@arcteninc/core 0.0.91 → 0.0.92

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 D, Fragment as Fe } from "react/jsx-runtime";
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 xt, useLayoutEffect as mc, useEffect as nt, useId as qs, useContext as St, useInsertionEffect as ro, useMemo as tt, useCallback as yn, Children as pc, isValidElement as gc, useState as _, Fragment as io, createElement as yc, forwardRef as vc, Component as xc, memo as An, Suspense as bc, lazy as wc } from "react";
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 am } from "./server.mjs";
16
- function bt(...t) {
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: bt(Ce({ variant: e, size: n, className: t })),
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: bt($c({ variant: e }), t),
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: bt(
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__ */ D(
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: bt(
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: bt(
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 = xt(null);
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 : nt, Zn = /* @__PURE__ */ Ve(null);
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 y = h && r ? n : s;
344
- return d && i.add(l), y.has(l) || y.add(l), 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((v, M) => (v[M] = Xc(o), v), {}), { setup: a, read: c, resolveKeyframes: u, preUpdate: l, update: d, preRender: h, render: p, postRender: y } = i, g = () => {
373
- const v = te.useManualTiming ? r.timestamp : performance.now();
374
- n = !1, te.useManualTiming || (r.delta = s ? 1e3 / 60 : Math.max(Math.min(v - r.timestamp, Yc), 1)), r.timestamp = v, r.isProcessing = !0, a.process(r), c.process(r), u.process(r), l.process(r), d.process(r), h.process(r), p.process(r), y.process(r), r.isProcessing = !1, n && e && (s = !1, t(g));
375
- }, T = () => {
376
- n = !0, s = !0, r.isProcessing || t(g);
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((v, M) => {
379
- const I = i[M];
380
- return v[M] = (E, N = !1, S = !1) => (n || T(), I.schedule(E, N, S)), v;
381
- }, {}), cancel: (v) => {
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(v);
383
+ i[Ln[M]].cancel(y);
384
384
  }, state: r, steps: i };
385
385
  }
386
- const { schedule: lt, cancel: pe, state: Tt, steps: ls } = /* @__PURE__ */ Do(typeof requestAnimationFrame < "u" ? requestAnimationFrame : jt, !0);
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
- }, vt = {
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 = vt.parse(t);
459
- return e.alpha = 0, vt.transform(e);
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) => (vt.test(c) ? (s.color.push(o), r.push(Ro), n.push(vt.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);
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 += vt.transform(r[i]) : o += r[i];
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 : vt.test(t) ? vt.getAnimatableNone(t) : t;
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 dt = (t, e, n) => t + (e - t) * n, hs = (t, e, n) => {
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 = dt(n.alpha, s.alpha, o), Me.transform(r));
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) => dt(t, e, 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 : vt.test(t) ? Hr : bl : Array.isArray(t) ? Oo : typeof t == "object" ? vt.test(t) ? Hr : vl : 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" ? dt(t, e, n) : ur(t)(t, e);
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) => lt.update(e, n),
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 ut = {
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 = ut.duration, bounce: e = ut.bounce, velocity: n = ut.velocity, mass: s = ut.mass }) {
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(ut.maxDuration), "Spring duration must be 10 seconds or less", "spring-duration-limit");
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(ut.minDamping, ut.maxDamping, i), t = Zt(ut.minDuration, ut.maxDuration, /* @__PURE__ */ Ot(t)), i < 1 ? (r = (u) => {
657
- const l = u * i, d = l * t, h = l - n, p = Ms(u, i), y = Math.exp(-d);
658
- return fs - h / p * y;
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, y = Math.exp(-d), g = Ms(Math.pow(u, 2), i);
661
- return (-r(u) + fs > 0 ? -1 : 1) * ((h - p) * y) / g;
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: ut.stiffness,
673
- damping: ut.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: ut.velocity,
702
- stiffness: ut.stiffness,
703
- damping: ut.damping,
704
- mass: ut.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: ut.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: ut.mass
722
+ mass: ht.mass
723
723
  }, e.isResolvedFromDuration = !0;
724
724
  }
725
725
  return e;
726
726
  }
727
- function Xn(t = ut.visualDuration, e = ut.bounce) {
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
- }), y = h || 0, g = u / (2 * Math.sqrt(c * l)), T = i - o, w = /* @__PURE__ */ Ot(Math.sqrt(c / l)), b = Math.abs(T) < 5;
738
- s || (s = b ? ut.restSpeed.granular : ut.restSpeed.default), r || (r = b ? ut.restDelta.granular : ut.restDelta.default);
739
- let v;
740
- if (g < 1) {
741
- const I = Ms(w, g);
742
- v = (E) => {
743
- const N = Math.exp(-g * w * E);
744
- return i - N * ((y + g * w * T) / I * Math.sin(I * E) + T * Math.cos(I * E));
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 (g === 1)
747
- v = (I) => i - Math.exp(-w * I) * (T + (y + w * T) * I);
746
+ } else if (w === 1)
747
+ y = (C) => i - Math.exp(-g * C) * (b + (T + g * b) * C);
748
748
  else {
749
- const I = w * Math.sqrt(g * g - 1);
750
- v = (E) => {
751
- const N = Math.exp(-g * w * E), S = Math.min(I * E, 300);
752
- return i - N * ((y + g * w * T) * Math.sinh(S) + I * T * Math.cosh(S)) / 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: (I) => {
758
- const E = v(I);
757
+ next: (C) => {
758
+ const D = y(C);
759
759
  if (p)
760
- a.done = I >= d;
760
+ a.done = C >= d;
761
761
  else {
762
- let N = I === 0 ? y : 0;
763
- g < 1 && (N = I === 0 ? /* @__PURE__ */ _t(y) : Fo(v, I, E));
764
- const S = Math.abs(N) <= s, $ = Math.abs(i - E) <= r;
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 : E, a;
767
+ return a.value = a.done ? i : D, a;
768
768
  },
769
769
  toString: () => {
770
- const I = Math.min(dr(M), qn), E = $o((N) => M.next(I * N).value, I, 30);
771
- return I + "ms " + E;
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, y = (S) => a === void 0 ? c : c === void 0 || Math.abs(a - S) < Math.abs(c - S) ? a : c;
787
- let g = n * e;
788
- const T = d + g, w = i === void 0 ? T : i(T);
789
- w !== T && (g = w - d);
790
- const b = (S) => -g * Math.exp(-S / s), v = (S) => w + b(S), M = (S) => {
791
- const $ = b(S), k = v(S);
792
- h.done = Math.abs($) <= u, h.value = h.done ? w : k;
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 I, E;
795
- const N = (S) => {
796
- p(h.value) && (I = S, E = Xn({
797
- keyframes: [h.value, y(h.value)],
798
- velocity: Fo(v, S, h.value),
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 N(0), {
806
+ return E(0), {
807
807
  calculatedDuration: null,
808
808
  next: (S) => {
809
809
  let $ = !1;
810
- return !E && I === void 0 && ($ = !0, M(S), N(S)), I !== void 0 && S >= I ? E.next(S - I) : (!$ && M(S), h);
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(dt(n, 1, r));
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: y, onUpdate: g, finalKeyframe: T } = this.options;
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 w = this.currentTime - u * (this.playbackSpeed >= 0 ? 1 : -1), b = this.playbackSpeed >= 0 ? w < 0 : w > r;
954
- this.currentTime = Math.max(w, 0), this.state === "finished" && this.holdTime === null && (this.currentTime = r);
955
- let v = this.currentTime, M = s;
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), k = S % 1;
959
- !k && S >= 1 && (k = 1), k === 1 && $--, $ = Math.min($, d + 1), !!($ % 2) && (h === "reverse" ? (k = 1 - k, p && (k -= p / a)) : h === "mirror" && (M = i)), v = Zt(0, 1, k) * a;
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 I = b ? { done: !1, value: l[0] } : M.next(v);
962
- o && (I.value = o(I.value));
963
- let { done: E } = I;
964
- !b && c !== null && (E = this.playbackSpeed >= 0 ? this.currentTime >= r : this.currentTime <= 0);
965
- const N = this.holdTime === null && (this.state === "finished" || this.state === "running" && E);
966
- return N && y !== Ds && (I.value = hr(l, this.options, T, this.speed)), g && g(I.value), N && this.finish(), I;
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, lt.read(Uo), lt.resolveKeyframes(zo))) : (this.readKeyframes(), this.complete());
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, (y, g, T) => this.onKeyframesResolved(y, g, h, !T), c, u, l), this.keyframeResolver?.scheduleResolve();
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: vt,
1647
- backgroundColor: vt,
1648
- outlineColor: vt,
1649
- fill: vt,
1650
- stroke: vt,
1646
+ color: xt,
1647
+ backgroundColor: xt,
1648
+ outlineColor: xt,
1649
+ fill: xt,
1650
+ stroke: xt,
1651
1651
  // Border props
1652
- borderColor: vt,
1653
- borderTopColor: vt,
1654
- borderRightColor: vt,
1655
- borderBottomColor: vt,
1656
- borderLeftColor: vt,
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(), lt.read(() => {
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, y) => {
2030
- window.removeEventListener("pointerup", d), window.removeEventListener("pointercancel", h), zn.has(c) && zn.delete(c), ai(p) && typeof u == "function" && u(p, { success: y });
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, vt, ge], Ou = (t) => Lu.find(Xo(t)), br = Ve({
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 = xt(null), i = xt({
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 y = n === "left" ? `left: ${h}` : `right: ${p}`;
2107
+ const T = n === "left" ? `left: ${h}` : `right: ${p}`;
2108
2108
  o.current.dataset.motionPopId = r;
2109
- const g = document.createElement("style");
2110
- a && (g.nonce = a);
2111
- const T = s ?? document.head;
2112
- return T.appendChild(g), g.sheet && g.sheet.insertRule(`
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
- ${y}px !important;
2117
+ ${T}px !important;
2118
2118
  top: ${d}px !important;
2119
2119
  }
2120
2120
  `), () => {
2121
- T.contains(g) && T.removeChild(g);
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 = tt(() => (d = !1, {
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 y of u.values())
2135
- if (!y)
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 }), tt(() => {
2142
- u.forEach((p, y) => u.set(y, !1));
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
- nt(() => {
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 = tt(() => li(t), [t]), h = i && !u ? [] : d.map(jn), p = xt(!0), y = xt(d), g = Js(() => /* @__PURE__ */ new Map()), [T, w] = _(d), [b, v] = _(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, y.current = d;
2173
- for (let E = 0; E < b.length; E++) {
2174
- const N = jn(b[E]);
2175
- h.includes(N) ? g.delete(N) : g.get(N) !== !0 && g.set(N, !1);
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
- }, [b, h.length, h.join("-")]);
2177
+ }, [v, h.length, h.join("-")]);
2178
2178
  const M = [];
2179
- if (d !== T) {
2180
- let E = [...d];
2181
- for (let N = 0; N < b.length; N++) {
2182
- const S = b[N], $ = jn(S);
2183
- h.includes($) || (E.splice(N, 0, S), M.push(S));
2184
- }
2185
- return o === "wait" && M.length && (E = M), v(li(E)), w(d), null;
2186
- }
2187
- process.env.NODE_ENV !== "production" && o === "wait" && b.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: I } = St(Ys);
2189
- return m(Fe, { children: b.map((E) => {
2190
- const N = jn(E), S = i && !u ? !1 : d === b || h.includes(N), $ = () => {
2191
- if (g.has(N))
2192
- g.set(N, !0);
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 k = !0;
2196
- g.forEach((q) => {
2197
- q || (k = !1);
2198
- }), k && (I?.(), v(y.current), i && l?.(), s && s());
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: E }, N);
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] = _(!ps(e)), r = xt(void 0);
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 nt(() => {
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 tt(() => ({ initial: e, animate: n }), [di(e), di(n)]);
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 tt(() => {
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 = tt(() => {
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 = tt(() => Ct(l) ? l.get() : l, [l]);
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 y = kr(t, h[p]);
2559
- if (y) {
2560
- const { transitionEnd: g, transition: T, ...w } = y;
2561
- for (const b in w) {
2562
- let v = w[b];
2563
- if (Array.isArray(v)) {
2564
- const M = l ? v.length - 1 : 0;
2565
- v = v[M];
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
- v !== null && (r[b] = v);
2567
+ y !== null && (r[v] = y);
2568
2568
  }
2569
- for (const b in g)
2570
- r[b] = g[b];
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 = xt(null);
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 = xt(!1);
2631
+ const h = bt(!1);
2632
2632
  ro(() => {
2633
2633
  l && h.current && l.update(n, a);
2634
2634
  });
2635
- const p = n[pa], y = xt(!!p && !window.MotionHandoffIsComplete?.(p) && window.MotionHasOptimisedAnimation?.(p));
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(), y.current && l.animationState && l.animationState.animateChanges());
2638
- }), nt(() => {
2639
- l && (!y.current && l.animationState && l.animationState.animateChanges(), y.current && (queueMicrotask(() => {
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
- }), y.current = !1), l.enteringChildren = void 0);
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 y = bd(l);
2682
- u = y.MeasureLayout, h.visualElement = gd(t, p, l, s, y.ProjectionNode);
2681
+ const T = bd(l);
2682
+ u = T.MeasureLayout, h.visualElement = gd(t, p, l, s, T.ProjectionNode);
2683
2683
  }
2684
- return D(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)] });
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 = dt(t.min, t.max, r);
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, lt.render(this.render, !1, !0));
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 && lt.preRender(this.notifyUpdate), s && this.projection && (this.projection.isTransformDirty = !0), this.scheduleRender();
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
- lt.update(() => {
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
- }, y = d.get();
3283
- if (y !== void 0 && !d.isAnimating && !Array.isArray(h) && h === y && !p.velocity)
3282
+ }, T = d.get();
3283
+ if (T !== void 0 && !d.isAnimating && !Array.isArray(h) && h === T && !p.velocity)
3284
3284
  continue;
3285
- let g = !1;
3285
+ let w = !1;
3286
3286
  if (window.MotionHandoffAnimation) {
3287
- const w = ka(t);
3288
- if (w) {
3289
- const b = window.MotionHandoffAnimation(w, l, lt);
3290
- b !== null && (p.startTime = b, g = !0);
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, g));
3294
- const T = d.animation;
3295
- T && c.push(T);
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
- lt.update(() => {
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, ...y } = d;
3382
- u = { ...u, ...y, ...p };
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 = {}, y = 1 / 0;
3392
- for (let T = 0; T < Jd; T++) {
3393
- const w = Yd[T], b = n[w], v = u[w] !== void 0 ? u[w] : l[w], M = wn(v), I = w === c ? b.isActive : null;
3394
- I === !1 && (y = T);
3395
- let E = v === l[w] && v !== u[w] && M;
3396
- if (E && s && t.manuallyAnimateOnMount && (E = !1), b.protectedKeys = { ...p }, // If it isn't active and hasn't *just* been set as inactive
3397
- !b.isActive && I === null || // If we didn't and don't have any defined prop for this animation type
3398
- !v && !b.prevProp || // Or if the prop doesn't define an animation
3399
- ts(v) || typeof v == "boolean")
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 N = th(b.prevProp, v);
3402
- let S = N || // If we're making this variant active, we want to always make it active
3403
- w === c && b.isActive && !E && M || // If we removed a higher-priority variant (i is in reverse order)
3404
- T > y && M, $ = !1;
3405
- const k = Array.isArray(v) ? v : [v];
3406
- let q = k.reduce(r(w), {});
3407
- I === !1 && (q = {});
3408
- const { prevResolvedValues: X = {} } = b, W = {
3409
- ...X,
3410
- ...q
3411
- }, J = (it) => {
3412
- S = !0, h.has(it) && ($ = !0, h.delete(it)), b.needsAnimating[it] = !0;
3413
- const pt = t.getValue(it);
3414
- pt && (pt.liveStyle = !1);
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 it in W) {
3417
- const pt = q[it], ht = X[it];
3418
- if (p.hasOwnProperty(it))
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(pt) && _s(ht) ? ot = !Ea(pt, ht) : ot = pt !== ht, ot ? pt != null ? J(it) : h.add(it) : pt !== void 0 && h.has(it) ? J(it) : b.protectedKeys[it] = !0;
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
- b.prevProp = v, b.prevResolvedValues = q, b.isActive && (p = { ...p, ...q }), s && t.blockInitialAnimation && (S = !1);
3424
- const rt = E && N;
3425
- S && (!rt || $) && d.push(...k.map((it) => {
3426
- const pt = { type: w };
3427
- if (typeof it == "string" && s && !rt && t.manuallyAnimateOnMount && t.parent) {
3428
- const { parent: ht } = t, ot = He(ht, it);
3429
- if (ht.enteringChildren && ot) {
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
- pt.delay = Da(ht.enteringChildren, t, ee);
3431
+ it.delay = Da(lt.enteringChildren, t, ee);
3432
3432
  }
3433
3433
  }
3434
3434
  return {
3435
- animation: it,
3436
- options: pt
3435
+ animation: Z,
3436
+ options: it
3437
3437
  };
3438
3438
  }));
3439
3439
  }
3440
3440
  if (h.size) {
3441
- const T = {};
3441
+ const b = {};
3442
3442
  if (typeof u.initial != "boolean") {
3443
- const w = He(t, Array.isArray(u.initial) ? u.initial[0] : u.initial);
3444
- w && w.transition && (T.transition = w.transition);
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((w) => {
3447
- const b = t.getBaseTarget(w), v = t.getValue(w);
3448
- v && (v.liveStyle = !0), T[w] = b ?? null;
3449
- }), d.push({ animation: T });
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 g = !!d.length;
3452
- return s && (u.initial === !1 || u.initial === u.animate) && !t.manuallyAnimateOnMount && (g = !1), s = !1, g ? e(d) : Promise.resolve();
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 = dt(e.min, e.max, t.origin), t.scale = Mt(n) / Mt(e), t.translate = dt(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);
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, y = dh(h.offset, { x: 0, y: 0 }) >= this.distanceThreshold;
3614
- if (!p && !y)
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: g } = h, { timestamp: T } = Tt;
3617
- this.history.push({ ...g, timestamp: T });
3618
- const { onStart: w, onMove: b } = this.handlers;
3619
- p || (w && w(this.lastMoveEvent, h), this.startEvent = this.lastMoveEvent), b && b(this.lastMoveEvent, h);
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), lt.update(this.updatePoint, !0);
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: y, onSessionEnd: g, resumeAnimation: T } = this.handlers;
3625
- if (this.dragSnapToOrigin && T && T(), !(this.lastMoveEvent && this.lastMoveEventInfo))
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 w = vs(h.type === "pointercancel" ? this.lastMoveEventInfo : ys(p, this.transformPagePoint), this.history);
3628
- this.startEvent && y && y(h, w), g && g(h, w);
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 ? dt(e, t, s.min) : Math.max(t, e) : n !== void 0 && t > n && (t = s ? dt(n, t, s.max) : Math.min(t, n)), t;
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: y, onDragStart: g } = this.getProps();
3746
- if (p && !y && (this.openDragLock && this.openDragLock(), this.openDragLock = Mu(p), !this.openDragLock))
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((w) => {
3749
- let b = this.getAxisMotionValue(w).get() || 0;
3750
- if (Ht.test(b)) {
3751
- const { projection: v } = this.visualElement;
3752
- if (v && v.layout) {
3753
- const M = v.layout.layoutBox[w];
3754
- M && (b = Mt(M) * (parseFloat(b) / 100));
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[w] = b;
3758
- }), g && lt.postRender(() => g(d, h)), Ws(this.visualElement, "transform");
3759
- const { animationState: T } = this.visualElement;
3760
- T && T.setActive("whileDrag", !0);
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: y, onDirectionLock: g, onDrag: T } = this.getProps();
3763
+ const { dragPropagation: p, dragDirectionLock: T, onDirectionLock: w, onDrag: b } = this.getProps();
3764
3764
  if (!p && !this.openDragLock)
3765
3765
  return;
3766
- const { offset: w } = h;
3767
- if (y && this.currentDirection === null) {
3768
- this.currentDirection = Th(w), this.currentDirection !== null && g && g(this.currentDirection);
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, w), this.updateAxis("y", h.point, w), this.visualElement.render(), T && T(d, h);
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 && lt.postRender(() => a(s, r));
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, y = {
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, y);
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] - dt(i, a, 0.5));
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(dt(c, u, r[i]));
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()), lt.read(s);
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 && lt.postRender(() => t(e, n));
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 && lt.postRender(() => r(o, i));
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 = dt(a, c, 0.5);
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() || lt.postRender(() => {
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 lt.setup(s, !0), () => pe(s);
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 = dt(0, n.opacity ?? 1, Ih(s)), t.opacityExit = dt(e.opacity ?? 1, 0, Lh(s))) : o && (t.opacity = dt(e.opacity ?? 1, n.opacity ?? 1, s));
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(dt(Ri(c), Ri(u), s), 0), (Ht.test(u) || Ht.test(c)) && (t[a] += "%")) : t[a] = u;
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 = dt(e.rotate || 0, n.rotate || 0, s));
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 = dt(i.min, i.max, e / 100) - i.min), typeof e != "number")
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 = dt(o.min, o.max, s);
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: y } = 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) `), y && (s += `skewY(${y}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", lt, !(r || o));
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
- lt.read(() => {
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 y = this.options.transition || u.getDefaultTransition() || nf, { onLayoutAnimationStart: g, onLayoutAnimationComplete: T } = u.getProps(), w = !this.targetLayout || !Ua(this.targetLayout, p), b = !d && h;
4336
- if (this.options.layoutRoot || this.resumeFrom || b || d && (w || !this.currentAnimation)) {
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 v = {
4339
- ...gr(y, "layout"),
4340
- onPlay: g,
4341
- onComplete: T
4338
+ const y = {
4339
+ ...gr(T, "layout"),
4340
+ onPlay: w,
4341
+ onComplete: b
4342
4342
  };
4343
- (u.shouldReduceMotion || this.options.layoutRoot) && (v.delay = 0, v.type = !1), this.startAnimation(v), this.setAnimationOrigin(l, b);
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, lt.preRender(this.updateProjection, !1, !0));
4413
+ this.projectionUpdateScheduled || (this.projectionUpdateScheduled = !0, dt.preRender(this.updateProjection, !1, !0));
4414
4414
  }
4415
4415
  scheduleCheckAfterUnmount() {
4416
- lt.postRender(() => {
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, y = this.layout ? this.layout.source : void 0, g = p !== y, T = this.getStack(), w = !T || T.members.length <= 1, b = !!(g && !w && this.options.crossfade === !0 && !this.path.some(ef));
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 v;
4594
+ let y;
4595
4595
  this.mixTargetDelta = (M) => {
4596
- const I = M / 1e3;
4597
- Xi(d.x, i.x, I), Xi(d.y, i.y, I), 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, I), v && Fh(this.relativeTarget, v) && (this.isProjectionDirty = !1), v || (v = gt()), It(v, this.relativeTarget)), g && (this.animationValues = l, Rh(l, u, this.latestValues, I, b, w)), this.root.scheduleUpdateProjection(), this.scheduleRender(), this.animationProgress = I;
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 = lt.update(() => {
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 y in Tn) {
4714
- if (l[y] === void 0)
4713
+ for (const T in Tn) {
4714
+ if (l[T] === void 0)
4715
4715
  continue;
4716
- const { correct: g, applyTo: T, isCSSVariable: w } = Tn[y], b = d === "none" ? l[y] : g(l[y], u);
4717
- if (T) {
4718
- const v = T.length;
4719
- for (let M = 0; M < v; M++)
4720
- i[T[M]] = b;
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
- w ? this.options.visualElement.renderState.vars[y] = b : i[y] = b;
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 y = gt();
4763
- mn(y, n, h.layoutBox), Ua(p, y) || (u = !0), l.options.layoutRoot && (t.relativeTarget = y, t.relativeTargetOrigin = p, t.relativeParent = l);
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 = dt(e.translate, 0, n), t.scale = dt(e.scale, 1, n), t.origin = e.origin, t.originPoint = e.originPoint;
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 = dt(e.min, n.min, s), t.max = dt(e.max, n.max, s);
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 && lt.postRender(() => o(e, Mn(e)));
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 && lt.postRender(() => o(e, Mn(e)));
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 nm(t, e) {
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__ */ D("div", { className: "flex items-start gap-2", children: [
5089
- /* @__PURE__ */ D("div", { className: "flex-1 min-w-0", children: [
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__ */ D("div", { className: "flex items-start gap-1.5 text-xs", children: [
5092
- /* @__PURE__ */ D("span", { className: "text-muted-foreground min-w-[60px]", children: [
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__ */ D("div", { className: "flex items-center gap-1 flex-shrink-0", children: [
5100
- /* @__PURE__ */ D(
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] = _(!1);
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__ */ D("div", { className: "my-1", children: [
5141
- /* @__PURE__ */ D(
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__ */ D("span", { className: "font-medium", children: [
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__ */ D("div", { className: "flex items-start gap-1.5 text-xs", children: [
5158
- /* @__PURE__ */ D("span", { className: "text-muted-foreground min-w-[60px]", children: [
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: bt(
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 = tt(
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: bt(
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] = _(!1), [y, g] = _(null);
5271
- nt(() => {
5272
- e ? y === null && g(Date.now()) : y !== null && (d(Math.ceil((Date.now() - y) / Of)), g(null));
5273
- }, [e, y, d]), nt(() => {
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 w = setTimeout(() => {
5275
+ const g = setTimeout(() => {
5276
5276
  u(!1), p(!0);
5277
5277
  }, Lf);
5278
- return () => clearTimeout(w);
5278
+ return () => clearTimeout(g);
5279
5279
  }
5280
5280
  }, [e, c, s, u, h]);
5281
- const T = (w) => {
5282
- u(w);
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: bt("not-prose mb-4", t),
5292
- onOpenChange: T,
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__ */ D("p", { children: [
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: bt(
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__ */ D(Fe, { children: [
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: bt(
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: bt(
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__ */ D(de, { children: [
5357
- /* @__PURE__ */ m(he, { asChild: !0, children: /* @__PURE__ */ D(
5356
+ return /* @__PURE__ */ R(de, { children: [
5357
+ /* @__PURE__ */ m(he, { asChild: !0, children: /* @__PURE__ */ R(
5358
5358
  "button",
5359
5359
  {
5360
- className: bt(
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__ */ D("div", { className: "space-y-1.5", children: [
5396
- /* @__PURE__ */ D("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: [
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) => /* @__PURE__ */ D(
5401
- "a",
5402
- {
5403
- href: o.url,
5404
- target: "_blank",
5405
- rel: "noopener noreferrer",
5406
- className: bt(
5407
- "flex items-center gap-2 p-2 rounded-md hover:bg-stone-700/50 dark:hover:bg-stone-700/50 transition-colors",
5408
- "text-stone-300 dark:text-stone-300 hover:text-white dark:hover:text-white"
5409
- ),
5410
- onClick: (i) => i.stopPropagation(),
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
- /* @__PURE__ */ m("span", { className: "text-xs flex-1 truncate", children: o.domain })
5425
- ]
5426
- },
5427
- o.number
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 = xt(null), [l, d] = _([]);
5446
- nt(() => {
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 y = u.current;
5452
- let g, T = !1;
5453
- const w = /* @__PURE__ */ new WeakSet(), b = () => {
5454
- if (!u.current || T) return;
5455
- T = !0;
5456
- const M = u.current, I = /\[(\d+)\]/g, E = document.createTreeWalker(
5457
- M,
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
- ), N = [];
5461
- let S;
5462
- for (; S = E.nextNode(); )
5463
- if (S.nodeType === Node.TEXT_NODE && !w.has(S)) {
5464
- const k = S, q = k.textContent || "";
5465
- let X = k.parentElement, W = !1;
5466
- for (; X && X !== M; ) {
5467
- if (X.tagName === "A" || X.tagName === "CODE" || X.tagName === "PRE") {
5468
- W = !0;
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
- X = X.parentElement;
5474
+ q = q.parentElement;
5472
5475
  }
5473
- if (!W) {
5474
- const rt = Array.from(q.matchAll(I)).filter((G) => {
5475
- if (!G[1]) return !1;
5476
- const it = parseInt(G[1], 10);
5477
- return n.has(it);
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
- rt.length > 0 && N.push({ node: k, matches: rt });
5482
+ Z.length > 0 && $.push({ node: J, matches: Z });
5480
5483
  }
5481
5484
  }
5482
- if (N.length === 0) {
5483
- T = !1;
5485
+ if ($.length === 0) {
5486
+ v = !1;
5484
5487
  return;
5485
5488
  }
5486
- const $ = [];
5487
- N.forEach(({ node: k, matches: q }) => {
5488
- w.add(k);
5489
- const X = k.textContent || "", W = document.createDocumentFragment();
5490
- let J = 0;
5491
- q.forEach((rt) => {
5492
- if (!rt[1]) return;
5493
- rt.index !== void 0 && rt.index > J && W.appendChild(document.createTextNode(X.slice(J, rt.index)));
5494
- const G = document.createElement("span");
5495
- G.className = "inline-flex items-center citation-button-container";
5496
- const it = parseInt(rt[1], 10);
5497
- G.setAttribute("data-citation", rt[1]), W.appendChild(G), $.push({ element: G, citationNum: it }), J = (rt.index || 0) + rt[0].length;
5498
- }), J < X.length && W.appendChild(document.createTextNode(X.slice(J))), k.parentNode && k.parentNode.replaceChild(W, k);
5499
- }), $.length > 0 && d((k) => {
5500
- const q = new Set(k.map((J) => J.element)), X = k.filter((J) => J.element.isConnected), W = $.filter((J) => !q.has(J.element));
5501
- return [...X, ...W];
5502
- }), T = !1;
5503
- }, v = new MutationObserver(() => {
5504
- clearTimeout(g), g = setTimeout(b, 100);
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 v.observe(y, {
5509
+ return C.observe(b, {
5507
5510
  childList: !0,
5508
5511
  subtree: !0,
5509
5512
  characterData: !0
5510
- }), g = setTimeout(b, 200), () => {
5511
- v.disconnect(), clearTimeout(g);
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, p = a && c && h ? /* @__PURE__ */ D("div", { className: "mt-4 pt-4 border-t border-stone-200 dark:border-stone-700", children: [
5515
- /* @__PURE__ */ m("div", { className: "text-xs font-semibold text-stone-600 dark:text-stone-400 mb-2", children: "References" }),
5516
- /* @__PURE__ */ m("div", { className: "text-xs text-stone-600 dark:text-stone-400 space-y-1", children: s && s.length > 0 ? (
5517
- // Use grouped citations if available
5518
- s.map((y, g) => {
5519
- const T = y.numbers[0], w = y.title || y.baseUrl;
5520
- return /* @__PURE__ */ D("div", { className: "flex items-start gap-2", children: [
5521
- /* @__PURE__ */ D("span", { className: "font-medium whitespace-nowrap", children: [
5522
- "[",
5523
- T,
5524
- "]"
5525
- ] }),
5526
- /* @__PURE__ */ m("div", { className: "flex-1 min-w-0", children: /* @__PURE__ */ m(
5527
- "a",
5528
- {
5529
- href: y.url,
5530
- target: "_blank",
5531
- rel: "noopener noreferrer",
5532
- className: "text-blue-600 dark:text-blue-400 hover:underline break-all",
5533
- children: w
5534
- }
5535
- ) })
5536
- ] }, `group-${g}`);
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(([y], [g]) => y - g).map(([y, g]) => /* @__PURE__ */ D("div", { className: "flex items-start gap-2", children: [
5541
- /* @__PURE__ */ D("span", { className: "font-medium", children: [
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: "text-blue-600 dark:text-blue-400 hover:underline break-all",
5553
- children: g
5554
- }
5555
- )
5556
- ] }, y))
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__ */ D("div", { className: i, children: [
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: y }) => y.isConnected).map(({ element: y, citationNum: g }, T) => {
5562
- if (!e.find((v) => v.number === g)) return null;
5563
- const b = Array.from(
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((v) => [v.url.replace(/\/+$/, ""), {
5566
- number: v.number,
5567
- url: v.url,
5568
- domain: Bf(v.url)
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: b,
5629
+ sources: M,
5577
5630
  citationNumber: g
5578
5631
  },
5579
- `citation-${g}-${y}`
5632
+ `citation-${g}-${b}`
5580
5633
  ),
5581
- y,
5582
- `citation-${g}-${T}`
5634
+ b,
5635
+ `citation-${g}-${v}`
5583
5636
  );
5584
5637
  }),
5585
- p
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 Uf(t) {
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 k;
5626
- for (; (k = $.exec(S)) !== null; )
5627
- if (k[1] && k[2]) {
5628
- const q = parseInt(k[1], 10), X = k[2].replace(/[.,;:!?]+$/, ""), W = X.replace(/\/+$/, "");
5629
- if (a.has(W) || a.set(W, X), i.has(W) || i.set(W, []), i.get(W).push(q), !c.has(W))
5630
- c.set(W, q);
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 J = c.get(W);
5633
- q < J && c.set(W, q);
5678
+ const q = c.get(H);
5679
+ Y < q && c.set(H, Y);
5634
5680
  }
5635
5681
  }
5636
- for (const [q, X] of i.entries()) {
5637
- const W = c.get(q);
5638
- for (const J of X)
5639
- J !== W && u.set(J, W);
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 [q, X] of c.entries()) {
5642
- const W = a.get(q) || q;
5643
- r.set(X, W), o.push({ number: X, url: W });
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 y = /```[\s\S]*?```|`[^`]+`/g;
5651
- let g;
5652
- for (; (g = y.exec(d)) !== null; )
5653
- g.index > p && h.push({ type: "text", content: d.slice(p, g.index), start: p, end: g.index }), h.push({ type: "code", content: g[0], start: g.index, end: g.index + g[0].length }), p = g.index + g[0].length;
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 T = h.map((S) => {
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, (q, X, W) => {
5660
- const J = parseInt(X, 10), rt = W.replace(/\/+$/, ""), G = u.get(J) || J;
5661
- return c.has(rt) || (c.set(rt, G), r.has(G) || (r.set(G, W), o.push({ number: G, url: W }))), `[${G}]`;
5662
- }), $ = $.replace(/\[(\d+)\]/g, (q, X) => {
5663
- const W = parseInt(X, 10);
5664
- return `[${u.get(W) || W}]`;
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
- }), w = [];
5712
+ }), g = [];
5667
5713
  for (const [S, $] of c.entries()) {
5668
- const k = a.get(S) || S, { baseUrl: q, anchor: X } = zf(k), W = Uf(k);
5669
- w.push({
5670
- url: k,
5671
- baseUrl: q,
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: X,
5675
- title: W
5720
+ anchor: J,
5721
+ title: H
5676
5722
  });
5677
5723
  }
5678
- w.sort((S, $) => (S.numbers[0] || 0) - ($.numbers[0] || 0));
5679
- const b = /* @__PURE__ */ new Map();
5680
- let v = 1;
5681
- for (const S of w) {
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
- b.set($, v), S.numbers = [v], v++;
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 k = b.get(S);
5688
- k && M.set(k, $);
5733
+ const L = v.get(S);
5734
+ L && M.set(L, $);
5689
5735
  }
5690
- const I = o.map((S) => {
5691
- const $ = b.get(S.number);
5736
+ const C = o.map((S) => {
5737
+ const $ = v.get(S.number);
5692
5738
  return $ ? { number: $, url: S.url } : S;
5693
- }).filter((S) => b.has(S.number)), E = Array.from(b.entries()).sort((S, $) => $[0] - S[0]);
5694
- let N = T.join("");
5695
- for (const [S, $] of E) {
5696
- const k = new RegExp(`\\[${S}\\](?!\\d)`, "g");
5697
- N = N.replace(k, `[${$}]`);
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: N,
5701
- citations: I.sort((S, $) => S.number - $.number),
5746
+ processedText: E,
5747
+ citations: C.sort((S, $) => S.number - $.number),
5702
5748
  citationMap: M,
5703
- groupedCitations: w,
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 sm({
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: y = "/api/arcten/token",
5753
- apiBaseUrl: g = "https://api.arcten.com",
5754
- user: T,
5755
- state: w,
5756
- onStateChange: b,
5757
- allowStateEdits: v = !0,
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: I,
5760
- showCitations: E = !0
5805
+ ragConfig: C,
5806
+ showCitations: D = !0
5761
5807
  }) {
5762
- const N = tt(() => I !== void 0 ? I : M && M.length > 0 ? {
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, I]), [S, $] = _(null), k = xt(null), [q, X] = _(null), [W, J] = _(null), rt = xt(null), G = w !== void 0, [it, pt] = _({}), ht = xt({});
5771
- G && w ? ht.current = w : G || (ht.current = it);
5772
- const [ot, ee] = _(!1), [Re, wt] = _(null), ne = xt(!1), [Wt, Ie] = _(u), [Kt, se] = _(i), [re, Le] = _(600), [ie, $t] = _(!1), [et, Ft] = _(!1), [Dt, Vt] = _(!1), [At, Oe] = _({ x: 100, y: 100 }), [tn, ve] = _(!1), [je, Dn] = _({ x: 0, y: 0 }), [En, Gt] = _(!1), en = xt(null), oe = xt(null), [ae, nn] = _(""), [xe, sn] = _(null), [ns, ss] = _("Thinking..."), [rn, qt] = _(/* @__PURE__ */ new Set()), [rs, is] = _(""), [A, P] = _([]), [L, O] = _(!1), [K, Q] = _([]), [Y, Pt] = _(() => typeof window < "u" ? crypto.randomUUID() : null), [ft, Et] = _(!1), [ct, at] = _(!1), [$e, be] = _([]), Rr = yn(async (f, x = 3) => {
5773
- if (!Y || !k.current)
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 C = async () => {
5776
- const R = `${g.replace("/chat", "").replace(/\/$/, "")}/convex/api/mutation`, F = await fetch(R, {
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 ${k.current}`
5826
+ Authorization: `Bearer ${L.current}`
5781
5827
  },
5782
5828
  body: JSON.stringify({
5783
5829
  path: "conversations:mergeStateByChatId",
5784
- args: { chatId: Y, updates: f },
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 Z = await F.text().catch(() => "Unknown error");
5794
- throw new Error(`Failed to sync conversation state: ${F.status} ${Z}`);
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 V = 0; V < x; V++)
5843
+ for (let N = 0; N < x; N++)
5798
5844
  try {
5799
- await C(), wt(null);
5845
+ await k(), wt(null);
5800
5846
  return;
5801
- } catch (R) {
5802
- if (V === x - 1) {
5803
- const Z = R instanceof Error ? R : new Error(String(R));
5804
- throw wt(Z), console.error("Failed to sync state to Convex after retries:", R), Z;
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((Z) => setTimeout(Z, Math.pow(2, V) * 100));
5852
+ await new Promise((Q) => setTimeout(Q, Math.pow(2, N) * 100));
5807
5853
  }
5808
- }, [Y, g, k]), on = tt(() => function() {
5809
- return ht.current;
5810
- }, []), an = tt(() => async function(x) {
5811
- const C = { ...ht.current, ...x };
5812
- ht.current = C, G || pt(C), b && b(C);
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 (V) {
5816
- throw V;
5817
- }
5818
- }, [Rr, b, G]);
5819
- nt(() => {
5820
- G && w && (ht.current = w);
5821
- }, [G, w]);
5822
- const we = tt(() => N?.enabled ? async function(x, C = 20, V) {
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 Z = M.map(
5825
- (U) => fetch(`${g}/search`, {
5870
+ const Q = M.map(
5871
+ (U) => fetch(`${w}/search`, {
5826
5872
  method: "POST",
5827
5873
  headers: {
5828
5874
  "Content-Type": "application/json",
5829
- ...k.current ? { Authorization: `Bearer ${k.current}` } : {}
5875
+ ...L.current ? { Authorization: `Bearer ${L.current}` } : {}
5830
5876
  },
5831
5877
  body: JSON.stringify({
5832
5878
  q: x,
5833
- k: Math.min(C, 100),
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
- ), H = await Promise.all(Z), st = [];
5839
- for (const U of H)
5840
- U?.candidates && st.push(...U.candidates);
5841
- st.sort((U, B) => {
5842
- const yt = U.scores?.rerank || U.scores?.dense || 0;
5843
- return (B.scores?.rerank || B.scores?.dense || 0) - yt;
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 = st.slice(0, C).map((U, B) => {
5846
- const yt = U.citation || U.url;
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: yt,
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: st.length,
5912
+ total: rt.length,
5867
5913
  results: j,
5868
- summary: `Found ${st.length} relevant results across ${M.length} source(s) for "${x}". Top result: ${j[0]?.title || "N/A"}`
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 R = N.organizationId && N.organizationId !== "default" ? N.organizationId : void 0, F = {
5872
- ...N.filters,
5873
- ...V
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 Z = {
5922
+ const Q = {
5877
5923
  q: x,
5878
- k: Math.min(C, 100)
5924
+ k: Math.min(k, 100)
5879
5925
  // Cap at 100 results
5880
5926
  };
5881
- R && (Z.organizationId = R), Object.keys(F).length > 0 && (Z.filters = F);
5882
- const H = {
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
- k.current && (H.Authorization = `Bearer ${k.current}`);
5886
- const st = await fetch(`${g}/search`, {
5931
+ L.current && (G.Authorization = `Bearer ${L.current}`);
5932
+ const rt = await fetch(`${w}/search`, {
5887
5933
  method: "POST",
5888
- headers: H,
5889
- body: JSON.stringify(Z)
5934
+ headers: G,
5935
+ body: JSON.stringify(Q)
5890
5936
  });
5891
- if (!st.ok) {
5892
- const B = await st.text();
5937
+ if (!rt.ok) {
5938
+ const B = await rt.text();
5893
5939
  return {
5894
5940
  success: !1,
5895
- error: `Search failed: ${st.status} ${B}`
5941
+ error: `Search failed: ${rt.status} ${B}`
5896
5942
  };
5897
5943
  }
5898
- const j = await st.json(), U = j.candidates.map((B, yt) => {
5899
- const mt = B.citation || B.url;
5944
+ const j = await rt.json(), U = j.candidates.map((B, vt) => {
5945
+ const pt = B.citation || B.url;
5900
5946
  return {
5901
- rank: yt + 1,
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: mt,
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 (Z) {
5969
+ } catch (Q) {
5924
5970
  return {
5925
5971
  success: !1,
5926
- error: Z instanceof Error ? Z.message : "Unknown error occurred"
5972
+ error: Q instanceof Error ? Q.message : "Unknown error occurred"
5927
5973
  };
5928
5974
  }
5929
- } : null, [I, g, k]), Te = tt(() => N?.enabled ? async function(x, C) {
5930
- const V = N.organizationId && N.organizationId !== "default" ? N.organizationId : M && M.length > 0 ? M[0] : void 0;
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 R = {
5978
+ const V = {
5933
5979
  "Content-Type": "application/json"
5934
5980
  };
5935
- k.current && (R.Authorization = `Bearer ${k.current}`);
5936
- const F = await fetch(`${g}/fetch`, {
5981
+ L.current && (V.Authorization = `Bearer ${L.current}`);
5982
+ const F = await fetch(`${w}/fetch`, {
5937
5983
  method: "POST",
5938
- headers: R,
5984
+ headers: V,
5939
5985
  body: JSON.stringify({
5940
5986
  doc_id: x,
5941
- block_ids: C,
5942
- ...V ? { organizationId: V } : {}
5987
+ block_ids: k,
5988
+ ...N ? { organizationId: N } : {}
5943
5989
  })
5944
5990
  });
5945
5991
  if (!F.ok) {
5946
- const H = await F.text();
5992
+ const G = await F.text();
5947
5993
  return {
5948
5994
  success: !1,
5949
- error: `Fetch failed: ${F.status} ${H}`
5995
+ error: `Fetch failed: ${F.status} ${G}`
5950
5996
  };
5951
5997
  }
5952
- const Z = await F.json();
5998
+ const Q = await F.json();
5953
5999
  return {
5954
6000
  success: !0,
5955
- blocks: Z.blocks || [],
5956
- fullContent: Z.fullContent || "",
5957
- pageUrl: Z.pageUrl || "",
5958
- pageTitle: Z.pageTitle || "",
5959
- summary: `Fetched ${Z.blocks?.length || 0} blocks from ${Z.pageTitle || x}`
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 (R) {
6007
+ } catch (V) {
5962
6008
  return {
5963
6009
  success: !1,
5964
- error: R instanceof Error ? R.message : "Unknown error occurred"
6010
+ error: V instanceof Error ? V.message : "Unknown error occurred"
5965
6011
  };
5966
6012
  }
5967
- } : null, [I, g, k]), Se = tt(() => {
6013
+ } : null, [C, w, L]), Se = et(() => {
5968
6014
  const f = [
5969
6015
  ...l,
5970
6016
  ...d,
5971
6017
  on
5972
6018
  ];
5973
- return (!G || v) && f.push(an), N?.enabled && (we && f.push(we), Te && f.push(Te)), f;
5974
- }, [l, d, on, an, we, Te, G, v, N]), os = tt(() => qa(Se, h), [Se, h]), Xt = tt(() => {
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
- (!G || v) && f.push({
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 N?.enabled && x.push(
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, G, v, N]), Ir = tt(() => new Set(Xt.map((f) => f.name)), [Xt]), Nn = tt(() => Xt.filter((f) => f.name === "getState" ? !0 : f.name === "setState" ? !G || v : Ir.has(f.name)), [Xt, Ir, G, v]), Vn = tt(() => {
6053
- const f = /* @__PURE__ */ new Map(), x = new Map(os.map((C) => [C.name, C]));
6054
- return f.set("getState", on), (!G || v) && f.set("setState", an), N?.enabled && (we && f.set("searchDocs", we), Te && f.set("fetchDocContent", Te)), Se.forEach((C) => {
6055
- if (C === on || C === an || C === we || C === Te)
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 V = C[Jt];
6058
- if (V) {
6059
- const F = x.get(V);
6103
+ const N = k[Jt];
6104
+ if (N) {
6105
+ const F = x.get(N);
6060
6106
  if (F) {
6061
- f.set(F.name, C);
6107
+ f.set(F.name, k);
6062
6108
  return;
6063
6109
  }
6064
6110
  }
6065
- const R = Xt.find((F) => F.name === C.name);
6066
- R && f.set(R.name, C);
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, G, v, N]), cn = tt(() => {
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"), N?.enabled && N.autoExecute !== !1 && (f.add("searchDocs"), f.add("fetchDocContent"));
6071
- const x = new Map(Xt.map((C) => [C.name, C]));
6072
- return d.forEach((C) => {
6073
- const V = C[Jt];
6074
- if (V && x.has(V))
6075
- f.add(V);
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 R = Xt.find((F) => F.name === C.name);
6078
- R && f.add(R.name);
6123
+ const V = Xt.find((F) => F.name === k.name);
6124
+ V && f.add(V.name);
6079
6125
  }
6080
6126
  }), f;
6081
- }, [d, Xt, N]), Lr = [
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
- nt(() => {
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 C = localStorage.getItem("arcten-sidebar-height");
6152
- C && Le(parseInt(C));
6153
- const V = localStorage.getItem("arcten-sidebar-detached");
6154
- V && Ft(JSON.parse(V));
6155
- const R = localStorage.getItem("arcten-sidebar-position");
6156
- if (R) {
6157
- const Z = JSON.parse(R), H = 50, st = Math.max(
6158
- H - i,
6159
- Math.min(Z.x, window.innerWidth - H)
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(Z.y, window.innerHeight - H)
6208
+ Math.min(Q.y, window.innerHeight - G)
6163
6209
  );
6164
- Oe({ x: st, y: j });
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 = tt(() => T, [T?.id]);
6171
- nt(() => ((async () => {
6216
+ const ce = et(() => b, [b?.id]);
6217
+ st(() => ((async () => {
6172
6218
  try {
6173
- const x = await fetch(y, {
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 C = await x.json();
6186
- $(C.clientToken), k.current = C.clientToken, J(C.expiresAt), X(null);
6231
+ const k = await x.json();
6232
+ $(k.clientToken), L.current = k.clientToken, q(k.expiresAt), J(null);
6187
6233
  } catch (x) {
6188
- X(x instanceof Error ? x.message : "Failed to fetch token");
6234
+ J(x instanceof Error ? x.message : "Failed to fetch token");
6189
6235
  }
6190
6236
  })(), () => {
6191
- rt.current && clearTimeout(rt.current);
6192
- }), [y, ce]), nt(() => {
6193
- if (!W) return;
6194
- rt.current && clearTimeout(rt.current);
6195
- const f = Math.floor(Date.now() / 1e3), x = W - f, V = Math.max(0, x - 5);
6196
- return rt.current = setTimeout(async () => {
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 R = await fetch(y, {
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 (!R.ok)
6253
+ if (!V.ok)
6208
6254
  throw new Error("Failed to refresh token");
6209
- const F = await R.json();
6210
- $(F.clientToken), k.current = F.clientToken, J(F.expiresAt), X(null);
6211
- } catch (R) {
6212
- console.error("Token refresh failed:", R), X(R instanceof Error ? R.message : "Failed to refresh token");
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
- }, V * 1e3), () => {
6215
- rt.current && clearTimeout(rt.current);
6260
+ }, N * 1e3), () => {
6261
+ ct.current && clearTimeout(ct.current);
6216
6262
  };
6217
- }, [W, y, ce]), nt(() => {
6263
+ }, [H, T, ce]), st(() => {
6218
6264
  (async () => {
6219
6265
  if (Se.length !== 0)
6220
6266
  try {
6221
- const x = Se.map((V) => ({
6222
- name: V.name,
6223
- code: V.toString()
6224
- })), C = await fetch(`${g}/tools/describe`, {
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 (C.ok) {
6230
- const V = await C.json();
6231
- P(V.tools);
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]), nt(() => {
6283
+ }, [Se]), st(() => {
6238
6284
  Promise.resolve().then(() => Nf).then((f) => {
6239
6285
  sn(() => f.Response);
6240
6286
  });
6241
- }, []), nt(() => {
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(`${g}/conversations`, {
6301
+ const x = await (await fetch(`${w}/conversations`, {
6256
6302
  headers: {
6257
6303
  Authorization: `Bearer ${S}`
6258
6304
  }
6259
6305
  })).json();
6260
- Q(x.conversations || []);
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, g]);
6268
- nt(() => {
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 = G ? w || {} : {};
6279
- ht.current = x, G || pt(x), b && b(x), ne.current = !1;
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(`${g}/conversations/${f}`, {
6330
+ await fetch(`${w}/conversations/${f}`, {
6285
6331
  method: "DELETE",
6286
6332
  headers: {
6287
6333
  Authorization: `Bearer ${S}`
6288
6334
  }
6289
- }), Q(K.filter((x) => x._id !== f)), f === Y && tc();
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(`${g}/conversations/${f.chatId}/messages`, {
6343
+ const x = await fetch(`${w}/conversations/${f.chatId}/messages`, {
6298
6344
  headers: {
6299
- Authorization: `Bearer ${k.current}`
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 V = (await x.json()).messages || [];
6305
- In(V), be(V);
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 C = f.messages || [];
6309
- In(C), be(C);
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 C = x.headers ? new Headers(x.headers) : new Headers();
6316
- return C.delete("user-agent"), C.delete("User-Agent"), fetch(f, {
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: C
6364
+ headers: k
6319
6365
  });
6320
6366
  }, { messages: Yt, sendMessage: rc, status: Bt, error: Or, stop: Rn, addToolResult: Ae, setMessages: In } = ao({
6321
- id: Y || void 0,
6367
+ id: X || void 0,
6322
6368
  // Pass AI SDK chat ID
6323
6369
  transport: new lo({
6324
- api: `${g}/chat`,
6370
+ api: `${w}/chat`,
6325
6371
  fetch: sc,
6326
6372
  headers: () => {
6327
6373
  const f = {};
6328
- return k.current && (f.Authorization = `Bearer ${k.current}`), f;
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: ht.current
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
- nt(() => {
6395
+ st(() => {
6350
6396
  const f = Yt[Yt.length - 1];
6351
6397
  if (!f || f.role !== "assistant") return;
6352
- const x = f.parts?.filter((C) => C.type?.startsWith("tool-") && C.state === "input-available" && typeof C.toolCallId == "string" && C.input !== void 0) || [];
6353
- for (const C of x) {
6354
- const V = C, R = V.type?.replace("tool-", "") || "", F = V.toolCallId;
6355
- if (cn.has(R)) {
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((H) => H.has(F) ? H : new Set(H).add(F)), (async () => {
6404
+ qt((G) => G.has(F) ? G : new Set(G).add(F)), (async () => {
6359
6405
  try {
6360
- const H = Vn.get(R);
6361
- if (!H) {
6362
- console.warn(`[ArctenAgent] Tool ${R} not found in toolsMap. Available tools:`, Array.from(Vn.keys())), Ae({
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: R,
6365
- output: `Error: Tool ${R} not found`
6410
+ tool: V,
6411
+ output: `Error: Tool ${V} not found`
6366
6412
  }), qt((B) => {
6367
- const yt = new Set(B);
6368
- return yt.delete(F), yt;
6413
+ const vt = new Set(B);
6414
+ return vt.delete(F), vt;
6369
6415
  });
6370
6416
  return;
6371
6417
  }
6372
- const st = As(V.input), j = Nn.find((B) => B.name === R);
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 yt = Object.keys(j.jsonSchema.properties).map((mt) => st[mt]);
6376
- console.log(`[ArctenAgent] Executing safe tool ${R} with args:`, yt), U = await H(...yt);
6377
- } else if (R === "getState")
6378
- U = H();
6379
- else if (R === "setState") {
6380
- const B = st.updates || st;
6381
- U = await H(B);
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 H(...Object.values(st));
6384
- console.log(`[ArctenAgent] Tool ${R} completed, result:`, U), Ae({
6429
+ U = await G(...Object.values(rt));
6430
+ console.log(`[ArctenAgent] Tool ${V} completed, result:`, U), Ae({
6385
6431
  toolCallId: F,
6386
- tool: R,
6432
+ tool: V,
6387
6433
  output: U
6388
6434
  }), qt((B) => {
6389
- const yt = new Set(B);
6390
- return yt.delete(F), yt;
6435
+ const vt = new Set(B);
6436
+ return vt.delete(F), vt;
6391
6437
  });
6392
- } catch (H) {
6393
- console.error(`[ArctenAgent] Error executing safe tool ${R}:`, H), Ae({
6438
+ } catch (G) {
6439
+ console.error(`[ArctenAgent] Error executing safe tool ${V}:`, G), Ae({
6394
6440
  toolCallId: F,
6395
- tool: R,
6396
- output: `Error: ${H instanceof Error ? H.message : String(H)}`
6397
- }), qt((st) => {
6398
- const j = new Set(st);
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]), nt(() => {
6406
- if (!Y || !k.current) return;
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 C = `${g.replace("/chat", "").replace(/\/$/, "")}/convex/api/query`, V = await fetch(C, {
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 ${k.current}`
6460
+ Authorization: `Bearer ${L.current}`
6415
6461
  },
6416
6462
  body: JSON.stringify({
6417
6463
  path: "conversations:getStateByChatId",
6418
- args: { chatId: Y },
6464
+ args: { chatId: X },
6419
6465
  format: "json"
6420
6466
  })
6421
6467
  });
6422
- if (!V.ok) {
6423
- if (V.status === 404 || V.status >= 500) {
6424
- console.warn(`[ArctenAgent] Convex API endpoint not available (${V.status}), using empty state`);
6425
- const j = G ? w || {} : {};
6426
- ht.current = j, G || pt(j), b && b(j), ne.current = !0, ee(!1);
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 st = await V.text().catch(() => "Unknown error");
6430
- throw new Error(`Failed to fetch conversation state: ${V.status} ${st}`);
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 V.json())?.value || {}, Z = !ne.current;
6433
- let H;
6434
- Z ? (H = { ...G ? w || {} : {}, ...F }, ne.current = !0) : H = F, ht.current = H, G || pt(H), b && b(H);
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 V = x instanceof Error ? x : new Error(String(x));
6438
- if (wt(V), !ne.current) {
6439
- const R = G ? w || {} : {};
6440
- ht.current = R, G || pt(R), b && b(R), ne.current = !0;
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
- }, [Y, g, G, w, b]), nt(() => {
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
- nt(() => {
6456
- }, [Wt]), nt(() => {
6501
+ st(() => {
6502
+ }, [Wt]), st(() => {
6457
6503
  en.current && en.current.scrollIntoView({ behavior: "smooth" });
6458
- }, [Yt]), nt(() => {
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
- nt(() => {
6524
+ st(() => {
6479
6525
  if (!ie) return;
6480
- function f(C) {
6481
- if (et) {
6482
- const V = C.clientX - At.x, R = C.clientY - At.y;
6483
- V >= a && V <= c && se(V), R >= 400 && R <= 1e3 && Le(R);
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 V = window.innerWidth - C.clientX;
6486
- V >= a && V <= c && se(V);
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, et, At, a, c]);
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
- et && (ve(!0), Dn({
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 nt(() => {
6515
- if (!et) return;
6560
+ return st(() => {
6561
+ if (!nt) return;
6516
6562
  function f() {
6517
6563
  Oe((x) => {
6518
- const V = window.innerWidth - 50, R = window.innerHeight - 50, F = 50 - Kt, Z = 0, H = Math.max(F, Math.min(x.x, V)), st = Math.max(Z, Math.min(x.y, R));
6519
- if (H !== x.x || st !== x.y) {
6520
- const j = { x: H, y: st };
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
- }, [et, Kt]), nt(() => {
6573
+ }, [nt, Kt]), st(() => {
6528
6574
  if (!tn) return;
6529
- function f(C) {
6530
- const V = C.clientX - je.x, R = C.clientY - je.y, F = 50, Z = window.innerWidth - F, H = window.innerHeight - F, st = F - Kt, j = 0, U = Math.max(st, Math.min(V, Z)), B = Math.max(j, Math.min(R, H));
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 ? q ? /* @__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__ */ D("div", { className: "p-4 bg-destructive/10 text-destructive text-sm rounded-lg", children: [
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
- q
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: et ? { opacity: 0, scale: 0.95, filter: "blur(4px)" } : !1,
6550
- animate: et ? { opacity: 1, scale: 1, filter: "blur(0px)" } : {},
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
- ${et ? "fixed z-50 shadow-xl rounded-xl" : "h-screen flex-shrink-0 relative rounded-l-2xl"}
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
- ${et ? "border border-border" : "border-l border-border"}
6601
+ ${nt ? "border border-border" : "border-l border-border"}
6556
6602
  ${Wt ? "" : "w-[30px]"}
6557
6603
  `,
6558
- style: Wt ? et ? {
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__ */ D(Fe, { children: [
6566
- !et && /* @__PURE__ */ m(
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
- et && /* @__PURE__ */ D(Fe, { children: [
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__ */ D("div", { className: "flex flex-col h-full", children: [
6608
- /* @__PURE__ */ D(
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 ${et ? "cursor-move" : ""}`,
6612
- onMouseDown: et ? hc : void 0,
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 ${et && Dt ? "cursor-pointer" : ""}`,
6618
- onClick: et && Dt ? (f) => {
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__ */ D("div", { className: "flex items-center gap-1", onClick: (f) => f.stopPropagation(), children: [
6625
- /* @__PURE__ */ D(de, { children: [
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: bt(Ce({ variant: "ghost", size: "icon" }), "h-8 w-8"),
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__ */ D(de, { children: [
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: bt(Ce({ variant: "ghost", size: "icon" }), "h-8 w-8"),
6644
- onClick: et ? dc : uc,
6645
- "aria-label": et ? "Dock sidebar" : "Float sidebar",
6646
- children: et ? /* @__PURE__ */ m(Mc, { className: "h-4 w-4" }) : /* @__PURE__ */ m(Dc, { className: "h-4 w-4" })
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: et ? "Dock to sidebar" : "Undock to floating window" })
6695
+ /* @__PURE__ */ m(fe, { children: nt ? "Dock to sidebar" : "Undock to floating window" })
6650
6696
  ] }),
6651
- /* @__PURE__ */ D(de, { children: [
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: bt(Ce({ variant: "ghost", size: "icon" }), "h-8 w-8"),
6657
- onClick: et ? $r : oc,
6658
- "aria-label": et ? Dt ? "Maximize" : "Minimize" : "Close sidebar",
6659
- children: et ? 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" })
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: et ? Dt ? "Maximize window" : "Minimize to header" : "Close the chat" })
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__ */ D(Fe, { children: [
6669
- T && K.length > 0 && /* @__PURE__ */ D("div", { className: `border-b border-border ${ft ? "flex flex-col flex-1" : ""}`, children: [
6670
- /* @__PURE__ */ D("div", { className: "flex items-center justify-between px-3 py-1", children: [
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
- ft || as(), Et(!ft);
6724
+ mt || as(), Et(!mt);
6679
6725
  },
6680
- children: ft ? "Show less" : "View all"
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 ${ft ? "flex-1 overflow-y-auto" : ""}`, children: K.slice(0, ft ? void 0 : 3).map((f) => /* @__PURE__ */ D("div", { className: "group relative", children: [
6685
- /* @__PURE__ */ D(
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: bt(Ce({ variant: "ghost" }), "w-full justify-between h-auto py-1 px-3 font-normal active:scale-[0.99]"),
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__ */ D("div", { className: "flex-1 flex flex-col overflow-hidden relative", children: [
6712
- /* @__PURE__ */ m("div", { className: "flex-1 overflow-y-auto p-4 space-y-4 scroll-smooth", children: Yt.length === 0 ? /* @__PURE__ */ D("div", { className: "flex flex-col items-center justify-center h-full", children: [
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__ */ D("div", { className: "flex flex-wrap gap-2 justify-center", children: [
6716
- (L ? A : A.slice(0, 10)).map((f) => /* @__PURE__ */ D(de, { children: [
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__ */ D("div", { className: "max-w-xs", children: [
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__ */ D("p", { className: "text-xs text-muted-foreground mt-2", children: [
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__ */ D("p", { className: "text-xs text-muted-foreground mt-1", children: [
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 && !L && /* @__PURE__ */ D(de, { children: [
6744
- /* @__PURE__ */ m(he, { asChild: !0, children: /* @__PURE__ */ D(
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__ */ D("div", { className: "max-w-xs", children: [
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__ */ D("div", { children: [
6760
- /* @__PURE__ */ D("span", { className: "font-medium text-xs", children: [
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
- L && A.length > 10 && /* @__PURE__ */ m(
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__ */ D(Fe, { children: [
6825
+ ] }) : /* @__PURE__ */ R(Fe, { children: [
6780
6826
  Yt.map((f) => {
6781
- const C = f.parts.filter((j) => j.type === "text").map((j) => j.text).join("");
6782
- let V = f.parts;
6783
- f.role === "assistant" && f.parts.some((U) => U.timestamp) && (V = [...f.parts].sort((U, B) => {
6784
- const yt = U.timestamp || 0, mt = B.timestamp || 0;
6785
- return yt - mt;
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 R = [], F = /* @__PURE__ */ new Map(), Z = [], H, st = !0;
6833
+ let V = [], F = /* @__PURE__ */ new Map(), Q = [], G, rt = !0;
6788
6834
  if (f.role === "assistant") {
6789
- const j = V.filter((mt) => mt.type === "text" && mt.text), U = [], B = [];
6790
- j.forEach((mt) => {
6791
- const { citations: le, citationMap: kt, groupedCitations: Rt, referencesText: ue } = so(mt.text);
6792
- R.push(...le), U.push(kt), Rt && B.push(...Rt), ue && (H = ue);
6793
- }), U.forEach((mt) => {
6794
- mt.forEach((le, kt) => {
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
- }), Z = Array.from(
6798
- new Map(B.map((mt) => [mt.url, mt])).values()
6799
- ).sort((mt, le) => (mt.numbers[0] || 0) - (le.numbers[0] || 0)), st = !(Bt === "streaming" && f.id === Yt.at(-1)?.id);
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: C
6862
+ children: k
6817
6863
  }
6818
- ) : /* @__PURE__ */ m("div", { className: "space-y-2", children: V.map((j, U) => {
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-", "") || "", yt = Nn.find((kt) => kt.name === B), mt = j.state === "input-available", le = j.state === "output-available";
6821
- if (mt && cn.has(B), mt) {
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: yt?.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 = !V.slice(U + 1).some((Rt) => Rt.type === "text" && Rt.text) && st && F.size > 0;
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: R,
6937
+ citations: V,
6892
6938
  citationMap: F,
6893
- groupedCitations: kt ? Z : void 0,
6894
- referencesText: kt ? H : void 0,
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: E,
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__ */ D(
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__ */ D("div", { className: "px-4 py-2 bg-destructive/10 text-destructive text-xs", children: [
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__ */ D("div", { className: "p-4 border-t border-border relative overflow-visible", children: [
6929
- /* @__PURE__ */ m(_u, { mode: "wait", children: (Bt === "streaming" || Bt === "submitted") && /* @__PURE__ */ D(
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__ */ D("form", { onSubmit: jr, className: "relative", children: [
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__ */ D(de, { children: [
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: bt(Ce({ variant: "ghost", size: "icon" }), "absolute top-1/2 -translate-y-1/2 right-2 h-8 w-8"),
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__ */ D(fe, { children: [
7034
+ /* @__PURE__ */ R(fe, { children: [
6989
7035
  /* @__PURE__ */ m(Br, { children: "Escape" }),
6990
7036
  " to stop"
6991
7037
  ] })
6992
- ] }) : /* @__PURE__ */ D(de, { children: [
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: bt(Ce({ variant: "ghost", size: "icon" }), "absolute top-1/2 -translate-y-1/2 right-2 h-8 w-8"),
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__ */ D(fe, { children: [
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__ */ D(
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__ */ D("div", { className: "flex flex-col items-center justify-center gap-3 h-full cursor-pointer", children: [
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 _f(t) {
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 rm({
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: y,
7079
- onFinish: g,
7080
- sources: T,
7081
- ragConfig: w,
7082
- ragFilters: b
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 v = tt(() => w !== void 0 ? w : b ? { enabled: !0, filters: b } : T && T.length > 0 ? {
7131
+ const y = et(() => g !== void 0 ? g : v ? { enabled: !0, filters: v } : b && b.length > 0 ? {
7086
7132
  enabled: !0,
7087
- organizationId: T[0],
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 }, [T, w, b]), [M, I] = _(n || null), E = xt(n || null), [N, S] = _(null), [$, k] = _(null), q = xt(null), [X, W] = _([]), [J, rt] = _(
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
- ), [G, it] = _(!1), [pt, ht] = _(/* @__PURE__ */ new Set()), ot = d !== void 0, [ee, Re] = _({}), wt = xt({}), ne = ot ? d || {} : ee;
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] = _(!1), [Kt, se] = _(null), re = xt(!1), Le = yn(async (A, P = 3) => {
7097
- if (!J || !E.current)
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 L = async () => {
7100
- const K = `${t.replace("/chat", "").replace(/\/$/, "")}/convex/api/mutation`, Q = await fetch(K, {
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 ${E.current}`
7150
+ Authorization: `Bearer ${D.current}`
7105
7151
  },
7106
7152
  body: JSON.stringify({
7107
7153
  path: "conversations:mergeStateByChatId",
7108
- args: { chatId: J, updates: A },
7154
+ args: { chatId: q, updates: A },
7109
7155
  format: "json"
7110
7156
  })
7111
7157
  });
7112
- if (!Q.ok) {
7113
- if (Q.status === 404) {
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 Y = await Q.text().catch(() => "Unknown error");
7118
- throw new Error(`Failed to sync conversation state: ${Q.status} ${Y}`);
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 L(), se(null);
7169
+ await I(), se(null);
7124
7170
  return;
7125
7171
  } catch (K) {
7126
7172
  if (O === P - 1) {
7127
- const Y = K instanceof Error ? K : new Error(String(K));
7128
- throw se(Y), console.error("Failed to sync state to Convex after retries:", K), Y;
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((Y) => setTimeout(Y, Math.pow(2, O) * 100));
7176
+ await new Promise((X) => setTimeout(X, Math.pow(2, O) * 100));
7131
7177
  }
7132
- }, [J, t, E]), ie = tt(() => function() {
7178
+ }, [q, t, D]), ie = et(() => function() {
7133
7179
  return wt.current;
7134
- }, []), $t = tt(() => async function(P) {
7135
- const L = { ...wt.current, ...P };
7136
- wt.current = L, ot || Re(L), h && h(L);
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
- nt(() => {
7189
+ st(() => {
7144
7190
  ot && d && (wt.current = d);
7145
7191
  }, [ot, d]);
7146
- const et = tt(() => v?.enabled ? async function(P, L = 20, O) {
7192
+ const nt = et(() => y?.enabled ? async function(P, I = 20, O) {
7147
7193
  const K = {
7148
- ...v.filters,
7194
+ ...y.filters,
7149
7195
  ...O
7150
7196
  };
7151
- if (T && T.length > 1) {
7152
- const Y = T.map(
7153
- (ct) => fetch(`${t}/search`, {
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
- ...E.current ? { Authorization: `Bearer ${E.current}` } : {}
7203
+ ...D.current ? { Authorization: `Bearer ${D.current}` } : {}
7158
7204
  },
7159
7205
  body: JSON.stringify({
7160
7206
  q: P,
7161
- k: Math.min(L, 100),
7162
- organizationId: ct,
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(Y), ft = [];
7167
- for (const ct of Pt)
7168
- ct?.candidates && ft.push(...ct.candidates);
7169
- ft.sort((ct, at) => {
7170
- const $e = ct.scores?.rerank || ct.scores?.dense || 0;
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 = ft.slice(0, L).map((ct, at) => {
7174
- const $e = ct.citation || ct.url;
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: ct.doc_id,
7178
- block_id: ct.block_id,
7179
- url: ct.url,
7223
+ doc_id: ut.doc_id,
7224
+ block_id: ut.block_id,
7225
+ url: ut.url,
7180
7226
  citation: $e,
7181
- title: ct.title || "Untitled",
7182
- snippet: ct.snippet,
7183
- score: ct.scores?.rerank || ct.scores?.dense || 0,
7227
+ title: ut.title || "Untitled",
7228
+ snippet: ut.snippet,
7229
+ score: ut.scores?.rerank || ut.scores?.dense || 0,
7184
7230
  metadata: {
7185
- site: ct.metadata?.site,
7186
- lang: ct.metadata?.lang,
7187
- contentType: ct.metadata?.content_type
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: ft.length,
7240
+ total: mt.length,
7195
7241
  results: Et,
7196
- summary: `Found ${ft.length} relevant results across ${T.length} source(s) for "${P}". Top result: ${Et[0]?.title || "N/A"}`
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 Q = v.organizationId && v.organizationId !== "default" ? v.organizationId : T && T.length > 0 ? T[0] : void 0;
7245
+ const tt = y.organizationId && y.organizationId !== "default" ? y.organizationId : b && b.length > 0 ? b[0] : void 0;
7200
7246
  try {
7201
- const Y = {
7247
+ const X = {
7202
7248
  q: P,
7203
- k: Math.min(L, 100)
7249
+ k: Math.min(I, 100)
7204
7250
  };
7205
- Q && (Y.organizationId = Q), Object.keys(K).length > 0 && (Y.filters = K);
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
- E.current && (Pt.Authorization = `Bearer ${E.current}`);
7210
- const ft = await fetch(`${t}/search`, {
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(Y)
7259
+ body: JSON.stringify(X)
7214
7260
  });
7215
- if (!ft.ok) {
7216
- const at = await ft.text();
7261
+ if (!mt.ok) {
7262
+ const at = await mt.text();
7217
7263
  return {
7218
7264
  success: !1,
7219
- error: `Search failed: ${ft.status} ${at}`
7265
+ error: `Search failed: ${mt.status} ${at}`
7220
7266
  };
7221
7267
  }
7222
- const Et = await ft.json(), ct = Et.candidates.map((at, $e) => {
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: ct,
7245
- summary: `Found ${Et.total} relevant results for "${P}". Top result: ${ct[0]?.title || "N/A"}`
7290
+ results: ut,
7291
+ summary: `Found ${Et.total} relevant results for "${P}". Top result: ${ut[0]?.title || "N/A"}`
7246
7292
  };
7247
- } catch (Y) {
7293
+ } catch (X) {
7248
7294
  return {
7249
7295
  success: !1,
7250
- error: Y instanceof Error ? Y.message : "Unknown error occurred"
7296
+ error: X instanceof Error ? X.message : "Unknown error occurred"
7251
7297
  };
7252
7298
  }
7253
- } : null, [v, t, E]), Ft = tt(() => v?.enabled ? async function(P, L) {
7254
- const O = v.organizationId && v.organizationId !== "default" ? v.organizationId : T && T.length > 0 ? T[0] : void 0;
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
- E.current && (K.Authorization = `Bearer ${E.current}`);
7260
- const Q = await fetch(`${t}/fetch`, {
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: L,
7311
+ block_ids: I,
7266
7312
  ...O ? { organizationId: O } : {}
7267
7313
  })
7268
7314
  });
7269
- if (!Q.ok) {
7270
- const Pt = await Q.text();
7315
+ if (!tt.ok) {
7316
+ const Pt = await tt.text();
7271
7317
  return {
7272
7318
  success: !1,
7273
- error: `Fetch failed: ${Q.status} ${Pt}`
7319
+ error: `Fetch failed: ${tt.status} ${Pt}`
7274
7320
  };
7275
7321
  }
7276
- const Y = await Q.json();
7322
+ const X = await tt.json();
7277
7323
  return {
7278
7324
  success: !0,
7279
- blocks: Y.blocks || [],
7280
- fullContent: Y.fullContent || "",
7281
- pageUrl: Y.pageUrl || "",
7282
- pageTitle: Y.pageTitle || "",
7283
- summary: `Fetched ${Y.blocks?.length || 0} blocks from ${Y.pageTitle || P}`
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, [v, t, E]), Dt = tt(() => {
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), v?.enabled && (et && A.push(et), Ft && A.push(Ft)), A;
7298
- }, [o, i, ie, $t, et, Ft, v, ot, p]), Vt = tt(() => qa(Dt, a), [Dt, a]), At = tt(() => {
7299
- const A = /* @__PURE__ */ new Map(), P = new Map(Vt.map((L) => [L.name, L]));
7300
- return A.set("getState", ie), (!ot || p) && A.set("setState", $t), v?.enabled && (et && A.set("searchDocs", et), Ft && A.set("fetchDocContent", Ft)), Dt.forEach((L) => {
7301
- if (L === ie || L === $t || L === et || L === Ft)
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 = L[Jt];
7349
+ const O = I[Jt];
7304
7350
  if (O) {
7305
- const Q = P.get(O);
7306
- if (Q) {
7307
- A.set(Q.name, L);
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((Q) => Q.name === L.name);
7312
- K && A.set(K.name, L);
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, et, Ft, v, ot, p]), Oe = tt(() => new Set(Vt.map((A) => A.name)), [Vt]), tn = tt(() => {
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 v?.enabled && P.push(
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, v, ot, p]), ve = tt(() => tn.filter((A) => A.name === "getState" ? !0 : A.name === "setState" ? !ot || p : v?.enabled && (A.name === "searchDocs" || A.name === "fetchDocContent") ? !0 : Oe.has(A.name)), [tn, Oe, ot, p, v]), je = tt(() => {
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"), v?.enabled && v.autoExecute !== !1 && (A.add("searchDocs"), A.add("fetchDocContent")), i.forEach((P) => {
7395
- for (const [L, O] of At.entries())
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(L);
7443
+ A.add(I);
7398
7444
  break;
7399
7445
  }
7400
7446
  }), A;
7401
- }, [i, At, v]);
7402
- nt(() => s || n ? void 0 : ((async () => {
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 L = await P.json();
7416
- I(L.clientToken), E.current = L.clientToken, k(L.expiresAt), S(null);
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
- q.current && clearTimeout(q.current);
7422
- }), [e, JSON.stringify(r), s, n]), nt(() => {
7467
+ Y.current && clearTimeout(Y.current);
7468
+ }), [e, JSON.stringify(r), s, n]), st(() => {
7423
7469
  if (!$ || s || n)
7424
7470
  return;
7425
- q.current && clearTimeout(q.current);
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 q.current = setTimeout(async () => {
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 Q = await K.json();
7441
- I(Q.clientToken), E.current = Q.clientToken, k(Q.expiresAt), S(null);
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
- q.current && clearTimeout(q.current);
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 L = P.headers ? new Headers(P.headers) : new Headers();
7451
- L.delete("user-agent"), L.delete("User-Agent"), console.log("[useAgent] Making request to:", A), console.log("[useAgent] Method:", P.method || "GET"), console.log("[useAgent] Has Authorization header:", L.has("Authorization")), console.log("[useAgent] Client token available:", !!E.current);
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: L
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: J || void 0,
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 E.current ? (A.Authorization = `Bearer ${E.current}`, console.log("[useAgent] Adding Authorization header with token")) : console.warn("[useAgent] No client token available - request may fail"), A;
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), L = A.filter((O) => O.name === "searchDocs" || O.name === "fetchDocContent").map((O) => O.name);
7485
- return P.length > 0 && console.log("[useAgent] State tools included in tools list sent to AI SDK:", P), L.length > 0 ? console.log("[useAgent] RAG tools included in tools list sent to AI SDK:", L) : v?.enabled && console.warn("[useAgent] RAG is enabled but no RAG tools found in tools list!"), {
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
- ...b && { ragFilters: b }
7536
+ ...v && { ragFilters: v }
7491
7537
  };
7492
7538
  }
7493
7539
  }),
7494
7540
  sendAutomaticallyWhen: co
7495
7541
  });
7496
- nt(() => {
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 L = P.type.replace("tool-", ""), O = P.toolCallId;
7501
- if (pt.has(O)) return;
7502
- ht((Q) => new Set(Q).add(O));
7503
- const K = _f(P.input);
7504
- if (je.has(L)) {
7505
- const Q = At.get(L);
7506
- Q ? (async () => {
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 Y = ve.find((ft) => ft.name === L);
7554
+ const X = ve.find((mt) => mt.name === I);
7509
7555
  let Pt;
7510
- if (Y && Y.jsonSchema?.properties) {
7511
- const Et = Object.keys(Y.jsonSchema.properties).map((ct) => K[ct]);
7512
- Pt = await Q(...Et);
7513
- } else if (L === "getState")
7514
- Pt = Q();
7515
- else if (L === "setState") {
7516
- const ft = K.updates || K;
7517
- Pt = await Q(ft);
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 Q(...Object.values(K));
7565
+ Pt = await tt(...Object.values(K));
7520
7566
  xe({
7521
7567
  toolCallId: O,
7522
- tool: L,
7568
+ tool: I,
7523
7569
  output: Pt
7524
7570
  });
7525
- } catch (Y) {
7526
- console.error(`[useAgent] Error executing tool ${L}:`, Y), xe({
7571
+ } catch (X) {
7572
+ console.error(`[useAgent] Error executing tool ${I}:`, X), xe({
7527
7573
  toolCallId: O,
7528
- tool: L,
7529
- output: `Error: ${Y}`
7574
+ tool: I,
7575
+ output: `Error: ${X}`
7530
7576
  });
7531
7577
  }
7532
- })() : console.warn(`[useAgent] Tool ${L} not found in toolsMap`);
7533
- } else y && y({ toolCall: {
7578
+ })() : console.warn(`[useAgent] Tool ${I} not found in toolsMap`);
7579
+ } else T && T({ toolCall: {
7534
7580
  toolCallId: O,
7535
- toolName: L,
7581
+ toolName: I,
7536
7582
  args: K
7537
7583
  } });
7538
7584
  });
7539
7585
  });
7540
- }, [Gt, je, At, y, xe, pt, $t, ve]), nt(() => {
7541
- if (oe === "ready" && Gt.length > 0 && g) {
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" && g({
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, g]);
7597
+ }, [oe, Gt, ae, w]);
7552
7598
  async function ns() {
7553
7599
  if (!(!r?.id || !M)) {
7554
- it(!0);
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
- W(P.conversations || []);
7607
+ H(P.conversations || []);
7562
7608
  } catch (A) {
7563
7609
  console.error("Failed to fetch conversations:", A);
7564
7610
  } finally {
7565
- it(!1);
7611
+ Z(!1);
7566
7612
  }
7567
7613
  }
7568
7614
  }
7569
- nt(() => {
7615
+ st(() => {
7570
7616
  r?.id && M && ns();
7571
- }, [JSON.stringify(r), M, t]), nt(() => {
7572
- if (!J || !E.current) return;
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 ${E.current}`
7626
+ Authorization: `Bearer ${D.current}`
7581
7627
  },
7582
7628
  body: JSON.stringify({
7583
7629
  path: "conversations:getStateByChatId",
7584
- args: { chatId: J },
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 L = P instanceof Error ? P : new Error(String(P));
7597
- se(L), re.current || (wt.current = {}, ot ? h && h({}) : (Re({}), h && h({})), re.current = !0);
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
- }, [J, t, ot, h]);
7648
+ }, [q, t, ot, h]);
7603
7649
  async function ss(A) {
7604
- rt(A), it(!0);
7650
+ ct(A), Z(!0);
7605
7651
  try {
7606
7652
  const P = await fetch(`${t}/conversations/${A}/messages`, {
7607
7653
  headers: {
7608
- Authorization: `Bearer ${E.current}`
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
- it(!1);
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
- }), W(X.filter((P) => P._id !== A)), A === J && qt();
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
- rt(A), sn([]), ht(/* @__PURE__ */ new Set()), wt.current = {}, ot ? h && h({}) : (Re({}), h && h({})), re.current = !1;
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 (L) {
7647
- throw L;
7692
+ } catch (I) {
7693
+ throw I;
7648
7694
  }
7649
7695
  }
7650
7696
  return {
7651
- id: J,
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: X,
7705
+ conversations: J,
7660
7706
  loadConversation: ss,
7661
7707
  deleteConversation: rn,
7662
7708
  startNewConversation: qt,
7663
- isLoadingConversations: G,
7709
+ isLoadingConversations: _,
7664
7710
  clientToken: M,
7665
- tokenError: N,
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
- sm as ArctenAgent,
7677
- nm as preserveToolName,
7678
- rm as useAgent,
7679
- am as verifyToken
7722
+ nm as ArctenAgent,
7723
+ em as preserveToolName,
7724
+ sm as useAgent,
7725
+ om as verifyToken
7680
7726
  };