teodor-new-chat-ui 4.3.457 → 4.3.459
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 +72 -70
- package/dist/index.umd.js +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -2,7 +2,7 @@ var Ng = Object.defineProperty;
|
|
|
2
2
|
var Ag = (e, t, n) => t in e ? Ng(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
3
|
var zl = (e, t, n) => Ag(e, typeof t != "symbol" ? t + "" : t, n);
|
|
4
4
|
import * as h from "react";
|
|
5
|
-
import M, { useMemo as Qe, createContext as Pr, useContext as Mr, useState as de, useRef as
|
|
5
|
+
import M, { useMemo as Qe, createContext as Pr, useContext as Mr, useState as de, useRef as Le, useCallback as he, useEffect as Ze, useReducer as jg, useLayoutEffect as _g, createElement as Yo, memo as Pg, useImperativeHandle as Mg, forwardRef as Og, isValidElement as ga } from "react";
|
|
6
6
|
import { Slot as Dg, createSlot as Rr, createSlottable as Lg } from "@radix-ui/react-slot";
|
|
7
7
|
import { cva as mo } from "class-variance-authority";
|
|
8
8
|
import { clsx as $g } from "clsx";
|
|
@@ -630,7 +630,7 @@ function mx() {
|
|
|
630
630
|
function qe(I) {
|
|
631
631
|
return "" + I;
|
|
632
632
|
}
|
|
633
|
-
function
|
|
633
|
+
function $e(I) {
|
|
634
634
|
if (He(I))
|
|
635
635
|
return w("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", Ve(I)), qe(I);
|
|
636
636
|
}
|
|
@@ -713,7 +713,7 @@ function mx() {
|
|
|
713
713
|
function zt(I, ee, ue, ke, Ye) {
|
|
714
714
|
{
|
|
715
715
|
var nt, ie = {}, ce = null, Te = null;
|
|
716
|
-
ue !== void 0 && (
|
|
716
|
+
ue !== void 0 && ($e(ue), ce = "" + ue), Tt(ee) && ($e(ee.key), ce = "" + ee.key), Mt(ee) && (Te = ee.ref, gt(ee, Ye));
|
|
717
717
|
for (nt in ee)
|
|
718
718
|
we.call(ee, nt) && !pt.hasOwnProperty(nt) && (ie[nt] = ee[nt]);
|
|
719
719
|
if (I && I.defaultProps) {
|
|
@@ -757,7 +757,7 @@ Check the render method of \`` + I + "`.";
|
|
|
757
757
|
return "";
|
|
758
758
|
}
|
|
759
759
|
var xe = {};
|
|
760
|
-
function
|
|
760
|
+
function Fe(I) {
|
|
761
761
|
{
|
|
762
762
|
var ee = pe();
|
|
763
763
|
if (!ee) {
|
|
@@ -774,7 +774,7 @@ Check the top-level render call using <` + ue + ">.");
|
|
|
774
774
|
if (!I._store || I._store.validated || I.key != null)
|
|
775
775
|
return;
|
|
776
776
|
I._store.validated = !0;
|
|
777
|
-
var ue =
|
|
777
|
+
var ue = Fe(ee);
|
|
778
778
|
if (xe[ue])
|
|
779
779
|
return;
|
|
780
780
|
xe[ue] = !0;
|
|
@@ -3059,7 +3059,7 @@ function fd(e) {
|
|
|
3059
3059
|
return t[t.length - 1] || null;
|
|
3060
3060
|
}
|
|
3061
3061
|
function ow(e = {}) {
|
|
3062
|
-
const t = Qe(() => An(e.baseUrl), [e.baseUrl]), n = e.streamPath ?? "/runs/stream", [r, o] = de(e.token ?? null), s =
|
|
3062
|
+
const t = Qe(() => An(e.baseUrl), [e.baseUrl]), n = e.streamPath ?? "/runs/stream", [r, o] = de(e.token ?? null), s = Le(e.headers ?? {}), a = e.credentials ?? "include", [i, l] = de(!1), [c, d] = de(null), [p, m] = de(""), [f, v] = de(null), [g, x] = de(0), [b, w] = de(!1), [y, C] = de(null), S = Le(null), T = Le(!0), k = Le(0), R = Le(null), _ = Le(null), O = Le(null), $ = Le(null), W = Le({
|
|
3063
3063
|
messageId: null,
|
|
3064
3064
|
lastSeq: null,
|
|
3065
3065
|
lastText: ""
|
|
@@ -3093,9 +3093,9 @@ function ow(e = {}) {
|
|
|
3093
3093
|
var He;
|
|
3094
3094
|
try {
|
|
3095
3095
|
const qe = JSON.parse(JSON.stringify(Ve));
|
|
3096
|
-
return (He = qe == null ? void 0 : qe.payload) != null && He.files_info && Array.isArray(qe.payload.files_info) && (qe.payload.files_info = qe.payload.files_info.map((
|
|
3097
|
-
|
|
3098
|
-
data:
|
|
3096
|
+
return (He = qe == null ? void 0 : qe.payload) != null && He.files_info && Array.isArray(qe.payload.files_info) && (qe.payload.files_info = qe.payload.files_info.map(($e) => ({
|
|
3097
|
+
...$e,
|
|
3098
|
+
data: $e != null && $e.data ? `<base64 ${String($e.data).length} chars>` : $e == null ? void 0 : $e.data
|
|
3099
3099
|
}))), qe;
|
|
3100
3100
|
} catch {
|
|
3101
3101
|
return Ve;
|
|
@@ -3135,13 +3135,13 @@ function ow(e = {}) {
|
|
|
3135
3135
|
...Ve,
|
|
3136
3136
|
...He,
|
|
3137
3137
|
...s.current
|
|
3138
|
-
},
|
|
3138
|
+
}, $e = {
|
|
3139
3139
|
"Content-Type": "application/json",
|
|
3140
3140
|
Accept: "text/event-stream",
|
|
3141
3141
|
...qe
|
|
3142
3142
|
}, Ue = await fetch(t + n, {
|
|
3143
3143
|
method: "POST",
|
|
3144
|
-
headers:
|
|
3144
|
+
headers: $e,
|
|
3145
3145
|
body: JSON.stringify(D),
|
|
3146
3146
|
signal: F.signal,
|
|
3147
3147
|
credentials: a
|
|
@@ -3191,9 +3191,9 @@ function ow(e = {}) {
|
|
|
3191
3191
|
for (; (xe = it.indexOf(`
|
|
3192
3192
|
|
|
3193
3193
|
`)) >= 0; ) {
|
|
3194
|
-
const
|
|
3194
|
+
const Fe = it.slice(0, xe);
|
|
3195
3195
|
it = it.slice(xe + 2);
|
|
3196
|
-
const Ge =
|
|
3196
|
+
const Ge = Fe.split(/\r?\n/), kt = [];
|
|
3197
3197
|
for (const Je of Ge)
|
|
3198
3198
|
if (!(!Je || Je.startsWith(":")) && Je.startsWith("data:")) {
|
|
3199
3199
|
const dt = Je.slice(5);
|
|
@@ -3321,14 +3321,14 @@ function ow(e = {}) {
|
|
|
3321
3321
|
G = "error", A = He, d(He), (at = E == null ? void 0 : E.onError) == null || at.call(E, He), P || ((yt = E == null ? void 0 : E.onConnectionError) == null || yt.call(E, He), P = !0);
|
|
3322
3322
|
}
|
|
3323
3323
|
} finally {
|
|
3324
|
-
const Ve = k.current, He = _.current, qe = O.current,
|
|
3324
|
+
const Ve = k.current, He = _.current, qe = O.current, $e = $.current, Ue = G ?? (F.signal.aborted ? "aborted" : A ? "error" : "complete");
|
|
3325
3325
|
try {
|
|
3326
3326
|
(Nt = E == null ? void 0 : E.onClosed) == null || Nt.call(E, {
|
|
3327
3327
|
reason: Ue,
|
|
3328
3328
|
lastSeq: Ve,
|
|
3329
3329
|
lastCheckpointId: He,
|
|
3330
3330
|
lastCheckpointNs: qe,
|
|
3331
|
-
lastStateHistory:
|
|
3331
|
+
lastStateHistory: $e,
|
|
3332
3332
|
error: A
|
|
3333
3333
|
});
|
|
3334
3334
|
} catch (pt) {
|
|
@@ -3407,7 +3407,7 @@ function iw({
|
|
|
3407
3407
|
onThreadChange: r,
|
|
3408
3408
|
onCurrentThreadDeleted: o
|
|
3409
3409
|
}) {
|
|
3410
|
-
const [s, a] = de([]), [i, l] = de(t), [c, d] = de(!1), [p, m] = de(null), [f, v] = de([]), [g, x] = de(!1), [, b] = de(null), [w, y] = de(null), [C, S] = de(!1), T =
|
|
3410
|
+
const [s, a] = de([]), [i, l] = de(t), [c, d] = de(!1), [p, m] = de(null), [f, v] = de([]), [g, x] = de(!1), [, b] = de(null), [w, y] = de(null), [C, S] = de(!1), T = Le(i), k = Le(/* @__PURE__ */ new Map());
|
|
3411
3411
|
Ze(() => {
|
|
3412
3412
|
T.current = i;
|
|
3413
3413
|
}, [i]);
|
|
@@ -3852,7 +3852,7 @@ function ww(e, t) {
|
|
|
3852
3852
|
}
|
|
3853
3853
|
}
|
|
3854
3854
|
function bw(e = []) {
|
|
3855
|
-
const [t, n] = jg(ww, { ...vw, messages: e }), r =
|
|
3855
|
+
const [t, n] = jg(ww, { ...vw, messages: e }), r = Le([]), o = Le(null), s = Le(null), a = he(() => {
|
|
3856
3856
|
o.current !== null && typeof window < "u" && window.cancelAnimationFrame(o.current), s.current !== null && clearTimeout(s.current), o.current = null, s.current = null;
|
|
3857
3857
|
const d = r.current;
|
|
3858
3858
|
d.length && (r.current = [], n({ type: "batch", payload: { events: d } }));
|
|
@@ -4098,7 +4098,7 @@ function Ew({
|
|
|
4098
4098
|
const [p, m] = de(null), v = Qe(
|
|
4099
4099
|
() => Yn(p),
|
|
4100
4100
|
[p]
|
|
4101
|
-
).checkpoints, g = sx(v), x = g.timeline, [b, w] = de(!1), [y, C] = de(null), [S, T] = de(!1), [k, R] = de(!1), [_, O] = de(!1), [$, W] = de(null), H =
|
|
4101
|
+
).checkpoints, g = sx(v), x = g.timeline, [b, w] = de(!1), [y, C] = de(null), [S, T] = de(!1), [k, R] = de(!1), [_, O] = de(!1), [$, W] = de(null), H = Le(o), N = Le(null), K = Le(null), V = Le(null), D = Le(null), j = Le(null), E = Le(/* @__PURE__ */ new Map());
|
|
4102
4102
|
Ze(() => {
|
|
4103
4103
|
H.current = o;
|
|
4104
4104
|
}, [o]);
|
|
@@ -4568,7 +4568,7 @@ function _w({
|
|
|
4568
4568
|
});
|
|
4569
4569
|
},
|
|
4570
4570
|
[i, O, r, o, s]
|
|
4571
|
-
), W =
|
|
4571
|
+
), W = Le(g);
|
|
4572
4572
|
Ze(() => {
|
|
4573
4573
|
W.current = g;
|
|
4574
4574
|
}, [g]);
|
|
@@ -4679,7 +4679,7 @@ function Mw(e, t) {
|
|
|
4679
4679
|
return !0;
|
|
4680
4680
|
}
|
|
4681
4681
|
function Ow(e) {
|
|
4682
|
-
const t =
|
|
4682
|
+
const t = Le(e), n = Le(e);
|
|
4683
4683
|
return Mw(t.current, e) || (t.current = e, n.current = e), n.current;
|
|
4684
4684
|
}
|
|
4685
4685
|
function Jr({
|
|
@@ -4722,7 +4722,7 @@ function Jr({
|
|
|
4722
4722
|
return /* @__PURE__ */ u.jsx(Jv, { apiConfig: p, children: /* @__PURE__ */ u.jsx(jw, { ...b, children: e }) });
|
|
4723
4723
|
}
|
|
4724
4724
|
function qr(e) {
|
|
4725
|
-
const t =
|
|
4725
|
+
const t = Le(e);
|
|
4726
4726
|
return Ze(() => {
|
|
4727
4727
|
t.current = e;
|
|
4728
4728
|
}, [e]), he((...n) => {
|
|
@@ -11470,8 +11470,8 @@ const uC = /* @__PURE__ */ Xe(
|
|
|
11470
11470
|
const Ve = $p(Nt, yt, _e);
|
|
11471
11471
|
let He, qe;
|
|
11472
11472
|
we ? Y === 0 && Q === 0 && ge > 0 ? (He = 0, qe = ge - 1) : (He = Ve * ys((Y + Ee) / (at + Ee)), qe = Ve * iu((Q + Ee) / (at + Ee)) - 1, qe = La(L - 1, Qr(qe, Ve - 1)), He = La(qe, Qr(0, He))) : (He = 0, qe = -1);
|
|
11473
|
-
const
|
|
11474
|
-
return { bottom: Ue, itemHeight: at, items:
|
|
11473
|
+
const $e = cu(He, qe, se), { bottom: Ue, top: pt } = uu(ae, J, B, $e), Pt = iu(L / Ve), it = Pt * at + (Pt - 1) * Ee - Ue;
|
|
11474
|
+
return { bottom: Ue, itemHeight: at, items: $e, itemWidth: yt, offsetBottom: it, offsetTop: pt, top: pt };
|
|
11475
11475
|
}
|
|
11476
11476
|
)
|
|
11477
11477
|
),
|
|
@@ -14508,19 +14508,21 @@ const mE = {
|
|
|
14508
14508
|
});
|
|
14509
14509
|
bh.displayName = "MessageRow";
|
|
14510
14510
|
function gE(e, t, n) {
|
|
14511
|
-
const [r, o] = de(e);
|
|
14511
|
+
const [r, o] = de(e), s = Le([]);
|
|
14512
14512
|
return Ze(() => {
|
|
14513
14513
|
if (!t) {
|
|
14514
|
-
o(e)
|
|
14514
|
+
o(e), s.current = e.map(
|
|
14515
|
+
(i) => i.type === "text" ? i.text ?? "" : void 0
|
|
14516
|
+
);
|
|
14515
14517
|
return;
|
|
14516
14518
|
}
|
|
14517
|
-
const
|
|
14518
|
-
if (
|
|
14519
|
-
return
|
|
14520
|
-
const
|
|
14521
|
-
return
|
|
14519
|
+
const a = e.map((i, l) => {
|
|
14520
|
+
if (i.type !== "text")
|
|
14521
|
+
return s.current[l] = void 0, i;
|
|
14522
|
+
const c = i.text ?? "", d = n(c), p = s.current[l];
|
|
14523
|
+
return d === c ? (s.current[l] = c, i) : { ...i, text: p ?? "" };
|
|
14522
14524
|
});
|
|
14523
|
-
o(
|
|
14525
|
+
o(a);
|
|
14524
14526
|
}, [e, t, n]), r;
|
|
14525
14527
|
}
|
|
14526
14528
|
function xE({
|
|
@@ -14952,7 +14954,7 @@ const Al = Pg(function({
|
|
|
14952
14954
|
g(t.id, Ce, Z);
|
|
14953
14955
|
}, [g, t.id, F, Ne, ge, t]), qe = he(() => {
|
|
14954
14956
|
x == null || x(n);
|
|
14955
|
-
}, [x, n]),
|
|
14957
|
+
}, [x, n]), $e = he(() => {
|
|
14956
14958
|
H((Ce) => Ce === "expanded" ? "preview" : "expanded");
|
|
14957
14959
|
}, []), Ue = he(() => {
|
|
14958
14960
|
const Z = ne(j ? "h-3 w-3" : "h-4 w-4", "opacity-60 flex-shrink-0", Y);
|
|
@@ -15118,7 +15120,7 @@ const Al = Pg(function({
|
|
|
15118
15120
|
messageRole: E,
|
|
15119
15121
|
toolViewMode: W,
|
|
15120
15122
|
toolMeta: we,
|
|
15121
|
-
onToggleToolView:
|
|
15123
|
+
onToggleToolView: $e,
|
|
15122
15124
|
onCopy: Ve,
|
|
15123
15125
|
onEdit: He,
|
|
15124
15126
|
onRegenerate: qe,
|
|
@@ -15245,7 +15247,7 @@ const yh = M.forwardRef(({
|
|
|
15245
15247
|
createSyntheticThinkingMessage: O = !0,
|
|
15246
15248
|
forceSyntheticThinking: $ = !1
|
|
15247
15249
|
}, W) => {
|
|
15248
|
-
const H =
|
|
15250
|
+
const H = Le(null), N = Le(null), K = Le(!1), V = Le(!1), [D, j] = de(!0), E = Qe(() => w ? e.some((B) => B.role === "default_message" ? !1 : Array.isArray(B == null ? void 0 : B.content) && B.content.some(
|
|
15249
15251
|
(ae) => ae && ae.type === "interrupt" && (ae.id ?? ae.interrupt_id) === w.id
|
|
15250
15252
|
)) : !1, [w, e]), F = Qe(() => {
|
|
15251
15253
|
if (!w || E)
|
|
@@ -15448,16 +15450,16 @@ function to({
|
|
|
15448
15450
|
q(!0);
|
|
15449
15451
|
}, []), L = he(() => {
|
|
15450
15452
|
q(!1);
|
|
15451
|
-
}, []), Y = !!A || P, [Q, J] = de(null), [B, ae] = de(""), [se, ge] = de(null), [we, Ne] = de(null), [_e, Ee] = de([]), [at, yt] = de(0), [Nt, Ve] = de(0), [He, qe] = de(!1), [
|
|
15453
|
+
}, []), Y = !!A || P, [Q, J] = de(null), [B, ae] = de(""), [se, ge] = de(null), [we, Ne] = de(null), [_e, Ee] = de([]), [at, yt] = de(0), [Nt, Ve] = de(0), [He, qe] = de(!1), [$e, Ue] = de(null), [pt, Pt] = de(null), [it, Mt] = de(!1), [Tt, gt] = de(null), At = Le(!1), [Ct, Et] = de(() => bu.value), zt = Le(Ct), xt = Le(null), Me = he((ie) => {
|
|
15452
15454
|
bu.value = ie, Et(ie);
|
|
15453
|
-
}, []), [Ke, Ce] = de(!1), Z =
|
|
15455
|
+
}, []), [Ke, Ce] = de(!1), Z = Le(null), pe = Le(null), et = Le(null), xe = he(() => {
|
|
15454
15456
|
pe.current && (pe.current.value = ""), et.current && (et.current.value = ""), yt((ie) => ie + 1), Ve((ie) => ie + 1);
|
|
15455
|
-
}, []),
|
|
15457
|
+
}, []), Fe = he(
|
|
15456
15458
|
(ie) => {
|
|
15457
15459
|
Me(ie);
|
|
15458
15460
|
},
|
|
15459
15461
|
[Me]
|
|
15460
|
-
), Ge =
|
|
15462
|
+
), Ge = Le(!1);
|
|
15461
15463
|
Ze(() => {
|
|
15462
15464
|
Ge.current && !H && (Ee([]), xe()), Ge.current = H;
|
|
15463
15465
|
}, [H, xe]), Ze(() => {
|
|
@@ -15745,7 +15747,7 @@ function to({
|
|
|
15745
15747
|
" Uploading Excel file..."
|
|
15746
15748
|
] }),
|
|
15747
15749
|
pt && !He && /* @__PURE__ */ u.jsx("div", { className: "text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700", children: pt }),
|
|
15748
|
-
|
|
15750
|
+
$e && !He && /* @__PURE__ */ u.jsx("div", { className: "text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600", children: $e })
|
|
15749
15751
|
] })
|
|
15750
15752
|
] }),
|
|
15751
15753
|
we && /* @__PURE__ */ u.jsx("div", { className: "mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2", children: we }),
|
|
@@ -15793,7 +15795,7 @@ function to({
|
|
|
15793
15795
|
initialValue: B,
|
|
15794
15796
|
editingMessageId: Q,
|
|
15795
15797
|
value: Ct,
|
|
15796
|
-
onValueChange:
|
|
15798
|
+
onValueChange: Fe,
|
|
15797
15799
|
placeholder: Q ? "Edit your message..." : t,
|
|
15798
15800
|
isStreaming: H,
|
|
15799
15801
|
disabled: Y,
|
|
@@ -16926,7 +16928,7 @@ function hi({
|
|
|
16926
16928
|
shareInFlight: $,
|
|
16927
16929
|
shareStatus: W,
|
|
16928
16930
|
clearShareStatus: H
|
|
16929
|
-
} = To(), { createThread: N, deleteThread: K, renameThread: V, shareThread: D } = O, { loadThread: j } = Ds(), E = a ?? T, [F, G] = de(Array.isArray(C) ? C : []), A =
|
|
16931
|
+
} = To(), { createThread: N, deleteThread: K, renameThread: V, shareThread: D } = O, { loadThread: j } = Ds(), E = a ?? T, [F, G] = de(Array.isArray(C) ? C : []), A = Le(F.length > 0), P = Le(null), q = Le(0), [X, oe] = de(null), [U, L] = de(""), [Y, Q] = de(!1), [J, B] = de(!1), [ae, se] = de(null), [ge, we] = de(""), Ne = v && v.length > 0 ? v : mk, _e = hk({ defaultView: m }), Ee = g ?? _e, at = p ?? Ee.view, yt = he(
|
|
16930
16932
|
(Z) => {
|
|
16931
16933
|
p || Ee.setView(Z), f == null || f(Z);
|
|
16932
16934
|
},
|
|
@@ -16945,7 +16947,7 @@ function hi({
|
|
|
16945
16947
|
}
|
|
16946
16948
|
},
|
|
16947
16949
|
[He, $, ae, D]
|
|
16948
|
-
),
|
|
16950
|
+
), $e = Qe(() => {
|
|
16949
16951
|
const Z = b ?? [], pe = ge.trim().toLowerCase();
|
|
16950
16952
|
return pe ? y ? Z.filter((et) => y(et, pe)) : Z.filter((et) => `${et.label} ${et.secondaryLabel ?? ""}`.toLowerCase().includes(pe)) : Z;
|
|
16951
16953
|
}, [b, ge, y]), Ue = at === "shared", pt = Ue ? S : F, Pt = Ue ? _ : R, it = Ue ? "No shared conversations yet" : "No conversations yet", Mt = (Z) => {
|
|
@@ -17016,8 +17018,8 @@ function hi({
|
|
|
17016
17018
|
}, Me = (Z) => {
|
|
17017
17019
|
if (!Z) return "";
|
|
17018
17020
|
try {
|
|
17019
|
-
const pe = new Date(Z), xe = (/* @__PURE__ */ new Date()).getTime() - pe.getTime(),
|
|
17020
|
-
return
|
|
17021
|
+
const pe = new Date(Z), xe = (/* @__PURE__ */ new Date()).getTime() - pe.getTime(), Fe = Math.floor(xe / (1e3 * 60 * 60 * 24));
|
|
17022
|
+
return Fe === 0 ? pe.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" }) : Fe === 1 ? "Yesterday" : Fe < 7 ? `${Fe} days ago` : pe.toLocaleDateString();
|
|
17021
17023
|
} catch {
|
|
17022
17024
|
return "";
|
|
17023
17025
|
}
|
|
@@ -17142,7 +17144,7 @@ function hi({
|
|
|
17142
17144
|
/* @__PURE__ */ u.jsx(Xn, { className: "h-4 w-4 animate-spin" }),
|
|
17143
17145
|
"Loading recipients…"
|
|
17144
17146
|
] }) : "No matching recipients found" }),
|
|
17145
|
-
|
|
17147
|
+
$e.length > 0 && /* @__PURE__ */ u.jsx(Mh, { heading: "Recipients", children: $e.map((Z) => /* @__PURE__ */ u.jsx(Oh, { onSelect: () => qe(Z), children: /* @__PURE__ */ u.jsxs("div", { className: "flex flex-col items-start text-sm", children: [
|
|
17146
17148
|
/* @__PURE__ */ u.jsx("span", { className: "font-medium", children: Z.label }),
|
|
17147
17149
|
Z.secondaryLabel && /* @__PURE__ */ u.jsx("span", { className: "text-xs text-muted-foreground", children: Z.secondaryLabel })
|
|
17148
17150
|
] }) }, Z.id)) })
|
|
@@ -19530,10 +19532,10 @@ function jI(e) {
|
|
|
19530
19532
|
}
|
|
19531
19533
|
var _I = (e) => {
|
|
19532
19534
|
var t, n, r, o, s, a, i, l, c, d, p;
|
|
19533
|
-
let { invert: m, toast: f, unstyled: v, interacting: g, setHeights: x, visibleToasts: b, heights: w, index: y, toasts: C, expanded: S, removeToast: T, defaultRichColors: k, closeButton: R, style: _, cancelButtonStyle: O, actionButtonStyle: $, className: W = "", descriptionClassName: H = "", duration: N, position: K, gap: V, loadingIcon: D, expandByDefault: j, classNames: E, icons: F, closeButtonAriaLabel: G = "Close toast", pauseWhenPageIsHidden: A } = e, [P, q] = M.useState(null), [X, oe] = M.useState(null), [U, L] = M.useState(!1), [Y, Q] = M.useState(!1), [J, B] = M.useState(!1), [ae, se] = M.useState(!1), [ge, we] = M.useState(!1), [Ne, _e] = M.useState(0), [Ee, at] = M.useState(0), yt = M.useRef(f.duration || N || Iu), Nt = M.useRef(null), Ve = M.useRef(null), He = y === 0, qe = y + 1 <= b,
|
|
19535
|
+
let { invert: m, toast: f, unstyled: v, interacting: g, setHeights: x, visibleToasts: b, heights: w, index: y, toasts: C, expanded: S, removeToast: T, defaultRichColors: k, closeButton: R, style: _, cancelButtonStyle: O, actionButtonStyle: $, className: W = "", descriptionClassName: H = "", duration: N, position: K, gap: V, loadingIcon: D, expandByDefault: j, classNames: E, icons: F, closeButtonAriaLabel: G = "Close toast", pauseWhenPageIsHidden: A } = e, [P, q] = M.useState(null), [X, oe] = M.useState(null), [U, L] = M.useState(!1), [Y, Q] = M.useState(!1), [J, B] = M.useState(!1), [ae, se] = M.useState(!1), [ge, we] = M.useState(!1), [Ne, _e] = M.useState(0), [Ee, at] = M.useState(0), yt = M.useRef(f.duration || N || Iu), Nt = M.useRef(null), Ve = M.useRef(null), He = y === 0, qe = y + 1 <= b, $e = f.type, Ue = f.dismissible !== !1, pt = f.className || "", Pt = f.descriptionClassName || "", it = M.useMemo(() => w.findIndex((xe) => xe.toastId === f.id) || 0, [w, f.id]), Mt = M.useMemo(() => {
|
|
19534
19536
|
var xe;
|
|
19535
19537
|
return (xe = f.closeButton) != null ? xe : R;
|
|
19536
|
-
}, [f.closeButton, R]), Tt = M.useMemo(() => f.duration || N || Iu, [f.duration, N]), gt = M.useRef(0), At = M.useRef(0), Ct = M.useRef(0), Et = M.useRef(null), [zt, xt] = K.split("-"), Me = M.useMemo(() => w.reduce((xe,
|
|
19538
|
+
}, [f.closeButton, R]), Tt = M.useMemo(() => f.duration || N || Iu, [f.duration, N]), gt = M.useRef(0), At = M.useRef(0), Ct = M.useRef(0), Et = M.useRef(null), [zt, xt] = K.split("-"), Me = M.useMemo(() => w.reduce((xe, Fe, Ge) => Ge >= it ? xe : xe + Fe.height, 0), [w, it]), Ke = gI(), Ce = f.invert || m, Z = $e === "loading";
|
|
19537
19539
|
At.current = M.useMemo(() => it * V + Me, [it, Me]), M.useEffect(() => {
|
|
19538
19540
|
yt.current = Tt;
|
|
19539
19541
|
}, [Tt]), M.useEffect(() => {
|
|
@@ -19541,58 +19543,58 @@ var _I = (e) => {
|
|
|
19541
19543
|
}, []), M.useEffect(() => {
|
|
19542
19544
|
let xe = Ve.current;
|
|
19543
19545
|
if (xe) {
|
|
19544
|
-
let
|
|
19545
|
-
return at(
|
|
19546
|
+
let Fe = xe.getBoundingClientRect().height;
|
|
19547
|
+
return at(Fe), x((Ge) => [{ toastId: f.id, height: Fe, position: f.position }, ...Ge]), () => x((Ge) => Ge.filter((kt) => kt.toastId !== f.id));
|
|
19546
19548
|
}
|
|
19547
19549
|
}, [x, f.id]), M.useLayoutEffect(() => {
|
|
19548
19550
|
if (!U) return;
|
|
19549
|
-
let xe = Ve.current,
|
|
19551
|
+
let xe = Ve.current, Fe = xe.style.height;
|
|
19550
19552
|
xe.style.height = "auto";
|
|
19551
19553
|
let Ge = xe.getBoundingClientRect().height;
|
|
19552
|
-
xe.style.height =
|
|
19554
|
+
xe.style.height = Fe, at(Ge), x((kt) => kt.find((Rt) => Rt.toastId === f.id) ? kt.map((Rt) => Rt.toastId === f.id ? { ...Rt, height: Ge } : Rt) : [{ toastId: f.id, height: Ge, position: f.position }, ...kt]);
|
|
19553
19555
|
}, [U, f.title, f.description, x, f.id]);
|
|
19554
19556
|
let pe = M.useCallback(() => {
|
|
19555
|
-
Q(!0), _e(At.current), x((xe) => xe.filter((
|
|
19557
|
+
Q(!0), _e(At.current), x((xe) => xe.filter((Fe) => Fe.toastId !== f.id)), setTimeout(() => {
|
|
19556
19558
|
T(f);
|
|
19557
19559
|
}, AI);
|
|
19558
19560
|
}, [f, T, x, At]);
|
|
19559
19561
|
M.useEffect(() => {
|
|
19560
|
-
if (f.promise &&
|
|
19562
|
+
if (f.promise && $e === "loading" || f.duration === 1 / 0 || f.type === "loading") return;
|
|
19561
19563
|
let xe;
|
|
19562
19564
|
return S || g || A && Ke ? (() => {
|
|
19563
19565
|
if (Ct.current < gt.current) {
|
|
19564
|
-
let
|
|
19565
|
-
yt.current = yt.current -
|
|
19566
|
+
let Fe = (/* @__PURE__ */ new Date()).getTime() - gt.current;
|
|
19567
|
+
yt.current = yt.current - Fe;
|
|
19566
19568
|
}
|
|
19567
19569
|
Ct.current = (/* @__PURE__ */ new Date()).getTime();
|
|
19568
19570
|
})() : yt.current !== 1 / 0 && (gt.current = (/* @__PURE__ */ new Date()).getTime(), xe = setTimeout(() => {
|
|
19569
|
-
var
|
|
19570
|
-
(
|
|
19571
|
+
var Fe;
|
|
19572
|
+
(Fe = f.onAutoClose) == null || Fe.call(f, f), pe();
|
|
19571
19573
|
}, yt.current)), () => clearTimeout(xe);
|
|
19572
|
-
}, [S, g, f,
|
|
19574
|
+
}, [S, g, f, $e, A, Ke, pe]), M.useEffect(() => {
|
|
19573
19575
|
f.delete && pe();
|
|
19574
19576
|
}, [pe, f.delete]);
|
|
19575
19577
|
function et() {
|
|
19576
|
-
var xe,
|
|
19577
|
-
return F != null && F.loading ? M.createElement("div", { className: un(E == null ? void 0 : E.loader, (xe = f == null ? void 0 : f.classNames) == null ? void 0 : xe.loader, "sonner-loader"), "data-visible":
|
|
19578
|
+
var xe, Fe, Ge;
|
|
19579
|
+
return F != null && F.loading ? M.createElement("div", { className: un(E == null ? void 0 : E.loader, (xe = f == null ? void 0 : f.classNames) == null ? void 0 : xe.loader, "sonner-loader"), "data-visible": $e === "loading" }, F.loading) : D ? M.createElement("div", { className: un(E == null ? void 0 : E.loader, (Fe = f == null ? void 0 : f.classNames) == null ? void 0 : Fe.loader, "sonner-loader"), "data-visible": $e === "loading" }, D) : M.createElement(uI, { className: un(E == null ? void 0 : E.loader, (Ge = f == null ? void 0 : f.classNames) == null ? void 0 : Ge.loader), visible: $e === "loading" });
|
|
19578
19580
|
}
|
|
19579
|
-
return M.createElement("li", { tabIndex: 0, ref: Ve, className: un(W, pt, E == null ? void 0 : E.toast, (t = f == null ? void 0 : f.classNames) == null ? void 0 : t.toast, E == null ? void 0 : E.default, E == null ? void 0 : E[
|
|
19581
|
+
return M.createElement("li", { tabIndex: 0, ref: Ve, className: un(W, pt, E == null ? void 0 : E.toast, (t = f == null ? void 0 : f.classNames) == null ? void 0 : t.toast, E == null ? void 0 : E.default, E == null ? void 0 : E[$e], (n = f == null ? void 0 : f.classNames) == null ? void 0 : n[$e]), "data-sonner-toast": "", "data-rich-colors": (r = f.richColors) != null ? r : k, "data-styled": !(f.jsx || f.unstyled || v), "data-mounted": U, "data-promise": !!f.promise, "data-swiped": ge, "data-removed": Y, "data-visible": qe, "data-y-position": zt, "data-x-position": xt, "data-index": y, "data-front": He, "data-swiping": J, "data-dismissible": Ue, "data-type": $e, "data-invert": Ce, "data-swipe-out": ae, "data-swipe-direction": X, "data-expanded": !!(S || j && U), style: { "--index": y, "--toasts-before": y, "--z-index": C.length - y, "--offset": `${Y ? Ne : At.current}px`, "--initial-height": j ? "auto" : `${Ee}px`, ..._, ...f.style }, onDragEnd: () => {
|
|
19580
19582
|
B(!1), q(null), Et.current = null;
|
|
19581
19583
|
}, onPointerDown: (xe) => {
|
|
19582
19584
|
Z || !Ue || (Nt.current = /* @__PURE__ */ new Date(), _e(At.current), xe.target.setPointerCapture(xe.pointerId), xe.target.tagName !== "BUTTON" && (B(!0), Et.current = { x: xe.clientX, y: xe.clientY }));
|
|
19583
19585
|
}, onPointerUp: () => {
|
|
19584
|
-
var xe,
|
|
19586
|
+
var xe, Fe, Ge, kt;
|
|
19585
19587
|
if (ae || !Ue) return;
|
|
19586
19588
|
Et.current = null;
|
|
19587
|
-
let Rt = Number(((xe = Ve.current) == null ? void 0 : xe.style.getPropertyValue("--swipe-amount-x").replace("px", "")) || 0), jt = Number(((
|
|
19589
|
+
let Rt = Number(((xe = Ve.current) == null ? void 0 : xe.style.getPropertyValue("--swipe-amount-x").replace("px", "")) || 0), jt = Number(((Fe = Ve.current) == null ? void 0 : Fe.style.getPropertyValue("--swipe-amount-y").replace("px", "")) || 0), Ot = (/* @__PURE__ */ new Date()).getTime() - ((Ge = Nt.current) == null ? void 0 : Ge.getTime()), Ae = P === "x" ? Rt : jt, ht = Math.abs(Ae) / Ot;
|
|
19588
19590
|
if (Math.abs(Ae) >= NI || ht > 0.11) {
|
|
19589
19591
|
_e(At.current), (kt = f.onDismiss) == null || kt.call(f, f), oe(P === "x" ? Rt > 0 ? "right" : "left" : jt > 0 ? "down" : "up"), pe(), se(!0), we(!1);
|
|
19590
19592
|
return;
|
|
19591
19593
|
}
|
|
19592
19594
|
B(!1), q(null);
|
|
19593
19595
|
}, onPointerMove: (xe) => {
|
|
19594
|
-
var
|
|
19595
|
-
if (!Et.current || !Ue || ((
|
|
19596
|
+
var Fe, Ge, kt, Rt;
|
|
19597
|
+
if (!Et.current || !Ue || ((Fe = window.getSelection()) == null ? void 0 : Fe.toString().length) > 0) return;
|
|
19596
19598
|
let jt = xe.clientY - Et.current.y, Ot = xe.clientX - Et.current.x, Ae = (Ge = e.swipeDirections) != null ? Ge : jI(K);
|
|
19597
19599
|
!P && (Math.abs(Ot) > 1 || Math.abs(jt) > 1) && q(Math.abs(Ot) > Math.abs(jt) ? "x" : "y");
|
|
19598
19600
|
let ht = { x: 0, y: 0 };
|
|
@@ -19601,12 +19603,12 @@ var _I = (e) => {
|
|
|
19601
19603
|
} : () => {
|
|
19602
19604
|
var xe;
|
|
19603
19605
|
pe(), (xe = f.onDismiss) == null || xe.call(f, f);
|
|
19604
|
-
}, className: un(E == null ? void 0 : E.closeButton, (o = f == null ? void 0 : f.classNames) == null ? void 0 : o.closeButton) }, (s = F == null ? void 0 : F.close) != null ? s : mI) : null, f.jsx || ga(f.title) ? f.jsx ? f.jsx : typeof f.title == "function" ? f.title() : f.title : M.createElement(M.Fragment, null,
|
|
19605
|
-
var
|
|
19606
|
-
Go(f.cancel) && Ue && ((Ge = (
|
|
19606
|
+
}, className: un(E == null ? void 0 : E.closeButton, (o = f == null ? void 0 : f.classNames) == null ? void 0 : o.closeButton) }, (s = F == null ? void 0 : F.close) != null ? s : mI) : null, f.jsx || ga(f.title) ? f.jsx ? f.jsx : typeof f.title == "function" ? f.title() : f.title : M.createElement(M.Fragment, null, $e || f.icon || f.promise ? M.createElement("div", { "data-icon": "", className: un(E == null ? void 0 : E.icon, (a = f == null ? void 0 : f.classNames) == null ? void 0 : a.icon) }, f.promise || f.type === "loading" && !f.icon ? f.icon || et() : null, f.type !== "loading" ? f.icon || (F == null ? void 0 : F[$e]) || lI($e) : null) : null, M.createElement("div", { "data-content": "", className: un(E == null ? void 0 : E.content, (i = f == null ? void 0 : f.classNames) == null ? void 0 : i.content) }, M.createElement("div", { "data-title": "", className: un(E == null ? void 0 : E.title, (l = f == null ? void 0 : f.classNames) == null ? void 0 : l.title) }, typeof f.title == "function" ? f.title() : f.title), f.description ? M.createElement("div", { "data-description": "", className: un(H, Pt, E == null ? void 0 : E.description, (c = f == null ? void 0 : f.classNames) == null ? void 0 : c.description) }, typeof f.description == "function" ? f.description() : f.description) : null), ga(f.cancel) ? f.cancel : f.cancel && Go(f.cancel) ? M.createElement("button", { "data-button": !0, "data-cancel": !0, style: f.cancelButtonStyle || O, onClick: (xe) => {
|
|
19607
|
+
var Fe, Ge;
|
|
19608
|
+
Go(f.cancel) && Ue && ((Ge = (Fe = f.cancel).onClick) == null || Ge.call(Fe, xe), pe());
|
|
19607
19609
|
}, className: un(E == null ? void 0 : E.cancelButton, (d = f == null ? void 0 : f.classNames) == null ? void 0 : d.cancelButton) }, f.cancel.label) : null, ga(f.action) ? f.action : f.action && Go(f.action) ? M.createElement("button", { "data-button": !0, "data-action": !0, style: f.actionButtonStyle || $, onClick: (xe) => {
|
|
19608
|
-
var
|
|
19609
|
-
Go(f.action) && ((Ge = (
|
|
19610
|
+
var Fe, Ge;
|
|
19611
|
+
Go(f.action) && ((Ge = (Fe = f.action).onClick) == null || Ge.call(Fe, xe), !xe.defaultPrevented && pe());
|
|
19610
19612
|
}, className: un(E == null ? void 0 : E.actionButton, (p = f == null ? void 0 : f.classNames) == null ? void 0 : p.actionButton) }, f.action.label) : null));
|
|
19611
19613
|
};
|
|
19612
19614
|
function Nu() {
|
package/dist/index.umd.js
CHANGED
|
@@ -125,6 +125,6 @@ ${t}</tr>
|
|
|
125
125
|
`}tablecell(t,n){const r=n.header?"th":"td";return(n.align?`<${r} align="${n.align}">`:`<${r}>`)+t+`</${r}>
|
|
126
126
|
`}strong(t){return`<strong>${t}</strong>`}em(t){return`<em>${t}</em>`}codespan(t){return`<code>${t}</code>`}br(){return this.options.xhtml?"<br/>":"<br>"}del(t){return`<del>${t}</del>`}link(t,n,r){if(t=fp(this.options.sanitize,this.options.baseUrl,t),t===null)return r;let o='<a href="'+t+'"';return n&&(o+=' title="'+n+'"'),o+=">"+r+"</a>",o}image(t,n,r){if(t=fp(this.options.sanitize,this.options.baseUrl,t),t===null)return r;let o=`<img src="${t}" alt="${r}"`;return n&&(o+=` title="${n}"`),o+=this.options.xhtml?"/>":">",o}text(t){return t}}class xp{strong(t){return t}em(t){return t}codespan(t){return t}del(t){return t}html(t){return t}text(t){return t}link(t,n,r){return""+r}image(t,n,r){return""+r}br(){return""}}class vp{constructor(){this.seen={}}serialize(t){return t.toLowerCase().trim().replace(/<[!\/a-z].*?>/ig,"").replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g,"").replace(/\s/g,"-")}getNextSafeSlug(t,n){let r=t,o=0;if(this.seen.hasOwnProperty(r)){o=this.seen[t];do o++,r=t+"-"+o;while(this.seen.hasOwnProperty(r))}return n||(this.seen[t]=o,this.seen[r]=0),r}slug(t,n={}){const r=this.serialize(t);return this.getNextSafeSlug(r,n.dryrun)}}class Kn{constructor(t){this.options=t||lr,this.options.renderer=this.options.renderer||new ol,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new xp,this.slugger=new vp}static parse(t,n){return new Kn(n).parse(t)}static parseInline(t,n){return new Kn(n).parseInline(t)}parse(t,n=!0){let r="",o,s,i,a,l,c,d,h,m,f,v,g,x,y,w,S,k,C,T;const I=t.length;for(o=0;o<I;o++){if(f=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[f.type]&&(T=this.options.extensions.renderers[f.type].call({parser:this},f),T!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(f.type))){r+=T||"";continue}switch(f.type){case"space":continue;case"hr":{r+=this.renderer.hr();continue}case"heading":{r+=this.renderer.heading(this.parseInline(f.tokens),f.depth,dp(this.parseInline(f.tokens,this.textRenderer)),this.slugger);continue}case"code":{r+=this.renderer.code(f.text,f.lang,f.escaped);continue}case"table":{for(h="",d="",a=f.header.length,s=0;s<a;s++)d+=this.renderer.tablecell(this.parseInline(f.header[s].tokens),{header:!0,align:f.align[s]});for(h+=this.renderer.tablerow(d),m="",a=f.rows.length,s=0;s<a;s++){for(c=f.rows[s],d="",l=c.length,i=0;i<l;i++)d+=this.renderer.tablecell(this.parseInline(c[i].tokens),{header:!1,align:f.align[i]});m+=this.renderer.tablerow(d)}r+=this.renderer.table(h,m);continue}case"blockquote":{m=this.parse(f.tokens),r+=this.renderer.blockquote(m);continue}case"list":{for(v=f.ordered,g=f.start,x=f.loose,a=f.items.length,m="",s=0;s<a;s++)w=f.items[s],S=w.checked,k=w.task,y="",w.task&&(C=this.renderer.checkbox(S),x?w.tokens.length>0&&w.tokens[0].type==="paragraph"?(w.tokens[0].text=C+" "+w.tokens[0].text,w.tokens[0].tokens&&w.tokens[0].tokens.length>0&&w.tokens[0].tokens[0].type==="text"&&(w.tokens[0].tokens[0].text=C+" "+w.tokens[0].tokens[0].text)):w.tokens.unshift({type:"text",text:C}):y+=C),y+=this.parse(w.tokens,x),m+=this.renderer.listitem(y,k,S);r+=this.renderer.list(m,v,g);continue}case"html":{r+=this.renderer.html(f.text);continue}case"paragraph":{r+=this.renderer.paragraph(this.parseInline(f.tokens));continue}case"text":{for(m=f.tokens?this.parseInline(f.tokens):f.text;o+1<I&&t[o+1].type==="text";)f=t[++o],m+=`
|
|
127
127
|
`+(f.tokens?this.parseInline(f.tokens):f.text);r+=n?this.renderer.paragraph(m):m;continue}default:{const N='Token with "'+f.type+'" type was not found.';if(this.options.silent){console.error(N);return}else throw new Error(N)}}}return r}parseInline(t,n){n=n||this.renderer;let r="",o,s,i;const a=t.length;for(o=0;o<a;o++){if(s=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[s.type]&&(i=this.options.extensions.renderers[s.type].call({parser:this},s),i!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type))){r+=i||"";continue}switch(s.type){case"escape":{r+=n.text(s.text);break}case"html":{r+=n.html(s.text);break}case"link":{r+=n.link(s.href,s.title,this.parseInline(s.tokens,n));break}case"image":{r+=n.image(s.href,s.title,s.text);break}case"strong":{r+=n.strong(this.parseInline(s.tokens,n));break}case"em":{r+=n.em(this.parseInline(s.tokens,n));break}case"codespan":{r+=n.codespan(s.text);break}case"br":{r+=n.br();break}case"del":{r+=n.del(this.parseInline(s.tokens,n));break}case"text":{r+=n.text(s.text);break}default:{const l='Token with "'+s.type+'" type was not found.';if(this.options.silent){console.error(l);return}else throw new Error(l)}}}return r}}class Gs{constructor(t){this.options=t||lr}preprocess(t){return t}postprocess(t){return t}}Qg(Gs,"passThroughHooks",new Set(["preprocess","postprocess"]));function _T(e,t,n){return r=>{if(r.message+=`
|
|
128
|
-
Please report this to https://github.com/markedjs/marked.`,e){const o="<p>An error occurred:</p><pre>"+Dt(r.message+"",!0)+"</pre>";if(t)return Promise.resolve(o);if(n){n(null,o);return}return o}if(t)return Promise.reject(r);if(n){n(r);return}throw r}}function bp(e,t){return(n,r,o)=>{typeof r=="function"&&(o=r,r=null);const s={...r};r={...ye.defaults,...s};const i=_T(r.silent,r.async,o);if(typeof n>"u"||n===null)return i(new Error("marked(): input parameter is undefined or null"));if(typeof n!="string")return i(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(n)+", string expected"));if(NT(r),r.hooks&&(r.hooks.options=r),o){const a=r.highlight;let l;try{r.hooks&&(n=r.hooks.preprocess(n)),l=e(n,r)}catch(h){return i(h)}const c=function(h){let m;if(!h)try{r.walkTokens&&ye.walkTokens(l,r.walkTokens),m=t(l,r),r.hooks&&(m=r.hooks.postprocess(m))}catch(f){h=f}return r.highlight=a,h?i(h):o(null,m)};if(!a||a.length<3||(delete r.highlight,!l.length))return c();let d=0;ye.walkTokens(l,function(h){h.type==="code"&&(d++,setTimeout(()=>{a(h.text,h.lang,function(m,f){if(m)return c(m);f!=null&&f!==h.text&&(h.text=f,h.escaped=!0),d--,d===0&&c()})},0))}),d===0&&c();return}if(r.async)return Promise.resolve(r.hooks?r.hooks.preprocess(n):n).then(a=>e(a,r)).then(a=>r.walkTokens?Promise.all(ye.walkTokens(a,r.walkTokens)).then(()=>a):a).then(a=>t(a,r)).then(a=>r.hooks?r.hooks.postprocess(a):a).catch(i);try{r.hooks&&(n=r.hooks.preprocess(n));const a=e(n,r);r.walkTokens&&ye.walkTokens(a,r.walkTokens);let l=t(a,r);return r.hooks&&(l=r.hooks.postprocess(l)),l}catch(a){return i(a)}}}function ye(e,t,n){return bp(Vn.lex,Kn.parse)(e,t,n)}ye.options=ye.setOptions=function(e){return ye.defaults={...ye.defaults,...e},mT(ye.defaults),ye},ye.getDefaults=ap,ye.defaults=lr,ye.use=function(...e){const t=ye.defaults.extensions||{renderers:{},childTokens:{}};e.forEach(n=>{const r={...n};if(r.async=ye.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(o=>{if(!o.name)throw new Error("extension name required");if(o.renderer){const s=t.renderers[o.name];s?t.renderers[o.name]=function(...i){let a=o.renderer.apply(this,i);return a===!1&&(a=s.apply(this,i)),a}:t.renderers[o.name]=o.renderer}if(o.tokenizer){if(!o.level||o.level!=="block"&&o.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");t[o.level]?t[o.level].unshift(o.tokenizer):t[o.level]=[o.tokenizer],o.start&&(o.level==="block"?t.startBlock?t.startBlock.push(o.start):t.startBlock=[o.start]:o.level==="inline"&&(t.startInline?t.startInline.push(o.start):t.startInline=[o.start]))}o.childTokens&&(t.childTokens[o.name]=o.childTokens)}),r.extensions=t),n.renderer){const o=ye.defaults.renderer||new ol;for(const s in n.renderer){const i=o[s];o[s]=(...a)=>{let l=n.renderer[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.renderer=o}if(n.tokenizer){const o=ye.defaults.tokenizer||new rl;for(const s in n.tokenizer){const i=o[s];o[s]=(...a)=>{let l=n.tokenizer[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.tokenizer=o}if(n.hooks){const o=ye.defaults.hooks||new Gs;for(const s in n.hooks){const i=o[s];Gs.passThroughHooks.has(s)?o[s]=a=>{if(ye.defaults.async)return Promise.resolve(n.hooks[s].call(o,a)).then(c=>i.call(o,c));const l=n.hooks[s].call(o,a);return i.call(o,l)}:o[s]=(...a)=>{let l=n.hooks[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.hooks=o}if(n.walkTokens){const o=ye.defaults.walkTokens;r.walkTokens=function(s){let i=[];return i.push(n.walkTokens.call(this,s)),o&&(i=i.concat(o.call(this,s))),i}}ye.setOptions(r)})},ye.walkTokens=function(e,t){let n=[];for(const r of e)switch(n=n.concat(t.call(ye,r)),r.type){case"table":{for(const o of r.header)n=n.concat(ye.walkTokens(o.tokens,t));for(const o of r.rows)for(const s of o)n=n.concat(ye.walkTokens(s.tokens,t));break}case"list":{n=n.concat(ye.walkTokens(r.items,t));break}default:ye.defaults.extensions&&ye.defaults.extensions.childTokens&&ye.defaults.extensions.childTokens[r.type]?ye.defaults.extensions.childTokens[r.type].forEach(function(o){n=n.concat(ye.walkTokens(r[o],t))}):r.tokens&&(n=n.concat(ye.walkTokens(r.tokens,t)))}return n},ye.parseInline=bp(Vn.lexInline,Kn.parseInline),ye.Parser=Kn,ye.parser=Kn.parse,ye.Renderer=ol,ye.TextRenderer=xp,ye.Lexer=Vn,ye.lexer=Vn.lex,ye.Tokenizer=rl,ye.Slugger=vp,ye.Hooks=Gs,ye.parse=ye,ye.options,ye.setOptions,ye.use,ye.walkTokens,ye.parseInline,Kn.parse,Vn.lex;function Rr({content:e,className:t="",allowHtml:n=!1,style:r}){const o=b.useMemo(()=>{if(!e||typeof e!="string"||e.trim().length===0)return"";try{if(!n){const i=e.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"").replace(/<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi,"").replace(/javascript:/gi,"").replace(/on\w+\s*=/gi,"");return typeof ye.parse=="function"?ye.parse(i):ye(i)}return typeof ye.parse=="function"?ye.parse(e):ye(e)}catch(i){return console.error("[MarkdownContent] parse error",i),`<pre class="font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words">Error rendering markdown: ${String(i)}</pre>`}},[e,n]),s=b.useMemo(()=>{const i={color:"currentColor",...r};if(r&&r.color){const a=r.color;return{...i,"--tw-prose-body":a,"--tw-prose-headings":a,"--tw-prose-links":a,"--tw-prose-bold":a,"--tw-prose-counters":a,"--tw-prose-bullets":a,"--tw-prose-hr":a,"--tw-prose-quotes":a,"--tw-prose-quote-borders":a,"--tw-prose-captions":a,"--tw-prose-code":a,"--tw-prose-pre-code":a,"--tw-prose-pre-bg":"inherit","--tw-prose-th-borders":a,"--tw-prose-td-borders":a}}return i},[r]);return u.jsx("div",{className:re("markdown prose prose-sm max-w-none break-words","dark:prose-invert","text-current","prose-headings:text-current prose-p:text-current prose-li:text-current prose-a:text-current prose-strong:text-current","prose-em:text-current prose-blockquote:text-current prose-table:text-current prose-td:text-current prose-th:text-current","prose-pre:font-mono prose-pre:text-xs prose-pre:bg-background/50 prose-pre:border prose-pre:rounded prose-pre:p-3 prose-pre:whitespace-pre prose-pre:overflow-x-auto","prose-code:font-mono prose-code:text-sm prose-code:bg-background/50 prose-code:px-1.5 prose-code:py-0.5 prose-code:rounded prose-code:text-current",t),style:s,dangerouslySetInnerHTML:{__html:o}})}function wp({preview:e,idx:t}){return u.jsxs("div",{className:"space-y-2",children:[e.label&&u.jsxs("p",{className:"text-[0.65rem] uppercase tracking-wide text-muted-foreground",children:["Artifact: ",e.label]}),u.jsx("div",{className:"overflow-hidden rounded border border-border/60 bg-background/60 p-1 shadow-sm",children:u.jsx("img",{src:e.src,alt:e.alt,title:e.label,loading:"lazy",className:"h-auto max-h-[420px] w-full rounded object-contain",onLoad:()=>{},onError:n=>{console.error(`[MessageComponent] ❌ Image failed to load for artifact ${t}:`,{alt:e.alt,label:e.label,message:n.target.alt})}})})]})}const yp={completed:{label:"Completed",badgeClass:"border border-green-200 bg-green-50 text-green-700"},success:{label:"Completed",badgeClass:"border border-green-200 bg-green-50 text-green-700"},failed:{label:"Failed",badgeClass:"border border-red-200 bg-red-50 text-red-700"},error:{label:"Failed",badgeClass:"border border-red-200 bg-red-50 text-red-700"},cancelled:{label:"Cancelled",badgeClass:"border border-orange-200 bg-orange-50 text-orange-700"},cancel:{label:"Cancelled",badgeClass:"border border-orange-200 bg-orange-50 text-orange-700"},pending:{label:"Pending",badgeClass:"border border-blue-200 bg-blue-50 text-blue-700"},processing:{label:"Processing",badgeClass:"border border-yellow-200 bg-yellow-50 text-yellow-700"}},PT=e=>{if(!e)return yp.processing;const t=e.toLowerCase().trim();return yp[t]??{label:t.replace(/(^\w|\s\w)/g,n=>n.toUpperCase()),badgeClass:"border border-slate-200 bg-slate-50 text-slate-800"}},RT=e=>e?e.length>10?`${e.slice(0,8)}…`:e:"";function Sp({artifact:e}){const t=PT(e.status),n=e.task_url??e.taskUrl??"";return u.jsxs("div",{className:"rounded-lg border border-blue-200/70 bg-blue-50/40 p-4 space-y-3",children:[u.jsxs("div",{className:"flex items-start justify-between gap-3",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsx("div",{className:"flex h-7 w-7 items-center justify-center rounded-full bg-blue-600/10 text-blue-600",children:u.jsx(ue.Search,{className:"h-4 w-4"})}),u.jsxs("div",{className:"space-y-1",children:[u.jsx("p",{className:"text-xs font-semibold uppercase tracking-wide text-blue-700",children:"Research Task"}),u.jsxs("p",{className:"text-[11px] text-blue-900/80",children:["Task ID: ",u.jsx("span",{className:"font-mono",children:RT(e.task_id)})]})]})]}),t&&u.jsx("span",{className:`inline-flex items-center rounded-full px-3 py-1 text-[11px] font-semibold ${t.badgeClass}`,children:t.label})]}),e.query&&u.jsxs("div",{className:"rounded border border-blue-100 bg-white/80 px-3 py-2 text-xs text-blue-900/90",children:[u.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wide text-blue-500",children:"Query"}),u.jsx("p",{className:"line-clamp-2 text-[11px] text-blue-900",children:e.query})]}),typeof e.results=="string"&&e.results.trim()&&u.jsxs("div",{className:"rounded border border-blue-100 bg-white/80 px-3 py-2 text-sm text-blue-900/90 space-y-1",children:[u.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wide text-blue-500",children:"Results"}),u.jsx(Rr,{content:e.results,allowHtml:!1,className:"prose text-xs !prose-sm prose-blue dark:prose-invert"})]}),u.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[n?u.jsxs("a",{href:n,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 rounded-full border border-blue-600/80 bg-blue-600/10 px-3 py-1 text-xs font-semibold text-blue-700 transition hover:bg-blue-600/20",children:[u.jsx("span",{children:"Go to task"}),u.jsx(ue.ExternalLink,{className:"h-3 w-3"})]}):u.jsx("span",{className:"text-xs text-muted-foreground",children:"Task link unavailable"}),e.createdAt&&u.jsxs("p",{className:"text-[10px] text-blue-700/70",children:["Started: ",new Date(e.createdAt).toLocaleTimeString()]})]})]})}function Cp({artifact:e,idx:t=0}){const n=b.useMemo(()=>e?(Array.isArray(e.plots)?e.plots:[]).map(o=>nb(o)).filter(o=>o!==null):[],[e]);return(e==null?void 0:e.type)==="research_task_info"?u.jsx(Sp,{artifact:{type:"research_task_info",task_id:e.task_id,task_url:e.task_url,query:e.query,status:e.status,createdAt:e.createdAt}}):n.length>0?u.jsx("div",{className:"space-y-2",children:n.map((r,o)=>u.jsx(wp,{preview:r,idx:o},`${t}-plot-${o}`))}):e&&typeof e=="object"?u.jsx("div",{className:"rounded-lg border border-gray-200 dark:border-gray-800 bg-gray-50 dark:bg-gray-900/20 p-4",children:u.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:["Unknown artifact type: ",u.jsx("code",{className:"font-mono",children:e.type||"unknown"})]})}):null}const sl=p.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:re("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));sl.displayName="Card";const il=p.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:re("flex flex-col space-y-1.5 p-6",e),...t}));il.displayName="CardHeader";const al=p.forwardRef(({className:e,...t},n)=>u.jsx("h3",{ref:n,className:re("text-2xl font-semibold leading-none tracking-tight",e),...t}));al.displayName="CardTitle";const ll=p.forwardRef(({className:e,...t},n)=>u.jsx("p",{ref:n,className:re("text-sm text-muted-foreground",e),...t}));ll.displayName="CardDescription";const cl=p.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:re("p-6 pt-0",e),...t}));cl.displayName="CardContent";const Tp=p.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:re("flex items-center p-6 pt-0",e),...t}));Tp.displayName="CardFooter";function kp({interruptPart:e,onApprove:t,onReject:n,disabled:r,isActive:o,payload:s}){const i=e.title??"Approve the result?";let a=null;if(s!=null)if(typeof s=="string")a=u.jsx("p",{className:"text-sm leading-relaxed text-blue-800/90 dark:text-blue-200/90 whitespace-pre-wrap",children:s});else{const c=xr(s);a=u.jsx("pre",{className:"max-h-48 overflow-auto rounded bg-blue-100/60 p-2 text-xs text-blue-900/90 dark:bg-blue-900/40 dark:text-blue-100/80",children:c})}const l=o?"Please approve or reject this action to resume the workflow.":"Waiting for approval from another participant.";return u.jsxs(sl,{className:re("border-blue-200 dark:border-blue-800 bg-blue-50/50 dark:bg-blue-950/10 transition-shadow",o?"shadow-md ring-1 ring-blue-300 dark:ring-blue-500/70":"opacity-80"),children:[u.jsxs(il,{className:"pb-3",children:[u.jsx(al,{className:"text-blue-900 dark:text-blue-100 text-base",children:i}),u.jsx(ll,{className:"text-blue-700 dark:text-blue-300 text-sm",children:l})]}),a&&u.jsx(cl,{className:"pt-0 pb-3",children:a}),u.jsx(Tp,{className:"pt-0",children:u.jsxs("div",{className:"flex gap-2 ml-auto",children:[u.jsx(Qe,{size:"sm",variant:"outline",onClick:()=>n(e),className:"border-red-300 text-red-700 hover:bg-red-50 dark:border-red-700 dark:text-red-300 dark:hover:bg-red-950/50",disabled:r||!o,children:"Reject"}),u.jsx(Qe,{size:"sm",onClick:()=>t(e),className:"bg-blue-600 hover:bg-blue-700 text-white",disabled:r||!o,children:"Approve"})]})})]})}const MT="prose prose-sm max-w-none break-words dark:prose-invert prose-headings:break-words prose-p:break-words prose-li:break-words prose-td:break-words prose-th:break-words prose-a:break-all prose-code:break-words prose-blockquote:break-words";function ul({data:e}){return Array.isArray(e)?e.every(n=>n===null||["string","number","boolean"].includes(typeof n))?u.jsx("div",{className:MT,children:u.jsx("ul",{className:"list-disc pl-5",children:e.map((n,r)=>u.jsx("li",{children:String(n)},r))})}):u.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:xr(e)}):u.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:xr(e)})}function Ep({message:e,isStreaming:t=!1}){const n=e.name??"tool",r=b.useMemo(()=>{const a=e.additionalKwargs??{};return Array.isArray(a.toolProgress)?[...a.toolProgress]:[]},[e]),s=r.some(a=>a.type==="tool.start"||a.type==="tool.call"||a.type==="message.start")?`Running ${n}…`:void 0;return t||r.length>0?u.jsxs("div",{className:"space-y-2",children:[u.jsxs("div",{className:"flex items-center gap-2 text-xs uppercase tracking-wide text-muted-foreground",children:[t&&u.jsx(ue.Loader,{className:"h-3 w-3 animate-spin"}),u.jsx("span",{children:s??`Running ${n}…`})]}),r.length>0&&u.jsx("div",{className:"space-y-2 text-xs text-muted-foreground",children:r.map((a,l)=>{var c;return u.jsxs("div",{className:"rounded border border-current/10 bg-muted/60 p-2 text-[11px] leading-snug",children:[u.jsxs("div",{className:"mb-1 flex items-center justify-between text-[8px] uppercase tracking-wide text-muted-foreground",children:[u.jsx("span",{children:((c=a.type)==null?void 0:c.replace(/\./g," "))??"progress"}),u.jsx("span",{children:a.idx??l+1})]}),a.content&&u.jsx("p",{className:"mt-1 text-[12px] text-foreground/90",children:a.content}),u.jsxs("div",{className:"mt-1 flex flex-wrap gap-2 text-[10px] opacity-70",children:[typeof a.factsFound=="number"&&u.jsxs("span",{children:["Facts found: ",a.factsFound]}),typeof a.isSufficient=="boolean"&&u.jsxs("span",{children:["Research ",a.isSufficient?"sufficient":"needs more data"]})]})]},`tool-progress-${n}-${l}`)})})]}):null}function Ip({className:e}){const[t,n]=b.useState(0);return b.useEffect(()=>{const r=setInterval(()=>n(o=>(o+1)%4),500);return()=>clearInterval(r)},[]),u.jsxs("span",{"aria-live":"polite",className:re("inline-block text-xs opacity-70 ml-1",e),children:["Is thinking",".".repeat(t)]})}function Np({text:e,expanded:t,onExpandedChange:n,previewLength:r,isCompact:o}){const s=Math.max(e.length-r,0),i=e.substring(0,r);return u.jsxs("div",{className:"flex flex-col gap-1",children:[u.jsx("div",{className:re("text-sm text-[hsl(var(--chat-bubble-user-text))]",o&&"text-xs"),children:t?u.jsx(Rr,{content:e,allowHtml:!1}):u.jsxs("pre",{className:re("font-sans whitespace-pre-wrap break-words bg-transparent p-0 m-0 text-[hsl(var(--chat-bubble-user-text))]",o&&"text-xs"),children:[i,"..."]})}),u.jsx(Qe,{type:"button",variant:"ghost",size:"sm",className:"h-6 text-xs !text-[hsl(var(--chat-bubble-user-text))]",onClick:()=>n(!t),children:t?u.jsxs(u.Fragment,{children:[u.jsx(ue.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):u.jsxs(u.Fragment,{children:[u.jsx(ue.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more (",s," chars)"]})})]})}function Ap({message:e,viewMode:t,isStreaming:n=!1}){const o=Mi(e).name||"tool",s=e.artifact??null,i=c=>{if(c==null)return null;const d=typeof c=="string"?Ri(c)??c:c;if(d&&typeof d=="object")return u.jsx(ul,{data:d});const h=typeof d=="string"?d:(()=>{try{return xr(d)}catch{return String(d??"")}})();return u.jsx("pre",{className:"whitespace-pre-wrap break-words font-sans text-sm text-foreground/90",children:h})},a=c=>{if(c==null)return null;const{content:d,isMarkdown:h}=Yv(c);return h?u.jsx(Rr,{content:d,className:"text-current"}):i(c)},l=()=>{const c=e.content.find(m=>m.type!=="tool_call");if(!c)return u.jsx("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:u.jsxs("span",{children:["Running ",o,"…"]})});if(c.type==="text"){const f=(c.text??"").trim();if(!f)return null;const v=Qr(f);return a(v)}const d=Zr(c),h=Qr(d);return a(h)};return u.jsxs("div",{className:"space-y-2",children:[s&&u.jsx(Cp,{artifact:s,idx:0}),u.jsx(Ep,{message:e,isStreaming:n}),t==="expanded"&&u.jsx(u.Fragment,{children:l()})]})}function jp(e){const{allowFileOpen:t,currentThreadId:n}=e,{toast:r}=nl(),[o,s]=b.useState({}),[i,a]=b.useState(null),[l,c]=b.useState(!1),d=b.useCallback(()=>{c(!1),a(null)},[]),h=b.useCallback(f=>{a(f),c(!0)},[]),m=b.useCallback(async(f,v,g)=>{var x,y;if(!t){f.preventDefault();return}if(o[g]){f.preventDefault();return}try{const w=String(v.url??""),S=w.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);if(S){f.preventDefault();const k=S[1],C=v.name||`file_${k}`,T=v.mimeType||"application/octet-stream";h({id:k,name:C,mimeType:T});return}if(w.startsWith("data:")){f.preventDefault(),s(C=>({...C,[g]:!0}));const k=r({title:"Fetching file...",description:"",open:!0});try{const C=await Qc(n??void 0);if(!C||!Array.isArray(C))throw new Error("Invalid file list response");const T=C.find(I=>!I||typeof I!="object"||!((I.filename??"")===(v.name??""))?!1:typeof v.size=="number"&&typeof I.size=="number"?I.size===v.size:!0);if(!(T!=null&&T.id))throw new Error(`File "${v.name}" is not yet available on the server`);if(!T.id||!T.filename)throw new Error("Invalid file data received from server");h({id:T.id,name:v.name||T.filename||`file_${T.id}`,mimeType:v.mimeType||T.mime_type||"application/octet-stream"}),(x=k.update)==null||x.call(k,{id:k.id,title:"Success",description:`Opened ${v.name}`,open:!0})}catch(C){console.error("Failed to fetch server file:",C);const T=C instanceof Error?C.message:"Unknown error occurred";(y=k.update)==null||y.call(k,{id:k.id,title:"Failed",description:T}),r({title:"Failed to fetch file",description:T,open:!0})}finally{s(C=>({...C,[g]:!1}))}}}catch(w){console.error("File click error:",w),s(S=>({...S,[g]:!1}))}},[t,o,r,n,h]);return{uploadingFiles:o,handleFileClick:m,fileViewerOpen:l,currentFileInfo:i,closeFileViewer:d}}function _p(e,t){return b.useMemo(()=>{if(t)return{contentParts:[],textContent:"",toolMeta:{},imageParts:[],fileParts:[],interruptParts:[],toolRaw:"",isToolStreaming:!1};const n=e,r=Array.isArray(n.content)?n.content:[],o=n.additionalKwargs??{};return{contentParts:r,textContent:Xv(r),toolMeta:Mi(n),imageParts:r.filter(s=>s.type==="image_url"),fileParts:r.filter(s=>s.type==="file"),interruptParts:r.filter(s=>s.type==="interrupt"),toolRaw:Jv(r),isToolStreaming:!!o.toolStreaming}},[e,t])}const OT={checkpoints:[],checkpointMetaByCheckpointId:new Map,timeline:[],messagePreviews:new Map,getLatest:()=>{},getCheckpoint:()=>{},getMessageAttempts:()=>[]},dl=(e,t)=>(e==null?void 0:e.id)??`message-${t}`,fl=b.memo(function({message:t,index:n,isStreaming:r,streamingAssistantId:o,streamingDebounceMs:s,layoutSize:i,enableMessageEditing:a,editingMessageId:l,onEdit:c,onRegenerate:d,onCancelEdit:h,activeInterrupt:m,disableInterruptActions:f,onInterruptActionStart:v,onInterruptActionEnd:g,showToolMessages:x,checkpointIndex:y,onSelectCheckpoint:w}){const S=dl(t,n),k=t.role==="default_message",T=!!t.__syntheticStreaming,I=y??OT,N=!k&&"checkpointId"in t?t.checkpointId??null:null,{attemptCount:R,attemptIndex:O,attempts:$}=b.useMemo(()=>ec(t.id,N,I),[t.id,N,I]);return u.jsx("div",{className:"relative mb-4 last:mb-0","data-message-id":S,style:{minHeight:"60px",containIntrinsicSize:"auto 120px"},children:u.jsx(Ys,{message:t,messageIndex:n,isStreamingMessage:T||r&&o===t.id&&t.role==="assistant",streamingDebounceMs:s,isEditing:l===t.id,showActions:a,showTimestamp:!1,showAgentName:!0,layoutSize:i,onEdit:c,onRegenerate:()=>d(n),onCancelEdit:h,activeInterrupt:m,disableInterruptActions:f,onInterruptActionStart:v,onInterruptActionEnd:g,showToolMessages:x,attemptCount:R,attemptIndex:O,attemptMetas:$,onSelectCheckpoint:w})})});fl.displayName="MessageRow";function DT(e,t,n){const[r,o]=b.useState(e);return b.useEffect(()=>{if(!t){o(e);return}const s=e.map(i=>{if(i.type!=="text")return i;const a=i.text??"",l=n(a);return l===a?i:{...i,text:l}});o(s)},[e,t,n]),r}function LT({message:e,isToolMessage:t,showToolMessages:n,toolViewMode:r,isToolStreaming:o,contentParts:s,textContent:i,imageParts:a,fileParts:l,interruptParts:c,isStreamingMessage:d,enableStreamingMarkdownBuffer:h,defaultMessage:m,handleFileClick:f,uploadingFiles:v,handleInterruptApprove:g,handleInterruptReject:x,disableInterruptActions:y,messageRole:w,truncateUserMessages:S,userMessagePreviewLength:k,isUserExpanded:C,setIsUserExpanded:T,isCompactLayout:I,activeInterruptId:N,activeInterruptValue:R,iconForeground:O}){const $=b.useCallback(()=>u.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/30 rounded",children:[u.jsx(ue.Loader,{className:"h-4 w-4 text-muted-foreground"}),u.jsx("span",{className:"text-sm text-muted-foreground",children:"File upload"})]}),[]),V=h??!0,U=b.useCallback(D=>$T(D,d),[d]),j=DT(s,V&&d,U),q=b.useCallback(({part:D,i:P})=>{if(D.type==="text"){const E=D.text??"",B=E.trim(),Y=Ri(B);return Y&&w!=="tool"?u.jsx(ul,{data:Y},P):w==="user"&&S&&B.length>k?u.jsx(Np,{text:B,expanded:C,onExpandedChange:T,previewLength:k,isCompact:I},P):u.jsx(Rr,{content:E,allowHtml:!1},P)}if(D.type==="image_url"){const E=D;return u.jsx("div",{className:"my-2",children:u.jsx("img",{src:E.url,alt:E.alt??"",loading:"lazy",className:"border rounded max-h-[420px] w-auto object-contain"})},P)}if(D.type==="file"){const E=D,B=E.name||"file";return u.jsxs("a",{href:E.url,onClick:Y=>f(Y,E,P),className:`inline-flex items-center gap-2 rounded px-2 py-1 text-xs bg-gray-100 border hover:bg-gray-200
|
|
128
|
+
Please report this to https://github.com/markedjs/marked.`,e){const o="<p>An error occurred:</p><pre>"+Dt(r.message+"",!0)+"</pre>";if(t)return Promise.resolve(o);if(n){n(null,o);return}return o}if(t)return Promise.reject(r);if(n){n(r);return}throw r}}function bp(e,t){return(n,r,o)=>{typeof r=="function"&&(o=r,r=null);const s={...r};r={...ye.defaults,...s};const i=_T(r.silent,r.async,o);if(typeof n>"u"||n===null)return i(new Error("marked(): input parameter is undefined or null"));if(typeof n!="string")return i(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(n)+", string expected"));if(NT(r),r.hooks&&(r.hooks.options=r),o){const a=r.highlight;let l;try{r.hooks&&(n=r.hooks.preprocess(n)),l=e(n,r)}catch(h){return i(h)}const c=function(h){let m;if(!h)try{r.walkTokens&&ye.walkTokens(l,r.walkTokens),m=t(l,r),r.hooks&&(m=r.hooks.postprocess(m))}catch(f){h=f}return r.highlight=a,h?i(h):o(null,m)};if(!a||a.length<3||(delete r.highlight,!l.length))return c();let d=0;ye.walkTokens(l,function(h){h.type==="code"&&(d++,setTimeout(()=>{a(h.text,h.lang,function(m,f){if(m)return c(m);f!=null&&f!==h.text&&(h.text=f,h.escaped=!0),d--,d===0&&c()})},0))}),d===0&&c();return}if(r.async)return Promise.resolve(r.hooks?r.hooks.preprocess(n):n).then(a=>e(a,r)).then(a=>r.walkTokens?Promise.all(ye.walkTokens(a,r.walkTokens)).then(()=>a):a).then(a=>t(a,r)).then(a=>r.hooks?r.hooks.postprocess(a):a).catch(i);try{r.hooks&&(n=r.hooks.preprocess(n));const a=e(n,r);r.walkTokens&&ye.walkTokens(a,r.walkTokens);let l=t(a,r);return r.hooks&&(l=r.hooks.postprocess(l)),l}catch(a){return i(a)}}}function ye(e,t,n){return bp(Vn.lex,Kn.parse)(e,t,n)}ye.options=ye.setOptions=function(e){return ye.defaults={...ye.defaults,...e},mT(ye.defaults),ye},ye.getDefaults=ap,ye.defaults=lr,ye.use=function(...e){const t=ye.defaults.extensions||{renderers:{},childTokens:{}};e.forEach(n=>{const r={...n};if(r.async=ye.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(o=>{if(!o.name)throw new Error("extension name required");if(o.renderer){const s=t.renderers[o.name];s?t.renderers[o.name]=function(...i){let a=o.renderer.apply(this,i);return a===!1&&(a=s.apply(this,i)),a}:t.renderers[o.name]=o.renderer}if(o.tokenizer){if(!o.level||o.level!=="block"&&o.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");t[o.level]?t[o.level].unshift(o.tokenizer):t[o.level]=[o.tokenizer],o.start&&(o.level==="block"?t.startBlock?t.startBlock.push(o.start):t.startBlock=[o.start]:o.level==="inline"&&(t.startInline?t.startInline.push(o.start):t.startInline=[o.start]))}o.childTokens&&(t.childTokens[o.name]=o.childTokens)}),r.extensions=t),n.renderer){const o=ye.defaults.renderer||new ol;for(const s in n.renderer){const i=o[s];o[s]=(...a)=>{let l=n.renderer[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.renderer=o}if(n.tokenizer){const o=ye.defaults.tokenizer||new rl;for(const s in n.tokenizer){const i=o[s];o[s]=(...a)=>{let l=n.tokenizer[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.tokenizer=o}if(n.hooks){const o=ye.defaults.hooks||new Gs;for(const s in n.hooks){const i=o[s];Gs.passThroughHooks.has(s)?o[s]=a=>{if(ye.defaults.async)return Promise.resolve(n.hooks[s].call(o,a)).then(c=>i.call(o,c));const l=n.hooks[s].call(o,a);return i.call(o,l)}:o[s]=(...a)=>{let l=n.hooks[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.hooks=o}if(n.walkTokens){const o=ye.defaults.walkTokens;r.walkTokens=function(s){let i=[];return i.push(n.walkTokens.call(this,s)),o&&(i=i.concat(o.call(this,s))),i}}ye.setOptions(r)})},ye.walkTokens=function(e,t){let n=[];for(const r of e)switch(n=n.concat(t.call(ye,r)),r.type){case"table":{for(const o of r.header)n=n.concat(ye.walkTokens(o.tokens,t));for(const o of r.rows)for(const s of o)n=n.concat(ye.walkTokens(s.tokens,t));break}case"list":{n=n.concat(ye.walkTokens(r.items,t));break}default:ye.defaults.extensions&&ye.defaults.extensions.childTokens&&ye.defaults.extensions.childTokens[r.type]?ye.defaults.extensions.childTokens[r.type].forEach(function(o){n=n.concat(ye.walkTokens(r[o],t))}):r.tokens&&(n=n.concat(ye.walkTokens(r.tokens,t)))}return n},ye.parseInline=bp(Vn.lexInline,Kn.parseInline),ye.Parser=Kn,ye.parser=Kn.parse,ye.Renderer=ol,ye.TextRenderer=xp,ye.Lexer=Vn,ye.lexer=Vn.lex,ye.Tokenizer=rl,ye.Slugger=vp,ye.Hooks=Gs,ye.parse=ye,ye.options,ye.setOptions,ye.use,ye.walkTokens,ye.parseInline,Kn.parse,Vn.lex;function Rr({content:e,className:t="",allowHtml:n=!1,style:r}){const o=b.useMemo(()=>{if(!e||typeof e!="string"||e.trim().length===0)return"";try{if(!n){const i=e.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"").replace(/<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi,"").replace(/javascript:/gi,"").replace(/on\w+\s*=/gi,"");return typeof ye.parse=="function"?ye.parse(i):ye(i)}return typeof ye.parse=="function"?ye.parse(e):ye(e)}catch(i){return console.error("[MarkdownContent] parse error",i),`<pre class="font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words">Error rendering markdown: ${String(i)}</pre>`}},[e,n]),s=b.useMemo(()=>{const i={color:"currentColor",...r};if(r&&r.color){const a=r.color;return{...i,"--tw-prose-body":a,"--tw-prose-headings":a,"--tw-prose-links":a,"--tw-prose-bold":a,"--tw-prose-counters":a,"--tw-prose-bullets":a,"--tw-prose-hr":a,"--tw-prose-quotes":a,"--tw-prose-quote-borders":a,"--tw-prose-captions":a,"--tw-prose-code":a,"--tw-prose-pre-code":a,"--tw-prose-pre-bg":"inherit","--tw-prose-th-borders":a,"--tw-prose-td-borders":a}}return i},[r]);return u.jsx("div",{className:re("markdown prose prose-sm max-w-none break-words","dark:prose-invert","text-current","prose-headings:text-current prose-p:text-current prose-li:text-current prose-a:text-current prose-strong:text-current","prose-em:text-current prose-blockquote:text-current prose-table:text-current prose-td:text-current prose-th:text-current","prose-pre:font-mono prose-pre:text-xs prose-pre:bg-background/50 prose-pre:border prose-pre:rounded prose-pre:p-3 prose-pre:whitespace-pre prose-pre:overflow-x-auto","prose-code:font-mono prose-code:text-sm prose-code:bg-background/50 prose-code:px-1.5 prose-code:py-0.5 prose-code:rounded prose-code:text-current",t),style:s,dangerouslySetInnerHTML:{__html:o}})}function wp({preview:e,idx:t}){return u.jsxs("div",{className:"space-y-2",children:[e.label&&u.jsxs("p",{className:"text-[0.65rem] uppercase tracking-wide text-muted-foreground",children:["Artifact: ",e.label]}),u.jsx("div",{className:"overflow-hidden rounded border border-border/60 bg-background/60 p-1 shadow-sm",children:u.jsx("img",{src:e.src,alt:e.alt,title:e.label,loading:"lazy",className:"h-auto max-h-[420px] w-full rounded object-contain",onLoad:()=>{},onError:n=>{console.error(`[MessageComponent] ❌ Image failed to load for artifact ${t}:`,{alt:e.alt,label:e.label,message:n.target.alt})}})})]})}const yp={completed:{label:"Completed",badgeClass:"border border-green-200 bg-green-50 text-green-700"},success:{label:"Completed",badgeClass:"border border-green-200 bg-green-50 text-green-700"},failed:{label:"Failed",badgeClass:"border border-red-200 bg-red-50 text-red-700"},error:{label:"Failed",badgeClass:"border border-red-200 bg-red-50 text-red-700"},cancelled:{label:"Cancelled",badgeClass:"border border-orange-200 bg-orange-50 text-orange-700"},cancel:{label:"Cancelled",badgeClass:"border border-orange-200 bg-orange-50 text-orange-700"},pending:{label:"Pending",badgeClass:"border border-blue-200 bg-blue-50 text-blue-700"},processing:{label:"Processing",badgeClass:"border border-yellow-200 bg-yellow-50 text-yellow-700"}},PT=e=>{if(!e)return yp.processing;const t=e.toLowerCase().trim();return yp[t]??{label:t.replace(/(^\w|\s\w)/g,n=>n.toUpperCase()),badgeClass:"border border-slate-200 bg-slate-50 text-slate-800"}},RT=e=>e?e.length>10?`${e.slice(0,8)}…`:e:"";function Sp({artifact:e}){const t=PT(e.status),n=e.task_url??e.taskUrl??"";return u.jsxs("div",{className:"rounded-lg border border-blue-200/70 bg-blue-50/40 p-4 space-y-3",children:[u.jsxs("div",{className:"flex items-start justify-between gap-3",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsx("div",{className:"flex h-7 w-7 items-center justify-center rounded-full bg-blue-600/10 text-blue-600",children:u.jsx(ue.Search,{className:"h-4 w-4"})}),u.jsxs("div",{className:"space-y-1",children:[u.jsx("p",{className:"text-xs font-semibold uppercase tracking-wide text-blue-700",children:"Research Task"}),u.jsxs("p",{className:"text-[11px] text-blue-900/80",children:["Task ID: ",u.jsx("span",{className:"font-mono",children:RT(e.task_id)})]})]})]}),t&&u.jsx("span",{className:`inline-flex items-center rounded-full px-3 py-1 text-[11px] font-semibold ${t.badgeClass}`,children:t.label})]}),e.query&&u.jsxs("div",{className:"rounded border border-blue-100 bg-white/80 px-3 py-2 text-xs text-blue-900/90",children:[u.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wide text-blue-500",children:"Query"}),u.jsx("p",{className:"line-clamp-2 text-[11px] text-blue-900",children:e.query})]}),typeof e.results=="string"&&e.results.trim()&&u.jsxs("div",{className:"rounded border border-blue-100 bg-white/80 px-3 py-2 text-sm text-blue-900/90 space-y-1",children:[u.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wide text-blue-500",children:"Results"}),u.jsx(Rr,{content:e.results,allowHtml:!1,className:"prose text-xs !prose-sm prose-blue dark:prose-invert"})]}),u.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[n?u.jsxs("a",{href:n,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 rounded-full border border-blue-600/80 bg-blue-600/10 px-3 py-1 text-xs font-semibold text-blue-700 transition hover:bg-blue-600/20",children:[u.jsx("span",{children:"Go to task"}),u.jsx(ue.ExternalLink,{className:"h-3 w-3"})]}):u.jsx("span",{className:"text-xs text-muted-foreground",children:"Task link unavailable"}),e.createdAt&&u.jsxs("p",{className:"text-[10px] text-blue-700/70",children:["Started: ",new Date(e.createdAt).toLocaleTimeString()]})]})]})}function Cp({artifact:e,idx:t=0}){const n=b.useMemo(()=>e?(Array.isArray(e.plots)?e.plots:[]).map(o=>nb(o)).filter(o=>o!==null):[],[e]);return(e==null?void 0:e.type)==="research_task_info"?u.jsx(Sp,{artifact:{type:"research_task_info",task_id:e.task_id,task_url:e.task_url,query:e.query,status:e.status,createdAt:e.createdAt}}):n.length>0?u.jsx("div",{className:"space-y-2",children:n.map((r,o)=>u.jsx(wp,{preview:r,idx:o},`${t}-plot-${o}`))}):e&&typeof e=="object"?u.jsx("div",{className:"rounded-lg border border-gray-200 dark:border-gray-800 bg-gray-50 dark:bg-gray-900/20 p-4",children:u.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:["Unknown artifact type: ",u.jsx("code",{className:"font-mono",children:e.type||"unknown"})]})}):null}const sl=p.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:re("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));sl.displayName="Card";const il=p.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:re("flex flex-col space-y-1.5 p-6",e),...t}));il.displayName="CardHeader";const al=p.forwardRef(({className:e,...t},n)=>u.jsx("h3",{ref:n,className:re("text-2xl font-semibold leading-none tracking-tight",e),...t}));al.displayName="CardTitle";const ll=p.forwardRef(({className:e,...t},n)=>u.jsx("p",{ref:n,className:re("text-sm text-muted-foreground",e),...t}));ll.displayName="CardDescription";const cl=p.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:re("p-6 pt-0",e),...t}));cl.displayName="CardContent";const Tp=p.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:re("flex items-center p-6 pt-0",e),...t}));Tp.displayName="CardFooter";function kp({interruptPart:e,onApprove:t,onReject:n,disabled:r,isActive:o,payload:s}){const i=e.title??"Approve the result?";let a=null;if(s!=null)if(typeof s=="string")a=u.jsx("p",{className:"text-sm leading-relaxed text-blue-800/90 dark:text-blue-200/90 whitespace-pre-wrap",children:s});else{const c=xr(s);a=u.jsx("pre",{className:"max-h-48 overflow-auto rounded bg-blue-100/60 p-2 text-xs text-blue-900/90 dark:bg-blue-900/40 dark:text-blue-100/80",children:c})}const l=o?"Please approve or reject this action to resume the workflow.":"Waiting for approval from another participant.";return u.jsxs(sl,{className:re("border-blue-200 dark:border-blue-800 bg-blue-50/50 dark:bg-blue-950/10 transition-shadow",o?"shadow-md ring-1 ring-blue-300 dark:ring-blue-500/70":"opacity-80"),children:[u.jsxs(il,{className:"pb-3",children:[u.jsx(al,{className:"text-blue-900 dark:text-blue-100 text-base",children:i}),u.jsx(ll,{className:"text-blue-700 dark:text-blue-300 text-sm",children:l})]}),a&&u.jsx(cl,{className:"pt-0 pb-3",children:a}),u.jsx(Tp,{className:"pt-0",children:u.jsxs("div",{className:"flex gap-2 ml-auto",children:[u.jsx(Qe,{size:"sm",variant:"outline",onClick:()=>n(e),className:"border-red-300 text-red-700 hover:bg-red-50 dark:border-red-700 dark:text-red-300 dark:hover:bg-red-950/50",disabled:r||!o,children:"Reject"}),u.jsx(Qe,{size:"sm",onClick:()=>t(e),className:"bg-blue-600 hover:bg-blue-700 text-white",disabled:r||!o,children:"Approve"})]})})]})}const MT="prose prose-sm max-w-none break-words dark:prose-invert prose-headings:break-words prose-p:break-words prose-li:break-words prose-td:break-words prose-th:break-words prose-a:break-all prose-code:break-words prose-blockquote:break-words";function ul({data:e}){return Array.isArray(e)?e.every(n=>n===null||["string","number","boolean"].includes(typeof n))?u.jsx("div",{className:MT,children:u.jsx("ul",{className:"list-disc pl-5",children:e.map((n,r)=>u.jsx("li",{children:String(n)},r))})}):u.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:xr(e)}):u.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:xr(e)})}function Ep({message:e,isStreaming:t=!1}){const n=e.name??"tool",r=b.useMemo(()=>{const a=e.additionalKwargs??{};return Array.isArray(a.toolProgress)?[...a.toolProgress]:[]},[e]),s=r.some(a=>a.type==="tool.start"||a.type==="tool.call"||a.type==="message.start")?`Running ${n}…`:void 0;return t||r.length>0?u.jsxs("div",{className:"space-y-2",children:[u.jsxs("div",{className:"flex items-center gap-2 text-xs uppercase tracking-wide text-muted-foreground",children:[t&&u.jsx(ue.Loader,{className:"h-3 w-3 animate-spin"}),u.jsx("span",{children:s??`Running ${n}…`})]}),r.length>0&&u.jsx("div",{className:"space-y-2 text-xs text-muted-foreground",children:r.map((a,l)=>{var c;return u.jsxs("div",{className:"rounded border border-current/10 bg-muted/60 p-2 text-[11px] leading-snug",children:[u.jsxs("div",{className:"mb-1 flex items-center justify-between text-[8px] uppercase tracking-wide text-muted-foreground",children:[u.jsx("span",{children:((c=a.type)==null?void 0:c.replace(/\./g," "))??"progress"}),u.jsx("span",{children:a.idx??l+1})]}),a.content&&u.jsx("p",{className:"mt-1 text-[12px] text-foreground/90",children:a.content}),u.jsxs("div",{className:"mt-1 flex flex-wrap gap-2 text-[10px] opacity-70",children:[typeof a.factsFound=="number"&&u.jsxs("span",{children:["Facts found: ",a.factsFound]}),typeof a.isSufficient=="boolean"&&u.jsxs("span",{children:["Research ",a.isSufficient?"sufficient":"needs more data"]})]})]},`tool-progress-${n}-${l}`)})})]}):null}function Ip({className:e}){const[t,n]=b.useState(0);return b.useEffect(()=>{const r=setInterval(()=>n(o=>(o+1)%4),500);return()=>clearInterval(r)},[]),u.jsxs("span",{"aria-live":"polite",className:re("inline-block text-xs opacity-70 ml-1",e),children:["Is thinking",".".repeat(t)]})}function Np({text:e,expanded:t,onExpandedChange:n,previewLength:r,isCompact:o}){const s=Math.max(e.length-r,0),i=e.substring(0,r);return u.jsxs("div",{className:"flex flex-col gap-1",children:[u.jsx("div",{className:re("text-sm text-[hsl(var(--chat-bubble-user-text))]",o&&"text-xs"),children:t?u.jsx(Rr,{content:e,allowHtml:!1}):u.jsxs("pre",{className:re("font-sans whitespace-pre-wrap break-words bg-transparent p-0 m-0 text-[hsl(var(--chat-bubble-user-text))]",o&&"text-xs"),children:[i,"..."]})}),u.jsx(Qe,{type:"button",variant:"ghost",size:"sm",className:"h-6 text-xs !text-[hsl(var(--chat-bubble-user-text))]",onClick:()=>n(!t),children:t?u.jsxs(u.Fragment,{children:[u.jsx(ue.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):u.jsxs(u.Fragment,{children:[u.jsx(ue.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more (",s," chars)"]})})]})}function Ap({message:e,viewMode:t,isStreaming:n=!1}){const o=Mi(e).name||"tool",s=e.artifact??null,i=c=>{if(c==null)return null;const d=typeof c=="string"?Ri(c)??c:c;if(d&&typeof d=="object")return u.jsx(ul,{data:d});const h=typeof d=="string"?d:(()=>{try{return xr(d)}catch{return String(d??"")}})();return u.jsx("pre",{className:"whitespace-pre-wrap break-words font-sans text-sm text-foreground/90",children:h})},a=c=>{if(c==null)return null;const{content:d,isMarkdown:h}=Yv(c);return h?u.jsx(Rr,{content:d,className:"text-current"}):i(c)},l=()=>{const c=e.content.find(m=>m.type!=="tool_call");if(!c)return u.jsx("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:u.jsxs("span",{children:["Running ",o,"…"]})});if(c.type==="text"){const f=(c.text??"").trim();if(!f)return null;const v=Qr(f);return a(v)}const d=Zr(c),h=Qr(d);return a(h)};return u.jsxs("div",{className:"space-y-2",children:[s&&u.jsx(Cp,{artifact:s,idx:0}),u.jsx(Ep,{message:e,isStreaming:n}),t==="expanded"&&u.jsx(u.Fragment,{children:l()})]})}function jp(e){const{allowFileOpen:t,currentThreadId:n}=e,{toast:r}=nl(),[o,s]=b.useState({}),[i,a]=b.useState(null),[l,c]=b.useState(!1),d=b.useCallback(()=>{c(!1),a(null)},[]),h=b.useCallback(f=>{a(f),c(!0)},[]),m=b.useCallback(async(f,v,g)=>{var x,y;if(!t){f.preventDefault();return}if(o[g]){f.preventDefault();return}try{const w=String(v.url??""),S=w.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);if(S){f.preventDefault();const k=S[1],C=v.name||`file_${k}`,T=v.mimeType||"application/octet-stream";h({id:k,name:C,mimeType:T});return}if(w.startsWith("data:")){f.preventDefault(),s(C=>({...C,[g]:!0}));const k=r({title:"Fetching file...",description:"",open:!0});try{const C=await Qc(n??void 0);if(!C||!Array.isArray(C))throw new Error("Invalid file list response");const T=C.find(I=>!I||typeof I!="object"||!((I.filename??"")===(v.name??""))?!1:typeof v.size=="number"&&typeof I.size=="number"?I.size===v.size:!0);if(!(T!=null&&T.id))throw new Error(`File "${v.name}" is not yet available on the server`);if(!T.id||!T.filename)throw new Error("Invalid file data received from server");h({id:T.id,name:v.name||T.filename||`file_${T.id}`,mimeType:v.mimeType||T.mime_type||"application/octet-stream"}),(x=k.update)==null||x.call(k,{id:k.id,title:"Success",description:`Opened ${v.name}`,open:!0})}catch(C){console.error("Failed to fetch server file:",C);const T=C instanceof Error?C.message:"Unknown error occurred";(y=k.update)==null||y.call(k,{id:k.id,title:"Failed",description:T}),r({title:"Failed to fetch file",description:T,open:!0})}finally{s(C=>({...C,[g]:!1}))}}}catch(w){console.error("File click error:",w),s(S=>({...S,[g]:!1}))}},[t,o,r,n,h]);return{uploadingFiles:o,handleFileClick:m,fileViewerOpen:l,currentFileInfo:i,closeFileViewer:d}}function _p(e,t){return b.useMemo(()=>{if(t)return{contentParts:[],textContent:"",toolMeta:{},imageParts:[],fileParts:[],interruptParts:[],toolRaw:"",isToolStreaming:!1};const n=e,r=Array.isArray(n.content)?n.content:[],o=n.additionalKwargs??{};return{contentParts:r,textContent:Xv(r),toolMeta:Mi(n),imageParts:r.filter(s=>s.type==="image_url"),fileParts:r.filter(s=>s.type==="file"),interruptParts:r.filter(s=>s.type==="interrupt"),toolRaw:Jv(r),isToolStreaming:!!o.toolStreaming}},[e,t])}const OT={checkpoints:[],checkpointMetaByCheckpointId:new Map,timeline:[],messagePreviews:new Map,getLatest:()=>{},getCheckpoint:()=>{},getMessageAttempts:()=>[]},dl=(e,t)=>(e==null?void 0:e.id)??`message-${t}`,fl=b.memo(function({message:t,index:n,isStreaming:r,streamingAssistantId:o,streamingDebounceMs:s,layoutSize:i,enableMessageEditing:a,editingMessageId:l,onEdit:c,onRegenerate:d,onCancelEdit:h,activeInterrupt:m,disableInterruptActions:f,onInterruptActionStart:v,onInterruptActionEnd:g,showToolMessages:x,checkpointIndex:y,onSelectCheckpoint:w}){const S=dl(t,n),k=t.role==="default_message",T=!!t.__syntheticStreaming,I=y??OT,N=!k&&"checkpointId"in t?t.checkpointId??null:null,{attemptCount:R,attemptIndex:O,attempts:$}=b.useMemo(()=>ec(t.id,N,I),[t.id,N,I]);return u.jsx("div",{className:"relative mb-4 last:mb-0","data-message-id":S,style:{minHeight:"60px",containIntrinsicSize:"auto 120px"},children:u.jsx(Ys,{message:t,messageIndex:n,isStreamingMessage:T||r&&o===t.id&&t.role==="assistant",streamingDebounceMs:s,isEditing:l===t.id,showActions:a,showTimestamp:!1,showAgentName:!0,layoutSize:i,onEdit:c,onRegenerate:()=>d(n),onCancelEdit:h,activeInterrupt:m,disableInterruptActions:f,onInterruptActionStart:v,onInterruptActionEnd:g,showToolMessages:x,attemptCount:R,attemptIndex:O,attemptMetas:$,onSelectCheckpoint:w})})});fl.displayName="MessageRow";function DT(e,t,n){const[r,o]=b.useState(e),s=b.useRef([]);return b.useEffect(()=>{if(!t){o(e),s.current=e.map(a=>a.type==="text"?a.text??"":void 0);return}const i=e.map((a,l)=>{if(a.type!=="text")return s.current[l]=void 0,a;const c=a.text??"",d=n(c),h=s.current[l];return d===c?(s.current[l]=c,a):{...a,text:h??""}});o(i)},[e,t,n]),r}function LT({message:e,isToolMessage:t,showToolMessages:n,toolViewMode:r,isToolStreaming:o,contentParts:s,textContent:i,imageParts:a,fileParts:l,interruptParts:c,isStreamingMessage:d,enableStreamingMarkdownBuffer:h,defaultMessage:m,handleFileClick:f,uploadingFiles:v,handleInterruptApprove:g,handleInterruptReject:x,disableInterruptActions:y,messageRole:w,truncateUserMessages:S,userMessagePreviewLength:k,isUserExpanded:C,setIsUserExpanded:T,isCompactLayout:I,activeInterruptId:N,activeInterruptValue:R,iconForeground:O}){const $=b.useCallback(()=>u.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/30 rounded",children:[u.jsx(ue.Loader,{className:"h-4 w-4 text-muted-foreground"}),u.jsx("span",{className:"text-sm text-muted-foreground",children:"File upload"})]}),[]),V=h??!0,U=b.useCallback(D=>$T(D,d),[d]),j=DT(s,V&&d,U),q=b.useCallback(({part:D,i:P})=>{if(D.type==="text"){const E=D.text??"",B=E.trim(),Y=Ri(B);return Y&&w!=="tool"?u.jsx(ul,{data:Y},P):w==="user"&&S&&B.length>k?u.jsx(Np,{text:B,expanded:C,onExpandedChange:T,previewLength:k,isCompact:I},P):u.jsx(Rr,{content:E,allowHtml:!1},P)}if(D.type==="image_url"){const E=D;return u.jsx("div",{className:"my-2",children:u.jsx("img",{src:E.url,alt:E.alt??"",loading:"lazy",className:"border rounded max-h-[420px] w-auto object-contain"})},P)}if(D.type==="file"){const E=D,B=E.name||"file";return u.jsxs("a",{href:E.url,onClick:Y=>f(Y,E,P),className:`inline-flex items-center gap-2 rounded px-2 py-1 text-xs bg-gray-100 border hover:bg-gray-200
|
|
129
129
|
dark:bg-background/10 dark:border-border/30 dark:hover:bg-background/20`,children:[v[P]?u.jsx(ue.Loader,{className:"h-4 w-4 animate-spin"}):null,u.jsxs("span",{className:"truncate max-w-[180px]",children:[B,v[P]?" (processing)":""]})]},P)}if(D.type==="interrupt"){const E=D,B=Go((E==null?void 0:E.id)??(E==null?void 0:E.interrupt_id)),Y=!!(N&&B&&B===N),_=Y?R??(E==null?void 0:E.value):E==null?void 0:E.value,M=B?{...E,id:B,interrupt_id:B}:E;return u.jsx(kp,{interruptPart:M,onApprove:g,onReject:x,disabled:y,isActive:Y,payload:_},P)}return null},[N,R,y,f,g,x,I,C,w,S,v,k,T]),K=i.trim().length>0||a.length>0||l.length>0||c.length>0;if(!t&&l.length>0&&!d)return $();if(!t&&!K&&!d)return null;if(t)return n?u.jsx(Ap,{message:e,viewMode:r,isStreaming:o},e.id):null;if(!m){const D=u.jsx("div",{className:"space-y-2",children:j.map((P,E)=>u.jsx(q,{part:P,i:E},E))});return d?u.jsxs("div",{"aria-busy":"true",role:"status",children:[D,u.jsx(Ip,{className:O})]}):D}return null}function $T(e,t){if(!t||!e)return e;let n=e;return n=FT(n),n=BT(n),n}function FT(e){const t=e.match(/\[[^\]]*\]\([^)]*$/);if(t&&typeof t.index=="number")return e.slice(0,t.index);const n=e.match(/\[[^\]]*$/);return n&&typeof n.index=="number"?e.slice(0,n.index):e}function BT(e){const t=e.match(/`[^`]*$/);return t&&typeof t.index=="number"?e.slice(0,t.index):e}const zT=zr.cva("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function Pp({className:e,variant:t,...n}){return u.jsx("div",{className:re(zT({variant:t}),e),...n})}function HT({showTimestamp:e,showAgentName:t,isToolMessage:n,iconForeground:r,agentName:o,messageIcon:s,customHeaderClass:i,customActionsClass:a,isCompactLayout:l,showActions:c,isEditing:d,messageRole:h,toolViewMode:m,toolMeta:f,onToggleToolView:v,onCopy:g,onEdit:x,onRegenerate:y,showCheckpointControls:w,attemptCount:S,attemptIndex:k,handleOlderAttemptSelect:C,handleNewerAttemptSelect:T,messageCreatedAt:I,copied:N}){return!e&&!t&&!n?null:u.jsxs("div",{className:re("flex items-center justify-between mb-2 pb-2 border-b border-current/10",l&&"mb-1 pb-1",r,i),children:[u.jsxs("div",{className:"flex items-center gap-2",children:[s,t&&o&&u.jsx("span",{className:re("font-medium",l?"text-xs":"text-sm"),children:o}),n&&u.jsxs(Pp,{variant:"outline",className:re("text-xs flex items-center gap-1 cursor-pointer select-none",r,"border border-current/40",l&&"text-xs h-4"),role:"button",tabIndex:0,"aria-expanded":m==="expanded",onClick:v,onKeyDown:R=>{(R.key==="Enter"||R.key===" ")&&(R.preventDefault(),v())},children:[u.jsx("span",{children:f.name??"Tool Output"}),f.toolCallId&&u.jsx("span",{className:"opacity-70",children:f.toolCallId.slice(0,8)}),m==="expanded"?u.jsx(ue.ChevronUp,{className:"h-3 w-3"}):u.jsx(ue.ChevronDown,{className:"h-3 w-3"})]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[w&&S>1&&u.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[u.jsx("button",{type:"button",className:re("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",k<S-1?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{k>=S-1||C()},"aria-label":"Older attempt (back in time)",disabled:k>=S-1,children:u.jsx(ue.ChevronLeft,{className:"h-3 w-3"})}),u.jsx("div",{className:"flex items-center gap-2",children:u.jsxs("span",{className:"whitespace-nowrap",children:[S-k," / ",S]})}),u.jsx("button",{type:"button",className:re("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",k>0?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{k<=0||T()},"aria-label":"Newer attempt (forward in time)",disabled:k<=0,children:u.jsx(ue.ChevronRight,{className:"h-3 w-3"})})]}),e&&I&&u.jsx("time",{className:re("text-xs opacity-60",r,l&&"text-xs"),dateTime:new Date(I).toISOString(),title:new Date(I).toLocaleString(),children:new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"}).format(new Date(I))}),c&&!d&&u.jsxs("div",{className:re("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",a),children:[u.jsx("div",{className:"relative",children:u.jsx(Qe,{variant:"ghost",size:"sm",onClick:g,className:re("h-6 w-6 p-0 hover:bg-foreground/10",r,l&&"h-5 w-5"),"aria-label":"Copy message",title:"Copy message",children:u.jsx(ue.Copy,{className:re(N?"text-success":r,l?"h-3 w-3":"h-4 w-4")})})}),h==="user"&&x&&u.jsx(Qe,{variant:"ghost",size:"sm",onClick:x,className:re("h-6 w-6 p-0 hover:bg-foreground/10",r,l&&"h-5 w-5"),"aria-label":"Edit message",children:u.jsx(ue.Edit,{className:re(r,l?"h-3 w-3":"h-4 w-4")})}),h==="assistant"&&y&&u.jsx(Qe,{variant:"ghost",size:"sm",onClick:y,className:re("h-6 w-6 p-0 hover:bg-foreground/10",r,l&&"h-5 w-5"),"aria-label":"Regenerate response",children:u.jsx(ue.RotateCcw,{className:re(r,l?"h-3 w-3":"h-4 w-4")})})]})]})]})}const Ys=b.memo(function({message:t,messageIndex:n,isStreamingMessage:r=!1,isEditing:o=!1,showActions:s=!0,showTimestamp:i=!0,showAgentName:a=!0,layoutSize:l="desktop",truncateUserMessages:c=!0,userMessagePreviewLength:d=500,showToolMessages:h=!0,customStyles:m={},streamingDebounceMs:f=300,enableStreamingMarkdownBuffer:v,onEdit:g,onRegenerate:x,onCopy:y,activeInterrupt:w,disableInterruptActions:S=!1,onInterruptActionStart:k,onInterruptActionEnd:C,attemptCount:T=1,attemptIndex:I=0,onSelectCheckpoint:N,attemptMetas:R=[]}){const[O,$]=b.useState(!1),[V,U]=b.useState("preview"),[j,q]=b.useState(!1),{currentThreadId:K}=gr(),{respondToInterrupt:D}=eo(),P=l==="phone"||l==="half-screen",E=t.role,B=E==="tool",Y=b.useMemo(()=>t.role==="default_message"?t:null,[t]),_=!!Y,M=!(r&&E!=="user"),{uploadingFiles:G,handleFileClick:J,fileViewerOpen:se,currentFileInfo:W,closeFileViewer:L}=jp({allowFileOpen:M,currentThreadId:K}),X=b.useMemo(()=>{switch(E){case"user":return"text-[hsl(var(--chat-bubble-user-text))]";case"assistant":return"text-[hsl(var(--chat-bubble-ai-text))]";case"tool":return"text-secondary-foreground";case"system":return"text-muted-foreground";default:return"text-[hsl(var(--chat-bubble-ai-text))]"}},[E]),ee=_p(t,Y),{contentParts:Z,imageParts:z,fileParts:ae,interruptParts:ie,textContent:ge,toolMeta:we,toolRaw:Ae,isToolStreaming:Pe}=ee,ke=v??f!==0,st=(w==null?void 0:w.id)??(w==null?void 0:w.interrupt_id),bt=Go(st),It=w==null?void 0:w.value,We=b.useCallback(async()=>{const Te=B?Ae:ge;async function Q(me){if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function"){await navigator.clipboard.writeText(me);return}if(navigator.clipboard&&typeof navigator.clipboard.write=="function"&&typeof ClipboardItem<"u"){const Ze=new Blob([me],{type:"text/plain"});await navigator.clipboard.write([new ClipboardItem({"text/plain":Ze})]);return}throw new Error("Clipboard API not supported in this context.")}try{await Q(Te),$(!0),setTimeout(()=>$(!1),2e3),y==null||y(Te)}catch(me){console.error("Failed to copy:",me)}},[B,Ae,ge,y]),ze=b.useCallback(()=>{if(!g||!t.id)return;const Te=(B?Ae:ge)??"",Q="type"in t&&t.type==="default_message"?void 0:{checkpointId:t.checkpointId??null,checkpointNs:t.checkpointNs??null};g(t.id,Te,Q)},[g,t.id,B,Ae,ge,t]),Ke=b.useCallback(()=>{x==null||x(n)},[x,n]),Fe=b.useCallback(()=>{U(Te=>Te==="expanded"?"preview":"expanded")},[]),Ue=b.useCallback(()=>{const Q=re(P?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",X);switch(E){case"user":return u.jsx(ue.User,{className:Q});case"assistant":return u.jsx(ue.Bot,{className:Q});case"tool":return u.jsx(ue.Wrench,{className:Q});default:return u.jsx(ue.Bot,{className:Q})}},[P,X,E]),ut=b.useCallback(()=>{const Te="group relative mb-4 flex w-full";switch(E){case"user":return re(Te,"justify-end");case"assistant":case"tool":case"system":return re(Te,"justify-start");default:return Te}},[E]),jt=b.useCallback(()=>{const Te=re("rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",P&&"px-3 py-2 text-sm");if(_)return re(Te,"w-full","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40 shadow-sm");switch(E){case"user":return re(Te,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-user))] text-[hsl(var(--chat-bubble-user-text))]","border border-transparent");case"assistant":return re(Te,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40");case"tool":return re(Te,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return re(Te,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return re(Te,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40")}},[P,_,E]),it=b.useCallback(async Te=>{if(S)return;const Q=Go((Te==null?void 0:Te.id)??(Te==null?void 0:Te.interrupt_id));if(!Q){console.warn("Interrupt part missing id",Te);return}try{k==null||k(),await D(Q,!0)}catch(me){console.error("Failed to approve interrupt:",me)}finally{C==null||C()}},[S,C,k,D]),_t=b.useCallback(async Te=>{if(S)return;const Q=Go((Te==null?void 0:Te.id)??(Te==null?void 0:Te.interrupt_id));if(!Q){console.warn("Interrupt part missing id",Te);return}try{k==null||k(),await D(Q,!1)}catch(me){console.error("Failed to reject interrupt:",me)}finally{C==null||C()}},[S,C,k,D]),yt=u.jsx(LT,{message:t,isToolMessage:B,showToolMessages:h,toolViewMode:V,isToolStreaming:Pe,contentParts:Z,textContent:ge,imageParts:z,fileParts:ae,interruptParts:ie,isStreamingMessage:r,defaultMessage:Y,enableStreamingMarkdownBuffer:ke,handleFileClick:J,uploadingFiles:G,handleInterruptApprove:it,handleInterruptReject:_t,disableInterruptActions:S,messageRole:E,truncateUserMessages:c,userMessagePreviewLength:d,isUserExpanded:j,setIsUserExpanded:q,isCompactLayout:P,activeInterruptId:bt,activeInterruptValue:It,iconForeground:X}),gt=b.useMemo(()=>Y?"Assistant":Zv(t),[Y,t]),Nt=Ue(),St=E==="user"&&(T??1)>1&&typeof N=="function",Ct=(R==null?void 0:R.length)??0,zt=Ct>0&&I<Ct-1?R[I+1]:void 0,xt=Ct>0&&I>0?R[I-1]:void 0,Oe=b.useCallback(()=>{!zt||!N||N(zt.id,void 0,!!zt.isLatestAttempt)},[zt,N]),Ve=b.useCallback(()=>{!xt||!N||N(xt.id,void 0,!!xt.isLatestAttempt)},[xt,N]);return B&&!h?null:_&&Y?u.jsx("div",{className:re(ut(),m.container),children:u.jsxs("div",{className:re(jt(),m.content),children:[u.jsxs("div",{className:"flex items-center gap-2 mb-2 pb-2 border-b border-current/10",children:[u.jsx(ue.Bot,{className:re("h-4 w-4",X)}),a&&u.jsx("span",{className:"font-medium text-sm",children:"Assistant"})]}),u.jsx(Rr,{content:Y.content,className:"text-current"})]})}):u.jsxs(u.Fragment,{children:[u.jsx("div",{className:re(ut(),m.container),children:u.jsxs("div",{className:re(jt(),m.content),children:[u.jsx(HT,{showTimestamp:i,showAgentName:a,isToolMessage:B,iconForeground:X,agentName:gt,messageIcon:Nt,customHeaderClass:m.header,customActionsClass:m.actions,isCompactLayout:P,showActions:s,isEditing:o,messageRole:E,toolViewMode:V,toolMeta:we,onToggleToolView:Fe,onCopy:We,onEdit:ze,onRegenerate:Ke,showCheckpointControls:St,attemptCount:T,attemptIndex:I,handleOlderAttemptSelect:Oe,handleNewerAttemptSelect:Ve,messageCreatedAt:t.createdAt,copied:O}),u.jsx("div",{className:"relative",children:yt}),B&&V==="expanded"&&(we.toolCallId||we.name)&&u.jsxs("div",{className:re("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",P&&"text-xs"),children:[we.name&&u.jsxs("div",{children:["Function: ",we.name]}),we.toolCallId&&u.jsxs("div",{children:["Call ID: ",we.toolCallId]})]}),!(i||a||B)&&s&&!o&&u.jsxs("div",{className:re("absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",m.actions),children:[u.jsx(Qe,{variant:"ghost",size:"sm",onClick:()=>We(),className:re("h-6 w-6 p-0 hover:bg-background/50 text-current",P&&"h-5 w-5"),children:u.jsx(ue.Copy,{className:re(O?"text-success":"text-current",P?"h-3 w-3":"h-4 w-4")})}),E==="user"&&g&&u.jsx(Qe,{variant:"ghost",size:"sm",onClick:ze,className:re("h-6 w-6 p-0 hover:bg-background/50 text-current",P&&"h-5 w-5"),children:u.jsx(ue.Edit,{className:re("text-current",P?"h-3 w-3":"h-4 w-4")})}),E==="assistant"&&x&&u.jsx(Qe,{variant:"ghost",size:"sm",onClick:Ke,className:re("h-6 w-6 p-0 hover:bg-background/50 text-current",P&&"h-5 w-5"),children:u.jsx(ue.RotateCcw,{className:re("text-current",P?"h-3 w-3":"h-4 w-4")})})]})]})}),W&&u.jsx(ip,{isOpen:se,onClose:L,fileId:W.id,fileName:W.name,mimeType:W.mimeType})]})},(e,t)=>{var l,c,d,h,m,f,v,g;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&pu(e.message)===pu(t.message)))return!1;const o=["isEditing","showActions","layoutSize","showTimestamp","showAgentName","truncateUserMessages","userMessagePreviewLength","showToolMessages"].every(x=>e[x]===t[x]),s=((l=e.customStyles)==null?void 0:l.container)===((c=t.customStyles)==null?void 0:c.container)&&((d=e.customStyles)==null?void 0:d.content)===((h=t.customStyles)==null?void 0:h.content)&&((m=e.customStyles)==null?void 0:m.actions)===((f=t.customStyles)==null?void 0:f.actions)&&((v=e.customStyles)==null?void 0:v.header)===((g=t.customStyles)==null?void 0:g.header);if(!o||!s)return!1;const i=mu(e.message),a=mu(t.message);return i.length===a.length});Ys.displayName="MessageComponent";const hl=b.forwardRef(({messages:e,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onStartReached:a,onEdit:l,onRegenerate:c,onCancelEdit:d,className:h,style:m,emptyMessage:f,followNewMessages:v=!0,isNavigatingCheckpoint:g=!1,onScrollAway:x,onAtBottom:y,activeInterrupt:w,disableInterruptActions:S=!1,onInterruptActionStart:k,onInterruptActionEnd:C,showToolMessages:T=!0,checkpointIndex:I,activeCheckpointId:N,onSelectCheckpoint:R,createSyntheticThinkingMessage:O=!0,forceSyntheticThinking:$=!1},V)=>{const U=b.useRef(null),j=b.useRef(null),q=b.useRef(!1),K=b.useRef(!1),[D,P]=b.useState(!0),E=b.useMemo(()=>w?e.some(z=>z.role==="default_message"?!1:Array.isArray(z==null?void 0:z.content)&&z.content.some(ae=>ae&&ae.type==="interrupt"&&(ae.id??ae.interrupt_id)===w.id)):!1,[w,e]),B=b.useMemo(()=>{if(!w||E)return null;const z=w.id&&String(w.id).trim()?String(w.id).trim():"pending-interrupt";let ae;const ie=w.value;if(ie&&typeof ie=="object"&&!Array.isArray(ie)){const ge=ie.title;typeof ge=="string"&&ge.trim()&&(ae=ge.trim())}return{id:`interrupt-${z}`,role:"system",createdAt:new Date().toISOString(),content:[{type:"interrupt",id:z,value:ie,title:ae}]}},[w,E]),Y=b.useMemo(()=>B?[...e,B]:e,[e,B]),_=b.useMemo(()=>{const z=n&&Y.some(ie=>ie.id===n);return O&&(t||$)&&!z&&Y.length>0?[...Y,{id:"thinking-assistant",role:"assistant",content:[{type:"text",text:""}],createdAt:new Date().toISOString(),__syntheticStreaming:!0}]:Y},[Y,t,n,O,$]),M=b.useMemo(()=>T?_:_.filter(z=>(z==null?void 0:z.role)!=="tool"),[_,T]),G=b.useCallback(z=>{P(z),x&&x(!z),y&&y(z)},[x,y]),J=b.useMemo(()=>{if(a)return async()=>{if(!q.current){q.current=!0;try{await a()}finally{q.current=!1}}}},[a]),se=b.useMemo(()=>!v||g?!1:D?"auto":!1,[D,v,g]),W=b.useMemo(()=>{if(typeof f!="string")return null;const z=f.trim();return!z||M&&M.length>0?null:{id:"default-message",role:"default_message",content:z,createdAt:new Date().toISOString()}},[f,M]),L=["flex h-full flex-col md:flex-row",h].filter(Boolean).join(" "),X=()=>W?u.jsx("div",{className:"p-6 h-full overflow-y-auto",children:u.jsx("div",{className:"w-full max-w-full",children:u.jsx(Ys,{message:W,messageIndex:0,isStreamingMessage:!1,showActions:!1,showTimestamp:!1,showAgentName:!0,layoutSize:o,onEdit:()=>{},onRegenerate:()=>{},onCancelEdit:()=>{}})})}):u.jsx("div",{className:"flex h-full items-center justify-center py-8 text-center text-muted-foreground",children:f??"No messages yet. Start a conversation!"}),ee=M.length,Z=ee>0;return b.useEffect(()=>{var z,ae;if(ee===0){K.current=!1;return}if(!K.current)if(K.current=!0,U.current&&M.length>0){const ie=M.length-1;(ae=(z=U.current).scrollToIndex)==null||ae.call(z,{index:ie,align:"end",behavior:"auto"})}else j.current&&(j.current.scrollTop=j.current.scrollHeight)},[ee,M.length]),b.useImperativeHandle(V,()=>({scrollToLatest:()=>{var z,ae;if(U.current&&M.length>0){const ie=M.length-1;(ae=(z=U.current).scrollToIndex)==null||ae.call(z,{index:ie,align:"end",behavior:"auto"})}else j.current&&(j.current.scrollTop=j.current.scrollHeight)},scrollToTop:()=>{var z,ae;U.current&&M.length>0?(ae=(z=U.current).scrollToIndex)==null||ae.call(z,{index:0,align:"start",behavior:"auto"}):j.current&&(j.current.scrollTop=0)}}),[M]),u.jsx("div",{className:L,style:m,children:u.jsx("div",{className:"relative flex-1 min-h-0",children:Z?u.jsx(LC,{ref:z=>{U.current=z},scrollerRef:z=>{j.current=z instanceof HTMLDivElement?z:null},data:M,followOutput:se,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,startReached:()=>{J&&J()},atBottomStateChange:G,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:(z,ae)=>dl(ae,z),itemContent:(z,ae)=>u.jsx(fl,{message:ae,index:z,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onEdit:l,onRegenerate:c,onCancelEdit:d,activeInterrupt:w,disableInterruptActions:S,onInterruptActionStart:k,onInterruptActionEnd:C,showToolMessages:T,checkpointIndex:I,activeCheckpointId:N,onSelectCheckpoint:R})}):X()})})});hl.displayName="MessageList";const Rp={value:""};function Mr({className:e="",placeholder:t="Type your message...",autoFocus:n=!0,maxHeight:r=void 0,streamingDebounceMs:o=500,streamingThrottleMs:s,followNewMessages:i=!0,enableFileUpload:a=!0,enableExcelUpload:l=!1,enableMessageEditing:c=!0,showToolMessages:d=!0,payloadExtras:h={},customStyles:m={},onMessageSent:f,onExcelUploadSuccess:v,onError:g}){const{api:x}=Xr(),{currentThreadId:y}=gr(),{threadId:w,messages:S,isHistoryLoading:k,isLoading:C,navigateToCheckpoint:T,returnToLatest:I,checkpoint:N,checkpoints:R,interrupt:O,metadata:$,checkpointIndex:V}=eo(),{isStreaming:U,error:j,connectionState:q,submit:K,stop:D}=Li(),P=w??y??null,E=(N==null?void 0:N.id)??null,B=(N==null?void 0:N.namespace)??null,Y=($==null?void 0:$.assemblingMessageId)??null,_=O,[M,G]=b.useState(!1),[J,se]=b.useState(!1);b.useEffect(()=>{_||G(!1)},[_]);const W=b.useCallback(()=>{G(!0)},[]),L=b.useCallback(()=>{G(!1)},[]),X=!!_||M,[ee,Z]=b.useState(null),[z,ae]=b.useState(""),[ie,ge]=b.useState(null),[we,Ae]=b.useState(null),[Pe,ke]=b.useState([]),[st,bt]=b.useState(0),[It,We]=b.useState(0),[ze,Ke]=b.useState(!1),[Fe,Ue]=b.useState(null),[ut,jt]=b.useState(null),[it,_t]=b.useState(!1),[yt,gt]=b.useState(null),Nt=b.useRef(!1),[St,Ct]=b.useState(()=>Rp.value),zt=b.useRef(St),xt=b.useRef(null),Oe=b.useCallback(le=>{Rp.value=le,Ct(le)},[]),[Ve,Te]=b.useState(!1),Q=b.useRef(null),me=b.useRef(null),Ze=b.useRef(null),xe=b.useCallback(()=>{me.current&&(me.current.value=""),Ze.current&&(Ze.current.value=""),bt(le=>le+1),We(le=>le+1)},[]),Be=b.useCallback(le=>{Oe(le)},[Oe]),Ge=b.useRef(!1);b.useEffect(()=>{Ge.current&&!U&&(ke([]),xe()),Ge.current=U},[U,xe]),b.useEffect(()=>{U||se(!1)},[U]),b.useEffect(()=>{$!=null&&$.assemblingMessageId&&se(!1)},[$==null?void 0:$.assemblingMessageId]);const[Tt,kt]=b.useState("desktop");b.useEffect(()=>{const le=()=>{const de=window.innerWidth;kt(de<640?"phone":de<1024?"tablet":"desktop")};return le(),window.addEventListener("resize",le),()=>window.removeEventListener("resize",le)},[]),b.useEffect(()=>{Nt.current=!1},[P]),b.useEffect(()=>{zt.current=St},[St]),b.useEffect(()=>{if(!ee){xt.current=null;return}xt.current===null&&(xt.current=zt.current),Oe(z??"")},[z,ee,Oe]),b.useEffect(()=>{(async()=>{if(!x.baseUrl){gt(null);return}try{const Ce=(await x.getAgent("default")).uiDefaultMessage||"";gt(Ce||null)}catch(de){console.warn("Failed to fetch default message:",de),gt(null)}})()},[x.baseUrl]),b.useEffect(()=>{j&&!it&&(g==null||g(j))},[j,it,g]);const At=async le=>{const de=le.trim();if(!(!de&&Pe.length===0))try{const Ce=ee?(ie==null?void 0:ie.checkpointId)??E??void 0:E??void 0,De=ee?(ie==null?void 0:ie.checkpointNs)??B??void 0:B??void 0;await K({text:de||"",attachments:Pe,payload:h},{checkpointId:Ce,checkpointNs:De,edit:!!ee,originalMessageId:ee??void 0}),f==null||f(de),se(!0),Oe(""),Ae(null),ke([]),xe(),Z(null),ae(""),ge(null)}catch(Ce){const De=(Ce==null?void 0:Ce.message)||"Failed to send message";Ae(De),g==null||g(De),se(!1)}},Lt=b.useCallback((le,de,Ce)=>{c&&(xt.current=St,Z(le),ae(de),Oe(de),Ae(null),ge({checkpointId:(Ce==null?void 0:Ce.checkpointId)??null,checkpointNs:(Ce==null?void 0:Ce.checkpointNs)??null}))},[St,c,Oe]),je=b.useCallback(()=>{Z(null),ae(""),ge(null),Ae(null),Oe(xt.current??St),xt.current=null},[St,Oe]),dt=b.useCallback((le,de,Ce)=>{Lt(le,de,Ce)},[Lt]),Xe=b.useCallback(le=>{let de=null;for(let ft=le-1;ft>=0;ft--)if(S[ft].role==="user"){de=S[ft];break}if(!de)return;const Ce=Array.isArray(de.content)?de.content:[],at=Ce.filter(ft=>(ft==null?void 0:ft.type)==="text").map(ft=>ft.text).join("")||(()=>{try{return JSON.stringify(Ce,null,2)}catch{return String(Ce)}})();at&&K({text:at,payload:h},{checkpointId:E??void 0,checkpointNs:B??void 0,edit:!0,originalMessageId:de.id})},[S,K,E,B,h]),ct=le=>{const de=Array.from(le.target.files||[]);ke(Ce=>[...Ce,...de]),le.target.value=""},an=le=>{ke(de=>{const Ce=de.filter((De,at)=>le!==at);return Ce.length===0&&xe(),Ce})},A=async le=>{const de=(le.target.files||[])[0];if(de){Ue(null),jt(null),Ke(!0);try{await K({attachments:[de],payload:h},{checkpointId:E??void 0,checkpointNs:B??void 0});const Ce=`Uploaded ${de.name} - processing through chat stream`;jt(Ce)}catch(Ce){const De=Ce instanceof Error?Ce.message:"Failed to upload Excel file";console.error("Excel upload failed",Ce),Ue(De),g==null||g(De)}finally{Ke(!1),le.target.value="",xe()}}},te=async le=>{if(y){Te(!0);try{if(!le){await I(),requestAnimationFrame(()=>{var De;(De=Q.current)==null||De.scrollToLatest()});return}const de=R.find(De=>De.checkpointId===le),Ce=(de==null?void 0:de.checkpointNs)??null;await T(le,Ce),requestAnimationFrame(()=>{var De;(De=Q.current)==null||De.scrollToTop()})}finally{Te(!1)}}},fe=b.useCallback(async(le,de,Ce)=>{await te(Ce?null:le)},[te]),Ie=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${m.container||""}`,Ye=`flex-1 min-h-0 min-w-0 max-h-full w-full overflow-hidden overscroll-contain break-words break-anywhere p-4 bg-transparent ${m.messagesArea||""}`,et=`relative flex-shrink-0 w-full border-t p-4 bg-transparent ${m.inputArea||""}`;return u.jsxs("div",{className:Ie,children:[!!j&&!it&&u.jsxs("div",{className:"flex-shrink-0 bg-red-50 border border-red-200 text-red-800 px-4 py-2 text-sm flex items-center justify-between",children:[u.jsx("span",{children:j}),u.jsx(Qe,{variant:"ghost",size:"sm",onClick:()=>_t(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:u.jsx(ue.X,{size:16})})]}),u.jsxs("div",{className:`relative ${Ye}`,style:r?{maxHeight:r}:void 0,children:[u.jsx(hl,{ref:Q,className:"h-full",style:{height:"100%"},messages:S,isStreaming:U,streamingAssistantId:Y,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:Tt,enableMessageEditing:c,editingMessageId:ee,onEdit:dt,onRegenerate:Xe,onCancelEdit:je,emptyMessage:yt??void 0,isNavigatingCheckpoint:Ve,activeInterrupt:_,disableInterruptActions:M,onInterruptActionStart:W,onInterruptActionEnd:L,showToolMessages:d,checkpointIndex:V,activeCheckpointId:E,onSelectCheckpoint:fe,createSyntheticThinkingMessage:!0,forceSyntheticThinking:J}),(q==="reconnecting"||q==="connecting")&&u.jsx("div",{className:"pointer-events-none absolute top-3 right-3 z-20 rounded-full bg-muted/80 px-3 py-1 text-xs font-medium text-foreground shadow-sm backdrop-blur-sm dark:bg-muted/60",children:u.jsxs("span",{className:"flex items-center gap-2",children:[u.jsx(ue.Loader2,{className:"h-3 w-3 animate-spin"}),q==="reconnecting"?"Reconnecting…":"Connecting…"]})}),q==="error"&&u.jsx("div",{className:"pointer-events-none absolute top-3 right-3 z-20 rounded-full bg-destructive/10 px-3 py-1 text-xs font-semibold text-destructive shadow-sm",children:"Connection lost"}),C&&u.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 bg-background/80 backdrop-blur-sm text-muted-foreground",children:[u.jsx(ue.Loader2,{className:"h-6 w-6 animate-spin"}),u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading messages…"})]}),(k||Ve)&&u.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 bg-background/80 backdrop-blur-sm text-muted-foreground",children:[u.jsx(ue.Loader2,{className:"h-6 w-6 animate-spin"}),u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading checkpoint…"})]})]}),u.jsxs("div",{className:et,children:[ee&&u.jsx("div",{className:"mb-3 p-3 bg-blue-50 border border-blue-200 rounded-lg",children:u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(ue.Edit3,{size:16,className:"text-blue-600"}),u.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),u.jsx(Qe,{variant:"ghost",size:"sm",onClick:je,className:"text-blue-600 hover:bg-blue-100",children:u.jsx(ue.X,{size:16})})]})}),(a||l)&&u.jsxs("div",{className:"mb-3 space-y-3",children:[a&&u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:me,type:"file",multiple:!0,onChange:le=>ct(le),className:"hidden"},st),Pe.length>0&&u.jsx("div",{className:"flex flex-wrap gap-2",children:Pe.map((le,de)=>u.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:[u.jsx(ue.Paperclip,{size:14}),u.jsx("span",{className:"truncate max-w-[150px]",children:le.name}),u.jsx(Qe,{variant:"ghost",size:"sm",onClick:()=>an(de),className:"h-4 w-4 p-0 text-gray-500 dark:text-gray-400 hover:text-red-500 dark:hover:text-red-400","aria-label":`Remove ${le.name}`,children:u.jsx(ue.X,{size:12})})]},de))})]}),l&&u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:Ze,type:"file",accept:".xls,.xlsx,.xlsm",onChange:A,className:"hidden"},It),ze&&u.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(ue.Loader2,{className:"h-4 w-4 animate-spin"})," Uploading Excel file..."]}),ut&&!ze&&u.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:ut}),Fe&&!ze&&u.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:Fe})]})]}),we&&u.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:we}),u.jsxs("div",{className:"flex items-end gap-2",children:[(a||l)&&u.jsxs(Ss,{children:[u.jsx(Cs,{asChild:!0,children:u.jsx(Qe,{type:"button",size:"icon",variant:"outline",disabled:U||X,title:"More input actions",className:m.moreButton||"",children:u.jsx(ue.Plus,{size:16})})}),u.jsxs(ho,{align:"start",sideOffset:6,className:"w-52",children:[a&&u.jsxs(Bn,{onClick:()=>{var le;return(le=me.current)==null?void 0:le.click()},className:"cursor-pointer",children:[u.jsx(ue.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),l&&u.jsxs(Bn,{onClick:()=>{var le;ze||(le=Ze.current)==null||le.click()},className:`cursor-pointer ${ze?"opacity-60 pointer-events-none":""}`,children:[u.jsx(ue.FileSpreadsheet,{className:"h-4 w-4 mr-2"})," Upload Excel file"]})]})]}),u.jsx("div",{className:"flex-1",children:u.jsx(IS,{initialValue:z,editingMessageId:ee,value:St,onValueChange:Be,placeholder:ee?"Edit your message...":t,isStreaming:U,disabled:X,onSend:At,onCancelEdit:je,onStop:D,allowEmptySend:Pe.length>0,textareaClassName:`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${ee?"border-blue-400 bg-blue-50 text-blue-900 dark:border-blue-500 dark:bg-blue-950/60 dark:text-blue-50":""} ${we?"border-red-400":""} ${m.textarea||""}`})})]})]})]})}var Mp=1,UT=.9,WT=.8,VT=.17,pl=.1,ml=.999,KT=.9999,qT=.99,GT=/[\\\/_+.#"@\[\(\{&]/,YT=/[\\\/_+.#"@\[\(\{&]/g,XT=/[\s-]/,Op=/[\s-]/g;function gl(e,t,n,r,o,s,i){if(s===t.length)return o===e.length?Mp:qT;var a=`${o},${s}`;if(i[a]!==void 0)return i[a];for(var l=r.charAt(s),c=n.indexOf(l,o),d=0,h,m,f,v;c>=0;)h=gl(e,t,n,r,c+1,s+1,i),h>d&&(c===o?h*=Mp:GT.test(e.charAt(c-1))?(h*=WT,f=e.slice(o,c-1).match(YT),f&&o>0&&(h*=Math.pow(ml,f.length))):XT.test(e.charAt(c-1))?(h*=UT,v=e.slice(o,c-1).match(Op),v&&o>0&&(h*=Math.pow(ml,v.length))):(h*=VT,o>0&&(h*=Math.pow(ml,c-o))),e.charAt(c)!==t.charAt(s)&&(h*=KT)),(h<pl&&n.charAt(c-1)===r.charAt(s+1)||r.charAt(s+1)===r.charAt(s)&&n.charAt(c-1)!==r.charAt(s))&&(m=gl(e,t,n,r,c+1,s+2,i),m*pl>h&&(h=m*pl)),h>d&&(d=h),c=n.indexOf(l,c+1);return i[a]=d,d}function Dp(e){return e.toLowerCase().replace(Op," ")}function JT(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,gl(e,t,Dp(e),Dp(t),0,0,{})}var Io='[cmdk-group=""]',xl='[cmdk-group-items=""]',ZT='[cmdk-group-heading=""]',Lp='[cmdk-item=""]',$p=`${Lp}:not([aria-disabled="true"])`,vl="cmdk-item-select",Or="data-value",QT=(e,t,n)=>JT(e,t,n),Fp=p.createContext(void 0),No=()=>p.useContext(Fp),Bp=p.createContext(void 0),bl=()=>p.useContext(Bp),zp=p.createContext(void 0),Hp=p.forwardRef((e,t)=>{let n=Dr(()=>{var _,M;return{search:"",value:(M=(_=e.value)!=null?_:e.defaultValue)!=null?M:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=Dr(()=>new Set),o=Dr(()=>new Map),s=Dr(()=>new Map),i=Dr(()=>new Set),a=Up(e),{label:l,children:c,value:d,onValueChange:h,filter:m,shouldFilter:f,loop:v,disablePointerSelection:g=!1,vimBindings:x=!0,...y}=e,w=Rt(),S=Rt(),k=Rt(),C=p.useRef(null),T=uk();cr(()=>{if(d!==void 0){let _=d.trim();n.current.value=_,I.emit()}},[d]),cr(()=>{T(6,U)},[]);let I=p.useMemo(()=>({subscribe:_=>(i.current.add(_),()=>i.current.delete(_)),snapshot:()=>n.current,setState:(_,M,G)=>{var J,se,W,L;if(!Object.is(n.current[_],M)){if(n.current[_]=M,_==="search")V(),O(),T(1,$);else if(_==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let X=document.getElementById(k);X?X.focus():(J=document.getElementById(w))==null||J.focus()}if(T(7,()=>{var X;n.current.selectedItemId=(X=j())==null?void 0:X.id,I.emit()}),G||T(5,U),((se=a.current)==null?void 0:se.value)!==void 0){let X=M??"";(L=(W=a.current).onValueChange)==null||L.call(W,X);return}}I.emit()}},emit:()=>{i.current.forEach(_=>_())}}),[]),N=p.useMemo(()=>({value:(_,M,G)=>{var J;M!==((J=s.current.get(_))==null?void 0:J.value)&&(s.current.set(_,{value:M,keywords:G}),n.current.filtered.items.set(_,R(M,G)),T(2,()=>{O(),I.emit()}))},item:(_,M)=>(r.current.add(_),M&&(o.current.has(M)?o.current.get(M).add(_):o.current.set(M,new Set([_]))),T(3,()=>{V(),O(),n.current.value||$(),I.emit()}),()=>{s.current.delete(_),r.current.delete(_),n.current.filtered.items.delete(_);let G=j();T(4,()=>{V(),(G==null?void 0:G.getAttribute("id"))===_&&$(),I.emit()})}),group:_=>(o.current.has(_)||o.current.set(_,new Set),()=>{s.current.delete(_),o.current.delete(_)}),filter:()=>a.current.shouldFilter,label:l||e["aria-label"],getDisablePointerSelection:()=>a.current.disablePointerSelection,listId:w,inputId:k,labelId:S,listInnerRef:C}),[]);function R(_,M){var G,J;let se=(J=(G=a.current)==null?void 0:G.filter)!=null?J:QT;return _?se(_,n.current.search,M):0}function O(){if(!n.current.search||a.current.shouldFilter===!1)return;let _=n.current.filtered.items,M=[];n.current.filtered.groups.forEach(J=>{let se=o.current.get(J),W=0;se.forEach(L=>{let X=_.get(L);W=Math.max(X,W)}),M.push([J,W])});let G=C.current;q().sort((J,se)=>{var W,L;let X=J.getAttribute("id"),ee=se.getAttribute("id");return((W=_.get(ee))!=null?W:0)-((L=_.get(X))!=null?L:0)}).forEach(J=>{let se=J.closest(xl);se?se.appendChild(J.parentElement===se?J:J.closest(`${xl} > *`)):G.appendChild(J.parentElement===G?J:J.closest(`${xl} > *`))}),M.sort((J,se)=>se[1]-J[1]).forEach(J=>{var se;let W=(se=C.current)==null?void 0:se.querySelector(`${Io}[${Or}="${encodeURIComponent(J[0])}"]`);W==null||W.parentElement.appendChild(W)})}function $(){let _=q().find(G=>G.getAttribute("aria-disabled")!=="true"),M=_==null?void 0:_.getAttribute(Or);I.setState("value",M||void 0)}function V(){var _,M,G,J;if(!n.current.search||a.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let se=0;for(let W of r.current){let L=(M=(_=s.current.get(W))==null?void 0:_.value)!=null?M:"",X=(J=(G=s.current.get(W))==null?void 0:G.keywords)!=null?J:[],ee=R(L,X);n.current.filtered.items.set(W,ee),ee>0&&se++}for(let[W,L]of o.current)for(let X of L)if(n.current.filtered.items.get(X)>0){n.current.filtered.groups.add(W);break}n.current.filtered.count=se}function U(){var _,M,G;let J=j();J&&(((_=J.parentElement)==null?void 0:_.firstChild)===J&&((G=(M=J.closest(Io))==null?void 0:M.querySelector(ZT))==null||G.scrollIntoView({block:"nearest"})),J.scrollIntoView({block:"nearest"}))}function j(){var _;return(_=C.current)==null?void 0:_.querySelector(`${Lp}[aria-selected="true"]`)}function q(){var _;return Array.from(((_=C.current)==null?void 0:_.querySelectorAll($p))||[])}function K(_){let M=q()[_];M&&I.setState("value",M.getAttribute(Or))}function D(_){var M;let G=j(),J=q(),se=J.findIndex(L=>L===G),W=J[se+_];(M=a.current)!=null&&M.loop&&(W=se+_<0?J[J.length-1]:se+_===J.length?J[0]:J[se+_]),W&&I.setState("value",W.getAttribute(Or))}function P(_){let M=j(),G=M==null?void 0:M.closest(Io),J;for(;G&&!J;)G=_>0?lk(G,Io):ck(G,Io),J=G==null?void 0:G.querySelector($p);J?I.setState("value",J.getAttribute(Or)):D(_)}let E=()=>K(q().length-1),B=_=>{_.preventDefault(),_.metaKey?E():_.altKey?P(1):D(1)},Y=_=>{_.preventDefault(),_.metaKey?K(0):_.altKey?P(-1):D(-1)};return p.createElement(ve.div,{ref:t,tabIndex:-1,...y,"cmdk-root":"",onKeyDown:_=>{var M;(M=y.onKeyDown)==null||M.call(y,_);let G=_.nativeEvent.isComposing||_.keyCode===229;if(!(_.defaultPrevented||G))switch(_.key){case"n":case"j":{x&&_.ctrlKey&&B(_);break}case"ArrowDown":{B(_);break}case"p":case"k":{x&&_.ctrlKey&&Y(_);break}case"ArrowUp":{Y(_);break}case"Home":{_.preventDefault(),K(0);break}case"End":{_.preventDefault(),E();break}case"Enter":{_.preventDefault();let J=j();if(J){let se=new Event(vl);J.dispatchEvent(se)}}}}},p.createElement("label",{"cmdk-label":"",htmlFor:N.inputId,id:N.labelId,style:fk},l),Xs(e,_=>p.createElement(Bp.Provider,{value:I},p.createElement(Fp.Provider,{value:N},_))))}),ek=p.forwardRef((e,t)=>{var n,r;let o=Rt(),s=p.useRef(null),i=p.useContext(zp),a=No(),l=Up(e),c=(r=(n=l.current)==null?void 0:n.forceMount)!=null?r:i==null?void 0:i.forceMount;cr(()=>{if(!c)return a.item(o,i==null?void 0:i.id)},[c]);let d=Wp(o,s,[e.value,e.children,s],e.keywords),h=bl(),m=qn(T=>T.value&&T.value===d.current),f=qn(T=>c||a.filter()===!1?!0:T.search?T.filtered.items.get(o)>0:!0);p.useEffect(()=>{let T=s.current;if(!(!T||e.disabled))return T.addEventListener(vl,v),()=>T.removeEventListener(vl,v)},[f,e.onSelect,e.disabled]);function v(){var T,I;g(),(I=(T=l.current).onSelect)==null||I.call(T,d.current)}function g(){h.setState("value",d.current,!0)}if(!f)return null;let{disabled:x,value:y,onSelect:w,forceMount:S,keywords:k,...C}=e;return p.createElement(ve.div,{ref:On(s,t),...C,id:o,"cmdk-item":"",role:"option","aria-disabled":!!x,"aria-selected":!!m,"data-disabled":!!x,"data-selected":!!m,onPointerMove:x||a.getDisablePointerSelection()?void 0:g,onClick:x?void 0:v},e.children)}),tk=p.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:o,...s}=e,i=Rt(),a=p.useRef(null),l=p.useRef(null),c=Rt(),d=No(),h=qn(f=>o||d.filter()===!1?!0:f.search?f.filtered.groups.has(i):!0);cr(()=>d.group(i),[]),Wp(i,a,[e.value,e.heading,l]);let m=p.useMemo(()=>({id:i,forceMount:o}),[o]);return p.createElement(ve.div,{ref:On(a,t),...s,"cmdk-group":"",role:"presentation",hidden:h?void 0:!0},n&&p.createElement("div",{ref:l,"cmdk-group-heading":"","aria-hidden":!0,id:c},n),Xs(e,f=>p.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?c:void 0},p.createElement(zp.Provider,{value:m},f))))}),nk=p.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,o=p.useRef(null),s=qn(i=>!i.search);return!n&&!s?null:p.createElement(ve.div,{ref:On(o,t),...r,"cmdk-separator":"",role:"separator"})}),rk=p.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,o=e.value!=null,s=bl(),i=qn(c=>c.search),a=qn(c=>c.selectedItemId),l=No();return p.useEffect(()=>{e.value!=null&&s.setState("search",e.value)},[e.value]),p.createElement(ve.input,{ref:t,...r,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":l.listId,"aria-labelledby":l.labelId,"aria-activedescendant":a,id:l.inputId,type:"text",value:o?e.value:i,onChange:c=>{o||s.setState("search",c.target.value),n==null||n(c.target.value)}})}),ok=p.forwardRef((e,t)=>{let{children:n,label:r="Suggestions",...o}=e,s=p.useRef(null),i=p.useRef(null),a=qn(c=>c.selectedItemId),l=No();return p.useEffect(()=>{if(i.current&&s.current){let c=i.current,d=s.current,h,m=new ResizeObserver(()=>{h=requestAnimationFrame(()=>{let f=c.offsetHeight;d.style.setProperty("--cmdk-list-height",f.toFixed(1)+"px")})});return m.observe(c),()=>{cancelAnimationFrame(h),m.unobserve(c)}}},[]),p.createElement(ve.div,{ref:On(s,t),...o,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":a,"aria-label":r,id:l.listId},Xs(e,c=>p.createElement("div",{ref:On(i,l.listInnerRef),"cmdk-list-sizer":""},c)))}),sk=p.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:o,contentClassName:s,container:i,...a}=e;return p.createElement(Ja,{open:n,onOpenChange:r},p.createElement(Za,{container:i},p.createElement(To,{"cmdk-overlay":"",className:o}),p.createElement(ko,{"aria-label":e.label,"cmdk-dialog":"",className:s},p.createElement(Hp,{ref:t,...a}))))}),ik=p.forwardRef((e,t)=>qn(n=>n.filtered.count===0)?p.createElement(ve.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),ak=p.forwardRef((e,t)=>{let{progress:n,children:r,label:o="Loading...",...s}=e;return p.createElement(ve.div,{ref:t,...s,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":o},Xs(e,i=>p.createElement("div",{"aria-hidden":!0},i)))}),Kt=Object.assign(Hp,{List:ok,Item:ek,Input:rk,Group:tk,Separator:nk,Dialog:sk,Empty:ik,Loading:ak});function lk(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function ck(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function Up(e){let t=p.useRef(e);return cr(()=>{t.current=e}),t}var cr=typeof window>"u"?p.useEffect:p.useLayoutEffect;function Dr(e){let t=p.useRef();return t.current===void 0&&(t.current=e()),t}function qn(e){let t=bl(),n=()=>e(t.snapshot());return p.useSyncExternalStore(t.subscribe,n,n)}function Wp(e,t,n,r=[]){let o=p.useRef(),s=No();return cr(()=>{var i;let a=(()=>{var c;for(let d of n){if(typeof d=="string")return d.trim();if(typeof d=="object"&&"current"in d)return d.current?(c=d.current.textContent)==null?void 0:c.trim():o.current}})(),l=r.map(c=>c.trim());s.value(e,a,l),(i=t.current)==null||i.setAttribute(Or,a),o.current=a}),o}var uk=()=>{let[e,t]=p.useState(),n=Dr(()=>new Map);return cr(()=>{n.current.forEach(r=>r()),n.current=new Map},[e]),(r,o)=>{n.current.set(r,o),t({})}};function dk(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function Xs({asChild:e,children:t},n){return e&&p.isValidElement(t)?p.cloneElement(dk(t),{ref:t.ref},n(t.props.children)):n(t)}var fk={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const wl=p.forwardRef(({className:e,...t},n)=>u.jsx(Kt,{ref:n,className:re("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));wl.displayName=Kt.displayName;const yl=p.forwardRef(({className:e,...t},n)=>u.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[u.jsx(ue.Search,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),u.jsx(Kt.Input,{ref:n,className:re("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",e),...t})]}));yl.displayName=Kt.Input.displayName;const Sl=p.forwardRef(({className:e,...t},n)=>u.jsx(Kt.List,{ref:n,className:re("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));Sl.displayName=Kt.List.displayName;const Cl=p.forwardRef((e,t)=>u.jsx(Kt.Empty,{ref:t,className:"py-6 text-center text-sm",...e}));Cl.displayName=Kt.Empty.displayName;const Tl=p.forwardRef(({className:e,...t},n)=>u.jsx(Kt.Group,{ref:n,className:re("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",e),...t}));Tl.displayName=Kt.Group.displayName;const hk=p.forwardRef(({className:e,...t},n)=>u.jsx(Kt.Separator,{ref:n,className:re("-mx-1 h-px bg-border",e),...t}));hk.displayName=Kt.Separator.displayName;const kl=p.forwardRef(({className:e,...t},n)=>u.jsx(Kt.Item,{ref:n,className:re("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected='true']:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50",e),...t}));kl.displayName=Kt.Item.displayName;function El(e,[t,n]){return Math.min(n,Math.max(t,e))}function pk(e,t){return p.useReducer((n,r)=>t[n][r]??n,e)}var Il="ScrollArea",[Vp,_N]=cn(Il),[mk,sn]=Vp(Il),Kp=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,l]=p.useState(null),[c,d]=p.useState(null),[h,m]=p.useState(null),[f,v]=p.useState(null),[g,x]=p.useState(null),[y,w]=p.useState(0),[S,k]=p.useState(0),[C,T]=p.useState(!1),[I,N]=p.useState(!1),R=Le(t,$=>l($)),O=Xo(o);return u.jsx(mk,{scope:n,type:r,dir:O,scrollHideDelay:s,scrollArea:a,viewport:c,onViewportChange:d,content:h,onContentChange:m,scrollbarX:f,onScrollbarXChange:v,scrollbarXEnabled:C,onScrollbarXEnabledChange:T,scrollbarY:g,onScrollbarYChange:x,scrollbarYEnabled:I,onScrollbarYEnabledChange:N,onCornerWidthChange:w,onCornerHeightChange:k,children:u.jsx(ve.div,{dir:O,...i,ref:R,style:{position:"relative","--radix-scroll-area-corner-width":y+"px","--radix-scroll-area-corner-height":S+"px",...e.style}})})});Kp.displayName=Il;var qp="ScrollAreaViewport",Gp=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=sn(qp,n),a=p.useRef(null),l=Le(t,a,i.onViewportChange);return u.jsxs(u.Fragment,{children:[u.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:o}),u.jsx(ve.div,{"data-radix-scroll-area-viewport":"",...s,ref:l,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...e.style},children:u.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});Gp.displayName=qp;var In="ScrollAreaScrollbar",Nl=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=sn(In,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:i}=o,a=e.orientation==="horizontal";return p.useEffect(()=>(a?s(!0):i(!0),()=>{a?s(!1):i(!1)}),[a,s,i]),o.type==="hover"?u.jsx(gk,{...r,ref:t,forceMount:n}):o.type==="scroll"?u.jsx(xk,{...r,ref:t,forceMount:n}):o.type==="auto"?u.jsx(Yp,{...r,ref:t,forceMount:n}):o.type==="always"?u.jsx(Al,{...r,ref:t}):null});Nl.displayName=In;var gk=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=sn(In,e.__scopeScrollArea),[s,i]=p.useState(!1);return p.useEffect(()=>{const a=o.scrollArea;let l=0;if(a){const c=()=>{window.clearTimeout(l),i(!0)},d=()=>{l=window.setTimeout(()=>i(!1),o.scrollHideDelay)};return a.addEventListener("pointerenter",c),a.addEventListener("pointerleave",d),()=>{window.clearTimeout(l),a.removeEventListener("pointerenter",c),a.removeEventListener("pointerleave",d)}}},[o.scrollArea,o.scrollHideDelay]),u.jsx(Wt,{present:n||s,children:u.jsx(Yp,{"data-state":s?"visible":"hidden",...r,ref:t})})}),xk=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=sn(In,e.__scopeScrollArea),s=e.orientation==="horizontal",i=ei(()=>l("SCROLL_END"),100),[a,l]=pk("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return p.useEffect(()=>{if(a==="idle"){const c=window.setTimeout(()=>l("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(c)}},[a,o.scrollHideDelay,l]),p.useEffect(()=>{const c=o.viewport,d=s?"scrollLeft":"scrollTop";if(c){let h=c[d];const m=()=>{const f=c[d];h!==f&&(l("SCROLL"),i()),h=f};return c.addEventListener("scroll",m),()=>c.removeEventListener("scroll",m)}},[o.viewport,s,l,i]),u.jsx(Wt,{present:n||a!=="hidden",children:u.jsx(Al,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:ce(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:ce(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),Yp=p.forwardRef((e,t)=>{const n=sn(In,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=p.useState(!1),a=e.orientation==="horizontal",l=ei(()=>{if(n.viewport){const c=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?c:d)}},10);return Lr(n.viewport,l),Lr(n.content,l),u.jsx(Wt,{present:r||s,children:u.jsx(Al,{"data-state":s?"visible":"hidden",...o,ref:t})})}),Al=p.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=sn(In,e.__scopeScrollArea),s=p.useRef(null),i=p.useRef(0),[a,l]=p.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),c=em(a.viewport,a.content),d={...r,sizes:a,onSizesChange:l,hasThumb:c>0&&c<1,onThumbChange:m=>s.current=m,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:m=>i.current=m};function h(m,f){return Ck(m,i.current,a,f)}return n==="horizontal"?u.jsx(vk,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollLeft,f=tm(m,a,o.dir);s.current.style.transform=`translate3d(${f}px, 0, 0)`}},onWheelScroll:m=>{o.viewport&&(o.viewport.scrollLeft=m)},onDragScroll:m=>{o.viewport&&(o.viewport.scrollLeft=h(m,o.dir))}}):n==="vertical"?u.jsx(bk,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollTop,f=tm(m,a);s.current.style.transform=`translate3d(0, ${f}px, 0)`}},onWheelScroll:m=>{o.viewport&&(o.viewport.scrollTop=m)},onDragScroll:m=>{o.viewport&&(o.viewport.scrollTop=h(m))}}):null}),vk=p.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=sn(In,e.__scopeScrollArea),[i,a]=p.useState(),l=p.useRef(null),c=Le(t,l,s.onScrollbarXChange);return p.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(Jp,{"data-orientation":"horizontal",...o,ref:c,sizes:n,style:{bottom:0,left:s.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:s.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":Qs(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.x),onDragScroll:d=>e.onDragScroll(d.x),onWheelScroll:(d,h)=>{if(s.viewport){const m=s.viewport.scrollLeft+d.deltaX;e.onWheelScroll(m),rm(m,h)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:l.current.clientWidth,paddingStart:Zs(i.paddingLeft),paddingEnd:Zs(i.paddingRight)}})}})}),bk=p.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=sn(In,e.__scopeScrollArea),[i,a]=p.useState(),l=p.useRef(null),c=Le(t,l,s.onScrollbarYChange);return p.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(Jp,{"data-orientation":"vertical",...o,ref:c,sizes:n,style:{top:0,right:s.dir==="ltr"?0:void 0,left:s.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":Qs(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.y),onDragScroll:d=>e.onDragScroll(d.y),onWheelScroll:(d,h)=>{if(s.viewport){const m=s.viewport.scrollTop+d.deltaY;e.onWheelScroll(m),rm(m,h)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:l.current.clientHeight,paddingStart:Zs(i.paddingTop),paddingEnd:Zs(i.paddingBottom)}})}})}),[wk,Xp]=Vp(In),Jp=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:s,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:l,onDragScroll:c,onWheelScroll:d,onResize:h,...m}=e,f=sn(In,n),[v,g]=p.useState(null),x=Le(t,R=>g(R)),y=p.useRef(null),w=p.useRef(""),S=f.viewport,k=r.content-r.viewport,C=pt(d),T=pt(l),I=ei(h,10);function N(R){if(y.current){const O=R.clientX-y.current.left,$=R.clientY-y.current.top;c({x:O,y:$})}}return p.useEffect(()=>{const R=O=>{const $=O.target;(v==null?void 0:v.contains($))&&C(O,k)};return document.addEventListener("wheel",R,{passive:!1}),()=>document.removeEventListener("wheel",R,{passive:!1})},[S,v,k,C]),p.useEffect(T,[r,T]),Lr(v,I),Lr(f.content,I),u.jsx(wk,{scope:n,scrollbar:v,hasThumb:o,onThumbChange:pt(s),onThumbPointerUp:pt(i),onThumbPositionChange:T,onThumbPointerDown:pt(a),children:u.jsx(ve.div,{...m,ref:x,style:{position:"absolute",...m.style},onPointerDown:ce(e.onPointerDown,R=>{R.button===0&&(R.target.setPointerCapture(R.pointerId),y.current=v.getBoundingClientRect(),w.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",f.viewport&&(f.viewport.style.scrollBehavior="auto"),N(R))}),onPointerMove:ce(e.onPointerMove,N),onPointerUp:ce(e.onPointerUp,R=>{const O=R.target;O.hasPointerCapture(R.pointerId)&&O.releasePointerCapture(R.pointerId),document.body.style.webkitUserSelect=w.current,f.viewport&&(f.viewport.style.scrollBehavior=""),y.current=null})})})}),Js="ScrollAreaThumb",Zp=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Xp(Js,e.__scopeScrollArea);return u.jsx(Wt,{present:n||o.hasThumb,children:u.jsx(yk,{ref:t,...r})})}),yk=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=sn(Js,n),i=Xp(Js,n),{onThumbPositionChange:a}=i,l=Le(t,h=>i.onThumbChange(h)),c=p.useRef(void 0),d=ei(()=>{c.current&&(c.current(),c.current=void 0)},100);return p.useEffect(()=>{const h=s.viewport;if(h){const m=()=>{if(d(),!c.current){const f=Tk(h,a);c.current=f,a()}};return a(),h.addEventListener("scroll",m),()=>h.removeEventListener("scroll",m)}},[s.viewport,d,a]),u.jsx(ve.div,{"data-state":i.hasThumb?"visible":"hidden",...o,ref:l,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture:ce(e.onPointerDownCapture,h=>{const f=h.target.getBoundingClientRect(),v=h.clientX-f.left,g=h.clientY-f.top;i.onThumbPointerDown({x:v,y:g})}),onPointerUp:ce(e.onPointerUp,i.onThumbPointerUp)})});Zp.displayName=Js;var jl="ScrollAreaCorner",Qp=p.forwardRef((e,t)=>{const n=sn(jl,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?u.jsx(Sk,{...e,ref:t}):null});Qp.displayName=jl;var Sk=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=sn(jl,n),[s,i]=p.useState(0),[a,l]=p.useState(0),c=!!(s&&a);return Lr(o.scrollbarX,()=>{var h;const d=((h=o.scrollbarX)==null?void 0:h.offsetHeight)||0;o.onCornerHeightChange(d),l(d)}),Lr(o.scrollbarY,()=>{var h;const d=((h=o.scrollbarY)==null?void 0:h.offsetWidth)||0;o.onCornerWidthChange(d),i(d)}),c?u.jsx(ve.div,{...r,ref:t,style:{width:s,height:a,position:"absolute",right:o.dir==="ltr"?0:void 0,left:o.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function Zs(e){return e?parseInt(e,10):0}function em(e,t){const n=e/t;return isNaN(n)?0:n}function Qs(e){const t=em(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function Ck(e,t,n,r="ltr"){const o=Qs(n),s=o/2,i=t||s,a=o-i,l=n.scrollbar.paddingStart+i,c=n.scrollbar.size-n.scrollbar.paddingEnd-a,d=n.content-n.viewport,h=r==="ltr"?[0,d]:[d*-1,0];return nm([l,c],h)(e)}function tm(e,t,n="ltr"){const r=Qs(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,s=t.scrollbar.size-o,i=t.content-t.viewport,a=s-r,l=n==="ltr"?[0,i]:[i*-1,0],c=El(e,l);return nm([0,i],[0,a])(c)}function nm(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function rm(e,t){return e>0&&e<t}var Tk=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;return function o(){const s={left:e.scrollLeft,top:e.scrollTop},i=n.left!==s.left,a=n.top!==s.top;(i||a)&&t(),n=s,r=window.requestAnimationFrame(o)}(),()=>window.cancelAnimationFrame(r)};function ei(e,t){const n=pt(e),r=p.useRef(0);return p.useEffect(()=>()=>window.clearTimeout(r.current),[]),p.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function Lr(e,t){const n=pt(t);Et(()=>{let r=0;if(e){const o=new ResizeObserver(()=>{cancelAnimationFrame(r),r=window.requestAnimationFrame(n)});return o.observe(e),()=>{window.cancelAnimationFrame(r),o.unobserve(e)}}},[e,n])}var om=Kp,kk=Gp,Ek=Qp;const _l=p.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(om,{ref:r,className:re("relative overflow-hidden",e),...n,children:[u.jsx(kk,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),u.jsx(sm,{}),u.jsx(Ek,{})]}));_l.displayName=om.displayName;const sm=p.forwardRef(({className:e,orientation:t="vertical",...n},r)=>u.jsx(Nl,{ref:r,orientation:t,className:re("flex touch-none select-none transition-colors",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...n,children:u.jsx(Zp,{className:"relative flex-1 rounded-full bg-border"})}));sm.displayName=Nl.displayName;const Pl=p.forwardRef(({className:e,type:t,...n},r)=>u.jsx("input",{type:t,className:re("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:r,...n}));Pl.displayName="Input";const Ik="group relative p-3 rounded-lg cursor-pointer transition-colors border text-gray-900 dark:text-slate-100",Nk="bg-slate-700 border-slate-600 hover:bg-slate-600",Ak="bg-slate-600 border-slate-500";function im({thread:e,isActive:t,editingThreadId:n,editingTitle:r,onSelect:o,onStartEditing:s,onEditingTitleChange:i,onSaveEditing:a,onCancelEditing:l,onShare:c,onDelete:d,showEditTitle:h,showDeleteButton:m,formatDate:f,getDisplayThreadTitle:v,secondaryLine:g,itemClassName:x,activeItemClassName:y}){const w=n===e.threadId,S=t?`${y??Ak}`:`${x??Nk}`,k=C=>{C.stopPropagation(),o(e.threadId)};return u.jsxs("div",{onClick:k,className:`${Ik} ${S}`,children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("div",{className:"flex-1 min-w-0",children:w?u.jsxs("div",{className:"flex items-center gap-2",onClick:C=>C.stopPropagation(),children:[u.jsx(Pl,{value:r,onChange:C=>i(C.target.value),onKeyDown:C=>{C.key==="Enter"?a(e.threadId):C.key==="Escape"&&l()},className:"h-6 text-sm",autoFocus:!0}),u.jsx(Qe,{variant:"ghost",size:"sm",onClick:()=>a(e.threadId),className:"h-6 w-6 p-0",children:u.jsx(ue.Check,{size:12})}),u.jsx(Qe,{variant:"ghost",size:"sm",onClick:l,className:"h-6 w-6 p-0",children:u.jsx(ue.X,{size:12})})]}):u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"font-medium text-sm truncate text-gray-900 dark:text-slate-100",children:v(e)}),u.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500 dark:text-slate-400 mt-1",children:[u.jsx(ue.Calendar,{size:10}),u.jsx("span",{children:f(e.updatedAt||e.createdAt)})]}),g&&u.jsx("div",{className:"text-[11px] text-muted-foreground mt-1",children:g})]})}),u.jsx("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-2",children:u.jsxs(Ss,{children:[u.jsx(Cs,{asChild:!0,children:u.jsx(Qe,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",children:u.jsx(ue.MoreHorizontal,{size:12})})}),u.jsxs(ho,{align:"end",sideOffset:6,className:"w-44",children:[u.jsxs(Bn,{onClick:C=>{C.preventDefault(),c(e.threadId)},children:[u.jsx(ue.Share2,{className:"mr-2 h-4 w-4"}),"Share thread"]}),h&&n!==e.threadId&&u.jsxs(Bn,{onClick:C=>{C.preventDefault(),s(e,C)},children:[u.jsx(ue.Edit3,{className:"mr-2 h-4 w-4"}),"Rename"]}),m&&d&&u.jsxs(Bn,{className:"text-red-400 hover:text-red-300",onClick:C=>{C.preventDefault(),d(e.threadId,C)},children:[u.jsx(ue.Trash2,{className:"mr-2 h-4 w-4"}),"Delete"]})]})]})})]}),t&&u.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-1 h-8 bg-blue-400 rounded-r"})]})}const am=25,lm="thread-manager-view",jk=e=>e==="default"||e==="shared",_k=()=>{if(typeof window>"u")return null;try{const e=window.localStorage.getItem(lm);if(jk(e))return e}catch{}return null};function cm({defaultView:e}={}){const[t,n]=b.useState(()=>_k()??e??"default");b.useEffect(()=>{if(!(typeof window>"u"))try{window.localStorage.setItem(lm,t)}catch{}},[t]);const r=b.useCallback(o=>{n(o)},[]);return{view:t,setView:r}}const Pk=[{key:"default",label:"My chats"},{key:"shared",label:"Shared with you"}];function ti({className:e="",showCreateButton:t=!0,showDeleteButton:n=!0,showEditTitle:r=!0,maxHeight:o="400px",customStyles:s={},currentThreadId:i=null,navigateToThread:a,onThreadSelect:l,onThreadCreate:c,onThreadDelete:d,view:h,defaultView:m,onViewChange:f,viewOptions:v,viewState:g,showHeader:x=!0,shareTargets:y,isLoadingShareTargets:w,shareTargetFilter:S}){const{threads:k,sharedThreads:C,currentThreadId:T,setCurrentThreadId:I,isLoading:N,isLoadingSharedThreads:R,actions:O,shareInFlight:$,shareStatus:V,clearShareStatus:U}=gr(),{createThread:j,deleteThread:q,renameThread:K,shareThread:D}=O,{loadThread:P}=eo(),E=i??T,[B,Y]=b.useState(Array.isArray(k)?k:[]),_=b.useRef(B.length>0),M=b.useRef(null),G=b.useRef(0),[J,se]=b.useState(null),[W,L]=b.useState(""),[X,ee]=b.useState(!1),[Z,z]=b.useState(!1),[ae,ie]=b.useState(null),[ge,we]=b.useState(""),Ae=v&&v.length>0?v:Pk,Pe=cm({defaultView:m}),ke=g??Pe,st=h??ke.view,bt=b.useCallback(Q=>{h||ke.setView(Q),f==null||f(Q)},[h,f,ke]),It=Ae.find(Q=>Q.key===st)??Ae[0],We=Q=>{ie(Q),we(""),z(!0)},ze=()=>{z(!1),ie(null),we(""),U()},Ke=b.useCallback(async Q=>{if(!(!ae||$)&&Q.id)try{await D(ae,Q.id),setTimeout(()=>ze(),600)}catch(me){console.error("Failed to share thread:",me)}},[ze,$,ae,D]),Fe=b.useMemo(()=>{const Q=y??[],me=ge.trim().toLowerCase();return me?S?Q.filter(Ze=>S(Ze,me)):Q.filter(Ze=>`${Ze.label} ${Ze.secondaryLabel??""}`.toLowerCase().includes(me)):Q},[y,ge,S]),Ue=st==="shared",ut=Ue?C:B,jt=Ue?R:N,it=Ue?"No shared conversations yet":"No conversations yet",_t=Q=>{const me=Q.sharedAt?` • ${Oe(Q.sharedAt)}`:"";return`Shared by ${Q.sharedByUserId}${me}`},yt=Q=>"sharedByUserId"in Q;b.useEffect(()=>{const Q=Array.isArray(k)?k:[];if(Q.length>0){_.current=!0,Y(Q);return}N||(_.current=!1,Y(Q))},[k,N]),b.useEffect(()=>{if(!M.current)return;const Q=M.current.querySelector("[data-radix-scroll-area-viewport]");if(!Q)return;let me=null,Ze=null;return me=requestAnimationFrame(()=>{Ze=requestAnimationFrame(()=>{Q.scrollTop=G.current})}),()=>{me!==null&&cancelAnimationFrame(me),Ze!==null&&cancelAnimationFrame(Ze)}},[B]);const gt=async Q=>{try{I(Q),await P(Q),a==null||a(Q),l==null||l(Q)}catch(me){console.error("Failed to select thread:",me)}},Nt=async()=>{try{ee(!0);const Q=await j();Q&&(c==null||c(Q),a==null||a(Q))}catch(Q){console.error("Failed to create thread:",Q)}finally{ee(!1)}},St=async(Q,me)=>{if(me.stopPropagation(),!!confirm("Delete this thread?")){if(M.current){const Ze=M.current.querySelector("[data-radix-scroll-area-viewport]");Ze&&(G.current=Ze.scrollTop)}try{await q(Q),d==null||d(Q)}catch(Ze){console.error("Failed to delete thread:",Ze)}}},Ct=(Q,me)=>{me.stopPropagation(),se(Q.threadId),L(Q.title||`Thread ${Q.threadId.slice(0,8)}`)},zt=async Q=>{if(W.trim())try{await K(Q,W.trim()),se(null),L("")}catch(me){console.error("Failed to update title:",me)}},xt=()=>{se(null),L("")},Oe=Q=>{if(!Q)return"";try{const me=new Date(Q),xe=new Date().getTime()-me.getTime(),Be=Math.floor(xe/(1e3*60*60*24));return Be===0?me.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):Be===1?"Yesterday":Be<7?`${Be} days ago`:me.toLocaleDateString()}catch{return""}},Ve=Q=>Q.title||`Thread ${Q.threadId.slice(0,8)}`,Te=Q=>{const me=Ve(Q);return me.length<=am?me:`${me.slice(0,am)}...`};return u.jsxs("div",{className:`flex flex-col h-full ${e} ${s.container||""}`,children:[x&&u.jsxs("div",{className:s.header||"flex flex-col gap-2 px-1 py-0 border border-slate-200 bg-white dark:border-slate-700 dark:bg-slate-900 shadow-sm",children:[t&&u.jsx("div",{className:"flex justify-end",children:u.jsxs(Qe,{onClick:Nt,disabled:X||N,className:s.createButton||"px-3 py-2 gap-1",size:"sm",variant:"ghost",title:X?"Creating...":"New Chat",children:[u.jsx(ue.Edit3,{size:16}),u.jsx("span",{children:"New chat"})]})}),u.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-slate-700 dark:text-slate-200 uppercase tracking-wide leading-tight",children:[u.jsx("span",{children:"Current View"}),u.jsxs(Ss,{children:[u.jsx(Cs,{asChild:!0,children:u.jsx(Qe,{variant:"outline",size:"sm",className:"text-[11px] text-slate-700 dark:text-slate-200 border border-slate-300 dark:border-slate-600 bg-white dark:bg-slate-900 hover:bg-slate-50 dark:hover:bg-slate-800 px-2 py-0",children:It.label})}),u.jsx(ho,{align:"start",sideOffset:6,className:"w-40",children:Ae.map(Q=>u.jsxs(Bn,{className:"justify-between text-[12px]",onClick:me=>{me.preventDefault(),bt(Q.key)},children:[u.jsx("span",{children:Q.label}),st===Q.key&&u.jsx(ue.Check,{className:"h-3 w-3"})]},Q.key))})]})]})]}),u.jsx(_l,{ref:M,className:`flex-1 min-h-0 ${s.threadList||""}`,style:o?{maxHeight:o}:void 0,children:u.jsx("div",{className:"p-2 space-y-1 pb-4",children:jt?u.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-8 text-slate-400",children:[u.jsx(ue.Loader2,{className:"h-5 w-5 animate-spin"}),u.jsx("span",{className:"text-sm",children:"Loading threads…"})]}):ut.length===0?u.jsxs("div",{className:"text-center py-8 text-slate-400",children:[u.jsx(ue.MessageSquare,{className:"w-8 h-8 mx-auto mb-2 opacity-40 text-slate-500"}),u.jsx("p",{className:"text-sm text-slate-500",children:it})]}):ut.slice().sort((Q,me)=>new Date(me.updatedAt||me.createdAt||"").getTime()-new Date(Q.updatedAt||Q.createdAt||"").getTime()).map(Q=>u.jsx(im,{thread:Q,isActive:E===Q.threadId,editingThreadId:J,editingTitle:W,onSelect:gt,onStartEditing:Ct,onEditingTitleChange:me=>L(me),onSaveEditing:zt,onCancelEditing:xt,onShare:()=>We(Q.threadId),onDelete:St,showEditTitle:r,showDeleteButton:n,formatDate:Oe,getDisplayThreadTitle:Te,secondaryLine:Ue&&yt(Q)?_t(Q):void 0,itemClassName:s.threadItem,activeItemClassName:s.activeThread},Q.threadId))})}),u.jsx(Qa,{open:Z,onOpenChange:Q=>!Q&&ze(),children:u.jsxs(Bs,{className:"max-w-md p-0",children:[u.jsx(zs,{children:u.jsx(Hs,{children:"Share thread"})}),u.jsxs(wl,{children:[u.jsx(yl,{autoFocus:!0,value:ge,onValueChange:Q=>we(Q),placeholder:"Search for recipients..."}),u.jsxs(Sl,{children:[V&&u.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-xs text-muted-foreground",children:[$&&u.jsx(ue.Loader2,{className:"h-3 w-3 animate-spin"}),u.jsx("span",{className:V.startsWith("Failed")?"text-red-500":V.startsWith("Shared")?"text-emerald-500":"text-slate-600 dark:text-slate-400",children:V})]}),u.jsx(Cl,{children:w?u.jsxs("span",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(ue.Loader2,{className:"h-4 w-4 animate-spin"}),"Loading recipients…"]}):"No matching recipients found"}),Fe.length>0&&u.jsx(Tl,{heading:"Recipients",children:Fe.map(Q=>u.jsx(kl,{onSelect:()=>Ke(Q),children:u.jsxs("div",{className:"flex flex-col items-start text-sm",children:[u.jsx("span",{className:"font-medium",children:Q.label}),Q.secondaryLabel&&u.jsx("span",{className:"text-xs text-muted-foreground",children:Q.secondaryLabel})]})},Q.id))})]})]})]})})]})}function Rk({layout:e="sidebar",layoutSize:t="desktop",showThreads:n=!0,className:r="",customStyles:o={},...s}){const i=c=>{const d="h-full";switch(c){case"phone":return`${d} max-w-none`;case"tablet":return`${d} max-w-4xl mx-auto`;case"half-screen":return`${d} max-w-2xl`;case"desktop":default:return`${d} max-w-7xl mx-auto`}},a=c=>({"--chat-sidebar-width":c==="phone"?"100%":c==="tablet"?"280px":c==="half-screen"?"240px":"320px","--chat-message-max-width":c==="phone"?"95%":c==="tablet"?"90%":c==="half-screen"?"85%":"80%","--chat-input-height":c==="phone"?"120px":"100px"}),l=b.useCallback(c=>{var d;(d=s.onThreadChange)==null||d.call(s,c)},[s]);return e==="fullscreen"?u.jsx(vr,{...s,onThreadChange:l,children:u.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:u.jsx(Mr,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?u.jsx(vr,{...s,onThreadChange:l,children:u.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:u.jsxs("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[n&&u.jsx("div",{className:`w-80 border-r flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:u.jsx(ti,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),u.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:u.jsx(Mr,{onError:s.onError,enableFileUpload:!0})})]})})}):u.jsx(vr,{...s,onThreadChange:l,children:u.jsxs("div",{className:`${i(t)} flex overflow-hidden ${r} ${o.container||""}`,style:a(t),children:[n&&u.jsx("div",{className:`w-80 border-r bg-gray-50 flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:u.jsx(ti,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),u.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:u.jsx(Mr,{onError:s.onError,enableFileUpload:!0})})]})})}function Mk({apiConfig:e,className:t="",onError:n}){return u.jsx(vr,{apiConfig:e,onError:n,children:u.jsx("div",{className:`h-full ${t}`,children:u.jsx(Mr,{})})})}function Ok({placeholder:e,onMessageSent:t}){const[n,r]=b.useState("chat");return u.jsxs("div",{className:"flex flex-col h-full",children:[u.jsxs("div",{className:"flex border-b border-gray-200 bg-gray-50",children:[u.jsx("button",{onClick:()=>r("chat"),className:`flex-1 px-3 py-2 text-sm font-medium transition-colors ${n==="chat"?"border-b-2 border-slate-800 text-slate-800 bg-white":"text-gray-600 hover:text-gray-800"}`,children:u.jsxs("div",{className:"flex items-center justify-center gap-2",children:[u.jsx(ue.MessageSquare,{size:14}),"Chat"]})}),u.jsx("button",{onClick:()=>r("threads"),className:`flex-1 px-3 py-2 text-sm font-medium transition-colors ${n==="threads"?"border-b-2 border-slate-800 text-slate-800 bg-white":"text-gray-600 hover:text-gray-800"}`,children:u.jsxs("div",{className:"flex items-center justify-center gap-2",children:[u.jsx(ue.History,{size:14}),"History"]})})]}),u.jsx("div",{className:"flex-1 min-h-0",children:n==="chat"?u.jsx(Mr,{placeholder:e??"Ask Serti AI anything...",autoFocus:!0,className:"h-full",onMessageSent:t}):u.jsx(ti,{showCreateButton:!0,className:"h-full",onThreadSelect:()=>r("chat")})})]})}function Dk({className:e="",placeholder:t,isAuthenticated:n=!0,onMessageSent:r,widgetTitle:o="Serti AI Navigator",widgetSubtitle:s="AI-Powered Assistant",...i}){const[a,l]=b.useState(!1);return n?u.jsx(vr,{...i,children:u.jsx("div",{className:`fixed bottom-6 right-6 z-[9999] transition-all duration-300 ${e}`,children:u.jsxs("div",{className:`w-96 bg-white rounded-xl shadow-2xl border border-gray-200 overflow-hidden relative ${a?"scale-75":"scale-100"}`,children:[u.jsx("div",{className:"bg-slate-800 text-white p-4 flex-shrink-0",children:u.jsxs("div",{className:"flex items-center justify-between gap-3",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsxs("div",{className:"relative h-10 w-10 rounded-full bg-gradient-to-br from-slate-500 to-slate-700 border border-white/30 flex items-center justify-center text-white text-sm font-bold",children:["S",u.jsx("span",{className:"absolute -bottom-0.5 -right-0.5 h-3 w-3 rounded-full border-2 border-slate-800 bg-emerald-400"})]}),u.jsxs("div",{className:"flex flex-col",children:[u.jsx("h3",{className:"text-lg font-semibold leading-tight",children:o}),u.jsx("p",{className:"text-xs text-white/70",children:s})]}),u.jsx("span",{className:"ml-2 inline-flex items-center justify-center rounded-full bg-red-500 px-2 py-0.5 text-[11px] font-semibold leading-none text-white",children:"1"})]}),u.jsxs("div",{className:"flex items-center gap-1",children:[u.jsx(Qe,{variant:"ghost",size:"sm",className:"text-white hover:bg-white/10 h-8 w-8 p-0",title:"Options",children:u.jsx(ue.MoreHorizontal,{size:16})}),u.jsx(Qe,{variant:"ghost",size:"sm",className:"text-white hover:bg-white/10 h-8 w-8 p-0",title:"Compose",children:u.jsx(ue.Edit3,{size:16})}),u.jsx(Qe,{variant:"ghost",size:"sm",onClick:c=>{c.stopPropagation(),l(d=>!d)},className:"text-white hover:bg-white/10 h-8 w-8 p-0",title:a?"Maximize":"Minimize",children:a?u.jsx(ue.Maximize2,{size:14}):u.jsx(ue.Minimize2,{size:14})})]})]})}),!a&&u.jsx("div",{className:"h-96 flex flex-col",children:u.jsx(Ok,{placeholder:t,onMessageSent:r})})]})})}):null}function Lk({label:e="New chat",children:t,className:n,variant:r="ghost",size:o="sm",...s}){return u.jsxs(Qe,{variant:r,size:o,className:re("gap-2 rounded-full px-3 font-semibold transition-all hover:scale-[1.01]",n),...s,children:[u.jsx(ue.Edit3,{size:16}),t??e]})}var $k="Label",um=p.forwardRef((e,t)=>u.jsx(ve.label,{...e,ref:t,onMouseDown:n=>{var o;n.target.closest("button, input, select, textarea")||((o=e.onMouseDown)==null||o.call(e,n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));um.displayName=$k;var dm=um;const Fk=zr.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),fm=p.forwardRef(({className:e,...t},n)=>u.jsx(dm,{ref:n,className:re(Fk(),e),...t}));fm.displayName=dm.displayName;function hm(e){const t=p.useRef({value:e,previous:e});return p.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var pm=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),Bk="VisuallyHidden",ni=p.forwardRef((e,t)=>u.jsx(ve.span,{...e,ref:t,style:{...pm,...e.style}}));ni.displayName=Bk;var zk=ni,Hk=[" ","Enter","ArrowUp","ArrowDown"],Uk=[" ","Enter"],ur="Select",[ri,oi,Wk]=Yo(ur),[$r,PN]=cn(ur,[Wk,kr]),si=kr(),[Vk,Gn]=$r(ur),[Kk,qk]=$r(ur),mm=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:s,value:i,defaultValue:a,onValueChange:l,dir:c,name:d,autoComplete:h,disabled:m,required:f,form:v}=e,g=si(t),[x,y]=p.useState(null),[w,S]=p.useState(null),[k,C]=p.useState(!1),T=Xo(c),[I,N]=Dn({prop:r,defaultProp:o??!1,onChange:s,caller:ur}),[R,O]=Dn({prop:i,defaultProp:a,onChange:l,caller:ur}),$=p.useRef(null),V=x?v||!!x.closest("form"):!0,[U,j]=p.useState(new Set),q=Array.from(U).map(K=>K.props.value).join(";");return u.jsx(oa,{...g,children:u.jsxs(Vk,{required:f,scope:t,trigger:x,onTriggerChange:y,valueNode:w,onValueNodeChange:S,valueNodeHasChildren:k,onValueNodeHasChildrenChange:C,contentId:Rt(),value:R,onValueChange:O,open:I,onOpenChange:N,dir:T,triggerPointerDownPosRef:$,disabled:m,children:[u.jsx(ri.Provider,{scope:t,children:u.jsx(Kk,{scope:e.__scopeSelect,onNativeOptionAdd:p.useCallback(K=>{j(D=>new Set(D).add(K))},[]),onNativeOptionRemove:p.useCallback(K=>{j(D=>{const P=new Set(D);return P.delete(K),P})},[]),children:n})}),V?u.jsxs(Fm,{"aria-hidden":!0,required:f,tabIndex:-1,name:d,autoComplete:h,value:R,onChange:K=>O(K.target.value),disabled:m,form:v,children:[R===void 0?u.jsx("option",{value:""}):null,Array.from(U)]},q):null]})})};mm.displayName=ur;var gm="SelectTrigger",xm=p.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=si(n),i=Gn(gm,n),a=i.disabled||r,l=Le(t,i.onTriggerChange),c=oi(n),d=p.useRef("touch"),[h,m,f]=zm(g=>{const x=c().filter(S=>!S.disabled),y=x.find(S=>S.value===i.value),w=Hm(x,g,y);w!==void 0&&i.onValueChange(w.value)}),v=g=>{a||(i.onOpenChange(!0),f()),g&&(i.triggerPointerDownPosRef.current={x:Math.round(g.pageX),y:Math.round(g.pageY)})};return u.jsx(sa,{asChild:!0,...s,children:u.jsx(ve.button,{type:"button",role:"combobox","aria-controls":i.contentId,"aria-expanded":i.open,"aria-required":i.required,"aria-autocomplete":"none",dir:i.dir,"data-state":i.open?"open":"closed",disabled:a,"data-disabled":a?"":void 0,"data-placeholder":Bm(i.value)?"":void 0,...o,ref:l,onClick:ce(o.onClick,g=>{g.currentTarget.focus(),d.current!=="mouse"&&v(g)}),onPointerDown:ce(o.onPointerDown,g=>{d.current=g.pointerType;const x=g.target;x.hasPointerCapture(g.pointerId)&&x.releasePointerCapture(g.pointerId),g.button===0&&g.ctrlKey===!1&&g.pointerType==="mouse"&&(v(g),g.preventDefault())}),onKeyDown:ce(o.onKeyDown,g=>{const x=h.current!=="";!(g.ctrlKey||g.altKey||g.metaKey)&&g.key.length===1&&m(g.key),!(x&&g.key===" ")&&Hk.includes(g.key)&&(v(),g.preventDefault())})})})});xm.displayName=gm;var vm="SelectValue",bm=p.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,l=Gn(vm,n),{onValueNodeHasChildrenChange:c}=l,d=s!==void 0,h=Le(t,l.onValueNodeChange);return Et(()=>{c(d)},[c,d]),u.jsx(ve.span,{...a,ref:h,style:{pointerEvents:"none"},children:Bm(l.value)?u.jsx(u.Fragment,{children:i}):s})});bm.displayName=vm;var Gk="SelectIcon",wm=p.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return u.jsx(ve.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});wm.displayName=Gk;var Yk="SelectPortal",ym=e=>u.jsx(so,{asChild:!0,...e});ym.displayName=Yk;var dr="SelectContent",Sm=p.forwardRef((e,t)=>{const n=Gn(dr,e.__scopeSelect),[r,o]=p.useState();if(Et(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?Hr.createPortal(u.jsx(Cm,{scope:e.__scopeSelect,children:u.jsx(ri.Slot,{scope:e.__scopeSelect,children:u.jsx("div",{children:e.children})})}),s):null}return u.jsx(Tm,{...e,ref:t})});Sm.displayName=dr;var mn=10,[Cm,Yn]=$r(dr),Xk="SelectContentImpl",Jk=Yt.createSlot("SelectContent.RemoveScroll"),Tm=p.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:i,side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:h,collisionBoundary:m,collisionPadding:f,sticky:v,hideWhenDetached:g,avoidCollisions:x,...y}=e,w=Gn(dr,n),[S,k]=p.useState(null),[C,T]=p.useState(null),I=Le(t,W=>k(W)),[N,R]=p.useState(null),[O,$]=p.useState(null),V=oi(n),[U,j]=p.useState(!1),q=p.useRef(!1);p.useEffect(()=>{if(S)return da(S)},[S]),Hi();const K=p.useCallback(W=>{const[L,...X]=V().map(z=>z.ref.current),[ee]=X.slice(-1),Z=document.activeElement;for(const z of W)if(z===Z||(z==null||z.scrollIntoView({block:"nearest"}),z===L&&C&&(C.scrollTop=0),z===ee&&C&&(C.scrollTop=C.scrollHeight),z==null||z.focus(),document.activeElement!==Z))return},[V,C]),D=p.useCallback(()=>K([N,S]),[K,N,S]);p.useEffect(()=>{U&&D()},[U,D]);const{onOpenChange:P,triggerPointerDownPosRef:E}=w;p.useEffect(()=>{if(S){let W={x:0,y:0};const L=ee=>{var Z,z;W={x:Math.abs(Math.round(ee.pageX)-(((Z=E.current)==null?void 0:Z.x)??0)),y:Math.abs(Math.round(ee.pageY)-(((z=E.current)==null?void 0:z.y)??0))}},X=ee=>{W.x<=10&&W.y<=10?ee.preventDefault():S.contains(ee.target)||P(!1),document.removeEventListener("pointermove",L),E.current=null};return E.current!==null&&(document.addEventListener("pointermove",L),document.addEventListener("pointerup",X,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",L),document.removeEventListener("pointerup",X,{capture:!0})}}},[S,P,E]),p.useEffect(()=>{const W=()=>P(!1);return window.addEventListener("blur",W),window.addEventListener("resize",W),()=>{window.removeEventListener("blur",W),window.removeEventListener("resize",W)}},[P]);const[B,Y]=zm(W=>{const L=V().filter(Z=>!Z.disabled),X=L.find(Z=>Z.ref.current===document.activeElement),ee=Hm(L,W,X);ee&&setTimeout(()=>ee.ref.current.focus())}),_=p.useCallback((W,L,X)=>{const ee=!q.current&&!X;(w.value!==void 0&&w.value===L||ee)&&(R(W),ee&&(q.current=!0))},[w.value]),M=p.useCallback(()=>S==null?void 0:S.focus(),[S]),G=p.useCallback((W,L,X)=>{const ee=!q.current&&!X;(w.value!==void 0&&w.value===L||ee)&&$(W)},[w.value]),J=r==="popper"?Rl:km,se=J===Rl?{side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:h,collisionBoundary:m,collisionPadding:f,sticky:v,hideWhenDetached:g,avoidCollisions:x}:{};return u.jsx(Cm,{scope:n,content:S,viewport:C,onViewportChange:T,itemRefCallback:_,selectedItem:N,onItemLeave:M,itemTextRefCallback:G,focusSelectedItem:D,selectedItemText:O,position:r,isPositioned:U,searchRef:B,children:u.jsx(gs,{as:Jk,allowPinchZoom:!0,children:u.jsx(Jo,{asChild:!0,trapped:w.open,onMountAutoFocus:W=>{W.preventDefault()},onUnmountAutoFocus:ce(o,W=>{var L;(L=w.trigger)==null||L.focus({preventScroll:!0}),W.preventDefault()}),children:u.jsx(wr,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:W=>W.preventDefault(),onDismiss:()=>w.onOpenChange(!1),children:u.jsx(J,{role:"listbox",id:w.contentId,"data-state":w.open?"open":"closed",dir:w.dir,onContextMenu:W=>W.preventDefault(),...y,...se,onPlaced:()=>j(!0),ref:I,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:ce(y.onKeyDown,W=>{const L=W.ctrlKey||W.altKey||W.metaKey;if(W.key==="Tab"&&W.preventDefault(),!L&&W.key.length===1&&Y(W.key),["ArrowUp","ArrowDown","Home","End"].includes(W.key)){let ee=V().filter(Z=>!Z.disabled).map(Z=>Z.ref.current);if(["ArrowUp","End"].includes(W.key)&&(ee=ee.slice().reverse()),["ArrowUp","ArrowDown"].includes(W.key)){const Z=W.target,z=ee.indexOf(Z);ee=ee.slice(z+1)}setTimeout(()=>K(ee)),W.preventDefault()}})})})})})})});Tm.displayName=Xk;var Zk="SelectItemAlignedPosition",km=p.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=Gn(dr,n),i=Yn(dr,n),[a,l]=p.useState(null),[c,d]=p.useState(null),h=Le(t,I=>d(I)),m=oi(n),f=p.useRef(!1),v=p.useRef(!0),{viewport:g,selectedItem:x,selectedItemText:y,focusSelectedItem:w}=i,S=p.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&c&&g&&x&&y){const I=s.trigger.getBoundingClientRect(),N=c.getBoundingClientRect(),R=s.valueNode.getBoundingClientRect(),O=y.getBoundingClientRect();if(s.dir!=="rtl"){const Z=O.left-N.left,z=R.left-Z,ae=I.left-z,ie=I.width+ae,ge=Math.max(ie,N.width),we=window.innerWidth-mn,Ae=El(z,[mn,Math.max(mn,we-ge)]);a.style.minWidth=ie+"px",a.style.left=Ae+"px"}else{const Z=N.right-O.right,z=window.innerWidth-R.right-Z,ae=window.innerWidth-I.right-z,ie=I.width+ae,ge=Math.max(ie,N.width),we=window.innerWidth-mn,Ae=El(z,[mn,Math.max(mn,we-ge)]);a.style.minWidth=ie+"px",a.style.right=Ae+"px"}const $=m(),V=window.innerHeight-mn*2,U=g.scrollHeight,j=window.getComputedStyle(c),q=parseInt(j.borderTopWidth,10),K=parseInt(j.paddingTop,10),D=parseInt(j.borderBottomWidth,10),P=parseInt(j.paddingBottom,10),E=q+K+U+P+D,B=Math.min(x.offsetHeight*5,E),Y=window.getComputedStyle(g),_=parseInt(Y.paddingTop,10),M=parseInt(Y.paddingBottom,10),G=I.top+I.height/2-mn,J=V-G,se=x.offsetHeight/2,W=x.offsetTop+se,L=q+K+W,X=E-L;if(L<=G){const Z=$.length>0&&x===$[$.length-1].ref.current;a.style.bottom="0px";const z=c.clientHeight-g.offsetTop-g.offsetHeight,ae=Math.max(J,se+(Z?M:0)+z+D),ie=L+ae;a.style.height=ie+"px"}else{const Z=$.length>0&&x===$[0].ref.current;a.style.top="0px";const ae=Math.max(G,q+g.offsetTop+(Z?_:0)+se)+X;a.style.height=ae+"px",g.scrollTop=L-G+g.offsetTop}a.style.margin=`${mn}px 0`,a.style.minHeight=B+"px",a.style.maxHeight=V+"px",r==null||r(),requestAnimationFrame(()=>f.current=!0)}},[m,s.trigger,s.valueNode,a,c,g,x,y,s.dir,r]);Et(()=>S(),[S]);const[k,C]=p.useState();Et(()=>{c&&C(window.getComputedStyle(c).zIndex)},[c]);const T=p.useCallback(I=>{I&&v.current===!0&&(S(),w==null||w(),v.current=!1)},[S,w]);return u.jsx(eE,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:f,onScrollButtonChange:T,children:u.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:k},children:u.jsx(ve.div,{...o,ref:h,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});km.displayName=Zk;var Qk="SelectPopperPosition",Rl=p.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=mn,...s}=e,i=si(n);return u.jsx(ia,{...i,...s,ref:t,align:r,collisionPadding:o,style:{boxSizing:"border-box",...s.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});Rl.displayName=Qk;var[eE,Ml]=$r(dr,{}),Ol="SelectViewport",Em=p.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=Yn(Ol,n),i=Ml(Ol,n),a=Le(t,s.onViewportChange),l=p.useRef(0);return u.jsxs(u.Fragment,{children:[u.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),u.jsx(ri.Slot,{scope:n,children:u.jsx(ve.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:ce(o.onScroll,c=>{const d=c.currentTarget,{contentWrapper:h,shouldExpandOnScrollRef:m}=i;if(m!=null&&m.current&&h){const f=Math.abs(l.current-d.scrollTop);if(f>0){const v=window.innerHeight-mn*2,g=parseFloat(h.style.minHeight),x=parseFloat(h.style.height),y=Math.max(g,x);if(y<v){const w=y+f,S=Math.min(v,w),k=w-S;h.style.height=S+"px",h.style.bottom==="0px"&&(d.scrollTop=k>0?k:0,h.style.justifyContent="flex-end")}}}l.current=d.scrollTop})})})]})});Em.displayName=Ol;var Im="SelectGroup",[tE,nE]=$r(Im),rE=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Rt();return u.jsx(tE,{scope:n,id:o,children:u.jsx(ve.div,{role:"group","aria-labelledby":o,...r,ref:t})})});rE.displayName=Im;var Nm="SelectLabel",Am=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=nE(Nm,n);return u.jsx(ve.div,{id:o.id,...r,ref:t})});Am.displayName=Nm;var ii="SelectItem",[oE,jm]=$r(ii),_m=p.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=Gn(ii,n),l=Yn(ii,n),c=a.value===r,[d,h]=p.useState(s??""),[m,f]=p.useState(!1),v=Le(t,w=>{var S;return(S=l.itemRefCallback)==null?void 0:S.call(l,w,r,o)}),g=Rt(),x=p.useRef("touch"),y=()=>{o||(a.onValueChange(r),a.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return u.jsx(oE,{scope:n,value:r,disabled:o,textId:g,isSelected:c,onItemTextChange:p.useCallback(w=>{h(S=>S||((w==null?void 0:w.textContent)??"").trim())},[]),children:u.jsx(ri.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:u.jsx(ve.div,{role:"option","aria-labelledby":g,"data-highlighted":m?"":void 0,"aria-selected":c&&m,"data-state":c?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...i,ref:v,onFocus:ce(i.onFocus,()=>f(!0)),onBlur:ce(i.onBlur,()=>f(!1)),onClick:ce(i.onClick,()=>{x.current!=="mouse"&&y()}),onPointerUp:ce(i.onPointerUp,()=>{x.current==="mouse"&&y()}),onPointerDown:ce(i.onPointerDown,w=>{x.current=w.pointerType}),onPointerMove:ce(i.onPointerMove,w=>{var S;x.current=w.pointerType,o?(S=l.onItemLeave)==null||S.call(l):x.current==="mouse"&&w.currentTarget.focus({preventScroll:!0})}),onPointerLeave:ce(i.onPointerLeave,w=>{var S;w.currentTarget===document.activeElement&&((S=l.onItemLeave)==null||S.call(l))}),onKeyDown:ce(i.onKeyDown,w=>{var k;((k=l.searchRef)==null?void 0:k.current)!==""&&w.key===" "||(Uk.includes(w.key)&&y(),w.key===" "&&w.preventDefault())})})})})});_m.displayName=ii;var Ao="SelectItemText",Pm=p.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=Gn(Ao,n),a=Yn(Ao,n),l=jm(Ao,n),c=qk(Ao,n),[d,h]=p.useState(null),m=Le(t,y=>h(y),l.onItemTextChange,y=>{var w;return(w=a.itemTextRefCallback)==null?void 0:w.call(a,y,l.value,l.disabled)}),f=d==null?void 0:d.textContent,v=p.useMemo(()=>u.jsx("option",{value:l.value,disabled:l.disabled,children:f},l.value),[l.disabled,l.value,f]),{onNativeOptionAdd:g,onNativeOptionRemove:x}=c;return Et(()=>(g(v),()=>x(v)),[g,x,v]),u.jsxs(u.Fragment,{children:[u.jsx(ve.span,{id:l.textId,...s,ref:m}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?Hr.createPortal(s.children,i.valueNode):null]})});Pm.displayName=Ao;var Rm="SelectItemIndicator",Mm=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return jm(Rm,n).isSelected?u.jsx(ve.span,{"aria-hidden":!0,...r,ref:t}):null});Mm.displayName=Rm;var Dl="SelectScrollUpButton",Om=p.forwardRef((e,t)=>{const n=Yn(Dl,e.__scopeSelect),r=Ml(Dl,e.__scopeSelect),[o,s]=p.useState(!1),i=Le(t,r.onScrollButtonChange);return Et(()=>{if(n.viewport&&n.isPositioned){let a=function(){const c=l.scrollTop>0;s(c)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?u.jsx(Lm,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});Om.displayName=Dl;var Ll="SelectScrollDownButton",Dm=p.forwardRef((e,t)=>{const n=Yn(Ll,e.__scopeSelect),r=Ml(Ll,e.__scopeSelect),[o,s]=p.useState(!1),i=Le(t,r.onScrollButtonChange);return Et(()=>{if(n.viewport&&n.isPositioned){let a=function(){const c=l.scrollHeight-l.clientHeight,d=Math.ceil(l.scrollTop)<c;s(d)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?u.jsx(Lm,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});Dm.displayName=Ll;var Lm=p.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=Yn("SelectScrollButton",n),i=p.useRef(null),a=oi(n),l=p.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return p.useEffect(()=>()=>l(),[l]),Et(()=>{var d;const c=a().find(h=>h.ref.current===document.activeElement);(d=c==null?void 0:c.ref.current)==null||d.scrollIntoView({block:"nearest"})},[a]),u.jsx(ve.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:ce(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:ce(o.onPointerMove,()=>{var c;(c=s.onItemLeave)==null||c.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:ce(o.onPointerLeave,()=>{l()})})}),sE="SelectSeparator",$m=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return u.jsx(ve.div,{"aria-hidden":!0,...r,ref:t})});$m.displayName=sE;var $l="SelectArrow",iE=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=si(n),s=Gn($l,n),i=Yn($l,n);return s.open&&i.position==="popper"?u.jsx(aa,{...o,...r,ref:t}):null});iE.displayName=$l;var aE="SelectBubbleInput",Fm=p.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=p.useRef(null),s=Le(r,o),i=hm(t);return p.useEffect(()=>{const a=o.current;if(!a)return;const l=window.HTMLSelectElement.prototype,d=Object.getOwnPropertyDescriptor(l,"value").set;if(i!==t&&d){const h=new Event("change",{bubbles:!0});d.call(a,t),a.dispatchEvent(h)}},[i,t]),u.jsx(ve.select,{...n,style:{...pm,...n.style},ref:s,defaultValue:t})});Fm.displayName=aE;function Bm(e){return e===""||e===void 0}function zm(e){const t=pt(e),n=p.useRef(""),r=p.useRef(0),o=p.useCallback(i=>{const a=n.current+i;t(a),function l(c){n.current=c,window.clearTimeout(r.current),c!==""&&(r.current=window.setTimeout(()=>l(""),1e3))}(a)},[t]),s=p.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return p.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function Hm(e,t,n){const o=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=lE(e,Math.max(s,0));o.length===1&&(i=i.filter(c=>c!==n));const l=i.find(c=>c.textValue.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function lE(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var cE=mm,Um=xm,uE=bm,dE=wm,fE=ym,Wm=Sm,hE=Em,Vm=Am,Km=_m,pE=Pm,mE=Mm,qm=Om,Gm=Dm,Ym=$m;const gE=cE,xE=uE,Xm=p.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Um,{ref:r,className:re("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...n,children:[t,u.jsx(dE,{asChild:!0,children:u.jsx(ue.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));Xm.displayName=Um.displayName;const Jm=p.forwardRef(({className:e,...t},n)=>u.jsx(qm,{ref:n,className:re("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(ue.ChevronUp,{className:"h-4 w-4"})}));Jm.displayName=qm.displayName;const Zm=p.forwardRef(({className:e,...t},n)=>u.jsx(Gm,{ref:n,className:re("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(ue.ChevronDown,{className:"h-4 w-4"})}));Zm.displayName=Gm.displayName;const Qm=p.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>u.jsx(fE,{children:u.jsxs(Wm,{ref:o,className:re("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...r,children:[u.jsx(Jm,{}),u.jsx(hE,{className:re("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),u.jsx(Zm,{})]})}));Qm.displayName=Wm.displayName;const vE=p.forwardRef(({className:e,...t},n)=>u.jsx(Vm,{ref:n,className:re("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));vE.displayName=Vm.displayName;const eg=p.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Km,{ref:r,className:re("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[u.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:u.jsx(mE,{children:u.jsx(ue.Check,{className:"h-4 w-4"})})}),u.jsx(pE,{children:t})]}));eg.displayName=Km.displayName;const bE=p.forwardRef(({className:e,...t},n)=>u.jsx(Ym,{ref:n,className:re("-mx-1 my-1 h-px bg-muted",e),...t}));bE.displayName=Ym.displayName;var wE="Separator",tg="horizontal",yE=["horizontal","vertical"],ng=p.forwardRef((e,t)=>{const{decorative:n,orientation:r=tg,...o}=e,s=SE(r)?r:tg,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return u.jsx(ve.div,{"data-orientation":s,...a,...o,ref:t})});ng.displayName=wE;function SE(e){return yE.includes(e)}var rg=ng;const og=p.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>u.jsx(rg,{ref:o,decorative:n,orientation:t,className:re("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));og.displayName=rg.displayName;var ai="Switch",[CE,RN]=cn(ai),[TE,kE]=CE(ai),sg=p.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:s,required:i,disabled:a,value:l="on",onCheckedChange:c,form:d,...h}=e,[m,f]=p.useState(null),v=Le(t,S=>f(S)),g=p.useRef(!1),x=m?d||!!m.closest("form"):!0,[y,w]=Dn({prop:o,defaultProp:s??!1,onChange:c,caller:ai});return u.jsxs(TE,{scope:n,checked:y,disabled:a,children:[u.jsx(ve.button,{type:"button",role:"switch","aria-checked":y,"aria-required":i,"data-state":cg(y),"data-disabled":a?"":void 0,disabled:a,value:l,...h,ref:v,onClick:ce(e.onClick,S=>{w(k=>!k),x&&(g.current=S.isPropagationStopped(),g.current||S.stopPropagation())})}),x&&u.jsx(lg,{control:m,bubbles:!g.current,name:r,value:l,checked:y,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});sg.displayName=ai;var ig="SwitchThumb",ag=p.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=kE(ig,n);return u.jsx(ve.span,{"data-state":cg(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});ag.displayName=ig;var EE="SwitchBubbleInput",lg=p.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=p.useRef(null),a=Le(i,s),l=hm(n),c=vd(t);return p.useEffect(()=>{const d=i.current;if(!d)return;const h=window.HTMLInputElement.prototype,f=Object.getOwnPropertyDescriptor(h,"checked").set;if(l!==n&&f){const v=new Event("click",{bubbles:r});f.call(d,n),d.dispatchEvent(v)}},[l,n,r]),u.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:a,style:{...o.style,...c,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});lg.displayName=EE;function cg(e){return e?"checked":"unchecked"}var ug=sg,IE=ag;const dg=p.forwardRef(({className:e,...t},n)=>u.jsx(ug,{className:re("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...t,ref:n,children:u.jsx(IE,{className:re("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));dg.displayName=ug.displayName;const NE=Ja,AE=aT,jE=Za,fg=p.forwardRef(({className:e,...t},n)=>u.jsx(To,{className:re("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t,ref:n}));fg.displayName=To.displayName;const _E=zr.cva("fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500",{variants:{side:{top:"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",right:"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm"}},defaultVariants:{side:"right"}}),hg=p.forwardRef(({side:e="right",className:t,children:n,...r},o)=>u.jsxs(jE,{children:[u.jsx(fg,{}),u.jsxs(ko,{ref:o,className:re(_E({side:e}),t),...r,children:[n,u.jsxs(rp,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary",children:[u.jsx(ue.X,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));hg.displayName=ko.displayName;const pg=({className:e,...t})=>u.jsx("div",{className:re("flex flex-col space-y-2 text-center sm:text-left",e),...t});pg.displayName="SheetHeader";const mg=p.forwardRef(({className:e,...t},n)=>u.jsx(ar,{ref:n,className:re("text-lg font-semibold text-foreground",e),...t}));mg.displayName=ar.displayName;const gg=p.forwardRef(({className:e,...t},n)=>u.jsx(Fs,{ref:n,className:re("text-sm text-muted-foreground",e),...t}));gg.displayName=Fs.displayName;var[li,MN]=cn("Tooltip",[kr]),ci=kr(),xg="TooltipProvider",PE=700,Fl="tooltip.open",[RE,Bl]=li(xg),vg=e=>{const{__scopeTooltip:t,delayDuration:n=PE,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:s}=e,i=p.useRef(!0),a=p.useRef(!1),l=p.useRef(0);return p.useEffect(()=>{const c=l.current;return()=>window.clearTimeout(c)},[]),u.jsx(RE,{scope:t,isOpenDelayedRef:i,delayDuration:n,onOpen:p.useCallback(()=>{window.clearTimeout(l.current),i.current=!1},[]),onClose:p.useCallback(()=>{window.clearTimeout(l.current),l.current=window.setTimeout(()=>i.current=!0,r)},[r]),isPointerInTransitRef:a,onPointerInTransitChange:p.useCallback(c=>{a.current=c},[]),disableHoverableContent:o,children:s})};vg.displayName=xg;var jo="Tooltip",[ME,ui]=li(jo),bg=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o,onOpenChange:s,disableHoverableContent:i,delayDuration:a}=e,l=Bl(jo,e.__scopeTooltip),c=ci(t),[d,h]=p.useState(null),m=Rt(),f=p.useRef(0),v=i??l.disableHoverableContent,g=a??l.delayDuration,x=p.useRef(!1),[y,w]=Dn({prop:r,defaultProp:o??!1,onChange:I=>{I?(l.onOpen(),document.dispatchEvent(new CustomEvent(Fl))):l.onClose(),s==null||s(I)},caller:jo}),S=p.useMemo(()=>y?x.current?"delayed-open":"instant-open":"closed",[y]),k=p.useCallback(()=>{window.clearTimeout(f.current),f.current=0,x.current=!1,w(!0)},[w]),C=p.useCallback(()=>{window.clearTimeout(f.current),f.current=0,w(!1)},[w]),T=p.useCallback(()=>{window.clearTimeout(f.current),f.current=window.setTimeout(()=>{x.current=!0,w(!0),f.current=0},g)},[g,w]);return p.useEffect(()=>()=>{f.current&&(window.clearTimeout(f.current),f.current=0)},[]),u.jsx(oa,{...c,children:u.jsx(ME,{scope:t,contentId:m,open:y,stateAttribute:S,trigger:d,onTriggerChange:h,onTriggerEnter:p.useCallback(()=>{l.isOpenDelayedRef.current?T():k()},[l.isOpenDelayedRef,T,k]),onTriggerLeave:p.useCallback(()=>{v?C():(window.clearTimeout(f.current),f.current=0)},[C,v]),onOpen:k,onClose:C,disableHoverableContent:v,children:n})})};bg.displayName=jo;var zl="TooltipTrigger",wg=p.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=ui(zl,n),s=Bl(zl,n),i=ci(n),a=p.useRef(null),l=Le(t,a,o.onTriggerChange),c=p.useRef(!1),d=p.useRef(!1),h=p.useCallback(()=>c.current=!1,[]);return p.useEffect(()=>()=>document.removeEventListener("pointerup",h),[h]),u.jsx(sa,{asChild:!0,...i,children:u.jsx(ve.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:l,onPointerMove:ce(e.onPointerMove,m=>{m.pointerType!=="touch"&&!d.current&&!s.isPointerInTransitRef.current&&(o.onTriggerEnter(),d.current=!0)}),onPointerLeave:ce(e.onPointerLeave,()=>{o.onTriggerLeave(),d.current=!1}),onPointerDown:ce(e.onPointerDown,()=>{o.open&&o.onClose(),c.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:ce(e.onFocus,()=>{c.current||o.onOpen()}),onBlur:ce(e.onBlur,o.onClose),onClick:ce(e.onClick,o.onClose)})})});wg.displayName=zl;var OE="TooltipPortal",[ON,DE]=li(OE,{forceMount:void 0}),Fr="TooltipContent",yg=p.forwardRef((e,t)=>{const n=DE(Fr,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...s}=e,i=ui(Fr,e.__scopeTooltip);return u.jsx(Wt,{present:r||i.open,children:i.disableHoverableContent?u.jsx(Sg,{side:o,...s,ref:t}):u.jsx(LE,{side:o,...s,ref:t})})}),LE=p.forwardRef((e,t)=>{const n=ui(Fr,e.__scopeTooltip),r=Bl(Fr,e.__scopeTooltip),o=p.useRef(null),s=Le(t,o),[i,a]=p.useState(null),{trigger:l,onClose:c}=n,d=o.current,{onPointerInTransitChange:h}=r,m=p.useCallback(()=>{a(null),h(!1)},[h]),f=p.useCallback((v,g)=>{const x=v.currentTarget,y={x:v.clientX,y:v.clientY},w=HE(y,x.getBoundingClientRect()),S=UE(y,w),k=WE(g.getBoundingClientRect()),C=KE([...S,...k]);a(C),h(!0)},[h]);return p.useEffect(()=>()=>m(),[m]),p.useEffect(()=>{if(l&&d){const v=x=>f(x,d),g=x=>f(x,l);return l.addEventListener("pointerleave",v),d.addEventListener("pointerleave",g),()=>{l.removeEventListener("pointerleave",v),d.removeEventListener("pointerleave",g)}}},[l,d,f,m]),p.useEffect(()=>{if(i){const v=g=>{const x=g.target,y={x:g.clientX,y:g.clientY},w=(l==null?void 0:l.contains(x))||(d==null?void 0:d.contains(x)),S=!VE(y,i);w?m():S&&(m(),c())};return document.addEventListener("pointermove",v),()=>document.removeEventListener("pointermove",v)}},[l,d,i,c,m]),u.jsx(Sg,{...e,ref:s})}),[$E,FE]=li(jo,{isInside:!1}),BE=Yt.createSlottable("TooltipContent"),Sg=p.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:s,onPointerDownOutside:i,...a}=e,l=ui(Fr,n),c=ci(n),{onClose:d}=l;return p.useEffect(()=>(document.addEventListener(Fl,d),()=>document.removeEventListener(Fl,d)),[d]),p.useEffect(()=>{if(l.trigger){const h=m=>{const f=m.target;f!=null&&f.contains(l.trigger)&&d()};return window.addEventListener("scroll",h,{capture:!0}),()=>window.removeEventListener("scroll",h,{capture:!0})}},[l.trigger,d]),u.jsx(wr,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:h=>h.preventDefault(),onDismiss:d,children:u.jsxs(ia,{"data-state":l.stateAttribute,...c,...a,ref:t,style:{...a.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[u.jsx(BE,{children:r}),u.jsx($E,{scope:n,isInside:!0,children:u.jsx(zk,{id:l.contentId,role:"tooltip",children:o||r})})]})})});yg.displayName=Fr;var Cg="TooltipArrow",zE=p.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=ci(n);return FE(Cg,n).isInside?null:u.jsx(aa,{...o,...r,ref:t})});zE.displayName=Cg;function HE(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),o=Math.abs(t.right-e.x),s=Math.abs(t.left-e.x);switch(Math.min(n,r,o,s)){case s:return"left";case o:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function UE(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function WE(e){const{top:t,right:n,bottom:r,left:o}=e;return[{x:o,y:t},{x:n,y:t},{x:n,y:r},{x:o,y:r}]}function VE(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,i=t.length-1;s<t.length;i=s++){const a=t[s],l=t[i],c=a.x,d=a.y,h=l.x,m=l.y;d>r!=m>r&&n<(h-c)*(r-d)/(m-d)+c&&(o=!o)}return o}function KE(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),qE(t)}function qE(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const o=e[r];for(;t.length>=2;){const s=t[t.length-1],i=t[t.length-2];if((s.x-i.x)*(o.y-i.y)>=(s.y-i.y)*(o.x-i.x))t.pop();else break}t.push(o)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const o=e[r];for(;n.length>=2;){const s=n[n.length-1],i=n[n.length-2];if((s.x-i.x)*(o.y-i.y)>=(s.y-i.y)*(o.x-i.x))n.pop();else break}n.push(o)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var GE=vg,YE=bg,XE=wg,Tg=yg;const JE=GE,ZE=YE,QE=XE,kg=p.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(Tg,{ref:r,sideOffset:t,className:re("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n}));kg.displayName=Tg.displayName;var Hl="ToastProvider",[Ul,eI,tI]=Yo("Toast"),[Eg,DN]=cn("Toast",[tI]),[nI,di]=Eg(Hl),Ig=e=>{const{__scopeToast:t,label:n="Notification",duration:r=5e3,swipeDirection:o="right",swipeThreshold:s=50,children:i}=e,[a,l]=p.useState(null),[c,d]=p.useState(0),h=p.useRef(!1),m=p.useRef(!1);return n.trim()||console.error(`Invalid prop \`label\` supplied to \`${Hl}\`. Expected non-empty \`string\`.`),u.jsx(Ul.Provider,{scope:t,children:u.jsx(nI,{scope:t,label:n,duration:r,swipeDirection:o,swipeThreshold:s,toastCount:c,viewport:a,onViewportChange:l,onToastAdd:p.useCallback(()=>d(f=>f+1),[]),onToastRemove:p.useCallback(()=>d(f=>f-1),[]),isFocusedToastEscapeKeyDownRef:h,isClosePausedRef:m,children:i})})};Ig.displayName=Hl;var Ng="ToastViewport",rI=["F8"],Wl="toast.viewportPause",Vl="toast.viewportResume",Ag=p.forwardRef((e,t)=>{const{__scopeToast:n,hotkey:r=rI,label:o="Notifications ({hotkey})",...s}=e,i=di(Ng,n),a=eI(n),l=p.useRef(null),c=p.useRef(null),d=p.useRef(null),h=p.useRef(null),m=Le(t,h,i.onViewportChange),f=r.join("+").replace(/Key/g,"").replace(/Digit/g,""),v=i.toastCount>0;p.useEffect(()=>{const x=y=>{var S;r.length!==0&&r.every(k=>y[k]||y.code===k)&&((S=h.current)==null||S.focus())};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[r]),p.useEffect(()=>{const x=l.current,y=h.current;if(v&&x&&y){const w=()=>{if(!i.isClosePausedRef.current){const T=new CustomEvent(Wl);y.dispatchEvent(T),i.isClosePausedRef.current=!0}},S=()=>{if(i.isClosePausedRef.current){const T=new CustomEvent(Vl);y.dispatchEvent(T),i.isClosePausedRef.current=!1}},k=T=>{!x.contains(T.relatedTarget)&&S()},C=()=>{x.contains(document.activeElement)||S()};return x.addEventListener("focusin",w),x.addEventListener("focusout",k),x.addEventListener("pointermove",w),x.addEventListener("pointerleave",C),window.addEventListener("blur",w),window.addEventListener("focus",S),()=>{x.removeEventListener("focusin",w),x.removeEventListener("focusout",k),x.removeEventListener("pointermove",w),x.removeEventListener("pointerleave",C),window.removeEventListener("blur",w),window.removeEventListener("focus",S)}}},[v,i.isClosePausedRef]);const g=p.useCallback(({tabbingDirection:x})=>{const w=a().map(S=>{const k=S.ref.current,C=[k,...gI(k)];return x==="forwards"?C:C.reverse()});return(x==="forwards"?w.reverse():w).flat()},[a]);return p.useEffect(()=>{const x=h.current;if(x){const y=w=>{var C,T,I;const S=w.altKey||w.ctrlKey||w.metaKey;if(w.key==="Tab"&&!S){const N=document.activeElement,R=w.shiftKey;if(w.target===x&&R){(C=c.current)==null||C.focus();return}const V=g({tabbingDirection:R?"backwards":"forwards"}),U=V.findIndex(j=>j===N);Gl(V.slice(U+1))?w.preventDefault():R?(T=c.current)==null||T.focus():(I=d.current)==null||I.focus()}};return x.addEventListener("keydown",y),()=>x.removeEventListener("keydown",y)}},[a,g]),u.jsxs(Db,{ref:l,role:"region","aria-label":o.replace("{hotkey}",f),tabIndex:-1,style:{pointerEvents:v?void 0:"none"},children:[v&&u.jsx(Kl,{ref:c,onFocusFromOutsideViewport:()=>{const x=g({tabbingDirection:"forwards"});Gl(x)}}),u.jsx(Ul.Slot,{scope:n,children:u.jsx(ve.ol,{tabIndex:-1,...s,ref:m})}),v&&u.jsx(Kl,{ref:d,onFocusFromOutsideViewport:()=>{const x=g({tabbingDirection:"backwards"});Gl(x)}})]})});Ag.displayName=Ng;var jg="ToastFocusProxy",Kl=p.forwardRef((e,t)=>{const{__scopeToast:n,onFocusFromOutsideViewport:r,...o}=e,s=di(jg,n);return u.jsx(ni,{tabIndex:0,...o,ref:t,style:{position:"fixed"},onFocus:i=>{var c;const a=i.relatedTarget;!((c=s.viewport)!=null&&c.contains(a))&&r()}})});Kl.displayName=jg;var _o="Toast",oI="toast.swipeStart",sI="toast.swipeMove",iI="toast.swipeCancel",aI="toast.swipeEnd",_g=p.forwardRef((e,t)=>{const{forceMount:n,open:r,defaultOpen:o,onOpenChange:s,...i}=e,[a,l]=Dn({prop:r,defaultProp:o??!0,onChange:s,caller:_o});return u.jsx(Wt,{present:n||a,children:u.jsx(uI,{open:a,...i,ref:t,onClose:()=>l(!1),onPause:pt(e.onPause),onResume:pt(e.onResume),onSwipeStart:ce(e.onSwipeStart,c=>{c.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:ce(e.onSwipeMove,c=>{const{x:d,y:h}=c.detail.delta;c.currentTarget.setAttribute("data-swipe","move"),c.currentTarget.style.setProperty("--radix-toast-swipe-move-x",`${d}px`),c.currentTarget.style.setProperty("--radix-toast-swipe-move-y",`${h}px`)}),onSwipeCancel:ce(e.onSwipeCancel,c=>{c.currentTarget.setAttribute("data-swipe","cancel"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),c.currentTarget.style.removeProperty("--radix-toast-swipe-end-x"),c.currentTarget.style.removeProperty("--radix-toast-swipe-end-y")}),onSwipeEnd:ce(e.onSwipeEnd,c=>{const{x:d,y:h}=c.detail.delta;c.currentTarget.setAttribute("data-swipe","end"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),c.currentTarget.style.setProperty("--radix-toast-swipe-end-x",`${d}px`),c.currentTarget.style.setProperty("--radix-toast-swipe-end-y",`${h}px`),l(!1)})})})});_g.displayName=_o;var[lI,cI]=Eg(_o,{onClose(){}}),uI=p.forwardRef((e,t)=>{const{__scopeToast:n,type:r="foreground",duration:o,open:s,onClose:i,onEscapeKeyDown:a,onPause:l,onResume:c,onSwipeStart:d,onSwipeMove:h,onSwipeCancel:m,onSwipeEnd:f,...v}=e,g=di(_o,n),[x,y]=p.useState(null),w=Le(t,j=>y(j)),S=p.useRef(null),k=p.useRef(null),C=o||g.duration,T=p.useRef(0),I=p.useRef(C),N=p.useRef(0),{onToastAdd:R,onToastRemove:O}=g,$=pt(()=>{var q;(x==null?void 0:x.contains(document.activeElement))&&((q=g.viewport)==null||q.focus()),i()}),V=p.useCallback(j=>{!j||j===1/0||(window.clearTimeout(N.current),T.current=new Date().getTime(),N.current=window.setTimeout($,j))},[$]);p.useEffect(()=>{const j=g.viewport;if(j){const q=()=>{V(I.current),c==null||c()},K=()=>{const D=new Date().getTime()-T.current;I.current=I.current-D,window.clearTimeout(N.current),l==null||l()};return j.addEventListener(Wl,K),j.addEventListener(Vl,q),()=>{j.removeEventListener(Wl,K),j.removeEventListener(Vl,q)}}},[g.viewport,C,l,c,V]),p.useEffect(()=>{s&&!g.isClosePausedRef.current&&V(C)},[s,C,g.isClosePausedRef,V]),p.useEffect(()=>(R(),()=>O()),[R,O]);const U=p.useMemo(()=>x?$g(x):null,[x]);return g.viewport?u.jsxs(u.Fragment,{children:[U&&u.jsx(dI,{__scopeToast:n,role:"status","aria-live":r==="foreground"?"assertive":"polite",children:U}),u.jsx(lI,{scope:n,onClose:$,children:Hr.createPortal(u.jsx(Ul.ItemSlot,{scope:n,children:u.jsx(Ob,{asChild:!0,onEscapeKeyDown:ce(a,()=>{g.isFocusedToastEscapeKeyDownRef.current||$(),g.isFocusedToastEscapeKeyDownRef.current=!1}),children:u.jsx(ve.li,{tabIndex:0,"data-state":s?"open":"closed","data-swipe-direction":g.swipeDirection,...v,ref:w,style:{userSelect:"none",touchAction:"none",...e.style},onKeyDown:ce(e.onKeyDown,j=>{j.key==="Escape"&&(a==null||a(j.nativeEvent),j.nativeEvent.defaultPrevented||(g.isFocusedToastEscapeKeyDownRef.current=!0,$()))}),onPointerDown:ce(e.onPointerDown,j=>{j.button===0&&(S.current={x:j.clientX,y:j.clientY})}),onPointerMove:ce(e.onPointerMove,j=>{if(!S.current)return;const q=j.clientX-S.current.x,K=j.clientY-S.current.y,D=!!k.current,P=["left","right"].includes(g.swipeDirection),E=["left","up"].includes(g.swipeDirection)?Math.min:Math.max,B=P?E(0,q):0,Y=P?0:E(0,K),_=j.pointerType==="touch"?10:2,M={x:B,y:Y},G={originalEvent:j,delta:M};D?(k.current=M,fi(sI,h,G,{discrete:!1})):Fg(M,g.swipeDirection,_)?(k.current=M,fi(oI,d,G,{discrete:!1}),j.target.setPointerCapture(j.pointerId)):(Math.abs(q)>_||Math.abs(K)>_)&&(S.current=null)}),onPointerUp:ce(e.onPointerUp,j=>{const q=k.current,K=j.target;if(K.hasPointerCapture(j.pointerId)&&K.releasePointerCapture(j.pointerId),k.current=null,S.current=null,q){const D=j.currentTarget,P={originalEvent:j,delta:q};Fg(q,g.swipeDirection,g.swipeThreshold)?fi(aI,f,P,{discrete:!0}):fi(iI,m,P,{discrete:!0}),D.addEventListener("click",E=>E.preventDefault(),{once:!0})}})})})}),g.viewport)})]}):null}),dI=e=>{const{__scopeToast:t,children:n,...r}=e,o=di(_o,t),[s,i]=p.useState(!1),[a,l]=p.useState(!1);return pI(()=>i(!0)),p.useEffect(()=>{const c=window.setTimeout(()=>l(!0),1e3);return()=>window.clearTimeout(c)},[]),a?null:u.jsx(so,{asChild:!0,children:u.jsx(ni,{...r,children:s&&u.jsxs(u.Fragment,{children:[o.label," ",n]})})})},fI="ToastTitle",Pg=p.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(ve.div,{...r,ref:t})});Pg.displayName=fI;var hI="ToastDescription",Rg=p.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(ve.div,{...r,ref:t})});Rg.displayName=hI;var Mg="ToastAction",Og=p.forwardRef((e,t)=>{const{altText:n,...r}=e;return n.trim()?u.jsx(Lg,{altText:n,asChild:!0,children:u.jsx(ql,{...r,ref:t})}):(console.error(`Invalid prop \`altText\` supplied to \`${Mg}\`. Expected non-empty \`string\`.`),null)});Og.displayName=Mg;var Dg="ToastClose",ql=p.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e,o=cI(Dg,n);return u.jsx(Lg,{asChild:!0,children:u.jsx(ve.button,{type:"button",...r,ref:t,onClick:ce(e.onClick,o.onClose)})})});ql.displayName=Dg;var Lg=p.forwardRef((e,t)=>{const{__scopeToast:n,altText:r,...o}=e;return u.jsx(ve.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":r||void 0,...o,ref:t})});function $g(e){const t=[];return Array.from(e.childNodes).forEach(r=>{if(r.nodeType===r.TEXT_NODE&&r.textContent&&t.push(r.textContent),mI(r)){const o=r.ariaHidden||r.hidden||r.style.display==="none",s=r.dataset.radixToastAnnounceExclude==="";if(!o)if(s){const i=r.dataset.radixToastAnnounceAlt;i&&t.push(i)}else t.push(...$g(r))}}),t}function fi(e,t,n,{discrete:r}){const o=n.originalEvent.currentTarget,s=new CustomEvent(e,{bubbles:!0,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?Fi(o,s):o.dispatchEvent(s)}var Fg=(e,t,n=0)=>{const r=Math.abs(e.x),o=Math.abs(e.y),s=r>o;return t==="left"||t==="right"?s&&r>n:!s&&o>n};function pI(e=()=>{}){const t=pt(e);Et(()=>{let n=0,r=0;return n=window.requestAnimationFrame(()=>r=window.requestAnimationFrame(t)),()=>{window.cancelAnimationFrame(n),window.cancelAnimationFrame(r)}},[t])}function mI(e){return e.nodeType===e.ELEMENT_NODE}function gI(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function Gl(e){const t=document.activeElement;return e.some(n=>n===t?!0:(n.focus(),document.activeElement!==t))}var xI=Ig,Bg=Ag,zg=_g,Hg=Pg,Ug=Rg,Wg=Og,Vg=ql;const vI=xI,Kg=p.forwardRef(({className:e,...t},n)=>u.jsx(Bg,{ref:n,className:re("fixed bottom-0 right-0 z-[100] flex max-h-screen w-full flex-col p-4 md:max-w-[420px]",e),...t}));Kg.displayName=Bg.displayName;const bI=zr.cva("group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md border p-6 pr-8 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",{variants:{variant:{default:"border bg-background text-foreground",destructive:"destructive group border-destructive bg-destructive text-destructive-foreground"}},defaultVariants:{variant:"default"}}),qg=p.forwardRef(({className:e,variant:t,...n},r)=>u.jsx(zg,{ref:r,className:re(bI({variant:t}),e),...n}));qg.displayName=zg.displayName;const wI=p.forwardRef(({className:e,...t},n)=>u.jsx(Wg,{ref:n,className:re("inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors hover:bg-secondary focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive",e),...t}));wI.displayName=Wg.displayName;const Gg=p.forwardRef(({className:e,...t},n)=>u.jsx(Vg,{ref:n,className:re("absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-2 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",e),"toast-close":"",...t,children:u.jsx(ue.X,{className:"h-4 w-4"})}));Gg.displayName=Vg.displayName;const Yg=p.forwardRef(({className:e,...t},n)=>u.jsx(Hg,{ref:n,className:re("text-sm font-semibold",e),...t}));Yg.displayName=Hg.displayName;const Xg=p.forwardRef(({className:e,...t},n)=>u.jsx(Ug,{ref:n,className:re("text-sm opacity-90",e),...t}));Xg.displayName=Ug.displayName;function yI(){const{toasts:e}=nl();return u.jsxs(vI,{children:[e.map(function({id:t,title:n,description:r,action:o,...s}){return u.jsxs(qg,{...s,children:[u.jsxs("div",{className:"grid gap-1",children:[n&&u.jsx(Yg,{children:n}),r&&u.jsx(Xg,{children:r})]}),o,u.jsx(Gg,{})]},t)}),u.jsx(Kg,{})]})}var SI=(e,t,n,r,o,s,i,a)=>{let l=document.documentElement,c=["light","dark"];function d(f){(Array.isArray(e)?e:[e]).forEach(v=>{let g=v==="class",x=g&&s?o.map(y=>s[y]||y):o;g?(l.classList.remove(...x),l.classList.add(s&&s[f]?s[f]:f)):l.setAttribute(v,f)}),h(f)}function h(f){a&&c.includes(f)&&(l.style.colorScheme=f)}function m(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}if(r)d(r);else try{let f=localStorage.getItem(t)||n,v=i&&f==="system"?m():f;d(v)}catch{}},CI=p.createContext(void 0),TI={setTheme:e=>{},themes:[]},kI=()=>{var e;return(e=p.useContext(CI))!=null?e:TI};p.memo(({forcedTheme:e,storageKey:t,attribute:n,enableSystem:r,enableColorScheme:o,defaultTheme:s,value:i,themes:a,nonce:l,scriptProps:c})=>{let d=JSON.stringify([n,t,s,e,a,i,r,o]).slice(1,-1);return p.createElement("script",{...c,suppressHydrationWarning:!0,nonce:typeof window>"u"?l:"",dangerouslySetInnerHTML:{__html:`(${SI.toString()})(${d})`}})});var EI=e=>{switch(e){case"success":return AI;case"info":return _I;case"warning":return jI;case"error":return PI;default:return null}},II=Array(12).fill(0),NI=({visible:e,className:t})=>b.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},b.createElement("div",{className:"sonner-spinner"},II.map((n,r)=>b.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),AI=b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},b.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),jI=b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},b.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),_I=b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},b.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),PI=b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},b.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),RI=b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},b.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),b.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),MI=()=>{let[e,t]=b.useState(document.hidden);return b.useEffect(()=>{let n=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",n),()=>window.removeEventListener("visibilitychange",n)},[]),e},Yl=1,OI=class{constructor(){this.subscribe=e=>(this.subscribers.push(e),()=>{let t=this.subscribers.indexOf(e);this.subscribers.splice(t,1)}),this.publish=e=>{this.subscribers.forEach(t=>t(e))},this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e]},this.create=e=>{var t;let{message:n,...r}=e,o=typeof(e==null?void 0:e.id)=="number"||((t=e.id)==null?void 0:t.length)>0?e.id:Yl++,s=this.toasts.find(a=>a.id===o),i=e.dismissible===void 0?!0:e.dismissible;return this.dismissedToasts.has(o)&&this.dismissedToasts.delete(o),s?this.toasts=this.toasts.map(a=>a.id===o?(this.publish({...a,...e,id:o,title:n}),{...a,...e,id:o,dismissible:i,title:n}):a):this.addToast({title:n,...r,dismissible:i,id:o}),o},this.dismiss=e=>(this.dismissedToasts.add(e),e||this.toasts.forEach(t=>{this.subscribers.forEach(n=>n({id:t.id,dismiss:!0}))}),this.subscribers.forEach(t=>t({id:e,dismiss:!0})),e),this.message=(e,t)=>this.create({...t,message:e}),this.error=(e,t)=>this.create({...t,message:e,type:"error"}),this.success=(e,t)=>this.create({...t,type:"success",message:e}),this.info=(e,t)=>this.create({...t,type:"info",message:e}),this.warning=(e,t)=>this.create({...t,type:"warning",message:e}),this.loading=(e,t)=>this.create({...t,type:"loading",message:e}),this.promise=(e,t)=>{if(!t)return;let n;t.loading!==void 0&&(n=this.create({...t,promise:e,type:"loading",message:t.loading,description:typeof t.description!="function"?t.description:void 0}));let r=e instanceof Promise?e:e(),o=n!==void 0,s,i=r.then(async l=>{if(s=["resolve",l],b.isValidElement(l))o=!1,this.create({id:n,type:"default",message:l});else if(LI(l)&&!l.ok){o=!1;let c=typeof t.error=="function"?await t.error(`HTTP error! status: ${l.status}`):t.error,d=typeof t.description=="function"?await t.description(`HTTP error! status: ${l.status}`):t.description;this.create({id:n,type:"error",message:c,description:d})}else if(t.success!==void 0){o=!1;let c=typeof t.success=="function"?await t.success(l):t.success,d=typeof t.description=="function"?await t.description(l):t.description;this.create({id:n,type:"success",message:c,description:d})}}).catch(async l=>{if(s=["reject",l],t.error!==void 0){o=!1;let c=typeof t.error=="function"?await t.error(l):t.error,d=typeof t.description=="function"?await t.description(l):t.description;this.create({id:n,type:"error",message:c,description:d})}}).finally(()=>{var l;o&&(this.dismiss(n),n=void 0),(l=t.finally)==null||l.call(t)}),a=()=>new Promise((l,c)=>i.then(()=>s[0]==="reject"?c(s[1]):l(s[1])).catch(c));return typeof n!="string"&&typeof n!="number"?{unwrap:a}:Object.assign(n,{unwrap:a})},this.custom=(e,t)=>{let n=(t==null?void 0:t.id)||Yl++;return this.create({jsx:e(n),id:n,...t}),n},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},qt=new OI,DI=(e,t)=>{let n=(t==null?void 0:t.id)||Yl++;return qt.addToast({title:e,...t,id:n}),n},LI=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",$I=DI,FI=()=>qt.toasts,BI=()=>qt.getActiveToasts();Object.assign($I,{success:qt.success,info:qt.info,warning:qt.warning,error:qt.error,custom:qt.custom,message:qt.message,promise:qt.promise,dismiss:qt.dismiss,loading:qt.loading},{getHistory:FI,getToasts:BI});function zI(e,{insertAt:t}={}){if(typeof document>"u")return;let n=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css",t==="top"&&n.firstChild?n.insertBefore(r,n.firstChild):n.appendChild(r),r.styleSheet?r.styleSheet.cssText=e:r.appendChild(document.createTextNode(e))}zI(`:where(html[dir="ltr"]),:where([data-sonner-toaster][dir="ltr"]){--toast-icon-margin-start: -3px;--toast-icon-margin-end: 4px;--toast-svg-margin-start: -1px;--toast-svg-margin-end: 0px;--toast-button-margin-start: auto;--toast-button-margin-end: 0;--toast-close-button-start: 0;--toast-close-button-end: unset;--toast-close-button-transform: translate(-35%, -35%)}:where(html[dir="rtl"]),:where([data-sonner-toaster][dir="rtl"]){--toast-icon-margin-start: 4px;--toast-icon-margin-end: -3px;--toast-svg-margin-start: 0px;--toast-svg-margin-end: -1px;--toast-button-margin-start: 0;--toast-button-margin-end: auto;--toast-close-button-start: unset;--toast-close-button-end: 0;--toast-close-button-transform: translate(35%, -35%)}:where([data-sonner-toaster]){position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1: hsl(0, 0%, 99%);--gray2: hsl(0, 0%, 97.3%);--gray3: hsl(0, 0%, 95.1%);--gray4: hsl(0, 0%, 93%);--gray5: hsl(0, 0%, 90.9%);--gray6: hsl(0, 0%, 88.7%);--gray7: hsl(0, 0%, 85.8%);--gray8: hsl(0, 0%, 78%);--gray9: hsl(0, 0%, 56.1%);--gray10: hsl(0, 0%, 52.3%);--gray11: hsl(0, 0%, 43.5%);--gray12: hsl(0, 0%, 9%);--border-radius: 8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:none;z-index:999999999;transition:transform .4s ease}:where([data-sonner-toaster][data-lifted="true"]){transform:translateY(-10px)}@media (hover: none) and (pointer: coarse){:where([data-sonner-toaster][data-lifted="true"]){transform:none}}:where([data-sonner-toaster][data-x-position="right"]){right:var(--offset-right)}:where([data-sonner-toaster][data-x-position="left"]){left:var(--offset-left)}:where([data-sonner-toaster][data-x-position="center"]){left:50%;transform:translate(-50%)}:where([data-sonner-toaster][data-y-position="top"]){top:var(--offset-top)}:where([data-sonner-toaster][data-y-position="bottom"]){bottom:var(--offset-bottom)}:where([data-sonner-toast]){--y: translateY(100%);--lift-amount: calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);filter:blur(0);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:none;overflow-wrap:anywhere}:where([data-sonner-toast][data-styled="true"]){padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px #0000001a;width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}:where([data-sonner-toast]:focus-visible){box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast][data-y-position="top"]){top:0;--y: translateY(-100%);--lift: 1;--lift-amount: calc(1 * var(--gap))}:where([data-sonner-toast][data-y-position="bottom"]){bottom:0;--y: translateY(100%);--lift: -1;--lift-amount: calc(var(--lift) * var(--gap))}:where([data-sonner-toast]) :where([data-description]){font-weight:400;line-height:1.4;color:inherit}:where([data-sonner-toast]) :where([data-title]){font-weight:500;line-height:1.5;color:inherit}:where([data-sonner-toast]) :where([data-icon]){display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}:where([data-sonner-toast][data-promise="true"]) :where([data-icon])>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}:where([data-sonner-toast]) :where([data-icon])>*{flex-shrink:0}:where([data-sonner-toast]) :where([data-icon]) svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}:where([data-sonner-toast]) :where([data-content]){display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;cursor:pointer;outline:none;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}:where([data-sonner-toast]) :where([data-button]):focus-visible{box-shadow:0 0 0 2px #0006}:where([data-sonner-toast]) :where([data-button]):first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}:where([data-sonner-toast]) :where([data-cancel]){color:var(--normal-text);background:rgba(0,0,0,.08)}:where([data-sonner-toast][data-theme="dark"]) :where([data-cancel]){background:rgba(255,255,255,.3)}:where([data-sonner-toast]) :where([data-close-button]){position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast] [data-close-button]{background:var(--gray1)}:where([data-sonner-toast]) :where([data-close-button]):focus-visible{box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast]) :where([data-disabled="true"]){cursor:not-allowed}:where([data-sonner-toast]):hover :where([data-close-button]):hover{background:var(--gray2);border-color:var(--gray5)}:where([data-sonner-toast][data-swiping="true"]):before{content:"";position:absolute;left:-50%;right:-50%;height:100%;z-index:-1}:where([data-sonner-toast][data-y-position="top"][data-swiping="true"]):before{bottom:50%;transform:scaleY(3) translateY(50%)}:where([data-sonner-toast][data-y-position="bottom"][data-swiping="true"]):before{top:50%;transform:scaleY(3) translateY(-50%)}:where([data-sonner-toast][data-swiping="false"][data-removed="true"]):before{content:"";position:absolute;inset:0;transform:scaleY(2)}:where([data-sonner-toast]):after{content:"";position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}:where([data-sonner-toast][data-mounted="true"]){--y: translateY(0);opacity:1}:where([data-sonner-toast][data-expanded="false"][data-front="false"]){--scale: var(--toasts-before) * .05 + 1;--y: translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}:where([data-sonner-toast])>*{transition:opacity .4s}:where([data-sonner-toast][data-expanded="false"][data-front="false"][data-styled="true"])>*{opacity:0}:where([data-sonner-toast][data-visible="false"]){opacity:0;pointer-events:none}:where([data-sonner-toast][data-mounted="true"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}:where([data-sonner-toast][data-removed="true"][data-front="true"][data-swipe-out="false"]){--y: translateY(calc(var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="false"]){--y: translateY(40%);opacity:0;transition:transform .5s,opacity .2s}:where([data-sonner-toast][data-removed="true"][data-front="false"]):before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y, 0px)) translate(var(--swipe-amount-x, 0px));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width: 600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-theme=light]{--normal-bg: #fff;--normal-border: var(--gray4);--normal-text: var(--gray12);--success-bg: hsl(143, 85%, 96%);--success-border: hsl(145, 92%, 91%);--success-text: hsl(140, 100%, 27%);--info-bg: hsl(208, 100%, 97%);--info-border: hsl(221, 91%, 91%);--info-text: hsl(210, 92%, 45%);--warning-bg: hsl(49, 100%, 97%);--warning-border: hsl(49, 91%, 91%);--warning-text: hsl(31, 92%, 45%);--error-bg: hsl(359, 100%, 97%);--error-border: hsl(359, 100%, 94%);--error-text: hsl(360, 100%, 45%)}[data-sonner-toaster][data-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg: #000;--normal-border: hsl(0, 0%, 20%);--normal-text: var(--gray1)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg: #fff;--normal-border: var(--gray3);--normal-text: var(--gray12)}[data-sonner-toaster][data-theme=dark]{--normal-bg: #000;--normal-bg-hover: hsl(0, 0%, 12%);--normal-border: hsl(0, 0%, 20%);--normal-border-hover: hsl(0, 0%, 25%);--normal-text: var(--gray1);--success-bg: hsl(150, 100%, 6%);--success-border: hsl(147, 100%, 12%);--success-text: hsl(150, 86%, 65%);--info-bg: hsl(215, 100%, 6%);--info-border: hsl(223, 100%, 12%);--info-text: hsl(216, 87%, 65%);--warning-bg: hsl(64, 100%, 6%);--warning-border: hsl(60, 100%, 12%);--warning-text: hsl(46, 87%, 65%);--error-bg: hsl(358, 76%, 10%);--error-border: hsl(357, 89%, 16%);--error-text: hsl(358, 100%, 81%)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success],[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info],[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning],[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error],[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size: 16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:nth-child(1){animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}to{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}to{opacity:.15}}@media (prefers-reduced-motion){[data-sonner-toast],[data-sonner-toast]>*,.sonner-loading-bar{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}
|
|
130
130
|
`);function hi(e){return e.label!==void 0}var HI=3,UI="32px",WI="16px",Jg=4e3,VI=356,KI=14,qI=20,GI=200;function gn(...e){return e.filter(Boolean).join(" ")}function YI(e){let[t,n]=e.split("-"),r=[];return t&&r.push(t),n&&r.push(n),r}var XI=e=>{var t,n,r,o,s,i,a,l,c,d,h;let{invert:m,toast:f,unstyled:v,interacting:g,setHeights:x,visibleToasts:y,heights:w,index:S,toasts:k,expanded:C,removeToast:T,defaultRichColors:I,closeButton:N,style:R,cancelButtonStyle:O,actionButtonStyle:$,className:V="",descriptionClassName:U="",duration:j,position:q,gap:K,loadingIcon:D,expandByDefault:P,classNames:E,icons:B,closeButtonAriaLabel:Y="Close toast",pauseWhenPageIsHidden:_}=e,[M,G]=b.useState(null),[J,se]=b.useState(null),[W,L]=b.useState(!1),[X,ee]=b.useState(!1),[Z,z]=b.useState(!1),[ae,ie]=b.useState(!1),[ge,we]=b.useState(!1),[Ae,Pe]=b.useState(0),[ke,st]=b.useState(0),bt=b.useRef(f.duration||j||Jg),It=b.useRef(null),We=b.useRef(null),ze=S===0,Ke=S+1<=y,Fe=f.type,Ue=f.dismissible!==!1,ut=f.className||"",jt=f.descriptionClassName||"",it=b.useMemo(()=>w.findIndex(xe=>xe.toastId===f.id)||0,[w,f.id]),_t=b.useMemo(()=>{var xe;return(xe=f.closeButton)!=null?xe:N},[f.closeButton,N]),yt=b.useMemo(()=>f.duration||j||Jg,[f.duration,j]),gt=b.useRef(0),Nt=b.useRef(0),St=b.useRef(0),Ct=b.useRef(null),[zt,xt]=q.split("-"),Oe=b.useMemo(()=>w.reduce((xe,Be,Ge)=>Ge>=it?xe:xe+Be.height,0),[w,it]),Ve=MI(),Te=f.invert||m,Q=Fe==="loading";Nt.current=b.useMemo(()=>it*K+Oe,[it,Oe]),b.useEffect(()=>{bt.current=yt},[yt]),b.useEffect(()=>{L(!0)},[]),b.useEffect(()=>{let xe=We.current;if(xe){let Be=xe.getBoundingClientRect().height;return st(Be),x(Ge=>[{toastId:f.id,height:Be,position:f.position},...Ge]),()=>x(Ge=>Ge.filter(Tt=>Tt.toastId!==f.id))}},[x,f.id]),b.useLayoutEffect(()=>{if(!W)return;let xe=We.current,Be=xe.style.height;xe.style.height="auto";let Ge=xe.getBoundingClientRect().height;xe.style.height=Be,st(Ge),x(Tt=>Tt.find(kt=>kt.toastId===f.id)?Tt.map(kt=>kt.toastId===f.id?{...kt,height:Ge}:kt):[{toastId:f.id,height:Ge,position:f.position},...Tt])},[W,f.title,f.description,x,f.id]);let me=b.useCallback(()=>{ee(!0),Pe(Nt.current),x(xe=>xe.filter(Be=>Be.toastId!==f.id)),setTimeout(()=>{T(f)},GI)},[f,T,x,Nt]);b.useEffect(()=>{if(f.promise&&Fe==="loading"||f.duration===1/0||f.type==="loading")return;let xe;return C||g||_&&Ve?(()=>{if(St.current<gt.current){let Be=new Date().getTime()-gt.current;bt.current=bt.current-Be}St.current=new Date().getTime()})():bt.current!==1/0&&(gt.current=new Date().getTime(),xe=setTimeout(()=>{var Be;(Be=f.onAutoClose)==null||Be.call(f,f),me()},bt.current)),()=>clearTimeout(xe)},[C,g,f,Fe,_,Ve,me]),b.useEffect(()=>{f.delete&&me()},[me,f.delete]);function Ze(){var xe,Be,Ge;return B!=null&&B.loading?b.createElement("div",{className:gn(E==null?void 0:E.loader,(xe=f==null?void 0:f.classNames)==null?void 0:xe.loader,"sonner-loader"),"data-visible":Fe==="loading"},B.loading):D?b.createElement("div",{className:gn(E==null?void 0:E.loader,(Be=f==null?void 0:f.classNames)==null?void 0:Be.loader,"sonner-loader"),"data-visible":Fe==="loading"},D):b.createElement(NI,{className:gn(E==null?void 0:E.loader,(Ge=f==null?void 0:f.classNames)==null?void 0:Ge.loader),visible:Fe==="loading"})}return b.createElement("li",{tabIndex:0,ref:We,className:gn(V,ut,E==null?void 0:E.toast,(t=f==null?void 0:f.classNames)==null?void 0:t.toast,E==null?void 0:E.default,E==null?void 0:E[Fe],(n=f==null?void 0:f.classNames)==null?void 0:n[Fe]),"data-sonner-toast":"","data-rich-colors":(r=f.richColors)!=null?r:I,"data-styled":!(f.jsx||f.unstyled||v),"data-mounted":W,"data-promise":!!f.promise,"data-swiped":ge,"data-removed":X,"data-visible":Ke,"data-y-position":zt,"data-x-position":xt,"data-index":S,"data-front":ze,"data-swiping":Z,"data-dismissible":Ue,"data-type":Fe,"data-invert":Te,"data-swipe-out":ae,"data-swipe-direction":J,"data-expanded":!!(C||P&&W),style:{"--index":S,"--toasts-before":S,"--z-index":k.length-S,"--offset":`${X?Ae:Nt.current}px`,"--initial-height":P?"auto":`${ke}px`,...R,...f.style},onDragEnd:()=>{z(!1),G(null),Ct.current=null},onPointerDown:xe=>{Q||!Ue||(It.current=new Date,Pe(Nt.current),xe.target.setPointerCapture(xe.pointerId),xe.target.tagName!=="BUTTON"&&(z(!0),Ct.current={x:xe.clientX,y:xe.clientY}))},onPointerUp:()=>{var xe,Be,Ge,Tt;if(ae||!Ue)return;Ct.current=null;let kt=Number(((xe=We.current)==null?void 0:xe.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),At=Number(((Be=We.current)==null?void 0:Be.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),Lt=new Date().getTime()-((Ge=It.current)==null?void 0:Ge.getTime()),je=M==="x"?kt:At,dt=Math.abs(je)/Lt;if(Math.abs(je)>=qI||dt>.11){Pe(Nt.current),(Tt=f.onDismiss)==null||Tt.call(f,f),se(M==="x"?kt>0?"right":"left":At>0?"down":"up"),me(),ie(!0),we(!1);return}z(!1),G(null)},onPointerMove:xe=>{var Be,Ge,Tt,kt;if(!Ct.current||!Ue||((Be=window.getSelection())==null?void 0:Be.toString().length)>0)return;let At=xe.clientY-Ct.current.y,Lt=xe.clientX-Ct.current.x,je=(Ge=e.swipeDirections)!=null?Ge:YI(q);!M&&(Math.abs(Lt)>1||Math.abs(At)>1)&&G(Math.abs(Lt)>Math.abs(At)?"x":"y");let dt={x:0,y:0};M==="y"?(je.includes("top")||je.includes("bottom"))&&(je.includes("top")&&At<0||je.includes("bottom")&&At>0)&&(dt.y=At):M==="x"&&(je.includes("left")||je.includes("right"))&&(je.includes("left")&&Lt<0||je.includes("right")&&Lt>0)&&(dt.x=Lt),(Math.abs(dt.x)>0||Math.abs(dt.y)>0)&&we(!0),(Tt=We.current)==null||Tt.style.setProperty("--swipe-amount-x",`${dt.x}px`),(kt=We.current)==null||kt.style.setProperty("--swipe-amount-y",`${dt.y}px`)}},_t&&!f.jsx?b.createElement("button",{"aria-label":Y,"data-disabled":Q,"data-close-button":!0,onClick:Q||!Ue?()=>{}:()=>{var xe;me(),(xe=f.onDismiss)==null||xe.call(f,f)},className:gn(E==null?void 0:E.closeButton,(o=f==null?void 0:f.classNames)==null?void 0:o.closeButton)},(s=B==null?void 0:B.close)!=null?s:RI):null,f.jsx||b.isValidElement(f.title)?f.jsx?f.jsx:typeof f.title=="function"?f.title():f.title:b.createElement(b.Fragment,null,Fe||f.icon||f.promise?b.createElement("div",{"data-icon":"",className:gn(E==null?void 0:E.icon,(i=f==null?void 0:f.classNames)==null?void 0:i.icon)},f.promise||f.type==="loading"&&!f.icon?f.icon||Ze():null,f.type!=="loading"?f.icon||(B==null?void 0:B[Fe])||EI(Fe):null):null,b.createElement("div",{"data-content":"",className:gn(E==null?void 0:E.content,(a=f==null?void 0:f.classNames)==null?void 0:a.content)},b.createElement("div",{"data-title":"",className:gn(E==null?void 0:E.title,(l=f==null?void 0:f.classNames)==null?void 0:l.title)},typeof f.title=="function"?f.title():f.title),f.description?b.createElement("div",{"data-description":"",className:gn(U,jt,E==null?void 0:E.description,(c=f==null?void 0:f.classNames)==null?void 0:c.description)},typeof f.description=="function"?f.description():f.description):null),b.isValidElement(f.cancel)?f.cancel:f.cancel&&hi(f.cancel)?b.createElement("button",{"data-button":!0,"data-cancel":!0,style:f.cancelButtonStyle||O,onClick:xe=>{var Be,Ge;hi(f.cancel)&&Ue&&((Ge=(Be=f.cancel).onClick)==null||Ge.call(Be,xe),me())},className:gn(E==null?void 0:E.cancelButton,(d=f==null?void 0:f.classNames)==null?void 0:d.cancelButton)},f.cancel.label):null,b.isValidElement(f.action)?f.action:f.action&&hi(f.action)?b.createElement("button",{"data-button":!0,"data-action":!0,style:f.actionButtonStyle||$,onClick:xe=>{var Be,Ge;hi(f.action)&&((Ge=(Be=f.action).onClick)==null||Ge.call(Be,xe),!xe.defaultPrevented&&me())},className:gn(E==null?void 0:E.actionButton,(h=f==null?void 0:f.classNames)==null?void 0:h.actionButton)},f.action.label):null))};function Zg(){if(typeof window>"u"||typeof document>"u")return"ltr";let e=document.documentElement.getAttribute("dir");return e==="auto"||!e?window.getComputedStyle(document.documentElement).direction:e}function JI(e,t){let n={};return[e,t].forEach((r,o)=>{let s=o===1,i=s?"--mobile-offset":"--offset",a=s?WI:UI;function l(c){["top","right","bottom","left"].forEach(d=>{n[`${i}-${d}`]=typeof c=="number"?`${c}px`:c})}typeof r=="number"||typeof r=="string"?l(r):typeof r=="object"?["top","right","bottom","left"].forEach(c=>{r[c]===void 0?n[`${i}-${c}`]=a:n[`${i}-${c}`]=typeof r[c]=="number"?`${r[c]}px`:r[c]}):l(a)}),n}var ZI=b.forwardRef(function(e,t){let{invert:n,position:r="bottom-right",hotkey:o=["altKey","KeyT"],expand:s,closeButton:i,className:a,offset:l,mobileOffset:c,theme:d="light",richColors:h,duration:m,style:f,visibleToasts:v=HI,toastOptions:g,dir:x=Zg(),gap:y=KI,loadingIcon:w,icons:S,containerAriaLabel:k="Notifications",pauseWhenPageIsHidden:C}=e,[T,I]=b.useState([]),N=b.useMemo(()=>Array.from(new Set([r].concat(T.filter(_=>_.position).map(_=>_.position)))),[T,r]),[R,O]=b.useState([]),[$,V]=b.useState(!1),[U,j]=b.useState(!1),[q,K]=b.useState(d!=="system"?d:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),D=b.useRef(null),P=o.join("+").replace(/Key/g,"").replace(/Digit/g,""),E=b.useRef(null),B=b.useRef(!1),Y=b.useCallback(_=>{I(M=>{var G;return(G=M.find(J=>J.id===_.id))!=null&&G.delete||qt.dismiss(_.id),M.filter(({id:J})=>J!==_.id)})},[]);return b.useEffect(()=>qt.subscribe(_=>{if(_.dismiss){I(M=>M.map(G=>G.id===_.id?{...G,delete:!0}:G));return}setTimeout(()=>{Po.flushSync(()=>{I(M=>{let G=M.findIndex(J=>J.id===_.id);return G!==-1?[...M.slice(0,G),{...M[G],..._},...M.slice(G+1)]:[_,...M]})})})}),[]),b.useEffect(()=>{if(d!=="system"){K(d);return}if(d==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?K("dark"):K("light")),typeof window>"u")return;let _=window.matchMedia("(prefers-color-scheme: dark)");try{_.addEventListener("change",({matches:M})=>{K(M?"dark":"light")})}catch{_.addListener(({matches:G})=>{try{K(G?"dark":"light")}catch(J){console.error(J)}})}},[d]),b.useEffect(()=>{T.length<=1&&V(!1)},[T]),b.useEffect(()=>{let _=M=>{var G,J;o.every(se=>M[se]||M.code===se)&&(V(!0),(G=D.current)==null||G.focus()),M.code==="Escape"&&(document.activeElement===D.current||(J=D.current)!=null&&J.contains(document.activeElement))&&V(!1)};return document.addEventListener("keydown",_),()=>document.removeEventListener("keydown",_)},[o]),b.useEffect(()=>{if(D.current)return()=>{E.current&&(E.current.focus({preventScroll:!0}),E.current=null,B.current=!1)}},[D.current]),b.createElement("section",{ref:t,"aria-label":`${k} ${P}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},N.map((_,M)=>{var G;let[J,se]=_.split("-");return T.length?b.createElement("ol",{key:_,dir:x==="auto"?Zg():x,tabIndex:-1,ref:D,className:a,"data-sonner-toaster":!0,"data-theme":q,"data-y-position":J,"data-lifted":$&&T.length>1&&!s,"data-x-position":se,style:{"--front-toast-height":`${((G=R[0])==null?void 0:G.height)||0}px`,"--width":`${VI}px`,"--gap":`${y}px`,...f,...JI(l,c)},onBlur:W=>{B.current&&!W.currentTarget.contains(W.relatedTarget)&&(B.current=!1,E.current&&(E.current.focus({preventScroll:!0}),E.current=null))},onFocus:W=>{W.target instanceof HTMLElement&&W.target.dataset.dismissible==="false"||B.current||(B.current=!0,E.current=W.relatedTarget)},onMouseEnter:()=>V(!0),onMouseMove:()=>V(!0),onMouseLeave:()=>{U||V(!1)},onDragEnd:()=>V(!1),onPointerDown:W=>{W.target instanceof HTMLElement&&W.target.dataset.dismissible==="false"||j(!0)},onPointerUp:()=>j(!1)},T.filter(W=>!W.position&&M===0||W.position===_).map((W,L)=>{var X,ee;return b.createElement(XI,{key:W.id,icons:S,index:L,toast:W,defaultRichColors:h,duration:(X=g==null?void 0:g.duration)!=null?X:m,className:g==null?void 0:g.className,descriptionClassName:g==null?void 0:g.descriptionClassName,invert:n,visibleToasts:v,closeButton:(ee=g==null?void 0:g.closeButton)!=null?ee:i,interacting:U,position:_,style:g==null?void 0:g.style,unstyled:g==null?void 0:g.unstyled,classNames:g==null?void 0:g.classNames,cancelButtonStyle:g==null?void 0:g.cancelButtonStyle,actionButtonStyle:g==null?void 0:g.actionButtonStyle,removeToast:Y,toasts:T.filter(Z=>Z.position==W.position),heights:R.filter(Z=>Z.position==W.position),setHeights:O,expandByDefault:s,gap:y,loadingIcon:w,expanded:$,pauseWhenPageIsHidden:C,swipeDirections:e.swipeDirections})})):null}))});const QI=({...e})=>{const{theme:t="system"}=kI();return u.jsx(ZI,{theme:t,className:"toaster group",toastOptions:{classNames:{toast:"group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg",description:"group-[.toast]:text-muted-foreground",actionButton:"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",cancelButton:"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground"}},...e})};F.Api=Fv,F.ApiClient=$v,F.ApiProvider=tu,F.ArtifactRenderer=Cp,F.Badge=Pp,F.Button=Qe,F.Card=sl,F.CardContent=cl,F.CardDescription=ll,F.CardHeader=il,F.CardTitle=al,F.ChatApi=Ko,F.ChatApp=Rk,F.ChatInput=Hf,F.ChatInterface=Mr,F.ChatProviders=vr,F.ChatWidget=Dk,F.Command=wl,F.CommandEmpty=Cl,F.CommandGroup=Tl,F.CommandInput=yl,F.CommandItem=kl,F.CommandList=Sl,F.DEFAULT_TIMEOUT_MS=Yc,F.Dialog=Qa,F.DialogContent=Bs,F.DialogHeader=zs,F.DialogTitle=Hs,F.DropdownMenu=Ss,F.DropdownMenuContent=ho,F.DropdownMenuItem=Bn,F.DropdownMenuTrigger=Cs,F.FileViewerModal=ip,F.HISTORY_TIMEOUT_MS=Xc,F.Input=Pl,F.InterruptPartRenderer=kp,F.Label=fm,F.MarkdownContent=Rr,F.MessageComponent=Ys,F.MessageList=hl,F.MessageRow=fl,F.NewChatButton=Lk,F.PlotArtifact=wp,F.ResearchTaskArtifact=Sp,F.SETTINGS_STORAGE_KEY=$i,F.ScrollArea=_l,F.Select=gE,F.SelectContent=Qm,F.SelectItem=eg,F.SelectTrigger=Xm,F.SelectValue=xE,F.Separator=og,F.Sheet=NE,F.SheetContent=hg,F.SheetDescription=gg,F.SheetHeader=pg,F.SheetTitle=mg,F.SheetTrigger=AE,F.SimpleChat=Mk,F.SimpleJsonView=ul,F.Sonner=QI,F.StreamProgress=Ep,F.Switch=dg,F.Textarea=Ta,F.ThinkingIndicator=Ip,F.ThreadListItem=im,F.ThreadManager=ti,F.ThreadStateProvider=Tu,F.ThreadsProvider=fu,F.TimelineColumn=mx,F.Toaster=yI,F.ToolComponent=Ap,F.Tooltip=ZE,F.TooltipContent=kg,F.TooltipProvider=JE,F.TooltipTrigger=QE,F.UserTextContent=Np,F.applySettings=bb,F.buildCheckpointIndex=Ql,F.buildCheckpointPreviewMap=ox,F.chatApiClient=Mn,F.del=Ai,F.downloadFileById=Zc,F.extractConfigFields=mi,F.fileToBase64=nu,F.get=Jt,F.getChatToken=qc,F.getCheckpointForMessage=sx,F.getCurrentSettings=vb,F.getDefaultApiConfig=Ru,F.getDefaultChatSettings=Mu,F.getFileContent=_i,F.getFileInfo=zv,F.getMessageAttemptInfo=ec,F.getMessageDomKey=dl,F.getPreviewForMessage=pi,F.httpClient=Xt,F.hydrateHistorySnapshots=Rn,F.isEnvelope=ou,F.listFiles=Qc,F.loadStoredSettings=Ou,F.onChatTokenChanged=Gc,F.post=Vo,F.processAttachments=ru,F.put=Jc,F.readNumber=nc,F.readString=Pn,F.resolveChatBaseUrl=vn,F.saveSettings=Du,F.setChatToken=Wo,F.toPlainObject=_n,F.unwrap=$t,F.useApi=Xr,F.useCheckpointIndex=tc,F.useFilePreview=jp,F.useHasChatSession=mb,F.useParsedMessageContent=_p,F.useShallowStableValue=Au,F.useStream=Li,F.useStreamingHook=Li,F.useThreadHistoryState=wu,F.useThreadManagerViewState=cm,F.useThreadState=eo,F.useThreadStateUpdater=Cu,F.useThreads=gr,F.useThreadsState=uu,F.viewFileById=Bv,Object.defineProperty(F,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED