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