@arcteninc/core 0.0.91 → 0.0.93
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.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { jsx as m, jsxs as
|
|
1
|
+
import { jsx as m, jsxs as R, Fragment as Fe } from "react/jsx-runtime";
|
|
2
2
|
import * as Ut from "react";
|
|
3
|
-
import { useImperativeHandle as fc, createContext as Ve, useRef as
|
|
3
|
+
import { useImperativeHandle as fc, createContext as Ve, useRef as bt, useLayoutEffect as mc, useEffect as st, useId as qs, useContext as St, useInsertionEffect as ro, useMemo as et, useCallback as yn, Children as pc, isValidElement as gc, useState as W, Fragment as io, createElement as yc, forwardRef as vc, Component as xc, memo as An, Suspense as bc, lazy as wc } from "react";
|
|
4
4
|
import { Check as oo, X as Kn, ChevronDown as Tc, ChevronRight as Sc, Zap as Ac, BrainIcon as Pc, ChevronDownIcon as Cc, Plus as kc, Dock as Mc, PictureInPicture2 as Dc, Maximize2 as Ec, Minimize2 as Nc, Square as Vc, ArrowRight as Rc, BotMessageSquare as Ic } from "lucide-react";
|
|
5
5
|
import { useChat as ao } from "@ai-sdk/react";
|
|
6
6
|
import { lastAssistantMessageIsCompleteWithToolCalls as co, DefaultChatTransport as lo } from "ai";
|
|
@@ -12,8 +12,8 @@ import * as Ge from "@radix-ui/react-tooltip";
|
|
|
12
12
|
import { useControllableState as Fr } from "@radix-ui/react-use-controllable-state";
|
|
13
13
|
import * as Xs from "@radix-ui/react-collapsible";
|
|
14
14
|
import { createPortal as jc } from "react-dom";
|
|
15
|
-
import { verifyToken as
|
|
16
|
-
function
|
|
15
|
+
import { verifyToken as om } from "./server.mjs";
|
|
16
|
+
function yt(...t) {
|
|
17
17
|
return Oc(Lc(t));
|
|
18
18
|
}
|
|
19
19
|
const Ce = ho(
|
|
@@ -47,7 +47,7 @@ const Ce = ho(
|
|
|
47
47
|
{
|
|
48
48
|
ref: o,
|
|
49
49
|
"data-slot": "button",
|
|
50
|
-
className:
|
|
50
|
+
className: yt(Ce({ variant: e, size: n, className: t })),
|
|
51
51
|
...r
|
|
52
52
|
}
|
|
53
53
|
));
|
|
@@ -78,7 +78,7 @@ function cs({
|
|
|
78
78
|
n ? uo : "span",
|
|
79
79
|
{
|
|
80
80
|
"data-slot": "badge",
|
|
81
|
-
className:
|
|
81
|
+
className: yt($c({ variant: e }), t),
|
|
82
82
|
...s
|
|
83
83
|
}
|
|
84
84
|
);
|
|
@@ -126,7 +126,7 @@ const Fc = ({
|
|
|
126
126
|
...o,
|
|
127
127
|
value: r,
|
|
128
128
|
ref: a,
|
|
129
|
-
className:
|
|
129
|
+
className: yt(
|
|
130
130
|
"flex w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",
|
|
131
131
|
n
|
|
132
132
|
),
|
|
@@ -167,12 +167,12 @@ function fe({
|
|
|
167
167
|
children: n,
|
|
168
168
|
...s
|
|
169
169
|
}) {
|
|
170
|
-
return /* @__PURE__ */ m(Ge.Portal, { children: /* @__PURE__ */
|
|
170
|
+
return /* @__PURE__ */ m(Ge.Portal, { children: /* @__PURE__ */ R(
|
|
171
171
|
Ge.Content,
|
|
172
172
|
{
|
|
173
173
|
"data-slot": "tooltip-content",
|
|
174
174
|
sideOffset: e,
|
|
175
|
-
className:
|
|
175
|
+
className: yt(
|
|
176
176
|
"bg-foreground text-background 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 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",
|
|
177
177
|
t
|
|
178
178
|
),
|
|
@@ -189,7 +189,7 @@ function Br({ className: t, ...e }) {
|
|
|
189
189
|
"kbd",
|
|
190
190
|
{
|
|
191
191
|
"data-slot": "kbd",
|
|
192
|
-
className:
|
|
192
|
+
className: yt(
|
|
193
193
|
"bg-muted text-muted-foreground pointer-events-none inline-flex h-5 w-fit min-w-5 items-center justify-center gap-1 rounded-sm px-1 font-sans text-xs font-medium select-none",
|
|
194
194
|
"[&_svg:not([class*='size-'])]:size-3",
|
|
195
195
|
"[[data-slot=tooltip-content]_&]:bg-background/20 [[data-slot=tooltip-content]_&]:text-background dark:[[data-slot=tooltip-content]_&]:bg-background/10",
|
|
@@ -201,10 +201,10 @@ function Br({ className: t, ...e }) {
|
|
|
201
201
|
}
|
|
202
202
|
const Ys = Ve({});
|
|
203
203
|
function Js(t) {
|
|
204
|
-
const e =
|
|
204
|
+
const e = bt(null);
|
|
205
205
|
return e.current === null && (e.current = t()), e.current;
|
|
206
206
|
}
|
|
207
|
-
const Zs = typeof window < "u", mo = Zs ? mc :
|
|
207
|
+
const Zs = typeof window < "u", mo = Zs ? mc : st, Zn = /* @__PURE__ */ Ve(null);
|
|
208
208
|
function Qs(t, e) {
|
|
209
209
|
t.indexOf(e) === -1 && t.push(e);
|
|
210
210
|
}
|
|
@@ -340,8 +340,8 @@ function Xc(t, e) {
|
|
|
340
340
|
* Schedule a process to run on the next frame.
|
|
341
341
|
*/
|
|
342
342
|
schedule: (l, d = !1, h = !1) => {
|
|
343
|
-
const
|
|
344
|
-
return d && i.add(l),
|
|
343
|
+
const T = h && r ? n : s;
|
|
344
|
+
return d && i.add(l), T.has(l) || T.add(l), l;
|
|
345
345
|
},
|
|
346
346
|
/**
|
|
347
347
|
* Cancel the provided callback from running on the next frame.
|
|
@@ -369,21 +369,21 @@ function Do(t, e) {
|
|
|
369
369
|
delta: 0,
|
|
370
370
|
timestamp: 0,
|
|
371
371
|
isProcessing: !1
|
|
372
|
-
}, o = () => n = !0, i = Ln.reduce((
|
|
373
|
-
const
|
|
374
|
-
n = !1, te.useManualTiming || (r.delta = s ? 1e3 / 60 : Math.max(Math.min(
|
|
375
|
-
},
|
|
376
|
-
n = !0, s = !0, r.isProcessing || t(
|
|
372
|
+
}, o = () => n = !0, i = Ln.reduce((y, M) => (y[M] = Xc(o), y), {}), { setup: a, read: c, resolveKeyframes: u, preUpdate: l, update: d, preRender: h, render: p, postRender: T } = i, w = () => {
|
|
373
|
+
const y = te.useManualTiming ? r.timestamp : performance.now();
|
|
374
|
+
n = !1, te.useManualTiming || (r.delta = s ? 1e3 / 60 : Math.max(Math.min(y - r.timestamp, Yc), 1)), r.timestamp = y, r.isProcessing = !0, a.process(r), c.process(r), u.process(r), l.process(r), d.process(r), h.process(r), p.process(r), T.process(r), r.isProcessing = !1, n && e && (s = !1, t(w));
|
|
375
|
+
}, b = () => {
|
|
376
|
+
n = !0, s = !0, r.isProcessing || t(w);
|
|
377
377
|
};
|
|
378
|
-
return { schedule: Ln.reduce((
|
|
379
|
-
const
|
|
380
|
-
return
|
|
381
|
-
}, {}), cancel: (
|
|
378
|
+
return { schedule: Ln.reduce((y, M) => {
|
|
379
|
+
const C = i[M];
|
|
380
|
+
return y[M] = (D, E = !1, S = !1) => (n || b(), C.schedule(D, E, S)), y;
|
|
381
|
+
}, {}), cancel: (y) => {
|
|
382
382
|
for (let M = 0; M < Ln.length; M++)
|
|
383
|
-
i[Ln[M]].cancel(
|
|
383
|
+
i[Ln[M]].cancel(y);
|
|
384
384
|
}, state: r, steps: i };
|
|
385
385
|
}
|
|
386
|
-
const { schedule:
|
|
386
|
+
const { schedule: dt, cancel: pe, state: Tt, steps: ls } = /* @__PURE__ */ Do(typeof requestAnimationFrame < "u" ? requestAnimationFrame : jt, !0);
|
|
387
387
|
let Bn;
|
|
388
388
|
function Jc() {
|
|
389
389
|
Bn = void 0;
|
|
@@ -450,13 +450,13 @@ const Cs = {
|
|
|
450
450
|
test: /* @__PURE__ */ lr("hsl", "hue"),
|
|
451
451
|
parse: /* @__PURE__ */ No("hue", "saturation", "lightness"),
|
|
452
452
|
transform: ({ hue: t, saturation: e, lightness: n, alpha: s = 1 }) => "hsla(" + Math.round(t) + ", " + Ht.transform(dn(e)) + ", " + Ht.transform(dn(n)) + ", " + dn(xn.transform(s)) + ")"
|
|
453
|
-
},
|
|
453
|
+
}, xt = {
|
|
454
454
|
test: (t) => Me.test(t) || Cs.test(t) || Be.test(t),
|
|
455
455
|
parse: (t) => Me.test(t) ? Me.parse(t) : Be.test(t) ? Be.parse(t) : Cs.parse(t),
|
|
456
456
|
transform: (t) => typeof t == "string" ? t : t.hasOwnProperty("red") ? Me.transform(t) : Be.transform(t),
|
|
457
457
|
getAnimatableNone: (t) => {
|
|
458
|
-
const e =
|
|
459
|
-
return e.alpha = 0,
|
|
458
|
+
const e = xt.parse(t);
|
|
459
|
+
return e.alpha = 0, xt.transform(e);
|
|
460
460
|
}
|
|
461
461
|
}, ol = /(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;
|
|
462
462
|
function al(t) {
|
|
@@ -470,7 +470,7 @@ function bn(t) {
|
|
|
470
470
|
var: []
|
|
471
471
|
}, r = [];
|
|
472
472
|
let o = 0;
|
|
473
|
-
const a = e.replace(ul, (c) => (
|
|
473
|
+
const a = e.replace(ul, (c) => (xt.test(c) ? (s.color.push(o), r.push(Ro), n.push(xt.parse(c))) : c.startsWith(ll) ? (s.var.push(o), r.push(cl), n.push(c)) : (s.number.push(o), r.push(Vo), n.push(parseFloat(c))), ++o, Kr)).split(Kr);
|
|
474
474
|
return { values: n, split: a, indexes: s, types: r };
|
|
475
475
|
}
|
|
476
476
|
function Io(t) {
|
|
@@ -483,12 +483,12 @@ function Lo(t) {
|
|
|
483
483
|
for (let i = 0; i < s; i++)
|
|
484
484
|
if (o += e[i], r[i] !== void 0) {
|
|
485
485
|
const a = n[i];
|
|
486
|
-
a === Vo ? o += dn(r[i]) : a === Ro ? o +=
|
|
486
|
+
a === Vo ? o += dn(r[i]) : a === Ro ? o += xt.transform(r[i]) : o += r[i];
|
|
487
487
|
}
|
|
488
488
|
return o;
|
|
489
489
|
};
|
|
490
490
|
}
|
|
491
|
-
const dl = (t) => typeof t == "number" ? 0 :
|
|
491
|
+
const dl = (t) => typeof t == "number" ? 0 : xt.test(t) ? xt.getAnimatableNone(t) : t;
|
|
492
492
|
function hl(t) {
|
|
493
493
|
const e = Io(t);
|
|
494
494
|
return Lo(t)(e.map(dl));
|
|
@@ -521,7 +521,7 @@ function fl({ hue: t, saturation: e, lightness: n, alpha: s }) {
|
|
|
521
521
|
function Hn(t, e) {
|
|
522
522
|
return (n) => n > 0 ? e : t;
|
|
523
523
|
}
|
|
524
|
-
const
|
|
524
|
+
const ft = (t, e, n) => t + (e - t) * n, hs = (t, e, n) => {
|
|
525
525
|
const s = t * t, r = n * (e * e - s) + s;
|
|
526
526
|
return r < 0 ? 0 : Math.sqrt(r);
|
|
527
527
|
}, ml = [Cs, Me, Be], pl = (t) => ml.find((e) => e.test(t));
|
|
@@ -537,16 +537,16 @@ const Hr = (t, e) => {
|
|
|
537
537
|
if (!n || !s)
|
|
538
538
|
return Hn(t, e);
|
|
539
539
|
const r = { ...n };
|
|
540
|
-
return (o) => (r.red = hs(n.red, s.red, o), r.green = hs(n.green, s.green, o), r.blue = hs(n.blue, s.blue, o), r.alpha =
|
|
540
|
+
return (o) => (r.red = hs(n.red, s.red, o), r.green = hs(n.green, s.green, o), r.blue = hs(n.blue, s.blue, o), r.alpha = ft(n.alpha, s.alpha, o), Me.transform(r));
|
|
541
541
|
}, ks = /* @__PURE__ */ new Set(["none", "hidden"]);
|
|
542
542
|
function gl(t, e) {
|
|
543
543
|
return ks.has(t) ? (n) => n <= 0 ? t : e : (n) => n >= 1 ? e : t;
|
|
544
544
|
}
|
|
545
545
|
function yl(t, e) {
|
|
546
|
-
return (n) =>
|
|
546
|
+
return (n) => ft(t, e, n);
|
|
547
547
|
}
|
|
548
548
|
function ur(t) {
|
|
549
|
-
return typeof t == "number" ? yl : typeof t == "string" ? ar(t) ? Hn :
|
|
549
|
+
return typeof t == "number" ? yl : typeof t == "string" ? ar(t) ? Hn : xt.test(t) ? Hr : bl : Array.isArray(t) ? Oo : typeof t == "object" ? xt.test(t) ? Hr : vl : Hn;
|
|
550
550
|
}
|
|
551
551
|
function Oo(t, e) {
|
|
552
552
|
const n = [...t], s = n.length, r = t.map((o, i) => ur(o)(o, e[i]));
|
|
@@ -579,12 +579,12 @@ const bl = (t, e) => {
|
|
|
579
579
|
return s.indexes.var.length === r.indexes.var.length && s.indexes.color.length === r.indexes.color.length && s.indexes.number.length >= r.indexes.number.length ? ks.has(t) && !r.values.length || ks.has(e) && !s.values.length ? gl(t, e) : Pn(Oo(xl(s, r), r.values), n) : (Ye(!0, `Complex values '${t}' and '${e}' too different to mix. Ensure all colors are of the same type, and that each contains the same quantity of number and color values. Falling back to instant transition.`, "complex-values-different"), Hn(t, e));
|
|
580
580
|
};
|
|
581
581
|
function jo(t, e, n) {
|
|
582
|
-
return typeof t == "number" && typeof e == "number" && typeof n == "number" ?
|
|
582
|
+
return typeof t == "number" && typeof e == "number" && typeof n == "number" ? ft(t, e, n) : ur(t)(t, e);
|
|
583
583
|
}
|
|
584
584
|
const wl = (t) => {
|
|
585
585
|
const e = ({ timestamp: n }) => t(n);
|
|
586
586
|
return {
|
|
587
|
-
start: (n = !0) =>
|
|
587
|
+
start: (n = !0) => dt.update(e, n),
|
|
588
588
|
stop: () => pe(e),
|
|
589
589
|
/**
|
|
590
590
|
* If we're processing this frame we can use the
|
|
@@ -620,7 +620,7 @@ function Fo(t, e, n) {
|
|
|
620
620
|
const s = Math.max(e - Sl, 0);
|
|
621
621
|
return vo(n - t(s), e - s);
|
|
622
622
|
}
|
|
623
|
-
const
|
|
623
|
+
const ht = {
|
|
624
624
|
// Default spring physics
|
|
625
625
|
stiffness: 100,
|
|
626
626
|
damping: 10,
|
|
@@ -649,16 +649,16 @@ const ut = {
|
|
|
649
649
|
minDamping: 0.05,
|
|
650
650
|
maxDamping: 1
|
|
651
651
|
}, fs = 1e-3;
|
|
652
|
-
function Al({ duration: t =
|
|
652
|
+
function Al({ duration: t = ht.duration, bounce: e = ht.bounce, velocity: n = ht.velocity, mass: s = ht.mass }) {
|
|
653
653
|
let r, o;
|
|
654
|
-
Ye(t <= /* @__PURE__ */ _t(
|
|
654
|
+
Ye(t <= /* @__PURE__ */ _t(ht.maxDuration), "Spring duration must be 10 seconds or less", "spring-duration-limit");
|
|
655
655
|
let i = 1 - e;
|
|
656
|
-
i = Zt(
|
|
657
|
-
const l = u * i, d = l * t, h = l - n, p = Ms(u, i),
|
|
658
|
-
return fs - h / p *
|
|
656
|
+
i = Zt(ht.minDamping, ht.maxDamping, i), t = Zt(ht.minDuration, ht.maxDuration, /* @__PURE__ */ Ot(t)), i < 1 ? (r = (u) => {
|
|
657
|
+
const l = u * i, d = l * t, h = l - n, p = Ms(u, i), T = Math.exp(-d);
|
|
658
|
+
return fs - h / p * T;
|
|
659
659
|
}, o = (u) => {
|
|
660
|
-
const d = u * i * t, h = d * n + n, p = Math.pow(i, 2) * Math.pow(u, 2) * t,
|
|
661
|
-
return (-r(u) + fs > 0 ? -1 : 1) * ((h - p) *
|
|
660
|
+
const d = u * i * t, h = d * n + n, p = Math.pow(i, 2) * Math.pow(u, 2) * t, T = Math.exp(-d), w = Ms(Math.pow(u, 2), i);
|
|
661
|
+
return (-r(u) + fs > 0 ? -1 : 1) * ((h - p) * T) / w;
|
|
662
662
|
}) : (r = (u) => {
|
|
663
663
|
const l = Math.exp(-u * t), d = (u - n) * t + 1;
|
|
664
664
|
return -fs + l * d;
|
|
@@ -669,8 +669,8 @@ function Al({ duration: t = ut.duration, bounce: e = ut.bounce, velocity: n = ut
|
|
|
669
669
|
const a = 5 / t, c = Cl(r, o, a);
|
|
670
670
|
if (t = /* @__PURE__ */ _t(t), isNaN(c))
|
|
671
671
|
return {
|
|
672
|
-
stiffness:
|
|
673
|
-
damping:
|
|
672
|
+
stiffness: ht.stiffness,
|
|
673
|
+
damping: ht.damping,
|
|
674
674
|
duration: t
|
|
675
675
|
};
|
|
676
676
|
{
|
|
@@ -698,10 +698,10 @@ function qr(t, e) {
|
|
|
698
698
|
}
|
|
699
699
|
function Dl(t) {
|
|
700
700
|
let e = {
|
|
701
|
-
velocity:
|
|
702
|
-
stiffness:
|
|
703
|
-
damping:
|
|
704
|
-
mass:
|
|
701
|
+
velocity: ht.velocity,
|
|
702
|
+
stiffness: ht.stiffness,
|
|
703
|
+
damping: ht.damping,
|
|
704
|
+
mass: ht.mass,
|
|
705
705
|
isResolvedFromDuration: !1,
|
|
706
706
|
...t
|
|
707
707
|
};
|
|
@@ -710,7 +710,7 @@ function Dl(t) {
|
|
|
710
710
|
const n = t.visualDuration, s = 2 * Math.PI / (n * 1.2), r = s * s, o = 2 * Zt(0.05, 1, 1 - (t.bounce || 0)) * Math.sqrt(r);
|
|
711
711
|
e = {
|
|
712
712
|
...e,
|
|
713
|
-
mass:
|
|
713
|
+
mass: ht.mass,
|
|
714
714
|
stiffness: r,
|
|
715
715
|
damping: o
|
|
716
716
|
};
|
|
@@ -719,12 +719,12 @@ function Dl(t) {
|
|
|
719
719
|
e = {
|
|
720
720
|
...e,
|
|
721
721
|
...n,
|
|
722
|
-
mass:
|
|
722
|
+
mass: ht.mass
|
|
723
723
|
}, e.isResolvedFromDuration = !0;
|
|
724
724
|
}
|
|
725
725
|
return e;
|
|
726
726
|
}
|
|
727
|
-
function Xn(t =
|
|
727
|
+
function Xn(t = ht.visualDuration, e = ht.bounce) {
|
|
728
728
|
const n = typeof t != "object" ? {
|
|
729
729
|
visualDuration: t,
|
|
730
730
|
keyframes: [0, 1],
|
|
@@ -734,41 +734,41 @@ function Xn(t = ut.visualDuration, e = ut.bounce) {
|
|
|
734
734
|
const o = n.keyframes[0], i = n.keyframes[n.keyframes.length - 1], a = { done: !1, value: o }, { stiffness: c, damping: u, mass: l, duration: d, velocity: h, isResolvedFromDuration: p } = Dl({
|
|
735
735
|
...n,
|
|
736
736
|
velocity: -/* @__PURE__ */ Ot(n.velocity || 0)
|
|
737
|
-
}),
|
|
738
|
-
s || (s =
|
|
739
|
-
let
|
|
740
|
-
if (
|
|
741
|
-
const
|
|
742
|
-
|
|
743
|
-
const
|
|
744
|
-
return i -
|
|
737
|
+
}), T = h || 0, w = u / (2 * Math.sqrt(c * l)), b = i - o, g = /* @__PURE__ */ Ot(Math.sqrt(c / l)), v = Math.abs(b) < 5;
|
|
738
|
+
s || (s = v ? ht.restSpeed.granular : ht.restSpeed.default), r || (r = v ? ht.restDelta.granular : ht.restDelta.default);
|
|
739
|
+
let y;
|
|
740
|
+
if (w < 1) {
|
|
741
|
+
const C = Ms(g, w);
|
|
742
|
+
y = (D) => {
|
|
743
|
+
const E = Math.exp(-w * g * D);
|
|
744
|
+
return i - E * ((T + w * g * b) / C * Math.sin(C * D) + b * Math.cos(C * D));
|
|
745
745
|
};
|
|
746
|
-
} else if (
|
|
747
|
-
|
|
746
|
+
} else if (w === 1)
|
|
747
|
+
y = (C) => i - Math.exp(-g * C) * (b + (T + g * b) * C);
|
|
748
748
|
else {
|
|
749
|
-
const
|
|
750
|
-
|
|
751
|
-
const
|
|
752
|
-
return i -
|
|
749
|
+
const C = g * Math.sqrt(w * w - 1);
|
|
750
|
+
y = (D) => {
|
|
751
|
+
const E = Math.exp(-w * g * D), S = Math.min(C * D, 300);
|
|
752
|
+
return i - E * ((T + w * g * b) * Math.sinh(S) + C * b * Math.cosh(S)) / C;
|
|
753
753
|
};
|
|
754
754
|
}
|
|
755
755
|
const M = {
|
|
756
756
|
calculatedDuration: p && d || null,
|
|
757
|
-
next: (
|
|
758
|
-
const
|
|
757
|
+
next: (C) => {
|
|
758
|
+
const D = y(C);
|
|
759
759
|
if (p)
|
|
760
|
-
a.done =
|
|
760
|
+
a.done = C >= d;
|
|
761
761
|
else {
|
|
762
|
-
let
|
|
763
|
-
|
|
764
|
-
const S = Math.abs(
|
|
762
|
+
let E = C === 0 ? T : 0;
|
|
763
|
+
w < 1 && (E = C === 0 ? /* @__PURE__ */ _t(T) : Fo(y, C, D));
|
|
764
|
+
const S = Math.abs(E) <= s, $ = Math.abs(i - D) <= r;
|
|
765
765
|
a.done = S && $;
|
|
766
766
|
}
|
|
767
|
-
return a.value = a.done ? i :
|
|
767
|
+
return a.value = a.done ? i : D, a;
|
|
768
768
|
},
|
|
769
769
|
toString: () => {
|
|
770
|
-
const
|
|
771
|
-
return
|
|
770
|
+
const C = Math.min(dr(M), qn), D = $o((E) => M.next(C * E).value, C, 30);
|
|
771
|
+
return C + "ms " + D;
|
|
772
772
|
},
|
|
773
773
|
toTransition: () => {
|
|
774
774
|
}
|
|
@@ -783,19 +783,19 @@ function Ds({ keyframes: t, velocity: e = 0, power: n = 0.8, timeConstant: s = 3
|
|
|
783
783
|
const d = t[0], h = {
|
|
784
784
|
done: !1,
|
|
785
785
|
value: d
|
|
786
|
-
}, p = (S) => a !== void 0 && S < a || c !== void 0 && S > c,
|
|
787
|
-
let
|
|
788
|
-
const
|
|
789
|
-
|
|
790
|
-
const
|
|
791
|
-
const $ =
|
|
792
|
-
h.done = Math.abs($) <= u, h.value = h.done ?
|
|
786
|
+
}, p = (S) => a !== void 0 && S < a || c !== void 0 && S > c, T = (S) => a === void 0 ? c : c === void 0 || Math.abs(a - S) < Math.abs(c - S) ? a : c;
|
|
787
|
+
let w = n * e;
|
|
788
|
+
const b = d + w, g = i === void 0 ? b : i(b);
|
|
789
|
+
g !== b && (w = g - d);
|
|
790
|
+
const v = (S) => -w * Math.exp(-S / s), y = (S) => g + v(S), M = (S) => {
|
|
791
|
+
const $ = v(S), L = y(S);
|
|
792
|
+
h.done = Math.abs($) <= u, h.value = h.done ? g : L;
|
|
793
793
|
};
|
|
794
|
-
let
|
|
795
|
-
const
|
|
796
|
-
p(h.value) && (
|
|
797
|
-
keyframes: [h.value,
|
|
798
|
-
velocity: Fo(
|
|
794
|
+
let C, D;
|
|
795
|
+
const E = (S) => {
|
|
796
|
+
p(h.value) && (C = S, D = Xn({
|
|
797
|
+
keyframes: [h.value, T(h.value)],
|
|
798
|
+
velocity: Fo(y, S, h.value),
|
|
799
799
|
// TODO: This should be passing * 1000
|
|
800
800
|
damping: r,
|
|
801
801
|
stiffness: o,
|
|
@@ -803,11 +803,11 @@ function Ds({ keyframes: t, velocity: e = 0, power: n = 0.8, timeConstant: s = 3
|
|
|
803
803
|
restSpeed: l
|
|
804
804
|
}));
|
|
805
805
|
};
|
|
806
|
-
return
|
|
806
|
+
return E(0), {
|
|
807
807
|
calculatedDuration: null,
|
|
808
808
|
next: (S) => {
|
|
809
809
|
let $ = !1;
|
|
810
|
-
return !
|
|
810
|
+
return !D && C === void 0 && ($ = !0, M(S), E(S)), C !== void 0 && S >= C ? D.next(S - C) : (!$ && M(S), h);
|
|
811
811
|
}
|
|
812
812
|
};
|
|
813
813
|
}
|
|
@@ -847,7 +847,7 @@ function Vl(t, e) {
|
|
|
847
847
|
const n = t[t.length - 1];
|
|
848
848
|
for (let s = 1; s <= e; s++) {
|
|
849
849
|
const r = /* @__PURE__ */ vn(0, e, s);
|
|
850
|
-
t.push(
|
|
850
|
+
t.push(ft(n, 1, r));
|
|
851
851
|
}
|
|
852
852
|
}
|
|
853
853
|
function Rl(t) {
|
|
@@ -948,22 +948,22 @@ class mr extends fr {
|
|
|
948
948
|
const { generator: s, totalDuration: r, mixKeyframes: o, mirroredGenerator: i, resolvedDuration: a, calculatedDuration: c } = this;
|
|
949
949
|
if (this.startTime === null)
|
|
950
950
|
return s.next(0);
|
|
951
|
-
const { delay: u = 0, keyframes: l, repeat: d, repeatType: h, repeatDelay: p, type:
|
|
951
|
+
const { delay: u = 0, keyframes: l, repeat: d, repeatType: h, repeatDelay: p, type: T, onUpdate: w, finalKeyframe: b } = this.options;
|
|
952
952
|
this.speed > 0 ? this.startTime = Math.min(this.startTime, e) : this.speed < 0 && (this.startTime = Math.min(e - r / this.speed, this.startTime)), n ? this.currentTime = e : this.updateTime(e);
|
|
953
|
-
const
|
|
954
|
-
this.currentTime = Math.max(
|
|
955
|
-
let
|
|
953
|
+
const g = this.currentTime - u * (this.playbackSpeed >= 0 ? 1 : -1), v = this.playbackSpeed >= 0 ? g < 0 : g > r;
|
|
954
|
+
this.currentTime = Math.max(g, 0), this.state === "finished" && this.holdTime === null && (this.currentTime = r);
|
|
955
|
+
let y = this.currentTime, M = s;
|
|
956
956
|
if (d) {
|
|
957
957
|
const S = Math.min(this.currentTime, r) / a;
|
|
958
|
-
let $ = Math.floor(S),
|
|
959
|
-
!
|
|
958
|
+
let $ = Math.floor(S), L = S % 1;
|
|
959
|
+
!L && S >= 1 && (L = 1), L === 1 && $--, $ = Math.min($, d + 1), !!($ % 2) && (h === "reverse" ? (L = 1 - L, p && (L -= p / a)) : h === "mirror" && (M = i)), y = Zt(0, 1, L) * a;
|
|
960
960
|
}
|
|
961
|
-
const
|
|
962
|
-
o && (
|
|
963
|
-
let { done:
|
|
964
|
-
!
|
|
965
|
-
const
|
|
966
|
-
return
|
|
961
|
+
const C = v ? { done: !1, value: l[0] } : M.next(y);
|
|
962
|
+
o && (C.value = o(C.value));
|
|
963
|
+
let { done: D } = C;
|
|
964
|
+
!v && c !== null && (D = this.playbackSpeed >= 0 ? this.currentTime >= r : this.currentTime <= 0);
|
|
965
|
+
const E = this.holdTime === null && (this.state === "finished" || this.state === "running" && D);
|
|
966
|
+
return E && T !== Ds && (C.value = hr(l, this.options, b, this.speed)), w && w(C.value), E && this.finish(), C;
|
|
967
967
|
}
|
|
968
968
|
/**
|
|
969
969
|
* Allows the returned animation to be awaited or promise-chained. Currently
|
|
@@ -1164,7 +1164,7 @@ class pr {
|
|
|
1164
1164
|
this.state = "pending", this.isAsync = !1, this.needsMeasurement = !1, this.unresolvedKeyframes = [...e], this.onComplete = n, this.name = s, this.motionValue = r, this.element = o, this.isAsync = i;
|
|
1165
1165
|
}
|
|
1166
1166
|
scheduleResolve() {
|
|
1167
|
-
this.state = "scheduled", this.isAsync ? (Ne.add(this), Is || (Is = !0,
|
|
1167
|
+
this.state = "scheduled", this.isAsync ? (Ne.add(this), Is || (Is = !0, dt.read(Uo), dt.resolveKeyframes(zo))) : (this.readKeyframes(), this.complete());
|
|
1168
1168
|
}
|
|
1169
1169
|
readKeyframes() {
|
|
1170
1170
|
const { unresolvedKeyframes: e, name: n, element: s, motionValue: r } = this;
|
|
@@ -1443,7 +1443,7 @@ class du extends fr {
|
|
|
1443
1443
|
element: l,
|
|
1444
1444
|
...d
|
|
1445
1445
|
}, p = l?.KeyframeResolver || pr;
|
|
1446
|
-
this.keyframeResolver = new p(a, (
|
|
1446
|
+
this.keyframeResolver = new p(a, (T, w, b) => this.onKeyframesResolved(T, w, h, !b), c, u, l), this.keyframeResolver?.scheduleResolve();
|
|
1447
1447
|
}
|
|
1448
1448
|
onKeyframesResolved(e, n, s, r) {
|
|
1449
1449
|
this.keyframeResolver = void 0;
|
|
@@ -1643,17 +1643,17 @@ const xu = /\b([a-z-]*)\(.*?\)/gu, $s = {
|
|
|
1643
1643
|
}, wu = {
|
|
1644
1644
|
...yr,
|
|
1645
1645
|
// Color props
|
|
1646
|
-
color:
|
|
1647
|
-
backgroundColor:
|
|
1648
|
-
outlineColor:
|
|
1649
|
-
fill:
|
|
1650
|
-
stroke:
|
|
1646
|
+
color: xt,
|
|
1647
|
+
backgroundColor: xt,
|
|
1648
|
+
outlineColor: xt,
|
|
1649
|
+
fill: xt,
|
|
1650
|
+
stroke: xt,
|
|
1651
1651
|
// Border props
|
|
1652
|
-
borderColor:
|
|
1653
|
-
borderTopColor:
|
|
1654
|
-
borderRightColor:
|
|
1655
|
-
borderBottomColor:
|
|
1656
|
-
borderLeftColor:
|
|
1652
|
+
borderColor: xt,
|
|
1653
|
+
borderTopColor: xt,
|
|
1654
|
+
borderRightColor: xt,
|
|
1655
|
+
borderBottomColor: xt,
|
|
1656
|
+
borderLeftColor: xt,
|
|
1657
1657
|
filter: $s,
|
|
1658
1658
|
WebkitFilter: $s
|
|
1659
1659
|
}, Jo = (t) => wu[t];
|
|
@@ -1808,7 +1808,7 @@ class ku {
|
|
|
1808
1808
|
this.events[e] || (this.events[e] = new nr());
|
|
1809
1809
|
const s = this.events[e].add(n);
|
|
1810
1810
|
return e === "change" ? () => {
|
|
1811
|
-
s(),
|
|
1811
|
+
s(), dt.read(() => {
|
|
1812
1812
|
this.events.change.getSize() || this.stop();
|
|
1813
1813
|
});
|
|
1814
1814
|
} : s;
|
|
@@ -2026,8 +2026,8 @@ function Ru(t, e, n = {}) {
|
|
|
2026
2026
|
if (!ai(a))
|
|
2027
2027
|
return;
|
|
2028
2028
|
zn.add(c);
|
|
2029
|
-
const u = e(c, a), l = (p,
|
|
2030
|
-
window.removeEventListener("pointerup", d), window.removeEventListener("pointercancel", h), zn.has(c) && zn.delete(c), ai(p) && typeof u == "function" && u(p, { success:
|
|
2029
|
+
const u = e(c, a), l = (p, T) => {
|
|
2030
|
+
window.removeEventListener("pointerup", d), window.removeEventListener("pointercancel", h), zn.has(c) && zn.delete(c), ai(p) && typeof u == "function" && u(p, { success: T });
|
|
2031
2031
|
}, d = (p) => {
|
|
2032
2032
|
l(p, c === window || c === document || n.useGlobalTarget || sa(c, p.target));
|
|
2033
2033
|
}, h = (p) => {
|
|
@@ -2045,7 +2045,7 @@ function ra(t) {
|
|
|
2045
2045
|
function Iu(t) {
|
|
2046
2046
|
return ra(t) && t.tagName === "svg";
|
|
2047
2047
|
}
|
|
2048
|
-
const Ct = (t) => !!(t && t.getVelocity), Lu = [...Yo,
|
|
2048
|
+
const Ct = (t) => !!(t && t.getVelocity), Lu = [...Yo, xt, ge], Ou = (t) => Lu.find(Xo(t)), br = Ve({
|
|
2049
2049
|
transformPagePoint: (t) => t,
|
|
2050
2050
|
isStatic: !1,
|
|
2051
2051
|
reducedMotion: "never"
|
|
@@ -2093,7 +2093,7 @@ class Fu extends Ut.Component {
|
|
|
2093
2093
|
}
|
|
2094
2094
|
}
|
|
2095
2095
|
function Bu({ children: t, isPresent: e, anchorX: n, root: s }) {
|
|
2096
|
-
const r = qs(), o =
|
|
2096
|
+
const r = qs(), o = bt(null), i = bt({
|
|
2097
2097
|
width: 0,
|
|
2098
2098
|
height: 0,
|
|
2099
2099
|
top: 0,
|
|
@@ -2104,42 +2104,42 @@ function Bu({ children: t, isPresent: e, anchorX: n, root: s }) {
|
|
|
2104
2104
|
const { width: u, height: l, top: d, left: h, right: p } = i.current;
|
|
2105
2105
|
if (e || !o.current || !u || !l)
|
|
2106
2106
|
return;
|
|
2107
|
-
const
|
|
2107
|
+
const T = n === "left" ? `left: ${h}` : `right: ${p}`;
|
|
2108
2108
|
o.current.dataset.motionPopId = r;
|
|
2109
|
-
const
|
|
2110
|
-
a && (
|
|
2111
|
-
const
|
|
2112
|
-
return
|
|
2109
|
+
const w = document.createElement("style");
|
|
2110
|
+
a && (w.nonce = a);
|
|
2111
|
+
const b = s ?? document.head;
|
|
2112
|
+
return b.appendChild(w), w.sheet && w.sheet.insertRule(`
|
|
2113
2113
|
[data-motion-pop-id="${r}"] {
|
|
2114
2114
|
position: absolute !important;
|
|
2115
2115
|
width: ${u}px !important;
|
|
2116
2116
|
height: ${l}px !important;
|
|
2117
|
-
${
|
|
2117
|
+
${T}px !important;
|
|
2118
2118
|
top: ${d}px !important;
|
|
2119
2119
|
}
|
|
2120
2120
|
`), () => {
|
|
2121
|
-
|
|
2121
|
+
b.contains(w) && b.removeChild(w);
|
|
2122
2122
|
};
|
|
2123
2123
|
}, [e]), m(Fu, { isPresent: e, childRef: o, sizeRef: i, children: Ut.cloneElement(t, { ref: c }) });
|
|
2124
2124
|
}
|
|
2125
2125
|
const zu = ({ children: t, initial: e, isPresent: n, onExitComplete: s, custom: r, presenceAffectsLayout: o, mode: i, anchorX: a, root: c }) => {
|
|
2126
2126
|
const u = Js(Uu), l = qs();
|
|
2127
|
-
let d = !0, h =
|
|
2127
|
+
let d = !0, h = et(() => (d = !1, {
|
|
2128
2128
|
id: l,
|
|
2129
2129
|
initial: e,
|
|
2130
2130
|
isPresent: n,
|
|
2131
2131
|
custom: r,
|
|
2132
2132
|
onExitComplete: (p) => {
|
|
2133
2133
|
u.set(p, !0);
|
|
2134
|
-
for (const
|
|
2135
|
-
if (!
|
|
2134
|
+
for (const T of u.values())
|
|
2135
|
+
if (!T)
|
|
2136
2136
|
return;
|
|
2137
2137
|
s && s();
|
|
2138
2138
|
},
|
|
2139
2139
|
register: (p) => (u.set(p, !1), () => u.delete(p))
|
|
2140
2140
|
}), [n, u, s]);
|
|
2141
|
-
return o && d && (h = { ...h }),
|
|
2142
|
-
u.forEach((p,
|
|
2141
|
+
return o && d && (h = { ...h }), et(() => {
|
|
2142
|
+
u.forEach((p, T) => u.set(T, !1));
|
|
2143
2143
|
}, [n]), Ut.useEffect(() => {
|
|
2144
2144
|
!n && !u.size && s && s();
|
|
2145
2145
|
}, [n]), i === "popLayout" && (t = m(Bu, { isPresent: n, anchorX: a, root: c, children: t })), m(Zn.Provider, { value: h, children: t });
|
|
@@ -2152,7 +2152,7 @@ function ia(t = !0) {
|
|
|
2152
2152
|
if (e === null)
|
|
2153
2153
|
return [!0, null];
|
|
2154
2154
|
const { isPresent: n, onExitComplete: s, register: r } = e, o = qs();
|
|
2155
|
-
|
|
2155
|
+
st(() => {
|
|
2156
2156
|
if (t)
|
|
2157
2157
|
return r(o);
|
|
2158
2158
|
}, [t]);
|
|
@@ -2167,37 +2167,37 @@ function li(t) {
|
|
|
2167
2167
|
}), e;
|
|
2168
2168
|
}
|
|
2169
2169
|
const _u = ({ children: t, custom: e, initial: n = !0, onExitComplete: s, presenceAffectsLayout: r = !0, mode: o = "sync", propagate: i = !1, anchorX: a = "left", root: c }) => {
|
|
2170
|
-
const [u, l] = ia(i), d =
|
|
2170
|
+
const [u, l] = ia(i), d = et(() => li(t), [t]), h = i && !u ? [] : d.map(jn), p = bt(!0), T = bt(d), w = Js(() => /* @__PURE__ */ new Map()), [b, g] = W(d), [v, y] = W(d);
|
|
2171
2171
|
mo(() => {
|
|
2172
|
-
p.current = !1,
|
|
2173
|
-
for (let
|
|
2174
|
-
const
|
|
2175
|
-
h.includes(
|
|
2172
|
+
p.current = !1, T.current = d;
|
|
2173
|
+
for (let D = 0; D < v.length; D++) {
|
|
2174
|
+
const E = jn(v[D]);
|
|
2175
|
+
h.includes(E) ? w.delete(E) : w.get(E) !== !0 && w.set(E, !1);
|
|
2176
2176
|
}
|
|
2177
|
-
}, [
|
|
2177
|
+
}, [v, h.length, h.join("-")]);
|
|
2178
2178
|
const M = [];
|
|
2179
|
-
if (d !==
|
|
2180
|
-
let
|
|
2181
|
-
for (let
|
|
2182
|
-
const S =
|
|
2183
|
-
h.includes($) || (
|
|
2184
|
-
}
|
|
2185
|
-
return o === "wait" && M.length && (
|
|
2186
|
-
}
|
|
2187
|
-
process.env.NODE_ENV !== "production" && o === "wait" &&
|
|
2188
|
-
const { forceRender:
|
|
2189
|
-
return m(Fe, { children:
|
|
2190
|
-
const
|
|
2191
|
-
if (
|
|
2192
|
-
|
|
2179
|
+
if (d !== b) {
|
|
2180
|
+
let D = [...d];
|
|
2181
|
+
for (let E = 0; E < v.length; E++) {
|
|
2182
|
+
const S = v[E], $ = jn(S);
|
|
2183
|
+
h.includes($) || (D.splice(E, 0, S), M.push(S));
|
|
2184
|
+
}
|
|
2185
|
+
return o === "wait" && M.length && (D = M), y(li(D)), g(d), null;
|
|
2186
|
+
}
|
|
2187
|
+
process.env.NODE_ENV !== "production" && o === "wait" && v.length > 1 && console.warn(`You're attempting to animate multiple children within AnimatePresence, but its mode is set to "wait". This will lead to odd visual behaviour.`);
|
|
2188
|
+
const { forceRender: C } = St(Ys);
|
|
2189
|
+
return m(Fe, { children: v.map((D) => {
|
|
2190
|
+
const E = jn(D), S = i && !u ? !1 : d === v || h.includes(E), $ = () => {
|
|
2191
|
+
if (w.has(E))
|
|
2192
|
+
w.set(E, !0);
|
|
2193
2193
|
else
|
|
2194
2194
|
return;
|
|
2195
|
-
let
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
}),
|
|
2195
|
+
let L = !0;
|
|
2196
|
+
w.forEach((Y) => {
|
|
2197
|
+
Y || (L = !1);
|
|
2198
|
+
}), L && (C?.(), y(T.current), i && l?.(), s && s());
|
|
2199
2199
|
};
|
|
2200
|
-
return m(zu, { isPresent: S, initial: !p.current || n ? void 0 : !1, custom: e, presenceAffectsLayout: r, mode: o, root: c, onExitComplete: S ? void 0 : $, anchorX: a, children:
|
|
2200
|
+
return m(zu, { isPresent: S, initial: !p.current || n ? void 0 : !1, custom: e, presenceAffectsLayout: r, mode: o, root: c, onExitComplete: S ? void 0 : $, anchorX: a, children: D }, E);
|
|
2201
2201
|
}) });
|
|
2202
2202
|
}, wr = Ve({ strict: !1 }), ui = {
|
|
2203
2203
|
animation: [
|
|
@@ -2231,12 +2231,12 @@ function Fs(t) {
|
|
|
2231
2231
|
};
|
|
2232
2232
|
}
|
|
2233
2233
|
function Wu({ children: t, features: e, strict: n = !1 }) {
|
|
2234
|
-
const [, s] =
|
|
2234
|
+
const [, s] = W(!ps(e)), r = bt(void 0);
|
|
2235
2235
|
if (!ps(e)) {
|
|
2236
2236
|
const { renderer: o, ...i } = e;
|
|
2237
2237
|
r.current = o, Fs(i);
|
|
2238
2238
|
}
|
|
2239
|
-
return
|
|
2239
|
+
return st(() => {
|
|
2240
2240
|
ps(e) && e().then(({ renderer: o, ...i }) => {
|
|
2241
2241
|
Fs(i), r.current = o, s(!0);
|
|
2242
2242
|
});
|
|
@@ -2329,7 +2329,7 @@ function qu(t, e) {
|
|
|
2329
2329
|
}
|
|
2330
2330
|
function Xu(t) {
|
|
2331
2331
|
const { initial: e, animate: n } = qu(t, St(Qn));
|
|
2332
|
-
return
|
|
2332
|
+
return et(() => ({ initial: e, animate: n }), [di(e), di(n)]);
|
|
2333
2333
|
}
|
|
2334
2334
|
function di(t) {
|
|
2335
2335
|
return Array.isArray(t) ? t.join(" ") : t;
|
|
@@ -2399,7 +2399,7 @@ function la(t, e, n) {
|
|
|
2399
2399
|
!Ct(e[s]) && !ca(s, n) && (t[s] = e[s]);
|
|
2400
2400
|
}
|
|
2401
2401
|
function td({ transformTemplate: t }, e) {
|
|
2402
|
-
return
|
|
2402
|
+
return et(() => {
|
|
2403
2403
|
const n = Pr();
|
|
2404
2404
|
return Ar(n, e, t), Object.assign({}, n.vars, n.style);
|
|
2405
2405
|
}, [e]);
|
|
@@ -2449,7 +2449,7 @@ const da = () => ({
|
|
|
2449
2449
|
attrs: {}
|
|
2450
2450
|
}), ha = (t) => typeof t == "string" && t.toLowerCase() === "svg";
|
|
2451
2451
|
function od(t, e, n, s) {
|
|
2452
|
-
const r =
|
|
2452
|
+
const r = et(() => {
|
|
2453
2453
|
const o = da();
|
|
2454
2454
|
return ua(o, e, ha(s), t.transformTemplate, t.style), {
|
|
2455
2455
|
...o.attrs,
|
|
@@ -2510,7 +2510,7 @@ function Cr(t) {
|
|
|
2510
2510
|
);
|
|
2511
2511
|
}
|
|
2512
2512
|
function cd(t, e, n, { latestValues: s }, r, o = !1) {
|
|
2513
|
-
const a = (Cr(t) ? od : nd)(e, s, r, t), c = Hu(e, typeof t == "string", o), u = t !== io ? { ...c, ...a, ref: n } : {}, { children: l } = e, d =
|
|
2513
|
+
const a = (Cr(t) ? od : nd)(e, s, r, t), c = Hu(e, typeof t == "string", o), u = t !== io ? { ...c, ...a, ref: n } : {}, { children: l } = e, d = et(() => Ct(l) ? l.get() : l, [l]);
|
|
2514
2514
|
return yc(t, {
|
|
2515
2515
|
...u,
|
|
2516
2516
|
children: d
|
|
@@ -2555,19 +2555,19 @@ function ud(t, e, n, s) {
|
|
|
2555
2555
|
if (d && typeof d != "boolean" && !ts(d)) {
|
|
2556
2556
|
const h = Array.isArray(d) ? d : [d];
|
|
2557
2557
|
for (let p = 0; p < h.length; p++) {
|
|
2558
|
-
const
|
|
2559
|
-
if (
|
|
2560
|
-
const { transitionEnd:
|
|
2561
|
-
for (const
|
|
2562
|
-
let
|
|
2563
|
-
if (Array.isArray(
|
|
2564
|
-
const M = l ?
|
|
2565
|
-
|
|
2558
|
+
const T = kr(t, h[p]);
|
|
2559
|
+
if (T) {
|
|
2560
|
+
const { transitionEnd: w, transition: b, ...g } = T;
|
|
2561
|
+
for (const v in g) {
|
|
2562
|
+
let y = g[v];
|
|
2563
|
+
if (Array.isArray(y)) {
|
|
2564
|
+
const M = l ? y.length - 1 : 0;
|
|
2565
|
+
y = y[M];
|
|
2566
2566
|
}
|
|
2567
|
-
|
|
2567
|
+
y !== null && (r[v] = y);
|
|
2568
2568
|
}
|
|
2569
|
-
for (const
|
|
2570
|
-
r[
|
|
2569
|
+
for (const v in w)
|
|
2570
|
+
r[v] = w[v];
|
|
2571
2571
|
}
|
|
2572
2572
|
}
|
|
2573
2573
|
}
|
|
@@ -2617,7 +2617,7 @@ function md(t, e, n) {
|
|
|
2617
2617
|
}
|
|
2618
2618
|
const Dr = (t) => t.replace(/([a-z])([A-Z])/gu, "$1-$2").toLowerCase(), pd = "framerAppearId", pa = "data-" + Dr(pd), ga = Ve({});
|
|
2619
2619
|
function gd(t, e, n, s, r) {
|
|
2620
|
-
const { visualElement: o } = St(Qn), i = St(wr), a = St(Zn), c = St(br).reducedMotion, u =
|
|
2620
|
+
const { visualElement: o } = St(Qn), i = St(wr), a = St(Zn), c = St(br).reducedMotion, u = bt(null);
|
|
2621
2621
|
s = s || i.renderer, !u.current && s && (u.current = s(t, {
|
|
2622
2622
|
visualState: e,
|
|
2623
2623
|
parent: o,
|
|
@@ -2628,17 +2628,17 @@ function gd(t, e, n, s, r) {
|
|
|
2628
2628
|
}));
|
|
2629
2629
|
const l = u.current, d = St(ga);
|
|
2630
2630
|
l && !l.projection && r && (l.type === "html" || l.type === "svg") && yd(u.current, n, r, d);
|
|
2631
|
-
const h =
|
|
2631
|
+
const h = bt(!1);
|
|
2632
2632
|
ro(() => {
|
|
2633
2633
|
l && h.current && l.update(n, a);
|
|
2634
2634
|
});
|
|
2635
|
-
const p = n[pa],
|
|
2635
|
+
const p = n[pa], T = bt(!!p && !window.MotionHandoffIsComplete?.(p) && window.MotionHasOptimisedAnimation?.(p));
|
|
2636
2636
|
return mo(() => {
|
|
2637
|
-
l && (h.current = !0, window.MotionIsMounted = !0, l.updateFeatures(), l.scheduleRenderMicrotask(),
|
|
2638
|
-
}),
|
|
2639
|
-
l && (!
|
|
2637
|
+
l && (h.current = !0, window.MotionIsMounted = !0, l.updateFeatures(), l.scheduleRenderMicrotask(), T.current && l.animationState && l.animationState.animateChanges());
|
|
2638
|
+
}), st(() => {
|
|
2639
|
+
l && (!T.current && l.animationState && l.animationState.animateChanges(), T.current && (queueMicrotask(() => {
|
|
2640
2640
|
window.MotionHandoffMarkAsComplete?.(p);
|
|
2641
|
-
}),
|
|
2641
|
+
}), T.current = !1), l.enteringChildren = void 0);
|
|
2642
2642
|
}), l;
|
|
2643
2643
|
}
|
|
2644
2644
|
function yd(t, e, n, s) {
|
|
@@ -2678,10 +2678,10 @@ function _n(t, { forwardMotionProps: e = !1 } = {}, n, s) {
|
|
|
2678
2678
|
}, { isStatic: d } = l, h = Xu(a), p = r(a, d);
|
|
2679
2679
|
if (!d && Zs) {
|
|
2680
2680
|
xd(l, n);
|
|
2681
|
-
const
|
|
2682
|
-
u =
|
|
2681
|
+
const T = bd(l);
|
|
2682
|
+
u = T.MeasureLayout, h.visualElement = gd(t, p, l, s, T.ProjectionNode);
|
|
2683
2683
|
}
|
|
2684
|
-
return
|
|
2684
|
+
return R(Qn.Provider, { value: h, children: [u && h.visualElement ? m(u, { visualElement: h.visualElement, ...l }) : null, cd(t, a, md(p, h.visualElement, c), p, d, e)] });
|
|
2685
2685
|
}
|
|
2686
2686
|
o.displayName = `motion.${typeof t == "string" ? t : `create(${t.displayName ?? t.name ?? ""})`}`;
|
|
2687
2687
|
const i = vc(o);
|
|
@@ -2790,7 +2790,7 @@ function _e(t, e) {
|
|
|
2790
2790
|
t.min = t.min + e, t.max = t.max + e;
|
|
2791
2791
|
}
|
|
2792
2792
|
function yi(t, e, n, s, r = 0.5) {
|
|
2793
|
-
const o =
|
|
2793
|
+
const o = ft(t.min, t.max, r);
|
|
2794
2794
|
zs(t, e, n, o, s);
|
|
2795
2795
|
}
|
|
2796
2796
|
function We(t, e) {
|
|
@@ -2869,7 +2869,7 @@ class Dd {
|
|
|
2869
2869
|
this.current && (this.triggerBuild(), this.renderInstance(this.current, this.renderState, this.props.style, this.projection));
|
|
2870
2870
|
}, this.renderScheduledAt = 0, this.scheduleRender = () => {
|
|
2871
2871
|
const h = Nt.now();
|
|
2872
|
-
this.renderScheduledAt < h && (this.renderScheduledAt = h,
|
|
2872
|
+
this.renderScheduledAt < h && (this.renderScheduledAt = h, dt.render(this.render, !1, !0));
|
|
2873
2873
|
};
|
|
2874
2874
|
const { latestValues: c, renderState: u } = i;
|
|
2875
2875
|
this.latestValues = c, this.baseTarget = { ...c }, this.initialValues = n.initial ? { ...c } : {}, this.renderState = u, this.parent = e, this.props = n, this.presenceContext = s, this.depth = e ? e.depth + 1 : 0, this.reducedMotionConfig = r, this.options = a, this.blockInitialAnimation = !!o, this.isControllingVariants = es(n), this.isVariantNode = aa(n), this.isVariantNode && (this.variantChildren = /* @__PURE__ */ new Set()), this.manuallyAnimateOnMount = !!(e && e.current);
|
|
@@ -2903,7 +2903,7 @@ class Dd {
|
|
|
2903
2903
|
const s = Qe.has(e);
|
|
2904
2904
|
s && this.onBindTransform && this.onBindTransform();
|
|
2905
2905
|
const r = n.on("change", (i) => {
|
|
2906
|
-
this.latestValues[e] = i, this.props.onUpdate &&
|
|
2906
|
+
this.latestValues[e] = i, this.props.onUpdate && dt.preRender(this.notifyUpdate), s && this.projection && (this.projection.isTransformDirty = !0), this.scheduleRender();
|
|
2907
2907
|
});
|
|
2908
2908
|
let o;
|
|
2909
2909
|
window.MotionCheckAppearSync && (o = window.MotionCheckAppearSync(this, e, n)), this.valueSubscriptions.set(e, () => {
|
|
@@ -3256,7 +3256,7 @@ const Er = (t, e, n, s = {}, r, o) => (i) => {
|
|
|
3256
3256
|
if ((l.type === !1 || l.duration === 0 && !l.repeatDelay) && (js(l), l.delay === 0 && (d = !0)), (te.instantAnimations || te.skipAnimations) && (d = !0, js(l), l.delay = 0), l.allowFlatten = !a.type && !a.ease, d && !o && e.get() !== void 0) {
|
|
3257
3257
|
const h = Fd(l.keyframes, a);
|
|
3258
3258
|
if (h !== void 0) {
|
|
3259
|
-
|
|
3259
|
+
dt.update(() => {
|
|
3260
3260
|
l.onUpdate(h), l.onComplete();
|
|
3261
3261
|
});
|
|
3262
3262
|
return;
|
|
@@ -3279,23 +3279,23 @@ function Ma(t, e, { delay: n = 0, transitionOverride: s, type: r } = {}) {
|
|
|
3279
3279
|
const p = {
|
|
3280
3280
|
delay: n,
|
|
3281
3281
|
...gr(o || {}, l)
|
|
3282
|
-
},
|
|
3283
|
-
if (
|
|
3282
|
+
}, T = d.get();
|
|
3283
|
+
if (T !== void 0 && !d.isAnimating && !Array.isArray(h) && h === T && !p.velocity)
|
|
3284
3284
|
continue;
|
|
3285
|
-
let
|
|
3285
|
+
let w = !1;
|
|
3286
3286
|
if (window.MotionHandoffAnimation) {
|
|
3287
|
-
const
|
|
3288
|
-
if (
|
|
3289
|
-
const
|
|
3290
|
-
|
|
3287
|
+
const g = ka(t);
|
|
3288
|
+
if (g) {
|
|
3289
|
+
const v = window.MotionHandoffAnimation(g, l, dt);
|
|
3290
|
+
v !== null && (p.startTime = v, w = !0);
|
|
3291
3291
|
}
|
|
3292
3292
|
}
|
|
3293
|
-
Ws(t, l), d.start(Er(l, d, h, t.shouldReduceMotion && qo.has(l) ? { type: !1 } : p, t,
|
|
3294
|
-
const
|
|
3295
|
-
|
|
3293
|
+
Ws(t, l), d.start(Er(l, d, h, t.shouldReduceMotion && qo.has(l) ? { type: !1 } : p, t, w));
|
|
3294
|
+
const b = d.animation;
|
|
3295
|
+
b && c.push(b);
|
|
3296
3296
|
}
|
|
3297
3297
|
return i && Promise.all(c).then(() => {
|
|
3298
|
-
|
|
3298
|
+
dt.update(() => {
|
|
3299
3299
|
i && Od(t, i);
|
|
3300
3300
|
});
|
|
3301
3301
|
}), c;
|
|
@@ -3378,8 +3378,8 @@ function Qd(t) {
|
|
|
3378
3378
|
const r = (c) => (u, l) => {
|
|
3379
3379
|
const d = He(t, l, c === "exit" ? t.presenceContext?.custom : void 0);
|
|
3380
3380
|
if (d) {
|
|
3381
|
-
const { transition: h, transitionEnd: p, ...
|
|
3382
|
-
u = { ...u, ...
|
|
3381
|
+
const { transition: h, transitionEnd: p, ...T } = d;
|
|
3382
|
+
u = { ...u, ...T, ...p };
|
|
3383
3383
|
}
|
|
3384
3384
|
return u;
|
|
3385
3385
|
};
|
|
@@ -3388,68 +3388,68 @@ function Qd(t) {
|
|
|
3388
3388
|
}
|
|
3389
3389
|
function i(c) {
|
|
3390
3390
|
const { props: u } = t, l = Na(t.parent) || {}, d = [], h = /* @__PURE__ */ new Set();
|
|
3391
|
-
let p = {},
|
|
3392
|
-
for (let
|
|
3393
|
-
const
|
|
3394
|
-
|
|
3395
|
-
let
|
|
3396
|
-
if (
|
|
3397
|
-
!
|
|
3398
|
-
!
|
|
3399
|
-
ts(
|
|
3391
|
+
let p = {}, T = 1 / 0;
|
|
3392
|
+
for (let b = 0; b < Jd; b++) {
|
|
3393
|
+
const g = Yd[b], v = n[g], y = u[g] !== void 0 ? u[g] : l[g], M = wn(y), C = g === c ? v.isActive : null;
|
|
3394
|
+
C === !1 && (T = b);
|
|
3395
|
+
let D = y === l[g] && y !== u[g] && M;
|
|
3396
|
+
if (D && s && t.manuallyAnimateOnMount && (D = !1), v.protectedKeys = { ...p }, // If it isn't active and hasn't *just* been set as inactive
|
|
3397
|
+
!v.isActive && C === null || // If we didn't and don't have any defined prop for this animation type
|
|
3398
|
+
!y && !v.prevProp || // Or if the prop doesn't define an animation
|
|
3399
|
+
ts(y) || typeof y == "boolean")
|
|
3400
3400
|
continue;
|
|
3401
|
-
const
|
|
3402
|
-
let S =
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
const
|
|
3406
|
-
let
|
|
3407
|
-
|
|
3408
|
-
const { prevResolvedValues:
|
|
3409
|
-
...
|
|
3410
|
-
...
|
|
3411
|
-
},
|
|
3412
|
-
S = !0, h.has(
|
|
3413
|
-
const
|
|
3414
|
-
|
|
3401
|
+
const E = th(v.prevProp, y);
|
|
3402
|
+
let S = E || // If we're making this variant active, we want to always make it active
|
|
3403
|
+
g === c && v.isActive && !D && M || // If we removed a higher-priority variant (i is in reverse order)
|
|
3404
|
+
b > T && M, $ = !1;
|
|
3405
|
+
const L = Array.isArray(y) ? y : [y];
|
|
3406
|
+
let Y = L.reduce(r(g), {});
|
|
3407
|
+
C === !1 && (Y = {});
|
|
3408
|
+
const { prevResolvedValues: J = {} } = v, H = {
|
|
3409
|
+
...J,
|
|
3410
|
+
...Y
|
|
3411
|
+
}, q = (Z) => {
|
|
3412
|
+
S = !0, h.has(Z) && ($ = !0, h.delete(Z)), v.needsAnimating[Z] = !0;
|
|
3413
|
+
const it = t.getValue(Z);
|
|
3414
|
+
it && (it.liveStyle = !1);
|
|
3415
3415
|
};
|
|
3416
|
-
for (const
|
|
3417
|
-
const
|
|
3418
|
-
if (p.hasOwnProperty(
|
|
3416
|
+
for (const Z in H) {
|
|
3417
|
+
const it = Y[Z], lt = J[Z];
|
|
3418
|
+
if (p.hasOwnProperty(Z))
|
|
3419
3419
|
continue;
|
|
3420
3420
|
let ot = !1;
|
|
3421
|
-
_s(
|
|
3421
|
+
_s(it) && _s(lt) ? ot = !Ea(it, lt) : ot = it !== lt, ot ? it != null ? q(Z) : h.add(Z) : it !== void 0 && h.has(Z) ? q(Z) : v.protectedKeys[Z] = !0;
|
|
3422
3422
|
}
|
|
3423
|
-
|
|
3424
|
-
const
|
|
3425
|
-
S && (!
|
|
3426
|
-
const
|
|
3427
|
-
if (typeof
|
|
3428
|
-
const { parent:
|
|
3429
|
-
if (
|
|
3423
|
+
v.prevProp = y, v.prevResolvedValues = Y, v.isActive && (p = { ...p, ...Y }), s && t.blockInitialAnimation && (S = !1);
|
|
3424
|
+
const ct = D && E;
|
|
3425
|
+
S && (!ct || $) && d.push(...L.map((Z) => {
|
|
3426
|
+
const it = { type: g };
|
|
3427
|
+
if (typeof Z == "string" && s && !ct && t.manuallyAnimateOnMount && t.parent) {
|
|
3428
|
+
const { parent: lt } = t, ot = He(lt, Z);
|
|
3429
|
+
if (lt.enteringChildren && ot) {
|
|
3430
3430
|
const { delayChildren: ee } = ot.transition || {};
|
|
3431
|
-
|
|
3431
|
+
it.delay = Da(lt.enteringChildren, t, ee);
|
|
3432
3432
|
}
|
|
3433
3433
|
}
|
|
3434
3434
|
return {
|
|
3435
|
-
animation:
|
|
3436
|
-
options:
|
|
3435
|
+
animation: Z,
|
|
3436
|
+
options: it
|
|
3437
3437
|
};
|
|
3438
3438
|
}));
|
|
3439
3439
|
}
|
|
3440
3440
|
if (h.size) {
|
|
3441
|
-
const
|
|
3441
|
+
const b = {};
|
|
3442
3442
|
if (typeof u.initial != "boolean") {
|
|
3443
|
-
const
|
|
3444
|
-
|
|
3443
|
+
const g = He(t, Array.isArray(u.initial) ? u.initial[0] : u.initial);
|
|
3444
|
+
g && g.transition && (b.transition = g.transition);
|
|
3445
3445
|
}
|
|
3446
|
-
h.forEach((
|
|
3447
|
-
const
|
|
3448
|
-
|
|
3449
|
-
}), d.push({ animation:
|
|
3446
|
+
h.forEach((g) => {
|
|
3447
|
+
const v = t.getBaseTarget(g), y = t.getValue(g);
|
|
3448
|
+
y && (y.liveStyle = !0), b[g] = v ?? null;
|
|
3449
|
+
}), d.push({ animation: b });
|
|
3450
3450
|
}
|
|
3451
|
-
let
|
|
3452
|
-
return s && (u.initial === !1 || u.initial === u.animate) && !t.manuallyAnimateOnMount && (
|
|
3451
|
+
let w = !!d.length;
|
|
3452
|
+
return s && (u.initial === !1 || u.initial === u.animate) && !t.manuallyAnimateOnMount && (w = !1), s = !1, w ? e(d) : Promise.resolve();
|
|
3453
3453
|
}
|
|
3454
3454
|
function a(c, u) {
|
|
3455
3455
|
if (n[c].isActive === u)
|
|
@@ -3580,7 +3580,7 @@ function lh(t, e, n) {
|
|
|
3580
3580
|
return Math.abs(t - e) <= n;
|
|
3581
3581
|
}
|
|
3582
3582
|
function Ti(t, e, n, s = 0.5) {
|
|
3583
|
-
t.origin = s, t.originPoint =
|
|
3583
|
+
t.origin = s, t.originPoint = ft(e.min, e.max, t.origin), t.scale = Mt(n) / Mt(e), t.translate = ft(n.min, n.max, t.origin) - t.originPoint, (t.scale >= ih && t.scale <= oh || isNaN(t.scale)) && (t.scale = 1), (t.translate >= ah && t.translate <= ch || isNaN(t.translate)) && (t.translate = 0);
|
|
3584
3584
|
}
|
|
3585
3585
|
function fn(t, e, n, s) {
|
|
3586
3586
|
Ti(t.x, e.x, n.x, s ? s.originX : void 0), Ti(t.y, e.y, n.y, s ? s.originY : void 0);
|
|
@@ -3610,22 +3610,22 @@ class Oa {
|
|
|
3610
3610
|
if (this.startEvent = null, this.lastMoveEvent = null, this.lastMoveEventInfo = null, this.handlers = {}, this.contextWindow = window, this.updatePoint = () => {
|
|
3611
3611
|
if (!(this.lastMoveEvent && this.lastMoveEventInfo))
|
|
3612
3612
|
return;
|
|
3613
|
-
const h = vs(this.lastMoveEventInfo, this.history), p = this.startEvent !== null,
|
|
3614
|
-
if (!p && !
|
|
3613
|
+
const h = vs(this.lastMoveEventInfo, this.history), p = this.startEvent !== null, T = dh(h.offset, { x: 0, y: 0 }) >= this.distanceThreshold;
|
|
3614
|
+
if (!p && !T)
|
|
3615
3615
|
return;
|
|
3616
|
-
const { point:
|
|
3617
|
-
this.history.push({ ...
|
|
3618
|
-
const { onStart:
|
|
3619
|
-
p || (
|
|
3616
|
+
const { point: w } = h, { timestamp: b } = Tt;
|
|
3617
|
+
this.history.push({ ...w, timestamp: b });
|
|
3618
|
+
const { onStart: g, onMove: v } = this.handlers;
|
|
3619
|
+
p || (g && g(this.lastMoveEvent, h), this.startEvent = this.lastMoveEvent), v && v(this.lastMoveEvent, h);
|
|
3620
3620
|
}, this.handlePointerMove = (h, p) => {
|
|
3621
|
-
this.lastMoveEvent = h, this.lastMoveEventInfo = ys(p, this.transformPagePoint),
|
|
3621
|
+
this.lastMoveEvent = h, this.lastMoveEventInfo = ys(p, this.transformPagePoint), dt.update(this.updatePoint, !0);
|
|
3622
3622
|
}, this.handlePointerUp = (h, p) => {
|
|
3623
3623
|
this.end();
|
|
3624
|
-
const { onEnd:
|
|
3625
|
-
if (this.dragSnapToOrigin &&
|
|
3624
|
+
const { onEnd: T, onSessionEnd: w, resumeAnimation: b } = this.handlers;
|
|
3625
|
+
if (this.dragSnapToOrigin && b && b(), !(this.lastMoveEvent && this.lastMoveEventInfo))
|
|
3626
3626
|
return;
|
|
3627
|
-
const
|
|
3628
|
-
this.startEvent &&
|
|
3627
|
+
const g = vs(h.type === "pointercancel" ? this.lastMoveEventInfo : ys(p, this.transformPagePoint), this.history);
|
|
3628
|
+
this.startEvent && T && T(h, g), w && w(h, g);
|
|
3629
3629
|
}, !xr(e))
|
|
3630
3630
|
return;
|
|
3631
3631
|
this.dragSnapToOrigin = o, this.handlers = n, this.transformPagePoint = s, this.distanceThreshold = i, this.contextWindow = r || window;
|
|
@@ -3680,7 +3680,7 @@ function fh(t, e) {
|
|
|
3680
3680
|
return i.x === 1 / 0 && (i.x = 0), i.y === 1 / 0 && (i.y = 0), i;
|
|
3681
3681
|
}
|
|
3682
3682
|
function mh(t, { min: e, max: n }, s) {
|
|
3683
|
-
return e !== void 0 && t < e ? t = s ?
|
|
3683
|
+
return e !== void 0 && t < e ? t = s ? ft(e, t, s.min) : Math.max(t, e) : n !== void 0 && t > n && (t = s ? ft(n, t, s.max) : Math.min(t, n)), t;
|
|
3684
3684
|
}
|
|
3685
3685
|
function ki(t, e, n) {
|
|
3686
3686
|
return {
|
|
@@ -3742,33 +3742,33 @@ class wh {
|
|
|
3742
3742
|
const { dragSnapToOrigin: h } = this.getProps();
|
|
3743
3743
|
h ? this.pauseAnimation() : this.stopAnimation(), n && this.snapToCursor(Mn(d).point);
|
|
3744
3744
|
}, i = (d, h) => {
|
|
3745
|
-
const { drag: p, dragPropagation:
|
|
3746
|
-
if (p && !
|
|
3745
|
+
const { drag: p, dragPropagation: T, onDragStart: w } = this.getProps();
|
|
3746
|
+
if (p && !T && (this.openDragLock && this.openDragLock(), this.openDragLock = Mu(p), !this.openDragLock))
|
|
3747
3747
|
return;
|
|
3748
|
-
this.latestPointerEvent = d, this.latestPanInfo = h, this.isDragging = !0, this.currentDirection = null, this.resolveConstraints(), this.visualElement.projection && (this.visualElement.projection.isAnimationBlocked = !0, this.visualElement.projection.target = void 0), Lt((
|
|
3749
|
-
let
|
|
3750
|
-
if (Ht.test(
|
|
3751
|
-
const { projection:
|
|
3752
|
-
if (
|
|
3753
|
-
const M =
|
|
3754
|
-
M && (
|
|
3748
|
+
this.latestPointerEvent = d, this.latestPanInfo = h, this.isDragging = !0, this.currentDirection = null, this.resolveConstraints(), this.visualElement.projection && (this.visualElement.projection.isAnimationBlocked = !0, this.visualElement.projection.target = void 0), Lt((g) => {
|
|
3749
|
+
let v = this.getAxisMotionValue(g).get() || 0;
|
|
3750
|
+
if (Ht.test(v)) {
|
|
3751
|
+
const { projection: y } = this.visualElement;
|
|
3752
|
+
if (y && y.layout) {
|
|
3753
|
+
const M = y.layout.layoutBox[g];
|
|
3754
|
+
M && (v = Mt(M) * (parseFloat(v) / 100));
|
|
3755
3755
|
}
|
|
3756
3756
|
}
|
|
3757
|
-
this.originPoint[
|
|
3758
|
-
}),
|
|
3759
|
-
const { animationState:
|
|
3760
|
-
|
|
3757
|
+
this.originPoint[g] = v;
|
|
3758
|
+
}), w && dt.postRender(() => w(d, h)), Ws(this.visualElement, "transform");
|
|
3759
|
+
const { animationState: b } = this.visualElement;
|
|
3760
|
+
b && b.setActive("whileDrag", !0);
|
|
3761
3761
|
}, a = (d, h) => {
|
|
3762
3762
|
this.latestPointerEvent = d, this.latestPanInfo = h;
|
|
3763
|
-
const { dragPropagation: p, dragDirectionLock:
|
|
3763
|
+
const { dragPropagation: p, dragDirectionLock: T, onDirectionLock: w, onDrag: b } = this.getProps();
|
|
3764
3764
|
if (!p && !this.openDragLock)
|
|
3765
3765
|
return;
|
|
3766
|
-
const { offset:
|
|
3767
|
-
if (
|
|
3768
|
-
this.currentDirection = Th(
|
|
3766
|
+
const { offset: g } = h;
|
|
3767
|
+
if (T && this.currentDirection === null) {
|
|
3768
|
+
this.currentDirection = Th(g), this.currentDirection !== null && w && w(this.currentDirection);
|
|
3769
3769
|
return;
|
|
3770
3770
|
}
|
|
3771
|
-
this.updateAxis("x", h.point,
|
|
3771
|
+
this.updateAxis("x", h.point, g), this.updateAxis("y", h.point, g), this.visualElement.render(), b && b(d, h);
|
|
3772
3772
|
}, c = (d, h) => {
|
|
3773
3773
|
this.latestPointerEvent = d, this.latestPanInfo = h, this.stop(d, h), this.latestPointerEvent = null, this.latestPanInfo = null;
|
|
3774
3774
|
}, u = () => Lt((d) => this.getAnimationState(d) === "paused" && this.getAxisMotionValue(d).animation?.play()), { dragSnapToOrigin: l } = this.getProps();
|
|
@@ -3795,7 +3795,7 @@ class wh {
|
|
|
3795
3795
|
const { velocity: i } = r;
|
|
3796
3796
|
this.startAnimation(i);
|
|
3797
3797
|
const { onDragEnd: a } = this.getProps();
|
|
3798
|
-
a &&
|
|
3798
|
+
a && dt.postRender(() => a(s, r));
|
|
3799
3799
|
}
|
|
3800
3800
|
/**
|
|
3801
3801
|
* @internal
|
|
@@ -3844,7 +3844,7 @@ class wh {
|
|
|
3844
3844
|
return;
|
|
3845
3845
|
let d = c && c[l] || {};
|
|
3846
3846
|
i && (d = { min: 0, max: 0 });
|
|
3847
|
-
const h = r ? 200 : 1e6, p = r ? 40 : 1e7,
|
|
3847
|
+
const h = r ? 200 : 1e6, p = r ? 40 : 1e7, T = {
|
|
3848
3848
|
type: "inertia",
|
|
3849
3849
|
velocity: s ? e[l] : 0,
|
|
3850
3850
|
bounceStiffness: h,
|
|
@@ -3855,7 +3855,7 @@ class wh {
|
|
|
3855
3855
|
...o,
|
|
3856
3856
|
...d
|
|
3857
3857
|
};
|
|
3858
|
-
return this.startAxisValueAnimation(l,
|
|
3858
|
+
return this.startAxisValueAnimation(l, T);
|
|
3859
3859
|
});
|
|
3860
3860
|
return Promise.all(u).then(a);
|
|
3861
3861
|
}
|
|
@@ -3890,7 +3890,7 @@ class wh {
|
|
|
3890
3890
|
const { projection: r } = this.visualElement, o = this.getAxisMotionValue(n);
|
|
3891
3891
|
if (r && r.layout) {
|
|
3892
3892
|
const { min: i, max: a } = r.layout.layoutBox[n];
|
|
3893
|
-
o.set(e[n] -
|
|
3893
|
+
o.set(e[n] - ft(i, a, 0.5));
|
|
3894
3894
|
}
|
|
3895
3895
|
});
|
|
3896
3896
|
}
|
|
@@ -3919,7 +3919,7 @@ class wh {
|
|
|
3919
3919
|
if (!$n(i, e, null))
|
|
3920
3920
|
return;
|
|
3921
3921
|
const a = this.getAxisMotionValue(i), { min: c, max: u } = this.constraints[i];
|
|
3922
|
-
a.set(
|
|
3922
|
+
a.set(ft(c, u, r[i]));
|
|
3923
3923
|
});
|
|
3924
3924
|
}
|
|
3925
3925
|
addListeners() {
|
|
@@ -3933,7 +3933,7 @@ class wh {
|
|
|
3933
3933
|
const { dragConstraints: c } = this.getProps();
|
|
3934
3934
|
Ue(c) && c.current && (this.constraints = this.resolveRefConstraints());
|
|
3935
3935
|
}, { projection: r } = this.visualElement, o = r.addEventListener("measure", s);
|
|
3936
|
-
r && !r.layout && (r.root && r.root.updateScroll(), r.updateLayout()),
|
|
3936
|
+
r && !r.layout && (r.root && r.root.updateScroll(), r.updateLayout()), dt.read(s);
|
|
3937
3937
|
const i = Sn(window, "resize", () => this.scalePositionWithinConstraints()), a = r.addEventListener("didUpdate", ({ delta: c, hasLayoutChanged: u }) => {
|
|
3938
3938
|
this.isDragging && u && (Lt((l) => {
|
|
3939
3939
|
const d = this.getAxisMotionValue(l);
|
|
@@ -3977,7 +3977,7 @@ class Sh extends ye {
|
|
|
3977
3977
|
}
|
|
3978
3978
|
}
|
|
3979
3979
|
const Ni = (t) => (e, n) => {
|
|
3980
|
-
t &&
|
|
3980
|
+
t && dt.postRender(() => t(e, n));
|
|
3981
3981
|
};
|
|
3982
3982
|
class Ah extends ye {
|
|
3983
3983
|
constructor() {
|
|
@@ -3996,7 +3996,7 @@ class Ah extends ye {
|
|
|
3996
3996
|
onStart: Ni(n),
|
|
3997
3997
|
onMove: s,
|
|
3998
3998
|
onEnd: (o, i) => {
|
|
3999
|
-
delete this.session, r &&
|
|
3999
|
+
delete this.session, r && dt.postRender(() => r(o, i));
|
|
4000
4000
|
}
|
|
4001
4001
|
};
|
|
4002
4002
|
}
|
|
@@ -4044,7 +4044,7 @@ const ln = {
|
|
|
4044
4044
|
return s;
|
|
4045
4045
|
const o = ge.createTransformer(t), i = typeof r[0] != "number" ? 1 : 0, a = n.x.scale * e.x, c = n.y.scale * e.y;
|
|
4046
4046
|
r[0 + i] /= a, r[1 + i] /= c;
|
|
4047
|
-
const u =
|
|
4047
|
+
const u = ft(a, c, 0.5);
|
|
4048
4048
|
return typeof r[2 + i] == "number" && (r[2 + i] /= u), typeof r[3 + i] == "number" && (r[3 + i] /= u), o(r);
|
|
4049
4049
|
}
|
|
4050
4050
|
};
|
|
@@ -4066,7 +4066,7 @@ class Ch extends xc {
|
|
|
4066
4066
|
}
|
|
4067
4067
|
getSnapshotBeforeUpdate(e) {
|
|
4068
4068
|
const { layoutDependency: n, visualElement: s, drag: r, isPresent: o } = this.props, { projection: i } = s;
|
|
4069
|
-
return i && (i.isPresent = o, xs = !0, r || e.layoutDependency !== n || n === void 0 || e.isPresent !== o ? i.willUpdate() : this.safeToRemove(), e.isPresent !== o && (o ? i.promote() : i.relegate() ||
|
|
4069
|
+
return i && (i.isPresent = o, xs = !0, r || e.layoutDependency !== n || n === void 0 || e.isPresent !== o ? i.willUpdate() : this.safeToRemove(), e.isPresent !== o && (o ? i.promote() : i.relegate() || dt.postRender(() => {
|
|
4070
4070
|
const a = i.getStack();
|
|
4071
4071
|
(!a || !a.members.length) && this.safeToRemove();
|
|
4072
4072
|
}))), null;
|
|
@@ -4133,19 +4133,19 @@ function Nh(t, e) {
|
|
|
4133
4133
|
const o = r - n;
|
|
4134
4134
|
o >= e && (pe(s), t(o - e));
|
|
4135
4135
|
};
|
|
4136
|
-
return
|
|
4136
|
+
return dt.setup(s, !0), () => pe(s);
|
|
4137
4137
|
}
|
|
4138
4138
|
const Fa = ["TopLeft", "TopRight", "BottomLeft", "BottomRight"], Vh = Fa.length, Ri = (t) => typeof t == "string" ? parseFloat(t) : t, Ii = (t) => typeof t == "number" || z.test(t);
|
|
4139
4139
|
function Rh(t, e, n, s, r, o) {
|
|
4140
|
-
r ? (t.opacity =
|
|
4140
|
+
r ? (t.opacity = ft(0, n.opacity ?? 1, Ih(s)), t.opacityExit = ft(e.opacity ?? 1, 0, Lh(s))) : o && (t.opacity = ft(e.opacity ?? 1, n.opacity ?? 1, s));
|
|
4141
4141
|
for (let i = 0; i < Vh; i++) {
|
|
4142
4142
|
const a = `border${Fa[i]}Radius`;
|
|
4143
4143
|
let c = Li(e, a), u = Li(n, a);
|
|
4144
4144
|
if (c === void 0 && u === void 0)
|
|
4145
4145
|
continue;
|
|
4146
|
-
c || (c = 0), u || (u = 0), c === 0 || u === 0 || Ii(c) === Ii(u) ? (t[a] = Math.max(
|
|
4146
|
+
c || (c = 0), u || (u = 0), c === 0 || u === 0 || Ii(c) === Ii(u) ? (t[a] = Math.max(ft(Ri(c), Ri(u), s), 0), (Ht.test(u) || Ht.test(c)) && (t[a] += "%")) : t[a] = u;
|
|
4147
4147
|
}
|
|
4148
|
-
(e.rotate || n.rotate) && (t.rotate =
|
|
4148
|
+
(e.rotate || n.rotate) && (t.rotate = ft(e.rotate || 0, n.rotate || 0, s));
|
|
4149
4149
|
}
|
|
4150
4150
|
function Li(t, e) {
|
|
4151
4151
|
return t[e] !== void 0 ? t[e] : t.borderRadius;
|
|
@@ -4167,9 +4167,9 @@ function $i(t, e, n, s, r) {
|
|
|
4167
4167
|
return t -= e, t = Jn(t, 1 / n, s), r !== void 0 && (t = Jn(t, 1 / r, s)), t;
|
|
4168
4168
|
}
|
|
4169
4169
|
function Oh(t, e = 0, n = 1, s = 0.5, r, o = t, i = t) {
|
|
4170
|
-
if (Ht.test(e) && (e = parseFloat(e), e =
|
|
4170
|
+
if (Ht.test(e) && (e = parseFloat(e), e = ft(i.min, i.max, e / 100) - i.min), typeof e != "number")
|
|
4171
4171
|
return;
|
|
4172
|
-
let a =
|
|
4172
|
+
let a = ft(o.min, o.max, s);
|
|
4173
4173
|
t === o && (a -= e), t.min = $i(t.min, e, n, a, r), t.max = $i(t.max, e, n, a, r);
|
|
4174
4174
|
}
|
|
4175
4175
|
function Fi(t, e, [n, s, r], o, i) {
|
|
@@ -4261,8 +4261,8 @@ function zh(t, e, n) {
|
|
|
4261
4261
|
let s = "";
|
|
4262
4262
|
const r = t.x.translate / e.x, o = t.y.translate / e.y, i = n?.z || 0;
|
|
4263
4263
|
if ((r || o || i) && (s = `translate3d(${r}px, ${o}px, ${i}px) `), (e.x !== 1 || e.y !== 1) && (s += `scale(${1 / e.x}, ${1 / e.y}) `), n) {
|
|
4264
|
-
const { transformPerspective: u, rotate: l, rotateX: d, rotateY: h, skewX: p, skewY:
|
|
4265
|
-
u && (s = `perspective(${u}px) ${s}`), l && (s += `rotate(${l}deg) `), d && (s += `rotateX(${d}deg) `), h && (s += `rotateY(${h}deg) `), p && (s += `skewX(${p}deg) `),
|
|
4264
|
+
const { transformPerspective: u, rotate: l, rotateX: d, rotateY: h, skewX: p, skewY: T } = n;
|
|
4265
|
+
u && (s = `perspective(${u}px) ${s}`), l && (s += `rotate(${l}deg) `), d && (s += `rotateX(${d}deg) `), h && (s += `rotateY(${h}deg) `), p && (s += `skewX(${p}deg) `), T && (s += `skewY(${T}deg) `);
|
|
4266
4266
|
}
|
|
4267
4267
|
const a = t.x.scale * e.x, c = t.y.scale * e.y;
|
|
4268
4268
|
return (a !== 1 || c !== 1) && (s += `scale(${a}, ${c})`), s || "none";
|
|
@@ -4282,7 +4282,7 @@ function _a(t) {
|
|
|
4282
4282
|
const n = ka(e);
|
|
4283
4283
|
if (window.MotionHasOptimisedAnimation(n, "transform")) {
|
|
4284
4284
|
const { layout: r, layoutId: o } = t.options;
|
|
4285
|
-
window.MotionCancelOptimisedAnimation(n, "transform",
|
|
4285
|
+
window.MotionCancelOptimisedAnimation(n, "transform", dt, !(r || o));
|
|
4286
4286
|
}
|
|
4287
4287
|
const { parent: s } = t;
|
|
4288
4288
|
s && !s.hasCheckedOptimisedAppear && _a(s);
|
|
@@ -4320,7 +4320,7 @@ function Wa({ attachResizeListener: t, defaultParent: e, measureScroll: n, check
|
|
|
4320
4320
|
if (u && !u.current && u.mount(i), this.root.nodes.add(this), this.parent && this.parent.children.add(this), this.root.hasTreeAnimated && (c || a) && (this.isLayoutDirty = !0), t) {
|
|
4321
4321
|
let l, d = 0;
|
|
4322
4322
|
const h = () => this.root.updateBlockedByResize = !1;
|
|
4323
|
-
|
|
4323
|
+
dt.read(() => {
|
|
4324
4324
|
d = window.innerWidth;
|
|
4325
4325
|
}), t(i, () => {
|
|
4326
4326
|
const p = window.innerWidth;
|
|
@@ -4332,15 +4332,15 @@ function Wa({ attachResizeListener: t, defaultParent: e, measureScroll: n, check
|
|
|
4332
4332
|
this.target = void 0, this.relativeTarget = void 0;
|
|
4333
4333
|
return;
|
|
4334
4334
|
}
|
|
4335
|
-
const
|
|
4336
|
-
if (this.options.layoutRoot || this.resumeFrom ||
|
|
4335
|
+
const T = this.options.transition || u.getDefaultTransition() || nf, { onLayoutAnimationStart: w, onLayoutAnimationComplete: b } = u.getProps(), g = !this.targetLayout || !Ua(this.targetLayout, p), v = !d && h;
|
|
4336
|
+
if (this.options.layoutRoot || this.resumeFrom || v || d && (g || !this.currentAnimation)) {
|
|
4337
4337
|
this.resumeFrom && (this.resumingFrom = this.resumeFrom, this.resumingFrom.resumingFrom = void 0);
|
|
4338
|
-
const
|
|
4339
|
-
...gr(
|
|
4340
|
-
onPlay:
|
|
4341
|
-
onComplete:
|
|
4338
|
+
const y = {
|
|
4339
|
+
...gr(T, "layout"),
|
|
4340
|
+
onPlay: w,
|
|
4341
|
+
onComplete: b
|
|
4342
4342
|
};
|
|
4343
|
-
(u.shouldReduceMotion || this.options.layoutRoot) && (
|
|
4343
|
+
(u.shouldReduceMotion || this.options.layoutRoot) && (y.delay = 0, y.type = !1), this.startAnimation(y), this.setAnimationOrigin(l, v);
|
|
4344
4344
|
} else
|
|
4345
4345
|
d || qi(this), this.isLead() && this.options.onExitComplete && this.options.onExitComplete();
|
|
4346
4346
|
this.targetLayout = p;
|
|
@@ -4410,10 +4410,10 @@ function Wa({ attachResizeListener: t, defaultParent: e, measureScroll: n, check
|
|
|
4410
4410
|
this.nodes.forEach(qh), this.sharedNodes.forEach(Qh);
|
|
4411
4411
|
}
|
|
4412
4412
|
scheduleUpdateProjection() {
|
|
4413
|
-
this.projectionUpdateScheduled || (this.projectionUpdateScheduled = !0,
|
|
4413
|
+
this.projectionUpdateScheduled || (this.projectionUpdateScheduled = !0, dt.preRender(this.updateProjection, !1, !0));
|
|
4414
4414
|
}
|
|
4415
4415
|
scheduleCheckAfterUnmount() {
|
|
4416
|
-
|
|
4416
|
+
dt.postRender(() => {
|
|
4417
4417
|
this.isLayoutDirty ? this.root.didUpdate() : this.root.checkUpdateFailed();
|
|
4418
4418
|
});
|
|
4419
4419
|
}
|
|
@@ -4589,16 +4589,16 @@ function Wa({ attachResizeListener: t, defaultParent: e, measureScroll: n, check
|
|
|
4589
4589
|
setAnimationOrigin(i, a = !1) {
|
|
4590
4590
|
const c = this.snapshot, u = c ? c.latestValues : {}, l = { ...this.latestValues }, d = Ke();
|
|
4591
4591
|
(!this.relativeParent || !this.relativeParent.options.layoutRoot) && (this.relativeTarget = this.relativeTargetOrigin = void 0), this.attemptToResolveRelativeTarget = !a;
|
|
4592
|
-
const h = gt(), p = c ? c.source : void 0,
|
|
4592
|
+
const h = gt(), p = c ? c.source : void 0, T = this.layout ? this.layout.source : void 0, w = p !== T, b = this.getStack(), g = !b || b.members.length <= 1, v = !!(w && !g && this.options.crossfade === !0 && !this.path.some(ef));
|
|
4593
4593
|
this.animationProgress = 0;
|
|
4594
|
-
let
|
|
4594
|
+
let y;
|
|
4595
4595
|
this.mixTargetDelta = (M) => {
|
|
4596
|
-
const
|
|
4597
|
-
Xi(d.x, i.x,
|
|
4596
|
+
const C = M / 1e3;
|
|
4597
|
+
Xi(d.x, i.x, C), Xi(d.y, i.y, C), this.setTargetDelta(d), this.relativeTarget && this.relativeTargetOrigin && this.layout && this.relativeParent && this.relativeParent.layout && (mn(h, this.layout.layoutBox, this.relativeParent.layout.layoutBox), tf(this.relativeTarget, this.relativeTargetOrigin, h, C), y && Fh(this.relativeTarget, y) && (this.isProjectionDirty = !1), y || (y = gt()), It(y, this.relativeTarget)), w && (this.animationValues = l, Rh(l, u, this.latestValues, C, v, g)), this.root.scheduleUpdateProjection(), this.scheduleRender(), this.animationProgress = C;
|
|
4598
4598
|
}, this.mixTargetDelta(this.options.layoutRoot ? 1e3 : 0);
|
|
4599
4599
|
}
|
|
4600
4600
|
startAnimation(i) {
|
|
4601
|
-
this.notifyListeners("animationStart"), this.currentAnimation?.stop(), this.resumingFrom?.currentAnimation?.stop(), this.pendingAnimation && (pe(this.pendingAnimation), this.pendingAnimation = void 0), this.pendingAnimation =
|
|
4601
|
+
this.notifyListeners("animationStart"), this.currentAnimation?.stop(), this.resumingFrom?.currentAnimation?.stop(), this.pendingAnimation && (pe(this.pendingAnimation), this.pendingAnimation = void 0), this.pendingAnimation = dt.update(() => {
|
|
4602
4602
|
Wn.hasAnimatedSinceResize = !0, this.motionValue || (this.motionValue = qe(0)), this.currentAnimation = Mh(this.motionValue, [0, 1e3], {
|
|
4603
4603
|
...i,
|
|
4604
4604
|
velocity: 0,
|
|
@@ -4710,16 +4710,16 @@ function Wa({ attachResizeListener: t, defaultParent: e, measureScroll: n, check
|
|
|
4710
4710
|
c && (d = c(l, d)), i.transform = d;
|
|
4711
4711
|
const { x: h, y: p } = this.projectionDelta;
|
|
4712
4712
|
i.transformOrigin = `${h.origin * 100}% ${p.origin * 100}% 0`, u.animationValues ? i.opacity = u === this ? l.opacity ?? this.latestValues.opacity ?? 1 : this.preserveOpacity ? this.latestValues.opacity : l.opacityExit : i.opacity = u === this ? l.opacity !== void 0 ? l.opacity : "" : l.opacityExit !== void 0 ? l.opacityExit : 0;
|
|
4713
|
-
for (const
|
|
4714
|
-
if (l[
|
|
4713
|
+
for (const T in Tn) {
|
|
4714
|
+
if (l[T] === void 0)
|
|
4715
4715
|
continue;
|
|
4716
|
-
const { correct:
|
|
4717
|
-
if (
|
|
4718
|
-
const
|
|
4719
|
-
for (let M = 0; M <
|
|
4720
|
-
i[
|
|
4716
|
+
const { correct: w, applyTo: b, isCSSVariable: g } = Tn[T], v = d === "none" ? l[T] : w(l[T], u);
|
|
4717
|
+
if (b) {
|
|
4718
|
+
const y = b.length;
|
|
4719
|
+
for (let M = 0; M < y; M++)
|
|
4720
|
+
i[b[M]] = v;
|
|
4721
4721
|
} else
|
|
4722
|
-
|
|
4722
|
+
g ? this.options.visualElement.renderState.vars[T] = v : i[T] = v;
|
|
4723
4723
|
}
|
|
4724
4724
|
this.options.layoutId && (i.pointerEvents = u === this ? Un(a?.pointerEvents) || "" : "none");
|
|
4725
4725
|
}
|
|
@@ -4759,8 +4759,8 @@ function Kh(t) {
|
|
|
4759
4759
|
if (d && h) {
|
|
4760
4760
|
const p = gt();
|
|
4761
4761
|
mn(p, e.layoutBox, d.layoutBox);
|
|
4762
|
-
const
|
|
4763
|
-
mn(
|
|
4762
|
+
const T = gt();
|
|
4763
|
+
mn(T, n, h.layoutBox), Ua(p, T) || (u = !0), l.options.layoutRoot && (t.relativeTarget = T, t.relativeTargetOrigin = p, t.relativeParent = l);
|
|
4764
4764
|
}
|
|
4765
4765
|
}
|
|
4766
4766
|
}
|
|
@@ -4813,10 +4813,10 @@ function Qh(t) {
|
|
|
4813
4813
|
t.removeLeadSnapshot();
|
|
4814
4814
|
}
|
|
4815
4815
|
function Xi(t, e, n) {
|
|
4816
|
-
t.translate =
|
|
4816
|
+
t.translate = ft(e.translate, 0, n), t.scale = ft(e.scale, 1, n), t.origin = e.origin, t.originPoint = e.originPoint;
|
|
4817
4817
|
}
|
|
4818
4818
|
function Yi(t, e, n, s) {
|
|
4819
|
-
t.min =
|
|
4819
|
+
t.min = ft(e.min, n.min, s), t.max = ft(e.max, n.max, s);
|
|
4820
4820
|
}
|
|
4821
4821
|
function tf(t, e, n, s) {
|
|
4822
4822
|
Yi(t.x, e.x, n.x, s), Yi(t.y, e.y, n.y, s);
|
|
@@ -4879,7 +4879,7 @@ function to(t, e, n) {
|
|
|
4879
4879
|
const { props: s } = t;
|
|
4880
4880
|
t.animationState && s.whileHover && t.animationState.setActive("whileHover", n === "Start");
|
|
4881
4881
|
const r = "onHover" + n, o = s[r];
|
|
4882
|
-
o &&
|
|
4882
|
+
o && dt.postRender(() => o(e, Mn(e)));
|
|
4883
4883
|
}
|
|
4884
4884
|
class cf extends ye {
|
|
4885
4885
|
mount() {
|
|
@@ -4917,7 +4917,7 @@ function eo(t, e, n) {
|
|
|
4917
4917
|
return;
|
|
4918
4918
|
t.animationState && s.whileTap && t.animationState.setActive("whileTap", n === "Start");
|
|
4919
4919
|
const r = "onTap" + (n === "End" ? "" : n), o = s[r];
|
|
4920
|
-
o &&
|
|
4920
|
+
o && dt.postRender(() => o(e, Mn(e)));
|
|
4921
4921
|
}
|
|
4922
4922
|
class uf extends ye {
|
|
4923
4923
|
mount() {
|
|
@@ -5016,7 +5016,7 @@ function Nr(t, e) {
|
|
|
5016
5016
|
return _n(t, e);
|
|
5017
5017
|
}
|
|
5018
5018
|
const Tf = /* @__PURE__ */ Nr("button"), Fn = /* @__PURE__ */ Nr("div"), Sf = /* @__PURE__ */ Nr("p"), Jt = Symbol.for("@arcteninc/core:originalName");
|
|
5019
|
-
function
|
|
5019
|
+
function em(t, e) {
|
|
5020
5020
|
return t[Jt] = e, t;
|
|
5021
5021
|
}
|
|
5022
5022
|
function Af(t, e, n, s) {
|
|
@@ -5085,19 +5085,19 @@ function Pf({
|
|
|
5085
5085
|
onDeny: r
|
|
5086
5086
|
}) {
|
|
5087
5087
|
const o = Object.keys(n).length > 0;
|
|
5088
|
-
return /* @__PURE__ */ m("div", { className: "bg-stone-100 dark:bg-stone-800 border border-border rounded-lg px-3 py-2.5 my-1.5", children: /* @__PURE__ */
|
|
5089
|
-
/* @__PURE__ */
|
|
5088
|
+
return /* @__PURE__ */ m("div", { className: "bg-stone-100 dark:bg-stone-800 border border-border rounded-lg px-3 py-2.5 my-1.5", children: /* @__PURE__ */ R("div", { className: "flex items-start gap-2", children: [
|
|
5089
|
+
/* @__PURE__ */ R("div", { className: "flex-1 min-w-0", children: [
|
|
5090
5090
|
/* @__PURE__ */ m("div", { className: "flex items-center gap-1.5 mb-1", children: /* @__PURE__ */ m("span", { className: "text-sm font-medium text-foreground", children: t }) }),
|
|
5091
|
-
o && /* @__PURE__ */ m("div", { className: "space-y-0.5 mb-1.5", children: Object.entries(n).map(([i, a]) => /* @__PURE__ */
|
|
5092
|
-
/* @__PURE__ */
|
|
5091
|
+
o && /* @__PURE__ */ m("div", { className: "space-y-0.5 mb-1.5", children: Object.entries(n).map(([i, a]) => /* @__PURE__ */ R("div", { className: "flex items-start gap-1.5 text-xs", children: [
|
|
5092
|
+
/* @__PURE__ */ R("span", { className: "text-muted-foreground min-w-[60px]", children: [
|
|
5093
5093
|
i,
|
|
5094
5094
|
":"
|
|
5095
5095
|
] }),
|
|
5096
5096
|
/* @__PURE__ */ m("span", { className: "font-mono text-foreground", children: typeof a == "string" ? a : JSON.stringify(a) })
|
|
5097
5097
|
] }, i)) })
|
|
5098
5098
|
] }),
|
|
5099
|
-
/* @__PURE__ */
|
|
5100
|
-
/* @__PURE__ */
|
|
5099
|
+
/* @__PURE__ */ R("div", { className: "flex items-center gap-1 flex-shrink-0", children: [
|
|
5100
|
+
/* @__PURE__ */ R(
|
|
5101
5101
|
Gn,
|
|
5102
5102
|
{
|
|
5103
5103
|
size: "sm",
|
|
@@ -5129,7 +5129,7 @@ function Cf({
|
|
|
5129
5129
|
isDenied: n,
|
|
5130
5130
|
isSafe: s
|
|
5131
5131
|
}) {
|
|
5132
|
-
const [r, o] =
|
|
5132
|
+
const [r, o] = W(!1);
|
|
5133
5133
|
if (t === "fetchDocContent")
|
|
5134
5134
|
return null;
|
|
5135
5135
|
const i = ["k", "maxResults", "_organizationId"];
|
|
@@ -5137,8 +5137,8 @@ function Cf({
|
|
|
5137
5137
|
const a = Object.fromEntries(
|
|
5138
5138
|
Object.entries(e).filter(([u]) => !i.includes(u))
|
|
5139
5139
|
), c = Object.keys(a).length > 0;
|
|
5140
|
-
return /* @__PURE__ */
|
|
5141
|
-
/* @__PURE__ */
|
|
5140
|
+
return /* @__PURE__ */ R("div", { className: "my-1", children: [
|
|
5141
|
+
/* @__PURE__ */ R(
|
|
5142
5142
|
"button",
|
|
5143
5143
|
{
|
|
5144
5144
|
onClick: () => c && o(!r),
|
|
@@ -5146,7 +5146,7 @@ function Cf({
|
|
|
5146
5146
|
children: [
|
|
5147
5147
|
c && /* @__PURE__ */ m("span", { className: "transition-transform duration-200", children: r ? /* @__PURE__ */ m(Tc, { className: "h-3 w-3" }) : /* @__PURE__ */ m(Sc, { className: "h-3 w-3" }) }),
|
|
5148
5148
|
n ? /* @__PURE__ */ m(Kn, { className: "h-3 w-3" }) : s ? /* @__PURE__ */ m(Ac, { className: "h-3 w-3" }) : /* @__PURE__ */ m(oo, { className: "h-3 w-3" }),
|
|
5149
|
-
/* @__PURE__ */
|
|
5149
|
+
/* @__PURE__ */ R("span", { className: "font-medium", children: [
|
|
5150
5150
|
n ? "Denied" : s ? "Auto-executed" : "Executed",
|
|
5151
5151
|
" ",
|
|
5152
5152
|
t
|
|
@@ -5154,8 +5154,8 @@ function Cf({
|
|
|
5154
5154
|
]
|
|
5155
5155
|
}
|
|
5156
5156
|
),
|
|
5157
|
-
r && c && /* @__PURE__ */ m("div", { className: "mt-1 ml-6 p-2 bg-stone-50 dark:bg-stone-900 rounded-md border border-border", children: /* @__PURE__ */ m("div", { className: "space-y-0.5", children: Object.entries(a).map(([u, l]) => /* @__PURE__ */
|
|
5158
|
-
/* @__PURE__ */
|
|
5157
|
+
r && c && /* @__PURE__ */ m("div", { className: "mt-1 ml-6 p-2 bg-stone-50 dark:bg-stone-900 rounded-md border border-border", children: /* @__PURE__ */ m("div", { className: "space-y-0.5", children: Object.entries(a).map(([u, l]) => /* @__PURE__ */ R("div", { className: "flex items-start gap-1.5 text-xs", children: [
|
|
5158
|
+
/* @__PURE__ */ R("span", { className: "text-muted-foreground min-w-[60px]", children: [
|
|
5159
5159
|
u,
|
|
5160
5160
|
":"
|
|
5161
5161
|
] }),
|
|
@@ -5196,7 +5196,7 @@ const Ef = wc(
|
|
|
5196
5196
|
({ className: t, ...e }) => typeof window > "u" ? null : /* @__PURE__ */ m(bc, { fallback: null, children: /* @__PURE__ */ m(
|
|
5197
5197
|
Ef,
|
|
5198
5198
|
{
|
|
5199
|
-
className:
|
|
5199
|
+
className: yt(
|
|
5200
5200
|
"size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",
|
|
5201
5201
|
t
|
|
5202
5202
|
),
|
|
@@ -5218,7 +5218,7 @@ const Nf = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
5218
5218
|
}) => {
|
|
5219
5219
|
const o = bf.create(
|
|
5220
5220
|
e
|
|
5221
|
-
), i =
|
|
5221
|
+
), i = et(
|
|
5222
5222
|
() => (t?.length ?? 0) * r,
|
|
5223
5223
|
[t, r]
|
|
5224
5224
|
);
|
|
@@ -5226,7 +5226,7 @@ const Nf = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
5226
5226
|
o,
|
|
5227
5227
|
{
|
|
5228
5228
|
animate: { backgroundPosition: "0% center" },
|
|
5229
|
-
className:
|
|
5229
|
+
className: yt(
|
|
5230
5230
|
"relative inline-block bg-[length:250%_100%,auto] bg-clip-text text-transparent",
|
|
5231
5231
|
"[--bg:linear-gradient(90deg,#0000_calc(50%-var(--spread)),var(--color-background),#0000_calc(50%+var(--spread)))] [background-repeat:no-repeat,padding-box]",
|
|
5232
5232
|
n
|
|
@@ -5267,19 +5267,19 @@ const Nf = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
5267
5267
|
}), [l, d] = Fr({
|
|
5268
5268
|
prop: o,
|
|
5269
5269
|
defaultProp: 0
|
|
5270
|
-
}), [h, p] =
|
|
5271
|
-
|
|
5272
|
-
e ?
|
|
5273
|
-
}, [e,
|
|
5270
|
+
}), [h, p] = W(!1), [T, w] = W(null);
|
|
5271
|
+
st(() => {
|
|
5272
|
+
e ? T === null && w(Date.now()) : T !== null && (d(Math.ceil((Date.now() - T) / Of)), w(null));
|
|
5273
|
+
}, [e, T, d]), st(() => {
|
|
5274
5274
|
if (s && !e && c && !h) {
|
|
5275
|
-
const
|
|
5275
|
+
const g = setTimeout(() => {
|
|
5276
5276
|
u(!1), p(!0);
|
|
5277
5277
|
}, Lf);
|
|
5278
|
-
return () => clearTimeout(
|
|
5278
|
+
return () => clearTimeout(g);
|
|
5279
5279
|
}
|
|
5280
5280
|
}, [e, c, s, u, h]);
|
|
5281
|
-
const
|
|
5282
|
-
u(
|
|
5281
|
+
const b = (g) => {
|
|
5282
|
+
u(g);
|
|
5283
5283
|
};
|
|
5284
5284
|
return /* @__PURE__ */ m(
|
|
5285
5285
|
Xa.Provider,
|
|
@@ -5288,8 +5288,8 @@ const Nf = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
5288
5288
|
children: /* @__PURE__ */ m(
|
|
5289
5289
|
kf,
|
|
5290
5290
|
{
|
|
5291
|
-
className:
|
|
5292
|
-
onOpenChange:
|
|
5291
|
+
className: yt("not-prose mb-4", t),
|
|
5292
|
+
onOpenChange: b,
|
|
5293
5293
|
open: c,
|
|
5294
5294
|
...a,
|
|
5295
5295
|
children: i
|
|
@@ -5298,7 +5298,7 @@ const Nf = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
5298
5298
|
}
|
|
5299
5299
|
);
|
|
5300
5300
|
}
|
|
5301
|
-
), jf = (t, e) => t || e === 0 ? /* @__PURE__ */ m(Rf, { duration: 1, children: "Thinking..." }) : e === void 0 ? /* @__PURE__ */ m("p", { children: "Thought for a few seconds" }) : /* @__PURE__ */
|
|
5301
|
+
), jf = (t, e) => t || e === 0 ? /* @__PURE__ */ m(Rf, { duration: 1, children: "Thinking..." }) : e === void 0 ? /* @__PURE__ */ m("p", { children: "Thought for a few seconds" }) : /* @__PURE__ */ R("p", { children: [
|
|
5302
5302
|
"Thought for ",
|
|
5303
5303
|
e,
|
|
5304
5304
|
" seconds"
|
|
@@ -5308,18 +5308,18 @@ const Nf = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
5308
5308
|
return /* @__PURE__ */ m(
|
|
5309
5309
|
Mf,
|
|
5310
5310
|
{
|
|
5311
|
-
className:
|
|
5311
|
+
className: yt(
|
|
5312
5312
|
"flex w-full items-center gap-2 text-muted-foreground text-sm transition-colors hover:text-foreground",
|
|
5313
5313
|
t
|
|
5314
5314
|
),
|
|
5315
5315
|
...n,
|
|
5316
|
-
children: e ?? /* @__PURE__ */
|
|
5316
|
+
children: e ?? /* @__PURE__ */ R(Fe, { children: [
|
|
5317
5317
|
/* @__PURE__ */ m(Pc, { className: "size-4" }),
|
|
5318
5318
|
jf(s, o),
|
|
5319
5319
|
/* @__PURE__ */ m(
|
|
5320
5320
|
Cc,
|
|
5321
5321
|
{
|
|
5322
|
-
className:
|
|
5322
|
+
className: yt(
|
|
5323
5323
|
"size-4 transition-transform",
|
|
5324
5324
|
r ? "rotate-180" : "rotate-0"
|
|
5325
5325
|
)
|
|
@@ -5333,7 +5333,7 @@ const Nf = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
5333
5333
|
({ className: t, children: e, ...n }) => /* @__PURE__ */ m(
|
|
5334
5334
|
Df,
|
|
5335
5335
|
{
|
|
5336
|
-
className:
|
|
5336
|
+
className: yt(
|
|
5337
5337
|
"mt-4 text-sm",
|
|
5338
5338
|
"data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-muted-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in",
|
|
5339
5339
|
t
|
|
@@ -5353,11 +5353,11 @@ function $f({ sources: t, citationNumber: e, className: n }) {
|
|
|
5353
5353
|
const s = t.find((o) => o.number === e);
|
|
5354
5354
|
if (!s) return null;
|
|
5355
5355
|
const r = no(s.domain);
|
|
5356
|
-
return /* @__PURE__ */
|
|
5357
|
-
/* @__PURE__ */ m(he, { asChild: !0, children: /* @__PURE__ */
|
|
5356
|
+
return /* @__PURE__ */ R(de, { children: [
|
|
5357
|
+
/* @__PURE__ */ m(he, { asChild: !0, children: /* @__PURE__ */ R(
|
|
5358
5358
|
"button",
|
|
5359
5359
|
{
|
|
5360
|
-
className:
|
|
5360
|
+
className: yt(
|
|
5361
5361
|
"inline-flex items-center gap-1 px-1 py-0.5 rounded text-[10px] font-medium",
|
|
5362
5362
|
"bg-stone-200/60 dark:bg-stone-700/60 text-stone-800 dark:text-stone-200",
|
|
5363
5363
|
"hover:bg-stone-300/80 dark:hover:bg-stone-600/80",
|
|
@@ -5392,40 +5392,43 @@ function $f({ sources: t, citationNumber: e, className: n }) {
|
|
|
5392
5392
|
{
|
|
5393
5393
|
side: "top",
|
|
5394
5394
|
className: "bg-stone-800 dark:bg-stone-900 border border-stone-700 dark:border-stone-600 p-3 max-w-sm z-50 rounded-lg shadow-lg",
|
|
5395
|
-
children: /* @__PURE__ */
|
|
5396
|
-
/* @__PURE__ */
|
|
5395
|
+
children: /* @__PURE__ */ R("div", { className: "space-y-1.5", children: [
|
|
5396
|
+
/* @__PURE__ */ R("div", { className: "text-xs font-semibold text-stone-300 dark:text-stone-200 mb-2 pb-2 border-b border-stone-700 dark:border-stone-600", children: [
|
|
5397
5397
|
"Sources • ",
|
|
5398
5398
|
t.length
|
|
5399
5399
|
] }),
|
|
5400
|
-
t.map((o) =>
|
|
5401
|
-
|
|
5402
|
-
|
|
5403
|
-
|
|
5404
|
-
|
|
5405
|
-
|
|
5406
|
-
|
|
5407
|
-
|
|
5408
|
-
|
|
5409
|
-
|
|
5410
|
-
|
|
5411
|
-
children: [
|
|
5412
|
-
/* @__PURE__ */ m(
|
|
5413
|
-
"img",
|
|
5414
|
-
{
|
|
5415
|
-
src: no(o.domain),
|
|
5416
|
-
alt: "",
|
|
5417
|
-
className: "w-4 h-4 flex-shrink-0",
|
|
5418
|
-
onError: (i) => {
|
|
5419
|
-
const a = i.target;
|
|
5420
|
-
a.style.display = "none";
|
|
5421
|
-
}
|
|
5422
|
-
}
|
|
5400
|
+
t.map((o) => {
|
|
5401
|
+
const i = o.title || o.domain;
|
|
5402
|
+
return /* @__PURE__ */ R(
|
|
5403
|
+
"a",
|
|
5404
|
+
{
|
|
5405
|
+
href: o.url,
|
|
5406
|
+
target: "_blank",
|
|
5407
|
+
rel: "noopener noreferrer",
|
|
5408
|
+
className: yt(
|
|
5409
|
+
"flex items-center gap-2 p-2 rounded-md hover:bg-stone-700/50 dark:hover:bg-stone-700/50 transition-colors",
|
|
5410
|
+
"text-stone-300 dark:text-stone-300 hover:text-white dark:hover:text-white"
|
|
5423
5411
|
),
|
|
5424
|
-
|
|
5425
|
-
|
|
5426
|
-
|
|
5427
|
-
|
|
5428
|
-
|
|
5412
|
+
onClick: (a) => a.stopPropagation(),
|
|
5413
|
+
children: [
|
|
5414
|
+
/* @__PURE__ */ m(
|
|
5415
|
+
"img",
|
|
5416
|
+
{
|
|
5417
|
+
src: no(o.domain),
|
|
5418
|
+
alt: "",
|
|
5419
|
+
className: "w-4 h-4 flex-shrink-0",
|
|
5420
|
+
onError: (a) => {
|
|
5421
|
+
const c = a.target;
|
|
5422
|
+
c.style.display = "none";
|
|
5423
|
+
}
|
|
5424
|
+
}
|
|
5425
|
+
),
|
|
5426
|
+
/* @__PURE__ */ m("span", { className: "text-xs flex-1 truncate", children: i })
|
|
5427
|
+
]
|
|
5428
|
+
},
|
|
5429
|
+
o.number
|
|
5430
|
+
);
|
|
5431
|
+
})
|
|
5429
5432
|
] })
|
|
5430
5433
|
}
|
|
5431
5434
|
)
|
|
@@ -5442,157 +5445,200 @@ function Ff({
|
|
|
5442
5445
|
showCitations: a = !0,
|
|
5443
5446
|
showReferences: c = !0
|
|
5444
5447
|
}) {
|
|
5445
|
-
const u =
|
|
5446
|
-
|
|
5448
|
+
const u = bt(null), [l, d] = W([]);
|
|
5449
|
+
st(() => {
|
|
5447
5450
|
if (!a || !u.current || e.length === 0 || n.size === 0) {
|
|
5448
5451
|
(n.size === 0 || !a) && d([]);
|
|
5449
5452
|
return;
|
|
5450
5453
|
}
|
|
5451
|
-
const
|
|
5452
|
-
let g,
|
|
5453
|
-
const
|
|
5454
|
-
if (!u.current ||
|
|
5455
|
-
|
|
5456
|
-
const
|
|
5457
|
-
|
|
5454
|
+
const b = u.current;
|
|
5455
|
+
let g, v = !1;
|
|
5456
|
+
const y = /* @__PURE__ */ new WeakSet(), M = () => {
|
|
5457
|
+
if (!u.current || v) return;
|
|
5458
|
+
v = !0;
|
|
5459
|
+
const D = u.current, E = /\[(\d+)\]/g, S = document.createTreeWalker(
|
|
5460
|
+
D,
|
|
5458
5461
|
NodeFilter.SHOW_TEXT,
|
|
5459
5462
|
null
|
|
5460
|
-
),
|
|
5461
|
-
let
|
|
5462
|
-
for (;
|
|
5463
|
-
if (
|
|
5464
|
-
const
|
|
5465
|
-
let
|
|
5466
|
-
for (;
|
|
5467
|
-
if (
|
|
5468
|
-
|
|
5463
|
+
), $ = [];
|
|
5464
|
+
let L;
|
|
5465
|
+
for (; L = S.nextNode(); )
|
|
5466
|
+
if (L.nodeType === Node.TEXT_NODE && !y.has(L)) {
|
|
5467
|
+
const J = L, H = J.textContent || "";
|
|
5468
|
+
let q = J.parentElement, ct = !1;
|
|
5469
|
+
for (; q && q !== D; ) {
|
|
5470
|
+
if (q.tagName === "A" || q.tagName === "CODE" || q.tagName === "PRE") {
|
|
5471
|
+
ct = !0;
|
|
5469
5472
|
break;
|
|
5470
5473
|
}
|
|
5471
|
-
|
|
5474
|
+
q = q.parentElement;
|
|
5472
5475
|
}
|
|
5473
|
-
if (!
|
|
5474
|
-
const
|
|
5475
|
-
if (!
|
|
5476
|
-
const
|
|
5477
|
-
return n.has(
|
|
5476
|
+
if (!ct) {
|
|
5477
|
+
const Z = Array.from(H.matchAll(E)).filter((it) => {
|
|
5478
|
+
if (!it[1]) return !1;
|
|
5479
|
+
const lt = parseInt(it[1], 10);
|
|
5480
|
+
return n.has(lt);
|
|
5478
5481
|
});
|
|
5479
|
-
|
|
5482
|
+
Z.length > 0 && $.push({ node: J, matches: Z });
|
|
5480
5483
|
}
|
|
5481
5484
|
}
|
|
5482
|
-
if (
|
|
5483
|
-
|
|
5485
|
+
if ($.length === 0) {
|
|
5486
|
+
v = !1;
|
|
5484
5487
|
return;
|
|
5485
5488
|
}
|
|
5486
|
-
const
|
|
5487
|
-
|
|
5488
|
-
|
|
5489
|
-
const
|
|
5490
|
-
let
|
|
5491
|
-
|
|
5492
|
-
if (!
|
|
5493
|
-
|
|
5494
|
-
const
|
|
5495
|
-
|
|
5496
|
-
const
|
|
5497
|
-
|
|
5498
|
-
}),
|
|
5499
|
-
}),
|
|
5500
|
-
const
|
|
5501
|
-
return [...
|
|
5502
|
-
}),
|
|
5503
|
-
},
|
|
5504
|
-
clearTimeout(g), g = setTimeout(
|
|
5489
|
+
const Y = [];
|
|
5490
|
+
$.forEach(({ node: J, matches: H }) => {
|
|
5491
|
+
y.add(J);
|
|
5492
|
+
const q = J.textContent || "", ct = document.createDocumentFragment();
|
|
5493
|
+
let _ = 0;
|
|
5494
|
+
H.forEach((Z) => {
|
|
5495
|
+
if (!Z[1]) return;
|
|
5496
|
+
Z.index !== void 0 && Z.index > _ && ct.appendChild(document.createTextNode(q.slice(_, Z.index)));
|
|
5497
|
+
const it = document.createElement("span");
|
|
5498
|
+
it.className = "inline-flex items-center citation-button-container";
|
|
5499
|
+
const lt = parseInt(Z[1], 10);
|
|
5500
|
+
it.setAttribute("data-citation", Z[1]), ct.appendChild(it), Y.push({ element: it, citationNum: lt }), _ = (Z.index || 0) + Z[0].length;
|
|
5501
|
+
}), _ < q.length && ct.appendChild(document.createTextNode(q.slice(_))), J.parentNode && J.parentNode.replaceChild(ct, J);
|
|
5502
|
+
}), Y.length > 0 && d((J) => {
|
|
5503
|
+
const H = new Set(J.map((_) => _.element)), q = J.filter((_) => _.element.isConnected), ct = Y.filter((_) => !H.has(_.element));
|
|
5504
|
+
return [...q, ...ct];
|
|
5505
|
+
}), v = !1;
|
|
5506
|
+
}, C = new MutationObserver(() => {
|
|
5507
|
+
clearTimeout(g), g = setTimeout(M, 100);
|
|
5505
5508
|
});
|
|
5506
|
-
return
|
|
5509
|
+
return C.observe(b, {
|
|
5507
5510
|
childList: !0,
|
|
5508
5511
|
subtree: !0,
|
|
5509
5512
|
characterData: !0
|
|
5510
|
-
}), g = setTimeout(
|
|
5511
|
-
|
|
5513
|
+
}), g = setTimeout(M, 200), () => {
|
|
5514
|
+
C.disconnect(), clearTimeout(g);
|
|
5512
5515
|
};
|
|
5513
5516
|
}, [t, e, n, a]);
|
|
5514
|
-
const h = s && s.length > 0 || n && n.size > 0 || r
|
|
5515
|
-
|
|
5516
|
-
|
|
5517
|
-
|
|
5518
|
-
|
|
5519
|
-
|
|
5520
|
-
|
|
5521
|
-
|
|
5522
|
-
|
|
5523
|
-
|
|
5524
|
-
|
|
5525
|
-
|
|
5526
|
-
|
|
5527
|
-
|
|
5528
|
-
|
|
5529
|
-
|
|
5530
|
-
|
|
5531
|
-
|
|
5532
|
-
|
|
5533
|
-
|
|
5534
|
-
|
|
5535
|
-
|
|
5536
|
-
|
|
5517
|
+
const h = s && s.length > 0 || n && n.size > 0 || r;
|
|
5518
|
+
function p(b) {
|
|
5519
|
+
return `https://www.google.com/s2/favicons?domain=${encodeURIComponent(b)}&sz=16`;
|
|
5520
|
+
}
|
|
5521
|
+
function T(b) {
|
|
5522
|
+
try {
|
|
5523
|
+
return new URL(b).hostname.replace(/^www\./, "");
|
|
5524
|
+
} catch {
|
|
5525
|
+
return b;
|
|
5526
|
+
}
|
|
5527
|
+
}
|
|
5528
|
+
const w = a && c && h ? /* @__PURE__ */ R("div", { className: "mt-4 pt-4 border-t border-stone-200 dark:border-stone-700", children: [
|
|
5529
|
+
/* @__PURE__ */ m("div", { className: "text-xs font-semibold text-stone-600 dark:text-stone-400 mb-3", children: "References" }),
|
|
5530
|
+
/* @__PURE__ */ m("div", { className: "flex flex-wrap gap-2", children: s && s.length > 0 ? (
|
|
5531
|
+
// Use grouped citations if available - show as buttons with favicon + title
|
|
5532
|
+
s.map((b, g) => {
|
|
5533
|
+
const v = b.title || b.baseUrl, y = T(b.url), M = p(y);
|
|
5534
|
+
return /* @__PURE__ */ R(
|
|
5535
|
+
"a",
|
|
5536
|
+
{
|
|
5537
|
+
href: b.url,
|
|
5538
|
+
target: "_blank",
|
|
5539
|
+
rel: "noopener noreferrer",
|
|
5540
|
+
className: yt(
|
|
5541
|
+
"inline-flex items-center gap-1.5 px-2.5 py-1.5 rounded-md text-xs font-medium",
|
|
5542
|
+
"bg-stone-100 dark:bg-stone-800 text-stone-700 dark:text-stone-300",
|
|
5543
|
+
"hover:bg-stone-200 dark:hover:bg-stone-700",
|
|
5544
|
+
"transition-all duration-200",
|
|
5545
|
+
"border border-stone-200 dark:border-stone-700",
|
|
5546
|
+
"cursor-pointer hover:scale-105 active:scale-95",
|
|
5547
|
+
"no-underline"
|
|
5548
|
+
),
|
|
5549
|
+
children: [
|
|
5550
|
+
/* @__PURE__ */ m(
|
|
5551
|
+
"img",
|
|
5552
|
+
{
|
|
5553
|
+
src: M,
|
|
5554
|
+
alt: "",
|
|
5555
|
+
className: "w-3.5 h-3.5 shrink-0",
|
|
5556
|
+
onError: (C) => {
|
|
5557
|
+
const D = C.target;
|
|
5558
|
+
D.style.display = "none";
|
|
5559
|
+
}
|
|
5560
|
+
}
|
|
5561
|
+
),
|
|
5562
|
+
/* @__PURE__ */ m("span", { className: "leading-none", children: v })
|
|
5563
|
+
]
|
|
5564
|
+
},
|
|
5565
|
+
`group-${g}`
|
|
5566
|
+
);
|
|
5537
5567
|
})
|
|
5538
5568
|
) : (
|
|
5539
5569
|
// Fallback to original format if no grouped citations
|
|
5540
|
-
Array.from(n.entries()).sort(([
|
|
5541
|
-
|
|
5542
|
-
|
|
5543
|
-
y,
|
|
5544
|
-
"]"
|
|
5545
|
-
] }),
|
|
5546
|
-
/* @__PURE__ */ m(
|
|
5570
|
+
Array.from(n.entries()).sort(([b], [g]) => b - g).map(([b, g]) => {
|
|
5571
|
+
const v = T(g), y = p(v);
|
|
5572
|
+
return /* @__PURE__ */ R(
|
|
5547
5573
|
"a",
|
|
5548
5574
|
{
|
|
5549
5575
|
href: g,
|
|
5550
5576
|
target: "_blank",
|
|
5551
5577
|
rel: "noopener noreferrer",
|
|
5552
|
-
className:
|
|
5553
|
-
|
|
5554
|
-
|
|
5555
|
-
|
|
5556
|
-
|
|
5578
|
+
className: yt(
|
|
5579
|
+
"inline-flex items-center gap-1.5 px-2.5 py-1.5 rounded-md text-xs font-medium",
|
|
5580
|
+
"bg-stone-100 dark:bg-stone-800 text-stone-700 dark:text-stone-300",
|
|
5581
|
+
"hover:bg-stone-200 dark:hover:bg-stone-700",
|
|
5582
|
+
"transition-all duration-200",
|
|
5583
|
+
"border border-stone-200 dark:border-stone-700",
|
|
5584
|
+
"cursor-pointer hover:scale-105 active:scale-95",
|
|
5585
|
+
"no-underline"
|
|
5586
|
+
),
|
|
5587
|
+
children: [
|
|
5588
|
+
/* @__PURE__ */ m(
|
|
5589
|
+
"img",
|
|
5590
|
+
{
|
|
5591
|
+
src: y,
|
|
5592
|
+
alt: "",
|
|
5593
|
+
className: "w-3.5 h-3.5 shrink-0",
|
|
5594
|
+
onError: (M) => {
|
|
5595
|
+
const C = M.target;
|
|
5596
|
+
C.style.display = "none";
|
|
5597
|
+
}
|
|
5598
|
+
}
|
|
5599
|
+
),
|
|
5600
|
+
/* @__PURE__ */ m("span", { className: "leading-none", children: g })
|
|
5601
|
+
]
|
|
5602
|
+
},
|
|
5603
|
+
b
|
|
5604
|
+
);
|
|
5605
|
+
})
|
|
5557
5606
|
) })
|
|
5558
5607
|
] }) : null;
|
|
5559
|
-
return /* @__PURE__ */
|
|
5608
|
+
return /* @__PURE__ */ R("div", { className: i, children: [
|
|
5560
5609
|
/* @__PURE__ */ m("div", { ref: u, children: /* @__PURE__ */ m(o, { children: t }) }),
|
|
5561
|
-
a && l.filter(({ element:
|
|
5562
|
-
if (!e.find((
|
|
5563
|
-
const
|
|
5610
|
+
a && l.filter(({ element: b }) => b.isConnected).map(({ element: b, citationNum: g }, v) => {
|
|
5611
|
+
if (!e.find((C) => C.number === g)) return null;
|
|
5612
|
+
const M = Array.from(
|
|
5564
5613
|
new Map(
|
|
5565
|
-
e.map((
|
|
5566
|
-
|
|
5567
|
-
|
|
5568
|
-
|
|
5569
|
-
|
|
5614
|
+
e.map((C) => {
|
|
5615
|
+
const D = C.url.replace(/\/+$/, ""), E = s?.find((S) => S.url.replace(/\/+$/, "") === D);
|
|
5616
|
+
return [D, {
|
|
5617
|
+
number: C.number,
|
|
5618
|
+
url: C.url,
|
|
5619
|
+
domain: T(C.url),
|
|
5620
|
+
title: E?.title
|
|
5621
|
+
}];
|
|
5622
|
+
})
|
|
5570
5623
|
).values()
|
|
5571
5624
|
);
|
|
5572
5625
|
return jc(
|
|
5573
5626
|
/* @__PURE__ */ m(
|
|
5574
5627
|
$f,
|
|
5575
5628
|
{
|
|
5576
|
-
sources:
|
|
5629
|
+
sources: M,
|
|
5577
5630
|
citationNumber: g
|
|
5578
5631
|
},
|
|
5579
|
-
`citation-${g}-${
|
|
5632
|
+
`citation-${g}-${b}`
|
|
5580
5633
|
),
|
|
5581
|
-
|
|
5582
|
-
`citation-${g}-${
|
|
5634
|
+
b,
|
|
5635
|
+
`citation-${g}-${v}`
|
|
5583
5636
|
);
|
|
5584
5637
|
}),
|
|
5585
|
-
|
|
5638
|
+
w
|
|
5586
5639
|
] });
|
|
5587
5640
|
}
|
|
5588
5641
|
function Bf(t) {
|
|
5589
|
-
try {
|
|
5590
|
-
return new URL(t).hostname.replace(/^www\./, "");
|
|
5591
|
-
} catch {
|
|
5592
|
-
return t;
|
|
5593
|
-
}
|
|
5594
|
-
}
|
|
5595
|
-
function zf(t) {
|
|
5596
5642
|
try {
|
|
5597
5643
|
const e = new URL(t), n = `${e.protocol}//${e.host}${e.pathname}`, s = e.hash ? e.hash.substring(1) : void 0;
|
|
5598
5644
|
return { baseUrl: n, anchor: s };
|
|
@@ -5601,7 +5647,7 @@ function zf(t) {
|
|
|
5601
5647
|
return e !== -1 ? { baseUrl: t.substring(0, e), anchor: t.substring(e + 1) } : { baseUrl: t };
|
|
5602
5648
|
}
|
|
5603
5649
|
}
|
|
5604
|
-
function
|
|
5650
|
+
function zf(t) {
|
|
5605
5651
|
try {
|
|
5606
5652
|
const e = new URL(t), s = e.pathname.split("/").filter((a) => a.length > 0);
|
|
5607
5653
|
if (s.length === 0)
|
|
@@ -5622,85 +5668,85 @@ function so(t) {
|
|
|
5622
5668
|
const n = /(?:^|\n)(?:#+\s*)?(?:References|References:)(?:\*\*)?\s*\n?([\s\S]*?)(?=\n\n|\n#|$)/i, s = e.match(n), r = /* @__PURE__ */ new Map(), o = [], i = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Map();
|
|
5623
5669
|
if (s && s[1]) {
|
|
5624
5670
|
const S = s[1], $ = /\[(\d+)\]\s*(https?:\/\/[^\s\)]+)/g;
|
|
5625
|
-
let
|
|
5626
|
-
for (; (
|
|
5627
|
-
if (
|
|
5628
|
-
const
|
|
5629
|
-
if (a.has(
|
|
5630
|
-
c.set(
|
|
5671
|
+
let L;
|
|
5672
|
+
for (; (L = $.exec(S)) !== null; )
|
|
5673
|
+
if (L[1] && L[2]) {
|
|
5674
|
+
const Y = parseInt(L[1], 10), J = L[2].replace(/[.,;:!?]+$/, ""), H = J.replace(/\/+$/, "");
|
|
5675
|
+
if (a.has(H) || a.set(H, J), i.has(H) || i.set(H, []), i.get(H).push(Y), !c.has(H))
|
|
5676
|
+
c.set(H, Y);
|
|
5631
5677
|
else {
|
|
5632
|
-
const
|
|
5633
|
-
|
|
5678
|
+
const q = c.get(H);
|
|
5679
|
+
Y < q && c.set(H, Y);
|
|
5634
5680
|
}
|
|
5635
5681
|
}
|
|
5636
|
-
for (const [
|
|
5637
|
-
const
|
|
5638
|
-
for (const
|
|
5639
|
-
|
|
5682
|
+
for (const [Y, J] of i.entries()) {
|
|
5683
|
+
const H = c.get(Y);
|
|
5684
|
+
for (const q of J)
|
|
5685
|
+
q !== H && u.set(q, H);
|
|
5640
5686
|
}
|
|
5641
|
-
for (const [
|
|
5642
|
-
const
|
|
5643
|
-
r.set(
|
|
5687
|
+
for (const [Y, J] of c.entries()) {
|
|
5688
|
+
const H = a.get(Y) || Y;
|
|
5689
|
+
r.set(J, H), o.push({ number: J, url: H });
|
|
5644
5690
|
}
|
|
5645
5691
|
}
|
|
5646
5692
|
let l, d = e;
|
|
5647
5693
|
s && s[0] && (l = s[0], d = e.replace(n, ""));
|
|
5648
5694
|
const h = [];
|
|
5649
5695
|
let p = 0;
|
|
5650
|
-
const
|
|
5651
|
-
let
|
|
5652
|
-
for (; (
|
|
5653
|
-
|
|
5696
|
+
const T = /```[\s\S]*?```|`[^`]+`/g;
|
|
5697
|
+
let w;
|
|
5698
|
+
for (; (w = T.exec(d)) !== null; )
|
|
5699
|
+
w.index > p && h.push({ type: "text", content: d.slice(p, w.index), start: p, end: w.index }), h.push({ type: "code", content: w[0], start: w.index, end: w.index + w[0].length }), p = w.index + w[0].length;
|
|
5654
5700
|
p < d.length && h.push({ type: "text", content: d.slice(p), start: p, end: d.length });
|
|
5655
|
-
const
|
|
5701
|
+
const b = h.map((S) => {
|
|
5656
5702
|
if (S.type === "code")
|
|
5657
5703
|
return S.content;
|
|
5658
5704
|
let $ = S.content;
|
|
5659
|
-
return $ = $.replace(/\[(\d+)\]\((https?:\/\/[^\)]+)\)/g, (
|
|
5660
|
-
const
|
|
5661
|
-
return c.has(
|
|
5662
|
-
}), $ = $.replace(/\[(\d+)\]/g, (
|
|
5663
|
-
const
|
|
5664
|
-
return `[${u.get(
|
|
5705
|
+
return $ = $.replace(/\[(\d+)\]\((https?:\/\/[^\)]+)\)/g, (Y, J, H) => {
|
|
5706
|
+
const q = parseInt(J, 10), ct = H.replace(/\/+$/, ""), _ = u.get(q) || q;
|
|
5707
|
+
return c.has(ct) || (c.set(ct, _), r.has(_) || (r.set(_, H), o.push({ number: _, url: H }))), `[${_}]`;
|
|
5708
|
+
}), $ = $.replace(/\[(\d+)\]/g, (Y, J) => {
|
|
5709
|
+
const H = parseInt(J, 10);
|
|
5710
|
+
return `[${u.get(H) || H}]`;
|
|
5665
5711
|
}), $;
|
|
5666
|
-
}),
|
|
5712
|
+
}), g = [];
|
|
5667
5713
|
for (const [S, $] of c.entries()) {
|
|
5668
|
-
const
|
|
5669
|
-
|
|
5670
|
-
url:
|
|
5671
|
-
baseUrl:
|
|
5714
|
+
const L = a.get(S) || S, { baseUrl: Y, anchor: J } = Bf(L), H = zf(L);
|
|
5715
|
+
g.push({
|
|
5716
|
+
url: L,
|
|
5717
|
+
baseUrl: Y,
|
|
5672
5718
|
numbers: [$],
|
|
5673
5719
|
// Only show primary number
|
|
5674
|
-
anchor:
|
|
5675
|
-
title:
|
|
5720
|
+
anchor: J,
|
|
5721
|
+
title: H
|
|
5676
5722
|
});
|
|
5677
5723
|
}
|
|
5678
|
-
|
|
5679
|
-
const
|
|
5680
|
-
let
|
|
5681
|
-
for (const S of
|
|
5724
|
+
g.sort((S, $) => (S.numbers[0] || 0) - ($.numbers[0] || 0));
|
|
5725
|
+
const v = /* @__PURE__ */ new Map();
|
|
5726
|
+
let y = 1;
|
|
5727
|
+
for (const S of g) {
|
|
5682
5728
|
const $ = S.numbers[0];
|
|
5683
|
-
|
|
5729
|
+
v.set($, y), S.numbers = [y], y++;
|
|
5684
5730
|
}
|
|
5685
5731
|
const M = /* @__PURE__ */ new Map();
|
|
5686
5732
|
for (const [S, $] of r.entries()) {
|
|
5687
|
-
const
|
|
5688
|
-
|
|
5733
|
+
const L = v.get(S);
|
|
5734
|
+
L && M.set(L, $);
|
|
5689
5735
|
}
|
|
5690
|
-
const
|
|
5691
|
-
const $ =
|
|
5736
|
+
const C = o.map((S) => {
|
|
5737
|
+
const $ = v.get(S.number);
|
|
5692
5738
|
return $ ? { number: $, url: S.url } : S;
|
|
5693
|
-
}).filter((S) =>
|
|
5694
|
-
let
|
|
5695
|
-
for (const [S, $] of
|
|
5696
|
-
const
|
|
5697
|
-
|
|
5739
|
+
}).filter((S) => v.has(S.number)), D = Array.from(v.entries()).sort((S, $) => $[0] - S[0]);
|
|
5740
|
+
let E = b.join("");
|
|
5741
|
+
for (const [S, $] of D) {
|
|
5742
|
+
const L = new RegExp(`\\[${S}\\](?!\\d)`, "g");
|
|
5743
|
+
E = E.replace(L, `[${$}]`);
|
|
5698
5744
|
}
|
|
5699
5745
|
return {
|
|
5700
|
-
processedText:
|
|
5701
|
-
citations:
|
|
5746
|
+
processedText: E,
|
|
5747
|
+
citations: C.sort((S, $) => S.number - $.number),
|
|
5702
5748
|
citationMap: M,
|
|
5703
|
-
groupedCitations:
|
|
5749
|
+
groupedCitations: g,
|
|
5704
5750
|
referencesText: l
|
|
5705
5751
|
};
|
|
5706
5752
|
}
|
|
@@ -5734,7 +5780,7 @@ function As(t) {
|
|
|
5734
5780
|
}
|
|
5735
5781
|
return t && typeof t == "object" && !Array.isArray(t) ? pn(t) : {};
|
|
5736
5782
|
}
|
|
5737
|
-
function
|
|
5783
|
+
function nm({
|
|
5738
5784
|
theme: t = "auto",
|
|
5739
5785
|
layout: e = "sidebar",
|
|
5740
5786
|
model: n = "auto",
|
|
@@ -5749,17 +5795,17 @@ function sm({
|
|
|
5749
5795
|
safeTools: d = [],
|
|
5750
5796
|
toolMetadata: h,
|
|
5751
5797
|
systemPrompt: p = "",
|
|
5752
|
-
tokenEndpoint:
|
|
5753
|
-
apiBaseUrl:
|
|
5754
|
-
user:
|
|
5755
|
-
state:
|
|
5756
|
-
onStateChange:
|
|
5757
|
-
allowStateEdits:
|
|
5798
|
+
tokenEndpoint: T = "/api/arcten/token",
|
|
5799
|
+
apiBaseUrl: w = "https://api.arcten.com",
|
|
5800
|
+
user: b,
|
|
5801
|
+
state: g,
|
|
5802
|
+
onStateChange: v,
|
|
5803
|
+
allowStateEdits: y = !0,
|
|
5758
5804
|
sources: M,
|
|
5759
|
-
ragConfig:
|
|
5760
|
-
showCitations:
|
|
5805
|
+
ragConfig: C,
|
|
5806
|
+
showCitations: D = !0
|
|
5761
5807
|
}) {
|
|
5762
|
-
const
|
|
5808
|
+
const E = et(() => C !== void 0 ? C : M && M.length > 0 ? {
|
|
5763
5809
|
enabled: !0,
|
|
5764
5810
|
organizationId: M[0],
|
|
5765
5811
|
// Use first source as default
|
|
@@ -5767,21 +5813,21 @@ function sm({
|
|
|
5767
5813
|
// Default to auto-execute when sources are provided
|
|
5768
5814
|
filters: void 0
|
|
5769
5815
|
// Can be extended later if needed
|
|
5770
|
-
} : { enabled: !1 }, [M,
|
|
5771
|
-
|
|
5772
|
-
const [ot, ee] =
|
|
5773
|
-
if (!
|
|
5816
|
+
} : { enabled: !1 }, [M, C]), [S, $] = W(null), L = bt(null), [Y, J] = W(null), [H, q] = W(null), ct = bt(null), _ = g !== void 0, [Z, it] = W({}), lt = bt({});
|
|
5817
|
+
_ && g ? lt.current = g : _ || (lt.current = Z);
|
|
5818
|
+
const [ot, ee] = W(!1), [Re, wt] = W(null), ne = bt(!1), [Wt, Ie] = W(u), [Kt, se] = W(i), [re, Le] = W(600), [ie, $t] = W(!1), [nt, Ft] = W(!1), [Dt, Vt] = W(!1), [At, Oe] = W({ x: 100, y: 100 }), [tn, ve] = W(!1), [je, Dn] = W({ x: 0, y: 0 }), [En, Gt] = W(!1), en = bt(null), oe = bt(null), [ae, nn] = W(""), [xe, sn] = W(null), [ns, ss] = W("Thinking..."), [rn, qt] = W(/* @__PURE__ */ new Set()), [rs, is] = W(""), [A, P] = W([]), [I, O] = W(!1), [K, tt] = W([]), [X, Pt] = W(() => typeof window < "u" ? crypto.randomUUID() : null), [mt, Et] = W(!1), [ut, at] = W(!1), [$e, be] = W([]), Rr = yn(async (f, x = 3) => {
|
|
5819
|
+
if (!X || !L.current)
|
|
5774
5820
|
return;
|
|
5775
|
-
const
|
|
5776
|
-
const
|
|
5821
|
+
const k = async () => {
|
|
5822
|
+
const V = `${w.replace("/chat", "").replace(/\/$/, "")}/convex/api/mutation`, F = await fetch(V, {
|
|
5777
5823
|
method: "POST",
|
|
5778
5824
|
headers: {
|
|
5779
5825
|
"Content-Type": "application/json",
|
|
5780
|
-
Authorization: `Bearer ${
|
|
5826
|
+
Authorization: `Bearer ${L.current}`
|
|
5781
5827
|
},
|
|
5782
5828
|
body: JSON.stringify({
|
|
5783
5829
|
path: "conversations:mergeStateByChatId",
|
|
5784
|
-
args: { chatId:
|
|
5830
|
+
args: { chatId: X, updates: f },
|
|
5785
5831
|
format: "json"
|
|
5786
5832
|
})
|
|
5787
5833
|
});
|
|
@@ -5790,66 +5836,66 @@ function sm({
|
|
|
5790
5836
|
console.warn("[ArctenAgent] Convex API endpoint not available (404), state changes will not be persisted");
|
|
5791
5837
|
return;
|
|
5792
5838
|
}
|
|
5793
|
-
const
|
|
5794
|
-
throw new Error(`Failed to sync conversation state: ${F.status} ${
|
|
5839
|
+
const Q = await F.text().catch(() => "Unknown error");
|
|
5840
|
+
throw new Error(`Failed to sync conversation state: ${F.status} ${Q}`);
|
|
5795
5841
|
}
|
|
5796
5842
|
};
|
|
5797
|
-
for (let
|
|
5843
|
+
for (let N = 0; N < x; N++)
|
|
5798
5844
|
try {
|
|
5799
|
-
await
|
|
5845
|
+
await k(), wt(null);
|
|
5800
5846
|
return;
|
|
5801
|
-
} catch (
|
|
5802
|
-
if (
|
|
5803
|
-
const
|
|
5804
|
-
throw wt(
|
|
5847
|
+
} catch (V) {
|
|
5848
|
+
if (N === x - 1) {
|
|
5849
|
+
const Q = V instanceof Error ? V : new Error(String(V));
|
|
5850
|
+
throw wt(Q), console.error("Failed to sync state to Convex after retries:", V), Q;
|
|
5805
5851
|
}
|
|
5806
|
-
await new Promise((
|
|
5852
|
+
await new Promise((Q) => setTimeout(Q, Math.pow(2, N) * 100));
|
|
5807
5853
|
}
|
|
5808
|
-
}, [
|
|
5809
|
-
return
|
|
5810
|
-
}, []), an =
|
|
5811
|
-
const
|
|
5812
|
-
|
|
5854
|
+
}, [X, w, L]), on = et(() => function() {
|
|
5855
|
+
return lt.current;
|
|
5856
|
+
}, []), an = et(() => async function(x) {
|
|
5857
|
+
const k = { ...lt.current, ...x };
|
|
5858
|
+
lt.current = k, _ || it(k), v && v(k);
|
|
5813
5859
|
try {
|
|
5814
5860
|
await Rr(x);
|
|
5815
|
-
} catch (
|
|
5816
|
-
throw
|
|
5817
|
-
}
|
|
5818
|
-
}, [Rr,
|
|
5819
|
-
|
|
5820
|
-
|
|
5821
|
-
}, [
|
|
5822
|
-
const we =
|
|
5861
|
+
} catch (N) {
|
|
5862
|
+
throw N;
|
|
5863
|
+
}
|
|
5864
|
+
}, [Rr, v, _]);
|
|
5865
|
+
st(() => {
|
|
5866
|
+
_ && g && (lt.current = g);
|
|
5867
|
+
}, [_, g]);
|
|
5868
|
+
const we = et(() => E?.enabled ? async function(x, k = 20, N) {
|
|
5823
5869
|
if (M && M.length > 1) {
|
|
5824
|
-
const
|
|
5825
|
-
(U) => fetch(`${
|
|
5870
|
+
const Q = M.map(
|
|
5871
|
+
(U) => fetch(`${w}/search`, {
|
|
5826
5872
|
method: "POST",
|
|
5827
5873
|
headers: {
|
|
5828
5874
|
"Content-Type": "application/json",
|
|
5829
|
-
...
|
|
5875
|
+
...L.current ? { Authorization: `Bearer ${L.current}` } : {}
|
|
5830
5876
|
},
|
|
5831
5877
|
body: JSON.stringify({
|
|
5832
5878
|
q: x,
|
|
5833
|
-
k: Math.min(
|
|
5879
|
+
k: Math.min(k, 100),
|
|
5834
5880
|
organizationId: U,
|
|
5835
5881
|
...Object.keys(F).length > 0 ? { filters: F } : {}
|
|
5836
5882
|
})
|
|
5837
5883
|
}).then((B) => B.ok ? B.json() : null)
|
|
5838
|
-
),
|
|
5839
|
-
for (const U of
|
|
5840
|
-
U?.candidates &&
|
|
5841
|
-
|
|
5842
|
-
const
|
|
5843
|
-
return (B.scores?.rerank || B.scores?.dense || 0) -
|
|
5884
|
+
), G = await Promise.all(Q), rt = [];
|
|
5885
|
+
for (const U of G)
|
|
5886
|
+
U?.candidates && rt.push(...U.candidates);
|
|
5887
|
+
rt.sort((U, B) => {
|
|
5888
|
+
const vt = U.scores?.rerank || U.scores?.dense || 0;
|
|
5889
|
+
return (B.scores?.rerank || B.scores?.dense || 0) - vt;
|
|
5844
5890
|
});
|
|
5845
|
-
const j =
|
|
5846
|
-
const
|
|
5891
|
+
const j = rt.slice(0, k).map((U, B) => {
|
|
5892
|
+
const vt = U.citation || U.url;
|
|
5847
5893
|
return {
|
|
5848
5894
|
rank: B + 1,
|
|
5849
5895
|
doc_id: U.doc_id,
|
|
5850
5896
|
block_id: U.block_id,
|
|
5851
5897
|
url: U.url,
|
|
5852
|
-
citation:
|
|
5898
|
+
citation: vt,
|
|
5853
5899
|
title: U.title || "Untitled",
|
|
5854
5900
|
snippet: U.snippet,
|
|
5855
5901
|
score: U.scores?.rerank || U.scores?.dense || 0,
|
|
@@ -5863,46 +5909,46 @@ function sm({
|
|
|
5863
5909
|
return {
|
|
5864
5910
|
success: !0,
|
|
5865
5911
|
query: x,
|
|
5866
|
-
total:
|
|
5912
|
+
total: rt.length,
|
|
5867
5913
|
results: j,
|
|
5868
|
-
summary: `Found ${
|
|
5914
|
+
summary: `Found ${rt.length} relevant results across ${M.length} source(s) for "${x}". Top result: ${j[0]?.title || "N/A"}`
|
|
5869
5915
|
};
|
|
5870
5916
|
}
|
|
5871
|
-
const
|
|
5872
|
-
...
|
|
5873
|
-
...
|
|
5917
|
+
const V = E.organizationId && E.organizationId !== "default" ? E.organizationId : void 0, F = {
|
|
5918
|
+
...E.filters,
|
|
5919
|
+
...N
|
|
5874
5920
|
};
|
|
5875
5921
|
try {
|
|
5876
|
-
const
|
|
5922
|
+
const Q = {
|
|
5877
5923
|
q: x,
|
|
5878
|
-
k: Math.min(
|
|
5924
|
+
k: Math.min(k, 100)
|
|
5879
5925
|
// Cap at 100 results
|
|
5880
5926
|
};
|
|
5881
|
-
|
|
5882
|
-
const
|
|
5927
|
+
V && (Q.organizationId = V), Object.keys(F).length > 0 && (Q.filters = F);
|
|
5928
|
+
const G = {
|
|
5883
5929
|
"Content-Type": "application/json"
|
|
5884
5930
|
};
|
|
5885
|
-
|
|
5886
|
-
const
|
|
5931
|
+
L.current && (G.Authorization = `Bearer ${L.current}`);
|
|
5932
|
+
const rt = await fetch(`${w}/search`, {
|
|
5887
5933
|
method: "POST",
|
|
5888
|
-
headers:
|
|
5889
|
-
body: JSON.stringify(
|
|
5934
|
+
headers: G,
|
|
5935
|
+
body: JSON.stringify(Q)
|
|
5890
5936
|
});
|
|
5891
|
-
if (!
|
|
5892
|
-
const B = await
|
|
5937
|
+
if (!rt.ok) {
|
|
5938
|
+
const B = await rt.text();
|
|
5893
5939
|
return {
|
|
5894
5940
|
success: !1,
|
|
5895
|
-
error: `Search failed: ${
|
|
5941
|
+
error: `Search failed: ${rt.status} ${B}`
|
|
5896
5942
|
};
|
|
5897
5943
|
}
|
|
5898
|
-
const j = await
|
|
5899
|
-
const
|
|
5944
|
+
const j = await rt.json(), U = j.candidates.map((B, vt) => {
|
|
5945
|
+
const pt = B.citation || B.url;
|
|
5900
5946
|
return {
|
|
5901
|
-
rank:
|
|
5947
|
+
rank: vt + 1,
|
|
5902
5948
|
doc_id: B.doc_id,
|
|
5903
5949
|
block_id: B.block_id,
|
|
5904
5950
|
url: B.url,
|
|
5905
|
-
citation:
|
|
5951
|
+
citation: pt,
|
|
5906
5952
|
title: B.title || "Untitled",
|
|
5907
5953
|
snippet: B.snippet,
|
|
5908
5954
|
score: B.scores?.rerank || B.scores?.dense || 0,
|
|
@@ -5920,58 +5966,58 @@ function sm({
|
|
|
5920
5966
|
results: U,
|
|
5921
5967
|
summary: `Found ${j.total} relevant results for "${x}". Top result: ${U[0]?.title || "N/A"}`
|
|
5922
5968
|
};
|
|
5923
|
-
} catch (
|
|
5969
|
+
} catch (Q) {
|
|
5924
5970
|
return {
|
|
5925
5971
|
success: !1,
|
|
5926
|
-
error:
|
|
5972
|
+
error: Q instanceof Error ? Q.message : "Unknown error occurred"
|
|
5927
5973
|
};
|
|
5928
5974
|
}
|
|
5929
|
-
} : null, [
|
|
5930
|
-
const
|
|
5975
|
+
} : null, [C, w, L]), Te = et(() => E?.enabled ? async function(x, k) {
|
|
5976
|
+
const N = E.organizationId && E.organizationId !== "default" ? E.organizationId : M && M.length > 0 ? M[0] : void 0;
|
|
5931
5977
|
try {
|
|
5932
|
-
const
|
|
5978
|
+
const V = {
|
|
5933
5979
|
"Content-Type": "application/json"
|
|
5934
5980
|
};
|
|
5935
|
-
|
|
5936
|
-
const F = await fetch(`${
|
|
5981
|
+
L.current && (V.Authorization = `Bearer ${L.current}`);
|
|
5982
|
+
const F = await fetch(`${w}/fetch`, {
|
|
5937
5983
|
method: "POST",
|
|
5938
|
-
headers:
|
|
5984
|
+
headers: V,
|
|
5939
5985
|
body: JSON.stringify({
|
|
5940
5986
|
doc_id: x,
|
|
5941
|
-
block_ids:
|
|
5942
|
-
...
|
|
5987
|
+
block_ids: k,
|
|
5988
|
+
...N ? { organizationId: N } : {}
|
|
5943
5989
|
})
|
|
5944
5990
|
});
|
|
5945
5991
|
if (!F.ok) {
|
|
5946
|
-
const
|
|
5992
|
+
const G = await F.text();
|
|
5947
5993
|
return {
|
|
5948
5994
|
success: !1,
|
|
5949
|
-
error: `Fetch failed: ${F.status} ${
|
|
5995
|
+
error: `Fetch failed: ${F.status} ${G}`
|
|
5950
5996
|
};
|
|
5951
5997
|
}
|
|
5952
|
-
const
|
|
5998
|
+
const Q = await F.json();
|
|
5953
5999
|
return {
|
|
5954
6000
|
success: !0,
|
|
5955
|
-
blocks:
|
|
5956
|
-
fullContent:
|
|
5957
|
-
pageUrl:
|
|
5958
|
-
pageTitle:
|
|
5959
|
-
summary: `Fetched ${
|
|
6001
|
+
blocks: Q.blocks || [],
|
|
6002
|
+
fullContent: Q.fullContent || "",
|
|
6003
|
+
pageUrl: Q.pageUrl || "",
|
|
6004
|
+
pageTitle: Q.pageTitle || "",
|
|
6005
|
+
summary: `Fetched ${Q.blocks?.length || 0} blocks from ${Q.pageTitle || x}`
|
|
5960
6006
|
};
|
|
5961
|
-
} catch (
|
|
6007
|
+
} catch (V) {
|
|
5962
6008
|
return {
|
|
5963
6009
|
success: !1,
|
|
5964
|
-
error:
|
|
6010
|
+
error: V instanceof Error ? V.message : "Unknown error occurred"
|
|
5965
6011
|
};
|
|
5966
6012
|
}
|
|
5967
|
-
} : null, [
|
|
6013
|
+
} : null, [C, w, L]), Se = et(() => {
|
|
5968
6014
|
const f = [
|
|
5969
6015
|
...l,
|
|
5970
6016
|
...d,
|
|
5971
6017
|
on
|
|
5972
6018
|
];
|
|
5973
|
-
return (!
|
|
5974
|
-
}, [l, d, on, an, we, Te,
|
|
6019
|
+
return (!_ || y) && f.push(an), E?.enabled && (we && f.push(we), Te && f.push(Te)), f;
|
|
6020
|
+
}, [l, d, on, an, we, Te, _, y, E]), os = et(() => qa(Se, h), [Se, h]), Xt = et(() => {
|
|
5975
6021
|
const f = [
|
|
5976
6022
|
{
|
|
5977
6023
|
name: "getState",
|
|
@@ -5983,7 +6029,7 @@ function sm({
|
|
|
5983
6029
|
}
|
|
5984
6030
|
}
|
|
5985
6031
|
];
|
|
5986
|
-
(!
|
|
6032
|
+
(!_ || y) && f.push({
|
|
5987
6033
|
name: "setState",
|
|
5988
6034
|
description: "Update the agent state. Store IDs, workflow state, checklists, context, and other data that must persist across conversations. Merges with existing state.",
|
|
5989
6035
|
jsonSchema: {
|
|
@@ -5998,7 +6044,7 @@ function sm({
|
|
|
5998
6044
|
}
|
|
5999
6045
|
});
|
|
6000
6046
|
const x = [];
|
|
6001
|
-
return
|
|
6047
|
+
return E?.enabled && x.push(
|
|
6002
6048
|
{
|
|
6003
6049
|
name: "searchDocs",
|
|
6004
6050
|
description: "Search documentation using semantic search. Returns relevant results with snippets and scores. Use this first to find relevant documentation. Default returns 20 results - use higher k values (30-50) when you need to find many sources.",
|
|
@@ -6049,36 +6095,36 @@ function sm({
|
|
|
6049
6095
|
}
|
|
6050
6096
|
}
|
|
6051
6097
|
), [...os, ...f, ...x];
|
|
6052
|
-
}, [os,
|
|
6053
|
-
const f = /* @__PURE__ */ new Map(), x = new Map(os.map((
|
|
6054
|
-
return f.set("getState", on), (!
|
|
6055
|
-
if (
|
|
6098
|
+
}, [os, _, y, E]), Ir = et(() => new Set(Xt.map((f) => f.name)), [Xt]), Nn = et(() => Xt.filter((f) => f.name === "getState" ? !0 : f.name === "setState" ? !_ || y : Ir.has(f.name)), [Xt, Ir, _, y]), Vn = et(() => {
|
|
6099
|
+
const f = /* @__PURE__ */ new Map(), x = new Map(os.map((k) => [k.name, k]));
|
|
6100
|
+
return f.set("getState", on), (!_ || y) && f.set("setState", an), E?.enabled && (we && f.set("searchDocs", we), Te && f.set("fetchDocContent", Te)), Se.forEach((k) => {
|
|
6101
|
+
if (k === on || k === an || k === we || k === Te)
|
|
6056
6102
|
return;
|
|
6057
|
-
const
|
|
6058
|
-
if (
|
|
6059
|
-
const F = x.get(
|
|
6103
|
+
const N = k[Jt];
|
|
6104
|
+
if (N) {
|
|
6105
|
+
const F = x.get(N);
|
|
6060
6106
|
if (F) {
|
|
6061
|
-
f.set(F.name,
|
|
6107
|
+
f.set(F.name, k);
|
|
6062
6108
|
return;
|
|
6063
6109
|
}
|
|
6064
6110
|
}
|
|
6065
|
-
const
|
|
6066
|
-
|
|
6111
|
+
const V = Xt.find((F) => F.name === k.name);
|
|
6112
|
+
V && f.set(V.name, k);
|
|
6067
6113
|
}), f;
|
|
6068
|
-
}, [Se, Xt, on, an, we, Te,
|
|
6114
|
+
}, [Se, Xt, on, an, we, Te, _, y, E]), cn = et(() => {
|
|
6069
6115
|
const f = /* @__PURE__ */ new Set();
|
|
6070
|
-
f.add("getState"), f.add("setState"),
|
|
6071
|
-
const x = new Map(Xt.map((
|
|
6072
|
-
return d.forEach((
|
|
6073
|
-
const
|
|
6074
|
-
if (
|
|
6075
|
-
f.add(
|
|
6116
|
+
f.add("getState"), f.add("setState"), E?.enabled && E.autoExecute !== !1 && (f.add("searchDocs"), f.add("fetchDocContent"));
|
|
6117
|
+
const x = new Map(Xt.map((k) => [k.name, k]));
|
|
6118
|
+
return d.forEach((k) => {
|
|
6119
|
+
const N = k[Jt];
|
|
6120
|
+
if (N && x.has(N))
|
|
6121
|
+
f.add(N);
|
|
6076
6122
|
else {
|
|
6077
|
-
const
|
|
6078
|
-
|
|
6123
|
+
const V = Xt.find((F) => F.name === k.name);
|
|
6124
|
+
V && f.add(V.name);
|
|
6079
6125
|
}
|
|
6080
6126
|
}), f;
|
|
6081
|
-
}, [d, Xt,
|
|
6127
|
+
}, [d, Xt, E]), Lr = [
|
|
6082
6128
|
"Thinking...",
|
|
6083
6129
|
"Pondering...",
|
|
6084
6130
|
"Contemplating...",
|
|
@@ -6142,35 +6188,35 @@ function sm({
|
|
|
6142
6188
|
"Rattling the idea can...",
|
|
6143
6189
|
"Waving the logic wand..."
|
|
6144
6190
|
];
|
|
6145
|
-
|
|
6191
|
+
st(() => {
|
|
6146
6192
|
if (typeof window < "u") {
|
|
6147
6193
|
const f = localStorage.getItem("arcten-sidebar-expanded");
|
|
6148
6194
|
f && Ie(JSON.parse(f));
|
|
6149
6195
|
const x = localStorage.getItem("arcten-sidebar-width");
|
|
6150
6196
|
x && se(parseInt(x));
|
|
6151
|
-
const
|
|
6152
|
-
|
|
6153
|
-
const
|
|
6154
|
-
|
|
6155
|
-
const
|
|
6156
|
-
if (
|
|
6157
|
-
const
|
|
6158
|
-
|
|
6159
|
-
Math.min(
|
|
6197
|
+
const k = localStorage.getItem("arcten-sidebar-height");
|
|
6198
|
+
k && Le(parseInt(k));
|
|
6199
|
+
const N = localStorage.getItem("arcten-sidebar-detached");
|
|
6200
|
+
N && Ft(JSON.parse(N));
|
|
6201
|
+
const V = localStorage.getItem("arcten-sidebar-position");
|
|
6202
|
+
if (V) {
|
|
6203
|
+
const Q = JSON.parse(V), G = 50, rt = Math.max(
|
|
6204
|
+
G - i,
|
|
6205
|
+
Math.min(Q.x, window.innerWidth - G)
|
|
6160
6206
|
), j = Math.max(
|
|
6161
6207
|
0,
|
|
6162
|
-
Math.min(
|
|
6208
|
+
Math.min(Q.y, window.innerHeight - G)
|
|
6163
6209
|
);
|
|
6164
|
-
Oe({ x:
|
|
6210
|
+
Oe({ x: rt, y: j });
|
|
6165
6211
|
}
|
|
6166
6212
|
const F = localStorage.getItem("arcten-sidebar-minimized");
|
|
6167
6213
|
F && Vt(JSON.parse(F)), Gt(!0);
|
|
6168
6214
|
}
|
|
6169
6215
|
}, []);
|
|
6170
|
-
const ce =
|
|
6171
|
-
|
|
6216
|
+
const ce = et(() => b, [b?.id]);
|
|
6217
|
+
st(() => ((async () => {
|
|
6172
6218
|
try {
|
|
6173
|
-
const x = await fetch(
|
|
6219
|
+
const x = await fetch(T, {
|
|
6174
6220
|
method: "POST",
|
|
6175
6221
|
headers: {
|
|
6176
6222
|
"Content-Type": "application/json"
|
|
@@ -6182,20 +6228,20 @@ function sm({
|
|
|
6182
6228
|
});
|
|
6183
6229
|
if (!x.ok)
|
|
6184
6230
|
throw new Error("Failed to fetch token");
|
|
6185
|
-
const
|
|
6186
|
-
$(
|
|
6231
|
+
const k = await x.json();
|
|
6232
|
+
$(k.clientToken), L.current = k.clientToken, q(k.expiresAt), J(null);
|
|
6187
6233
|
} catch (x) {
|
|
6188
|
-
|
|
6234
|
+
J(x instanceof Error ? x.message : "Failed to fetch token");
|
|
6189
6235
|
}
|
|
6190
6236
|
})(), () => {
|
|
6191
|
-
|
|
6192
|
-
}), [
|
|
6193
|
-
if (!
|
|
6194
|
-
|
|
6195
|
-
const f = Math.floor(Date.now() / 1e3), x =
|
|
6196
|
-
return
|
|
6237
|
+
ct.current && clearTimeout(ct.current);
|
|
6238
|
+
}), [T, ce]), st(() => {
|
|
6239
|
+
if (!H) return;
|
|
6240
|
+
ct.current && clearTimeout(ct.current);
|
|
6241
|
+
const f = Math.floor(Date.now() / 1e3), x = H - f, N = Math.max(0, x - 5);
|
|
6242
|
+
return ct.current = setTimeout(async () => {
|
|
6197
6243
|
try {
|
|
6198
|
-
const
|
|
6244
|
+
const V = await fetch(T, {
|
|
6199
6245
|
method: "POST",
|
|
6200
6246
|
headers: {
|
|
6201
6247
|
"Content-Type": "application/json"
|
|
@@ -6204,41 +6250,41 @@ function sm({
|
|
|
6204
6250
|
user: ce
|
|
6205
6251
|
})
|
|
6206
6252
|
});
|
|
6207
|
-
if (!
|
|
6253
|
+
if (!V.ok)
|
|
6208
6254
|
throw new Error("Failed to refresh token");
|
|
6209
|
-
const F = await
|
|
6210
|
-
$(F.clientToken),
|
|
6211
|
-
} catch (
|
|
6212
|
-
console.error("Token refresh failed:",
|
|
6255
|
+
const F = await V.json();
|
|
6256
|
+
$(F.clientToken), L.current = F.clientToken, q(F.expiresAt), J(null);
|
|
6257
|
+
} catch (V) {
|
|
6258
|
+
console.error("Token refresh failed:", V), J(V instanceof Error ? V.message : "Failed to refresh token");
|
|
6213
6259
|
}
|
|
6214
|
-
},
|
|
6215
|
-
|
|
6260
|
+
}, N * 1e3), () => {
|
|
6261
|
+
ct.current && clearTimeout(ct.current);
|
|
6216
6262
|
};
|
|
6217
|
-
}, [
|
|
6263
|
+
}, [H, T, ce]), st(() => {
|
|
6218
6264
|
(async () => {
|
|
6219
6265
|
if (Se.length !== 0)
|
|
6220
6266
|
try {
|
|
6221
|
-
const x = Se.map((
|
|
6222
|
-
name:
|
|
6223
|
-
code:
|
|
6224
|
-
})),
|
|
6267
|
+
const x = Se.map((N) => ({
|
|
6268
|
+
name: N.name,
|
|
6269
|
+
code: N.toString()
|
|
6270
|
+
})), k = await fetch(`${w}/tools/describe`, {
|
|
6225
6271
|
method: "POST",
|
|
6226
6272
|
headers: { "Content-Type": "application/json" },
|
|
6227
6273
|
body: JSON.stringify({ tools: x })
|
|
6228
6274
|
});
|
|
6229
|
-
if (
|
|
6230
|
-
const
|
|
6231
|
-
P(
|
|
6275
|
+
if (k.ok) {
|
|
6276
|
+
const N = await k.json();
|
|
6277
|
+
P(N.tools);
|
|
6232
6278
|
}
|
|
6233
6279
|
} catch (x) {
|
|
6234
6280
|
console.error("Failed to fetch tool descriptions:", x);
|
|
6235
6281
|
}
|
|
6236
6282
|
})();
|
|
6237
|
-
}, [Se]),
|
|
6283
|
+
}, [Se]), st(() => {
|
|
6238
6284
|
Promise.resolve().then(() => Nf).then((f) => {
|
|
6239
6285
|
sn(() => f.Response);
|
|
6240
6286
|
});
|
|
6241
|
-
}, []),
|
|
6287
|
+
}, []), st(() => {
|
|
6242
6288
|
const f = () => {
|
|
6243
6289
|
is(window.location.pathname);
|
|
6244
6290
|
};
|
|
@@ -6252,20 +6298,20 @@ function sm({
|
|
|
6252
6298
|
if (!(!ce?.id || !S)) {
|
|
6253
6299
|
at(!0);
|
|
6254
6300
|
try {
|
|
6255
|
-
const x = await (await fetch(`${
|
|
6301
|
+
const x = await (await fetch(`${w}/conversations`, {
|
|
6256
6302
|
headers: {
|
|
6257
6303
|
Authorization: `Bearer ${S}`
|
|
6258
6304
|
}
|
|
6259
6305
|
})).json();
|
|
6260
|
-
|
|
6306
|
+
tt(x.conversations || []);
|
|
6261
6307
|
} catch (f) {
|
|
6262
6308
|
console.error("Failed to fetch conversations:", f);
|
|
6263
6309
|
} finally {
|
|
6264
6310
|
at(!1);
|
|
6265
6311
|
}
|
|
6266
6312
|
}
|
|
6267
|
-
}, [ce?.id, S,
|
|
6268
|
-
|
|
6313
|
+
}, [ce?.id, S, w]);
|
|
6314
|
+
st(() => {
|
|
6269
6315
|
ce?.id && S && as();
|
|
6270
6316
|
}, [ce?.id, S, as]);
|
|
6271
6317
|
function Qa(f) {
|
|
@@ -6275,18 +6321,18 @@ function sm({
|
|
|
6275
6321
|
function tc() {
|
|
6276
6322
|
const f = crypto.randomUUID();
|
|
6277
6323
|
Pt(f), In([]), be([]), Et(!1);
|
|
6278
|
-
const x =
|
|
6279
|
-
|
|
6324
|
+
const x = _ ? g || {} : {};
|
|
6325
|
+
lt.current = x, _ || it(x), v && v(x), ne.current = !1;
|
|
6280
6326
|
}
|
|
6281
6327
|
async function ec(f) {
|
|
6282
6328
|
if (S)
|
|
6283
6329
|
try {
|
|
6284
|
-
await fetch(`${
|
|
6330
|
+
await fetch(`${w}/conversations/${f}`, {
|
|
6285
6331
|
method: "DELETE",
|
|
6286
6332
|
headers: {
|
|
6287
6333
|
Authorization: `Bearer ${S}`
|
|
6288
6334
|
}
|
|
6289
|
-
}),
|
|
6335
|
+
}), tt(K.filter((x) => x._id !== f)), f === X && tc();
|
|
6290
6336
|
} catch (x) {
|
|
6291
6337
|
console.error("Failed to delete conversation:", x);
|
|
6292
6338
|
}
|
|
@@ -6294,38 +6340,38 @@ function sm({
|
|
|
6294
6340
|
async function nc(f) {
|
|
6295
6341
|
Pt(f.chatId), Et(!1), at(!0);
|
|
6296
6342
|
try {
|
|
6297
|
-
const x = await fetch(`${
|
|
6343
|
+
const x = await fetch(`${w}/conversations/${f.chatId}/messages`, {
|
|
6298
6344
|
headers: {
|
|
6299
|
-
Authorization: `Bearer ${
|
|
6345
|
+
Authorization: `Bearer ${L.current}`
|
|
6300
6346
|
}
|
|
6301
6347
|
});
|
|
6302
6348
|
if (!x.ok)
|
|
6303
6349
|
throw new Error(`Failed to fetch messages: ${x.statusText}`);
|
|
6304
|
-
const
|
|
6305
|
-
In(
|
|
6350
|
+
const N = (await x.json()).messages || [];
|
|
6351
|
+
In(N), be(N);
|
|
6306
6352
|
} catch (x) {
|
|
6307
6353
|
console.error("Failed to load conversation messages:", x);
|
|
6308
|
-
const
|
|
6309
|
-
In(
|
|
6354
|
+
const k = f.messages || [];
|
|
6355
|
+
In(k), be(k);
|
|
6310
6356
|
} finally {
|
|
6311
6357
|
at(!1);
|
|
6312
6358
|
}
|
|
6313
6359
|
}
|
|
6314
6360
|
const sc = async (f, x = {}) => {
|
|
6315
|
-
const
|
|
6316
|
-
return
|
|
6361
|
+
const k = x.headers ? new Headers(x.headers) : new Headers();
|
|
6362
|
+
return k.delete("user-agent"), k.delete("User-Agent"), fetch(f, {
|
|
6317
6363
|
...x,
|
|
6318
|
-
headers:
|
|
6364
|
+
headers: k
|
|
6319
6365
|
});
|
|
6320
6366
|
}, { messages: Yt, sendMessage: rc, status: Bt, error: Or, stop: Rn, addToolResult: Ae, setMessages: In } = ao({
|
|
6321
|
-
id:
|
|
6367
|
+
id: X || void 0,
|
|
6322
6368
|
// Pass AI SDK chat ID
|
|
6323
6369
|
transport: new lo({
|
|
6324
|
-
api: `${
|
|
6370
|
+
api: `${w}/chat`,
|
|
6325
6371
|
fetch: sc,
|
|
6326
6372
|
headers: () => {
|
|
6327
6373
|
const f = {};
|
|
6328
|
-
return
|
|
6374
|
+
return L.current && (f.Authorization = `Bearer ${L.current}`), f;
|
|
6329
6375
|
},
|
|
6330
6376
|
body: () => ({
|
|
6331
6377
|
tools: Nn.map((x) => ({
|
|
@@ -6338,7 +6384,7 @@ function sm({
|
|
|
6338
6384
|
// Send custom system prompt
|
|
6339
6385
|
currentRoute: rs,
|
|
6340
6386
|
// Send current route for context
|
|
6341
|
-
state:
|
|
6387
|
+
state: lt.current
|
|
6342
6388
|
// Always include current state
|
|
6343
6389
|
// Note: conversationId removed - AI SDK sends 'id' automatically at root level
|
|
6344
6390
|
})
|
|
@@ -6346,104 +6392,104 @@ function sm({
|
|
|
6346
6392
|
// Automatically continue when all tool results are available
|
|
6347
6393
|
sendAutomaticallyWhen: co
|
|
6348
6394
|
});
|
|
6349
|
-
|
|
6395
|
+
st(() => {
|
|
6350
6396
|
const f = Yt[Yt.length - 1];
|
|
6351
6397
|
if (!f || f.role !== "assistant") return;
|
|
6352
|
-
const x = f.parts?.filter((
|
|
6353
|
-
for (const
|
|
6354
|
-
const
|
|
6355
|
-
if (cn.has(
|
|
6398
|
+
const x = f.parts?.filter((k) => k.type?.startsWith("tool-") && k.state === "input-available" && typeof k.toolCallId == "string" && k.input !== void 0) || [];
|
|
6399
|
+
for (const k of x) {
|
|
6400
|
+
const N = k, V = N.type?.replace("tool-", "") || "", F = N.toolCallId;
|
|
6401
|
+
if (cn.has(V)) {
|
|
6356
6402
|
if (rn.has(F))
|
|
6357
6403
|
continue;
|
|
6358
|
-
qt((
|
|
6404
|
+
qt((G) => G.has(F) ? G : new Set(G).add(F)), (async () => {
|
|
6359
6405
|
try {
|
|
6360
|
-
const
|
|
6361
|
-
if (!
|
|
6362
|
-
console.warn(`[ArctenAgent] Tool ${
|
|
6406
|
+
const G = Vn.get(V);
|
|
6407
|
+
if (!G) {
|
|
6408
|
+
console.warn(`[ArctenAgent] Tool ${V} not found in toolsMap. Available tools:`, Array.from(Vn.keys())), Ae({
|
|
6363
6409
|
toolCallId: F,
|
|
6364
|
-
tool:
|
|
6365
|
-
output: `Error: Tool ${
|
|
6410
|
+
tool: V,
|
|
6411
|
+
output: `Error: Tool ${V} not found`
|
|
6366
6412
|
}), qt((B) => {
|
|
6367
|
-
const
|
|
6368
|
-
return
|
|
6413
|
+
const vt = new Set(B);
|
|
6414
|
+
return vt.delete(F), vt;
|
|
6369
6415
|
});
|
|
6370
6416
|
return;
|
|
6371
6417
|
}
|
|
6372
|
-
const
|
|
6418
|
+
const rt = As(N.input), j = Nn.find((B) => B.name === V);
|
|
6373
6419
|
let U;
|
|
6374
6420
|
if (j && j.jsonSchema?.properties) {
|
|
6375
|
-
const
|
|
6376
|
-
console.log(`[ArctenAgent] Executing safe tool ${
|
|
6377
|
-
} else if (
|
|
6378
|
-
U =
|
|
6379
|
-
else if (
|
|
6380
|
-
const B =
|
|
6381
|
-
U = await
|
|
6421
|
+
const vt = Object.keys(j.jsonSchema.properties).map((pt) => rt[pt]);
|
|
6422
|
+
console.log(`[ArctenAgent] Executing safe tool ${V} with args:`, vt), U = await G(...vt);
|
|
6423
|
+
} else if (V === "getState")
|
|
6424
|
+
U = G();
|
|
6425
|
+
else if (V === "setState") {
|
|
6426
|
+
const B = rt.updates || rt;
|
|
6427
|
+
U = await G(B);
|
|
6382
6428
|
} else
|
|
6383
|
-
U = await
|
|
6384
|
-
console.log(`[ArctenAgent] Tool ${
|
|
6429
|
+
U = await G(...Object.values(rt));
|
|
6430
|
+
console.log(`[ArctenAgent] Tool ${V} completed, result:`, U), Ae({
|
|
6385
6431
|
toolCallId: F,
|
|
6386
|
-
tool:
|
|
6432
|
+
tool: V,
|
|
6387
6433
|
output: U
|
|
6388
6434
|
}), qt((B) => {
|
|
6389
|
-
const
|
|
6390
|
-
return
|
|
6435
|
+
const vt = new Set(B);
|
|
6436
|
+
return vt.delete(F), vt;
|
|
6391
6437
|
});
|
|
6392
|
-
} catch (
|
|
6393
|
-
console.error(`[ArctenAgent] Error executing safe tool ${
|
|
6438
|
+
} catch (G) {
|
|
6439
|
+
console.error(`[ArctenAgent] Error executing safe tool ${V}:`, G), Ae({
|
|
6394
6440
|
toolCallId: F,
|
|
6395
|
-
tool:
|
|
6396
|
-
output: `Error: ${
|
|
6397
|
-
}), qt((
|
|
6398
|
-
const j = new Set(
|
|
6441
|
+
tool: V,
|
|
6442
|
+
output: `Error: ${G instanceof Error ? G.message : String(G)}`
|
|
6443
|
+
}), qt((rt) => {
|
|
6444
|
+
const j = new Set(rt);
|
|
6399
6445
|
return j.delete(F), j;
|
|
6400
6446
|
});
|
|
6401
6447
|
}
|
|
6402
6448
|
})();
|
|
6403
6449
|
}
|
|
6404
6450
|
}
|
|
6405
|
-
}, [Yt, cn, Vn, Nn, Ae]),
|
|
6406
|
-
if (!
|
|
6451
|
+
}, [Yt, cn, Vn, Nn, Ae]), st(() => {
|
|
6452
|
+
if (!X || !L.current) return;
|
|
6407
6453
|
(async () => {
|
|
6408
6454
|
ee(!0), wt(null);
|
|
6409
6455
|
try {
|
|
6410
|
-
const
|
|
6456
|
+
const k = `${w.replace("/chat", "").replace(/\/$/, "")}/convex/api/query`, N = await fetch(k, {
|
|
6411
6457
|
method: "POST",
|
|
6412
6458
|
headers: {
|
|
6413
6459
|
"Content-Type": "application/json",
|
|
6414
|
-
Authorization: `Bearer ${
|
|
6460
|
+
Authorization: `Bearer ${L.current}`
|
|
6415
6461
|
},
|
|
6416
6462
|
body: JSON.stringify({
|
|
6417
6463
|
path: "conversations:getStateByChatId",
|
|
6418
|
-
args: { chatId:
|
|
6464
|
+
args: { chatId: X },
|
|
6419
6465
|
format: "json"
|
|
6420
6466
|
})
|
|
6421
6467
|
});
|
|
6422
|
-
if (!
|
|
6423
|
-
if (
|
|
6424
|
-
console.warn(`[ArctenAgent] Convex API endpoint not available (${
|
|
6425
|
-
const j =
|
|
6426
|
-
|
|
6468
|
+
if (!N.ok) {
|
|
6469
|
+
if (N.status === 404 || N.status >= 500) {
|
|
6470
|
+
console.warn(`[ArctenAgent] Convex API endpoint not available (${N.status}), using empty state`);
|
|
6471
|
+
const j = _ ? g || {} : {};
|
|
6472
|
+
lt.current = j, _ || it(j), v && v(j), ne.current = !0, ee(!1);
|
|
6427
6473
|
return;
|
|
6428
6474
|
}
|
|
6429
|
-
const
|
|
6430
|
-
throw new Error(`Failed to fetch conversation state: ${
|
|
6475
|
+
const rt = await N.text().catch(() => "Unknown error");
|
|
6476
|
+
throw new Error(`Failed to fetch conversation state: ${N.status} ${rt}`);
|
|
6431
6477
|
}
|
|
6432
|
-
const F = (await
|
|
6433
|
-
let
|
|
6434
|
-
|
|
6478
|
+
const F = (await N.json())?.value || {}, Q = !ne.current;
|
|
6479
|
+
let G;
|
|
6480
|
+
Q ? (G = { ..._ ? g || {} : {}, ...F }, ne.current = !0) : G = F, lt.current = G, _ || it(G), v && v(G);
|
|
6435
6481
|
} catch (x) {
|
|
6436
6482
|
x instanceof TypeError && x.message.includes("fetch") ? console.warn("[ArctenAgent] Network error fetching state (likely Convex endpoint not available), using fallback state:", x) : console.error("[ArctenAgent] Failed to fetch state:", x);
|
|
6437
|
-
const
|
|
6438
|
-
if (wt(
|
|
6439
|
-
const
|
|
6440
|
-
|
|
6483
|
+
const N = x instanceof Error ? x : new Error(String(x));
|
|
6484
|
+
if (wt(N), !ne.current) {
|
|
6485
|
+
const V = _ ? g || {} : {};
|
|
6486
|
+
lt.current = V, _ || it(V), v && v(V), ne.current = !0;
|
|
6441
6487
|
}
|
|
6442
6488
|
} finally {
|
|
6443
6489
|
ee(!1);
|
|
6444
6490
|
}
|
|
6445
6491
|
})();
|
|
6446
|
-
}, [
|
|
6492
|
+
}, [X, w, _, g, v]), st(() => {
|
|
6447
6493
|
Wt && oe.current && oe.current.focus();
|
|
6448
6494
|
}, [Wt, Yt]);
|
|
6449
6495
|
function ic() {
|
|
@@ -6452,10 +6498,10 @@ function sm({
|
|
|
6452
6498
|
function oc() {
|
|
6453
6499
|
Ie(!1), localStorage.setItem("arcten-sidebar-expanded", "false");
|
|
6454
6500
|
}
|
|
6455
|
-
|
|
6456
|
-
}, [Wt]),
|
|
6501
|
+
st(() => {
|
|
6502
|
+
}, [Wt]), st(() => {
|
|
6457
6503
|
en.current && en.current.scrollIntoView({ behavior: "smooth" });
|
|
6458
|
-
}, [Yt]),
|
|
6504
|
+
}, [Yt]), st(() => {
|
|
6459
6505
|
function f(x) {
|
|
6460
6506
|
x.key === "Escape" && (Bt === "streaming" || Bt === "submitted") && (x.preventDefault(), Rn());
|
|
6461
6507
|
}
|
|
@@ -6475,15 +6521,15 @@ function sm({
|
|
|
6475
6521
|
const x = f.target.value;
|
|
6476
6522
|
nn(x);
|
|
6477
6523
|
}
|
|
6478
|
-
|
|
6524
|
+
st(() => {
|
|
6479
6525
|
if (!ie) return;
|
|
6480
|
-
function f(
|
|
6481
|
-
if (
|
|
6482
|
-
const
|
|
6483
|
-
|
|
6526
|
+
function f(k) {
|
|
6527
|
+
if (nt) {
|
|
6528
|
+
const N = k.clientX - At.x, V = k.clientY - At.y;
|
|
6529
|
+
N >= a && N <= c && se(N), V >= 400 && V <= 1e3 && Le(V);
|
|
6484
6530
|
} else {
|
|
6485
|
-
const
|
|
6486
|
-
|
|
6531
|
+
const N = window.innerWidth - k.clientX;
|
|
6532
|
+
N >= a && N <= c && se(N);
|
|
6487
6533
|
}
|
|
6488
6534
|
}
|
|
6489
6535
|
function x() {
|
|
@@ -6492,7 +6538,7 @@ function sm({
|
|
|
6492
6538
|
return window.addEventListener("mousemove", f), window.addEventListener("mouseup", x), () => {
|
|
6493
6539
|
window.removeEventListener("mousemove", f), window.removeEventListener("mouseup", x);
|
|
6494
6540
|
};
|
|
6495
|
-
}, [ie, Kt, re,
|
|
6541
|
+
}, [ie, Kt, re, nt, At, a, c]);
|
|
6496
6542
|
function lc(f) {
|
|
6497
6543
|
f.preventDefault(), $t(!0);
|
|
6498
6544
|
}
|
|
@@ -6506,28 +6552,28 @@ function sm({
|
|
|
6506
6552
|
Vt(!Dt), localStorage.setItem("arcten-sidebar-minimized", JSON.stringify(!Dt));
|
|
6507
6553
|
}
|
|
6508
6554
|
function hc(f) {
|
|
6509
|
-
|
|
6555
|
+
nt && (ve(!0), Dn({
|
|
6510
6556
|
x: f.clientX - At.x,
|
|
6511
6557
|
y: f.clientY - At.y
|
|
6512
6558
|
}));
|
|
6513
6559
|
}
|
|
6514
|
-
return
|
|
6515
|
-
if (!
|
|
6560
|
+
return st(() => {
|
|
6561
|
+
if (!nt) return;
|
|
6516
6562
|
function f() {
|
|
6517
6563
|
Oe((x) => {
|
|
6518
|
-
const
|
|
6519
|
-
if (
|
|
6520
|
-
const j = { x:
|
|
6564
|
+
const N = window.innerWidth - 50, V = window.innerHeight - 50, F = 50 - Kt, Q = 0, G = Math.max(F, Math.min(x.x, N)), rt = Math.max(Q, Math.min(x.y, V));
|
|
6565
|
+
if (G !== x.x || rt !== x.y) {
|
|
6566
|
+
const j = { x: G, y: rt };
|
|
6521
6567
|
return localStorage.setItem("arcten-sidebar-position", JSON.stringify(j)), j;
|
|
6522
6568
|
}
|
|
6523
6569
|
return x;
|
|
6524
6570
|
});
|
|
6525
6571
|
}
|
|
6526
6572
|
return window.addEventListener("resize", f), () => window.removeEventListener("resize", f);
|
|
6527
|
-
}, [
|
|
6573
|
+
}, [nt, Kt]), st(() => {
|
|
6528
6574
|
if (!tn) return;
|
|
6529
|
-
function f(
|
|
6530
|
-
const
|
|
6575
|
+
function f(k) {
|
|
6576
|
+
const N = k.clientX - je.x, V = k.clientY - je.y, F = 50, Q = window.innerWidth - F, G = window.innerHeight - F, rt = F - Kt, j = 0, U = Math.max(rt, Math.min(N, Q)), B = Math.max(j, Math.min(V, G));
|
|
6531
6577
|
Oe({ x: U, y: B });
|
|
6532
6578
|
}
|
|
6533
6579
|
function x() {
|
|
@@ -6536,9 +6582,9 @@ function sm({
|
|
|
6536
6582
|
return window.addEventListener("mousemove", f), window.addEventListener("mouseup", x), () => {
|
|
6537
6583
|
window.removeEventListener("mousemove", f), window.removeEventListener("mouseup", x);
|
|
6538
6584
|
};
|
|
6539
|
-
}, [tn, je, At, Kt]), En ?
|
|
6585
|
+
}, [tn, je, At, Kt]), En ? Y ? /* @__PURE__ */ m("div", { className: "fixed right-0 top-0 h-screen w-96 flex items-center justify-center p-4 bg-stone-50 dark:bg-stone-900 border-l border-border", children: /* @__PURE__ */ R("div", { className: "p-4 bg-destructive/10 text-destructive text-sm rounded-lg", children: [
|
|
6540
6586
|
"Authentication error: ",
|
|
6541
|
-
|
|
6587
|
+
Y
|
|
6542
6588
|
] }) }) : S ? /* @__PURE__ */ m(Wu, { features: wf, children: /* @__PURE__ */ m(
|
|
6543
6589
|
Fn,
|
|
6544
6590
|
{
|
|
@@ -6546,24 +6592,24 @@ function sm({
|
|
|
6546
6592
|
"data-theme": t,
|
|
6547
6593
|
"data-layout": e,
|
|
6548
6594
|
"data-model": n,
|
|
6549
|
-
initial:
|
|
6550
|
-
animate:
|
|
6595
|
+
initial: nt ? { opacity: 0, scale: 0.95, filter: "blur(4px)" } : !1,
|
|
6596
|
+
animate: nt ? { opacity: 1, scale: 1, filter: "blur(0px)" } : {},
|
|
6551
6597
|
transition: { duration: 0.2, ease: "easeOut" },
|
|
6552
6598
|
className: `
|
|
6553
|
-
${
|
|
6599
|
+
${nt ? "fixed z-50 shadow-xl rounded-xl" : "h-screen flex-shrink-0 relative rounded-l-2xl"}
|
|
6554
6600
|
${Wt ? "bg-stone-50 dark:bg-stone-900" : "bg-stone-100 dark:bg-stone-800 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors duration-200"}
|
|
6555
|
-
${
|
|
6601
|
+
${nt ? "border border-border" : "border-l border-border"}
|
|
6556
6602
|
${Wt ? "" : "w-[30px]"}
|
|
6557
6603
|
`,
|
|
6558
|
-
style: Wt ?
|
|
6604
|
+
style: Wt ? nt ? {
|
|
6559
6605
|
width: `${Kt}px`,
|
|
6560
6606
|
height: Dt ? "auto" : `${re}px`,
|
|
6561
6607
|
left: `${At.x}px`,
|
|
6562
6608
|
top: `${At.y}px`
|
|
6563
6609
|
} : { width: `${Kt}px` } : void 0,
|
|
6564
6610
|
onClick: Wt ? void 0 : ic,
|
|
6565
|
-
children: Wt ? /* @__PURE__ */
|
|
6566
|
-
!
|
|
6611
|
+
children: Wt ? /* @__PURE__ */ R(Fe, { children: [
|
|
6612
|
+
!nt && /* @__PURE__ */ m(
|
|
6567
6613
|
"div",
|
|
6568
6614
|
{
|
|
6569
6615
|
className: "absolute left-0 top-0 bottom-0 w-1 cursor-col-resize hover:bg-blue-500/40 hover:w-1 transition-all group",
|
|
@@ -6571,7 +6617,7 @@ function sm({
|
|
|
6571
6617
|
children: /* @__PURE__ */ m("div", { className: "absolute left-0 top-0 bottom-0 w-3 -translate-x-1" })
|
|
6572
6618
|
}
|
|
6573
6619
|
),
|
|
6574
|
-
|
|
6620
|
+
nt && /* @__PURE__ */ R(Fe, { children: [
|
|
6575
6621
|
/* @__PURE__ */ m(
|
|
6576
6622
|
"div",
|
|
6577
6623
|
{
|
|
@@ -6604,30 +6650,30 @@ function sm({
|
|
|
6604
6650
|
}
|
|
6605
6651
|
)
|
|
6606
6652
|
] }),
|
|
6607
|
-
/* @__PURE__ */
|
|
6608
|
-
/* @__PURE__ */
|
|
6653
|
+
/* @__PURE__ */ R("div", { className: "flex flex-col h-full", children: [
|
|
6654
|
+
/* @__PURE__ */ R(
|
|
6609
6655
|
"div",
|
|
6610
6656
|
{
|
|
6611
|
-
className: `flex items-center justify-between p-3 border-b border-border ${
|
|
6612
|
-
onMouseDown:
|
|
6657
|
+
className: `flex items-center justify-between p-3 border-b border-border ${nt ? "cursor-move" : ""}`,
|
|
6658
|
+
onMouseDown: nt ? hc : void 0,
|
|
6613
6659
|
children: [
|
|
6614
6660
|
/* @__PURE__ */ m(
|
|
6615
6661
|
"h2",
|
|
6616
6662
|
{
|
|
6617
|
-
className: `text-base font-semibold ${
|
|
6618
|
-
onClick:
|
|
6663
|
+
className: `text-base font-semibold ${nt && Dt ? "cursor-pointer" : ""}`,
|
|
6664
|
+
onClick: nt && Dt ? (f) => {
|
|
6619
6665
|
f.stopPropagation(), $r();
|
|
6620
6666
|
} : void 0,
|
|
6621
6667
|
children: r
|
|
6622
6668
|
}
|
|
6623
6669
|
),
|
|
6624
|
-
/* @__PURE__ */
|
|
6625
|
-
/* @__PURE__ */
|
|
6670
|
+
/* @__PURE__ */ R("div", { className: "flex items-center gap-1", onClick: (f) => f.stopPropagation(), children: [
|
|
6671
|
+
/* @__PURE__ */ R(de, { children: [
|
|
6626
6672
|
/* @__PURE__ */ m(he, { asChild: !0, children: /* @__PURE__ */ m(
|
|
6627
6673
|
"button",
|
|
6628
6674
|
{
|
|
6629
6675
|
type: "button",
|
|
6630
|
-
className:
|
|
6676
|
+
className: yt(Ce({ variant: "ghost", size: "icon" }), "h-8 w-8"),
|
|
6631
6677
|
onClick: ac,
|
|
6632
6678
|
"aria-label": "New chat",
|
|
6633
6679
|
children: /* @__PURE__ */ m(kc, { className: "h-4 w-4" })
|
|
@@ -6635,39 +6681,39 @@ function sm({
|
|
|
6635
6681
|
) }),
|
|
6636
6682
|
/* @__PURE__ */ m(fe, { children: "Start a new conversation" })
|
|
6637
6683
|
] }),
|
|
6638
|
-
/* @__PURE__ */
|
|
6684
|
+
/* @__PURE__ */ R(de, { children: [
|
|
6639
6685
|
/* @__PURE__ */ m(he, { asChild: !0, children: /* @__PURE__ */ m(
|
|
6640
6686
|
"button",
|
|
6641
6687
|
{
|
|
6642
6688
|
type: "button",
|
|
6643
|
-
className:
|
|
6644
|
-
onClick:
|
|
6645
|
-
"aria-label":
|
|
6646
|
-
children:
|
|
6689
|
+
className: yt(Ce({ variant: "ghost", size: "icon" }), "h-8 w-8"),
|
|
6690
|
+
onClick: nt ? dc : uc,
|
|
6691
|
+
"aria-label": nt ? "Dock sidebar" : "Float sidebar",
|
|
6692
|
+
children: nt ? /* @__PURE__ */ m(Mc, { className: "h-4 w-4" }) : /* @__PURE__ */ m(Dc, { className: "h-4 w-4" })
|
|
6647
6693
|
}
|
|
6648
6694
|
) }),
|
|
6649
|
-
/* @__PURE__ */ m(fe, { children:
|
|
6695
|
+
/* @__PURE__ */ m(fe, { children: nt ? "Dock to sidebar" : "Undock to floating window" })
|
|
6650
6696
|
] }),
|
|
6651
|
-
/* @__PURE__ */
|
|
6697
|
+
/* @__PURE__ */ R(de, { children: [
|
|
6652
6698
|
/* @__PURE__ */ m(he, { asChild: !0, children: /* @__PURE__ */ m(
|
|
6653
6699
|
"button",
|
|
6654
6700
|
{
|
|
6655
6701
|
type: "button",
|
|
6656
|
-
className:
|
|
6657
|
-
onClick:
|
|
6658
|
-
"aria-label":
|
|
6659
|
-
children:
|
|
6702
|
+
className: yt(Ce({ variant: "ghost", size: "icon" }), "h-8 w-8"),
|
|
6703
|
+
onClick: nt ? $r : oc,
|
|
6704
|
+
"aria-label": nt ? Dt ? "Maximize" : "Minimize" : "Close sidebar",
|
|
6705
|
+
children: nt ? Dt ? /* @__PURE__ */ m(Ec, { className: "h-4 w-4" }) : /* @__PURE__ */ m(Nc, { className: "h-4 w-4" }) : /* @__PURE__ */ m(Kn, { className: "h-4 w-4" })
|
|
6660
6706
|
}
|
|
6661
6707
|
) }),
|
|
6662
|
-
/* @__PURE__ */ m(fe, { children:
|
|
6708
|
+
/* @__PURE__ */ m(fe, { children: nt ? Dt ? "Maximize window" : "Minimize to header" : "Close the chat" })
|
|
6663
6709
|
] })
|
|
6664
6710
|
] })
|
|
6665
6711
|
]
|
|
6666
6712
|
}
|
|
6667
6713
|
),
|
|
6668
|
-
!Dt && /* @__PURE__ */
|
|
6669
|
-
|
|
6670
|
-
/* @__PURE__ */
|
|
6714
|
+
!Dt && /* @__PURE__ */ R(Fe, { children: [
|
|
6715
|
+
b && K.length > 0 && /* @__PURE__ */ R("div", { className: `border-b border-border ${mt ? "flex flex-col flex-1" : ""}`, children: [
|
|
6716
|
+
/* @__PURE__ */ R("div", { className: "flex items-center justify-between px-3 py-1", children: [
|
|
6671
6717
|
/* @__PURE__ */ m("h3", { className: "text-xs font-semibold text-muted-foreground", children: "Recent chats" }),
|
|
6672
6718
|
/* @__PURE__ */ m(
|
|
6673
6719
|
Gn,
|
|
@@ -6675,18 +6721,18 @@ function sm({
|
|
|
6675
6721
|
variant: "ghost",
|
|
6676
6722
|
className: "h-auto px-2 py-1 text-xs text-muted-foreground hover:text-foreground",
|
|
6677
6723
|
onClick: () => {
|
|
6678
|
-
|
|
6724
|
+
mt || as(), Et(!mt);
|
|
6679
6725
|
},
|
|
6680
|
-
children:
|
|
6726
|
+
children: mt ? "Show less" : "View all"
|
|
6681
6727
|
}
|
|
6682
6728
|
)
|
|
6683
6729
|
] }),
|
|
6684
|
-
/* @__PURE__ */ m("div", { className: `px-2 pb-2 space-y-0.5 ${
|
|
6685
|
-
/* @__PURE__ */
|
|
6730
|
+
/* @__PURE__ */ m("div", { className: `px-2 pb-2 space-y-0.5 ${mt ? "flex-1 overflow-y-auto" : ""}`, children: K.slice(0, mt ? void 0 : 3).map((f) => /* @__PURE__ */ R("div", { className: "group relative", children: [
|
|
6731
|
+
/* @__PURE__ */ R(
|
|
6686
6732
|
Tf,
|
|
6687
6733
|
{
|
|
6688
6734
|
type: "button",
|
|
6689
|
-
className:
|
|
6735
|
+
className: yt(Ce({ variant: "ghost" }), "w-full justify-between h-auto py-1 px-3 font-normal active:scale-[0.99]"),
|
|
6690
6736
|
onClick: () => nc(f),
|
|
6691
6737
|
children: [
|
|
6692
6738
|
/* @__PURE__ */ m("span", { className: "text-xs truncate", children: f.title }),
|
|
@@ -6708,12 +6754,12 @@ function sm({
|
|
|
6708
6754
|
)
|
|
6709
6755
|
] }, f._id)) })
|
|
6710
6756
|
] }),
|
|
6711
|
-
/* @__PURE__ */
|
|
6712
|
-
/* @__PURE__ */ m("div", { className: "flex-1 overflow-y-auto p-4 space-y-4 scroll-smooth", children: Yt.length === 0 ? /* @__PURE__ */
|
|
6757
|
+
/* @__PURE__ */ R("div", { className: "flex-1 flex flex-col overflow-hidden relative", children: [
|
|
6758
|
+
/* @__PURE__ */ m("div", { className: "flex-1 overflow-y-auto p-4 space-y-4 scroll-smooth", children: Yt.length === 0 ? /* @__PURE__ */ R("div", { className: "flex flex-col items-center justify-center h-full", children: [
|
|
6713
6759
|
o && /* @__PURE__ */ m("div", { className: "mb-6", children: o }),
|
|
6714
6760
|
/* @__PURE__ */ m("h3", { className: "text-lg font-semibold text-center mb-2", children: "How can I help you?" }),
|
|
6715
|
-
A.length > 0 && /* @__PURE__ */ m("div", { className: "mt-4 px-4 max-w-md mx-auto", children: /* @__PURE__ */
|
|
6716
|
-
(
|
|
6761
|
+
A.length > 0 && /* @__PURE__ */ m("div", { className: "mt-4 px-4 max-w-md mx-auto", children: /* @__PURE__ */ R("div", { className: "flex flex-wrap gap-2 justify-center", children: [
|
|
6762
|
+
(I ? A : A.slice(0, 10)).map((f) => /* @__PURE__ */ R(de, { children: [
|
|
6717
6763
|
/* @__PURE__ */ m(he, { asChild: !0, children: /* @__PURE__ */ m(
|
|
6718
6764
|
cs,
|
|
6719
6765
|
{
|
|
@@ -6725,23 +6771,23 @@ function sm({
|
|
|
6725
6771
|
children: f.friendlyName
|
|
6726
6772
|
}
|
|
6727
6773
|
) }),
|
|
6728
|
-
/* @__PURE__ */ m(fe, { children: /* @__PURE__ */
|
|
6774
|
+
/* @__PURE__ */ m(fe, { children: /* @__PURE__ */ R("div", { className: "max-w-xs", children: [
|
|
6729
6775
|
/* @__PURE__ */ m("p", { className: "font-medium", children: f.description }),
|
|
6730
|
-
/* @__PURE__ */
|
|
6776
|
+
/* @__PURE__ */ R("p", { className: "text-xs text-muted-foreground mt-2", children: [
|
|
6731
6777
|
/* @__PURE__ */ m("span", { className: "font-medium", children: "Example:" }),
|
|
6732
6778
|
' "',
|
|
6733
6779
|
f.sampleUsage,
|
|
6734
6780
|
'"'
|
|
6735
6781
|
] }),
|
|
6736
|
-
f.paramCount > 0 && /* @__PURE__ */
|
|
6782
|
+
f.paramCount > 0 && /* @__PURE__ */ R("p", { className: "text-xs text-muted-foreground mt-1", children: [
|
|
6737
6783
|
/* @__PURE__ */ m("span", { className: "font-medium", children: "Parameters:" }),
|
|
6738
6784
|
" ",
|
|
6739
6785
|
f.params.join(", ")
|
|
6740
6786
|
] })
|
|
6741
6787
|
] }) })
|
|
6742
6788
|
] }, f.name)),
|
|
6743
|
-
A.length > 10 && !
|
|
6744
|
-
/* @__PURE__ */ m(he, { asChild: !0, children: /* @__PURE__ */
|
|
6789
|
+
A.length > 10 && !I && /* @__PURE__ */ R(de, { children: [
|
|
6790
|
+
/* @__PURE__ */ m(he, { asChild: !0, children: /* @__PURE__ */ R(
|
|
6745
6791
|
cs,
|
|
6746
6792
|
{
|
|
6747
6793
|
variant: "secondary",
|
|
@@ -6754,10 +6800,10 @@ function sm({
|
|
|
6754
6800
|
]
|
|
6755
6801
|
}
|
|
6756
6802
|
) }),
|
|
6757
|
-
/* @__PURE__ */ m(fe, { children: /* @__PURE__ */
|
|
6803
|
+
/* @__PURE__ */ m(fe, { children: /* @__PURE__ */ R("div", { className: "max-w-xs", children: [
|
|
6758
6804
|
/* @__PURE__ */ m("p", { className: "font-medium mb-2", children: "Additional tools:" }),
|
|
6759
|
-
/* @__PURE__ */ m("div", { className: "space-y-1 max-h-64 overflow-y-auto pr-2", children: A.slice(10).map((f) => /* @__PURE__ */
|
|
6760
|
-
/* @__PURE__ */
|
|
6805
|
+
/* @__PURE__ */ m("div", { className: "space-y-1 max-h-64 overflow-y-auto pr-2", children: A.slice(10).map((f) => /* @__PURE__ */ R("div", { children: [
|
|
6806
|
+
/* @__PURE__ */ R("span", { className: "font-medium text-xs", children: [
|
|
6761
6807
|
f.friendlyName,
|
|
6762
6808
|
":"
|
|
6763
6809
|
] }),
|
|
@@ -6766,7 +6812,7 @@ function sm({
|
|
|
6766
6812
|
/* @__PURE__ */ m("p", { className: "text-xs text-muted-foreground mt-2 italic", children: "Click to show all tools" })
|
|
6767
6813
|
] }) })
|
|
6768
6814
|
] }),
|
|
6769
|
-
|
|
6815
|
+
I && A.length > 10 && /* @__PURE__ */ m(
|
|
6770
6816
|
cs,
|
|
6771
6817
|
{
|
|
6772
6818
|
variant: "secondary",
|
|
@@ -6776,27 +6822,27 @@ function sm({
|
|
|
6776
6822
|
}
|
|
6777
6823
|
)
|
|
6778
6824
|
] }) })
|
|
6779
|
-
] }) : /* @__PURE__ */
|
|
6825
|
+
] }) : /* @__PURE__ */ R(Fe, { children: [
|
|
6780
6826
|
Yt.map((f) => {
|
|
6781
|
-
const
|
|
6782
|
-
let
|
|
6783
|
-
f.role === "assistant" && f.parts.some((U) => U.timestamp) && (
|
|
6784
|
-
const
|
|
6785
|
-
return
|
|
6827
|
+
const k = f.parts.filter((j) => j.type === "text").map((j) => j.text).join("");
|
|
6828
|
+
let N = f.parts;
|
|
6829
|
+
f.role === "assistant" && f.parts.some((U) => U.timestamp) && (N = [...f.parts].sort((U, B) => {
|
|
6830
|
+
const vt = U.timestamp || 0, pt = B.timestamp || 0;
|
|
6831
|
+
return vt - pt;
|
|
6786
6832
|
}));
|
|
6787
|
-
let
|
|
6833
|
+
let V = [], F = /* @__PURE__ */ new Map(), Q = [], G, rt = !0;
|
|
6788
6834
|
if (f.role === "assistant") {
|
|
6789
|
-
const j =
|
|
6790
|
-
j.forEach((
|
|
6791
|
-
const { citations: le, citationMap: kt, groupedCitations: Rt, referencesText: ue } = so(
|
|
6792
|
-
|
|
6793
|
-
}), U.forEach((
|
|
6794
|
-
|
|
6835
|
+
const j = N.filter((pt) => pt.type === "text" && pt.text), U = [], B = [];
|
|
6836
|
+
j.forEach((pt) => {
|
|
6837
|
+
const { citations: le, citationMap: kt, groupedCitations: Rt, referencesText: ue } = so(pt.text);
|
|
6838
|
+
V.push(...le), U.push(kt), Rt && B.push(...Rt), ue && (G = ue);
|
|
6839
|
+
}), U.forEach((pt) => {
|
|
6840
|
+
pt.forEach((le, kt) => {
|
|
6795
6841
|
F.has(kt) || F.set(kt, le);
|
|
6796
6842
|
});
|
|
6797
|
-
}),
|
|
6798
|
-
new Map(B.map((
|
|
6799
|
-
).sort((
|
|
6843
|
+
}), Q = Array.from(
|
|
6844
|
+
new Map(B.map((pt) => [pt.url, pt])).values()
|
|
6845
|
+
).sort((pt, le) => (pt.numbers[0] || 0) - (le.numbers[0] || 0)), rt = !(Bt === "streaming" && f.id === Yt.at(-1)?.id);
|
|
6800
6846
|
}
|
|
6801
6847
|
return /* @__PURE__ */ m(
|
|
6802
6848
|
"div",
|
|
@@ -6813,12 +6859,12 @@ function sm({
|
|
|
6813
6859
|
animate: { opacity: 1, filter: "blur(0px)" },
|
|
6814
6860
|
transition: { duration: 0.3, ease: "easeOut" },
|
|
6815
6861
|
className: "text-sm whitespace-pre-wrap inline-block bg-stone-100 dark:bg-stone-800 px-3 py-2 rounded-xl",
|
|
6816
|
-
children:
|
|
6862
|
+
children: k
|
|
6817
6863
|
}
|
|
6818
|
-
) : /* @__PURE__ */ m("div", { className: "space-y-2", children:
|
|
6864
|
+
) : /* @__PURE__ */ m("div", { className: "space-y-2", children: N.map((j, U) => {
|
|
6819
6865
|
if (j.type?.startsWith("tool-")) {
|
|
6820
|
-
const B = j.type?.replace("tool-", "") || "",
|
|
6821
|
-
if (
|
|
6866
|
+
const B = j.type?.replace("tool-", "") || "", vt = Nn.find((kt) => kt.name === B), pt = j.state === "input-available", le = j.state === "output-available";
|
|
6867
|
+
if (pt && cn.has(B), pt) {
|
|
6822
6868
|
if (cn.has(B))
|
|
6823
6869
|
return null;
|
|
6824
6870
|
const kt = As(j.input);
|
|
@@ -6832,7 +6878,7 @@ function sm({
|
|
|
6832
6878
|
Pf,
|
|
6833
6879
|
{
|
|
6834
6880
|
toolName: B,
|
|
6835
|
-
description:
|
|
6881
|
+
description: vt?.description || "",
|
|
6836
6882
|
args: kt,
|
|
6837
6883
|
onApprove: async () => {
|
|
6838
6884
|
if (rn.has(j.toolCallId))
|
|
@@ -6883,24 +6929,24 @@ function sm({
|
|
|
6883
6929
|
return null;
|
|
6884
6930
|
}
|
|
6885
6931
|
if (j.type === "text" && j.text && xe) {
|
|
6886
|
-
const { processedText: B } = so(j.text), kt = !
|
|
6932
|
+
const { processedText: B } = so(j.text), kt = !N.slice(U + 1).some((Rt) => Rt.type === "text" && Rt.text) && rt && F.size > 0;
|
|
6887
6933
|
return /* @__PURE__ */ m(
|
|
6888
6934
|
Ff,
|
|
6889
6935
|
{
|
|
6890
6936
|
text: B,
|
|
6891
|
-
citations:
|
|
6937
|
+
citations: V,
|
|
6892
6938
|
citationMap: F,
|
|
6893
|
-
groupedCitations: kt ?
|
|
6894
|
-
referencesText: kt ?
|
|
6939
|
+
groupedCitations: kt ? Q : void 0,
|
|
6940
|
+
referencesText: kt ? G : void 0,
|
|
6895
6941
|
ResponseComponent: xe,
|
|
6896
6942
|
className: "text-sm prose prose-sm dark:prose-invert max-w-none",
|
|
6897
|
-
showCitations:
|
|
6943
|
+
showCitations: D,
|
|
6898
6944
|
showReferences: kt
|
|
6899
6945
|
},
|
|
6900
6946
|
`${f.id}-${U}`
|
|
6901
6947
|
);
|
|
6902
6948
|
}
|
|
6903
|
-
return j.type === "reasoning" && j.text ? /* @__PURE__ */
|
|
6949
|
+
return j.type === "reasoning" && j.text ? /* @__PURE__ */ R(
|
|
6904
6950
|
Ya,
|
|
6905
6951
|
{
|
|
6906
6952
|
className: "w-full",
|
|
@@ -6921,12 +6967,12 @@ function sm({
|
|
|
6921
6967
|
}),
|
|
6922
6968
|
/* @__PURE__ */ m("div", { ref: en })
|
|
6923
6969
|
] }) }),
|
|
6924
|
-
Or && /* @__PURE__ */
|
|
6970
|
+
Or && /* @__PURE__ */ R("div", { className: "px-4 py-2 bg-destructive/10 text-destructive text-xs", children: [
|
|
6925
6971
|
"Error: ",
|
|
6926
6972
|
Or.message
|
|
6927
6973
|
] }),
|
|
6928
|
-
/* @__PURE__ */
|
|
6929
|
-
/* @__PURE__ */ m(_u, { mode: "wait", children: (Bt === "streaming" || Bt === "submitted") && /* @__PURE__ */
|
|
6974
|
+
/* @__PURE__ */ R("div", { className: "p-4 border-t border-border relative overflow-visible", children: [
|
|
6975
|
+
/* @__PURE__ */ m(_u, { mode: "wait", children: (Bt === "streaming" || Bt === "submitted") && /* @__PURE__ */ R(
|
|
6930
6976
|
Fn,
|
|
6931
6977
|
{
|
|
6932
6978
|
initial: { opacity: 0, filter: "blur(4px)", y: 5 },
|
|
@@ -6959,7 +7005,7 @@ function sm({
|
|
|
6959
7005
|
]
|
|
6960
7006
|
}
|
|
6961
7007
|
) }),
|
|
6962
|
-
/* @__PURE__ */
|
|
7008
|
+
/* @__PURE__ */ R("form", { onSubmit: jr, className: "relative", children: [
|
|
6963
7009
|
/* @__PURE__ */ m(
|
|
6964
7010
|
fo,
|
|
6965
7011
|
{
|
|
@@ -6975,31 +7021,31 @@ function sm({
|
|
|
6975
7021
|
}
|
|
6976
7022
|
}
|
|
6977
7023
|
),
|
|
6978
|
-
Bt === "streaming" || Bt === "submitted" ? /* @__PURE__ */
|
|
7024
|
+
Bt === "streaming" || Bt === "submitted" ? /* @__PURE__ */ R(de, { children: [
|
|
6979
7025
|
/* @__PURE__ */ m(he, { asChild: !0, children: /* @__PURE__ */ m(
|
|
6980
7026
|
"button",
|
|
6981
7027
|
{
|
|
6982
7028
|
type: "button",
|
|
6983
|
-
className:
|
|
7029
|
+
className: yt(Ce({ variant: "ghost", size: "icon" }), "absolute top-1/2 -translate-y-1/2 right-2 h-8 w-8"),
|
|
6984
7030
|
onClick: Rn,
|
|
6985
7031
|
children: /* @__PURE__ */ m(Vc, { className: "h-4 w-4" })
|
|
6986
7032
|
}
|
|
6987
7033
|
) }),
|
|
6988
|
-
/* @__PURE__ */
|
|
7034
|
+
/* @__PURE__ */ R(fe, { children: [
|
|
6989
7035
|
/* @__PURE__ */ m(Br, { children: "Escape" }),
|
|
6990
7036
|
" to stop"
|
|
6991
7037
|
] })
|
|
6992
|
-
] }) : /* @__PURE__ */
|
|
7038
|
+
] }) : /* @__PURE__ */ R(de, { children: [
|
|
6993
7039
|
/* @__PURE__ */ m(he, { asChild: !0, children: /* @__PURE__ */ m(
|
|
6994
7040
|
"button",
|
|
6995
7041
|
{
|
|
6996
7042
|
type: "submit",
|
|
6997
|
-
className:
|
|
7043
|
+
className: yt(Ce({ variant: "ghost", size: "icon" }), "absolute top-1/2 -translate-y-1/2 right-2 h-8 w-8"),
|
|
6998
7044
|
disabled: !ae.trim(),
|
|
6999
7045
|
children: /* @__PURE__ */ m(Rc, { className: "h-4 w-4" })
|
|
7000
7046
|
}
|
|
7001
7047
|
) }),
|
|
7002
|
-
/* @__PURE__ */
|
|
7048
|
+
/* @__PURE__ */ R(fe, { children: [
|
|
7003
7049
|
/* @__PURE__ */ m(Br, { children: "Enter" }),
|
|
7004
7050
|
" to send"
|
|
7005
7051
|
] })
|
|
@@ -7007,7 +7053,7 @@ function sm({
|
|
|
7007
7053
|
] })
|
|
7008
7054
|
] })
|
|
7009
7055
|
] }),
|
|
7010
|
-
/* @__PURE__ */
|
|
7056
|
+
/* @__PURE__ */ R(
|
|
7011
7057
|
"a",
|
|
7012
7058
|
{
|
|
7013
7059
|
href: "https://arcten.com",
|
|
@@ -7023,7 +7069,7 @@ function sm({
|
|
|
7023
7069
|
)
|
|
7024
7070
|
] })
|
|
7025
7071
|
] })
|
|
7026
|
-
] }) : /* @__PURE__ */
|
|
7072
|
+
] }) : /* @__PURE__ */ R("div", { className: "flex flex-col items-center justify-center gap-3 h-full cursor-pointer", children: [
|
|
7027
7073
|
/* @__PURE__ */ m(Ic, { className: "h-5 w-5 text-stone-600 dark:text-stone-400" }),
|
|
7028
7074
|
/* @__PURE__ */ m("span", { className: "text-xs font-medium text-stone-600 dark:text-stone-400 [writing-mode:vertical-lr]", children: "AI agent" })
|
|
7029
7075
|
] })
|
|
@@ -7048,7 +7094,7 @@ function gn(t) {
|
|
|
7048
7094
|
}
|
|
7049
7095
|
return t;
|
|
7050
7096
|
}
|
|
7051
|
-
function
|
|
7097
|
+
function Uf(t) {
|
|
7052
7098
|
if (typeof t == "string") {
|
|
7053
7099
|
try {
|
|
7054
7100
|
const e = JSON.parse(t);
|
|
@@ -7060,7 +7106,7 @@ function _f(t) {
|
|
|
7060
7106
|
}
|
|
7061
7107
|
return t && typeof t == "object" && !Array.isArray(t) ? gn(t) : {};
|
|
7062
7108
|
}
|
|
7063
|
-
function
|
|
7109
|
+
function sm({
|
|
7064
7110
|
apiBaseUrl: t = "https://api.arcten.com",
|
|
7065
7111
|
tokenEndpoint: e = "/api/arcten/token",
|
|
7066
7112
|
clientToken: n,
|
|
@@ -7075,151 +7121,151 @@ function rm({
|
|
|
7075
7121
|
state: d,
|
|
7076
7122
|
onStateChange: h,
|
|
7077
7123
|
allowStateEdits: p = !0,
|
|
7078
|
-
onToolCall:
|
|
7079
|
-
onFinish:
|
|
7080
|
-
sources:
|
|
7081
|
-
ragConfig:
|
|
7082
|
-
ragFilters:
|
|
7124
|
+
onToolCall: T,
|
|
7125
|
+
onFinish: w,
|
|
7126
|
+
sources: b,
|
|
7127
|
+
ragConfig: g,
|
|
7128
|
+
ragFilters: v
|
|
7083
7129
|
// Deprecated: use ragConfig or sources instead
|
|
7084
7130
|
} = {}) {
|
|
7085
|
-
const
|
|
7131
|
+
const y = et(() => g !== void 0 ? g : v ? { enabled: !0, filters: v } : b && b.length > 0 ? {
|
|
7086
7132
|
enabled: !0,
|
|
7087
|
-
organizationId:
|
|
7133
|
+
organizationId: b[0],
|
|
7088
7134
|
// Use first source as default
|
|
7089
7135
|
autoExecute: !0,
|
|
7090
7136
|
// Default to auto-execute when sources are provided
|
|
7091
7137
|
filters: void 0
|
|
7092
|
-
} : { enabled: !1 }, [
|
|
7138
|
+
} : { enabled: !1 }, [b, g, v]), [M, C] = W(n || null), D = bt(n || null), [E, S] = W(null), [$, L] = W(null), Y = bt(null), [J, H] = W([]), [q, ct] = W(
|
|
7093
7139
|
l || (typeof window < "u" ? crypto.randomUUID() : null)
|
|
7094
|
-
), [
|
|
7140
|
+
), [_, Z] = W(!1), [it, lt] = W(/* @__PURE__ */ new Set()), ot = d !== void 0, [ee, Re] = W({}), wt = bt({}), ne = ot ? d || {} : ee;
|
|
7095
7141
|
ot && d ? wt.current = d : ot || (wt.current = ee);
|
|
7096
|
-
const [Wt, Ie] =
|
|
7097
|
-
if (!
|
|
7142
|
+
const [Wt, Ie] = W(!1), [Kt, se] = W(null), re = bt(!1), Le = yn(async (A, P = 3) => {
|
|
7143
|
+
if (!q || !D.current)
|
|
7098
7144
|
return;
|
|
7099
|
-
const
|
|
7100
|
-
const K = `${t.replace("/chat", "").replace(/\/$/, "")}/convex/api/mutation`,
|
|
7145
|
+
const I = async () => {
|
|
7146
|
+
const K = `${t.replace("/chat", "").replace(/\/$/, "")}/convex/api/mutation`, tt = await fetch(K, {
|
|
7101
7147
|
method: "POST",
|
|
7102
7148
|
headers: {
|
|
7103
7149
|
"Content-Type": "application/json",
|
|
7104
|
-
Authorization: `Bearer ${
|
|
7150
|
+
Authorization: `Bearer ${D.current}`
|
|
7105
7151
|
},
|
|
7106
7152
|
body: JSON.stringify({
|
|
7107
7153
|
path: "conversations:mergeStateByChatId",
|
|
7108
|
-
args: { chatId:
|
|
7154
|
+
args: { chatId: q, updates: A },
|
|
7109
7155
|
format: "json"
|
|
7110
7156
|
})
|
|
7111
7157
|
});
|
|
7112
|
-
if (!
|
|
7113
|
-
if (
|
|
7158
|
+
if (!tt.ok) {
|
|
7159
|
+
if (tt.status === 404) {
|
|
7114
7160
|
console.warn("[useAgent] Convex API endpoint not available (404), state changes will not be persisted");
|
|
7115
7161
|
return;
|
|
7116
7162
|
}
|
|
7117
|
-
const
|
|
7118
|
-
throw new Error(`Failed to sync conversation state: ${
|
|
7163
|
+
const X = await tt.text().catch(() => "Unknown error");
|
|
7164
|
+
throw new Error(`Failed to sync conversation state: ${tt.status} ${X}`);
|
|
7119
7165
|
}
|
|
7120
7166
|
};
|
|
7121
7167
|
for (let O = 0; O < P; O++)
|
|
7122
7168
|
try {
|
|
7123
|
-
await
|
|
7169
|
+
await I(), se(null);
|
|
7124
7170
|
return;
|
|
7125
7171
|
} catch (K) {
|
|
7126
7172
|
if (O === P - 1) {
|
|
7127
|
-
const
|
|
7128
|
-
throw se(
|
|
7173
|
+
const X = K instanceof Error ? K : new Error(String(K));
|
|
7174
|
+
throw se(X), console.error("Failed to sync state to Convex after retries:", K), X;
|
|
7129
7175
|
}
|
|
7130
|
-
await new Promise((
|
|
7176
|
+
await new Promise((X) => setTimeout(X, Math.pow(2, O) * 100));
|
|
7131
7177
|
}
|
|
7132
|
-
}, [
|
|
7178
|
+
}, [q, t, D]), ie = et(() => function() {
|
|
7133
7179
|
return wt.current;
|
|
7134
|
-
}, []), $t =
|
|
7135
|
-
const
|
|
7136
|
-
wt.current =
|
|
7180
|
+
}, []), $t = et(() => async function(P) {
|
|
7181
|
+
const I = { ...wt.current, ...P };
|
|
7182
|
+
wt.current = I, ot || Re(I), h && h(I);
|
|
7137
7183
|
try {
|
|
7138
7184
|
await Le(P);
|
|
7139
7185
|
} catch (O) {
|
|
7140
7186
|
throw O;
|
|
7141
7187
|
}
|
|
7142
7188
|
}, [Le, h, ot]);
|
|
7143
|
-
|
|
7189
|
+
st(() => {
|
|
7144
7190
|
ot && d && (wt.current = d);
|
|
7145
7191
|
}, [ot, d]);
|
|
7146
|
-
const
|
|
7192
|
+
const nt = et(() => y?.enabled ? async function(P, I = 20, O) {
|
|
7147
7193
|
const K = {
|
|
7148
|
-
...
|
|
7194
|
+
...y.filters,
|
|
7149
7195
|
...O
|
|
7150
7196
|
};
|
|
7151
|
-
if (
|
|
7152
|
-
const
|
|
7153
|
-
(
|
|
7197
|
+
if (b && b.length > 1) {
|
|
7198
|
+
const X = b.map(
|
|
7199
|
+
(ut) => fetch(`${t}/search`, {
|
|
7154
7200
|
method: "POST",
|
|
7155
7201
|
headers: {
|
|
7156
7202
|
"Content-Type": "application/json",
|
|
7157
|
-
...
|
|
7203
|
+
...D.current ? { Authorization: `Bearer ${D.current}` } : {}
|
|
7158
7204
|
},
|
|
7159
7205
|
body: JSON.stringify({
|
|
7160
7206
|
q: P,
|
|
7161
|
-
k: Math.min(
|
|
7162
|
-
organizationId:
|
|
7207
|
+
k: Math.min(I, 100),
|
|
7208
|
+
organizationId: ut,
|
|
7163
7209
|
...Object.keys(K).length > 0 ? { filters: K } : {}
|
|
7164
7210
|
})
|
|
7165
7211
|
}).then((at) => at.ok ? at.json() : null)
|
|
7166
|
-
), Pt = await Promise.all(
|
|
7167
|
-
for (const
|
|
7168
|
-
|
|
7169
|
-
|
|
7170
|
-
const $e =
|
|
7212
|
+
), Pt = await Promise.all(X), mt = [];
|
|
7213
|
+
for (const ut of Pt)
|
|
7214
|
+
ut?.candidates && mt.push(...ut.candidates);
|
|
7215
|
+
mt.sort((ut, at) => {
|
|
7216
|
+
const $e = ut.scores?.rerank || ut.scores?.dense || 0;
|
|
7171
7217
|
return (at.scores?.rerank || at.scores?.dense || 0) - $e;
|
|
7172
7218
|
});
|
|
7173
|
-
const Et =
|
|
7174
|
-
const $e =
|
|
7219
|
+
const Et = mt.slice(0, I).map((ut, at) => {
|
|
7220
|
+
const $e = ut.citation || ut.url;
|
|
7175
7221
|
return {
|
|
7176
7222
|
rank: at + 1,
|
|
7177
|
-
doc_id:
|
|
7178
|
-
block_id:
|
|
7179
|
-
url:
|
|
7223
|
+
doc_id: ut.doc_id,
|
|
7224
|
+
block_id: ut.block_id,
|
|
7225
|
+
url: ut.url,
|
|
7180
7226
|
citation: $e,
|
|
7181
|
-
title:
|
|
7182
|
-
snippet:
|
|
7183
|
-
score:
|
|
7227
|
+
title: ut.title || "Untitled",
|
|
7228
|
+
snippet: ut.snippet,
|
|
7229
|
+
score: ut.scores?.rerank || ut.scores?.dense || 0,
|
|
7184
7230
|
metadata: {
|
|
7185
|
-
site:
|
|
7186
|
-
lang:
|
|
7187
|
-
contentType:
|
|
7231
|
+
site: ut.metadata?.site,
|
|
7232
|
+
lang: ut.metadata?.lang,
|
|
7233
|
+
contentType: ut.metadata?.content_type
|
|
7188
7234
|
}
|
|
7189
7235
|
};
|
|
7190
7236
|
});
|
|
7191
7237
|
return {
|
|
7192
7238
|
success: !0,
|
|
7193
7239
|
query: P,
|
|
7194
|
-
total:
|
|
7240
|
+
total: mt.length,
|
|
7195
7241
|
results: Et,
|
|
7196
|
-
summary: `Found ${
|
|
7242
|
+
summary: `Found ${mt.length} relevant results across ${b.length} source(s) for "${P}". Top result: ${Et[0]?.title || "N/A"}`
|
|
7197
7243
|
};
|
|
7198
7244
|
}
|
|
7199
|
-
const
|
|
7245
|
+
const tt = y.organizationId && y.organizationId !== "default" ? y.organizationId : b && b.length > 0 ? b[0] : void 0;
|
|
7200
7246
|
try {
|
|
7201
|
-
const
|
|
7247
|
+
const X = {
|
|
7202
7248
|
q: P,
|
|
7203
|
-
k: Math.min(
|
|
7249
|
+
k: Math.min(I, 100)
|
|
7204
7250
|
};
|
|
7205
|
-
|
|
7251
|
+
tt && (X.organizationId = tt), Object.keys(K).length > 0 && (X.filters = K);
|
|
7206
7252
|
const Pt = {
|
|
7207
7253
|
"Content-Type": "application/json"
|
|
7208
7254
|
};
|
|
7209
|
-
|
|
7210
|
-
const
|
|
7255
|
+
D.current && (Pt.Authorization = `Bearer ${D.current}`);
|
|
7256
|
+
const mt = await fetch(`${t}/search`, {
|
|
7211
7257
|
method: "POST",
|
|
7212
7258
|
headers: Pt,
|
|
7213
|
-
body: JSON.stringify(
|
|
7259
|
+
body: JSON.stringify(X)
|
|
7214
7260
|
});
|
|
7215
|
-
if (!
|
|
7216
|
-
const at = await
|
|
7261
|
+
if (!mt.ok) {
|
|
7262
|
+
const at = await mt.text();
|
|
7217
7263
|
return {
|
|
7218
7264
|
success: !1,
|
|
7219
|
-
error: `Search failed: ${
|
|
7265
|
+
error: `Search failed: ${mt.status} ${at}`
|
|
7220
7266
|
};
|
|
7221
7267
|
}
|
|
7222
|
-
const Et = await
|
|
7268
|
+
const Et = await mt.json(), ut = Et.candidates.map((at, $e) => {
|
|
7223
7269
|
const be = at.citation || at.url;
|
|
7224
7270
|
return {
|
|
7225
7271
|
rank: $e + 1,
|
|
@@ -7241,46 +7287,46 @@ function rm({
|
|
|
7241
7287
|
success: !0,
|
|
7242
7288
|
query: Et.query,
|
|
7243
7289
|
total: Et.total,
|
|
7244
|
-
results:
|
|
7245
|
-
summary: `Found ${Et.total} relevant results for "${P}". Top result: ${
|
|
7290
|
+
results: ut,
|
|
7291
|
+
summary: `Found ${Et.total} relevant results for "${P}". Top result: ${ut[0]?.title || "N/A"}`
|
|
7246
7292
|
};
|
|
7247
|
-
} catch (
|
|
7293
|
+
} catch (X) {
|
|
7248
7294
|
return {
|
|
7249
7295
|
success: !1,
|
|
7250
|
-
error:
|
|
7296
|
+
error: X instanceof Error ? X.message : "Unknown error occurred"
|
|
7251
7297
|
};
|
|
7252
7298
|
}
|
|
7253
|
-
} : null, [
|
|
7254
|
-
const O =
|
|
7299
|
+
} : null, [y, t, D]), Ft = et(() => y?.enabled ? async function(P, I) {
|
|
7300
|
+
const O = y.organizationId && y.organizationId !== "default" ? y.organizationId : b && b.length > 0 ? b[0] : void 0;
|
|
7255
7301
|
try {
|
|
7256
7302
|
const K = {
|
|
7257
7303
|
"Content-Type": "application/json"
|
|
7258
7304
|
};
|
|
7259
|
-
|
|
7260
|
-
const
|
|
7305
|
+
D.current && (K.Authorization = `Bearer ${D.current}`);
|
|
7306
|
+
const tt = await fetch(`${t}/fetch`, {
|
|
7261
7307
|
method: "POST",
|
|
7262
7308
|
headers: K,
|
|
7263
7309
|
body: JSON.stringify({
|
|
7264
7310
|
doc_id: P,
|
|
7265
|
-
block_ids:
|
|
7311
|
+
block_ids: I,
|
|
7266
7312
|
...O ? { organizationId: O } : {}
|
|
7267
7313
|
})
|
|
7268
7314
|
});
|
|
7269
|
-
if (!
|
|
7270
|
-
const Pt = await
|
|
7315
|
+
if (!tt.ok) {
|
|
7316
|
+
const Pt = await tt.text();
|
|
7271
7317
|
return {
|
|
7272
7318
|
success: !1,
|
|
7273
|
-
error: `Fetch failed: ${
|
|
7319
|
+
error: `Fetch failed: ${tt.status} ${Pt}`
|
|
7274
7320
|
};
|
|
7275
7321
|
}
|
|
7276
|
-
const
|
|
7322
|
+
const X = await tt.json();
|
|
7277
7323
|
return {
|
|
7278
7324
|
success: !0,
|
|
7279
|
-
blocks:
|
|
7280
|
-
fullContent:
|
|
7281
|
-
pageUrl:
|
|
7282
|
-
pageTitle:
|
|
7283
|
-
summary: `Fetched ${
|
|
7325
|
+
blocks: X.blocks || [],
|
|
7326
|
+
fullContent: X.fullContent || "",
|
|
7327
|
+
pageUrl: X.pageUrl || "",
|
|
7328
|
+
pageTitle: X.pageTitle || "",
|
|
7329
|
+
summary: `Fetched ${X.blocks?.length || 0} blocks from ${X.pageTitle || P}`
|
|
7284
7330
|
};
|
|
7285
7331
|
} catch (K) {
|
|
7286
7332
|
return {
|
|
@@ -7288,30 +7334,30 @@ function rm({
|
|
|
7288
7334
|
error: K instanceof Error ? K.message : "Unknown error occurred"
|
|
7289
7335
|
};
|
|
7290
7336
|
}
|
|
7291
|
-
} : null, [
|
|
7337
|
+
} : null, [y, t, D]), Dt = et(() => {
|
|
7292
7338
|
const A = [
|
|
7293
7339
|
...o,
|
|
7294
7340
|
...i,
|
|
7295
7341
|
ie
|
|
7296
7342
|
];
|
|
7297
|
-
return (!ot || p) && A.push($t),
|
|
7298
|
-
}, [o, i, ie, $t,
|
|
7299
|
-
const A = /* @__PURE__ */ new Map(), P = new Map(Vt.map((
|
|
7300
|
-
return A.set("getState", ie), (!ot || p) && A.set("setState", $t),
|
|
7301
|
-
if (
|
|
7343
|
+
return (!ot || p) && A.push($t), y?.enabled && (nt && A.push(nt), Ft && A.push(Ft)), A;
|
|
7344
|
+
}, [o, i, ie, $t, nt, Ft, y, ot, p]), Vt = et(() => qa(Dt, a), [Dt, a]), At = et(() => {
|
|
7345
|
+
const A = /* @__PURE__ */ new Map(), P = new Map(Vt.map((I) => [I.name, I]));
|
|
7346
|
+
return A.set("getState", ie), (!ot || p) && A.set("setState", $t), y?.enabled && (nt && A.set("searchDocs", nt), Ft && A.set("fetchDocContent", Ft)), Dt.forEach((I) => {
|
|
7347
|
+
if (I === ie || I === $t || I === nt || I === Ft)
|
|
7302
7348
|
return;
|
|
7303
|
-
const O =
|
|
7349
|
+
const O = I[Jt];
|
|
7304
7350
|
if (O) {
|
|
7305
|
-
const
|
|
7306
|
-
if (
|
|
7307
|
-
A.set(
|
|
7351
|
+
const tt = P.get(O);
|
|
7352
|
+
if (tt) {
|
|
7353
|
+
A.set(tt.name, I);
|
|
7308
7354
|
return;
|
|
7309
7355
|
}
|
|
7310
7356
|
}
|
|
7311
|
-
const K = Vt.find((
|
|
7312
|
-
K && A.set(K.name,
|
|
7357
|
+
const K = Vt.find((tt) => tt.name === I.name);
|
|
7358
|
+
K && A.set(K.name, I);
|
|
7313
7359
|
}), A;
|
|
7314
|
-
}, [Dt, Vt, ie, $t,
|
|
7360
|
+
}, [Dt, Vt, ie, $t, nt, Ft, y, ot, p]), Oe = et(() => new Set(Vt.map((A) => A.name)), [Vt]), tn = et(() => {
|
|
7315
7361
|
const A = [
|
|
7316
7362
|
{
|
|
7317
7363
|
name: "getState",
|
|
@@ -7338,7 +7384,7 @@ function rm({
|
|
|
7338
7384
|
}
|
|
7339
7385
|
});
|
|
7340
7386
|
const P = [];
|
|
7341
|
-
return
|
|
7387
|
+
return y?.enabled && P.push(
|
|
7342
7388
|
{
|
|
7343
7389
|
name: "searchDocs",
|
|
7344
7390
|
description: "Search documentation using semantic search. Returns relevant results with snippets and scores. Use this first to find relevant documentation. Default returns 20 results - use higher k values (30-50) when you need to find many sources.",
|
|
@@ -7389,17 +7435,17 @@ function rm({
|
|
|
7389
7435
|
}
|
|
7390
7436
|
}
|
|
7391
7437
|
), [...Vt, ...A, ...P];
|
|
7392
|
-
}, [Vt,
|
|
7438
|
+
}, [Vt, y, ot, p]), ve = et(() => tn.filter((A) => A.name === "getState" ? !0 : A.name === "setState" ? !ot || p : y?.enabled && (A.name === "searchDocs" || A.name === "fetchDocContent") ? !0 : Oe.has(A.name)), [tn, Oe, ot, p, y]), je = et(() => {
|
|
7393
7439
|
const A = /* @__PURE__ */ new Set();
|
|
7394
|
-
return A.add("getState"), A.add("setState"),
|
|
7395
|
-
for (const [
|
|
7440
|
+
return A.add("getState"), A.add("setState"), y?.enabled && y.autoExecute !== !1 && (A.add("searchDocs"), A.add("fetchDocContent")), i.forEach((P) => {
|
|
7441
|
+
for (const [I, O] of At.entries())
|
|
7396
7442
|
if (O === P) {
|
|
7397
|
-
A.add(
|
|
7443
|
+
A.add(I);
|
|
7398
7444
|
break;
|
|
7399
7445
|
}
|
|
7400
7446
|
}), A;
|
|
7401
|
-
}, [i, At,
|
|
7402
|
-
|
|
7447
|
+
}, [i, At, y]);
|
|
7448
|
+
st(() => s || n ? void 0 : ((async () => {
|
|
7403
7449
|
try {
|
|
7404
7450
|
const P = await fetch(e, {
|
|
7405
7451
|
method: "POST",
|
|
@@ -7412,19 +7458,19 @@ function rm({
|
|
|
7412
7458
|
});
|
|
7413
7459
|
if (!P.ok)
|
|
7414
7460
|
throw new Error("Failed to fetch token");
|
|
7415
|
-
const
|
|
7416
|
-
I
|
|
7461
|
+
const I = await P.json();
|
|
7462
|
+
C(I.clientToken), D.current = I.clientToken, L(I.expiresAt), S(null);
|
|
7417
7463
|
} catch (P) {
|
|
7418
7464
|
console.error("[useAgent] Token fetch failed:", P), S(P instanceof Error ? P.message : "Failed to fetch token");
|
|
7419
7465
|
}
|
|
7420
7466
|
})(), () => {
|
|
7421
|
-
|
|
7422
|
-
}), [e, JSON.stringify(r), s, n]),
|
|
7467
|
+
Y.current && clearTimeout(Y.current);
|
|
7468
|
+
}), [e, JSON.stringify(r), s, n]), st(() => {
|
|
7423
7469
|
if (!$ || s || n)
|
|
7424
7470
|
return;
|
|
7425
|
-
|
|
7471
|
+
Y.current && clearTimeout(Y.current);
|
|
7426
7472
|
const A = Math.floor(Date.now() / 1e3), P = $ - A, O = Math.max(0, P - 5);
|
|
7427
|
-
return
|
|
7473
|
+
return Y.current = setTimeout(async () => {
|
|
7428
7474
|
try {
|
|
7429
7475
|
const K = await fetch(e, {
|
|
7430
7476
|
method: "POST",
|
|
@@ -7437,22 +7483,22 @@ function rm({
|
|
|
7437
7483
|
});
|
|
7438
7484
|
if (!K.ok)
|
|
7439
7485
|
throw new Error("Failed to refresh token");
|
|
7440
|
-
const
|
|
7441
|
-
|
|
7486
|
+
const tt = await K.json();
|
|
7487
|
+
C(tt.clientToken), D.current = tt.clientToken, L(tt.expiresAt), S(null);
|
|
7442
7488
|
} catch (K) {
|
|
7443
7489
|
console.error("[useAgent] Token refresh failed:", K), S(K instanceof Error ? K.message : "Failed to refresh token");
|
|
7444
7490
|
}
|
|
7445
7491
|
}, O * 1e3), () => {
|
|
7446
|
-
|
|
7492
|
+
Y.current && clearTimeout(Y.current);
|
|
7447
7493
|
};
|
|
7448
7494
|
}, [$, e, JSON.stringify(r), s, n]);
|
|
7449
7495
|
const Dn = async (A, P = {}) => {
|
|
7450
|
-
const
|
|
7451
|
-
|
|
7496
|
+
const I = P.headers ? new Headers(P.headers) : new Headers();
|
|
7497
|
+
I.delete("user-agent"), I.delete("User-Agent"), console.log("[useAgent] Making request to:", A), console.log("[useAgent] Method:", P.method || "GET"), console.log("[useAgent] Has Authorization header:", I.has("Authorization")), console.log("[useAgent] Client token available:", !!D.current);
|
|
7452
7498
|
try {
|
|
7453
7499
|
const O = await fetch(A, {
|
|
7454
7500
|
...P,
|
|
7455
|
-
headers:
|
|
7501
|
+
headers: I
|
|
7456
7502
|
});
|
|
7457
7503
|
if (!O.ok) {
|
|
7458
7504
|
console.error("[useAgent] Request failed:", O.status, O.statusText);
|
|
@@ -7466,14 +7512,14 @@ function rm({
|
|
|
7466
7512
|
}, En = `${t}/chat`;
|
|
7467
7513
|
console.log("[useAgent] Chat API URL:", En);
|
|
7468
7514
|
const { messages: Gt, sendMessage: en, status: oe, error: ae, stop: nn, addToolResult: xe, setMessages: sn } = ao({
|
|
7469
|
-
id:
|
|
7515
|
+
id: q || void 0,
|
|
7470
7516
|
messages: u,
|
|
7471
7517
|
transport: new lo({
|
|
7472
7518
|
api: En,
|
|
7473
7519
|
fetch: Dn,
|
|
7474
7520
|
headers: () => {
|
|
7475
7521
|
const A = {};
|
|
7476
|
-
return
|
|
7522
|
+
return D.current ? (A.Authorization = `Bearer ${D.current}`, console.log("[useAgent] Adding Authorization header with token")) : console.warn("[useAgent] No client token available - request may fail"), A;
|
|
7477
7523
|
},
|
|
7478
7524
|
body: () => {
|
|
7479
7525
|
const A = ve.map((O) => ({
|
|
@@ -7481,66 +7527,66 @@ function rm({
|
|
|
7481
7527
|
description: O.description,
|
|
7482
7528
|
inputSchema: O.jsonSchema
|
|
7483
7529
|
// JSON Schema format from build-time
|
|
7484
|
-
})), P = A.filter((O) => O.name === "getState" || O.name === "setState").map((O) => O.name),
|
|
7485
|
-
return P.length > 0 && console.log("[useAgent] State tools included in tools list sent to AI SDK:", P),
|
|
7530
|
+
})), P = A.filter((O) => O.name === "getState" || O.name === "setState").map((O) => O.name), I = A.filter((O) => O.name === "searchDocs" || O.name === "fetchDocContent").map((O) => O.name);
|
|
7531
|
+
return P.length > 0 && console.log("[useAgent] State tools included in tools list sent to AI SDK:", P), I.length > 0 ? console.log("[useAgent] RAG tools included in tools list sent to AI SDK:", I) : y?.enabled && console.warn("[useAgent] RAG is enabled but no RAG tools found in tools list!"), {
|
|
7486
7532
|
tools: A,
|
|
7487
7533
|
systemPrompt: c,
|
|
7488
7534
|
state: wt.current,
|
|
7489
7535
|
// Always include current state
|
|
7490
|
-
...
|
|
7536
|
+
...v && { ragFilters: v }
|
|
7491
7537
|
};
|
|
7492
7538
|
}
|
|
7493
7539
|
}),
|
|
7494
7540
|
sendAutomaticallyWhen: co
|
|
7495
7541
|
});
|
|
7496
|
-
|
|
7542
|
+
st(() => {
|
|
7497
7543
|
Gt.forEach((A) => {
|
|
7498
7544
|
A.role === "assistant" && A.parts.forEach((P) => {
|
|
7499
7545
|
if (!P.type?.startsWith("tool-") || P.state !== "input-available") return;
|
|
7500
|
-
const
|
|
7501
|
-
if (
|
|
7502
|
-
|
|
7503
|
-
const K =
|
|
7504
|
-
if (je.has(
|
|
7505
|
-
const
|
|
7506
|
-
|
|
7546
|
+
const I = P.type.replace("tool-", ""), O = P.toolCallId;
|
|
7547
|
+
if (it.has(O)) return;
|
|
7548
|
+
lt((tt) => new Set(tt).add(O));
|
|
7549
|
+
const K = Uf(P.input);
|
|
7550
|
+
if (je.has(I)) {
|
|
7551
|
+
const tt = At.get(I);
|
|
7552
|
+
tt ? (async () => {
|
|
7507
7553
|
try {
|
|
7508
|
-
const
|
|
7554
|
+
const X = ve.find((mt) => mt.name === I);
|
|
7509
7555
|
let Pt;
|
|
7510
|
-
if (
|
|
7511
|
-
const Et = Object.keys(
|
|
7512
|
-
Pt = await
|
|
7513
|
-
} else if (
|
|
7514
|
-
Pt =
|
|
7515
|
-
else if (
|
|
7516
|
-
const
|
|
7517
|
-
Pt = await
|
|
7556
|
+
if (X && X.jsonSchema?.properties) {
|
|
7557
|
+
const Et = Object.keys(X.jsonSchema.properties).map((ut) => K[ut]);
|
|
7558
|
+
Pt = await tt(...Et);
|
|
7559
|
+
} else if (I === "getState")
|
|
7560
|
+
Pt = tt();
|
|
7561
|
+
else if (I === "setState") {
|
|
7562
|
+
const mt = K.updates || K;
|
|
7563
|
+
Pt = await tt(mt);
|
|
7518
7564
|
} else
|
|
7519
|
-
Pt = await
|
|
7565
|
+
Pt = await tt(...Object.values(K));
|
|
7520
7566
|
xe({
|
|
7521
7567
|
toolCallId: O,
|
|
7522
|
-
tool:
|
|
7568
|
+
tool: I,
|
|
7523
7569
|
output: Pt
|
|
7524
7570
|
});
|
|
7525
|
-
} catch (
|
|
7526
|
-
console.error(`[useAgent] Error executing tool ${
|
|
7571
|
+
} catch (X) {
|
|
7572
|
+
console.error(`[useAgent] Error executing tool ${I}:`, X), xe({
|
|
7527
7573
|
toolCallId: O,
|
|
7528
|
-
tool:
|
|
7529
|
-
output: `Error: ${
|
|
7574
|
+
tool: I,
|
|
7575
|
+
output: `Error: ${X}`
|
|
7530
7576
|
});
|
|
7531
7577
|
}
|
|
7532
|
-
})() : console.warn(`[useAgent] Tool ${
|
|
7533
|
-
} else
|
|
7578
|
+
})() : console.warn(`[useAgent] Tool ${I} not found in toolsMap`);
|
|
7579
|
+
} else T && T({ toolCall: {
|
|
7534
7580
|
toolCallId: O,
|
|
7535
|
-
toolName:
|
|
7581
|
+
toolName: I,
|
|
7536
7582
|
args: K
|
|
7537
7583
|
} });
|
|
7538
7584
|
});
|
|
7539
7585
|
});
|
|
7540
|
-
}, [Gt, je, At,
|
|
7541
|
-
if (oe === "ready" && Gt.length > 0 &&
|
|
7586
|
+
}, [Gt, je, At, T, xe, it, $t, ve]), st(() => {
|
|
7587
|
+
if (oe === "ready" && Gt.length > 0 && w) {
|
|
7542
7588
|
const A = Gt[Gt.length - 1];
|
|
7543
|
-
A && A.role === "assistant" &&
|
|
7589
|
+
A && A.role === "assistant" && w({
|
|
7544
7590
|
message: A,
|
|
7545
7591
|
messages: Gt,
|
|
7546
7592
|
isAbort: !1,
|
|
@@ -7548,28 +7594,28 @@ function rm({
|
|
|
7548
7594
|
isError: !!ae
|
|
7549
7595
|
});
|
|
7550
7596
|
}
|
|
7551
|
-
}, [oe, Gt, ae,
|
|
7597
|
+
}, [oe, Gt, ae, w]);
|
|
7552
7598
|
async function ns() {
|
|
7553
7599
|
if (!(!r?.id || !M)) {
|
|
7554
|
-
|
|
7600
|
+
Z(!0);
|
|
7555
7601
|
try {
|
|
7556
7602
|
const P = await (await fetch(`${t}/conversations`, {
|
|
7557
7603
|
headers: {
|
|
7558
7604
|
Authorization: `Bearer ${M}`
|
|
7559
7605
|
}
|
|
7560
7606
|
})).json();
|
|
7561
|
-
|
|
7607
|
+
H(P.conversations || []);
|
|
7562
7608
|
} catch (A) {
|
|
7563
7609
|
console.error("Failed to fetch conversations:", A);
|
|
7564
7610
|
} finally {
|
|
7565
|
-
|
|
7611
|
+
Z(!1);
|
|
7566
7612
|
}
|
|
7567
7613
|
}
|
|
7568
7614
|
}
|
|
7569
|
-
|
|
7615
|
+
st(() => {
|
|
7570
7616
|
r?.id && M && ns();
|
|
7571
|
-
}, [JSON.stringify(r), M, t]),
|
|
7572
|
-
if (!
|
|
7617
|
+
}, [JSON.stringify(r), M, t]), st(() => {
|
|
7618
|
+
if (!q || !D.current) return;
|
|
7573
7619
|
(async () => {
|
|
7574
7620
|
Ie(!0), se(null);
|
|
7575
7621
|
try {
|
|
@@ -7577,11 +7623,11 @@ function rm({
|
|
|
7577
7623
|
method: "POST",
|
|
7578
7624
|
headers: {
|
|
7579
7625
|
"Content-Type": "application/json",
|
|
7580
|
-
Authorization: `Bearer ${
|
|
7626
|
+
Authorization: `Bearer ${D.current}`
|
|
7581
7627
|
},
|
|
7582
7628
|
body: JSON.stringify({
|
|
7583
7629
|
path: "conversations:getStateByChatId",
|
|
7584
|
-
args: { chatId:
|
|
7630
|
+
args: { chatId: q },
|
|
7585
7631
|
format: "json"
|
|
7586
7632
|
})
|
|
7587
7633
|
});
|
|
@@ -7593,19 +7639,19 @@ function rm({
|
|
|
7593
7639
|
wt.current = O, ot || Re(O), h && h(O), re.current = !0;
|
|
7594
7640
|
} catch (P) {
|
|
7595
7641
|
console.error("Failed to fetch state:", P);
|
|
7596
|
-
const
|
|
7597
|
-
se(
|
|
7642
|
+
const I = P instanceof Error ? P : new Error(String(P));
|
|
7643
|
+
se(I), re.current || (wt.current = {}, ot ? h && h({}) : (Re({}), h && h({})), re.current = !0);
|
|
7598
7644
|
} finally {
|
|
7599
7645
|
Ie(!1);
|
|
7600
7646
|
}
|
|
7601
7647
|
})();
|
|
7602
|
-
}, [
|
|
7648
|
+
}, [q, t, ot, h]);
|
|
7603
7649
|
async function ss(A) {
|
|
7604
|
-
|
|
7650
|
+
ct(A), Z(!0);
|
|
7605
7651
|
try {
|
|
7606
7652
|
const P = await fetch(`${t}/conversations/${A}/messages`, {
|
|
7607
7653
|
headers: {
|
|
7608
|
-
Authorization: `Bearer ${
|
|
7654
|
+
Authorization: `Bearer ${D.current}`
|
|
7609
7655
|
}
|
|
7610
7656
|
});
|
|
7611
7657
|
if (!P.ok)
|
|
@@ -7615,7 +7661,7 @@ function rm({
|
|
|
7615
7661
|
} catch (P) {
|
|
7616
7662
|
console.error("Failed to load conversation messages:", P);
|
|
7617
7663
|
} finally {
|
|
7618
|
-
|
|
7664
|
+
Z(!1);
|
|
7619
7665
|
}
|
|
7620
7666
|
}
|
|
7621
7667
|
async function rn(A) {
|
|
@@ -7626,14 +7672,14 @@ function rm({
|
|
|
7626
7672
|
headers: {
|
|
7627
7673
|
Authorization: `Bearer ${M}`
|
|
7628
7674
|
}
|
|
7629
|
-
}),
|
|
7675
|
+
}), H(J.filter((P) => P._id !== A)), A === q && qt();
|
|
7630
7676
|
} catch (P) {
|
|
7631
7677
|
console.error("Failed to delete conversation:", P);
|
|
7632
7678
|
}
|
|
7633
7679
|
}
|
|
7634
7680
|
function qt() {
|
|
7635
7681
|
const A = crypto.randomUUID();
|
|
7636
|
-
|
|
7682
|
+
ct(A), sn([]), lt(/* @__PURE__ */ new Set()), wt.current = {}, ot ? h && h({}) : (Re({}), h && h({})), re.current = !1;
|
|
7637
7683
|
}
|
|
7638
7684
|
function rs(A) {
|
|
7639
7685
|
xe(A);
|
|
@@ -7643,12 +7689,12 @@ function rm({
|
|
|
7643
7689
|
wt.current = P, ot || Re(P), h && h(P);
|
|
7644
7690
|
try {
|
|
7645
7691
|
await Le(A);
|
|
7646
|
-
} catch (
|
|
7647
|
-
throw
|
|
7692
|
+
} catch (I) {
|
|
7693
|
+
throw I;
|
|
7648
7694
|
}
|
|
7649
7695
|
}
|
|
7650
7696
|
return {
|
|
7651
|
-
id:
|
|
7697
|
+
id: q,
|
|
7652
7698
|
messages: Gt,
|
|
7653
7699
|
status: oe,
|
|
7654
7700
|
error: ae,
|
|
@@ -7656,13 +7702,13 @@ function rm({
|
|
|
7656
7702
|
stop: nn,
|
|
7657
7703
|
addToolOutput: rs,
|
|
7658
7704
|
setMessages: sn,
|
|
7659
|
-
conversations:
|
|
7705
|
+
conversations: J,
|
|
7660
7706
|
loadConversation: ss,
|
|
7661
7707
|
deleteConversation: rn,
|
|
7662
7708
|
startNewConversation: qt,
|
|
7663
|
-
isLoadingConversations:
|
|
7709
|
+
isLoadingConversations: _,
|
|
7664
7710
|
clientToken: M,
|
|
7665
|
-
tokenError:
|
|
7711
|
+
tokenError: E,
|
|
7666
7712
|
// State management
|
|
7667
7713
|
state: ne,
|
|
7668
7714
|
// Read-only, reactive (uses useState for reactivity)
|
|
@@ -7673,8 +7719,8 @@ function rm({
|
|
|
7673
7719
|
}
|
|
7674
7720
|
export {
|
|
7675
7721
|
Jt as ARCTEN_ORIGINAL_NAME,
|
|
7676
|
-
|
|
7677
|
-
|
|
7678
|
-
|
|
7679
|
-
|
|
7722
|
+
nm as ArctenAgent,
|
|
7723
|
+
em as preserveToolName,
|
|
7724
|
+
sm as useAgent,
|
|
7725
|
+
om as verifyToken
|
|
7680
7726
|
};
|