@object-ui/plugin-chatbot 11.4.0 → 13.1.0

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.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as e from "react";
2
2
  import { Children as t, Fragment as n, createContext as r, isValidElement as i, memo as a, useCallback as o, useContext as s, useEffect as c, useMemo as l, useRef as u, useState as d } from "react";
3
- import { Alert as f, AlertDescription as p, Avatar as m, AvatarFallback as h, AvatarImage as g, Badge as _, Button as v, Card as y, CardContent as b, CardDescription as x, CardHeader as S, CardTitle as C, Collapsible as w, CollapsibleContent as T, CollapsibleTrigger as E, Command as D, CommandEmpty as O, CommandGroup as k, CommandInput as A, CommandItem as j, CommandList as M, CommandSeparator as N, DropdownMenu as P, DropdownMenuContent as F, DropdownMenuItem as I, DropdownMenuTrigger as L, Empty as ee, EmptyDescription as te, EmptyHeader as R, EmptyMedia as ne, EmptyTitle as re, HoverCard as z, HoverCardContent as ie, HoverCardTrigger as ae, Input as B, Label as V, ScrollArea as oe, ScrollBar as se, Select as ce, SelectContent as le, SelectItem as ue, SelectTrigger as de, SelectValue as fe, Separator as pe, Sheet as me, SheetContent as he, SheetDescription as ge, SheetHeader as _e, SheetTitle as ve, Skeleton as ye, Table as be, TableBody as xe, TableCell as H, TableHead as U, TableHeader as W, TableRow as Se, Tabs as Ce, TabsList as we, TabsTrigger as G, Textarea as K, Tooltip as Te, TooltipContent as Ee, TooltipProvider as De, TooltipTrigger as Oe, cn as q } from "@object-ui/components";
3
+ import { Alert as f, AlertDescription as p, Avatar as m, AvatarFallback as h, AvatarImage as g, Badge as _, Button as v, Card as y, CardContent as b, CardDescription as x, CardHeader as S, CardTitle as C, Collapsible as w, CollapsibleContent as T, CollapsibleTrigger as E, Command as D, CommandEmpty as O, CommandGroup as k, CommandInput as A, CommandItem as j, CommandList as M, CommandSeparator as N, DropdownMenu as P, DropdownMenuContent as F, DropdownMenuItem as I, DropdownMenuTrigger as L, Empty as ee, EmptyDescription as te, EmptyHeader as R, EmptyMedia as ne, EmptyTitle as re, HoverCard as z, HoverCardContent as ie, HoverCardTrigger as B, Input as ae, Label as V, ScrollArea as oe, ScrollBar as se, Select as ce, SelectContent as le, SelectItem as ue, SelectTrigger as de, SelectValue as fe, Separator as pe, Sheet as me, SheetContent as he, SheetDescription as ge, SheetHeader as _e, SheetTitle as ve, Skeleton as ye, Table as be, TableBody as xe, TableCell as H, TableHead as U, TableHeader as W, TableRow as Se, Tabs as Ce, TabsList as we, TabsTrigger as G, Textarea as K, Tooltip as Te, TooltipContent as Ee, TooltipProvider as De, TooltipTrigger as Oe, cn as q } from "@object-ui/components";
4
4
  import { AlertCircle as ke, ArrowDownIcon as J, ArrowRight as Ae, BookIcon as je, Bot as Me, BrainIcon as Ne, Check as Pe, CheckCircle2 as Y, CheckCircleIcon as Fe, CheckIcon as Ie, ChevronDownIcon as Le, ChevronLeftIcon as Re, ChevronRightIcon as ze, CircleIcon as Be, ClipboardList as Ve, Clock as He, Clock3 as Ue, ClockIcon as We, Copy as Ge, CopyIcon as Ke, CornerDownLeft as qe, CornerDownLeftIcon as Je, Eye as Ye, GitCompareArrows as Xe, HelpCircle as Ze, Hourglass as Qe, ImageIcon as $e, Inbox as et, Loader2 as tt, Loader2Icon as nt, Maximize2 as rt, MicIcon as it, Minimize2 as at, PaperclipIcon as ot, PlusIcon as st, RefreshCw as ct, Rocket as lt, Send as ut, ShieldCheck as dt, Sparkles as ft, SquareIcon as pt, Table2 as mt, TriangleAlert as ht, WifiOff as gt, WrenchIcon as _t, X as vt, XCircle as X, XCircleIcon as yt, XIcon as bt } from "lucide-react";
5
5
  import { Fragment as Z, jsx as Q, jsxs as $ } from "react/jsx-runtime";
6
6
  import { useChat as xt } from "@ai-sdk/react";
@@ -539,34 +539,47 @@ function gn(e) {
539
539
  active: e.active !== !1
540
540
  }));
541
541
  }
542
- function _n(e = {}) {
542
+ var _n = 3e4, vn = /* @__PURE__ */ new Map(), yn = /* @__PURE__ */ new Map();
543
+ function bn(e, t, n) {
544
+ if (n) vn.delete(e);
545
+ else {
546
+ let t = vn.get(e);
547
+ if (t && Date.now() - t.timestamp < _n) return Promise.resolve(t.data);
548
+ }
549
+ let r = yn.get(e);
550
+ if (r && !n) return r;
551
+ let i = `${e.replace(/\/$/, "")}/agents`, a = fetch(i, {
552
+ method: "GET",
553
+ headers: {
554
+ Accept: "application/json",
555
+ ...t ?? {}
556
+ },
557
+ credentials: "include"
558
+ }).then(async (e) => {
559
+ if (!e.ok) throw Error(`Failed to load agents (${e.status})`);
560
+ let t = await e.json();
561
+ return gn(Array.isArray(t) ? t : t?.agents ?? []);
562
+ }).then((t) => (vn.set(e, {
563
+ data: t,
564
+ timestamp: Date.now()
565
+ }), t)).finally(() => {
566
+ yn.delete(e);
567
+ });
568
+ return yn.set(e, a), a;
569
+ }
570
+ function xn(e = {}) {
543
571
  let { apiBase: t, headers: n, enabled: r = !0, fallback: i = [] } = e, [a, s] = d(i), [l, f] = d(!1), [p, m] = d(void 0), [h, g] = d(0), _ = u(n);
544
572
  return _.current = n, c(() => {
545
573
  if (!r || !t) return;
546
- let e = new AbortController(), n = !1;
547
- f(!0), m(void 0);
548
- let a = `${t.replace(/\/$/, "")}/agents`;
549
- return fetch(a, {
550
- method: "GET",
551
- headers: {
552
- Accept: "application/json",
553
- ..._.current ?? {}
554
- },
555
- credentials: "include",
556
- signal: e.signal
557
- }).then(async (e) => {
558
- if (!e.ok) throw Error(`Failed to load agents (${e.status})`);
559
- return e.json();
560
- }).then((e) => {
561
- if (n) return;
562
- let t = gn(Array.isArray(e) ? e : e?.agents ?? []);
563
- s(t.length > 0 ? t : i);
564
- }).catch((e) => {
565
- n || e.name === "AbortError" || (m(e), s(i));
574
+ let e = !1;
575
+ return f(!0), m(void 0), bn(t, _.current, h > 0).then((t) => {
576
+ e || s(t.length > 0 ? t : i);
577
+ }).catch((t) => {
578
+ e || (m(t), s(i));
566
579
  }).finally(() => {
567
- n || f(!1);
580
+ e || f(!1);
568
581
  }), () => {
569
- n = !0, e.abort();
582
+ e = !0;
570
583
  };
571
584
  }, [
572
585
  t,
@@ -581,13 +594,13 @@ function _n(e = {}) {
581
594
  }
582
595
  //#endregion
583
596
  //#region src/useAiModels.ts
584
- function vn(e) {
597
+ function Sn(e) {
585
598
  return e.filter((e) => typeof e?.id == "string" && e.id.length > 0).map((e) => ({
586
599
  id: e.id,
587
600
  label: e.label || e.id
588
601
  }));
589
602
  }
590
- function yn(e = {}) {
603
+ function Cn(e = {}) {
591
604
  let { apiBase: t, headers: n, enabled: r = !0 } = e, [i, a] = d([]), [s, l] = d(void 0), [f, p] = d(!1), [m, h] = d(void 0), [g, _] = d(0), v = u(n);
592
605
  return v.current = n, c(() => {
593
606
  if (!r || !t) return;
@@ -607,7 +620,7 @@ function yn(e = {}) {
607
620
  if (!t.ok) throw Error(`Failed to load AI models (${t.status})`);
608
621
  let r = await t.json();
609
622
  if (n) return;
610
- let c = Array.isArray(r) ? r : r?.models ?? [], u = Array.isArray(r) ? void 0 : r?.defaultModel, d = vn(c);
623
+ let c = Array.isArray(r) ? r : r?.models ?? [], u = Array.isArray(r) ? void 0 : r?.defaultModel, d = Sn(c);
611
624
  a(d), l(u ?? c.find((e) => e?.default)?.id ?? c[0]?.id), p(!1), d.length === 0 && o < 5 && !n && (o += 1, setTimeout(() => {
612
625
  s();
613
626
  }, 1200));
@@ -636,8 +649,8 @@ function yn(e = {}) {
636
649
  }
637
650
  //#endregion
638
651
  //#region src/FloatingChatbotProvider.tsx
639
- var bn = e.createContext(null);
640
- function xn({ defaultOpen: t = !1, children: n }) {
652
+ var wn = e.createContext(null);
653
+ function Tn({ defaultOpen: t = !1, children: n }) {
641
654
  let [r, i] = e.useState(t), [a, o] = e.useState(!1), s = e.useMemo(() => ({
642
655
  isOpen: r,
643
656
  isFullscreen: a,
@@ -648,19 +661,19 @@ function xn({ defaultOpen: t = !1, children: n }) {
648
661
  toggle: () => i((e) => !e),
649
662
  toggleFullscreen: () => o((e) => !e)
650
663
  }), [r, a]);
651
- return /* @__PURE__ */ Q(bn.Provider, {
664
+ return /* @__PURE__ */ Q(wn.Provider, {
652
665
  value: s,
653
666
  children: n
654
667
  });
655
668
  }
656
- function Sn() {
657
- let t = e.useContext(bn);
669
+ function En() {
670
+ let t = e.useContext(wn);
658
671
  if (!t) throw Error("useFloatingChatbot must be used within a <FloatingChatbotProvider>");
659
672
  return t;
660
673
  }
661
674
  //#endregion
662
675
  //#region src/FloatingChatbotTrigger.tsx
663
- function Cn() {
676
+ function Dn() {
664
677
  try {
665
678
  let { t: e } = Tt();
666
679
  return (t, n) => {
@@ -671,7 +684,7 @@ function Cn() {
671
684
  return (e, t) => t;
672
685
  }
673
686
  }
674
- var wn = {
687
+ var On = {
675
688
  32: "size-8",
676
689
  36: "size-9",
677
690
  40: "size-10",
@@ -684,17 +697,17 @@ var wn = {
684
697
  72: "size-[72px]",
685
698
  80: "size-20"
686
699
  };
687
- function Tn(e, t) {
700
+ function kn(e, t) {
688
701
  return t.reduce((t, n) => Math.abs(n - e) < Math.abs(t - e) ? n : t);
689
702
  }
690
- function En(e) {
691
- return wn[e] ?? wn[Tn(e, Object.keys(wn).map(Number))];
703
+ function An(e) {
704
+ return On[e] ?? On[kn(e, Object.keys(On).map(Number))];
692
705
  }
693
- function Dn({ position: e = "bottom-right", size: t = 56, className: n }) {
694
- let { isOpen: r, toggle: i } = Sn(), a = Cn();
706
+ function jn({ position: e = "bottom-right", size: t = 56, className: n }) {
707
+ let { isOpen: r, toggle: i } = En(), a = Dn();
695
708
  return /* @__PURE__ */ Q(v, {
696
709
  onClick: i,
697
- className: q("fixed z-50 rounded-full shadow-lg transition-transform hover:scale-105", En(t), r && "hidden", e === "bottom-right" ? "right-6 bottom-20 sm:bottom-6" : "left-6 bottom-20 sm:bottom-6", n),
710
+ className: q("fixed z-50 rounded-full shadow-lg transition-transform hover:scale-105", An(t), r && "hidden", e === "bottom-right" ? "right-6 bottom-20 sm:bottom-6" : "left-6 bottom-20 sm:bottom-6", n),
698
711
  size: "icon",
699
712
  "aria-label": r ? a("closeChat", "Close chat") : a("openChat", "Open chat"),
700
713
  "data-testid": "floating-chatbot-trigger",
@@ -703,7 +716,7 @@ function Dn({ position: e = "bottom-right", size: t = 56, className: n }) {
703
716
  }
704
717
  //#endregion
705
718
  //#region src/FloatingChatbotPanel.tsx
706
- var On = {
719
+ var Mn = {
707
720
  300: "sm:w-[300px]",
708
721
  320: "sm:w-[320px]",
709
722
  340: "sm:w-[340px]",
@@ -722,7 +735,7 @@ var On = {
722
735
  640: "sm:w-[640px]",
723
736
  720: "sm:w-[720px]",
724
737
  800: "sm:w-[800px]"
725
- }, kn = {
738
+ }, Nn = {
726
739
  360: "h-[min(360px,calc(100svh_-_6rem_-_env(safe-area-inset-bottom)))] sm:h-[360px]",
727
740
  400: "h-[min(400px,calc(100svh_-_6rem_-_env(safe-area-inset-bottom)))] sm:h-[400px]",
728
741
  420: "h-[min(420px,calc(100svh_-_6rem_-_env(safe-area-inset-bottom)))] sm:h-[420px]",
@@ -736,19 +749,19 @@ var On = {
736
749
  720: "h-[min(720px,calc(100svh_-_6rem_-_env(safe-area-inset-bottom)))] sm:h-[720px]",
737
750
  800: "h-[min(800px,calc(100svh_-_6rem_-_env(safe-area-inset-bottom)))] sm:h-[800px]"
738
751
  };
739
- function An(e, t) {
752
+ function Pn(e, t) {
740
753
  return t.reduce((t, n) => Math.abs(n - e) < Math.abs(t - e) ? n : t);
741
754
  }
742
- function jn(e) {
743
- return On[e] ?? On[An(e, Object.keys(On).map(Number))];
755
+ function Fn(e) {
756
+ return Mn[e] ?? Mn[Pn(e, Object.keys(Mn).map(Number))];
744
757
  }
745
- function Mn(e) {
746
- return kn[e] ?? kn[An(e, Object.keys(kn).map(Number))];
758
+ function In(e) {
759
+ return Nn[e] ?? Nn[Pn(e, Object.keys(Nn).map(Number))];
747
760
  }
748
- function Nn({ title: e = "Chat", position: t = "bottom-right", width: n = 400, height: r = 520, children: i, className: a, headerExtra: o, headerActions: s }) {
749
- let { isOpen: c, isFullscreen: l, close: u, toggleFullscreen: d } = Sn();
761
+ function Ln({ title: e = "Chat", position: t = "bottom-right", width: n = 400, height: r = 520, children: i, className: a, headerExtra: o, headerActions: s }) {
762
+ let { isOpen: c, isFullscreen: l, close: u, toggleFullscreen: d } = En();
750
763
  return c ? /* @__PURE__ */ $("div", {
751
- className: q("fixed z-50 flex flex-col overflow-hidden border bg-background shadow-xl transition-all", l ? "inset-0 h-svh w-screen rounded-none" : t === "bottom-right" ? q("left-3 right-3 bottom-[calc(4rem_+_env(safe-area-inset-bottom))] rounded-lg", "sm:left-auto sm:right-6 sm:bottom-20 sm:max-h-[calc(100vh_-_100px)]", jn(n), Mn(r)) : q("left-3 right-3 bottom-[calc(4rem_+_env(safe-area-inset-bottom))] rounded-lg", "sm:right-auto sm:left-6 sm:bottom-20 sm:max-h-[calc(100vh_-_100px)]", jn(n), Mn(r)), a),
764
+ className: q("fixed z-50 flex flex-col overflow-hidden border bg-background shadow-xl transition-all", l ? "inset-0 h-svh w-screen rounded-none" : t === "bottom-right" ? q("left-3 right-3 bottom-[calc(4rem_+_env(safe-area-inset-bottom))] rounded-lg", "sm:left-auto sm:right-6 sm:bottom-20 sm:max-h-[calc(100vh_-_100px)]", Fn(n), In(r)) : q("left-3 right-3 bottom-[calc(4rem_+_env(safe-area-inset-bottom))] rounded-lg", "sm:right-auto sm:left-6 sm:bottom-20 sm:max-h-[calc(100vh_-_100px)]", Fn(n), In(r)), a),
752
765
  role: "dialog",
753
766
  "aria-label": e,
754
767
  "data-testid": "floating-chatbot-panel",
@@ -797,7 +810,7 @@ function Nn({ title: e = "Chat", position: t = "bottom-right", width: n = 400, h
797
810
  }
798
811
  //#endregion
799
812
  //#region src/tool-display.ts
800
- var Pn = {
813
+ var Rn = {
801
814
  ai: "AI",
802
815
  api: "API",
803
816
  crm: "CRM",
@@ -809,17 +822,17 @@ var Pn = {
809
822
  url: "URL",
810
823
  utc: "UTC"
811
824
  };
812
- function Fn(e) {
825
+ function zn(e) {
813
826
  if (!e) return "";
814
827
  let t = String(e).trim();
815
828
  if (!t) return "";
816
829
  let n = t.replace(/[_-]+/g, " ").replace(/([a-z])([A-Z])/g, "$1 $2").split(/\s+/).filter(Boolean);
817
830
  return n.length === 0 ? t : n.map((e, t) => {
818
831
  let n = e.toLowerCase();
819
- return Pn[n] ? Pn[n] : t === 0 ? n.charAt(0).toUpperCase() + n.slice(1) : n;
832
+ return Rn[n] ? Rn[n] : t === 0 ? n.charAt(0).toUpperCase() + n.slice(1) : n;
820
833
  }).join(" ");
821
834
  }
822
- function In(e) {
835
+ function Bn(e) {
823
836
  if (e == null) return e;
824
837
  let t = e;
825
838
  for (let e = 0; e < 2; e++) {
@@ -837,7 +850,7 @@ function In(e) {
837
850
  }
838
851
  return t;
839
852
  }
840
- function Ln(e) {
853
+ function Vn(e) {
841
854
  let t = (e instanceof Error ? e.message : String(e ?? "")).replace(/\s+/g, " ").trim();
842
855
  if (!t) return { summary: "Something went wrong. Please try again." };
843
856
  let n = t.replace(/^Failed after \d+ attempts?\.\s*Last error:\s*/i, ""), r = n.match(/^Invalid error response format:\s*(.+)$/i)?.[1]?.trim() ?? n, i = r.match(/^([^:]{8,80}):\s+(.+)$/)?.[1]?.trim() ?? r.match(/^([^.;!?]+[.;!?])\s/)?.[1]?.trim() ?? (r.length > 140 ? `${r.slice(0, 137).trimEnd()}…` : r);
@@ -846,12 +859,12 @@ function Ln(e) {
846
859
  details: n.length > i.length ? n : void 0
847
860
  };
848
861
  }
849
- var Rn = /* @__PURE__ */ new Set([
862
+ var Hn = /* @__PURE__ */ new Set([
850
863
  "ai_design_quota_exhausted",
851
864
  "ai_data_chat_trial_exhausted",
852
865
  "ai_allowance_exhausted"
853
866
  ]);
854
- function zn(e) {
867
+ function Un(e) {
855
868
  let t = e instanceof Error ? e.message : String(e ?? "");
856
869
  if (!t) return null;
857
870
  let n = t.replace(/^Failed after \d+ attempts?\.\s*Last error:\s*/i, "").replace(/^Invalid error response format:\s*/i, "").trim(), r = n.indexOf("{"), i = n.lastIndexOf("}");
@@ -862,7 +875,7 @@ function zn(e) {
862
875
  } catch {
863
876
  return null;
864
877
  }
865
- return !a || typeof a.error != "string" || !Rn.has(a.error) ? null : {
878
+ return !a || typeof a.error != "string" || !Hn.has(a.error) ? null : {
866
879
  code: a.error,
867
880
  message: typeof a.message == "string" ? a.message : "",
868
881
  messageEn: typeof a.messageEn == "string" ? a.messageEn : void 0,
@@ -870,30 +883,30 @@ function zn(e) {
870
883
  topUp: a.topUp === !0
871
884
  };
872
885
  }
873
- function Bn(e) {
886
+ function Wn(e) {
874
887
  return !!(e && typeof e == "object" && e.notSent === !0);
875
888
  }
876
- function Vn(e) {
889
+ function Gn(e) {
877
890
  let t = e && typeof e == "object" ? e.status : void 0;
878
891
  return typeof t == "number" ? t : void 0;
879
892
  }
880
- function Hn(e) {
881
- if (Vn(e) === 429) return !0;
893
+ function Kn(e) {
894
+ if (Gn(e) === 429) return !0;
882
895
  let t = e instanceof Error ? e.message : typeof e == "string" ? e : "";
883
896
  return /\b429\b|too many requests|rate[\s_-]?limit/i.test(t);
884
897
  }
885
898
  //#endregion
886
899
  //#region src/elements/conversation.tsx
887
- var Un = ({ className: e, ...t }) => /* @__PURE__ */ Q(Et, {
900
+ var qn = ({ className: e, ...t }) => /* @__PURE__ */ Q(Et, {
888
901
  className: q("relative flex-1 overflow-y-hidden", e),
889
902
  initial: "smooth",
890
903
  resize: "smooth",
891
904
  role: "log",
892
905
  ...t
893
- }), Wn = ({ className: e, ...t }) => /* @__PURE__ */ Q(Et.Content, {
906
+ }), Jn = ({ className: e, ...t }) => /* @__PURE__ */ Q(Et.Content, {
894
907
  className: q("flex flex-col gap-8 p-4", e),
895
908
  ...t
896
- }), Gn = ({ className: e, title: t = "No messages yet", description: n = "Start a conversation to see messages here", icon: r, children: i, ...a }) => /* @__PURE__ */ Q("div", {
909
+ }), Yn = ({ className: e, title: t = "No messages yet", description: n = "Start a conversation to see messages here", icon: r, children: i, ...a }) => /* @__PURE__ */ Q("div", {
897
910
  className: q("flex size-full flex-col items-center justify-center gap-3 p-8 text-center", e),
898
911
  ...a,
899
912
  children: i ?? /* @__PURE__ */ $(Z, { children: [r && /* @__PURE__ */ Q("div", {
@@ -909,7 +922,7 @@ var Un = ({ className: e, ...t }) => /* @__PURE__ */ Q(Et, {
909
922
  children: n
910
923
  })]
911
924
  })] })
912
- }), Kn = ({ className: e, ...t }) => {
925
+ }), Xn = ({ className: e, ...t }) => {
913
926
  let { isAtBottom: n, scrollToBottom: r } = Dt(), i = o(() => {
914
927
  r();
915
928
  }, [r]);
@@ -922,23 +935,23 @@ var Un = ({ className: e, ...t }) => /* @__PURE__ */ Q(Et, {
922
935
  ...t,
923
936
  children: /* @__PURE__ */ Q(J, { className: "size-4" })
924
937
  });
925
- }, qn = Ot("flex w-fit items-stretch has-[>[data-slot=button-group]]:gap-2 [&>*]:focus-visible:relative [&>*]:focus-visible:z-10 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-md [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1", {
938
+ }, Zn = Ot("flex w-fit items-stretch has-[>[data-slot=button-group]]:gap-2 [&>*]:focus-visible:relative [&>*]:focus-visible:z-10 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-md [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1", {
926
939
  variants: { orientation: {
927
940
  horizontal: "[&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none",
928
941
  vertical: "flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none"
929
942
  } },
930
943
  defaultVariants: { orientation: "horizontal" }
931
944
  });
932
- function Jn({ className: e, orientation: t, ...n }) {
945
+ function Qn({ className: e, orientation: t, ...n }) {
933
946
  return /* @__PURE__ */ Q("div", {
934
947
  role: "group",
935
948
  "data-slot": "button-group",
936
949
  "data-orientation": t,
937
- className: q(qn({ orientation: t }), e),
950
+ className: q(Zn({ orientation: t }), e),
938
951
  ...n
939
952
  });
940
953
  }
941
- function Yn({ className: e, asChild: t = !1, ...n }) {
954
+ function $n({ className: e, asChild: t = !1, ...n }) {
942
955
  return /* @__PURE__ */ Q(t ? kt : "div", {
943
956
  className: q("flex items-center gap-2 rounded-md border bg-muted px-4 text-sm font-medium shadow-xs [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4", e),
944
957
  ...n
@@ -946,18 +959,18 @@ function Yn({ className: e, asChild: t = !1, ...n }) {
946
959
  }
947
960
  //#endregion
948
961
  //#region src/elements/message.tsx
949
- var Xn = ({ className: e, from: t, ...n }) => /* @__PURE__ */ Q("div", {
962
+ var er = ({ className: e, from: t, ...n }) => /* @__PURE__ */ Q("div", {
950
963
  className: q("group flex w-full max-w-[95%] flex-col gap-2", t === "user" ? "is-user ml-auto justify-end" : "is-assistant", e),
951
964
  ...n
952
- }), Zn = ({ children: e, className: t, ...n }) => /* @__PURE__ */ Q("div", {
965
+ }), tr = ({ children: e, className: t, ...n }) => /* @__PURE__ */ Q("div", {
953
966
  className: q("is-user:dark flex w-fit max-w-full min-w-0 flex-col gap-2 overflow-hidden text-sm", "group-[.is-user]:ml-auto group-[.is-user]:rounded-lg group-[.is-user]:bg-secondary group-[.is-user]:px-4 group-[.is-user]:py-3 group-[.is-user]:text-foreground", "group-[.is-assistant]:text-foreground", t),
954
967
  ...n,
955
968
  children: e
956
- }), Qn = ({ className: e, children: t, ...n }) => /* @__PURE__ */ Q("div", {
969
+ }), nr = ({ className: e, children: t, ...n }) => /* @__PURE__ */ Q("div", {
957
970
  className: q("flex items-center gap-1", e),
958
971
  ...n,
959
972
  children: t
960
- }), $n = ({ tooltip: e, children: t, label: n, variant: r = "ghost", size: i = "icon", ...a }) => {
973
+ }), rr = ({ tooltip: e, children: t, label: n, variant: r = "ghost", size: i = "icon", ...a }) => {
961
974
  let o = /* @__PURE__ */ $(v, {
962
975
  size: i,
963
976
  type: "button",
@@ -972,34 +985,36 @@ var Xn = ({ className: e, from: t, ...n }) => /* @__PURE__ */ Q("div", {
972
985
  asChild: !0,
973
986
  children: o
974
987
  }), /* @__PURE__ */ Q(Ee, { children: /* @__PURE__ */ Q("p", { children: e }) })] }) }) : o;
975
- }, er = r(null), tr = () => {
976
- let e = s(er);
988
+ }, ir = r(null), ar = () => {
989
+ let e = s(ir);
977
990
  if (!e) throw Error("MessageBranch components must be used within MessageBranch");
978
991
  return e;
979
- }, nr = ({ defaultBranch: e = 0, onBranchChange: t, className: n, ...r }) => {
992
+ }, or = ({ defaultBranch: e = 0, onBranchChange: t, className: n, ...r }) => {
980
993
  let [i, a] = d(e), [o, s] = d([]), c = (e) => {
981
994
  a(e), t?.(e);
982
995
  }, l = {
983
996
  currentBranch: i,
984
997
  totalBranches: o.length,
985
998
  goToPrevious: () => {
986
- c(i > 0 ? i - 1 : o.length - 1);
999
+ let e = i > 0 ? i - 1 : o.length - 1;
1000
+ c(e);
987
1001
  },
988
1002
  goToNext: () => {
989
- c(i < o.length - 1 ? i + 1 : 0);
1003
+ let e = i < o.length - 1 ? i + 1 : 0;
1004
+ c(e);
990
1005
  },
991
1006
  branches: o,
992
1007
  setBranches: s
993
1008
  };
994
- return /* @__PURE__ */ Q(er.Provider, {
1009
+ return /* @__PURE__ */ Q(ir.Provider, {
995
1010
  value: l,
996
1011
  children: /* @__PURE__ */ Q("div", {
997
1012
  className: q("grid w-full gap-2 [&>div]:pb-0", n),
998
1013
  ...r
999
1014
  })
1000
1015
  });
1001
- }, rr = ({ children: e, ...t }) => {
1002
- let { currentBranch: n, setBranches: r, branches: i } = tr(), a = Array.isArray(e) ? e : [e];
1016
+ }, sr = ({ children: e, ...t }) => {
1017
+ let { currentBranch: n, setBranches: r, branches: i } = ar(), a = Array.isArray(e) ? e : [e];
1003
1018
  return c(() => {
1004
1019
  i.length !== a.length && r(a);
1005
1020
  }, [
@@ -1011,15 +1026,15 @@ var Xn = ({ className: e, from: t, ...n }) => /* @__PURE__ */ Q("div", {
1011
1026
  ...t,
1012
1027
  children: e
1013
1028
  }, e.key));
1014
- }, ir = ({ className: e, from: t, ...n }) => {
1015
- let { totalBranches: r } = tr();
1016
- return r <= 1 ? null : /* @__PURE__ */ Q(Jn, {
1029
+ }, cr = ({ className: e, from: t, ...n }) => {
1030
+ let { totalBranches: r } = ar();
1031
+ return r <= 1 ? null : /* @__PURE__ */ Q(Qn, {
1017
1032
  className: "[&>*:not(:first-child)]:rounded-l-md [&>*:not(:last-child)]:rounded-r-md",
1018
1033
  orientation: "horizontal",
1019
1034
  ...n
1020
1035
  });
1021
- }, ar = ({ children: e, ...t }) => {
1022
- let { goToPrevious: n, totalBranches: r } = tr();
1036
+ }, lr = ({ children: e, ...t }) => {
1037
+ let { goToPrevious: n, totalBranches: r } = ar();
1023
1038
  return /* @__PURE__ */ Q(v, {
1024
1039
  "aria-label": "Previous branch",
1025
1040
  disabled: r <= 1,
@@ -1030,8 +1045,8 @@ var Xn = ({ className: e, from: t, ...n }) => /* @__PURE__ */ Q("div", {
1030
1045
  ...t,
1031
1046
  children: e ?? /* @__PURE__ */ Q(Re, { size: 14 })
1032
1047
  });
1033
- }, or = ({ children: e, className: t, ...n }) => {
1034
- let { goToNext: r, totalBranches: i } = tr();
1048
+ }, ur = ({ children: e, className: t, ...n }) => {
1049
+ let { goToNext: r, totalBranches: i } = ar();
1035
1050
  return /* @__PURE__ */ Q(v, {
1036
1051
  "aria-label": "Next branch",
1037
1052
  disabled: i <= 1,
@@ -1042,9 +1057,9 @@ var Xn = ({ className: e, from: t, ...n }) => /* @__PURE__ */ Q("div", {
1042
1057
  ...n,
1043
1058
  children: e ?? /* @__PURE__ */ Q(ze, { size: 14 })
1044
1059
  });
1045
- }, sr = ({ className: e, ...t }) => {
1046
- let { currentBranch: n, totalBranches: r } = tr();
1047
- return /* @__PURE__ */ $(Yn, {
1060
+ }, dr = ({ className: e, ...t }) => {
1061
+ let { currentBranch: n, totalBranches: r } = ar();
1062
+ return /* @__PURE__ */ $($n, {
1048
1063
  className: q("border-none bg-transparent text-muted-foreground shadow-none", e),
1049
1064
  ...t,
1050
1065
  children: [
@@ -1053,12 +1068,12 @@ var Xn = ({ className: e, from: t, ...n }) => /* @__PURE__ */ Q("div", {
1053
1068
  r
1054
1069
  ]
1055
1070
  });
1056
- }, cr = a(({ className: e, ...t }) => /* @__PURE__ */ Q(At, {
1071
+ }, fr = a(({ className: e, ...t }) => /* @__PURE__ */ Q(At, {
1057
1072
  className: q("size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0", e),
1058
1073
  ...t
1059
1074
  }), (e, t) => e.children === t.children);
1060
- cr.displayName = "MessageResponse";
1061
- function lr({ data: e, className: t, onRemove: n, ...r }) {
1075
+ fr.displayName = "MessageResponse";
1076
+ function pr({ data: e, className: t, onRemove: n, ...r }) {
1062
1077
  let i = e.filename || "", a = (e.mediaType?.startsWith("image/") && e.url ? "image" : "file") == "image", o = i || (a ? "Image" : "Attachment");
1063
1078
  return /* @__PURE__ */ Q("div", {
1064
1079
  className: q("group relative size-24 overflow-hidden rounded-lg", t),
@@ -1102,21 +1117,21 @@ function lr({ data: e, className: t, onRemove: n, ...r }) {
1102
1117
  })] })
1103
1118
  });
1104
1119
  }
1105
- function ur({ children: e, className: t, ...n }) {
1120
+ function mr({ children: e, className: t, ...n }) {
1106
1121
  return e ? /* @__PURE__ */ Q("div", {
1107
1122
  className: q("ml-auto flex w-fit flex-wrap items-start gap-2", t),
1108
1123
  ...n,
1109
1124
  children: e
1110
1125
  }) : null;
1111
1126
  }
1112
- var dr = ({ className: e, children: t, ...n }) => /* @__PURE__ */ Q("div", {
1127
+ var hr = ({ className: e, children: t, ...n }) => /* @__PURE__ */ Q("div", {
1113
1128
  className: q("mt-4 flex w-full items-center justify-between gap-4", e),
1114
1129
  ...n,
1115
1130
  children: t
1116
1131
  });
1117
1132
  //#endregion
1118
1133
  //#region src/elements/ui/input-group.tsx
1119
- function fr({ className: e, ...t }) {
1134
+ function gr({ className: e, ...t }) {
1120
1135
  return /* @__PURE__ */ Q("div", {
1121
1136
  "data-slot": "input-group",
1122
1137
  role: "group",
@@ -1124,7 +1139,7 @@ function fr({ className: e, ...t }) {
1124
1139
  ...t
1125
1140
  });
1126
1141
  }
1127
- var pr = Ot("flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium text-muted-foreground select-none group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-4", {
1142
+ var _r = Ot("flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium text-muted-foreground select-none group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-4", {
1128
1143
  variants: { align: {
1129
1144
  "inline-start": "order-first pl-3 has-[>button]:ml-[-0.45rem] has-[>kbd]:ml-[-0.35rem]",
1130
1145
  "inline-end": "order-last pr-3 has-[>button]:mr-[-0.45rem] has-[>kbd]:mr-[-0.35rem]",
@@ -1133,19 +1148,19 @@ var pr = Ot("flex h-auto cursor-text items-center justify-center gap-2 py-1.5 te
1133
1148
  } },
1134
1149
  defaultVariants: { align: "inline-start" }
1135
1150
  });
1136
- function mr({ className: e, align: t = "inline-start", ...n }) {
1151
+ function vr({ className: e, align: t = "inline-start", ...n }) {
1137
1152
  return /* @__PURE__ */ Q("div", {
1138
1153
  role: "group",
1139
1154
  "data-slot": "input-group-addon",
1140
1155
  "data-align": t,
1141
- className: q(pr({ align: t }), e),
1156
+ className: q(_r({ align: t }), e),
1142
1157
  onClick: (e) => {
1143
1158
  e.target.closest("button") || e.currentTarget.parentElement?.querySelector("input")?.focus();
1144
1159
  },
1145
1160
  ...n
1146
1161
  });
1147
1162
  }
1148
- var hr = Ot("flex items-center gap-2 text-sm shadow-none", {
1163
+ var yr = Ot("flex items-center gap-2 text-sm shadow-none", {
1149
1164
  variants: { size: {
1150
1165
  xs: "h-6 gap-1 rounded-[calc(var(--radius)-5px)] px-2 has-[>svg]:px-2 [&>svg:not([class*='size-'])]:size-3.5",
1151
1166
  sm: "h-8 gap-1.5 rounded-md px-2.5 has-[>svg]:px-2.5",
@@ -1154,16 +1169,16 @@ var hr = Ot("flex items-center gap-2 text-sm shadow-none", {
1154
1169
  } },
1155
1170
  defaultVariants: { size: "xs" }
1156
1171
  });
1157
- function gr({ className: e, type: t = "button", variant: n = "ghost", size: r = "xs", ...i }) {
1172
+ function br({ className: e, type: t = "button", variant: n = "ghost", size: r = "xs", ...i }) {
1158
1173
  return /* @__PURE__ */ Q(v, {
1159
1174
  type: t,
1160
1175
  "data-size": r,
1161
1176
  variant: n,
1162
- className: q(hr({ size: r }), e),
1177
+ className: q(yr({ size: r }), e),
1163
1178
  ...i
1164
1179
  });
1165
1180
  }
1166
- function _r({ className: e, ...t }) {
1181
+ function xr({ className: e, ...t }) {
1167
1182
  return /* @__PURE__ */ Q(K, {
1168
1183
  "data-slot": "input-group-control",
1169
1184
  className: q("flex-1 resize-none rounded-none border-0 bg-transparent py-3 shadow-none focus-visible:ring-0 dark:bg-transparent", e),
@@ -1172,16 +1187,16 @@ function _r({ className: e, ...t }) {
1172
1187
  }
1173
1188
  //#endregion
1174
1189
  //#region src/elements/prompt-input.tsx
1175
- var vr = r(null), yr = r(null), br = () => {
1176
- let e = s(vr);
1190
+ var Sr = r(null), Cr = r(null), wr = () => {
1191
+ let e = s(Sr);
1177
1192
  if (!e) throw Error("Wrap your component inside <PromptInputProvider> to use usePromptInputController().");
1178
1193
  return e;
1179
- }, xr = () => s(vr), Sr = () => {
1180
- let e = s(yr);
1194
+ }, Tr = () => s(Sr), Er = () => {
1195
+ let e = s(Cr);
1181
1196
  if (!e) throw Error("Wrap your component inside <PromptInputProvider> to use useProviderAttachments().");
1182
1197
  return e;
1183
- }, Cr = () => s(yr);
1184
- function wr({ initialInput: e = "", children: t }) {
1198
+ }, Dr = () => s(Cr);
1199
+ function Or({ initialInput: e = "", children: t }) {
1185
1200
  let [n, r] = d(e), i = o(() => r(""), []), [a, s] = d([]), f = u(null), p = u(() => {}), m = o((e) => {
1186
1201
  let t = Array.from(e);
1187
1202
  t.length !== 0 && s((e) => e.concat(t.map((e) => ({
@@ -1236,22 +1251,22 @@ function wr({ initialInput: e = "", children: t }) {
1236
1251
  y,
1237
1252
  b
1238
1253
  ]);
1239
- return /* @__PURE__ */ Q(vr.Provider, {
1254
+ return /* @__PURE__ */ Q(Sr.Provider, {
1240
1255
  value: x,
1241
- children: /* @__PURE__ */ Q(yr.Provider, {
1256
+ children: /* @__PURE__ */ Q(Cr.Provider, {
1242
1257
  value: y,
1243
1258
  children: t
1244
1259
  })
1245
1260
  });
1246
1261
  }
1247
- var Tr = r(null), Er = () => {
1248
- let e = Cr(), t = s(Tr), n = e ?? t;
1262
+ var kr = r(null), Ar = () => {
1263
+ let e = Dr(), t = s(kr), n = e ?? t;
1249
1264
  if (!n) throw Error("usePromptInputAttachments must be used within a PromptInput or PromptInputProvider");
1250
1265
  return n;
1251
1266
  };
1252
- function Dr({ data: e, className: t, ...n }) {
1253
- let r = Er(), i = e.filename || "", a = (e.mediaType?.startsWith("image/") && e.url ? "image" : "file") == "image", o = i || (a ? "Image" : "Attachment");
1254
- return /* @__PURE__ */ $(Jr, { children: [/* @__PURE__ */ Q(ae, {
1267
+ function jr({ data: e, className: t, ...n }) {
1268
+ let r = Ar(), i = e.filename || "", a = (e.mediaType?.startsWith("image/") && e.url ? "image" : "file") == "image", o = i || (a ? "Image" : "Attachment");
1269
+ return /* @__PURE__ */ $(Qr, { children: [/* @__PURE__ */ Q(B, {
1255
1270
  asChild: !0,
1256
1271
  children: /* @__PURE__ */ $("div", {
1257
1272
  className: q("group relative flex h-8 cursor-pointer select-none items-center gap-1.5 rounded-md border border-border px-1.5 font-medium text-sm transition-all hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50", t),
@@ -1288,7 +1303,7 @@ function Dr({ data: e, className: t, ...n }) {
1288
1303
  children: o
1289
1304
  })]
1290
1305
  }, e.id)
1291
- }), /* @__PURE__ */ Q(Xr, {
1306
+ }), /* @__PURE__ */ Q(ei, {
1292
1307
  className: "w-auto p-2",
1293
1308
  children: /* @__PURE__ */ $("div", {
1294
1309
  className: "w-auto space-y-3",
@@ -1317,16 +1332,16 @@ function Dr({ data: e, className: t, ...n }) {
1317
1332
  })
1318
1333
  })] });
1319
1334
  }
1320
- function Or({ children: e, className: t, ...r }) {
1321
- let i = Er();
1335
+ function Mr({ children: e, className: t, ...r }) {
1336
+ let i = Ar();
1322
1337
  return i.files.length ? /* @__PURE__ */ Q("div", {
1323
1338
  className: q("flex flex-wrap items-center gap-2 p-3 w-full", t),
1324
1339
  ...r,
1325
1340
  children: i.files.map((t) => /* @__PURE__ */ Q(n, { children: e(t) }, t.id))
1326
1341
  }) : null;
1327
1342
  }
1328
- var kr = ({ label: e = "Add photos or files", ...t }) => {
1329
- let n = Er();
1343
+ var Nr = ({ label: e = "Add photos or files", ...t }) => {
1344
+ let n = Ar();
1330
1345
  return /* @__PURE__ */ $(I, {
1331
1346
  ...t,
1332
1347
  onSelect: (e) => {
@@ -1338,8 +1353,8 @@ var kr = ({ label: e = "Add photos or files", ...t }) => {
1338
1353
  e
1339
1354
  ]
1340
1355
  });
1341
- }, Ar = ({ className: e, accept: t, multiple: n, fileInputLabel: r = "Upload files", globalDrop: i, syncHiddenInput: a, maxFiles: s, maxFileSize: f, onError: p, onSubmit: m, children: h, ...g }) => {
1342
- let _ = xr(), v = !!_, y = u(null), b = u(null), [x, S] = d([]), C = v ? _.attachments.files : x, w = u(C);
1356
+ }, Pr = ({ className: e, accept: t, multiple: n, fileInputLabel: r = "Upload files", globalDrop: i, syncHiddenInput: a, maxFiles: s, maxFileSize: f, onError: p, onSubmit: m, children: h, ...g }) => {
1357
+ let _ = Tr(), v = !!_, y = u(null), b = u(null), [x, S] = d([]), C = v ? _.attachments.files : x, w = u(C);
1343
1358
  w.current = C;
1344
1359
  let T = o(() => {
1345
1360
  y.current?.click();
@@ -1487,20 +1502,20 @@ var kr = ({ label: e = "Add photos or files", ...t }) => {
1487
1502
  },
1488
1503
  ref: b,
1489
1504
  ...g,
1490
- children: /* @__PURE__ */ Q(fr, {
1505
+ children: /* @__PURE__ */ Q(gr, {
1491
1506
  className: "overflow-hidden",
1492
1507
  children: h
1493
1508
  })
1494
1509
  })] });
1495
- return v ? L : /* @__PURE__ */ Q(Tr.Provider, {
1510
+ return v ? L : /* @__PURE__ */ Q(kr.Provider, {
1496
1511
  value: I,
1497
1512
  children: L
1498
1513
  });
1499
- }, jr = ({ className: e, ...t }) => /* @__PURE__ */ Q("div", {
1514
+ }, Fr = ({ className: e, ...t }) => /* @__PURE__ */ Q("div", {
1500
1515
  className: q("contents", e),
1501
1516
  ...t
1502
- }), Mr = ({ onChange: e, className: t, placeholder: n = "What would you like to know?", ...r }) => {
1503
- let i = xr(), a = Er(), [o, s] = d(!1), c = (e) => {
1517
+ }), Ir = ({ onChange: e, className: t, placeholder: n = "What would you like to know?", ...r }) => {
1518
+ let i = Tr(), a = Ar(), [o, s] = d(!1), c = (e) => {
1504
1519
  if (e.key === "Enter") {
1505
1520
  if (o || e.nativeEvent.isComposing || e.shiftKey) return;
1506
1521
  e.preventDefault();
@@ -1528,7 +1543,7 @@ var kr = ({ label: e = "Add photos or files", ...t }) => {
1528
1543
  i.textInput.setInput(t.currentTarget.value), e?.(t);
1529
1544
  }
1530
1545
  } : { onChange: e };
1531
- return /* @__PURE__ */ Q(_r, {
1546
+ return /* @__PURE__ */ Q(xr, {
1532
1547
  className: q("field-sizing-content max-h-48 min-h-16", t),
1533
1548
  name: "message",
1534
1549
  onCompositionEnd: () => s(!1),
@@ -1539,43 +1554,43 @@ var kr = ({ label: e = "Add photos or files", ...t }) => {
1539
1554
  ...r,
1540
1555
  ...u
1541
1556
  });
1542
- }, Nr = ({ className: e, ...t }) => /* @__PURE__ */ Q(mr, {
1557
+ }, Lr = ({ className: e, ...t }) => /* @__PURE__ */ Q(vr, {
1543
1558
  align: "block-end",
1544
1559
  className: q("order-first flex-wrap gap-1", e),
1545
1560
  ...t
1546
- }), Pr = ({ className: e, ...t }) => /* @__PURE__ */ Q(mr, {
1561
+ }), Rr = ({ className: e, ...t }) => /* @__PURE__ */ Q(vr, {
1547
1562
  align: "block-end",
1548
1563
  className: q("justify-between gap-1", e),
1549
1564
  ...t
1550
- }), Fr = ({ className: e, ...t }) => /* @__PURE__ */ Q("div", {
1565
+ }), zr = ({ className: e, ...t }) => /* @__PURE__ */ Q("div", {
1551
1566
  className: q("flex items-center gap-1", e),
1552
1567
  ...t
1553
- }), Ir = ({ variant: e = "ghost", className: n, size: r, ...i }) => {
1568
+ }), Br = ({ variant: e = "ghost", className: n, size: r, ...i }) => {
1554
1569
  let a = r ?? (t.count(i.children) > 1 ? "sm" : "icon-sm");
1555
- return /* @__PURE__ */ Q(gr, {
1570
+ return /* @__PURE__ */ Q(br, {
1556
1571
  className: q(n),
1557
1572
  size: a,
1558
1573
  type: "button",
1559
1574
  variant: e,
1560
1575
  ...i
1561
1576
  });
1562
- }, Lr = (e) => /* @__PURE__ */ Q(P, { ...e }), Rr = ({ className: e, children: t, ...n }) => /* @__PURE__ */ Q(L, {
1577
+ }, Vr = (e) => /* @__PURE__ */ Q(P, { ...e }), Hr = ({ className: e, children: t, ...n }) => /* @__PURE__ */ Q(L, {
1563
1578
  asChild: !0,
1564
- children: /* @__PURE__ */ Q(Ir, {
1579
+ children: /* @__PURE__ */ Q(Br, {
1565
1580
  className: e,
1566
1581
  ...n,
1567
1582
  children: t ?? /* @__PURE__ */ Q(st, { className: "size-4" })
1568
1583
  })
1569
- }), zr = ({ className: e, ...t }) => /* @__PURE__ */ Q(F, {
1584
+ }), Ur = ({ className: e, ...t }) => /* @__PURE__ */ Q(F, {
1570
1585
  align: "start",
1571
1586
  className: q(e),
1572
1587
  ...t
1573
- }), Br = ({ className: e, ...t }) => /* @__PURE__ */ Q(I, {
1588
+ }), Wr = ({ className: e, ...t }) => /* @__PURE__ */ Q(I, {
1574
1589
  className: q(e),
1575
1590
  ...t
1576
- }), Vr = ({ className: e, variant: t = "default", size: n = "icon-sm", status: r, children: i, ...a }) => {
1591
+ }), Gr = ({ className: e, variant: t = "default", size: n = "icon-sm", status: r, children: i, ...a }) => {
1577
1592
  let o = /* @__PURE__ */ Q(Je, { className: "size-4" });
1578
- return r === "submitted" ? o = /* @__PURE__ */ Q(nt, { className: "size-4 animate-spin" }) : r === "streaming" ? o = /* @__PURE__ */ Q(pt, { className: "size-4" }) : r === "error" && (o = /* @__PURE__ */ Q(bt, { className: "size-4" })), /* @__PURE__ */ Q(gr, {
1593
+ return r === "submitted" ? o = /* @__PURE__ */ Q(nt, { className: "size-4 animate-spin" }) : r === "streaming" ? o = /* @__PURE__ */ Q(pt, { className: "size-4" }) : r === "error" && (o = /* @__PURE__ */ Q(bt, { className: "size-4" })), /* @__PURE__ */ Q(br, {
1579
1594
  "aria-label": "Submit",
1580
1595
  className: q(e),
1581
1596
  size: n,
@@ -1584,7 +1599,7 @@ var kr = ({ label: e = "Add photos or files", ...t }) => {
1584
1599
  ...a,
1585
1600
  children: i ?? o
1586
1601
  });
1587
- }, Hr = ({ className: e, textareaRef: t, onTranscriptionChange: n, ...r }) => {
1602
+ }, Kr = ({ className: e, textareaRef: t, onTranscriptionChange: n, ...r }) => {
1588
1603
  let [i, a] = d(!1), [s, l] = d(null), f = u(null);
1589
1604
  c(() => {
1590
1605
  if (typeof window < "u" && ("SpeechRecognition" in window || "webkitSpeechRecognition" in window)) {
@@ -1614,69 +1629,69 @@ var kr = ({ label: e = "Add photos or files", ...t }) => {
1614
1629
  let p = o(() => {
1615
1630
  s && (i ? s.stop() : s.start());
1616
1631
  }, [s, i]);
1617
- return /* @__PURE__ */ Q(Ir, {
1632
+ return /* @__PURE__ */ Q(Br, {
1618
1633
  className: q("relative transition-all duration-200", i && "animate-pulse bg-accent text-accent-foreground", e),
1619
1634
  disabled: !s,
1620
1635
  onClick: p,
1621
1636
  ...r,
1622
1637
  children: /* @__PURE__ */ Q(it, { className: "size-4" })
1623
1638
  });
1624
- }, Ur = (e) => /* @__PURE__ */ Q(ce, { ...e }), Wr = ({ className: e, ...t }) => /* @__PURE__ */ Q(de, {
1639
+ }, qr = (e) => /* @__PURE__ */ Q(ce, { ...e }), Jr = ({ className: e, ...t }) => /* @__PURE__ */ Q(de, {
1625
1640
  className: q("border-none bg-transparent font-medium text-muted-foreground shadow-none transition-colors", "hover:bg-accent hover:text-foreground aria-expanded:bg-accent aria-expanded:text-foreground", e),
1626
1641
  ...t
1627
- }), Gr = ({ className: e, ...t }) => /* @__PURE__ */ Q(le, {
1642
+ }), Yr = ({ className: e, ...t }) => /* @__PURE__ */ Q(le, {
1628
1643
  className: q(e),
1629
1644
  ...t
1630
- }), Kr = ({ className: e, ...t }) => /* @__PURE__ */ Q(ue, {
1645
+ }), Xr = ({ className: e, ...t }) => /* @__PURE__ */ Q(ue, {
1631
1646
  className: q(e),
1632
1647
  ...t
1633
- }), qr = ({ className: e, ...t }) => /* @__PURE__ */ Q(fe, {
1648
+ }), Zr = ({ className: e, ...t }) => /* @__PURE__ */ Q(fe, {
1634
1649
  className: q(e),
1635
1650
  ...t
1636
- }), Jr = ({ openDelay: e = 0, closeDelay: t = 0, ...n }) => /* @__PURE__ */ Q(z, {
1651
+ }), Qr = ({ openDelay: e = 0, closeDelay: t = 0, ...n }) => /* @__PURE__ */ Q(z, {
1637
1652
  closeDelay: t,
1638
1653
  openDelay: e,
1639
1654
  ...n
1640
- }), Yr = (e) => /* @__PURE__ */ Q(ae, { ...e }), Xr = ({ align: e = "start", ...t }) => /* @__PURE__ */ Q(ie, {
1655
+ }), $r = (e) => /* @__PURE__ */ Q(B, { ...e }), ei = ({ align: e = "start", ...t }) => /* @__PURE__ */ Q(ie, {
1641
1656
  align: e,
1642
1657
  ...t
1643
- }), Zr = ({ className: e, ...t }) => /* @__PURE__ */ Q("div", {
1658
+ }), ti = ({ className: e, ...t }) => /* @__PURE__ */ Q("div", {
1644
1659
  className: q(e),
1645
1660
  ...t
1646
- }), Qr = ({ className: e, ...t }) => /* @__PURE__ */ Q("div", {
1661
+ }), ni = ({ className: e, ...t }) => /* @__PURE__ */ Q("div", {
1647
1662
  className: q(e),
1648
1663
  ...t
1649
- }), $r = ({ className: e, ...t }) => /* @__PURE__ */ Q("h3", {
1664
+ }), ri = ({ className: e, ...t }) => /* @__PURE__ */ Q("h3", {
1650
1665
  className: q("mb-2 px-3 font-medium text-muted-foreground text-xs", e),
1651
1666
  ...t
1652
- }), ei = ({ className: e, ...t }) => /* @__PURE__ */ Q("div", {
1667
+ }), ii = ({ className: e, ...t }) => /* @__PURE__ */ Q("div", {
1653
1668
  className: q("space-y-1", e),
1654
1669
  ...t
1655
- }), ti = ({ className: e, ...t }) => /* @__PURE__ */ Q("div", {
1670
+ }), ai = ({ className: e, ...t }) => /* @__PURE__ */ Q("div", {
1656
1671
  className: q("flex items-center gap-2 px-3 py-2 text-xs hover:bg-accent", e),
1657
1672
  ...t
1658
- }), ni = ({ className: e, ...t }) => /* @__PURE__ */ Q(D, {
1673
+ }), oi = ({ className: e, ...t }) => /* @__PURE__ */ Q(D, {
1659
1674
  className: q(e),
1660
1675
  ...t
1661
- }), ri = ({ className: e, ...t }) => /* @__PURE__ */ Q(A, {
1676
+ }), si = ({ className: e, ...t }) => /* @__PURE__ */ Q(A, {
1662
1677
  className: q(e),
1663
1678
  ...t
1664
- }), ii = ({ className: e, ...t }) => /* @__PURE__ */ Q(M, {
1679
+ }), ci = ({ className: e, ...t }) => /* @__PURE__ */ Q(M, {
1665
1680
  className: q(e),
1666
1681
  ...t
1667
- }), ai = ({ className: e, ...t }) => /* @__PURE__ */ Q(O, {
1682
+ }), li = ({ className: e, ...t }) => /* @__PURE__ */ Q(O, {
1668
1683
  className: q(e),
1669
1684
  ...t
1670
- }), oi = ({ className: e, ...t }) => /* @__PURE__ */ Q(k, {
1685
+ }), ui = ({ className: e, ...t }) => /* @__PURE__ */ Q(k, {
1671
1686
  className: q(e),
1672
1687
  ...t
1673
- }), si = ({ className: e, ...t }) => /* @__PURE__ */ Q(j, {
1688
+ }), di = ({ className: e, ...t }) => /* @__PURE__ */ Q(j, {
1674
1689
  className: q(e),
1675
1690
  ...t
1676
- }), ci = ({ className: e, ...t }) => /* @__PURE__ */ Q(N, {
1691
+ }), fi = ({ className: e, ...t }) => /* @__PURE__ */ Q(N, {
1677
1692
  className: q(e),
1678
1693
  ...t
1679
- }), li = ({ className: e, children: t, ...n }) => /* @__PURE__ */ $(oe, {
1694
+ }), pi = ({ className: e, children: t, ...n }) => /* @__PURE__ */ $(oe, {
1680
1695
  className: "w-full overflow-x-auto whitespace-nowrap",
1681
1696
  ...n,
1682
1697
  children: [/* @__PURE__ */ Q("div", {
@@ -1686,7 +1701,7 @@ var kr = ({ label: e = "Add photos or files", ...t }) => {
1686
1701
  className: "hidden",
1687
1702
  orientation: "horizontal"
1688
1703
  })]
1689
- }), ui = ({ suggestion: e, onClick: t, className: n, variant: r = "outline", size: i = "sm", children: a, ...o }) => /* @__PURE__ */ Q(v, {
1704
+ }), mi = ({ suggestion: e, onClick: t, className: n, variant: r = "outline", size: i = "sm", children: a, ...o }) => /* @__PURE__ */ Q(v, {
1690
1705
  className: q("cursor-pointer rounded-full px-4", n),
1691
1706
  onClick: () => {
1692
1707
  t?.(e);
@@ -1696,7 +1711,7 @@ var kr = ({ label: e = "Add photos or files", ...t }) => {
1696
1711
  variant: r,
1697
1712
  ...o,
1698
1713
  children: a || e
1699
- }), di = r({ code: "" }), fi = {
1714
+ }), hi = r({ code: "" }), gi = {
1700
1715
  name: "line-numbers",
1701
1716
  line(e, t) {
1702
1717
  e.children.unshift({
@@ -1717,8 +1732,8 @@ var kr = ({ label: e = "Add photos or files", ...t }) => {
1717
1732
  });
1718
1733
  }
1719
1734
  };
1720
- async function pi(e, t, n = !1) {
1721
- let r = n ? [fi] : [];
1735
+ async function _i(e, t, n = !1) {
1736
+ let r = n ? [gi] : [];
1722
1737
  return await Promise.all([Mt(e, {
1723
1738
  lang: t,
1724
1739
  theme: "one-light",
@@ -1729,9 +1744,9 @@ async function pi(e, t, n = !1) {
1729
1744
  transformers: r
1730
1745
  })]);
1731
1746
  }
1732
- var mi = ({ code: e, language: t, showLineNumbers: n = !1, className: r, children: i, ...a }) => {
1747
+ var vi = ({ code: e, language: t, showLineNumbers: n = !1, className: r, children: i, ...a }) => {
1733
1748
  let [o, s] = d(""), [l, f] = d(""), p = u(!1);
1734
- return c(() => (pi(e, t, n).then(([e, t]) => {
1749
+ return c(() => (_i(e, t, n).then(([e, t]) => {
1735
1750
  p.current ||= (s(e), f(t), !0);
1736
1751
  }), () => {
1737
1752
  p.current = !1;
@@ -1739,7 +1754,7 @@ var mi = ({ code: e, language: t, showLineNumbers: n = !1, className: r, childre
1739
1754
  e,
1740
1755
  t,
1741
1756
  n
1742
- ]), /* @__PURE__ */ Q(di.Provider, {
1757
+ ]), /* @__PURE__ */ Q(hi.Provider, {
1743
1758
  value: { code: e },
1744
1759
  children: /* @__PURE__ */ Q("div", {
1745
1760
  className: q("group relative w-full overflow-hidden rounded-md border bg-background text-foreground", r),
@@ -1763,8 +1778,8 @@ var mi = ({ code: e, language: t, showLineNumbers: n = !1, className: r, childre
1763
1778
  })
1764
1779
  })
1765
1780
  });
1766
- }, hi = ({ onCopy: e, onError: t, timeout: n = 2e3, children: r, className: i, ...a }) => {
1767
- let [o, c] = d(!1), { code: l } = s(di), u = async () => {
1781
+ }, yi = ({ onCopy: e, onError: t, timeout: n = 2e3, children: r, className: i, ...a }) => {
1782
+ let [o, c] = d(!1), { code: l } = s(hi), u = async () => {
1768
1783
  if (typeof window > "u" || !navigator?.clipboard?.writeText) {
1769
1784
  t?.(/* @__PURE__ */ Error("Clipboard API not available"));
1770
1785
  return;
@@ -1783,10 +1798,10 @@ var mi = ({ code: e, language: t, showLineNumbers: n = !1, className: r, childre
1783
1798
  ...a,
1784
1799
  children: r ?? /* @__PURE__ */ Q(f, { size: 14 })
1785
1800
  });
1786
- }, gi = ({ className: e, ...t }) => /* @__PURE__ */ Q(w, {
1801
+ }, bi = ({ className: e, ...t }) => /* @__PURE__ */ Q(w, {
1787
1802
  className: q("not-prose mb-4 w-full rounded-md border", e),
1788
1803
  ...t
1789
- }), _i = (e) => /* @__PURE__ */ $(_, {
1804
+ }), xi = (e) => /* @__PURE__ */ $(_, {
1790
1805
  className: "gap-1.5 rounded-full text-xs",
1791
1806
  variant: "secondary",
1792
1807
  children: [{
@@ -1806,7 +1821,7 @@ var mi = ({ code: e, language: t, showLineNumbers: n = !1, className: r, childre
1806
1821
  "output-error": "Error",
1807
1822
  "output-denied": "Denied"
1808
1823
  }[e]]
1809
- }), vi = ({ className: e, title: t, type: n, state: r, ...i }) => /* @__PURE__ */ $(E, {
1824
+ }), Si = ({ className: e, title: t, type: n, state: r, ...i }) => /* @__PURE__ */ $(E, {
1810
1825
  className: q("flex w-full items-center justify-between gap-4 p-3", e),
1811
1826
  ...i,
1812
1827
  children: [/* @__PURE__ */ $("div", {
@@ -1817,13 +1832,13 @@ var mi = ({ code: e, language: t, showLineNumbers: n = !1, className: r, childre
1817
1832
  className: "font-medium text-sm",
1818
1833
  children: t ?? n.split("-").slice(1).join("-")
1819
1834
  }),
1820
- _i(r)
1835
+ xi(r)
1821
1836
  ]
1822
1837
  }), /* @__PURE__ */ Q(Le, { className: "size-4 text-muted-foreground transition-transform group-data-[state=open]:rotate-180" })]
1823
- }), yi = ({ className: e, ...t }) => /* @__PURE__ */ Q(T, {
1838
+ }), Ci = ({ className: e, ...t }) => /* @__PURE__ */ Q(T, {
1824
1839
  className: q("data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-popover-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in", e),
1825
1840
  ...t
1826
- }), bi = ({ className: e, input: t, ...n }) => /* @__PURE__ */ $("div", {
1841
+ }), wi = ({ className: e, input: t, ...n }) => /* @__PURE__ */ $("div", {
1827
1842
  className: q("space-y-2 overflow-hidden p-4", e),
1828
1843
  ...n,
1829
1844
  children: [/* @__PURE__ */ Q("h4", {
@@ -1831,18 +1846,18 @@ var mi = ({ code: e, language: t, showLineNumbers: n = !1, className: r, childre
1831
1846
  children: "Parameters"
1832
1847
  }), /* @__PURE__ */ Q("div", {
1833
1848
  className: "rounded-md bg-muted/50",
1834
- children: /* @__PURE__ */ Q(mi, {
1849
+ children: /* @__PURE__ */ Q(vi, {
1835
1850
  code: JSON.stringify(t, null, 2),
1836
1851
  language: "json"
1837
1852
  })
1838
1853
  })]
1839
- }), xi = ({ className: e, output: t, errorText: n, ...r }) => {
1854
+ }), Ti = ({ className: e, output: t, errorText: n, ...r }) => {
1840
1855
  if (!(t || n)) return null;
1841
1856
  let a = /* @__PURE__ */ Q("div", { children: t });
1842
- return typeof t == "object" && !i(t) ? a = /* @__PURE__ */ Q(mi, {
1857
+ return typeof t == "object" && !i(t) ? a = /* @__PURE__ */ Q(vi, {
1843
1858
  code: JSON.stringify(t, null, 2),
1844
1859
  language: "json"
1845
- }) : typeof t == "string" && (a = /* @__PURE__ */ Q(mi, {
1860
+ }) : typeof t == "string" && (a = /* @__PURE__ */ Q(vi, {
1846
1861
  code: t,
1847
1862
  language: "json"
1848
1863
  })), /* @__PURE__ */ $("div", {
@@ -1856,7 +1871,7 @@ var mi = ({ code: e, language: t, showLineNumbers: n = !1, className: r, childre
1856
1871
  children: [n && /* @__PURE__ */ Q("div", { children: n }), a]
1857
1872
  })]
1858
1873
  });
1859
- }, Si = a(({ children: e, as: t = "p", className: n, duration: r = 2, spread: i = 2 }) => {
1874
+ }, Ei = a(({ children: e, as: t = "p", className: n, duration: r = 2, spread: i = 2 }) => {
1860
1875
  let a = Pt.create(t), o = l(() => (e?.length ?? 0) * i, [e, i]);
1861
1876
  return /* @__PURE__ */ Q(a, {
1862
1877
  animate: { backgroundPosition: "0% center" },
@@ -1873,11 +1888,11 @@ var mi = ({ code: e, language: t, showLineNumbers: n = !1, className: r, childre
1873
1888
  },
1874
1889
  children: e
1875
1890
  });
1876
- }), Ci = r(null), wi = () => {
1877
- let e = s(Ci);
1891
+ }), Di = r(null), Oi = () => {
1892
+ let e = s(Di);
1878
1893
  if (!e) throw Error("Reasoning components must be used within Reasoning");
1879
1894
  return e;
1880
- }, Ti = 1e3, Ei = 1e3, Di = a(({ className: e, isStreaming: t = !1, open: n, defaultOpen: r = !0, onOpenChange: i, duration: a, children: o, ...s }) => {
1895
+ }, ki = 1e3, Ai = 1e3, ji = a(({ className: e, isStreaming: t = !1, open: n, defaultOpen: r = !0, onOpenChange: i, duration: a, children: o, ...s }) => {
1881
1896
  let [l, u] = Nt({
1882
1897
  prop: n,
1883
1898
  defaultProp: r,
@@ -1887,7 +1902,7 @@ var mi = ({ code: e, language: t, showLineNumbers: n = !1, className: r, childre
1887
1902
  defaultProp: void 0
1888
1903
  }), [m, h] = d(!1), [g, _] = d(null);
1889
1904
  return c(() => {
1890
- t ? g === null && _(Date.now()) : g !== null && (p(Math.ceil((Date.now() - g) / Ei)), _(null));
1905
+ t ? g === null && _(Date.now()) : g !== null && (p(Math.ceil((Date.now() - g) / Ai)), _(null));
1891
1906
  }, [
1892
1907
  t,
1893
1908
  g,
@@ -1896,7 +1911,7 @@ var mi = ({ code: e, language: t, showLineNumbers: n = !1, className: r, childre
1896
1911
  if (r && !t && l && !m) {
1897
1912
  let e = setTimeout(() => {
1898
1913
  u(!1), h(!0);
1899
- }, Ti);
1914
+ }, ki);
1900
1915
  return () => clearTimeout(e);
1901
1916
  }
1902
1917
  }, [
@@ -1905,7 +1920,7 @@ var mi = ({ code: e, language: t, showLineNumbers: n = !1, className: r, childre
1905
1920
  r,
1906
1921
  u,
1907
1922
  m
1908
- ]), /* @__PURE__ */ Q(Ci.Provider, {
1923
+ ]), /* @__PURE__ */ Q(Di.Provider, {
1909
1924
  value: {
1910
1925
  isStreaming: t,
1911
1926
  isOpen: l,
@@ -1922,15 +1937,15 @@ var mi = ({ code: e, language: t, showLineNumbers: n = !1, className: r, childre
1922
1937
  children: o
1923
1938
  })
1924
1939
  });
1925
- }), Oi = (e, t) => e || t === 0 ? /* @__PURE__ */ Q(Si, {
1940
+ }), Mi = (e, t) => e || t === 0 ? /* @__PURE__ */ Q(Ei, {
1926
1941
  duration: 1,
1927
1942
  children: "Thinking..."
1928
1943
  }) : t === void 0 ? /* @__PURE__ */ Q("p", { children: "Thought for a few seconds" }) : /* @__PURE__ */ $("p", { children: [
1929
1944
  "Thought for ",
1930
1945
  t,
1931
1946
  " seconds"
1932
- ] }), ki = a(({ className: e, children: t, getThinkingMessage: n = Oi, ...r }) => {
1933
- let { isStreaming: i, isOpen: a, duration: o } = wi();
1947
+ ] }), Ni = a(({ className: e, children: t, getThinkingMessage: n = Mi, ...r }) => {
1948
+ let { isStreaming: i, isOpen: a, duration: o } = Oi();
1934
1949
  return /* @__PURE__ */ Q(E, {
1935
1950
  className: q("flex w-full items-center gap-2 text-muted-foreground text-sm transition-colors hover:text-foreground", e),
1936
1951
  ...r,
@@ -1940,18 +1955,18 @@ var mi = ({ code: e, language: t, showLineNumbers: n = !1, className: r, childre
1940
1955
  /* @__PURE__ */ Q(Le, { className: q("size-4 transition-transform", a ? "rotate-180" : "rotate-0") })
1941
1956
  ] })
1942
1957
  });
1943
- }), Ai = a(({ className: e, children: t, ...n }) => /* @__PURE__ */ Q(T, {
1958
+ }), Pi = a(({ className: e, children: t, ...n }) => /* @__PURE__ */ Q(T, {
1944
1959
  className: q("mt-4 text-sm", "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", e),
1945
1960
  ...n,
1946
1961
  children: /* @__PURE__ */ Q(At, { children: t })
1947
1962
  }));
1948
- Di.displayName = "Reasoning", ki.displayName = "ReasoningTrigger", Ai.displayName = "ReasoningContent";
1963
+ ji.displayName = "Reasoning", Ni.displayName = "ReasoningTrigger", Pi.displayName = "ReasoningContent";
1949
1964
  //#endregion
1950
1965
  //#region src/elements/sources.tsx
1951
- var ji = ({ className: e, ...t }) => /* @__PURE__ */ Q(w, {
1966
+ var Fi = ({ className: e, ...t }) => /* @__PURE__ */ Q(w, {
1952
1967
  className: q("not-prose mb-4 text-primary text-xs", e),
1953
1968
  ...t
1954
- }), Mi = ({ className: e, count: t, children: n, ...r }) => /* @__PURE__ */ Q(E, {
1969
+ }), Ii = ({ className: e, count: t, children: n, ...r }) => /* @__PURE__ */ Q(E, {
1955
1970
  className: q("flex items-center gap-2", e),
1956
1971
  ...r,
1957
1972
  children: n ?? /* @__PURE__ */ $(Z, { children: [/* @__PURE__ */ $("p", {
@@ -1962,10 +1977,10 @@ var ji = ({ className: e, ...t }) => /* @__PURE__ */ Q(w, {
1962
1977
  " sources"
1963
1978
  ]
1964
1979
  }), /* @__PURE__ */ Q(Le, { className: "h-4 w-4" })] })
1965
- }), Ni = ({ className: e, ...t }) => /* @__PURE__ */ Q(T, {
1980
+ }), Li = ({ className: e, ...t }) => /* @__PURE__ */ Q(T, {
1966
1981
  className: q("mt-3 flex w-fit flex-col gap-2", "data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 outline-none data-[state=closed]:animate-out data-[state=open]:animate-in", e),
1967
1982
  ...t
1968
- }), Pi = ({ href: e, title: t, children: n, ...r }) => /* @__PURE__ */ Q("a", {
1983
+ }), Ri = ({ href: e, title: t, children: n, ...r }) => /* @__PURE__ */ Q("a", {
1969
1984
  className: "flex items-center gap-2",
1970
1985
  href: e,
1971
1986
  rel: "noreferrer",
@@ -1978,7 +1993,7 @@ var ji = ({ className: e, ...t }) => /* @__PURE__ */ Q(w, {
1978
1993
  });
1979
1994
  //#endregion
1980
1995
  //#region src/ChatbotEnhanced.tsx
1981
- function Fi(e) {
1996
+ function zi(e) {
1982
1997
  let t = e ?? {}, n = t.data && typeof t.data == "object" ? t.data : t, r = n.seedApplied, i = n.probes;
1983
1998
  if (!r && !i) return;
1984
1999
  let a = {};
@@ -1992,10 +2007,10 @@ function Fi(e) {
1992
2007
  message: String(e.message)
1993
2008
  }))), a;
1994
2009
  }
1995
- function Ii(e) {
2010
+ function Bi(e) {
1996
2011
  return e === "user" ? "user" : "assistant";
1997
2012
  }
1998
- function Li(e) {
2013
+ function Vi(e) {
1999
2014
  let t = e.trim();
2000
2015
  if (t.length < 2 || !(t.startsWith("{") || t.startsWith("[")) || !(t.endsWith("}") || t.endsWith("]"))) return !1;
2001
2016
  try {
@@ -2004,11 +2019,15 @@ function Li(e) {
2004
2019
  return !1;
2005
2020
  }
2006
2021
  }
2007
- function Ri(e) {
2022
+ function Hi(e) {
2023
+ let t = Vt(e)?.status;
2024
+ return t === "changes_proposed" || t === "blueprint_proposed" || t === "awaiting_confirmation";
2025
+ }
2026
+ function Ui(e) {
2008
2027
  let t = e.state ?? (e.errorText ? "output-error" : e.result === void 0 ? "input-available" : "output-available");
2009
- return t === "output-error" || t === "output-denied" ? "failed" : t === "approval-requested" || t === "approval-responded" ? "awaiting" : t === "output-available" ? "completed" : "running";
2028
+ return t === "output-error" || t === "output-denied" ? "failed" : t === "approval-requested" || t === "approval-responded" ? "awaiting" : t === "output-available" ? Hi(e.result) ? "awaiting" : "completed" : "running";
2010
2029
  }
2011
- function zi(e) {
2030
+ function Wi(e) {
2012
2031
  return [
2013
2032
  {
2014
2033
  create_object: "新建对象",
@@ -2024,13 +2043,13 @@ function zi(e) {
2024
2043
  e.details
2025
2044
  ].filter(Boolean).join(" ");
2026
2045
  }
2027
- function Bi(e) {
2046
+ function Gi(e) {
2028
2047
  return e.toolName === "propose_blueprint";
2029
2048
  }
2030
- function Vi(e) {
2031
- return Bi(e) && Ri(e) === "completed" && !e.proposedPlan && !e.proposedChanges && !e.draftReview?.items.length;
2049
+ function Ki(e) {
2050
+ return Gi(e) && Ui(e) === "completed" && !e.proposedPlan && !e.proposedChanges && !e.draftReview?.items.length;
2032
2051
  }
2033
- var Hi = [
2052
+ var qi = [
2034
2053
  "待补",
2035
2054
  "后续",
2036
2055
  "将在",
@@ -2056,25 +2075,25 @@ var Hi = [
2056
2075
  "coming soon",
2057
2076
  "tbd"
2058
2077
  ];
2059
- function Ui(e) {
2078
+ function Ji(e) {
2060
2079
  let t = [], n = [];
2061
2080
  for (let r of e) {
2062
2081
  if (typeof r != "string") continue;
2063
2082
  let e = r.trim();
2064
2083
  if (!e) continue;
2065
2084
  let i = e.toLowerCase();
2066
- Hi.some((e) => i.includes(e)) ? n.push(e) : t.push(e);
2085
+ qi.some((e) => i.includes(e)) ? n.push(e) : t.push(e);
2067
2086
  }
2068
2087
  return {
2069
2088
  designNotes: t,
2070
2089
  deferred: n
2071
2090
  };
2072
2091
  }
2073
- function Wi(e) {
2074
- let t = Ri(e);
2075
- return t === "awaiting" || t === "failed" || !!e.pendingActionId || !!e.draftReview?.items.length || !!e.proposedPlan || !!e.proposedChanges || Vi(e);
2092
+ function Yi(e) {
2093
+ let t = Ui(e);
2094
+ return t === "awaiting" || t === "failed" || !!e.pendingActionId || !!e.draftReview?.items.length || !!e.proposedPlan || !!e.proposedChanges || Ki(e);
2076
2095
  }
2077
- function Gi(e) {
2096
+ function Xi(e) {
2078
2097
  switch (e) {
2079
2098
  case "failed": return 4;
2080
2099
  case "awaiting": return 3;
@@ -2082,17 +2101,20 @@ function Gi(e) {
2082
2101
  case "completed": return 1;
2083
2102
  }
2084
2103
  }
2085
- function Ki(e) {
2104
+ function Zi(e) {
2105
+ return /^\((?:called [^)]*|tool call|no content)\)$/.test(e.trim());
2106
+ }
2107
+ function Qi(e) {
2086
2108
  let t = /* @__PURE__ */ new Map();
2087
2109
  for (let n of e) {
2088
- let e = Ri(n), r = `${n.toolName}:${e}`, i = t.get(r);
2110
+ let e = Ui(n), r = `${n.toolName}:${e}`, i = t.get(r);
2089
2111
  if (i) {
2090
2112
  i.count += 1, i.errorText = i.errorText ?? n.errorText;
2091
2113
  continue;
2092
2114
  }
2093
2115
  t.set(r, {
2094
2116
  key: r,
2095
- title: Fn(n.toolName) || n.toolName,
2117
+ title: zn(n.toolName) || n.toolName,
2096
2118
  rawName: n.toolName,
2097
2119
  count: 1,
2098
2120
  state: e,
@@ -2100,11 +2122,11 @@ function Ki(e) {
2100
2122
  });
2101
2123
  }
2102
2124
  return Array.from(t.values()).sort((e, t) => {
2103
- let n = Gi(t.state) - Gi(e.state);
2125
+ let n = Xi(t.state) - Xi(e.state);
2104
2126
  return n === 0 ? e.title.localeCompare(t.title) : n;
2105
2127
  });
2106
2128
  }
2107
- function qi({ health: e }) {
2129
+ function $i({ health: e }) {
2108
2130
  if (!e) return null;
2109
2131
  let t = e.issues ?? [], n = t.filter((e) => e.severity === "error"), r = t.filter((e) => e.severity !== "error"), i = e.checked, a = !!i && i.seeds + i.views + i.widgets > 0, o = [];
2110
2132
  if (typeof e.seededRows == "number" && e.seededRows > 0 && !e.seedError && o.push(`${e.seededRows} sample row${e.seededRows === 1 ? "" : "s"} live`), a && n.length === 0) {
@@ -2134,7 +2156,7 @@ function qi({ health: e }) {
2134
2156
  ]
2135
2157
  });
2136
2158
  }
2137
- var Ji = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type your message...", onSendMessage: i, onClear: a, onStop: o, onReload: s, onUpgrade: c, disabled: l = !1, readOnly: u = !1, isLoading: d = !1, error: f, showTimestamp: p = !1, showAvatars: m = !1, userAvatarUrl: h, userAvatarFallback: g = "You", assistantAvatarUrl: _, assistantAvatarFallback: v = "AI", hideClearBar: y = !1, maxHeight: b = "500px", enableMarkdown: x = !0, enableFileUpload: S = !1, acceptedFileTypes: C = "image/*,.pdf,.doc,.docx,.txt", maxFileSize: w = 10 * 1024 * 1024, suggestions: T, labels: E, models: D, selectedModelId: O, onModelChange: k, headerSlot: A, promptOverlaySlot: j, onInputChange: M, onToolApprove: N, toolApproveLabel: P = "Approve", toolDenyLabel: F = "Deny", toolDenyReason: I = "User denied the operation", toolDecisions: L, onReviewDraft: ee, toolReviewLabel: te = (e) => `Review ${e} change${e === 1 ? "" : "s"}`, onPublishDrafts: R, onOpenBuiltApp: ne, openBuiltAppLabel: re = "Open app", onPreviewDraftApp: z, previewDraftLabel: ie = "Preview", onDraftArtifacts: ae, onBuildMaterialized: B, publishDraftsLabel: V = "Publish", publishedLabel: oe = "Published", verifiedLabel: se = "Verified", nextStepsLabel: ce = "What's next", planTitleLabel: le = "Proposed plan", planExtendLabel: ue = "Adding to existing app", planQuestionsLabel: de = "Confirm before building", planAssumptionsLabel: fe = "Assumptions", planDeferredLabel: pe = "Not yet built", planApproveHintLabel: me = "Reply to approve or adjust this plan.", planApproveLabel: he = "Build it", planAdjustLabel: ge = "Adjust", planBuiltLabel: _e = "Built", planReadyLabel: ve = "The plan is ready. Build it now, or tell me what to adjust.", planApproveMessage: ye = "Looks good — build it as proposed.", planApproveDefaultsMessage: be = "Build it with your best assumptions; use sensible defaults for the open questions.", planAnswerMessage: xe = (e, t) => `For "${e}", go with: ${t}.`, fetchPendingDraftCount: H, autoPublishDrafts: U = !1, processVisibility: W = "summary", surface: Se = "card", ...Ce }, we) => {
2159
+ var ea = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type your message...", onSendMessage: i, onClear: a, onStop: o, onReload: s, onUpgrade: c, disabled: l = !1, readOnly: u = !1, isLoading: d = !1, error: f, showTimestamp: p = !1, showAvatars: m = !1, userAvatarUrl: h, userAvatarFallback: g = "You", assistantAvatarUrl: _, assistantAvatarFallback: v = "AI", hideClearBar: y = !1, maxHeight: b = "500px", enableMarkdown: x = !0, enableFileUpload: S = !1, acceptedFileTypes: C = "image/*,.pdf,.doc,.docx,.txt", maxFileSize: w = 10 * 1024 * 1024, suggestions: T, labels: E, models: D, selectedModelId: O, onModelChange: k, headerSlot: A, promptOverlaySlot: j, onInputChange: M, onToolApprove: N, toolApproveLabel: P = "Approve", toolDenyLabel: F = "Deny", toolDenyReason: I = "User denied the operation", toolDecisions: L, onReviewDraft: ee, toolReviewLabel: te = (e) => `Review ${e} change${e === 1 ? "" : "s"}`, onPublishDrafts: R, onOpenBuiltApp: ne, openBuiltAppLabel: re = "Open app", onPreviewDraftApp: z, previewDraftLabel: ie = "Preview", onDraftArtifacts: B, onBuildMaterialized: ae, publishDraftsLabel: V = "Publish", publishedLabel: oe = "Published", verifiedLabel: se = "Verified", nextStepsLabel: ce = "What's next", planTitleLabel: le = "Proposed plan", planExtendLabel: ue = "Adding to existing app", planQuestionsLabel: de = "Confirm before building", planAssumptionsLabel: fe = "Assumptions", planDeferredLabel: pe = "Not yet built", planApproveHintLabel: me = "Reply to approve or adjust this plan.", planApproveLabel: he = "Build it", planAdjustLabel: ge = "Adjust", planBuiltLabel: _e = "Built", planReadyLabel: ve = "The plan is ready. Build it now, or tell me what to adjust.", planApproveMessage: ye = "Looks good — build it as proposed.", planApproveDefaultsMessage: be = "Build it with your best assumptions; use sensible defaults for the open questions.", planAnswerMessage: xe = (e, t) => `For "${e}", go with: ${t}.`, fetchPendingDraftCount: H, autoPublishDrafts: U = !1, processVisibility: W = "summary", surface: Se = "card", ...Ce }, we) => {
2138
2160
  let G = d ? "streaming" : "ready", K = Se === "plain", [Te, Ee] = e.useState(null), De = e.useRef(""), Oe = e.useRef(null), J = e.useMemo(() => ({
2139
2161
  emptyTitle: E?.emptyTitle ?? "Start a conversation",
2140
2162
  emptyDescription: E?.emptyDescription ?? "Ask anything — the assistant has access to your current app context.",
@@ -2161,7 +2183,7 @@ var Ji = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
2161
2183
  connectionStalledLabel: E?.connectionStalledLabel ?? "Still working…",
2162
2184
  connectionOfflineLabel: E?.connectionOfflineLabel ?? "Connection lost — reconnecting…",
2163
2185
  designingPlanLabel: E?.designingPlanLabel ?? "Designing your app…",
2164
- designingPlanHints: E?.designingPlanHints ?? ra
2186
+ designingPlanHints: E?.designingPlanHints ?? la
2165
2187
  }), [E]), [Ae, je] = e.useState(() => /* @__PURE__ */ new Set()), [Ne, Fe] = e.useState(() => /* @__PURE__ */ new Map()), [Ie, Le] = e.useState(() => /* @__PURE__ */ new Map()), Re = e.useRef(/* @__PURE__ */ new Set()), ze = e.useCallback(async (e) => {
2166
2188
  if (H) try {
2167
2189
  let t = await H(e);
@@ -2239,7 +2261,7 @@ var Ji = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
2239
2261
  ]);
2240
2262
  let We = e.useRef(/* @__PURE__ */ new Set());
2241
2263
  e.useEffect(() => {
2242
- if (!ae) return;
2264
+ if (!B) return;
2243
2265
  let e = /* @__PURE__ */ new Map(), t;
2244
2266
  for (let r of n) {
2245
2267
  for (let t of r.buildProgress?.items ?? []) t?.type && t?.name && e.set(`${t.type}:${t.name}`, t);
@@ -2251,17 +2273,17 @@ var Ji = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
2251
2273
  }
2252
2274
  let r = We.current, i = !1;
2253
2275
  for (let t of e.keys()) r.has(t) || (r.add(t), i = !0);
2254
- i && ae([...e.values()], t);
2255
- }, [n, ae]);
2276
+ i && B([...e.values()], t);
2277
+ }, [n, B]);
2256
2278
  let Ke = e.useRef(/* @__PURE__ */ new Set());
2257
2279
  e.useEffect(() => {
2258
- if (B) for (let e of n) for (let t of e.toolInvocations ?? []) {
2280
+ if (ae) for (let e of n) for (let t of e.toolInvocations ?? []) {
2259
2281
  let e = t.draftReview;
2260
2282
  if (!e?.materialized || !t.toolCallId) continue;
2261
2283
  let n = e.items.find((e) => e.type === "app");
2262
- !n || Ke.current.has(t.toolCallId) || (Ke.current.add(t.toolCallId), B(n.name));
2284
+ !n || Ke.current.has(t.toolCallId) || (Ke.current.add(t.toolCallId), ae(n.name));
2263
2285
  }
2264
- }, [n, B]);
2286
+ }, [n, ae]);
2265
2287
  let Je = e.useCallback((e) => {
2266
2288
  let t = !!e.text?.trim(), n = e.files?.map((e) => e.file).filter(Boolean), r = !!(n && n.length > 0);
2267
2289
  if (!(t || r)) return;
@@ -2280,7 +2302,7 @@ var Ji = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
2280
2302
  e && (e.focus(), e.scrollIntoView({ block: "nearest" }));
2281
2303
  }, []);
2282
2304
  e.useEffect(() => {
2283
- if (!f || !Bn(f) || Oe.current === f) return;
2305
+ if (!f || !Wn(f) || Oe.current === f) return;
2284
2306
  Oe.current = f;
2285
2307
  let e = De.current;
2286
2308
  if (!e) return;
@@ -2291,7 +2313,7 @@ var Ji = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
2291
2313
  navigator.clipboard?.writeText(e.content), Ee(e.id), window.setTimeout(() => Ee((t) => t === e.id ? null : t), 1500);
2292
2314
  }, []), it = e.useMemo(() => {
2293
2315
  let e = /* @__PURE__ */ new Set(), t = [], r = -1, i = 0;
2294
- for (let e of n) for (let n of e.toolInvocations ?? []) (n.proposedPlan || Vi(n)) && n.toolCallId && t.push({
2316
+ for (let e of n) for (let n of e.toolInvocations ?? []) (n.proposedPlan || Ki(n)) && n.toolCallId && t.push({
2295
2317
  id: n.toolCallId,
2296
2318
  order: i
2297
2319
  }), n.toolName === "apply_blueprint" && (r = i), i += 1;
@@ -2310,7 +2332,7 @@ var Ji = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
2310
2332
  }
2311
2333
  return e;
2312
2334
  }, [n]), ot = (e) => {
2313
- let t = e.state ?? (e.errorText ? "output-error" : e.result === void 0 ? "input-available" : "output-available"), n = `tool-${e.toolName}`, r = L?.[e.toolCallId], a = t === "approval-requested" && !!N && !r, o = t === "approval-requested" && !!e.pendingActionId, s = Fn(e.toolName), c = In(e.result), l = W === "debug" && s && s.toLowerCase() !== e.toolName.toLowerCase(), u = W === "debug" || a, d = e.draftReview?.packageId, f = d === void 0 ? void 0 : Ie.get(d), p = f === void 0 ? Ae.has(e.toolCallId) : f === 0, m = t === "input-streaming" || t === "input-available", h = /* @__PURE__ */ $("span", {
2335
+ let t = e.state ?? (e.errorText ? "output-error" : e.result === void 0 ? "input-available" : "output-available"), n = `tool-${e.toolName}`, r = L?.[e.toolCallId], a = t === "approval-requested" && !!N && !r, o = t === "approval-requested" && !!e.pendingActionId, s = zn(e.toolName), c = Bn(e.result), l = W === "debug" && s && s.toLowerCase() !== e.toolName.toLowerCase(), u = W === "debug" || a, d = e.draftReview?.packageId, f = d === void 0 ? void 0 : Ie.get(d), p = f === void 0 ? Ae.has(e.toolCallId) : f === 0, m = t === "input-streaming" || t === "input-available", h = t === "output-available" && Hi(e.result) ? "approval-requested" : t, g = /* @__PURE__ */ $("span", {
2314
2336
  className: "inline-flex min-w-0 items-center gap-2",
2315
2337
  children: [
2316
2338
  /* @__PURE__ */ Q("span", { children: s || e.toolName }),
@@ -2318,22 +2340,22 @@ var Ji = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
2318
2340
  className: "rounded bg-muted px-1 py-px text-[10px] font-mono text-muted-foreground",
2319
2341
  children: e.toolName
2320
2342
  }) : null,
2321
- m ? Bi(e) ? /* @__PURE__ */ Q(oa, {
2343
+ m ? Gi(e) ? /* @__PURE__ */ Q(fa, {
2322
2344
  label: J.designingPlanLabel,
2323
2345
  hints: J.designingPlanHints,
2324
2346
  offlineLabel: J.connectionOfflineLabel
2325
- }) : /* @__PURE__ */ Q(sa, { offlineLabel: J.connectionOfflineLabel }) : null
2347
+ }) : /* @__PURE__ */ Q(pa, { offlineLabel: J.connectionOfflineLabel }) : null
2326
2348
  ]
2327
2349
  });
2328
- return /* @__PURE__ */ $(gi, {
2329
- defaultOpen: t === "output-error" || t === "approval-requested" || !!(e.draftReview && e.draftReview.items.length > 0) || !!e.proposedPlan || !!e.proposedChanges || Vi(e),
2330
- children: [/* @__PURE__ */ Q(vi, {
2350
+ return /* @__PURE__ */ $(bi, {
2351
+ defaultOpen: t === "output-error" || t === "approval-requested" || !!(e.draftReview && e.draftReview.items.length > 0) || !!e.proposedPlan || !!e.proposedChanges || Ki(e),
2352
+ children: [/* @__PURE__ */ Q(Si, {
2331
2353
  type: n,
2332
- state: t,
2333
- title: h
2334
- }), /* @__PURE__ */ $(yi, { children: [
2335
- u && e.args !== void 0 ? /* @__PURE__ */ Q(bi, { input: e.args }) : null,
2336
- o ? null : u || t === "output-error" ? /* @__PURE__ */ Q(_a, {
2354
+ state: h,
2355
+ title: g
2356
+ }), /* @__PURE__ */ $(Ci, { children: [
2357
+ u && e.args !== void 0 ? /* @__PURE__ */ Q(wi, { input: e.args }) : null,
2358
+ o ? null : u || t === "output-error" ? /* @__PURE__ */ Q(Ca, {
2337
2359
  output: c,
2338
2360
  errorText: e.errorText
2339
2361
  }) : null,
@@ -2425,7 +2447,7 @@ var Ji = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
2425
2447
  children: [/* @__PURE__ */ Q(ke, { className: "mt-0.5 size-3.5 shrink-0" }), /* @__PURE__ */ Q("span", { children: e.message })]
2426
2448
  }, `w${t}`))]
2427
2449
  }) : null,
2428
- Ae.has(e.toolCallId) ? /* @__PURE__ */ Q(qi, { health: Ne.get(e.toolCallId) }) : null,
2450
+ Ae.has(e.toolCallId) ? /* @__PURE__ */ Q($i, { health: Ne.get(e.toolCallId) }) : null,
2429
2451
  e.draftReview.nextSteps && e.draftReview.nextSteps.length > 0 ? /* @__PURE__ */ $("div", {
2430
2452
  className: "flex flex-col gap-1 border-t bg-muted/20 px-3 py-2",
2431
2453
  "data-testid": "draft-next-steps",
@@ -2487,7 +2509,7 @@ var Ji = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
2487
2509
  }) : null;
2488
2510
  })(),
2489
2511
  (() => {
2490
- let { designNotes: t, deferred: n } = Ui(e.proposedPlan.assumptions);
2512
+ let { designNotes: t, deferred: n } = Ji(e.proposedPlan.assumptions);
2491
2513
  return /* @__PURE__ */ $(Z, { children: [t.length > 0 ? /* @__PURE__ */ $("div", {
2492
2514
  className: "flex flex-col gap-0.5",
2493
2515
  "data-testid": "proposed-plan-assumptions",
@@ -2575,7 +2597,7 @@ var Ji = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
2575
2597
  })
2576
2598
  ]
2577
2599
  }) : null,
2578
- Vi(e) ? /* @__PURE__ */ $("div", {
2600
+ Ki(e) ? /* @__PURE__ */ $("div", {
2579
2601
  className: "flex flex-col gap-2 border-t bg-muted/20 px-3 py-2.5",
2580
2602
  "data-testid": "proposed-plan-fallback",
2581
2603
  children: [
@@ -2633,7 +2655,7 @@ var Ji = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
2633
2655
  className: "flex flex-col gap-1",
2634
2656
  children: e.proposedChanges.changes.map((e, t) => /* @__PURE__ */ $("div", {
2635
2657
  className: "flex items-start gap-1.5 rounded-md border bg-background px-2 py-1 text-[11px] text-foreground/80",
2636
- children: [/* @__PURE__ */ Q(mt, { className: "mt-px size-3 shrink-0 text-foreground/40" }), /* @__PURE__ */ Q("span", { children: zi(e) })]
2658
+ children: [/* @__PURE__ */ Q(mt, { className: "mt-px size-3 shrink-0 text-foreground/40" }), /* @__PURE__ */ Q("span", { children: Wi(e) })]
2637
2659
  }, t))
2638
2660
  }),
2639
2661
  i ? at.has(e.toolCallId) ? /* @__PURE__ */ Q("div", {
@@ -2688,11 +2710,11 @@ var Ji = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
2688
2710
  className: q("shrink-0", !K && "border-b bg-background/50"),
2689
2711
  children: A
2690
2712
  }) : null,
2691
- /* @__PURE__ */ $(Un, {
2713
+ /* @__PURE__ */ $(qn, {
2692
2714
  className: "flex-1 min-h-0",
2693
- children: [/* @__PURE__ */ $(Wn, {
2715
+ children: [/* @__PURE__ */ $(Jn, {
2694
2716
  className: q("space-y-4", K ? "mx-auto w-full max-w-2xl px-4 py-8 sm:px-0" : "px-4 py-3"),
2695
- children: [n.length === 0 ? /* @__PURE__ */ $(Gn, {
2717
+ children: [n.length === 0 ? /* @__PURE__ */ $(Yn, {
2696
2718
  className: "gap-3 px-0 py-8",
2697
2719
  children: [
2698
2720
  /* @__PURE__ */ Q("div", {
@@ -2704,38 +2726,38 @@ var Ji = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
2704
2726
  }) : /* @__PURE__ */ Q(Me, { className: "size-4" })
2705
2727
  }),
2706
2728
  /* @__PURE__ */ $("div", {
2707
- className: "space-y-1",
2729
+ className: "w-full max-w-full space-y-1",
2708
2730
  children: [/* @__PURE__ */ Q("h3", {
2709
- className: "text-sm font-medium text-foreground/90",
2731
+ className: "text-sm font-medium text-foreground/90 break-words",
2710
2732
  children: J.emptyTitle
2711
2733
  }), /* @__PURE__ */ Q("p", {
2712
- className: "text-sm text-muted-foreground",
2734
+ className: "text-sm text-muted-foreground break-words",
2713
2735
  children: J.emptyDescription
2714
2736
  })]
2715
2737
  }),
2716
- T && T.length > 0 ? /* @__PURE__ */ Q(li, {
2717
- className: "justify-center gap-2",
2718
- children: T.map((e) => /* @__PURE__ */ Q(ui, {
2719
- className: "h-8 border-border/60 bg-background/80 px-3 text-xs font-medium text-foreground/90 shadow-none hover:bg-muted/60",
2738
+ T && T.length > 0 ? /* @__PURE__ */ Q("div", {
2739
+ className: "flex w-full max-w-full flex-wrap justify-center gap-2",
2740
+ children: T.map((e) => /* @__PURE__ */ Q(mi, {
2741
+ className: "h-auto min-h-8 min-w-0 max-w-full whitespace-normal break-words rounded-full border-border/60 bg-background/80 px-3 py-1 text-left text-xs font-medium text-foreground/90 shadow-none hover:bg-muted/60",
2720
2742
  suggestion: e,
2721
2743
  onClick: $e
2722
2744
  }, e))
2723
2745
  }) : null
2724
2746
  ]
2725
2747
  }) : n.map((e) => {
2726
- let t = e.role === "user", n = e.toolInvocations ?? [], r = e.reasoning?.trim(), i = e.sources ?? [], a = t ? void 0 : e.buildProgress, o = !t && !n.some((e) => !!e.proposedPlan) ? e.blueprintProgress : void 0, c = !t && !!e.streaming && !e.content && n.length === 0 && !r && !a && !o, l = !t && W === "summary" ? n.filter((e) => !Wi(e) && !(o && e.toolName === "propose_blueprint")) : [], u = !t && W === "debug" ? n : !t && W !== "debug" ? n.filter(Wi) : [];
2727
- return /* @__PURE__ */ Q(Xn, {
2728
- from: Ii(e.role),
2748
+ let t = e.role === "user", n = e.toolInvocations ?? [], r = e.reasoning?.trim(), i = e.sources ?? [], a = t ? void 0 : e.buildProgress, o = !t && !n.some((e) => !!e.proposedPlan) ? e.blueprintProgress : void 0, c = !t && !!e.streaming && !e.content && n.length === 0 && !r && !a && !o, l = !t && W === "summary" ? n.filter((e) => !Yi(e) && !(o && e.toolName === "propose_blueprint")) : [], u = !t && W === "debug" ? n : !t && W !== "debug" ? n.filter(Yi) : [];
2749
+ return /* @__PURE__ */ Q(er, {
2750
+ from: Bi(e.role),
2729
2751
  children: /* @__PURE__ */ $("div", {
2730
2752
  className: q("flex w-full gap-2.5", m ? t ? "flex-row-reverse items-start" : "flex-row items-start" : "flex-col"),
2731
- children: [m ? /* @__PURE__ */ Q(Yi, {
2753
+ children: [m ? /* @__PURE__ */ Q(ta, {
2732
2754
  isUser: t,
2733
2755
  url: t ? h : _,
2734
2756
  fallback: t ? g : v
2735
2757
  }) : null, /* @__PURE__ */ $("div", {
2736
2758
  className: q("flex min-w-0 flex-col gap-2", m && !t && "flex-1"),
2737
- children: [/* @__PURE__ */ $(Zn, { children: [
2738
- o ? /* @__PURE__ */ Q(ua, {
2759
+ children: [/* @__PURE__ */ $(tr, { children: [
2760
+ o ? /* @__PURE__ */ Q(ga, {
2739
2761
  progress: o,
2740
2762
  designingLabel: J.designingPlanLabel,
2741
2763
  extendLabel: ue,
@@ -2743,7 +2765,7 @@ var Ji = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
2743
2765
  stalledLabel: J.connectionStalledLabel,
2744
2766
  offlineLabel: J.connectionOfflineLabel
2745
2767
  }) : null,
2746
- a ? /* @__PURE__ */ Q(da, {
2768
+ a ? /* @__PURE__ */ Q(_a, {
2747
2769
  progress: a,
2748
2770
  onOpenBuiltApp: ne,
2749
2771
  openBuiltAppLabel: re,
@@ -2753,20 +2775,24 @@ var Ji = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
2753
2775
  stalledLabel: J.connectionStalledLabel,
2754
2776
  offlineLabel: J.connectionOfflineLabel
2755
2777
  }) : null,
2756
- !t && W === "debug" && r ? /* @__PURE__ */ $(Di, {
2778
+ !t && W === "debug" && r ? /* @__PURE__ */ $(ji, {
2757
2779
  isStreaming: !!e.streaming && !e.content,
2758
2780
  className: "mb-2",
2759
- children: [/* @__PURE__ */ Q(ki, {}), /* @__PURE__ */ Q(Ai, { children: r })]
2781
+ children: [/* @__PURE__ */ Q(Ni, {}), /* @__PURE__ */ Q(Pi, { children: r })]
2760
2782
  }) : null,
2761
- !t && W === "summary" && l.length > 0 ? /* @__PURE__ */ Q(fa, {
2762
- groups: Ki(l),
2783
+ !t && W === "summary" && l.length > 0 ? /* @__PURE__ */ Q(va, {
2784
+ groups: Qi(l),
2763
2785
  labels: J
2764
2786
  }) : null,
2765
2787
  !t && u.length > 0 ? u.map(ot) : null,
2766
2788
  t ? e.content ? /* @__PURE__ */ Q("div", {
2767
2789
  className: "whitespace-pre-wrap break-words",
2768
2790
  children: e.content
2769
- }) : null : c ? /* @__PURE__ */ Q(Zi, {}) : e.content ? /* @__PURE__ */ Q(cr, { children: e.content }) : null,
2791
+ }) : null : c ? /* @__PURE__ */ Q(ra, {}) : e.content ? Zi(e.content) ? /* @__PURE__ */ Q("span", {
2792
+ className: "text-xs italic text-muted-foreground/70",
2793
+ title: e.content,
2794
+ children: J.agentActivity
2795
+ }) : /* @__PURE__ */ Q(fr, { children: e.content }) : null,
2770
2796
  e.streaming && !c ? /* @__PURE__ */ Q("span", {
2771
2797
  "aria-hidden": !0,
2772
2798
  className: "ml-0.5 inline-block w-[2px] h-4 align-middle bg-current animate-pulse"
@@ -2790,7 +2816,7 @@ var Ji = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
2790
2816
  } })]
2791
2817
  }, t))
2792
2818
  }) : null,
2793
- !t && i.length > 0 ? /* @__PURE__ */ $(ji, { children: [/* @__PURE__ */ Q(Mi, { count: i.length }), /* @__PURE__ */ Q(Ni, { children: i.map((e, t) => /* @__PURE__ */ Q(Pi, {
2819
+ !t && i.length > 0 ? /* @__PURE__ */ $(Fi, { children: [/* @__PURE__ */ Q(Ii, { count: i.length }), /* @__PURE__ */ Q(Li, { children: i.map((e, t) => /* @__PURE__ */ Q(Ri, {
2794
2820
  href: e.url,
2795
2821
  title: e.title ?? e.url
2796
2822
  }, e.id ?? e.url ?? t)) })] }) : null,
@@ -2798,16 +2824,16 @@ var Ji = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
2798
2824
  className: "text-[10px] opacity-70 mt-1",
2799
2825
  children: e.timestamp
2800
2826
  }) : null
2801
- ] }), !t && !c ? /* @__PURE__ */ $(Qn, {
2827
+ ] }), !t && !c ? /* @__PURE__ */ $(nr, {
2802
2828
  className: "opacity-0 transition-opacity group-focus-within:opacity-100 group-hover:opacity-100",
2803
2829
  children: [
2804
- /* @__PURE__ */ Q($n, {
2830
+ /* @__PURE__ */ Q(rr, {
2805
2831
  label: Te === e.id ? J.copied : J.copy,
2806
2832
  tooltip: Te === e.id ? J.copied : J.copy,
2807
2833
  onClick: () => rt(e),
2808
2834
  children: Te === e.id ? /* @__PURE__ */ Q(Pe, { className: "size-3.5" }) : /* @__PURE__ */ Q(Ge, { className: "size-3.5" })
2809
2835
  }),
2810
- s ? /* @__PURE__ */ Q($n, {
2836
+ s ? /* @__PURE__ */ Q(rr, {
2811
2837
  label: J.regenerate,
2812
2838
  tooltip: J.regenerate,
2813
2839
  onClick: s,
@@ -2825,7 +2851,7 @@ var Ji = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
2825
2851
  })]
2826
2852
  })
2827
2853
  }, e.id);
2828
- }), d && !n.some((e) => e.streaming) ? /* @__PURE__ */ Q(Xi, {
2854
+ }), d && !n.some((e) => e.streaming) ? /* @__PURE__ */ Q(na, {
2829
2855
  showAvatar: m,
2830
2856
  assistantAvatarUrl: _,
2831
2857
  assistantAvatarFallback: v,
@@ -2833,13 +2859,13 @@ var Ji = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
2833
2859
  stalledLabel: J.connectionStalledLabel,
2834
2860
  offlineLabel: J.connectionOfflineLabel
2835
2861
  }) : null]
2836
- }), /* @__PURE__ */ Q(Kn, {})]
2862
+ }), /* @__PURE__ */ Q(Xn, {})]
2837
2863
  }),
2838
- f ? Bn(f) && !zn(f) ? /* @__PURE__ */ Q(ha, {
2864
+ f ? Wn(f) && !Un(f) ? /* @__PURE__ */ Q(xa, {
2839
2865
  error: f,
2840
2866
  rateLimitedLabel: J.sendFailedRateLimited,
2841
2867
  genericLabel: J.sendFailedGeneric
2842
- }) : /* @__PURE__ */ Q(ga, {
2868
+ }) : /* @__PURE__ */ Q(Sa, {
2843
2869
  error: f,
2844
2870
  onReload: s,
2845
2871
  onUpgrade: c
@@ -2850,7 +2876,7 @@ var Ji = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
2850
2876
  children: [j ? /* @__PURE__ */ Q("div", {
2851
2877
  className: "absolute bottom-full left-0 right-0 z-10 px-3 pb-1",
2852
2878
  children: j
2853
- }) : null, /* @__PURE__ */ $(Ar, {
2879
+ }) : null, /* @__PURE__ */ $(Pr, {
2854
2880
  accept: C,
2855
2881
  fileInputLabel: J.uploadFiles,
2856
2882
  maxFileSize: w,
@@ -2859,14 +2885,14 @@ var Ji = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
2859
2885
  console.warn("[plugin-chatbot] prompt-input error", e);
2860
2886
  },
2861
2887
  children: [
2862
- S ? /* @__PURE__ */ Q(jr, { children: /* @__PURE__ */ Q(Or, { children: (e) => /* @__PURE__ */ Q(Dr, { data: e }) }) }) : null,
2863
- /* @__PURE__ */ Q(Mr, {
2888
+ S ? /* @__PURE__ */ Q(Fr, { children: /* @__PURE__ */ Q(Mr, { children: (e) => /* @__PURE__ */ Q(jr, { data: e }) }) }) : null,
2889
+ /* @__PURE__ */ Q(Ir, {
2864
2890
  placeholder: r,
2865
2891
  disabled: l || G === "streaming",
2866
2892
  onChange: M ? (e) => M(e.currentTarget.value) : void 0
2867
2893
  }),
2868
- /* @__PURE__ */ $(Pr, { children: [/* @__PURE__ */ $(Fr, { children: [
2869
- S ? /* @__PURE__ */ $(Lr, { children: [/* @__PURE__ */ Q(Rr, {}), /* @__PURE__ */ Q(zr, { children: /* @__PURE__ */ Q(kr, {}) })] }) : null,
2894
+ /* @__PURE__ */ $(Rr, { children: [/* @__PURE__ */ $(zr, { children: [
2895
+ S ? /* @__PURE__ */ $(Vr, { children: [/* @__PURE__ */ Q(Hr, {}), /* @__PURE__ */ Q(Ur, { children: /* @__PURE__ */ Q(Nr, {}) })] }) : null,
2870
2896
  D && D.length > 1 ? /* @__PURE__ */ Q("select", {
2871
2897
  "aria-label": J.model,
2872
2898
  value: O ?? D[0].id,
@@ -2892,7 +2918,7 @@ var Ji = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
2892
2918
  })
2893
2919
  ]
2894
2920
  })
2895
- ] }), /* @__PURE__ */ Q(Vr, {
2921
+ ] }), /* @__PURE__ */ Q(Gr, {
2896
2922
  "aria-label": G === "streaming" ? J.stopResponse : J.submit,
2897
2923
  status: G,
2898
2924
  disabled: l,
@@ -2905,8 +2931,8 @@ var Ji = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
2905
2931
  ]
2906
2932
  });
2907
2933
  });
2908
- Ji.displayName = "ChatbotEnhanced";
2909
- function Yi({ isUser: e, url: t, fallback: n }) {
2934
+ ea.displayName = "ChatbotEnhanced";
2935
+ function ta({ isUser: e, url: t, fallback: n }) {
2910
2936
  return /* @__PURE__ */ Q("div", {
2911
2937
  className: q("mt-0.5 flex size-7 shrink-0 items-center justify-center overflow-hidden rounded-full text-[11px] font-medium", e ? "bg-secondary text-secondary-foreground" : "bg-primary/10 text-primary"),
2912
2938
  "aria-hidden": "true",
@@ -2917,21 +2943,21 @@ function Yi({ isUser: e, url: t, fallback: n }) {
2917
2943
  }) : e ? n?.trim()?.charAt(0)?.toUpperCase() || "U" : /* @__PURE__ */ Q(Me, { className: "size-4" })
2918
2944
  });
2919
2945
  }
2920
- function Xi({ showAvatar: e, assistantAvatarUrl: t, assistantAvatarFallback: n, waitingLabel: r, stalledLabel: i, offlineLabel: a }) {
2921
- return /* @__PURE__ */ Q(Xn, {
2946
+ function na({ showAvatar: e, assistantAvatarUrl: t, assistantAvatarFallback: n, waitingLabel: r, stalledLabel: i, offlineLabel: a }) {
2947
+ return /* @__PURE__ */ Q(er, {
2922
2948
  from: "assistant",
2923
2949
  "aria-live": "polite",
2924
2950
  children: /* @__PURE__ */ $("div", {
2925
2951
  className: q("flex w-full gap-2.5", e ? "flex-row items-start" : "flex-col"),
2926
- children: [e ? /* @__PURE__ */ Q(Yi, {
2952
+ children: [e ? /* @__PURE__ */ Q(ta, {
2927
2953
  isUser: !1,
2928
2954
  url: t,
2929
2955
  fallback: n
2930
- }) : null, /* @__PURE__ */ Q(Zn, {
2956
+ }) : null, /* @__PURE__ */ Q(tr, {
2931
2957
  className: "rounded-lg border bg-muted/30 px-3 py-2 text-muted-foreground",
2932
2958
  children: /* @__PURE__ */ $("span", {
2933
2959
  className: "inline-flex items-center gap-2",
2934
- children: [/* @__PURE__ */ Q(Zi, {}), /* @__PURE__ */ Q(na, {
2960
+ children: [/* @__PURE__ */ Q(ra, {}), /* @__PURE__ */ Q(ca, {
2935
2961
  active: !0,
2936
2962
  pending: !0,
2937
2963
  activityKey: 0,
@@ -2944,7 +2970,7 @@ function Xi({ showAvatar: e, assistantAvatarUrl: t, assistantAvatarFallback: n,
2944
2970
  })
2945
2971
  });
2946
2972
  }
2947
- function Zi() {
2973
+ function ra() {
2948
2974
  return /* @__PURE__ */ $(Z, { children: [/* @__PURE__ */ Q("span", {
2949
2975
  className: "sr-only",
2950
2976
  children: "Assistant is responding"
@@ -2958,12 +2984,12 @@ function Zi() {
2958
2984
  ]
2959
2985
  })] });
2960
2986
  }
2961
- function Qi(e) {
2987
+ function ia(e) {
2962
2988
  let t = Math.floor(e / 60), n = e % 60;
2963
2989
  return `${t}:${String(n).padStart(2, "0")}`;
2964
2990
  }
2965
- var $i = 6;
2966
- function ea(t, n) {
2991
+ var aa = 6;
2992
+ function oa(t, n) {
2967
2993
  let r = e.useRef(0), i = e.useRef(0), [a, o] = e.useState({
2968
2994
  elapsed: 0,
2969
2995
  quiet: 0
@@ -2992,10 +3018,10 @@ function ea(t, n) {
2992
3018
  }, [t]), {
2993
3019
  elapsedSeconds: a.elapsed,
2994
3020
  quietSeconds: a.quiet,
2995
- live: a.quiet < $i
3021
+ live: a.quiet < aa
2996
3022
  };
2997
3023
  }
2998
- function ta() {
3024
+ function sa() {
2999
3025
  let [t, n] = e.useState(() => typeof navigator < "u" && navigator.onLine === !1);
3000
3026
  return e.useEffect(() => {
3001
3027
  if (typeof window > "u") return;
@@ -3005,8 +3031,8 @@ function ta() {
3005
3031
  };
3006
3032
  }, []), t;
3007
3033
  }
3008
- function na({ active: e, activityKey: t, pending: n = !1, waitingLabel: r, stalledLabel: i = "Still working…", offlineLabel: a = "Connection lost — reconnecting…" }) {
3009
- let { elapsedSeconds: o, quietSeconds: s, live: c } = ea(e, t), l = ta() ? "offline" : c ? n ? "waiting" : "receiving" : "stalled", u = Qi(o);
3034
+ function ca({ active: e, activityKey: t, pending: n = !1, waitingLabel: r, stalledLabel: i = "Still working…", offlineLabel: a = "Connection lost — reconnecting…" }) {
3035
+ let { elapsedSeconds: o, quietSeconds: s, live: c } = oa(e, t), l = sa() ? "offline" : c ? n ? "waiting" : "receiving" : "stalled", u = ia(o);
3010
3036
  return /* @__PURE__ */ $("span", {
3011
3037
  className: q("inline-flex items-center gap-1.5 text-xs tabular-nums", l === "offline" ? "text-red-600 font-medium" : l === "stalled" ? "text-amber-600 font-medium" : "font-normal text-muted-foreground"),
3012
3038
  "aria-live": "polite",
@@ -3029,7 +3055,7 @@ function na({ active: e, activityKey: t, pending: n = !1, waitingLabel: r, stall
3029
3055
  ]
3030
3056
  });
3031
3057
  }
3032
- var ra = [
3058
+ var la = [
3033
3059
  "Mapping out the data you’ll track…",
3034
3060
  "Shaping objects and their fields…",
3035
3061
  "Connecting related records…",
@@ -3040,21 +3066,21 @@ var ra = [
3040
3066
  "Sketching a dashboard to track it…",
3041
3067
  "Double-checking the structure hangs together…",
3042
3068
  "Pulling the plan together…"
3043
- ], ia = 3500;
3044
- function aa(e, t, n = ia) {
3069
+ ], ua = 3500;
3070
+ function da(e, t, n = ua) {
3045
3071
  if (t <= 0) return -1;
3046
3072
  if (t === 1) return 0;
3047
- let r = Math.floor((Number.isFinite(e) && e > 0 ? e : 0) / (n > 0 ? n : ia));
3073
+ let r = Math.floor((Number.isFinite(e) && e > 0 ? e : 0) / (n > 0 ? n : ua));
3048
3074
  return Math.min(r, t - 1);
3049
3075
  }
3050
- function oa({ label: t, hints: n, offlineLabel: r }) {
3076
+ function fa({ label: t, hints: n, offlineLabel: r }) {
3051
3077
  let [i, a] = e.useState(0);
3052
3078
  e.useEffect(() => {
3053
3079
  if (n.length <= 1) return;
3054
- let e = Date.now(), t = setInterval(() => a(Date.now() - e), ia);
3080
+ let e = Date.now(), t = setInterval(() => a(Date.now() - e), ua);
3055
3081
  return () => clearInterval(t);
3056
3082
  }, [n.length]);
3057
- let o = aa(i, n.length), s = o >= 0 ? n[o] : void 0, c = n.length > 1 && n.length <= 12;
3083
+ let o = da(i, n.length), s = o >= 0 ? n[o] : void 0, c = n.length > 1 && n.length <= 12;
3058
3084
  return /* @__PURE__ */ $("span", {
3059
3085
  className: "inline-flex min-w-0 items-center gap-1.5 text-xs text-muted-foreground",
3060
3086
  "data-testid": "build-proposal-progress",
@@ -3078,12 +3104,12 @@ function oa({ label: t, hints: n, offlineLabel: r }) {
3078
3104
  "aria-hidden": !0,
3079
3105
  children: n.map((e, t) => /* @__PURE__ */ Q("span", { className: q("size-1 rounded-full transition-colors", t <= o ? "bg-primary/70" : "bg-muted-foreground/25") }, t))
3080
3106
  }) : null,
3081
- /* @__PURE__ */ Q(sa, { offlineLabel: r })
3107
+ /* @__PURE__ */ Q(pa, { offlineLabel: r })
3082
3108
  ]
3083
3109
  });
3084
3110
  }
3085
- function sa({ offlineLabel: t }) {
3086
- let [n, r] = e.useState(0), i = ta();
3111
+ function pa({ offlineLabel: t }) {
3112
+ let [n, r] = e.useState(0), i = sa();
3087
3113
  return e.useEffect(() => {
3088
3114
  let e = Date.now(), t = setInterval(() => r(Math.floor((Date.now() - e) / 1e3)), 1e3);
3089
3115
  return () => clearInterval(t);
@@ -3096,25 +3122,25 @@ function sa({ offlineLabel: t }) {
3096
3122
  className: "size-3 shrink-0",
3097
3123
  "aria-hidden": !0
3098
3124
  }),
3099
- /* @__PURE__ */ Q("span", { children: Qi(n) }),
3125
+ /* @__PURE__ */ Q("span", { children: ia(n) }),
3100
3126
  i ? /* @__PURE__ */ $("span", { children: ["· ", t] }) : null
3101
3127
  ]
3102
3128
  });
3103
3129
  }
3104
- var ca = [
3130
+ var ma = [
3105
3131
  "object",
3106
3132
  "view",
3107
3133
  "dashboard",
3108
3134
  "app",
3109
3135
  "seed"
3110
- ], la = {
3136
+ ], ha = {
3111
3137
  object: "Objects",
3112
3138
  view: "Views",
3113
3139
  dashboard: "Dashboards",
3114
3140
  app: "App",
3115
3141
  seed: "Sample data"
3116
3142
  };
3117
- function ua({ progress: e, designingLabel: t = "Designing your app…", extendLabel: n = "Adding to existing app", waitingLabel: r = "Waiting for server…", stalledLabel: i = "Still working…", offlineLabel: a = "Connection lost — reconnecting…" }) {
3143
+ function ga({ progress: e, designingLabel: t = "Designing your app…", extendLabel: n = "Adding to existing app", waitingLabel: r = "Waiting for server…", stalledLabel: i = "Still working…", offlineLabel: a = "Connection lost — reconnecting…" }) {
3118
3144
  let { phase: o, summary: s, appLabel: c, targetApp: l, objects: u, counts: d, seq: f } = e, p = o === "done", m = f ?? `${o}:${u.length}`, h = p && (s || c) || t, g = [];
3119
3145
  return d?.objects && g.push(`${d.objects} object${d.objects === 1 ? "" : "s"}`), d?.views && g.push(`${d.views} view${d.views === 1 ? "" : "s"}`), d?.dashboards && g.push(`${d.dashboards} dashboard${d.dashboards === 1 ? "" : "s"}`), /* @__PURE__ */ $("div", {
3120
3146
  className: "rounded-lg border bg-muted/30 p-3 text-sm",
@@ -3141,7 +3167,7 @@ function ua({ progress: e, designingLabel: t = "Designing your app…", extendLa
3141
3167
  }) : null,
3142
3168
  p ? null : /* @__PURE__ */ Q("span", {
3143
3169
  className: "ml-auto shrink-0",
3144
- children: /* @__PURE__ */ Q(na, {
3170
+ children: /* @__PURE__ */ Q(ca, {
3145
3171
  active: !0,
3146
3172
  activityKey: m,
3147
3173
  waitingLabel: r,
@@ -3178,13 +3204,13 @@ function ua({ progress: e, designingLabel: t = "Designing your app…", extendLa
3178
3204
  ]
3179
3205
  });
3180
3206
  }
3181
- function da({ progress: e, onOpenBuiltApp: t, openBuiltAppLabel: n = "Open app", onPreviewDraftApp: r, previewDraftLabel: i = "Preview", waitingLabel: a = "Waiting for server…", stalledLabel: o = "Still working…", offlineLabel: s = "Connection lost — reconnecting…" }) {
3207
+ function _a({ progress: e, onOpenBuiltApp: t, openBuiltAppLabel: n = "Open app", onPreviewDraftApp: r, previewDraftLabel: i = "Preview", waitingLabel: a = "Waiting for server…", stalledLabel: o = "Still working…", offlineLabel: s = "Connection lost — reconnecting…" }) {
3182
3208
  let { phase: c, appLabel: l, items: u, done: d, total: f, seq: p } = e, m = c === "done", h = p ?? `${c}:${d}:${u.length}`, g = u.find((e) => e.type === "app"), _ = f > 0 ? Math.min(100, Math.round(d / f * 100)) : m ? 100 : 6, v = /* @__PURE__ */ new Map();
3183
3209
  for (let e of u) {
3184
3210
  let t = v.get(e.type) ?? [];
3185
3211
  t.push(e.name.replace(/_sample$/, "")), v.set(e.type, t);
3186
3212
  }
3187
- let y = [...ca.filter((e) => v.has(e)), ...[...v.keys()].filter((e) => !ca.includes(e))];
3213
+ let y = [...ma.filter((e) => v.has(e)), ...[...v.keys()].filter((e) => !ma.includes(e))];
3188
3214
  return /* @__PURE__ */ $("div", {
3189
3215
  className: "rounded-lg border bg-muted/30 p-3 text-sm",
3190
3216
  "data-testid": "build-progress",
@@ -3200,7 +3226,7 @@ function da({ progress: e, onOpenBuiltApp: t, openBuiltAppLabel: n = "Open app",
3200
3226
  }) : null,
3201
3227
  m ? null : /* @__PURE__ */ Q("span", {
3202
3228
  className: "ml-auto",
3203
- children: /* @__PURE__ */ Q(na, {
3229
+ children: /* @__PURE__ */ Q(ca, {
3204
3230
  active: !0,
3205
3231
  activityKey: h,
3206
3232
  waitingLabel: a,
@@ -3228,7 +3254,7 @@ function da({ progress: e, onOpenBuiltApp: t, openBuiltAppLabel: n = "Open app",
3228
3254
  children: [
3229
3255
  /* @__PURE__ */ Q("span", {
3230
3256
  className: "font-medium text-foreground",
3231
- children: la[e] ?? e
3257
+ children: ha[e] ?? e
3232
3258
  }),
3233
3259
  " ",
3234
3260
  t.slice(0, 6).join(", "),
@@ -3257,7 +3283,7 @@ function da({ progress: e, onOpenBuiltApp: t, openBuiltAppLabel: n = "Open app",
3257
3283
  ]
3258
3284
  });
3259
3285
  }
3260
- function fa({ groups: e, labels: t }) {
3286
+ function va({ groups: e, labels: t }) {
3261
3287
  return e.length === 0 ? null : /* @__PURE__ */ Q("div", {
3262
3288
  className: "not-prose mb-2 border-l border-border/70 pl-3",
3263
3289
  children: /* @__PURE__ */ Q("div", {
@@ -3267,7 +3293,7 @@ function fa({ groups: e, labels: t }) {
3267
3293
  children: [/* @__PURE__ */ $("div", {
3268
3294
  className: "flex min-w-0 items-center gap-2",
3269
3295
  children: [
3270
- /* @__PURE__ */ Q(pa, { state: e.state }),
3296
+ /* @__PURE__ */ Q(ya, { state: e.state }),
3271
3297
  /* @__PURE__ */ Q("span", {
3272
3298
  className: "truncate font-medium text-foreground",
3273
3299
  children: e.title
@@ -3277,22 +3303,22 @@ function fa({ groups: e, labels: t }) {
3277
3303
  children: ["x", e.count]
3278
3304
  }) : null
3279
3305
  ]
3280
- }), e.state === "running" ? e.rawName === "propose_blueprint" ? /* @__PURE__ */ Q(oa, {
3306
+ }), e.state === "running" ? e.rawName === "propose_blueprint" ? /* @__PURE__ */ Q(fa, {
3281
3307
  label: t.designingPlanLabel,
3282
3308
  hints: t.designingPlanHints,
3283
3309
  offlineLabel: t.connectionOfflineLabel
3284
- }) : /* @__PURE__ */ Q(sa, { offlineLabel: t.connectionOfflineLabel }) : /* @__PURE__ */ Q("span", {
3310
+ }) : /* @__PURE__ */ Q(pa, { offlineLabel: t.connectionOfflineLabel }) : /* @__PURE__ */ Q("span", {
3285
3311
  className: q("shrink-0 text-[10px] font-medium", e.state === "failed" ? "text-destructive" : e.state === "completed" ? "text-emerald-700 dark:text-emerald-400" : "text-muted-foreground"),
3286
- children: ma(e.state, t)
3312
+ children: ba(e.state, t)
3287
3313
  })]
3288
3314
  }, e.key))
3289
3315
  })
3290
3316
  });
3291
3317
  }
3292
- function pa({ state: e }) {
3318
+ function ya({ state: e }) {
3293
3319
  return e === "failed" ? /* @__PURE__ */ Q(X, { className: "size-3.5 shrink-0 text-destructive" }) : e === "completed" ? /* @__PURE__ */ Q(Y, { className: "size-3.5 shrink-0 text-emerald-600" }) : /* @__PURE__ */ Q(Ue, { className: "size-3.5 shrink-0 text-muted-foreground" });
3294
3320
  }
3295
- function ma(e, t) {
3321
+ function ba(e, t) {
3296
3322
  switch (e) {
3297
3323
  case "failed": return t.toolFailed;
3298
3324
  case "awaiting": return t.toolAwaitingApproval;
@@ -3300,8 +3326,8 @@ function ma(e, t) {
3300
3326
  case "completed": return t.toolCompleted;
3301
3327
  }
3302
3328
  }
3303
- function ha({ error: t, rateLimitedLabel: n, genericLabel: r }) {
3304
- let i = e.useMemo(() => Hn(t) ? n : r, [
3329
+ function xa({ error: t, rateLimitedLabel: n, genericLabel: r }) {
3330
+ let i = e.useMemo(() => Kn(t) ? n : r, [
3305
3331
  t,
3306
3332
  n,
3307
3333
  r
@@ -3322,8 +3348,8 @@ function ha({ error: t, rateLimitedLabel: n, genericLabel: r }) {
3322
3348
  })
3323
3349
  });
3324
3350
  }
3325
- function ga({ error: t, onReload: n, onUpgrade: r }) {
3326
- let i = e.useMemo(() => zn(t), [t]), { summary: a, details: o } = e.useMemo(() => Ln(t), [t]), [s, c] = e.useState(!1);
3351
+ function Sa({ error: t, onReload: n, onUpgrade: r }) {
3352
+ let i = e.useMemo(() => Un(t), [t]), { summary: a, details: o } = e.useMemo(() => Vn(t), [t]), [s, c] = e.useState(!1);
3327
3353
  if (i) {
3328
3354
  let e = typeof navigator < "u" && !!navigator.language?.toLowerCase().startsWith("zh"), t = (e ? i.message : i.messageEn ?? i.message) || (e ? "AI 额度已用完。" : "You have reached your AI quota."), n = i.topUp ? e ? "购买额度包" : "Buy a credit pack" : e ? "升级方案" : "Upgrade plan";
3329
3355
  return /* @__PURE__ */ Q("div", {
@@ -3394,27 +3420,27 @@ function ga({ error: t, onReload: n, onUpgrade: r }) {
3394
3420
  })
3395
3421
  });
3396
3422
  }
3397
- function _a({ output: e, errorText: t }) {
3398
- return t ? /* @__PURE__ */ Q(xi, {
3423
+ function Ca({ output: e, errorText: t }) {
3424
+ return t ? /* @__PURE__ */ Q(Ti, {
3399
3425
  output: void 0,
3400
3426
  errorText: t
3401
- }) : e == null || e === "" ? null : typeof e == "string" && !Li(e) ? /* @__PURE__ */ $("div", {
3427
+ }) : e == null || e === "" ? null : typeof e == "string" && !Vi(e) ? /* @__PURE__ */ $("div", {
3402
3428
  className: "space-y-2 p-4",
3403
3429
  children: [/* @__PURE__ */ Q("h4", {
3404
3430
  className: "font-medium text-muted-foreground text-xs uppercase tracking-wide",
3405
3431
  children: "Result"
3406
3432
  }), /* @__PURE__ */ Q("div", {
3407
3433
  className: "overflow-x-auto rounded-md bg-muted/40 px-3 py-2 text-sm text-foreground",
3408
- children: /* @__PURE__ */ Q(cr, { children: e })
3434
+ children: /* @__PURE__ */ Q(fr, { children: e })
3409
3435
  })]
3410
- }) : /* @__PURE__ */ Q(xi, {
3436
+ }) : /* @__PURE__ */ Q(Ti, {
3411
3437
  output: e,
3412
3438
  errorText: void 0
3413
3439
  });
3414
3440
  }
3415
3441
  //#endregion
3416
3442
  //#region src/FloatingChatbot.tsx
3417
- function va({ floatingConfig: t, headerExtra: n, headerActions: r, ...i }) {
3443
+ function wa({ floatingConfig: t, headerExtra: n, headerActions: r, ...i }) {
3418
3444
  let { position: a = "bottom-right", defaultOpen: o = !1, panelWidth: s = 400, panelHeight: c = 520, title: l = "Chat", triggerSize: u = 56 } = t ?? {}, [d, f] = e.useState(null);
3419
3445
  e.useEffect(() => {
3420
3446
  let e = document.getElementById("floating-chatbot-portal");
@@ -3422,19 +3448,19 @@ function va({ floatingConfig: t, headerExtra: n, headerActions: r, ...i }) {
3422
3448
  e && e.parentNode && !e.hasChildNodes() && e.parentNode.removeChild(e);
3423
3449
  };
3424
3450
  }, []);
3425
- let p = /* @__PURE__ */ $(xn, {
3451
+ let p = /* @__PURE__ */ $(Tn, {
3426
3452
  defaultOpen: o,
3427
- children: [/* @__PURE__ */ Q(Dn, {
3453
+ children: [/* @__PURE__ */ Q(jn, {
3428
3454
  position: a,
3429
3455
  size: u
3430
- }), /* @__PURE__ */ Q(Nn, {
3456
+ }), /* @__PURE__ */ Q(Ln, {
3431
3457
  title: l,
3432
3458
  position: a,
3433
3459
  width: s,
3434
3460
  height: c,
3435
3461
  headerExtra: n,
3436
3462
  headerActions: r,
3437
- children: /* @__PURE__ */ Q(Ji, {
3463
+ children: /* @__PURE__ */ Q(ea, {
3438
3464
  ...i,
3439
3465
  maxHeight: "100%",
3440
3466
  className: "h-full border-0 rounded-none"
@@ -3461,7 +3487,7 @@ Ft.register("chatbot", ({ schema: e, className: t, ...n }) => {
3461
3487
  autoResponseDelay: e.autoResponseDelay,
3462
3488
  onSend: e.onSend
3463
3489
  });
3464
- return /* @__PURE__ */ Q(za, {
3490
+ return /* @__PURE__ */ Q(Ga, {
3465
3491
  messages: r,
3466
3492
  placeholder: e.placeholder,
3467
3493
  onSendMessage: (e) => {
@@ -3627,7 +3653,7 @@ Ft.register("chatbot", ({ schema: e, className: t, ...n }) => {
3627
3653
  autoResponseDelay: e.autoResponseDelay,
3628
3654
  onSend: e.onSend
3629
3655
  });
3630
- return /* @__PURE__ */ Q(Ji, {
3656
+ return /* @__PURE__ */ Q(ea, {
3631
3657
  messages: r,
3632
3658
  placeholder: e.placeholder,
3633
3659
  onSendMessage: (e, t) => {
@@ -3814,7 +3840,7 @@ Ft.register("chatbot", ({ schema: e, className: t, ...n }) => {
3814
3840
  autoResponseDelay: e.autoResponseDelay,
3815
3841
  onSend: e.onSend
3816
3842
  });
3817
- return /* @__PURE__ */ Q(va, {
3843
+ return /* @__PURE__ */ Q(wa, {
3818
3844
  floatingConfig: e.floatingConfig,
3819
3845
  messages: r,
3820
3846
  placeholder: e.placeholder,
@@ -3986,7 +4012,7 @@ Ft.register("chatbot", ({ schema: e, className: t, ...n }) => {
3986
4012
  });
3987
4013
  //#endregion
3988
4014
  //#region src/elements/loader.tsx
3989
- var ya = ({ size: e = 16 }) => /* @__PURE__ */ $("svg", {
4015
+ var Ta = ({ size: e = 16 }) => /* @__PURE__ */ $("svg", {
3990
4016
  height: e,
3991
4017
  strokeLinejoin: "round",
3992
4018
  style: { color: "currentcolor" },
@@ -4067,97 +4093,97 @@ var ya = ({ size: e = 16 }) => /* @__PURE__ */ $("svg", {
4067
4093
  })
4068
4094
  }) })
4069
4095
  ]
4070
- }), ba = ({ className: e, size: t = 16, ...n }) => /* @__PURE__ */ Q("div", {
4096
+ }), Ea = ({ className: e, size: t = 16, ...n }) => /* @__PURE__ */ Q("div", {
4071
4097
  className: q("inline-flex animate-spin items-center justify-center", e),
4072
4098
  ...n,
4073
- children: /* @__PURE__ */ Q(ya, { size: t })
4074
- }), xa = /* @__PURE__ */ Lt({
4075
- CodeBlock: () => mi,
4076
- CodeBlockCopyButton: () => hi,
4077
- Conversation: () => Un,
4078
- ConversationContent: () => Wn,
4079
- ConversationEmptyState: () => Gn,
4080
- ConversationScrollButton: () => Kn,
4081
- Loader: () => ba,
4082
- Message: () => Xn,
4083
- MessageAction: () => $n,
4084
- MessageActions: () => Qn,
4085
- MessageAttachment: () => lr,
4086
- MessageAttachments: () => ur,
4087
- MessageBranch: () => nr,
4088
- MessageBranchContent: () => rr,
4089
- MessageBranchNext: () => or,
4090
- MessageBranchPage: () => sr,
4091
- MessageBranchPrevious: () => ar,
4092
- MessageBranchSelector: () => ir,
4093
- MessageContent: () => Zn,
4094
- MessageResponse: () => cr,
4095
- MessageToolbar: () => dr,
4096
- PromptInput: () => Ar,
4097
- PromptInputActionAddAttachments: () => kr,
4098
- PromptInputActionMenu: () => Lr,
4099
- PromptInputActionMenuContent: () => zr,
4100
- PromptInputActionMenuItem: () => Br,
4101
- PromptInputActionMenuTrigger: () => Rr,
4102
- PromptInputAttachment: () => Dr,
4103
- PromptInputAttachments: () => Or,
4104
- PromptInputBody: () => jr,
4105
- PromptInputButton: () => Ir,
4106
- PromptInputCommand: () => ni,
4107
- PromptInputCommandEmpty: () => ai,
4108
- PromptInputCommandGroup: () => oi,
4109
- PromptInputCommandInput: () => ri,
4110
- PromptInputCommandItem: () => si,
4111
- PromptInputCommandList: () => ii,
4112
- PromptInputCommandSeparator: () => ci,
4113
- PromptInputFooter: () => Pr,
4114
- PromptInputHeader: () => Nr,
4115
- PromptInputHoverCard: () => Jr,
4116
- PromptInputHoverCardContent: () => Xr,
4117
- PromptInputHoverCardTrigger: () => Yr,
4118
- PromptInputProvider: () => wr,
4119
- PromptInputSelect: () => Ur,
4120
- PromptInputSelectContent: () => Gr,
4121
- PromptInputSelectItem: () => Kr,
4122
- PromptInputSelectTrigger: () => Wr,
4123
- PromptInputSelectValue: () => qr,
4124
- PromptInputSpeechButton: () => Hr,
4125
- PromptInputSubmit: () => Vr,
4126
- PromptInputTab: () => Qr,
4127
- PromptInputTabBody: () => ei,
4128
- PromptInputTabItem: () => ti,
4129
- PromptInputTabLabel: () => $r,
4130
- PromptInputTabsList: () => Zr,
4131
- PromptInputTextarea: () => Mr,
4132
- PromptInputTools: () => Fr,
4133
- Reasoning: () => Di,
4134
- ReasoningContent: () => Ai,
4135
- ReasoningTrigger: () => ki,
4136
- Shimmer: () => Si,
4137
- Source: () => Pi,
4138
- Sources: () => ji,
4139
- SourcesContent: () => Ni,
4140
- SourcesTrigger: () => Mi,
4141
- Suggestion: () => ui,
4142
- Suggestions: () => li,
4143
- Tool: () => gi,
4144
- ToolContent: () => yi,
4145
- ToolHeader: () => vi,
4146
- ToolInput: () => bi,
4147
- ToolOutput: () => xi,
4148
- highlightCode: () => pi,
4149
- usePromptInputAttachments: () => Er,
4150
- usePromptInputController: () => br,
4151
- useProviderAttachments: () => Sr,
4152
- useReasoning: () => wi
4153
- }), Sa = "/api/v1/ai";
4154
- function Ca(e, t, n) {
4099
+ children: /* @__PURE__ */ Q(Ta, { size: t })
4100
+ }), Da = /* @__PURE__ */ Lt({
4101
+ CodeBlock: () => vi,
4102
+ CodeBlockCopyButton: () => yi,
4103
+ Conversation: () => qn,
4104
+ ConversationContent: () => Jn,
4105
+ ConversationEmptyState: () => Yn,
4106
+ ConversationScrollButton: () => Xn,
4107
+ Loader: () => Ea,
4108
+ Message: () => er,
4109
+ MessageAction: () => rr,
4110
+ MessageActions: () => nr,
4111
+ MessageAttachment: () => pr,
4112
+ MessageAttachments: () => mr,
4113
+ MessageBranch: () => or,
4114
+ MessageBranchContent: () => sr,
4115
+ MessageBranchNext: () => ur,
4116
+ MessageBranchPage: () => dr,
4117
+ MessageBranchPrevious: () => lr,
4118
+ MessageBranchSelector: () => cr,
4119
+ MessageContent: () => tr,
4120
+ MessageResponse: () => fr,
4121
+ MessageToolbar: () => hr,
4122
+ PromptInput: () => Pr,
4123
+ PromptInputActionAddAttachments: () => Nr,
4124
+ PromptInputActionMenu: () => Vr,
4125
+ PromptInputActionMenuContent: () => Ur,
4126
+ PromptInputActionMenuItem: () => Wr,
4127
+ PromptInputActionMenuTrigger: () => Hr,
4128
+ PromptInputAttachment: () => jr,
4129
+ PromptInputAttachments: () => Mr,
4130
+ PromptInputBody: () => Fr,
4131
+ PromptInputButton: () => Br,
4132
+ PromptInputCommand: () => oi,
4133
+ PromptInputCommandEmpty: () => li,
4134
+ PromptInputCommandGroup: () => ui,
4135
+ PromptInputCommandInput: () => si,
4136
+ PromptInputCommandItem: () => di,
4137
+ PromptInputCommandList: () => ci,
4138
+ PromptInputCommandSeparator: () => fi,
4139
+ PromptInputFooter: () => Rr,
4140
+ PromptInputHeader: () => Lr,
4141
+ PromptInputHoverCard: () => Qr,
4142
+ PromptInputHoverCardContent: () => ei,
4143
+ PromptInputHoverCardTrigger: () => $r,
4144
+ PromptInputProvider: () => Or,
4145
+ PromptInputSelect: () => qr,
4146
+ PromptInputSelectContent: () => Yr,
4147
+ PromptInputSelectItem: () => Xr,
4148
+ PromptInputSelectTrigger: () => Jr,
4149
+ PromptInputSelectValue: () => Zr,
4150
+ PromptInputSpeechButton: () => Kr,
4151
+ PromptInputSubmit: () => Gr,
4152
+ PromptInputTab: () => ni,
4153
+ PromptInputTabBody: () => ii,
4154
+ PromptInputTabItem: () => ai,
4155
+ PromptInputTabLabel: () => ri,
4156
+ PromptInputTabsList: () => ti,
4157
+ PromptInputTextarea: () => Ir,
4158
+ PromptInputTools: () => zr,
4159
+ Reasoning: () => ji,
4160
+ ReasoningContent: () => Pi,
4161
+ ReasoningTrigger: () => Ni,
4162
+ Shimmer: () => Ei,
4163
+ Source: () => Ri,
4164
+ Sources: () => Fi,
4165
+ SourcesContent: () => Li,
4166
+ SourcesTrigger: () => Ii,
4167
+ Suggestion: () => mi,
4168
+ Suggestions: () => pi,
4169
+ Tool: () => bi,
4170
+ ToolContent: () => Ci,
4171
+ ToolHeader: () => Si,
4172
+ ToolInput: () => wi,
4173
+ ToolOutput: () => Ti,
4174
+ highlightCode: () => _i,
4175
+ usePromptInputAttachments: () => Ar,
4176
+ usePromptInputController: () => wr,
4177
+ useProviderAttachments: () => Er,
4178
+ useReasoning: () => Oi
4179
+ }), Oa = "/api/v1/ai";
4180
+ function ka(e, t, n) {
4155
4181
  let r = e.replace(/\/$/, ""), i = new URLSearchParams();
4156
4182
  if (n) for (let [e, t] of Object.entries(n)) t == null || t === "" || i.set(e, String(t));
4157
4183
  let a = i.toString();
4158
4184
  return `${r}${t}${a ? `?${a}` : ""}`;
4159
4185
  }
4160
- async function wa(e, t, n) {
4186
+ async function Aa(e, t, n) {
4161
4187
  let r = await fetch(e, {
4162
4188
  credentials: "include",
4163
4189
  ...t,
@@ -4177,8 +4203,8 @@ async function wa(e, t, n) {
4177
4203
  }
4178
4204
  return i;
4179
4205
  }
4180
- function Ta(t = {}) {
4181
- let { apiBase: n = Sa, status: r = "pending", conversationId: i, limit: a, headers: o, pollInterval: s = 5e3, enabled: c = !0 } = t, [l, u] = e.useState([]), [d, f] = e.useState(0), [p, m] = e.useState(!1), [h, g] = e.useState(void 0), _ = e.useRef({
4206
+ function ja(t = {}) {
4207
+ let { apiBase: n = Oa, status: r = "pending", conversationId: i, limit: a, headers: o, pollInterval: s = 5e3, enabled: c = !0 } = t, [l, u] = e.useState([]), [d, f] = e.useState(0), [p, m] = e.useState(!1), [h, g] = e.useState(void 0), _ = e.useRef({
4182
4208
  apiBase: n,
4183
4209
  status: r,
4184
4210
  conversationId: i,
@@ -4196,7 +4222,7 @@ function Ta(t = {}) {
4196
4222
  let { apiBase: e, status: t, conversationId: n, limit: r, headers: i } = _.current;
4197
4223
  m(!0), g(void 0);
4198
4224
  try {
4199
- let a = await wa(Ca(e, "/pending-actions", {
4225
+ let a = await Aa(ka(e, "/pending-actions", {
4200
4226
  status: t && t !== "all" ? t : void 0,
4201
4227
  conversationId: n,
4202
4228
  limit: r
@@ -4208,9 +4234,9 @@ function Ta(t = {}) {
4208
4234
  m(!1);
4209
4235
  }
4210
4236
  }, []), y = e.useCallback(async (e) => {
4211
- let { apiBase: t, headers: n } = _.current, r = Ca(t, `/pending-actions/${encodeURIComponent(e)}/approve`);
4237
+ let { apiBase: t, headers: n } = _.current, r = ka(t, `/pending-actions/${encodeURIComponent(e)}/approve`);
4212
4238
  try {
4213
- return await wa(r, {
4239
+ return await Aa(r, {
4214
4240
  method: "POST",
4215
4241
  body: "{}"
4216
4242
  }, n);
@@ -4218,9 +4244,9 @@ function Ta(t = {}) {
4218
4244
  v();
4219
4245
  }
4220
4246
  }, [v]), b = e.useCallback(async (e, t) => {
4221
- let { apiBase: n, headers: r } = _.current, i = Ca(n, `/pending-actions/${encodeURIComponent(e)}/reject`);
4247
+ let { apiBase: n, headers: r } = _.current, i = ka(n, `/pending-actions/${encodeURIComponent(e)}/reject`);
4222
4248
  try {
4223
- return await wa(i, {
4249
+ return await Aa(i, {
4224
4250
  method: "POST",
4225
4251
  body: JSON.stringify(t ? { reason: t } : {})
4226
4252
  }, r);
@@ -4254,7 +4280,7 @@ function Ta(t = {}) {
4254
4280
  }
4255
4281
  //#endregion
4256
4282
  //#region src/AiPendingActionsInbox.tsx
4257
- var Ea = {
4283
+ var Ma = {
4258
4284
  pending: {
4259
4285
  variant: "secondary",
4260
4286
  label: "Pending"
@@ -4276,8 +4302,8 @@ var Ea = {
4276
4302
  label: "Rejected"
4277
4303
  }
4278
4304
  };
4279
- function Da({ status: e }) {
4280
- let t = Ea[e] ?? {
4305
+ function Na({ status: e }) {
4306
+ let t = Ma[e] ?? {
4281
4307
  variant: "outline",
4282
4308
  label: e
4283
4309
  };
@@ -4286,7 +4312,7 @@ function Da({ status: e }) {
4286
4312
  children: t.label
4287
4313
  });
4288
4314
  }
4289
- function Oa(e) {
4315
+ function Pa(e) {
4290
4316
  if (!e) return "—";
4291
4317
  let t = Date.parse(e);
4292
4318
  if (Number.isNaN(t)) return e;
@@ -4304,7 +4330,7 @@ function Oa(e) {
4304
4330
  return e;
4305
4331
  }
4306
4332
  }
4307
- function ka(e) {
4333
+ function Fa(e) {
4308
4334
  if (!e) return null;
4309
4335
  try {
4310
4336
  return JSON.parse(e);
@@ -4312,7 +4338,7 @@ function ka(e) {
4312
4338
  return e;
4313
4339
  }
4314
4340
  }
4315
- function Aa({ value: e, max: t = 320 }) {
4341
+ function Ia({ value: e, max: t = 320 }) {
4316
4342
  let n = typeof e == "string" ? e : JSON.stringify(e, null, 2);
4317
4343
  return n == null || n === "" ? /* @__PURE__ */ Q("span", {
4318
4344
  className: "text-muted-foreground text-xs",
@@ -4323,20 +4349,20 @@ function Aa({ value: e, max: t = 320 }) {
4323
4349
  children: n
4324
4350
  });
4325
4351
  }
4326
- function ja(e) {
4352
+ function La(e) {
4327
4353
  switch (e) {
4328
4354
  case "pending": return "pending";
4329
4355
  case "all": return "all";
4330
4356
  case "decided": return "all";
4331
4357
  }
4332
4358
  }
4333
- function Ma({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i, variant: a = "card", title: o = "AI Approvals", description: s = "Actions an AI agent proposed that need a human review before execution.", className: c }) {
4334
- let [l, u] = e.useState("pending"), [d, m] = e.useState(null), [h, g] = e.useState(null), [_, w] = e.useState(""), [T, E] = e.useState(null), [D, O] = e.useState(null), [k, A] = e.useState(null), { items: j, isLoading: M, error: N, refresh: P, approve: F, reject: I } = Ta({
4359
+ function Ra({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i, variant: a = "card", title: o = "AI Approvals", description: s = "Actions an AI agent proposed that need a human review before execution.", className: c }) {
4360
+ let [l, u] = e.useState("pending"), [d, m] = e.useState(null), [h, g] = e.useState(null), [_, w] = e.useState(""), [T, E] = e.useState(null), [D, O] = e.useState(null), [k, A] = e.useState(null), { items: j, isLoading: M, error: N, refresh: P, approve: F, reject: I } = ja({
4335
4361
  apiBase: t,
4336
4362
  headers: n,
4337
4363
  pollInterval: r,
4338
4364
  conversationId: i,
4339
- status: ja(l)
4365
+ status: La(l)
4340
4366
  }), L = e.useMemo(() => l === "decided" ? j.filter((e) => e.status !== "pending") : j, [j, l]), z = e.useMemo(() => d ? j.find((e) => e.id === d) ?? null : null, [d, j]), ie = e.useCallback(async (e) => {
4341
4367
  E(e), O(null);
4342
4368
  try {
@@ -4358,7 +4384,7 @@ function Ma({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
4358
4384
  } finally {
4359
4385
  E(null);
4360
4386
  }
4361
- }, [F]), ae = e.useCallback(async (e, t) => {
4387
+ }, [F]), B = e.useCallback(async (e, t) => {
4362
4388
  E(e), O(null);
4363
4389
  try {
4364
4390
  await I(e, t.trim() || void 0), A({
@@ -4378,7 +4404,7 @@ function Ma({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
4378
4404
  } finally {
4379
4405
  E(null);
4380
4406
  }
4381
- }, [I]), B = /* @__PURE__ */ $("div", {
4407
+ }, [I]), ae = /* @__PURE__ */ $("div", {
4382
4408
  className: "space-y-3",
4383
4409
  children: [
4384
4410
  /* @__PURE__ */ $("div", {
@@ -4485,7 +4511,7 @@ function Ma({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
4485
4511
  className: "text-sm",
4486
4512
  children: e.object_name
4487
4513
  }),
4488
- /* @__PURE__ */ Q(H, { children: /* @__PURE__ */ Q(Da, { status: e.status }) }),
4514
+ /* @__PURE__ */ Q(H, { children: /* @__PURE__ */ Q(Na, { status: e.status }) }),
4489
4515
  /* @__PURE__ */ Q(H, {
4490
4516
  className: "text-xs text-muted-foreground",
4491
4517
  children: /* @__PURE__ */ $("span", {
@@ -4493,7 +4519,7 @@ function Ma({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
4493
4519
  children: [
4494
4520
  /* @__PURE__ */ Q(He, { className: "h-3 w-3" }),
4495
4521
  " ",
4496
- Oa(e.proposed_at)
4522
+ Pa(e.proposed_at)
4497
4523
  ]
4498
4524
  })
4499
4525
  }),
@@ -4544,10 +4570,10 @@ function Ma({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
4544
4570
  o
4545
4571
  ]
4546
4572
  }), s ? /* @__PURE__ */ Q(x, { children: s }) : null]
4547
- }), /* @__PURE__ */ Q(b, { children: B })]
4573
+ }), /* @__PURE__ */ Q(b, { children: ae })]
4548
4574
  }) : /* @__PURE__ */ Q("div", {
4549
4575
  className: c,
4550
- children: B
4576
+ children: ae
4551
4577
  }),
4552
4578
  /* @__PURE__ */ Q(me, {
4553
4579
  open: !!d,
@@ -4582,14 +4608,14 @@ function Ma({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
4582
4608
  children: "Status"
4583
4609
  }), /* @__PURE__ */ Q("div", {
4584
4610
  className: "mt-1",
4585
- children: /* @__PURE__ */ Q(Da, { status: z.status })
4611
+ children: /* @__PURE__ */ Q(Na, { status: z.status })
4586
4612
  })] }),
4587
4613
  /* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q(V, {
4588
4614
  className: "text-xs text-muted-foreground",
4589
4615
  children: "Proposed"
4590
4616
  }), /* @__PURE__ */ Q("div", {
4591
4617
  className: "mt-1 text-xs",
4592
- children: Oa(z.proposed_at)
4618
+ children: Pa(z.proposed_at)
4593
4619
  })] }),
4594
4620
  /* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q(V, {
4595
4621
  className: "text-xs text-muted-foreground",
@@ -4623,21 +4649,21 @@ function Ma({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
4623
4649
  children: "Tool input"
4624
4650
  }), /* @__PURE__ */ Q("div", {
4625
4651
  className: "mt-1.5",
4626
- children: /* @__PURE__ */ Q(Aa, { value: ka(z.tool_input) })
4652
+ children: /* @__PURE__ */ Q(Ia, { value: Fa(z.tool_input) })
4627
4653
  })] }),
4628
4654
  z.result ? /* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q(V, {
4629
4655
  className: "text-xs",
4630
4656
  children: "Result"
4631
4657
  }), /* @__PURE__ */ Q("div", {
4632
4658
  className: "mt-1.5",
4633
- children: /* @__PURE__ */ Q(Aa, { value: ka(z.result) })
4659
+ children: /* @__PURE__ */ Q(Ia, { value: Fa(z.result) })
4634
4660
  })] }) : null,
4635
4661
  z.error ? /* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q(V, {
4636
4662
  className: "text-xs text-destructive",
4637
4663
  children: "Error"
4638
4664
  }), /* @__PURE__ */ Q("div", {
4639
4665
  className: "mt-1.5",
4640
- children: /* @__PURE__ */ Q(Aa, { value: z.error })
4666
+ children: /* @__PURE__ */ Q(Ia, { value: z.error })
4641
4667
  })] }) : null,
4642
4668
  z.rejection_reason ? /* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q(V, {
4643
4669
  className: "text-xs",
@@ -4695,7 +4721,7 @@ function Ma({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
4695
4721
  }), /* @__PURE__ */ $(v, {
4696
4722
  variant: "destructive",
4697
4723
  size: "sm",
4698
- onClick: () => h && void ae(h, _),
4724
+ onClick: () => h && void B(h, _),
4699
4725
  disabled: !h || T === h,
4700
4726
  "data-testid": "ai-inbox-reject-confirm",
4701
4727
  children: [/* @__PURE__ */ Q(X, { className: "h-3.5 w-3.5 mr-1" }), "Reject"]
@@ -4708,14 +4734,14 @@ function Ma({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
4708
4734
  }
4709
4735
  //#endregion
4710
4736
  //#region src/useHitlInChat.ts
4711
- function Na(e) {
4737
+ function za(e) {
4712
4738
  return !e || e.length === 0 ? "/api/v1/ai" : e.endsWith("/") ? e.slice(0, -1) : e;
4713
4739
  }
4714
- function Pa(e, t) {
4740
+ function Ba(e, t) {
4715
4741
  let n = { ...e ?? {} };
4716
4742
  return t && (n["Content-Type"] = "application/json"), n;
4717
4743
  }
4718
- async function Fa(e) {
4744
+ async function Va(e) {
4719
4745
  let t = await e.text();
4720
4746
  if (!t) return null;
4721
4747
  try {
@@ -4724,8 +4750,8 @@ async function Fa(e) {
4724
4750
  return { raw: t };
4725
4751
  }
4726
4752
  }
4727
- function Ia(t) {
4728
- let { messages: n, apiBase: r, headers: i, onDecided: a, continueConversation: o } = t, s = Na(r), c = e.useMemo(() => {
4753
+ function Ha(t) {
4754
+ let { messages: n, apiBase: r, headers: i, onDecided: a, continueConversation: o } = t, s = za(r), c = e.useMemo(() => {
4729
4755
  let e = /* @__PURE__ */ new Map();
4730
4756
  for (let t of n) {
4731
4757
  let n = t.toolInvocations ?? [];
@@ -4768,9 +4794,9 @@ function Ia(t) {
4768
4794
  let r = `${s}/pending-actions/${encodeURIComponent(l)}/${t ? "approve" : "reject"}`, c = t ? "{}" : JSON.stringify({ reason: n ?? "" }), d = await fetch(r, {
4769
4795
  method: "POST",
4770
4796
  credentials: "include",
4771
- headers: Pa(i, !0),
4797
+ headers: Ba(i, !0),
4772
4798
  body: c
4773
- }), f = await Fa(d) ?? {};
4799
+ }), f = await Va(d) ?? {};
4774
4800
  if (!d.ok) {
4775
4801
  let t = typeof f.error == "string" ? f.error : `Approval failed: HTTP ${d.status}`;
4776
4802
  m(e, {
@@ -4784,20 +4810,26 @@ function Ia(t) {
4784
4810
  return;
4785
4811
  }
4786
4812
  let p = f.status ?? (t ? "executed" : "rejected"), h = !1;
4787
- if (p === "executed" ? (m(e, {
4813
+ if (p === "executed") m(e, {
4788
4814
  state: "success",
4789
4815
  message: "Approved — action executed."
4790
- }), h = !0) : p === "rejected" ? (m(e, {
4816
+ }), h = !0;
4817
+ else if (p === "rejected") m(e, {
4791
4818
  state: "success",
4792
4819
  message: n ? `Rejected: ${n}` : "Rejected."
4793
- }), h = !0) : p === "failed" ? m(e, {
4794
- state: "error",
4795
- message: f.error ?? "Action approved but execution failed."
4796
- }) : (m(e, {
4820
+ }), h = !0;
4821
+ else if (p === "failed") {
4822
+ let t = f.error ?? "Action approved but execution failed.";
4823
+ m(e, {
4824
+ state: "error",
4825
+ message: t
4826
+ });
4827
+ } else m(e, {
4797
4828
  state: "success",
4798
4829
  message: `Status: ${p}`
4799
- }), h = !0), a?.(e, f), h && o) {
4800
- let r = La({
4830
+ }), h = !0;
4831
+ if (a?.(e, f), h && o) {
4832
+ let r = Ua({
4801
4833
  approved: t,
4802
4834
  status: p,
4803
4835
  toolName: u,
@@ -4814,9 +4846,10 @@ function Ia(t) {
4814
4846
  });
4815
4847
  }
4816
4848
  } catch (t) {
4849
+ let n = t instanceof Error ? t.message : String(t);
4817
4850
  m(e, {
4818
4851
  state: "error",
4819
- message: t instanceof Error ? t.message : String(t)
4852
+ message: n
4820
4853
  });
4821
4854
  } finally {
4822
4855
  --d.current, d.current <= 0 && (d.current = 0, p(!1));
@@ -4832,24 +4865,24 @@ function Ia(t) {
4832
4865
  isDeciding: f
4833
4866
  };
4834
4867
  }
4835
- function La(e) {
4868
+ function Ua(e) {
4836
4869
  let { approved: t, status: n, toolName: r, pendingActionId: i, outcome: a, reason: o } = e, s = `[HITL ${i}]`;
4837
4870
  if (t && n === "executed") {
4838
4871
  let e = a.result;
4839
- return `${s} The operator approved the \`${r}\` call. It executed successfully with result: ${e == null ? "(no payload)" : typeof e == "string" ? e : Ra(JSON.stringify(e), 800)}. Acknowledge the outcome concisely and continue the user's task.`;
4872
+ return `${s} The operator approved the \`${r}\` call. It executed successfully with result: ${e == null ? "(no payload)" : typeof e == "string" ? e : Wa(JSON.stringify(e), 800)}. Acknowledge the outcome concisely and continue the user's task.`;
4840
4873
  }
4841
4874
  if (!t && n === "rejected") return `${s} The operator rejected the \`${r}\` call.${o && o.trim().length > 0 ? ` Reason: ${o}.` : ""} Acknowledge the rejection and ask whether to try a different approach.`;
4842
4875
  if (n === "failed") {
4843
4876
  let e = a.error;
4844
- return `${s} The \`${r}\` call was approved but execution failed: ${typeof e == "string" ? e : Ra(JSON.stringify(e ?? {}), 400)}. Apologize concisely and offer alternatives.`;
4877
+ return `${s} The \`${r}\` call was approved but execution failed: ${typeof e == "string" ? e : Wa(JSON.stringify(e ?? {}), 400)}. Apologize concisely and offer alternatives.`;
4845
4878
  }
4846
4879
  }
4847
- function Ra(e, t) {
4880
+ function Wa(e, t) {
4848
4881
  return e.length <= t ? e : `${e.slice(0, t - 1)}…`;
4849
4882
  }
4850
4883
  //#endregion
4851
4884
  //#region src/index.tsx
4852
- var za = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type your message...", onSendMessage: i, disabled: a = !1, showTimestamp: o = !1, userAvatarUrl: s, userAvatarFallback: c = "You", assistantAvatarUrl: l, assistantAvatarFallback: u = "AI", maxHeight: d = "500px", ...f }, p) => {
4885
+ var Ga = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type your message...", onSendMessage: i, disabled: a = !1, showTimestamp: o = !1, userAvatarUrl: s, userAvatarFallback: c = "You", assistantAvatarUrl: l, assistantAvatarFallback: u = "AI", maxHeight: d = "500px", ...f }, p) => {
4853
4886
  let [m, h] = e.useState(""), g = e.useRef(null), _ = e.useRef(null);
4854
4887
  e.useEffect(() => {
4855
4888
  if (g.current) {
@@ -4875,7 +4908,7 @@ var za = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
4875
4908
  children: n.length === 0 ? /* @__PURE__ */ Q("div", {
4876
4909
  className: "flex items-center justify-center h-32 text-muted-foreground text-sm",
4877
4910
  children: "No messages yet. Start a conversation!"
4878
- }) : n.map((e) => /* @__PURE__ */ Q(Ba, {
4911
+ }) : n.map((e) => /* @__PURE__ */ Q(Ka, {
4879
4912
  message: e,
4880
4913
  showTimestamp: o,
4881
4914
  userAvatarUrl: s,
@@ -4888,7 +4921,7 @@ var za = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
4888
4921
  className: "border-t p-4",
4889
4922
  children: /* @__PURE__ */ $("div", {
4890
4923
  className: "flex gap-2",
4891
- children: [/* @__PURE__ */ Q(B, {
4924
+ children: [/* @__PURE__ */ Q(ae, {
4892
4925
  ref: _,
4893
4926
  value: m,
4894
4927
  onChange: (e) => h(e.target.value),
@@ -4906,8 +4939,8 @@ var za = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
4906
4939
  })]
4907
4940
  });
4908
4941
  });
4909
- za.displayName = "Chatbot";
4910
- var Ba = ({ message: e, showTimestamp: t, userAvatarUrl: n, userAvatarFallback: r, assistantAvatarUrl: i, assistantAvatarFallback: a }) => {
4942
+ Ga.displayName = "Chatbot";
4943
+ var Ka = ({ message: e, showTimestamp: t, userAvatarUrl: n, userAvatarFallback: r, assistantAvatarUrl: i, assistantAvatarFallback: a }) => {
4911
4944
  let o = e.role === "user";
4912
4945
  if (e.role === "system") return /* @__PURE__ */ Q("div", {
4913
4946
  className: "flex justify-center",
@@ -4939,7 +4972,7 @@ var Ba = ({ message: e, showTimestamp: t, userAvatarUrl: n, userAvatarFallback:
4939
4972
  })]
4940
4973
  })]
4941
4974
  });
4942
- }, Va = e.forwardRef(({ className: e, avatarSrc: t, avatarFallback: n = "AI", ...r }, i) => /* @__PURE__ */ $("div", {
4975
+ }, qa = e.forwardRef(({ className: e, avatarSrc: t, avatarFallback: n = "AI", ...r }, i) => /* @__PURE__ */ $("div", {
4943
4976
  ref: i,
4944
4977
  className: q("flex gap-3", e),
4945
4978
  ...r,
@@ -4961,6 +4994,6 @@ var Ba = ({ message: e, showTimestamp: t, userAvatarUrl: n, userAvatarFallback:
4961
4994
  })
4962
4995
  })]
4963
4996
  }));
4964
- Va.displayName = "TypingIndicator";
4997
+ qa.displayName = "TypingIndicator";
4965
4998
  //#endregion
4966
- export { sn as AGENT_ALIAS_GROUPS, xa as AIElements, Ma as AiPendingActionsInbox, za as Chatbot, Ji as ChatbotEnhanced, va as FloatingChatbot, Nn as FloatingChatbotPanel, xn as FloatingChatbotProvider, Dn as FloatingChatbotTrigger, mn as PLATFORM_DEFAULT_AGENT, Va as TypingIndicator, cn as agentAliasGroup, ln as agentRouteName, Jt as buildProgressFromDraftReview, Kt as detectDraftResult, Wt as detectProposedPlan, Fn as humanizeToolName, pn as isAskAgent, fn as isBuildAgent, dn as isBuiltinAgentName, Fi as publishHealthFromResponse, un as resolveAgentParam, hn as resolveDefaultAgentName, Ln as summarizeChatError, en as uiMessageToChatMessage, tn as uiMessagesToChatMessages, In as unwrapToolResult, _n as useAgents, yn as useAiModels, Sn as useFloatingChatbot, Ia as useHitlInChat, on as useObjectChat, Ta as usePendingActions };
4999
+ export { sn as AGENT_ALIAS_GROUPS, Da as AIElements, Ra as AiPendingActionsInbox, Ga as Chatbot, ea as ChatbotEnhanced, wa as FloatingChatbot, Ln as FloatingChatbotPanel, Tn as FloatingChatbotProvider, jn as FloatingChatbotTrigger, mn as PLATFORM_DEFAULT_AGENT, qa as TypingIndicator, cn as agentAliasGroup, ln as agentRouteName, Jt as buildProgressFromDraftReview, Kt as detectDraftResult, Wt as detectProposedPlan, zn as humanizeToolName, pn as isAskAgent, fn as isBuildAgent, dn as isBuiltinAgentName, zi as publishHealthFromResponse, un as resolveAgentParam, hn as resolveDefaultAgentName, Vn as summarizeChatError, en as uiMessageToChatMessage, tn as uiMessagesToChatMessages, Bn as unwrapToolResult, xn as useAgents, Cn as useAiModels, En as useFloatingChatbot, Ha as useHitlInChat, on as useObjectChat, ja as usePendingActions };