@qfei-design/make-ai-assistant 0.2.11 → 0.2.13
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 +5 -4
- package/README.md +6 -7
- package/dist/make-app.cjs +1 -1
- package/dist/make-app.d.ts +1 -1
- package/dist/make-app.mjs +418 -416
- package/dist/react/conversation-controls.d.ts +1 -1
- package/dist/react/use-attachments.d.ts +1 -0
- package/dist/react/use-conversation-manager.d.ts +2 -2
- package/dist/react.cjs +4 -4
- package/dist/react.mjs +1716 -1627
- package/dist/styles.css +368 -177
- package/docs/make-app-integration.md +5 -5
- package/examples/make-app/README.md +1 -1
- package/package.json +1 -1
package/dist/react.mjs
CHANGED
|
@@ -1,121 +1,122 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { isValidElement as
|
|
3
|
-
import { resolveArtifactTemplate as
|
|
4
|
-
import { extendArtifactTemplateRegistry as
|
|
5
|
-
import { n as
|
|
6
|
-
import { q as
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { jsxs as l, jsx as a, Fragment as Ne } from "react/jsx-runtime";
|
|
2
|
+
import { isValidElement as na, cloneElement as ra, useRef as S, useState as N, useEffect as ie, useLayoutEffect as gt, useId as ia, useMemo as Rt } from "react";
|
|
3
|
+
import { resolveArtifactTemplate as oa, createArtifactTemplateRegistry as Wt, createArtifactCapabilities as ca } from "./index.mjs";
|
|
4
|
+
import { extendArtifactTemplateRegistry as Cs } from "./index.mjs";
|
|
5
|
+
import { n as fe, k as ht, r as Me, l as Ot, o as Ht, c as it, M as ue } from "./conversation-CZfbgCXd.js";
|
|
6
|
+
import { q as Rs, s as Es, t as Ss, u as Ls, v as $s } from "./conversation-CZfbgCXd.js";
|
|
7
|
+
import { createPortal as la } from "react-dom";
|
|
8
|
+
const qt = (e) => e?.trim() || void 0, _e = (e, t) => qt(e) ?? t, yt = (e) => {
|
|
9
|
+
const t = qt(e?.primary);
|
|
9
10
|
if (t)
|
|
10
11
|
return {
|
|
11
12
|
"--make-ai-theme-primary": t,
|
|
12
|
-
"--make-ai-theme-primary-hover":
|
|
13
|
+
"--make-ai-theme-primary-hover": _e(
|
|
13
14
|
e?.primaryHover,
|
|
14
15
|
"color-mix(in srgb, var(--make-ai-theme-primary) 84%, #15233d)"
|
|
15
16
|
),
|
|
16
|
-
"--make-ai-theme-on-primary":
|
|
17
|
+
"--make-ai-theme-on-primary": _e(
|
|
17
18
|
e?.onPrimary,
|
|
18
19
|
"#fcfcff"
|
|
19
20
|
),
|
|
20
|
-
"--make-ai-theme-bg":
|
|
21
|
+
"--make-ai-theme-bg": _e(
|
|
21
22
|
e?.background,
|
|
22
23
|
"color-mix(in srgb, var(--make-ai-theme-primary) 2%, #fcfcff)"
|
|
23
24
|
),
|
|
24
|
-
"--make-ai-theme-surface":
|
|
25
|
+
"--make-ai-theme-surface": _e(
|
|
25
26
|
e?.surface,
|
|
26
27
|
"color-mix(in srgb, var(--make-ai-theme-primary) 4%, var(--make-ai-theme-bg))"
|
|
27
28
|
),
|
|
28
|
-
"--make-ai-theme-surface-strong":
|
|
29
|
+
"--make-ai-theme-surface-strong": _e(
|
|
29
30
|
e?.surfaceStrong,
|
|
30
31
|
"color-mix(in srgb, var(--make-ai-theme-primary) 8%, var(--make-ai-theme-bg))"
|
|
31
32
|
),
|
|
32
|
-
"--make-ai-theme-text":
|
|
33
|
+
"--make-ai-theme-text": _e(
|
|
33
34
|
e?.text,
|
|
34
35
|
"color-mix(in srgb, var(--make-ai-theme-primary) 12%, #252631)"
|
|
35
36
|
),
|
|
36
|
-
"--make-ai-theme-text-secondary":
|
|
37
|
+
"--make-ai-theme-text-secondary": _e(
|
|
37
38
|
e?.textSecondary,
|
|
38
39
|
"color-mix(in srgb, var(--make-ai-theme-text) 74%, var(--make-ai-theme-primary))"
|
|
39
40
|
),
|
|
40
|
-
"--make-ai-theme-border":
|
|
41
|
+
"--make-ai-theme-border": _e(
|
|
41
42
|
e?.border,
|
|
42
43
|
"color-mix(in srgb, var(--make-ai-theme-primary) 14%, var(--make-ai-theme-bg))"
|
|
43
44
|
),
|
|
44
|
-
"--make-ai-theme-overlay":
|
|
45
|
+
"--make-ai-theme-overlay": _e(
|
|
45
46
|
e?.overlay,
|
|
46
47
|
"color-mix(in srgb, var(--make-ai-theme-text) 88%, var(--make-ai-theme-primary))"
|
|
47
48
|
),
|
|
48
|
-
"--make-ai-theme-on-overlay":
|
|
49
|
+
"--make-ai-theme-on-overlay": _e(
|
|
49
50
|
e?.onOverlay,
|
|
50
51
|
"#fcfcff"
|
|
51
52
|
)
|
|
52
53
|
};
|
|
53
|
-
},
|
|
54
|
+
}, Et = (e, t) => !t || !na(e) || typeof e.type != "string" ? e : ra(e, {
|
|
54
55
|
style: { ...e.props.style, ...t }
|
|
55
56
|
});
|
|
56
|
-
function
|
|
57
|
+
function da({
|
|
57
58
|
artifact: e,
|
|
58
59
|
context: t,
|
|
59
|
-
fallback:
|
|
60
|
+
fallback: s,
|
|
60
61
|
onAction: i,
|
|
61
|
-
onActionError:
|
|
62
|
-
registry:
|
|
62
|
+
onActionError: o,
|
|
63
|
+
registry: c,
|
|
63
64
|
theme: d
|
|
64
65
|
}) {
|
|
65
|
-
const
|
|
66
|
-
if (!
|
|
67
|
-
const
|
|
66
|
+
const h = yt(d), b = oa(c, e, t);
|
|
67
|
+
if (!b) {
|
|
68
|
+
const L = s ? s(e) : /* @__PURE__ */ l("section", { className: "make-ai-artifact make-ai-artifact--unsupported", role: "status", children: [
|
|
68
69
|
/* @__PURE__ */ a("strong", { children: "暂不支持展示此结果" }),
|
|
69
|
-
/* @__PURE__ */
|
|
70
|
+
/* @__PURE__ */ l("span", { children: [
|
|
70
71
|
"结果类型:",
|
|
71
72
|
e.kind
|
|
72
73
|
] })
|
|
73
74
|
] });
|
|
74
|
-
return
|
|
75
|
+
return Et(L, h);
|
|
75
76
|
}
|
|
76
|
-
const
|
|
77
|
+
const f = {
|
|
77
78
|
context: t,
|
|
78
79
|
onAction: i,
|
|
79
|
-
onActionError:
|
|
80
|
+
onActionError: o,
|
|
80
81
|
theme: d,
|
|
81
|
-
themeStyle:
|
|
82
|
-
},
|
|
83
|
-
return
|
|
82
|
+
themeStyle: h
|
|
83
|
+
}, $ = b.template.render(e, t, f);
|
|
84
|
+
return Et($, h);
|
|
84
85
|
}
|
|
85
|
-
const
|
|
86
|
+
const $e = (e, t, s) => {
|
|
86
87
|
if (e == null || e === "") return "—";
|
|
87
88
|
if (typeof e == "boolean") return e ? "是" : "否";
|
|
88
89
|
if (typeof e != "number") return `${e}${t?.unit ?? ""}`;
|
|
89
|
-
const i = t?.precision,
|
|
90
|
+
const i = t?.precision, o = {
|
|
90
91
|
maximumFractionDigits: i ?? 2,
|
|
91
92
|
minimumFractionDigits: i
|
|
92
93
|
};
|
|
93
|
-
t?.style === "currency" && t.currency ? (
|
|
94
|
+
t?.style === "currency" && t.currency ? (o.style = "currency", o.currency = t.currency) : t?.style === "percent" && (o.style = "percent");
|
|
94
95
|
try {
|
|
95
|
-
const
|
|
96
|
-
return `${new Intl.NumberFormat(
|
|
96
|
+
const c = t?.style === "percent" ? e / 100 : e;
|
|
97
|
+
return `${new Intl.NumberFormat(s, o).format(c)}${t?.unit ?? ""}`;
|
|
97
98
|
} catch {
|
|
98
99
|
return `${e}${t?.unit ?? ""}`;
|
|
99
100
|
}
|
|
100
|
-
},
|
|
101
|
-
let t = Number.POSITIVE_INFINITY,
|
|
101
|
+
}, Kt = (e) => {
|
|
102
|
+
let t = Number.POSITIVE_INFINITY, s = Number.NEGATIVE_INFINITY;
|
|
102
103
|
for (const i of e)
|
|
103
|
-
t = Math.min(t, i),
|
|
104
|
-
return Number.isFinite(t) && Number.isFinite(
|
|
105
|
-
},
|
|
106
|
-
if (!
|
|
107
|
-
const i = (
|
|
104
|
+
t = Math.min(t, i), s = Math.max(s, i);
|
|
105
|
+
return Number.isFinite(t) && Number.isFinite(s) ? { min: t, max: s } : { min: 0, max: 0 };
|
|
106
|
+
}, jt = (e, t, s) => {
|
|
107
|
+
if (!s.onAction) return;
|
|
108
|
+
const i = (c) => {
|
|
108
109
|
console.error("[make-ai-assistant] host action error handler failed", {
|
|
109
110
|
actionId: e.id,
|
|
110
111
|
artifactId: t.artifact.id,
|
|
111
|
-
errorType:
|
|
112
|
+
errorType: c instanceof Error ? c.name : typeof c,
|
|
112
113
|
intent: e.intent
|
|
113
114
|
});
|
|
114
|
-
},
|
|
115
|
-
if (
|
|
115
|
+
}, o = (c) => {
|
|
116
|
+
if (s.onActionError) {
|
|
116
117
|
try {
|
|
117
118
|
Promise.resolve(
|
|
118
|
-
|
|
119
|
+
s.onActionError(c, e, t)
|
|
119
120
|
).catch(i);
|
|
120
121
|
} catch (d) {
|
|
121
122
|
i(d);
|
|
@@ -125,32 +126,32 @@ const Fe = (e, t, n) => {
|
|
|
125
126
|
console.error("[make-ai-assistant] host action failed", {
|
|
126
127
|
actionId: e.id,
|
|
127
128
|
artifactId: t.artifact.id,
|
|
128
|
-
errorType:
|
|
129
|
+
errorType: c instanceof Error ? c.name : typeof c,
|
|
129
130
|
intent: e.intent
|
|
130
131
|
});
|
|
131
132
|
};
|
|
132
133
|
try {
|
|
133
|
-
Promise.resolve(
|
|
134
|
-
} catch (
|
|
135
|
-
|
|
134
|
+
Promise.resolve(s.onAction(e, t)).catch(o);
|
|
135
|
+
} catch (c) {
|
|
136
|
+
o(c);
|
|
136
137
|
}
|
|
137
|
-
},
|
|
138
|
+
}, ze = (e, t) => e.actions?.length && t.onAction ? /* @__PURE__ */ a("div", { className: "make-ai-artifact__actions", children: e.actions.map((s) => /* @__PURE__ */ l(
|
|
138
139
|
"button",
|
|
139
140
|
{
|
|
140
|
-
className: `make-ai-artifact__action make-ai-artifact__action--${
|
|
141
|
+
className: `make-ai-artifact__action make-ai-artifact__action--${s.appearance ?? "link"}`,
|
|
141
142
|
type: "button",
|
|
142
|
-
onClick: () =>
|
|
143
|
+
onClick: () => jt(s, { artifact: e, context: t.context }, t),
|
|
143
144
|
children: [
|
|
144
|
-
|
|
145
|
+
s.label,
|
|
145
146
|
/* @__PURE__ */ a("span", { "aria-hidden": "true", children: "→" })
|
|
146
147
|
]
|
|
147
148
|
},
|
|
148
|
-
|
|
149
|
-
)) }) : null,
|
|
149
|
+
s.id
|
|
150
|
+
)) }) : null, We = (e, t, s = "", i) => /* @__PURE__ */ l(
|
|
150
151
|
"section",
|
|
151
152
|
{
|
|
152
153
|
"aria-label": e.title ?? `${e.kind} result`,
|
|
153
|
-
className: `make-ai-artifact ${
|
|
154
|
+
className: `make-ai-artifact ${s}`.trim(),
|
|
154
155
|
"data-artifact-density": e.presentation?.density,
|
|
155
156
|
"data-artifact-kind": e.kind,
|
|
156
157
|
style: i,
|
|
@@ -160,141 +161,141 @@ const Fe = (e, t, n) => {
|
|
|
160
161
|
t
|
|
161
162
|
]
|
|
162
163
|
}
|
|
163
|
-
),
|
|
164
|
+
), ua = ({
|
|
164
165
|
artifact: e,
|
|
165
166
|
renderContext: t
|
|
166
167
|
}) => {
|
|
167
|
-
const
|
|
168
|
-
|
|
169
|
-
|
|
168
|
+
const s = e.data.delta, i = s ? $e(
|
|
169
|
+
s.value,
|
|
170
|
+
s.format === "percent" ? { style: "percent" } : void 0,
|
|
170
171
|
t.context.locale
|
|
171
172
|
) : void 0;
|
|
172
|
-
return
|
|
173
|
+
return We(
|
|
173
174
|
e,
|
|
174
|
-
/* @__PURE__ */
|
|
175
|
-
/* @__PURE__ */ a("div", { className: "make-ai-artifact__metric-value", children:
|
|
175
|
+
/* @__PURE__ */ l(Ne, { children: [
|
|
176
|
+
/* @__PURE__ */ a("div", { className: "make-ai-artifact__metric-value", children: $e(
|
|
176
177
|
e.data.value,
|
|
177
178
|
e.data.format,
|
|
178
179
|
t.context.locale
|
|
179
180
|
) }),
|
|
180
|
-
|
|
181
|
+
s ? /* @__PURE__ */ l(
|
|
181
182
|
"div",
|
|
182
183
|
{
|
|
183
|
-
className: `make-ai-artifact__delta make-ai-artifact__delta--${
|
|
184
|
+
className: `make-ai-artifact__delta make-ai-artifact__delta--${s.direction ?? "flat"}`,
|
|
184
185
|
children: [
|
|
185
|
-
/* @__PURE__ */ a("span", { "aria-hidden": "true", children:
|
|
186
|
+
/* @__PURE__ */ a("span", { "aria-hidden": "true", children: s.direction === "up" ? "↗" : s.direction === "down" ? "↘" : "→" }),
|
|
186
187
|
/* @__PURE__ */ a("span", { children: i }),
|
|
187
|
-
|
|
188
|
+
s.label ? /* @__PURE__ */ a("span", { children: s.label }) : null
|
|
188
189
|
]
|
|
189
190
|
}
|
|
190
191
|
) : null,
|
|
191
192
|
e.data.context ? /* @__PURE__ */ a("p", { className: "make-ai-artifact__context", children: e.data.context }) : null,
|
|
192
|
-
|
|
193
|
+
ze(e, t)
|
|
193
194
|
] }),
|
|
194
195
|
"make-ai-artifact--metric",
|
|
195
196
|
t.themeStyle
|
|
196
197
|
);
|
|
197
|
-
},
|
|
198
|
+
}, ma = ({
|
|
198
199
|
artifact: e,
|
|
199
200
|
renderContext: t
|
|
200
|
-
}) =>
|
|
201
|
+
}) => We(
|
|
201
202
|
e,
|
|
202
|
-
/* @__PURE__ */
|
|
203
|
-
/* @__PURE__ */ a("div", { className: "make-ai-artifact__comparison", children: e.data.items.map((
|
|
204
|
-
/* @__PURE__ */ a("span", { children:
|
|
205
|
-
/* @__PURE__ */ a("strong", { children:
|
|
206
|
-
|
|
207
|
-
] },
|
|
208
|
-
|
|
203
|
+
/* @__PURE__ */ l(Ne, { children: [
|
|
204
|
+
/* @__PURE__ */ a("div", { className: "make-ai-artifact__comparison", children: e.data.items.map((s) => /* @__PURE__ */ l("div", { className: "make-ai-artifact__comparison-item", children: [
|
|
205
|
+
/* @__PURE__ */ a("span", { children: s.label }),
|
|
206
|
+
/* @__PURE__ */ a("strong", { children: $e(s.value, s.format, t.context.locale) }),
|
|
207
|
+
s.hint ? /* @__PURE__ */ a("small", { children: s.hint }) : null
|
|
208
|
+
] }, s.id)) }),
|
|
209
|
+
ze(e, t)
|
|
209
210
|
] }),
|
|
210
211
|
"make-ai-artifact--comparison",
|
|
211
212
|
t.themeStyle
|
|
212
|
-
),
|
|
213
|
+
), ha = ({
|
|
213
214
|
artifact: e,
|
|
214
215
|
renderContext: t
|
|
215
216
|
}) => {
|
|
216
|
-
const
|
|
217
|
-
return
|
|
217
|
+
const s = e.data.series.flatMap((d) => d.points.map((h) => h.y)), { max: i, min: o } = Kt(s), c = i - o || 1;
|
|
218
|
+
return We(
|
|
218
219
|
e,
|
|
219
|
-
/* @__PURE__ */
|
|
220
|
-
/* @__PURE__ */ a("div", { className: "make-ai-artifact__trend", children: e.data.series.map((d) => /* @__PURE__ */
|
|
220
|
+
/* @__PURE__ */ l(Ne, { children: [
|
|
221
|
+
/* @__PURE__ */ a("div", { className: "make-ai-artifact__trend", children: e.data.series.map((d) => /* @__PURE__ */ l("div", { className: "make-ai-artifact__trend-series", children: [
|
|
221
222
|
/* @__PURE__ */ a("div", { className: "make-ai-artifact__trend-label", children: d.label }),
|
|
222
|
-
/* @__PURE__ */ a("div", { className: "make-ai-artifact__trend-bars", children: d.points.map((
|
|
223
|
-
const
|
|
224
|
-
return /* @__PURE__ */
|
|
223
|
+
/* @__PURE__ */ a("div", { className: "make-ai-artifact__trend-bars", children: d.points.map((h, b) => {
|
|
224
|
+
const f = 18 + (h.y - o) / c * 70;
|
|
225
|
+
return /* @__PURE__ */ l("div", { className: "make-ai-artifact__trend-point", children: [
|
|
225
226
|
/* @__PURE__ */ a(
|
|
226
227
|
"span",
|
|
227
228
|
{
|
|
228
|
-
"aria-label": `${
|
|
229
|
-
|
|
229
|
+
"aria-label": `${h.x}: ${$e(
|
|
230
|
+
h.y,
|
|
230
231
|
d.format,
|
|
231
232
|
t.context.locale
|
|
232
233
|
)}`,
|
|
233
234
|
className: "make-ai-artifact__trend-bar",
|
|
234
235
|
role: "img",
|
|
235
|
-
style: { height: `${
|
|
236
|
-
title: `${
|
|
237
|
-
|
|
236
|
+
style: { height: `${f}%` },
|
|
237
|
+
title: `${h.x}: ${$e(
|
|
238
|
+
h.y,
|
|
238
239
|
d.format,
|
|
239
240
|
t.context.locale
|
|
240
241
|
)}`
|
|
241
242
|
}
|
|
242
243
|
),
|
|
243
|
-
/* @__PURE__ */ a("small", { children:
|
|
244
|
-
] }, `${
|
|
244
|
+
/* @__PURE__ */ a("small", { children: h.x })
|
|
245
|
+
] }, `${h.x}-${b}`);
|
|
245
246
|
}) })
|
|
246
247
|
] }, d.id)) }),
|
|
247
|
-
|
|
248
|
+
ze(e, t)
|
|
248
249
|
] }),
|
|
249
250
|
"make-ai-artifact--trend",
|
|
250
251
|
t.themeStyle
|
|
251
252
|
);
|
|
252
|
-
},
|
|
253
|
+
}, pa = ({
|
|
253
254
|
artifact: e,
|
|
254
255
|
renderContext: t
|
|
255
256
|
}) => {
|
|
256
|
-
const { max:
|
|
257
|
-
e.data.items.map((
|
|
258
|
-
), i = Math.max(
|
|
259
|
-
return
|
|
257
|
+
const { max: s } = Kt(
|
|
258
|
+
e.data.items.map((o) => Math.abs(o.value))
|
|
259
|
+
), i = Math.max(s, 1);
|
|
260
|
+
return We(
|
|
260
261
|
e,
|
|
261
|
-
/* @__PURE__ */
|
|
262
|
-
/* @__PURE__ */ a("ol", { className: "make-ai-artifact__ranking", children: e.data.items.map((
|
|
263
|
-
/* @__PURE__ */ a("span", { className: "make-ai-artifact__rank", children:
|
|
264
|
-
/* @__PURE__ */
|
|
265
|
-
/* @__PURE__ */ a("span", { children:
|
|
266
|
-
|
|
262
|
+
/* @__PURE__ */ l(Ne, { children: [
|
|
263
|
+
/* @__PURE__ */ a("ol", { className: "make-ai-artifact__ranking", children: e.data.items.map((o, c) => /* @__PURE__ */ l("li", { children: [
|
|
264
|
+
/* @__PURE__ */ a("span", { className: "make-ai-artifact__rank", children: c + 1 }),
|
|
265
|
+
/* @__PURE__ */ l("span", { className: "make-ai-artifact__ranking-label", children: [
|
|
266
|
+
/* @__PURE__ */ a("span", { children: o.label }),
|
|
267
|
+
o.description ? /* @__PURE__ */ a("small", { children: o.description }) : null
|
|
267
268
|
] }),
|
|
268
|
-
/* @__PURE__ */ a("span", { className: "make-ai-artifact__ranking-track", "aria-hidden": "true", children: /* @__PURE__ */ a("span", { style: { width: `${Math.abs(
|
|
269
|
-
/* @__PURE__ */ a("strong", { children:
|
|
270
|
-
] },
|
|
271
|
-
|
|
269
|
+
/* @__PURE__ */ a("span", { className: "make-ai-artifact__ranking-track", "aria-hidden": "true", children: /* @__PURE__ */ a("span", { style: { width: `${Math.abs(o.value) / i * 100}%` } }) }),
|
|
270
|
+
/* @__PURE__ */ a("strong", { children: $e(o.value, o.format, t.context.locale) })
|
|
271
|
+
] }, o.id)) }),
|
|
272
|
+
ze(e, t)
|
|
272
273
|
] }),
|
|
273
274
|
"make-ai-artifact--ranking",
|
|
274
275
|
t.themeStyle
|
|
275
276
|
);
|
|
276
|
-
},
|
|
277
|
+
}, fa = (e, t) => t.action ?? {
|
|
277
278
|
id: `open-${t.id}`,
|
|
278
279
|
label: t.title ?? t.id,
|
|
279
280
|
intent: "open-record",
|
|
280
281
|
target: { entityKey: e.data.entity.key, recordId: t.id }
|
|
281
|
-
},
|
|
282
|
+
}, va = ({
|
|
282
283
|
artifact: e,
|
|
283
284
|
renderContext: t
|
|
284
|
-
}) =>
|
|
285
|
+
}) => We(
|
|
285
286
|
e,
|
|
286
|
-
/* @__PURE__ */
|
|
287
|
-
/* @__PURE__ */ a("div", { className: "make-ai-artifact__record-list", children: e.data.records.length === 0 ? /* @__PURE__ */ a("p", { className: "make-ai-artifact__empty", children: "没有符合条件的记录" }) : e.data.records.map((
|
|
288
|
-
const i =
|
|
289
|
-
/* @__PURE__ */ a("strong", { children:
|
|
290
|
-
/* @__PURE__ */ a("span", { className: "make-ai-artifact__record-values", children: e.data.columns.map((
|
|
291
|
-
/* @__PURE__ */ a("small", { children:
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
287
|
+
/* @__PURE__ */ l(Ne, { children: [
|
|
288
|
+
/* @__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) => {
|
|
289
|
+
const i = fa(e, s), o = /* @__PURE__ */ l(Ne, { children: [
|
|
290
|
+
/* @__PURE__ */ a("strong", { children: s.title ?? s.id }),
|
|
291
|
+
/* @__PURE__ */ a("span", { className: "make-ai-artifact__record-values", children: e.data.columns.map((c) => /* @__PURE__ */ l("span", { children: [
|
|
292
|
+
/* @__PURE__ */ a("small", { children: c.label }),
|
|
293
|
+
$e(
|
|
294
|
+
s.values[c.key],
|
|
295
|
+
c.format,
|
|
295
296
|
t.context.locale
|
|
296
297
|
)
|
|
297
|
-
] },
|
|
298
|
+
] }, c.key)) }),
|
|
298
299
|
t.onAction ? /* @__PURE__ */ a("span", { "aria-hidden": "true", children: "›" }) : null
|
|
299
300
|
] });
|
|
300
301
|
return t.onAction ? /* @__PURE__ */ a(
|
|
@@ -302,244 +303,254 @@ const Fe = (e, t, n) => {
|
|
|
302
303
|
{
|
|
303
304
|
className: "make-ai-artifact__record",
|
|
304
305
|
type: "button",
|
|
305
|
-
onClick: () =>
|
|
306
|
+
onClick: () => jt(i, {
|
|
306
307
|
artifact: e,
|
|
307
308
|
context: t.context
|
|
308
309
|
}, t),
|
|
309
|
-
children:
|
|
310
|
+
children: o
|
|
310
311
|
},
|
|
311
|
-
|
|
312
|
-
) : /* @__PURE__ */ a("div", { className: "make-ai-artifact__record", children:
|
|
312
|
+
s.id
|
|
313
|
+
) : /* @__PURE__ */ a("div", { className: "make-ai-artifact__record", children: o }, s.id);
|
|
313
314
|
}) }),
|
|
314
|
-
e.data.total !== void 0 ? /* @__PURE__ */
|
|
315
|
+
e.data.total !== void 0 ? /* @__PURE__ */ l("p", { className: "make-ai-artifact__record-total", children: [
|
|
315
316
|
"共 ",
|
|
316
317
|
e.data.total,
|
|
317
318
|
" 条"
|
|
318
319
|
] }) : null,
|
|
319
|
-
|
|
320
|
+
ze(e, t)
|
|
320
321
|
] }),
|
|
321
322
|
"make-ai-artifact--record-list",
|
|
322
323
|
t.themeStyle
|
|
323
|
-
),
|
|
324
|
+
), ga = ({
|
|
324
325
|
artifact: e,
|
|
325
326
|
renderContext: t
|
|
326
|
-
}) =>
|
|
327
|
+
}) => We(
|
|
327
328
|
e,
|
|
328
|
-
/* @__PURE__ */
|
|
329
|
-
/* @__PURE__ */
|
|
329
|
+
/* @__PURE__ */ l(Ne, { children: [
|
|
330
|
+
/* @__PURE__ */ l("div", { className: `make-ai-artifact__notice make-ai-artifact__notice--${e.data.tone}`, children: [
|
|
330
331
|
/* @__PURE__ */ a("span", { "aria-hidden": "true", children: e.data.tone === "success" ? "✓" : e.data.tone === "warning" ? "!" : e.data.tone === "danger" ? "×" : "i" }),
|
|
331
332
|
/* @__PURE__ */ a("p", { children: e.data.body })
|
|
332
333
|
] }),
|
|
333
|
-
|
|
334
|
+
ze(e, t)
|
|
334
335
|
] }),
|
|
335
336
|
"make-ai-artifact--notice",
|
|
336
337
|
t.themeStyle
|
|
337
|
-
),
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
],
|
|
345
|
-
const t = e,
|
|
346
|
-
return
|
|
338
|
+
), Fe = (e, t, s) => ({ id: e, kinds: [t], priority: 0, render: s }), ya = [
|
|
339
|
+
Fe("platform.metric.default", "metric", (e, t, s) => /* @__PURE__ */ a(ua, { artifact: e, renderContext: s })),
|
|
340
|
+
Fe("platform.comparison.default", "comparison", (e, t, s) => /* @__PURE__ */ a(ma, { artifact: e, renderContext: s })),
|
|
341
|
+
Fe("platform.trend.default", "trend", (e, t, s) => /* @__PURE__ */ a(ha, { artifact: e, renderContext: s })),
|
|
342
|
+
Fe("platform.ranking.default", "ranking", (e, t, s) => /* @__PURE__ */ a(pa, { artifact: e, renderContext: s })),
|
|
343
|
+
Fe("platform.record-list.default", "record-list", (e, t, s) => /* @__PURE__ */ a(va, { artifact: e, renderContext: s })),
|
|
344
|
+
Fe("platform.notice.default", "notice", (e, t, s) => /* @__PURE__ */ a(ga, { artifact: e, renderContext: s }))
|
|
345
|
+
], ba = Wt(ya).templates, ka = (e = ba) => Wt(e), Pe = () => globalThis.crypto.randomUUID(), bt = (e) => {
|
|
346
|
+
const t = e, s = t?.status ?? t?.response?.status;
|
|
347
|
+
return s === 409 ? "数据已变化或对话仍在运行,请刷新后重试" : s === 401 || t?.code === "AI_AUTH_REQUIRED" || t?.code === "AI_AUTH_EXPIRED" ? "登录已失效,请重新登录" : s === 403 ? "当前账号无权访问该对话" : s === 404 ? "对话或回答已不可见,请刷新列表" : t?.message?.startsWith("输入内容过长") ? t.message : "操作未完成,请重试或刷新对话";
|
|
347
348
|
};
|
|
348
|
-
function
|
|
349
|
-
const
|
|
350
|
-
|
|
351
|
-
const
|
|
352
|
-
const
|
|
353
|
-
|
|
354
|
-
}, [
|
|
349
|
+
function _a(e, t) {
|
|
350
|
+
const s = t.features?.conversationManagement === !0, i = s ? t.scopeKey?.(e) ?? e.app.id : "", o = S(i);
|
|
351
|
+
o.current = i;
|
|
352
|
+
const c = S(i), [d, h] = N(fe), b = S(d), f = (r) => {
|
|
353
|
+
const u = typeof r == "function" ? r(b.current) : r;
|
|
354
|
+
b.current = u, h(u);
|
|
355
|
+
}, [$, L] = N([]), [T, j] = N(), M = S(void 0), [U, g] = N(""), [R, P] = N(-1), [p, n] = N(!1), [v, k] = N(!1), [q, I] = N(s), [G, Y] = N(!1), [z, Q] = N(), [ve, oe] = N([]), [F, ne] = N([]), ce = S(/* @__PURE__ */ new Set()), V = S(/* @__PURE__ */ new Map()), B = S(0), A = S(0), W = S(0), ae = S(void 0), ge = S(void 0), Re = S(/* @__PURE__ */ new Map()), x = (r, u = i) => A.current === r && o.current === u, ee = () => {
|
|
355
356
|
const r = new AbortController();
|
|
356
|
-
return
|
|
357
|
-
},
|
|
358
|
-
|
|
359
|
-
},
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
357
|
+
return ce.current.add(r), r;
|
|
358
|
+
}, le = (r) => ce.current.delete(r), de = (r) => {
|
|
359
|
+
M.current = r, j(r);
|
|
360
|
+
}, lt = (r) => {
|
|
361
|
+
L(
|
|
362
|
+
(u) => u.map((y) => y.chatId === r.chatId ? r : y)
|
|
363
|
+
);
|
|
364
|
+
}, ye = (r) => {
|
|
365
|
+
L(
|
|
366
|
+
(u) => u.filter((y) => y.chatId !== r)
|
|
367
|
+
);
|
|
368
|
+
}, we = () => {
|
|
369
|
+
W.current += 1;
|
|
370
|
+
}, be = () => {
|
|
371
|
+
for (const r of V.current.values()) r.abort();
|
|
372
|
+
V.current.clear();
|
|
373
|
+
}, te = (r) => {
|
|
363
374
|
r instanceof Error && r.name === "AbortError" || (console.warn("[make-ai-assistant] conversation operation failed", {
|
|
364
375
|
errorType: r instanceof Error ? r.name : typeof r
|
|
365
|
-
}),
|
|
366
|
-
},
|
|
367
|
-
if (!
|
|
368
|
-
const
|
|
376
|
+
}), Q(bt(r)));
|
|
377
|
+
}, Ce = async (r) => {
|
|
378
|
+
if (!s || !t.listConversations) return;
|
|
379
|
+
const u = A.current, y = ++W.current, w = ee();
|
|
369
380
|
try {
|
|
370
|
-
const
|
|
381
|
+
const C = await t.listConversations(
|
|
371
382
|
e,
|
|
372
383
|
{ cursor: r },
|
|
373
|
-
{ signal:
|
|
384
|
+
{ signal: w.signal }
|
|
374
385
|
);
|
|
375
|
-
if (!
|
|
386
|
+
if (!x(u) || w.signal.aborted || y !== W.current)
|
|
376
387
|
return;
|
|
377
|
-
|
|
388
|
+
L((D) => [
|
|
378
389
|
...new Map(
|
|
379
|
-
[...r ?
|
|
380
|
-
|
|
381
|
-
|
|
390
|
+
[...r ? D : [], ...C.chats].map((_) => [
|
|
391
|
+
_.chatId,
|
|
392
|
+
_
|
|
382
393
|
])
|
|
383
394
|
).values()
|
|
384
|
-
]),
|
|
385
|
-
} catch (
|
|
386
|
-
|
|
395
|
+
]), g(C.nextCursor);
|
|
396
|
+
} catch (C) {
|
|
397
|
+
x(u) && !w.signal.aborted && y === W.current && te(C);
|
|
387
398
|
} finally {
|
|
388
|
-
|
|
399
|
+
le(w), x(u) && y === W.current && I(!1);
|
|
389
400
|
}
|
|
390
|
-
},
|
|
391
|
-
const
|
|
392
|
-
let
|
|
401
|
+
}, ke = async (r, u, y) => {
|
|
402
|
+
const w = A.current, C = B.current;
|
|
403
|
+
let D;
|
|
393
404
|
try {
|
|
394
|
-
for await (const
|
|
395
|
-
if (!
|
|
405
|
+
for await (const _ of r) {
|
|
406
|
+
if (!x(w) || u.signal.aborted || C !== B.current || M.current?.chatId !== y)
|
|
396
407
|
return;
|
|
397
|
-
const
|
|
398
|
-
if (
|
|
399
|
-
|
|
400
|
-
const
|
|
401
|
-
if (
|
|
402
|
-
|
|
408
|
+
const Z = Ot(_);
|
|
409
|
+
if (Z.type === "response.accepted" || Z.type === "response.state") {
|
|
410
|
+
D = Z.responseId;
|
|
411
|
+
const O = V.current.get(D);
|
|
412
|
+
if (O && O !== u) {
|
|
413
|
+
Z.type === "response.accepted" && f((H) => Me(H, Z)), u.abort();
|
|
403
414
|
return;
|
|
404
415
|
}
|
|
405
|
-
|
|
416
|
+
V.current.set(D, u);
|
|
406
417
|
}
|
|
407
|
-
|
|
418
|
+
f((O) => Me(O, Z)), Z.type === "response.terminal" && (oe((O) => O.filter((H) => H !== Z.responseId)), Ce());
|
|
408
419
|
}
|
|
409
|
-
} catch (
|
|
410
|
-
|
|
411
|
-
...
|
|
412
|
-
status: Object.values(
|
|
413
|
-
(
|
|
420
|
+
} catch (_) {
|
|
421
|
+
x(w) && !u.signal.aborted && C === B.current && (te(_), D || f((Z) => ({
|
|
422
|
+
...Z,
|
|
423
|
+
status: Object.values(Z.responses ?? {}).some(
|
|
424
|
+
(O) => !ht(O.status)
|
|
414
425
|
) ? "streaming" : "error"
|
|
415
426
|
})));
|
|
416
427
|
} finally {
|
|
417
|
-
|
|
428
|
+
D && V.current.get(D) === u && V.current.delete(D), le(u);
|
|
418
429
|
}
|
|
419
|
-
},
|
|
430
|
+
}, Oe = async (r, u, y, w) => {
|
|
420
431
|
if (!t.getResponse || !t.watchResponse) return;
|
|
421
|
-
const
|
|
422
|
-
r.filter((
|
|
423
|
-
),
|
|
432
|
+
const C = new Set(
|
|
433
|
+
r.filter((_) => _.role === "assistant" && _.persistent).map((_) => _.responseId)
|
|
434
|
+
), D = [
|
|
424
435
|
...new Map(
|
|
425
436
|
r.filter(
|
|
426
|
-
(
|
|
427
|
-
).map((
|
|
437
|
+
(_) => _.role === "user" && _.responseId && !C.has(_.responseId)
|
|
438
|
+
).map((_) => [_.responseId, _.cursor ?? -1])
|
|
428
439
|
).entries()
|
|
429
440
|
].slice(-20);
|
|
430
|
-
for (const [
|
|
431
|
-
if (!
|
|
432
|
-
if (
|
|
433
|
-
const
|
|
441
|
+
for (const [_, Z] of D) {
|
|
442
|
+
if (!x(w) || y !== B.current) return;
|
|
443
|
+
if (V.current.has(_)) continue;
|
|
444
|
+
const O = ee();
|
|
434
445
|
try {
|
|
435
|
-
const
|
|
446
|
+
const H = await t.getResponse(
|
|
436
447
|
e,
|
|
437
|
-
{ chatId:
|
|
438
|
-
{ signal:
|
|
448
|
+
{ chatId: u, responseId: _ },
|
|
449
|
+
{ signal: O.signal }
|
|
439
450
|
);
|
|
440
|
-
if (!
|
|
441
|
-
|
|
442
|
-
(
|
|
443
|
-
|
|
444
|
-
|
|
451
|
+
if (!x(w) || O.signal.aborted || y !== B.current || V.current.has(_)) continue;
|
|
452
|
+
f(
|
|
453
|
+
(Ie) => Me(
|
|
454
|
+
Ie,
|
|
455
|
+
ht(H.status) ? { type: "response.snapshot", snapshot: H } : {
|
|
445
456
|
type: "response.state",
|
|
446
|
-
chatId:
|
|
447
|
-
responseId:
|
|
448
|
-
status:
|
|
457
|
+
chatId: u,
|
|
458
|
+
responseId: _,
|
|
459
|
+
status: H.status
|
|
449
460
|
}
|
|
450
461
|
)
|
|
451
|
-
),
|
|
452
|
-
(
|
|
462
|
+
), H.status === "failed" || H.status === "cancelled" ? f(
|
|
463
|
+
(Ie) => Me(Ie, {
|
|
453
464
|
type: "response.terminal",
|
|
454
|
-
chatId:
|
|
455
|
-
responseId:
|
|
456
|
-
status:
|
|
465
|
+
chatId: u,
|
|
466
|
+
responseId: _,
|
|
467
|
+
status: H.status
|
|
457
468
|
})
|
|
458
|
-
) : (
|
|
469
|
+
) : (V.current.set(_, O), ke(
|
|
459
470
|
t.watchResponse(
|
|
460
471
|
e,
|
|
461
|
-
{ chatId:
|
|
462
|
-
{ signal:
|
|
472
|
+
{ chatId: u, responseId: _, historyCursor: Z },
|
|
473
|
+
{ signal: O.signal }
|
|
463
474
|
),
|
|
464
|
-
|
|
465
|
-
|
|
475
|
+
O,
|
|
476
|
+
u
|
|
466
477
|
));
|
|
467
|
-
} catch (
|
|
468
|
-
|
|
478
|
+
} catch (H) {
|
|
479
|
+
x(w) && !O.signal.aborted && te(H);
|
|
469
480
|
} finally {
|
|
470
|
-
|
|
481
|
+
V.current.get(_) !== O && le(O);
|
|
471
482
|
}
|
|
472
483
|
}
|
|
473
|
-
},
|
|
474
|
-
const
|
|
475
|
-
|
|
484
|
+
}, He = async (r) => {
|
|
485
|
+
const u = ++B.current, y = A.current, w = ee();
|
|
486
|
+
be(), Q(void 0), I(!0), oe([]), ge.current = void 0, de(r), f({ messages: [], status: "idle", threadId: r.chatId }), P(-1), n(!1), k(!1);
|
|
476
487
|
try {
|
|
477
|
-
const [
|
|
488
|
+
const [C, D] = await Promise.all([
|
|
478
489
|
t.getConversation(
|
|
479
490
|
e,
|
|
480
491
|
{ chatId: r.chatId },
|
|
481
|
-
{ signal:
|
|
492
|
+
{ signal: w.signal }
|
|
482
493
|
),
|
|
483
494
|
t.loadConversation(e, {
|
|
484
495
|
threadId: r.chatId,
|
|
485
496
|
cursor: -1,
|
|
486
|
-
signal:
|
|
497
|
+
signal: w.signal
|
|
487
498
|
})
|
|
488
499
|
]);
|
|
489
|
-
if (!
|
|
500
|
+
if (!x(y) || w.signal.aborted || u !== B.current)
|
|
490
501
|
return;
|
|
491
|
-
if (
|
|
502
|
+
if (C.chatId !== r.chatId || D.threadId !== r.chatId)
|
|
492
503
|
throw new Error("Conversation mismatch");
|
|
493
|
-
|
|
494
|
-
} catch (
|
|
495
|
-
|
|
504
|
+
de(C), f(fe(D)), P(D.nextCursor ?? -1), n(D.hasMore ?? !1), Oe(D.messages, r.chatId, u, y);
|
|
505
|
+
} catch (C) {
|
|
506
|
+
x(y) && !w.signal.aborted && u === B.current && te(C);
|
|
496
507
|
} finally {
|
|
497
|
-
|
|
508
|
+
le(w), x(y) && u === B.current && I(!1);
|
|
498
509
|
}
|
|
499
|
-
},
|
|
500
|
-
if (
|
|
501
|
-
if (
|
|
502
|
-
const r =
|
|
503
|
-
return
|
|
510
|
+
}, Ee = async () => {
|
|
511
|
+
if (M.current) return M.current;
|
|
512
|
+
if (ae.current ??= { requestId: Pe() }, ae.current.promise) return ae.current.promise;
|
|
513
|
+
const r = A.current, u = B.current, y = ee(), w = ae.current;
|
|
514
|
+
return Y(!0), w.promise = t.createConversation(
|
|
504
515
|
e,
|
|
505
|
-
{ requestId:
|
|
506
|
-
{ signal:
|
|
507
|
-
).then((
|
|
508
|
-
if (!
|
|
516
|
+
{ requestId: w.requestId },
|
|
517
|
+
{ signal: y.signal }
|
|
518
|
+
).then((C) => {
|
|
519
|
+
if (!x(r) || y.signal.aborted || u !== B.current)
|
|
509
520
|
throw Object.assign(new Error("Stale create"), {
|
|
510
521
|
name: "AbortError"
|
|
511
522
|
});
|
|
512
|
-
return
|
|
523
|
+
return ae.current = void 0, de(C), f({ messages: [], status: "idle", threadId: C.chatId }), Ce(), C;
|
|
513
524
|
}).finally(() => {
|
|
514
|
-
|
|
515
|
-
}),
|
|
516
|
-
},
|
|
517
|
-
if (!(
|
|
518
|
-
|
|
525
|
+
le(y), w.promise = void 0, x(r) && Y(!1);
|
|
526
|
+
}), w.promise;
|
|
527
|
+
}, Xe = async () => {
|
|
528
|
+
if (!(G || ae.current?.promise)) {
|
|
529
|
+
B.current += 1, be(), de(void 0), Q(void 0), ge.current = void 0, f(fe()), n(!1), P(-1);
|
|
519
530
|
try {
|
|
520
|
-
await
|
|
531
|
+
await Ee();
|
|
521
532
|
} catch (r) {
|
|
522
|
-
|
|
533
|
+
te(r);
|
|
523
534
|
}
|
|
524
535
|
}
|
|
525
|
-
},
|
|
526
|
-
const
|
|
527
|
-
|
|
528
|
-
t.run(r, { signal:
|
|
529
|
-
|
|
536
|
+
}, me = async (r) => {
|
|
537
|
+
const u = ee();
|
|
538
|
+
ge.current = r, Q(void 0), b.current.messages.some((y) => y.id === r.message.id) || f((y) => Ht(y, r.message)), await ke(
|
|
539
|
+
t.run(r, { signal: u.signal }),
|
|
540
|
+
u,
|
|
530
541
|
r.threadId
|
|
531
542
|
);
|
|
532
|
-
},
|
|
533
|
-
if (!(!r.trim() && !
|
|
543
|
+
}, Ge = async (r, u) => {
|
|
544
|
+
if (!(!r.trim() && !u?.length))
|
|
534
545
|
try {
|
|
535
|
-
const
|
|
536
|
-
id:
|
|
546
|
+
const y = await Ee(), w = {
|
|
547
|
+
id: Pe(),
|
|
537
548
|
content: r,
|
|
538
|
-
...
|
|
549
|
+
...u ? { parts: u } : {}
|
|
539
550
|
};
|
|
540
|
-
await
|
|
541
|
-
threadId:
|
|
542
|
-
message:
|
|
551
|
+
await me({
|
|
552
|
+
threadId: y.chatId,
|
|
553
|
+
message: w,
|
|
543
554
|
context: e,
|
|
544
555
|
capabilities: {
|
|
545
556
|
artifactSchemaVersions: [],
|
|
@@ -547,247 +558,311 @@ function La(e, t) {
|
|
|
547
558
|
templates: []
|
|
548
559
|
}
|
|
549
560
|
});
|
|
550
|
-
} catch (
|
|
551
|
-
|
|
561
|
+
} catch (y) {
|
|
562
|
+
te(y);
|
|
552
563
|
}
|
|
553
|
-
},
|
|
554
|
-
const r =
|
|
555
|
-
if (!r || r.threadId !==
|
|
556
|
-
|
|
564
|
+
}, Ye = async () => {
|
|
565
|
+
const r = ge.current;
|
|
566
|
+
if (!r || r.threadId !== M.current?.chatId) {
|
|
567
|
+
M.current && await He(M.current);
|
|
557
568
|
return;
|
|
558
569
|
}
|
|
559
|
-
const
|
|
560
|
-
(
|
|
570
|
+
const u = b.current.messages.find(
|
|
571
|
+
(y) => y.id === r.message.id
|
|
561
572
|
);
|
|
562
|
-
if (
|
|
563
|
-
const
|
|
564
|
-
if (
|
|
565
|
-
const
|
|
566
|
-
|
|
573
|
+
if (u?.responseId && t.watchResponse) {
|
|
574
|
+
const y = u.responseId;
|
|
575
|
+
if (V.current.has(y)) return;
|
|
576
|
+
const w = ee();
|
|
577
|
+
V.current.set(y, w), Q(void 0), await ke(
|
|
567
578
|
t.watchResponse(
|
|
568
579
|
e,
|
|
569
580
|
{
|
|
570
581
|
chatId: r.threadId,
|
|
571
|
-
responseId:
|
|
572
|
-
historyCursor:
|
|
582
|
+
responseId: y,
|
|
583
|
+
historyCursor: u.cursor
|
|
573
584
|
},
|
|
574
|
-
{ signal:
|
|
585
|
+
{ signal: w.signal }
|
|
575
586
|
),
|
|
576
|
-
|
|
587
|
+
w,
|
|
577
588
|
r.threadId
|
|
578
589
|
);
|
|
579
|
-
} else await
|
|
580
|
-
},
|
|
581
|
-
const
|
|
582
|
-
if (!
|
|
590
|
+
} else await me(r);
|
|
591
|
+
}, Je = async (r = b.current.activeRunId) => {
|
|
592
|
+
const u = M.current;
|
|
593
|
+
if (!u || !r || !t.cancelResponse || ve.includes(r))
|
|
583
594
|
return;
|
|
584
|
-
const
|
|
585
|
-
oe((
|
|
595
|
+
const y = A.current, w = B.current, C = ee();
|
|
596
|
+
oe((D) => [...D, r]), Q(void 0);
|
|
586
597
|
try {
|
|
587
|
-
const
|
|
598
|
+
const D = await t.cancelResponse(
|
|
588
599
|
e,
|
|
589
|
-
{ chatId:
|
|
590
|
-
{ signal:
|
|
600
|
+
{ chatId: u.chatId, responseId: r },
|
|
601
|
+
{ signal: C.signal }
|
|
591
602
|
);
|
|
592
|
-
if (!
|
|
593
|
-
if (
|
|
594
|
-
|
|
595
|
-
(
|
|
603
|
+
if (!x(y) || w !== B.current) return;
|
|
604
|
+
if (ht(D.status))
|
|
605
|
+
f(
|
|
606
|
+
(_) => Me(_, {
|
|
596
607
|
type: "response.snapshot",
|
|
597
|
-
snapshot:
|
|
608
|
+
snapshot: D
|
|
598
609
|
})
|
|
599
|
-
), oe((
|
|
600
|
-
else if (!
|
|
601
|
-
const
|
|
602
|
-
|
|
610
|
+
), oe((_) => _.filter((Z) => Z !== r));
|
|
611
|
+
else if (!V.current.has(r) && t.watchResponse) {
|
|
612
|
+
const _ = ee();
|
|
613
|
+
V.current.set(r, _), ke(
|
|
603
614
|
t.watchResponse(
|
|
604
615
|
e,
|
|
605
|
-
{ chatId:
|
|
606
|
-
{ signal:
|
|
616
|
+
{ chatId: u.chatId, responseId: r },
|
|
617
|
+
{ signal: _.signal }
|
|
607
618
|
),
|
|
608
|
-
|
|
609
|
-
|
|
619
|
+
_,
|
|
620
|
+
u.chatId
|
|
610
621
|
);
|
|
611
622
|
}
|
|
612
|
-
} catch (
|
|
613
|
-
|
|
623
|
+
} catch (D) {
|
|
624
|
+
x(y) && w === B.current && (te(D), oe((_) => _.filter((Z) => Z !== r)));
|
|
614
625
|
} finally {
|
|
615
|
-
|
|
626
|
+
le(C);
|
|
616
627
|
}
|
|
617
|
-
},
|
|
618
|
-
if (!
|
|
619
|
-
const
|
|
620
|
-
|
|
628
|
+
}, Qe = async (r, u = M.current) => {
|
|
629
|
+
if (!u || G) return !1;
|
|
630
|
+
const y = A.current, w = ee();
|
|
631
|
+
Y(!0), Q(void 0);
|
|
621
632
|
try {
|
|
622
|
-
const
|
|
633
|
+
const C = await t.updateConversation(
|
|
623
634
|
e,
|
|
624
|
-
{ chatId:
|
|
625
|
-
{ signal:
|
|
635
|
+
{ chatId: u.chatId, expectedRevision: u.revision, ...r },
|
|
636
|
+
{ signal: w.signal }
|
|
626
637
|
);
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
Q(M);
|
|
638
|
+
return x(y) ? (we(), lt(C), M.current?.chatId === C.chatId && de(C), !0) : !1;
|
|
639
|
+
} catch (C) {
|
|
640
|
+
if (x(y)) {
|
|
641
|
+
te(C);
|
|
632
642
|
try {
|
|
633
|
-
const
|
|
643
|
+
const D = await t.getConversation(
|
|
634
644
|
e,
|
|
635
|
-
{ chatId:
|
|
636
|
-
{ signal:
|
|
645
|
+
{ chatId: u.chatId },
|
|
646
|
+
{ signal: w.signal }
|
|
637
647
|
);
|
|
638
|
-
|
|
648
|
+
x(y) && M.current?.chatId === u.chatId && de(D);
|
|
639
649
|
} catch {
|
|
640
650
|
}
|
|
641
|
-
|
|
651
|
+
Ce();
|
|
642
652
|
}
|
|
653
|
+
return !1;
|
|
643
654
|
} finally {
|
|
644
|
-
|
|
655
|
+
le(w), x(y) && Y(!1);
|
|
645
656
|
}
|
|
646
|
-
},
|
|
647
|
-
if (!r ||
|
|
648
|
-
const
|
|
649
|
-
|
|
657
|
+
}, et = async (r = M.current) => {
|
|
658
|
+
if (!r || G) return !1;
|
|
659
|
+
const u = A.current, y = ee();
|
|
660
|
+
Y(!0), Q(void 0);
|
|
650
661
|
try {
|
|
651
|
-
|
|
662
|
+
return await t.deleteConversation(
|
|
652
663
|
e,
|
|
653
664
|
{ chatId: r.chatId, expectedRevision: r.revision },
|
|
654
|
-
{ signal:
|
|
655
|
-
),
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
S(h) && Q(A);
|
|
665
|
+
{ signal: y.signal }
|
|
666
|
+
), x(u) ? (we(), ye(r.chatId), M.current?.chatId === r.chatId && (B.current += 1, be(), de(void 0), f(fe())), !0) : !1;
|
|
667
|
+
} catch (w) {
|
|
668
|
+
return x(u) && te(w), !1;
|
|
659
669
|
} finally {
|
|
660
|
-
|
|
670
|
+
le(y), x(u) && Y(!1);
|
|
661
671
|
}
|
|
662
|
-
},
|
|
663
|
-
const
|
|
664
|
-
if (!
|
|
672
|
+
}, xe = async (r, u, y = "", w = "") => {
|
|
673
|
+
const C = M.current;
|
|
674
|
+
if (!C || !r.persistent || !t.setFeedback || F.includes(r.id))
|
|
665
675
|
return;
|
|
666
|
-
const
|
|
667
|
-
chatId:
|
|
676
|
+
const D = {
|
|
677
|
+
chatId: C.chatId,
|
|
668
678
|
messageId: r.id,
|
|
669
|
-
rating:
|
|
670
|
-
...
|
|
671
|
-
...
|
|
672
|
-
},
|
|
679
|
+
rating: u,
|
|
680
|
+
...y ? { reason: y } : {},
|
|
681
|
+
...w ? { comment: w } : {}
|
|
682
|
+
}, _ = Re.current.get(r.id), { requestId: Z, ...O } = _ ?? {
|
|
673
683
|
requestId: ""
|
|
674
|
-
},
|
|
675
|
-
|
|
676
|
-
const
|
|
677
|
-
|
|
684
|
+
}, H = _ && JSON.stringify(O) === JSON.stringify(D) ? _ : { ...D, requestId: Pe() };
|
|
685
|
+
Re.current.set(r.id, H);
|
|
686
|
+
const Ie = A.current, Le = B.current, tt = ee();
|
|
687
|
+
ne((he) => [...he, r.id]), Q(void 0);
|
|
678
688
|
try {
|
|
679
|
-
const
|
|
680
|
-
signal:
|
|
689
|
+
const he = await t.setFeedback(e, H, {
|
|
690
|
+
signal: tt.signal
|
|
681
691
|
});
|
|
682
|
-
return !
|
|
683
|
-
...
|
|
684
|
-
messages:
|
|
685
|
-
(
|
|
692
|
+
return !x(Ie) || Le !== B.current || Re.current.get(r.id) !== H ? void 0 : (f((De) => ({
|
|
693
|
+
...De,
|
|
694
|
+
messages: De.messages.map(
|
|
695
|
+
(m) => m.id === r.id && he.revision >= (m.feedback?.revision ?? 0) ? { ...m, feedback: he } : m
|
|
686
696
|
)
|
|
687
|
-
})),
|
|
688
|
-
} catch (
|
|
689
|
-
return
|
|
697
|
+
})), Re.current.delete(r.id), !0);
|
|
698
|
+
} catch (he) {
|
|
699
|
+
return x(Ie) && Le === B.current && te(he), !1;
|
|
690
700
|
} finally {
|
|
691
|
-
|
|
701
|
+
le(tt), x(Ie) && ne((he) => he.filter((De) => De !== r.id));
|
|
692
702
|
}
|
|
693
|
-
},
|
|
694
|
-
if (!
|
|
695
|
-
const r =
|
|
696
|
-
|
|
703
|
+
}, dt = async () => {
|
|
704
|
+
if (!M.current || !p || q) return;
|
|
705
|
+
const r = A.current, u = B.current, y = M.current, w = ee();
|
|
706
|
+
I(!0);
|
|
697
707
|
try {
|
|
698
|
-
const
|
|
699
|
-
threadId:
|
|
700
|
-
cursor:
|
|
701
|
-
signal:
|
|
708
|
+
const C = await t.loadConversation(e, {
|
|
709
|
+
threadId: y.chatId,
|
|
710
|
+
cursor: R,
|
|
711
|
+
signal: w.signal
|
|
702
712
|
});
|
|
703
|
-
if (!
|
|
704
|
-
const
|
|
713
|
+
if (!x(r) || u !== B.current) return;
|
|
714
|
+
const D = fe(C), _ = [
|
|
705
715
|
...new Map(
|
|
706
|
-
[...
|
|
707
|
-
|
|
708
|
-
|
|
716
|
+
[...b.current.messages, ...D.messages].map((H) => [
|
|
717
|
+
H.id,
|
|
718
|
+
H
|
|
709
719
|
])
|
|
710
720
|
).values()
|
|
711
721
|
];
|
|
712
|
-
let
|
|
713
|
-
const
|
|
714
|
-
for (const
|
|
715
|
-
if (
|
|
716
|
-
|
|
722
|
+
let Z = 0;
|
|
723
|
+
const O = [];
|
|
724
|
+
for (const H of _.slice(-200).reverse()) {
|
|
725
|
+
if (Z += [...H.content].length, Z > 1e6) break;
|
|
726
|
+
O.unshift(H);
|
|
717
727
|
}
|
|
718
|
-
|
|
719
|
-
} catch (
|
|
720
|
-
|
|
728
|
+
O.length < _.length && k(!0), f((H) => ({ ...H, messages: O })), P(C.nextCursor ?? R), n(C.hasMore ?? !1), Oe(C.messages, y.chatId, u, r);
|
|
729
|
+
} catch (C) {
|
|
730
|
+
x(r) && te(C);
|
|
721
731
|
} finally {
|
|
722
|
-
|
|
732
|
+
le(w), x(r) && I(!1);
|
|
723
733
|
}
|
|
724
734
|
};
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
for (const r of
|
|
728
|
-
|
|
729
|
-
}), [
|
|
730
|
-
const
|
|
735
|
+
ie(() => (A.current += 1, c.current = i, ae.current = void 0, ge.current = void 0, Re.current.clear(), de(void 0), L([]), g(""), f(fe()), Q(void 0), I(s), Y(!1), oe([]), ne([]), s && Ce(), () => {
|
|
736
|
+
A.current += 1, B.current += 1;
|
|
737
|
+
for (const r of ce.current) r.abort();
|
|
738
|
+
ce.current.clear(), V.current.clear();
|
|
739
|
+
}), [s, i, t]);
|
|
740
|
+
const Se = c.current === i;
|
|
731
741
|
return {
|
|
732
|
-
enabled:
|
|
733
|
-
state:
|
|
734
|
-
setState:
|
|
735
|
-
chats:
|
|
736
|
-
chat:
|
|
737
|
-
listCursor:
|
|
738
|
-
historyMore:
|
|
739
|
-
historyTruncated:
|
|
740
|
-
loading:
|
|
741
|
-
busy:
|
|
742
|
-
error:
|
|
743
|
-
cancelling:
|
|
744
|
-
feedbackBusy:
|
|
745
|
-
refresh:
|
|
746
|
-
select:
|
|
747
|
-
create:
|
|
748
|
-
ensureChat:
|
|
749
|
-
send:
|
|
750
|
-
retry:
|
|
751
|
-
stop:
|
|
752
|
-
update:
|
|
753
|
-
remove:
|
|
754
|
-
feedback:
|
|
755
|
-
moreHistory:
|
|
756
|
-
setError:
|
|
742
|
+
enabled: s,
|
|
743
|
+
state: Se ? d : fe(),
|
|
744
|
+
setState: f,
|
|
745
|
+
chats: Se ? $ : [],
|
|
746
|
+
chat: Se ? T : void 0,
|
|
747
|
+
listCursor: U,
|
|
748
|
+
historyMore: p,
|
|
749
|
+
historyTruncated: v,
|
|
750
|
+
loading: !Se || q,
|
|
751
|
+
busy: G,
|
|
752
|
+
error: Se ? z : void 0,
|
|
753
|
+
cancelling: ve,
|
|
754
|
+
feedbackBusy: F,
|
|
755
|
+
refresh: Ce,
|
|
756
|
+
select: He,
|
|
757
|
+
create: Xe,
|
|
758
|
+
ensureChat: Ee,
|
|
759
|
+
send: Ge,
|
|
760
|
+
retry: Ye,
|
|
761
|
+
stop: Je,
|
|
762
|
+
update: Qe,
|
|
763
|
+
remove: et,
|
|
764
|
+
feedback: xe,
|
|
765
|
+
moreHistory: dt,
|
|
766
|
+
setError: Q
|
|
757
767
|
};
|
|
758
768
|
}
|
|
759
|
-
const
|
|
769
|
+
const wa = () => /* @__PURE__ */ l("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
|
|
760
770
|
/* @__PURE__ */ a("path", { d: "M5 5.5h14v10H9l-4 3v-13Z" }),
|
|
761
771
|
/* @__PURE__ */ a("path", { d: "M8 9h8M8 12h6" })
|
|
762
|
-
] }),
|
|
763
|
-
|
|
772
|
+
] }), Ia = () => /* @__PURE__ */ a("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: /* @__PURE__ */ a("path", { d: "M12 5v14M5 12h14" }) }), Aa = () => /* @__PURE__ */ l("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
|
|
773
|
+
/* @__PURE__ */ a("path", { d: "m4.5 16.8-.7 3.7 3.7-.7L18 9.3l-3-3L4.5 16.8Z" }),
|
|
774
|
+
/* @__PURE__ */ a("path", { d: "m13.8 7.5 3 3" })
|
|
775
|
+
] }), Ma = () => /* @__PURE__ */ a("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: /* @__PURE__ */ a("path", { d: "M5.5 7.5h13M9.5 7.5V5.7h5v1.8M8 10.5v6M12 10.5v6M16 10.5v6M7 7.5l.7 12h8.6l.7-12" }) }), St = () => /* @__PURE__ */ a("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: /* @__PURE__ */ a("path", { d: "m5 12.5 4.5 4.5L19 7.5" }) }), Lt = () => /* @__PURE__ */ a("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: /* @__PURE__ */ a("path", { d: "m6 6 12 12M18 6 6 18" }) }), Na = ({
|
|
776
|
+
anchor: e,
|
|
777
|
+
label: t,
|
|
778
|
+
onDismiss: s
|
|
779
|
+
}) => {
|
|
780
|
+
const [i, o] = N();
|
|
781
|
+
if (gt(() => {
|
|
782
|
+
const d = () => {
|
|
783
|
+
if (!e.isConnected) {
|
|
784
|
+
s();
|
|
785
|
+
return;
|
|
786
|
+
}
|
|
787
|
+
const h = e.getBoundingClientRect(), b = h.top >= 48 ? "above" : "below";
|
|
788
|
+
o({
|
|
789
|
+
left: h.left + h.width / 2,
|
|
790
|
+
placement: b,
|
|
791
|
+
top: b === "above" ? h.top - 8 : h.bottom + 8
|
|
792
|
+
});
|
|
793
|
+
};
|
|
794
|
+
return d(), window.addEventListener("resize", d), document.addEventListener("scroll", d, !0), () => {
|
|
795
|
+
window.removeEventListener("resize", d), document.removeEventListener("scroll", d, !0);
|
|
796
|
+
};
|
|
797
|
+
}, [e, s]), !i || typeof document > "u") return null;
|
|
798
|
+
const c = e.closest(".make-ai-assistant") ?? document.body;
|
|
799
|
+
return la(
|
|
800
|
+
/* @__PURE__ */ a(
|
|
801
|
+
"span",
|
|
802
|
+
{
|
|
803
|
+
className: "make-ai-assistant__conversation-tooltip",
|
|
804
|
+
"data-placement": i.placement,
|
|
805
|
+
role: "tooltip",
|
|
806
|
+
style: { left: i.left, top: i.top },
|
|
807
|
+
children: t
|
|
808
|
+
}
|
|
809
|
+
),
|
|
810
|
+
c
|
|
811
|
+
);
|
|
812
|
+
}, Ca = () => /* @__PURE__ */ l("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
|
|
813
|
+
/* @__PURE__ */ a("path", { d: "M7.5 10.5v9H4.8a1.8 1.8 0 0 1-1.8-1.8v-5.4a1.8 1.8 0 0 1 1.8-1.8h2.7Z" }),
|
|
814
|
+
/* @__PURE__ */ a("path", { d: "M7.5 19.5h8.1a2.4 2.4 0 0 0 2.3-1.8l1.4-5.4a1.5 1.5 0 0 0-1.5-1.8h-4.1l.7-3.4A2.4 2.4 0 0 0 12 4.2L7.5 10.5Z" })
|
|
815
|
+
] }), Ta = () => /* @__PURE__ */ l("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
|
|
816
|
+
/* @__PURE__ */ a("path", { d: "M7.5 13.5v-9H4.8A1.8 1.8 0 0 0 3 6.3v5.4a1.8 1.8 0 0 0 1.8 1.8h2.7Z" }),
|
|
817
|
+
/* @__PURE__ */ a("path", { d: "M7.5 4.5h8.1a2.4 2.4 0 0 1 2.3 1.8l1.4 5.4a1.5 1.5 0 0 1-1.5 1.8h-4.1l.7 3.4A2.4 2.4 0 0 1 12 19.8l-4.5-6.3Z" })
|
|
818
|
+
] });
|
|
819
|
+
function Ra({
|
|
764
820
|
id: e,
|
|
765
821
|
manager: t,
|
|
766
|
-
onDismiss:
|
|
822
|
+
onDismiss: s,
|
|
767
823
|
onNewConversation: i,
|
|
768
|
-
triggerRef:
|
|
824
|
+
triggerRef: o
|
|
769
825
|
}) {
|
|
770
|
-
const [
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
826
|
+
const [c, d] = N(), [h, b] = N(""), [f, $] = N(), [L, T] = N(), j = S(null), M = (n, v) => {
|
|
827
|
+
T(
|
|
828
|
+
(k) => k?.anchor === v && k.label === n ? k : { anchor: v, label: n }
|
|
829
|
+
);
|
|
830
|
+
}, U = (n) => {
|
|
831
|
+
T(
|
|
832
|
+
(v) => v?.anchor === n ? void 0 : v
|
|
833
|
+
);
|
|
834
|
+
}, g = (n) => ({
|
|
835
|
+
"data-tooltip": n,
|
|
836
|
+
onBlur: (v) => U(v.currentTarget),
|
|
837
|
+
onFocus: (v) => M(n, v.currentTarget),
|
|
838
|
+
onPointerEnter: (v) => M(n, v.currentTarget),
|
|
839
|
+
onPointerLeave: (v) => U(v.currentTarget)
|
|
840
|
+
}), R = () => {
|
|
841
|
+
d(void 0), b("");
|
|
842
|
+
}, P = async (n) => {
|
|
843
|
+
const v = h.trim();
|
|
844
|
+
v && await t.update({ title: v }, n) && R();
|
|
845
|
+
}, p = async (n) => {
|
|
846
|
+
await t.remove(n) && $(void 0);
|
|
847
|
+
};
|
|
848
|
+
return ie(() => {
|
|
849
|
+
const n = (v) => {
|
|
850
|
+
const k = v.target;
|
|
851
|
+
k instanceof Node && (j.current?.contains(k) || o.current?.contains(k) || s());
|
|
777
852
|
};
|
|
778
|
-
return document.addEventListener("pointerdown",
|
|
779
|
-
document.removeEventListener("pointerdown",
|
|
853
|
+
return document.addEventListener("pointerdown", n), () => {
|
|
854
|
+
document.removeEventListener("pointerdown", n);
|
|
780
855
|
};
|
|
781
|
-
}, [
|
|
856
|
+
}, [s, o]), /* @__PURE__ */ l(
|
|
782
857
|
"div",
|
|
783
858
|
{
|
|
784
859
|
"aria-label": "任务列表",
|
|
785
860
|
className: "make-ai-assistant__conversation-controls",
|
|
786
861
|
id: e,
|
|
787
|
-
ref:
|
|
862
|
+
ref: j,
|
|
788
863
|
role: "dialog",
|
|
789
864
|
children: [
|
|
790
|
-
/* @__PURE__ */
|
|
865
|
+
/* @__PURE__ */ l("div", { className: "make-ai-assistant__conversation-heading", children: [
|
|
791
866
|
/* @__PURE__ */ a("span", { children: "最近对话" }),
|
|
792
867
|
/* @__PURE__ */ a(
|
|
793
868
|
"button",
|
|
@@ -803,47 +878,172 @@ function Fa({
|
|
|
803
878
|
}
|
|
804
879
|
)
|
|
805
880
|
] }),
|
|
806
|
-
/* @__PURE__ */
|
|
881
|
+
/* @__PURE__ */ l(
|
|
807
882
|
"nav",
|
|
808
883
|
{
|
|
809
884
|
"aria-label": "对话列表",
|
|
810
885
|
className: "make-ai-assistant__conversation-list",
|
|
811
886
|
children: [
|
|
812
|
-
t.chats.map((
|
|
813
|
-
"
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
"
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
887
|
+
t.chats.map((n) => {
|
|
888
|
+
const v = c === n.chatId, k = f === n.chatId, q = n.title || "未命名对话";
|
|
889
|
+
return /* @__PURE__ */ l(
|
|
890
|
+
"div",
|
|
891
|
+
{
|
|
892
|
+
className: "make-ai-assistant__conversation-row",
|
|
893
|
+
"data-editing": v || k || void 0,
|
|
894
|
+
children: [
|
|
895
|
+
k ? /* @__PURE__ */ l(
|
|
896
|
+
"div",
|
|
897
|
+
{
|
|
898
|
+
"aria-label": "确认删除对话",
|
|
899
|
+
className: "make-ai-assistant__conversation-delete-confirmation",
|
|
900
|
+
role: "group",
|
|
901
|
+
children: [
|
|
902
|
+
/* @__PURE__ */ l("span", { children: [
|
|
903
|
+
"删除“",
|
|
904
|
+
q,
|
|
905
|
+
"”?"
|
|
906
|
+
] }),
|
|
907
|
+
/* @__PURE__ */ a(
|
|
908
|
+
"button",
|
|
909
|
+
{
|
|
910
|
+
"aria-label": `确认删除:${q}`,
|
|
911
|
+
className: "make-ai-assistant__conversation-row-action make-ai-assistant__conversation-row-action--danger",
|
|
912
|
+
disabled: t.busy,
|
|
913
|
+
type: "button",
|
|
914
|
+
...g("确认删除"),
|
|
915
|
+
onClick: () => {
|
|
916
|
+
p(n);
|
|
917
|
+
},
|
|
918
|
+
children: /* @__PURE__ */ a(St, {})
|
|
919
|
+
}
|
|
920
|
+
),
|
|
921
|
+
/* @__PURE__ */ a(
|
|
922
|
+
"button",
|
|
923
|
+
{
|
|
924
|
+
"aria-label": `取消删除:${q}`,
|
|
925
|
+
className: "make-ai-assistant__conversation-row-action",
|
|
926
|
+
disabled: t.busy,
|
|
927
|
+
type: "button",
|
|
928
|
+
...g("取消"),
|
|
929
|
+
onClick: () => $(void 0),
|
|
930
|
+
children: /* @__PURE__ */ a(Lt, {})
|
|
931
|
+
}
|
|
932
|
+
)
|
|
933
|
+
]
|
|
934
|
+
}
|
|
935
|
+
) : v ? /* @__PURE__ */ a(
|
|
936
|
+
"input",
|
|
937
|
+
{
|
|
938
|
+
"aria-label": "对话标题",
|
|
939
|
+
autoFocus: !0,
|
|
940
|
+
className: "make-ai-assistant__conversation-row-title-input",
|
|
941
|
+
disabled: t.busy,
|
|
942
|
+
maxLength: 255,
|
|
943
|
+
value: h,
|
|
944
|
+
onChange: (I) => b(I.currentTarget.value),
|
|
945
|
+
onKeyDown: (I) => {
|
|
946
|
+
I.nativeEvent.isComposing || (I.key === "Escape" && (I.preventDefault(), R()), I.key === "Enter" && (I.preventDefault(), P(n)));
|
|
947
|
+
}
|
|
948
|
+
}
|
|
949
|
+
) : /* @__PURE__ */ l(
|
|
950
|
+
"button",
|
|
951
|
+
{
|
|
952
|
+
"aria-pressed": t.chat?.chatId === n.chatId,
|
|
953
|
+
className: "make-ai-assistant__conversation-row-select",
|
|
954
|
+
type: "button",
|
|
955
|
+
onClick: () => {
|
|
956
|
+
s(), t.select(n);
|
|
957
|
+
},
|
|
958
|
+
children: [
|
|
959
|
+
/* @__PURE__ */ a(wa, {}),
|
|
960
|
+
/* @__PURE__ */ a("span", { children: q })
|
|
961
|
+
]
|
|
962
|
+
}
|
|
963
|
+
),
|
|
964
|
+
v ? /* @__PURE__ */ l(
|
|
965
|
+
"div",
|
|
966
|
+
{
|
|
967
|
+
"aria-label": "修改标题操作",
|
|
968
|
+
className: "make-ai-assistant__conversation-row-actions",
|
|
969
|
+
role: "group",
|
|
970
|
+
children: [
|
|
971
|
+
/* @__PURE__ */ a(
|
|
972
|
+
"button",
|
|
973
|
+
{
|
|
974
|
+
"aria-label": "确认修改标题",
|
|
975
|
+
className: "make-ai-assistant__conversation-row-action",
|
|
976
|
+
disabled: t.busy || !h.trim(),
|
|
977
|
+
type: "button",
|
|
978
|
+
...g("保存标题"),
|
|
979
|
+
onClick: () => {
|
|
980
|
+
P(n);
|
|
981
|
+
},
|
|
982
|
+
children: /* @__PURE__ */ a(St, {})
|
|
983
|
+
}
|
|
984
|
+
),
|
|
985
|
+
/* @__PURE__ */ a(
|
|
986
|
+
"button",
|
|
987
|
+
{
|
|
988
|
+
"aria-label": "取消修改标题",
|
|
989
|
+
className: "make-ai-assistant__conversation-row-action",
|
|
990
|
+
disabled: t.busy,
|
|
991
|
+
type: "button",
|
|
992
|
+
...g("取消"),
|
|
993
|
+
onClick: R,
|
|
994
|
+
children: /* @__PURE__ */ a(Lt, {})
|
|
995
|
+
}
|
|
996
|
+
)
|
|
997
|
+
]
|
|
998
|
+
}
|
|
999
|
+
) : k ? null : /* @__PURE__ */ l("div", { className: "make-ai-assistant__conversation-row-actions", children: [
|
|
1000
|
+
/* @__PURE__ */ a(
|
|
1001
|
+
"button",
|
|
1002
|
+
{
|
|
1003
|
+
"aria-label": `${n.pinned ? "取消置顶" : "置顶"} ${q}`,
|
|
1004
|
+
className: "make-ai-assistant__conversation-row-pin",
|
|
1005
|
+
disabled: t.busy,
|
|
1006
|
+
type: "button",
|
|
1007
|
+
onClick: () => {
|
|
1008
|
+
t.update({ pinned: !n.pinned }, n);
|
|
1009
|
+
},
|
|
1010
|
+
children: n.pinned ? "★" : "☆"
|
|
1011
|
+
}
|
|
1012
|
+
),
|
|
1013
|
+
/* @__PURE__ */ a(
|
|
1014
|
+
"button",
|
|
1015
|
+
{
|
|
1016
|
+
"aria-label": `修改标题:${q}`,
|
|
1017
|
+
className: "make-ai-assistant__conversation-row-action",
|
|
1018
|
+
disabled: t.busy,
|
|
1019
|
+
type: "button",
|
|
1020
|
+
...g("修改标题"),
|
|
1021
|
+
onClick: () => {
|
|
1022
|
+
$(void 0), d(n.chatId), b(n.title);
|
|
1023
|
+
},
|
|
1024
|
+
children: /* @__PURE__ */ a(Aa, {})
|
|
1025
|
+
}
|
|
1026
|
+
),
|
|
1027
|
+
/* @__PURE__ */ a(
|
|
1028
|
+
"button",
|
|
1029
|
+
{
|
|
1030
|
+
"aria-label": `删除:${q}`,
|
|
1031
|
+
className: "make-ai-assistant__conversation-row-action make-ai-assistant__conversation-row-action--danger",
|
|
1032
|
+
disabled: t.busy,
|
|
1033
|
+
type: "button",
|
|
1034
|
+
...g("删除"),
|
|
1035
|
+
onClick: () => {
|
|
1036
|
+
R(), $(n.chatId);
|
|
1037
|
+
},
|
|
1038
|
+
children: /* @__PURE__ */ a(Ma, {})
|
|
1039
|
+
}
|
|
1040
|
+
)
|
|
1041
|
+
] })
|
|
1042
|
+
]
|
|
1043
|
+
},
|
|
1044
|
+
n.chatId
|
|
1045
|
+
);
|
|
1046
|
+
}),
|
|
847
1047
|
!t.loading && !t.chats.length ? /* @__PURE__ */ a("p", { children: "暂无对话,发送消息即可新建" }) : null,
|
|
848
1048
|
t.listCursor ? /* @__PURE__ */ a(
|
|
849
1049
|
"button",
|
|
@@ -859,180 +1059,166 @@ function Fa({
|
|
|
859
1059
|
]
|
|
860
1060
|
}
|
|
861
1061
|
),
|
|
862
|
-
t.chat ? /* @__PURE__ */
|
|
863
|
-
/* @__PURE__ */ a(
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
"
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
"button",
|
|
876
|
-
{
|
|
877
|
-
type: "button",
|
|
878
|
-
disabled: t.busy || !o.trim(),
|
|
879
|
-
onClick: () => {
|
|
880
|
-
t.update({ title: o });
|
|
881
|
-
},
|
|
882
|
-
children: "保存标题"
|
|
883
|
-
}
|
|
884
|
-
),
|
|
885
|
-
/* @__PURE__ */ a(
|
|
886
|
-
"button",
|
|
887
|
-
{
|
|
888
|
-
type: "button",
|
|
889
|
-
disabled: t.busy,
|
|
890
|
-
onClick: () => f(!0),
|
|
891
|
-
children: "删除对话"
|
|
892
|
-
}
|
|
893
|
-
),
|
|
894
|
-
g ? /* @__PURE__ */ c("div", { role: "group", "aria-label": "确认删除对话", children: [
|
|
895
|
-
/* @__PURE__ */ c("span", { children: [
|
|
896
|
-
"删除“",
|
|
897
|
-
t.chat.title,
|
|
898
|
-
"”?"
|
|
899
|
-
] }),
|
|
900
|
-
/* @__PURE__ */ a(
|
|
901
|
-
"button",
|
|
902
|
-
{
|
|
903
|
-
type: "button",
|
|
904
|
-
disabled: t.busy,
|
|
905
|
-
onClick: () => {
|
|
906
|
-
f(!1), t.remove();
|
|
907
|
-
},
|
|
908
|
-
children: "确认删除"
|
|
909
|
-
}
|
|
910
|
-
),
|
|
911
|
-
/* @__PURE__ */ a("button", { type: "button", onClick: () => f(!1), children: "保留" })
|
|
912
|
-
] }) : null,
|
|
913
|
-
t.historyMore ? /* @__PURE__ */ a(
|
|
914
|
-
"button",
|
|
915
|
-
{
|
|
916
|
-
type: "button",
|
|
917
|
-
disabled: t.loading,
|
|
918
|
-
onClick: () => {
|
|
919
|
-
t.moreHistory();
|
|
920
|
-
},
|
|
921
|
-
children: "继续加载历史"
|
|
922
|
-
}
|
|
923
|
-
) : null,
|
|
924
|
-
t.historyTruncated || t.state.historyTruncated ? /* @__PURE__ */ a("p", { children: "当前展示有界消息窗口,可重新选择对话从头读取。" }) : null
|
|
925
|
-
] })
|
|
1062
|
+
t.chat && (t.historyMore || t.historyTruncated || t.state.historyTruncated) ? /* @__PURE__ */ l("div", { className: "make-ai-assistant__conversation-history-actions", children: [
|
|
1063
|
+
t.historyMore ? /* @__PURE__ */ a(
|
|
1064
|
+
"button",
|
|
1065
|
+
{
|
|
1066
|
+
type: "button",
|
|
1067
|
+
disabled: t.loading,
|
|
1068
|
+
onClick: () => {
|
|
1069
|
+
t.moreHistory();
|
|
1070
|
+
},
|
|
1071
|
+
children: "继续加载历史"
|
|
1072
|
+
}
|
|
1073
|
+
) : null,
|
|
1074
|
+
t.historyTruncated || t.state.historyTruncated ? /* @__PURE__ */ a("p", { children: "当前展示有界消息窗口,可重新选择对话从头读取。" }) : null
|
|
926
1075
|
] }) : null,
|
|
927
|
-
t.error ? /* @__PURE__ */
|
|
1076
|
+
t.error ? /* @__PURE__ */ l("div", { className: "make-ai-assistant__conversation-error", role: "alert", children: [
|
|
928
1077
|
/* @__PURE__ */ a("span", { children: t.error }),
|
|
929
1078
|
/* @__PURE__ */ a("button", { type: "button", onClick: () => {
|
|
930
1079
|
t.retry();
|
|
931
1080
|
}, children: "恢复对话" })
|
|
932
1081
|
] }) : null,
|
|
933
|
-
i ? /* @__PURE__ */
|
|
1082
|
+
i ? /* @__PURE__ */ l(
|
|
934
1083
|
"button",
|
|
935
1084
|
{
|
|
936
1085
|
className: "make-ai-assistant__conversation-new",
|
|
937
1086
|
type: "button",
|
|
938
1087
|
onClick: i,
|
|
939
1088
|
children: [
|
|
940
|
-
/* @__PURE__ */ a(
|
|
1089
|
+
/* @__PURE__ */ a(Ia, {}),
|
|
941
1090
|
/* @__PURE__ */ a("span", { children: "新建对话" })
|
|
942
1091
|
]
|
|
943
1092
|
}
|
|
1093
|
+
) : null,
|
|
1094
|
+
L ? /* @__PURE__ */ a(
|
|
1095
|
+
Na,
|
|
1096
|
+
{
|
|
1097
|
+
anchor: L.anchor,
|
|
1098
|
+
label: L.label,
|
|
1099
|
+
onDismiss: () => T(void 0)
|
|
1100
|
+
}
|
|
944
1101
|
) : null
|
|
945
1102
|
]
|
|
946
1103
|
}
|
|
947
1104
|
);
|
|
948
1105
|
}
|
|
949
|
-
function
|
|
1106
|
+
function Ea({
|
|
950
1107
|
message: e,
|
|
951
1108
|
manager: t
|
|
952
1109
|
}) {
|
|
953
|
-
const [
|
|
1110
|
+
const [s, i] = N(!1), [o, c] = N(""), [d, h] = N(""), b = t.feedbackBusy.includes(e.id);
|
|
954
1111
|
if (!e.persistent || e.role !== "assistant" || e.intermediate)
|
|
955
1112
|
return null;
|
|
956
|
-
const
|
|
957
|
-
return /* @__PURE__ */
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
disabled: f,
|
|
978
|
-
onClick: () => {
|
|
979
|
-
if (p === "dislike") {
|
|
980
|
-
t.feedback(e, "none");
|
|
981
|
-
return;
|
|
1113
|
+
const f = e.feedback?.rating ?? "none";
|
|
1114
|
+
return /* @__PURE__ */ l(
|
|
1115
|
+
"div",
|
|
1116
|
+
{
|
|
1117
|
+
"aria-label": "回答反馈",
|
|
1118
|
+
className: "make-ai-assistant__feedback",
|
|
1119
|
+
role: "group",
|
|
1120
|
+
children: [
|
|
1121
|
+
/* @__PURE__ */ a(
|
|
1122
|
+
"button",
|
|
1123
|
+
{
|
|
1124
|
+
type: "button",
|
|
1125
|
+
"aria-label": "喜欢",
|
|
1126
|
+
"aria-pressed": f === "like",
|
|
1127
|
+
className: "make-ai-assistant__reply-action make-ai-assistant__reply-feedback-action",
|
|
1128
|
+
"data-tooltip": "喜欢",
|
|
1129
|
+
disabled: b,
|
|
1130
|
+
onClick: () => {
|
|
1131
|
+
t.feedback(e, f === "like" ? "none" : "like");
|
|
1132
|
+
},
|
|
1133
|
+
children: /* @__PURE__ */ a(Ca, {})
|
|
982
1134
|
}
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1135
|
+
),
|
|
1136
|
+
/* @__PURE__ */ a(
|
|
1137
|
+
"button",
|
|
1138
|
+
{
|
|
1139
|
+
type: "button",
|
|
1140
|
+
"aria-label": "不喜欢",
|
|
1141
|
+
"aria-pressed": f === "dislike",
|
|
1142
|
+
className: "make-ai-assistant__reply-action make-ai-assistant__reply-feedback-action",
|
|
1143
|
+
"data-tooltip": "不喜欢",
|
|
1144
|
+
disabled: b,
|
|
1145
|
+
onClick: () => {
|
|
1146
|
+
if (f === "dislike") {
|
|
1147
|
+
t.feedback(e, "none");
|
|
1148
|
+
return;
|
|
1149
|
+
}
|
|
1150
|
+
c(e.feedback?.reason ?? ""), h(e.feedback?.comment ?? ""), i(!0);
|
|
1151
|
+
},
|
|
1152
|
+
children: /* @__PURE__ */ a(Ta, {})
|
|
1153
|
+
}
|
|
1154
|
+
),
|
|
1155
|
+
f === "dislike" ? /* @__PURE__ */ a(
|
|
1156
|
+
"button",
|
|
1157
|
+
{
|
|
1158
|
+
className: "make-ai-assistant__feedback-text-action",
|
|
1159
|
+
type: "button",
|
|
1160
|
+
disabled: b,
|
|
1161
|
+
onClick: () => {
|
|
1162
|
+
c(e.feedback?.reason ?? ""), h(e.feedback?.comment ?? ""), i(!0);
|
|
1163
|
+
},
|
|
1164
|
+
children: "修改反馈"
|
|
1165
|
+
}
|
|
1166
|
+
) : null,
|
|
1167
|
+
s ? /* @__PURE__ */ l(
|
|
1168
|
+
"form",
|
|
1169
|
+
{
|
|
1170
|
+
onSubmit: ($) => {
|
|
1171
|
+
$.preventDefault(), t.feedback(e, "dislike", o, d).then((L) => {
|
|
1172
|
+
L && i(!1);
|
|
1173
|
+
});
|
|
1174
|
+
},
|
|
1175
|
+
children: [
|
|
1176
|
+
/* @__PURE__ */ a(
|
|
1177
|
+
"input",
|
|
1178
|
+
{
|
|
1179
|
+
"aria-label": "反馈原因",
|
|
1180
|
+
maxLength: 128,
|
|
1181
|
+
value: o,
|
|
1182
|
+
onChange: ($) => c($.currentTarget.value),
|
|
1183
|
+
placeholder: "原因(可选)"
|
|
1184
|
+
}
|
|
1185
|
+
),
|
|
1186
|
+
/* @__PURE__ */ a(
|
|
1187
|
+
"textarea",
|
|
1188
|
+
{
|
|
1189
|
+
"aria-label": "反馈说明",
|
|
1190
|
+
maxLength: 4e3,
|
|
1191
|
+
value: d,
|
|
1192
|
+
onChange: ($) => h($.currentTarget.value),
|
|
1193
|
+
placeholder: "补充说明(可选)"
|
|
1194
|
+
}
|
|
1195
|
+
),
|
|
1196
|
+
/* @__PURE__ */ a(
|
|
1197
|
+
"button",
|
|
1198
|
+
{
|
|
1199
|
+
className: "make-ai-assistant__feedback-text-action",
|
|
1200
|
+
type: "submit",
|
|
1201
|
+
disabled: b,
|
|
1202
|
+
children: "提交反馈"
|
|
1203
|
+
}
|
|
1204
|
+
),
|
|
1205
|
+
/* @__PURE__ */ a(
|
|
1206
|
+
"button",
|
|
1207
|
+
{
|
|
1208
|
+
className: "make-ai-assistant__feedback-text-action",
|
|
1209
|
+
type: "button",
|
|
1210
|
+
onClick: () => i(!1),
|
|
1211
|
+
children: "取消"
|
|
1212
|
+
}
|
|
1213
|
+
)
|
|
1214
|
+
]
|
|
1215
|
+
}
|
|
1216
|
+
) : null
|
|
1217
|
+
]
|
|
1218
|
+
}
|
|
1219
|
+
);
|
|
1034
1220
|
}
|
|
1035
|
-
const
|
|
1221
|
+
const $t = /* @__PURE__ */ new Set([
|
|
1036
1222
|
"image/png",
|
|
1037
1223
|
"image/jpeg",
|
|
1038
1224
|
"image/webp",
|
|
@@ -1045,428 +1231,390 @@ const Bt = /* @__PURE__ */ new Set([
|
|
|
1045
1231
|
"video/webm",
|
|
1046
1232
|
"video/ogg"
|
|
1047
1233
|
]);
|
|
1048
|
-
function
|
|
1234
|
+
function Sa({
|
|
1049
1235
|
part: e,
|
|
1050
1236
|
context: t,
|
|
1051
|
-
transport:
|
|
1237
|
+
transport: s,
|
|
1052
1238
|
chatId: i
|
|
1053
1239
|
}) {
|
|
1054
|
-
const [
|
|
1055
|
-
|
|
1240
|
+
const [o, c] = N(), [d, h] = N(), [b, f] = N(!1), $ = S([]), L = S(void 0);
|
|
1241
|
+
ie(
|
|
1056
1242
|
() => () => {
|
|
1057
|
-
|
|
1243
|
+
L.current?.abort(), $.current.forEach((j) => URL.revokeObjectURL(j));
|
|
1058
1244
|
},
|
|
1059
1245
|
[]
|
|
1060
1246
|
);
|
|
1061
|
-
const
|
|
1062
|
-
if (!
|
|
1063
|
-
const
|
|
1064
|
-
|
|
1247
|
+
const T = async (j) => {
|
|
1248
|
+
if (!s.readContent || b) return;
|
|
1249
|
+
const M = new AbortController();
|
|
1250
|
+
L.current = M, f(!0), h(void 0);
|
|
1065
1251
|
try {
|
|
1066
|
-
const
|
|
1252
|
+
const U = await s.readContent(
|
|
1067
1253
|
t,
|
|
1068
1254
|
{ chatId: i, contentRef: e.media.contentRef },
|
|
1069
|
-
{ signal:
|
|
1255
|
+
{ signal: M.signal }
|
|
1070
1256
|
);
|
|
1071
|
-
if (
|
|
1072
|
-
const
|
|
1073
|
-
type:
|
|
1074
|
-
}),
|
|
1075
|
-
if (
|
|
1257
|
+
if (M.signal.aborted) return;
|
|
1258
|
+
const g = new Blob([new Uint8Array(U).buffer], {
|
|
1259
|
+
type: j && $t.has(e.media.contentType) ? e.media.contentType : "application/octet-stream"
|
|
1260
|
+
}), R = URL.createObjectURL(g);
|
|
1261
|
+
if ($.current.push(R), j) c(R);
|
|
1076
1262
|
else {
|
|
1077
|
-
const
|
|
1078
|
-
|
|
1263
|
+
const P = document.createElement("a");
|
|
1264
|
+
P.href = R, P.download = e.name ?? "attachment", P.click();
|
|
1079
1265
|
}
|
|
1080
|
-
} catch (
|
|
1081
|
-
|
|
1266
|
+
} catch (U) {
|
|
1267
|
+
M.signal.aborted || h(bt(U));
|
|
1082
1268
|
} finally {
|
|
1083
|
-
|
|
1269
|
+
M.signal.aborted || f(!1);
|
|
1084
1270
|
}
|
|
1085
1271
|
};
|
|
1086
|
-
return /* @__PURE__ */
|
|
1087
|
-
/* @__PURE__ */
|
|
1272
|
+
return /* @__PURE__ */ l("div", { className: "make-ai-assistant__attachment", children: [
|
|
1273
|
+
/* @__PURE__ */ l("span", { children: [
|
|
1088
1274
|
e.name ?? "附件",
|
|
1089
1275
|
" · ",
|
|
1090
1276
|
e.media.sizeBytes,
|
|
1091
1277
|
" 字节"
|
|
1092
1278
|
] }),
|
|
1093
|
-
/* @__PURE__ */
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1279
|
+
s.readContent ? /* @__PURE__ */ l(Ne, { children: [
|
|
1280
|
+
/* @__PURE__ */ a("button", { type: "button", disabled: b, onClick: () => {
|
|
1281
|
+
T(!1);
|
|
1282
|
+
}, children: "下载附件" }),
|
|
1283
|
+
$t.has(e.media.contentType) ? /* @__PURE__ */ a("button", { type: "button", disabled: b, onClick: () => {
|
|
1284
|
+
T(!0);
|
|
1285
|
+
}, children: "预览附件" }) : null
|
|
1286
|
+
] }) : null,
|
|
1099
1287
|
d ? /* @__PURE__ */ a("span", { role: "alert", children: d }) : null,
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1288
|
+
o && e.kind === "image" ? /* @__PURE__ */ a("img", { src: o, alt: e.name ?? "附件图片" }) : null,
|
|
1289
|
+
o && e.kind === "audio" ? /* @__PURE__ */ a("audio", { src: o, controls: !0 }) : null,
|
|
1290
|
+
o && e.kind === "video" ? /* @__PURE__ */ a("video", { src: o, controls: !0 }) : null
|
|
1103
1291
|
] });
|
|
1104
1292
|
}
|
|
1105
|
-
function
|
|
1293
|
+
function La({
|
|
1106
1294
|
message: e,
|
|
1107
1295
|
context: t,
|
|
1108
|
-
transport:
|
|
1296
|
+
transport: s,
|
|
1109
1297
|
chatId: i
|
|
1110
1298
|
}) {
|
|
1111
|
-
return /* @__PURE__ */ a(
|
|
1112
|
-
(
|
|
1113
|
-
|
|
1299
|
+
return /* @__PURE__ */ a(Ne, { children: e.parts?.map(
|
|
1300
|
+
(o, c) => o.kind === "text" ? null : /* @__PURE__ */ a(
|
|
1301
|
+
Sa,
|
|
1114
1302
|
{
|
|
1115
|
-
part:
|
|
1303
|
+
part: o,
|
|
1116
1304
|
context: t,
|
|
1117
|
-
transport:
|
|
1305
|
+
transport: s,
|
|
1118
1306
|
chatId: i
|
|
1119
1307
|
},
|
|
1120
|
-
|
|
1308
|
+
o.id ?? `${e.id}:${c}`
|
|
1121
1309
|
)
|
|
1122
1310
|
) });
|
|
1123
1311
|
}
|
|
1124
|
-
const
|
|
1125
|
-
const
|
|
1126
|
-
|
|
1312
|
+
const Vt = (e) => e.type.split(";")[0].trim().toLowerCase() || "application/octet-stream", $a = (e) => e.startsWith("image/") && e !== "image/svg+xml" ? "image" : e.startsWith("audio/") ? "audio" : e.startsWith("video/") ? "video" : "file", xa = (e) => {
|
|
1313
|
+
const t = Vt(e);
|
|
1314
|
+
if (!(!t.startsWith("image/") || t === "image/svg+xml" || typeof URL > "u" || typeof URL.createObjectURL != "function"))
|
|
1315
|
+
return URL.createObjectURL(e);
|
|
1316
|
+
}, xt = (e) => {
|
|
1317
|
+
e && typeof URL < "u" && typeof URL.revokeObjectURL == "function" && URL.revokeObjectURL(e);
|
|
1318
|
+
}, Da = (e, t) => new Promise((s, i) => {
|
|
1319
|
+
const o = new FileReader(), c = () => t.removeEventListener("abort", d), d = () => {
|
|
1320
|
+
o.abort(), c(), i(Object.assign(new Error("Read aborted"), { name: "AbortError" }));
|
|
1127
1321
|
};
|
|
1128
1322
|
if (t.aborted) {
|
|
1129
1323
|
d();
|
|
1130
1324
|
return;
|
|
1131
1325
|
}
|
|
1132
|
-
t.addEventListener("abort", d, { once: !0 }),
|
|
1133
|
-
|
|
1134
|
-
},
|
|
1135
|
-
|
|
1136
|
-
},
|
|
1326
|
+
t.addEventListener("abort", d, { once: !0 }), o.onload = () => {
|
|
1327
|
+
c(), s(new Uint8Array(o.result));
|
|
1328
|
+
}, o.onerror = () => {
|
|
1329
|
+
c(), i(new Error("无法读取文件"));
|
|
1330
|
+
}, o.readAsArrayBuffer(e);
|
|
1137
1331
|
});
|
|
1138
|
-
function
|
|
1139
|
-
const [i,
|
|
1140
|
-
|
|
1141
|
-
const
|
|
1142
|
-
!
|
|
1143
|
-
},
|
|
1144
|
-
for (const
|
|
1145
|
-
|
|
1332
|
+
function Ba(e, t, s) {
|
|
1333
|
+
const [i, o] = N([]), c = S(/* @__PURE__ */ new Map()), d = S(Promise.resolve()), h = t.scopeKey?.(e) ?? e.app.id, b = S(h);
|
|
1334
|
+
b.current = h;
|
|
1335
|
+
const f = S(void 0), $ = s.enabled && t.features?.attachments === !0, L = (p, n) => {
|
|
1336
|
+
!c.current.has(p.draft.id) || p.scope !== b.current || (p.draft = { ...p.draft, ...n }, o([...c.current.values()].map((v) => v.draft)));
|
|
1337
|
+
}, T = () => {
|
|
1338
|
+
for (const p of c.current.values())
|
|
1339
|
+
p.controller.abort(), xt(p.draft.previewUrl);
|
|
1340
|
+
c.current.clear(), o([]), f.current = void 0, d.current = Promise.resolve();
|
|
1146
1341
|
};
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
}, [
|
|
1150
|
-
const
|
|
1151
|
-
const
|
|
1152
|
-
if (
|
|
1342
|
+
ie(() => (T(), T), [h, t]), ie(() => {
|
|
1343
|
+
f.current && s.chat?.chatId !== f.current && T();
|
|
1344
|
+
}, [s.chat?.chatId]);
|
|
1345
|
+
const j = async (p) => {
|
|
1346
|
+
const n = p.controller.signal, v = () => {
|
|
1347
|
+
if (n.aborted || p.scope !== b.current || !c.current.has(p.draft.id))
|
|
1153
1348
|
throw Object.assign(new Error("Upload aborted"), {
|
|
1154
1349
|
name: "AbortError"
|
|
1155
1350
|
});
|
|
1156
1351
|
};
|
|
1157
1352
|
try {
|
|
1158
|
-
if (
|
|
1159
|
-
const
|
|
1160
|
-
|
|
1161
|
-
const
|
|
1162
|
-
|
|
1163
|
-
let
|
|
1353
|
+
if (v(), p.file.size > 64 << 20) throw new Error("文件不能超过 64 MiB");
|
|
1354
|
+
const k = await s.ensureChat();
|
|
1355
|
+
v(), f.current = k.chatId;
|
|
1356
|
+
const q = Vt(p.file);
|
|
1357
|
+
L(p, { status: "uploading", error: void 0 });
|
|
1358
|
+
let I = p.draft.upload ? await t.getUpload(
|
|
1164
1359
|
e,
|
|
1165
|
-
{ chatId:
|
|
1166
|
-
{ signal:
|
|
1360
|
+
{ chatId: k.chatId, uploadId: p.draft.upload.id },
|
|
1361
|
+
{ signal: n }
|
|
1167
1362
|
) : await t.startUpload(
|
|
1168
1363
|
e,
|
|
1169
1364
|
{
|
|
1170
|
-
chatId:
|
|
1171
|
-
fileId:
|
|
1172
|
-
name:
|
|
1173
|
-
contentType:
|
|
1174
|
-
sizeBytes:
|
|
1365
|
+
chatId: k.chatId,
|
|
1366
|
+
fileId: p.draft.fileId,
|
|
1367
|
+
name: p.file.name,
|
|
1368
|
+
contentType: q,
|
|
1369
|
+
sizeBytes: p.file.size
|
|
1175
1370
|
},
|
|
1176
|
-
{ signal:
|
|
1371
|
+
{ signal: n }
|
|
1177
1372
|
);
|
|
1178
|
-
if (
|
|
1373
|
+
if (v(), L(p, { upload: I }), I.name !== p.file.name || I.contentType !== q || I.sizeBytes !== p.file.size)
|
|
1179
1374
|
throw new Error("上传文件身份不一致");
|
|
1180
|
-
if (
|
|
1181
|
-
|
|
1375
|
+
if (I.status !== "ready") {
|
|
1376
|
+
I = await t.getUpload(
|
|
1182
1377
|
e,
|
|
1183
|
-
{ chatId:
|
|
1184
|
-
{ signal:
|
|
1185
|
-
),
|
|
1186
|
-
const
|
|
1187
|
-
for (let
|
|
1188
|
-
if (
|
|
1189
|
-
const
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
Math.min(
|
|
1378
|
+
{ chatId: k.chatId, uploadId: I.id },
|
|
1379
|
+
{ signal: n }
|
|
1380
|
+
), v();
|
|
1381
|
+
const G = new Set(I.completedParts), Y = Math.ceil(p.file.size / I.partSize);
|
|
1382
|
+
for (let z = 0; z < Y; z += 1) {
|
|
1383
|
+
if (v(), !G.has(z)) {
|
|
1384
|
+
const Q = await Da(
|
|
1385
|
+
p.file.slice(
|
|
1386
|
+
z * I.partSize,
|
|
1387
|
+
Math.min(p.file.size, (z + 1) * I.partSize)
|
|
1193
1388
|
),
|
|
1194
|
-
|
|
1389
|
+
n
|
|
1195
1390
|
);
|
|
1196
|
-
|
|
1391
|
+
v(), await t.uploadPart(
|
|
1197
1392
|
e,
|
|
1198
|
-
{ chatId:
|
|
1199
|
-
{ signal:
|
|
1200
|
-
),
|
|
1393
|
+
{ chatId: k.chatId, uploadId: I.id, part: z, bytes: Q },
|
|
1394
|
+
{ signal: n }
|
|
1395
|
+
), v(), G.add(z);
|
|
1201
1396
|
}
|
|
1202
|
-
|
|
1397
|
+
L(p, { progress: G.size / Math.max(Y, 1) });
|
|
1203
1398
|
}
|
|
1204
|
-
|
|
1399
|
+
L(p, { status: "completing" }), I = await t.completeUpload(
|
|
1205
1400
|
e,
|
|
1206
|
-
{ chatId:
|
|
1207
|
-
{ signal:
|
|
1208
|
-
),
|
|
1401
|
+
{ chatId: k.chatId, uploadId: I.id },
|
|
1402
|
+
{ signal: n }
|
|
1403
|
+
), v();
|
|
1209
1404
|
}
|
|
1210
|
-
if (
|
|
1405
|
+
if (I.status !== "ready" || !I.content)
|
|
1211
1406
|
throw new Error("上传尚未完成");
|
|
1212
|
-
|
|
1213
|
-
} catch (
|
|
1214
|
-
|
|
1215
|
-
status:
|
|
1216
|
-
error:
|
|
1407
|
+
L(p, { status: "ready", progress: 1, upload: I });
|
|
1408
|
+
} catch (k) {
|
|
1409
|
+
L(p, {
|
|
1410
|
+
status: n.aborted ? "paused" : "failed",
|
|
1411
|
+
error: n.aborted ? void 0 : bt(k)
|
|
1217
1412
|
});
|
|
1218
1413
|
}
|
|
1219
|
-
},
|
|
1220
|
-
if (
|
|
1221
|
-
if (
|
|
1222
|
-
|
|
1414
|
+
}, M = (p) => {
|
|
1415
|
+
if ($) {
|
|
1416
|
+
if (p.length + c.current.size > 32) {
|
|
1417
|
+
s.setError("每条消息最多包含 32 个附件或文本片段");
|
|
1223
1418
|
return;
|
|
1224
1419
|
}
|
|
1225
|
-
for (const
|
|
1226
|
-
const
|
|
1227
|
-
id:
|
|
1228
|
-
fileId:
|
|
1229
|
-
name:
|
|
1230
|
-
size:
|
|
1420
|
+
for (const n of p) {
|
|
1421
|
+
const v = {
|
|
1422
|
+
id: Pe(),
|
|
1423
|
+
fileId: Pe(),
|
|
1424
|
+
name: n.name,
|
|
1425
|
+
size: n.size,
|
|
1231
1426
|
status: "queued",
|
|
1232
|
-
progress: 0
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1427
|
+
progress: 0,
|
|
1428
|
+
previewUrl: xa(n)
|
|
1429
|
+
}, k = {
|
|
1430
|
+
draft: v,
|
|
1431
|
+
file: n,
|
|
1236
1432
|
controller: new AbortController(),
|
|
1237
|
-
scope:
|
|
1433
|
+
scope: h
|
|
1238
1434
|
};
|
|
1239
|
-
|
|
1435
|
+
c.current.set(v.id, k), d.current = d.current.then(() => j(k));
|
|
1240
1436
|
}
|
|
1241
|
-
|
|
1437
|
+
o([...c.current.values()].map((n) => n.draft));
|
|
1242
1438
|
}
|
|
1243
|
-
},
|
|
1244
|
-
const
|
|
1245
|
-
!
|
|
1246
|
-
},
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1439
|
+
}, U = (p) => {
|
|
1440
|
+
const n = c.current.get(p);
|
|
1441
|
+
!n || !["paused", "failed"].includes(n.draft.status) || (n.controller = new AbortController(), L(n, { status: "queued" }), d.current = d.current.then(() => j(n)));
|
|
1442
|
+
}, g = (p) => {
|
|
1443
|
+
const n = c.current.get(p);
|
|
1444
|
+
n?.controller.abort(), xt(n?.draft.previewUrl), c.current.delete(p), o([...c.current.values()].map((v) => v.draft));
|
|
1445
|
+
}, R = (p) => c.current.get(p)?.controller.abort(), P = i.flatMap((p) => {
|
|
1446
|
+
const n = p.upload;
|
|
1447
|
+
if (p.status !== "ready" || !n?.content) return [];
|
|
1448
|
+
const v = $a(n.contentType);
|
|
1252
1449
|
return [
|
|
1253
1450
|
{
|
|
1254
|
-
id:
|
|
1255
|
-
kind:
|
|
1256
|
-
name:
|
|
1451
|
+
id: p.id,
|
|
1452
|
+
kind: v,
|
|
1453
|
+
name: n.name,
|
|
1257
1454
|
media: {
|
|
1258
|
-
contentRef:
|
|
1259
|
-
contentType:
|
|
1260
|
-
sizeBytes:
|
|
1261
|
-
digestSha256:
|
|
1455
|
+
contentRef: n.content.contentRef,
|
|
1456
|
+
contentType: n.contentType,
|
|
1457
|
+
sizeBytes: n.content.sizeBytes,
|
|
1458
|
+
digestSha256: n.content.digestSha256
|
|
1262
1459
|
}
|
|
1263
1460
|
}
|
|
1264
1461
|
];
|
|
1265
1462
|
});
|
|
1266
1463
|
return {
|
|
1267
|
-
enabled:
|
|
1464
|
+
enabled: $,
|
|
1268
1465
|
drafts: i,
|
|
1269
|
-
parts:
|
|
1270
|
-
pending: i.some((
|
|
1271
|
-
add:
|
|
1272
|
-
retry:
|
|
1273
|
-
remove:
|
|
1274
|
-
pause:
|
|
1275
|
-
clear:
|
|
1466
|
+
parts: P,
|
|
1467
|
+
pending: i.some((p) => p.status !== "ready"),
|
|
1468
|
+
add: M,
|
|
1469
|
+
retry: U,
|
|
1470
|
+
remove: g,
|
|
1471
|
+
pause: R,
|
|
1472
|
+
clear: T
|
|
1276
1473
|
};
|
|
1277
1474
|
}
|
|
1278
1475
|
function Ua({
|
|
1279
1476
|
attachments: e,
|
|
1280
1477
|
onOpenChange: t,
|
|
1281
|
-
open:
|
|
1478
|
+
open: s,
|
|
1282
1479
|
triggerRef: i
|
|
1283
1480
|
}) {
|
|
1284
|
-
const
|
|
1285
|
-
|
|
1286
|
-
if (!
|
|
1287
|
-
const
|
|
1288
|
-
const
|
|
1289
|
-
|
|
1481
|
+
const o = S(null), c = S(null);
|
|
1482
|
+
ie(() => {
|
|
1483
|
+
if (!s) return;
|
|
1484
|
+
const h = (b) => {
|
|
1485
|
+
const f = b.target;
|
|
1486
|
+
f instanceof Node && !o.current?.contains(f) && t(!1);
|
|
1290
1487
|
};
|
|
1291
|
-
return document.addEventListener("pointerdown",
|
|
1292
|
-
document.removeEventListener("pointerdown",
|
|
1488
|
+
return document.addEventListener("pointerdown", h), () => {
|
|
1489
|
+
document.removeEventListener("pointerdown", h);
|
|
1293
1490
|
};
|
|
1294
|
-
}, [t,
|
|
1295
|
-
const
|
|
1296
|
-
e.add(Array.from(
|
|
1491
|
+
}, [t, s]);
|
|
1492
|
+
const d = (h) => {
|
|
1493
|
+
e.add(Array.from(h.files ?? [])), h.value = "", t(!1);
|
|
1297
1494
|
};
|
|
1298
|
-
return /* @__PURE__ */
|
|
1495
|
+
return /* @__PURE__ */ l("div", { className: "make-ai-assistant__attachment-composer", ref: o, children: [
|
|
1299
1496
|
/* @__PURE__ */ a(
|
|
1300
1497
|
"button",
|
|
1301
1498
|
{
|
|
1302
|
-
"aria-expanded":
|
|
1499
|
+
"aria-expanded": s,
|
|
1303
1500
|
"aria-haspopup": "menu",
|
|
1304
1501
|
"aria-label": "添加附件",
|
|
1305
1502
|
className: "make-ai-assistant__attachment-trigger",
|
|
1306
1503
|
ref: i,
|
|
1307
1504
|
title: "添加附件",
|
|
1308
1505
|
type: "button",
|
|
1309
|
-
onClick: () => t(!
|
|
1506
|
+
onClick: () => t(!s),
|
|
1310
1507
|
children: /* @__PURE__ */ a("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: /* @__PURE__ */ a("path", { d: "M12 5v14M5 12h14" }) })
|
|
1311
1508
|
}
|
|
1312
1509
|
),
|
|
1313
|
-
|
|
1510
|
+
s ? /* @__PURE__ */ a(
|
|
1314
1511
|
"div",
|
|
1315
1512
|
{
|
|
1316
1513
|
"aria-label": "附件选项",
|
|
1317
1514
|
className: "make-ai-assistant__attachment-menu",
|
|
1318
1515
|
role: "menu",
|
|
1319
|
-
children:
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
children: [
|
|
1327
|
-
/* @__PURE__ */
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
}
|
|
1335
|
-
),
|
|
1336
|
-
/* @__PURE__ */ c(
|
|
1337
|
-
"button",
|
|
1338
|
-
{
|
|
1339
|
-
role: "menuitem",
|
|
1340
|
-
type: "button",
|
|
1341
|
-
onClick: () => d.current?.click(),
|
|
1342
|
-
children: [
|
|
1343
|
-
/* @__PURE__ */ c("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
|
|
1344
|
-
/* @__PURE__ */ a("path", { d: "M7 3.5h7l4 4V20H7z" }),
|
|
1345
|
-
/* @__PURE__ */ a("path", { d: "M14 3.5v4h4M10 12h5M10 15h5" })
|
|
1346
|
-
] }),
|
|
1347
|
-
/* @__PURE__ */ a("span", { children: "上传文件" })
|
|
1348
|
-
]
|
|
1349
|
-
}
|
|
1350
|
-
)
|
|
1351
|
-
]
|
|
1516
|
+
children: /* @__PURE__ */ l(
|
|
1517
|
+
"button",
|
|
1518
|
+
{
|
|
1519
|
+
role: "menuitem",
|
|
1520
|
+
type: "button",
|
|
1521
|
+
onClick: () => c.current?.click(),
|
|
1522
|
+
children: [
|
|
1523
|
+
/* @__PURE__ */ l("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
|
|
1524
|
+
/* @__PURE__ */ a("path", { d: "M12 15V4M7.5 8.5 12 4l4.5 4.5" }),
|
|
1525
|
+
/* @__PURE__ */ a("path", { d: "M5 14v5h14v-5" })
|
|
1526
|
+
] }),
|
|
1527
|
+
/* @__PURE__ */ a("span", { children: "上传文件或图片" })
|
|
1528
|
+
]
|
|
1529
|
+
}
|
|
1530
|
+
)
|
|
1352
1531
|
}
|
|
1353
1532
|
) : null,
|
|
1354
1533
|
/* @__PURE__ */ a(
|
|
1355
1534
|
"input",
|
|
1356
1535
|
{
|
|
1357
|
-
|
|
1358
|
-
"aria-label": "上传图片",
|
|
1536
|
+
"aria-label": "上传文件或图片",
|
|
1359
1537
|
hidden: !0,
|
|
1360
1538
|
multiple: !0,
|
|
1361
|
-
ref:
|
|
1539
|
+
ref: c,
|
|
1362
1540
|
type: "file",
|
|
1363
|
-
onChange: (
|
|
1364
|
-
}
|
|
1365
|
-
),
|
|
1366
|
-
/* @__PURE__ */ a(
|
|
1367
|
-
"input",
|
|
1368
|
-
{
|
|
1369
|
-
"aria-label": "上传文件",
|
|
1370
|
-
hidden: !0,
|
|
1371
|
-
multiple: !0,
|
|
1372
|
-
ref: d,
|
|
1373
|
-
type: "file",
|
|
1374
|
-
onChange: (f) => g(f.currentTarget)
|
|
1541
|
+
onChange: (h) => d(h.currentTarget)
|
|
1375
1542
|
}
|
|
1376
1543
|
)
|
|
1377
1544
|
] });
|
|
1378
1545
|
}
|
|
1379
|
-
function
|
|
1546
|
+
function Fa({
|
|
1380
1547
|
attachments: e
|
|
1381
1548
|
}) {
|
|
1382
|
-
return e.drafts.length ? /* @__PURE__ */ a("div", { className: "make-ai-assistant__attachment-drafts", "aria-label": "待发送附件", children: /* @__PURE__ */ a("ul", { children: e.drafts.map((t) => /* @__PURE__ */
|
|
1383
|
-
/* @__PURE__ */
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1549
|
+
return e.drafts.length ? /* @__PURE__ */ a("div", { className: "make-ai-assistant__attachment-drafts", "aria-label": "待发送附件", children: /* @__PURE__ */ a("ul", { children: e.drafts.map((t) => /* @__PURE__ */ l("li", { "data-status": t.status, children: [
|
|
1550
|
+
t.previewUrl ? /* @__PURE__ */ a(
|
|
1551
|
+
"img",
|
|
1552
|
+
{
|
|
1553
|
+
alt: "",
|
|
1554
|
+
className: "make-ai-assistant__attachment-draft-preview",
|
|
1555
|
+
src: t.previewUrl
|
|
1556
|
+
}
|
|
1557
|
+
) : /* @__PURE__ */ a(
|
|
1558
|
+
"span",
|
|
1559
|
+
{
|
|
1560
|
+
"aria-hidden": "true",
|
|
1561
|
+
className: "make-ai-assistant__attachment-draft-file",
|
|
1562
|
+
children: /* @__PURE__ */ l("svg", { viewBox: "0 0 24 24", children: [
|
|
1563
|
+
/* @__PURE__ */ a("path", { d: "M6 3h8l4 4v14H6z" }),
|
|
1564
|
+
/* @__PURE__ */ a("path", { d: "M14 3v5h5M9 13h6M9 16h6" })
|
|
1565
|
+
] })
|
|
1566
|
+
}
|
|
1567
|
+
),
|
|
1568
|
+
/* @__PURE__ */ l("span", { className: "make-ai-assistant__attachment-draft-details", children: [
|
|
1569
|
+
/* @__PURE__ */ a("span", { className: "make-ai-assistant__attachment-draft-name", title: t.name, children: t.name }),
|
|
1570
|
+
/* @__PURE__ */ a("span", { className: "make-ai-assistant__attachment-draft-status", children: t.status === "ready" ? "已上传" : t.status === "completing" ? "校验中" : t.status === "paused" ? "已暂停" : t.status === "failed" ? "上传失败" : `${Math.round(t.progress * 100)}%` })
|
|
1388
1571
|
] }),
|
|
1389
1572
|
t.error ? /* @__PURE__ */ a("span", { role: "alert", children: t.error }) : null,
|
|
1390
1573
|
t.status === "failed" || t.status === "paused" ? /* @__PURE__ */ a("button", { type: "button", onClick: () => e.retry(t.id), children: "重试上传" }) : null,
|
|
1391
1574
|
t.status === "uploading" ? /* @__PURE__ */ a("button", { type: "button", onClick: () => e.pause(t.id), children: "暂停上传" }) : null,
|
|
1392
|
-
/* @__PURE__ */ a(
|
|
1575
|
+
/* @__PURE__ */ a(
|
|
1576
|
+
"button",
|
|
1577
|
+
{
|
|
1578
|
+
"aria-label": `移除附件 ${t.name}`,
|
|
1579
|
+
className: "make-ai-assistant__attachment-draft-remove",
|
|
1580
|
+
type: "button",
|
|
1581
|
+
onClick: () => e.remove(t.id),
|
|
1582
|
+
children: /* @__PURE__ */ a("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: /* @__PURE__ */ a("path", { d: "m7 7 10 10M17 7 7 17" }) })
|
|
1583
|
+
}
|
|
1584
|
+
)
|
|
1393
1585
|
] }, t.id)) }) }) : null;
|
|
1394
1586
|
}
|
|
1395
|
-
const
|
|
1587
|
+
const Pa = (e) => `${e}-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`, za = "Make", Wa = [
|
|
1396
1588
|
"总结当前页面数据",
|
|
1397
1589
|
"找出需要关注的记录",
|
|
1398
1590
|
"列出我有权限查看的数据对象"
|
|
1399
|
-
],
|
|
1591
|
+
], Zt = (e, t) => t ?? `${e?.trim() || za} AI 助手`, Oa = (e) => e ?? Wa, Ha = 480, Xt = 1024, qa = 0.72, Dt = 16, pt = (e, t, s) => Math.min(Math.max(e, Math.min(t, s)), s), Ka = (e) => typeof e == "number" && Number.isFinite(e) && e > 0 ? e : void 0, ja = (e, t, s) => {
|
|
1400
1592
|
const i = Math.min(
|
|
1401
|
-
|
|
1402
|
-
|
|
1593
|
+
Xt,
|
|
1594
|
+
s * qa
|
|
1403
1595
|
);
|
|
1404
|
-
return Math.max(e, Math.min(t ?? i,
|
|
1405
|
-
},
|
|
1406
|
-
|
|
1407
|
-
Math.max(t.width, 1),
|
|
1408
|
-
Math.max(1, i - be * 2)
|
|
1409
|
-
), o = Math.min(
|
|
1410
|
-
Math.max(t.height, 1),
|
|
1411
|
-
Math.max(1, n - be * 2)
|
|
1412
|
-
), d = e.left + e.width / 2, g = e.top + e.height / 2, p = [
|
|
1413
|
-
{
|
|
1414
|
-
left: e.right + Ge,
|
|
1415
|
-
placement: "right",
|
|
1416
|
-
top: g - o / 2
|
|
1417
|
-
},
|
|
1418
|
-
{
|
|
1419
|
-
left: e.left - Ge - s,
|
|
1420
|
-
placement: "left",
|
|
1421
|
-
top: g - o / 2
|
|
1422
|
-
},
|
|
1423
|
-
{
|
|
1424
|
-
left: d - s / 2,
|
|
1425
|
-
placement: "bottom",
|
|
1426
|
-
top: e.bottom + Ge
|
|
1427
|
-
},
|
|
1428
|
-
{
|
|
1429
|
-
left: d - s / 2,
|
|
1430
|
-
placement: "top",
|
|
1431
|
-
top: e.top - Ge - o
|
|
1432
|
-
}
|
|
1433
|
-
].find(
|
|
1434
|
-
({ left: k, top: $ }) => k >= be && $ >= be && k + s <= i - be && $ + o <= n - be
|
|
1435
|
-
);
|
|
1436
|
-
return p || {
|
|
1437
|
-
left: Ht(
|
|
1438
|
-
d - s / 2,
|
|
1439
|
-
be,
|
|
1440
|
-
i - be - s
|
|
1441
|
-
),
|
|
1442
|
-
placement: "bottom",
|
|
1443
|
-
top: Ht(
|
|
1444
|
-
e.bottom + Ge,
|
|
1445
|
-
be,
|
|
1446
|
-
n - be - o
|
|
1447
|
-
)
|
|
1448
|
-
};
|
|
1449
|
-
}, an = (e) => typeof e == "number" ? Number.isFinite(e) ? `${e}px` : void 0 : e?.trim() || void 0;
|
|
1450
|
-
class G extends Error {
|
|
1596
|
+
return Math.max(e, Math.min(t ?? i, s));
|
|
1597
|
+
}, Va = (e) => typeof e == "number" ? Number.isFinite(e) ? `${e}px` : void 0 : e?.trim() || void 0;
|
|
1598
|
+
class J extends Error {
|
|
1451
1599
|
}
|
|
1452
|
-
const
|
|
1600
|
+
const ot = (e, t) => {
|
|
1453
1601
|
if (!(typeof e != "object" || e === null))
|
|
1454
1602
|
return e[t];
|
|
1455
|
-
},
|
|
1456
|
-
const t =
|
|
1457
|
-
return typeof t == "number" ? t :
|
|
1458
|
-
|
|
1603
|
+
}, Za = (e) => {
|
|
1604
|
+
const t = ot(e, "status");
|
|
1605
|
+
return typeof t == "number" ? t : ot(
|
|
1606
|
+
ot(e, "response"),
|
|
1459
1607
|
"status"
|
|
1460
1608
|
);
|
|
1461
|
-
},
|
|
1462
|
-
const t =
|
|
1609
|
+
}, Xa = (e) => {
|
|
1610
|
+
const t = ot(e, "code"), s = Za(e), i = e instanceof Error ? e.message : "", o = [t, i].filter((b) => typeof b == "string").join(" ").toLowerCase(), d = globalThis.navigator?.onLine === !1 || /network|fetch|timeout|offline|connection|网络|连接|超时/.test(o), h = typeof s == "number" && s >= 500 || /server|service|服务器|服务异常/.test(o);
|
|
1463
1611
|
return d ? {
|
|
1464
1612
|
actionLabel: "重新连接",
|
|
1465
1613
|
description: "请检查网络后再试。",
|
|
1466
1614
|
kind: "network",
|
|
1467
1615
|
label: "网络连接",
|
|
1468
1616
|
title: "网络连接不可用"
|
|
1469
|
-
} :
|
|
1617
|
+
} : h ? {
|
|
1470
1618
|
actionLabel: "重新加载",
|
|
1471
1619
|
description: "服务暂时未能响应,请稍后重试。",
|
|
1472
1620
|
kind: "service",
|
|
@@ -1479,13 +1627,13 @@ const ut = (e, t) => {
|
|
|
1479
1627
|
label: "加载异常",
|
|
1480
1628
|
title: "暂时无法加载对话"
|
|
1481
1629
|
};
|
|
1482
|
-
},
|
|
1630
|
+
}, Bt = (e) => {
|
|
1483
1631
|
try {
|
|
1484
1632
|
const t = e?.return?.();
|
|
1485
1633
|
if (!t) return;
|
|
1486
|
-
Promise.resolve(t).catch((
|
|
1634
|
+
Promise.resolve(t).catch((s) => {
|
|
1487
1635
|
console.error("[make-ai-assistant] transport iterator close failed", {
|
|
1488
|
-
errorType:
|
|
1636
|
+
errorType: s instanceof Error ? s.name : typeof s
|
|
1489
1637
|
});
|
|
1490
1638
|
});
|
|
1491
1639
|
} catch (t) {
|
|
@@ -1493,7 +1641,7 @@ const ut = (e, t) => {
|
|
|
1493
1641
|
errorType: t instanceof Error ? t.name : typeof t
|
|
1494
1642
|
});
|
|
1495
1643
|
}
|
|
1496
|
-
},
|
|
1644
|
+
}, Ga = async (e) => {
|
|
1497
1645
|
if (globalThis.navigator?.clipboard?.writeText) {
|
|
1498
1646
|
await globalThis.navigator.clipboard.writeText(e);
|
|
1499
1647
|
return;
|
|
@@ -1502,187 +1650,183 @@ const ut = (e, t) => {
|
|
|
1502
1650
|
throw new Error("Clipboard API is unavailable");
|
|
1503
1651
|
const t = document.createElement("textarea");
|
|
1504
1652
|
t.value = e, t.setAttribute("readonly", ""), t.style.position = "fixed", t.style.inset = "0 auto auto 0", t.style.opacity = "0", document.body.append(t), t.select();
|
|
1505
|
-
const
|
|
1506
|
-
if (t.remove(), !
|
|
1653
|
+
const s = document.execCommand("copy");
|
|
1654
|
+
if (t.remove(), !s)
|
|
1507
1655
|
throw new Error("Clipboard copy failed");
|
|
1508
|
-
},
|
|
1656
|
+
}, Gt = () => /* @__PURE__ */ l("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
|
|
1509
1657
|
/* @__PURE__ */ a("path", { d: "M12 2.8c.5 4.4 2.8 6.8 7.2 7.2-4.4.5-6.8 2.8-7.2 7.2-.5-4.4-2.8-6.8-7.2-7.2 4.4-.5 6.8-2.8 7.2-7.2Z" }),
|
|
1510
1658
|
/* @__PURE__ */ a("path", { d: "M18.3 16.1c.2 1.8 1.2 2.8 3 3-1.8.2-2.8 1.2-3 3-.2-1.8-1.2-2.8-3-3 1.8-.2 2.8-1.2 3-3Z" })
|
|
1511
|
-
] }),
|
|
1659
|
+
] }), Ya = () => /* @__PURE__ */ a("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: /* @__PURE__ */ a("path", { d: "m6 6 12 12M18 6 6 18" }) }), Ja = () => /* @__PURE__ */ l("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
|
|
1512
1660
|
/* @__PURE__ */ a("path", { d: "M8 8h10v12H8z" }),
|
|
1513
1661
|
/* @__PURE__ */ a("path", { d: "M6 16H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" })
|
|
1514
|
-
] }),
|
|
1662
|
+
] }), Qa = () => /* @__PURE__ */ l("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
|
|
1515
1663
|
/* @__PURE__ */ a("path", { d: "M20 11a8 8 0 0 0-14.7-4.4L4 8" }),
|
|
1516
1664
|
/* @__PURE__ */ a("path", { d: "M4 4v4h4" }),
|
|
1517
1665
|
/* @__PURE__ */ a("path", { d: "M4 13a8 8 0 0 0 14.7 4.4L20 16" }),
|
|
1518
1666
|
/* @__PURE__ */ a("path", { d: "M20 20v-4h-4" })
|
|
1519
|
-
] }),
|
|
1520
|
-
/* @__PURE__ */ a("circle", { cx: "12", cy: "12", r: "8" }),
|
|
1521
|
-
/* @__PURE__ */ a("path", { d: "M9.8 9.4a2.35 2.35 0 1 1 3.93 1.73c-.96.86-1.73 1.42-1.73 2.87" }),
|
|
1522
|
-
/* @__PURE__ */ a("path", { d: "M12 17h.01" })
|
|
1523
|
-
] }), un = () => /* @__PURE__ */ c("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
|
|
1667
|
+
] }), es = () => /* @__PURE__ */ l("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
|
|
1524
1668
|
/* @__PURE__ */ a("path", { d: "M12 4v11" }),
|
|
1525
1669
|
/* @__PURE__ */ a("path", { d: "m7 10 5 5 5-5" }),
|
|
1526
1670
|
/* @__PURE__ */ a("path", { d: "M5 20h14" })
|
|
1527
|
-
] }),
|
|
1671
|
+
] }), ts = () => /* @__PURE__ */ a("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: /* @__PURE__ */ a("path", { d: "M12 5v14M5 12h14" }) }), as = () => /* @__PURE__ */ l("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
|
|
1528
1672
|
/* @__PURE__ */ a("path", { d: "M10 6h9M10 12h9M10 18h9" }),
|
|
1529
1673
|
/* @__PURE__ */ a("path", { d: "M5 6h.01M5 12h.01M5 18h.01" })
|
|
1530
|
-
] }),
|
|
1674
|
+
] }), ss = () => /* @__PURE__ */ a("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: /* @__PURE__ */ a("path", { d: "m7 10 5 5 5-5" }) }), Ut = () => /* @__PURE__ */ l("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
|
|
1531
1675
|
/* @__PURE__ */ a("path", { d: "m4 4 17 8-17 8 3-8-3-8Z" }),
|
|
1532
1676
|
/* @__PURE__ */ a("path", { d: "M7 12h14" })
|
|
1533
|
-
] }),
|
|
1677
|
+
] }), Yt = () => /* @__PURE__ */ l("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
|
|
1534
1678
|
/* @__PURE__ */ a("path", { d: "M20 11a8 8 0 0 0-14.7-4.4L4 8" }),
|
|
1535
1679
|
/* @__PURE__ */ a("path", { d: "M4 4v4h4" }),
|
|
1536
1680
|
/* @__PURE__ */ a("path", { d: "M4 13a8 8 0 0 0 14.7 4.4L20 16" }),
|
|
1537
1681
|
/* @__PURE__ */ a("path", { d: "M20 20v-4h-4" })
|
|
1538
|
-
] }),
|
|
1682
|
+
] }), ns = () => /* @__PURE__ */ l("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
|
|
1539
1683
|
/* @__PURE__ */ a("circle", { cx: "12", cy: "12", r: "8" }),
|
|
1540
1684
|
/* @__PURE__ */ a("path", { d: "M12 8v4.5" }),
|
|
1541
1685
|
/* @__PURE__ */ a("path", { d: "M12 16h.01" })
|
|
1542
|
-
] }),
|
|
1686
|
+
] }), ct = ({ className: e = "" }) => /* @__PURE__ */ a("span", { className: `make-ai-assistant__avatar ${e}`.trim(), "aria-hidden": "true", children: /* @__PURE__ */ a(Gt, {}) }), rs = ({ src: e }) => e ? /* @__PURE__ */ a("span", { className: "make-ai-assistant__user-avatar", "aria-hidden": "true", children: /* @__PURE__ */ a("img", { alt: "", src: e }) }) : null, is = ({
|
|
1543
1687
|
userAvatarUrl: e,
|
|
1544
1688
|
userName: t
|
|
1545
1689
|
}) => {
|
|
1546
|
-
const
|
|
1547
|
-
return !
|
|
1548
|
-
|
|
1549
|
-
/* @__PURE__ */ a(
|
|
1690
|
+
const s = t?.trim();
|
|
1691
|
+
return !s && !e ? null : /* @__PURE__ */ l("div", { className: "make-ai-assistant__message-identity", children: [
|
|
1692
|
+
s ? /* @__PURE__ */ a("span", { className: "make-ai-assistant__message-sender", children: s }) : null,
|
|
1693
|
+
/* @__PURE__ */ a(rs, { src: e })
|
|
1550
1694
|
] });
|
|
1551
|
-
},
|
|
1695
|
+
}, ft = (e) => {
|
|
1552
1696
|
const t = e.trim();
|
|
1553
1697
|
if (!(!t.startsWith("|") || !t.endsWith("|")))
|
|
1554
|
-
return t.slice(1, -1).split("|").map((
|
|
1555
|
-
},
|
|
1556
|
-
const
|
|
1557
|
-
if (!
|
|
1698
|
+
return t.slice(1, -1).split("|").map((s) => s.trim());
|
|
1699
|
+
}, os = (e) => e.length > 0 && e.every((t) => /^:?-{3,}:?$/.test(t)), cs = (e, t) => {
|
|
1700
|
+
const s = ft(e[t] ?? ""), i = ft(e[t + 1] ?? "");
|
|
1701
|
+
if (!s || !i || s.length !== i.length || !os(i))
|
|
1558
1702
|
return;
|
|
1559
|
-
const
|
|
1560
|
-
let
|
|
1561
|
-
for (;
|
|
1562
|
-
const d =
|
|
1563
|
-
if (!d || d.length !==
|
|
1564
|
-
|
|
1703
|
+
const o = [];
|
|
1704
|
+
let c = t + 2;
|
|
1705
|
+
for (; c < e.length; ) {
|
|
1706
|
+
const d = ft(e[c] ?? "");
|
|
1707
|
+
if (!d || d.length !== s.length) break;
|
|
1708
|
+
o.push(d), c += 1;
|
|
1565
1709
|
}
|
|
1566
|
-
return { headers:
|
|
1567
|
-
},
|
|
1568
|
-
const t = [],
|
|
1710
|
+
return { headers: s, lastIndex: c - 1, rows: o };
|
|
1711
|
+
}, ls = (e) => {
|
|
1712
|
+
const t = [], s = [], i = [], o = [], c = e.replace(/\r\n?/g, `
|
|
1569
1713
|
`).split(`
|
|
1570
1714
|
`), d = () => {
|
|
1571
|
-
const
|
|
1715
|
+
const f = s.join(`
|
|
1572
1716
|
`).trim();
|
|
1573
|
-
|
|
1574
|
-
},
|
|
1717
|
+
s.length = 0, f && t.push({ type: "paragraph", text: f });
|
|
1718
|
+
}, h = () => {
|
|
1575
1719
|
i.length && t.push({ type: "list", items: i.splice(0) });
|
|
1576
|
-
},
|
|
1577
|
-
const
|
|
1720
|
+
}, b = () => {
|
|
1721
|
+
const f = o.join(`
|
|
1578
1722
|
`).trim();
|
|
1579
|
-
|
|
1723
|
+
o.length = 0, f && t.push({ type: "pre", text: f });
|
|
1580
1724
|
};
|
|
1581
|
-
for (let
|
|
1582
|
-
const
|
|
1583
|
-
if (
|
|
1584
|
-
d(),
|
|
1725
|
+
for (let f = 0; f < c.length; f += 1) {
|
|
1726
|
+
const $ = c[f] ?? "", L = $.trim();
|
|
1727
|
+
if (!L) {
|
|
1728
|
+
d(), h(), b();
|
|
1585
1729
|
continue;
|
|
1586
1730
|
}
|
|
1587
|
-
const
|
|
1588
|
-
if (
|
|
1589
|
-
d(),
|
|
1731
|
+
const T = cs(c, f);
|
|
1732
|
+
if (T) {
|
|
1733
|
+
d(), h(), b(), t.push({ headers: T.headers, rows: T.rows, type: "table" }), f = T.lastIndex;
|
|
1590
1734
|
continue;
|
|
1591
1735
|
}
|
|
1592
|
-
const
|
|
1593
|
-
if (
|
|
1594
|
-
d(),
|
|
1595
|
-
const
|
|
1596
|
-
|
|
1736
|
+
const j = /^(#{1,6})\s+(.+)$/.exec(L);
|
|
1737
|
+
if (j) {
|
|
1738
|
+
d(), h(), b();
|
|
1739
|
+
const U = (j[2] ?? "").replace(/\s+#+\s*$/, "").trim();
|
|
1740
|
+
U && t.push({
|
|
1597
1741
|
type: "heading",
|
|
1598
|
-
level:
|
|
1599
|
-
text:
|
|
1742
|
+
level: j[1]?.length,
|
|
1743
|
+
text: U
|
|
1600
1744
|
});
|
|
1601
1745
|
continue;
|
|
1602
1746
|
}
|
|
1603
|
-
if (/^\s*\|.+\|\s*$/.test(
|
|
1604
|
-
d(),
|
|
1747
|
+
if (/^\s*\|.+\|\s*$/.test($)) {
|
|
1748
|
+
d(), h(), o.push($.trim());
|
|
1605
1749
|
continue;
|
|
1606
1750
|
}
|
|
1607
|
-
const
|
|
1608
|
-
if (
|
|
1609
|
-
d(),
|
|
1751
|
+
const M = /^\s*[-*]\s+(.+)$/.exec($);
|
|
1752
|
+
if (M) {
|
|
1753
|
+
d(), b(), i.push(M[1]?.trim() ?? "");
|
|
1610
1754
|
continue;
|
|
1611
1755
|
}
|
|
1612
|
-
|
|
1756
|
+
h(), b(), s.push(L);
|
|
1613
1757
|
}
|
|
1614
|
-
return d(),
|
|
1615
|
-
},
|
|
1616
|
-
const t = [],
|
|
1758
|
+
return d(), h(), b(), t;
|
|
1759
|
+
}, Ze = (e) => {
|
|
1760
|
+
const t = [], s = /(\*\*[^*]+\*\*|`[^`]+`)/g;
|
|
1617
1761
|
let i = 0;
|
|
1618
|
-
for (const
|
|
1619
|
-
const
|
|
1620
|
-
d > i && t.push(e.slice(i, d)),
|
|
1762
|
+
for (const o of e.matchAll(s)) {
|
|
1763
|
+
const c = o[0], d = o.index ?? 0;
|
|
1764
|
+
d > i && t.push(e.slice(i, d)), c.startsWith("**") ? t.push(/* @__PURE__ */ a("strong", { children: c.slice(2, -2) }, `${d}-strong`)) : t.push(/* @__PURE__ */ a("code", { children: c.slice(1, -1) }, `${d}-code`)), i = d + c.length;
|
|
1621
1765
|
}
|
|
1622
1766
|
return i < e.length && t.push(e.slice(i)), t;
|
|
1623
|
-
},
|
|
1624
|
-
const t =
|
|
1625
|
-
return t.length ? /* @__PURE__ */ a("div", { className: "make-ai-assistant__bubble make-ai-assistant__assistant-text", children: t.map((
|
|
1626
|
-
if (
|
|
1627
|
-
const
|
|
1767
|
+
}, Ft = ({ content: e }) => {
|
|
1768
|
+
const t = ls(e);
|
|
1769
|
+
return t.length ? /* @__PURE__ */ a("div", { className: "make-ai-assistant__bubble make-ai-assistant__assistant-text", children: t.map((s, i) => {
|
|
1770
|
+
if (s.type === "heading") {
|
|
1771
|
+
const o = s.level <= 2 ? "h3" : "h4";
|
|
1628
1772
|
return /* @__PURE__ */ a(
|
|
1629
|
-
|
|
1773
|
+
o,
|
|
1630
1774
|
{
|
|
1631
|
-
className: `make-ai-assistant__markdown-heading make-ai-assistant__markdown-heading--${
|
|
1632
|
-
children:
|
|
1775
|
+
className: `make-ai-assistant__markdown-heading make-ai-assistant__markdown-heading--${s.level}`,
|
|
1776
|
+
children: Ze(s.text)
|
|
1633
1777
|
},
|
|
1634
1778
|
`${i}-heading`
|
|
1635
1779
|
);
|
|
1636
1780
|
}
|
|
1637
|
-
return
|
|
1781
|
+
return s.type === "paragraph" ? /* @__PURE__ */ a("p", { children: Ze(s.text) }, `${i}-paragraph`) : s.type === "pre" ? /* @__PURE__ */ a("pre", { children: /* @__PURE__ */ a("code", { children: s.text }) }, `${i}-pre`) : s.type === "table" ? /* @__PURE__ */ a(
|
|
1638
1782
|
"div",
|
|
1639
1783
|
{
|
|
1640
1784
|
"aria-label": "表格内容,可横向滚动",
|
|
1641
1785
|
className: "make-ai-assistant__markdown-table-scroll",
|
|
1642
1786
|
role: "region",
|
|
1643
1787
|
tabIndex: 0,
|
|
1644
|
-
children: /* @__PURE__ */
|
|
1645
|
-
/* @__PURE__ */ a("thead", { children: /* @__PURE__ */ a("tr", { children:
|
|
1646
|
-
/* @__PURE__ */ a("tbody", { children:
|
|
1788
|
+
children: /* @__PURE__ */ l("table", { className: "make-ai-assistant__markdown-table", children: [
|
|
1789
|
+
/* @__PURE__ */ a("thead", { children: /* @__PURE__ */ a("tr", { children: s.headers.map((o, c) => /* @__PURE__ */ a("th", { scope: "col", children: Ze(o) }, `${c}-${o}`)) }) }),
|
|
1790
|
+
/* @__PURE__ */ a("tbody", { children: s.rows.map((o, c) => /* @__PURE__ */ a("tr", { children: o.map((d, h) => /* @__PURE__ */ a("td", { children: Ze(d) }, `${h}-${d}`)) }, `${c}-${o.join("|")}`)) })
|
|
1647
1791
|
] })
|
|
1648
1792
|
},
|
|
1649
1793
|
`${i}-table`
|
|
1650
|
-
) : /* @__PURE__ */ a("ul", { children:
|
|
1794
|
+
) : /* @__PURE__ */ a("ul", { children: s.items.map((o, c) => /* @__PURE__ */ a("li", { children: Ze(o) }, `${c}-${o}`)) }, `${i}-list`);
|
|
1651
1795
|
}) }) : null;
|
|
1652
|
-
},
|
|
1653
|
-
/* @__PURE__ */ a(
|
|
1796
|
+
}, Jt = ({ assistantName: e }) => /* @__PURE__ */ l("div", { className: "make-ai-assistant__message-identity", children: [
|
|
1797
|
+
/* @__PURE__ */ a(ct, { className: "make-ai-assistant__avatar--message" }),
|
|
1654
1798
|
/* @__PURE__ */ a("span", { className: "make-ai-assistant__message-sender", children: e })
|
|
1655
|
-
] }),
|
|
1799
|
+
] }), Qt = (e) => {
|
|
1656
1800
|
for (let t = e.messages.length - 1; t >= 0; t -= 1) {
|
|
1657
|
-
const
|
|
1658
|
-
if (
|
|
1659
|
-
return
|
|
1801
|
+
const s = e.messages[t];
|
|
1802
|
+
if (s.role === "assistant" && s.status === "streaming")
|
|
1803
|
+
return s.id;
|
|
1660
1804
|
}
|
|
1661
|
-
},
|
|
1805
|
+
}, ds = (e) => {
|
|
1662
1806
|
for (let t = e.messages.length - 1; t >= 0; t -= 1)
|
|
1663
1807
|
if (e.messages[t].role === "user") return t;
|
|
1664
1808
|
return -1;
|
|
1665
|
-
},
|
|
1666
|
-
const t =
|
|
1809
|
+
}, ea = (e) => {
|
|
1810
|
+
const t = ds(e);
|
|
1667
1811
|
if (!(t < 0))
|
|
1668
|
-
for (let
|
|
1669
|
-
const i = e.messages[
|
|
1812
|
+
for (let s = e.messages.length - 1; s > t; s -= 1) {
|
|
1813
|
+
const i = e.messages[s];
|
|
1670
1814
|
if (i.role === "assistant") return i.id;
|
|
1671
1815
|
}
|
|
1672
|
-
},
|
|
1816
|
+
}, us = (e) => {
|
|
1673
1817
|
if (e.status === "idle")
|
|
1674
1818
|
for (let t = e.messages.length - 1; t >= 0; t -= 1) {
|
|
1675
|
-
const
|
|
1676
|
-
if (
|
|
1677
|
-
return
|
|
1819
|
+
const s = e.messages[t];
|
|
1820
|
+
if (s.role === "assistant" && s.status === "complete")
|
|
1821
|
+
return s.id;
|
|
1678
1822
|
}
|
|
1679
|
-
},
|
|
1823
|
+
}, ms = (e) => {
|
|
1680
1824
|
for (let t = e.messages.length - 1; t >= 0; t -= 1) {
|
|
1681
|
-
const
|
|
1682
|
-
if (
|
|
1825
|
+
const s = e.messages[t];
|
|
1826
|
+
if (s.role === "user") return s;
|
|
1683
1827
|
}
|
|
1684
|
-
},
|
|
1685
|
-
const
|
|
1828
|
+
}, hs = (e, t) => {
|
|
1829
|
+
const s = e.messages.findIndex(
|
|
1686
1830
|
(i) => i.id === t && i.role === "user"
|
|
1687
1831
|
);
|
|
1688
1832
|
return {
|
|
@@ -1690,130 +1834,151 @@ const ut = (e, t) => {
|
|
|
1690
1834
|
error: void 0,
|
|
1691
1835
|
progress: void 0,
|
|
1692
1836
|
status: "streaming",
|
|
1693
|
-
messages:
|
|
1837
|
+
messages: s < 0 ? e.messages : e.messages.slice(0, s + 1)
|
|
1694
1838
|
};
|
|
1695
|
-
},
|
|
1839
|
+
}, ps = (e) => e.scrollHeight - e.scrollTop - e.clientHeight <= 48, Pt = (e = "smooth") => globalThis.matchMedia?.("(prefers-reduced-motion: reduce)").matches ? "auto" : e, vt = (e, t) => {
|
|
1696
1840
|
typeof e.scrollTo == "function" ? e.scrollTo({ top: e.scrollHeight, behavior: t }) : e.scrollTop = e.scrollHeight;
|
|
1697
|
-
},
|
|
1841
|
+
}, ta = ({
|
|
1698
1842
|
error: e,
|
|
1699
1843
|
onRetry: t
|
|
1700
|
-
}) => /* @__PURE__ */
|
|
1844
|
+
}) => /* @__PURE__ */ l(
|
|
1701
1845
|
"div",
|
|
1702
1846
|
{
|
|
1703
1847
|
className: "make-ai-assistant__message-status make-ai-assistant__message-status--error",
|
|
1704
1848
|
"data-error-presentation": "request-failed",
|
|
1705
1849
|
role: "alert",
|
|
1706
1850
|
children: [
|
|
1707
|
-
/* @__PURE__ */
|
|
1708
|
-
/* @__PURE__ */ a("span", { className: "make-ai-assistant__message-status-icon", "aria-hidden": "true", children: /* @__PURE__ */ a(
|
|
1851
|
+
/* @__PURE__ */ l("div", { className: "make-ai-assistant__message-status-header", children: [
|
|
1852
|
+
/* @__PURE__ */ a("span", { className: "make-ai-assistant__message-status-icon", "aria-hidden": "true", children: /* @__PURE__ */ a(ns, {}) }),
|
|
1709
1853
|
/* @__PURE__ */ a("strong", { children: "请求未完成" })
|
|
1710
1854
|
] }),
|
|
1711
1855
|
/* @__PURE__ */ a("span", { className: "make-ai-assistant__message-status-message", children: e.message }),
|
|
1712
|
-
e.retryable && t ? /* @__PURE__ */
|
|
1856
|
+
e.retryable && t ? /* @__PURE__ */ l(
|
|
1713
1857
|
"button",
|
|
1714
1858
|
{
|
|
1715
1859
|
className: "make-ai-assistant__retry",
|
|
1716
1860
|
type: "button",
|
|
1717
1861
|
onClick: t,
|
|
1718
1862
|
children: [
|
|
1719
|
-
/* @__PURE__ */ a(
|
|
1863
|
+
/* @__PURE__ */ a(Yt, {}),
|
|
1720
1864
|
"重新发送"
|
|
1721
1865
|
]
|
|
1722
1866
|
}
|
|
1723
1867
|
) : null
|
|
1724
1868
|
]
|
|
1725
1869
|
}
|
|
1726
|
-
),
|
|
1870
|
+
), fs = ({
|
|
1727
1871
|
error: e,
|
|
1728
1872
|
onRetry: t
|
|
1729
1873
|
}) => {
|
|
1730
|
-
const
|
|
1731
|
-
return /* @__PURE__ */
|
|
1874
|
+
const s = Xa(e);
|
|
1875
|
+
return /* @__PURE__ */ l(
|
|
1732
1876
|
"section",
|
|
1733
1877
|
{
|
|
1734
1878
|
"aria-live": "assertive",
|
|
1735
1879
|
className: "make-ai-assistant__load-failure",
|
|
1736
|
-
"data-load-failure-kind":
|
|
1880
|
+
"data-load-failure-kind": s.kind,
|
|
1737
1881
|
role: "alert",
|
|
1738
1882
|
children: [
|
|
1739
|
-
/* @__PURE__ */ a("span", { className: "make-ai-assistant__load-failure-icon", "aria-hidden": "true", children: /* @__PURE__ */
|
|
1883
|
+
/* @__PURE__ */ a("span", { className: "make-ai-assistant__load-failure-icon", "aria-hidden": "true", children: /* @__PURE__ */ l("svg", { viewBox: "0 0 24 24", children: [
|
|
1740
1884
|
/* @__PURE__ */ a("path", { d: "M5 12a7 7 0 0 1 13.4-2.8A4.5 4.5 0 0 1 18 18H7.5A4.5 4.5 0 0 1 5 12Z" }),
|
|
1741
1885
|
/* @__PURE__ */ a("path", { d: "m9.2 14.8 5.6-5.6M9.2 9.2l5.6 5.6" })
|
|
1742
1886
|
] }) }),
|
|
1743
|
-
/* @__PURE__ */
|
|
1744
|
-
/* @__PURE__ */ a("span", { className: "make-ai-assistant__load-failure-label", children:
|
|
1745
|
-
/* @__PURE__ */ a("h3", { children:
|
|
1746
|
-
/* @__PURE__ */ a("p", { children:
|
|
1887
|
+
/* @__PURE__ */ l("div", { className: "make-ai-assistant__load-failure-copy", children: [
|
|
1888
|
+
/* @__PURE__ */ a("span", { className: "make-ai-assistant__load-failure-label", children: s.label }),
|
|
1889
|
+
/* @__PURE__ */ a("h3", { children: s.title }),
|
|
1890
|
+
/* @__PURE__ */ a("p", { children: s.description })
|
|
1747
1891
|
] }),
|
|
1748
|
-
/* @__PURE__ */
|
|
1892
|
+
/* @__PURE__ */ l(
|
|
1749
1893
|
"button",
|
|
1750
1894
|
{
|
|
1751
1895
|
className: "make-ai-assistant__retry make-ai-assistant__retry--primary",
|
|
1752
1896
|
type: "button",
|
|
1753
1897
|
onClick: t,
|
|
1754
1898
|
children: [
|
|
1755
|
-
/* @__PURE__ */ a(
|
|
1756
|
-
|
|
1899
|
+
/* @__PURE__ */ a(Yt, {}),
|
|
1900
|
+
s.actionLabel
|
|
1757
1901
|
]
|
|
1758
1902
|
}
|
|
1759
1903
|
)
|
|
1760
1904
|
]
|
|
1761
1905
|
}
|
|
1762
1906
|
);
|
|
1763
|
-
},
|
|
1907
|
+
}, aa = ({
|
|
1764
1908
|
active: e,
|
|
1765
1909
|
steps: t
|
|
1766
1910
|
}) => {
|
|
1911
|
+
const [s, i] = N(!1);
|
|
1767
1912
|
if (!e || !t?.length) return null;
|
|
1768
|
-
const
|
|
1769
|
-
return /* @__PURE__ */
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
t.length
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1913
|
+
const o = t[t.length - 1] ?? "处理中";
|
|
1914
|
+
return /* @__PURE__ */ l(
|
|
1915
|
+
"details",
|
|
1916
|
+
{
|
|
1917
|
+
className: "make-ai-assistant__process",
|
|
1918
|
+
open: s,
|
|
1919
|
+
onToggle: (c) => i(c.currentTarget.open),
|
|
1920
|
+
children: [
|
|
1921
|
+
/* @__PURE__ */ l("summary", { "aria-label": `查看处理过程,共 ${t.length} 步`, children: [
|
|
1922
|
+
/* @__PURE__ */ l("span", { className: "make-ai-assistant__process-summary", children: [
|
|
1923
|
+
/* @__PURE__ */ a("span", { className: "make-ai-assistant__process-indicator", "aria-hidden": "true" }),
|
|
1924
|
+
/* @__PURE__ */ l("span", { className: "make-ai-assistant__process-copy", children: [
|
|
1925
|
+
/* @__PURE__ */ a("span", { className: "make-ai-assistant__process-title", children: "处理过程" }),
|
|
1926
|
+
/* @__PURE__ */ a(
|
|
1927
|
+
"span",
|
|
1928
|
+
{
|
|
1929
|
+
className: "make-ai-assistant__progress make-ai-assistant__process-latest",
|
|
1930
|
+
role: "status",
|
|
1931
|
+
children: o
|
|
1932
|
+
}
|
|
1933
|
+
)
|
|
1934
|
+
] })
|
|
1935
|
+
] }),
|
|
1936
|
+
/* @__PURE__ */ l("span", { className: "make-ai-assistant__process-count", children: [
|
|
1937
|
+
t.length,
|
|
1938
|
+
" 步"
|
|
1939
|
+
] })
|
|
1940
|
+
] }),
|
|
1941
|
+
/* @__PURE__ */ a("ol", { children: t.map((c, d) => /* @__PURE__ */ l(
|
|
1942
|
+
"li",
|
|
1943
|
+
{
|
|
1944
|
+
"data-step-active": d === t.length - 1 ? !0 : void 0,
|
|
1945
|
+
children: [
|
|
1946
|
+
/* @__PURE__ */ a("span", { "aria-hidden": "true" }),
|
|
1947
|
+
/* @__PURE__ */ a("span", { children: c })
|
|
1948
|
+
]
|
|
1949
|
+
},
|
|
1950
|
+
`${d}-${c}`
|
|
1951
|
+
)) })
|
|
1952
|
+
]
|
|
1953
|
+
}
|
|
1954
|
+
);
|
|
1955
|
+
}, vs = ({
|
|
1793
1956
|
copyFeedback: e,
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1957
|
+
feedback: t,
|
|
1958
|
+
onCopy: s,
|
|
1959
|
+
onRegenerate: i
|
|
1960
|
+
}) => !t && !s && !i ? null : /* @__PURE__ */ l("div", { className: "make-ai-assistant__reply-actions", "aria-label": "回复操作", children: [
|
|
1961
|
+
s ? /* @__PURE__ */ a(
|
|
1798
1962
|
"button",
|
|
1799
1963
|
{
|
|
1800
1964
|
"aria-label": "复制回答",
|
|
1801
1965
|
className: "make-ai-assistant__reply-action make-ai-assistant__reply-copy",
|
|
1802
1966
|
"data-tooltip": "复制",
|
|
1803
1967
|
type: "button",
|
|
1804
|
-
onClick:
|
|
1805
|
-
children: /* @__PURE__ */ a(
|
|
1968
|
+
onClick: s,
|
|
1969
|
+
children: /* @__PURE__ */ a(Ja, {})
|
|
1806
1970
|
}
|
|
1807
1971
|
) : null,
|
|
1808
|
-
|
|
1972
|
+
t,
|
|
1973
|
+
i ? /* @__PURE__ */ a(
|
|
1809
1974
|
"button",
|
|
1810
1975
|
{
|
|
1811
1976
|
"aria-label": "重新生成",
|
|
1812
1977
|
className: "make-ai-assistant__reply-action make-ai-assistant__reply-regenerate",
|
|
1813
1978
|
"data-tooltip": "重新生成",
|
|
1814
1979
|
type: "button",
|
|
1815
|
-
onClick:
|
|
1816
|
-
children: /* @__PURE__ */ a(
|
|
1980
|
+
onClick: i,
|
|
1981
|
+
children: /* @__PURE__ */ a(Qa, {})
|
|
1817
1982
|
}
|
|
1818
1983
|
) : null,
|
|
1819
1984
|
e ? /* @__PURE__ */ a(
|
|
@@ -1825,678 +1990,602 @@ const ut = (e, t) => {
|
|
|
1825
1990
|
children: e.message
|
|
1826
1991
|
}
|
|
1827
1992
|
) : null
|
|
1828
|
-
] }),
|
|
1993
|
+
] }), zt = ({
|
|
1829
1994
|
assistantName: e,
|
|
1830
1995
|
error: t,
|
|
1831
|
-
onRetry:
|
|
1996
|
+
onRetry: s,
|
|
1832
1997
|
progress: i
|
|
1833
1998
|
}) => {
|
|
1834
|
-
const
|
|
1999
|
+
const o = t ? "error" : "progress";
|
|
1835
2000
|
return t?.message ?? i?.message ? /* @__PURE__ */ a(
|
|
1836
2001
|
"article",
|
|
1837
2002
|
{
|
|
1838
|
-
"aria-label": `${e}的${
|
|
1839
|
-
className: `make-ai-assistant__message make-ai-assistant__message--assistant make-ai-assistant__message--${
|
|
2003
|
+
"aria-label": `${e}的${o === "error" ? "错误消息" : "状态消息"}`,
|
|
2004
|
+
className: `make-ai-assistant__message make-ai-assistant__message--assistant make-ai-assistant__message--${o}`,
|
|
1840
2005
|
"data-message-role": "assistant",
|
|
1841
|
-
"data-message-state":
|
|
1842
|
-
children: /* @__PURE__ */
|
|
1843
|
-
/* @__PURE__ */ a(
|
|
1844
|
-
/* @__PURE__ */ a("div", { className: "make-ai-assistant__message-stack", children: t ? /* @__PURE__ */ a(
|
|
2006
|
+
"data-message-state": o,
|
|
2007
|
+
children: /* @__PURE__ */ l("div", { className: "make-ai-assistant__message-turn", children: [
|
|
2008
|
+
/* @__PURE__ */ a(Jt, { assistantName: e }),
|
|
2009
|
+
/* @__PURE__ */ a("div", { className: "make-ai-assistant__message-stack", children: t ? /* @__PURE__ */ a(ta, { error: t, onRetry: s }) : /* @__PURE__ */ a(aa, { active: !0, steps: i?.steps }) })
|
|
1845
2010
|
] })
|
|
1846
2011
|
}
|
|
1847
2012
|
) : null;
|
|
1848
|
-
},
|
|
1849
|
-
const
|
|
1850
|
-
let
|
|
1851
|
-
return e.messages.map((
|
|
1852
|
-
if (
|
|
2013
|
+
}, gs = (e, t, s, i, o, c, d, h, b, f, $, L, T, j, M, U) => {
|
|
2014
|
+
const g = ea(e), R = Qt(e), P = us(e);
|
|
2015
|
+
let p;
|
|
2016
|
+
return e.messages.map((n) => {
|
|
2017
|
+
if (n.intermediate) return /* @__PURE__ */ l("details", { className: "make-ai-assistant__process", children: [
|
|
1853
2018
|
/* @__PURE__ */ a("summary", { children: "处理过程" }),
|
|
1854
|
-
/* @__PURE__ */ a(
|
|
1855
|
-
] },
|
|
1856
|
-
const
|
|
1857
|
-
|
|
1858
|
-
const
|
|
2019
|
+
/* @__PURE__ */ a(Ft, { content: n.content })
|
|
2020
|
+
] }, n.id);
|
|
2021
|
+
const v = n.role === "assistant", k = p;
|
|
2022
|
+
v || (p = n);
|
|
2023
|
+
const q = n.id === R, I = n.id === g ? e.error : void 0, G = n.error ?? I, Y = !v && !!(b?.trim() || f), z = v ? d : b?.trim() || "用户", Q = v && n.status === "complete" && !G && (n.content.trim() || n.id === P), ve = !!(M && U?.features?.feedback && v && n.persistent), oe = Q || ve;
|
|
1859
2024
|
return /* @__PURE__ */ a(
|
|
1860
2025
|
"article",
|
|
1861
2026
|
{
|
|
1862
|
-
"aria-label": `${
|
|
1863
|
-
className: `make-ai-assistant__message make-ai-assistant__message--${
|
|
1864
|
-
"data-message-role":
|
|
1865
|
-
"data-message-state":
|
|
1866
|
-
"data-message-status":
|
|
1867
|
-
"data-message-has-identity":
|
|
1868
|
-
children: /* @__PURE__ */
|
|
1869
|
-
|
|
1870
|
-
/* @__PURE__ */
|
|
1871
|
-
|
|
1872
|
-
|
|
2027
|
+
"aria-label": `${z}的消息`,
|
|
2028
|
+
className: `make-ai-assistant__message make-ai-assistant__message--${n.role}`,
|
|
2029
|
+
"data-message-role": n.role,
|
|
2030
|
+
"data-message-state": G ? "error" : void 0,
|
|
2031
|
+
"data-message-status": n.status,
|
|
2032
|
+
"data-message-has-identity": v || Y ? !0 : void 0,
|
|
2033
|
+
children: /* @__PURE__ */ l("div", { className: "make-ai-assistant__message-turn", children: [
|
|
2034
|
+
v ? /* @__PURE__ */ a(Jt, { assistantName: d }) : Y ? /* @__PURE__ */ a(is, { userAvatarUrl: f, userName: b }) : null,
|
|
2035
|
+
/* @__PURE__ */ l("div", { className: "make-ai-assistant__message-stack", children: [
|
|
2036
|
+
v && n.responseId && e.responses?.[n.responseId]?.status === "cancelled" ? /* @__PURE__ */ a("p", { className: "make-ai-assistant__response-status", role: "status", children: "已停止生成" }) : null,
|
|
2037
|
+
n.content ? v ? /* @__PURE__ */ a(Ft, { content: n.content }) : /* @__PURE__ */ a("div", { className: "make-ai-assistant__bubble", children: n.content }) : n.status === "streaming" ? /* @__PURE__ */ l("div", { className: "make-ai-assistant__typing", "aria-label": `${d}正在思考`, children: [
|
|
1873
2038
|
/* @__PURE__ */ a("span", {}),
|
|
1874
2039
|
/* @__PURE__ */ a("span", {}),
|
|
1875
2040
|
/* @__PURE__ */ a("span", {})
|
|
1876
2041
|
] }) : null,
|
|
1877
|
-
|
|
1878
|
-
|
|
2042
|
+
v ? /* @__PURE__ */ a(
|
|
2043
|
+
aa,
|
|
1879
2044
|
{
|
|
1880
|
-
active:
|
|
1881
|
-
steps:
|
|
2045
|
+
active: q && e.status === "streaming",
|
|
2046
|
+
steps: n.progressSteps
|
|
1882
2047
|
}
|
|
1883
2048
|
) : null,
|
|
1884
|
-
|
|
1885
|
-
|
|
2049
|
+
G ? /* @__PURE__ */ a(
|
|
2050
|
+
ta,
|
|
1886
2051
|
{
|
|
1887
|
-
error:
|
|
1888
|
-
onRetry:
|
|
2052
|
+
error: G,
|
|
2053
|
+
onRetry: I ? h : void 0
|
|
1889
2054
|
}
|
|
1890
2055
|
) : null,
|
|
1891
|
-
|
|
1892
|
-
|
|
2056
|
+
n.artifacts.map((F) => /* @__PURE__ */ a(
|
|
2057
|
+
da,
|
|
1893
2058
|
{
|
|
1894
|
-
artifact:
|
|
2059
|
+
artifact: F,
|
|
1895
2060
|
context: t,
|
|
1896
|
-
onAction:
|
|
1897
|
-
onActionError:
|
|
1898
|
-
registry:
|
|
2061
|
+
onAction: o,
|
|
2062
|
+
onActionError: c,
|
|
2063
|
+
registry: s,
|
|
1899
2064
|
theme: i
|
|
1900
2065
|
},
|
|
1901
|
-
|
|
2066
|
+
F.id
|
|
1902
2067
|
)),
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
Cn,
|
|
2068
|
+
M && U && e.threadId ? /* @__PURE__ */ a(La, { message: n, context: t, transport: U, chatId: e.threadId }) : null,
|
|
2069
|
+
oe ? /* @__PURE__ */ a(
|
|
2070
|
+
vs,
|
|
1907
2071
|
{
|
|
1908
|
-
copyFeedback:
|
|
1909
|
-
message:
|
|
1910
|
-
status:
|
|
2072
|
+
copyFeedback: $?.messageId === n.id ? {
|
|
2073
|
+
message: $.message,
|
|
2074
|
+
status: $.status
|
|
1911
2075
|
} : void 0,
|
|
1912
|
-
onCopy:
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
2076
|
+
onCopy: n.content.trim() ? () => T(n.id, n.content) : void 0,
|
|
2077
|
+
feedback: M && ve ? /* @__PURE__ */ a(Ea, { message: n, manager: M }) : void 0,
|
|
2078
|
+
onRegenerate: L && n.id === P && k ? () => j({
|
|
2079
|
+
userMessage: k,
|
|
2080
|
+
assistantMessage: n
|
|
1916
2081
|
}) : void 0
|
|
1917
2082
|
}
|
|
1918
2083
|
) : null
|
|
1919
2084
|
] })
|
|
1920
2085
|
] })
|
|
1921
2086
|
},
|
|
1922
|
-
`${e.threadId ?? "local"}:${
|
|
2087
|
+
`${e.threadId ?? "local"}:${n.id}`
|
|
1923
2088
|
);
|
|
1924
2089
|
});
|
|
1925
2090
|
};
|
|
1926
|
-
function
|
|
2091
|
+
function sa({
|
|
1927
2092
|
assistantName: e = "AI 助手",
|
|
1928
2093
|
brandName: t,
|
|
1929
|
-
context:
|
|
2094
|
+
context: s,
|
|
1930
2095
|
onAction: i,
|
|
1931
|
-
onActionError:
|
|
1932
|
-
onClose:
|
|
2096
|
+
onActionError: o,
|
|
2097
|
+
onClose: c,
|
|
1933
2098
|
onNewConversation: d,
|
|
1934
|
-
headerHeight:
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
userName: ee,
|
|
1944
|
-
visible: j
|
|
2099
|
+
headerHeight: h,
|
|
2100
|
+
registry: b,
|
|
2101
|
+
suggestions: f,
|
|
2102
|
+
title: $,
|
|
2103
|
+
theme: L,
|
|
2104
|
+
transport: T,
|
|
2105
|
+
userAvatarUrl: j,
|
|
2106
|
+
userName: M,
|
|
2107
|
+
visible: U
|
|
1945
2108
|
}) {
|
|
1946
|
-
const
|
|
1947
|
-
...
|
|
1948
|
-
...
|
|
1949
|
-
} : void 0, [
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
}, [
|
|
1953
|
-
const [
|
|
1954
|
-
|
|
1955
|
-
const [
|
|
1956
|
-
() =>
|
|
1957
|
-
[
|
|
1958
|
-
),
|
|
1959
|
-
() =>
|
|
1960
|
-
[
|
|
1961
|
-
),
|
|
1962
|
-
const
|
|
1963
|
-
|
|
1964
|
-
const F = tn(
|
|
1965
|
-
m.getBoundingClientRect(),
|
|
1966
|
-
P.getBoundingClientRect(),
|
|
1967
|
-
window.innerHeight,
|
|
1968
|
-
window.innerWidth
|
|
1969
|
-
);
|
|
1970
|
-
tt(
|
|
1971
|
-
(U) => U?.left === F.left && U.top === F.top && U.placement === F.placement ? U : F
|
|
1972
|
-
);
|
|
1973
|
-
}, Ve = () => et(!0), ue = () => et(!1), Be = Re ? {
|
|
1974
|
-
left: `${Re.left}px`,
|
|
1975
|
-
top: `${Re.top}px`
|
|
1976
|
-
} : void 0;
|
|
1977
|
-
bt(() => {
|
|
1978
|
-
if (!ve || !T) {
|
|
1979
|
-
tt(void 0);
|
|
1980
|
-
return;
|
|
1981
|
-
}
|
|
1982
|
-
Ke();
|
|
1983
|
-
}, [ve, T]), ae(() => {
|
|
1984
|
-
if (!ve || !T) return;
|
|
1985
|
-
const m = () => Ke();
|
|
1986
|
-
return window.addEventListener("resize", m), window.addEventListener("scroll", m, !0), () => {
|
|
1987
|
-
window.removeEventListener("resize", m), window.removeEventListener("scroll", m, !0);
|
|
1988
|
-
};
|
|
1989
|
-
}, [ve, T]);
|
|
1990
|
-
const _e = (m) => {
|
|
1991
|
-
const P = Ee.current, F = Se.current?.iterator;
|
|
1992
|
-
return !P && !F ? !1 : (xe.current += 1, Ee.current = void 0, Se.current = void 0, console.info("[make-ai-assistant] local run cancellation requested", { reason: m }), P?.abort(), Ot(F), !0);
|
|
2109
|
+
const g = _a(s, T), R = Ba(s, T, g), P = Zt(t, $), p = Va(h), n = yt(L), v = n || p ? {
|
|
2110
|
+
...n,
|
|
2111
|
+
...p ? { "--make-ai-internal-header-height": p } : {}
|
|
2112
|
+
} : void 0, [k, q] = N(""), [I, G] = N(!1), [Y, z] = N(!1), Q = g.enabled ? T.scopeKey?.(s) ?? s.app.id : "";
|
|
2113
|
+
gt(() => {
|
|
2114
|
+
g.enabled && q("");
|
|
2115
|
+
}, [Q, g.enabled]);
|
|
2116
|
+
const [ve, oe] = N(fe), F = g.enabled ? g.state : ve, ne = g.enabled ? g.setState : oe, ce = S(F);
|
|
2117
|
+
ce.current = F;
|
|
2118
|
+
const [V, B] = N(void 0), [A, W] = N(void 0), [ae, ge] = N(0), [Re, x] = N(() => T.loadConversation ? "loading" : "ready"), ee = g.enabled ? g.loading && !F.messages.length ? "loading" : "ready" : Re, [le, de] = N(void 0), [lt, ye] = N(!1), we = S(void 0), be = S(void 0), te = S(0), Ce = S(null), ke = S(null), Oe = S(null), He = S(null), Ee = S(null), Xe = S(null), me = S(!0), Ge = S(s.app.id), Ye = S(U), Je = ia(), Qe = Rt(
|
|
2119
|
+
() => b ?? ka(),
|
|
2120
|
+
[b]
|
|
2121
|
+
), et = Rt(
|
|
2122
|
+
() => Oa(f),
|
|
2123
|
+
[f]
|
|
2124
|
+
), xe = (m) => {
|
|
2125
|
+
const K = we.current, X = be.current?.iterator;
|
|
2126
|
+
return !K && !X ? !1 : (te.current += 1, we.current = void 0, be.current = void 0, console.info("[make-ai-assistant] local run cancellation requested", { reason: m }), K?.abort(), Bt(X), !0);
|
|
1993
2127
|
};
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
}, []),
|
|
1997
|
-
if (
|
|
1998
|
-
const m =
|
|
1999
|
-
if (
|
|
2000
|
-
|
|
2128
|
+
ie(() => () => {
|
|
2129
|
+
xe("unmount");
|
|
2130
|
+
}, []), ie(() => {
|
|
2131
|
+
if (g.enabled) return;
|
|
2132
|
+
const m = T.loadConversation, K = Ge.current !== s.app.id;
|
|
2133
|
+
if (Ge.current = s.app.id, xe("reinitialize"), K && (q(""), me.current = !0), B(void 0), W(void 0), ye(!1), ne(fe()), !m) {
|
|
2134
|
+
de(void 0), x("ready");
|
|
2001
2135
|
return;
|
|
2002
2136
|
}
|
|
2003
|
-
const
|
|
2004
|
-
return
|
|
2005
|
-
appId:
|
|
2006
|
-
}), m.call(
|
|
2007
|
-
|
|
2008
|
-
appId:
|
|
2009
|
-
messageCount:
|
|
2137
|
+
const X = new AbortController();
|
|
2138
|
+
return de(void 0), x("loading"), console.info("[make-ai-assistant] conversation load start", {
|
|
2139
|
+
appId: s.app.id
|
|
2140
|
+
}), m.call(T, s, { signal: X.signal }).then((se) => {
|
|
2141
|
+
X.signal.aborted || (ne(fe(se)), x("ready"), console.info("[make-ai-assistant] conversation load success", {
|
|
2142
|
+
appId: s.app.id,
|
|
2143
|
+
messageCount: se.messages.length
|
|
2010
2144
|
}));
|
|
2011
|
-
}).catch((
|
|
2012
|
-
|
|
2013
|
-
appId:
|
|
2014
|
-
errorType:
|
|
2015
|
-
}),
|
|
2016
|
-
}), () =>
|
|
2017
|
-
}, [
|
|
2018
|
-
const m =
|
|
2019
|
-
if (!m || !
|
|
2020
|
-
|
|
2021
|
-
const
|
|
2022
|
-
if (!
|
|
2023
|
-
const
|
|
2024
|
-
|
|
2145
|
+
}).catch((se) => {
|
|
2146
|
+
X.signal.aborted || (console.error("[make-ai-assistant] conversation load failed", {
|
|
2147
|
+
appId: s.app.id,
|
|
2148
|
+
errorType: se instanceof Error ? se.name : typeof se
|
|
2149
|
+
}), de(se), x("error"));
|
|
2150
|
+
}), () => X.abort();
|
|
2151
|
+
}, [s.app.id, ae, T, g.enabled]), ie(() => {
|
|
2152
|
+
const m = ke.current;
|
|
2153
|
+
if (!m || !me.current) return;
|
|
2154
|
+
ye(!1);
|
|
2155
|
+
const K = requestAnimationFrame(() => {
|
|
2156
|
+
if (!me.current) return;
|
|
2157
|
+
const X = F.status === "streaming" || globalThis.matchMedia?.("(prefers-reduced-motion: reduce)").matches ? "auto" : "smooth";
|
|
2158
|
+
vt(m, X);
|
|
2025
2159
|
});
|
|
2026
|
-
return () => cancelAnimationFrame(
|
|
2027
|
-
}, [
|
|
2028
|
-
|
|
2029
|
-
}, [
|
|
2030
|
-
const m =
|
|
2031
|
-
if (
|
|
2032
|
-
const
|
|
2033
|
-
const
|
|
2034
|
-
if (
|
|
2035
|
-
|
|
2036
|
-
const
|
|
2037
|
-
|
|
2038
|
-
} else
|
|
2039
|
-
const
|
|
2040
|
-
(
|
|
2160
|
+
return () => cancelAnimationFrame(K);
|
|
2161
|
+
}, [F.messages, F.progress, F.status]), ie(() => {
|
|
2162
|
+
U || (G(!1), z(!1));
|
|
2163
|
+
}, [U]), ie(() => {
|
|
2164
|
+
const m = U && !Ye.current;
|
|
2165
|
+
if (Ye.current = U, !m) return;
|
|
2166
|
+
const K = requestAnimationFrame(() => {
|
|
2167
|
+
const X = ke.current;
|
|
2168
|
+
if (X && me.current) {
|
|
2169
|
+
ye(!1);
|
|
2170
|
+
const qe = ce.current.status === "streaming" ? "auto" : Pt();
|
|
2171
|
+
vt(X, qe);
|
|
2172
|
+
} else X && ye(ce.current.messages.length > 0);
|
|
2173
|
+
const se = Oe.current;
|
|
2174
|
+
(se && !se.disabled ? se : Xe.current ?? Ce.current?.querySelector("button:not(:disabled)"))?.focus();
|
|
2041
2175
|
});
|
|
2042
|
-
return () => cancelAnimationFrame(
|
|
2043
|
-
}, [
|
|
2044
|
-
const
|
|
2045
|
-
const m =
|
|
2176
|
+
return () => cancelAnimationFrame(K);
|
|
2177
|
+
}, [U]);
|
|
2178
|
+
const dt = () => {
|
|
2179
|
+
const m = ke.current;
|
|
2046
2180
|
if (!m) return;
|
|
2047
|
-
const
|
|
2048
|
-
|
|
2049
|
-
},
|
|
2050
|
-
const m =
|
|
2181
|
+
const K = ps(m);
|
|
2182
|
+
me.current = K, ye(!K && ce.current.messages.length > 0);
|
|
2183
|
+
}, Se = () => {
|
|
2184
|
+
const m = ke.current;
|
|
2051
2185
|
if (!m) return;
|
|
2052
|
-
|
|
2053
|
-
const
|
|
2054
|
-
|
|
2055
|
-
},
|
|
2056
|
-
const
|
|
2057
|
-
if (!
|
|
2058
|
-
if (
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
) >
|
|
2062
|
-
|
|
2063
|
-
`输入内容过长,请控制在 ${
|
|
2186
|
+
me.current = !0, ye(!1);
|
|
2187
|
+
const K = Pt();
|
|
2188
|
+
vt(m, K);
|
|
2189
|
+
}, r = async (m, K) => {
|
|
2190
|
+
const X = m.trim(), se = ce.current, Ae = K?.regenerateFrom, qe = T.regenerate;
|
|
2191
|
+
if (!X || ee !== "ready" || se.status === "streaming" || we.current || Ae && !qe) return;
|
|
2192
|
+
if (it(
|
|
2193
|
+
X,
|
|
2194
|
+
ue.messageCharacters
|
|
2195
|
+
) > ue.messageCharacters) {
|
|
2196
|
+
B(
|
|
2197
|
+
`输入内容过长,请控制在 ${ue.messageCharacters} 个字符以内`
|
|
2064
2198
|
);
|
|
2065
2199
|
return;
|
|
2066
2200
|
}
|
|
2067
|
-
const
|
|
2068
|
-
id:
|
|
2069
|
-
content:
|
|
2070
|
-
},
|
|
2071
|
-
|
|
2201
|
+
const at = {
|
|
2202
|
+
id: Ae?.userMessage.id ?? Pa("user"),
|
|
2203
|
+
content: X
|
|
2204
|
+
}, st = Ae ? hs(se, Ae.userMessage.id) : Ht(se, at), nt = new AbortController(), Be = te.current + 1;
|
|
2205
|
+
te.current = Be, we.current = nt, B(void 0), W(void 0), ye(!me.current && se.messages.length > 0), Ae || q(""), ne(st);
|
|
2072
2206
|
try {
|
|
2073
|
-
let
|
|
2074
|
-
const
|
|
2207
|
+
let Te = !1, re, kt = 0, _t = 0, wt = 0, ut = 0, Ke = 0;
|
|
2208
|
+
const je = /* @__PURE__ */ new Map(), It = /* @__PURE__ */ new Set(), At = /* @__PURE__ */ new Set(
|
|
2075
2209
|
[
|
|
2076
|
-
...
|
|
2077
|
-
|
|
2210
|
+
...st.messages.map((rt) => rt.id),
|
|
2211
|
+
at.id
|
|
2078
2212
|
]
|
|
2079
|
-
),
|
|
2080
|
-
let
|
|
2081
|
-
if (
|
|
2082
|
-
if (!
|
|
2083
|
-
throw new
|
|
2084
|
-
|
|
2085
|
-
threadId:
|
|
2086
|
-
message:
|
|
2213
|
+
), Ve = /* @__PURE__ */ new Set(), Mt = ca(Qe), Nt = { signal: nt.signal };
|
|
2214
|
+
let mt;
|
|
2215
|
+
if (Ae) {
|
|
2216
|
+
if (!qe)
|
|
2217
|
+
throw new J("当前 AI 助手不支持重新生成");
|
|
2218
|
+
mt = qe({
|
|
2219
|
+
threadId: st.threadId,
|
|
2220
|
+
message: at,
|
|
2087
2221
|
assistantMessage: {
|
|
2088
|
-
id:
|
|
2089
|
-
content:
|
|
2222
|
+
id: Ae.assistantMessage.id,
|
|
2223
|
+
content: Ae.assistantMessage.content
|
|
2090
2224
|
},
|
|
2091
|
-
context:
|
|
2092
|
-
capabilities:
|
|
2093
|
-
},
|
|
2225
|
+
context: s,
|
|
2226
|
+
capabilities: Mt
|
|
2227
|
+
}, Nt);
|
|
2094
2228
|
} else
|
|
2095
|
-
|
|
2229
|
+
mt = T.run(
|
|
2096
2230
|
{
|
|
2097
|
-
threadId:
|
|
2098
|
-
message:
|
|
2099
|
-
context:
|
|
2100
|
-
capabilities:
|
|
2231
|
+
threadId: st.threadId,
|
|
2232
|
+
message: at,
|
|
2233
|
+
context: s,
|
|
2234
|
+
capabilities: Mt
|
|
2101
2235
|
},
|
|
2102
|
-
|
|
2236
|
+
Nt
|
|
2103
2237
|
);
|
|
2104
|
-
const
|
|
2105
|
-
for (
|
|
2106
|
-
const
|
|
2107
|
-
if (
|
|
2108
|
-
let
|
|
2238
|
+
const Ct = mt[Symbol.asyncIterator]();
|
|
2239
|
+
for (be.current = { iterator: Ct, requestVersion: Be }; ; ) {
|
|
2240
|
+
const rt = await Ct.next();
|
|
2241
|
+
if (te.current !== Be || rt.done) break;
|
|
2242
|
+
let E;
|
|
2109
2243
|
try {
|
|
2110
|
-
|
|
2111
|
-
} catch (
|
|
2112
|
-
throw new
|
|
2113
|
-
|
|
2244
|
+
E = Ot(rt.value);
|
|
2245
|
+
} catch (pe) {
|
|
2246
|
+
throw new J(
|
|
2247
|
+
pe instanceof Error ? pe.message : "Invalid assistant event"
|
|
2114
2248
|
);
|
|
2115
2249
|
}
|
|
2116
|
-
if (
|
|
2117
|
-
if (
|
|
2118
|
-
throw new
|
|
2119
|
-
if (
|
|
2120
|
-
throw new
|
|
2121
|
-
if (
|
|
2122
|
-
throw new
|
|
2123
|
-
|
|
2250
|
+
if (E.type === "message.start") {
|
|
2251
|
+
if (re !== void 0 && re !== E.runId)
|
|
2252
|
+
throw new J("AI 助手响应 run id 不一致");
|
|
2253
|
+
if (re ??= E.runId, _t += 1, _t > ue.assistantMessagesPerRun)
|
|
2254
|
+
throw new J("AI 助手单次响应消息数量超过限制");
|
|
2255
|
+
if (At.has(E.messageId))
|
|
2256
|
+
throw new J("AI 助手响应包含重复的 message id");
|
|
2257
|
+
At.add(E.messageId), Ve.add(E.messageId), je.set(E.messageId, 0);
|
|
2124
2258
|
}
|
|
2125
|
-
if (
|
|
2126
|
-
if (!
|
|
2127
|
-
throw new
|
|
2128
|
-
const
|
|
2129
|
-
|
|
2130
|
-
|
|
2259
|
+
if (E.type === "message.delta") {
|
|
2260
|
+
if (!Ve.has(E.messageId))
|
|
2261
|
+
throw new J("AI 助手响应事件顺序无效");
|
|
2262
|
+
const pe = je.get(E.messageId) ?? 0, Ue = it(
|
|
2263
|
+
E.delta,
|
|
2264
|
+
ue.messageCharacters - Ke
|
|
2131
2265
|
);
|
|
2132
|
-
if (
|
|
2133
|
-
throw new
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2266
|
+
if (Ke + Ue > ue.messageCharacters)
|
|
2267
|
+
throw new J("AI 助手响应文本超过大小限制");
|
|
2268
|
+
Ke += Ue, je.set(
|
|
2269
|
+
E.messageId,
|
|
2270
|
+
pe + Ue
|
|
2137
2271
|
);
|
|
2138
2272
|
}
|
|
2139
|
-
if (
|
|
2140
|
-
if (!
|
|
2141
|
-
throw new
|
|
2142
|
-
const
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
),
|
|
2146
|
-
if (
|
|
2147
|
-
throw new
|
|
2148
|
-
|
|
2273
|
+
if (E.type === "message.replace") {
|
|
2274
|
+
if (!Ve.has(E.messageId))
|
|
2275
|
+
throw new J("AI 助手响应事件顺序无效");
|
|
2276
|
+
const pe = je.get(E.messageId) ?? 0, Ue = it(
|
|
2277
|
+
E.content,
|
|
2278
|
+
ue.messageCharacters
|
|
2279
|
+
), Tt = Ke - pe + Ue;
|
|
2280
|
+
if (Tt > ue.messageCharacters)
|
|
2281
|
+
throw new J("AI 助手响应文本超过大小限制");
|
|
2282
|
+
Ke = Tt, je.set(E.messageId, Ue);
|
|
2149
2283
|
}
|
|
2150
|
-
if (
|
|
2151
|
-
if (
|
|
2152
|
-
throw new
|
|
2153
|
-
if (
|
|
2154
|
-
throw new
|
|
2155
|
-
const
|
|
2156
|
-
|
|
2157
|
-
|
|
2284
|
+
if (E.type === "run.progress") {
|
|
2285
|
+
if (re !== void 0 && re !== E.runId)
|
|
2286
|
+
throw new J("AI 助手响应 run id 不一致");
|
|
2287
|
+
if (re ??= E.runId, wt += 1, wt > ue.progressStepsPerRun)
|
|
2288
|
+
throw new J("AI 助手处理过程数量超过限制");
|
|
2289
|
+
const pe = it(
|
|
2290
|
+
E.message,
|
|
2291
|
+
ue.progressCharactersPerRun - ut
|
|
2158
2292
|
);
|
|
2159
|
-
if (
|
|
2160
|
-
throw new
|
|
2161
|
-
|
|
2293
|
+
if (ut + pe > ue.progressCharactersPerRun)
|
|
2294
|
+
throw new J("AI 助手处理过程文本超过大小限制");
|
|
2295
|
+
ut += pe;
|
|
2162
2296
|
}
|
|
2163
|
-
if (
|
|
2164
|
-
if (!
|
|
2165
|
-
throw new
|
|
2166
|
-
if (
|
|
2167
|
-
throw new
|
|
2168
|
-
if (
|
|
2169
|
-
throw new
|
|
2170
|
-
|
|
2297
|
+
if (E.type === "artifact") {
|
|
2298
|
+
if (!Ve.has(E.messageId))
|
|
2299
|
+
throw new J("AI 助手响应事件顺序无效");
|
|
2300
|
+
if (kt += 1, kt > ue.artifactsPerRun)
|
|
2301
|
+
throw new J("AI 助手单次响应 Artifact 数量超过限制");
|
|
2302
|
+
if (It.has(E.artifact.id))
|
|
2303
|
+
throw new J("AI 助手响应包含重复的 Artifact id");
|
|
2304
|
+
It.add(E.artifact.id);
|
|
2171
2305
|
}
|
|
2172
|
-
if (
|
|
2173
|
-
throw new
|
|
2174
|
-
if (
|
|
2175
|
-
throw new
|
|
2176
|
-
if (
|
|
2177
|
-
throw new
|
|
2178
|
-
if (
|
|
2179
|
-
|
|
2306
|
+
if (E.type === "message.complete" && !Ve.delete(E.messageId))
|
|
2307
|
+
throw new J("AI 助手响应事件顺序无效");
|
|
2308
|
+
if (E.type === "run.complete" && re !== void 0 && re !== E.runId)
|
|
2309
|
+
throw new J("AI 助手响应 run id 不一致");
|
|
2310
|
+
if (E.type === "run.cancelled" && E.runId !== void 0 && re !== void 0 && re !== E.runId)
|
|
2311
|
+
throw new J("AI 助手响应 run id 不一致");
|
|
2312
|
+
if (ne((pe) => Me(pe, E)), E.type === "error" || E.type === "run.cancelled" || E.type === "run.complete") {
|
|
2313
|
+
Te = !0;
|
|
2180
2314
|
break;
|
|
2181
2315
|
}
|
|
2182
2316
|
}
|
|
2183
|
-
if (!
|
|
2184
|
-
throw new
|
|
2185
|
-
} catch (
|
|
2186
|
-
if (
|
|
2187
|
-
if (
|
|
2188
|
-
|
|
2189
|
-
(
|
|
2317
|
+
if (!Te)
|
|
2318
|
+
throw new J("AI 助手流式响应在终止事件前结束");
|
|
2319
|
+
} catch (Te) {
|
|
2320
|
+
if (te.current !== Be) return;
|
|
2321
|
+
if (nt.signal.aborted) {
|
|
2322
|
+
ne(
|
|
2323
|
+
(re) => Me(re, { type: "run.cancelled" })
|
|
2190
2324
|
);
|
|
2191
2325
|
return;
|
|
2192
2326
|
}
|
|
2193
2327
|
console.error("[make-ai-assistant] assistant run failed", {
|
|
2194
|
-
appId:
|
|
2195
|
-
errorType:
|
|
2196
|
-
}),
|
|
2197
|
-
(
|
|
2328
|
+
appId: s.app.id,
|
|
2329
|
+
errorType: Te instanceof Error ? Te.name : typeof Te
|
|
2330
|
+
}), ne(
|
|
2331
|
+
(re) => Me(re, {
|
|
2198
2332
|
type: "error",
|
|
2199
2333
|
code: "TRANSPORT_ERROR",
|
|
2200
|
-
message:
|
|
2334
|
+
message: Te instanceof J ? Te.message : "连接失败,请重试",
|
|
2201
2335
|
retryable: !0
|
|
2202
2336
|
})
|
|
2203
2337
|
);
|
|
2204
2338
|
} finally {
|
|
2205
|
-
|
|
2339
|
+
te.current === Be && we.current === nt && (we.current = void 0), be.current?.requestVersion === Be && (Bt(be.current.iterator), be.current = void 0);
|
|
2206
2340
|
}
|
|
2207
|
-
},
|
|
2208
|
-
if (
|
|
2209
|
-
if (
|
|
2210
|
-
return
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
const P = m.trim(), F = u.parts.length ? [...P ? [{ id: We(), kind: "text", text: P }] : [], ...u.parts] : void 0;
|
|
2214
|
-
return D(""), u.clear(), v.send(P, F);
|
|
2341
|
+
}, u = (m) => {
|
|
2342
|
+
if (g.enabled) {
|
|
2343
|
+
if (R.pending)
|
|
2344
|
+
return B("请等待附件上传完成,或移除失败的附件"), Promise.resolve();
|
|
2345
|
+
const K = m.trim(), X = R.parts.length ? [...K ? [{ id: Pe(), kind: "text", text: K }] : [], ...R.parts] : void 0;
|
|
2346
|
+
return q(""), R.clear(), g.send(K, X);
|
|
2215
2347
|
}
|
|
2216
|
-
return
|
|
2217
|
-
},
|
|
2348
|
+
return r(m);
|
|
2349
|
+
}, y = (m) => r(m.userMessage.content, { regenerateFrom: m }), w = async (m, K) => {
|
|
2218
2350
|
try {
|
|
2219
|
-
await
|
|
2220
|
-
} catch (
|
|
2351
|
+
await Ga(K), W({ messageId: m, message: "已复制", status: "success" });
|
|
2352
|
+
} catch (X) {
|
|
2221
2353
|
console.error("[make-ai-assistant] copy answer failed", {
|
|
2222
|
-
errorType:
|
|
2223
|
-
}),
|
|
2354
|
+
errorType: X instanceof Error ? X.name : typeof X
|
|
2355
|
+
}), W({ messageId: m, message: "复制失败", status: "error" });
|
|
2224
2356
|
}
|
|
2225
|
-
},
|
|
2226
|
-
m.preventDefault(),
|
|
2227
|
-
},
|
|
2228
|
-
m.key === "Enter" && !m.shiftKey && !m.nativeEvent.isComposing && (m.preventDefault(),
|
|
2229
|
-
},
|
|
2230
|
-
if (
|
|
2231
|
-
|
|
2357
|
+
}, C = (m) => {
|
|
2358
|
+
m.preventDefault(), u(k);
|
|
2359
|
+
}, D = (m) => {
|
|
2360
|
+
m.key === "Enter" && !m.shiftKey && !m.nativeEvent.isComposing && (m.preventDefault(), u(k));
|
|
2361
|
+
}, _ = () => {
|
|
2362
|
+
if (g.enabled) {
|
|
2363
|
+
g.stop();
|
|
2232
2364
|
return;
|
|
2233
2365
|
}
|
|
2234
|
-
|
|
2235
|
-
(m) =>
|
|
2366
|
+
xe("stop") && ne(
|
|
2367
|
+
(m) => Me(m, { type: "run.cancelled" })
|
|
2236
2368
|
);
|
|
2237
|
-
},
|
|
2238
|
-
if (
|
|
2239
|
-
|
|
2369
|
+
}, Z = () => {
|
|
2370
|
+
if (z(!1), g.enabled) {
|
|
2371
|
+
q(""), g.create(), d?.();
|
|
2240
2372
|
return;
|
|
2241
2373
|
}
|
|
2242
|
-
|
|
2243
|
-
},
|
|
2244
|
-
if (
|
|
2245
|
-
|
|
2374
|
+
xe("new-conversation"), q(""), B(void 0), W(void 0), ye(!1), me.current = !0, ne(fe()), d?.();
|
|
2375
|
+
}, O = g.enabled && g.cancelling.length ? "停止中" : T.features?.remoteCancellation === !1 ? "停止接收" : "停止生成", H = Qt(F), Ie = ea(F), Le = ms(F), tt = typeof T.regenerate == "function" && T.features?.regeneration !== !1, he = () => {
|
|
2376
|
+
if (g.enabled) {
|
|
2377
|
+
g.retry();
|
|
2246
2378
|
return;
|
|
2247
2379
|
}
|
|
2248
|
-
|
|
2249
|
-
},
|
|
2250
|
-
if (m.key === "Escape" && !(!
|
|
2251
|
-
if (m.preventDefault(), m.stopPropagation(),
|
|
2252
|
-
|
|
2380
|
+
Le && u(Le.content);
|
|
2381
|
+
}, De = (m) => {
|
|
2382
|
+
if (m.key === "Escape" && !(!I && !Y)) {
|
|
2383
|
+
if (m.preventDefault(), m.stopPropagation(), I) {
|
|
2384
|
+
G(!1), He.current?.focus();
|
|
2253
2385
|
return;
|
|
2254
2386
|
}
|
|
2255
|
-
|
|
2387
|
+
z(!1), Ee.current?.focus();
|
|
2256
2388
|
}
|
|
2257
2389
|
};
|
|
2258
|
-
return /* @__PURE__ */
|
|
2390
|
+
return /* @__PURE__ */ l(
|
|
2259
2391
|
"section",
|
|
2260
2392
|
{
|
|
2261
|
-
className: `make-ai-assistant make-ai-assistant__panel${
|
|
2262
|
-
ref:
|
|
2263
|
-
style:
|
|
2264
|
-
onKeyDown:
|
|
2393
|
+
className: `make-ai-assistant make-ai-assistant__panel${g.enabled ? " make-ai-assistant__panel--managed" : ""}`,
|
|
2394
|
+
ref: Ce,
|
|
2395
|
+
style: v,
|
|
2396
|
+
onKeyDown: De,
|
|
2265
2397
|
onDragOver: (m) => {
|
|
2266
|
-
|
|
2398
|
+
R.enabled && m.dataTransfer.types.includes("Files") && m.preventDefault();
|
|
2267
2399
|
},
|
|
2268
2400
|
onDrop: (m) => {
|
|
2269
|
-
|
|
2401
|
+
R.enabled && m.dataTransfer.files.length && (m.preventDefault(), R.add(Array.from(m.dataTransfer.files)));
|
|
2270
2402
|
},
|
|
2271
2403
|
children: [
|
|
2272
|
-
/* @__PURE__ */
|
|
2273
|
-
/* @__PURE__ */ a("div", { className: "make-ai-assistant__header-leading", children:
|
|
2404
|
+
/* @__PURE__ */ l("header", { className: "make-ai-assistant__header", children: [
|
|
2405
|
+
/* @__PURE__ */ a("div", { className: "make-ai-assistant__header-leading", children: g.enabled ? /* @__PURE__ */ l(
|
|
2274
2406
|
"button",
|
|
2275
2407
|
{
|
|
2276
|
-
"aria-controls":
|
|
2277
|
-
"aria-expanded":
|
|
2408
|
+
"aria-controls": Je,
|
|
2409
|
+
"aria-expanded": Y,
|
|
2278
2410
|
"aria-haspopup": "dialog",
|
|
2279
2411
|
"aria-label": "任务列表",
|
|
2280
2412
|
className: "make-ai-assistant__task-list-trigger",
|
|
2281
|
-
ref:
|
|
2413
|
+
ref: Ee,
|
|
2282
2414
|
type: "button",
|
|
2283
|
-
onClick: () =>
|
|
2415
|
+
onClick: () => z((m) => !m),
|
|
2284
2416
|
children: [
|
|
2285
|
-
/* @__PURE__ */ a(
|
|
2417
|
+
/* @__PURE__ */ a(as, {}),
|
|
2286
2418
|
/* @__PURE__ */ a("span", { children: "任务列表" }),
|
|
2287
|
-
/* @__PURE__ */ a(
|
|
2419
|
+
/* @__PURE__ */ a(ss, {})
|
|
2288
2420
|
]
|
|
2289
2421
|
}
|
|
2290
2422
|
) : null }),
|
|
2291
|
-
/* @__PURE__ */
|
|
2292
|
-
/* @__PURE__ */ a(
|
|
2293
|
-
/* @__PURE__ */
|
|
2294
|
-
/* @__PURE__ */ c("div", { className: "make-ai-assistant__header-title-row", children: [
|
|
2295
|
-
/* @__PURE__ */ a("h2", { className: "make-ai-assistant__header-title", title: l, children: l }),
|
|
2296
|
-
v.enabled ? /* @__PURE__ */ a("span", { className: "make-ai-assistant__current-conversation", children: v.chat?.title || "新对话" }) : null,
|
|
2297
|
-
/* @__PURE__ */ a("span", { className: "make-ai-assistant__read-only-tag", children: "只读" })
|
|
2298
|
-
] }),
|
|
2299
|
-
/* @__PURE__ */ c("div", { className: "make-ai-assistant__header-context", children: [
|
|
2300
|
-
/* @__PURE__ */ a("p", { title: L, children: L }),
|
|
2301
|
-
T ? /* @__PURE__ */ c(Ae, { children: [
|
|
2302
|
-
/* @__PURE__ */ a(
|
|
2303
|
-
"span",
|
|
2304
|
-
{
|
|
2305
|
-
"aria-describedby": W,
|
|
2306
|
-
"aria-label": `使用提示:${T}`,
|
|
2307
|
-
className: "make-ai-assistant__header-context-help",
|
|
2308
|
-
"data-tooltip": T,
|
|
2309
|
-
ref: h,
|
|
2310
|
-
role: "note",
|
|
2311
|
-
tabIndex: 0,
|
|
2312
|
-
onBlur: ue,
|
|
2313
|
-
onFocus: Ve,
|
|
2314
|
-
onPointerEnter: Ve,
|
|
2315
|
-
onPointerLeave: ue,
|
|
2316
|
-
children: /* @__PURE__ */ a(dn, {})
|
|
2317
|
-
}
|
|
2318
|
-
),
|
|
2319
|
-
/* @__PURE__ */ a(
|
|
2320
|
-
"span",
|
|
2321
|
-
{
|
|
2322
|
-
"aria-hidden": !ve,
|
|
2323
|
-
className: "make-ai-assistant__header-context-tooltip",
|
|
2324
|
-
"data-placement": Re?.placement,
|
|
2325
|
-
"data-positioned": Re ? !0 : void 0,
|
|
2326
|
-
"data-visible": ve || void 0,
|
|
2327
|
-
id: W,
|
|
2328
|
-
ref: _,
|
|
2329
|
-
role: "tooltip",
|
|
2330
|
-
style: Be,
|
|
2331
|
-
children: T
|
|
2332
|
-
}
|
|
2333
|
-
)
|
|
2334
|
-
] }) : null
|
|
2335
|
-
] })
|
|
2336
|
-
] })
|
|
2423
|
+
/* @__PURE__ */ l("div", { className: "make-ai-assistant__header-center", children: [
|
|
2424
|
+
/* @__PURE__ */ a(ct, {}),
|
|
2425
|
+
/* @__PURE__ */ a("h2", { className: "make-ai-assistant__header-title", title: P, children: P })
|
|
2337
2426
|
] }),
|
|
2338
|
-
/* @__PURE__ */
|
|
2339
|
-
|
|
2427
|
+
/* @__PURE__ */ l("div", { className: "make-ai-assistant__header-actions", children: [
|
|
2428
|
+
T.features?.newConversation !== !1 ? /* @__PURE__ */ a(
|
|
2340
2429
|
"button",
|
|
2341
2430
|
{
|
|
2342
2431
|
"aria-label": "新建对话",
|
|
2343
2432
|
className: "make-ai-assistant__icon-button",
|
|
2344
2433
|
type: "button",
|
|
2345
|
-
onClick:
|
|
2346
|
-
children: /* @__PURE__ */ a(
|
|
2434
|
+
onClick: Z,
|
|
2435
|
+
children: /* @__PURE__ */ a(ts, {})
|
|
2347
2436
|
}
|
|
2348
2437
|
) : null,
|
|
2349
|
-
|
|
2438
|
+
c ? /* @__PURE__ */ a(
|
|
2350
2439
|
"button",
|
|
2351
2440
|
{
|
|
2352
|
-
"aria-label": `关闭 ${
|
|
2441
|
+
"aria-label": `关闭 ${P}`,
|
|
2353
2442
|
className: "make-ai-assistant__icon-button",
|
|
2354
2443
|
type: "button",
|
|
2355
|
-
onClick:
|
|
2356
|
-
children: /* @__PURE__ */ a(
|
|
2444
|
+
onClick: c,
|
|
2445
|
+
children: /* @__PURE__ */ a(Ya, {})
|
|
2357
2446
|
}
|
|
2358
2447
|
) : null
|
|
2359
2448
|
] })
|
|
2360
2449
|
] }),
|
|
2361
|
-
|
|
2362
|
-
|
|
2450
|
+
g.enabled && Y ? /* @__PURE__ */ a(
|
|
2451
|
+
Ra,
|
|
2363
2452
|
{
|
|
2364
|
-
id:
|
|
2365
|
-
manager:
|
|
2366
|
-
triggerRef:
|
|
2367
|
-
onDismiss: () =>
|
|
2368
|
-
onNewConversation:
|
|
2453
|
+
id: Je,
|
|
2454
|
+
manager: g,
|
|
2455
|
+
triggerRef: Ee,
|
|
2456
|
+
onDismiss: () => z(!1),
|
|
2457
|
+
onNewConversation: T.features?.newConversation !== !1 ? Z : void 0
|
|
2369
2458
|
}
|
|
2370
2459
|
) : null,
|
|
2371
|
-
/* @__PURE__ */
|
|
2460
|
+
/* @__PURE__ */ l(
|
|
2372
2461
|
"div",
|
|
2373
2462
|
{
|
|
2374
2463
|
className: "make-ai-assistant__body",
|
|
2375
2464
|
"aria-live": "polite",
|
|
2376
2465
|
"aria-relevant": "additions text",
|
|
2377
|
-
ref:
|
|
2466
|
+
ref: ke,
|
|
2378
2467
|
role: "log",
|
|
2379
|
-
onScroll:
|
|
2468
|
+
onScroll: dt,
|
|
2380
2469
|
children: [
|
|
2381
|
-
|
|
2382
|
-
/* @__PURE__ */ a(
|
|
2470
|
+
ee === "loading" ? /* @__PURE__ */ l("div", { className: "make-ai-assistant__empty", role: "status", children: [
|
|
2471
|
+
/* @__PURE__ */ a(ct, {}),
|
|
2383
2472
|
/* @__PURE__ */ a("h3", { children: "正在恢复对话" }),
|
|
2384
2473
|
/* @__PURE__ */ a("p", { children: "正在读取当前 App 的历史消息…" })
|
|
2385
|
-
] }) :
|
|
2386
|
-
|
|
2474
|
+
] }) : ee === "error" ? /* @__PURE__ */ a("div", { className: "make-ai-assistant__empty", children: /* @__PURE__ */ a(
|
|
2475
|
+
fs,
|
|
2387
2476
|
{
|
|
2388
|
-
error:
|
|
2389
|
-
onRetry: () =>
|
|
2477
|
+
error: le,
|
|
2478
|
+
onRetry: () => ge((m) => m + 1)
|
|
2390
2479
|
}
|
|
2391
|
-
) }) :
|
|
2392
|
-
/* @__PURE__ */ a(
|
|
2480
|
+
) }) : F.messages.length === 0 ? /* @__PURE__ */ l("div", { className: "make-ai-assistant__empty", children: [
|
|
2481
|
+
/* @__PURE__ */ a(ct, {}),
|
|
2393
2482
|
/* @__PURE__ */ a("h3", { children: "有什么可以帮你?" }),
|
|
2394
2483
|
/* @__PURE__ */ a("p", { children: "我会结合当前 App、页面位置和宿主允许的上下文回答,并把过程与结果分开展示。" })
|
|
2395
|
-
] }) :
|
|
2396
|
-
|
|
2397
|
-
n,
|
|
2398
|
-
B,
|
|
2399
|
-
q,
|
|
2400
|
-
i,
|
|
2484
|
+
] }) : gs(
|
|
2485
|
+
F,
|
|
2401
2486
|
s,
|
|
2487
|
+
Qe,
|
|
2488
|
+
L,
|
|
2489
|
+
i,
|
|
2490
|
+
o,
|
|
2402
2491
|
e,
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
(m,
|
|
2409
|
-
|
|
2492
|
+
Le ? he : void 0,
|
|
2493
|
+
M,
|
|
2494
|
+
j,
|
|
2495
|
+
A,
|
|
2496
|
+
tt,
|
|
2497
|
+
(m, K) => {
|
|
2498
|
+
w(m, K);
|
|
2410
2499
|
},
|
|
2411
2500
|
(m) => {
|
|
2412
|
-
|
|
2501
|
+
y(m);
|
|
2413
2502
|
},
|
|
2414
|
-
|
|
2415
|
-
|
|
2503
|
+
g.enabled ? g : void 0,
|
|
2504
|
+
T
|
|
2416
2505
|
),
|
|
2417
|
-
|
|
2418
|
-
|
|
2506
|
+
F.progress && !H ? /* @__PURE__ */ a(
|
|
2507
|
+
zt,
|
|
2419
2508
|
{
|
|
2420
2509
|
assistantName: e,
|
|
2421
|
-
progress:
|
|
2510
|
+
progress: F.progress
|
|
2422
2511
|
}
|
|
2423
2512
|
) : null,
|
|
2424
|
-
|
|
2425
|
-
|
|
2513
|
+
F.error && !Ie ? /* @__PURE__ */ a(
|
|
2514
|
+
zt,
|
|
2426
2515
|
{
|
|
2427
2516
|
assistantName: e,
|
|
2428
|
-
error:
|
|
2429
|
-
onRetry:
|
|
2517
|
+
error: F.error,
|
|
2518
|
+
onRetry: Le ? he : void 0
|
|
2430
2519
|
}
|
|
2431
2520
|
) : null
|
|
2432
2521
|
]
|
|
2433
2522
|
}
|
|
2434
2523
|
),
|
|
2435
|
-
|
|
2524
|
+
lt ? /* @__PURE__ */ a(
|
|
2436
2525
|
"button",
|
|
2437
2526
|
{
|
|
2438
2527
|
"aria-label": "回到最新消息",
|
|
2439
2528
|
className: "make-ai-assistant__back-to-latest",
|
|
2440
2529
|
type: "button",
|
|
2441
|
-
onClick:
|
|
2442
|
-
children: /* @__PURE__ */ a(
|
|
2530
|
+
onClick: Se,
|
|
2531
|
+
children: /* @__PURE__ */ a(es, {})
|
|
2443
2532
|
}
|
|
2444
2533
|
) : null,
|
|
2445
|
-
/* @__PURE__ */
|
|
2446
|
-
|
|
2447
|
-
|
|
2534
|
+
/* @__PURE__ */ l("footer", { className: "make-ai-assistant__composer-region", children: [
|
|
2535
|
+
R.enabled ? /* @__PURE__ */ a(Fa, { attachments: R }) : null,
|
|
2536
|
+
ee === "ready" && et.length > 0 && F.messages.length === 0 ? /* @__PURE__ */ a("div", { className: "make-ai-assistant__suggestions", "aria-label": "推荐问题", children: et.map((m, K) => /* @__PURE__ */ a(
|
|
2448
2537
|
"button",
|
|
2449
2538
|
{
|
|
2450
2539
|
type: "button",
|
|
2451
2540
|
onClick: () => {
|
|
2452
|
-
|
|
2541
|
+
u(m);
|
|
2453
2542
|
},
|
|
2454
2543
|
children: m
|
|
2455
2544
|
},
|
|
2456
|
-
`${
|
|
2545
|
+
`${K}-${m}`
|
|
2457
2546
|
)) }) : null,
|
|
2458
|
-
/* @__PURE__ */
|
|
2547
|
+
/* @__PURE__ */ l("form", { className: "make-ai-assistant__composer", onSubmit: C, children: [
|
|
2459
2548
|
/* @__PURE__ */ a(
|
|
2460
2549
|
"textarea",
|
|
2461
2550
|
{
|
|
2462
2551
|
"aria-label": `向 ${e} 提问`,
|
|
2463
|
-
"aria-describedby":
|
|
2464
|
-
"aria-invalid":
|
|
2552
|
+
"aria-describedby": V ? "make-ai-composer-error" : void 0,
|
|
2553
|
+
"aria-invalid": V ? !0 : void 0,
|
|
2465
2554
|
autoFocus: !0,
|
|
2466
|
-
disabled:
|
|
2467
|
-
placeholder: `询问当前 ${
|
|
2468
|
-
ref:
|
|
2555
|
+
disabled: ee !== "ready" || !g.enabled && F.status === "streaming",
|
|
2556
|
+
placeholder: `询问当前 ${s.app.name ?? "App"} 中的数据…`,
|
|
2557
|
+
ref: Oe,
|
|
2469
2558
|
rows: 2,
|
|
2470
|
-
value:
|
|
2559
|
+
value: k,
|
|
2471
2560
|
onChange: (m) => {
|
|
2472
|
-
|
|
2561
|
+
q(m.currentTarget.value), B(void 0);
|
|
2473
2562
|
},
|
|
2474
|
-
onKeyDown:
|
|
2563
|
+
onKeyDown: D,
|
|
2475
2564
|
onPaste: (m) => {
|
|
2476
|
-
|
|
2565
|
+
R.enabled && m.clipboardData.files.length && (m.preventDefault(), R.add(Array.from(m.clipboardData.files)));
|
|
2477
2566
|
}
|
|
2478
2567
|
}
|
|
2479
2568
|
),
|
|
2480
|
-
|
|
2569
|
+
R.enabled ? /* @__PURE__ */ a(
|
|
2481
2570
|
Ua,
|
|
2482
2571
|
{
|
|
2483
|
-
attachments:
|
|
2484
|
-
open:
|
|
2485
|
-
triggerRef:
|
|
2486
|
-
onOpenChange:
|
|
2572
|
+
attachments: R,
|
|
2573
|
+
open: I,
|
|
2574
|
+
triggerRef: He,
|
|
2575
|
+
onOpenChange: G
|
|
2487
2576
|
}
|
|
2488
2577
|
) : null,
|
|
2489
|
-
/* @__PURE__ */
|
|
2490
|
-
|
|
2578
|
+
/* @__PURE__ */ l("div", { className: "make-ai-assistant__composer-actions", children: [
|
|
2579
|
+
F.status === "streaming" ? /* @__PURE__ */ a(
|
|
2491
2580
|
"button",
|
|
2492
2581
|
{
|
|
2493
|
-
"aria-label":
|
|
2582
|
+
"aria-label": O,
|
|
2494
2583
|
className: "make-ai-assistant__send make-ai-assistant__send--stop",
|
|
2495
|
-
"data-tooltip":
|
|
2496
|
-
ref:
|
|
2497
|
-
disabled:
|
|
2584
|
+
"data-tooltip": O,
|
|
2585
|
+
ref: Xe,
|
|
2586
|
+
disabled: g.enabled && g.cancelling.includes(F.activeRunId ?? ""),
|
|
2498
2587
|
type: "button",
|
|
2499
|
-
onClick:
|
|
2588
|
+
onClick: _,
|
|
2500
2589
|
children: /* @__PURE__ */ a("span", { "aria-hidden": "true" })
|
|
2501
2590
|
}
|
|
2502
2591
|
) : /* @__PURE__ */ a(
|
|
@@ -2504,154 +2593,154 @@ function oa({
|
|
|
2504
2593
|
{
|
|
2505
2594
|
"aria-label": "发送",
|
|
2506
2595
|
className: "make-ai-assistant__send",
|
|
2507
|
-
disabled:
|
|
2596
|
+
disabled: ee !== "ready" || R.pending || !k.trim() && !R.parts.length,
|
|
2508
2597
|
type: "submit",
|
|
2509
|
-
children: /* @__PURE__ */ a(
|
|
2598
|
+
children: /* @__PURE__ */ a(Ut, {})
|
|
2510
2599
|
}
|
|
2511
2600
|
),
|
|
2512
|
-
|
|
2601
|
+
g.enabled && F.status === "streaming" ? /* @__PURE__ */ a("button", { "aria-label": "发送", className: "make-ai-assistant__send", disabled: g.busy || R.pending || !k.trim() && !R.parts.length, type: "submit", children: /* @__PURE__ */ a(Ut, {}) }) : null
|
|
2513
2602
|
] })
|
|
2514
2603
|
] }),
|
|
2515
|
-
|
|
2604
|
+
V ? /* @__PURE__ */ a("p", { id: "make-ai-composer-error", role: "alert", children: V }) : null,
|
|
2516
2605
|
/* @__PURE__ */ a("p", { children: "AI 生成的结果可能存在偏差,重要数据请核对明细。" })
|
|
2517
2606
|
] })
|
|
2518
2607
|
]
|
|
2519
2608
|
}
|
|
2520
2609
|
);
|
|
2521
2610
|
}
|
|
2522
|
-
function
|
|
2523
|
-
return /* @__PURE__ */ a(
|
|
2611
|
+
function Is(e) {
|
|
2612
|
+
return /* @__PURE__ */ a(sa, { ...e, visible: !0 });
|
|
2524
2613
|
}
|
|
2525
|
-
function
|
|
2614
|
+
function As({
|
|
2526
2615
|
defaultOpen: e = !1,
|
|
2527
2616
|
hideLauncher: t = !1,
|
|
2528
|
-
launcher:
|
|
2617
|
+
launcher: s,
|
|
2529
2618
|
launcherPosition: i = "bottom-right",
|
|
2530
|
-
maxDrawerWidth:
|
|
2531
|
-
onOpenChange:
|
|
2619
|
+
maxDrawerWidth: o,
|
|
2620
|
+
onOpenChange: c,
|
|
2532
2621
|
open: d,
|
|
2533
|
-
...
|
|
2622
|
+
...h
|
|
2534
2623
|
}) {
|
|
2535
|
-
const
|
|
2624
|
+
const b = Zt(h.brandName, h.title), [f, $] = N(e), [L, T] = N(
|
|
2536
2625
|
() => e || d === !0
|
|
2537
|
-
),
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
typeof window > "u" ?
|
|
2541
|
-
),
|
|
2542
|
-
...
|
|
2543
|
-
...
|
|
2544
|
-
"--make-ai-internal-drawer-max-width": `max(var(--make-ai-internal-drawer-min-width), ${
|
|
2626
|
+
), j = S(null), M = S(null), U = S(void 0), [g, R] = N(), [P, p] = N(Ha), [n, v] = N(!1), k = d ?? f, q = yt(h.theme), I = Ka(o), G = () => ja(
|
|
2627
|
+
P,
|
|
2628
|
+
I,
|
|
2629
|
+
typeof window > "u" ? Xt : window.innerWidth
|
|
2630
|
+
), Y = G(), z = g === void 0 ? void 0 : pt(g, P, Y), Q = z === void 0 && I === void 0 ? void 0 : {
|
|
2631
|
+
...z === void 0 ? {} : { "--make-ai-internal-drawer-width": `${z}px` },
|
|
2632
|
+
...I === void 0 ? {} : {
|
|
2633
|
+
"--make-ai-internal-drawer-max-width": `max(var(--make-ai-internal-drawer-min-width), ${I}px)`
|
|
2545
2634
|
}
|
|
2546
2635
|
};
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
}, [
|
|
2550
|
-
const
|
|
2551
|
-
if (
|
|
2552
|
-
const
|
|
2553
|
-
return
|
|
2554
|
-
}, oe = (
|
|
2555
|
-
if (
|
|
2556
|
-
const
|
|
2557
|
-
|
|
2558
|
-
minimumWidth:
|
|
2559
|
-
pointerId:
|
|
2560
|
-
startWidth:
|
|
2561
|
-
startX:
|
|
2562
|
-
},
|
|
2563
|
-
},
|
|
2564
|
-
const
|
|
2565
|
-
if (!
|
|
2566
|
-
const
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2636
|
+
gt(() => {
|
|
2637
|
+
z !== void 0 && z !== g && R(z);
|
|
2638
|
+
}, [z, g]);
|
|
2639
|
+
const ve = () => {
|
|
2640
|
+
if (z !== void 0) return z;
|
|
2641
|
+
const A = M.current?.getBoundingClientRect().width;
|
|
2642
|
+
return A && Number.isFinite(A) && A > 0 ? A : P;
|
|
2643
|
+
}, oe = (A) => {
|
|
2644
|
+
if (A.button !== 0) return;
|
|
2645
|
+
const W = ve(), ae = g === void 0 ? W : P;
|
|
2646
|
+
p(ae), U.current = {
|
|
2647
|
+
minimumWidth: ae,
|
|
2648
|
+
pointerId: A.pointerId,
|
|
2649
|
+
startWidth: W,
|
|
2650
|
+
startX: A.clientX
|
|
2651
|
+
}, v(!0), typeof A.currentTarget.setPointerCapture == "function" && A.currentTarget.setPointerCapture(A.pointerId), A.preventDefault();
|
|
2652
|
+
}, F = (A) => {
|
|
2653
|
+
const W = U.current;
|
|
2654
|
+
if (!W || W.pointerId !== A.pointerId) return;
|
|
2655
|
+
const ae = pt(
|
|
2656
|
+
W.startWidth + W.startX - A.clientX,
|
|
2657
|
+
W.minimumWidth,
|
|
2658
|
+
G()
|
|
2570
2659
|
);
|
|
2571
|
-
|
|
2572
|
-
},
|
|
2573
|
-
const
|
|
2574
|
-
!
|
|
2575
|
-
},
|
|
2576
|
-
const
|
|
2577
|
-
if (
|
|
2578
|
-
|
|
2579
|
-
const
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2660
|
+
R(ae);
|
|
2661
|
+
}, ne = (A) => {
|
|
2662
|
+
const W = U.current;
|
|
2663
|
+
!W || W.pointerId !== A.pointerId || (U.current = void 0, v(!1));
|
|
2664
|
+
}, ce = (A) => {
|
|
2665
|
+
const W = A.key === "ArrowLeft" ? Dt : A.key === "ArrowRight" ? -Dt : void 0;
|
|
2666
|
+
if (W === void 0) return;
|
|
2667
|
+
A.preventDefault();
|
|
2668
|
+
const ae = ve(), ge = g === void 0 ? ae : P;
|
|
2669
|
+
p(ge), R(pt(
|
|
2670
|
+
ae + W,
|
|
2671
|
+
ge,
|
|
2672
|
+
G()
|
|
2584
2673
|
));
|
|
2585
|
-
},
|
|
2586
|
-
d === void 0 &&
|
|
2587
|
-
},
|
|
2588
|
-
return
|
|
2589
|
-
|
|
2590
|
-
}, [
|
|
2591
|
-
if (!
|
|
2592
|
-
const
|
|
2593
|
-
|
|
2674
|
+
}, V = (A) => {
|
|
2675
|
+
d === void 0 && $(A), c?.(A), A || requestAnimationFrame(() => j.current?.focus());
|
|
2676
|
+
}, B = () => V(!k);
|
|
2677
|
+
return ie(() => {
|
|
2678
|
+
k && T(!0);
|
|
2679
|
+
}, [k]), ie(() => {
|
|
2680
|
+
if (!k) return;
|
|
2681
|
+
const A = (W) => {
|
|
2682
|
+
W.key === "Escape" && (V(!1), requestAnimationFrame(() => j.current?.focus()));
|
|
2594
2683
|
};
|
|
2595
|
-
return document.addEventListener("keydown",
|
|
2596
|
-
}, [
|
|
2684
|
+
return document.addEventListener("keydown", A), () => document.removeEventListener("keydown", A);
|
|
2685
|
+
}, [c, k]), /* @__PURE__ */ l(
|
|
2597
2686
|
"div",
|
|
2598
2687
|
{
|
|
2599
2688
|
className: "make-ai-assistant",
|
|
2600
|
-
"data-open":
|
|
2601
|
-
style:
|
|
2689
|
+
"data-open": k || void 0,
|
|
2690
|
+
style: q,
|
|
2602
2691
|
children: [
|
|
2603
|
-
!t && (!
|
|
2692
|
+
!t && (!k || s) ? s ? s({ open: k, toggle: B }) : /* @__PURE__ */ l(
|
|
2604
2693
|
"button",
|
|
2605
2694
|
{
|
|
2606
|
-
"aria-label":
|
|
2607
|
-
"aria-expanded":
|
|
2695
|
+
"aria-label": k ? `关闭 ${b}` : `打开 ${b}`,
|
|
2696
|
+
"aria-expanded": k,
|
|
2608
2697
|
className: "make-ai-assistant__launcher",
|
|
2609
2698
|
"data-launcher-position": i,
|
|
2610
|
-
ref:
|
|
2699
|
+
ref: j,
|
|
2611
2700
|
type: "button",
|
|
2612
|
-
onClick:
|
|
2701
|
+
onClick: B,
|
|
2613
2702
|
children: [
|
|
2614
2703
|
/* @__PURE__ */ a("span", { className: "make-ai-assistant__launcher-orbit", "aria-hidden": "true" }),
|
|
2615
|
-
/* @__PURE__ */ a(
|
|
2704
|
+
/* @__PURE__ */ a(Gt, {})
|
|
2616
2705
|
]
|
|
2617
2706
|
}
|
|
2618
2707
|
) : null,
|
|
2619
|
-
|
|
2708
|
+
L ? /* @__PURE__ */ l(
|
|
2620
2709
|
"aside",
|
|
2621
2710
|
{
|
|
2622
|
-
"aria-label":
|
|
2711
|
+
"aria-label": b,
|
|
2623
2712
|
"aria-modal": "false",
|
|
2624
2713
|
className: "make-ai-assistant__drawer",
|
|
2625
|
-
"data-resizing":
|
|
2626
|
-
hidden: !
|
|
2627
|
-
ref:
|
|
2714
|
+
"data-resizing": n || void 0,
|
|
2715
|
+
hidden: !k,
|
|
2716
|
+
ref: M,
|
|
2628
2717
|
role: "dialog",
|
|
2629
|
-
style:
|
|
2718
|
+
style: Q,
|
|
2630
2719
|
children: [
|
|
2631
2720
|
/* @__PURE__ */ a(
|
|
2632
2721
|
"div",
|
|
2633
2722
|
{
|
|
2634
2723
|
"aria-label": "调整对话框宽度",
|
|
2635
2724
|
"aria-orientation": "vertical",
|
|
2636
|
-
"aria-valuemax":
|
|
2637
|
-
"aria-valuemin":
|
|
2638
|
-
"aria-valuenow":
|
|
2725
|
+
"aria-valuemax": Y,
|
|
2726
|
+
"aria-valuemin": P,
|
|
2727
|
+
"aria-valuenow": z ?? P,
|
|
2639
2728
|
className: "make-ai-assistant__drawer-resize-handle",
|
|
2640
2729
|
role: "separator",
|
|
2641
2730
|
tabIndex: 0,
|
|
2642
|
-
onKeyDown:
|
|
2643
|
-
onPointerCancel:
|
|
2731
|
+
onKeyDown: ce,
|
|
2732
|
+
onPointerCancel: ne,
|
|
2644
2733
|
onPointerDown: oe,
|
|
2645
|
-
onPointerMove:
|
|
2646
|
-
onPointerUp:
|
|
2734
|
+
onPointerMove: F,
|
|
2735
|
+
onPointerUp: ne
|
|
2647
2736
|
}
|
|
2648
2737
|
),
|
|
2649
2738
|
/* @__PURE__ */ a(
|
|
2650
|
-
|
|
2739
|
+
sa,
|
|
2651
2740
|
{
|
|
2652
|
-
...
|
|
2653
|
-
onClose: () =>
|
|
2654
|
-
visible:
|
|
2741
|
+
...h,
|
|
2742
|
+
onClose: () => V(!1),
|
|
2743
|
+
visible: k
|
|
2655
2744
|
}
|
|
2656
2745
|
)
|
|
2657
2746
|
]
|
|
@@ -2662,24 +2751,24 @@ function Ln({
|
|
|
2662
2751
|
);
|
|
2663
2752
|
}
|
|
2664
2753
|
export {
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2754
|
+
da as ArtifactRenderer,
|
|
2755
|
+
Is as AssistantPanel,
|
|
2756
|
+
Rs as MAKE_AI_ARTIFACT_KINDS,
|
|
2757
|
+
Es as MAKE_AI_ARTIFACT_LIMITS,
|
|
2758
|
+
Ss as MAKE_AI_ARTIFACT_SCHEMA_VERSION,
|
|
2759
|
+
ue as MAKE_AI_CONVERSATION_LIMITS,
|
|
2760
|
+
As as MakeAiAssistant,
|
|
2761
|
+
Ht as appendUserMessage,
|
|
2762
|
+
ca as createArtifactCapabilities,
|
|
2763
|
+
Wt as createArtifactTemplateRegistry,
|
|
2764
|
+
fe as createAssistantConversationState,
|
|
2765
|
+
ka as createPlatformArtifactRegistry,
|
|
2766
|
+
Cs as extendArtifactTemplateRegistry,
|
|
2767
|
+
$e as formatArtifactValue,
|
|
2768
|
+
Ls as parseArtifact,
|
|
2769
|
+
Ot as parseAssistantEvent,
|
|
2770
|
+
ba as platformArtifactTemplates,
|
|
2771
|
+
Me as reduceAssistantEvent,
|
|
2772
|
+
oa as resolveArtifactTemplate,
|
|
2773
|
+
$s as validateArtifact
|
|
2685
2774
|
};
|