@qfei-design/make-ai-assistant 0.2.16 → 0.3.1
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 +40 -0
- package/README.md +25 -11
- package/capabilities.json +27 -0
- package/dist/client-types.d.ts +1 -0
- package/dist/client.cjs +2 -2
- package/dist/client.mjs +46 -41
- package/dist/core/conversation-management.d.ts +1 -0
- package/dist/react/use-conversation-manager.d.ts +3 -0
- package/dist/react.cjs +6 -4
- package/dist/react.mjs +1339 -1311
- package/dist/styles.css +31 -14
- package/docs/make-app-integration.md +56 -1
- package/examples/make-app/README.md +21 -3
- package/package.ai.json +1 -1
- package/package.json +1 -1
package/dist/react.mjs
CHANGED
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { isValidElement as Oa, cloneElement as qa, useContext as
|
|
3
|
-
import { resolveArtifactTemplate as
|
|
1
|
+
import { jsxs as m, jsx as a, Fragment as Ne } from "react/jsx-runtime";
|
|
2
|
+
import { isValidElement as Oa, cloneElement as qa, useContext as Ba, createContext as Va, forwardRef as Yt, createElement as Nt, useRef as P, useState as R, useEffect as se, useLayoutEffect as At, useCallback as Ka, useId as Wa, useMemo as Ft } from "react";
|
|
3
|
+
import { resolveArtifactTemplate as Xa, createArtifactTemplateRegistry as Qt, createArtifactCapabilities as Ga } from "./index.mjs";
|
|
4
4
|
import { extendArtifactTemplateRegistry as En } from "./index.mjs";
|
|
5
|
-
import { a as
|
|
5
|
+
import { a as ye, r as Ie, p as ea, b as ta, c as lt, M as ue } from "./conversation-DuqMadaQ.js";
|
|
6
6
|
import { d as Sn, e as Rn, f as Ln, g as zn, v as xn } from "./conversation-DuqMadaQ.js";
|
|
7
|
-
import { i as
|
|
7
|
+
import { i as kt } from "./conversation-management-DZROhXyK.js";
|
|
8
8
|
import { createPortal as aa } from "react-dom";
|
|
9
|
-
const sa = (e) => e?.trim() || void 0,
|
|
9
|
+
const sa = (e) => e?.trim() || void 0, _e = (e, t) => sa(e) ?? t, Mt = (e) => {
|
|
10
10
|
const t = sa(e?.primary);
|
|
11
11
|
if (t)
|
|
12
12
|
return {
|
|
13
13
|
"--make-ai-theme-primary": t,
|
|
14
|
-
"--make-ai-theme-primary-hover":
|
|
14
|
+
"--make-ai-theme-primary-hover": _e(
|
|
15
15
|
e?.primaryHover,
|
|
16
16
|
"color-mix(in srgb, var(--make-ai-theme-primary) 84%, #15233d)"
|
|
17
17
|
),
|
|
18
|
-
"--make-ai-theme-on-primary":
|
|
18
|
+
"--make-ai-theme-on-primary": _e(
|
|
19
19
|
e?.onPrimary,
|
|
20
20
|
"#fcfcff"
|
|
21
21
|
),
|
|
22
|
-
"--make-ai-theme-bg":
|
|
22
|
+
"--make-ai-theme-bg": _e(
|
|
23
23
|
e?.background,
|
|
24
24
|
"color-mix(in srgb, var(--make-ai-theme-primary) 2%, #fcfcff)"
|
|
25
25
|
),
|
|
26
|
-
"--make-ai-theme-surface":
|
|
26
|
+
"--make-ai-theme-surface": _e(
|
|
27
27
|
e?.surface,
|
|
28
28
|
"color-mix(in srgb, var(--make-ai-theme-primary) 4%, var(--make-ai-theme-bg))"
|
|
29
29
|
),
|
|
30
|
-
"--make-ai-theme-surface-strong":
|
|
30
|
+
"--make-ai-theme-surface-strong": _e(
|
|
31
31
|
e?.surfaceStrong,
|
|
32
32
|
"color-mix(in srgb, var(--make-ai-theme-primary) 8%, var(--make-ai-theme-bg))"
|
|
33
33
|
),
|
|
34
|
-
"--make-ai-theme-text":
|
|
34
|
+
"--make-ai-theme-text": _e(
|
|
35
35
|
e?.text,
|
|
36
36
|
"color-mix(in srgb, var(--make-ai-theme-primary) 12%, #252631)"
|
|
37
37
|
),
|
|
38
|
-
"--make-ai-theme-text-secondary":
|
|
38
|
+
"--make-ai-theme-text-secondary": _e(
|
|
39
39
|
e?.textSecondary,
|
|
40
40
|
"color-mix(in srgb, var(--make-ai-theme-text) 74%, var(--make-ai-theme-primary))"
|
|
41
41
|
),
|
|
42
|
-
"--make-ai-theme-border":
|
|
42
|
+
"--make-ai-theme-border": _e(
|
|
43
43
|
e?.border,
|
|
44
44
|
"color-mix(in srgb, var(--make-ai-theme-primary) 14%, var(--make-ai-theme-bg))"
|
|
45
45
|
),
|
|
46
|
-
"--make-ai-theme-overlay":
|
|
46
|
+
"--make-ai-theme-overlay": _e(
|
|
47
47
|
e?.overlay,
|
|
48
48
|
"color-mix(in srgb, var(--make-ai-theme-text) 88%, var(--make-ai-theme-primary))"
|
|
49
49
|
),
|
|
50
|
-
"--make-ai-theme-on-overlay":
|
|
50
|
+
"--make-ai-theme-on-overlay": _e(
|
|
51
51
|
e?.onOverlay,
|
|
52
52
|
"#fcfcff"
|
|
53
53
|
)
|
|
@@ -55,36 +55,36 @@ const sa = (e) => e?.trim() || void 0, ke = (e, t) => sa(e) ?? t, Mt = (e) => {
|
|
|
55
55
|
}, Ht = (e, t) => !t || !Oa(e) || typeof e.type != "string" ? e : qa(e, {
|
|
56
56
|
style: { ...e.props.style, ...t }
|
|
57
57
|
});
|
|
58
|
-
function
|
|
58
|
+
function Za({
|
|
59
59
|
artifact: e,
|
|
60
60
|
context: t,
|
|
61
61
|
fallback: s,
|
|
62
62
|
onAction: n,
|
|
63
63
|
onActionError: i,
|
|
64
|
-
registry:
|
|
65
|
-
theme:
|
|
64
|
+
registry: o,
|
|
65
|
+
theme: d
|
|
66
66
|
}) {
|
|
67
|
-
const
|
|
68
|
-
if (!
|
|
69
|
-
const
|
|
67
|
+
const h = Mt(d), v = Xa(o, e, t);
|
|
68
|
+
if (!v) {
|
|
69
|
+
const N = s ? s(e) : /* @__PURE__ */ m("section", { className: "make-ai-artifact make-ai-artifact--unsupported", role: "status", children: [
|
|
70
70
|
/* @__PURE__ */ a("strong", { children: "暂不支持展示此结果" }),
|
|
71
|
-
/* @__PURE__ */
|
|
71
|
+
/* @__PURE__ */ m("span", { children: [
|
|
72
72
|
"结果类型:",
|
|
73
73
|
e.kind
|
|
74
74
|
] })
|
|
75
75
|
] });
|
|
76
|
-
return Ht(
|
|
76
|
+
return Ht(N, h);
|
|
77
77
|
}
|
|
78
|
-
const
|
|
78
|
+
const I = {
|
|
79
79
|
context: t,
|
|
80
80
|
onAction: n,
|
|
81
81
|
onActionError: i,
|
|
82
|
-
theme:
|
|
83
|
-
themeStyle:
|
|
84
|
-
},
|
|
85
|
-
return Ht(
|
|
82
|
+
theme: d,
|
|
83
|
+
themeStyle: h
|
|
84
|
+
}, f = v.template.render(e, t, I);
|
|
85
|
+
return Ht(f, h);
|
|
86
86
|
}
|
|
87
|
-
const
|
|
87
|
+
const xe = (e, t, s) => {
|
|
88
88
|
if (e == null || e === "") return "—";
|
|
89
89
|
if (typeof e == "boolean") return e ? "是" : "否";
|
|
90
90
|
if (typeof e != "number") return `${e}${t?.unit ?? ""}`;
|
|
@@ -94,8 +94,8 @@ const Le = (e, t, s) => {
|
|
|
94
94
|
};
|
|
95
95
|
t?.style === "currency" && t.currency ? (i.style = "currency", i.currency = t.currency) : t?.style === "percent" && (i.style = "percent");
|
|
96
96
|
try {
|
|
97
|
-
const
|
|
98
|
-
return `${new Intl.NumberFormat(s, i).format(
|
|
97
|
+
const o = t?.style === "percent" ? e / 100 : e;
|
|
98
|
+
return `${new Intl.NumberFormat(s, i).format(o)}${t?.unit ?? ""}`;
|
|
99
99
|
} catch {
|
|
100
100
|
return `${e}${t?.unit ?? ""}`;
|
|
101
101
|
}
|
|
@@ -106,37 +106,37 @@ const Le = (e, t, s) => {
|
|
|
106
106
|
return Number.isFinite(t) && Number.isFinite(s) ? { min: t, max: s } : { min: 0, max: 0 };
|
|
107
107
|
}, ia = (e, t, s) => {
|
|
108
108
|
if (!s.onAction) return;
|
|
109
|
-
const n = (
|
|
109
|
+
const n = (o) => {
|
|
110
110
|
console.error("[make-ai-assistant] host action error handler failed", {
|
|
111
111
|
actionId: e.id,
|
|
112
112
|
artifactId: t.artifact.id,
|
|
113
|
-
errorType:
|
|
113
|
+
errorType: o instanceof Error ? o.name : typeof o,
|
|
114
114
|
intent: e.intent
|
|
115
115
|
});
|
|
116
|
-
}, i = (
|
|
116
|
+
}, i = (o) => {
|
|
117
117
|
if (s.onActionError) {
|
|
118
118
|
try {
|
|
119
119
|
Promise.resolve(
|
|
120
|
-
s.onActionError(
|
|
120
|
+
s.onActionError(o, e, t)
|
|
121
121
|
).catch(n);
|
|
122
|
-
} catch (
|
|
123
|
-
n(
|
|
122
|
+
} catch (d) {
|
|
123
|
+
n(d);
|
|
124
124
|
}
|
|
125
125
|
return;
|
|
126
126
|
}
|
|
127
127
|
console.error("[make-ai-assistant] host action failed", {
|
|
128
128
|
actionId: e.id,
|
|
129
129
|
artifactId: t.artifact.id,
|
|
130
|
-
errorType:
|
|
130
|
+
errorType: o instanceof Error ? o.name : typeof o,
|
|
131
131
|
intent: e.intent
|
|
132
132
|
});
|
|
133
133
|
};
|
|
134
134
|
try {
|
|
135
135
|
Promise.resolve(s.onAction(e, t)).catch(i);
|
|
136
|
-
} catch (
|
|
137
|
-
i(
|
|
136
|
+
} catch (o) {
|
|
137
|
+
i(o);
|
|
138
138
|
}
|
|
139
|
-
},
|
|
139
|
+
}, Be = (e, t) => e.actions?.length && t.onAction ? /* @__PURE__ */ a("div", { className: "make-ai-artifact__actions", children: e.actions.map((s) => /* @__PURE__ */ m(
|
|
140
140
|
"button",
|
|
141
141
|
{
|
|
142
142
|
className: `make-ai-artifact__action make-ai-artifact__action--${s.appearance ?? "link"}`,
|
|
@@ -148,7 +148,7 @@ const Le = (e, t, s) => {
|
|
|
148
148
|
]
|
|
149
149
|
},
|
|
150
150
|
s.id
|
|
151
|
-
)) }) : null,
|
|
151
|
+
)) }) : null, Ve = (e, t, s = "", n) => /* @__PURE__ */ m(
|
|
152
152
|
"section",
|
|
153
153
|
{
|
|
154
154
|
"aria-label": e.title ?? `${e.kind} result`,
|
|
@@ -162,24 +162,24 @@ const Le = (e, t, s) => {
|
|
|
162
162
|
t
|
|
163
163
|
]
|
|
164
164
|
}
|
|
165
|
-
),
|
|
165
|
+
), Ja = ({
|
|
166
166
|
artifact: e,
|
|
167
167
|
renderContext: t
|
|
168
168
|
}) => {
|
|
169
|
-
const s = e.data.delta, n = s ?
|
|
169
|
+
const s = e.data.delta, n = s ? xe(
|
|
170
170
|
s.value,
|
|
171
171
|
s.format === "percent" ? { style: "percent" } : void 0,
|
|
172
172
|
t.context.locale
|
|
173
173
|
) : void 0;
|
|
174
|
-
return
|
|
174
|
+
return Ve(
|
|
175
175
|
e,
|
|
176
|
-
/* @__PURE__ */
|
|
177
|
-
/* @__PURE__ */ a("div", { className: "make-ai-artifact__metric-value", children:
|
|
176
|
+
/* @__PURE__ */ m(Ne, { children: [
|
|
177
|
+
/* @__PURE__ */ a("div", { className: "make-ai-artifact__metric-value", children: xe(
|
|
178
178
|
e.data.value,
|
|
179
179
|
e.data.format,
|
|
180
180
|
t.context.locale
|
|
181
181
|
) }),
|
|
182
|
-
s ? /* @__PURE__ */
|
|
182
|
+
s ? /* @__PURE__ */ m(
|
|
183
183
|
"div",
|
|
184
184
|
{
|
|
185
185
|
className: `make-ai-artifact__delta make-ai-artifact__delta--${s.direction ?? "flat"}`,
|
|
@@ -191,112 +191,112 @@ const Le = (e, t, s) => {
|
|
|
191
191
|
}
|
|
192
192
|
) : null,
|
|
193
193
|
e.data.context ? /* @__PURE__ */ a("p", { className: "make-ai-artifact__context", children: e.data.context }) : null,
|
|
194
|
-
|
|
194
|
+
Be(e, t)
|
|
195
195
|
] }),
|
|
196
196
|
"make-ai-artifact--metric",
|
|
197
197
|
t.themeStyle
|
|
198
198
|
);
|
|
199
|
-
},
|
|
199
|
+
}, Ya = ({
|
|
200
200
|
artifact: e,
|
|
201
201
|
renderContext: t
|
|
202
|
-
}) =>
|
|
202
|
+
}) => Ve(
|
|
203
203
|
e,
|
|
204
|
-
/* @__PURE__ */
|
|
205
|
-
/* @__PURE__ */ a("div", { className: "make-ai-artifact__comparison", children: e.data.items.map((s) => /* @__PURE__ */
|
|
204
|
+
/* @__PURE__ */ m(Ne, { children: [
|
|
205
|
+
/* @__PURE__ */ a("div", { className: "make-ai-artifact__comparison", children: e.data.items.map((s) => /* @__PURE__ */ m("div", { className: "make-ai-artifact__comparison-item", children: [
|
|
206
206
|
/* @__PURE__ */ a("span", { children: s.label }),
|
|
207
|
-
/* @__PURE__ */ a("strong", { children:
|
|
207
|
+
/* @__PURE__ */ a("strong", { children: xe(s.value, s.format, t.context.locale) }),
|
|
208
208
|
s.hint ? /* @__PURE__ */ a("small", { children: s.hint }) : null
|
|
209
209
|
] }, s.id)) }),
|
|
210
|
-
|
|
210
|
+
Be(e, t)
|
|
211
211
|
] }),
|
|
212
212
|
"make-ai-artifact--comparison",
|
|
213
213
|
t.themeStyle
|
|
214
|
-
),
|
|
214
|
+
), Qa = ({
|
|
215
215
|
artifact: e,
|
|
216
216
|
renderContext: t
|
|
217
217
|
}) => {
|
|
218
|
-
const s = e.data.series.flatMap((
|
|
219
|
-
return
|
|
218
|
+
const s = e.data.series.flatMap((d) => d.points.map((h) => h.y)), { max: n, min: i } = na(s), o = n - i || 1;
|
|
219
|
+
return Ve(
|
|
220
220
|
e,
|
|
221
|
-
/* @__PURE__ */
|
|
222
|
-
/* @__PURE__ */ a("div", { className: "make-ai-artifact__trend", children: e.data.series.map((
|
|
223
|
-
/* @__PURE__ */ a("div", { className: "make-ai-artifact__trend-label", children:
|
|
224
|
-
/* @__PURE__ */ a("div", { className: "make-ai-artifact__trend-bars", children:
|
|
225
|
-
const
|
|
226
|
-
return /* @__PURE__ */
|
|
221
|
+
/* @__PURE__ */ m(Ne, { children: [
|
|
222
|
+
/* @__PURE__ */ a("div", { className: "make-ai-artifact__trend", children: e.data.series.map((d) => /* @__PURE__ */ m("div", { className: "make-ai-artifact__trend-series", children: [
|
|
223
|
+
/* @__PURE__ */ a("div", { className: "make-ai-artifact__trend-label", children: d.label }),
|
|
224
|
+
/* @__PURE__ */ a("div", { className: "make-ai-artifact__trend-bars", children: d.points.map((h, v) => {
|
|
225
|
+
const I = 18 + (h.y - i) / o * 70;
|
|
226
|
+
return /* @__PURE__ */ m("div", { className: "make-ai-artifact__trend-point", children: [
|
|
227
227
|
/* @__PURE__ */ a(
|
|
228
228
|
"span",
|
|
229
229
|
{
|
|
230
|
-
"aria-label": `${
|
|
231
|
-
|
|
232
|
-
|
|
230
|
+
"aria-label": `${h.x}: ${xe(
|
|
231
|
+
h.y,
|
|
232
|
+
d.format,
|
|
233
233
|
t.context.locale
|
|
234
234
|
)}`,
|
|
235
235
|
className: "make-ai-artifact__trend-bar",
|
|
236
236
|
role: "img",
|
|
237
|
-
style: { height: `${
|
|
238
|
-
title: `${
|
|
239
|
-
|
|
240
|
-
|
|
237
|
+
style: { height: `${I}%` },
|
|
238
|
+
title: `${h.x}: ${xe(
|
|
239
|
+
h.y,
|
|
240
|
+
d.format,
|
|
241
241
|
t.context.locale
|
|
242
242
|
)}`
|
|
243
243
|
}
|
|
244
244
|
),
|
|
245
|
-
/* @__PURE__ */ a("small", { children:
|
|
246
|
-
] }, `${
|
|
245
|
+
/* @__PURE__ */ a("small", { children: h.x })
|
|
246
|
+
] }, `${h.x}-${v}`);
|
|
247
247
|
}) })
|
|
248
|
-
] },
|
|
249
|
-
|
|
248
|
+
] }, d.id)) }),
|
|
249
|
+
Be(e, t)
|
|
250
250
|
] }),
|
|
251
251
|
"make-ai-artifact--trend",
|
|
252
252
|
t.themeStyle
|
|
253
253
|
);
|
|
254
|
-
},
|
|
254
|
+
}, es = ({
|
|
255
255
|
artifact: e,
|
|
256
256
|
renderContext: t
|
|
257
257
|
}) => {
|
|
258
258
|
const { max: s } = na(
|
|
259
259
|
e.data.items.map((i) => Math.abs(i.value))
|
|
260
260
|
), n = Math.max(s, 1);
|
|
261
|
-
return
|
|
261
|
+
return Ve(
|
|
262
262
|
e,
|
|
263
|
-
/* @__PURE__ */
|
|
264
|
-
/* @__PURE__ */ a("ol", { className: "make-ai-artifact__ranking", children: e.data.items.map((i,
|
|
265
|
-
/* @__PURE__ */ a("span", { className: "make-ai-artifact__rank", children:
|
|
266
|
-
/* @__PURE__ */
|
|
263
|
+
/* @__PURE__ */ m(Ne, { children: [
|
|
264
|
+
/* @__PURE__ */ a("ol", { className: "make-ai-artifact__ranking", children: e.data.items.map((i, o) => /* @__PURE__ */ m("li", { children: [
|
|
265
|
+
/* @__PURE__ */ a("span", { className: "make-ai-artifact__rank", children: o + 1 }),
|
|
266
|
+
/* @__PURE__ */ m("span", { className: "make-ai-artifact__ranking-label", children: [
|
|
267
267
|
/* @__PURE__ */ a("span", { children: i.label }),
|
|
268
268
|
i.description ? /* @__PURE__ */ a("small", { children: i.description }) : null
|
|
269
269
|
] }),
|
|
270
270
|
/* @__PURE__ */ a("span", { className: "make-ai-artifact__ranking-track", "aria-hidden": "true", children: /* @__PURE__ */ a("span", { style: { width: `${Math.abs(i.value) / n * 100}%` } }) }),
|
|
271
|
-
/* @__PURE__ */ a("strong", { children:
|
|
271
|
+
/* @__PURE__ */ a("strong", { children: xe(i.value, i.format, t.context.locale) })
|
|
272
272
|
] }, i.id)) }),
|
|
273
|
-
|
|
273
|
+
Be(e, t)
|
|
274
274
|
] }),
|
|
275
275
|
"make-ai-artifact--ranking",
|
|
276
276
|
t.themeStyle
|
|
277
277
|
);
|
|
278
|
-
},
|
|
278
|
+
}, ts = (e, t) => t.action ?? {
|
|
279
279
|
id: `open-${t.id}`,
|
|
280
280
|
label: t.title ?? t.id,
|
|
281
281
|
intent: "open-record",
|
|
282
282
|
target: { entityKey: e.data.entity.key, recordId: t.id }
|
|
283
|
-
},
|
|
283
|
+
}, as = ({
|
|
284
284
|
artifact: e,
|
|
285
285
|
renderContext: t
|
|
286
|
-
}) =>
|
|
286
|
+
}) => Ve(
|
|
287
287
|
e,
|
|
288
|
-
/* @__PURE__ */
|
|
288
|
+
/* @__PURE__ */ m(Ne, { children: [
|
|
289
289
|
/* @__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) => {
|
|
290
|
-
const n =
|
|
290
|
+
const n = ts(e, s), i = /* @__PURE__ */ m(Ne, { children: [
|
|
291
291
|
/* @__PURE__ */ a("strong", { children: s.title ?? s.id }),
|
|
292
|
-
/* @__PURE__ */ a("span", { className: "make-ai-artifact__record-values", children: e.data.columns.map((
|
|
293
|
-
/* @__PURE__ */ a("small", { children:
|
|
294
|
-
|
|
295
|
-
s.values[
|
|
296
|
-
|
|
292
|
+
/* @__PURE__ */ a("span", { className: "make-ai-artifact__record-values", children: e.data.columns.map((o) => /* @__PURE__ */ m("span", { children: [
|
|
293
|
+
/* @__PURE__ */ a("small", { children: o.label }),
|
|
294
|
+
xe(
|
|
295
|
+
s.values[o.key],
|
|
296
|
+
o.format,
|
|
297
297
|
t.context.locale
|
|
298
298
|
)
|
|
299
|
-
] },
|
|
299
|
+
] }, o.key)) }),
|
|
300
300
|
t.onAction ? /* @__PURE__ */ a("span", { "aria-hidden": "true", children: "›" }) : null
|
|
301
301
|
] });
|
|
302
302
|
return t.onAction ? /* @__PURE__ */ a(
|
|
@@ -313,49 +313,49 @@ const Le = (e, t, s) => {
|
|
|
313
313
|
s.id
|
|
314
314
|
) : /* @__PURE__ */ a("div", { className: "make-ai-artifact__record", children: i }, s.id);
|
|
315
315
|
}) }),
|
|
316
|
-
e.data.total !== void 0 ? /* @__PURE__ */
|
|
316
|
+
e.data.total !== void 0 ? /* @__PURE__ */ m("p", { className: "make-ai-artifact__record-total", children: [
|
|
317
317
|
"共 ",
|
|
318
318
|
e.data.total,
|
|
319
319
|
" 条"
|
|
320
320
|
] }) : null,
|
|
321
|
-
|
|
321
|
+
Be(e, t)
|
|
322
322
|
] }),
|
|
323
323
|
"make-ai-artifact--record-list",
|
|
324
324
|
t.themeStyle
|
|
325
|
-
),
|
|
325
|
+
), ss = ({
|
|
326
326
|
artifact: e,
|
|
327
327
|
renderContext: t
|
|
328
|
-
}) =>
|
|
328
|
+
}) => Ve(
|
|
329
329
|
e,
|
|
330
|
-
/* @__PURE__ */
|
|
331
|
-
/* @__PURE__ */
|
|
330
|
+
/* @__PURE__ */ m(Ne, { children: [
|
|
331
|
+
/* @__PURE__ */ m("div", { className: `make-ai-artifact__notice make-ai-artifact__notice--${e.data.tone}`, children: [
|
|
332
332
|
/* @__PURE__ */ a("span", { "aria-hidden": "true", children: e.data.tone === "success" ? "✓" : e.data.tone === "warning" ? "!" : e.data.tone === "danger" ? "×" : "i" }),
|
|
333
333
|
/* @__PURE__ */ a("p", { children: e.data.body })
|
|
334
334
|
] }),
|
|
335
|
-
|
|
335
|
+
Be(e, t)
|
|
336
336
|
] }),
|
|
337
337
|
"make-ai-artifact--notice",
|
|
338
338
|
t.themeStyle
|
|
339
|
-
),
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
],
|
|
347
|
-
const
|
|
348
|
-
function
|
|
339
|
+
), Oe = (e, t, s) => ({ id: e, kinds: [t], priority: 0, render: s }), ns = [
|
|
340
|
+
Oe("platform.metric.default", "metric", (e, t, s) => /* @__PURE__ */ a(Ja, { artifact: e, renderContext: s })),
|
|
341
|
+
Oe("platform.comparison.default", "comparison", (e, t, s) => /* @__PURE__ */ a(Ya, { artifact: e, renderContext: s })),
|
|
342
|
+
Oe("platform.trend.default", "trend", (e, t, s) => /* @__PURE__ */ a(Qa, { artifact: e, renderContext: s })),
|
|
343
|
+
Oe("platform.ranking.default", "ranking", (e, t, s) => /* @__PURE__ */ a(es, { artifact: e, renderContext: s })),
|
|
344
|
+
Oe("platform.record-list.default", "record-list", (e, t, s) => /* @__PURE__ */ a(as, { artifact: e, renderContext: s })),
|
|
345
|
+
Oe("platform.notice.default", "notice", (e, t, s) => /* @__PURE__ */ a(ss, { artifact: e, renderContext: s }))
|
|
346
|
+
], is = Qt(ns).templates, rs = (e = is) => Qt(e);
|
|
347
|
+
const os = (e) => e?.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
|
|
348
|
+
function cs(e, t, s = []) {
|
|
349
349
|
if (t == null)
|
|
350
350
|
throw new Error("[lucide]: iconNode is required when icon name is used");
|
|
351
351
|
return {
|
|
352
|
-
name:
|
|
352
|
+
name: os(e),
|
|
353
353
|
size: 24,
|
|
354
354
|
node: t,
|
|
355
355
|
...s.length > 0 ? { aliases: s } : {}
|
|
356
356
|
};
|
|
357
357
|
}
|
|
358
|
-
const
|
|
358
|
+
const ls = (e) => {
|
|
359
359
|
let t = "", s = !1;
|
|
360
360
|
for (const n of e) {
|
|
361
361
|
if (n === "-" || n === "_" || n <= " ") {
|
|
@@ -366,12 +366,12 @@ const cs = (e) => {
|
|
|
366
366
|
}
|
|
367
367
|
return t;
|
|
368
368
|
};
|
|
369
|
-
const
|
|
370
|
-
const t =
|
|
369
|
+
const ds = (e) => {
|
|
370
|
+
const t = ls(e);
|
|
371
371
|
return t.charAt(0).toUpperCase() + t.slice(1);
|
|
372
372
|
};
|
|
373
373
|
const Ct = (...e) => e.filter((t, s, n) => !!t && t.trim() !== "" && n.indexOf(t) === s).join(" ").trim();
|
|
374
|
-
const
|
|
374
|
+
const ze = {
|
|
375
375
|
xmlns: "http://www.w3.org/2000/svg",
|
|
376
376
|
width: 24,
|
|
377
377
|
height: 24,
|
|
@@ -385,12 +385,12 @@ const Re = {
|
|
|
385
385
|
function bt(e) {
|
|
386
386
|
return e != null;
|
|
387
387
|
}
|
|
388
|
-
function
|
|
389
|
-
const s = t.attributeNames ?? {}, n = (C) => s[C] ?? C, i = e.size ?? e.width ??
|
|
388
|
+
function us(e, t = {}) {
|
|
389
|
+
const s = t.attributeNames ?? {}, n = (C) => s[C] ?? C, i = e.size ?? e.width ?? ze.width, o = e.size ?? e.height ?? ze.height, d = e.aliases?.filter((C) => typeof C == "string" && C.trim() !== "").map((C) => `lucide-${C}`) ?? [], h = [...e.name ? [`lucide-${e.name}`] : [], ...d], v = t.className?.split(" ").filter(Boolean) ?? [], I = t.includeDefaultClasses === !1 ? Ct(...v) : Ct("lucide", ...h, ...v), f = t.absoluteStrokeWidth ? Number(t.strokeWidth ?? ze["stroke-width"]) * Number(e.size ?? e.width ?? ze.width) / Number(t.size ?? t.width ?? ze.width) : t.strokeWidth ?? ze["stroke-width"];
|
|
390
390
|
return [
|
|
391
391
|
"svg",
|
|
392
392
|
{
|
|
393
|
-
...Object.entries(
|
|
393
|
+
...Object.entries(ze).reduce((C, [A, g]) => (C[n(A)] = g, C), {}),
|
|
394
394
|
..."color" in t && t.color && {
|
|
395
395
|
[n("stroke")]: t.color
|
|
396
396
|
},
|
|
@@ -404,24 +404,24 @@ function ds(e, t = {}) {
|
|
|
404
404
|
..."height" in t && bt(t.height) && {
|
|
405
405
|
[n("height")]: t.height
|
|
406
406
|
},
|
|
407
|
-
[n("stroke-width")]:
|
|
408
|
-
...
|
|
409
|
-
[n("class")]:
|
|
407
|
+
[n("stroke-width")]: f,
|
|
408
|
+
...I && {
|
|
409
|
+
[n("class")]: I
|
|
410
410
|
},
|
|
411
|
-
[n("viewBox")]: `0 0 ${i} ${
|
|
411
|
+
[n("viewBox")]: `0 0 ${i} ${o}`,
|
|
412
412
|
...t.hasA11yProp === !1 ? {
|
|
413
413
|
[n("aria-hidden")]: "true"
|
|
414
414
|
} : {},
|
|
415
415
|
..."attributes" in t && t.attributes
|
|
416
416
|
},
|
|
417
417
|
e.node.map((C) => {
|
|
418
|
-
const [
|
|
419
|
-
return
|
|
418
|
+
const [A, g, F] = C, T = t.nonScalingStroke ? { [n("vector-effect")]: "non-scaling-stroke", ...g } : g;
|
|
419
|
+
return F ? [A, T, F] : [A, T];
|
|
420
420
|
})
|
|
421
421
|
];
|
|
422
422
|
}
|
|
423
|
-
function
|
|
424
|
-
return
|
|
423
|
+
function ms(e, t = {}) {
|
|
424
|
+
return us(e, {
|
|
425
425
|
...t,
|
|
426
426
|
attributeNames: {
|
|
427
427
|
...t.attributeNames,
|
|
@@ -433,71 +433,71 @@ function us(e, t = {}) {
|
|
|
433
433
|
}
|
|
434
434
|
});
|
|
435
435
|
}
|
|
436
|
-
const
|
|
436
|
+
const hs = (e) => {
|
|
437
437
|
for (const t in e)
|
|
438
438
|
if (t.startsWith("aria-") || t === "role" || t === "title")
|
|
439
439
|
return !0;
|
|
440
440
|
return !1;
|
|
441
|
-
},
|
|
441
|
+
}, fs = Va({}), ps = () => Ba(fs), vs = Yt(
|
|
442
442
|
({
|
|
443
443
|
color: e,
|
|
444
444
|
size: t,
|
|
445
445
|
width: s,
|
|
446
446
|
height: n,
|
|
447
447
|
strokeWidth: i,
|
|
448
|
-
absoluteStrokeWidth:
|
|
449
|
-
nonScalingStroke:
|
|
450
|
-
className:
|
|
451
|
-
children:
|
|
452
|
-
iconNode:
|
|
453
|
-
icon:
|
|
454
|
-
node:
|
|
448
|
+
absoluteStrokeWidth: o,
|
|
449
|
+
nonScalingStroke: d,
|
|
450
|
+
className: h = "",
|
|
451
|
+
children: v,
|
|
452
|
+
iconNode: I = [],
|
|
453
|
+
icon: f = {
|
|
454
|
+
node: I,
|
|
455
455
|
aliases: [],
|
|
456
456
|
size: 24
|
|
457
457
|
},
|
|
458
|
-
...
|
|
458
|
+
...N
|
|
459
459
|
}, C) => {
|
|
460
460
|
const {
|
|
461
|
-
size:
|
|
462
|
-
strokeWidth:
|
|
463
|
-
absoluteStrokeWidth:
|
|
464
|
-
nonScalingStroke:
|
|
461
|
+
size: A = 24,
|
|
462
|
+
strokeWidth: g = 2,
|
|
463
|
+
absoluteStrokeWidth: F = !1,
|
|
464
|
+
nonScalingStroke: T = !1,
|
|
465
465
|
color: H = "currentColor",
|
|
466
|
-
className:
|
|
467
|
-
} = ps() ?? {},
|
|
466
|
+
className: b = ""
|
|
467
|
+
} = ps() ?? {}, l = !!v || hs(N), [c, k, E = []] = ms(f, {
|
|
468
468
|
color: e ?? H,
|
|
469
|
-
width: s ?? t ??
|
|
470
|
-
height: n ?? t ??
|
|
471
|
-
strokeWidth: i ??
|
|
472
|
-
absoluteStrokeWidth:
|
|
473
|
-
nonScalingStroke:
|
|
474
|
-
className: Ct(
|
|
475
|
-
hasA11yProp:
|
|
476
|
-
attributes:
|
|
469
|
+
width: s ?? t ?? A,
|
|
470
|
+
height: n ?? t ?? A,
|
|
471
|
+
strokeWidth: i ?? g,
|
|
472
|
+
absoluteStrokeWidth: o ?? F,
|
|
473
|
+
nonScalingStroke: d ?? T,
|
|
474
|
+
className: Ct(b, h),
|
|
475
|
+
hasA11yProp: l,
|
|
476
|
+
attributes: N
|
|
477
477
|
});
|
|
478
478
|
return Nt(
|
|
479
|
-
|
|
479
|
+
c,
|
|
480
480
|
{
|
|
481
481
|
ref: C,
|
|
482
|
-
...
|
|
482
|
+
...k
|
|
483
483
|
},
|
|
484
484
|
[
|
|
485
|
-
...
|
|
486
|
-
...Array.isArray(
|
|
485
|
+
...E.map(([W, M]) => Nt(W, M)),
|
|
486
|
+
...Array.isArray(v) ? v : [v]
|
|
487
487
|
]
|
|
488
488
|
);
|
|
489
489
|
}
|
|
490
490
|
);
|
|
491
|
-
function
|
|
492
|
-
const n = typeof e == "string" ?
|
|
493
|
-
({ className:
|
|
494
|
-
ref:
|
|
491
|
+
function B(e, t = [], s = []) {
|
|
492
|
+
const n = typeof e == "string" ? cs(e, t, s) : e, i = Yt(
|
|
493
|
+
({ className: o, ...d }, h) => Nt(vs, {
|
|
494
|
+
ref: h,
|
|
495
495
|
icon: n,
|
|
496
|
-
className:
|
|
497
|
-
...
|
|
496
|
+
className: o,
|
|
497
|
+
...d
|
|
498
498
|
})
|
|
499
499
|
);
|
|
500
|
-
return n.name && (i.displayName =
|
|
500
|
+
return n.name && (i.displayName = ds(n.name)), i;
|
|
501
501
|
}
|
|
502
502
|
const ra = {
|
|
503
503
|
name: "arrow-down-to-line",
|
|
@@ -509,28 +509,28 @@ const ra = {
|
|
|
509
509
|
]
|
|
510
510
|
};
|
|
511
511
|
ra.node;
|
|
512
|
-
const
|
|
512
|
+
const ys = B(ra);
|
|
513
513
|
const oa = {
|
|
514
514
|
name: "check",
|
|
515
515
|
size: 24,
|
|
516
516
|
node: [["path", { d: "M20 6 9 17l-5-5", key: "1gmf2c" }]]
|
|
517
517
|
};
|
|
518
518
|
oa.node;
|
|
519
|
-
const
|
|
519
|
+
const gs = B(oa);
|
|
520
520
|
const ca = {
|
|
521
521
|
name: "chevron-down",
|
|
522
522
|
size: 24,
|
|
523
523
|
node: [["path", { d: "m6 9 6 6 6-6", key: "qrunsl" }]]
|
|
524
524
|
};
|
|
525
525
|
ca.node;
|
|
526
|
-
const ks =
|
|
526
|
+
const ks = B(ca);
|
|
527
527
|
const la = {
|
|
528
528
|
name: "chevron-up",
|
|
529
529
|
size: 24,
|
|
530
530
|
node: [["path", { d: "m18 15-6-6-6 6", key: "153udz" }]]
|
|
531
531
|
};
|
|
532
532
|
la.node;
|
|
533
|
-
const
|
|
533
|
+
const bs = B(la);
|
|
534
534
|
const da = {
|
|
535
535
|
name: "circle-alert",
|
|
536
536
|
size: 24,
|
|
@@ -542,8 +542,8 @@ const da = {
|
|
|
542
542
|
aliases: ["alert-circle"]
|
|
543
543
|
};
|
|
544
544
|
da.node;
|
|
545
|
-
const
|
|
546
|
-
const
|
|
545
|
+
const ua = B(da);
|
|
546
|
+
const ma = {
|
|
547
547
|
name: "cloud-off",
|
|
548
548
|
size: 24,
|
|
549
549
|
node: [
|
|
@@ -555,9 +555,9 @@ const ua = {
|
|
|
555
555
|
["path", { d: "m2 2 20 20", key: "1ooewy" }]
|
|
556
556
|
]
|
|
557
557
|
};
|
|
558
|
-
|
|
559
|
-
const _s =
|
|
560
|
-
const
|
|
558
|
+
ma.node;
|
|
559
|
+
const _s = B(ma);
|
|
560
|
+
const ha = {
|
|
561
561
|
name: "copy",
|
|
562
562
|
size: 24,
|
|
563
563
|
node: [
|
|
@@ -565,9 +565,9 @@ const ma = {
|
|
|
565
565
|
["path", { d: "M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2", key: "zix9uf" }]
|
|
566
566
|
]
|
|
567
567
|
};
|
|
568
|
-
|
|
569
|
-
const ws =
|
|
570
|
-
const
|
|
568
|
+
ha.node;
|
|
569
|
+
const ws = B(ha);
|
|
570
|
+
const fa = {
|
|
571
571
|
name: "file-text",
|
|
572
572
|
size: 24,
|
|
573
573
|
node: [
|
|
@@ -584,8 +584,8 @@ const ha = {
|
|
|
584
584
|
["path", { d: "M16 17H8", key: "z1uh3a" }]
|
|
585
585
|
]
|
|
586
586
|
};
|
|
587
|
-
|
|
588
|
-
const
|
|
587
|
+
fa.node;
|
|
588
|
+
const jt = B(fa);
|
|
589
589
|
const pa = {
|
|
590
590
|
name: "list",
|
|
591
591
|
size: 24,
|
|
@@ -599,8 +599,8 @@ const pa = {
|
|
|
599
599
|
]
|
|
600
600
|
};
|
|
601
601
|
pa.node;
|
|
602
|
-
const Is =
|
|
603
|
-
const
|
|
602
|
+
const Is = B(pa);
|
|
603
|
+
const va = {
|
|
604
604
|
name: "maximize",
|
|
605
605
|
size: 24,
|
|
606
606
|
node: [
|
|
@@ -610,9 +610,9 @@ const fa = {
|
|
|
610
610
|
["path", { d: "M16 21h3a2 2 0 0 0 2-2v-3", key: "18trek" }]
|
|
611
611
|
]
|
|
612
612
|
};
|
|
613
|
-
|
|
614
|
-
const Ns =
|
|
615
|
-
const
|
|
613
|
+
va.node;
|
|
614
|
+
const Ns = B(va);
|
|
615
|
+
const ya = {
|
|
616
616
|
name: "message-square-text",
|
|
617
617
|
size: 24,
|
|
618
618
|
node: [
|
|
@@ -628,9 +628,9 @@ const va = {
|
|
|
628
628
|
["path", { d: "M7 7h8", key: "af5zfr" }]
|
|
629
629
|
]
|
|
630
630
|
};
|
|
631
|
-
|
|
632
|
-
const As =
|
|
633
|
-
const
|
|
631
|
+
ya.node;
|
|
632
|
+
const As = B(ya);
|
|
633
|
+
const ga = {
|
|
634
634
|
name: "minimize",
|
|
635
635
|
size: 24,
|
|
636
636
|
node: [
|
|
@@ -640,8 +640,8 @@ const ya = {
|
|
|
640
640
|
["path", { d: "M16 21v-3a2 2 0 0 1 2-2h3", key: "ph8mxp" }]
|
|
641
641
|
]
|
|
642
642
|
};
|
|
643
|
-
|
|
644
|
-
const Cs =
|
|
643
|
+
ga.node;
|
|
644
|
+
const Cs = B(ga);
|
|
645
645
|
const ka = {
|
|
646
646
|
name: "pause",
|
|
647
647
|
size: 24,
|
|
@@ -651,8 +651,8 @@ const ka = {
|
|
|
651
651
|
]
|
|
652
652
|
};
|
|
653
653
|
ka.node;
|
|
654
|
-
const Ms =
|
|
655
|
-
const
|
|
654
|
+
const Ms = B(ka);
|
|
655
|
+
const ba = {
|
|
656
656
|
name: "pencil",
|
|
657
657
|
size: 24,
|
|
658
658
|
node: [
|
|
@@ -666,9 +666,9 @@ const ga = {
|
|
|
666
666
|
["path", { d: "m15 5 4 4", key: "1mk7zo" }]
|
|
667
667
|
]
|
|
668
668
|
};
|
|
669
|
-
|
|
670
|
-
const Ts =
|
|
671
|
-
const
|
|
669
|
+
ba.node;
|
|
670
|
+
const Ts = B(ba);
|
|
671
|
+
const _a = {
|
|
672
672
|
name: "pin",
|
|
673
673
|
size: 24,
|
|
674
674
|
node: [
|
|
@@ -682,9 +682,9 @@ const ba = {
|
|
|
682
682
|
]
|
|
683
683
|
]
|
|
684
684
|
};
|
|
685
|
-
|
|
686
|
-
const Es =
|
|
687
|
-
const
|
|
685
|
+
_a.node;
|
|
686
|
+
const Es = B(_a);
|
|
687
|
+
const wa = {
|
|
688
688
|
name: "plus",
|
|
689
689
|
size: 24,
|
|
690
690
|
node: [
|
|
@@ -692,9 +692,9 @@ const _a = {
|
|
|
692
692
|
["path", { d: "M12 5v14", key: "s699le" }]
|
|
693
693
|
]
|
|
694
694
|
};
|
|
695
|
-
|
|
696
|
-
const Tt =
|
|
697
|
-
const
|
|
695
|
+
wa.node;
|
|
696
|
+
const Tt = B(wa);
|
|
697
|
+
const Ia = {
|
|
698
698
|
name: "refresh-cw",
|
|
699
699
|
size: 24,
|
|
700
700
|
node: [
|
|
@@ -704,9 +704,9 @@ const wa = {
|
|
|
704
704
|
["path", { d: "M8 16H3v5", key: "1cv678" }]
|
|
705
705
|
]
|
|
706
706
|
};
|
|
707
|
-
|
|
708
|
-
const
|
|
709
|
-
const
|
|
707
|
+
Ia.node;
|
|
708
|
+
const mt = B(Ia);
|
|
709
|
+
const Na = {
|
|
710
710
|
name: "rotate-ccw",
|
|
711
711
|
size: 24,
|
|
712
712
|
node: [
|
|
@@ -714,9 +714,9 @@ const Ia = {
|
|
|
714
714
|
["path", { d: "M3 3v5h5", key: "1xhq8a" }]
|
|
715
715
|
]
|
|
716
716
|
};
|
|
717
|
-
|
|
718
|
-
const $s =
|
|
719
|
-
const
|
|
717
|
+
Na.node;
|
|
718
|
+
const $s = B(Na);
|
|
719
|
+
const Aa = {
|
|
720
720
|
name: "send",
|
|
721
721
|
size: 24,
|
|
722
722
|
node: [
|
|
@@ -730,9 +730,9 @@ const Na = {
|
|
|
730
730
|
["path", { d: "m21.854 2.147-10.94 10.939", key: "12cjpa" }]
|
|
731
731
|
]
|
|
732
732
|
};
|
|
733
|
-
|
|
734
|
-
const
|
|
735
|
-
const
|
|
733
|
+
Aa.node;
|
|
734
|
+
const Ot = B(Aa);
|
|
735
|
+
const Ca = {
|
|
736
736
|
name: "sparkles",
|
|
737
737
|
size: 24,
|
|
738
738
|
node: [
|
|
@@ -749,9 +749,9 @@ const Aa = {
|
|
|
749
749
|
],
|
|
750
750
|
aliases: ["stars"]
|
|
751
751
|
};
|
|
752
|
-
|
|
753
|
-
const
|
|
754
|
-
const
|
|
752
|
+
Ca.node;
|
|
753
|
+
const Ma = B(Ca);
|
|
754
|
+
const Ta = {
|
|
755
755
|
name: "thumbs-down",
|
|
756
756
|
size: 24,
|
|
757
757
|
node: [
|
|
@@ -765,9 +765,9 @@ const Ma = {
|
|
|
765
765
|
["path", { d: "M17 14V2", key: "8ymqnk" }]
|
|
766
766
|
]
|
|
767
767
|
};
|
|
768
|
-
|
|
769
|
-
const Ss =
|
|
770
|
-
const
|
|
768
|
+
Ta.node;
|
|
769
|
+
const Ss = B(Ta);
|
|
770
|
+
const Ea = {
|
|
771
771
|
name: "thumbs-up",
|
|
772
772
|
size: 24,
|
|
773
773
|
node: [
|
|
@@ -781,9 +781,9 @@ const Ta = {
|
|
|
781
781
|
["path", { d: "M7 10v12", key: "1qc93n" }]
|
|
782
782
|
]
|
|
783
783
|
};
|
|
784
|
-
|
|
785
|
-
const Rs =
|
|
786
|
-
const
|
|
784
|
+
Ea.node;
|
|
785
|
+
const Rs = B(Ea);
|
|
786
|
+
const $a = {
|
|
787
787
|
name: "trash",
|
|
788
788
|
size: 24,
|
|
789
789
|
node: [
|
|
@@ -795,9 +795,9 @@ const Ea = {
|
|
|
795
795
|
],
|
|
796
796
|
aliases: ["trash-2"]
|
|
797
797
|
};
|
|
798
|
-
|
|
799
|
-
const
|
|
800
|
-
const
|
|
798
|
+
$a.node;
|
|
799
|
+
const qt = B($a);
|
|
800
|
+
const Sa = {
|
|
801
801
|
name: "triangle-alert",
|
|
802
802
|
size: 24,
|
|
803
803
|
node: [
|
|
@@ -813,9 +813,9 @@ const $a = {
|
|
|
813
813
|
],
|
|
814
814
|
aliases: ["alert-triangle"]
|
|
815
815
|
};
|
|
816
|
-
|
|
817
|
-
const Ls =
|
|
818
|
-
const
|
|
816
|
+
Sa.node;
|
|
817
|
+
const Ls = B(Sa);
|
|
818
|
+
const Ra = {
|
|
819
819
|
name: "upload",
|
|
820
820
|
size: 24,
|
|
821
821
|
node: [
|
|
@@ -824,9 +824,9 @@ const Sa = {
|
|
|
824
824
|
["path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4", key: "ih7n3h" }]
|
|
825
825
|
]
|
|
826
826
|
};
|
|
827
|
-
|
|
828
|
-
const zs =
|
|
829
|
-
const
|
|
827
|
+
Ra.node;
|
|
828
|
+
const zs = B(Ra);
|
|
829
|
+
const La = {
|
|
830
830
|
name: "x",
|
|
831
831
|
size: 24,
|
|
832
832
|
node: [
|
|
@@ -834,237 +834,239 @@ const Ra = {
|
|
|
834
834
|
["path", { d: "m6 6 12 12", key: "d8bk6v" }]
|
|
835
835
|
]
|
|
836
836
|
};
|
|
837
|
-
|
|
838
|
-
const tt =
|
|
837
|
+
La.node;
|
|
838
|
+
const tt = B(La), qe = () => globalThis.crypto.randomUUID(), Bt = 1e3, _t = (e, t) => e?.chatId === t.chatId && e.revision > t.revision ? e : t, Et = (e) => {
|
|
839
839
|
const t = e, s = t?.status ?? t?.response?.status;
|
|
840
840
|
return s === 410 || t?.code === "AI_UPLOAD_EXPIRED" ? "上传已过期,请移除后重新选择文件" : s === 409 ? "数据已变化或对话仍在运行,请刷新后重试" : s === 401 || t?.code === "AI_AUTH_REQUIRED" || t?.code === "AI_AUTH_EXPIRED" ? "登录已失效,请重新登录" : s === 403 ? "当前账号无权访问该对话" : s === 404 ? "对话或回答已不可见,请刷新列表" : t?.message?.startsWith("输入内容过长") ? t.message : "操作未完成,请重试或刷新对话";
|
|
841
841
|
};
|
|
842
842
|
function xs(e, t) {
|
|
843
|
-
const s = t.features?.conversationManagement === !0, n = s ? t.scopeKey?.(e) ?? e.app.id : "",
|
|
844
|
-
|
|
845
|
-
const
|
|
846
|
-
const
|
|
847
|
-
|
|
848
|
-
}, [
|
|
849
|
-
const
|
|
850
|
-
return
|
|
851
|
-
},
|
|
852
|
-
const
|
|
853
|
-
|
|
854
|
-
},
|
|
855
|
-
|
|
856
|
-
(
|
|
857
|
-
(
|
|
843
|
+
const s = t.features?.conversationManagement === !0, n = s ? ["listConversations", "createConversation", "getConversation", "loadConversation"].filter((r) => typeof t[r] != "function") : [], i = n.length ? `会话管理配置不完整:缺少 ${n.join("、")}` : void 0, o = s && !i, d = o && t.features?.conversationEditing !== !1 && typeof t.updateConversation == "function", h = o && t.features?.conversationEditing !== !1 && typeof t.deleteConversation == "function", v = s ? t.scopeKey?.(e) ?? e.app.id : "", I = P(v);
|
|
844
|
+
I.current = v;
|
|
845
|
+
const f = P(v), [N, C] = R(ye), A = P(N), g = (r) => {
|
|
846
|
+
const u = typeof r == "function" ? r(A.current) : r;
|
|
847
|
+
A.current = u, C(u);
|
|
848
|
+
}, [F, T] = R([]), [H, b] = R(), l = P(void 0), [c, k] = R(""), [E, W] = R(void 0), [M, X] = R(!1), [me, ee] = R(!1), [he, ne] = R(o), [Ae, ce] = R(!1), [ht, U] = R(), [fe, le] = R([]), [Ee, ge] = R([]), De = P(/* @__PURE__ */ new Set()), G = P(/* @__PURE__ */ new Map()), K = P(0), te = P(0), $e = P(0), de = P(void 0), oe = P(void 0), Se = P(/* @__PURE__ */ new Map()), L = (r, u = v) => te.current === r && I.current === u, ae = () => {
|
|
849
|
+
const r = new AbortController();
|
|
850
|
+
return De.current.add(r), r;
|
|
851
|
+
}, Z = (r) => De.current.delete(r), Q = (r) => {
|
|
852
|
+
const u = r ? _t(l.current, r) : void 0;
|
|
853
|
+
l.current = u, b(u);
|
|
854
|
+
}, ke = (r) => {
|
|
855
|
+
T(
|
|
856
|
+
(u) => u.map(
|
|
857
|
+
(y) => y.chatId === r.chatId ? _t(y, r) : y
|
|
858
858
|
)
|
|
859
859
|
);
|
|
860
|
-
},
|
|
861
|
-
|
|
862
|
-
},
|
|
863
|
-
|
|
864
|
-
},
|
|
865
|
-
for (const
|
|
866
|
-
|
|
867
|
-
},
|
|
868
|
-
|
|
869
|
-
errorType:
|
|
870
|
-
}),
|
|
871
|
-
},
|
|
872
|
-
if (!
|
|
873
|
-
const
|
|
860
|
+
}, Ce = (r) => {
|
|
861
|
+
T((u) => u.filter((y) => y.chatId !== r));
|
|
862
|
+
}, Ke = () => {
|
|
863
|
+
$e.current += 1;
|
|
864
|
+
}, we = () => {
|
|
865
|
+
for (const r of G.current.values()) r.abort();
|
|
866
|
+
G.current.clear();
|
|
867
|
+
}, Y = (r) => {
|
|
868
|
+
r instanceof Error && r.name === "AbortError" || (console.warn("[make-ai-assistant] conversation operation failed", {
|
|
869
|
+
errorType: r instanceof Error ? r.name : typeof r
|
|
870
|
+
}), U(Et(r)));
|
|
871
|
+
}, Me = async (r) => {
|
|
872
|
+
if (!o || !t.listConversations) return;
|
|
873
|
+
const u = te.current, y = ++$e.current, w = ae();
|
|
874
874
|
try {
|
|
875
|
-
const
|
|
875
|
+
const $ = await t.listConversations(
|
|
876
876
|
e,
|
|
877
|
-
{ cursor:
|
|
877
|
+
{ cursor: r },
|
|
878
878
|
{ signal: w.signal }
|
|
879
879
|
);
|
|
880
|
-
if (!
|
|
880
|
+
if (!L(u) || w.signal.aborted || y !== $e.current)
|
|
881
881
|
return;
|
|
882
|
-
|
|
883
|
-
const
|
|
884
|
-
(
|
|
882
|
+
T((z) => {
|
|
883
|
+
const _ = new Map(z.map((S) => [S.chatId, S])), x = $.chats.map(
|
|
884
|
+
(S) => _t(_.get(S.chatId), S)
|
|
885
885
|
);
|
|
886
886
|
return [
|
|
887
887
|
...new Map(
|
|
888
|
-
[...
|
|
889
|
-
|
|
890
|
-
|
|
888
|
+
[...r ? z : [], ...x].map((S) => [
|
|
889
|
+
S.chatId,
|
|
890
|
+
S
|
|
891
891
|
])
|
|
892
892
|
).values()
|
|
893
893
|
];
|
|
894
|
-
}),
|
|
895
|
-
} catch (
|
|
896
|
-
|
|
894
|
+
}), k($.nextCursor);
|
|
895
|
+
} catch ($) {
|
|
896
|
+
L(u) && !w.signal.aborted && y === $e.current && Y($);
|
|
897
897
|
} finally {
|
|
898
|
-
|
|
898
|
+
Z(w), L(u) && y === $e.current && ne(!1);
|
|
899
899
|
}
|
|
900
|
-
},
|
|
900
|
+
}, We = async (r) => {
|
|
901
901
|
if (!t.getConversation) return;
|
|
902
|
-
const
|
|
902
|
+
const u = te.current, y = ae();
|
|
903
903
|
try {
|
|
904
904
|
const w = await t.getConversation(
|
|
905
905
|
e,
|
|
906
|
-
{ chatId:
|
|
907
|
-
{ signal:
|
|
906
|
+
{ chatId: r },
|
|
907
|
+
{ signal: y.signal }
|
|
908
908
|
);
|
|
909
|
-
if (!
|
|
910
|
-
|
|
909
|
+
if (!L(u) || y.signal.aborted || w.chatId !== r) return;
|
|
910
|
+
ke(w), l.current?.chatId === r && Q(w);
|
|
911
911
|
} catch (w) {
|
|
912
|
-
|
|
912
|
+
L(u) && !y.signal.aborted && Y(w);
|
|
913
913
|
} finally {
|
|
914
|
-
|
|
914
|
+
Z(y);
|
|
915
915
|
}
|
|
916
|
-
},
|
|
917
|
-
const w =
|
|
916
|
+
}, Re = async (r, u, y) => {
|
|
917
|
+
const w = te.current, $ = K.current;
|
|
918
918
|
let z;
|
|
919
919
|
try {
|
|
920
|
-
for await (const
|
|
921
|
-
if (!
|
|
920
|
+
for await (const _ of r) {
|
|
921
|
+
if (!L(w) || u.signal.aborted || $ !== K.current || l.current?.chatId !== y)
|
|
922
922
|
return;
|
|
923
|
-
const
|
|
924
|
-
if (
|
|
925
|
-
z =
|
|
926
|
-
const
|
|
927
|
-
if (
|
|
928
|
-
|
|
923
|
+
const x = ea(_);
|
|
924
|
+
if (x.type === "response.accepted" || x.type === "response.state") {
|
|
925
|
+
z = x.responseId;
|
|
926
|
+
const S = G.current.get(z);
|
|
927
|
+
if (S && S !== u) {
|
|
928
|
+
x.type === "response.accepted" && g((O) => Ie(O, x)), u.abort();
|
|
929
929
|
return;
|
|
930
930
|
}
|
|
931
|
-
|
|
931
|
+
G.current.set(z, u);
|
|
932
932
|
}
|
|
933
|
-
|
|
933
|
+
g((S) => Ie(S, x)), x.type === "response.accepted" && We(y), x.type === "response.terminal" && (le((S) => S.filter((O) => O !== x.responseId)), Me());
|
|
934
934
|
}
|
|
935
|
-
} catch (
|
|
936
|
-
|
|
937
|
-
...
|
|
938
|
-
status: Object.values(
|
|
939
|
-
(
|
|
935
|
+
} catch (_) {
|
|
936
|
+
L(w) && !u.signal.aborted && $ === K.current && (Y(_), z || g((x) => ({
|
|
937
|
+
...x,
|
|
938
|
+
status: Object.values(x.responses ?? {}).some(
|
|
939
|
+
(S) => !kt(S)
|
|
940
940
|
) ? "streaming" : "error"
|
|
941
941
|
})));
|
|
942
942
|
} finally {
|
|
943
|
-
z &&
|
|
943
|
+
z && G.current.get(z) === u && G.current.delete(z), Z(u);
|
|
944
944
|
}
|
|
945
|
-
},
|
|
945
|
+
}, pe = async (r, u, y, w) => {
|
|
946
946
|
if (!t.getResponse || !t.watchResponse) return;
|
|
947
|
-
const
|
|
948
|
-
|
|
947
|
+
const $ = new Set(
|
|
948
|
+
r.filter((_) => _.role === "assistant" && _.persistent).map((_) => _.responseId)
|
|
949
949
|
), z = [
|
|
950
950
|
...new Map(
|
|
951
|
-
|
|
952
|
-
(
|
|
953
|
-
).map((
|
|
951
|
+
r.filter(
|
|
952
|
+
(_) => _.role === "user" && _.responseId && !$.has(_.responseId)
|
|
953
|
+
).map((_) => [_.responseId, _.cursor])
|
|
954
954
|
).entries()
|
|
955
955
|
].slice(-20);
|
|
956
|
-
for (const [
|
|
957
|
-
if (!
|
|
958
|
-
if (
|
|
959
|
-
const
|
|
956
|
+
for (const [_, x] of z) {
|
|
957
|
+
if (!L(w) || y !== K.current) return;
|
|
958
|
+
if (G.current.has(_)) continue;
|
|
959
|
+
const S = ae();
|
|
960
960
|
try {
|
|
961
|
-
const
|
|
961
|
+
const O = await t.getResponse(
|
|
962
962
|
e,
|
|
963
|
-
{ chatId:
|
|
964
|
-
{ signal:
|
|
963
|
+
{ chatId: u, responseId: _ },
|
|
964
|
+
{ signal: S.signal }
|
|
965
965
|
);
|
|
966
|
-
if (!
|
|
967
|
-
|
|
968
|
-
(
|
|
969
|
-
|
|
970
|
-
|
|
966
|
+
if (!L(w) || S.signal.aborted || y !== K.current || G.current.has(_)) continue;
|
|
967
|
+
g(
|
|
968
|
+
(p) => Ie(
|
|
969
|
+
p,
|
|
970
|
+
kt(O) ? { type: "response.snapshot", snapshot: O } : {
|
|
971
971
|
type: "response.state",
|
|
972
|
-
chatId:
|
|
973
|
-
responseId:
|
|
974
|
-
status:
|
|
972
|
+
chatId: u,
|
|
973
|
+
responseId: _,
|
|
974
|
+
status: O.status
|
|
975
975
|
}
|
|
976
976
|
)
|
|
977
|
-
),
|
|
978
|
-
(
|
|
977
|
+
), O.status === "failed" || O.status === "cancelled" ? g(
|
|
978
|
+
(p) => Ie(p, {
|
|
979
979
|
type: "response.terminal",
|
|
980
|
-
chatId:
|
|
981
|
-
responseId:
|
|
982
|
-
status:
|
|
980
|
+
chatId: u,
|
|
981
|
+
responseId: _,
|
|
982
|
+
status: O.status
|
|
983
983
|
})
|
|
984
|
-
) : (
|
|
984
|
+
) : (G.current.set(_, S), Re(
|
|
985
985
|
t.watchResponse(
|
|
986
986
|
e,
|
|
987
|
-
{ chatId:
|
|
988
|
-
{ signal:
|
|
987
|
+
{ chatId: u, responseId: _, historyCursor: x },
|
|
988
|
+
{ signal: S.signal }
|
|
989
989
|
),
|
|
990
|
-
|
|
991
|
-
|
|
990
|
+
S,
|
|
991
|
+
u
|
|
992
992
|
));
|
|
993
|
-
} catch (
|
|
994
|
-
|
|
993
|
+
} catch (O) {
|
|
994
|
+
L(w) && !S.signal.aborted && Y(O);
|
|
995
995
|
} finally {
|
|
996
|
-
|
|
996
|
+
G.current.get(_) !== S && Z(S);
|
|
997
997
|
}
|
|
998
998
|
}
|
|
999
|
-
},
|
|
1000
|
-
|
|
1001
|
-
|
|
999
|
+
}, Xe = async (r) => {
|
|
1000
|
+
if (!o) return;
|
|
1001
|
+
const u = ++K.current, y = te.current, w = ae();
|
|
1002
|
+
we(), U(void 0), ne(!0), le([]), oe.current = void 0, Q(r), g({ messages: [], status: "idle", threadId: r.chatId }), W(void 0), X(!1), ee(!1);
|
|
1002
1003
|
try {
|
|
1003
|
-
const [
|
|
1004
|
+
const [$, z] = await Promise.all([
|
|
1004
1005
|
t.getConversation(
|
|
1005
1006
|
e,
|
|
1006
|
-
{ chatId:
|
|
1007
|
+
{ chatId: r.chatId },
|
|
1007
1008
|
{ signal: w.signal }
|
|
1008
1009
|
),
|
|
1009
1010
|
t.loadConversation(e, {
|
|
1010
|
-
threadId:
|
|
1011
|
+
threadId: r.chatId,
|
|
1011
1012
|
cursor: void 0,
|
|
1012
1013
|
signal: w.signal
|
|
1013
1014
|
})
|
|
1014
1015
|
]);
|
|
1015
|
-
if (!
|
|
1016
|
+
if (!L(y) || w.signal.aborted || u !== K.current)
|
|
1016
1017
|
return;
|
|
1017
|
-
if (
|
|
1018
|
+
if ($.chatId !== r.chatId || z.threadId !== r.chatId)
|
|
1018
1019
|
throw new Error("Conversation mismatch");
|
|
1019
|
-
|
|
1020
|
-
} catch (
|
|
1021
|
-
|
|
1020
|
+
Q($), g(ye(z)), W(z.nextCursor ?? -1), X(z.hasMore ?? !1), pe(z.messages, r.chatId, u, y);
|
|
1021
|
+
} catch ($) {
|
|
1022
|
+
L(y) && !w.signal.aborted && u === K.current && Y($);
|
|
1022
1023
|
} finally {
|
|
1023
|
-
|
|
1024
|
+
Z(w), L(y) && u === K.current && ne(!1);
|
|
1024
1025
|
}
|
|
1025
|
-
},
|
|
1026
|
-
if (
|
|
1027
|
-
if (
|
|
1028
|
-
|
|
1029
|
-
|
|
1026
|
+
}, Pe = async () => {
|
|
1027
|
+
if (!o) throw new Error(i ?? "会话管理不可用");
|
|
1028
|
+
if (l.current) return l.current;
|
|
1029
|
+
if (de.current ??= { requestId: qe() }, de.current.promise) return de.current.promise;
|
|
1030
|
+
const r = te.current, u = K.current, y = ae(), w = de.current;
|
|
1031
|
+
return ce(!0), w.promise = t.createConversation(
|
|
1030
1032
|
e,
|
|
1031
1033
|
{ requestId: w.requestId },
|
|
1032
|
-
{ signal:
|
|
1033
|
-
).then((
|
|
1034
|
-
if (!
|
|
1034
|
+
{ signal: y.signal }
|
|
1035
|
+
).then(($) => {
|
|
1036
|
+
if (!L(r) || y.signal.aborted || u !== K.current)
|
|
1035
1037
|
throw Object.assign(new Error("Stale create"), {
|
|
1036
1038
|
name: "AbortError"
|
|
1037
1039
|
});
|
|
1038
|
-
return
|
|
1040
|
+
return de.current = void 0, Q($), g({ messages: [], status: "idle", threadId: $.chatId }), Me(), $;
|
|
1039
1041
|
}).finally(() => {
|
|
1040
|
-
|
|
1042
|
+
Z(y), w.promise = void 0, L(r) && ce(!1);
|
|
1041
1043
|
}), w.promise;
|
|
1042
|
-
},
|
|
1043
|
-
if (!(
|
|
1044
|
-
|
|
1044
|
+
}, at = async () => {
|
|
1045
|
+
if (!(!o || Ae || de.current?.promise)) {
|
|
1046
|
+
K.current += 1, we(), Q(void 0), U(void 0), oe.current = void 0, g(ye()), X(!1), W(void 0);
|
|
1045
1047
|
try {
|
|
1046
|
-
await
|
|
1047
|
-
} catch (
|
|
1048
|
-
|
|
1048
|
+
await Pe();
|
|
1049
|
+
} catch (r) {
|
|
1050
|
+
Y(r);
|
|
1049
1051
|
}
|
|
1050
1052
|
}
|
|
1051
|
-
},
|
|
1052
|
-
const
|
|
1053
|
-
|
|
1054
|
-
t.run(
|
|
1055
|
-
|
|
1056
|
-
|
|
1053
|
+
}, Ge = async (r) => {
|
|
1054
|
+
const u = ae();
|
|
1055
|
+
oe.current = r, U(void 0), A.current.messages.some((y) => y.id === r.message.id) || g((y) => ta(y, r.message)), await Re(
|
|
1056
|
+
t.run(r, { signal: u.signal }),
|
|
1057
|
+
u,
|
|
1058
|
+
r.threadId
|
|
1057
1059
|
);
|
|
1058
|
-
},
|
|
1059
|
-
if (!(!o.trim() && !
|
|
1060
|
+
}, st = async (r, u) => {
|
|
1061
|
+
if (!(!o || !r.trim() && !u?.length))
|
|
1060
1062
|
try {
|
|
1061
|
-
const
|
|
1062
|
-
id:
|
|
1063
|
-
content:
|
|
1064
|
-
...
|
|
1063
|
+
const y = await Pe(), w = {
|
|
1064
|
+
id: qe(),
|
|
1065
|
+
content: r,
|
|
1066
|
+
...u ? { parts: u } : {}
|
|
1065
1067
|
};
|
|
1066
|
-
await
|
|
1067
|
-
threadId:
|
|
1068
|
+
await Ge({
|
|
1069
|
+
threadId: y.chatId,
|
|
1068
1070
|
message: w,
|
|
1069
1071
|
context: e,
|
|
1070
1072
|
capabilities: {
|
|
@@ -1073,256 +1075,259 @@ function xs(e, t) {
|
|
|
1073
1075
|
templates: []
|
|
1074
1076
|
}
|
|
1075
1077
|
});
|
|
1076
|
-
} catch (
|
|
1077
|
-
|
|
1078
|
+
} catch (y) {
|
|
1079
|
+
Y(y);
|
|
1078
1080
|
}
|
|
1079
|
-
},
|
|
1080
|
-
const
|
|
1081
|
-
if (!
|
|
1082
|
-
|
|
1081
|
+
}, Ue = async () => {
|
|
1082
|
+
const r = oe.current;
|
|
1083
|
+
if (!r || r.threadId !== l.current?.chatId) {
|
|
1084
|
+
l.current && await Xe(l.current);
|
|
1083
1085
|
return;
|
|
1084
1086
|
}
|
|
1085
|
-
const
|
|
1086
|
-
(
|
|
1087
|
+
const u = A.current.messages.find(
|
|
1088
|
+
(y) => y.id === r.message.id
|
|
1087
1089
|
);
|
|
1088
|
-
if (
|
|
1089
|
-
const
|
|
1090
|
-
if (
|
|
1090
|
+
if (u?.responseId && t.watchResponse) {
|
|
1091
|
+
const y = u.responseId;
|
|
1092
|
+
if (G.current.has(y)) return;
|
|
1091
1093
|
const w = ae();
|
|
1092
|
-
|
|
1094
|
+
G.current.set(y, w), U(void 0), await Re(
|
|
1093
1095
|
t.watchResponse(
|
|
1094
1096
|
e,
|
|
1095
1097
|
{
|
|
1096
|
-
chatId:
|
|
1097
|
-
responseId:
|
|
1098
|
-
historyCursor:
|
|
1098
|
+
chatId: r.threadId,
|
|
1099
|
+
responseId: y,
|
|
1100
|
+
historyCursor: u.cursor
|
|
1099
1101
|
},
|
|
1100
1102
|
{ signal: w.signal }
|
|
1101
1103
|
),
|
|
1102
1104
|
w,
|
|
1103
|
-
|
|
1105
|
+
r.threadId
|
|
1104
1106
|
);
|
|
1105
|
-
} else await
|
|
1106
|
-
},
|
|
1107
|
-
const
|
|
1108
|
-
if (!
|
|
1107
|
+
} else await Ge(r);
|
|
1108
|
+
}, ft = async (r = A.current.activeRunId) => {
|
|
1109
|
+
const u = l.current;
|
|
1110
|
+
if (!u || !r || !t.cancelResponse || fe.includes(r))
|
|
1109
1111
|
return;
|
|
1110
|
-
const
|
|
1111
|
-
|
|
1112
|
+
const y = te.current, w = K.current, $ = ae();
|
|
1113
|
+
le((z) => [...z, r]), U(void 0);
|
|
1112
1114
|
try {
|
|
1113
1115
|
const z = await t.cancelResponse(
|
|
1114
1116
|
e,
|
|
1115
|
-
{ chatId:
|
|
1116
|
-
{ signal:
|
|
1117
|
+
{ chatId: u.chatId, responseId: r },
|
|
1118
|
+
{ signal: $.signal }
|
|
1117
1119
|
);
|
|
1118
|
-
if (!
|
|
1119
|
-
if (
|
|
1120
|
-
|
|
1121
|
-
(
|
|
1120
|
+
if (!L(y) || w !== K.current) return;
|
|
1121
|
+
if (kt(z))
|
|
1122
|
+
g(
|
|
1123
|
+
(_) => Ie(_, {
|
|
1122
1124
|
type: "response.snapshot",
|
|
1123
1125
|
snapshot: z
|
|
1124
1126
|
})
|
|
1125
|
-
),
|
|
1126
|
-
else if (!
|
|
1127
|
-
const
|
|
1128
|
-
|
|
1127
|
+
), le((_) => _.filter((x) => x !== r));
|
|
1128
|
+
else if (!G.current.has(r) && t.watchResponse) {
|
|
1129
|
+
const _ = ae();
|
|
1130
|
+
G.current.set(r, _), Re(
|
|
1129
1131
|
t.watchResponse(
|
|
1130
1132
|
e,
|
|
1131
|
-
{ chatId:
|
|
1132
|
-
{ signal:
|
|
1133
|
+
{ chatId: u.chatId, responseId: r },
|
|
1134
|
+
{ signal: _.signal }
|
|
1133
1135
|
),
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
+
_,
|
|
1137
|
+
u.chatId
|
|
1136
1138
|
);
|
|
1137
1139
|
}
|
|
1138
1140
|
} catch (z) {
|
|
1139
|
-
|
|
1141
|
+
L(y) && w === K.current && (Y(z), le((_) => _.filter((x) => x !== r)));
|
|
1140
1142
|
} finally {
|
|
1141
|
-
|
|
1143
|
+
Z($);
|
|
1142
1144
|
}
|
|
1143
|
-
},
|
|
1144
|
-
if (!d ||
|
|
1145
|
-
const
|
|
1146
|
-
|
|
1145
|
+
}, pt = async (r, u = l.current) => {
|
|
1146
|
+
if (!d || !u || Ae) return !1;
|
|
1147
|
+
const y = te.current, w = ae();
|
|
1148
|
+
ce(!0), U(void 0);
|
|
1147
1149
|
try {
|
|
1148
|
-
const
|
|
1150
|
+
const $ = await t.updateConversation(
|
|
1149
1151
|
e,
|
|
1150
|
-
{ chatId:
|
|
1152
|
+
{ chatId: u.chatId, expectedRevision: u.revision, ...r },
|
|
1151
1153
|
{ signal: w.signal }
|
|
1152
1154
|
);
|
|
1153
|
-
return
|
|
1154
|
-
} catch (
|
|
1155
|
-
if (
|
|
1156
|
-
|
|
1155
|
+
return L(y) ? (Ke(), ke($), l.current?.chatId === $.chatId && Q($), !0) : !1;
|
|
1156
|
+
} catch ($) {
|
|
1157
|
+
if (L(y)) {
|
|
1158
|
+
Y($);
|
|
1157
1159
|
try {
|
|
1158
1160
|
const z = await t.getConversation(
|
|
1159
1161
|
e,
|
|
1160
|
-
{ chatId:
|
|
1162
|
+
{ chatId: u.chatId },
|
|
1161
1163
|
{ signal: w.signal }
|
|
1162
1164
|
);
|
|
1163
|
-
|
|
1165
|
+
L(y) && l.current?.chatId === u.chatId && Q(z);
|
|
1164
1166
|
} catch {
|
|
1165
1167
|
}
|
|
1166
|
-
|
|
1168
|
+
Me();
|
|
1167
1169
|
}
|
|
1168
1170
|
return !1;
|
|
1169
1171
|
} finally {
|
|
1170
|
-
|
|
1172
|
+
Z(w), L(y) && ce(!1);
|
|
1171
1173
|
}
|
|
1172
|
-
},
|
|
1173
|
-
if (!
|
|
1174
|
-
const
|
|
1175
|
-
|
|
1174
|
+
}, nt = async (r = l.current) => {
|
|
1175
|
+
if (!h || !r || Ae) return !1;
|
|
1176
|
+
const u = te.current, y = ae();
|
|
1177
|
+
ce(!0), U(void 0);
|
|
1176
1178
|
try {
|
|
1177
1179
|
return await t.deleteConversation(
|
|
1178
1180
|
e,
|
|
1179
|
-
{ chatId:
|
|
1180
|
-
{ signal:
|
|
1181
|
-
),
|
|
1181
|
+
{ chatId: r.chatId, expectedRevision: r.revision },
|
|
1182
|
+
{ signal: y.signal }
|
|
1183
|
+
), L(u) ? (Ke(), Ce(r.chatId), l.current?.chatId === r.chatId && (K.current += 1, we(), Q(void 0), g(ye())), !0) : !1;
|
|
1182
1184
|
} catch (w) {
|
|
1183
|
-
return
|
|
1185
|
+
return L(u) && Y(w), !1;
|
|
1184
1186
|
} finally {
|
|
1185
|
-
|
|
1187
|
+
Z(y), L(u) && ce(!1);
|
|
1186
1188
|
}
|
|
1187
|
-
},
|
|
1188
|
-
const
|
|
1189
|
-
if (
|
|
1189
|
+
}, Fe = async (r, u, y = "", w = "") => {
|
|
1190
|
+
const $ = l.current;
|
|
1191
|
+
if (!$ || !r.persistent || !t.setFeedback || Ee.includes(r.id))
|
|
1190
1192
|
return;
|
|
1191
1193
|
const z = {
|
|
1192
|
-
chatId:
|
|
1193
|
-
messageId:
|
|
1194
|
-
rating:
|
|
1195
|
-
...
|
|
1194
|
+
chatId: $.chatId,
|
|
1195
|
+
messageId: r.id,
|
|
1196
|
+
rating: u,
|
|
1197
|
+
...y ? { reason: y } : {},
|
|
1196
1198
|
...w ? { comment: w } : {}
|
|
1197
|
-
},
|
|
1199
|
+
}, _ = Se.current.get(r.id), { requestId: x, ...S } = _ ?? {
|
|
1198
1200
|
requestId: ""
|
|
1199
|
-
},
|
|
1200
|
-
|
|
1201
|
-
const
|
|
1202
|
-
|
|
1201
|
+
}, O = _ && JSON.stringify(S) === JSON.stringify(z) ? _ : { ...z, requestId: qe() };
|
|
1202
|
+
Se.current.set(r.id, O);
|
|
1203
|
+
const p = te.current, j = K.current, q = ae();
|
|
1204
|
+
ge((V) => [...V, r.id]), U(void 0);
|
|
1203
1205
|
try {
|
|
1204
|
-
const
|
|
1205
|
-
signal:
|
|
1206
|
+
const V = await t.setFeedback(e, O, {
|
|
1207
|
+
signal: q.signal
|
|
1206
1208
|
});
|
|
1207
|
-
return !
|
|
1208
|
-
...
|
|
1209
|
-
messages:
|
|
1210
|
-
(
|
|
1209
|
+
return !L(p) || j !== K.current || Se.current.get(r.id) !== O ? void 0 : (g((ie) => ({
|
|
1210
|
+
...ie,
|
|
1211
|
+
messages: ie.messages.map(
|
|
1212
|
+
(be) => be.id === r.id && V.revision >= (be.feedback?.revision ?? 0) ? { ...be, feedback: V } : be
|
|
1211
1213
|
)
|
|
1212
|
-
})),
|
|
1213
|
-
} catch (
|
|
1214
|
-
return
|
|
1214
|
+
})), Se.current.delete(r.id), !0);
|
|
1215
|
+
} catch (V) {
|
|
1216
|
+
return L(p) && j === K.current && Y(V), !1;
|
|
1215
1217
|
} finally {
|
|
1216
|
-
|
|
1218
|
+
Z(q), L(p) && ge((V) => V.filter((ie) => ie !== r.id));
|
|
1217
1219
|
}
|
|
1218
|
-
},
|
|
1219
|
-
if (!
|
|
1220
|
-
const
|
|
1221
|
-
|
|
1220
|
+
}, vt = async () => {
|
|
1221
|
+
if (!l.current || !M || he) return;
|
|
1222
|
+
const r = te.current, u = K.current, y = l.current, w = ae();
|
|
1223
|
+
ne(!0);
|
|
1222
1224
|
try {
|
|
1223
|
-
const
|
|
1224
|
-
threadId:
|
|
1225
|
-
cursor:
|
|
1225
|
+
const $ = await t.loadConversation(e, {
|
|
1226
|
+
threadId: y.chatId,
|
|
1227
|
+
cursor: E,
|
|
1226
1228
|
signal: w.signal
|
|
1227
1229
|
});
|
|
1228
|
-
if (!
|
|
1229
|
-
const z =
|
|
1230
|
+
if (!L(r) || u !== K.current) return;
|
|
1231
|
+
const z = ye($), _ = [
|
|
1230
1232
|
...new Map(
|
|
1231
|
-
[...
|
|
1232
|
-
|
|
1233
|
-
|
|
1233
|
+
[...A.current.messages, ...z.messages].map((O) => [
|
|
1234
|
+
O.id,
|
|
1235
|
+
O
|
|
1234
1236
|
])
|
|
1235
1237
|
).values()
|
|
1236
1238
|
];
|
|
1237
|
-
let
|
|
1238
|
-
const
|
|
1239
|
-
for (const
|
|
1240
|
-
if (
|
|
1241
|
-
|
|
1239
|
+
let x = 0;
|
|
1240
|
+
const S = [];
|
|
1241
|
+
for (const O of _.slice(-200).reverse()) {
|
|
1242
|
+
if (x += [...O.content].length, x > 1e6) break;
|
|
1243
|
+
S.unshift(O);
|
|
1242
1244
|
}
|
|
1243
|
-
|
|
1244
|
-
} catch (
|
|
1245
|
-
|
|
1245
|
+
S.length < _.length && ee(!0), g((O) => ({ ...O, messages: S })), W($.nextCursor ?? E), X($.hasMore ?? !1), pe($.messages, y.chatId, u, r);
|
|
1246
|
+
} catch ($) {
|
|
1247
|
+
L(r) && Y($);
|
|
1246
1248
|
} finally {
|
|
1247
|
-
|
|
1249
|
+
Z(w), L(r) && ne(!1);
|
|
1248
1250
|
}
|
|
1249
|
-
},
|
|
1251
|
+
}, Ze = [
|
|
1250
1252
|
.../* @__PURE__ */ new Set([
|
|
1251
|
-
...
|
|
1252
|
-
...
|
|
1253
|
+
...F.filter((r) => r.titlePending).map((r) => r.chatId),
|
|
1254
|
+
...H?.titlePending ? [H.chatId] : []
|
|
1253
1255
|
])
|
|
1254
1256
|
].sort().join("\0");
|
|
1255
|
-
|
|
1256
|
-
if (!s || !t.getConversation || !
|
|
1257
|
-
const
|
|
1258
|
-
let
|
|
1257
|
+
se(() => {
|
|
1258
|
+
if (!s || !t.getConversation || !Ze) return;
|
|
1259
|
+
const r = te.current, u = ae(), y = Ze.split("\0"), w = /* @__PURE__ */ new Set();
|
|
1260
|
+
let $;
|
|
1259
1261
|
console.debug("[make-ai-assistant] watching pending conversation titles", {
|
|
1260
|
-
count:
|
|
1262
|
+
count: y.length
|
|
1261
1263
|
});
|
|
1262
1264
|
const z = async () => {
|
|
1263
1265
|
await Promise.all(
|
|
1264
|
-
|
|
1265
|
-
if (!w.has(
|
|
1266
|
+
y.map(async (_) => {
|
|
1267
|
+
if (!w.has(_))
|
|
1266
1268
|
try {
|
|
1267
|
-
const
|
|
1269
|
+
const x = await t.getConversation(
|
|
1268
1270
|
e,
|
|
1269
|
-
{ chatId:
|
|
1270
|
-
{ signal:
|
|
1271
|
+
{ chatId: _ },
|
|
1272
|
+
{ signal: u.signal }
|
|
1271
1273
|
);
|
|
1272
|
-
if (!
|
|
1274
|
+
if (!L(r) || u.signal.aborted || x.chatId !== _)
|
|
1273
1275
|
return;
|
|
1274
|
-
|
|
1275
|
-
} catch (
|
|
1276
|
-
if (!
|
|
1276
|
+
ke(x), l.current?.chatId === _ && Q(x);
|
|
1277
|
+
} catch (x) {
|
|
1278
|
+
if (!L(r) || u.signal.aborted) return;
|
|
1277
1279
|
console.warn("[make-ai-assistant] title metadata refresh failed", {
|
|
1278
|
-
errorType:
|
|
1280
|
+
errorType: x instanceof Error ? x.name : typeof x
|
|
1279
1281
|
});
|
|
1280
|
-
const
|
|
1281
|
-
|
|
1282
|
+
const S = x?.status;
|
|
1283
|
+
S === 401 ? (u.abort(), Y(x)) : (S === 403 || S === 404) && (w.add(_), l.current?.chatId === _ && Y(x));
|
|
1282
1284
|
}
|
|
1283
1285
|
})
|
|
1284
|
-
),
|
|
1286
|
+
), L(r) && !u.signal.aborted && y.some((_) => !w.has(_)) && ($ = setTimeout(() => {
|
|
1285
1287
|
z();
|
|
1286
1288
|
}, Bt));
|
|
1287
1289
|
};
|
|
1288
|
-
return
|
|
1290
|
+
return $ = setTimeout(() => {
|
|
1289
1291
|
z();
|
|
1290
1292
|
}, Bt), () => {
|
|
1291
|
-
clearTimeout(
|
|
1293
|
+
clearTimeout($), u.abort(), Z(u);
|
|
1292
1294
|
};
|
|
1293
|
-
}, [s,
|
|
1294
|
-
|
|
1295
|
-
for (const
|
|
1296
|
-
|
|
1297
|
-
}), [
|
|
1298
|
-
const
|
|
1295
|
+
}, [s, v, t, Ze]), se(() => (te.current += 1, f.current = v, de.current = void 0, oe.current = void 0, Se.current.clear(), Q(void 0), T([]), k(""), g(ye()), U(void 0), ne(o), ce(!1), le([]), ge([]), o && Me(), () => {
|
|
1296
|
+
te.current += 1, K.current += 1;
|
|
1297
|
+
for (const r of De.current) r.abort();
|
|
1298
|
+
De.current.clear(), G.current.clear();
|
|
1299
|
+
}), [o, v, t]);
|
|
1300
|
+
const Le = f.current === v;
|
|
1299
1301
|
return {
|
|
1300
1302
|
enabled: s,
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1303
|
+
available: o,
|
|
1304
|
+
configurationError: i,
|
|
1305
|
+
canEdit: d,
|
|
1306
|
+
canDelete: h,
|
|
1307
|
+
state: Le ? N : ye(),
|
|
1308
|
+
setState: g,
|
|
1309
|
+
chats: Le ? F : [],
|
|
1310
|
+
chat: Le ? H : void 0,
|
|
1311
|
+
listCursor: c,
|
|
1312
|
+
historyMore: M,
|
|
1313
|
+
historyTruncated: me,
|
|
1314
|
+
loading: !Le || he,
|
|
1315
|
+
busy: Ae,
|
|
1316
|
+
error: Le ? ht : void 0,
|
|
1317
|
+
cancelling: fe,
|
|
1318
|
+
feedbackBusy: Ee,
|
|
1319
|
+
refresh: Me,
|
|
1320
|
+
select: Xe,
|
|
1321
|
+
create: at,
|
|
1322
|
+
ensureChat: Pe,
|
|
1323
|
+
send: st,
|
|
1324
|
+
retry: Ue,
|
|
1325
|
+
stop: ft,
|
|
1326
|
+
update: pt,
|
|
1327
|
+
remove: nt,
|
|
1328
|
+
feedback: Fe,
|
|
1329
|
+
moreHistory: vt,
|
|
1330
|
+
setError: U
|
|
1326
1331
|
};
|
|
1327
1332
|
}
|
|
1328
1333
|
const Ds = ({
|
|
@@ -1330,25 +1335,25 @@ const Ds = ({
|
|
|
1330
1335
|
label: t,
|
|
1331
1336
|
onDismiss: s
|
|
1332
1337
|
}) => {
|
|
1333
|
-
const [n, i] =
|
|
1338
|
+
const [n, i] = R();
|
|
1334
1339
|
if (At(() => {
|
|
1335
|
-
const
|
|
1340
|
+
const d = () => {
|
|
1336
1341
|
if (!e.isConnected) {
|
|
1337
1342
|
s();
|
|
1338
1343
|
return;
|
|
1339
1344
|
}
|
|
1340
|
-
const
|
|
1345
|
+
const h = e.getBoundingClientRect(), v = h.top >= 48 ? "above" : "below";
|
|
1341
1346
|
i({
|
|
1342
|
-
left:
|
|
1343
|
-
placement:
|
|
1344
|
-
top:
|
|
1347
|
+
left: h.left + h.width / 2,
|
|
1348
|
+
placement: v,
|
|
1349
|
+
top: v === "above" ? h.top - 8 : h.bottom + 8
|
|
1345
1350
|
});
|
|
1346
1351
|
};
|
|
1347
|
-
return
|
|
1348
|
-
window.removeEventListener("resize",
|
|
1352
|
+
return d(), window.addEventListener("resize", d), document.addEventListener("scroll", d, !0), () => {
|
|
1353
|
+
window.removeEventListener("resize", d), document.removeEventListener("scroll", d, !0);
|
|
1349
1354
|
};
|
|
1350
1355
|
}, [e, s]), !n || typeof document > "u") return null;
|
|
1351
|
-
const
|
|
1356
|
+
const o = e.closest(".make-ai-assistant") ?? document.body;
|
|
1352
1357
|
return aa(
|
|
1353
1358
|
/* @__PURE__ */ a(
|
|
1354
1359
|
"span",
|
|
@@ -1360,7 +1365,7 @@ const Ds = ({
|
|
|
1360
1365
|
children: t
|
|
1361
1366
|
}
|
|
1362
1367
|
),
|
|
1363
|
-
|
|
1368
|
+
o
|
|
1364
1369
|
);
|
|
1365
1370
|
};
|
|
1366
1371
|
function Ps({
|
|
@@ -1370,44 +1375,44 @@ function Ps({
|
|
|
1370
1375
|
onNewConversation: n,
|
|
1371
1376
|
triggerRef: i
|
|
1372
1377
|
}) {
|
|
1373
|
-
const [
|
|
1378
|
+
const [o, d] = R(), [h, v] = R(""), [I, f] = R(), [N, C] = R(), A = P(null), g = (c, k) => {
|
|
1374
1379
|
C(
|
|
1375
|
-
(
|
|
1380
|
+
(E) => E?.anchor === k && E.label === c ? E : { anchor: k, label: c }
|
|
1376
1381
|
);
|
|
1377
|
-
},
|
|
1378
|
-
C((
|
|
1379
|
-
},
|
|
1380
|
-
"data-tooltip":
|
|
1381
|
-
onBlur: (
|
|
1382
|
-
onFocus: (
|
|
1383
|
-
onPointerEnter: (
|
|
1384
|
-
onPointerLeave: (
|
|
1382
|
+
}, F = (c) => {
|
|
1383
|
+
C((k) => k?.anchor === c ? void 0 : k);
|
|
1384
|
+
}, T = (c) => ({
|
|
1385
|
+
"data-tooltip": c,
|
|
1386
|
+
onBlur: (k) => F(k.currentTarget),
|
|
1387
|
+
onFocus: (k) => g(c, k.currentTarget),
|
|
1388
|
+
onPointerEnter: (k) => g(c, k.currentTarget),
|
|
1389
|
+
onPointerLeave: (k) => F(k.currentTarget)
|
|
1385
1390
|
}), H = () => {
|
|
1386
|
-
|
|
1387
|
-
},
|
|
1388
|
-
const
|
|
1389
|
-
|
|
1390
|
-
},
|
|
1391
|
-
await t.remove(
|
|
1391
|
+
d(void 0), v("");
|
|
1392
|
+
}, b = async (c) => {
|
|
1393
|
+
const k = h.trim();
|
|
1394
|
+
k && await t.update({ title: k }, c) && H();
|
|
1395
|
+
}, l = async (c) => {
|
|
1396
|
+
await t.remove(c) && f(void 0);
|
|
1392
1397
|
};
|
|
1393
|
-
return
|
|
1394
|
-
const
|
|
1395
|
-
const
|
|
1396
|
-
|
|
1398
|
+
return se(() => {
|
|
1399
|
+
const c = (k) => {
|
|
1400
|
+
const E = k.target;
|
|
1401
|
+
E instanceof Node && (A.current?.contains(E) || i.current?.contains(E) || s());
|
|
1397
1402
|
};
|
|
1398
|
-
return document.addEventListener("pointerdown",
|
|
1399
|
-
document.removeEventListener("pointerdown",
|
|
1403
|
+
return document.addEventListener("pointerdown", c), () => {
|
|
1404
|
+
document.removeEventListener("pointerdown", c);
|
|
1400
1405
|
};
|
|
1401
|
-
}, [s, i]), /* @__PURE__ */
|
|
1406
|
+
}, [s, i]), /* @__PURE__ */ m(
|
|
1402
1407
|
"div",
|
|
1403
1408
|
{
|
|
1404
1409
|
"aria-label": "任务列表",
|
|
1405
1410
|
className: "make-ai-assistant__conversation-controls",
|
|
1406
1411
|
id: e,
|
|
1407
|
-
ref:
|
|
1412
|
+
ref: A,
|
|
1408
1413
|
role: "dialog",
|
|
1409
1414
|
children: [
|
|
1410
|
-
/* @__PURE__ */
|
|
1415
|
+
/* @__PURE__ */ m("div", { className: "make-ai-assistant__conversation-heading", children: [
|
|
1411
1416
|
/* @__PURE__ */ a("span", { children: "最近对话" }),
|
|
1412
1417
|
/* @__PURE__ */ a(
|
|
1413
1418
|
"button",
|
|
@@ -1416,12 +1421,12 @@ function Ps({
|
|
|
1416
1421
|
className: "make-ai-assistant__conversation-refresh",
|
|
1417
1422
|
disabled: t.busy,
|
|
1418
1423
|
type: "button",
|
|
1419
|
-
...
|
|
1424
|
+
...T("刷新"),
|
|
1420
1425
|
onClick: () => {
|
|
1421
1426
|
t.refresh();
|
|
1422
1427
|
},
|
|
1423
1428
|
children: /* @__PURE__ */ a(
|
|
1424
|
-
|
|
1429
|
+
mt,
|
|
1425
1430
|
{
|
|
1426
1431
|
"aria-hidden": "true",
|
|
1427
1432
|
className: "make-ai-assistant__conversation-refresh-icon"
|
|
@@ -1430,22 +1435,22 @@ function Ps({
|
|
|
1430
1435
|
}
|
|
1431
1436
|
)
|
|
1432
1437
|
] }),
|
|
1433
|
-
/* @__PURE__ */
|
|
1438
|
+
/* @__PURE__ */ m(
|
|
1434
1439
|
"nav",
|
|
1435
1440
|
{
|
|
1436
1441
|
"aria-label": "对话列表",
|
|
1437
1442
|
className: "make-ai-assistant__conversation-list",
|
|
1438
1443
|
children: [
|
|
1439
|
-
t.chats.map((
|
|
1440
|
-
const
|
|
1441
|
-
return /* @__PURE__ */
|
|
1444
|
+
t.chats.map((c) => {
|
|
1445
|
+
const k = o === c.chatId, E = I === c.chatId, W = c.title || "未命名对话";
|
|
1446
|
+
return /* @__PURE__ */ m(
|
|
1442
1447
|
"div",
|
|
1443
1448
|
{
|
|
1444
1449
|
className: "make-ai-assistant__conversation-row",
|
|
1445
|
-
"data-active": t.chat?.chatId ===
|
|
1446
|
-
"data-editing":
|
|
1450
|
+
"data-active": t.chat?.chatId === c.chatId || void 0,
|
|
1451
|
+
"data-editing": k || E || void 0,
|
|
1447
1452
|
children: [
|
|
1448
|
-
|
|
1453
|
+
E ? /* @__PURE__ */ m(
|
|
1449
1454
|
"div",
|
|
1450
1455
|
{
|
|
1451
1456
|
"aria-label": "确认删除对话",
|
|
@@ -1459,7 +1464,7 @@ function Ps({
|
|
|
1459
1464
|
className: "make-ai-assistant__conversation-delete-confirmation-icon"
|
|
1460
1465
|
}
|
|
1461
1466
|
),
|
|
1462
|
-
/* @__PURE__ */
|
|
1467
|
+
/* @__PURE__ */ m("span", { className: "make-ai-assistant__conversation-delete-confirmation-message", children: [
|
|
1463
1468
|
"确认删除“",
|
|
1464
1469
|
W,
|
|
1465
1470
|
"”?"
|
|
@@ -1469,14 +1474,14 @@ function Ps({
|
|
|
1469
1474
|
{
|
|
1470
1475
|
"aria-label": `确认删除:${W}`,
|
|
1471
1476
|
className: "make-ai-assistant__conversation-row-action make-ai-assistant__conversation-row-action--danger make-ai-assistant__conversation-delete-confirmation-confirm",
|
|
1472
|
-
disabled: t.busy || !t.
|
|
1477
|
+
disabled: t.busy || !t.canDelete,
|
|
1473
1478
|
type: "button",
|
|
1474
|
-
...
|
|
1479
|
+
...T("确认删除"),
|
|
1475
1480
|
onClick: () => {
|
|
1476
|
-
|
|
1481
|
+
l(c);
|
|
1477
1482
|
},
|
|
1478
1483
|
children: /* @__PURE__ */ a(
|
|
1479
|
-
|
|
1484
|
+
qt,
|
|
1480
1485
|
{
|
|
1481
1486
|
"aria-hidden": "true",
|
|
1482
1487
|
className: "make-ai-assistant__conversation-row-action-icon"
|
|
@@ -1491,8 +1496,8 @@ function Ps({
|
|
|
1491
1496
|
className: "make-ai-assistant__conversation-row-action make-ai-assistant__conversation-delete-confirmation-cancel",
|
|
1492
1497
|
disabled: t.busy,
|
|
1493
1498
|
type: "button",
|
|
1494
|
-
...
|
|
1495
|
-
onClick: () =>
|
|
1499
|
+
...T("取消"),
|
|
1500
|
+
onClick: () => f(void 0),
|
|
1496
1501
|
children: /* @__PURE__ */ a(
|
|
1497
1502
|
tt,
|
|
1498
1503
|
{
|
|
@@ -1504,7 +1509,7 @@ function Ps({
|
|
|
1504
1509
|
)
|
|
1505
1510
|
]
|
|
1506
1511
|
}
|
|
1507
|
-
) :
|
|
1512
|
+
) : k ? /* @__PURE__ */ a(
|
|
1508
1513
|
"input",
|
|
1509
1514
|
{
|
|
1510
1515
|
"aria-label": "对话标题",
|
|
@@ -1512,20 +1517,20 @@ function Ps({
|
|
|
1512
1517
|
className: "make-ai-assistant__conversation-row-title-input",
|
|
1513
1518
|
disabled: t.busy,
|
|
1514
1519
|
maxLength: 255,
|
|
1515
|
-
value:
|
|
1516
|
-
onChange: (
|
|
1517
|
-
onKeyDown: (
|
|
1518
|
-
|
|
1520
|
+
value: h,
|
|
1521
|
+
onChange: (M) => v(M.currentTarget.value),
|
|
1522
|
+
onKeyDown: (M) => {
|
|
1523
|
+
M.nativeEvent.isComposing || (M.key === "Escape" && (M.preventDefault(), H()), M.key === "Enter" && (M.preventDefault(), b(c)));
|
|
1519
1524
|
}
|
|
1520
1525
|
}
|
|
1521
|
-
) : /* @__PURE__ */
|
|
1526
|
+
) : /* @__PURE__ */ m(
|
|
1522
1527
|
"button",
|
|
1523
1528
|
{
|
|
1524
|
-
"aria-pressed": t.chat?.chatId ===
|
|
1529
|
+
"aria-pressed": t.chat?.chatId === c.chatId,
|
|
1525
1530
|
className: "make-ai-assistant__conversation-row-select",
|
|
1526
1531
|
type: "button",
|
|
1527
1532
|
onClick: () => {
|
|
1528
|
-
s(), t.select(
|
|
1533
|
+
s(), t.select(c);
|
|
1529
1534
|
},
|
|
1530
1535
|
children: [
|
|
1531
1536
|
/* @__PURE__ */ a(As, { "aria-hidden": "true" }),
|
|
@@ -1533,7 +1538,7 @@ function Ps({
|
|
|
1533
1538
|
]
|
|
1534
1539
|
}
|
|
1535
1540
|
),
|
|
1536
|
-
|
|
1541
|
+
k ? /* @__PURE__ */ m(
|
|
1537
1542
|
"div",
|
|
1538
1543
|
{
|
|
1539
1544
|
"aria-label": "修改标题操作",
|
|
@@ -1545,14 +1550,14 @@ function Ps({
|
|
|
1545
1550
|
{
|
|
1546
1551
|
"aria-label": "确认修改标题",
|
|
1547
1552
|
className: "make-ai-assistant__conversation-row-action",
|
|
1548
|
-
disabled: t.busy || !
|
|
1553
|
+
disabled: t.busy || !h.trim(),
|
|
1549
1554
|
type: "button",
|
|
1550
|
-
...
|
|
1555
|
+
...T("保存标题"),
|
|
1551
1556
|
onClick: () => {
|
|
1552
|
-
|
|
1557
|
+
b(c);
|
|
1553
1558
|
},
|
|
1554
1559
|
children: /* @__PURE__ */ a(
|
|
1555
|
-
|
|
1560
|
+
gs,
|
|
1556
1561
|
{
|
|
1557
1562
|
"aria-hidden": "true",
|
|
1558
1563
|
className: "make-ai-assistant__conversation-row-action-icon"
|
|
@@ -1567,7 +1572,7 @@ function Ps({
|
|
|
1567
1572
|
className: "make-ai-assistant__conversation-row-action",
|
|
1568
1573
|
disabled: t.busy,
|
|
1569
1574
|
type: "button",
|
|
1570
|
-
...
|
|
1575
|
+
...T("取消"),
|
|
1571
1576
|
onClick: H,
|
|
1572
1577
|
children: /* @__PURE__ */ a(
|
|
1573
1578
|
tt,
|
|
@@ -1580,18 +1585,18 @@ function Ps({
|
|
|
1580
1585
|
)
|
|
1581
1586
|
]
|
|
1582
1587
|
}
|
|
1583
|
-
) :
|
|
1588
|
+
) : E ? null : /* @__PURE__ */ m("div", { className: "make-ai-assistant__conversation-row-actions", children: [
|
|
1584
1589
|
/* @__PURE__ */ a(
|
|
1585
1590
|
"button",
|
|
1586
1591
|
{
|
|
1587
|
-
"aria-label": `${
|
|
1588
|
-
"aria-pressed":
|
|
1592
|
+
"aria-label": `${c.pinned ? "取消置顶" : "置顶"} ${W}`,
|
|
1593
|
+
"aria-pressed": c.pinned,
|
|
1589
1594
|
className: "make-ai-assistant__conversation-row-action make-ai-assistant__conversation-row-pin",
|
|
1590
1595
|
disabled: t.busy || !t.canEdit,
|
|
1591
1596
|
type: "button",
|
|
1592
|
-
...
|
|
1597
|
+
...T(c.pinned ? "取消置顶" : "置顶"),
|
|
1593
1598
|
onClick: () => {
|
|
1594
|
-
t.update({ pinned: !
|
|
1599
|
+
t.update({ pinned: !c.pinned }, c);
|
|
1595
1600
|
},
|
|
1596
1601
|
children: /* @__PURE__ */ a(
|
|
1597
1602
|
Es,
|
|
@@ -1609,9 +1614,9 @@ function Ps({
|
|
|
1609
1614
|
className: "make-ai-assistant__conversation-row-action",
|
|
1610
1615
|
disabled: t.busy || !t.canEdit,
|
|
1611
1616
|
type: "button",
|
|
1612
|
-
...
|
|
1617
|
+
...T("修改标题"),
|
|
1613
1618
|
onClick: () => {
|
|
1614
|
-
|
|
1619
|
+
f(void 0), d(c.chatId), v(c.title);
|
|
1615
1620
|
},
|
|
1616
1621
|
children: /* @__PURE__ */ a(
|
|
1617
1622
|
Ts,
|
|
@@ -1627,14 +1632,14 @@ function Ps({
|
|
|
1627
1632
|
{
|
|
1628
1633
|
"aria-label": `删除:${W}`,
|
|
1629
1634
|
className: "make-ai-assistant__conversation-row-action make-ai-assistant__conversation-row-action--danger",
|
|
1630
|
-
disabled: t.busy,
|
|
1635
|
+
disabled: t.busy || !t.canDelete,
|
|
1631
1636
|
type: "button",
|
|
1632
|
-
...
|
|
1637
|
+
...T("删除"),
|
|
1633
1638
|
onClick: () => {
|
|
1634
|
-
H(),
|
|
1639
|
+
H(), f(c.chatId);
|
|
1635
1640
|
},
|
|
1636
1641
|
children: /* @__PURE__ */ a(
|
|
1637
|
-
|
|
1642
|
+
qt,
|
|
1638
1643
|
{
|
|
1639
1644
|
"aria-hidden": "true",
|
|
1640
1645
|
className: "make-ai-assistant__conversation-row-action-icon"
|
|
@@ -1645,7 +1650,7 @@ function Ps({
|
|
|
1645
1650
|
] })
|
|
1646
1651
|
]
|
|
1647
1652
|
},
|
|
1648
|
-
|
|
1653
|
+
c.chatId
|
|
1649
1654
|
);
|
|
1650
1655
|
}),
|
|
1651
1656
|
!t.loading && !t.chats.length ? /* @__PURE__ */ a("p", { children: "暂无对话,发送消息即可新建" }) : null,
|
|
@@ -1663,7 +1668,7 @@ function Ps({
|
|
|
1663
1668
|
]
|
|
1664
1669
|
}
|
|
1665
1670
|
),
|
|
1666
|
-
t.chat && (t.historyMore || t.historyTruncated || t.state.historyTruncated) ? /* @__PURE__ */
|
|
1671
|
+
t.chat && (t.historyMore || t.historyTruncated || t.state.historyTruncated) ? /* @__PURE__ */ m("div", { className: "make-ai-assistant__conversation-history-actions", children: [
|
|
1667
1672
|
t.historyMore ? /* @__PURE__ */ a(
|
|
1668
1673
|
"button",
|
|
1669
1674
|
{
|
|
@@ -1677,13 +1682,13 @@ function Ps({
|
|
|
1677
1682
|
) : null,
|
|
1678
1683
|
t.historyTruncated || t.state.historyTruncated ? /* @__PURE__ */ a("p", { children: "当前展示有界消息窗口,可重新选择对话从头读取。" }) : null
|
|
1679
1684
|
] }) : null,
|
|
1680
|
-
t.error ? /* @__PURE__ */
|
|
1685
|
+
t.error ? /* @__PURE__ */ m("div", { className: "make-ai-assistant__conversation-error", role: "alert", children: [
|
|
1681
1686
|
/* @__PURE__ */ a("span", { children: t.error }),
|
|
1682
1687
|
/* @__PURE__ */ a("button", { type: "button", onClick: () => {
|
|
1683
1688
|
t.retry();
|
|
1684
1689
|
}, children: "恢复对话" })
|
|
1685
1690
|
] }) : null,
|
|
1686
|
-
n ? /* @__PURE__ */
|
|
1691
|
+
n ? /* @__PURE__ */ m(
|
|
1687
1692
|
"button",
|
|
1688
1693
|
{
|
|
1689
1694
|
className: "make-ai-assistant__conversation-new",
|
|
@@ -1701,11 +1706,11 @@ function Ps({
|
|
|
1701
1706
|
]
|
|
1702
1707
|
}
|
|
1703
1708
|
) : null,
|
|
1704
|
-
|
|
1709
|
+
N ? /* @__PURE__ */ a(
|
|
1705
1710
|
Ds,
|
|
1706
1711
|
{
|
|
1707
|
-
anchor:
|
|
1708
|
-
label:
|
|
1712
|
+
anchor: N.anchor,
|
|
1713
|
+
label: N.label,
|
|
1709
1714
|
onDismiss: () => C(void 0)
|
|
1710
1715
|
}
|
|
1711
1716
|
) : null
|
|
@@ -1717,11 +1722,11 @@ function Us({
|
|
|
1717
1722
|
message: e,
|
|
1718
1723
|
manager: t
|
|
1719
1724
|
}) {
|
|
1720
|
-
const [s, n] =
|
|
1725
|
+
const [s, n] = R(!1), [i, o] = R(""), [d, h] = R(""), v = t.feedbackBusy.includes(e.id);
|
|
1721
1726
|
if (!e.persistent || e.role !== "assistant" || e.intermediate)
|
|
1722
1727
|
return null;
|
|
1723
|
-
const
|
|
1724
|
-
return /* @__PURE__ */
|
|
1728
|
+
const I = e.feedback?.rating ?? "none";
|
|
1729
|
+
return /* @__PURE__ */ m(
|
|
1725
1730
|
"div",
|
|
1726
1731
|
{
|
|
1727
1732
|
"aria-label": "回答反馈",
|
|
@@ -1733,12 +1738,12 @@ function Us({
|
|
|
1733
1738
|
{
|
|
1734
1739
|
type: "button",
|
|
1735
1740
|
"aria-label": "喜欢",
|
|
1736
|
-
"aria-pressed":
|
|
1741
|
+
"aria-pressed": I === "like",
|
|
1737
1742
|
className: "make-ai-assistant__reply-action make-ai-assistant__reply-feedback-action",
|
|
1738
1743
|
"data-tooltip": "喜欢",
|
|
1739
|
-
disabled:
|
|
1744
|
+
disabled: v,
|
|
1740
1745
|
onClick: () => {
|
|
1741
|
-
t.feedback(e,
|
|
1746
|
+
t.feedback(e, I === "like" ? "none" : "like");
|
|
1742
1747
|
},
|
|
1743
1748
|
children: /* @__PURE__ */ a(
|
|
1744
1749
|
Rs,
|
|
@@ -1754,16 +1759,16 @@ function Us({
|
|
|
1754
1759
|
{
|
|
1755
1760
|
type: "button",
|
|
1756
1761
|
"aria-label": "不喜欢",
|
|
1757
|
-
"aria-pressed":
|
|
1762
|
+
"aria-pressed": I === "dislike",
|
|
1758
1763
|
className: "make-ai-assistant__reply-action make-ai-assistant__reply-feedback-action",
|
|
1759
1764
|
"data-tooltip": "不喜欢",
|
|
1760
|
-
disabled:
|
|
1765
|
+
disabled: v,
|
|
1761
1766
|
onClick: () => {
|
|
1762
|
-
if (
|
|
1767
|
+
if (I === "dislike") {
|
|
1763
1768
|
t.feedback(e, "none");
|
|
1764
1769
|
return;
|
|
1765
1770
|
}
|
|
1766
|
-
|
|
1771
|
+
o(e.feedback?.reason ?? ""), h(e.feedback?.comment ?? ""), n(!0);
|
|
1767
1772
|
},
|
|
1768
1773
|
children: /* @__PURE__ */ a(
|
|
1769
1774
|
Ss,
|
|
@@ -1774,24 +1779,24 @@ function Us({
|
|
|
1774
1779
|
)
|
|
1775
1780
|
}
|
|
1776
1781
|
),
|
|
1777
|
-
|
|
1782
|
+
I === "dislike" ? /* @__PURE__ */ a(
|
|
1778
1783
|
"button",
|
|
1779
1784
|
{
|
|
1780
1785
|
className: "make-ai-assistant__feedback-text-action",
|
|
1781
1786
|
type: "button",
|
|
1782
|
-
disabled:
|
|
1787
|
+
disabled: v,
|
|
1783
1788
|
onClick: () => {
|
|
1784
|
-
|
|
1789
|
+
o(e.feedback?.reason ?? ""), h(e.feedback?.comment ?? ""), n(!0);
|
|
1785
1790
|
},
|
|
1786
1791
|
children: "修改反馈"
|
|
1787
1792
|
}
|
|
1788
1793
|
) : null,
|
|
1789
|
-
s ? /* @__PURE__ */
|
|
1794
|
+
s ? /* @__PURE__ */ m(
|
|
1790
1795
|
"form",
|
|
1791
1796
|
{
|
|
1792
|
-
onSubmit: (
|
|
1793
|
-
|
|
1794
|
-
|
|
1797
|
+
onSubmit: (f) => {
|
|
1798
|
+
f.preventDefault(), t.feedback(e, "dislike", i, d).then((N) => {
|
|
1799
|
+
N && n(!1);
|
|
1795
1800
|
});
|
|
1796
1801
|
},
|
|
1797
1802
|
children: [
|
|
@@ -1801,7 +1806,7 @@ function Us({
|
|
|
1801
1806
|
"aria-label": "反馈原因",
|
|
1802
1807
|
maxLength: 128,
|
|
1803
1808
|
value: i,
|
|
1804
|
-
onChange: (
|
|
1809
|
+
onChange: (f) => o(f.currentTarget.value),
|
|
1805
1810
|
placeholder: "原因(可选)"
|
|
1806
1811
|
}
|
|
1807
1812
|
),
|
|
@@ -1810,8 +1815,8 @@ function Us({
|
|
|
1810
1815
|
{
|
|
1811
1816
|
"aria-label": "反馈说明",
|
|
1812
1817
|
maxLength: 4e3,
|
|
1813
|
-
value:
|
|
1814
|
-
onChange: (
|
|
1818
|
+
value: d,
|
|
1819
|
+
onChange: (f) => h(f.currentTarget.value),
|
|
1815
1820
|
placeholder: "补充说明(可选)"
|
|
1816
1821
|
}
|
|
1817
1822
|
),
|
|
@@ -1820,7 +1825,7 @@ function Us({
|
|
|
1820
1825
|
{
|
|
1821
1826
|
className: "make-ai-assistant__feedback-text-action",
|
|
1822
1827
|
type: "submit",
|
|
1823
|
-
disabled:
|
|
1828
|
+
disabled: v,
|
|
1824
1829
|
children: "提交反馈"
|
|
1825
1830
|
}
|
|
1826
1831
|
),
|
|
@@ -1859,51 +1864,51 @@ function Fs({
|
|
|
1859
1864
|
transport: s,
|
|
1860
1865
|
chatId: n
|
|
1861
1866
|
}) {
|
|
1862
|
-
const [i,
|
|
1863
|
-
|
|
1867
|
+
const [i, o] = R(), [d, h] = R(), [v, I] = R(!1), f = P([]), N = P(void 0);
|
|
1868
|
+
se(
|
|
1864
1869
|
() => () => {
|
|
1865
|
-
|
|
1870
|
+
N.current?.abort(), f.current.forEach((A) => URL.revokeObjectURL(A));
|
|
1866
1871
|
},
|
|
1867
1872
|
[]
|
|
1868
1873
|
);
|
|
1869
|
-
const C = async (
|
|
1870
|
-
if (!s.readContent ||
|
|
1871
|
-
const
|
|
1872
|
-
|
|
1874
|
+
const C = async (A) => {
|
|
1875
|
+
if (!s.readContent || v) return;
|
|
1876
|
+
const g = new AbortController();
|
|
1877
|
+
N.current = g, I(!0), h(void 0);
|
|
1873
1878
|
try {
|
|
1874
|
-
const
|
|
1879
|
+
const F = await s.readContent(
|
|
1875
1880
|
t,
|
|
1876
1881
|
{ chatId: n, contentRef: e.media.contentRef },
|
|
1877
|
-
{ signal:
|
|
1882
|
+
{ signal: g.signal }
|
|
1878
1883
|
);
|
|
1879
|
-
if (
|
|
1880
|
-
const
|
|
1881
|
-
type:
|
|
1882
|
-
}), H = URL.createObjectURL(
|
|
1883
|
-
if (
|
|
1884
|
+
if (g.signal.aborted) return;
|
|
1885
|
+
const T = new Blob([new Uint8Array(F).buffer], {
|
|
1886
|
+
type: A && Vt.has(e.media.contentType) ? e.media.contentType : "application/octet-stream"
|
|
1887
|
+
}), H = URL.createObjectURL(T);
|
|
1888
|
+
if (f.current.push(H), A) o(H);
|
|
1884
1889
|
else {
|
|
1885
|
-
const
|
|
1886
|
-
|
|
1890
|
+
const b = document.createElement("a");
|
|
1891
|
+
b.href = H, b.download = e.name ?? "attachment", b.click();
|
|
1887
1892
|
}
|
|
1888
|
-
} catch (
|
|
1889
|
-
|
|
1893
|
+
} catch (F) {
|
|
1894
|
+
g.signal.aborted || h(Et(F));
|
|
1890
1895
|
} finally {
|
|
1891
|
-
|
|
1896
|
+
g.signal.aborted || I(!1);
|
|
1892
1897
|
}
|
|
1893
1898
|
};
|
|
1894
|
-
return /* @__PURE__ */
|
|
1895
|
-
/* @__PURE__ */
|
|
1899
|
+
return /* @__PURE__ */ m("div", { className: "make-ai-assistant__attachment", children: [
|
|
1900
|
+
/* @__PURE__ */ m("span", { children: [
|
|
1896
1901
|
e.name ?? "附件",
|
|
1897
1902
|
" · ",
|
|
1898
1903
|
e.media.sizeBytes,
|
|
1899
1904
|
" 字节"
|
|
1900
1905
|
] }),
|
|
1901
|
-
s.readContent ? /* @__PURE__ */
|
|
1906
|
+
s.readContent ? /* @__PURE__ */ m(Ne, { children: [
|
|
1902
1907
|
/* @__PURE__ */ a(
|
|
1903
1908
|
"button",
|
|
1904
1909
|
{
|
|
1905
1910
|
type: "button",
|
|
1906
|
-
disabled:
|
|
1911
|
+
disabled: v,
|
|
1907
1912
|
onClick: () => {
|
|
1908
1913
|
C(!1);
|
|
1909
1914
|
},
|
|
@@ -1914,7 +1919,7 @@ function Fs({
|
|
|
1914
1919
|
"button",
|
|
1915
1920
|
{
|
|
1916
1921
|
type: "button",
|
|
1917
|
-
disabled:
|
|
1922
|
+
disabled: v,
|
|
1918
1923
|
onClick: () => {
|
|
1919
1924
|
C(!0);
|
|
1920
1925
|
},
|
|
@@ -1922,7 +1927,7 @@ function Fs({
|
|
|
1922
1927
|
}
|
|
1923
1928
|
) : null
|
|
1924
1929
|
] }) : null,
|
|
1925
|
-
|
|
1930
|
+
d ? /* @__PURE__ */ a("span", { role: "alert", children: d }) : null,
|
|
1926
1931
|
i && e.kind === "image" ? /* @__PURE__ */ a("img", { src: i, alt: e.name ?? "附件图片" }) : null,
|
|
1927
1932
|
i && e.kind === "audio" ? /* @__PURE__ */ a("audio", { src: i, controls: !0 }) : null,
|
|
1928
1933
|
i && e.kind === "video" ? /* @__PURE__ */ a("video", { src: i, controls: !0 }) : null
|
|
@@ -1934,14 +1939,14 @@ function Hs({
|
|
|
1934
1939
|
transport: s,
|
|
1935
1940
|
chatId: n
|
|
1936
1941
|
}) {
|
|
1937
|
-
return /* @__PURE__ */ a(
|
|
1938
|
-
(i,
|
|
1942
|
+
return /* @__PURE__ */ a(Ne, { children: e.parts?.map(
|
|
1943
|
+
(i, o) => i.kind === "text" ? null : i.kind === "unknown" ? /* @__PURE__ */ a(
|
|
1939
1944
|
"span",
|
|
1940
1945
|
{
|
|
1941
1946
|
className: "make-ai-assistant__attachment",
|
|
1942
1947
|
children: i.textFallback ?? "此内容类型暂不支持展示"
|
|
1943
1948
|
},
|
|
1944
|
-
i.id ?? `${e.id}:${
|
|
1949
|
+
i.id ?? `${e.id}:${o}`
|
|
1945
1950
|
) : /* @__PURE__ */ a(
|
|
1946
1951
|
Fs,
|
|
1947
1952
|
{
|
|
@@ -1950,7 +1955,7 @@ function Hs({
|
|
|
1950
1955
|
transport: s,
|
|
1951
1956
|
chatId: n
|
|
1952
1957
|
},
|
|
1953
|
-
i.id ?? `${e.id}:${
|
|
1958
|
+
i.id ?? `${e.id}:${o}`
|
|
1954
1959
|
)
|
|
1955
1960
|
) });
|
|
1956
1961
|
}
|
|
@@ -1967,7 +1972,7 @@ const Kt = (e) => {
|
|
|
1967
1972
|
default:
|
|
1968
1973
|
return `${Math.round(e.progress * 100)}%`;
|
|
1969
1974
|
}
|
|
1970
|
-
},
|
|
1975
|
+
}, js = (e, t) => {
|
|
1971
1976
|
switch (e.status) {
|
|
1972
1977
|
case "uploading":
|
|
1973
1978
|
case "queued":
|
|
@@ -1981,165 +1986,165 @@ const Kt = (e) => {
|
|
|
1981
1986
|
case "ready":
|
|
1982
1987
|
return;
|
|
1983
1988
|
}
|
|
1984
|
-
},
|
|
1985
|
-
const t =
|
|
1989
|
+
}, za = (e) => e.type.split(";")[0].trim().toLowerCase() || "application/octet-stream", Os = (e) => e.startsWith("image/") && e !== "image/svg+xml" ? "image" : e.startsWith("audio/") ? "audio" : e.startsWith("video/") ? "video" : "file", qs = (e) => {
|
|
1990
|
+
const t = za(e);
|
|
1986
1991
|
if (!(!t.startsWith("image/") || t === "image/svg+xml" || typeof URL > "u" || typeof URL.createObjectURL != "function"))
|
|
1987
1992
|
return URL.createObjectURL(e);
|
|
1988
1993
|
}, Wt = (e) => {
|
|
1989
1994
|
e && typeof URL < "u" && typeof URL.revokeObjectURL == "function" && URL.revokeObjectURL(e);
|
|
1990
1995
|
}, Bs = (e, t) => new Promise((s, n) => {
|
|
1991
|
-
const i = new FileReader(),
|
|
1992
|
-
i.abort(),
|
|
1996
|
+
const i = new FileReader(), o = () => t.removeEventListener("abort", d), d = () => {
|
|
1997
|
+
i.abort(), o(), n(Object.assign(new Error("Read aborted"), { name: "AbortError" }));
|
|
1993
1998
|
};
|
|
1994
1999
|
if (t.aborted) {
|
|
1995
|
-
|
|
2000
|
+
d();
|
|
1996
2001
|
return;
|
|
1997
2002
|
}
|
|
1998
|
-
t.addEventListener("abort",
|
|
1999
|
-
|
|
2003
|
+
t.addEventListener("abort", d, { once: !0 }), i.onload = () => {
|
|
2004
|
+
o(), s(new Uint8Array(i.result));
|
|
2000
2005
|
}, i.onerror = () => {
|
|
2001
|
-
|
|
2006
|
+
o(), n(new Error("无法读取文件"));
|
|
2002
2007
|
}, i.readAsArrayBuffer(e);
|
|
2003
2008
|
});
|
|
2004
2009
|
function Vs(e, t, s) {
|
|
2005
|
-
const [n, i] =
|
|
2006
|
-
|
|
2007
|
-
const
|
|
2008
|
-
!
|
|
2010
|
+
const [n, i] = R([]), o = P(/* @__PURE__ */ new Map()), d = P(Promise.resolve()), h = t.scopeKey?.(e) ?? e.app.id, v = P(h);
|
|
2011
|
+
v.current = h;
|
|
2012
|
+
const I = P(void 0), f = s.available && t.features?.attachments === !0 && typeof t.startUpload == "function" && typeof t.getUpload == "function" && typeof t.uploadPart == "function" && typeof t.completeUpload == "function", N = (l, c) => {
|
|
2013
|
+
!o.current.has(l.draft.id) || l.scope !== v.current || (l.draft = { ...l.draft, ...c }, i([...o.current.values()].map((k) => k.draft)));
|
|
2009
2014
|
}, C = () => {
|
|
2010
|
-
for (const
|
|
2011
|
-
|
|
2012
|
-
|
|
2015
|
+
for (const l of o.current.values())
|
|
2016
|
+
l.controller.abort(), Wt(l.draft.previewUrl);
|
|
2017
|
+
o.current.clear(), i([]), I.current = void 0, d.current = Promise.resolve();
|
|
2013
2018
|
};
|
|
2014
|
-
|
|
2015
|
-
|
|
2019
|
+
se(() => (C(), C), [h, t]), se(() => {
|
|
2020
|
+
I.current && s.chat?.chatId !== I.current && C();
|
|
2016
2021
|
}, [s.chat?.chatId]);
|
|
2017
|
-
const
|
|
2018
|
-
const
|
|
2019
|
-
if (
|
|
2022
|
+
const A = async (l) => {
|
|
2023
|
+
const c = l.controller.signal, k = () => {
|
|
2024
|
+
if (c.aborted || l.scope !== v.current || !o.current.has(l.draft.id))
|
|
2020
2025
|
throw Object.assign(new Error("Upload aborted"), {
|
|
2021
2026
|
name: "AbortError"
|
|
2022
2027
|
});
|
|
2023
2028
|
};
|
|
2024
2029
|
try {
|
|
2025
|
-
if (
|
|
2026
|
-
const
|
|
2027
|
-
|
|
2028
|
-
const W =
|
|
2029
|
-
|
|
2030
|
-
let
|
|
2030
|
+
if (k(), l.file.size > 64 << 20) throw new Error("文件不能超过 64 MiB");
|
|
2031
|
+
const E = await s.ensureChat();
|
|
2032
|
+
k(), I.current = E.chatId;
|
|
2033
|
+
const W = za(l.file);
|
|
2034
|
+
N(l, { status: "uploading", error: void 0 });
|
|
2035
|
+
let M = l.draft.upload ? await t.getUpload(
|
|
2031
2036
|
e,
|
|
2032
|
-
{ chatId:
|
|
2033
|
-
{ signal:
|
|
2037
|
+
{ chatId: E.chatId, uploadId: l.draft.upload.id },
|
|
2038
|
+
{ signal: c }
|
|
2034
2039
|
) : await t.startUpload(
|
|
2035
2040
|
e,
|
|
2036
2041
|
{
|
|
2037
|
-
chatId:
|
|
2038
|
-
fileId:
|
|
2039
|
-
name:
|
|
2042
|
+
chatId: E.chatId,
|
|
2043
|
+
fileId: l.draft.fileId,
|
|
2044
|
+
name: l.file.name,
|
|
2040
2045
|
contentType: W,
|
|
2041
|
-
sizeBytes:
|
|
2046
|
+
sizeBytes: l.file.size
|
|
2042
2047
|
},
|
|
2043
|
-
{ signal:
|
|
2048
|
+
{ signal: c }
|
|
2044
2049
|
);
|
|
2045
|
-
if (
|
|
2050
|
+
if (k(), N(l, { upload: M }), M.name !== l.file.name || M.contentType !== W || M.sizeBytes !== l.file.size)
|
|
2046
2051
|
throw new Error("上传文件身份不一致");
|
|
2047
|
-
if (
|
|
2048
|
-
if (
|
|
2052
|
+
if (M.status !== "ready") {
|
|
2053
|
+
if (M = await t.getUpload(
|
|
2049
2054
|
e,
|
|
2050
|
-
{ chatId:
|
|
2051
|
-
{ signal:
|
|
2052
|
-
),
|
|
2053
|
-
const X = new Set(
|
|
2054
|
-
for (let
|
|
2055
|
-
if (
|
|
2056
|
-
const
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
Math.min(
|
|
2055
|
+
{ chatId: E.chatId, uploadId: M.id },
|
|
2056
|
+
{ signal: c }
|
|
2057
|
+
), k(), M.status !== "uploading" || !Number.isSafeInteger(M.partSize) || M.partSize <= 0 || M.partSize > 1 << 20) throw new Error("当前上传状态无法继续,请重新选择文件");
|
|
2058
|
+
const X = new Set(M.completedParts), me = Math.ceil(l.file.size / M.partSize);
|
|
2059
|
+
for (let ee = 0; ee < me; ee += 1) {
|
|
2060
|
+
if (k(), !X.has(ee)) {
|
|
2061
|
+
const he = await Bs(
|
|
2062
|
+
l.file.slice(
|
|
2063
|
+
ee * M.partSize,
|
|
2064
|
+
Math.min(l.file.size, (ee + 1) * M.partSize)
|
|
2060
2065
|
),
|
|
2061
|
-
|
|
2066
|
+
c
|
|
2062
2067
|
);
|
|
2063
|
-
|
|
2068
|
+
k(), await t.uploadPart(
|
|
2064
2069
|
e,
|
|
2065
|
-
{ chatId:
|
|
2066
|
-
{ signal:
|
|
2067
|
-
),
|
|
2070
|
+
{ chatId: E.chatId, uploadId: M.id, part: ee, bytes: he },
|
|
2071
|
+
{ signal: c }
|
|
2072
|
+
), k(), X.add(ee);
|
|
2068
2073
|
}
|
|
2069
|
-
|
|
2074
|
+
N(l, { progress: X.size / Math.max(me, 1) });
|
|
2070
2075
|
}
|
|
2071
|
-
|
|
2076
|
+
N(l, { status: "completing" }), M = await t.completeUpload(
|
|
2072
2077
|
e,
|
|
2073
|
-
{ chatId:
|
|
2074
|
-
{ signal:
|
|
2075
|
-
),
|
|
2078
|
+
{ chatId: E.chatId, uploadId: M.id },
|
|
2079
|
+
{ signal: c }
|
|
2080
|
+
), k();
|
|
2076
2081
|
}
|
|
2077
|
-
if (
|
|
2082
|
+
if (M.status !== "ready" || !M.content)
|
|
2078
2083
|
throw new Error("上传尚未完成");
|
|
2079
|
-
|
|
2080
|
-
} catch (
|
|
2081
|
-
|
|
2082
|
-
status:
|
|
2083
|
-
error:
|
|
2084
|
+
N(l, { status: "ready", progress: 1, upload: M });
|
|
2085
|
+
} catch (E) {
|
|
2086
|
+
N(l, {
|
|
2087
|
+
status: c.aborted ? "paused" : "failed",
|
|
2088
|
+
error: c.aborted ? void 0 : Et(E)
|
|
2084
2089
|
});
|
|
2085
2090
|
}
|
|
2086
|
-
},
|
|
2087
|
-
if (
|
|
2088
|
-
if (
|
|
2091
|
+
}, g = (l) => {
|
|
2092
|
+
if (f) {
|
|
2093
|
+
if (l.length + o.current.size > 32) {
|
|
2089
2094
|
s.setError("每条消息最多包含 32 个附件或文本片段");
|
|
2090
2095
|
return;
|
|
2091
2096
|
}
|
|
2092
|
-
for (const
|
|
2093
|
-
const
|
|
2094
|
-
id:
|
|
2095
|
-
fileId:
|
|
2096
|
-
name:
|
|
2097
|
-
size:
|
|
2097
|
+
for (const c of l) {
|
|
2098
|
+
const k = {
|
|
2099
|
+
id: qe(),
|
|
2100
|
+
fileId: qe(),
|
|
2101
|
+
name: c.name,
|
|
2102
|
+
size: c.size,
|
|
2098
2103
|
status: "queued",
|
|
2099
2104
|
progress: 0,
|
|
2100
|
-
previewUrl:
|
|
2101
|
-
},
|
|
2102
|
-
draft:
|
|
2103
|
-
file:
|
|
2105
|
+
previewUrl: qs(c)
|
|
2106
|
+
}, E = {
|
|
2107
|
+
draft: k,
|
|
2108
|
+
file: c,
|
|
2104
2109
|
controller: new AbortController(),
|
|
2105
|
-
scope:
|
|
2110
|
+
scope: h
|
|
2106
2111
|
};
|
|
2107
|
-
|
|
2112
|
+
o.current.set(k.id, E), d.current = d.current.then(() => A(E));
|
|
2108
2113
|
}
|
|
2109
|
-
i([...
|
|
2114
|
+
i([...o.current.values()].map((c) => c.draft));
|
|
2110
2115
|
}
|
|
2111
|
-
},
|
|
2112
|
-
const
|
|
2113
|
-
!
|
|
2114
|
-
},
|
|
2115
|
-
const
|
|
2116
|
-
|
|
2117
|
-
}, H = (
|
|
2118
|
-
const
|
|
2119
|
-
if (
|
|
2120
|
-
const
|
|
2116
|
+
}, F = (l) => {
|
|
2117
|
+
const c = o.current.get(l);
|
|
2118
|
+
!c || !["paused", "failed"].includes(c.draft.status) || (c.controller = new AbortController(), N(c, { status: "queued" }), d.current = d.current.then(() => A(c)));
|
|
2119
|
+
}, T = (l) => {
|
|
2120
|
+
const c = o.current.get(l);
|
|
2121
|
+
c?.controller.abort(), Wt(c?.draft.previewUrl), o.current.delete(l), i([...o.current.values()].map((k) => k.draft));
|
|
2122
|
+
}, H = (l) => o.current.get(l)?.controller.abort(), b = n.flatMap((l) => {
|
|
2123
|
+
const c = l.upload;
|
|
2124
|
+
if (l.status !== "ready" || !c?.content) return [];
|
|
2125
|
+
const k = Os(c.contentType);
|
|
2121
2126
|
return [
|
|
2122
2127
|
{
|
|
2123
|
-
id:
|
|
2124
|
-
kind:
|
|
2125
|
-
name:
|
|
2128
|
+
id: l.id,
|
|
2129
|
+
kind: k,
|
|
2130
|
+
name: c.name,
|
|
2126
2131
|
media: {
|
|
2127
|
-
contentRef:
|
|
2128
|
-
contentType:
|
|
2129
|
-
sizeBytes:
|
|
2130
|
-
digestSha256:
|
|
2132
|
+
contentRef: c.content.contentRef,
|
|
2133
|
+
contentType: c.contentType,
|
|
2134
|
+
sizeBytes: c.content.sizeBytes,
|
|
2135
|
+
digestSha256: c.content.digestSha256
|
|
2131
2136
|
}
|
|
2132
2137
|
}
|
|
2133
2138
|
];
|
|
2134
2139
|
});
|
|
2135
2140
|
return {
|
|
2136
|
-
enabled:
|
|
2141
|
+
enabled: f,
|
|
2137
2142
|
drafts: n,
|
|
2138
|
-
parts:
|
|
2139
|
-
pending: n.some((
|
|
2140
|
-
add:
|
|
2141
|
-
retry:
|
|
2142
|
-
remove:
|
|
2143
|
+
parts: b,
|
|
2144
|
+
pending: n.some((l) => l.status !== "ready"),
|
|
2145
|
+
add: g,
|
|
2146
|
+
retry: F,
|
|
2147
|
+
remove: T,
|
|
2143
2148
|
pause: H,
|
|
2144
2149
|
clear: C
|
|
2145
2150
|
};
|
|
@@ -2150,21 +2155,21 @@ function Ks({
|
|
|
2150
2155
|
open: s,
|
|
2151
2156
|
triggerRef: n
|
|
2152
2157
|
}) {
|
|
2153
|
-
const i =
|
|
2154
|
-
|
|
2158
|
+
const i = P(null), o = P(null);
|
|
2159
|
+
se(() => {
|
|
2155
2160
|
if (!s) return;
|
|
2156
|
-
const
|
|
2157
|
-
const
|
|
2158
|
-
|
|
2161
|
+
const h = (v) => {
|
|
2162
|
+
const I = v.target;
|
|
2163
|
+
I instanceof Node && !i.current?.contains(I) && t(!1);
|
|
2159
2164
|
};
|
|
2160
|
-
return document.addEventListener("pointerdown",
|
|
2161
|
-
document.removeEventListener("pointerdown",
|
|
2165
|
+
return document.addEventListener("pointerdown", h), () => {
|
|
2166
|
+
document.removeEventListener("pointerdown", h);
|
|
2162
2167
|
};
|
|
2163
2168
|
}, [t, s]);
|
|
2164
|
-
const
|
|
2165
|
-
e.add(Array.from(
|
|
2169
|
+
const d = (h) => {
|
|
2170
|
+
e.add(Array.from(h.files ?? [])), h.value = "", t(!1);
|
|
2166
2171
|
};
|
|
2167
|
-
return /* @__PURE__ */
|
|
2172
|
+
return /* @__PURE__ */ m("div", { className: "make-ai-assistant__attachment-composer", ref: i, children: [
|
|
2168
2173
|
/* @__PURE__ */ a(
|
|
2169
2174
|
"button",
|
|
2170
2175
|
{
|
|
@@ -2191,12 +2196,12 @@ function Ks({
|
|
|
2191
2196
|
"aria-label": "附件选项",
|
|
2192
2197
|
className: "make-ai-assistant__attachment-menu",
|
|
2193
2198
|
role: "menu",
|
|
2194
|
-
children: /* @__PURE__ */
|
|
2199
|
+
children: /* @__PURE__ */ m(
|
|
2195
2200
|
"button",
|
|
2196
2201
|
{
|
|
2197
2202
|
role: "menuitem",
|
|
2198
2203
|
type: "button",
|
|
2199
|
-
onClick: () =>
|
|
2204
|
+
onClick: () => o.current?.click(),
|
|
2200
2205
|
children: [
|
|
2201
2206
|
/* @__PURE__ */ a(zs, { "aria-hidden": "true" }),
|
|
2202
2207
|
/* @__PURE__ */ a("span", { children: "上传文件或图片" })
|
|
@@ -2211,9 +2216,9 @@ function Ks({
|
|
|
2211
2216
|
"aria-label": "上传文件或图片",
|
|
2212
2217
|
hidden: !0,
|
|
2213
2218
|
multiple: !0,
|
|
2214
|
-
ref:
|
|
2219
|
+
ref: o,
|
|
2215
2220
|
type: "file",
|
|
2216
|
-
onChange: (
|
|
2221
|
+
onChange: (h) => d(h.currentTarget)
|
|
2217
2222
|
}
|
|
2218
2223
|
)
|
|
2219
2224
|
] });
|
|
@@ -2222,96 +2227,96 @@ function Ws({
|
|
|
2222
2227
|
attachments: e,
|
|
2223
2228
|
visible: t
|
|
2224
2229
|
}) {
|
|
2225
|
-
const [s, n] =
|
|
2226
|
-
n(void 0),
|
|
2230
|
+
const [s, n] = R(), i = e.drafts.find((f) => f.id === s), o = !!i, d = P(null), h = P(null), v = Ka(() => {
|
|
2231
|
+
n(void 0), h.current?.focus();
|
|
2227
2232
|
}, []);
|
|
2228
|
-
if (
|
|
2229
|
-
if (!
|
|
2230
|
-
const
|
|
2231
|
-
|
|
2233
|
+
if (se(() => {
|
|
2234
|
+
if (!o) return;
|
|
2235
|
+
const f = (N) => {
|
|
2236
|
+
N.key === "Escape" && (N.preventDefault(), N.stopImmediatePropagation(), v());
|
|
2232
2237
|
};
|
|
2233
|
-
return document.addEventListener("keydown",
|
|
2234
|
-
}, [
|
|
2238
|
+
return document.addEventListener("keydown", f, !0), () => document.removeEventListener("keydown", f, !0);
|
|
2239
|
+
}, [v, o]), se(() => {
|
|
2235
2240
|
t || n(void 0);
|
|
2236
2241
|
}, [t]), !e.drafts.length) return null;
|
|
2237
|
-
const
|
|
2238
|
-
return /* @__PURE__ */
|
|
2242
|
+
const I = typeof document > "u" ? void 0 : d.current?.closest(".make-ai-assistant") ?? document.body;
|
|
2243
|
+
return /* @__PURE__ */ m(
|
|
2239
2244
|
"div",
|
|
2240
2245
|
{
|
|
2241
2246
|
"aria-label": "待发送附件",
|
|
2242
2247
|
className: "make-ai-assistant__attachment-drafts",
|
|
2243
|
-
ref:
|
|
2248
|
+
ref: d,
|
|
2244
2249
|
children: [
|
|
2245
|
-
/* @__PURE__ */ a("ul", { children: e.drafts.map((
|
|
2246
|
-
const
|
|
2247
|
-
return /* @__PURE__ */
|
|
2250
|
+
/* @__PURE__ */ a("ul", { children: e.drafts.map((f) => {
|
|
2251
|
+
const N = Kt(f), C = js(f, N);
|
|
2252
|
+
return /* @__PURE__ */ m(
|
|
2248
2253
|
"li",
|
|
2249
2254
|
{
|
|
2250
|
-
"aria-label": `${
|
|
2251
|
-
"data-status":
|
|
2255
|
+
"aria-label": `${f.name},${N}`,
|
|
2256
|
+
"data-status": f.status,
|
|
2252
2257
|
children: [
|
|
2253
|
-
|
|
2258
|
+
f.previewUrl ? /* @__PURE__ */ a(
|
|
2254
2259
|
"button",
|
|
2255
2260
|
{
|
|
2256
|
-
"aria-label": `预览附件 ${
|
|
2261
|
+
"aria-label": `预览附件 ${f.name}`,
|
|
2257
2262
|
className: "make-ai-assistant__attachment-draft-preview-button",
|
|
2258
2263
|
type: "button",
|
|
2259
|
-
onClick: (
|
|
2260
|
-
|
|
2264
|
+
onClick: (A) => {
|
|
2265
|
+
h.current = A.currentTarget, n(f.id);
|
|
2261
2266
|
},
|
|
2262
2267
|
children: /* @__PURE__ */ a(
|
|
2263
2268
|
"img",
|
|
2264
2269
|
{
|
|
2265
2270
|
alt: "",
|
|
2266
2271
|
className: "make-ai-assistant__attachment-draft-preview",
|
|
2267
|
-
src:
|
|
2272
|
+
src: f.previewUrl
|
|
2268
2273
|
}
|
|
2269
2274
|
)
|
|
2270
2275
|
}
|
|
2271
2276
|
) : /* @__PURE__ */ a(
|
|
2272
2277
|
"button",
|
|
2273
2278
|
{
|
|
2274
|
-
"aria-label": `查看附件详情 ${
|
|
2279
|
+
"aria-label": `查看附件详情 ${f.name}`,
|
|
2275
2280
|
className: "make-ai-assistant__attachment-draft-file",
|
|
2276
2281
|
type: "button",
|
|
2277
|
-
onClick: (
|
|
2278
|
-
|
|
2282
|
+
onClick: (A) => {
|
|
2283
|
+
h.current = A.currentTarget, n(f.id);
|
|
2279
2284
|
},
|
|
2280
|
-
children: /* @__PURE__ */ a(
|
|
2285
|
+
children: /* @__PURE__ */ a(jt, { "aria-hidden": "true" })
|
|
2281
2286
|
}
|
|
2282
2287
|
),
|
|
2283
2288
|
C ? /* @__PURE__ */ a("span", { "aria-hidden": "true", className: "make-ai-assistant__attachment-draft-status", children: C }) : null,
|
|
2284
|
-
|
|
2285
|
-
|
|
2289
|
+
f.error ? /* @__PURE__ */ a("span", { className: "make-ai-assistant__attachment-draft-error", role: "alert", children: f.error }) : null,
|
|
2290
|
+
f.status === "failed" || f.status === "paused" ? /* @__PURE__ */ a(
|
|
2286
2291
|
"button",
|
|
2287
2292
|
{
|
|
2288
|
-
"aria-label": `重试上传 ${
|
|
2293
|
+
"aria-label": `重试上传 ${f.name}`,
|
|
2289
2294
|
className: "make-ai-assistant__attachment-draft-control",
|
|
2290
2295
|
title: "重试上传",
|
|
2291
2296
|
type: "button",
|
|
2292
|
-
onClick: () => e.retry(
|
|
2297
|
+
onClick: () => e.retry(f.id),
|
|
2293
2298
|
children: /* @__PURE__ */ a($s, { "aria-hidden": "true" })
|
|
2294
2299
|
}
|
|
2295
2300
|
) : null,
|
|
2296
|
-
|
|
2301
|
+
f.status === "uploading" ? /* @__PURE__ */ a(
|
|
2297
2302
|
"button",
|
|
2298
2303
|
{
|
|
2299
|
-
"aria-label": `暂停上传 ${
|
|
2304
|
+
"aria-label": `暂停上传 ${f.name}`,
|
|
2300
2305
|
className: "make-ai-assistant__attachment-draft-control",
|
|
2301
2306
|
title: "暂停上传",
|
|
2302
2307
|
type: "button",
|
|
2303
|
-
onClick: () => e.pause(
|
|
2308
|
+
onClick: () => e.pause(f.id),
|
|
2304
2309
|
children: /* @__PURE__ */ a(Ms, { "aria-hidden": "true" })
|
|
2305
2310
|
}
|
|
2306
2311
|
) : null,
|
|
2307
2312
|
/* @__PURE__ */ a(
|
|
2308
2313
|
"button",
|
|
2309
2314
|
{
|
|
2310
|
-
"aria-label": `移除附件 ${
|
|
2315
|
+
"aria-label": `移除附件 ${f.name}`,
|
|
2311
2316
|
className: "make-ai-assistant__attachment-draft-remove",
|
|
2312
2317
|
type: "button",
|
|
2313
2318
|
onClick: () => {
|
|
2314
|
-
s ===
|
|
2319
|
+
s === f.id && v(), e.remove(f.id);
|
|
2315
2320
|
},
|
|
2316
2321
|
children: /* @__PURE__ */ a(
|
|
2317
2322
|
tt,
|
|
@@ -2324,18 +2329,18 @@ function Ws({
|
|
|
2324
2329
|
)
|
|
2325
2330
|
]
|
|
2326
2331
|
},
|
|
2327
|
-
|
|
2332
|
+
f.id
|
|
2328
2333
|
);
|
|
2329
2334
|
}) }),
|
|
2330
|
-
i &&
|
|
2335
|
+
i && I ? aa(
|
|
2331
2336
|
/* @__PURE__ */ a(
|
|
2332
2337
|
"div",
|
|
2333
2338
|
{
|
|
2334
2339
|
className: "make-ai-assistant__attachment-preview-backdrop",
|
|
2335
|
-
onPointerDown: (
|
|
2336
|
-
|
|
2340
|
+
onPointerDown: (f) => {
|
|
2341
|
+
f.target === f.currentTarget && v();
|
|
2337
2342
|
},
|
|
2338
|
-
children: /* @__PURE__ */
|
|
2343
|
+
children: /* @__PURE__ */ m(
|
|
2339
2344
|
"div",
|
|
2340
2345
|
{
|
|
2341
2346
|
"aria-label": `${i.previewUrl ? "预览附件" : "附件详情"} ${i.name}`,
|
|
@@ -2343,8 +2348,8 @@ function Ws({
|
|
|
2343
2348
|
className: "make-ai-assistant__attachment-preview-dialog",
|
|
2344
2349
|
"data-kind": i.previewUrl ? "image" : "file",
|
|
2345
2350
|
role: "dialog",
|
|
2346
|
-
onKeyDown: (
|
|
2347
|
-
|
|
2351
|
+
onKeyDown: (f) => {
|
|
2352
|
+
f.key === "Tab" && f.preventDefault();
|
|
2348
2353
|
},
|
|
2349
2354
|
children: [
|
|
2350
2355
|
/* @__PURE__ */ a(
|
|
@@ -2354,7 +2359,7 @@ function Ws({
|
|
|
2354
2359
|
autoFocus: !0,
|
|
2355
2360
|
className: "make-ai-assistant__attachment-preview-close",
|
|
2356
2361
|
type: "button",
|
|
2357
|
-
onClick:
|
|
2362
|
+
onClick: v,
|
|
2358
2363
|
children: /* @__PURE__ */ a(
|
|
2359
2364
|
tt,
|
|
2360
2365
|
{
|
|
@@ -2364,8 +2369,8 @@ function Ws({
|
|
|
2364
2369
|
)
|
|
2365
2370
|
}
|
|
2366
2371
|
),
|
|
2367
|
-
i.previewUrl ? /* @__PURE__ */ a("img", { alt: i.name, src: i.previewUrl }) : /* @__PURE__ */ a("div", { "aria-hidden": "true", className: "make-ai-assistant__attachment-preview-file", children: /* @__PURE__ */ a(
|
|
2368
|
-
/* @__PURE__ */
|
|
2372
|
+
i.previewUrl ? /* @__PURE__ */ a("img", { alt: i.name, src: i.previewUrl }) : /* @__PURE__ */ a("div", { "aria-hidden": "true", className: "make-ai-assistant__attachment-preview-file", children: /* @__PURE__ */ a(jt, {}) }),
|
|
2373
|
+
/* @__PURE__ */ m("div", { className: "make-ai-assistant__attachment-preview-details", children: [
|
|
2369
2374
|
/* @__PURE__ */ a("strong", { children: i.name }),
|
|
2370
2375
|
/* @__PURE__ */ a("span", { children: Kt(i) }),
|
|
2371
2376
|
i.error ? /* @__PURE__ */ a("p", { children: i.error }) : null
|
|
@@ -2375,7 +2380,7 @@ function Ws({
|
|
|
2375
2380
|
)
|
|
2376
2381
|
}
|
|
2377
2382
|
),
|
|
2378
|
-
|
|
2383
|
+
I
|
|
2379
2384
|
) : null
|
|
2380
2385
|
]
|
|
2381
2386
|
}
|
|
@@ -2385,27 +2390,27 @@ const Xs = (e) => `${e}-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`
|
|
|
2385
2390
|
"总结当前页面数据",
|
|
2386
2391
|
"找出需要关注的记录",
|
|
2387
2392
|
"列出我有权限查看的数据对象"
|
|
2388
|
-
], Js = 48, Ys = 160,
|
|
2393
|
+
], Js = 48, Ys = 160, xa = (e, t) => t ?? `${e?.trim() || Gs} AI 助手`, Qs = (e) => e ?? Zs, en = (e) => typeof e == "number" && Number.isFinite(e) && e > 0 ? e : void 0, tn = (e) => typeof e == "number" ? Number.isFinite(e) ? `${e}px` : void 0 : e?.trim() || void 0;
|
|
2389
2394
|
class J extends Error {
|
|
2390
2395
|
}
|
|
2391
|
-
const
|
|
2396
|
+
const dt = (e, t) => {
|
|
2392
2397
|
if (!(typeof e != "object" || e === null))
|
|
2393
2398
|
return e[t];
|
|
2394
2399
|
}, an = (e) => {
|
|
2395
|
-
const t =
|
|
2396
|
-
return typeof t == "number" ? t :
|
|
2397
|
-
|
|
2400
|
+
const t = dt(e, "status");
|
|
2401
|
+
return typeof t == "number" ? t : dt(
|
|
2402
|
+
dt(e, "response"),
|
|
2398
2403
|
"status"
|
|
2399
2404
|
);
|
|
2400
2405
|
}, sn = (e) => {
|
|
2401
|
-
const t =
|
|
2402
|
-
return
|
|
2406
|
+
const t = dt(e, "code"), s = an(e), n = e instanceof Error ? e.message : "", i = [t, n].filter((v) => typeof v == "string").join(" ").toLowerCase(), d = globalThis.navigator?.onLine === !1 || /network|fetch|timeout|offline|connection|网络|连接|超时/.test(i), h = typeof s == "number" && s >= 500 || /server|service|服务器|服务异常/.test(i);
|
|
2407
|
+
return d ? {
|
|
2403
2408
|
actionLabel: "重新连接",
|
|
2404
2409
|
description: "请检查网络后再试。",
|
|
2405
2410
|
kind: "network",
|
|
2406
2411
|
label: "网络连接",
|
|
2407
2412
|
title: "网络连接不可用"
|
|
2408
|
-
} :
|
|
2413
|
+
} : h ? {
|
|
2409
2414
|
actionLabel: "重新加载",
|
|
2410
2415
|
description: "服务暂时未能响应,请稍后重试。",
|
|
2411
2416
|
kind: "service",
|
|
@@ -2444,12 +2449,12 @@ const pt = (e, t) => {
|
|
|
2444
2449
|
const s = document.execCommand("copy");
|
|
2445
2450
|
if (t.remove(), !s)
|
|
2446
2451
|
throw new Error("Clipboard copy failed");
|
|
2447
|
-
},
|
|
2452
|
+
}, ut = ({ className: e = "" }) => /* @__PURE__ */ a("span", { className: `make-ai-assistant__avatar ${e}`.trim(), "aria-hidden": "true", children: /* @__PURE__ */ a(Ma, { "aria-hidden": "true" }) }), rn = ({ src: e }) => e ? /* @__PURE__ */ a("span", { className: "make-ai-assistant__user-avatar", "aria-hidden": "true", children: /* @__PURE__ */ a("img", { alt: "", src: e }) }) : null, on = ({
|
|
2448
2453
|
userAvatarUrl: e,
|
|
2449
2454
|
userName: t
|
|
2450
2455
|
}) => {
|
|
2451
2456
|
const s = t?.trim();
|
|
2452
|
-
return !s && !e ? null : /* @__PURE__ */
|
|
2457
|
+
return !s && !e ? null : /* @__PURE__ */ m("div", { className: "make-ai-assistant__message-identity", children: [
|
|
2453
2458
|
s ? /* @__PURE__ */ a("span", { className: "make-ai-assistant__message-sender", children: s }) : null,
|
|
2454
2459
|
/* @__PURE__ */ a(rn, { src: e })
|
|
2455
2460
|
] });
|
|
@@ -2462,67 +2467,80 @@ const pt = (e, t) => {
|
|
|
2462
2467
|
if (!s || !n || s.length !== n.length || !cn(n))
|
|
2463
2468
|
return;
|
|
2464
2469
|
const i = [];
|
|
2465
|
-
let
|
|
2466
|
-
for (;
|
|
2467
|
-
const
|
|
2468
|
-
if (!
|
|
2469
|
-
i.push(
|
|
2470
|
+
let o = t + 2;
|
|
2471
|
+
for (; o < e.length; ) {
|
|
2472
|
+
const d = wt(e[o] ?? "");
|
|
2473
|
+
if (!d || d.length !== s.length) break;
|
|
2474
|
+
i.push(d), o += 1;
|
|
2470
2475
|
}
|
|
2471
|
-
return { headers: s, lastIndex:
|
|
2476
|
+
return { headers: s, lastIndex: o - 1, rows: i };
|
|
2472
2477
|
}, dn = (e) => {
|
|
2473
|
-
const t = [], s = [], n = [], i = [],
|
|
2478
|
+
const t = [], s = [], n = [], i = [], o = [], d = e.replace(/\r\n?/g, `
|
|
2474
2479
|
`).split(`
|
|
2475
|
-
`)
|
|
2476
|
-
|
|
2480
|
+
`);
|
|
2481
|
+
let h;
|
|
2482
|
+
const v = () => {
|
|
2483
|
+
const N = s.join(`
|
|
2477
2484
|
`).trim();
|
|
2478
|
-
s.length = 0,
|
|
2479
|
-
},
|
|
2485
|
+
s.length = 0, N && t.push({ type: "paragraph", text: N });
|
|
2486
|
+
}, I = () => {
|
|
2480
2487
|
n.length && t.push({ type: "list", items: n.splice(0) });
|
|
2481
|
-
},
|
|
2482
|
-
const
|
|
2488
|
+
}, f = () => {
|
|
2489
|
+
const N = i.join(`
|
|
2483
2490
|
`).trim();
|
|
2484
|
-
i.length = 0,
|
|
2491
|
+
i.length = 0, N && t.push({ type: "pre", text: N });
|
|
2485
2492
|
};
|
|
2486
|
-
for (let
|
|
2487
|
-
const
|
|
2488
|
-
if (
|
|
2489
|
-
|
|
2493
|
+
for (let N = 0; N < d.length; N += 1) {
|
|
2494
|
+
const C = d[N] ?? "", A = /^ {0,3}(`{3,}|~{3,})(.*)$/.exec(C);
|
|
2495
|
+
if (h) {
|
|
2496
|
+
A && A[1]?.[0] === h.marker && A[1].length >= h.length && !A[2]?.trim() ? (t.push({ type: "pre", text: o.join(`
|
|
2497
|
+
`) }), o.length = 0, h = void 0) : o.push(C);
|
|
2498
|
+
continue;
|
|
2499
|
+
}
|
|
2500
|
+
if (A && (A[1]?.[0] === "~" || !A[2]?.includes("`"))) {
|
|
2501
|
+
v(), I(), f(), h = { marker: A[1]?.[0] ?? "`", length: A[1]?.length ?? 3 };
|
|
2490
2502
|
continue;
|
|
2491
2503
|
}
|
|
2492
|
-
const
|
|
2493
|
-
if (
|
|
2494
|
-
|
|
2504
|
+
const g = C.trim();
|
|
2505
|
+
if (!g) {
|
|
2506
|
+
v(), I(), f();
|
|
2495
2507
|
continue;
|
|
2496
2508
|
}
|
|
2497
|
-
const
|
|
2498
|
-
if (
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2509
|
+
const F = ln(d, N);
|
|
2510
|
+
if (F) {
|
|
2511
|
+
v(), I(), f(), t.push({ headers: F.headers, rows: F.rows, type: "table" }), N = F.lastIndex;
|
|
2512
|
+
continue;
|
|
2513
|
+
}
|
|
2514
|
+
const T = /^(#{1,6})\s+(.+)$/.exec(g);
|
|
2515
|
+
if (T) {
|
|
2516
|
+
v(), I(), f();
|
|
2517
|
+
const b = (T[2] ?? "").replace(/\s+#+\s*$/, "").trim();
|
|
2518
|
+
b && t.push({
|
|
2502
2519
|
type: "heading",
|
|
2503
|
-
level:
|
|
2504
|
-
text:
|
|
2520
|
+
level: T[1]?.length,
|
|
2521
|
+
text: b
|
|
2505
2522
|
});
|
|
2506
2523
|
continue;
|
|
2507
2524
|
}
|
|
2508
|
-
if (/^\s*\|.+\|\s*$/.test(
|
|
2509
|
-
|
|
2525
|
+
if (/^\s*\|.+\|\s*$/.test(C)) {
|
|
2526
|
+
v(), I(), i.push(C.trim());
|
|
2510
2527
|
continue;
|
|
2511
2528
|
}
|
|
2512
|
-
const
|
|
2513
|
-
if (
|
|
2514
|
-
|
|
2529
|
+
const H = /^\s*[-*]\s+(.+)$/.exec(C);
|
|
2530
|
+
if (H) {
|
|
2531
|
+
v(), f(), n.push(H[1]?.trim() ?? "");
|
|
2515
2532
|
continue;
|
|
2516
2533
|
}
|
|
2517
|
-
|
|
2534
|
+
I(), f(), s.push(g);
|
|
2518
2535
|
}
|
|
2519
|
-
return
|
|
2536
|
+
return v(), I(), f(), h && t.push({ type: "pre", text: o.join(`
|
|
2537
|
+
`) }), t;
|
|
2520
2538
|
}, et = (e) => {
|
|
2521
2539
|
const t = [], s = /(\*\*[^*]+\*\*|`[^`]+`)/g;
|
|
2522
2540
|
let n = 0;
|
|
2523
2541
|
for (const i of e.matchAll(s)) {
|
|
2524
|
-
const
|
|
2525
|
-
|
|
2542
|
+
const o = i[0], d = i.index ?? 0;
|
|
2543
|
+
d > n && t.push(e.slice(n, d)), o.startsWith("**") ? t.push(/* @__PURE__ */ a("strong", { children: o.slice(2, -2) }, `${d}-strong`)) : t.push(/* @__PURE__ */ a("code", { children: o.slice(1, -1) }, `${d}-code`)), n = d + o.length;
|
|
2526
2544
|
}
|
|
2527
2545
|
return n < e.length && t.push(e.slice(n)), t;
|
|
2528
2546
|
}, Gt = ({ content: e }) => {
|
|
@@ -2539,25 +2557,25 @@ const pt = (e, t) => {
|
|
|
2539
2557
|
`${n}-heading`
|
|
2540
2558
|
);
|
|
2541
2559
|
}
|
|
2542
|
-
return s.type === "paragraph" ? /* @__PURE__ */ a("p", { children: et(s.text) }, `${n}-paragraph`) : s.type === "pre" ? /* @__PURE__ */ a("pre", { children: /* @__PURE__ */ a("code", { children: s.text }) }, `${n}-pre`) : s.type === "table" ? /* @__PURE__ */ a(
|
|
2560
|
+
return s.type === "paragraph" ? /* @__PURE__ */ a("p", { children: et(s.text) }, `${n}-paragraph`) : s.type === "pre" ? /* @__PURE__ */ a("pre", { "aria-label": "代码块,可横向滚动", role: "region", tabIndex: 0, children: /* @__PURE__ */ a("code", { children: s.text }) }, `${n}-pre`) : s.type === "table" ? /* @__PURE__ */ a(
|
|
2543
2561
|
"div",
|
|
2544
2562
|
{
|
|
2545
2563
|
"aria-label": "表格内容,可横向滚动",
|
|
2546
2564
|
className: "make-ai-assistant__markdown-table-scroll",
|
|
2547
2565
|
role: "region",
|
|
2548
2566
|
tabIndex: 0,
|
|
2549
|
-
children: /* @__PURE__ */
|
|
2550
|
-
/* @__PURE__ */ a("thead", { children: /* @__PURE__ */ a("tr", { children: s.headers.map((i,
|
|
2551
|
-
/* @__PURE__ */ a("tbody", { children: s.rows.map((i,
|
|
2567
|
+
children: /* @__PURE__ */ m("table", { className: "make-ai-assistant__markdown-table", children: [
|
|
2568
|
+
/* @__PURE__ */ a("thead", { children: /* @__PURE__ */ a("tr", { children: s.headers.map((i, o) => /* @__PURE__ */ a("th", { scope: "col", children: et(i) }, `${o}-${i}`)) }) }),
|
|
2569
|
+
/* @__PURE__ */ a("tbody", { children: s.rows.map((i, o) => /* @__PURE__ */ a("tr", { children: i.map((d, h) => /* @__PURE__ */ a("td", { children: et(d) }, `${h}-${d}`)) }, `${o}-${i.join("|")}`)) })
|
|
2552
2570
|
] })
|
|
2553
2571
|
},
|
|
2554
2572
|
`${n}-table`
|
|
2555
|
-
) : /* @__PURE__ */ a("ul", { children: s.items.map((i,
|
|
2573
|
+
) : /* @__PURE__ */ a("ul", { children: s.items.map((i, o) => /* @__PURE__ */ a("li", { children: et(i) }, `${o}-${i}`)) }, `${n}-list`);
|
|
2556
2574
|
}) }) : null;
|
|
2557
|
-
},
|
|
2558
|
-
/* @__PURE__ */ a(
|
|
2575
|
+
}, Da = ({ assistantName: e }) => /* @__PURE__ */ m("div", { className: "make-ai-assistant__message-identity", children: [
|
|
2576
|
+
/* @__PURE__ */ a(ut, { className: "make-ai-assistant__avatar--message" }),
|
|
2559
2577
|
/* @__PURE__ */ a("span", { className: "make-ai-assistant__message-sender", children: e })
|
|
2560
|
-
] }),
|
|
2578
|
+
] }), Pa = (e) => {
|
|
2561
2579
|
for (let t = e.messages.length - 1; t >= 0; t -= 1) {
|
|
2562
2580
|
const s = e.messages[t];
|
|
2563
2581
|
if (s.role === "assistant" && s.status === "streaming")
|
|
@@ -2567,7 +2585,7 @@ const pt = (e, t) => {
|
|
|
2567
2585
|
for (let t = e.messages.length - 1; t >= 0; t -= 1)
|
|
2568
2586
|
if (e.messages[t].role === "user") return t;
|
|
2569
2587
|
return -1;
|
|
2570
|
-
},
|
|
2588
|
+
}, Ua = (e) => {
|
|
2571
2589
|
const t = un(e);
|
|
2572
2590
|
if (!(t < 0))
|
|
2573
2591
|
for (let s = e.messages.length - 1; s > t; s -= 1) {
|
|
@@ -2586,7 +2604,7 @@ const pt = (e, t) => {
|
|
|
2586
2604
|
const s = e.messages[t];
|
|
2587
2605
|
if (s.role === "user") return s;
|
|
2588
2606
|
}
|
|
2589
|
-
},
|
|
2607
|
+
}, fn = (e, t) => {
|
|
2590
2608
|
const s = e.messages.findIndex(
|
|
2591
2609
|
(n) => n.id === t && n.role === "user"
|
|
2592
2610
|
);
|
|
@@ -2597,31 +2615,31 @@ const pt = (e, t) => {
|
|
|
2597
2615
|
status: "streaming",
|
|
2598
2616
|
messages: s < 0 ? e.messages : e.messages.slice(0, s + 1)
|
|
2599
2617
|
};
|
|
2600
|
-
},
|
|
2618
|
+
}, pn = (e) => e.scrollHeight - e.scrollTop - e.clientHeight <= 48, Zt = (e = "smooth") => globalThis.matchMedia?.("(prefers-reduced-motion: reduce)").matches ? "auto" : e, It = (e, t) => {
|
|
2601
2619
|
typeof e.scrollTo == "function" ? e.scrollTo({ top: e.scrollHeight, behavior: t }) : e.scrollTop = e.scrollHeight;
|
|
2602
|
-
},
|
|
2620
|
+
}, Fa = ({
|
|
2603
2621
|
error: e,
|
|
2604
2622
|
onRetry: t
|
|
2605
|
-
}) => /* @__PURE__ */
|
|
2623
|
+
}) => /* @__PURE__ */ m(
|
|
2606
2624
|
"div",
|
|
2607
2625
|
{
|
|
2608
2626
|
className: "make-ai-assistant__message-status make-ai-assistant__message-status--error",
|
|
2609
2627
|
"data-error-presentation": "request-failed",
|
|
2610
2628
|
role: "alert",
|
|
2611
2629
|
children: [
|
|
2612
|
-
/* @__PURE__ */
|
|
2613
|
-
/* @__PURE__ */ a("span", { className: "make-ai-assistant__message-status-icon", "aria-hidden": "true", children: /* @__PURE__ */ a(
|
|
2630
|
+
/* @__PURE__ */ m("div", { className: "make-ai-assistant__message-status-header", children: [
|
|
2631
|
+
/* @__PURE__ */ a("span", { className: "make-ai-assistant__message-status-icon", "aria-hidden": "true", children: /* @__PURE__ */ a(ua, { "aria-hidden": "true" }) }),
|
|
2614
2632
|
/* @__PURE__ */ a("strong", { children: "请求未完成" })
|
|
2615
2633
|
] }),
|
|
2616
2634
|
/* @__PURE__ */ a("span", { className: "make-ai-assistant__message-status-message", children: e.message }),
|
|
2617
|
-
e.retryable && t ? /* @__PURE__ */
|
|
2635
|
+
e.retryable && t ? /* @__PURE__ */ m(
|
|
2618
2636
|
"button",
|
|
2619
2637
|
{
|
|
2620
2638
|
className: "make-ai-assistant__retry",
|
|
2621
2639
|
type: "button",
|
|
2622
2640
|
onClick: t,
|
|
2623
2641
|
children: [
|
|
2624
|
-
/* @__PURE__ */ a(
|
|
2642
|
+
/* @__PURE__ */ a(mt, { "aria-hidden": "true" }),
|
|
2625
2643
|
"重新发送"
|
|
2626
2644
|
]
|
|
2627
2645
|
}
|
|
@@ -2633,7 +2651,7 @@ const pt = (e, t) => {
|
|
|
2633
2651
|
onRetry: t
|
|
2634
2652
|
}) => {
|
|
2635
2653
|
const s = sn(e);
|
|
2636
|
-
return /* @__PURE__ */
|
|
2654
|
+
return /* @__PURE__ */ m(
|
|
2637
2655
|
"section",
|
|
2638
2656
|
{
|
|
2639
2657
|
"aria-live": "assertive",
|
|
@@ -2642,19 +2660,19 @@ const pt = (e, t) => {
|
|
|
2642
2660
|
role: "alert",
|
|
2643
2661
|
children: [
|
|
2644
2662
|
/* @__PURE__ */ a("span", { className: "make-ai-assistant__load-failure-icon", "aria-hidden": "true", children: /* @__PURE__ */ a(_s, { "aria-hidden": "true" }) }),
|
|
2645
|
-
/* @__PURE__ */
|
|
2663
|
+
/* @__PURE__ */ m("div", { className: "make-ai-assistant__load-failure-copy", children: [
|
|
2646
2664
|
/* @__PURE__ */ a("span", { className: "make-ai-assistant__load-failure-label", children: s.label }),
|
|
2647
2665
|
/* @__PURE__ */ a("h3", { children: s.title }),
|
|
2648
2666
|
/* @__PURE__ */ a("p", { children: s.description })
|
|
2649
2667
|
] }),
|
|
2650
|
-
/* @__PURE__ */
|
|
2668
|
+
/* @__PURE__ */ m(
|
|
2651
2669
|
"button",
|
|
2652
2670
|
{
|
|
2653
2671
|
className: "make-ai-assistant__retry make-ai-assistant__retry--primary",
|
|
2654
2672
|
type: "button",
|
|
2655
2673
|
onClick: t,
|
|
2656
2674
|
children: [
|
|
2657
|
-
/* @__PURE__ */ a(
|
|
2675
|
+
/* @__PURE__ */ a(mt, { "aria-hidden": "true" }),
|
|
2658
2676
|
s.actionLabel
|
|
2659
2677
|
]
|
|
2660
2678
|
}
|
|
@@ -2662,24 +2680,24 @@ const pt = (e, t) => {
|
|
|
2662
2680
|
]
|
|
2663
2681
|
}
|
|
2664
2682
|
);
|
|
2665
|
-
},
|
|
2683
|
+
}, Ha = ({
|
|
2666
2684
|
active: e,
|
|
2667
2685
|
steps: t
|
|
2668
2686
|
}) => {
|
|
2669
|
-
const [s, n] =
|
|
2687
|
+
const [s, n] = R(!1);
|
|
2670
2688
|
if (!e || !t?.length) return null;
|
|
2671
2689
|
const i = t[t.length - 1] ?? "处理中";
|
|
2672
|
-
return /* @__PURE__ */
|
|
2690
|
+
return /* @__PURE__ */ m(
|
|
2673
2691
|
"details",
|
|
2674
2692
|
{
|
|
2675
2693
|
className: "make-ai-assistant__process",
|
|
2676
2694
|
open: s,
|
|
2677
|
-
onToggle: (
|
|
2695
|
+
onToggle: (o) => n(o.currentTarget.open),
|
|
2678
2696
|
children: [
|
|
2679
|
-
/* @__PURE__ */
|
|
2680
|
-
/* @__PURE__ */
|
|
2697
|
+
/* @__PURE__ */ m("summary", { "aria-label": `查看处理过程,共 ${t.length} 步`, children: [
|
|
2698
|
+
/* @__PURE__ */ m("span", { className: "make-ai-assistant__process-summary", children: [
|
|
2681
2699
|
/* @__PURE__ */ a("span", { className: "make-ai-assistant__process-indicator", "aria-hidden": "true" }),
|
|
2682
|
-
/* @__PURE__ */
|
|
2700
|
+
/* @__PURE__ */ m("span", { className: "make-ai-assistant__process-copy", children: [
|
|
2683
2701
|
/* @__PURE__ */ a("span", { className: "make-ai-assistant__process-title", children: "处理过程" }),
|
|
2684
2702
|
/* @__PURE__ */ a(
|
|
2685
2703
|
"span",
|
|
@@ -2691,21 +2709,21 @@ const pt = (e, t) => {
|
|
|
2691
2709
|
)
|
|
2692
2710
|
] })
|
|
2693
2711
|
] }),
|
|
2694
|
-
/* @__PURE__ */
|
|
2712
|
+
/* @__PURE__ */ m("span", { className: "make-ai-assistant__process-count", children: [
|
|
2695
2713
|
t.length,
|
|
2696
2714
|
" 步"
|
|
2697
2715
|
] })
|
|
2698
2716
|
] }),
|
|
2699
|
-
/* @__PURE__ */ a("ol", { children: t.map((
|
|
2717
|
+
/* @__PURE__ */ a("ol", { children: t.map((o, d) => /* @__PURE__ */ m(
|
|
2700
2718
|
"li",
|
|
2701
2719
|
{
|
|
2702
|
-
"data-step-active":
|
|
2720
|
+
"data-step-active": d === t.length - 1 ? !0 : void 0,
|
|
2703
2721
|
children: [
|
|
2704
2722
|
/* @__PURE__ */ a("span", { "aria-hidden": "true" }),
|
|
2705
|
-
/* @__PURE__ */ a("span", { children:
|
|
2723
|
+
/* @__PURE__ */ a("span", { children: o })
|
|
2706
2724
|
]
|
|
2707
2725
|
},
|
|
2708
|
-
`${
|
|
2726
|
+
`${d}-${o}`
|
|
2709
2727
|
)) })
|
|
2710
2728
|
]
|
|
2711
2729
|
}
|
|
@@ -2715,7 +2733,7 @@ const pt = (e, t) => {
|
|
|
2715
2733
|
feedback: t,
|
|
2716
2734
|
onCopy: s,
|
|
2717
2735
|
onRegenerate: n
|
|
2718
|
-
}) => !t && !s && !n ? null : /* @__PURE__ */
|
|
2736
|
+
}) => !t && !s && !n ? null : /* @__PURE__ */ m("div", { className: "make-ai-assistant__reply-actions", "aria-label": "回复操作", children: [
|
|
2719
2737
|
s ? /* @__PURE__ */ a(
|
|
2720
2738
|
"button",
|
|
2721
2739
|
{
|
|
@@ -2742,7 +2760,7 @@ const pt = (e, t) => {
|
|
|
2742
2760
|
"data-tooltip": "重新生成",
|
|
2743
2761
|
type: "button",
|
|
2744
2762
|
onClick: n,
|
|
2745
|
-
children: /* @__PURE__ */ a(
|
|
2763
|
+
children: /* @__PURE__ */ a(mt, { "aria-hidden": "true" })
|
|
2746
2764
|
}
|
|
2747
2765
|
) : null,
|
|
2748
2766
|
e ? /* @__PURE__ */ a(
|
|
@@ -2768,465 +2786,471 @@ const pt = (e, t) => {
|
|
|
2768
2786
|
className: `make-ai-assistant__message make-ai-assistant__message--assistant make-ai-assistant__message--${i}`,
|
|
2769
2787
|
"data-message-role": "assistant",
|
|
2770
2788
|
"data-message-state": i,
|
|
2771
|
-
children: /* @__PURE__ */
|
|
2772
|
-
/* @__PURE__ */ a(
|
|
2773
|
-
/* @__PURE__ */ a("div", { className: "make-ai-assistant__message-stack", children: t ? /* @__PURE__ */ a(
|
|
2789
|
+
children: /* @__PURE__ */ m("div", { className: "make-ai-assistant__message-turn", children: [
|
|
2790
|
+
/* @__PURE__ */ a(Da, { assistantName: e }),
|
|
2791
|
+
/* @__PURE__ */ a("div", { className: "make-ai-assistant__message-stack", children: t ? /* @__PURE__ */ a(Fa, { error: t, onRetry: s }) : /* @__PURE__ */ a(Ha, { active: !0, steps: n?.steps }) })
|
|
2774
2792
|
] })
|
|
2775
2793
|
}
|
|
2776
2794
|
) : null;
|
|
2777
|
-
},
|
|
2778
|
-
const
|
|
2779
|
-
let
|
|
2780
|
-
return e.messages.map((
|
|
2781
|
-
if (
|
|
2795
|
+
}, gn = (e, t, s, n, i, o, d, h, v, I, f, N, C, A, g, F) => {
|
|
2796
|
+
const T = Ua(e), H = Pa(e), b = mn(e);
|
|
2797
|
+
let l;
|
|
2798
|
+
return e.messages.map((c) => {
|
|
2799
|
+
if (c.intermediate) return /* @__PURE__ */ m("details", { className: "make-ai-assistant__process", children: [
|
|
2782
2800
|
/* @__PURE__ */ a("summary", { children: "处理过程" }),
|
|
2783
|
-
/* @__PURE__ */ a(Gt, { content:
|
|
2784
|
-
] },
|
|
2785
|
-
const
|
|
2786
|
-
|
|
2787
|
-
const W =
|
|
2801
|
+
/* @__PURE__ */ a(Gt, { content: c.content })
|
|
2802
|
+
] }, c.id);
|
|
2803
|
+
const k = c.role === "assistant", E = l;
|
|
2804
|
+
k || (l = c);
|
|
2805
|
+
const W = c.id === H, M = c.id === T ? e.error : void 0, X = c.error ?? M, me = !k && !!(v?.trim() || I), ee = k ? d : v?.trim() || "用户", he = k && c.status === "complete" && !X && (c.content.trim() || c.id === b), ne = !!(g && F?.features?.feedback && typeof F.setFeedback == "function" && k && c.persistent), Ae = he || ne;
|
|
2788
2806
|
return /* @__PURE__ */ a(
|
|
2789
2807
|
"article",
|
|
2790
2808
|
{
|
|
2791
|
-
"aria-label": `${
|
|
2792
|
-
className: `make-ai-assistant__message make-ai-assistant__message--${
|
|
2793
|
-
"data-message-role":
|
|
2809
|
+
"aria-label": `${ee}的消息`,
|
|
2810
|
+
className: `make-ai-assistant__message make-ai-assistant__message--${c.role}`,
|
|
2811
|
+
"data-message-role": c.role,
|
|
2794
2812
|
"data-message-state": X ? "error" : void 0,
|
|
2795
|
-
"data-message-status":
|
|
2796
|
-
"data-message-has-identity":
|
|
2797
|
-
children: /* @__PURE__ */
|
|
2798
|
-
|
|
2799
|
-
/* @__PURE__ */
|
|
2800
|
-
|
|
2801
|
-
|
|
2813
|
+
"data-message-status": c.status,
|
|
2814
|
+
"data-message-has-identity": k || me ? !0 : void 0,
|
|
2815
|
+
children: /* @__PURE__ */ m("div", { className: "make-ai-assistant__message-turn", children: [
|
|
2816
|
+
k ? /* @__PURE__ */ a(Da, { assistantName: d }) : me ? /* @__PURE__ */ a(on, { userAvatarUrl: I, userName: v }) : null,
|
|
2817
|
+
/* @__PURE__ */ m("div", { className: "make-ai-assistant__message-stack", children: [
|
|
2818
|
+
k && c.responseId && e.responses?.[c.responseId]?.status === "cancelled" ? /* @__PURE__ */ a("p", { className: "make-ai-assistant__response-status", role: "status", children: "已停止生成" }) : null,
|
|
2819
|
+
c.content ? k ? /* @__PURE__ */ a(Gt, { content: c.content }) : /* @__PURE__ */ a("div", { className: "make-ai-assistant__bubble", children: c.content }) : c.status === "streaming" ? /* @__PURE__ */ m("div", { className: "make-ai-assistant__typing", "aria-label": `${d}正在思考`, children: [
|
|
2802
2820
|
/* @__PURE__ */ a("span", {}),
|
|
2803
2821
|
/* @__PURE__ */ a("span", {}),
|
|
2804
2822
|
/* @__PURE__ */ a("span", {})
|
|
2805
2823
|
] }) : null,
|
|
2806
|
-
|
|
2807
|
-
|
|
2824
|
+
k ? /* @__PURE__ */ a(
|
|
2825
|
+
Ha,
|
|
2808
2826
|
{
|
|
2809
2827
|
active: W && e.status === "streaming",
|
|
2810
|
-
steps:
|
|
2828
|
+
steps: c.progressSteps
|
|
2811
2829
|
}
|
|
2812
2830
|
) : null,
|
|
2813
2831
|
X ? /* @__PURE__ */ a(
|
|
2814
|
-
|
|
2832
|
+
Fa,
|
|
2815
2833
|
{
|
|
2816
2834
|
error: X,
|
|
2817
|
-
onRetry:
|
|
2835
|
+
onRetry: M ? h : void 0
|
|
2818
2836
|
}
|
|
2819
2837
|
) : null,
|
|
2820
|
-
|
|
2821
|
-
|
|
2838
|
+
c.artifacts.map((ce) => /* @__PURE__ */ a(
|
|
2839
|
+
Za,
|
|
2822
2840
|
{
|
|
2823
|
-
artifact:
|
|
2841
|
+
artifact: ce,
|
|
2824
2842
|
context: t,
|
|
2825
2843
|
onAction: i,
|
|
2826
|
-
onActionError:
|
|
2844
|
+
onActionError: o,
|
|
2827
2845
|
registry: s,
|
|
2828
2846
|
theme: n
|
|
2829
2847
|
},
|
|
2830
|
-
|
|
2848
|
+
ce.id
|
|
2831
2849
|
)),
|
|
2832
|
-
|
|
2833
|
-
|
|
2850
|
+
g && F && e.threadId ? /* @__PURE__ */ a(Hs, { message: c, context: t, transport: F, chatId: e.threadId }) : null,
|
|
2851
|
+
Ae ? /* @__PURE__ */ a(
|
|
2834
2852
|
yn,
|
|
2835
2853
|
{
|
|
2836
|
-
copyFeedback:
|
|
2837
|
-
message:
|
|
2838
|
-
status:
|
|
2854
|
+
copyFeedback: f?.messageId === c.id ? {
|
|
2855
|
+
message: f.message,
|
|
2856
|
+
status: f.status
|
|
2839
2857
|
} : void 0,
|
|
2840
|
-
onCopy:
|
|
2841
|
-
feedback:
|
|
2842
|
-
onRegenerate:
|
|
2843
|
-
userMessage:
|
|
2844
|
-
assistantMessage:
|
|
2858
|
+
onCopy: c.content.trim() ? () => C(c.id, c.content) : void 0,
|
|
2859
|
+
feedback: g && ne ? /* @__PURE__ */ a(Us, { message: c, manager: g }) : void 0,
|
|
2860
|
+
onRegenerate: N && c.id === b && E ? () => A({
|
|
2861
|
+
userMessage: E,
|
|
2862
|
+
assistantMessage: c
|
|
2845
2863
|
}) : void 0
|
|
2846
2864
|
}
|
|
2847
2865
|
) : null
|
|
2848
2866
|
] })
|
|
2849
2867
|
] })
|
|
2850
2868
|
},
|
|
2851
|
-
`${e.threadId ?? "local"}:${
|
|
2869
|
+
`${e.threadId ?? "local"}:${c.id}`
|
|
2852
2870
|
);
|
|
2853
2871
|
});
|
|
2854
2872
|
};
|
|
2855
|
-
function
|
|
2873
|
+
function ja({
|
|
2856
2874
|
assistantName: e = "AI 助手",
|
|
2857
2875
|
brandName: t,
|
|
2858
2876
|
context: s,
|
|
2859
2877
|
onAction: n,
|
|
2860
2878
|
onActionError: i,
|
|
2861
|
-
onClose:
|
|
2862
|
-
onNewConversation:
|
|
2863
|
-
onToggleFullscreen:
|
|
2864
|
-
headerHeight:
|
|
2865
|
-
isFullscreen:
|
|
2866
|
-
registry:
|
|
2867
|
-
suggestions:
|
|
2879
|
+
onClose: o,
|
|
2880
|
+
onNewConversation: d,
|
|
2881
|
+
onToggleFullscreen: h,
|
|
2882
|
+
headerHeight: v,
|
|
2883
|
+
isFullscreen: I = !1,
|
|
2884
|
+
registry: f,
|
|
2885
|
+
suggestions: N,
|
|
2868
2886
|
title: C,
|
|
2869
|
-
theme:
|
|
2870
|
-
transport:
|
|
2871
|
-
userAvatarUrl:
|
|
2872
|
-
userName:
|
|
2887
|
+
theme: A,
|
|
2888
|
+
transport: g,
|
|
2889
|
+
userAvatarUrl: F,
|
|
2890
|
+
userName: T,
|
|
2873
2891
|
visible: H
|
|
2874
2892
|
}) {
|
|
2875
|
-
const
|
|
2876
|
-
...
|
|
2877
|
-
...
|
|
2878
|
-
} : void 0, [
|
|
2893
|
+
const b = xs(s, g), l = Vs(s, g, b), c = xa(t, C), k = tn(v), E = Mt(A), W = E || k ? {
|
|
2894
|
+
...E,
|
|
2895
|
+
...k ? { "--make-ai-internal-header-height": k } : {}
|
|
2896
|
+
} : void 0, [M, X] = R(""), [me, ee] = R(!1), [he, ne] = R(!1), Ae = b.enabled ? g.scopeKey?.(s) ?? s.app.id : "";
|
|
2879
2897
|
At(() => {
|
|
2880
|
-
|
|
2881
|
-
}, [
|
|
2882
|
-
const [
|
|
2883
|
-
|
|
2884
|
-
const [
|
|
2898
|
+
b.enabled && X("");
|
|
2899
|
+
}, [Ae, b.enabled]);
|
|
2900
|
+
const [ce, ht] = R(ye), U = b.enabled ? b.state : ce, fe = b.enabled ? b.setState : ht, le = P(U);
|
|
2901
|
+
le.current = U;
|
|
2902
|
+
const [Ee, ge] = R(void 0), [De, G] = R(void 0), [K, te] = R(0), [$e, de] = R(() => g.loadConversation ? "loading" : "ready"), oe = b.configurationError ? "error" : b.enabled ? b.loading && !U.messages.length ? "loading" : "ready" : $e, [Se, L] = R(void 0), [ae, Z] = R(!1), Q = P(void 0), ke = P(void 0), Ce = P(0), Ke = P(null), we = P(null), Y = P(null), Me = P(null), We = P(null), Re = P(null), pe = P(!0), Xe = P(s.app.id), Pe = P(H), at = Wa();
|
|
2885
2903
|
At(() => {
|
|
2886
|
-
const
|
|
2887
|
-
|
|
2888
|
-
Math.max(
|
|
2904
|
+
const p = Y.current;
|
|
2905
|
+
p && (p.style.height = "auto", p.style.height = `${Math.min(
|
|
2906
|
+
Math.max(p.scrollHeight, Js),
|
|
2889
2907
|
Ys
|
|
2890
2908
|
)}px`);
|
|
2891
|
-
}, [
|
|
2892
|
-
const
|
|
2893
|
-
() =>
|
|
2894
|
-
[
|
|
2895
|
-
),
|
|
2896
|
-
() => Qs(
|
|
2897
|
-
[
|
|
2898
|
-
),
|
|
2899
|
-
const
|
|
2900
|
-
return !
|
|
2909
|
+
}, [M]);
|
|
2910
|
+
const Ge = Ft(
|
|
2911
|
+
() => f ?? rs(),
|
|
2912
|
+
[f]
|
|
2913
|
+
), st = Ft(
|
|
2914
|
+
() => Qs(N),
|
|
2915
|
+
[N]
|
|
2916
|
+
), Ue = (p) => {
|
|
2917
|
+
const j = Q.current, q = ke.current?.iterator;
|
|
2918
|
+
return !j && !q ? !1 : (Ce.current += 1, Q.current = void 0, ke.current = void 0, console.info("[make-ai-assistant] local run cancellation requested", { reason: p }), j?.abort(), Xt(q), !0);
|
|
2901
2919
|
};
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
}, []),
|
|
2905
|
-
if (
|
|
2906
|
-
const
|
|
2907
|
-
if (
|
|
2908
|
-
|
|
2920
|
+
se(() => () => {
|
|
2921
|
+
Ue("unmount");
|
|
2922
|
+
}, []), se(() => {
|
|
2923
|
+
if (b.enabled) return;
|
|
2924
|
+
const p = g.loadConversation, j = Xe.current !== s.app.id;
|
|
2925
|
+
if (Xe.current = s.app.id, Ue("reinitialize"), j && (X(""), pe.current = !0), ge(void 0), G(void 0), Z(!1), fe(ye()), !p) {
|
|
2926
|
+
L(void 0), de("ready");
|
|
2909
2927
|
return;
|
|
2910
2928
|
}
|
|
2911
|
-
const
|
|
2912
|
-
return
|
|
2929
|
+
const q = new AbortController();
|
|
2930
|
+
return L(void 0), de("loading"), console.info("[make-ai-assistant] conversation load start", {
|
|
2913
2931
|
appId: s.app.id
|
|
2914
|
-
}),
|
|
2915
|
-
|
|
2932
|
+
}), p.call(g, s, { signal: q.signal }).then((V) => {
|
|
2933
|
+
q.signal.aborted || (fe(ye(V)), de("ready"), console.info("[make-ai-assistant] conversation load success", {
|
|
2916
2934
|
appId: s.app.id,
|
|
2917
|
-
messageCount:
|
|
2935
|
+
messageCount: V.messages.length
|
|
2918
2936
|
}));
|
|
2919
|
-
}).catch((
|
|
2920
|
-
|
|
2937
|
+
}).catch((V) => {
|
|
2938
|
+
q.signal.aborted || (console.error("[make-ai-assistant] conversation load failed", {
|
|
2921
2939
|
appId: s.app.id,
|
|
2922
|
-
errorType:
|
|
2923
|
-
}),
|
|
2924
|
-
}), () =>
|
|
2925
|
-
}, [s.app.id,
|
|
2926
|
-
const
|
|
2927
|
-
if (!
|
|
2928
|
-
|
|
2929
|
-
const
|
|
2930
|
-
if (!
|
|
2931
|
-
const
|
|
2932
|
-
It(
|
|
2940
|
+
errorType: V instanceof Error ? V.name : typeof V
|
|
2941
|
+
}), L(V), de("error"));
|
|
2942
|
+
}), () => q.abort();
|
|
2943
|
+
}, [s.app.id, K, g, b.enabled]), se(() => {
|
|
2944
|
+
const p = we.current;
|
|
2945
|
+
if (!p || !pe.current) return;
|
|
2946
|
+
Z(!1);
|
|
2947
|
+
const j = requestAnimationFrame(() => {
|
|
2948
|
+
if (!pe.current) return;
|
|
2949
|
+
const q = U.status === "streaming" || globalThis.matchMedia?.("(prefers-reduced-motion: reduce)").matches ? "auto" : "smooth";
|
|
2950
|
+
It(p, q);
|
|
2933
2951
|
});
|
|
2934
|
-
return () => cancelAnimationFrame(
|
|
2935
|
-
}, [
|
|
2936
|
-
H || (
|
|
2937
|
-
}, [H]),
|
|
2938
|
-
const
|
|
2939
|
-
if (
|
|
2940
|
-
const
|
|
2941
|
-
const
|
|
2942
|
-
if (
|
|
2943
|
-
|
|
2944
|
-
const
|
|
2945
|
-
It(
|
|
2946
|
-
} else
|
|
2947
|
-
const
|
|
2948
|
-
(
|
|
2952
|
+
return () => cancelAnimationFrame(j);
|
|
2953
|
+
}, [U.messages, U.progress, U.status]), se(() => {
|
|
2954
|
+
H || (ee(!1), ne(!1));
|
|
2955
|
+
}, [H]), se(() => {
|
|
2956
|
+
const p = H && !Pe.current;
|
|
2957
|
+
if (Pe.current = H, !p) return;
|
|
2958
|
+
const j = requestAnimationFrame(() => {
|
|
2959
|
+
const q = we.current;
|
|
2960
|
+
if (q && pe.current) {
|
|
2961
|
+
Z(!1);
|
|
2962
|
+
const be = le.current.status === "streaming" ? "auto" : Zt();
|
|
2963
|
+
It(q, be);
|
|
2964
|
+
} else q && Z(le.current.messages.length > 0);
|
|
2965
|
+
const V = Y.current;
|
|
2966
|
+
(V && !V.disabled ? V : Re.current ?? Ke.current?.querySelector("button:not(:disabled)"))?.focus();
|
|
2949
2967
|
});
|
|
2950
|
-
return () => cancelAnimationFrame(
|
|
2968
|
+
return () => cancelAnimationFrame(j);
|
|
2951
2969
|
}, [H]);
|
|
2952
|
-
const
|
|
2953
|
-
const
|
|
2954
|
-
if (!
|
|
2955
|
-
const
|
|
2956
|
-
|
|
2957
|
-
},
|
|
2958
|
-
const
|
|
2959
|
-
if (!
|
|
2960
|
-
|
|
2961
|
-
const
|
|
2962
|
-
It(
|
|
2963
|
-
},
|
|
2964
|
-
const
|
|
2965
|
-
if (!
|
|
2966
|
-
if (
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
) >
|
|
2970
|
-
|
|
2971
|
-
`输入内容过长,请控制在 ${
|
|
2970
|
+
const ft = () => {
|
|
2971
|
+
const p = we.current;
|
|
2972
|
+
if (!p) return;
|
|
2973
|
+
const j = pn(p);
|
|
2974
|
+
pe.current = j, Z(!j && le.current.messages.length > 0);
|
|
2975
|
+
}, pt = () => {
|
|
2976
|
+
const p = we.current;
|
|
2977
|
+
if (!p) return;
|
|
2978
|
+
pe.current = !0, Z(!1);
|
|
2979
|
+
const j = Zt();
|
|
2980
|
+
It(p, j);
|
|
2981
|
+
}, nt = async (p, j) => {
|
|
2982
|
+
const q = p.trim(), V = le.current, ie = j?.regenerateFrom, be = g.regenerate;
|
|
2983
|
+
if (!q || oe !== "ready" || V.status === "streaming" || Q.current || ie && !be) return;
|
|
2984
|
+
if (lt(
|
|
2985
|
+
q,
|
|
2986
|
+
ue.messageCharacters
|
|
2987
|
+
) > ue.messageCharacters) {
|
|
2988
|
+
ge(
|
|
2989
|
+
`输入内容过长,请控制在 ${ue.messageCharacters} 个字符以内`
|
|
2972
2990
|
);
|
|
2973
2991
|
return;
|
|
2974
2992
|
}
|
|
2975
|
-
const
|
|
2976
|
-
id:
|
|
2977
|
-
content:
|
|
2978
|
-
},
|
|
2979
|
-
|
|
2993
|
+
const it = {
|
|
2994
|
+
id: ie?.userMessage.id ?? Xs("user"),
|
|
2995
|
+
content: q
|
|
2996
|
+
}, rt = ie ? fn(V, ie.userMessage.id) : ta(V, it), ot = new AbortController(), He = Ce.current + 1;
|
|
2997
|
+
Ce.current = He, Q.current = ot, ge(void 0), G(void 0), Z(!pe.current && V.messages.length > 0), ie || X(""), fe(rt);
|
|
2980
2998
|
try {
|
|
2981
|
-
let
|
|
2999
|
+
let Te = !1, re, $t = 0, St = 0, Rt = 0, yt = 0, Je = 0;
|
|
2982
3000
|
const Ye = /* @__PURE__ */ new Map(), Lt = /* @__PURE__ */ new Set(), zt = /* @__PURE__ */ new Set(
|
|
2983
3001
|
[
|
|
2984
|
-
...
|
|
2985
|
-
|
|
3002
|
+
...rt.messages.map((ct) => ct.id),
|
|
3003
|
+
it.id
|
|
2986
3004
|
]
|
|
2987
|
-
), Qe = /* @__PURE__ */ new Set(), xt =
|
|
2988
|
-
let
|
|
2989
|
-
if (
|
|
2990
|
-
if (!
|
|
3005
|
+
), Qe = /* @__PURE__ */ new Set(), xt = Ga(Ge), Dt = { signal: ot.signal };
|
|
3006
|
+
let gt;
|
|
3007
|
+
if (ie) {
|
|
3008
|
+
if (!be)
|
|
2991
3009
|
throw new J("当前 AI 助手不支持重新生成");
|
|
2992
|
-
|
|
2993
|
-
threadId:
|
|
2994
|
-
message:
|
|
3010
|
+
gt = be({
|
|
3011
|
+
threadId: rt.threadId,
|
|
3012
|
+
message: it,
|
|
2995
3013
|
assistantMessage: {
|
|
2996
|
-
id:
|
|
2997
|
-
content:
|
|
3014
|
+
id: ie.assistantMessage.id,
|
|
3015
|
+
content: ie.assistantMessage.content
|
|
2998
3016
|
},
|
|
2999
3017
|
context: s,
|
|
3000
3018
|
capabilities: xt
|
|
3001
3019
|
}, Dt);
|
|
3002
3020
|
} else
|
|
3003
|
-
|
|
3021
|
+
gt = g.run(
|
|
3004
3022
|
{
|
|
3005
|
-
threadId:
|
|
3006
|
-
message:
|
|
3023
|
+
threadId: rt.threadId,
|
|
3024
|
+
message: it,
|
|
3007
3025
|
context: s,
|
|
3008
3026
|
capabilities: xt
|
|
3009
3027
|
},
|
|
3010
3028
|
Dt
|
|
3011
3029
|
);
|
|
3012
|
-
const Pt =
|
|
3013
|
-
for (
|
|
3014
|
-
const
|
|
3015
|
-
if (
|
|
3016
|
-
let
|
|
3030
|
+
const Pt = gt[Symbol.asyncIterator]();
|
|
3031
|
+
for (ke.current = { iterator: Pt, requestVersion: He }; ; ) {
|
|
3032
|
+
const ct = await Pt.next();
|
|
3033
|
+
if (Ce.current !== He || ct.done) break;
|
|
3034
|
+
let D;
|
|
3017
3035
|
try {
|
|
3018
|
-
|
|
3019
|
-
} catch (
|
|
3036
|
+
D = ea(ct.value);
|
|
3037
|
+
} catch (ve) {
|
|
3020
3038
|
throw new J(
|
|
3021
|
-
|
|
3039
|
+
ve instanceof Error ? ve.message : "Invalid assistant event"
|
|
3022
3040
|
);
|
|
3023
3041
|
}
|
|
3024
|
-
if (
|
|
3025
|
-
if (re !== void 0 && re !==
|
|
3042
|
+
if (D.type === "message.start") {
|
|
3043
|
+
if (re !== void 0 && re !== D.runId)
|
|
3026
3044
|
throw new J("AI 助手响应 run id 不一致");
|
|
3027
|
-
if (re ??=
|
|
3045
|
+
if (re ??= D.runId, St += 1, St > ue.assistantMessagesPerRun)
|
|
3028
3046
|
throw new J("AI 助手单次响应消息数量超过限制");
|
|
3029
|
-
if (zt.has(
|
|
3047
|
+
if (zt.has(D.messageId))
|
|
3030
3048
|
throw new J("AI 助手响应包含重复的 message id");
|
|
3031
|
-
zt.add(
|
|
3049
|
+
zt.add(D.messageId), Qe.add(D.messageId), Ye.set(D.messageId, 0);
|
|
3032
3050
|
}
|
|
3033
|
-
if (
|
|
3034
|
-
if (!Qe.has(
|
|
3051
|
+
if (D.type === "message.delta") {
|
|
3052
|
+
if (!Qe.has(D.messageId))
|
|
3035
3053
|
throw new J("AI 助手响应事件顺序无效");
|
|
3036
|
-
const
|
|
3037
|
-
|
|
3038
|
-
|
|
3054
|
+
const ve = Ye.get(D.messageId) ?? 0, je = lt(
|
|
3055
|
+
D.delta,
|
|
3056
|
+
ue.messageCharacters - Je
|
|
3039
3057
|
);
|
|
3040
|
-
if (Je +
|
|
3058
|
+
if (Je + je > ue.messageCharacters)
|
|
3041
3059
|
throw new J("AI 助手响应文本超过大小限制");
|
|
3042
|
-
Je +=
|
|
3043
|
-
|
|
3044
|
-
|
|
3060
|
+
Je += je, Ye.set(
|
|
3061
|
+
D.messageId,
|
|
3062
|
+
ve + je
|
|
3045
3063
|
);
|
|
3046
3064
|
}
|
|
3047
|
-
if (
|
|
3048
|
-
if (!Qe.has(
|
|
3065
|
+
if (D.type === "message.replace") {
|
|
3066
|
+
if (!Qe.has(D.messageId))
|
|
3049
3067
|
throw new J("AI 助手响应事件顺序无效");
|
|
3050
|
-
const
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
), Ut = Je -
|
|
3054
|
-
if (Ut >
|
|
3068
|
+
const ve = Ye.get(D.messageId) ?? 0, je = lt(
|
|
3069
|
+
D.content,
|
|
3070
|
+
ue.messageCharacters
|
|
3071
|
+
), Ut = Je - ve + je;
|
|
3072
|
+
if (Ut > ue.messageCharacters)
|
|
3055
3073
|
throw new J("AI 助手响应文本超过大小限制");
|
|
3056
|
-
Je = Ut, Ye.set(
|
|
3074
|
+
Je = Ut, Ye.set(D.messageId, je);
|
|
3057
3075
|
}
|
|
3058
|
-
if (
|
|
3059
|
-
if (re !== void 0 && re !==
|
|
3076
|
+
if (D.type === "run.progress") {
|
|
3077
|
+
if (re !== void 0 && re !== D.runId)
|
|
3060
3078
|
throw new J("AI 助手响应 run id 不一致");
|
|
3061
|
-
if (re ??=
|
|
3079
|
+
if (re ??= D.runId, Rt += 1, Rt > ue.progressStepsPerRun)
|
|
3062
3080
|
throw new J("AI 助手处理过程数量超过限制");
|
|
3063
|
-
const
|
|
3064
|
-
|
|
3065
|
-
|
|
3081
|
+
const ve = lt(
|
|
3082
|
+
D.message,
|
|
3083
|
+
ue.progressCharactersPerRun - yt
|
|
3066
3084
|
);
|
|
3067
|
-
if (yt +
|
|
3085
|
+
if (yt + ve > ue.progressCharactersPerRun)
|
|
3068
3086
|
throw new J("AI 助手处理过程文本超过大小限制");
|
|
3069
|
-
yt +=
|
|
3087
|
+
yt += ve;
|
|
3070
3088
|
}
|
|
3071
|
-
if (
|
|
3072
|
-
if (!Qe.has(
|
|
3089
|
+
if (D.type === "artifact") {
|
|
3090
|
+
if (!Qe.has(D.messageId))
|
|
3073
3091
|
throw new J("AI 助手响应事件顺序无效");
|
|
3074
|
-
if ($t += 1, $t >
|
|
3092
|
+
if ($t += 1, $t > ue.artifactsPerRun)
|
|
3075
3093
|
throw new J("AI 助手单次响应 Artifact 数量超过限制");
|
|
3076
|
-
if (Lt.has(
|
|
3094
|
+
if (Lt.has(D.artifact.id))
|
|
3077
3095
|
throw new J("AI 助手响应包含重复的 Artifact id");
|
|
3078
|
-
Lt.add(
|
|
3096
|
+
Lt.add(D.artifact.id);
|
|
3079
3097
|
}
|
|
3080
|
-
if (
|
|
3098
|
+
if (D.type === "message.complete" && !Qe.delete(D.messageId))
|
|
3081
3099
|
throw new J("AI 助手响应事件顺序无效");
|
|
3082
|
-
if (
|
|
3100
|
+
if (D.type === "run.complete" && re !== void 0 && re !== D.runId)
|
|
3083
3101
|
throw new J("AI 助手响应 run id 不一致");
|
|
3084
|
-
if (
|
|
3102
|
+
if (D.type === "run.cancelled" && D.runId !== void 0 && re !== void 0 && re !== D.runId)
|
|
3085
3103
|
throw new J("AI 助手响应 run id 不一致");
|
|
3086
|
-
if (
|
|
3087
|
-
|
|
3104
|
+
if (fe((ve) => Ie(ve, D)), D.type === "error" || D.type === "run.cancelled" || D.type === "run.complete") {
|
|
3105
|
+
Te = !0;
|
|
3088
3106
|
break;
|
|
3089
3107
|
}
|
|
3090
3108
|
}
|
|
3091
|
-
if (!
|
|
3109
|
+
if (!Te)
|
|
3092
3110
|
throw new J("AI 助手流式响应在终止事件前结束");
|
|
3093
|
-
} catch (
|
|
3094
|
-
if (
|
|
3095
|
-
if (
|
|
3096
|
-
|
|
3097
|
-
(re) =>
|
|
3111
|
+
} catch (Te) {
|
|
3112
|
+
if (Ce.current !== He) return;
|
|
3113
|
+
if (ot.signal.aborted) {
|
|
3114
|
+
fe(
|
|
3115
|
+
(re) => Ie(re, { type: "run.cancelled" })
|
|
3098
3116
|
);
|
|
3099
3117
|
return;
|
|
3100
3118
|
}
|
|
3101
3119
|
console.error("[make-ai-assistant] assistant run failed", {
|
|
3102
3120
|
appId: s.app.id,
|
|
3103
|
-
errorType:
|
|
3104
|
-
}),
|
|
3105
|
-
(re) =>
|
|
3121
|
+
errorType: Te instanceof Error ? Te.name : typeof Te
|
|
3122
|
+
}), fe(
|
|
3123
|
+
(re) => Ie(re, {
|
|
3106
3124
|
type: "error",
|
|
3107
3125
|
code: "TRANSPORT_ERROR",
|
|
3108
|
-
message:
|
|
3126
|
+
message: Te instanceof J ? Te.message : "连接失败,请重试",
|
|
3109
3127
|
retryable: !0
|
|
3110
3128
|
})
|
|
3111
3129
|
);
|
|
3112
3130
|
} finally {
|
|
3113
|
-
|
|
3131
|
+
Ce.current === He && Q.current === ot && (Q.current = void 0), ke.current?.requestVersion === He && (Xt(ke.current.iterator), ke.current = void 0);
|
|
3114
3132
|
}
|
|
3115
|
-
},
|
|
3116
|
-
if (
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
|
|
3133
|
+
}, Fe = (p) => {
|
|
3134
|
+
if (oe !== "ready") return Promise.resolve();
|
|
3135
|
+
if (b.enabled) {
|
|
3136
|
+
if (l.pending)
|
|
3137
|
+
return ge("请等待附件上传完成,或移除失败的附件"), Promise.resolve();
|
|
3138
|
+
const j = p.trim(), q = l.parts.length ? [...j ? [{ id: qe(), kind: "text", text: j }] : [], ...l.parts] : void 0;
|
|
3139
|
+
return X(""), l.clear(), b.send(j, q);
|
|
3121
3140
|
}
|
|
3122
|
-
return
|
|
3123
|
-
},
|
|
3141
|
+
return nt(p);
|
|
3142
|
+
}, vt = (p) => nt(p.userMessage.content, { regenerateFrom: p }), Ze = async (p, j) => {
|
|
3124
3143
|
try {
|
|
3125
|
-
await nn(
|
|
3126
|
-
} catch (
|
|
3144
|
+
await nn(j), G({ messageId: p, message: "已复制", status: "success" });
|
|
3145
|
+
} catch (q) {
|
|
3127
3146
|
console.error("[make-ai-assistant] copy answer failed", {
|
|
3128
|
-
errorType:
|
|
3129
|
-
}),
|
|
3147
|
+
errorType: q instanceof Error ? q.name : typeof q
|
|
3148
|
+
}), G({ messageId: p, message: "复制失败", status: "error" });
|
|
3130
3149
|
}
|
|
3131
|
-
},
|
|
3132
|
-
|
|
3133
|
-
},
|
|
3134
|
-
|
|
3135
|
-
},
|
|
3136
|
-
if (
|
|
3137
|
-
|
|
3150
|
+
}, Le = (p) => {
|
|
3151
|
+
p.preventDefault(), Fe(M);
|
|
3152
|
+
}, r = (p) => {
|
|
3153
|
+
p.key === "Enter" && !p.shiftKey && !p.nativeEvent.isComposing && (p.preventDefault(), Fe(M));
|
|
3154
|
+
}, u = () => {
|
|
3155
|
+
if (b.enabled) {
|
|
3156
|
+
b.stop();
|
|
3138
3157
|
return;
|
|
3139
3158
|
}
|
|
3140
|
-
|
|
3141
|
-
(
|
|
3159
|
+
Ue("stop") && fe(
|
|
3160
|
+
(p) => Ie(p, { type: "run.cancelled" })
|
|
3142
3161
|
);
|
|
3143
|
-
},
|
|
3144
|
-
if (
|
|
3145
|
-
|
|
3146
|
-
|
|
3162
|
+
}, y = () => {
|
|
3163
|
+
if (!b.configurationError) {
|
|
3164
|
+
if (ne(!1), b.enabled) {
|
|
3165
|
+
X(""), b.create(), d?.();
|
|
3166
|
+
return;
|
|
3167
|
+
}
|
|
3168
|
+
Ue("new-conversation"), X(""), ge(void 0), G(void 0), Z(!1), pe.current = !0, fe(ye()), d?.();
|
|
3147
3169
|
}
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
_.retry();
|
|
3170
|
+
}, w = b.enabled && b.cancelling.length ? "停止中" : g.features?.remoteCancellation === !1 ? "停止接收" : "停止生成", $ = Pa(U), z = Ua(U), _ = hn(U), x = typeof g.regenerate == "function" && g.features?.regeneration !== !1, S = () => {
|
|
3171
|
+
if (b.enabled) {
|
|
3172
|
+
b.retry();
|
|
3152
3173
|
return;
|
|
3153
3174
|
}
|
|
3154
|
-
|
|
3155
|
-
},
|
|
3156
|
-
if (
|
|
3157
|
-
if (
|
|
3158
|
-
|
|
3175
|
+
_ && Fe(_.content);
|
|
3176
|
+
}, O = (p) => {
|
|
3177
|
+
if (p.key === "Escape" && !(!me && !he)) {
|
|
3178
|
+
if (p.preventDefault(), p.stopPropagation(), me) {
|
|
3179
|
+
ee(!1), Me.current?.focus();
|
|
3159
3180
|
return;
|
|
3160
3181
|
}
|
|
3161
|
-
|
|
3182
|
+
ne(!1), We.current?.focus();
|
|
3162
3183
|
}
|
|
3163
3184
|
};
|
|
3164
|
-
return /* @__PURE__ */
|
|
3185
|
+
return /* @__PURE__ */ m(
|
|
3165
3186
|
"section",
|
|
3166
3187
|
{
|
|
3167
|
-
className: `make-ai-assistant make-ai-assistant__panel${
|
|
3168
|
-
ref:
|
|
3188
|
+
className: `make-ai-assistant make-ai-assistant__panel${b.enabled ? " make-ai-assistant__panel--managed" : ""}`,
|
|
3189
|
+
ref: Ke,
|
|
3169
3190
|
style: W,
|
|
3170
|
-
onKeyDown:
|
|
3171
|
-
onDragOver: (
|
|
3172
|
-
|
|
3191
|
+
onKeyDown: O,
|
|
3192
|
+
onDragOver: (p) => {
|
|
3193
|
+
l.enabled && p.dataTransfer.types.includes("Files") && p.preventDefault();
|
|
3173
3194
|
},
|
|
3174
|
-
onDrop: (
|
|
3175
|
-
|
|
3195
|
+
onDrop: (p) => {
|
|
3196
|
+
l.enabled && p.dataTransfer.files.length && (p.preventDefault(), l.add(Array.from(p.dataTransfer.files)));
|
|
3176
3197
|
},
|
|
3177
3198
|
children: [
|
|
3178
|
-
/* @__PURE__ */
|
|
3179
|
-
/* @__PURE__ */ a("div", { className: "make-ai-assistant__header-leading", children:
|
|
3199
|
+
/* @__PURE__ */ m("header", { className: "make-ai-assistant__header", children: [
|
|
3200
|
+
/* @__PURE__ */ a("div", { className: "make-ai-assistant__header-leading", children: b.available ? /* @__PURE__ */ m(
|
|
3180
3201
|
"button",
|
|
3181
3202
|
{
|
|
3182
|
-
"aria-controls":
|
|
3183
|
-
"aria-expanded":
|
|
3203
|
+
"aria-controls": at,
|
|
3204
|
+
"aria-expanded": he,
|
|
3184
3205
|
"aria-haspopup": "dialog",
|
|
3185
3206
|
"aria-label": "任务列表",
|
|
3186
3207
|
className: "make-ai-assistant__task-list-trigger",
|
|
3187
3208
|
ref: We,
|
|
3188
3209
|
type: "button",
|
|
3189
|
-
onClick: () =>
|
|
3210
|
+
onClick: () => ne((p) => !p),
|
|
3190
3211
|
children: [
|
|
3191
3212
|
/* @__PURE__ */ a(
|
|
3192
3213
|
Is,
|
|
3193
3214
|
{
|
|
3194
3215
|
"aria-hidden": "true",
|
|
3195
|
-
className: "make-ai-assistant__task-list-icon"
|
|
3216
|
+
className: "make-ai-assistant__task-list-icon",
|
|
3217
|
+
size: 14
|
|
3196
3218
|
}
|
|
3197
3219
|
),
|
|
3198
3220
|
/* @__PURE__ */ a("span", { className: "make-ai-assistant__task-list-label", children: "任务列表" }),
|
|
3199
|
-
|
|
3200
|
-
|
|
3221
|
+
he ? /* @__PURE__ */ a(
|
|
3222
|
+
bs,
|
|
3201
3223
|
{
|
|
3202
3224
|
"aria-hidden": "true",
|
|
3203
|
-
className: "make-ai-assistant__task-list-disclosure"
|
|
3225
|
+
className: "make-ai-assistant__task-list-disclosure",
|
|
3226
|
+
size: 14
|
|
3204
3227
|
}
|
|
3205
3228
|
) : /* @__PURE__ */ a(
|
|
3206
3229
|
ks,
|
|
3207
3230
|
{
|
|
3208
3231
|
"aria-hidden": "true",
|
|
3209
|
-
className: "make-ai-assistant__task-list-disclosure"
|
|
3232
|
+
className: "make-ai-assistant__task-list-disclosure",
|
|
3233
|
+
size: 14
|
|
3210
3234
|
}
|
|
3211
3235
|
)
|
|
3212
3236
|
]
|
|
3213
3237
|
}
|
|
3214
3238
|
) : null }),
|
|
3215
|
-
/* @__PURE__ */
|
|
3216
|
-
/* @__PURE__ */ a(
|
|
3217
|
-
/* @__PURE__ */ a("h2", { className: "make-ai-assistant__header-title", title:
|
|
3239
|
+
/* @__PURE__ */ m("div", { className: "make-ai-assistant__header-center", children: [
|
|
3240
|
+
/* @__PURE__ */ a(ut, {}),
|
|
3241
|
+
/* @__PURE__ */ a("h2", { className: "make-ai-assistant__header-title", title: c, children: c })
|
|
3218
3242
|
] }),
|
|
3219
|
-
/* @__PURE__ */
|
|
3220
|
-
|
|
3243
|
+
/* @__PURE__ */ m("div", { className: "make-ai-assistant__header-actions", children: [
|
|
3244
|
+
h ? /* @__PURE__ */ a(
|
|
3221
3245
|
"button",
|
|
3222
3246
|
{
|
|
3223
|
-
"aria-label":
|
|
3224
|
-
"aria-pressed":
|
|
3247
|
+
"aria-label": I ? "退出全屏" : "全屏显示",
|
|
3248
|
+
"aria-pressed": I,
|
|
3225
3249
|
className: "make-ai-assistant__icon-button",
|
|
3226
|
-
title:
|
|
3250
|
+
title: I ? "退出全屏" : "全屏显示",
|
|
3227
3251
|
type: "button",
|
|
3228
|
-
onClick:
|
|
3229
|
-
children:
|
|
3252
|
+
onClick: h,
|
|
3253
|
+
children: I ? /* @__PURE__ */ a(
|
|
3230
3254
|
Cs,
|
|
3231
3255
|
{
|
|
3232
3256
|
"aria-hidden": "true",
|
|
@@ -3241,13 +3265,13 @@ function Ha({
|
|
|
3241
3265
|
)
|
|
3242
3266
|
}
|
|
3243
3267
|
) : null,
|
|
3244
|
-
|
|
3268
|
+
g.features?.newConversation !== !1 && !b.configurationError ? /* @__PURE__ */ a(
|
|
3245
3269
|
"button",
|
|
3246
3270
|
{
|
|
3247
3271
|
"aria-label": "新建对话",
|
|
3248
3272
|
className: "make-ai-assistant__icon-button",
|
|
3249
3273
|
type: "button",
|
|
3250
|
-
onClick:
|
|
3274
|
+
onClick: y,
|
|
3251
3275
|
children: /* @__PURE__ */ a(
|
|
3252
3276
|
Tt,
|
|
3253
3277
|
{
|
|
@@ -3257,158 +3281,162 @@ function Ha({
|
|
|
3257
3281
|
)
|
|
3258
3282
|
}
|
|
3259
3283
|
) : null,
|
|
3260
|
-
|
|
3284
|
+
o ? /* @__PURE__ */ a(
|
|
3261
3285
|
"button",
|
|
3262
3286
|
{
|
|
3263
|
-
"aria-label": `关闭 ${
|
|
3287
|
+
"aria-label": `关闭 ${c}`,
|
|
3264
3288
|
className: "make-ai-assistant__icon-button",
|
|
3265
3289
|
type: "button",
|
|
3266
|
-
onClick:
|
|
3290
|
+
onClick: o,
|
|
3267
3291
|
children: /* @__PURE__ */ a(tt, { "aria-hidden": "true", className: "make-ai-assistant__icon-button-icon" })
|
|
3268
3292
|
}
|
|
3269
3293
|
) : null
|
|
3270
3294
|
] })
|
|
3271
3295
|
] }),
|
|
3272
|
-
|
|
3296
|
+
b.available && he ? /* @__PURE__ */ a(
|
|
3273
3297
|
Ps,
|
|
3274
3298
|
{
|
|
3275
|
-
id:
|
|
3276
|
-
manager:
|
|
3299
|
+
id: at,
|
|
3300
|
+
manager: b,
|
|
3277
3301
|
triggerRef: We,
|
|
3278
|
-
onDismiss: () =>
|
|
3279
|
-
onNewConversation:
|
|
3302
|
+
onDismiss: () => ne(!1),
|
|
3303
|
+
onNewConversation: g.features?.newConversation !== !1 ? y : void 0
|
|
3280
3304
|
}
|
|
3281
3305
|
) : null,
|
|
3282
|
-
/* @__PURE__ */
|
|
3306
|
+
/* @__PURE__ */ m(
|
|
3283
3307
|
"div",
|
|
3284
3308
|
{
|
|
3285
3309
|
className: "make-ai-assistant__body",
|
|
3286
3310
|
"aria-live": "polite",
|
|
3287
3311
|
"aria-relevant": "additions text",
|
|
3288
|
-
ref:
|
|
3312
|
+
ref: we,
|
|
3289
3313
|
role: "log",
|
|
3290
|
-
onScroll:
|
|
3314
|
+
onScroll: ft,
|
|
3291
3315
|
children: [
|
|
3292
|
-
|
|
3293
|
-
/* @__PURE__ */ a(
|
|
3316
|
+
b.configurationError ? /* @__PURE__ */ m("div", { className: "make-ai-assistant__empty", role: "alert", children: [
|
|
3317
|
+
/* @__PURE__ */ a(ua, { "aria-hidden": "true" }),
|
|
3318
|
+
/* @__PURE__ */ a("h3", { children: "会话管理不可用" }),
|
|
3319
|
+
/* @__PURE__ */ a("p", { children: b.configurationError })
|
|
3320
|
+
] }) : oe === "loading" ? /* @__PURE__ */ m("div", { className: "make-ai-assistant__empty", role: "status", children: [
|
|
3321
|
+
/* @__PURE__ */ a(ut, {}),
|
|
3294
3322
|
/* @__PURE__ */ a("h3", { children: "正在恢复对话" }),
|
|
3295
3323
|
/* @__PURE__ */ a("p", { children: "正在读取当前 App 的历史消息…" })
|
|
3296
|
-
] }) :
|
|
3324
|
+
] }) : oe === "error" ? /* @__PURE__ */ a("div", { className: "make-ai-assistant__empty", children: /* @__PURE__ */ a(
|
|
3297
3325
|
vn,
|
|
3298
3326
|
{
|
|
3299
|
-
error:
|
|
3300
|
-
onRetry: () =>
|
|
3327
|
+
error: Se,
|
|
3328
|
+
onRetry: () => te((p) => p + 1)
|
|
3301
3329
|
}
|
|
3302
|
-
) }) :
|
|
3303
|
-
/* @__PURE__ */ a(
|
|
3330
|
+
) }) : U.messages.length === 0 ? /* @__PURE__ */ m("div", { className: "make-ai-assistant__empty", children: [
|
|
3331
|
+
/* @__PURE__ */ a(ut, {}),
|
|
3304
3332
|
/* @__PURE__ */ a("h3", { children: "有什么可以帮你?" }),
|
|
3305
3333
|
/* @__PURE__ */ a("p", { children: "我会结合当前 App、页面位置和宿主允许的上下文回答,并把过程与结果分开展示。" })
|
|
3306
|
-
] }) :
|
|
3307
|
-
|
|
3334
|
+
] }) : gn(
|
|
3335
|
+
U,
|
|
3308
3336
|
s,
|
|
3309
|
-
|
|
3310
|
-
|
|
3337
|
+
Ge,
|
|
3338
|
+
A,
|
|
3311
3339
|
n,
|
|
3312
3340
|
i,
|
|
3313
3341
|
e,
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
|
|
3317
|
-
|
|
3318
|
-
|
|
3319
|
-
(
|
|
3320
|
-
|
|
3342
|
+
_ ? S : void 0,
|
|
3343
|
+
T,
|
|
3344
|
+
F,
|
|
3345
|
+
De,
|
|
3346
|
+
x,
|
|
3347
|
+
(p, j) => {
|
|
3348
|
+
Ze(p, j);
|
|
3321
3349
|
},
|
|
3322
|
-
(
|
|
3323
|
-
|
|
3350
|
+
(p) => {
|
|
3351
|
+
vt(p);
|
|
3324
3352
|
},
|
|
3325
|
-
|
|
3326
|
-
|
|
3353
|
+
b.enabled ? b : void 0,
|
|
3354
|
+
g
|
|
3327
3355
|
),
|
|
3328
|
-
|
|
3356
|
+
U.progress && !$ ? /* @__PURE__ */ a(
|
|
3329
3357
|
Jt,
|
|
3330
3358
|
{
|
|
3331
3359
|
assistantName: e,
|
|
3332
|
-
progress:
|
|
3360
|
+
progress: U.progress
|
|
3333
3361
|
}
|
|
3334
3362
|
) : null,
|
|
3335
|
-
|
|
3363
|
+
U.error && !z ? /* @__PURE__ */ a(
|
|
3336
3364
|
Jt,
|
|
3337
3365
|
{
|
|
3338
3366
|
assistantName: e,
|
|
3339
|
-
error:
|
|
3340
|
-
onRetry:
|
|
3367
|
+
error: U.error,
|
|
3368
|
+
onRetry: _ ? S : void 0
|
|
3341
3369
|
}
|
|
3342
3370
|
) : null
|
|
3343
3371
|
]
|
|
3344
3372
|
}
|
|
3345
3373
|
),
|
|
3346
|
-
|
|
3374
|
+
ae ? /* @__PURE__ */ a(
|
|
3347
3375
|
"button",
|
|
3348
3376
|
{
|
|
3349
3377
|
"aria-label": "回到最新消息",
|
|
3350
3378
|
className: "make-ai-assistant__back-to-latest",
|
|
3351
3379
|
type: "button",
|
|
3352
|
-
onClick:
|
|
3353
|
-
children: /* @__PURE__ */ a(
|
|
3380
|
+
onClick: pt,
|
|
3381
|
+
children: /* @__PURE__ */ a(ys, { "aria-hidden": "true" })
|
|
3354
3382
|
}
|
|
3355
3383
|
) : null,
|
|
3356
|
-
/* @__PURE__ */
|
|
3357
|
-
|
|
3384
|
+
/* @__PURE__ */ m("footer", { className: "make-ai-assistant__composer-region", children: [
|
|
3385
|
+
oe === "ready" && st.length > 0 && U.messages.length === 0 ? /* @__PURE__ */ a("div", { className: "make-ai-assistant__suggestions", "aria-label": "推荐问题", children: st.map((p, j) => /* @__PURE__ */ a(
|
|
3358
3386
|
"button",
|
|
3359
3387
|
{
|
|
3360
3388
|
type: "button",
|
|
3361
3389
|
onClick: () => {
|
|
3362
|
-
|
|
3390
|
+
Fe(p);
|
|
3363
3391
|
},
|
|
3364
|
-
children:
|
|
3392
|
+
children: p
|
|
3365
3393
|
},
|
|
3366
|
-
`${
|
|
3394
|
+
`${j}-${p}`
|
|
3367
3395
|
)) }) : null,
|
|
3368
|
-
/* @__PURE__ */
|
|
3369
|
-
|
|
3396
|
+
/* @__PURE__ */ m("form", { className: "make-ai-assistant__composer", onSubmit: Le, children: [
|
|
3397
|
+
l.enabled ? /* @__PURE__ */ a(Ws, { attachments: l, visible: H }) : null,
|
|
3370
3398
|
/* @__PURE__ */ a(
|
|
3371
3399
|
"textarea",
|
|
3372
3400
|
{
|
|
3373
3401
|
"aria-label": `向 ${e} 提问`,
|
|
3374
|
-
"aria-describedby":
|
|
3375
|
-
"aria-invalid":
|
|
3402
|
+
"aria-describedby": Ee ? "make-ai-composer-error" : void 0,
|
|
3403
|
+
"aria-invalid": Ee ? !0 : void 0,
|
|
3376
3404
|
autoFocus: !0,
|
|
3377
|
-
disabled:
|
|
3405
|
+
disabled: oe !== "ready" || !b.enabled && U.status === "streaming",
|
|
3378
3406
|
placeholder: `询问当前 ${s.app.name ?? "App"} 中的数据…`,
|
|
3379
|
-
ref:
|
|
3407
|
+
ref: Y,
|
|
3380
3408
|
rows: 2,
|
|
3381
|
-
value:
|
|
3382
|
-
onChange: (
|
|
3383
|
-
X(
|
|
3409
|
+
value: M,
|
|
3410
|
+
onChange: (p) => {
|
|
3411
|
+
X(p.currentTarget.value), ge(void 0);
|
|
3384
3412
|
},
|
|
3385
|
-
onKeyDown:
|
|
3386
|
-
onPaste: (
|
|
3387
|
-
!
|
|
3413
|
+
onKeyDown: r,
|
|
3414
|
+
onPaste: (p) => {
|
|
3415
|
+
!l.enabled || !p.clipboardData.files.length || (p.preventDefault(), l.add(Array.from(p.clipboardData.files)));
|
|
3388
3416
|
}
|
|
3389
3417
|
}
|
|
3390
3418
|
),
|
|
3391
|
-
/* @__PURE__ */
|
|
3392
|
-
|
|
3419
|
+
/* @__PURE__ */ m("div", { className: "make-ai-assistant__composer-toolbar", children: [
|
|
3420
|
+
l.enabled ? /* @__PURE__ */ a(
|
|
3393
3421
|
Ks,
|
|
3394
3422
|
{
|
|
3395
|
-
attachments:
|
|
3396
|
-
open:
|
|
3397
|
-
triggerRef:
|
|
3398
|
-
onOpenChange:
|
|
3423
|
+
attachments: l,
|
|
3424
|
+
open: me,
|
|
3425
|
+
triggerRef: Me,
|
|
3426
|
+
onOpenChange: ee
|
|
3399
3427
|
}
|
|
3400
3428
|
) : null,
|
|
3401
|
-
/* @__PURE__ */
|
|
3402
|
-
|
|
3429
|
+
/* @__PURE__ */ m("div", { className: "make-ai-assistant__composer-actions", children: [
|
|
3430
|
+
U.status === "streaming" ? /* @__PURE__ */ a(
|
|
3403
3431
|
"button",
|
|
3404
3432
|
{
|
|
3405
|
-
"aria-label":
|
|
3433
|
+
"aria-label": w,
|
|
3406
3434
|
className: "make-ai-assistant__send make-ai-assistant__send--stop",
|
|
3407
|
-
"data-tooltip":
|
|
3408
|
-
ref:
|
|
3409
|
-
disabled:
|
|
3435
|
+
"data-tooltip": w,
|
|
3436
|
+
ref: Re,
|
|
3437
|
+
disabled: b.enabled && b.cancelling.includes(U.activeRunId ?? ""),
|
|
3410
3438
|
type: "button",
|
|
3411
|
-
onClick:
|
|
3439
|
+
onClick: u,
|
|
3412
3440
|
children: /* @__PURE__ */ a("span", { "aria-hidden": "true" })
|
|
3413
3441
|
}
|
|
3414
3442
|
) : /* @__PURE__ */ a(
|
|
@@ -3416,25 +3444,25 @@ function Ha({
|
|
|
3416
3444
|
{
|
|
3417
3445
|
"aria-label": "发送",
|
|
3418
3446
|
className: "make-ai-assistant__send",
|
|
3419
|
-
disabled:
|
|
3447
|
+
disabled: oe !== "ready" || l.pending || !M.trim() && !l.parts.length,
|
|
3420
3448
|
type: "submit",
|
|
3421
|
-
children: /* @__PURE__ */ a(
|
|
3449
|
+
children: /* @__PURE__ */ a(Ot, { "aria-hidden": "true" })
|
|
3422
3450
|
}
|
|
3423
3451
|
),
|
|
3424
|
-
|
|
3452
|
+
b.enabled && U.status === "streaming" ? /* @__PURE__ */ a(
|
|
3425
3453
|
"button",
|
|
3426
3454
|
{
|
|
3427
3455
|
"aria-label": "发送",
|
|
3428
3456
|
className: "make-ai-assistant__send",
|
|
3429
|
-
disabled:
|
|
3457
|
+
disabled: b.busy || l.pending || !M.trim() && !l.parts.length,
|
|
3430
3458
|
type: "submit",
|
|
3431
|
-
children: /* @__PURE__ */ a(
|
|
3459
|
+
children: /* @__PURE__ */ a(Ot, { "aria-hidden": "true" })
|
|
3432
3460
|
}
|
|
3433
3461
|
) : null
|
|
3434
3462
|
] })
|
|
3435
3463
|
] })
|
|
3436
3464
|
] }),
|
|
3437
|
-
|
|
3465
|
+
Ee ? /* @__PURE__ */ a("p", { id: "make-ai-composer-error", role: "alert", children: Ee }) : null,
|
|
3438
3466
|
/* @__PURE__ */ a("p", { children: "AI 生成的结果可能存在偏差,重要数据请核对明细。" })
|
|
3439
3467
|
] })
|
|
3440
3468
|
]
|
|
@@ -3442,7 +3470,7 @@ function Ha({
|
|
|
3442
3470
|
);
|
|
3443
3471
|
}
|
|
3444
3472
|
function An(e) {
|
|
3445
|
-
return /* @__PURE__ */ a(
|
|
3473
|
+
return /* @__PURE__ */ a(ja, { ...e, visible: !0 });
|
|
3446
3474
|
}
|
|
3447
3475
|
function Cn({
|
|
3448
3476
|
defaultOpen: e = !1,
|
|
@@ -3450,69 +3478,69 @@ function Cn({
|
|
|
3450
3478
|
launcher: s,
|
|
3451
3479
|
launcherPosition: n = "bottom-right",
|
|
3452
3480
|
maxDrawerWidth: i,
|
|
3453
|
-
onOpenChange:
|
|
3454
|
-
open:
|
|
3455
|
-
...
|
|
3481
|
+
onOpenChange: o,
|
|
3482
|
+
open: d,
|
|
3483
|
+
...h
|
|
3456
3484
|
}) {
|
|
3457
|
-
const
|
|
3458
|
-
() => e ||
|
|
3459
|
-
), [
|
|
3460
|
-
|
|
3461
|
-
},
|
|
3462
|
-
return
|
|
3463
|
-
|
|
3464
|
-
}, [
|
|
3465
|
-
if (!
|
|
3466
|
-
const
|
|
3485
|
+
const v = xa(h.brandName, h.title), [I, f] = R(e), [N, C] = R(
|
|
3486
|
+
() => e || d === !0
|
|
3487
|
+
), [A, g] = R(!1), F = P(null), T = d ?? I, H = Mt(h.theme), b = en(i), l = b === void 0 ? void 0 : { "--make-ai-internal-drawer-max-width": `${b}px` }, c = (E) => {
|
|
3488
|
+
d === void 0 && f(E), o?.(E), E || (g(!1), requestAnimationFrame(() => F.current?.focus()));
|
|
3489
|
+
}, k = () => c(!T);
|
|
3490
|
+
return se(() => {
|
|
3491
|
+
T && C(!0);
|
|
3492
|
+
}, [T]), se(() => {
|
|
3493
|
+
if (!T) return;
|
|
3494
|
+
const E = (W) => {
|
|
3467
3495
|
if (W.key === "Escape") {
|
|
3468
|
-
if (
|
|
3469
|
-
|
|
3496
|
+
if (A) {
|
|
3497
|
+
g(!1);
|
|
3470
3498
|
return;
|
|
3471
3499
|
}
|
|
3472
|
-
|
|
3500
|
+
c(!1), requestAnimationFrame(() => F.current?.focus());
|
|
3473
3501
|
}
|
|
3474
3502
|
};
|
|
3475
|
-
return document.addEventListener("keydown",
|
|
3476
|
-
}, [
|
|
3503
|
+
return document.addEventListener("keydown", E), () => document.removeEventListener("keydown", E);
|
|
3504
|
+
}, [A, o, T]), /* @__PURE__ */ m(
|
|
3477
3505
|
"div",
|
|
3478
3506
|
{
|
|
3479
3507
|
className: "make-ai-assistant",
|
|
3480
|
-
"data-open":
|
|
3508
|
+
"data-open": T || void 0,
|
|
3481
3509
|
style: H,
|
|
3482
3510
|
children: [
|
|
3483
|
-
!t && (!
|
|
3511
|
+
!t && (!T || s) ? s ? s({ open: T, toggle: k }) : /* @__PURE__ */ m(
|
|
3484
3512
|
"button",
|
|
3485
3513
|
{
|
|
3486
|
-
"aria-label":
|
|
3487
|
-
"aria-expanded":
|
|
3514
|
+
"aria-label": T ? `关闭 ${v}` : `打开 ${v}`,
|
|
3515
|
+
"aria-expanded": T,
|
|
3488
3516
|
className: "make-ai-assistant__launcher",
|
|
3489
3517
|
"data-launcher-position": n,
|
|
3490
|
-
ref:
|
|
3518
|
+
ref: F,
|
|
3491
3519
|
type: "button",
|
|
3492
|
-
onClick:
|
|
3520
|
+
onClick: k,
|
|
3493
3521
|
children: [
|
|
3494
3522
|
/* @__PURE__ */ a("span", { className: "make-ai-assistant__launcher-orbit", "aria-hidden": "true" }),
|
|
3495
|
-
/* @__PURE__ */ a(
|
|
3523
|
+
/* @__PURE__ */ a(Ma, { "aria-hidden": "true" })
|
|
3496
3524
|
]
|
|
3497
3525
|
}
|
|
3498
3526
|
) : null,
|
|
3499
|
-
|
|
3527
|
+
N ? /* @__PURE__ */ a(
|
|
3500
3528
|
"aside",
|
|
3501
3529
|
{
|
|
3502
|
-
"aria-label":
|
|
3530
|
+
"aria-label": v,
|
|
3503
3531
|
"aria-modal": "false",
|
|
3504
|
-
className: `make-ai-assistant__drawer${
|
|
3505
|
-
hidden: !
|
|
3532
|
+
className: `make-ai-assistant__drawer${A ? " make-ai-assistant__drawer--fullscreen" : ""}`,
|
|
3533
|
+
hidden: !T,
|
|
3506
3534
|
role: "dialog",
|
|
3507
|
-
style:
|
|
3535
|
+
style: l,
|
|
3508
3536
|
children: /* @__PURE__ */ a(
|
|
3509
|
-
|
|
3537
|
+
ja,
|
|
3510
3538
|
{
|
|
3511
|
-
...
|
|
3512
|
-
isFullscreen:
|
|
3513
|
-
onClose: () =>
|
|
3514
|
-
onToggleFullscreen: () =>
|
|
3515
|
-
visible:
|
|
3539
|
+
...h,
|
|
3540
|
+
isFullscreen: A,
|
|
3541
|
+
onClose: () => c(!1),
|
|
3542
|
+
onToggleFullscreen: () => g((E) => !E),
|
|
3543
|
+
visible: T
|
|
3516
3544
|
}
|
|
3517
3545
|
)
|
|
3518
3546
|
}
|
|
@@ -3522,24 +3550,24 @@ function Cn({
|
|
|
3522
3550
|
);
|
|
3523
3551
|
}
|
|
3524
3552
|
export {
|
|
3525
|
-
|
|
3553
|
+
Za as ArtifactRenderer,
|
|
3526
3554
|
An as AssistantPanel,
|
|
3527
3555
|
Sn as MAKE_AI_ARTIFACT_KINDS,
|
|
3528
3556
|
Rn as MAKE_AI_ARTIFACT_LIMITS,
|
|
3529
3557
|
Ln as MAKE_AI_ARTIFACT_SCHEMA_VERSION,
|
|
3530
|
-
|
|
3558
|
+
ue as MAKE_AI_CONVERSATION_LIMITS,
|
|
3531
3559
|
Cn as MakeAiAssistant,
|
|
3532
3560
|
ta as appendUserMessage,
|
|
3533
|
-
|
|
3561
|
+
Ga as createArtifactCapabilities,
|
|
3534
3562
|
Qt as createArtifactTemplateRegistry,
|
|
3535
|
-
|
|
3536
|
-
|
|
3563
|
+
ye as createAssistantConversationState,
|
|
3564
|
+
rs as createPlatformArtifactRegistry,
|
|
3537
3565
|
En as extendArtifactTemplateRegistry,
|
|
3538
|
-
|
|
3566
|
+
xe as formatArtifactValue,
|
|
3539
3567
|
zn as parseArtifact,
|
|
3540
3568
|
ea as parseAssistantEvent,
|
|
3541
|
-
|
|
3542
|
-
|
|
3543
|
-
|
|
3569
|
+
is as platformArtifactTemplates,
|
|
3570
|
+
Ie as reduceAssistantEvent,
|
|
3571
|
+
Xa as resolveArtifactTemplate,
|
|
3544
3572
|
xn as validateArtifact
|
|
3545
3573
|
};
|