teodor-new-chat-ui 4.1.22 → 4.1.23
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/dist/index.esm.js +331 -327
- package/dist/index.umd.js +16 -16
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -72,14 +72,14 @@ function hm() {
|
|
|
72
72
|
Ve.unshift("Warning: " + $), Function.prototype.apply.call(console[C], console, Ve);
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
|
-
var R = !1, S = !1, T = !1, E = !1, I = !1,
|
|
76
|
-
|
|
75
|
+
var R = !1, S = !1, T = !1, E = !1, I = !1, A;
|
|
76
|
+
A = Symbol.for("react.module.reference");
|
|
77
77
|
function j(C) {
|
|
78
78
|
return !!(typeof C == "string" || typeof C == "function" || C === r || C === s || I || C === o || C === u || C === d || E || C === p || R || S || T || typeof C == "object" && C !== null && (C.$$typeof === h || C.$$typeof === f || C.$$typeof === i || C.$$typeof === a || C.$$typeof === l || // This needs to include all possible module reference object
|
|
79
79
|
// types supported by any Flight configuration anywhere since
|
|
80
80
|
// we don't know which Flight build this will end up being used
|
|
81
81
|
// with.
|
|
82
|
-
C.$$typeof ===
|
|
82
|
+
C.$$typeof === A || C.getModuleId !== void 0));
|
|
83
83
|
}
|
|
84
84
|
function D(C, $, X) {
|
|
85
85
|
var fe = C.displayName;
|
|
@@ -136,14 +136,14 @@ function hm() {
|
|
|
136
136
|
}
|
|
137
137
|
return null;
|
|
138
138
|
}
|
|
139
|
-
var O = Object.assign, K = 0, W, G, F, N, q,
|
|
139
|
+
var O = Object.assign, K = 0, W, G, F, N, q, Q, ge;
|
|
140
140
|
function ce() {
|
|
141
141
|
}
|
|
142
142
|
ce.__reactDisabledLog = !0;
|
|
143
143
|
function te() {
|
|
144
144
|
{
|
|
145
145
|
if (K === 0) {
|
|
146
|
-
W = console.log, G = console.info, F = console.warn, N = console.error, q = console.group,
|
|
146
|
+
W = console.log, G = console.info, F = console.warn, N = console.error, q = console.group, Q = console.groupCollapsed, ge = console.groupEnd;
|
|
147
147
|
var C = {
|
|
148
148
|
configurable: !0,
|
|
149
149
|
enumerable: !0,
|
|
@@ -188,7 +188,7 @@ function hm() {
|
|
|
188
188
|
value: q
|
|
189
189
|
}),
|
|
190
190
|
groupCollapsed: O({}, C, {
|
|
191
|
-
value:
|
|
191
|
+
value: Q
|
|
192
192
|
}),
|
|
193
193
|
groupEnd: O({}, C, {
|
|
194
194
|
value: ge
|
|
@@ -579,7 +579,7 @@ Check the top-level render call using <` + X + ">.");
|
|
|
579
579
|
C.ref !== null && (Vt(C), b("Invalid attribute `ref` supplied to `React.Fragment`."), Vt(null));
|
|
580
580
|
}
|
|
581
581
|
}
|
|
582
|
-
function
|
|
582
|
+
function _(C, $, X, fe, He, Ve) {
|
|
583
583
|
{
|
|
584
584
|
var Fe = j(C);
|
|
585
585
|
if (!Fe) {
|
|
@@ -609,13 +609,13 @@ Check the top-level render call using <` + X + ">.");
|
|
|
609
609
|
return C === r ? k(ht) : $e(ht), ht;
|
|
610
610
|
}
|
|
611
611
|
}
|
|
612
|
-
function
|
|
613
|
-
return
|
|
612
|
+
function Z(C, $, X) {
|
|
613
|
+
return _(C, $, X, !0);
|
|
614
614
|
}
|
|
615
615
|
function he(C, $, X) {
|
|
616
|
-
return
|
|
616
|
+
return _(C, $, X, !1);
|
|
617
617
|
}
|
|
618
|
-
var pe = he, de =
|
|
618
|
+
var pe = he, de = Z;
|
|
619
619
|
Nr.Fragment = r, Nr.jsx = pe, Nr.jsxs = de;
|
|
620
620
|
}()), Nr;
|
|
621
621
|
}
|
|
@@ -1850,7 +1850,7 @@ const Zc = (e) => {
|
|
|
1850
1850
|
onUploadProgress: T,
|
|
1851
1851
|
responseType: E,
|
|
1852
1852
|
headers: I,
|
|
1853
|
-
withCredentials:
|
|
1853
|
+
withCredentials: A = "same-origin",
|
|
1854
1854
|
fetchOptions: j
|
|
1855
1855
|
} = Zc(w), D = t || fetch;
|
|
1856
1856
|
E = E ? (E + "").toLowerCase() : "text";
|
|
@@ -1861,20 +1861,20 @@ const Zc = (e) => {
|
|
|
1861
1861
|
let K;
|
|
1862
1862
|
try {
|
|
1863
1863
|
if (T && u && g !== "get" && g !== "head" && (K = await p(I, x)) !== 0) {
|
|
1864
|
-
let
|
|
1864
|
+
let Q = new n(v, {
|
|
1865
1865
|
method: "POST",
|
|
1866
1866
|
body: x,
|
|
1867
1867
|
duplex: "half"
|
|
1868
1868
|
}), ge;
|
|
1869
|
-
if (P.isFormData(x) && (ge =
|
|
1869
|
+
if (P.isFormData(x) && (ge = Q.headers.get("content-type")) && I.setContentType(ge), Q.body) {
|
|
1870
1870
|
const [ce, te] = rl(
|
|
1871
1871
|
K,
|
|
1872
1872
|
Mo(ol(T))
|
|
1873
1873
|
);
|
|
1874
|
-
x = il(
|
|
1874
|
+
x = il(Q.body, al, ce, te);
|
|
1875
1875
|
}
|
|
1876
1876
|
}
|
|
1877
|
-
P.isString(
|
|
1877
|
+
P.isString(A) || (A = A ? "include" : "omit");
|
|
1878
1878
|
const W = s && "credentials" in n.prototype, G = {
|
|
1879
1879
|
...j,
|
|
1880
1880
|
signal: L,
|
|
@@ -1882,15 +1882,15 @@ const Zc = (e) => {
|
|
|
1882
1882
|
headers: I.normalize().toJSON(),
|
|
1883
1883
|
body: x,
|
|
1884
1884
|
duplex: "half",
|
|
1885
|
-
credentials: W ?
|
|
1885
|
+
credentials: W ? A : void 0
|
|
1886
1886
|
};
|
|
1887
1887
|
z = s && new n(v, G);
|
|
1888
1888
|
let F = await (s ? D(z, j) : D(v, G));
|
|
1889
1889
|
const N = d && (E === "stream" || E === "response");
|
|
1890
1890
|
if (d && (S || N && O)) {
|
|
1891
|
-
const
|
|
1891
|
+
const Q = {};
|
|
1892
1892
|
["status", "statusText", "headers"].forEach((Ae) => {
|
|
1893
|
-
|
|
1893
|
+
Q[Ae] = F[Ae];
|
|
1894
1894
|
});
|
|
1895
1895
|
const ge = P.toFiniteNumber(F.headers.get("content-length")), [ce, te] = S && rl(
|
|
1896
1896
|
ge,
|
|
@@ -1900,13 +1900,13 @@ const Zc = (e) => {
|
|
|
1900
1900
|
il(F.body, al, ce, () => {
|
|
1901
1901
|
te && te(), O && O();
|
|
1902
1902
|
}),
|
|
1903
|
-
|
|
1903
|
+
Q
|
|
1904
1904
|
);
|
|
1905
1905
|
}
|
|
1906
1906
|
E = E || "text";
|
|
1907
1907
|
let q = await f[P.findKey(f, E) || "text"](F, w);
|
|
1908
|
-
return !N && O && O(), await new Promise((
|
|
1909
|
-
Xc(
|
|
1908
|
+
return !N && O && O(), await new Promise((Q, ge) => {
|
|
1909
|
+
Xc(Q, ge, {
|
|
1910
1910
|
data: q,
|
|
1911
1911
|
headers: It.from(F.headers),
|
|
1912
1912
|
status: F.status,
|
|
@@ -2886,12 +2886,12 @@ function ax(e = {}) {
|
|
|
2886
2886
|
(j = y.current) == null || j.abort(), y.current = null, l(!1), b(!1), S.current = 0, g(0);
|
|
2887
2887
|
}, []), I = De(() => {
|
|
2888
2888
|
h(""), w(null), d(null);
|
|
2889
|
-
}, []),
|
|
2889
|
+
}, []), A = De(
|
|
2890
2890
|
(j, D, L) => {
|
|
2891
2891
|
y.current && (y.current.abort(), y.current = null), l(!0), d(null), e.autoAppendAssistant !== !1 && h("");
|
|
2892
2892
|
const z = new AbortController();
|
|
2893
2893
|
return y.current = z, (async () => {
|
|
2894
|
-
var K, W, G, F, N, q,
|
|
2894
|
+
var K, W, G, F, N, q, Q, ge;
|
|
2895
2895
|
const O = (ce) => {
|
|
2896
2896
|
var te;
|
|
2897
2897
|
try {
|
|
@@ -3021,7 +3021,7 @@ function ax(e = {}) {
|
|
|
3021
3021
|
await Ae.cancel();
|
|
3022
3022
|
} catch {
|
|
3023
3023
|
} finally {
|
|
3024
|
-
(
|
|
3024
|
+
(Q = Ae.releaseLock) == null || Q.call(Ae);
|
|
3025
3025
|
}
|
|
3026
3026
|
U !== null && typeof window < "u" && window.cancelAnimationFrame(U), clearInterval(Xe), l(!1), b(!1), y.current = null, S.current = 0, g(0);
|
|
3027
3027
|
}
|
|
@@ -3047,7 +3047,7 @@ function ax(e = {}) {
|
|
|
3047
3047
|
lastCheckpointId: p,
|
|
3048
3048
|
lastSeq: v,
|
|
3049
3049
|
connected: x,
|
|
3050
|
-
stream:
|
|
3050
|
+
stream: A,
|
|
3051
3051
|
stop: E,
|
|
3052
3052
|
clear: I,
|
|
3053
3053
|
setToken: T
|
|
@@ -3243,31 +3243,31 @@ function wx({
|
|
|
3243
3243
|
}
|
|
3244
3244
|
}, [u]), h = lt(() => `threadPayload:${px}:${f}:`, [f]), p = De((k) => `${h}${k}`, [h]), w = De((k) => {
|
|
3245
3245
|
if (!k || typeof k != "object") return null;
|
|
3246
|
-
const
|
|
3247
|
-
return typeof
|
|
3248
|
-
threadId:
|
|
3249
|
-
messages:
|
|
3250
|
-
hasMore: !!
|
|
3251
|
-
nextCursor:
|
|
3252
|
-
checkpointId:
|
|
3253
|
-
checkpointNs:
|
|
3246
|
+
const _ = k;
|
|
3247
|
+
return typeof _.threadId != "string" || !Array.isArray(_.messages) ? null : {
|
|
3248
|
+
threadId: _.threadId,
|
|
3249
|
+
messages: _.messages,
|
|
3250
|
+
hasMore: !!_.hasMore,
|
|
3251
|
+
nextCursor: _.nextCursor ?? null,
|
|
3252
|
+
checkpointId: _.checkpointId ?? null,
|
|
3253
|
+
checkpointNs: _.checkpointNs ?? null
|
|
3254
3254
|
};
|
|
3255
3255
|
}, []), v = De((k) => {
|
|
3256
|
-
const
|
|
3257
|
-
if (!
|
|
3256
|
+
const _ = Ji(p(k));
|
|
3257
|
+
if (!_) return null;
|
|
3258
3258
|
try {
|
|
3259
|
-
const
|
|
3260
|
-
return w(
|
|
3259
|
+
const Z = JSON.parse(_);
|
|
3260
|
+
return w(Z);
|
|
3261
3261
|
} catch {
|
|
3262
3262
|
return null;
|
|
3263
3263
|
}
|
|
3264
|
-
}, [p, w]), g = De((k,
|
|
3265
|
-
const
|
|
3264
|
+
}, [p, w]), g = De((k, _ = 100) => {
|
|
3265
|
+
const Z = {
|
|
3266
3266
|
...k,
|
|
3267
|
-
messages: Array.isArray(k.messages) ? k.messages.slice(-
|
|
3267
|
+
messages: Array.isArray(k.messages) ? k.messages.slice(-_) : []
|
|
3268
3268
|
};
|
|
3269
3269
|
try {
|
|
3270
|
-
uu(p(k.threadId), JSON.stringify(
|
|
3270
|
+
uu(p(k.threadId), JSON.stringify(Z));
|
|
3271
3271
|
} catch {
|
|
3272
3272
|
}
|
|
3273
3273
|
}, [p]), x = De((k) => {
|
|
@@ -3276,9 +3276,9 @@ function wx({
|
|
|
3276
3276
|
if (Br())
|
|
3277
3277
|
try {
|
|
3278
3278
|
const k = h;
|
|
3279
|
-
for (let
|
|
3280
|
-
const
|
|
3281
|
-
|
|
3279
|
+
for (let _ = 0; _ < window.localStorage.length; _++) {
|
|
3280
|
+
const Z = window.localStorage.key(_);
|
|
3281
|
+
Z && Z.startsWith(k) && window.localStorage.removeItem(Z);
|
|
3282
3282
|
}
|
|
3283
3283
|
} catch {
|
|
3284
3284
|
}
|
|
@@ -3288,12 +3288,12 @@ function wx({
|
|
|
3288
3288
|
return Vs(f, (k = l.getAuthToken) == null ? void 0 : k.call(l));
|
|
3289
3289
|
}
|
|
3290
3290
|
), [S, T] = ve(() => {
|
|
3291
|
-
var
|
|
3291
|
+
var _;
|
|
3292
3292
|
const k = bl(
|
|
3293
|
-
Vs(f, (
|
|
3293
|
+
Vs(f, (_ = l.getAuthToken) == null ? void 0 : _.call(l))
|
|
3294
3294
|
);
|
|
3295
3295
|
return Ks(k);
|
|
3296
|
-
}), E = lt(() => yl(S), [S]), [I,
|
|
3296
|
+
}), E = lt(() => yl(S), [S]), [I, A] = ve(t), [j, D] = ve(!1), [L, z] = ve(!1), [O, K] = ve(!1), [W, G] = ve(!1), [F, N] = ve(null), [q, Q] = ve(void 0), [ge, ce] = ve(void 0), {
|
|
3297
3297
|
state: te,
|
|
3298
3298
|
seed: Ae,
|
|
3299
3299
|
prepend: Ce,
|
|
@@ -3304,11 +3304,11 @@ function wx({
|
|
|
3304
3304
|
pt(() => {
|
|
3305
3305
|
U.current = I;
|
|
3306
3306
|
}, [I]);
|
|
3307
|
-
const ue = et(!1), ae = et([]), Be = et(null), Xe = et(null), qe = et(/* @__PURE__ */ new Map()), Te = et(I), Me = et(!1), rt = et(null), ze = De((k,
|
|
3307
|
+
const ue = et(!1), ae = et([]), Be = et(null), Xe = et(null), qe = et(/* @__PURE__ */ new Map()), Te = et(I), Me = et(!1), rt = et(null), ze = De((k, _) => new Promise((Z, he) => {
|
|
3308
3308
|
const pe = async () => {
|
|
3309
3309
|
ue.current = !0;
|
|
3310
3310
|
try {
|
|
3311
|
-
await k(),
|
|
3311
|
+
await k(), Z();
|
|
3312
3312
|
} catch (de) {
|
|
3313
3313
|
he(de);
|
|
3314
3314
|
} finally {
|
|
@@ -3325,22 +3325,22 @@ function wx({
|
|
|
3325
3325
|
const k = E.length > 0;
|
|
3326
3326
|
k || D(!0);
|
|
3327
3327
|
try {
|
|
3328
|
-
const
|
|
3328
|
+
const _ = await l.listThreads();
|
|
3329
3329
|
$s(() => {
|
|
3330
|
-
T((
|
|
3331
|
-
const he = (C) => C.map(($) => `${$.threadId}:${$.updatedAt ?? ""}:${$.messageCount ?? ""}`).join("|"), pe = yl(
|
|
3332
|
-
return he(pe) === he(
|
|
3330
|
+
T((Z) => {
|
|
3331
|
+
const he = (C) => C.map(($) => `${$.threadId}:${$.updatedAt ?? ""}:${$.messageCount ?? ""}`).join("|"), pe = yl(Z);
|
|
3332
|
+
return he(pe) === he(_) ? Z : Ks(_);
|
|
3333
3333
|
});
|
|
3334
3334
|
});
|
|
3335
|
-
} catch (
|
|
3336
|
-
i == null || i(String(
|
|
3335
|
+
} catch (_) {
|
|
3336
|
+
i == null || i(String(_)), console.error("[ChatSessionProvider] Failed to refresh threads:", _);
|
|
3337
3337
|
} finally {
|
|
3338
3338
|
k || D(!1);
|
|
3339
3339
|
}
|
|
3340
3340
|
}, [l, i, E.length]), ft = et(!1), ne = et(null), re = et(null), xe = et(""), Re = De(
|
|
3341
|
-
(k,
|
|
3342
|
-
const he = Array.isArray(k == null ? void 0 : k.messages) ? k.messages : [], pe =
|
|
3343
|
-
if (
|
|
3341
|
+
(k, _, Z) => {
|
|
3342
|
+
const he = Array.isArray(k == null ? void 0 : k.messages) ? k.messages : [], pe = Z ?? (k == null ? void 0 : k.threadId) ?? U.current;
|
|
3343
|
+
if (_ === "replace") {
|
|
3344
3344
|
if (pe) {
|
|
3345
3345
|
const de = {
|
|
3346
3346
|
threadId: pe,
|
|
@@ -3356,7 +3356,7 @@ function wx({
|
|
|
3356
3356
|
checkpointId: (k == null ? void 0 : k.checkpointId) ?? null,
|
|
3357
3357
|
checkpointNs: (k == null ? void 0 : k.checkpointNs) ?? null
|
|
3358
3358
|
});
|
|
3359
|
-
} else if (
|
|
3359
|
+
} else if (_ === "prepend" && he.length && pe) {
|
|
3360
3360
|
const de = qe.current.get(pe), C = (de == null ? void 0 : de.messages) ?? [], $ = /* @__PURE__ */ new Set(), X = [...he, ...C].filter((He) => {
|
|
3361
3361
|
const Ve = He == null ? void 0 : He.id;
|
|
3362
3362
|
return Ve ? $.has(Ve) ? !1 : ($.add(Ve), !0) : !0;
|
|
@@ -3369,8 +3369,8 @@ function wx({
|
|
|
3369
3369
|
checkpointNs: (de == null ? void 0 : de.checkpointNs) ?? (k == null ? void 0 : k.checkpointNs) ?? null
|
|
3370
3370
|
};
|
|
3371
3371
|
qe.current.set(pe, fe), Ce(he);
|
|
3372
|
-
} else
|
|
3373
|
-
|
|
3372
|
+
} else _ === "prepend" && he.length && Ce(he);
|
|
3373
|
+
_ === "replace" ? (N((k == null ? void 0 : k.nextCursor) ?? null), K(!!(k != null && k.hasMore)), Q((k == null ? void 0 : k.checkpointId) ?? void 0), ce((k == null ? void 0 : k.checkpointNs) ?? void 0)) : (N((de) => (k == null ? void 0 : k.nextCursor) ?? de ?? null), K((de) => (k == null ? void 0 : k.hasMore) !== void 0 ? !!(k != null && k.hasMore) : de), Q((de) => (k == null ? void 0 : k.checkpointId) ?? de ?? void 0), ce((de) => (k == null ? void 0 : k.checkpointNs) ?? de ?? void 0));
|
|
3374
3374
|
},
|
|
3375
3375
|
[Ce, Ae]
|
|
3376
3376
|
), Se = De(
|
|
@@ -3378,44 +3378,44 @@ function wx({
|
|
|
3378
3378
|
Ae(k.messages, {
|
|
3379
3379
|
checkpointId: k.checkpointId,
|
|
3380
3380
|
checkpointNs: k.checkpointNs
|
|
3381
|
-
}), N(k.nextCursor), K(k.hasMore),
|
|
3381
|
+
}), N(k.nextCursor), K(k.hasMore), Q(k.checkpointId ?? void 0), ce(k.checkpointNs ?? void 0), Te.current = k.threadId;
|
|
3382
3382
|
},
|
|
3383
3383
|
[Ae]
|
|
3384
3384
|
), Ie = De((k) => {
|
|
3385
3385
|
k && (qe.current.delete(k), x(k), Te.current === k && (Te.current = null));
|
|
3386
3386
|
}, [x]), Ze = De(() => {
|
|
3387
3387
|
const k = U.current;
|
|
3388
|
-
k && Ie(k), J([]), K(!1), G(!1), N(null),
|
|
3389
|
-
}, [Ie, J]), Ge = De(({ from: k, to:
|
|
3390
|
-
const
|
|
3391
|
-
|
|
3392
|
-
`[ChatSessionProvider] Stream sequence gap detected (${k} -> ${
|
|
3388
|
+
k && Ie(k), J([]), K(!1), G(!1), N(null), Q(void 0), ce(void 0);
|
|
3389
|
+
}, [Ie, J]), Ge = De(({ from: k, to: _ }) => {
|
|
3390
|
+
const Z = U.current;
|
|
3391
|
+
Z && console.warn(
|
|
3392
|
+
`[ChatSessionProvider] Stream sequence gap detected (${k} -> ${_}) for thread ${Z}`
|
|
3393
3393
|
);
|
|
3394
3394
|
}, []), ct = De(
|
|
3395
3395
|
(k) => {
|
|
3396
|
-
const
|
|
3396
|
+
const _ = k.threadId;
|
|
3397
3397
|
console.log("[ChatSessionProvider] 📥 Handling thread_info event:", {
|
|
3398
|
-
threadId:
|
|
3398
|
+
threadId: _,
|
|
3399
3399
|
title: k.title,
|
|
3400
3400
|
created: k.created,
|
|
3401
3401
|
currentThreads: E.length
|
|
3402
3402
|
});
|
|
3403
|
-
const
|
|
3404
|
-
threadId:
|
|
3405
|
-
title: k.title || `Thread ${
|
|
3403
|
+
const Z = {
|
|
3404
|
+
threadId: _,
|
|
3405
|
+
title: k.title || `Thread ${_.slice(0, 8)}`,
|
|
3406
3406
|
createdAt: k.createdAt || (/* @__PURE__ */ new Date()).toISOString(),
|
|
3407
3407
|
updatedAt: k.updatedAt || (/* @__PURE__ */ new Date()).toISOString(),
|
|
3408
3408
|
messageCount: k.messageCount || 0
|
|
3409
3409
|
};
|
|
3410
|
-
U.current !==
|
|
3410
|
+
U.current !== _ && (!U.current && te.messages.length <= 1 && (Xe.current = _), A(_)), $s(() => {
|
|
3411
3411
|
T((he) => {
|
|
3412
|
-
const pe = he.byId[
|
|
3413
|
-
return pe ? pe.title ===
|
|
3414
|
-
byId: { ...he.byId, [
|
|
3412
|
+
const pe = he.byId[_];
|
|
3413
|
+
return pe ? pe.title === Z.title && pe.updatedAt === Z.updatedAt && pe.messageCount === Z.messageCount ? he : {
|
|
3414
|
+
byId: { ...he.byId, [_]: Z },
|
|
3415
3415
|
order: he.order
|
|
3416
3416
|
} : {
|
|
3417
|
-
byId: { ...he.byId, [
|
|
3418
|
-
order: [
|
|
3417
|
+
byId: { ...he.byId, [_]: Z },
|
|
3418
|
+
order: [_, ...he.order]
|
|
3419
3419
|
};
|
|
3420
3420
|
});
|
|
3421
3421
|
});
|
|
@@ -3434,8 +3434,8 @@ function wx({
|
|
|
3434
3434
|
ft.current = vn;
|
|
3435
3435
|
}, [vn]), pt(() => {
|
|
3436
3436
|
if (!Br()) return;
|
|
3437
|
-
re.current && window.clearTimeout(re.current);
|
|
3438
|
-
const k = E.map((
|
|
3437
|
+
re.current !== null && (window.clearTimeout(re.current), re.current = null);
|
|
3438
|
+
const k = E.map((Z) => `${Z.threadId}:${Z.updatedAt ?? ""}:${Z.messageCount ?? ""}`).join("|");
|
|
3439
3439
|
if (E.length === 0) {
|
|
3440
3440
|
try {
|
|
3441
3441
|
wl(y);
|
|
@@ -3444,23 +3444,27 @@ function wx({
|
|
|
3444
3444
|
xe.current = "";
|
|
3445
3445
|
return;
|
|
3446
3446
|
}
|
|
3447
|
-
if (k
|
|
3448
|
-
return
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
|
-
|
|
3452
|
-
|
|
3453
|
-
|
|
3454
|
-
|
|
3455
|
-
|
|
3456
|
-
}
|
|
3457
|
-
|
|
3458
|
-
|
|
3447
|
+
if (k === xe.current)
|
|
3448
|
+
return;
|
|
3449
|
+
const _ = () => {
|
|
3450
|
+
try {
|
|
3451
|
+
const Z = E.slice(0, cu);
|
|
3452
|
+
du(y, Z), xe.current = k;
|
|
3453
|
+
} catch {
|
|
3454
|
+
} finally {
|
|
3455
|
+
re.current = null;
|
|
3456
|
+
}
|
|
3457
|
+
};
|
|
3458
|
+
return re.current = window.setTimeout(() => {
|
|
3459
|
+
mx(_);
|
|
3460
|
+
}, Si), () => {
|
|
3461
|
+
re.current !== null && (window.clearTimeout(re.current), re.current = null);
|
|
3462
|
+
};
|
|
3459
3463
|
}, [E, y]), pt(() => {
|
|
3460
3464
|
var he;
|
|
3461
3465
|
const k = l.getAuthToken();
|
|
3462
3466
|
wn(k);
|
|
3463
|
-
const
|
|
3467
|
+
const _ = (pe) => {
|
|
3464
3468
|
const de = Vs(f, pe);
|
|
3465
3469
|
rt.current !== de && (rt.current = de, Me.current = !1), R(de);
|
|
3466
3470
|
const C = bl(de);
|
|
@@ -3469,76 +3473,76 @@ function wx({
|
|
|
3469
3473
|
}), Me.current || (Me.current = !0, Je().catch(() => {
|
|
3470
3474
|
}));
|
|
3471
3475
|
};
|
|
3472
|
-
|
|
3473
|
-
const
|
|
3474
|
-
wn(pe), b(),
|
|
3476
|
+
_(k);
|
|
3477
|
+
const Z = (he = l.onTokenChange) == null ? void 0 : he.call(l, (pe) => {
|
|
3478
|
+
wn(pe), b(), _(pe);
|
|
3475
3479
|
});
|
|
3476
3480
|
return () => {
|
|
3477
|
-
|
|
3481
|
+
Z == null || Z();
|
|
3478
3482
|
};
|
|
3479
3483
|
}, [l, f, wn, b, Je]);
|
|
3480
3484
|
const bn = De(
|
|
3481
3485
|
async (k) => {
|
|
3482
|
-
const
|
|
3483
|
-
threadId:
|
|
3486
|
+
const _ = `temp-${Date.now()}`, Z = {
|
|
3487
|
+
threadId: _,
|
|
3484
3488
|
title: k || "New Chat",
|
|
3485
3489
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3486
3490
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3487
3491
|
messageCount: 0
|
|
3488
3492
|
};
|
|
3489
3493
|
T((he) => ({
|
|
3490
|
-
byId: { ...he.byId, [
|
|
3491
|
-
order: [
|
|
3492
|
-
})), _
|
|
3494
|
+
byId: { ...he.byId, [_]: Z },
|
|
3495
|
+
order: [_, ...he.order]
|
|
3496
|
+
})), A(_);
|
|
3493
3497
|
try {
|
|
3494
3498
|
const he = await l.createThread(k), pe = typeof he == "string" ? he : he.threadId;
|
|
3495
3499
|
return T((de) => {
|
|
3496
|
-
const C = de.byId[
|
|
3500
|
+
const C = de.byId[_];
|
|
3497
3501
|
if (!C) return de;
|
|
3498
3502
|
const $ = { ...de.byId };
|
|
3499
|
-
delete $[
|
|
3500
|
-
const X = de.order.map((fe) => fe ===
|
|
3503
|
+
delete $[_], $[pe] = { ...C, threadId: pe };
|
|
3504
|
+
const X = de.order.map((fe) => fe === _ ? pe : fe);
|
|
3501
3505
|
return { byId: $, order: X };
|
|
3502
|
-
}),
|
|
3506
|
+
}), A(pe), setTimeout(() => Je(), 10), pe;
|
|
3503
3507
|
} catch (he) {
|
|
3504
3508
|
throw T((pe) => {
|
|
3505
|
-
if (!pe.byId[
|
|
3509
|
+
if (!pe.byId[_]) return pe;
|
|
3506
3510
|
const de = { ...pe.byId };
|
|
3507
|
-
delete de[
|
|
3508
|
-
const C = pe.order.filter(($) => $ !==
|
|
3511
|
+
delete de[_];
|
|
3512
|
+
const C = pe.order.filter(($) => $ !== _);
|
|
3509
3513
|
return { byId: de, order: C };
|
|
3510
|
-
}),
|
|
3514
|
+
}), A(null), he;
|
|
3511
3515
|
}
|
|
3512
3516
|
},
|
|
3513
3517
|
[l, Je]
|
|
3514
3518
|
), or = De(
|
|
3515
3519
|
async (k) => {
|
|
3516
|
-
await l.deleteThread(k), T((
|
|
3517
|
-
if (!
|
|
3518
|
-
const
|
|
3519
|
-
delete
|
|
3520
|
-
const he =
|
|
3521
|
-
return { byId:
|
|
3522
|
-
}), Ie(k), U.current === k && (Xe.current = k,
|
|
3520
|
+
await l.deleteThread(k), T((_) => {
|
|
3521
|
+
if (!_.byId[k]) return _;
|
|
3522
|
+
const Z = { ..._.byId };
|
|
3523
|
+
delete Z[k];
|
|
3524
|
+
const he = _.order.filter((pe) => pe !== k);
|
|
3525
|
+
return { byId: Z, order: he };
|
|
3526
|
+
}), Ie(k), U.current === k && (Xe.current = k, A(null), U.current = null, Te.current = null, Ze()), await Je();
|
|
3523
3527
|
},
|
|
3524
3528
|
[l, Ze, Ie, Je]
|
|
3525
3529
|
), yn = De(
|
|
3526
|
-
async (k,
|
|
3530
|
+
async (k, _) => {
|
|
3527
3531
|
try {
|
|
3528
|
-
await l.updateThread(k,
|
|
3529
|
-
const he =
|
|
3532
|
+
await l.updateThread(k, _), T((Z) => {
|
|
3533
|
+
const he = Z.byId[k];
|
|
3530
3534
|
return he ? {
|
|
3531
|
-
byId: { ...
|
|
3532
|
-
order:
|
|
3533
|
-
} :
|
|
3535
|
+
byId: { ...Z.byId, [k]: { ...he, title: _ } },
|
|
3536
|
+
order: Z.order
|
|
3537
|
+
} : Z;
|
|
3534
3538
|
});
|
|
3535
|
-
} catch (
|
|
3536
|
-
throw await Je(),
|
|
3539
|
+
} catch (Z) {
|
|
3540
|
+
throw await Je(), Z;
|
|
3537
3541
|
}
|
|
3538
3542
|
},
|
|
3539
3543
|
[l, Je]
|
|
3540
3544
|
), At = De(
|
|
3541
|
-
async (k,
|
|
3545
|
+
async (k, _, Z, he = !1) => {
|
|
3542
3546
|
await ze(async () => {
|
|
3543
3547
|
if (Xe.current === k && !he) {
|
|
3544
3548
|
Xe.current = null;
|
|
@@ -3546,8 +3550,8 @@ function wx({
|
|
|
3546
3550
|
}
|
|
3547
3551
|
if (Be.current === k && !he)
|
|
3548
3552
|
return;
|
|
3549
|
-
|
|
3550
|
-
const pe = !he && !
|
|
3553
|
+
A((X) => X === k ? X : k), U.current = k;
|
|
3554
|
+
const pe = !he && !_ && !Z;
|
|
3551
3555
|
let de = !1;
|
|
3552
3556
|
if (pe) {
|
|
3553
3557
|
const X = qe.current.get(k);
|
|
@@ -3558,13 +3562,13 @@ function wx({
|
|
|
3558
3562
|
fe && (qe.current.set(k, fe), Se(fe), de = !0);
|
|
3559
3563
|
}
|
|
3560
3564
|
}
|
|
3561
|
-
const C = he || !de || !!
|
|
3565
|
+
const C = he || !de || !!_ || !!Z, $ = async (X) => {
|
|
3562
3566
|
X && z(!0), Be.current = k;
|
|
3563
3567
|
try {
|
|
3564
3568
|
const fe = await l.getMessages({
|
|
3565
3569
|
threadId: k,
|
|
3566
|
-
checkpointId:
|
|
3567
|
-
checkpointNs:
|
|
3570
|
+
checkpointId: _,
|
|
3571
|
+
checkpointNs: Z
|
|
3568
3572
|
});
|
|
3569
3573
|
Re(fe, "replace", k);
|
|
3570
3574
|
} catch (fe) {
|
|
@@ -3582,23 +3586,23 @@ function wx({
|
|
|
3582
3586
|
), Vt = De(async () => {
|
|
3583
3587
|
await ze(async () => {
|
|
3584
3588
|
const k = U.current;
|
|
3585
|
-
k && Ie(k), Xe.current = null,
|
|
3589
|
+
k && Ie(k), Xe.current = null, A(null), U.current = null, Te.current = null, Ze(), Q(void 0), ce(void 0);
|
|
3586
3590
|
try {
|
|
3587
3591
|
localStorage.removeItem("lastThreadId");
|
|
3588
|
-
} catch (
|
|
3589
|
-
console.warn("[ChatSessionProvider] Failed to clear lastThreadId:",
|
|
3592
|
+
} catch (_) {
|
|
3593
|
+
console.warn("[ChatSessionProvider] Failed to clear lastThreadId:", _);
|
|
3590
3594
|
}
|
|
3591
3595
|
}, "clearCurrentThread");
|
|
3592
3596
|
}, [Ze, Ie, ze]), Sn = De(
|
|
3593
3597
|
async (k) => {
|
|
3594
|
-
const
|
|
3595
|
-
return Gg(
|
|
3598
|
+
const _ = await l.listCheckpoints(k);
|
|
3599
|
+
return Gg(_, k);
|
|
3596
3600
|
},
|
|
3597
3601
|
[l]
|
|
3598
3602
|
), Cn = De(
|
|
3599
|
-
async (k,
|
|
3603
|
+
async (k, _) => {
|
|
3600
3604
|
if (!U.current) throw new Error("No active thread");
|
|
3601
|
-
await At(U.current, k,
|
|
3605
|
+
await At(U.current, k, _ ?? void 0, !0);
|
|
3602
3606
|
},
|
|
3603
3607
|
[At]
|
|
3604
3608
|
), Dn = De(async () => {
|
|
@@ -3608,18 +3612,18 @@ function wx({
|
|
|
3608
3612
|
async (k) => {
|
|
3609
3613
|
if (!U.current) throw new Error("No active thread");
|
|
3610
3614
|
if (W || !O) return;
|
|
3611
|
-
const
|
|
3612
|
-
if (
|
|
3615
|
+
const _ = F;
|
|
3616
|
+
if (_) {
|
|
3613
3617
|
G(!0);
|
|
3614
3618
|
try {
|
|
3615
|
-
const
|
|
3616
|
-
threadId:
|
|
3619
|
+
const Z = U.current, he = await l.getMessages({
|
|
3620
|
+
threadId: Z,
|
|
3617
3621
|
checkpointId: q,
|
|
3618
3622
|
checkpointNs: ge,
|
|
3619
3623
|
limit: (k == null ? void 0 : k.limit) ?? fx,
|
|
3620
|
-
beforeId:
|
|
3624
|
+
beforeId: _
|
|
3621
3625
|
});
|
|
3622
|
-
Re(he, "prepend",
|
|
3626
|
+
Re(he, "prepend", Z ?? void 0);
|
|
3623
3627
|
} finally {
|
|
3624
3628
|
G(!1);
|
|
3625
3629
|
}
|
|
@@ -3635,11 +3639,11 @@ function wx({
|
|
|
3635
3639
|
W
|
|
3636
3640
|
]
|
|
3637
3641
|
), Ln = De(
|
|
3638
|
-
async (k,
|
|
3642
|
+
async (k, _) => {
|
|
3639
3643
|
var Fe;
|
|
3640
|
-
const
|
|
3641
|
-
!
|
|
3642
|
-
const he = (
|
|
3644
|
+
const Z = U.current;
|
|
3645
|
+
!Z && !(_ != null && _.payloadExtras) && console.warn("[ChatSessionProvider] No thread ID - message will create new thread");
|
|
3646
|
+
const he = (_ == null ? void 0 : _.attachments) || [], { contentParts: pe, filesInfo: de } = await Xg(
|
|
3643
3647
|
l,
|
|
3644
3648
|
he
|
|
3645
3649
|
), C = [...pe];
|
|
@@ -3649,29 +3653,29 @@ function wx({
|
|
|
3649
3653
|
role: "user",
|
|
3650
3654
|
content: C,
|
|
3651
3655
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3652
|
-
checkpointId: (
|
|
3653
|
-
checkpointNs: (
|
|
3656
|
+
checkpointId: (_ == null ? void 0 : _.checkpointId) ?? te.lastCheckpointId ?? void 0,
|
|
3657
|
+
checkpointNs: (_ == null ? void 0 : _.checkpointNs) ?? te.lastCheckpointNs ?? void 0
|
|
3654
3658
|
};
|
|
3655
3659
|
V($);
|
|
3656
|
-
const X = { ...$, content: C }, fe = { ...(
|
|
3657
|
-
...
|
|
3660
|
+
const X = { ...$, content: C }, fe = { ...(_ == null ? void 0 : _.payloadExtras) ?? {} }, He = he.length > 0, Ve = {
|
|
3661
|
+
...Z ? { threadId: Z } : {},
|
|
3658
3662
|
payload: {
|
|
3659
3663
|
messages: [X],
|
|
3660
3664
|
files_info: de,
|
|
3661
3665
|
...o && He && s ? { active_agent: s } : {},
|
|
3662
3666
|
...fe
|
|
3663
3667
|
},
|
|
3664
|
-
checkpointId: (
|
|
3665
|
-
checkpointNs: (
|
|
3666
|
-
nodeFilter:
|
|
3667
|
-
config:
|
|
3668
|
+
checkpointId: (_ == null ? void 0 : _.checkpointId) ?? te.lastCheckpointId ?? void 0,
|
|
3669
|
+
checkpointNs: (_ == null ? void 0 : _.checkpointNs) ?? te.lastCheckpointNs ?? void 0,
|
|
3670
|
+
nodeFilter: _ == null ? void 0 : _.nodeFilter,
|
|
3671
|
+
config: _ == null ? void 0 : _.config
|
|
3668
3672
|
};
|
|
3669
3673
|
Tt(Ve, {
|
|
3670
3674
|
onError: (je) => {
|
|
3671
3675
|
console.warn("[ChatSessionProvider] Stream error:", je);
|
|
3672
3676
|
},
|
|
3673
3677
|
onOpen: ({ threadId: je, created: wt }) => {
|
|
3674
|
-
!U.current && je && (te.messages.length <= 1 && (Xe.current = je),
|
|
3678
|
+
!U.current && je && (te.messages.length <= 1 && (Xe.current = je), A(je));
|
|
3675
3679
|
},
|
|
3676
3680
|
onGap: Ge
|
|
3677
3681
|
});
|
|
@@ -3688,12 +3692,12 @@ function wx({
|
|
|
3688
3692
|
Tt
|
|
3689
3693
|
]
|
|
3690
3694
|
), ir = De(
|
|
3691
|
-
async (k,
|
|
3695
|
+
async (k, _, Z) => {
|
|
3692
3696
|
const he = U.current;
|
|
3693
3697
|
if (!he)
|
|
3694
3698
|
throw new Error("No active thread to handle interrupt");
|
|
3695
3699
|
try {
|
|
3696
|
-
const pe =
|
|
3700
|
+
const pe = _ ? Z ?? !0 : !1;
|
|
3697
3701
|
await l.resume({ threadId: he, value: pe });
|
|
3698
3702
|
} catch (pe) {
|
|
3699
3703
|
throw console.error(`[ChatSessionProvider] Failed to handle interrupt ${k}:`, pe), pe;
|
|
@@ -3710,37 +3714,37 @@ function wx({
|
|
|
3710
3714
|
}
|
|
3711
3715
|
}, [I, a]), pt(() => ((async () => {
|
|
3712
3716
|
try {
|
|
3713
|
-
if (Je().catch((
|
|
3714
|
-
console.error("[ChatSessionProvider] Failed to refresh threads (background):",
|
|
3717
|
+
if (Je().catch((_) => {
|
|
3718
|
+
console.error("[ChatSessionProvider] Failed to refresh threads (background):", _), i == null || i(String(_));
|
|
3715
3719
|
}), !r && !t)
|
|
3716
3720
|
try {
|
|
3717
|
-
const
|
|
3718
|
-
|
|
3719
|
-
} catch (
|
|
3720
|
-
console.warn("[ChatSessionProvider] Failed to restore last thread:",
|
|
3721
|
+
const _ = localStorage.getItem("lastThreadId");
|
|
3722
|
+
_ && (A(_), n && await At(_));
|
|
3723
|
+
} catch (_) {
|
|
3724
|
+
console.warn("[ChatSessionProvider] Failed to restore last thread:", _);
|
|
3721
3725
|
}
|
|
3722
3726
|
else t && n && await At(t);
|
|
3723
|
-
} catch (
|
|
3724
|
-
console.error("[ChatSessionProvider] Initialization failed:",
|
|
3727
|
+
} catch (_) {
|
|
3728
|
+
console.error("[ChatSessionProvider] Initialization failed:", _), i == null || i(String(_));
|
|
3725
3729
|
}
|
|
3726
3730
|
})(), () => {
|
|
3727
3731
|
}), []), pt(() => {
|
|
3728
3732
|
const k = U.current;
|
|
3729
3733
|
if (!k || Te.current !== k) return;
|
|
3730
|
-
const
|
|
3734
|
+
const _ = {
|
|
3731
3735
|
threadId: k,
|
|
3732
3736
|
messages: te.messages.slice(),
|
|
3733
3737
|
hasMore: O,
|
|
3734
3738
|
nextCursor: F,
|
|
3735
3739
|
checkpointId: te.lastCheckpointId ?? null,
|
|
3736
3740
|
checkpointNs: te.lastCheckpointNs ?? null
|
|
3737
|
-
},
|
|
3738
|
-
(!
|
|
3741
|
+
}, Z = qe.current.get(k);
|
|
3742
|
+
(!Z || Z.messages.length !== _.messages.length || Z.messages.some((pe, de) => {
|
|
3739
3743
|
var C;
|
|
3740
|
-
return (pe == null ? void 0 : pe.id) !== ((C =
|
|
3741
|
-
}) || (
|
|
3744
|
+
return (pe == null ? void 0 : pe.id) !== ((C = _.messages[de]) == null ? void 0 : C.id);
|
|
3745
|
+
}) || (Z == null ? void 0 : Z.hasMore) !== _.hasMore || (Z == null ? void 0 : Z.nextCursor) !== _.nextCursor || (Z == null ? void 0 : Z.checkpointId) !== _.checkpointId || (Z == null ? void 0 : Z.checkpointNs) !== _.checkpointNs) && (qe.current.set(k, _), ne.current && window.clearTimeout(ne.current), ne.current = window.setTimeout(() => {
|
|
3742
3746
|
try {
|
|
3743
|
-
g(
|
|
3747
|
+
g(_, 100);
|
|
3744
3748
|
} catch (pe) {
|
|
3745
3749
|
console.warn("[ChatSessionProvider] Failed to persist thread payload:", pe);
|
|
3746
3750
|
}
|
|
@@ -3758,7 +3762,7 @@ function wx({
|
|
|
3758
3762
|
currentThreadId: I,
|
|
3759
3763
|
isLoadingThreads: j,
|
|
3760
3764
|
isLoadingThread: L,
|
|
3761
|
-
setCurrentThreadId:
|
|
3765
|
+
setCurrentThreadId: A,
|
|
3762
3766
|
createThread: bn,
|
|
3763
3767
|
deleteThread: or,
|
|
3764
3768
|
renameThread: yn,
|
|
@@ -3952,10 +3956,10 @@ function Sx({
|
|
|
3952
3956
|
const b = H.useCallback(
|
|
3953
3957
|
async (I) => {
|
|
3954
3958
|
I && I.preventDefault();
|
|
3955
|
-
const
|
|
3956
|
-
!
|
|
3959
|
+
const A = (h ?? "").trim();
|
|
3960
|
+
!A && !f || v(() => {
|
|
3957
3961
|
try {
|
|
3958
|
-
const j = i(
|
|
3962
|
+
const j = i(A);
|
|
3959
3963
|
j && typeof j.then == "function" ? j.then(() => {
|
|
3960
3964
|
p(""), g.current && (g.current.style.height = "auto");
|
|
3961
3965
|
}).catch(() => {
|
|
@@ -4766,7 +4770,7 @@ const qx = {
|
|
|
4766
4770
|
ke((S) => S.length > 0),
|
|
4767
4771
|
Le(v, p),
|
|
4768
4772
|
se(([S, T, E]) => {
|
|
4769
|
-
const I = S.reduce((
|
|
4773
|
+
const I = S.reduce((A, j, D) => Pt(A, j, Wr(j, T.offsetTree, E) || D), hr());
|
|
4770
4774
|
return {
|
|
4771
4775
|
...T,
|
|
4772
4776
|
groupIndices: S,
|
|
@@ -4850,7 +4854,7 @@ const qx = {
|
|
|
4850
4854
|
s,
|
|
4851
4855
|
Le(v),
|
|
4852
4856
|
se(([S, T]) => {
|
|
4853
|
-
const E = T.groupIndices.length > 0, I = [],
|
|
4857
|
+
const E = T.groupIndices.length > 0, I = [], A = T.lastSize;
|
|
4854
4858
|
if (E) {
|
|
4855
4859
|
const j = Hr(T.sizeTree, 0);
|
|
4856
4860
|
let D = 0, L = 0;
|
|
@@ -4862,7 +4866,7 @@ const qx = {
|
|
|
4862
4866
|
startIndex: O
|
|
4863
4867
|
}), I.push({
|
|
4864
4868
|
endIndex: O + 1 + K - 1,
|
|
4865
|
-
size:
|
|
4869
|
+
size: A,
|
|
4866
4870
|
startIndex: O + 1
|
|
4867
4871
|
}), L++, D += K + 1;
|
|
4868
4872
|
}
|
|
@@ -4898,7 +4902,7 @@ const qx = {
|
|
|
4898
4902
|
}),
|
|
4899
4903
|
{
|
|
4900
4904
|
prevIndex: 0,
|
|
4901
|
-
prevSize:
|
|
4905
|
+
prevSize: A,
|
|
4902
4906
|
ranges: []
|
|
4903
4907
|
}
|
|
4904
4908
|
).ranges;
|
|
@@ -4925,11 +4929,11 @@ const qx = {
|
|
|
4925
4929
|
if (tt(T.sizeTree))
|
|
4926
4930
|
return T;
|
|
4927
4931
|
let I = hr();
|
|
4928
|
-
const
|
|
4932
|
+
const A = ut(g);
|
|
4929
4933
|
let j = 0, D = 0, L = 0;
|
|
4930
4934
|
for (; j < -S; ) {
|
|
4931
|
-
L =
|
|
4932
|
-
const z =
|
|
4935
|
+
L = A[D];
|
|
4936
|
+
const z = A[D + 1] - L - 1;
|
|
4933
4937
|
D++, j += z + 1;
|
|
4934
4938
|
}
|
|
4935
4939
|
if (I = zn(T.sizeTree).reduce((z, { k: O, v: K }) => Pt(z, Math.max(0, O + S), K), I), j !== -S) {
|
|
@@ -4944,7 +4948,7 @@ const qx = {
|
|
|
4944
4948
|
...ki(T.offsetTree, 0, I, E)
|
|
4945
4949
|
};
|
|
4946
4950
|
} else {
|
|
4947
|
-
const I = zn(T.sizeTree).reduce((
|
|
4951
|
+
const I = zn(T.sizeTree).reduce((A, { k: j, v: D }) => Pt(A, Math.max(0, j + S), D), hr());
|
|
4948
4952
|
return {
|
|
4949
4953
|
...T,
|
|
4950
4954
|
sizeTree: I,
|
|
@@ -5062,14 +5066,14 @@ const no = Ye(
|
|
|
5062
5066
|
Le(e, s, o),
|
|
5063
5067
|
se(
|
|
5064
5068
|
([
|
|
5065
|
-
[R, S, T, E, I,
|
|
5069
|
+
[R, S, T, E, I, A, j, D],
|
|
5066
5070
|
L,
|
|
5067
5071
|
z,
|
|
5068
5072
|
O
|
|
5069
5073
|
]) => {
|
|
5070
5074
|
const K = Iu(R), { align: W, behavior: G, offset: F } = K, N = E - 1, q = Eu(K, S, N);
|
|
5071
|
-
let
|
|
5072
|
-
W === "end" ? (
|
|
5075
|
+
let Q = Wr(q, S.offsetTree, L) + A;
|
|
5076
|
+
W === "end" ? (Q += z + Gt(S.sizeTree, q)[1] - T + O, q === N && (Q += j)) : W === "center" ? Q += (z + Gt(S.sizeTree, q)[1] - T + O) / 2 : Q -= I, F && (Q += F);
|
|
5073
5077
|
const ge = (ce) => {
|
|
5074
5078
|
y(), ce ? (D("retrying to scroll to", { location: R }, Nt.DEBUG), Oe(p, R)) : (Oe(w, !0), D("list did not change, scroll successful", {}, Nt.DEBUG));
|
|
5075
5079
|
};
|
|
@@ -5084,7 +5088,7 @@ const no = Ye(
|
|
|
5084
5088
|
g = qt(B(t, Xx(150)), ge);
|
|
5085
5089
|
return x = setTimeout(() => {
|
|
5086
5090
|
y();
|
|
5087
|
-
}, 1200), Oe(l, !0), D("scrolling from index to", { behavior: G, index: q, top:
|
|
5091
|
+
}, 1200), Oe(l, !0), D("scrolling from index to", { behavior: G, index: q, top: Q }, Nt.DEBUG), { behavior: G, top: Q };
|
|
5088
5092
|
}
|
|
5089
5093
|
)
|
|
5090
5094
|
),
|
|
@@ -5196,12 +5200,12 @@ const Vr = "up", Or = "down", Jx = "none", Zx = {
|
|
|
5196
5200
|
B(
|
|
5197
5201
|
mt(r, Ee(s), Ee(t), Ee(e), Ee(d)),
|
|
5198
5202
|
nn((b, [{ scrollHeight: y, scrollTop: R }, S, T, E, I]) => {
|
|
5199
|
-
const
|
|
5203
|
+
const A = R + S - y > -I, j = {
|
|
5200
5204
|
scrollHeight: y,
|
|
5201
5205
|
scrollTop: R,
|
|
5202
5206
|
viewportHeight: S
|
|
5203
5207
|
};
|
|
5204
|
-
if (
|
|
5208
|
+
if (A) {
|
|
5205
5209
|
let L, z;
|
|
5206
5210
|
return R > b.state.scrollTop ? (L = "SCROLLED_DOWN", z = b.state.scrollTop - R) : (L = "SIZE_DECREASED", z = b.state.scrollTop - R || b.scrollTopDelta), {
|
|
5207
5211
|
atBottom: !0,
|
|
@@ -5342,10 +5346,10 @@ const ia = Ye(
|
|
|
5342
5346
|
]) => {
|
|
5343
5347
|
const R = d - b, S = g + x, T = Math.max(h - R, 0);
|
|
5344
5348
|
let E = Il;
|
|
5345
|
-
const I = Al(y, $o),
|
|
5346
|
-
return p -= b, p += h + x, w += h + x, w -= b, p > d + S - I && (E = Vr), w < d - T + f +
|
|
5349
|
+
const I = Al(y, $o), A = Al(y, Fo);
|
|
5350
|
+
return p -= b, p += h + x, w += h + x, w -= b, p > d + S - I && (E = Vr), w < d - T + f + A && (E = Or), E !== Il ? [
|
|
5347
5351
|
Math.max(R - h - Nl(v, $o, E) - I, 0),
|
|
5348
|
-
R - T - x + f + Nl(v, Fo, E) +
|
|
5352
|
+
R - T - x + f + Nl(v, Fo, E) + A
|
|
5349
5353
|
] : null;
|
|
5350
5354
|
}
|
|
5351
5355
|
),
|
|
@@ -5479,8 +5483,8 @@ const Qn = Ye(
|
|
|
5479
5483
|
Ee(n),
|
|
5480
5484
|
e
|
|
5481
5485
|
),
|
|
5482
|
-
ke(([T, E, , I, , , , , , ,
|
|
5483
|
-
const j =
|
|
5486
|
+
ke(([T, E, , I, , , , , , , A]) => {
|
|
5487
|
+
const j = A && A.length !== I;
|
|
5484
5488
|
return T && !E && !j;
|
|
5485
5489
|
}),
|
|
5486
5490
|
se(
|
|
@@ -5489,7 +5493,7 @@ const Qn = Ye(
|
|
|
5489
5493
|
,
|
|
5490
5494
|
[T, E],
|
|
5491
5495
|
I,
|
|
5492
|
-
|
|
5496
|
+
A,
|
|
5493
5497
|
j,
|
|
5494
5498
|
D,
|
|
5495
5499
|
L,
|
|
@@ -5497,11 +5501,11 @@ const Qn = Ye(
|
|
|
5497
5501
|
O,
|
|
5498
5502
|
K
|
|
5499
5503
|
]) => {
|
|
5500
|
-
const W =
|
|
5504
|
+
const W = A, { offsetTree: G, sizeTree: F } = W, N = ut(g);
|
|
5501
5505
|
if (I === 0)
|
|
5502
5506
|
return { ...Ys, totalCount: I };
|
|
5503
5507
|
if (T === 0 && E === 0)
|
|
5504
|
-
return N === 0 ? { ...Ys, totalCount: I } : Au(N, j,
|
|
5508
|
+
return N === 0 ? { ...Ys, totalCount: I } : Au(N, j, A, z, O, K || []);
|
|
5505
5509
|
if (tt(F))
|
|
5506
5510
|
return N > 0 ? null : Ro(
|
|
5507
5511
|
ev(sa(j, I), W, K),
|
|
@@ -5523,7 +5527,7 @@ const Qn = Ye(
|
|
|
5523
5527
|
}
|
|
5524
5528
|
if (!D)
|
|
5525
5529
|
return Ro([], q, I, O, W, z);
|
|
5526
|
-
const
|
|
5530
|
+
const Q = L.length > 0 ? L[L.length - 1] + 1 : 0, ge = Hx(G, T, E, Q);
|
|
5527
5531
|
if (ge.length === 0)
|
|
5528
5532
|
return null;
|
|
5529
5533
|
const ce = I - 1, te = cs([], (Ae) => {
|
|
@@ -5536,7 +5540,7 @@ const Qn = Ye(
|
|
|
5536
5540
|
const ae = J - Ce.start;
|
|
5537
5541
|
M += ae * U + ae * O;
|
|
5538
5542
|
}
|
|
5539
|
-
J <
|
|
5543
|
+
J < Q && (M += (Q - J) * U, J = Q);
|
|
5540
5544
|
const ue = Math.min(Ce.end, ce);
|
|
5541
5545
|
for (let ae = J; ae <= ue && !(M >= E); ae++)
|
|
5542
5546
|
Ae.push({ data: K == null ? void 0 : K[ae], index: ae, offset: M, size: U }), M += U + O;
|
|
@@ -5676,7 +5680,7 @@ const Qn = Ye(
|
|
|
5676
5680
|
Le(t, l, n, s, o, r, a),
|
|
5677
5681
|
Le(e),
|
|
5678
5682
|
se(([[f, h, p, w, v, g, x, b], y]) => {
|
|
5679
|
-
const { align: R, behavior: S, calculateViewLocation: T = nv, done: E, ...I } = f,
|
|
5683
|
+
const { align: R, behavior: S, calculateViewLocation: T = nv, done: E, ...I } = f, A = Eu(f, h, w - 1), j = Wr(A, h.offsetTree, y) + v + g, D = j + Gt(h.sizeTree, A)[1], L = b + g, z = b + p - x, O = T({
|
|
5680
5684
|
itemBottom: D,
|
|
5681
5685
|
itemTop: j,
|
|
5682
5686
|
locationParams: { align: R, behavior: S, ...I },
|
|
@@ -5732,8 +5736,8 @@ const rv = (e, t) => typeof e == "function" ? jl(e(t)) : t && jl(e), ov = Ye(
|
|
|
5732
5736
|
B(
|
|
5733
5737
|
mt(B(Ee(t), Kn(1)), l),
|
|
5734
5738
|
Le(Ee(w), s, a, f),
|
|
5735
|
-
se(([[S, T], E, I,
|
|
5736
|
-
let D = T &&
|
|
5739
|
+
se(([[S, T], E, I, A, j]) => {
|
|
5740
|
+
let D = T && A, L = "auto";
|
|
5737
5741
|
return D && (L = rv(E, I || j), D = D && !!L), { followOutputBehavior: L, shouldFollow: D, totalCount: S };
|
|
5738
5742
|
}),
|
|
5739
5743
|
ke(({ shouldFollow: S }) => S)
|
|
@@ -5788,7 +5792,7 @@ const rv = (e, t) => typeof e == "function" ? jl(e(t)) : t && jl(e), ov = Ye(
|
|
|
5788
5792
|
B(
|
|
5789
5793
|
mt(B(R, Kn(1)), l),
|
|
5790
5794
|
Le(Ee(y), a, f, h),
|
|
5791
|
-
se(([[S, T], E, I,
|
|
5795
|
+
se(([[S, T], E, I, A, j]) => T && I && (E == null ? void 0 : E({ context: j, totalCount: S, scrollingInProgress: A }))),
|
|
5792
5796
|
ke((S) => !!S),
|
|
5793
5797
|
pn(0)
|
|
5794
5798
|
),
|
|
@@ -5983,9 +5987,9 @@ const uv = Mu(() => /iP(ad|od|hone)/i.test(navigator.userAgent) && /WebKit/i.tes
|
|
|
5983
5987
|
Le(i),
|
|
5984
5988
|
nn(
|
|
5985
5989
|
([, x, b, y], [{ bottom: R, items: S, offsetBottom: T, totalCount: E }, I]) => {
|
|
5986
|
-
const
|
|
5990
|
+
const A = R + T;
|
|
5987
5991
|
let j = 0;
|
|
5988
|
-
return b === E && x.length > 0 && S.length > 0 && (S[0].originalIndex === 0 && x[0].originalIndex === 0 || (j =
|
|
5992
|
+
return b === E && x.length > 0 && S.length > 0 && (S[0].originalIndex === 0 && x[0].originalIndex === 0 || (j = A - y, j !== 0 && (j += I))), [j, S, E, A];
|
|
5989
5993
|
},
|
|
5990
5994
|
[0, [], 0, 0]
|
|
5991
5995
|
),
|
|
@@ -6027,11 +6031,11 @@ const uv = Mu(() => /iP(ad|od|hone)/i.test(navigator.userAgent) && /WebKit/i.tes
|
|
|
6027
6031
|
{
|
|
6028
6032
|
let E = 0;
|
|
6029
6033
|
const I = Hr(R, 0);
|
|
6030
|
-
let
|
|
6031
|
-
for (;
|
|
6032
|
-
|
|
6034
|
+
let A = 0, j = 0;
|
|
6035
|
+
for (; A < x; ) {
|
|
6036
|
+
A++, E += I;
|
|
6033
6037
|
let D = b.length === j + 1 ? 1 / 0 : b[j + 1] - b[j] - 1;
|
|
6034
|
-
|
|
6038
|
+
A + D > x && (E -= I, D = x - A + 1), A += D, E += T(D), j++;
|
|
6035
6039
|
}
|
|
6036
6040
|
return E;
|
|
6037
6041
|
}
|
|
@@ -6111,10 +6115,10 @@ const uv = Mu(() => /iP(ad|od|hone)/i.test(navigator.userAgent) && /WebKit/i.tes
|
|
|
6111
6115
|
T,
|
|
6112
6116
|
{ topItemCount: E },
|
|
6113
6117
|
{ groupCounts: I },
|
|
6114
|
-
|
|
6115
|
-
]) => (me(R.rangeChanged,
|
|
6118
|
+
A
|
|
6119
|
+
]) => (me(R.rangeChanged, A.scrollSeekRangeChanged), me(
|
|
6116
6120
|
B(
|
|
6117
|
-
|
|
6121
|
+
A.windowViewportRect,
|
|
6118
6122
|
se((j) => j.visibleHeight)
|
|
6119
6123
|
),
|
|
6120
6124
|
v.viewportHeight
|
|
@@ -6144,7 +6148,7 @@ const uv = Mu(() => /iP(ad|od|hone)/i.test(navigator.userAgent) && /WebKit/i.tes
|
|
|
6144
6148
|
// exported from stateFlagsSystem
|
|
6145
6149
|
...R,
|
|
6146
6150
|
// the bag of IO from featureGroup1System
|
|
6147
|
-
...
|
|
6151
|
+
...A,
|
|
6148
6152
|
...v,
|
|
6149
6153
|
sizes: l,
|
|
6150
6154
|
...g
|
|
@@ -6361,7 +6365,7 @@ const mv = /* @__PURE__ */ Ye(() => {
|
|
|
6361
6365
|
ua("deviation", (O) => {
|
|
6362
6366
|
x !== O && b(O);
|
|
6363
6367
|
});
|
|
6364
|
-
const y = _e("EmptyPlaceholder"), R = _e("ScrollSeekPlaceholder") || xv, S = _e("ListComponent"), T = _e("ItemComponent"), E = _e("GroupComponent"), I = _e("computeItemKey"),
|
|
6368
|
+
const y = _e("EmptyPlaceholder"), R = _e("ScrollSeekPlaceholder") || xv, S = _e("ListComponent"), T = _e("ItemComponent"), E = _e("GroupComponent"), I = _e("computeItemKey"), A = _e("isSeeking"), j = _e("groupIndices").length > 0, D = _e("alignToBottom"), L = _e("initialItemFinalLocationReached"), z = e ? {} : {
|
|
6365
6369
|
boxSizing: "border-box",
|
|
6366
6370
|
...v ? {
|
|
6367
6371
|
display: "inline-block",
|
|
@@ -6386,7 +6390,7 @@ const mv = /* @__PURE__ */ Ye(() => {
|
|
|
6386
6390
|
style: z,
|
|
6387
6391
|
children: (e ? t.topItems : t.items).map((O) => {
|
|
6388
6392
|
const K = O.originalIndex, W = I(K + t.firstItemIndex, O.data, u);
|
|
6389
|
-
return
|
|
6393
|
+
return A ? /* @__PURE__ */ bo(
|
|
6390
6394
|
R,
|
|
6391
6395
|
{
|
|
6392
6396
|
...St(R, u),
|
|
@@ -6704,7 +6708,7 @@ const $v = /* @__PURE__ */ Ye(
|
|
|
6704
6708
|
{ customScrollParent: g, useWindowScroll: x, windowScrollContainerState: b, windowScrollTo: y, windowViewportRect: R },
|
|
6705
6709
|
S
|
|
6706
6710
|
]) => {
|
|
6707
|
-
const T = Y(0), E = Y(0), I = Y(Ml),
|
|
6711
|
+
const T = Y(0), E = Y(0), I = Y(Ml), A = Y({ height: 0, width: 0 }), j = Y({ height: 0, width: 0 }), D = We(), L = We(), z = Y(0), O = Y(null), K = Y({ column: 0, row: 0 }), W = We(), G = We(), F = Y(!1), N = Y(0), q = Y(!0), Q = Y(!1), ge = Y(!1);
|
|
6708
6712
|
Qe(
|
|
6709
6713
|
B(
|
|
6710
6714
|
w,
|
|
@@ -6716,11 +6720,11 @@ const $v = /* @__PURE__ */ Ye(
|
|
|
6716
6720
|
}
|
|
6717
6721
|
), Qe(
|
|
6718
6722
|
B(
|
|
6719
|
-
mt(w, q, j,
|
|
6723
|
+
mt(w, q, j, A, N, Q),
|
|
6720
6724
|
ke(([M, J, U, ue, , ae]) => M && !J && U.height !== 0 && ue.height !== 0 && !ae)
|
|
6721
6725
|
),
|
|
6722
6726
|
([, , , , M]) => {
|
|
6723
|
-
Oe(
|
|
6727
|
+
Oe(Q, !0), oa(1, () => {
|
|
6724
6728
|
Oe(D, M);
|
|
6725
6729
|
}), qt(B(u), () => {
|
|
6726
6730
|
Oe(t, [0, 0]), Oe(q, !0);
|
|
@@ -6740,20 +6744,20 @@ const $v = /* @__PURE__ */ Ye(
|
|
|
6740
6744
|
ke(([, M]) => M != null)
|
|
6741
6745
|
),
|
|
6742
6746
|
([, M]) => {
|
|
6743
|
-
M && (Oe(
|
|
6747
|
+
M && (Oe(A, M.viewport), Oe(j, M.item), Oe(K, M.gap), M.scrollTop > 0 && (Oe(F, !0), qt(B(u, Kn(1)), (J) => {
|
|
6744
6748
|
Oe(F, !1);
|
|
6745
6749
|
}), Oe(l, { top: M.scrollTop })));
|
|
6746
6750
|
}
|
|
6747
6751
|
), me(
|
|
6748
6752
|
B(
|
|
6749
|
-
|
|
6753
|
+
A,
|
|
6750
6754
|
se(({ height: M }) => M)
|
|
6751
6755
|
),
|
|
6752
6756
|
f
|
|
6753
6757
|
), me(
|
|
6754
6758
|
B(
|
|
6755
6759
|
mt(
|
|
6756
|
-
Ee(
|
|
6760
|
+
Ee(A, fo),
|
|
6757
6761
|
Ee(j, fo),
|
|
6758
6762
|
Ee(K, (M, J) => M && M.column === J.column && M.row === J.row),
|
|
6759
6763
|
Ee(u)
|
|
@@ -6773,7 +6777,7 @@ const $v = /* @__PURE__ */ Ye(
|
|
|
6773
6777
|
r,
|
|
6774
6778
|
Ee(K, Lv),
|
|
6775
6779
|
Ee(j, fo),
|
|
6776
|
-
Ee(
|
|
6780
|
+
Ee(A, fo),
|
|
6777
6781
|
Ee(O),
|
|
6778
6782
|
Ee(E),
|
|
6779
6783
|
Ee(F),
|
|
@@ -6819,7 +6823,7 @@ const $v = /* @__PURE__ */ Ye(
|
|
|
6819
6823
|
T
|
|
6820
6824
|
), me(
|
|
6821
6825
|
B(
|
|
6822
|
-
mt(
|
|
6826
|
+
mt(A, j, I, K),
|
|
6823
6827
|
ke(([M, J, { items: U }]) => U.length > 0 && J.height !== 0 && M.height !== 0),
|
|
6824
6828
|
se(([M, J, { items: U }, ue]) => {
|
|
6825
6829
|
const { bottom: ae, top: Be } = Fl(M, ue, J, U);
|
|
@@ -6873,7 +6877,7 @@ const $v = /* @__PURE__ */ Ye(
|
|
|
6873
6877
|
me(Ce, p.scrollSeekRangeChanged), me(
|
|
6874
6878
|
B(
|
|
6875
6879
|
D,
|
|
6876
|
-
Le(
|
|
6880
|
+
Le(A, j, T, K),
|
|
6877
6881
|
se(([M, J, U, ue, ae]) => {
|
|
6878
6882
|
const Be = Iu(M), { align: Xe, behavior: qe, offset: Te } = Be;
|
|
6879
6883
|
let Me = Be.index;
|
|
@@ -6896,7 +6900,7 @@ const $v = /* @__PURE__ */ Ye(
|
|
|
6896
6900
|
R,
|
|
6897
6901
|
se((M) => ({ height: M.visibleHeight, width: M.visibleWidth }))
|
|
6898
6902
|
),
|
|
6899
|
-
|
|
6903
|
+
A
|
|
6900
6904
|
), {
|
|
6901
6905
|
customScrollParent: g,
|
|
6902
6906
|
// input
|
|
@@ -6919,7 +6923,7 @@ const $v = /* @__PURE__ */ Ye(
|
|
|
6919
6923
|
smoothScrollTargetReached: d,
|
|
6920
6924
|
totalCount: T,
|
|
6921
6925
|
useWindowScroll: x,
|
|
6922
|
-
viewportDimensions:
|
|
6926
|
+
viewportDimensions: A,
|
|
6923
6927
|
windowScrollContainerState: b,
|
|
6924
6928
|
windowScrollTo: y,
|
|
6925
6929
|
windowViewportRect: R,
|
|
@@ -9285,8 +9289,8 @@ var Lw = "DismissableLayer", Ai = "dismissableLayer.update", $w = "dismissableLa
|
|
|
9285
9289
|
onDismiss: a,
|
|
9286
9290
|
...l
|
|
9287
9291
|
} = e, u = m.useContext(ad), [d, f] = m.useState(null), h = (d == null ? void 0 : d.ownerDocument) ?? (globalThis == null ? void 0 : globalThis.document), [, p] = m.useState({}), w = Ue(t, (E) => f(E)), v = Array.from(u.layers), [g] = [...u.layersWithOutsidePointerEventsDisabled].slice(-1), x = v.indexOf(g), b = d ? v.indexOf(d) : -1, y = u.layersWithOutsidePointerEventsDisabled.size > 0, R = b >= x, S = Hw((E) => {
|
|
9288
|
-
const I = E.target,
|
|
9289
|
-
!R ||
|
|
9292
|
+
const I = E.target, A = [...u.branches].some((j) => j.contains(I));
|
|
9293
|
+
!R || A || (o == null || o(E), i == null || i(E), E.defaultPrevented || a == null || a());
|
|
9290
9294
|
}, h), T = Uw((E) => {
|
|
9291
9295
|
const I = E.target;
|
|
9292
9296
|
[...u.branches].some((j) => j.contains(I)) || (s == null || s(E), i == null || i(E), E.defaultPrevented || a == null || a());
|
|
@@ -9946,8 +9950,8 @@ function _b(e) {
|
|
|
9946
9950
|
return !1;
|
|
9947
9951
|
if (!r.current && "changedTouches" in v && (y || R) && (r.current = S), !S)
|
|
9948
9952
|
return !0;
|
|
9949
|
-
var
|
|
9950
|
-
return kb(
|
|
9953
|
+
var A = r.current || S;
|
|
9954
|
+
return kb(A, g, v, A === "h" ? y : R);
|
|
9951
9955
|
}, []), l = m.useCallback(function(v) {
|
|
9952
9956
|
var g = v;
|
|
9953
9957
|
if (!(!cr.length || cr[cr.length - 1] !== s)) {
|
|
@@ -10666,7 +10670,7 @@ const oy = H.memo(function({
|
|
|
10666
10670
|
onCancelEdit: g,
|
|
10667
10671
|
onCopy: x
|
|
10668
10672
|
}) {
|
|
10669
|
-
const [b, y] = ve(!1), [R, S] = ve("collapsed"), [T, E] = ve(!1), { currentThreadId: I } = Zi(), { handleInterrupt:
|
|
10673
|
+
const [b, y] = ve(!1), [R, S] = ve("collapsed"), [T, E] = ve(!1), { currentThreadId: I } = Zi(), { handleInterrupt: A } = fu(), { toast: j } = xa(), [D, L] = ve({}), [z, O] = ve(!1), [K, W] = ve(null), G = l === "phone" || l === "half-screen", F = t.role, N = F === "tool", q = !(r && F !== "user"), Q = H.useMemo(() => {
|
|
10670
10674
|
switch (F) {
|
|
10671
10675
|
case "user":
|
|
10672
10676
|
return "text-[hsl(var(--chat-bubble-user-text))]";
|
|
@@ -10766,7 +10770,7 @@ const oy = H.memo(function({
|
|
|
10766
10770
|
console.error("File click error:", Re), L((Se) => ({ ...Se, [xe]: !1 }));
|
|
10767
10771
|
}
|
|
10768
10772
|
}, [q, D, j, I]), Be = H.useCallback(() => {
|
|
10769
|
-
const re = ee(G ? "h-3 w-3" : "h-4 w-4", "opacity-60 flex-shrink-0",
|
|
10773
|
+
const re = ee(G ? "h-3 w-3" : "h-4 w-4", "opacity-60 flex-shrink-0", Q);
|
|
10770
10774
|
switch (F) {
|
|
10771
10775
|
case "user":
|
|
10772
10776
|
return /* @__PURE__ */ c.jsx(qp, { className: re });
|
|
@@ -10777,7 +10781,7 @@ const oy = H.memo(function({
|
|
|
10777
10781
|
default:
|
|
10778
10782
|
return /* @__PURE__ */ c.jsx(qa, { className: re });
|
|
10779
10783
|
}
|
|
10780
|
-
}, [G,
|
|
10784
|
+
}, [G, Q, F]), Xe = H.useCallback(() => {
|
|
10781
10785
|
const ne = "group relative mb-4 flex w-full";
|
|
10782
10786
|
switch (F) {
|
|
10783
10787
|
case "user":
|
|
@@ -10824,18 +10828,18 @@ const oy = H.memo(function({
|
|
|
10824
10828
|
}, [G, F]), Te = H.useCallback(async (ne) => {
|
|
10825
10829
|
try {
|
|
10826
10830
|
const re = ne.id || `interrupt-${Date.now()}`;
|
|
10827
|
-
await
|
|
10831
|
+
await A(re, !0);
|
|
10828
10832
|
} catch (re) {
|
|
10829
10833
|
console.error("Failed to approve interrupt:", re);
|
|
10830
10834
|
}
|
|
10831
|
-
}, [
|
|
10835
|
+
}, [A]), Me = H.useCallback(async (ne) => {
|
|
10832
10836
|
try {
|
|
10833
10837
|
const re = ne.id || `interrupt-${Date.now()}`;
|
|
10834
|
-
await
|
|
10838
|
+
await A(re, !1);
|
|
10835
10839
|
} catch (re) {
|
|
10836
10840
|
console.error("Failed to reject interrupt:", re);
|
|
10837
10841
|
}
|
|
10838
|
-
}, [
|
|
10842
|
+
}, [A]), rt = H.useCallback(({ part: ne, i: re }) => {
|
|
10839
10843
|
if (ne.type === "text") {
|
|
10840
10844
|
const xe = ne.text ?? "", Re = xe.trim(), Se = dc(Re);
|
|
10841
10845
|
return Se && F !== "tool" ? /* @__PURE__ */ c.jsx(sy, { data: Se }, re) : F === "user" && f && Re.length > h ? /* @__PURE__ */ c.jsxs(Hl, { open: T, onOpenChange: E, children: [
|
|
@@ -10953,7 +10957,7 @@ const oy = H.memo(function({
|
|
|
10953
10957
|
const re = /* @__PURE__ */ c.jsx("div", { className: "space-y-2", children: t.content.map((xe, Re) => /* @__PURE__ */ c.jsx(rt, { part: xe, i: Re }, Re)) });
|
|
10954
10958
|
return r ? /* @__PURE__ */ c.jsxs("div", { "aria-busy": "true", role: "status", children: [
|
|
10955
10959
|
re,
|
|
10956
|
-
/* @__PURE__ */ c.jsx(ry, { className:
|
|
10960
|
+
/* @__PURE__ */ c.jsx(ry, { className: Q })
|
|
10957
10961
|
] }) : re;
|
|
10958
10962
|
}
|
|
10959
10963
|
}, [
|
|
@@ -10969,7 +10973,7 @@ const oy = H.memo(function({
|
|
|
10969
10973
|
R,
|
|
10970
10974
|
u,
|
|
10971
10975
|
ze,
|
|
10972
|
-
|
|
10976
|
+
Q
|
|
10973
10977
|
]), ft = lt(() => ny(t), [t]);
|
|
10974
10978
|
return /* @__PURE__ */ c.jsxs(c.Fragment, { children: [
|
|
10975
10979
|
/* @__PURE__ */ c.jsx("div", { className: ee(Xe(), p.container), children: /* @__PURE__ */ c.jsxs("div", { className: ee(qe(), p.content), children: [
|
|
@@ -10979,7 +10983,7 @@ const oy = H.memo(function({
|
|
|
10979
10983
|
className: ee(
|
|
10980
10984
|
"flex items-center justify-between mb-2 pb-2 border-b border-current/10",
|
|
10981
10985
|
G && "mb-1 pb-1",
|
|
10982
|
-
|
|
10986
|
+
Q,
|
|
10983
10987
|
p.header
|
|
10984
10988
|
),
|
|
10985
10989
|
children: [
|
|
@@ -10992,7 +10996,7 @@ const oy = H.memo(function({
|
|
|
10992
10996
|
variant: "outline",
|
|
10993
10997
|
className: ee(
|
|
10994
10998
|
"text-xs flex items-center gap-1 cursor-pointer",
|
|
10995
|
-
|
|
10999
|
+
Q,
|
|
10996
11000
|
"border border-current/40",
|
|
10997
11001
|
G && "text-xs h-4"
|
|
10998
11002
|
),
|
|
@@ -11014,7 +11018,7 @@ const oy = H.memo(function({
|
|
|
11014
11018
|
{
|
|
11015
11019
|
variant: "ghost",
|
|
11016
11020
|
size: "sm",
|
|
11017
|
-
className: ee("h-6 px-1",
|
|
11021
|
+
className: ee("h-6 px-1", Q, "hover:bg-foreground/10"),
|
|
11018
11022
|
onClick: () => S((ne) => ne === "collapsed" ? "preview" : "collapsed"),
|
|
11019
11023
|
children: /* @__PURE__ */ c.jsxs("span", { className: "text-xs flex items-center gap-1", children: [
|
|
11020
11024
|
"Tool Output ",
|
|
@@ -11027,7 +11031,7 @@ const oy = H.memo(function({
|
|
|
11027
11031
|
i && t.createdAt && /* @__PURE__ */ c.jsx(
|
|
11028
11032
|
"time",
|
|
11029
11033
|
{
|
|
11030
|
-
className: ee("text-xs opacity-60",
|
|
11034
|
+
className: ee("text-xs opacity-60", Q, G && "text-xs"),
|
|
11031
11035
|
dateTime: new Date(t.createdAt).toISOString(),
|
|
11032
11036
|
title: new Date(t.createdAt).toLocaleString(),
|
|
11033
11037
|
children: new Intl.DateTimeFormat(void 0, { hour: "2-digit", minute: "2-digit" }).format(new Date(t.createdAt))
|
|
@@ -11049,10 +11053,10 @@ const oy = H.memo(function({
|
|
|
11049
11053
|
variant: "ghost",
|
|
11050
11054
|
size: "sm",
|
|
11051
11055
|
onClick: () => J(N ? "visible" : "all"),
|
|
11052
|
-
className: ee("h-6 w-6 p-0 hover:bg-foreground/10",
|
|
11056
|
+
className: ee("h-6 w-6 p-0 hover:bg-foreground/10", Q, G && "h-5 w-5"),
|
|
11053
11057
|
"aria-label": N ? "Copy visible" : "Copy message",
|
|
11054
11058
|
title: N ? "Copy visible portion" : "Copy message",
|
|
11055
|
-
children: /* @__PURE__ */ c.jsx(Ga, { className: ee(b ? "text-success" :
|
|
11059
|
+
children: /* @__PURE__ */ c.jsx(Ga, { className: ee(b ? "text-success" : Q, G ? "h-3 w-3" : "h-4 w-4") })
|
|
11056
11060
|
}
|
|
11057
11061
|
),
|
|
11058
11062
|
N && /* @__PURE__ */ c.jsx(
|
|
@@ -11061,7 +11065,7 @@ const oy = H.memo(function({
|
|
|
11061
11065
|
variant: "ghost",
|
|
11062
11066
|
size: "sm",
|
|
11063
11067
|
onClick: () => J("all"),
|
|
11064
|
-
className: ee("h-6 px-1 text-xs hover:bg-foreground/10",
|
|
11068
|
+
className: ee("h-6 px-1 text-xs hover:bg-foreground/10", Q),
|
|
11065
11069
|
"aria-label": "Copy all (may be large)",
|
|
11066
11070
|
title: "Copy all (may be large)",
|
|
11067
11071
|
children: "all"
|
|
@@ -11074,9 +11078,9 @@ const oy = H.memo(function({
|
|
|
11074
11078
|
variant: "ghost",
|
|
11075
11079
|
size: "sm",
|
|
11076
11080
|
onClick: U,
|
|
11077
|
-
className: ee("h-6 w-6 p-0 hover:bg-foreground/10",
|
|
11081
|
+
className: ee("h-6 w-6 p-0 hover:bg-foreground/10", Q, G && "h-5 w-5"),
|
|
11078
11082
|
"aria-label": "Edit message",
|
|
11079
|
-
children: /* @__PURE__ */ c.jsx(Ya, { className: ee(
|
|
11083
|
+
children: /* @__PURE__ */ c.jsx(Ya, { className: ee(Q, G ? "h-3 w-3" : "h-4 w-4") })
|
|
11080
11084
|
}
|
|
11081
11085
|
),
|
|
11082
11086
|
F === "assistant" && v && /* @__PURE__ */ c.jsx(
|
|
@@ -11085,9 +11089,9 @@ const oy = H.memo(function({
|
|
|
11085
11089
|
variant: "ghost",
|
|
11086
11090
|
size: "sm",
|
|
11087
11091
|
onClick: ue,
|
|
11088
|
-
className: ee("h-6 w-6 p-0 hover:bg-foreground/10",
|
|
11092
|
+
className: ee("h-6 w-6 p-0 hover:bg-foreground/10", Q, G && "h-5 w-5"),
|
|
11089
11093
|
"aria-label": "Regenerate response",
|
|
11090
|
-
children: /* @__PURE__ */ c.jsx(hi, { className: ee(
|
|
11094
|
+
children: /* @__PURE__ */ c.jsx(hi, { className: ee(Q, G ? "h-3 w-3" : "h-4 w-4") })
|
|
11091
11095
|
}
|
|
11092
11096
|
)
|
|
11093
11097
|
]
|
|
@@ -11315,7 +11319,7 @@ const hc = (e, t) => (e == null ? void 0 : e.id) ?? `message-${t}`, Ud = H.forwa
|
|
|
11315
11319
|
}, b) => {
|
|
11316
11320
|
const y = et(null), R = et(null), S = et(!1), [T, E] = ve(!0), I = De((D) => {
|
|
11317
11321
|
E(D), g && g(!D), x && x(D);
|
|
11318
|
-
}, [g, x]),
|
|
11322
|
+
}, [g, x]), A = lt(() => {
|
|
11319
11323
|
if (a)
|
|
11320
11324
|
return async () => {
|
|
11321
11325
|
if (!S.current) {
|
|
@@ -11345,7 +11349,7 @@ const hc = (e, t) => (e == null ? void 0 : e.id) ?? `message-${t}`, Ud = H.forwa
|
|
|
11345
11349
|
atBottomThreshold: 50,
|
|
11346
11350
|
alignToBottom: !1,
|
|
11347
11351
|
startReached: () => {
|
|
11348
|
-
|
|
11352
|
+
A && A();
|
|
11349
11353
|
},
|
|
11350
11354
|
atBottomStateChange: I,
|
|
11351
11355
|
style: { height: "100%", overscrollBehavior: "contain" },
|
|
@@ -11755,7 +11759,7 @@ const Ey = (e) => ({
|
|
|
11755
11759
|
}, p = Ea(o), w = Ra(p), v = await i.getDimensions(u), g = p === "y", x = g ? "top" : "left", b = g ? "bottom" : "right", y = g ? "clientHeight" : "clientWidth", R = s.reference[w] + s.reference[p] - h[p] - s.floating[w], S = h[p] - s.reference[p], T = await (i.getOffsetParent == null ? void 0 : i.getOffsetParent(u));
|
|
11756
11760
|
let E = T ? T[y] : 0;
|
|
11757
11761
|
(!E || !await (i.isElement == null ? void 0 : i.isElement(T))) && (E = a.floating[y] || s.floating[w]);
|
|
11758
|
-
const I = R / 2 - S / 2,
|
|
11762
|
+
const I = R / 2 - S / 2, A = E / 2 - v[w] / 2 - 1, j = Nn(f[x], A), D = Nn(f[b], A), L = j, z = E - v[w] - D, O = E / 2 - v[w] / 2 + I, K = Pi(L, O, z), W = !l.arrow && Rr(o) != null && O !== K && s.reference[w] / 2 - (O < L ? j : D) - v[w] / 2 < 0, G = W ? O < L ? O - L : O - z : 0;
|
|
11759
11763
|
return {
|
|
11760
11764
|
[p]: h[p] + G,
|
|
11761
11765
|
data: {
|
|
@@ -11794,16 +11798,16 @@ const Ey = (e) => ({
|
|
|
11794
11798
|
return {};
|
|
11795
11799
|
const x = xn(o), b = rn(a), y = xn(a) === a, R = await (l.isRTL == null ? void 0 : l.isRTL(u.floating)), S = h || (y || !v ? [Vo(a)] : wy(a)), T = w !== "none";
|
|
11796
11800
|
!h && T && S.push(...Cy(a, v, w, R));
|
|
11797
|
-
const E = [a, ...S], I = await qr(t, g),
|
|
11801
|
+
const E = [a, ...S], I = await qr(t, g), A = [];
|
|
11798
11802
|
let j = ((r = s.flip) == null ? void 0 : r.overflows) || [];
|
|
11799
|
-
if (d &&
|
|
11803
|
+
if (d && A.push(I[x]), f) {
|
|
11800
11804
|
const O = vy(o, i, R);
|
|
11801
|
-
|
|
11805
|
+
A.push(I[O[0]], I[O[1]]);
|
|
11802
11806
|
}
|
|
11803
11807
|
if (j = [...j, {
|
|
11804
11808
|
placement: o,
|
|
11805
|
-
overflows:
|
|
11806
|
-
}], !
|
|
11809
|
+
overflows: A
|
|
11810
|
+
}], !A.every((O) => O <= 0)) {
|
|
11807
11811
|
var D, L;
|
|
11808
11812
|
const O = (((D = s.flip) == null ? void 0 : D.index) || 0) + 1, K = E[O];
|
|
11809
11813
|
if (K && (!(f === "alignment" ? b !== rn(K) : !1) || // We leave the current main axis only if every placement on that axis
|
|
@@ -12082,8 +12086,8 @@ const Ay = function(e) {
|
|
|
12082
12086
|
availableWidth: I,
|
|
12083
12087
|
availableHeight: E
|
|
12084
12088
|
});
|
|
12085
|
-
const
|
|
12086
|
-
return w !==
|
|
12089
|
+
const A = await i.getDimensions(a.floating);
|
|
12090
|
+
return w !== A.width || v !== A.height ? {
|
|
12087
12091
|
reset: {
|
|
12088
12092
|
rects: !0
|
|
12089
12093
|
}
|
|
@@ -12663,7 +12667,7 @@ function m0(e) {
|
|
|
12663
12667
|
F !== T.current && (T.current = F, v(F));
|
|
12664
12668
|
}, []), y = m.useCallback((F) => {
|
|
12665
12669
|
F !== E.current && (E.current = F, x(F));
|
|
12666
|
-
}, []), R = s || w, S = i || g, T = m.useRef(null), E = m.useRef(null), I = m.useRef(d),
|
|
12670
|
+
}, []), R = s || w, S = i || g, T = m.useRef(null), E = m.useRef(null), I = m.useRef(d), A = l != null, j = ci(l), D = ci(o), L = ci(u), z = m.useCallback(() => {
|
|
12667
12671
|
if (!T.current || !E.current)
|
|
12668
12672
|
return;
|
|
12669
12673
|
const F = {
|
|
@@ -12700,7 +12704,7 @@ function m0(e) {
|
|
|
12700
12704
|
return j.current(R, S, z);
|
|
12701
12705
|
z();
|
|
12702
12706
|
}
|
|
12703
|
-
}, [R, S, z, j,
|
|
12707
|
+
}, [R, S, z, j, A]);
|
|
12704
12708
|
const K = m.useMemo(() => ({
|
|
12705
12709
|
reference: T,
|
|
12706
12710
|
floating: E,
|
|
@@ -12853,7 +12857,7 @@ var _a = "PopperContent", [k0, I0] = rf(_a), cf = m.forwardRef(
|
|
|
12853
12857
|
updatePositionStrategy: p = "optimized",
|
|
12854
12858
|
onPlaced: w,
|
|
12855
12859
|
...v
|
|
12856
|
-
} = e, g = of(_a, n), [x, b] = m.useState(null), y = Ue(t, (Be) => b(Be)), [R, S] = m.useState(null), T = nf(R), E = (T == null ? void 0 : T.width) ?? 0, I = (T == null ? void 0 : T.height) ?? 0,
|
|
12860
|
+
} = e, g = of(_a, n), [x, b] = m.useState(null), y = Ue(t, (Be) => b(Be)), [R, S] = m.useState(null), T = nf(R), E = (T == null ? void 0 : T.width) ?? 0, I = (T == null ? void 0 : T.height) ?? 0, A = r + (s !== "center" ? "-" + s : ""), j = typeof d == "number" ? d : { top: 0, right: 0, bottom: 0, left: 0, ...d }, D = Array.isArray(u) ? u : [u], L = D.length > 0, z = {
|
|
12857
12861
|
padding: j,
|
|
12858
12862
|
boundary: D.filter(A0),
|
|
12859
12863
|
// with `strategy: 'fixed'`, this is the only way to get it to respect boundaries
|
|
@@ -12861,7 +12865,7 @@ var _a = "PopperContent", [k0, I0] = rf(_a), cf = m.forwardRef(
|
|
|
12861
12865
|
}, { refs: O, floatingStyles: K, placement: W, isPositioned: G, middlewareData: F } = m0({
|
|
12862
12866
|
// default to `fixed` strategy so users don't have to pick and we also avoid focus scroll issues
|
|
12863
12867
|
strategy: "fixed",
|
|
12864
|
-
placement:
|
|
12868
|
+
placement: A,
|
|
12865
12869
|
whileElementsMounted: (...Be) => s0(...Be, {
|
|
12866
12870
|
animationFrame: p === "always"
|
|
12867
12871
|
}),
|
|
@@ -12888,10 +12892,10 @@ var _a = "PopperContent", [k0, I0] = rf(_a), cf = m.forwardRef(
|
|
|
12888
12892
|
_0({ arrowWidth: E, arrowHeight: I }),
|
|
12889
12893
|
h && S0({ strategy: "referenceHidden", ...z })
|
|
12890
12894
|
]
|
|
12891
|
-
}), [N, q] = ff(W),
|
|
12895
|
+
}), [N, q] = ff(W), Q = vt(w);
|
|
12892
12896
|
xt(() => {
|
|
12893
|
-
G && (
|
|
12894
|
-
}, [G,
|
|
12897
|
+
G && (Q == null || Q());
|
|
12898
|
+
}, [G, Q]);
|
|
12895
12899
|
const ge = (V = F.arrow) == null ? void 0 : V.x, ce = (M = F.arrow) == null ? void 0 : M.y, te = ((J = F.arrow) == null ? void 0 : J.centerOffset) !== 0, [Ae, Ce] = m.useState();
|
|
12896
12900
|
return xt(() => {
|
|
12897
12901
|
x && Ce(window.getComputedStyle(x).zIndex);
|
|
@@ -13080,8 +13084,8 @@ var L0 = m.forwardRef((e, t) => {
|
|
|
13080
13084
|
S.current = !0;
|
|
13081
13085
|
}),
|
|
13082
13086
|
onFocus: le(e.onFocus, (I) => {
|
|
13083
|
-
const
|
|
13084
|
-
if (I.target === I.currentTarget &&
|
|
13087
|
+
const A = !S.current;
|
|
13088
|
+
if (I.target === I.currentTarget && A && !x) {
|
|
13085
13089
|
const j = new CustomEvent(ui, j0);
|
|
13086
13090
|
if (I.currentTarget.dispatchEvent(j), !j.defaultPrevented) {
|
|
13087
13091
|
const D = R().filter((W) => W.focusable), L = D.find((W) => W.active), z = D.find((W) => W.id === v), K = [L, z, ...D].filter(
|
|
@@ -13296,17 +13300,17 @@ var Ht = "MenuContent", [eS, Oa] = tr(Ht), Nf = m.forwardRef(
|
|
|
13296
13300
|
onDismiss: p,
|
|
13297
13301
|
disableOutsideScroll: w,
|
|
13298
13302
|
...v
|
|
13299
|
-
} = e, g = nr(Ht, n), x = lo(Ht, n), b = Ns(n), y = Rf(n), R = G0(n), [S, T] = m.useState(null), E = m.useRef(null), I = Ue(t, E, g.onContentChange),
|
|
13303
|
+
} = e, g = nr(Ht, n), x = lo(Ht, n), b = Ns(n), y = Rf(n), R = G0(n), [S, T] = m.useState(null), E = m.useRef(null), I = Ue(t, E, g.onContentChange), A = m.useRef(0), j = m.useRef(""), D = m.useRef(0), L = m.useRef(null), z = m.useRef("right"), O = m.useRef(0), K = w ? vs : m.Fragment, W = w ? { as: rS, allowPinchZoom: !0 } : void 0, G = (N) => {
|
|
13300
13304
|
var V, M;
|
|
13301
|
-
const q = j.current + N,
|
|
13305
|
+
const q = j.current + N, Q = R().filter((J) => !J.disabled), ge = document.activeElement, ce = (V = Q.find((J) => J.ref.current === ge)) == null ? void 0 : V.textValue, te = Q.map((J) => J.textValue), Ae = mS(te, q, ce), Ce = (M = Q.find((J) => J.textValue === Ae)) == null ? void 0 : M.ref.current;
|
|
13302
13306
|
(function J(U) {
|
|
13303
|
-
j.current = U, window.clearTimeout(
|
|
13307
|
+
j.current = U, window.clearTimeout(A.current), U !== "" && (A.current = window.setTimeout(() => J(""), 1e3));
|
|
13304
13308
|
})(q), Ce && setTimeout(() => Ce.focus());
|
|
13305
13309
|
};
|
|
13306
|
-
m.useEffect(() => () => window.clearTimeout(
|
|
13310
|
+
m.useEffect(() => () => window.clearTimeout(A.current), []), va();
|
|
13307
13311
|
const F = m.useCallback((N) => {
|
|
13308
|
-
var
|
|
13309
|
-
return z.current === ((
|
|
13312
|
+
var Q, ge;
|
|
13313
|
+
return z.current === ((Q = L.current) == null ? void 0 : Q.side) && xS(N, (ge = L.current) == null ? void 0 : ge.area);
|
|
13310
13314
|
}, []);
|
|
13311
13315
|
return /* @__PURE__ */ c.jsx(
|
|
13312
13316
|
eS,
|
|
@@ -13383,8 +13387,8 @@ var Ht = "MenuContent", [eS, Oa] = tr(Ht), Nf = m.forwardRef(
|
|
|
13383
13387
|
ref: I,
|
|
13384
13388
|
style: { outline: "none", ...v.style },
|
|
13385
13389
|
onKeyDown: le(v.onKeyDown, (N) => {
|
|
13386
|
-
const
|
|
13387
|
-
|
|
13390
|
+
const Q = N.target.closest("[data-radix-menu-content]") === N.currentTarget, ge = N.ctrlKey || N.altKey || N.metaKey, ce = N.key.length === 1;
|
|
13391
|
+
Q && (N.key === "Tab" && N.preventDefault(), !ge && ce && G(N.key));
|
|
13388
13392
|
const te = E.current;
|
|
13389
13393
|
if (N.target !== te || !V0.includes(N.key)) return;
|
|
13390
13394
|
N.preventDefault();
|
|
@@ -13392,13 +13396,13 @@ var Ht = "MenuContent", [eS, Oa] = tr(Ht), Nf = m.forwardRef(
|
|
|
13392
13396
|
Cf.includes(N.key) && Ce.reverse(), hS(Ce);
|
|
13393
13397
|
}),
|
|
13394
13398
|
onBlur: le(e.onBlur, (N) => {
|
|
13395
|
-
N.currentTarget.contains(N.target) || (window.clearTimeout(
|
|
13399
|
+
N.currentTarget.contains(N.target) || (window.clearTimeout(A.current), j.current = "");
|
|
13396
13400
|
}),
|
|
13397
13401
|
onPointerMove: le(
|
|
13398
13402
|
e.onPointerMove,
|
|
13399
13403
|
Xr((N) => {
|
|
13400
|
-
const q = N.target,
|
|
13401
|
-
if (N.currentTarget.contains(q) &&
|
|
13404
|
+
const q = N.target, Q = O.current !== N.clientX;
|
|
13405
|
+
if (N.currentTarget.contains(q) && Q) {
|
|
13402
13406
|
const ge = N.clientX > O.current ? "right" : "left";
|
|
13403
13407
|
z.current = ge, O.current = N.clientX;
|
|
13404
13408
|
}
|
|
@@ -14068,14 +14072,14 @@ function di({
|
|
|
14068
14072
|
isLoadingHistory: T,
|
|
14069
14073
|
send: E,
|
|
14070
14074
|
stop: I,
|
|
14071
|
-
loadOlderMessages:
|
|
14075
|
+
loadOlderMessages: A
|
|
14072
14076
|
} = fu(), {
|
|
14073
14077
|
isStreaming: j,
|
|
14074
14078
|
error: D,
|
|
14075
14079
|
streamingAssistantId: L,
|
|
14076
14080
|
lastCheckpointId: z,
|
|
14077
14081
|
lastCheckpointNs: O
|
|
14078
|
-
} = bx(), [K, W] = ve(null), [G, F] = ve(""), [N, q] = ve(null), [
|
|
14082
|
+
} = bx(), [K, W] = ve(null), [G, F] = ve(""), [N, q] = ve(null), [Q, ge] = ve([]), [ce, te] = ve(0), [Ae, Ce] = ve(0), [V, M] = ve(!1), [J, U] = ve(null), [ue, ae] = ve(null), [Be, Xe] = ve(!1), [qe, Te] = ve(null), [Me, rt] = ve([]), [ze, Je] = ve(null), [ft, ne] = ve(null), [re, xe] = ve(!1), Re = et(null), Se = et(null), Ie = et(null), Ze = De(() => {
|
|
14079
14083
|
Re.current && (Re.current.value = ""), Se.current && (Se.current.value = ""), te((oe) => oe + 1), Ce((oe) => oe + 1);
|
|
14080
14084
|
}, []), Ge = et(!1);
|
|
14081
14085
|
pt(() => {
|
|
@@ -14103,12 +14107,12 @@ function di({
|
|
|
14103
14107
|
return x(v).then((k) => {
|
|
14104
14108
|
var de;
|
|
14105
14109
|
if (oe) return;
|
|
14106
|
-
const
|
|
14107
|
-
rt(
|
|
14108
|
-
const
|
|
14110
|
+
const _ = ((k == null ? void 0 : k.checkpoints) ?? []).slice().sort((C, $) => new Date($.createdAt).getTime() - new Date(C.createdAt).getTime());
|
|
14111
|
+
rt(_);
|
|
14112
|
+
const Z = ze, he = Z && _.some((C) => C.checkpointId === Z) ? Z : ((de = _[0]) == null ? void 0 : de.checkpointId) ?? null;
|
|
14109
14113
|
let pe = null;
|
|
14110
14114
|
if (he) {
|
|
14111
|
-
const C =
|
|
14115
|
+
const C = _.find(($) => $.checkpointId === he);
|
|
14112
14116
|
pe = (C == null ? void 0 : C.checkpointNs) ?? null;
|
|
14113
14117
|
}
|
|
14114
14118
|
Je(he), ne(pe), Ie.current = we;
|
|
@@ -14123,11 +14127,11 @@ function di({
|
|
|
14123
14127
|
const fn = De(async () => {
|
|
14124
14128
|
if (!(!S || T))
|
|
14125
14129
|
try {
|
|
14126
|
-
await
|
|
14130
|
+
await A();
|
|
14127
14131
|
} catch (oe) {
|
|
14128
14132
|
console.warn("loadOlderMessages failed", oe);
|
|
14129
14133
|
}
|
|
14130
|
-
}, [S, T,
|
|
14134
|
+
}, [S, T, A]);
|
|
14131
14135
|
pt(() => {
|
|
14132
14136
|
(async () => {
|
|
14133
14137
|
if (!w.baseUrl) {
|
|
@@ -14154,7 +14158,7 @@ function di({
|
|
|
14154
14158
|
}
|
|
14155
14159
|
}, rr = async (oe) => {
|
|
14156
14160
|
const we = oe.trim();
|
|
14157
|
-
if (!(!we &&
|
|
14161
|
+
if (!(!we && Q.length === 0)) {
|
|
14158
14162
|
if (we) {
|
|
14159
14163
|
const $e = vn(we);
|
|
14160
14164
|
if ($e) {
|
|
@@ -14167,7 +14171,7 @@ function di({
|
|
|
14167
14171
|
checkpointId: ze ?? z ?? void 0,
|
|
14168
14172
|
checkpointNs: ft ?? O ?? void 0,
|
|
14169
14173
|
payloadExtras: K ? { edit: !0, originalMessageId: K } : void 0,
|
|
14170
|
-
attachments:
|
|
14174
|
+
attachments: Q
|
|
14171
14175
|
}), f == null || f(we), q(null), ge([]), Ze(), W(null), F("");
|
|
14172
14176
|
} catch ($e) {
|
|
14173
14177
|
const k = ($e == null ? void 0 : $e.message) || "Failed to send message";
|
|
@@ -14182,8 +14186,8 @@ function di({
|
|
|
14182
14186
|
wn(oe, we);
|
|
14183
14187
|
}, [wn]), yn = De((oe) => {
|
|
14184
14188
|
const we = ($e) => {
|
|
14185
|
-
const k = $e.content || [],
|
|
14186
|
-
if (
|
|
14189
|
+
const k = $e.content || [], _ = k.filter((Z) => Z.type === "text").map((Z) => Z.text).join("");
|
|
14190
|
+
if (_) return _;
|
|
14187
14191
|
try {
|
|
14188
14192
|
return JSON.stringify(k, null, 2);
|
|
14189
14193
|
} catch {
|
|
@@ -14204,7 +14208,7 @@ function di({
|
|
|
14204
14208
|
ge(($e) => [...$e, ...we]), oe.target.value = "";
|
|
14205
14209
|
}, Vt = (oe) => {
|
|
14206
14210
|
ge((we) => {
|
|
14207
|
-
const $e = we.filter((k,
|
|
14211
|
+
const $e = we.filter((k, _) => oe !== _);
|
|
14208
14212
|
return $e.length === 0 && Ze(), $e;
|
|
14209
14213
|
});
|
|
14210
14214
|
}, Sn = async (oe) => {
|
|
@@ -14347,7 +14351,7 @@ function di({
|
|
|
14347
14351
|
},
|
|
14348
14352
|
ce
|
|
14349
14353
|
),
|
|
14350
|
-
|
|
14354
|
+
Q.length > 0 && /* @__PURE__ */ c.jsx("div", { className: "flex flex-wrap gap-2", children: Q.map((oe, we) => /* @__PURE__ */ c.jsxs("div", { className: "flex items-center gap-2 bg-gray-100 dark:bg-gray-800 rounded-lg px-3 py-2 text-sm text-gray-900 dark:text-gray-100", children: [
|
|
14351
14355
|
/* @__PURE__ */ c.jsx(fi, { size: 14 }),
|
|
14352
14356
|
/* @__PURE__ */ c.jsx("span", { className: "truncate max-w-[150px]", children: oe.name }),
|
|
14353
14357
|
/* @__PURE__ */ c.jsx(
|
|
@@ -14434,7 +14438,7 @@ function di({
|
|
|
14434
14438
|
onSend: rr,
|
|
14435
14439
|
onCancelEdit: bn,
|
|
14436
14440
|
onStop: I,
|
|
14437
|
-
allowEmptySend:
|
|
14441
|
+
allowEmptySend: Q.length > 0,
|
|
14438
14442
|
textareaClassName: `resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${K ? "border-blue-400 bg-blue-50 text-blue-900 dark:border-blue-500 dark:bg-blue-950/60 dark:text-blue-50" : ""} ${N ? "border-red-400" : ""} ${d.textarea || ""}`
|
|
14439
14443
|
}
|
|
14440
14444
|
) })
|
|
@@ -14471,7 +14475,7 @@ var Fa = "ScrollArea", [xh, YT] = cn(Fa), [lC, Wt] = xh(Fa), vh = m.forwardRef(
|
|
|
14471
14475
|
dir: o,
|
|
14472
14476
|
scrollHideDelay: s = 600,
|
|
14473
14477
|
...i
|
|
14474
|
-
} = e, [a, l] = m.useState(null), [u, d] = m.useState(null), [f, h] = m.useState(null), [p, w] = m.useState(null), [v, g] = m.useState(null), [x, b] = m.useState(0), [y, R] = m.useState(0), [S, T] = m.useState(!1), [E, I] = m.useState(!1),
|
|
14478
|
+
} = e, [a, l] = m.useState(null), [u, d] = m.useState(null), [f, h] = m.useState(null), [p, w] = m.useState(null), [v, g] = m.useState(null), [x, b] = m.useState(0), [y, R] = m.useState(0), [S, T] = m.useState(!1), [E, I] = m.useState(!1), A = Ue(t, (D) => l(D)), j = Cs(o);
|
|
14475
14479
|
return /* @__PURE__ */ c.jsx(
|
|
14476
14480
|
lC,
|
|
14477
14481
|
{
|
|
@@ -14499,7 +14503,7 @@ var Fa = "ScrollArea", [xh, YT] = cn(Fa), [lC, Wt] = xh(Fa), vh = m.forwardRef(
|
|
|
14499
14503
|
{
|
|
14500
14504
|
dir: j,
|
|
14501
14505
|
...i,
|
|
14502
|
-
ref:
|
|
14506
|
+
ref: A,
|
|
14503
14507
|
style: {
|
|
14504
14508
|
position: "relative",
|
|
14505
14509
|
// Pass corner sizes as CSS vars to reduce re-renders of context consumers
|
|
@@ -14793,19 +14797,19 @@ var cC = m.forwardRef((e, t) => {
|
|
|
14793
14797
|
onWheelScroll: d,
|
|
14794
14798
|
onResize: f,
|
|
14795
14799
|
...h
|
|
14796
|
-
} = e, p = Wt(dn, n), [w, v] = m.useState(null), g = Ue(t, (
|
|
14797
|
-
function I(
|
|
14800
|
+
} = e, p = Wt(dn, n), [w, v] = m.useState(null), g = Ue(t, (A) => v(A)), x = m.useRef(null), b = m.useRef(""), y = p.viewport, R = r.content - r.viewport, S = vt(d), T = vt(l), E = Ps(f, 10);
|
|
14801
|
+
function I(A) {
|
|
14798
14802
|
if (x.current) {
|
|
14799
|
-
const j =
|
|
14803
|
+
const j = A.clientX - x.current.left, D = A.clientY - x.current.top;
|
|
14800
14804
|
u({ x: j, y: D });
|
|
14801
14805
|
}
|
|
14802
14806
|
}
|
|
14803
14807
|
return m.useEffect(() => {
|
|
14804
|
-
const
|
|
14808
|
+
const A = (j) => {
|
|
14805
14809
|
const D = j.target;
|
|
14806
14810
|
(w == null ? void 0 : w.contains(D)) && S(j, R);
|
|
14807
14811
|
};
|
|
14808
|
-
return document.addEventListener("wheel",
|
|
14812
|
+
return document.addEventListener("wheel", A, { passive: !1 }), () => document.removeEventListener("wheel", A, { passive: !1 });
|
|
14809
14813
|
}, [y, w, R, S]), m.useEffect(T, [r, T]), br(w, E), br(p.content, E), /* @__PURE__ */ c.jsx(
|
|
14810
14814
|
hC,
|
|
14811
14815
|
{
|
|
@@ -14822,13 +14826,13 @@ var cC = m.forwardRef((e, t) => {
|
|
|
14822
14826
|
...h,
|
|
14823
14827
|
ref: g,
|
|
14824
14828
|
style: { position: "absolute", ...h.style },
|
|
14825
|
-
onPointerDown: le(e.onPointerDown, (
|
|
14826
|
-
|
|
14829
|
+
onPointerDown: le(e.onPointerDown, (A) => {
|
|
14830
|
+
A.button === 0 && (A.target.setPointerCapture(A.pointerId), x.current = w.getBoundingClientRect(), b.current = document.body.style.webkitUserSelect, document.body.style.webkitUserSelect = "none", p.viewport && (p.viewport.style.scrollBehavior = "auto"), I(A));
|
|
14827
14831
|
}),
|
|
14828
14832
|
onPointerMove: le(e.onPointerMove, I),
|
|
14829
|
-
onPointerUp: le(e.onPointerUp, (
|
|
14830
|
-
const j =
|
|
14831
|
-
j.hasPointerCapture(
|
|
14833
|
+
onPointerUp: le(e.onPointerUp, (A) => {
|
|
14834
|
+
const j = A.target;
|
|
14835
|
+
j.hasPointerCapture(A.pointerId) && j.releasePointerCapture(A.pointerId), document.body.style.webkitUserSelect = b.current, p.viewport && (p.viewport.style.scrollBehavior = ""), x.current = null;
|
|
14832
14836
|
})
|
|
14833
14837
|
}
|
|
14834
14838
|
)
|
|
@@ -15022,7 +15026,7 @@ function kc({
|
|
|
15022
15026
|
deleteThread: v,
|
|
15023
15027
|
renameThread: g,
|
|
15024
15028
|
isLoadingThreads: x
|
|
15025
|
-
} = Zi(), [b, y] = ve(h ?? []), [R, S] = ve(null), [T, E] = ve(""), [I,
|
|
15029
|
+
} = Zi(), [b, y] = ve(h ?? []), [R, S] = ve(null), [T, E] = ve(""), [I, A] = ve(!1);
|
|
15026
15030
|
pt(() => {
|
|
15027
15031
|
y(h ?? []);
|
|
15028
15032
|
}, [h]);
|
|
@@ -15034,20 +15038,20 @@ function kc({
|
|
|
15034
15038
|
}
|
|
15035
15039
|
}, D = async () => {
|
|
15036
15040
|
try {
|
|
15037
|
-
|
|
15041
|
+
A(!0);
|
|
15038
15042
|
const N = await w();
|
|
15039
15043
|
u == null || u(N), a == null || a(N);
|
|
15040
15044
|
} catch (N) {
|
|
15041
15045
|
console.error("Failed to create thread:", N);
|
|
15042
15046
|
} finally {
|
|
15043
|
-
|
|
15047
|
+
A(!1);
|
|
15044
15048
|
}
|
|
15045
15049
|
}, L = async (N, q) => {
|
|
15046
15050
|
if (q.stopPropagation(), !!confirm("Delete this thread?"))
|
|
15047
15051
|
try {
|
|
15048
15052
|
await v(N), d == null || d(N);
|
|
15049
|
-
} catch (
|
|
15050
|
-
console.error("Failed to delete thread:",
|
|
15053
|
+
} catch (Q) {
|
|
15054
|
+
console.error("Failed to delete thread:", Q);
|
|
15051
15055
|
}
|
|
15052
15056
|
}, z = (N, q) => {
|
|
15053
15057
|
q.stopPropagation(), S(N.threadId), E(N.title || `Thread ${N.threadId.slice(0, 8)}`);
|
|
@@ -15453,7 +15457,7 @@ var OC = [" ", "Enter", "ArrowUp", "ArrowDown"], MC = [" ", "Enter"], Xn = "Sele
|
|
|
15453
15457
|
defaultProp: o ?? !1,
|
|
15454
15458
|
onChange: s,
|
|
15455
15459
|
caller: Xn
|
|
15456
|
-
}), [
|
|
15460
|
+
}), [A, j] = qn({
|
|
15457
15461
|
prop: i,
|
|
15458
15462
|
defaultProp: a,
|
|
15459
15463
|
onChange: l,
|
|
@@ -15471,7 +15475,7 @@ var OC = [" ", "Enter", "ArrowUp", "ArrowDown"], MC = [" ", "Enter"], Xn = "Sele
|
|
|
15471
15475
|
valueNodeHasChildren: R,
|
|
15472
15476
|
onValueNodeHasChildrenChange: S,
|
|
15473
15477
|
contentId: on(),
|
|
15474
|
-
value:
|
|
15478
|
+
value: A,
|
|
15475
15479
|
onValueChange: j,
|
|
15476
15480
|
open: E,
|
|
15477
15481
|
onOpenChange: I,
|
|
@@ -15503,12 +15507,12 @@ var OC = [" ", "Enter", "ArrowUp", "ArrowDown"], MC = [" ", "Enter"], Xn = "Sele
|
|
|
15503
15507
|
tabIndex: -1,
|
|
15504
15508
|
name: d,
|
|
15505
15509
|
autoComplete: f,
|
|
15506
|
-
value:
|
|
15510
|
+
value: A,
|
|
15507
15511
|
onChange: (W) => j(W.target.value),
|
|
15508
15512
|
disabled: h,
|
|
15509
15513
|
form: w,
|
|
15510
15514
|
children: [
|
|
15511
|
-
|
|
15515
|
+
A === void 0 ? /* @__PURE__ */ c.jsx("option", { value: "" }) : null,
|
|
15512
15516
|
Array.from(z)
|
|
15513
15517
|
]
|
|
15514
15518
|
},
|
|
@@ -15627,7 +15631,7 @@ var Kt = 10, [ep, Mn] = kr(Jn), HC = "SelectContentImpl", UC = xr("SelectContent
|
|
|
15627
15631
|
avoidCollisions: g,
|
|
15628
15632
|
//
|
|
15629
15633
|
...x
|
|
15630
|
-
} = e, b = On(Jn, n), [y, R] = m.useState(null), [S, T] = m.useState(null), E = Ue(t, (V) => R(V)), [I,
|
|
15634
|
+
} = e, b = On(Jn, n), [y, R] = m.useState(null), [S, T] = m.useState(null), E = Ue(t, (V) => R(V)), [I, A] = m.useState(null), [j, D] = m.useState(
|
|
15631
15635
|
null
|
|
15632
15636
|
), L = Ds(n), [z, O] = m.useState(!1), K = m.useRef(!1);
|
|
15633
15637
|
m.useEffect(() => {
|
|
@@ -15670,13 +15674,13 @@ var Kt = 10, [ep, Mn] = kr(Jn), HC = "SelectContentImpl", UC = xr("SelectContent
|
|
|
15670
15674
|
window.removeEventListener("blur", V), window.removeEventListener("resize", V);
|
|
15671
15675
|
};
|
|
15672
15676
|
}, [F]);
|
|
15673
|
-
const [q,
|
|
15677
|
+
const [q, Q] = vp((V) => {
|
|
15674
15678
|
const M = L().filter((ue) => !ue.disabled), J = M.find((ue) => ue.ref.current === document.activeElement), U = wp(M, V, J);
|
|
15675
15679
|
U && setTimeout(() => U.ref.current.focus());
|
|
15676
15680
|
}), ge = m.useCallback(
|
|
15677
15681
|
(V, M, J) => {
|
|
15678
15682
|
const U = !K.current && !J;
|
|
15679
|
-
(b.value !== void 0 && b.value === M || U) && (
|
|
15683
|
+
(b.value !== void 0 && b.value === M || U) && (A(V), U && (K.current = !0));
|
|
15680
15684
|
},
|
|
15681
15685
|
[b.value]
|
|
15682
15686
|
), ce = m.useCallback(() => y == null ? void 0 : y.focus(), [y]), te = m.useCallback(
|
|
@@ -15756,7 +15760,7 @@ var Kt = 10, [ep, Mn] = kr(Jn), HC = "SelectContentImpl", UC = xr("SelectContent
|
|
|
15756
15760
|
},
|
|
15757
15761
|
onKeyDown: le(x.onKeyDown, (V) => {
|
|
15758
15762
|
const M = V.ctrlKey || V.altKey || V.metaKey;
|
|
15759
|
-
if (V.key === "Tab" && V.preventDefault(), !M && V.key.length === 1 &&
|
|
15763
|
+
if (V.key === "Tab" && V.preventDefault(), !M && V.key.length === 1 && Q(V.key), ["ArrowUp", "ArrowDown", "Home", "End"].includes(V.key)) {
|
|
15760
15764
|
let U = L().filter((ue) => !ue.disabled).map((ue) => ue.ref.current);
|
|
15761
15765
|
if (["ArrowUp", "End"].includes(V.key) && (U = U.slice().reverse()), ["ArrowUp", "ArrowDown"].includes(V.key)) {
|
|
15762
15766
|
const ue = V.target, ae = U.indexOf(ue);
|
|
@@ -15779,9 +15783,9 @@ tp.displayName = HC;
|
|
|
15779
15783
|
var WC = "SelectItemAlignedPosition", np = m.forwardRef((e, t) => {
|
|
15780
15784
|
const { __scopeSelect: n, onPlaced: r, ...o } = e, s = On(Jn, n), i = Mn(Jn, n), [a, l] = m.useState(null), [u, d] = m.useState(null), f = Ue(t, (E) => d(E)), h = Ds(n), p = m.useRef(!1), w = m.useRef(!0), { viewport: v, selectedItem: g, selectedItemText: x, focusSelectedItem: b } = i, y = m.useCallback(() => {
|
|
15781
15785
|
if (s.trigger && s.valueNode && a && u && v && g && x) {
|
|
15782
|
-
const E = s.trigger.getBoundingClientRect(), I = u.getBoundingClientRect(),
|
|
15786
|
+
const E = s.trigger.getBoundingClientRect(), I = u.getBoundingClientRect(), A = s.valueNode.getBoundingClientRect(), j = x.getBoundingClientRect();
|
|
15783
15787
|
if (s.dir !== "rtl") {
|
|
15784
|
-
const ue = j.left - I.left, ae =
|
|
15788
|
+
const ue = j.left - I.left, ae = A.left - ue, Be = E.left - ae, Xe = E.width + Be, qe = Math.max(Xe, I.width), Te = window.innerWidth - Kt, Me = Fi(ae, [
|
|
15785
15789
|
Kt,
|
|
15786
15790
|
// Prevents the content from going off the starting edge of the
|
|
15787
15791
|
// viewport. It may still go off the ending edge, but this can be
|
|
@@ -15792,13 +15796,13 @@ var WC = "SelectItemAlignedPosition", np = m.forwardRef((e, t) => {
|
|
|
15792
15796
|
]);
|
|
15793
15797
|
a.style.minWidth = Xe + "px", a.style.left = Me + "px";
|
|
15794
15798
|
} else {
|
|
15795
|
-
const ue = I.right - j.right, ae = window.innerWidth -
|
|
15799
|
+
const ue = I.right - j.right, ae = window.innerWidth - A.right - ue, Be = window.innerWidth - E.right - ae, Xe = E.width + Be, qe = Math.max(Xe, I.width), Te = window.innerWidth - Kt, Me = Fi(ae, [
|
|
15796
15800
|
Kt,
|
|
15797
15801
|
Math.max(Kt, Te - qe)
|
|
15798
15802
|
]);
|
|
15799
15803
|
a.style.minWidth = Xe + "px", a.style.right = Me + "px";
|
|
15800
15804
|
}
|
|
15801
|
-
const D = h(), L = window.innerHeight - Kt * 2, z = v.scrollHeight, O = window.getComputedStyle(u), K = parseInt(O.borderTopWidth, 10), W = parseInt(O.paddingTop, 10), G = parseInt(O.borderBottomWidth, 10), F = parseInt(O.paddingBottom, 10), N = K + W + z + F + G, q = Math.min(g.offsetHeight * 5, N),
|
|
15805
|
+
const D = h(), L = window.innerHeight - Kt * 2, z = v.scrollHeight, O = window.getComputedStyle(u), K = parseInt(O.borderTopWidth, 10), W = parseInt(O.paddingTop, 10), G = parseInt(O.borderBottomWidth, 10), F = parseInt(O.paddingBottom, 10), N = K + W + z + F + G, q = Math.min(g.offsetHeight * 5, N), Q = window.getComputedStyle(v), ge = parseInt(Q.paddingTop, 10), ce = parseInt(Q.paddingBottom, 10), te = E.top + E.height / 2 - Kt, Ae = L - te, Ce = g.offsetHeight / 2, V = g.offsetTop + Ce, M = K + W + V, J = N - M;
|
|
15802
15806
|
if (M <= te) {
|
|
15803
15807
|
const ue = D.length > 0 && g === D[D.length - 1].ref.current;
|
|
15804
15808
|
a.style.bottom = "0px";
|