@object-ui/plugin-chatbot 6.2.2 → 7.0.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.
Files changed (94) hide show
  1. package/CHANGELOG.md +103 -0
  2. package/README.md +60 -4
  3. package/dist/{packages/plugin-chatbot/src/AiPendingActionsInbox.d.ts → AiPendingActionsInbox.d.ts} +17 -1
  4. package/dist/AiPendingActionsInbox.d.ts.map +1 -0
  5. package/dist/ChatbotEnhanced.d.ts +568 -0
  6. package/dist/ChatbotEnhanced.d.ts.map +1 -0
  7. package/dist/{packages/plugin-chatbot/src/FloatingChatbot.d.ts → FloatingChatbot.d.ts} +1 -1
  8. package/dist/FloatingChatbot.d.ts.map +1 -0
  9. package/dist/{packages/plugin-chatbot/src/FloatingChatbotPanel.d.ts → FloatingChatbotPanel.d.ts} +1 -1
  10. package/dist/FloatingChatbotPanel.d.ts.map +1 -0
  11. package/dist/{packages/plugin-chatbot/src/FloatingChatbotProvider.d.ts → FloatingChatbotProvider.d.ts} +1 -1
  12. package/dist/FloatingChatbotProvider.d.ts.map +1 -0
  13. package/dist/{packages/plugin-chatbot/src/FloatingChatbotTrigger.d.ts → FloatingChatbotTrigger.d.ts} +2 -1
  14. package/dist/FloatingChatbotTrigger.d.ts.map +1 -0
  15. package/dist/agentAliases.d.ts +57 -0
  16. package/dist/agentAliases.d.ts.map +1 -0
  17. package/dist/{packages/plugin-chatbot/src/elements → elements}/code-block.d.ts +2 -2
  18. package/dist/elements/code-block.d.ts.map +1 -0
  19. package/dist/{packages/plugin-chatbot/src/elements → elements}/conversation.d.ts +4 -4
  20. package/dist/elements/conversation.d.ts.map +1 -0
  21. package/dist/elements/index.d.ts.map +1 -0
  22. package/dist/{packages/plugin-chatbot/src/elements → elements}/loader.d.ts +1 -1
  23. package/dist/elements/loader.d.ts.map +1 -0
  24. package/dist/{packages/plugin-chatbot/src/elements → elements}/message.d.ts +14 -14
  25. package/dist/elements/message.d.ts.map +1 -0
  26. package/dist/{packages/plugin-chatbot/src/elements → elements}/prompt-input.d.ts +38 -37
  27. package/dist/elements/prompt-input.d.ts.map +1 -0
  28. package/dist/{packages/plugin-chatbot/src/elements → elements}/reasoning.d.ts +3 -3
  29. package/dist/elements/reasoning.d.ts.map +1 -0
  30. package/dist/{packages/plugin-chatbot/src/elements → elements}/shimmer.d.ts +2 -2
  31. package/dist/elements/shimmer.d.ts.map +1 -0
  32. package/dist/{packages/plugin-chatbot/src/elements → elements}/sources.d.ts +4 -4
  33. package/dist/elements/sources.d.ts.map +1 -0
  34. package/dist/{packages/plugin-chatbot/src/elements → elements}/suggestion.d.ts +2 -2
  35. package/dist/elements/suggestion.d.ts.map +1 -0
  36. package/dist/{packages/plugin-chatbot/src/elements → elements}/tool.d.ts +5 -5
  37. package/dist/elements/tool.d.ts.map +1 -0
  38. package/dist/{packages/plugin-chatbot/src/elements → elements}/ui/button-group.d.ts +3 -3
  39. package/dist/elements/ui/button-group.d.ts.map +1 -0
  40. package/dist/{packages/plugin-chatbot/src/elements → elements}/ui/input-group.d.ts +6 -6
  41. package/dist/elements/ui/input-group.d.ts.map +1 -0
  42. package/dist/index.d.ts +70 -2
  43. package/dist/index.d.ts.map +1 -0
  44. package/dist/index.js +2004 -987
  45. package/dist/index.umd.cjs +1 -1
  46. package/dist/mapMessages.d.ts +147 -0
  47. package/dist/mapMessages.d.ts.map +1 -0
  48. package/dist/renderer.d.ts.map +1 -0
  49. package/dist/{packages/plugin-chatbot/src/tool-display.d.ts → tool-display.d.ts} +23 -0
  50. package/dist/tool-display.d.ts.map +1 -0
  51. package/dist/{packages/plugin-chatbot/src/useAgents.d.ts → useAgents.d.ts} +28 -0
  52. package/dist/useAgents.d.ts.map +1 -0
  53. package/dist/useHitlInChat.d.ts.map +1 -0
  54. package/dist/{packages/plugin-chatbot/src/useObjectChat.d.ts → useObjectChat.d.ts} +37 -1
  55. package/dist/useObjectChat.d.ts.map +1 -0
  56. package/dist/usePendingActions.d.ts.map +1 -0
  57. package/dist/utils.d.ts.map +1 -0
  58. package/package.json +16 -16
  59. package/dist/packages/plugin-chatbot/src/AiPendingActionsInbox.d.ts.map +0 -1
  60. package/dist/packages/plugin-chatbot/src/ChatbotEnhanced.d.ts +0 -171
  61. package/dist/packages/plugin-chatbot/src/ChatbotEnhanced.d.ts.map +0 -1
  62. package/dist/packages/plugin-chatbot/src/FloatingChatbot.d.ts.map +0 -1
  63. package/dist/packages/plugin-chatbot/src/FloatingChatbotPanel.d.ts.map +0 -1
  64. package/dist/packages/plugin-chatbot/src/FloatingChatbotProvider.d.ts.map +0 -1
  65. package/dist/packages/plugin-chatbot/src/FloatingChatbotTrigger.d.ts.map +0 -1
  66. package/dist/packages/plugin-chatbot/src/elements/code-block.d.ts.map +0 -1
  67. package/dist/packages/plugin-chatbot/src/elements/conversation.d.ts.map +0 -1
  68. package/dist/packages/plugin-chatbot/src/elements/index.d.ts.map +0 -1
  69. package/dist/packages/plugin-chatbot/src/elements/loader.d.ts.map +0 -1
  70. package/dist/packages/plugin-chatbot/src/elements/message.d.ts.map +0 -1
  71. package/dist/packages/plugin-chatbot/src/elements/prompt-input.d.ts.map +0 -1
  72. package/dist/packages/plugin-chatbot/src/elements/reasoning.d.ts.map +0 -1
  73. package/dist/packages/plugin-chatbot/src/elements/shimmer.d.ts.map +0 -1
  74. package/dist/packages/plugin-chatbot/src/elements/sources.d.ts.map +0 -1
  75. package/dist/packages/plugin-chatbot/src/elements/suggestion.d.ts.map +0 -1
  76. package/dist/packages/plugin-chatbot/src/elements/tool.d.ts.map +0 -1
  77. package/dist/packages/plugin-chatbot/src/elements/ui/button-group.d.ts.map +0 -1
  78. package/dist/packages/plugin-chatbot/src/elements/ui/input-group.d.ts.map +0 -1
  79. package/dist/packages/plugin-chatbot/src/index.d.ts +0 -68
  80. package/dist/packages/plugin-chatbot/src/index.d.ts.map +0 -1
  81. package/dist/packages/plugin-chatbot/src/mapMessages.d.ts +0 -45
  82. package/dist/packages/plugin-chatbot/src/mapMessages.d.ts.map +0 -1
  83. package/dist/packages/plugin-chatbot/src/renderer.d.ts.map +0 -1
  84. package/dist/packages/plugin-chatbot/src/tool-display.d.ts.map +0 -1
  85. package/dist/packages/plugin-chatbot/src/useAgents.d.ts.map +0 -1
  86. package/dist/packages/plugin-chatbot/src/useHitlInChat.d.ts.map +0 -1
  87. package/dist/packages/plugin-chatbot/src/useObjectChat.d.ts.map +0 -1
  88. package/dist/packages/plugin-chatbot/src/usePendingActions.d.ts.map +0 -1
  89. package/dist/packages/plugin-chatbot/src/utils.d.ts.map +0 -1
  90. /package/dist/{packages/plugin-chatbot/src/elements → elements}/index.d.ts +0 -0
  91. /package/dist/{packages/plugin-chatbot/src/renderer.d.ts → renderer.d.ts} +0 -0
  92. /package/dist/{packages/plugin-chatbot/src/useHitlInChat.d.ts → useHitlInChat.d.ts} +0 -0
  93. /package/dist/{packages/plugin-chatbot/src/usePendingActions.d.ts → usePendingActions.d.ts} +0 -0
  94. /package/dist/{packages/plugin-chatbot/src/utils.d.ts → utils.d.ts} +0 -0
package/dist/index.js CHANGED
@@ -1,45 +1,45 @@
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 ne, EmptyMedia as re, EmptyTitle as ie, HoverCard as R, HoverCardContent as ae, HoverCardTrigger as oe, Input as se, Label as z, ScrollArea as ce, ScrollBar as le, Select as ue, SelectContent as de, SelectItem as fe, SelectTrigger as pe, SelectValue as me, Separator as he, Sheet as ge, SheetContent as _e, SheetDescription as ve, SheetHeader as ye, SheetTitle as be, Skeleton as xe, Table as Se, TableBody as Ce, TableCell as B, TableHead as V, TableHeader as we, TableRow as Te, Tabs as Ee, TabsList as De, TabsTrigger as Oe, Textarea as ke, Tooltip as Ae, TooltipContent as je, TooltipProvider as Me, TooltipTrigger as Ne, cn as H } from "@object-ui/components";
4
- import { AlertCircle as Pe, ArrowDownIcon as Fe, BookIcon as Ie, Bot as Le, BrainIcon as Re, Check as ze, CheckCircle2 as Be, CheckCircleIcon as Ve, CheckIcon as He, ChevronDownIcon as Ue, ChevronLeftIcon as We, ChevronRightIcon as Ge, CircleIcon as Ke, Clock as qe, ClockIcon as Je, Copy as Ye, CopyIcon as Xe, CornerDownLeft as Ze, CornerDownLeftIcon as Qe, Eye as $e, ImageIcon as et, Inbox as tt, Loader2Icon as nt, Maximize2 as rt, MicIcon as it, Minimize2 as at, PaperclipIcon as ot, PlusIcon as st, RefreshCw as ct, Send as lt, SquareIcon as ut, WrenchIcon as dt, X as ft, XCircle as U, XCircleIcon as pt, XIcon as W } from "lucide-react";
5
- import { Fragment as G, jsx as K, jsxs as q } from "react/jsx-runtime";
6
- import { useChat as mt } from "@ai-sdk/react";
7
- import { DefaultChatTransport as ht } from "ai";
8
- import * as gt from "react-dom";
9
- import { useObjectTranslation as _t } from "@object-ui/react";
10
- import { StickToBottom as vt, useStickToBottomContext as yt } from "use-stick-to-bottom";
11
- import { cva as bt } from "class-variance-authority";
12
- import { Slot as xt } from "@radix-ui/react-slot";
13
- import { Streamdown as St } from "streamdown";
14
- import { nanoid as Ct } from "nanoid";
15
- import { codeToHtml as wt } from "shiki";
16
- import { useControllableState as Tt } from "@radix-ui/react-use-controllable-state";
17
- import { motion as Et } from "motion/react";
18
- import { ComponentRegistry as Dt } from "@object-ui/core";
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 ee, DropdownMenuContent as te, DropdownMenuItem as P, DropdownMenuTrigger as F, Empty as ne, EmptyDescription as I, EmptyHeader as re, EmptyMedia as ie, EmptyTitle as ae, HoverCard as L, HoverCardContent as R, HoverCardTrigger as z, Input as oe, Label as B, ScrollArea as se, ScrollBar as ce, Select as le, SelectContent as ue, SelectItem as de, SelectTrigger as fe, SelectValue as pe, Separator as me, Sheet as he, SheetContent as ge, SheetDescription as _e, SheetHeader as V, SheetTitle as ve, Skeleton as H, Table as ye, TableBody as be, TableCell as U, TableHead as W, TableHeader as G, TableRow as K, Tabs as xe, TabsList as q, TabsTrigger as Se, Textarea as Ce, Tooltip as we, TooltipContent as Te, TooltipProvider as Ee, TooltipTrigger as De, cn as J } from "@object-ui/components";
4
+ import { AlertCircle as Oe, ArrowDownIcon as ke, 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, ImageIcon as Qe, Inbox as $e, Loader2 as et, Loader2Icon as tt, Maximize2 as nt, MicIcon as rt, Minimize2 as it, PaperclipIcon as at, PlusIcon as ot, RefreshCw as st, Rocket as ct, Send as lt, ShieldCheck as ut, SquareIcon as dt, Table2 as ft, TriangleAlert as pt, WrenchIcon as mt, X as ht, XCircle as X, XCircleIcon as gt, XIcon as _t } from "lucide-react";
5
+ import { Fragment as Z, jsx as Q, jsxs as $ } from "react/jsx-runtime";
6
+ import { useChat as vt } from "@ai-sdk/react";
7
+ import { DefaultChatTransport as yt } from "ai";
8
+ import * as bt from "react-dom";
9
+ import { SchemaRenderer as xt, useObjectTranslation as St } from "@object-ui/react";
10
+ import { StickToBottom as Ct, useStickToBottomContext as wt } from "use-stick-to-bottom";
11
+ import { cva as Tt } from "class-variance-authority";
12
+ import { Slot as Et } from "@radix-ui/react-slot";
13
+ import { Streamdown as Dt } from "streamdown";
14
+ import { nanoid as Ot } from "nanoid";
15
+ import { codeToHtml as kt } from "shiki";
16
+ import { useControllableState as At } from "@radix-ui/react-use-controllable-state";
17
+ import { motion as jt } from "motion/react";
18
+ import { ComponentRegistry as Mt } from "@object-ui/core";
19
19
  //#region \0rolldown/runtime.js
20
- var Ot = Object.defineProperty, kt = (e, t) => {
20
+ var Nt = Object.defineProperty, Pt = (e, t) => {
21
21
  let n = {};
22
- for (var r in e) Ot(n, r, {
22
+ for (var r in e) Nt(n, r, {
23
23
  get: e[r],
24
24
  enumerable: !0
25
25
  });
26
- return t || Ot(n, Symbol.toStringTag, { value: "Module" }), n;
26
+ return t || Nt(n, Symbol.toStringTag, { value: "Module" }), n;
27
27
  };
28
28
  //#endregion
29
29
  //#region src/utils.ts
30
- function At(e = "msg") {
30
+ function Ft(e = "msg") {
31
31
  return typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID() : `${e}-${Date.now()}-${Math.random().toString(36).slice(2)}`;
32
32
  }
33
33
  //#endregion
34
34
  //#region src/mapMessages.ts
35
- function jt(e, t) {
35
+ function It(e, t) {
36
36
  return typeof e.content == "string" ? e.content : t.filter((e) => e.type === "text").map((e) => e.text ?? "").join("");
37
37
  }
38
- function Mt(e) {
38
+ function Lt(e) {
39
39
  let t = e.filter((e) => e.type === "reasoning" || e.type === "reasoning-delta").map((e) => e.text ?? "").join("\n").trim();
40
40
  return t.length > 0 ? t : void 0;
41
41
  }
42
- function Nt(e) {
42
+ function Rt(e) {
43
43
  let t = (e) => {
44
44
  if (e && typeof e == "object") return e;
45
45
  if (typeof e != "string") return;
@@ -52,31 +52,136 @@ function Nt(e) {
52
52
  }
53
53
  }, n = [e];
54
54
  e && typeof e == "object" && "value" in e && n.push(e.value);
55
+ let r;
55
56
  for (let e of n) {
56
57
  let n = t(e);
57
- if (!n) continue;
58
- let r = n.status, i = n.pendingActionId;
59
- if (r === "pending_approval" && typeof i == "string" && i.length > 0) return {
60
- pendingActionId: i,
61
- raw: n
62
- };
58
+ if (n) {
59
+ if (typeof n.status == "string") return n;
60
+ r ??= n;
61
+ }
63
62
  }
63
+ return r;
64
+ }
65
+ function zt(e) {
66
+ let t = Rt(e);
67
+ if (!t) return;
68
+ let n = t.pendingActionId;
69
+ if (t.status === "pending_approval" && typeof n == "string" && n.length > 0) return {
70
+ pendingActionId: n,
71
+ raw: t
72
+ };
73
+ }
74
+ function Bt(e) {
75
+ return Array.isArray(e) ? e.filter((e) => typeof e == "string" && e.trim().length > 0) : [];
76
+ }
77
+ function Vt(e) {
78
+ let t = Rt(e);
79
+ if (!t || t.status !== "blueprint_proposed") return;
80
+ let n = t.blueprint, r = n && typeof n == "object" ? n : {}, i = (Array.isArray(r.objects) ? r.objects : []).flatMap((e) => {
81
+ let t = e;
82
+ return typeof t?.name != "string" || !t.name ? [] : [{
83
+ name: t.name,
84
+ ...typeof t.label == "string" && t.label ? { label: t.label } : {},
85
+ fieldCount: Array.isArray(t.fields) ? t.fields.length : 0
86
+ }];
87
+ });
88
+ if (i.length === 0) return;
89
+ let a = (e, t) => typeof e == "number" && Number.isFinite(e) ? e : t, o = t.counts ?? {}, s = {
90
+ objects: a(o.objects, i.length),
91
+ views: a(o.views, Array.isArray(r.views) ? r.views.length : 0),
92
+ dashboards: a(o.dashboards, Array.isArray(r.dashboards) ? r.dashboards.length : 0),
93
+ seedData: a(o.seedData, Array.isArray(r.seedData) ? r.seedData.length : 0)
94
+ }, c = Bt(t.questions), l = t.questionChoices, u = Array.isArray(l) ? l.flatMap((e) => {
95
+ let t = e;
96
+ if (typeof t?.text != "string" || !t.text) return [];
97
+ let n = Array.isArray(t.options) ? t.options.filter((e) => typeof e == "string" && e.trim().length > 0) : [];
98
+ return n.length >= 2 ? [{
99
+ text: t.text,
100
+ options: n
101
+ }] : [];
102
+ }) : [], d = typeof t.summary == "string" && t.summary ? t.summary : typeof r.summary == "string" && r.summary ? r.summary : void 0, f = t.targetApp;
103
+ return {
104
+ ...d ? { summary: d } : {},
105
+ objects: i,
106
+ counts: s,
107
+ questions: c.length ? c : Bt(r.questions),
108
+ ...u.length ? { questionChoices: u } : {},
109
+ assumptions: Bt(r.assumptions),
110
+ ...typeof f == "string" && f ? { targetApp: f } : {}
111
+ };
64
112
  }
65
- function Pt(e) {
113
+ function Ht(e) {
114
+ let t = Rt(e);
115
+ if (!t || t.status !== "drafted") return;
116
+ let n = [];
117
+ if (Array.isArray(t.drafted)) {
118
+ for (let e of t.drafted) if (e && typeof e == "object") {
119
+ let { type: t, name: r } = e;
120
+ typeof t == "string" && typeof r == "string" && n.push({
121
+ type: t,
122
+ name: r
123
+ });
124
+ }
125
+ } else typeof t.type == "string" && typeof t.name == "string" && n.push({
126
+ type: t.type,
127
+ name: t.name
128
+ });
129
+ if (n.length === 0) return;
130
+ let r = Array.isArray(t.failed) ? t.failed.length : 0, i = t.verification, a = i && typeof i == "object" && typeof i.errors == "number" && typeof i.warnings == "number" ? {
131
+ errors: i.errors,
132
+ warnings: i.warnings
133
+ } : void 0, o = t.issues, s = Array.isArray(o) ? o.flatMap((e) => {
134
+ let t = e;
135
+ return typeof t?.message != "string" || !t.message ? [] : [{
136
+ severity: t.severity === "error" ? "error" : "warning",
137
+ code: typeof t.code == "string" ? t.code : "issue",
138
+ message: t.message,
139
+ ...typeof t.fix == "string" && t.fix ? { fix: t.fix } : {}
140
+ }];
141
+ }) : [], c = t.nextSteps, l = Array.isArray(c) ? c.filter((e) => typeof e == "string" && e.trim().length > 0) : [];
142
+ return {
143
+ items: n,
144
+ summary: typeof t.summary == "string" ? t.summary : void 0,
145
+ ...typeof t.packageId == "string" && t.packageId ? { packageId: t.packageId } : {},
146
+ ...t.autoPublishable === !0 ? { autoPublishable: !0 } : {},
147
+ ...r > 0 ? { failedCount: r } : {},
148
+ ...l.length ? { nextSteps: l } : {},
149
+ ...t.materialized === !0 ? { materialized: !0 } : {},
150
+ ...a ? { verification: a } : {},
151
+ ...s.length ? { issues: s } : {}
152
+ };
153
+ }
154
+ function Ut(e) {
155
+ return e.replace(/[._-]+/g, " ").replace(/\s+/g, " ").trim().replace(/\b\w/g, (e) => e.toUpperCase());
156
+ }
157
+ function Wt(e) {
158
+ if (!e || !Array.isArray(e.items) || e.items.length === 0) return;
159
+ let t = e.items.find((e) => e.type === "app");
160
+ if (t) return {
161
+ phase: "done",
162
+ appLabel: Ut(t.name),
163
+ items: e.items,
164
+ done: e.items.length,
165
+ total: e.items.length
166
+ };
167
+ }
168
+ function Gt(e, t = {}) {
66
169
  return e.filter((e) => e.type === "dynamic-tool" ? !0 : typeof e.type == "string" && e.type.startsWith("tool-")).map((e) => {
67
- let t = e.type === "dynamic-tool" ? e.toolName ?? "tool" : typeof e.type == "string" ? e.type.replace(/^tool-/, "") : "tool", n = e.output ?? e.result, r = Nt(n), i = e.state, a = r && i !== "output-error" ? "approval-requested" : i;
170
+ let n = e.type === "dynamic-tool" ? e.toolName ?? "tool" : typeof e.type == "string" ? e.type.replace(/^tool-/, "") : "tool", r = e.output ?? e.result, i = zt(r), a = Ht(r), o = Vt(r), s = e.state, c = (s === "input-available" || s === "input-streaming") && (r !== void 0 || !t.liveTail) ? "output-available" : s, l = i && c !== "output-error" ? "approval-requested" : c;
68
171
  return {
69
172
  toolCallId: e.toolCallId ?? e.id ?? `${e.type ?? "tool"}-${Math.random().toString(36).slice(2, 8)}`,
70
- toolName: t,
173
+ toolName: n,
71
174
  args: e.input ?? e.args,
72
- result: n,
175
+ result: r,
73
176
  errorText: e.errorText,
74
- state: a,
75
- pendingActionId: r?.pendingActionId
177
+ state: l,
178
+ pendingActionId: i?.pendingActionId,
179
+ draftReview: a,
180
+ proposedPlan: o
76
181
  };
77
182
  });
78
183
  }
79
- function Ft(e) {
184
+ function Kt(e) {
80
185
  let t = e.filter((e) => e.type === "source-url" || e.type === "source").map((e) => ({
81
186
  id: e.id,
82
187
  title: e.title,
@@ -84,26 +189,75 @@ function Ft(e) {
84
189
  })).filter((e) => !!e.url);
85
190
  return t.length > 0 ? t : void 0;
86
191
  }
87
- function It(e, t = {}) {
88
- let n = Array.isArray(e.parts) ? e.parts : [], r = Pt(n), i = Array.isArray(e.toolInvocations) ? e.toolInvocations : [];
192
+ function qt(e) {
193
+ let t = e.filter((e) => e.type === "data-build-progress").pop()?.data;
194
+ if (!t || typeof t != "object") return;
195
+ let n = t, r = Array.isArray(n.items) ? n.items.filter((e) => typeof e?.type == "string" && typeof e?.name == "string").map((e) => ({
196
+ type: e.type,
197
+ name: e.name
198
+ })) : [];
199
+ return {
200
+ phase: n.phase === "data" || n.phase === "done" ? n.phase : "structure",
201
+ ...typeof n.appLabel == "string" ? { appLabel: n.appLabel } : {},
202
+ items: r,
203
+ done: typeof n.done == "number" ? n.done : r.length,
204
+ total: typeof n.total == "number" ? n.total : r.length,
205
+ ...typeof n.seq == "number" ? { seq: n.seq } : {}
206
+ };
207
+ }
208
+ function Jt(e) {
209
+ let t = [];
210
+ for (let n of e) {
211
+ if (n.type !== "data-chart") continue;
212
+ let e = n.data;
213
+ if (!e || typeof e != "object") continue;
214
+ let r = e, i = Array.isArray(r.data) ? r.data : [], a = Array.isArray(r.series) ? r.series.filter((e) => e && typeof e.dataKey == "string").map((e) => ({
215
+ dataKey: e.dataKey,
216
+ ...typeof e.label == "string" ? { label: e.label } : {}
217
+ })) : [];
218
+ a.length !== 0 && t.push({
219
+ ...typeof r.chartType == "string" ? { chartType: r.chartType } : {},
220
+ ...typeof r.title == "string" ? { title: r.title } : {},
221
+ data: i,
222
+ ...typeof r.xAxisKey == "string" ? { xAxisKey: r.xAxisKey } : {},
223
+ series: a
224
+ });
225
+ }
226
+ return t.length > 0 ? t : void 0;
227
+ }
228
+ function Yt(e, t = {}) {
229
+ let n = Array.isArray(e.parts) ? e.parts : [], r = Gt(n, { liveTail: t.streaming }), i = Array.isArray(e.toolInvocations) ? e.toolInvocations : [], a = r.length > 0 ? r : i, o = qt(n) ?? a.map((e) => Wt(e.draftReview)).find((e) => !!e);
89
230
  return {
90
231
  id: e.id ?? `msg-${Math.random().toString(36).slice(2, 8)}`,
91
232
  role: e.role ?? "assistant",
92
- content: jt(e, n),
93
- reasoning: Mt(n),
94
- toolInvocations: r.length > 0 ? r : i,
95
- sources: Ft(n),
233
+ content: It(e, n),
234
+ reasoning: Lt(n),
235
+ toolInvocations: a,
236
+ sources: Kt(n),
237
+ buildProgress: o,
238
+ charts: Jt(n),
96
239
  streaming: t.streaming
97
240
  };
98
241
  }
99
- function Lt(e, t = {}) {
242
+ function Xt(e, t = {}) {
100
243
  if (!Array.isArray(e) || e.length === 0) return [];
101
244
  let n = e.length - 1;
102
- return e.map((e, r) => It(e, { streaming: !!t.isStreaming && r === n && e.role === "assistant" }));
245
+ return e.map((e, r) => Yt(e, { streaming: !!t.isStreaming && r === n && e.role === "assistant" }));
103
246
  }
104
247
  //#endregion
105
248
  //#region src/useObjectChat.ts
106
- function Rt(e) {
249
+ function Zt(e) {
250
+ let t = [...e.messages].reverse().find((e) => e.role === "user");
251
+ return { body: {
252
+ ...e.body ?? {},
253
+ id: e.id,
254
+ messages: e.messages,
255
+ trigger: e.trigger,
256
+ messageId: e.messageId,
257
+ ...t ? { turnId: t.id } : {}
258
+ } };
259
+ }
260
+ function Qt(e) {
107
261
  return (e ?? []).map((e, t) => ({
108
262
  id: e.id || `msg-${t}`,
109
263
  role: e.role || "user",
@@ -114,17 +268,41 @@ function Rt(e) {
114
268
  toolInvocations: e.toolInvocations
115
269
  }));
116
270
  }
117
- function J(e = {}) {
118
- let { api: t, initialMessages: n, conversationId: r, systemPrompt: i, model: a, streamingEnabled: s = !0, headers: f, body: p, maxToolRoundtrips: m = 5, onError: h, showTimestamp: g, autoResponse: _, autoResponseText: v, autoResponseDelay: y = 1e3, onSend: b } = e, x = u(t ? "api" : "local").current === "api", S = l(() => Rt(n).map((e) => ({
119
- id: e.id,
120
- role: e.role,
121
- parts: [{
271
+ function $t(e = {}) {
272
+ let { api: t, initialMessages: n, conversationId: r, systemPrompt: i, model: a, streamingEnabled: s = !0, headers: f, body: p, maxToolRoundtrips: m = 5, onError: h, showTimestamp: g, autoResponse: _, autoResponseText: v, autoResponseDelay: y = 1e3, onSend: b } = e, x = u(t ? "api" : "local").current === "api", S = l(() => (n ?? []).map((e, t) => {
273
+ if (Array.isArray(e.parts) && e.parts.length > 0) return {
274
+ id: e.id || `msg-${t}`,
275
+ role: e.role || "user",
276
+ parts: e.parts
277
+ };
278
+ let n = Qt([e])[0], r = [];
279
+ n.content && r.push({
122
280
  type: "text",
123
- text: e.content ?? ""
124
- }]
125
- })), []), C = mt({
281
+ text: n.content
282
+ }), e.reasoning && r.push({
283
+ type: "reasoning",
284
+ text: e.reasoning
285
+ });
286
+ for (let e of n.toolInvocations ?? []) r.push({
287
+ type: `tool-${e.toolName}`,
288
+ toolCallId: e.toolCallId,
289
+ toolName: e.toolName,
290
+ input: e.args,
291
+ output: e.result,
292
+ errorText: e.errorText,
293
+ state: e.state
294
+ });
295
+ return {
296
+ id: n.id || `msg-${t}`,
297
+ role: n.role,
298
+ parts: r.length > 0 ? r : [{
299
+ type: "text",
300
+ text: ""
301
+ }]
302
+ };
303
+ }), []), C = vt({
126
304
  transport: l(() => {
127
- if (x) return new ht({
305
+ if (x) return new yt({
128
306
  api: t,
129
307
  headers: { ...f },
130
308
  body: {
@@ -133,7 +311,14 @@ function J(e = {}) {
133
311
  ...a ? { model: a } : {},
134
312
  ...i ? { systemPrompt: i } : {},
135
313
  ...s === void 0 ? {} : { stream: s }
136
- }
314
+ },
315
+ prepareSendMessagesRequest: ({ id: e, body: t, messages: n, trigger: r, messageId: i }) => Zt({
316
+ id: e,
317
+ body: t,
318
+ messages: n,
319
+ trigger: r,
320
+ messageId: i
321
+ })
137
322
  });
138
323
  }, [
139
324
  x,
@@ -149,11 +334,11 @@ function J(e = {}) {
149
334
  onError: x ? (e) => {
150
335
  h?.(e);
151
336
  } : void 0
152
- }), [w, T] = d(() => Rt(n)), [E, D] = d(!1), [O, k] = d(""), [A, j] = d(""), M = u(null);
337
+ }), [w, T] = d(() => Qt(n)), [E, D] = d(!1), [O, k] = d(""), [A, j] = d(""), M = u(null);
153
338
  if (c(() => () => {
154
339
  M.current &&= (clearTimeout(M.current), null);
155
340
  }, []), x) {
156
- let { messages: e, status: t, error: n, sendMessage: r, regenerate: i, stop: a, setMessages: s } = C, c = t === "submitted" || t === "streaming", l = Lt(e, { isStreaming: c }).map((t, n) => ({
341
+ let { messages: e, status: t, error: n, sendMessage: r, regenerate: i, stop: a, setMessages: s } = C, c = t === "submitted" || t === "streaming", l = Xt(e, { isStreaming: c }).map((t, n) => ({
157
342
  ...t,
158
343
  metadata: e[n]?.metadata
159
344
  }));
@@ -165,7 +350,7 @@ function J(e = {}) {
165
350
  let t = e.trim();
166
351
  if (!t) return;
167
352
  let n = [...l, {
168
- id: At("msg"),
353
+ id: Ft("msg"),
169
354
  role: "user",
170
355
  content: t
171
356
  }];
@@ -180,6 +365,7 @@ function J(e = {}) {
180
365
  clear: o(() => {
181
366
  s([]);
182
367
  }, [s]),
368
+ setMessages: s,
183
369
  isApiMode: !0,
184
370
  input: A,
185
371
  setInput: j,
@@ -198,7 +384,7 @@ function J(e = {}) {
198
384
  sendMessage: o((e) => {
199
385
  if (!e.trim()) return;
200
386
  let t = {
201
- id: At("msg"),
387
+ id: Ft("msg"),
202
388
  role: "user",
203
389
  content: e.trim(),
204
390
  timestamp: g ? (/* @__PURE__ */ new Date()).toLocaleTimeString() : void 0
@@ -208,7 +394,7 @@ function J(e = {}) {
208
394
  return b?.(e.trim(), r), r;
209
395
  }), k(""), _ && (D(!0), M.current = setTimeout(() => {
210
396
  let e = {
211
- id: At("msg"),
397
+ id: Ft("msg"),
212
398
  role: "assistant",
213
399
  content: v || "Thank you for your message!",
214
400
  timestamp: g ? (/* @__PURE__ */ new Date()).toLocaleTimeString() : void 0
@@ -236,8 +422,42 @@ function J(e = {}) {
236
422
  };
237
423
  }
238
424
  //#endregion
425
+ //#region src/agentAliases.ts
426
+ var en = [["build", "metadata_assistant"], ["ask", "data_chat"]];
427
+ function tn(e) {
428
+ return en.find((t) => t.includes(e)) ?? [e];
429
+ }
430
+ function nn(e) {
431
+ return tn(e)[0];
432
+ }
433
+ function rn(e, t) {
434
+ if (e) {
435
+ if (t.includes(e)) return e;
436
+ for (let n of tn(e)) if (t.includes(n)) return n;
437
+ }
438
+ }
439
+ function an(e) {
440
+ return e != null && en.some((t) => t.includes(e));
441
+ }
442
+ function on(e) {
443
+ return e != null && nn(e) === "build";
444
+ }
445
+ function sn(e) {
446
+ return e != null && nn(e) === "ask";
447
+ }
448
+ //#endregion
239
449
  //#region src/useAgents.ts
240
- function zt(e) {
450
+ var cn = "ask";
451
+ function ln(e, t) {
452
+ if (e.length === 0) return;
453
+ let n = e.map((e) => e.name);
454
+ if (t) {
455
+ let e = rn(t, n);
456
+ if (e) return e;
457
+ }
458
+ return rn("ask", n) || e[0].name;
459
+ }
460
+ function un(e) {
241
461
  return e.filter((e) => typeof e?.name == "string" && e.name.length > 0).map((e) => ({
242
462
  name: e.name,
243
463
  label: e.label || e.name,
@@ -246,7 +466,7 @@ function zt(e) {
246
466
  active: e.active !== !1
247
467
  }));
248
468
  }
249
- function Bt(e = {}) {
469
+ function dn(e = {}) {
250
470
  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);
251
471
  return _.current = n, c(() => {
252
472
  if (!r || !t) return;
@@ -266,7 +486,7 @@ function Bt(e = {}) {
266
486
  return e.json();
267
487
  }).then((e) => {
268
488
  if (n) return;
269
- let t = zt(Array.isArray(e) ? e : e?.agents ?? []);
489
+ let t = un(Array.isArray(e) ? e : e?.agents ?? []);
270
490
  s(t.length > 0 ? t : i);
271
491
  }).catch((e) => {
272
492
  n || e.name === "AbortError" || (m(e), s(i));
@@ -288,8 +508,8 @@ function Bt(e = {}) {
288
508
  }
289
509
  //#endregion
290
510
  //#region src/FloatingChatbotProvider.tsx
291
- var Vt = e.createContext(null);
292
- function Ht({ defaultOpen: t = !1, children: n }) {
511
+ var fn = e.createContext(null);
512
+ function pn({ defaultOpen: t = !1, children: n }) {
293
513
  let [r, i] = e.useState(t), [a, o] = e.useState(!1), s = e.useMemo(() => ({
294
514
  isOpen: r,
295
515
  isFullscreen: a,
@@ -300,21 +520,21 @@ function Ht({ defaultOpen: t = !1, children: n }) {
300
520
  toggle: () => i((e) => !e),
301
521
  toggleFullscreen: () => o((e) => !e)
302
522
  }), [r, a]);
303
- return /* @__PURE__ */ K(Vt.Provider, {
523
+ return /* @__PURE__ */ Q(fn.Provider, {
304
524
  value: s,
305
525
  children: n
306
526
  });
307
527
  }
308
- function Ut() {
309
- let t = e.useContext(Vt);
528
+ function mn() {
529
+ let t = e.useContext(fn);
310
530
  if (!t) throw Error("useFloatingChatbot must be used within a <FloatingChatbotProvider>");
311
531
  return t;
312
532
  }
313
533
  //#endregion
314
534
  //#region src/FloatingChatbotTrigger.tsx
315
- function Wt() {
535
+ function hn() {
316
536
  try {
317
- let { t: e } = _t();
537
+ let { t: e } = St();
318
538
  return (t, n) => {
319
539
  let r = e(`common.${t}`);
320
540
  return !r || r === `common.${t}` ? n : r;
@@ -323,87 +543,133 @@ function Wt() {
323
543
  return (e, t) => t;
324
544
  }
325
545
  }
326
- function Gt({ position: e = "bottom-right", size: t = 56, className: n }) {
327
- let { isOpen: r, toggle: i } = Ut(), a = Wt();
328
- return /* @__PURE__ */ K(v, {
546
+ var gn = {
547
+ 32: "size-8",
548
+ 36: "size-9",
549
+ 40: "size-10",
550
+ 44: "size-11",
551
+ 48: "size-12",
552
+ 52: "size-[52px]",
553
+ 56: "size-14",
554
+ 60: "size-[60px]",
555
+ 64: "size-16",
556
+ 72: "size-[72px]",
557
+ 80: "size-20"
558
+ };
559
+ function _n(e, t) {
560
+ return t.reduce((t, n) => Math.abs(n - e) < Math.abs(t - e) ? n : t);
561
+ }
562
+ function vn(e) {
563
+ return gn[e] ?? gn[_n(e, Object.keys(gn).map(Number))];
564
+ }
565
+ function yn({ position: e = "bottom-right", size: t = 56, className: n }) {
566
+ let { isOpen: r, toggle: i } = mn(), a = hn();
567
+ return /* @__PURE__ */ Q(v, {
329
568
  onClick: i,
330
- className: H("fixed z-50 rounded-full shadow-lg transition-transform hover:scale-105", e === "bottom-right" ? "right-6 bottom-20 sm:bottom-6" : "left-6 bottom-20 sm:bottom-6", n),
331
- style: {
332
- width: t,
333
- height: t
334
- },
569
+ className: J("fixed z-50 rounded-full shadow-lg transition-transform hover:scale-105", vn(t), r && "hidden", e === "bottom-right" ? "right-6 bottom-20 sm:bottom-6" : "left-6 bottom-20 sm:bottom-6", n),
335
570
  size: "icon",
336
571
  "aria-label": r ? a("closeChat", "Close chat") : a("openChat", "Open chat"),
337
572
  "data-testid": "floating-chatbot-trigger",
338
- children: K(r ? ft : Le, { className: "h-6 w-6" })
573
+ children: Q(r ? ht : Me, { className: "h-6 w-6" })
339
574
  });
340
575
  }
341
576
  //#endregion
342
577
  //#region src/FloatingChatbotPanel.tsx
343
- function Kt({ title: e = "Chat", position: t = "bottom-right", width: n = 400, height: r = 520, children: i, className: a, headerExtra: o, headerActions: s }) {
344
- let { isOpen: c, isFullscreen: l, close: u, toggleFullscreen: d } = Ut();
345
- if (!c) return null;
346
- let f = l ? {
347
- inset: 0,
348
- width: "100vw",
349
- height: "100vh"
350
- } : {
351
- width: n,
352
- height: r,
353
- maxHeight: "calc(100vh - 100px)"
354
- };
355
- return /* @__PURE__ */ q("div", {
356
- className: H("fixed z-50 flex flex-col rounded-lg border bg-background shadow-xl overflow-hidden transition-all", l ? "inset-0 rounded-none" : t === "bottom-right" ? "right-6 bottom-20" : "left-6 bottom-20", a),
357
- style: f,
578
+ var bn = {
579
+ 300: "sm:w-[300px]",
580
+ 320: "sm:w-[320px]",
581
+ 340: "sm:w-[340px]",
582
+ 360: "sm:w-[360px]",
583
+ 380: "sm:w-[380px]",
584
+ 400: "sm:w-[400px]",
585
+ 420: "sm:w-[420px]",
586
+ 440: "sm:w-[440px]",
587
+ 450: "sm:w-[450px]",
588
+ 460: "sm:w-[460px]",
589
+ 480: "sm:w-[480px]",
590
+ 500: "sm:w-[500px]",
591
+ 520: "sm:w-[520px]",
592
+ 560: "sm:w-[560px]",
593
+ 600: "sm:w-[600px]",
594
+ 640: "sm:w-[640px]",
595
+ 720: "sm:w-[720px]",
596
+ 800: "sm:w-[800px]"
597
+ }, xn = {
598
+ 360: "h-[min(360px,calc(100svh_-_6rem_-_env(safe-area-inset-bottom)))] sm:h-[360px]",
599
+ 400: "h-[min(400px,calc(100svh_-_6rem_-_env(safe-area-inset-bottom)))] sm:h-[400px]",
600
+ 420: "h-[min(420px,calc(100svh_-_6rem_-_env(safe-area-inset-bottom)))] sm:h-[420px]",
601
+ 440: "h-[min(440px,calc(100svh_-_6rem_-_env(safe-area-inset-bottom)))] sm:h-[440px]",
602
+ 480: "h-[min(480px,calc(100svh_-_6rem_-_env(safe-area-inset-bottom)))] sm:h-[480px]",
603
+ 500: "h-[min(500px,calc(100svh_-_6rem_-_env(safe-area-inset-bottom)))] sm:h-[500px]",
604
+ 520: "h-[min(520px,calc(100svh_-_6rem_-_env(safe-area-inset-bottom)))] sm:h-[520px]",
605
+ 560: "h-[min(560px,calc(100svh_-_6rem_-_env(safe-area-inset-bottom)))] sm:h-[560px]",
606
+ 600: "h-[min(600px,calc(100svh_-_6rem_-_env(safe-area-inset-bottom)))] sm:h-[600px]",
607
+ 640: "h-[min(640px,calc(100svh_-_6rem_-_env(safe-area-inset-bottom)))] sm:h-[640px]",
608
+ 720: "h-[min(720px,calc(100svh_-_6rem_-_env(safe-area-inset-bottom)))] sm:h-[720px]",
609
+ 800: "h-[min(800px,calc(100svh_-_6rem_-_env(safe-area-inset-bottom)))] sm:h-[800px]"
610
+ };
611
+ function Sn(e, t) {
612
+ return t.reduce((t, n) => Math.abs(n - e) < Math.abs(t - e) ? n : t);
613
+ }
614
+ function Cn(e) {
615
+ return bn[e] ?? bn[Sn(e, Object.keys(bn).map(Number))];
616
+ }
617
+ function wn(e) {
618
+ return xn[e] ?? xn[Sn(e, Object.keys(xn).map(Number))];
619
+ }
620
+ function Tn({ title: e = "Chat", position: t = "bottom-right", width: n = 400, height: r = 520, children: i, className: a, headerExtra: o, headerActions: s }) {
621
+ let { isOpen: c, isFullscreen: l, close: u, toggleFullscreen: d } = mn();
622
+ return c ? /* @__PURE__ */ $("div", {
623
+ className: J("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" ? J("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)]", Cn(n), wn(r)) : J("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)]", Cn(n), wn(r)), a),
358
624
  role: "dialog",
359
625
  "aria-label": e,
360
626
  "data-testid": "floating-chatbot-panel",
361
- children: [/* @__PURE__ */ q("div", {
362
- className: "flex items-center justify-between gap-2 px-4 py-2 border-b bg-muted/40",
627
+ children: [/* @__PURE__ */ $("div", {
628
+ className: "flex min-h-10 items-center justify-between gap-2 border-b bg-muted/40 px-4 py-2",
363
629
  children: [
364
- /* @__PURE__ */ K("span", {
365
- className: "text-sm font-medium truncate shrink-0",
630
+ /* @__PURE__ */ Q("span", {
631
+ className: "min-w-0 flex-1 truncate text-sm font-medium",
366
632
  children: e
367
633
  }),
368
- o ? /* @__PURE__ */ K("div", {
369
- className: "flex-1 min-w-0 flex items-center justify-end mr-1",
634
+ o ? /* @__PURE__ */ Q("div", {
635
+ className: "mr-1 flex min-w-0 items-center justify-end",
370
636
  "data-testid": "floating-chatbot-header-extra",
371
637
  children: o
372
638
  }) : null,
373
- /* @__PURE__ */ q("div", {
639
+ /* @__PURE__ */ $("div", {
374
640
  className: "flex items-center gap-1 shrink-0",
375
641
  children: [
376
642
  s,
377
- /* @__PURE__ */ K(v, {
643
+ /* @__PURE__ */ Q(v, {
378
644
  variant: "ghost",
379
645
  size: "icon",
380
646
  className: "h-7 w-7",
381
647
  onClick: d,
382
648
  "aria-label": l ? "Exit fullscreen" : "Fullscreen",
383
649
  "data-testid": "floating-chatbot-fullscreen",
384
- children: K(l ? at : rt, { className: "h-4 w-4" })
650
+ children: Q(l ? it : nt, { className: "h-4 w-4" })
385
651
  }),
386
- /* @__PURE__ */ K(v, {
652
+ /* @__PURE__ */ Q(v, {
387
653
  variant: "ghost",
388
654
  size: "icon",
389
655
  className: "h-7 w-7",
390
656
  onClick: u,
391
657
  "aria-label": "Close chat",
392
658
  "data-testid": "floating-chatbot-close",
393
- children: /* @__PURE__ */ K(ft, { className: "h-4 w-4" })
659
+ children: /* @__PURE__ */ Q(ht, { className: "h-4 w-4" })
394
660
  })
395
661
  ]
396
662
  })
397
663
  ]
398
- }), /* @__PURE__ */ K("div", {
399
- className: "flex-1 overflow-hidden",
664
+ }), /* @__PURE__ */ Q("div", {
665
+ className: "min-h-0 flex-1 overflow-hidden",
400
666
  children: i
401
667
  })]
402
- });
668
+ }) : null;
403
669
  }
404
670
  //#endregion
405
671
  //#region src/tool-display.ts
406
- var qt = {
672
+ var En = {
407
673
  ai: "AI",
408
674
  api: "API",
409
675
  crm: "CRM",
@@ -415,17 +681,17 @@ var qt = {
415
681
  url: "URL",
416
682
  utc: "UTC"
417
683
  };
418
- function Jt(e) {
684
+ function Dn(e) {
419
685
  if (!e) return "";
420
686
  let t = String(e).trim();
421
687
  if (!t) return "";
422
688
  let n = t.replace(/[_-]+/g, " ").replace(/([a-z])([A-Z])/g, "$1 $2").split(/\s+/).filter(Boolean);
423
689
  return n.length === 0 ? t : n.map((e, t) => {
424
690
  let n = e.toLowerCase();
425
- return qt[n] ? qt[n] : t === 0 ? n.charAt(0).toUpperCase() + n.slice(1) : n;
691
+ return En[n] ? En[n] : t === 0 ? n.charAt(0).toUpperCase() + n.slice(1) : n;
426
692
  }).join(" ");
427
693
  }
428
- function Yt(e) {
694
+ function On(e) {
429
695
  if (e == null) return e;
430
696
  let t = e;
431
697
  for (let e = 0; e < 2; e++) {
@@ -443,110 +709,134 @@ function Yt(e) {
443
709
  }
444
710
  return t;
445
711
  }
446
- function Xt(e) {
712
+ function kn(e) {
447
713
  let t = (e instanceof Error ? e.message : String(e ?? "")).replace(/\s+/g, " ").trim();
448
714
  if (!t) return { summary: "Something went wrong. Please try again." };
449
- let n = t.replace(/^Failed after \d+ attempts?\.\s*Last error:\s*/i, ""), r = n.match(/^([^.;:]+[.;:!?])\s/)?.[1]?.trim() ?? (n.length > 140 ? `${n.slice(0, 137).trimEnd()}…` : n);
715
+ 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);
450
716
  return {
451
- summary: r,
452
- details: n.length > r.length ? n : void 0
717
+ summary: i.replace(/:$/, ""),
718
+ details: n.length > i.length ? n : void 0
719
+ };
720
+ }
721
+ var An = new Set([
722
+ "ai_design_quota_exhausted",
723
+ "ai_data_chat_trial_exhausted",
724
+ "ai_allowance_exhausted"
725
+ ]);
726
+ function jn(e) {
727
+ let t = e instanceof Error ? e.message : String(e ?? "");
728
+ if (!t) return null;
729
+ 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("}");
730
+ if (r < 0 || i <= r) return null;
731
+ let a;
732
+ try {
733
+ a = JSON.parse(n.slice(r, i + 1));
734
+ } catch {
735
+ return null;
736
+ }
737
+ return !a || typeof a.error != "string" || !An.has(a.error) ? null : {
738
+ code: a.error,
739
+ message: typeof a.message == "string" ? a.message : "",
740
+ messageEn: typeof a.messageEn == "string" ? a.messageEn : void 0,
741
+ upgrade: a.upgrade === !0,
742
+ topUp: a.topUp === !0
453
743
  };
454
744
  }
455
745
  //#endregion
456
746
  //#region src/elements/conversation.tsx
457
- var Zt = ({ className: e, ...t }) => /* @__PURE__ */ K(vt, {
458
- className: H("relative flex-1 overflow-y-hidden", e),
747
+ var Mn = ({ className: e, ...t }) => /* @__PURE__ */ Q(Ct, {
748
+ className: J("relative flex-1 overflow-y-hidden", e),
459
749
  initial: "smooth",
460
750
  resize: "smooth",
461
751
  role: "log",
462
752
  ...t
463
- }), Qt = ({ className: e, ...t }) => /* @__PURE__ */ K(vt.Content, {
464
- className: H("flex flex-col gap-8 p-4", e),
753
+ }), Nn = ({ className: e, ...t }) => /* @__PURE__ */ Q(Ct.Content, {
754
+ className: J("flex flex-col gap-8 p-4", e),
465
755
  ...t
466
- }), $t = ({ className: e, title: t = "No messages yet", description: n = "Start a conversation to see messages here", icon: r, children: i, ...a }) => /* @__PURE__ */ K("div", {
467
- className: H("flex size-full flex-col items-center justify-center gap-3 p-8 text-center", e),
756
+ }), Pn = ({ className: e, title: t = "No messages yet", description: n = "Start a conversation to see messages here", icon: r, children: i, ...a }) => /* @__PURE__ */ Q("div", {
757
+ className: J("flex size-full flex-col items-center justify-center gap-3 p-8 text-center", e),
468
758
  ...a,
469
- children: i ?? /* @__PURE__ */ q(G, { children: [r && /* @__PURE__ */ K("div", {
759
+ children: i ?? /* @__PURE__ */ $(Z, { children: [r && /* @__PURE__ */ Q("div", {
470
760
  className: "text-muted-foreground",
471
761
  children: r
472
- }), /* @__PURE__ */ q("div", {
762
+ }), /* @__PURE__ */ $("div", {
473
763
  className: "space-y-1",
474
- children: [/* @__PURE__ */ K("h3", {
764
+ children: [/* @__PURE__ */ Q("h3", {
475
765
  className: "font-medium text-sm",
476
766
  children: t
477
- }), n && /* @__PURE__ */ K("p", {
767
+ }), n && /* @__PURE__ */ Q("p", {
478
768
  className: "text-muted-foreground text-sm",
479
769
  children: n
480
770
  })]
481
771
  })] })
482
- }), en = ({ className: e, ...t }) => {
483
- let { isAtBottom: n, scrollToBottom: r } = yt(), i = o(() => {
772
+ }), Fn = ({ className: e, ...t }) => {
773
+ let { isAtBottom: n, scrollToBottom: r } = wt(), i = o(() => {
484
774
  r();
485
775
  }, [r]);
486
- return !n && /* @__PURE__ */ K(v, {
487
- className: H("absolute bottom-4 left-[50%] translate-x-[-50%] rounded-full", e),
776
+ return !n && /* @__PURE__ */ Q(v, {
777
+ className: J("absolute bottom-4 left-[50%] translate-x-[-50%] rounded-full", e),
488
778
  onClick: i,
489
779
  size: "icon",
490
780
  type: "button",
491
781
  variant: "outline",
492
782
  ...t,
493
- children: /* @__PURE__ */ K(Fe, { className: "size-4" })
783
+ children: /* @__PURE__ */ Q(ke, { className: "size-4" })
494
784
  });
495
- }, tn = bt("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", {
785
+ }, In = Tt("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", {
496
786
  variants: { orientation: {
497
787
  horizontal: "[&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none",
498
788
  vertical: "flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none"
499
789
  } },
500
790
  defaultVariants: { orientation: "horizontal" }
501
791
  });
502
- function nn({ className: e, orientation: t, ...n }) {
503
- return /* @__PURE__ */ K("div", {
792
+ function Ln({ className: e, orientation: t, ...n }) {
793
+ return /* @__PURE__ */ Q("div", {
504
794
  role: "group",
505
795
  "data-slot": "button-group",
506
796
  "data-orientation": t,
507
- className: H(tn({ orientation: t }), e),
797
+ className: J(In({ orientation: t }), e),
508
798
  ...n
509
799
  });
510
800
  }
511
- function rn({ className: e, asChild: t = !1, ...n }) {
512
- return /* @__PURE__ */ K(t ? xt : "div", {
513
- className: H("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),
801
+ function Rn({ className: e, asChild: t = !1, ...n }) {
802
+ return /* @__PURE__ */ Q(t ? Et : "div", {
803
+ className: J("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),
514
804
  ...n
515
805
  });
516
806
  }
517
807
  //#endregion
518
808
  //#region src/elements/message.tsx
519
- var an = ({ className: e, from: t, ...n }) => /* @__PURE__ */ K("div", {
520
- className: H("group flex w-full max-w-[95%] flex-col gap-2", t === "user" ? "is-user ml-auto justify-end" : "is-assistant", e),
809
+ var zn = ({ className: e, from: t, ...n }) => /* @__PURE__ */ Q("div", {
810
+ className: J("group flex w-full max-w-[95%] flex-col gap-2", t === "user" ? "is-user ml-auto justify-end" : "is-assistant", e),
521
811
  ...n
522
- }), on = ({ children: e, className: t, ...n }) => /* @__PURE__ */ K("div", {
523
- className: H("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),
812
+ }), Bn = ({ children: e, className: t, ...n }) => /* @__PURE__ */ Q("div", {
813
+ className: J("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),
524
814
  ...n,
525
815
  children: e
526
- }), sn = ({ className: e, children: t, ...n }) => /* @__PURE__ */ K("div", {
527
- className: H("flex items-center gap-1", e),
816
+ }), Vn = ({ className: e, children: t, ...n }) => /* @__PURE__ */ Q("div", {
817
+ className: J("flex items-center gap-1", e),
528
818
  ...n,
529
819
  children: t
530
- }), cn = ({ tooltip: e, children: t, label: n, variant: r = "ghost", size: i = "icon", ...a }) => {
531
- let o = /* @__PURE__ */ q(v, {
820
+ }), Hn = ({ tooltip: e, children: t, label: n, variant: r = "ghost", size: i = "icon", ...a }) => {
821
+ let o = /* @__PURE__ */ $(v, {
532
822
  size: i,
533
823
  type: "button",
534
824
  variant: r,
535
825
  ...a,
536
- children: [t, /* @__PURE__ */ K("span", {
826
+ children: [t, /* @__PURE__ */ Q("span", {
537
827
  className: "sr-only",
538
828
  children: n || e
539
829
  })]
540
830
  });
541
- return e ? /* @__PURE__ */ K(Me, { children: /* @__PURE__ */ q(Ae, { children: [/* @__PURE__ */ K(Ne, {
831
+ return e ? /* @__PURE__ */ Q(Ee, { children: /* @__PURE__ */ $(we, { children: [/* @__PURE__ */ Q(De, {
542
832
  asChild: !0,
543
833
  children: o
544
- }), /* @__PURE__ */ K(je, { children: /* @__PURE__ */ K("p", { children: e }) })] }) }) : o;
545
- }, ln = r(null), Y = () => {
546
- let e = s(ln);
834
+ }), /* @__PURE__ */ Q(Te, { children: /* @__PURE__ */ Q("p", { children: e }) })] }) }) : o;
835
+ }, Un = r(null), Wn = () => {
836
+ let e = s(Un);
547
837
  if (!e) throw Error("MessageBranch components must be used within MessageBranch");
548
838
  return e;
549
- }, un = ({ defaultBranch: e = 0, onBranchChange: t, className: n, ...r }) => {
839
+ }, Gn = ({ defaultBranch: e = 0, onBranchChange: t, className: n, ...r }) => {
550
840
  let [i, a] = d(e), [o, s] = d([]), c = (e) => {
551
841
  a(e), t?.(e);
552
842
  }, l = {
@@ -561,36 +851,36 @@ var an = ({ className: e, from: t, ...n }) => /* @__PURE__ */ K("div", {
561
851
  branches: o,
562
852
  setBranches: s
563
853
  };
564
- return /* @__PURE__ */ K(ln.Provider, {
854
+ return /* @__PURE__ */ Q(Un.Provider, {
565
855
  value: l,
566
- children: /* @__PURE__ */ K("div", {
567
- className: H("grid w-full gap-2 [&>div]:pb-0", n),
856
+ children: /* @__PURE__ */ Q("div", {
857
+ className: J("grid w-full gap-2 [&>div]:pb-0", n),
568
858
  ...r
569
859
  })
570
860
  });
571
- }, dn = ({ children: e, ...t }) => {
572
- let { currentBranch: n, setBranches: r, branches: i } = Y(), a = Array.isArray(e) ? e : [e];
861
+ }, Kn = ({ children: e, ...t }) => {
862
+ let { currentBranch: n, setBranches: r, branches: i } = Wn(), a = Array.isArray(e) ? e : [e];
573
863
  return c(() => {
574
864
  i.length !== a.length && r(a);
575
865
  }, [
576
866
  a,
577
867
  i,
578
868
  r
579
- ]), a.map((e, r) => /* @__PURE__ */ K("div", {
580
- className: H("grid gap-2 overflow-hidden [&>div]:pb-0", r === n ? "block" : "hidden"),
869
+ ]), a.map((e, r) => /* @__PURE__ */ Q("div", {
870
+ className: J("grid gap-2 overflow-hidden [&>div]:pb-0", r === n ? "block" : "hidden"),
581
871
  ...t,
582
872
  children: e
583
873
  }, e.key));
584
- }, fn = ({ className: e, from: t, ...n }) => {
585
- let { totalBranches: r } = Y();
586
- return r <= 1 ? null : /* @__PURE__ */ K(nn, {
874
+ }, qn = ({ className: e, from: t, ...n }) => {
875
+ let { totalBranches: r } = Wn();
876
+ return r <= 1 ? null : /* @__PURE__ */ Q(Ln, {
587
877
  className: "[&>*:not(:first-child)]:rounded-l-md [&>*:not(:last-child)]:rounded-r-md",
588
878
  orientation: "horizontal",
589
879
  ...n
590
880
  });
591
- }, pn = ({ children: e, ...t }) => {
592
- let { goToPrevious: n, totalBranches: r } = Y();
593
- return /* @__PURE__ */ K(v, {
881
+ }, Jn = ({ children: e, ...t }) => {
882
+ let { goToPrevious: n, totalBranches: r } = Wn();
883
+ return /* @__PURE__ */ Q(v, {
594
884
  "aria-label": "Previous branch",
595
885
  disabled: r <= 1,
596
886
  onClick: n,
@@ -598,11 +888,11 @@ var an = ({ className: e, from: t, ...n }) => /* @__PURE__ */ K("div", {
598
888
  type: "button",
599
889
  variant: "ghost",
600
890
  ...t,
601
- children: e ?? /* @__PURE__ */ K(We, { size: 14 })
891
+ children: e ?? /* @__PURE__ */ Q(Re, { size: 14 })
602
892
  });
603
- }, mn = ({ children: e, className: t, ...n }) => {
604
- let { goToNext: r, totalBranches: i } = Y();
605
- return /* @__PURE__ */ K(v, {
893
+ }, Yn = ({ children: e, className: t, ...n }) => {
894
+ let { goToNext: r, totalBranches: i } = Wn();
895
+ return /* @__PURE__ */ Q(v, {
606
896
  "aria-label": "Next branch",
607
897
  disabled: i <= 1,
608
898
  onClick: r,
@@ -610,12 +900,12 @@ var an = ({ className: e, from: t, ...n }) => /* @__PURE__ */ K("div", {
610
900
  type: "button",
611
901
  variant: "ghost",
612
902
  ...n,
613
- children: e ?? /* @__PURE__ */ K(Ge, { size: 14 })
903
+ children: e ?? /* @__PURE__ */ Q(ze, { size: 14 })
614
904
  });
615
- }, hn = ({ className: e, ...t }) => {
616
- let { currentBranch: n, totalBranches: r } = Y();
617
- return /* @__PURE__ */ q(rn, {
618
- className: H("border-none bg-transparent text-muted-foreground shadow-none", e),
905
+ }, Xn = ({ className: e, ...t }) => {
906
+ let { currentBranch: n, totalBranches: r } = Wn();
907
+ return /* @__PURE__ */ $(Rn, {
908
+ className: J("border-none bg-transparent text-muted-foreground shadow-none", e),
619
909
  ...t,
620
910
  children: [
621
911
  n + 1,
@@ -623,23 +913,23 @@ var an = ({ className: e, from: t, ...n }) => /* @__PURE__ */ K("div", {
623
913
  r
624
914
  ]
625
915
  });
626
- }, X = a(({ className: e, ...t }) => /* @__PURE__ */ K(St, {
627
- className: H("size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0", e),
916
+ }, Zn = a(({ className: e, ...t }) => /* @__PURE__ */ Q(Dt, {
917
+ className: J("size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0", e),
628
918
  ...t
629
919
  }), (e, t) => e.children === t.children);
630
- X.displayName = "MessageResponse";
631
- function gn({ data: e, className: t, onRemove: n, ...r }) {
920
+ Zn.displayName = "MessageResponse";
921
+ function Qn({ data: e, className: t, onRemove: n, ...r }) {
632
922
  let i = e.filename || "", a = (e.mediaType?.startsWith("image/") && e.url ? "image" : "file") == "image", o = i || (a ? "Image" : "Attachment");
633
- return /* @__PURE__ */ K("div", {
634
- className: H("group relative size-24 overflow-hidden rounded-lg", t),
923
+ return /* @__PURE__ */ Q("div", {
924
+ className: J("group relative size-24 overflow-hidden rounded-lg", t),
635
925
  ...r,
636
- children: a ? /* @__PURE__ */ q(G, { children: [/* @__PURE__ */ K("img", {
926
+ children: a ? /* @__PURE__ */ $(Z, { children: [/* @__PURE__ */ Q("img", {
637
927
  alt: i || "attachment",
638
928
  className: "size-full object-cover",
639
929
  height: 100,
640
930
  src: e.url,
641
931
  width: 100
642
- }), n && /* @__PURE__ */ q(v, {
932
+ }), n && /* @__PURE__ */ $(v, {
643
933
  "aria-label": "Remove attachment",
644
934
  className: "absolute top-2 right-2 size-6 rounded-full bg-background/80 p-0 opacity-0 backdrop-blur-sm transition-opacity hover:bg-background group-hover:opacity-100 [&>svg]:size-3",
645
935
  onClick: (e) => {
@@ -647,17 +937,17 @@ function gn({ data: e, className: t, onRemove: n, ...r }) {
647
937
  },
648
938
  type: "button",
649
939
  variant: "ghost",
650
- children: [/* @__PURE__ */ K(W, {}), /* @__PURE__ */ K("span", {
940
+ children: [/* @__PURE__ */ Q(_t, {}), /* @__PURE__ */ Q("span", {
651
941
  className: "sr-only",
652
942
  children: "Remove"
653
943
  })]
654
- })] }) : /* @__PURE__ */ q(G, { children: [/* @__PURE__ */ q(Ae, { children: [/* @__PURE__ */ K(Ne, {
944
+ })] }) : /* @__PURE__ */ $(Z, { children: [/* @__PURE__ */ $(we, { children: [/* @__PURE__ */ Q(De, {
655
945
  asChild: !0,
656
- children: /* @__PURE__ */ K("div", {
946
+ children: /* @__PURE__ */ Q("div", {
657
947
  className: "flex size-full shrink-0 items-center justify-center rounded-lg bg-muted text-muted-foreground",
658
- children: /* @__PURE__ */ K(ot, { className: "size-4" })
948
+ children: /* @__PURE__ */ Q(at, { className: "size-4" })
659
949
  })
660
- }), /* @__PURE__ */ K(je, { children: /* @__PURE__ */ K("p", { children: o }) })] }), n && /* @__PURE__ */ q(v, {
950
+ }), /* @__PURE__ */ Q(Te, { children: /* @__PURE__ */ Q("p", { children: o }) })] }), n && /* @__PURE__ */ $(v, {
661
951
  "aria-label": "Remove attachment",
662
952
  className: "size-6 shrink-0 rounded-full p-0 opacity-0 transition-opacity hover:bg-accent group-hover:opacity-100 [&>svg]:size-3",
663
953
  onClick: (e) => {
@@ -665,36 +955,36 @@ function gn({ data: e, className: t, onRemove: n, ...r }) {
665
955
  },
666
956
  type: "button",
667
957
  variant: "ghost",
668
- children: [/* @__PURE__ */ K(W, {}), /* @__PURE__ */ K("span", {
958
+ children: [/* @__PURE__ */ Q(_t, {}), /* @__PURE__ */ Q("span", {
669
959
  className: "sr-only",
670
960
  children: "Remove"
671
961
  })]
672
962
  })] })
673
963
  });
674
964
  }
675
- function _n({ children: e, className: t, ...n }) {
676
- return e ? /* @__PURE__ */ K("div", {
677
- className: H("ml-auto flex w-fit flex-wrap items-start gap-2", t),
965
+ function $n({ children: e, className: t, ...n }) {
966
+ return e ? /* @__PURE__ */ Q("div", {
967
+ className: J("ml-auto flex w-fit flex-wrap items-start gap-2", t),
678
968
  ...n,
679
969
  children: e
680
970
  }) : null;
681
971
  }
682
- var vn = ({ className: e, children: t, ...n }) => /* @__PURE__ */ K("div", {
683
- className: H("mt-4 flex w-full items-center justify-between gap-4", e),
972
+ var er = ({ className: e, children: t, ...n }) => /* @__PURE__ */ Q("div", {
973
+ className: J("mt-4 flex w-full items-center justify-between gap-4", e),
684
974
  ...n,
685
975
  children: t
686
976
  });
687
977
  //#endregion
688
978
  //#region src/elements/ui/input-group.tsx
689
- function yn({ className: e, ...t }) {
690
- return /* @__PURE__ */ K("div", {
979
+ function tr({ className: e, ...t }) {
980
+ return /* @__PURE__ */ Q("div", {
691
981
  "data-slot": "input-group",
692
982
  role: "group",
693
- className: H("group/input-group relative flex w-full items-center rounded-md border border-input shadow-xs transition-[color,box-shadow] outline-none dark:bg-input/30", "h-9 min-w-0 has-[>textarea]:h-auto", "has-[>[data-align=inline-start]]:[&>input]:pl-2", "has-[>[data-align=inline-end]]:[&>input]:pr-2", "has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>[data-align=block-start]]:[&>input]:pb-3", "has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-end]]:[&>input]:pt-3", "has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-[3px] has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50", "has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-destructive/20 dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40", e),
983
+ className: J("group/input-group relative flex w-full items-center rounded-md border border-input shadow-xs transition-[color,box-shadow] outline-none dark:bg-input/30", "h-9 min-w-0 has-[>textarea]:h-auto", "has-[>[data-align=inline-start]]:[&>input]:pl-2", "has-[>[data-align=inline-end]]:[&>input]:pr-2", "has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>[data-align=block-start]]:[&>input]:pb-3", "has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-end]]:[&>input]:pt-3", "has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-[3px] has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50", "has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-destructive/20 dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40", e),
694
984
  ...t
695
985
  });
696
986
  }
697
- var bn = bt("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", {
987
+ var nr = Tt("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", {
698
988
  variants: { align: {
699
989
  "inline-start": "order-first pl-3 has-[>button]:ml-[-0.45rem] has-[>kbd]:ml-[-0.35rem]",
700
990
  "inline-end": "order-last pr-3 has-[>button]:mr-[-0.45rem] has-[>kbd]:mr-[-0.35rem]",
@@ -703,19 +993,19 @@ var bn = bt("flex h-auto cursor-text items-center justify-center gap-2 py-1.5 te
703
993
  } },
704
994
  defaultVariants: { align: "inline-start" }
705
995
  });
706
- function xn({ className: e, align: t = "inline-start", ...n }) {
707
- return /* @__PURE__ */ K("div", {
996
+ function rr({ className: e, align: t = "inline-start", ...n }) {
997
+ return /* @__PURE__ */ Q("div", {
708
998
  role: "group",
709
999
  "data-slot": "input-group-addon",
710
1000
  "data-align": t,
711
- className: H(bn({ align: t }), e),
1001
+ className: J(nr({ align: t }), e),
712
1002
  onClick: (e) => {
713
1003
  e.target.closest("button") || e.currentTarget.parentElement?.querySelector("input")?.focus();
714
1004
  },
715
1005
  ...n
716
1006
  });
717
1007
  }
718
- var Sn = bt("flex items-center gap-2 text-sm shadow-none", {
1008
+ var ir = Tt("flex items-center gap-2 text-sm shadow-none", {
719
1009
  variants: { size: {
720
1010
  xs: "h-6 gap-1 rounded-[calc(var(--radius)-5px)] px-2 has-[>svg]:px-2 [&>svg:not([class*='size-'])]:size-3.5",
721
1011
  sm: "h-8 gap-1.5 rounded-md px-2.5 has-[>svg]:px-2.5",
@@ -724,38 +1014,38 @@ var Sn = bt("flex items-center gap-2 text-sm shadow-none", {
724
1014
  } },
725
1015
  defaultVariants: { size: "xs" }
726
1016
  });
727
- function Cn({ className: e, type: t = "button", variant: n = "ghost", size: r = "xs", ...i }) {
728
- return /* @__PURE__ */ K(v, {
1017
+ function ar({ className: e, type: t = "button", variant: n = "ghost", size: r = "xs", ...i }) {
1018
+ return /* @__PURE__ */ Q(v, {
729
1019
  type: t,
730
1020
  "data-size": r,
731
1021
  variant: n,
732
- className: H(Sn({ size: r }), e),
1022
+ className: J(ir({ size: r }), e),
733
1023
  ...i
734
1024
  });
735
1025
  }
736
- function wn({ className: e, ...t }) {
737
- return /* @__PURE__ */ K(ke, {
1026
+ function or({ className: e, ...t }) {
1027
+ return /* @__PURE__ */ Q(Ce, {
738
1028
  "data-slot": "input-group-control",
739
- className: H("flex-1 resize-none rounded-none border-0 bg-transparent py-3 shadow-none focus-visible:ring-0 dark:bg-transparent", e),
1029
+ className: J("flex-1 resize-none rounded-none border-0 bg-transparent py-3 shadow-none focus-visible:ring-0 dark:bg-transparent", e),
740
1030
  ...t
741
1031
  });
742
1032
  }
743
1033
  //#endregion
744
1034
  //#region src/elements/prompt-input.tsx
745
- var Tn = r(null), En = r(null), Dn = () => {
746
- let e = s(Tn);
1035
+ var sr = r(null), cr = r(null), lr = () => {
1036
+ let e = s(sr);
747
1037
  if (!e) throw Error("Wrap your component inside <PromptInputProvider> to use usePromptInputController().");
748
1038
  return e;
749
- }, On = () => s(Tn), kn = () => {
750
- let e = s(En);
1039
+ }, ur = () => s(sr), dr = () => {
1040
+ let e = s(cr);
751
1041
  if (!e) throw Error("Wrap your component inside <PromptInputProvider> to use useProviderAttachments().");
752
1042
  return e;
753
- }, An = () => s(En);
754
- function jn({ initialInput: e = "", children: t }) {
1043
+ }, fr = () => s(cr);
1044
+ function pr({ initialInput: e = "", children: t }) {
755
1045
  let [n, r] = d(e), i = o(() => r(""), []), [a, s] = d([]), f = u(null), p = u(() => {}), m = o((e) => {
756
1046
  let t = Array.from(e);
757
1047
  t.length !== 0 && s((e) => e.concat(t.map((e) => ({
758
- id: Ct(),
1048
+ id: Ot(),
759
1049
  type: "file",
760
1050
  url: URL.createObjectURL(e),
761
1051
  mediaType: e.type,
@@ -806,41 +1096,41 @@ function jn({ initialInput: e = "", children: t }) {
806
1096
  y,
807
1097
  b
808
1098
  ]);
809
- return /* @__PURE__ */ K(Tn.Provider, {
1099
+ return /* @__PURE__ */ Q(sr.Provider, {
810
1100
  value: x,
811
- children: /* @__PURE__ */ K(En.Provider, {
1101
+ children: /* @__PURE__ */ Q(cr.Provider, {
812
1102
  value: y,
813
1103
  children: t
814
1104
  })
815
1105
  });
816
1106
  }
817
- var Mn = r(null), Z = () => {
818
- let e = An(), t = s(Mn), n = e ?? t;
1107
+ var mr = r(null), hr = () => {
1108
+ let e = fr(), t = s(mr), n = e ?? t;
819
1109
  if (!n) throw Error("usePromptInputAttachments must be used within a PromptInput or PromptInputProvider");
820
1110
  return n;
821
1111
  };
822
- function Nn({ data: e, className: t, ...n }) {
823
- let r = Z(), i = e.filename || "", a = (e.mediaType?.startsWith("image/") && e.url ? "image" : "file") == "image", o = i || (a ? "Image" : "Attachment");
824
- return /* @__PURE__ */ q(er, { children: [/* @__PURE__ */ K(oe, {
1112
+ function gr({ data: e, className: t, ...n }) {
1113
+ let r = hr(), i = e.filename || "", a = (e.mediaType?.startsWith("image/") && e.url ? "image" : "file") == "image", o = i || (a ? "Image" : "Attachment");
1114
+ return /* @__PURE__ */ $(Lr, { children: [/* @__PURE__ */ Q(z, {
825
1115
  asChild: !0,
826
- children: /* @__PURE__ */ q("div", {
827
- className: H("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),
1116
+ children: /* @__PURE__ */ $("div", {
1117
+ className: J("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),
828
1118
  ...n,
829
- children: [/* @__PURE__ */ q("div", {
1119
+ children: [/* @__PURE__ */ $("div", {
830
1120
  className: "relative size-5 shrink-0",
831
- children: [/* @__PURE__ */ K("div", {
1121
+ children: [/* @__PURE__ */ Q("div", {
832
1122
  className: "absolute inset-0 flex size-5 items-center justify-center overflow-hidden rounded bg-background transition-opacity group-hover:opacity-0",
833
- children: a ? /* @__PURE__ */ K("img", {
1123
+ children: a ? /* @__PURE__ */ Q("img", {
834
1124
  alt: i || "attachment",
835
1125
  className: "size-5 object-cover",
836
1126
  height: 20,
837
1127
  src: e.url,
838
1128
  width: 20
839
- }) : /* @__PURE__ */ K("div", {
1129
+ }) : /* @__PURE__ */ Q("div", {
840
1130
  className: "flex size-5 items-center justify-center text-muted-foreground",
841
- children: /* @__PURE__ */ K(ot, { className: "size-3" })
1131
+ children: /* @__PURE__ */ Q(at, { className: "size-3" })
842
1132
  })
843
- }), /* @__PURE__ */ q(v, {
1133
+ }), /* @__PURE__ */ $(v, {
844
1134
  "aria-label": "Remove attachment",
845
1135
  className: "absolute inset-0 size-5 cursor-pointer rounded p-0 opacity-0 transition-opacity group-hover:pointer-events-auto group-hover:opacity-100 [&>svg]:size-2.5",
846
1136
  onClick: (t) => {
@@ -848,37 +1138,37 @@ function Nn({ data: e, className: t, ...n }) {
848
1138
  },
849
1139
  type: "button",
850
1140
  variant: "ghost",
851
- children: [/* @__PURE__ */ K(W, {}), /* @__PURE__ */ K("span", {
1141
+ children: [/* @__PURE__ */ Q(_t, {}), /* @__PURE__ */ Q("span", {
852
1142
  className: "sr-only",
853
1143
  children: "Remove"
854
1144
  })]
855
1145
  })]
856
- }), /* @__PURE__ */ K("span", {
1146
+ }), /* @__PURE__ */ Q("span", {
857
1147
  className: "flex-1 truncate",
858
1148
  children: o
859
1149
  })]
860
1150
  }, e.id)
861
- }), /* @__PURE__ */ K(nr, {
1151
+ }), /* @__PURE__ */ Q(zr, {
862
1152
  className: "w-auto p-2",
863
- children: /* @__PURE__ */ q("div", {
1153
+ children: /* @__PURE__ */ $("div", {
864
1154
  className: "w-auto space-y-3",
865
- children: [a && /* @__PURE__ */ K("div", {
1155
+ children: [a && /* @__PURE__ */ Q("div", {
866
1156
  className: "flex max-h-96 w-96 items-center justify-center overflow-hidden rounded-md border",
867
- children: /* @__PURE__ */ K("img", {
1157
+ children: /* @__PURE__ */ Q("img", {
868
1158
  alt: i || "attachment preview",
869
1159
  className: "max-h-full max-w-full object-contain",
870
1160
  height: 384,
871
1161
  src: e.url,
872
1162
  width: 448
873
1163
  })
874
- }), /* @__PURE__ */ K("div", {
1164
+ }), /* @__PURE__ */ Q("div", {
875
1165
  className: "flex items-center gap-2.5",
876
- children: /* @__PURE__ */ q("div", {
1166
+ children: /* @__PURE__ */ $("div", {
877
1167
  className: "min-w-0 flex-1 space-y-1 px-0.5",
878
- children: [/* @__PURE__ */ K("h4", {
1168
+ children: [/* @__PURE__ */ Q("h4", {
879
1169
  className: "truncate font-semibold text-sm leading-none",
880
1170
  children: i || (a ? "Image" : "Attachment")
881
- }), e.mediaType && /* @__PURE__ */ K("p", {
1171
+ }), e.mediaType && /* @__PURE__ */ Q("p", {
882
1172
  className: "truncate font-mono text-muted-foreground text-xs",
883
1173
  children: e.mediaType
884
1174
  })]
@@ -887,64 +1177,64 @@ function Nn({ data: e, className: t, ...n }) {
887
1177
  })
888
1178
  })] });
889
1179
  }
890
- function Pn({ children: e, className: t, ...r }) {
891
- let i = Z();
892
- return i.files.length ? /* @__PURE__ */ K("div", {
893
- className: H("flex flex-wrap items-center gap-2 p-3 w-full", t),
1180
+ function _r({ children: e, className: t, ...r }) {
1181
+ let i = hr();
1182
+ return i.files.length ? /* @__PURE__ */ Q("div", {
1183
+ className: J("flex flex-wrap items-center gap-2 p-3 w-full", t),
894
1184
  ...r,
895
- children: i.files.map((t) => /* @__PURE__ */ K(n, { children: e(t) }, t.id))
1185
+ children: i.files.map((t) => /* @__PURE__ */ Q(n, { children: e(t) }, t.id))
896
1186
  }) : null;
897
1187
  }
898
- var Fn = ({ label: e = "Add photos or files", ...t }) => {
899
- let n = Z();
900
- return /* @__PURE__ */ q(I, {
1188
+ var vr = ({ label: e = "Add photos or files", ...t }) => {
1189
+ let n = hr();
1190
+ return /* @__PURE__ */ $(P, {
901
1191
  ...t,
902
1192
  onSelect: (e) => {
903
1193
  e.preventDefault(), n.openFileDialog();
904
1194
  },
905
1195
  children: [
906
- /* @__PURE__ */ K(et, { className: "mr-2 size-4" }),
1196
+ /* @__PURE__ */ Q(Qe, { className: "mr-2 size-4" }),
907
1197
  " ",
908
1198
  e
909
1199
  ]
910
1200
  });
911
- }, In = ({ className: e, accept: t, multiple: n, globalDrop: r, syncHiddenInput: i, maxFiles: a, maxFileSize: s, onError: f, onSubmit: p, children: m, ...h }) => {
912
- let g = On(), _ = !!g, v = u(null), y = u(null), [b, x] = d([]), S = _ ? g.attachments.files : b, C = u(S);
913
- C.current = S;
914
- let w = o(() => {
915
- v.current?.click();
916
- }, []), T = o((e) => !t || t.trim() === "" ? !0 : t.split(",").map((e) => e.trim()).filter(Boolean).some((t) => {
1201
+ }, yr = ({ 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 }) => {
1202
+ let _ = ur(), v = !!_, y = u(null), b = u(null), [x, S] = d([]), C = v ? _.attachments.files : x, w = u(C);
1203
+ w.current = C;
1204
+ let T = o(() => {
1205
+ y.current?.click();
1206
+ }, []), E = o((e) => !t || t.trim() === "" ? !0 : t.split(",").map((e) => e.trim()).filter(Boolean).some((t) => {
917
1207
  if (t.endsWith("/*")) {
918
1208
  let n = t.slice(0, -1);
919
1209
  return e.type.startsWith(n);
920
1210
  }
921
1211
  return e.type === t;
922
- }), [t]), E = o((e) => {
923
- let t = Array.from(e), n = t.filter((e) => T(e));
1212
+ }), [t]), D = o((e) => {
1213
+ let t = Array.from(e), n = t.filter((e) => E(e));
924
1214
  if (t.length && n.length === 0) {
925
- f?.({
1215
+ p?.({
926
1216
  code: "accept",
927
1217
  message: "No files match the accepted types."
928
1218
  });
929
1219
  return;
930
1220
  }
931
- let r = n.filter((e) => s ? e.size <= s : !0);
1221
+ let r = n.filter((e) => f ? e.size <= f : !0);
932
1222
  if (n.length > 0 && r.length === 0) {
933
- f?.({
1223
+ p?.({
934
1224
  code: "max_file_size",
935
1225
  message: "All files exceed the maximum size."
936
1226
  });
937
1227
  return;
938
1228
  }
939
- x((e) => {
940
- let t = typeof a == "number" ? Math.max(0, a - e.length) : void 0, n = typeof t == "number" ? r.slice(0, t) : r;
941
- typeof t == "number" && r.length > t && f?.({
1229
+ S((e) => {
1230
+ let t = typeof s == "number" ? Math.max(0, s - e.length) : void 0, n = typeof t == "number" ? r.slice(0, t) : r;
1231
+ typeof t == "number" && r.length > t && p?.({
942
1232
  code: "max_files",
943
1233
  message: "Too many files. Some were not added."
944
1234
  });
945
1235
  let i = [];
946
1236
  for (let e of n) i.push({
947
- id: Ct(),
1237
+ id: Ot(),
948
1238
  type: "file",
949
1239
  url: URL.createObjectURL(e),
950
1240
  mediaType: e.type,
@@ -953,48 +1243,48 @@ var Fn = ({ label: e = "Add photos or files", ...t }) => {
953
1243
  return e.concat(i);
954
1244
  });
955
1245
  }, [
956
- T,
957
- a,
1246
+ E,
958
1247
  s,
959
- f
960
- ]), D = o((e) => x((t) => {
1248
+ f,
1249
+ p
1250
+ ]), O = o((e) => S((t) => {
961
1251
  let n = t.find((t) => t.id === e);
962
1252
  return n?.url && URL.revokeObjectURL(n.url), t.filter((t) => t.id !== e);
963
- }), []), O = o(() => x((e) => {
1253
+ }), []), k = o(() => S((e) => {
964
1254
  for (let t of e) t.url && URL.revokeObjectURL(t.url);
965
1255
  return [];
966
- }), []), k = _ ? g.attachments.add : E, A = _ ? g.attachments.remove : D, j = _ ? g.attachments.clear : O, M = _ ? g.attachments.openFileDialog : w;
1256
+ }), []), A = v ? _.attachments.add : D, j = v ? _.attachments.remove : O, M = v ? _.attachments.clear : k, N = v ? _.attachments.openFileDialog : T;
967
1257
  c(() => {
968
- _ && g.__registerFileInput(v, () => v.current?.click());
969
- }, [_, g]), c(() => {
970
- i && v.current && S.length === 0 && (v.current.value = "");
971
- }, [S, i]), c(() => {
972
- let e = y.current;
973
- if (!e || r) return;
1258
+ v && _.__registerFileInput(y, () => y.current?.click());
1259
+ }, [v, _]), c(() => {
1260
+ a && y.current && C.length === 0 && (y.current.value = "");
1261
+ }, [C, a]), c(() => {
1262
+ let e = b.current;
1263
+ if (!e || i) return;
974
1264
  let t = (e) => {
975
1265
  e.dataTransfer?.types?.includes("Files") && e.preventDefault();
976
1266
  }, n = (e) => {
977
- e.dataTransfer?.types?.includes("Files") && e.preventDefault(), e.dataTransfer?.files && e.dataTransfer.files.length > 0 && k(e.dataTransfer.files);
1267
+ e.dataTransfer?.types?.includes("Files") && e.preventDefault(), e.dataTransfer?.files && e.dataTransfer.files.length > 0 && A(e.dataTransfer.files);
978
1268
  };
979
1269
  return e.addEventListener("dragover", t), e.addEventListener("drop", n), () => {
980
1270
  e.removeEventListener("dragover", t), e.removeEventListener("drop", n);
981
1271
  };
982
- }, [k, r]), c(() => {
983
- if (!r) return;
1272
+ }, [A, i]), c(() => {
1273
+ if (!i) return;
984
1274
  let e = (e) => {
985
1275
  e.dataTransfer?.types?.includes("Files") && e.preventDefault();
986
1276
  }, t = (e) => {
987
- e.dataTransfer?.types?.includes("Files") && e.preventDefault(), e.dataTransfer?.files && e.dataTransfer.files.length > 0 && k(e.dataTransfer.files);
1277
+ e.dataTransfer?.types?.includes("Files") && e.preventDefault(), e.dataTransfer?.files && e.dataTransfer.files.length > 0 && A(e.dataTransfer.files);
988
1278
  };
989
1279
  return document.addEventListener("dragover", e), document.addEventListener("drop", t), () => {
990
1280
  document.removeEventListener("dragover", e), document.removeEventListener("drop", t);
991
1281
  };
992
- }, [k, r]), c(() => () => {
993
- if (!_) for (let e of C.current) e.url && URL.revokeObjectURL(e.url);
994
- }, [_]);
995
- let N = (e) => {
996
- e.currentTarget.files && k(e.currentTarget.files), e.currentTarget.value = "";
997
- }, P = async (e) => {
1282
+ }, [A, i]), c(() => () => {
1283
+ if (!v) for (let e of w.current) e.url && URL.revokeObjectURL(e.url);
1284
+ }, [v]);
1285
+ let ee = (e) => {
1286
+ e.currentTarget.files && A(e.currentTarget.files), e.currentTarget.value = "";
1287
+ }, te = async (e) => {
998
1288
  try {
999
1289
  let t = await (await fetch(e)).blob();
1000
1290
  return new Promise((e) => {
@@ -1004,39 +1294,39 @@ var Fn = ({ label: e = "Add photos or files", ...t }) => {
1004
1294
  } catch {
1005
1295
  return null;
1006
1296
  }
1007
- }, F = l(() => ({
1008
- files: S.map((e) => ({
1297
+ }, P = l(() => ({
1298
+ files: C.map((e) => ({
1009
1299
  ...e,
1010
1300
  id: e.id
1011
1301
  })),
1012
- add: k,
1013
- remove: A,
1014
- clear: j,
1015
- openFileDialog: M,
1016
- fileInputRef: v
1302
+ add: A,
1303
+ remove: j,
1304
+ clear: M,
1305
+ openFileDialog: N,
1306
+ fileInputRef: y
1017
1307
  }), [
1018
- S,
1019
- k,
1308
+ C,
1020
1309
  A,
1021
1310
  j,
1022
- M
1023
- ]), I = /* @__PURE__ */ q(G, { children: [/* @__PURE__ */ K("input", {
1311
+ M,
1312
+ N
1313
+ ]), F = /* @__PURE__ */ $(Z, { children: [/* @__PURE__ */ Q("input", {
1024
1314
  accept: t,
1025
- "aria-label": "Upload files",
1315
+ "aria-label": r,
1026
1316
  className: "hidden",
1027
1317
  multiple: n,
1028
- onChange: N,
1029
- ref: v,
1030
- title: "Upload files",
1318
+ onChange: ee,
1319
+ ref: y,
1320
+ title: r,
1031
1321
  type: "file"
1032
- }), /* @__PURE__ */ K("form", {
1033
- className: H("w-full", e),
1322
+ }), /* @__PURE__ */ Q("form", {
1323
+ className: J("w-full", e),
1034
1324
  onSubmit: (e) => {
1035
1325
  e.preventDefault();
1036
- let t = e.currentTarget, n = _ ? g.textInput.value : new FormData(t).get("message") || "";
1037
- _ || t.reset(), Promise.all(S.map(async ({ id: e, ...t }) => {
1326
+ let t = e.currentTarget, n = v ? _.textInput.value : new FormData(t).get("message") || "";
1327
+ v || t.reset(), Promise.all(C.map(async ({ id: e, ...t }) => {
1038
1328
  if (t.url && t.url.startsWith("blob:")) {
1039
- let e = await P(t.url);
1329
+ let e = await te(t.url);
1040
1330
  return {
1041
1331
  ...t,
1042
1332
  url: e ?? t.url
@@ -1045,32 +1335,32 @@ var Fn = ({ label: e = "Add photos or files", ...t }) => {
1045
1335
  return t;
1046
1336
  })).then((t) => {
1047
1337
  try {
1048
- let r = p({
1338
+ let r = m({
1049
1339
  text: n,
1050
1340
  files: t
1051
1341
  }, e);
1052
1342
  r instanceof Promise ? r.then(() => {
1053
- j(), _ && g.textInput.clear();
1054
- }).catch(() => {}) : (j(), _ && g.textInput.clear());
1343
+ M(), v && _.textInput.clear();
1344
+ }).catch(() => {}) : (M(), v && _.textInput.clear());
1055
1345
  } catch {}
1056
1346
  }).catch(() => {});
1057
1347
  },
1058
- ref: y,
1059
- ...h,
1060
- children: /* @__PURE__ */ K(yn, {
1348
+ ref: b,
1349
+ ...g,
1350
+ children: /* @__PURE__ */ Q(tr, {
1061
1351
  className: "overflow-hidden",
1062
- children: m
1352
+ children: h
1063
1353
  })
1064
1354
  })] });
1065
- return _ ? I : /* @__PURE__ */ K(Mn.Provider, {
1066
- value: F,
1067
- children: I
1355
+ return v ? F : /* @__PURE__ */ Q(mr.Provider, {
1356
+ value: P,
1357
+ children: F
1068
1358
  });
1069
- }, Ln = ({ className: e, ...t }) => /* @__PURE__ */ K("div", {
1070
- className: H("contents", e),
1359
+ }, br = ({ className: e, ...t }) => /* @__PURE__ */ Q("div", {
1360
+ className: J("contents", e),
1071
1361
  ...t
1072
- }), Rn = ({ onChange: e, className: t, placeholder: n = "What would you like to know?", ...r }) => {
1073
- let i = On(), a = Z(), [o, s] = d(!1), c = (e) => {
1362
+ }), xr = ({ onChange: e, className: t, placeholder: n = "What would you like to know?", ...r }) => {
1363
+ let i = ur(), a = hr(), [o, s] = d(!1), c = (e) => {
1074
1364
  if (e.key === "Enter") {
1075
1365
  if (o || e.nativeEvent.isComposing || e.shiftKey) return;
1076
1366
  e.preventDefault();
@@ -1098,8 +1388,8 @@ var Fn = ({ label: e = "Add photos or files", ...t }) => {
1098
1388
  i.textInput.setInput(t.currentTarget.value), e?.(t);
1099
1389
  }
1100
1390
  } : { onChange: e };
1101
- return /* @__PURE__ */ K(wn, {
1102
- className: H("field-sizing-content max-h-48 min-h-16", t),
1391
+ return /* @__PURE__ */ Q(or, {
1392
+ className: J("field-sizing-content max-h-48 min-h-16", t),
1103
1393
  name: "message",
1104
1394
  onCompositionEnd: () => s(!1),
1105
1395
  onCompositionStart: () => s(!0),
@@ -1109,52 +1399,52 @@ var Fn = ({ label: e = "Add photos or files", ...t }) => {
1109
1399
  ...r,
1110
1400
  ...u
1111
1401
  });
1112
- }, zn = ({ className: e, ...t }) => /* @__PURE__ */ K(xn, {
1402
+ }, Sr = ({ className: e, ...t }) => /* @__PURE__ */ Q(rr, {
1113
1403
  align: "block-end",
1114
- className: H("order-first flex-wrap gap-1", e),
1404
+ className: J("order-first flex-wrap gap-1", e),
1115
1405
  ...t
1116
- }), Bn = ({ className: e, ...t }) => /* @__PURE__ */ K(xn, {
1406
+ }), Cr = ({ className: e, ...t }) => /* @__PURE__ */ Q(rr, {
1117
1407
  align: "block-end",
1118
- className: H("justify-between gap-1", e),
1408
+ className: J("justify-between gap-1", e),
1119
1409
  ...t
1120
- }), Vn = ({ className: e, ...t }) => /* @__PURE__ */ K("div", {
1121
- className: H("flex items-center gap-1", e),
1410
+ }), wr = ({ className: e, ...t }) => /* @__PURE__ */ Q("div", {
1411
+ className: J("flex items-center gap-1", e),
1122
1412
  ...t
1123
- }), Hn = ({ variant: e = "ghost", className: n, size: r, ...i }) => {
1413
+ }), Tr = ({ variant: e = "ghost", className: n, size: r, ...i }) => {
1124
1414
  let a = r ?? (t.count(i.children) > 1 ? "sm" : "icon-sm");
1125
- return /* @__PURE__ */ K(Cn, {
1126
- className: H(n),
1415
+ return /* @__PURE__ */ Q(ar, {
1416
+ className: J(n),
1127
1417
  size: a,
1128
1418
  type: "button",
1129
1419
  variant: e,
1130
1420
  ...i
1131
1421
  });
1132
- }, Un = (e) => /* @__PURE__ */ K(P, { ...e }), Wn = ({ className: e, children: t, ...n }) => /* @__PURE__ */ K(L, {
1422
+ }, Er = (e) => /* @__PURE__ */ Q(ee, { ...e }), Dr = ({ className: e, children: t, ...n }) => /* @__PURE__ */ Q(F, {
1133
1423
  asChild: !0,
1134
- children: /* @__PURE__ */ K(Hn, {
1424
+ children: /* @__PURE__ */ Q(Tr, {
1135
1425
  className: e,
1136
1426
  ...n,
1137
- children: t ?? /* @__PURE__ */ K(st, { className: "size-4" })
1427
+ children: t ?? /* @__PURE__ */ Q(ot, { className: "size-4" })
1138
1428
  })
1139
- }), Gn = ({ className: e, ...t }) => /* @__PURE__ */ K(F, {
1429
+ }), Or = ({ className: e, ...t }) => /* @__PURE__ */ Q(te, {
1140
1430
  align: "start",
1141
- className: H(e),
1431
+ className: J(e),
1142
1432
  ...t
1143
- }), Kn = ({ className: e, ...t }) => /* @__PURE__ */ K(I, {
1144
- className: H(e),
1433
+ }), kr = ({ className: e, ...t }) => /* @__PURE__ */ Q(P, {
1434
+ className: J(e),
1145
1435
  ...t
1146
- }), qn = ({ className: e, variant: t = "default", size: n = "icon-sm", status: r, children: i, ...a }) => {
1147
- let o = /* @__PURE__ */ K(Qe, { className: "size-4" });
1148
- return r === "submitted" ? o = /* @__PURE__ */ K(nt, { className: "size-4 animate-spin" }) : r === "streaming" ? o = /* @__PURE__ */ K(ut, { className: "size-4" }) : r === "error" && (o = /* @__PURE__ */ K(W, { className: "size-4" })), /* @__PURE__ */ K(Cn, {
1436
+ }), Ar = ({ className: e, variant: t = "default", size: n = "icon-sm", status: r, children: i, ...a }) => {
1437
+ let o = /* @__PURE__ */ Q(Je, { className: "size-4" });
1438
+ return r === "submitted" ? o = /* @__PURE__ */ Q(tt, { className: "size-4 animate-spin" }) : r === "streaming" ? o = /* @__PURE__ */ Q(dt, { className: "size-4" }) : r === "error" && (o = /* @__PURE__ */ Q(_t, { className: "size-4" })), /* @__PURE__ */ Q(ar, {
1149
1439
  "aria-label": "Submit",
1150
- className: H(e),
1440
+ className: J(e),
1151
1441
  size: n,
1152
1442
  type: "submit",
1153
1443
  variant: t,
1154
1444
  ...a,
1155
1445
  children: i ?? o
1156
1446
  });
1157
- }, Jn = ({ className: e, textareaRef: t, onTranscriptionChange: n, ...r }) => {
1447
+ }, jr = ({ className: e, textareaRef: t, onTranscriptionChange: n, ...r }) => {
1158
1448
  let [i, a] = d(!1), [s, l] = d(null), f = u(null);
1159
1449
  c(() => {
1160
1450
  if (typeof window < "u" && ("SpeechRecognition" in window || "webkitSpeechRecognition" in window)) {
@@ -1184,80 +1474,80 @@ var Fn = ({ label: e = "Add photos or files", ...t }) => {
1184
1474
  let p = o(() => {
1185
1475
  s && (i ? s.stop() : s.start());
1186
1476
  }, [s, i]);
1187
- return /* @__PURE__ */ K(Hn, {
1188
- className: H("relative transition-all duration-200", i && "animate-pulse bg-accent text-accent-foreground", e),
1477
+ return /* @__PURE__ */ Q(Tr, {
1478
+ className: J("relative transition-all duration-200", i && "animate-pulse bg-accent text-accent-foreground", e),
1189
1479
  disabled: !s,
1190
1480
  onClick: p,
1191
1481
  ...r,
1192
- children: /* @__PURE__ */ K(it, { className: "size-4" })
1482
+ children: /* @__PURE__ */ Q(rt, { className: "size-4" })
1193
1483
  });
1194
- }, Yn = (e) => /* @__PURE__ */ K(ue, { ...e }), Xn = ({ className: e, ...t }) => /* @__PURE__ */ K(pe, {
1195
- className: H("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),
1484
+ }, Mr = (e) => /* @__PURE__ */ Q(le, { ...e }), Nr = ({ className: e, ...t }) => /* @__PURE__ */ Q(fe, {
1485
+ className: J("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),
1196
1486
  ...t
1197
- }), Zn = ({ className: e, ...t }) => /* @__PURE__ */ K(de, {
1198
- className: H(e),
1487
+ }), Pr = ({ className: e, ...t }) => /* @__PURE__ */ Q(ue, {
1488
+ className: J(e),
1199
1489
  ...t
1200
- }), Qn = ({ className: e, ...t }) => /* @__PURE__ */ K(fe, {
1201
- className: H(e),
1490
+ }), Fr = ({ className: e, ...t }) => /* @__PURE__ */ Q(de, {
1491
+ className: J(e),
1202
1492
  ...t
1203
- }), $n = ({ className: e, ...t }) => /* @__PURE__ */ K(me, {
1204
- className: H(e),
1493
+ }), Ir = ({ className: e, ...t }) => /* @__PURE__ */ Q(pe, {
1494
+ className: J(e),
1205
1495
  ...t
1206
- }), er = ({ openDelay: e = 0, closeDelay: t = 0, ...n }) => /* @__PURE__ */ K(R, {
1496
+ }), Lr = ({ openDelay: e = 0, closeDelay: t = 0, ...n }) => /* @__PURE__ */ Q(L, {
1207
1497
  closeDelay: t,
1208
1498
  openDelay: e,
1209
1499
  ...n
1210
- }), tr = (e) => /* @__PURE__ */ K(oe, { ...e }), nr = ({ align: e = "start", ...t }) => /* @__PURE__ */ K(ae, {
1500
+ }), Rr = (e) => /* @__PURE__ */ Q(z, { ...e }), zr = ({ align: e = "start", ...t }) => /* @__PURE__ */ Q(R, {
1211
1501
  align: e,
1212
1502
  ...t
1213
- }), rr = ({ className: e, ...t }) => /* @__PURE__ */ K("div", {
1214
- className: H(e),
1503
+ }), Br = ({ className: e, ...t }) => /* @__PURE__ */ Q("div", {
1504
+ className: J(e),
1215
1505
  ...t
1216
- }), ir = ({ className: e, ...t }) => /* @__PURE__ */ K("div", {
1217
- className: H(e),
1506
+ }), Vr = ({ className: e, ...t }) => /* @__PURE__ */ Q("div", {
1507
+ className: J(e),
1218
1508
  ...t
1219
- }), ar = ({ className: e, ...t }) => /* @__PURE__ */ K("h3", {
1220
- className: H("mb-2 px-3 font-medium text-muted-foreground text-xs", e),
1509
+ }), Hr = ({ className: e, ...t }) => /* @__PURE__ */ Q("h3", {
1510
+ className: J("mb-2 px-3 font-medium text-muted-foreground text-xs", e),
1221
1511
  ...t
1222
- }), or = ({ className: e, ...t }) => /* @__PURE__ */ K("div", {
1223
- className: H("space-y-1", e),
1512
+ }), Ur = ({ className: e, ...t }) => /* @__PURE__ */ Q("div", {
1513
+ className: J("space-y-1", e),
1224
1514
  ...t
1225
- }), sr = ({ className: e, ...t }) => /* @__PURE__ */ K("div", {
1226
- className: H("flex items-center gap-2 px-3 py-2 text-xs hover:bg-accent", e),
1515
+ }), Wr = ({ className: e, ...t }) => /* @__PURE__ */ Q("div", {
1516
+ className: J("flex items-center gap-2 px-3 py-2 text-xs hover:bg-accent", e),
1227
1517
  ...t
1228
- }), cr = ({ className: e, ...t }) => /* @__PURE__ */ K(D, {
1229
- className: H(e),
1518
+ }), Gr = ({ className: e, ...t }) => /* @__PURE__ */ Q(D, {
1519
+ className: J(e),
1230
1520
  ...t
1231
- }), lr = ({ className: e, ...t }) => /* @__PURE__ */ K(A, {
1232
- className: H(e),
1521
+ }), Kr = ({ className: e, ...t }) => /* @__PURE__ */ Q(A, {
1522
+ className: J(e),
1233
1523
  ...t
1234
- }), ur = ({ className: e, ...t }) => /* @__PURE__ */ K(M, {
1235
- className: H(e),
1524
+ }), qr = ({ className: e, ...t }) => /* @__PURE__ */ Q(M, {
1525
+ className: J(e),
1236
1526
  ...t
1237
- }), dr = ({ className: e, ...t }) => /* @__PURE__ */ K(O, {
1238
- className: H(e),
1527
+ }), Jr = ({ className: e, ...t }) => /* @__PURE__ */ Q(O, {
1528
+ className: J(e),
1239
1529
  ...t
1240
- }), fr = ({ className: e, ...t }) => /* @__PURE__ */ K(k, {
1241
- className: H(e),
1530
+ }), Yr = ({ className: e, ...t }) => /* @__PURE__ */ Q(k, {
1531
+ className: J(e),
1242
1532
  ...t
1243
- }), pr = ({ className: e, ...t }) => /* @__PURE__ */ K(j, {
1244
- className: H(e),
1533
+ }), Xr = ({ className: e, ...t }) => /* @__PURE__ */ Q(j, {
1534
+ className: J(e),
1245
1535
  ...t
1246
- }), mr = ({ className: e, ...t }) => /* @__PURE__ */ K(N, {
1247
- className: H(e),
1536
+ }), Zr = ({ className: e, ...t }) => /* @__PURE__ */ Q(N, {
1537
+ className: J(e),
1248
1538
  ...t
1249
- }), hr = ({ className: e, children: t, ...n }) => /* @__PURE__ */ q(ce, {
1539
+ }), Qr = ({ className: e, children: t, ...n }) => /* @__PURE__ */ $(se, {
1250
1540
  className: "w-full overflow-x-auto whitespace-nowrap",
1251
1541
  ...n,
1252
- children: [/* @__PURE__ */ K("div", {
1253
- className: H("flex w-max flex-nowrap items-center gap-2", e),
1542
+ children: [/* @__PURE__ */ Q("div", {
1543
+ className: J("flex w-max flex-nowrap items-center gap-2", e),
1254
1544
  children: t
1255
- }), /* @__PURE__ */ K(le, {
1545
+ }), /* @__PURE__ */ Q(ce, {
1256
1546
  className: "hidden",
1257
1547
  orientation: "horizontal"
1258
1548
  })]
1259
- }), gr = ({ suggestion: e, onClick: t, className: n, variant: r = "outline", size: i = "sm", children: a, ...o }) => /* @__PURE__ */ K(v, {
1260
- className: H("cursor-pointer rounded-full px-4", n),
1549
+ }), $r = ({ suggestion: e, onClick: t, className: n, variant: r = "outline", size: i = "sm", children: a, ...o }) => /* @__PURE__ */ Q(v, {
1550
+ className: J("cursor-pointer rounded-full px-4", n),
1261
1551
  onClick: () => {
1262
1552
  t?.(e);
1263
1553
  },
@@ -1266,7 +1556,7 @@ var Fn = ({ label: e = "Add photos or files", ...t }) => {
1266
1556
  variant: r,
1267
1557
  ...o,
1268
1558
  children: a || e
1269
- }), _r = r({ code: "" }), vr = {
1559
+ }), ei = r({ code: "" }), ti = {
1270
1560
  name: "line-numbers",
1271
1561
  line(e, t) {
1272
1562
  e.children.unshift({
@@ -1287,21 +1577,21 @@ var Fn = ({ label: e = "Add photos or files", ...t }) => {
1287
1577
  });
1288
1578
  }
1289
1579
  };
1290
- async function yr(e, t, n = !1) {
1291
- let r = n ? [vr] : [];
1292
- return await Promise.all([wt(e, {
1580
+ async function ni(e, t, n = !1) {
1581
+ let r = n ? [ti] : [];
1582
+ return await Promise.all([kt(e, {
1293
1583
  lang: t,
1294
1584
  theme: "one-light",
1295
1585
  transformers: r
1296
- }), wt(e, {
1586
+ }), kt(e, {
1297
1587
  lang: t,
1298
1588
  theme: "one-dark-pro",
1299
1589
  transformers: r
1300
1590
  })]);
1301
1591
  }
1302
- var Q = ({ code: e, language: t, showLineNumbers: n = !1, className: r, children: i, ...a }) => {
1592
+ var ri = ({ code: e, language: t, showLineNumbers: n = !1, className: r, children: i, ...a }) => {
1303
1593
  let [o, s] = d(""), [l, f] = d(""), p = u(!1);
1304
- return c(() => (yr(e, t, n).then(([e, t]) => {
1594
+ return c(() => (ni(e, t, n).then(([e, t]) => {
1305
1595
  p.current ||= (s(e), f(t), !0);
1306
1596
  }), () => {
1307
1597
  p.current = !1;
@@ -1309,23 +1599,23 @@ var Q = ({ code: e, language: t, showLineNumbers: n = !1, className: r, children
1309
1599
  e,
1310
1600
  t,
1311
1601
  n
1312
- ]), /* @__PURE__ */ K(_r.Provider, {
1602
+ ]), /* @__PURE__ */ Q(ei.Provider, {
1313
1603
  value: { code: e },
1314
- children: /* @__PURE__ */ K("div", {
1315
- className: H("group relative w-full overflow-hidden rounded-md border bg-background text-foreground", r),
1604
+ children: /* @__PURE__ */ Q("div", {
1605
+ className: J("group relative w-full overflow-hidden rounded-md border bg-background text-foreground", r),
1316
1606
  ...a,
1317
- children: /* @__PURE__ */ q("div", {
1607
+ children: /* @__PURE__ */ $("div", {
1318
1608
  className: "relative",
1319
1609
  children: [
1320
- /* @__PURE__ */ K("div", {
1610
+ /* @__PURE__ */ Q("div", {
1321
1611
  className: "overflow-auto dark:hidden [&>pre]:m-0 [&>pre]:bg-background! [&>pre]:p-4 [&>pre]:text-foreground! [&>pre]:text-sm [&_code]:font-mono [&_code]:text-sm",
1322
1612
  dangerouslySetInnerHTML: { __html: o }
1323
1613
  }),
1324
- /* @__PURE__ */ K("div", {
1614
+ /* @__PURE__ */ Q("div", {
1325
1615
  className: "hidden overflow-auto dark:block [&>pre]:m-0 [&>pre]:bg-background! [&>pre]:p-4 [&>pre]:text-foreground! [&>pre]:text-sm [&_code]:font-mono [&_code]:text-sm",
1326
1616
  dangerouslySetInnerHTML: { __html: l }
1327
1617
  }),
1328
- i && /* @__PURE__ */ K("div", {
1618
+ i && /* @__PURE__ */ Q("div", {
1329
1619
  className: "absolute top-2 right-2 flex items-center gap-2",
1330
1620
  children: i
1331
1621
  })
@@ -1333,8 +1623,8 @@ var Q = ({ code: e, language: t, showLineNumbers: n = !1, className: r, children
1333
1623
  })
1334
1624
  })
1335
1625
  });
1336
- }, br = ({ onCopy: e, onError: t, timeout: n = 2e3, children: r, className: i, ...a }) => {
1337
- let [o, c] = d(!1), { code: l } = s(_r), u = async () => {
1626
+ }, ii = ({ onCopy: e, onError: t, timeout: n = 2e3, children: r, className: i, ...a }) => {
1627
+ let [o, c] = d(!1), { code: l } = s(ei), u = async () => {
1338
1628
  if (typeof window > "u" || !navigator?.clipboard?.writeText) {
1339
1629
  t?.(/* @__PURE__ */ Error("Clipboard API not available"));
1340
1630
  return;
@@ -1344,29 +1634,29 @@ var Q = ({ code: e, language: t, showLineNumbers: n = !1, className: r, children
1344
1634
  } catch (e) {
1345
1635
  t?.(e);
1346
1636
  }
1347
- }, f = o ? He : Xe;
1348
- return /* @__PURE__ */ K(v, {
1349
- className: H("shrink-0", i),
1637
+ }, f = o ? Ie : Ke;
1638
+ return /* @__PURE__ */ Q(v, {
1639
+ className: J("shrink-0", i),
1350
1640
  onClick: u,
1351
1641
  size: "icon",
1352
1642
  variant: "ghost",
1353
1643
  ...a,
1354
- children: r ?? /* @__PURE__ */ K(f, { size: 14 })
1644
+ children: r ?? /* @__PURE__ */ Q(f, { size: 14 })
1355
1645
  });
1356
- }, xr = ({ className: e, ...t }) => /* @__PURE__ */ K(w, {
1357
- className: H("not-prose mb-4 w-full rounded-md border", e),
1646
+ }, ai = ({ className: e, ...t }) => /* @__PURE__ */ Q(w, {
1647
+ className: J("not-prose mb-4 w-full rounded-md border", e),
1358
1648
  ...t
1359
- }), Sr = (e) => /* @__PURE__ */ q(_, {
1649
+ }), oi = (e) => /* @__PURE__ */ $(_, {
1360
1650
  className: "gap-1.5 rounded-full text-xs",
1361
1651
  variant: "secondary",
1362
1652
  children: [{
1363
- "input-streaming": /* @__PURE__ */ K(Ke, { className: "size-4" }),
1364
- "input-available": /* @__PURE__ */ K(Je, { className: "size-4 animate-pulse" }),
1365
- "approval-requested": /* @__PURE__ */ K(Je, { className: "size-4 text-yellow-600" }),
1366
- "approval-responded": /* @__PURE__ */ K(Ve, { className: "size-4 text-blue-600" }),
1367
- "output-available": /* @__PURE__ */ K(Ve, { className: "size-4 text-green-600" }),
1368
- "output-error": /* @__PURE__ */ K(pt, { className: "size-4 text-red-600" }),
1369
- "output-denied": /* @__PURE__ */ K(pt, { className: "size-4 text-orange-600" })
1653
+ "input-streaming": /* @__PURE__ */ Q(Be, { className: "size-4" }),
1654
+ "input-available": /* @__PURE__ */ Q(We, { className: "size-4 animate-pulse" }),
1655
+ "approval-requested": /* @__PURE__ */ Q(We, { className: "size-4 text-yellow-600" }),
1656
+ "approval-responded": /* @__PURE__ */ Q(Fe, { className: "size-4 text-blue-600" }),
1657
+ "output-available": /* @__PURE__ */ Q(Fe, { className: "size-4 text-green-600" }),
1658
+ "output-error": /* @__PURE__ */ Q(gt, { className: "size-4 text-red-600" }),
1659
+ "output-denied": /* @__PURE__ */ Q(gt, { className: "size-4 text-orange-600" })
1370
1660
  }[e], {
1371
1661
  "input-streaming": "Pending",
1372
1662
  "input-available": "Running",
@@ -1376,61 +1666,61 @@ var Q = ({ code: e, language: t, showLineNumbers: n = !1, className: r, children
1376
1666
  "output-error": "Error",
1377
1667
  "output-denied": "Denied"
1378
1668
  }[e]]
1379
- }), Cr = ({ className: e, title: t, type: n, state: r, ...i }) => /* @__PURE__ */ q(E, {
1380
- className: H("flex w-full items-center justify-between gap-4 p-3", e),
1669
+ }), si = ({ className: e, title: t, type: n, state: r, ...i }) => /* @__PURE__ */ $(E, {
1670
+ className: J("flex w-full items-center justify-between gap-4 p-3", e),
1381
1671
  ...i,
1382
- children: [/* @__PURE__ */ q("div", {
1672
+ children: [/* @__PURE__ */ $("div", {
1383
1673
  className: "flex items-center gap-2",
1384
1674
  children: [
1385
- /* @__PURE__ */ K(dt, { className: "size-4 text-muted-foreground" }),
1386
- /* @__PURE__ */ K("span", {
1675
+ /* @__PURE__ */ Q(mt, { className: "size-4 text-muted-foreground" }),
1676
+ /* @__PURE__ */ Q("span", {
1387
1677
  className: "font-medium text-sm",
1388
1678
  children: t ?? n.split("-").slice(1).join("-")
1389
1679
  }),
1390
- Sr(r)
1680
+ oi(r)
1391
1681
  ]
1392
- }), /* @__PURE__ */ K(Ue, { className: "size-4 text-muted-foreground transition-transform group-data-[state=open]:rotate-180" })]
1393
- }), wr = ({ className: e, ...t }) => /* @__PURE__ */ K(T, {
1394
- className: H("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),
1682
+ }), /* @__PURE__ */ Q(Le, { className: "size-4 text-muted-foreground transition-transform group-data-[state=open]:rotate-180" })]
1683
+ }), ci = ({ className: e, ...t }) => /* @__PURE__ */ Q(T, {
1684
+ className: J("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),
1395
1685
  ...t
1396
- }), Tr = ({ className: e, input: t, ...n }) => /* @__PURE__ */ q("div", {
1397
- className: H("space-y-2 overflow-hidden p-4", e),
1686
+ }), li = ({ className: e, input: t, ...n }) => /* @__PURE__ */ $("div", {
1687
+ className: J("space-y-2 overflow-hidden p-4", e),
1398
1688
  ...n,
1399
- children: [/* @__PURE__ */ K("h4", {
1689
+ children: [/* @__PURE__ */ Q("h4", {
1400
1690
  className: "font-medium text-muted-foreground text-xs uppercase tracking-wide",
1401
1691
  children: "Parameters"
1402
- }), /* @__PURE__ */ K("div", {
1692
+ }), /* @__PURE__ */ Q("div", {
1403
1693
  className: "rounded-md bg-muted/50",
1404
- children: /* @__PURE__ */ K(Q, {
1694
+ children: /* @__PURE__ */ Q(ri, {
1405
1695
  code: JSON.stringify(t, null, 2),
1406
1696
  language: "json"
1407
1697
  })
1408
1698
  })]
1409
- }), Er = ({ className: e, output: t, errorText: n, ...r }) => {
1699
+ }), ui = ({ className: e, output: t, errorText: n, ...r }) => {
1410
1700
  if (!(t || n)) return null;
1411
- let a = /* @__PURE__ */ K("div", { children: t });
1412
- return typeof t == "object" && !i(t) ? a = /* @__PURE__ */ K(Q, {
1701
+ let a = /* @__PURE__ */ Q("div", { children: t });
1702
+ return typeof t == "object" && !i(t) ? a = /* @__PURE__ */ Q(ri, {
1413
1703
  code: JSON.stringify(t, null, 2),
1414
1704
  language: "json"
1415
- }) : typeof t == "string" && (a = /* @__PURE__ */ K(Q, {
1705
+ }) : typeof t == "string" && (a = /* @__PURE__ */ Q(ri, {
1416
1706
  code: t,
1417
1707
  language: "json"
1418
- })), /* @__PURE__ */ q("div", {
1419
- className: H("space-y-2 p-4", e),
1708
+ })), /* @__PURE__ */ $("div", {
1709
+ className: J("space-y-2 p-4", e),
1420
1710
  ...r,
1421
- children: [/* @__PURE__ */ K("h4", {
1711
+ children: [/* @__PURE__ */ Q("h4", {
1422
1712
  className: "font-medium text-muted-foreground text-xs uppercase tracking-wide",
1423
1713
  children: n ? "Error" : "Result"
1424
- }), /* @__PURE__ */ q("div", {
1425
- className: H("overflow-x-auto rounded-md text-xs [&_table]:w-full", n ? "bg-destructive/10 text-destructive" : "bg-muted/50 text-foreground"),
1426
- children: [n && /* @__PURE__ */ K("div", { children: n }), a]
1714
+ }), /* @__PURE__ */ $("div", {
1715
+ className: J("overflow-x-auto rounded-md text-xs [&_table]:w-full", n ? "bg-destructive/10 text-destructive" : "bg-muted/50 text-foreground"),
1716
+ children: [n && /* @__PURE__ */ Q("div", { children: n }), a]
1427
1717
  })]
1428
1718
  });
1429
- }, Dr = a(({ children: e, as: t = "p", className: n, duration: r = 2, spread: i = 2 }) => {
1430
- let a = Et.create(t), o = l(() => (e?.length ?? 0) * i, [e, i]);
1431
- return /* @__PURE__ */ K(a, {
1719
+ }, di = a(({ children: e, as: t = "p", className: n, duration: r = 2, spread: i = 2 }) => {
1720
+ let a = jt.create(t), o = l(() => (e?.length ?? 0) * i, [e, i]);
1721
+ return /* @__PURE__ */ Q(a, {
1432
1722
  animate: { backgroundPosition: "0% center" },
1433
- className: H("relative inline-block bg-[length:250%_100%,auto] bg-clip-text text-transparent", "[--bg:linear-gradient(90deg,#0000_calc(50%-var(--spread)),var(--color-background),#0000_calc(50%+var(--spread)))] [background-repeat:no-repeat,padding-box]", n),
1723
+ className: J("relative inline-block bg-[length:250%_100%,auto] bg-clip-text text-transparent", "[--bg:linear-gradient(90deg,#0000_calc(50%-var(--spread)),var(--color-background),#0000_calc(50%+var(--spread)))] [background-repeat:no-repeat,padding-box]", n),
1434
1724
  initial: { backgroundPosition: "100% center" },
1435
1725
  style: {
1436
1726
  "--spread": `${o}px`,
@@ -1443,21 +1733,21 @@ var Q = ({ code: e, language: t, showLineNumbers: n = !1, className: r, children
1443
1733
  },
1444
1734
  children: e
1445
1735
  });
1446
- }), Or = r(null), kr = () => {
1447
- let e = s(Or);
1736
+ }), fi = r(null), pi = () => {
1737
+ let e = s(fi);
1448
1738
  if (!e) throw Error("Reasoning components must be used within Reasoning");
1449
1739
  return e;
1450
- }, Ar = 1e3, jr = 1e3, Mr = a(({ className: e, isStreaming: t = !1, open: n, defaultOpen: r = !0, onOpenChange: i, duration: a, children: o, ...s }) => {
1451
- let [l, u] = Tt({
1740
+ }, mi = 1e3, hi = 1e3, gi = a(({ className: e, isStreaming: t = !1, open: n, defaultOpen: r = !0, onOpenChange: i, duration: a, children: o, ...s }) => {
1741
+ let [l, u] = At({
1452
1742
  prop: n,
1453
1743
  defaultProp: r,
1454
1744
  onChange: i
1455
- }), [f, p] = Tt({
1745
+ }), [f, p] = At({
1456
1746
  prop: a,
1457
1747
  defaultProp: void 0
1458
1748
  }), [m, h] = d(!1), [g, _] = d(null);
1459
1749
  return c(() => {
1460
- t ? g === null && _(Date.now()) : g !== null && (p(Math.ceil((Date.now() - g) / jr)), _(null));
1750
+ t ? g === null && _(Date.now()) : g !== null && (p(Math.ceil((Date.now() - g) / hi)), _(null));
1461
1751
  }, [
1462
1752
  t,
1463
1753
  g,
@@ -1466,7 +1756,7 @@ var Q = ({ code: e, language: t, showLineNumbers: n = !1, className: r, children
1466
1756
  if (r && !t && l && !m) {
1467
1757
  let e = setTimeout(() => {
1468
1758
  u(!1), h(!0);
1469
- }, Ar);
1759
+ }, mi);
1470
1760
  return () => clearTimeout(e);
1471
1761
  }
1472
1762
  }, [
@@ -1475,15 +1765,15 @@ var Q = ({ code: e, language: t, showLineNumbers: n = !1, className: r, children
1475
1765
  r,
1476
1766
  u,
1477
1767
  m
1478
- ]), /* @__PURE__ */ K(Or.Provider, {
1768
+ ]), /* @__PURE__ */ Q(fi.Provider, {
1479
1769
  value: {
1480
1770
  isStreaming: t,
1481
1771
  isOpen: l,
1482
1772
  setIsOpen: u,
1483
1773
  duration: f
1484
1774
  },
1485
- children: /* @__PURE__ */ K(w, {
1486
- className: H("not-prose mb-4", e),
1775
+ children: /* @__PURE__ */ Q(w, {
1776
+ className: J("not-prose mb-4", e),
1487
1777
  onOpenChange: (e) => {
1488
1778
  u(e);
1489
1779
  },
@@ -1492,69 +1782,80 @@ var Q = ({ code: e, language: t, showLineNumbers: n = !1, className: r, children
1492
1782
  children: o
1493
1783
  })
1494
1784
  });
1495
- }), Nr = (e, t) => e || t === 0 ? /* @__PURE__ */ K(Dr, {
1785
+ }), _i = (e, t) => e || t === 0 ? /* @__PURE__ */ Q(di, {
1496
1786
  duration: 1,
1497
1787
  children: "Thinking..."
1498
- }) : t === void 0 ? /* @__PURE__ */ K("p", { children: "Thought for a few seconds" }) : /* @__PURE__ */ q("p", { children: [
1788
+ }) : t === void 0 ? /* @__PURE__ */ Q("p", { children: "Thought for a few seconds" }) : /* @__PURE__ */ $("p", { children: [
1499
1789
  "Thought for ",
1500
1790
  t,
1501
1791
  " seconds"
1502
- ] }), Pr = a(({ className: e, children: t, getThinkingMessage: n = Nr, ...r }) => {
1503
- let { isStreaming: i, isOpen: a, duration: o } = kr();
1504
- return /* @__PURE__ */ K(E, {
1505
- className: H("flex w-full items-center gap-2 text-muted-foreground text-sm transition-colors hover:text-foreground", e),
1792
+ ] }), vi = a(({ className: e, children: t, getThinkingMessage: n = _i, ...r }) => {
1793
+ let { isStreaming: i, isOpen: a, duration: o } = pi();
1794
+ return /* @__PURE__ */ Q(E, {
1795
+ className: J("flex w-full items-center gap-2 text-muted-foreground text-sm transition-colors hover:text-foreground", e),
1506
1796
  ...r,
1507
- children: t ?? /* @__PURE__ */ q(G, { children: [
1508
- /* @__PURE__ */ K(Re, { className: "size-4" }),
1797
+ children: t ?? /* @__PURE__ */ $(Z, { children: [
1798
+ /* @__PURE__ */ Q(Ne, { className: "size-4" }),
1509
1799
  n(i, o),
1510
- /* @__PURE__ */ K(Ue, { className: H("size-4 transition-transform", a ? "rotate-180" : "rotate-0") })
1800
+ /* @__PURE__ */ Q(Le, { className: J("size-4 transition-transform", a ? "rotate-180" : "rotate-0") })
1511
1801
  ] })
1512
1802
  });
1513
- }), Fr = a(({ className: e, children: t, ...n }) => /* @__PURE__ */ K(T, {
1514
- className: H("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),
1803
+ }), yi = a(({ className: e, children: t, ...n }) => /* @__PURE__ */ Q(T, {
1804
+ className: J("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),
1515
1805
  ...n,
1516
- children: /* @__PURE__ */ K(St, { children: t })
1806
+ children: /* @__PURE__ */ Q(Dt, { children: t })
1517
1807
  }));
1518
- Mr.displayName = "Reasoning", Pr.displayName = "ReasoningTrigger", Fr.displayName = "ReasoningContent";
1808
+ gi.displayName = "Reasoning", vi.displayName = "ReasoningTrigger", yi.displayName = "ReasoningContent";
1519
1809
  //#endregion
1520
1810
  //#region src/elements/sources.tsx
1521
- var Ir = ({ className: e, ...t }) => /* @__PURE__ */ K(w, {
1522
- className: H("not-prose mb-4 text-primary text-xs", e),
1811
+ var bi = ({ className: e, ...t }) => /* @__PURE__ */ Q(w, {
1812
+ className: J("not-prose mb-4 text-primary text-xs", e),
1523
1813
  ...t
1524
- }), Lr = ({ className: e, count: t, children: n, ...r }) => /* @__PURE__ */ K(E, {
1525
- className: H("flex items-center gap-2", e),
1814
+ }), xi = ({ className: e, count: t, children: n, ...r }) => /* @__PURE__ */ Q(E, {
1815
+ className: J("flex items-center gap-2", e),
1526
1816
  ...r,
1527
- children: n ?? /* @__PURE__ */ q(G, { children: [/* @__PURE__ */ q("p", {
1817
+ children: n ?? /* @__PURE__ */ $(Z, { children: [/* @__PURE__ */ $("p", {
1528
1818
  className: "font-medium",
1529
1819
  children: [
1530
1820
  "Used ",
1531
1821
  t,
1532
1822
  " sources"
1533
1823
  ]
1534
- }), /* @__PURE__ */ K(Ue, { className: "h-4 w-4" })] })
1535
- }), Rr = ({ className: e, ...t }) => /* @__PURE__ */ K(T, {
1536
- className: H("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),
1824
+ }), /* @__PURE__ */ Q(Le, { className: "h-4 w-4" })] })
1825
+ }), Si = ({ className: e, ...t }) => /* @__PURE__ */ Q(T, {
1826
+ className: J("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),
1537
1827
  ...t
1538
- }), zr = ({ href: e, title: t, children: n, ...r }) => /* @__PURE__ */ K("a", {
1828
+ }), Ci = ({ href: e, title: t, children: n, ...r }) => /* @__PURE__ */ Q("a", {
1539
1829
  className: "flex items-center gap-2",
1540
1830
  href: e,
1541
1831
  rel: "noreferrer",
1542
1832
  target: "_blank",
1543
1833
  ...r,
1544
- children: n ?? /* @__PURE__ */ q(G, { children: [/* @__PURE__ */ K(Ie, { className: "h-4 w-4" }), /* @__PURE__ */ K("span", {
1834
+ children: n ?? /* @__PURE__ */ $(Z, { children: [/* @__PURE__ */ Q(je, { className: "h-4 w-4" }), /* @__PURE__ */ Q("span", {
1545
1835
  className: "block font-medium",
1546
1836
  children: t
1547
1837
  })] })
1548
1838
  });
1549
1839
  //#endregion
1550
1840
  //#region src/ChatbotEnhanced.tsx
1551
- function Br(e, t) {
1552
- return t ? "error" : e ? "streaming" : "ready";
1841
+ function wi(e) {
1842
+ let t = e ?? {}, n = t.data && typeof t.data == "object" ? t.data : t, r = n.seedApplied, i = n.probes;
1843
+ if (!r && !i) return;
1844
+ let a = {};
1845
+ return r && (r.success === !1 ? a.seedError = r.error ?? (Array.isArray(r.errors) && r.errors.length ? String(r.errors[0]) : "Sample data failed to load.") : a.seededRows = (r.inserted ?? 0) + (r.updated ?? 0)), i && (a.checked = {
1846
+ seeds: i.checked?.seeds ?? 0,
1847
+ views: i.checked?.views ?? 0,
1848
+ widgets: i.checked?.widgets ?? 0
1849
+ }, a.issues = (i.issues ?? []).filter((e) => e && typeof e.message == "string").map((e) => ({
1850
+ severity: e.severity === "error" ? "error" : "warning",
1851
+ code: String(e.code ?? "runtime_issue"),
1852
+ message: String(e.message)
1853
+ }))), a;
1553
1854
  }
1554
- function Vr(e) {
1855
+ function Ti(e) {
1555
1856
  return e === "user" ? "user" : "assistant";
1556
1857
  }
1557
- function Hr(e) {
1858
+ function Ei(e) {
1558
1859
  let t = e.trim();
1559
1860
  if (t.length < 2 || !(t.startsWith("{") || t.startsWith("[")) || !(t.endsWith("}") || t.endsWith("]"))) return !1;
1560
1861
  try {
@@ -1563,271 +1864,980 @@ function Hr(e) {
1563
1864
  return !1;
1564
1865
  }
1565
1866
  }
1566
- var $ = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type your message...", onSendMessage: i, onClear: a, onStop: o, onReload: s, disabled: c = !1, isLoading: l = !1, error: u, showTimestamp: d = !1, userAvatarUrl: f, userAvatarFallback: p = "You", assistantAvatarUrl: m, assistantAvatarFallback: h = "AI", maxHeight: g = "500px", enableMarkdown: _ = !0, enableFileUpload: v = !1, acceptedFileTypes: y = "image/*,.pdf,.doc,.docx,.txt", maxFileSize: b = 10 * 1024 * 1024, suggestions: x, models: S, selectedModelId: C, onModelChange: w, headerSlot: T, promptOverlaySlot: E, onInputChange: D, onToolApprove: O, toolApproveLabel: k = "Approve", toolDenyLabel: A = "Deny", toolDenyReason: j = "User denied the operation", toolDecisions: M, ...N }, P) => {
1567
- let F = Br(l, u), [I, L] = e.useState(null), ee = e.useCallback((e) => {
1867
+ function Di(e) {
1868
+ let t = e.state ?? (e.errorText ? "output-error" : e.result === void 0 ? "input-available" : "output-available");
1869
+ return t === "output-error" || t === "output-denied" ? "failed" : t === "approval-requested" || t === "approval-responded" ? "awaiting" : t === "output-available" ? "completed" : "running";
1870
+ }
1871
+ function Oi(e) {
1872
+ let t = Di(e);
1873
+ return t === "awaiting" || t === "failed" || !!e.pendingActionId || !!e.draftReview?.items.length || !!e.proposedPlan;
1874
+ }
1875
+ function ki(e) {
1876
+ switch (e) {
1877
+ case "failed": return 4;
1878
+ case "awaiting": return 3;
1879
+ case "running": return 2;
1880
+ case "completed": return 1;
1881
+ }
1882
+ }
1883
+ function Ai(e) {
1884
+ let t = /* @__PURE__ */ new Map();
1885
+ for (let n of e) {
1886
+ let e = Di(n), r = `${n.toolName}:${e}`, i = t.get(r);
1887
+ if (i) {
1888
+ i.count += 1, i.errorText = i.errorText ?? n.errorText;
1889
+ continue;
1890
+ }
1891
+ t.set(r, {
1892
+ key: r,
1893
+ title: Dn(n.toolName) || n.toolName,
1894
+ rawName: n.toolName,
1895
+ count: 1,
1896
+ state: e,
1897
+ errorText: n.errorText
1898
+ });
1899
+ }
1900
+ return Array.from(t.values()).sort((e, t) => {
1901
+ let n = ki(t.state) - ki(e.state);
1902
+ return n === 0 ? e.title.localeCompare(t.title) : n;
1903
+ });
1904
+ }
1905
+ function ji({ health: e }) {
1906
+ if (!e) return null;
1907
+ 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 = [];
1908
+ 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) {
1909
+ let e = [];
1910
+ i.views > 0 && e.push(`${i.views} view${i.views === 1 ? "" : "s"}`), i.widgets > 0 && e.push(`${i.widgets} widget${i.widgets === 1 ? "" : "s"}`), i.seeds > 0 && e.push(`${i.seeds} seed${i.seeds === 1 ? "" : "s"}`), e.length && o.push(`${e.join(" · ")} verified`);
1911
+ }
1912
+ return o.length === 0 && !e.seedError && t.length === 0 ? null : /* @__PURE__ */ $("div", {
1913
+ className: "flex flex-col gap-1 border-t bg-muted/20 px-3 py-2",
1914
+ "data-testid": "publish-health",
1915
+ children: [
1916
+ o.length > 0 ? /* @__PURE__ */ $("div", {
1917
+ className: "flex items-center gap-1.5 text-xs text-emerald-700",
1918
+ children: [/* @__PURE__ */ Q(Y, { className: "size-3.5 shrink-0" }), /* @__PURE__ */ Q("span", { children: o.join(" · ") })]
1919
+ }) : null,
1920
+ e.seedError ? /* @__PURE__ */ $("div", {
1921
+ className: "flex items-start gap-1.5 text-xs text-red-600",
1922
+ children: [/* @__PURE__ */ Q(X, { className: "mt-0.5 size-3.5 shrink-0" }), /* @__PURE__ */ Q("span", { children: e.seedError })]
1923
+ }) : null,
1924
+ n.map((e, t) => /* @__PURE__ */ $("div", {
1925
+ className: "flex items-start gap-1.5 text-xs text-red-600",
1926
+ children: [/* @__PURE__ */ Q(X, { className: "mt-0.5 size-3.5 shrink-0" }), /* @__PURE__ */ Q("span", { children: e.message })]
1927
+ }, `e${t}`)),
1928
+ r.map((e, t) => /* @__PURE__ */ $("div", {
1929
+ className: "flex items-start gap-1.5 text-xs text-amber-600",
1930
+ children: [/* @__PURE__ */ Q(Oe, { className: "mt-0.5 size-3.5 shrink-0" }), /* @__PURE__ */ Q("span", { children: e.message })]
1931
+ }, `w${t}`))
1932
+ ]
1933
+ });
1934
+ }
1935
+ var Mi = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type your message...", onSendMessage: i, onClear: a, onStop: o, onReload: s, onUpgrade: c, disabled: l = !1, isLoading: u = !1, error: d, showTimestamp: f = !1, showAvatars: p = !1, userAvatarUrl: m, userAvatarFallback: h = "You", assistantAvatarUrl: g, assistantAvatarFallback: _ = "AI", hideClearBar: v = !1, maxHeight: y = "500px", enableMarkdown: b = !0, enableFileUpload: x = !1, acceptedFileTypes: S = "image/*,.pdf,.doc,.docx,.txt", maxFileSize: C = 10 * 1024 * 1024, suggestions: w, labels: T, models: E, selectedModelId: D, onModelChange: O, headerSlot: k, promptOverlaySlot: A, onInputChange: j, onToolApprove: M, toolApproveLabel: N = "Approve", toolDenyLabel: ee = "Deny", toolDenyReason: te = "User denied the operation", toolDecisions: P, onReviewDraft: F, toolReviewLabel: ne = (e) => `Review ${e} change${e === 1 ? "" : "s"}`, onPublishDrafts: I, onOpenBuiltApp: re, openBuiltAppLabel: ie = "Open app", onPreviewDraftApp: ae, previewDraftLabel: L = "Preview", onDraftArtifacts: R, onBuildMaterialized: z, publishDraftsLabel: oe = "Publish", publishedLabel: B = "Published", verifiedLabel: se = "Verified", nextStepsLabel: ce = "What's next", planTitleLabel: le = "Proposed plan", planQuestionsLabel: ue = "Confirm before building", planAssumptionsLabel: de = "Assumptions", planApproveHintLabel: fe = "Reply to approve or adjust this plan.", planApproveLabel: pe = "Build it", planAdjustLabel: me = "Adjust", planApproveMessage: he = "Looks good — build it as proposed.", planApproveDefaultsMessage: ge = "Build it with your best assumptions; use sensible defaults for the open questions.", planAnswerMessage: _e = (e, t) => `For "${e}", go with: ${t}.`, fetchPendingDraftCount: V, autoPublishDrafts: ve = !1, processVisibility: H = "summary", surface: ye = "card", ...be }, U) => {
1936
+ let W = u ? "streaming" : "ready", G = ye === "plain", [K, xe] = e.useState(null), q = e.useMemo(() => ({
1937
+ emptyTitle: T?.emptyTitle ?? "Start a conversation",
1938
+ emptyDescription: T?.emptyDescription ?? "Ask anything — the assistant has access to your current app context.",
1939
+ clear: T?.clear ?? "Clear",
1940
+ sendHint: T?.sendHint ?? "to send",
1941
+ agentActivity: T?.agentActivity ?? "Agent activity",
1942
+ toolCompleted: T?.toolCompleted ?? "Completed",
1943
+ toolRunning: T?.toolRunning ?? "Running",
1944
+ toolAwaitingApproval: T?.toolAwaitingApproval ?? "Awaiting approval",
1945
+ toolFailed: T?.toolFailed ?? "Failed",
1946
+ toolDetailsHidden: T?.toolDetailsHidden ?? "Detailed tool inputs and outputs are hidden in this view.",
1947
+ copy: T?.copy ?? "Copy",
1948
+ copied: T?.copied ?? "Copied",
1949
+ regenerate: T?.regenerate ?? "Regenerate",
1950
+ model: T?.model ?? "Model",
1951
+ submit: T?.submit ?? "Submit",
1952
+ uploadFiles: T?.uploadFiles ?? "Upload files",
1953
+ stopResponse: T?.stopResponse ?? "Stop response",
1954
+ trace: T?.trace ?? "trace",
1955
+ viewTrace: T?.viewTrace ?? "View trace",
1956
+ connectionWaiting: T?.connectionWaiting ?? "Waiting for server…"
1957
+ }), [T]), [Se, Ce] = e.useState(() => /* @__PURE__ */ new Set()), [we, Te] = e.useState(() => /* @__PURE__ */ new Map()), [Ee, De] = e.useState(() => /* @__PURE__ */ new Map()), ke = e.useRef(/* @__PURE__ */ new Set()), Ae = e.useCallback(async (e) => {
1958
+ if (V) try {
1959
+ let t = await V(e);
1960
+ De((n) => {
1961
+ if (n.get(e) === t) return n;
1962
+ let r = new Map(n);
1963
+ return r.set(e, t), r;
1964
+ });
1965
+ } catch {}
1966
+ }, [V]);
1967
+ e.useEffect(() => {
1968
+ if (!V || u) return;
1969
+ let e = /* @__PURE__ */ new Set();
1970
+ for (let t of n) for (let n of t.toolInvocations ?? []) {
1971
+ let t = n.draftReview?.packageId, r = n.toolCallId;
1972
+ t && r && !ke.current.has(r) && (ke.current.add(r), e.add(t));
1973
+ }
1974
+ for (let t of e) Ae(t);
1975
+ }, [
1976
+ n,
1977
+ u,
1978
+ V,
1979
+ Ae
1980
+ ]);
1981
+ let je = e.useCallback(async (e) => {
1982
+ if (!I) return;
1983
+ let t = [];
1984
+ for (let r of n) for (let n of r.toolInvocations ?? []) n.draftReview?.packageId === e && n.toolCallId && t.push(n.toolCallId);
1985
+ let r = await I(e), i = r && typeof r == "object" ? r : void 0;
1986
+ if ((i ? i.ok !== !1 : r !== !1) && t.length > 0) {
1987
+ Ce((e) => {
1988
+ let n = new Set(e);
1989
+ for (let e of t) n.add(e);
1990
+ return n;
1991
+ });
1992
+ let e = i?.health;
1993
+ e && Te((n) => {
1994
+ let r = new Map(n);
1995
+ for (let n of t) r.set(n, e);
1996
+ return r;
1997
+ });
1998
+ }
1999
+ Ae(e);
2000
+ }, [
2001
+ I,
2002
+ n,
2003
+ Ae
2004
+ ]), Ne = e.useRef(/* @__PURE__ */ new Set()), Fe = e.useRef(!1);
2005
+ e.useEffect(() => {
2006
+ let e = [];
2007
+ for (let t of n) for (let n of t.toolInvocations ?? []) {
2008
+ let t = n.draftReview;
2009
+ t?.autoPublishable && t.packageId && n.toolCallId && t.items.length > 0 && e.push({
2010
+ key: n.toolCallId,
2011
+ packageId: t.packageId
2012
+ });
2013
+ }
2014
+ if (!Fe.current) {
2015
+ Fe.current = !0;
2016
+ for (let t of e) Ne.current.add(t.key);
2017
+ return;
2018
+ }
2019
+ if (!ve || !I || u) return;
2020
+ let t = e.filter((e) => !Ne.current.has(e.key));
2021
+ if (t.length !== 0) {
2022
+ for (let e of t) Ne.current.add(e.key);
2023
+ for (let e of [...new Set(t.map((e) => e.packageId))]) je(e);
2024
+ }
2025
+ }, [
2026
+ n,
2027
+ u,
2028
+ ve,
2029
+ I,
2030
+ je
2031
+ ]);
2032
+ let Ie = e.useRef(/* @__PURE__ */ new Set());
2033
+ e.useEffect(() => {
2034
+ if (!R) return;
2035
+ let e = /* @__PURE__ */ new Map();
2036
+ for (let t of n) {
2037
+ for (let n of t.buildProgress?.items ?? []) n?.type && n?.name && e.set(`${n.type}:${n.name}`, n);
2038
+ for (let n of t.toolInvocations ?? []) for (let t of n.draftReview?.items ?? []) t?.type && t?.name && e.set(`${t.type}:${t.name}`, t);
2039
+ }
2040
+ let t = Ie.current, r = !1;
2041
+ for (let n of e.keys()) t.has(n) || (t.add(n), r = !0);
2042
+ r && R([...e.values()]);
2043
+ }, [n, R]);
2044
+ let Le = e.useRef(/* @__PURE__ */ new Set());
2045
+ e.useEffect(() => {
2046
+ if (z) for (let e of n) for (let t of e.toolInvocations ?? []) {
2047
+ let e = t.draftReview;
2048
+ if (!e?.materialized || !t.toolCallId) continue;
2049
+ let n = e.items.find((e) => e.type === "app");
2050
+ !n || Le.current.has(t.toolCallId) || (Le.current.add(t.toolCallId), z(n.name));
2051
+ }
2052
+ }, [n, z]);
2053
+ let Re = e.useCallback((e) => {
1568
2054
  let t = !!e.text?.trim(), n = e.files?.map((e) => e.file).filter(Boolean), r = !!(n && n.length > 0);
1569
2055
  (t || r) && i?.(e.text?.trim() ?? "", n);
1570
- }, [i]), te = e.useCallback((e) => {
2056
+ }, [i]), ze = e.useCallback((e) => {
1571
2057
  i?.(e);
1572
- }, [i]), ne = e.useCallback((e) => {
1573
- navigator.clipboard?.writeText(e.content), L(e.id), window.setTimeout(() => L((t) => t === e.id ? null : t), 1500);
1574
- }, []);
1575
- return /* @__PURE__ */ q("div", {
1576
- ref: P,
1577
- className: H("flex flex-col border rounded-lg bg-background overflow-hidden", t),
1578
- style: { maxHeight: g },
1579
- ...N,
1580
- children: [
1581
- a && n.length > 0 && /* @__PURE__ */ q("div", {
1582
- className: "flex items-center justify-between px-4 py-2 border-b bg-muted/30",
1583
- children: [/* @__PURE__ */ q("span", {
1584
- className: "text-sm text-muted-foreground",
2058
+ }, [i]), Be = e.useRef(null), He = e.useCallback((e) => {
2059
+ i?.(e ? ge : he);
2060
+ }, [
2061
+ i,
2062
+ he,
2063
+ ge
2064
+ ]), Ue = e.useCallback(() => {
2065
+ let e = Be.current?.querySelector("textarea");
2066
+ e && (e.focus(), e.scrollIntoView({ block: "nearest" }));
2067
+ }, []), We = e.useCallback((e) => {
2068
+ navigator.clipboard?.writeText(e.content), xe(e.id), window.setTimeout(() => xe((t) => t === e.id ? null : t), 1500);
2069
+ }, []), Ke = (e) => {
2070
+ let t = e.state ?? (e.errorText ? "output-error" : e.result === void 0 ? "input-available" : "output-available"), n = `tool-${e.toolName}`, r = P?.[e.toolCallId], a = t === "approval-requested" && !!M && !r, o = t === "approval-requested" && !!e.pendingActionId, s = Dn(e.toolName), c = On(e.result), l = H === "debug" && s && s.toLowerCase() !== e.toolName.toLowerCase(), u = H === "debug" || a, d = e.draftReview?.packageId, f = d === void 0 ? void 0 : Ee.get(d), p = f === void 0 ? Se.has(e.toolCallId) : f === 0, m = /* @__PURE__ */ $("span", {
2071
+ className: "inline-flex items-center gap-2",
2072
+ children: [/* @__PURE__ */ Q("span", { children: s || e.toolName }), l ? /* @__PURE__ */ Q("code", {
2073
+ className: "rounded bg-muted px-1 py-px text-[10px] font-mono text-muted-foreground",
2074
+ children: e.toolName
2075
+ }) : null]
2076
+ });
2077
+ return /* @__PURE__ */ $(ai, {
2078
+ defaultOpen: t === "output-error" || t === "approval-requested" || !!(e.draftReview && e.draftReview.items.length > 0) || !!e.proposedPlan,
2079
+ children: [/* @__PURE__ */ Q(si, {
2080
+ type: n,
2081
+ state: t,
2082
+ title: m
2083
+ }), /* @__PURE__ */ $(ci, { children: [
2084
+ u && e.args !== void 0 ? /* @__PURE__ */ Q(li, { input: e.args }) : null,
2085
+ o ? null : u || t === "output-error" ? /* @__PURE__ */ Q(qi, {
2086
+ output: c,
2087
+ errorText: e.errorText
2088
+ }) : null,
2089
+ r ? /* @__PURE__ */ $("div", {
2090
+ className: "flex items-center gap-2 p-3 border-t text-xs " + (r.state === "error" ? "bg-destructive/10 text-destructive" : r.state === "success" ? "bg-emerald-500/10 text-emerald-700 dark:text-emerald-400" : "bg-muted/30 text-muted-foreground"),
2091
+ children: [/* @__PURE__ */ Q("span", {
2092
+ "aria-hidden": "true",
2093
+ children: r.state === "pending" ? "..." : r.state === "success" ? "OK" : "X"
2094
+ }), /* @__PURE__ */ Q("span", { children: r.message ?? (r.state === "pending" ? "Submitting decision..." : r.state === "success" ? "Action approved and executed." : "Decision failed.") })]
2095
+ }) : null,
2096
+ a ? /* @__PURE__ */ $("div", {
2097
+ className: "flex gap-2 p-3 border-t bg-muted/30",
2098
+ children: [/* @__PURE__ */ Q("button", {
2099
+ type: "button",
2100
+ onClick: () => M?.(e.toolCallId, !0),
2101
+ className: "inline-flex h-7 items-center rounded-md bg-primary px-3 text-xs font-medium text-primary-foreground hover:bg-primary/90",
2102
+ children: N
2103
+ }), /* @__PURE__ */ Q("button", {
2104
+ type: "button",
2105
+ onClick: () => M?.(e.toolCallId, !1, te),
2106
+ className: "inline-flex h-7 items-center rounded-md border bg-background px-3 text-xs font-medium hover:bg-accent",
2107
+ children: ee
2108
+ })]
2109
+ }) : null,
2110
+ e.draftReview && e.draftReview.items.length > 0 && (F || I && e.draftReview.packageId) ? /* @__PURE__ */ $(Z, { children: [
2111
+ /* @__PURE__ */ $("div", {
2112
+ className: "flex items-center gap-2 p-3 border-t bg-muted/30",
2113
+ children: [
2114
+ I && e.draftReview.packageId ? p ? /* @__PURE__ */ $("span", {
2115
+ className: "inline-flex h-7 items-center gap-1.5 rounded-md border border-emerald-200 bg-emerald-50 px-3 text-xs font-medium text-emerald-700",
2116
+ children: [
2117
+ /* @__PURE__ */ Q(Y, { className: "size-3.5" }),
2118
+ B,
2119
+ e.draftReview.failedCount ? ` · ${e.draftReview.failedCount} need${e.draftReview.failedCount === 1 ? "s" : ""} attention` : ""
2120
+ ]
2121
+ }) : /* @__PURE__ */ $("button", {
2122
+ type: "button",
2123
+ onClick: () => void je(e.draftReview.packageId),
2124
+ className: "inline-flex h-7 items-center gap-1.5 rounded-md bg-primary px-3 text-xs font-medium text-primary-foreground hover:bg-primary/90",
2125
+ "data-testid": "draft-publish",
2126
+ children: [
2127
+ /* @__PURE__ */ Q(ct, { className: "size-3.5" }),
2128
+ oe,
2129
+ typeof f == "number" && f > 0 ? ` (${f})` : ""
2130
+ ]
2131
+ }) : null,
2132
+ F ? /* @__PURE__ */ $("button", {
2133
+ type: "button",
2134
+ onClick: () => F(e.draftReview.items),
2135
+ className: I && e.draftReview.packageId ? "inline-flex h-7 items-center gap-1.5 rounded-md border px-3 text-xs font-medium hover:bg-muted" : "inline-flex h-7 items-center gap-1.5 rounded-md bg-primary px-3 text-xs font-medium text-primary-foreground hover:bg-primary/90",
2136
+ children: [/* @__PURE__ */ Q(Xe, { className: "size-3.5" }), ne(e.draftReview.items.length)]
2137
+ }) : null,
2138
+ ae && !p ? (() => {
2139
+ let t = e.draftReview.items.find((e) => e.type === "app");
2140
+ return t ? /* @__PURE__ */ $("button", {
2141
+ type: "button",
2142
+ onClick: () => ae(t.name, { materialized: e.draftReview.materialized === !0 }),
2143
+ className: "inline-flex h-7 items-center gap-1.5 rounded-md border px-3 text-xs font-medium hover:bg-muted",
2144
+ "data-testid": "draft-preview-app",
2145
+ children: [/* @__PURE__ */ Q(Ye, { className: "size-3.5" }), L]
2146
+ }) : null;
2147
+ })() : null,
2148
+ e.draftReview.verification ? e.draftReview.verification.errors > 0 ? /* @__PURE__ */ $("span", {
2149
+ className: "inline-flex h-7 shrink-0 items-center gap-1.5 rounded-md border border-amber-200 bg-amber-50 px-2.5 text-xs font-medium text-amber-700",
2150
+ "data-testid": "draft-verification-chip",
2151
+ children: [/* @__PURE__ */ Q(pt, { className: "size-3.5" }), `${e.draftReview.verification.errors} issue${e.draftReview.verification.errors === 1 ? "" : "s"}`]
2152
+ }) : /* @__PURE__ */ $("span", {
2153
+ className: "inline-flex h-7 shrink-0 items-center gap-1.5 rounded-md border border-emerald-200 bg-emerald-50 px-2.5 text-xs font-medium text-emerald-700",
2154
+ "data-testid": "draft-verification-chip",
2155
+ children: [/* @__PURE__ */ Q(ut, { className: "size-3.5" }), se]
2156
+ }) : null,
2157
+ e.draftReview.summary ? /* @__PURE__ */ Q("span", {
2158
+ className: "truncate text-xs text-muted-foreground",
2159
+ children: e.draftReview.summary
2160
+ }) : null
2161
+ ]
2162
+ }),
2163
+ e.draftReview.issues && e.draftReview.issues.length > 0 ? /* @__PURE__ */ $("div", {
2164
+ className: "flex flex-col gap-1 border-t bg-muted/20 px-3 py-2",
2165
+ "data-testid": "draft-issues",
2166
+ children: [e.draftReview.issues.filter((e) => e.severity === "error").map((e, t) => /* @__PURE__ */ $("div", {
2167
+ className: "flex items-start gap-1.5 text-xs text-red-600",
2168
+ children: [/* @__PURE__ */ Q(X, { className: "mt-0.5 size-3.5 shrink-0" }), /* @__PURE__ */ Q("span", { children: e.fix ? `${e.message} — ${e.fix}` : e.message })]
2169
+ }, `e${t}`)), e.draftReview.issues.filter((e) => e.severity !== "error").map((e, t) => /* @__PURE__ */ $("div", {
2170
+ className: "flex items-start gap-1.5 text-xs text-amber-600",
2171
+ children: [/* @__PURE__ */ Q(Oe, { className: "mt-0.5 size-3.5 shrink-0" }), /* @__PURE__ */ Q("span", { children: e.message })]
2172
+ }, `w${t}`))]
2173
+ }) : null,
2174
+ Se.has(e.toolCallId) ? /* @__PURE__ */ Q(ji, { health: we.get(e.toolCallId) }) : null,
2175
+ e.draftReview.nextSteps && e.draftReview.nextSteps.length > 0 ? /* @__PURE__ */ $("div", {
2176
+ className: "flex flex-col gap-1 border-t bg-muted/20 px-3 py-2",
2177
+ "data-testid": "draft-next-steps",
2178
+ children: [/* @__PURE__ */ Q("span", {
2179
+ className: "text-xs font-medium text-foreground/80",
2180
+ children: ce
2181
+ }), e.draftReview.nextSteps.map((e, t) => /* @__PURE__ */ $("div", {
2182
+ className: "flex items-start gap-1.5 text-xs text-muted-foreground",
2183
+ children: [/* @__PURE__ */ Q("span", {
2184
+ className: "mt-px shrink-0 text-foreground/40",
2185
+ children: "→"
2186
+ }), /* @__PURE__ */ Q("span", { children: e })]
2187
+ }, t))]
2188
+ }) : null
2189
+ ] }) : null,
2190
+ e.proposedPlan ? /* @__PURE__ */ $("div", {
2191
+ className: "flex flex-col gap-2 border-t bg-muted/20 px-3 py-2.5",
2192
+ "data-testid": "proposed-plan",
1585
2193
  children: [
1586
- n.length,
1587
- " message",
1588
- n.length === 1 ? "" : "s"
2194
+ /* @__PURE__ */ $("span", {
2195
+ className: "inline-flex items-center gap-1.5 text-xs font-medium text-foreground/80",
2196
+ children: [/* @__PURE__ */ Q(Ve, { className: "size-3.5" }), le]
2197
+ }),
2198
+ e.proposedPlan.summary ? /* @__PURE__ */ Q("p", {
2199
+ className: "text-xs text-muted-foreground",
2200
+ children: e.proposedPlan.summary
2201
+ }) : null,
2202
+ e.proposedPlan.objects.length > 0 ? /* @__PURE__ */ Q("div", {
2203
+ className: "flex flex-wrap gap-1.5",
2204
+ children: e.proposedPlan.objects.map((e) => /* @__PURE__ */ $("span", {
2205
+ className: "inline-flex items-center gap-1 rounded-md border bg-background px-1.5 py-0.5 text-[11px] text-foreground/80",
2206
+ title: e.name,
2207
+ children: [
2208
+ /* @__PURE__ */ Q(ft, { className: "size-3 text-foreground/40" }),
2209
+ e.label || e.name,
2210
+ e.fieldCount > 0 ? /* @__PURE__ */ $("span", {
2211
+ className: "text-foreground/40",
2212
+ children: ["· ", e.fieldCount]
2213
+ }) : null
2214
+ ]
2215
+ }, e.name))
2216
+ }) : null,
2217
+ (() => {
2218
+ let t = e.proposedPlan.counts, n = [];
2219
+ return t.objects && n.push(`${t.objects} object${t.objects === 1 ? "" : "s"}`), t.views && n.push(`${t.views} view${t.views === 1 ? "" : "s"}`), t.dashboards && n.push(`${t.dashboards} dashboard${t.dashboards === 1 ? "" : "s"}`), t.seedData && n.push("sample data"), n.length ? /* @__PURE__ */ Q("span", {
2220
+ className: "text-[11px] text-muted-foreground",
2221
+ children: n.join(" · ")
2222
+ }) : null;
2223
+ })(),
2224
+ e.proposedPlan.assumptions.length > 0 ? /* @__PURE__ */ $("div", {
2225
+ className: "flex flex-col gap-0.5",
2226
+ children: [/* @__PURE__ */ Q("span", {
2227
+ className: "text-[11px] font-medium text-foreground/70",
2228
+ children: de
2229
+ }), e.proposedPlan.assumptions.map((e, t) => /* @__PURE__ */ $("div", {
2230
+ className: "flex items-start gap-1.5 text-[11px] text-muted-foreground",
2231
+ children: [/* @__PURE__ */ Q("span", {
2232
+ className: "mt-px shrink-0 text-foreground/40",
2233
+ children: "·"
2234
+ }), /* @__PURE__ */ Q("span", { children: e })]
2235
+ }, t))]
2236
+ }) : null,
2237
+ e.proposedPlan.questions.length > 0 ? /* @__PURE__ */ $("div", {
2238
+ className: "flex flex-col gap-1 rounded-md border border-amber-200 bg-amber-50 px-2 py-1.5 dark:border-amber-900/50 dark:bg-amber-950/30",
2239
+ "data-testid": "proposed-plan-questions",
2240
+ children: [/* @__PURE__ */ $("span", {
2241
+ className: "inline-flex items-center gap-1.5 text-[11px] font-medium text-amber-800 dark:text-amber-300",
2242
+ children: [/* @__PURE__ */ Q(Ze, { className: "size-3.5" }), ue]
2243
+ }), e.proposedPlan.questions.map((t, n) => {
2244
+ let r = e.proposedPlan.questionChoices?.find((e) => e.text === t);
2245
+ return /* @__PURE__ */ $("div", {
2246
+ className: "flex flex-col gap-1",
2247
+ children: [/* @__PURE__ */ $("div", {
2248
+ className: "flex items-start gap-1.5 text-[11px] text-amber-900/90 dark:text-amber-200/90",
2249
+ children: [/* @__PURE__ */ Q("span", {
2250
+ className: "mt-px shrink-0",
2251
+ children: "?"
2252
+ }), /* @__PURE__ */ Q("span", { children: t })]
2253
+ }), i && r && r.options.length > 0 ? /* @__PURE__ */ Q("div", {
2254
+ className: "flex flex-wrap gap-1 pl-3.5",
2255
+ "data-testid": "proposed-plan-choice",
2256
+ children: r.options.map((e, n) => /* @__PURE__ */ Q("button", {
2257
+ type: "button",
2258
+ onClick: () => i(_e(t, e)),
2259
+ className: "inline-flex h-6 items-center rounded-full border border-amber-300 bg-background px-2 text-[11px] font-medium text-amber-900 hover:bg-amber-100 dark:border-amber-800 dark:text-amber-200 dark:hover:bg-amber-900/40",
2260
+ children: e
2261
+ }, n))
2262
+ }) : null]
2263
+ }, n);
2264
+ })]
2265
+ }) : null,
2266
+ i ? /* @__PURE__ */ $("div", {
2267
+ className: "flex flex-wrap items-center gap-1.5 pt-0.5",
2268
+ "data-testid": "proposed-plan-actions",
2269
+ children: [/* @__PURE__ */ $("button", {
2270
+ type: "button",
2271
+ onClick: () => He(e.proposedPlan.questions.length > 0),
2272
+ className: "inline-flex h-7 items-center gap-1.5 rounded-md bg-primary px-3 text-xs font-medium text-primary-foreground hover:bg-primary/90",
2273
+ "data-testid": "proposed-plan-approve",
2274
+ children: [/* @__PURE__ */ Q(ct, { className: "size-3.5" }), pe]
2275
+ }), /* @__PURE__ */ Q("button", {
2276
+ type: "button",
2277
+ onClick: Ue,
2278
+ className: "inline-flex h-7 items-center rounded-md border bg-background px-3 text-xs font-medium hover:bg-accent",
2279
+ "data-testid": "proposed-plan-adjust",
2280
+ children: me
2281
+ })]
2282
+ }) : /* @__PURE__ */ Q("span", {
2283
+ className: "text-[11px] italic text-muted-foreground/80",
2284
+ children: fe
2285
+ })
1589
2286
  ]
1590
- }), /* @__PURE__ */ K("button", {
2287
+ }) : null
2288
+ ] })]
2289
+ }, e.toolCallId);
2290
+ };
2291
+ return /* @__PURE__ */ $("div", {
2292
+ ref: U,
2293
+ className: J(G ? "flex min-h-0 flex-col overflow-hidden bg-background" : "flex min-h-0 flex-col overflow-hidden rounded-lg border bg-background", t),
2294
+ style: { maxHeight: y },
2295
+ ...be,
2296
+ children: [
2297
+ a && !v && n.length > 0 && /* @__PURE__ */ Q("div", {
2298
+ className: J("flex items-center justify-end px-4 py-2", G ? "bg-background" : "border-b bg-muted/30"),
2299
+ children: /* @__PURE__ */ Q("button", {
1591
2300
  type: "button",
1592
2301
  onClick: a,
1593
2302
  className: "text-xs text-muted-foreground hover:text-foreground transition-colors",
1594
- children: "Clear"
1595
- })]
2303
+ children: q.clear
2304
+ })
1596
2305
  }),
1597
- T ? /* @__PURE__ */ K("div", {
1598
- className: "shrink-0 border-b bg-background/50",
1599
- children: T
2306
+ k ? /* @__PURE__ */ Q("div", {
2307
+ className: J("shrink-0", !G && "border-b bg-background/50"),
2308
+ children: k
1600
2309
  }) : null,
1601
- /* @__PURE__ */ q(Zt, {
2310
+ /* @__PURE__ */ $(Mn, {
1602
2311
  className: "flex-1 min-h-0",
1603
- children: [/* @__PURE__ */ K(Qt, {
1604
- className: "space-y-4 px-4 py-3",
1605
- children: n.length === 0 ? /* @__PURE__ */ K($t, {
1606
- title: "Start a conversation",
1607
- description: "Ask anything — the assistant has access to your current app context.",
1608
- children: x && x.length > 0 ? /* @__PURE__ */ K(hr, {
1609
- className: "justify-center pt-2",
1610
- children: x.map((e) => /* @__PURE__ */ K(gr, {
1611
- suggestion: e,
1612
- onClick: te
1613
- }, e))
1614
- }) : null
2312
+ children: [/* @__PURE__ */ $(Nn, {
2313
+ className: J("space-y-4", G ? "mx-auto w-full max-w-2xl px-4 py-8 sm:px-0" : "px-4 py-3"),
2314
+ children: [n.length === 0 ? /* @__PURE__ */ $(Pn, {
2315
+ className: "gap-3 px-0 py-8",
2316
+ children: [
2317
+ /* @__PURE__ */ Q("div", {
2318
+ className: "flex size-9 items-center justify-center rounded-md bg-muted/70 text-muted-foreground",
2319
+ children: g ? /* @__PURE__ */ Q("img", {
2320
+ src: g,
2321
+ alt: "",
2322
+ className: "size-full rounded-md object-cover"
2323
+ }) : /* @__PURE__ */ Q(Me, { className: "size-4" })
2324
+ }),
2325
+ /* @__PURE__ */ $("div", {
2326
+ className: "space-y-1",
2327
+ children: [/* @__PURE__ */ Q("h3", {
2328
+ className: "text-sm font-medium text-foreground/90",
2329
+ children: q.emptyTitle
2330
+ }), /* @__PURE__ */ Q("p", {
2331
+ className: "text-sm text-muted-foreground",
2332
+ children: q.emptyDescription
2333
+ })]
2334
+ }),
2335
+ w && w.length > 0 ? /* @__PURE__ */ Q(Qr, {
2336
+ className: "justify-center gap-2",
2337
+ children: w.map((e) => /* @__PURE__ */ Q($r, {
2338
+ className: "h-8 border-border/60 bg-background/80 px-3 text-xs font-medium text-foreground/90 shadow-none hover:bg-muted/60",
2339
+ suggestion: e,
2340
+ onClick: ze
2341
+ }, e))
2342
+ }) : null
2343
+ ]
1615
2344
  }) : n.map((e) => {
1616
- let t = e.role === "user", n = e.toolInvocations ?? [], r = e.reasoning?.trim(), i = e.sources ?? [];
1617
- return /* @__PURE__ */ q(an, {
1618
- from: Vr(e.role),
1619
- children: [/* @__PURE__ */ q(on, { children: [
1620
- !t && r ? /* @__PURE__ */ q(Mr, {
1621
- isStreaming: !!e.streaming && !e.content,
1622
- className: "mb-2",
1623
- children: [/* @__PURE__ */ K(Pr, {}), /* @__PURE__ */ K(Fr, { children: r })]
1624
- }) : null,
1625
- !t && n.length > 0 ? n.map((e) => {
1626
- let t = e.state ?? (e.errorText ? "output-error" : e.result === void 0 ? "input-available" : "output-available"), n = `tool-${e.toolName}`, r = M?.[e.toolCallId], i = t === "approval-requested" && !!O && !r, a = t === "approval-requested" && !!e.pendingActionId, o = Jt(e.toolName), s = Yt(e.result), c = /* @__PURE__ */ q("span", {
1627
- className: "inline-flex items-center gap-2",
1628
- children: [/* @__PURE__ */ K("span", { children: o || e.toolName }), o && o.toLowerCase() !== e.toolName.toLowerCase() ? /* @__PURE__ */ K("code", {
1629
- className: "rounded bg-muted px-1 py-px text-[10px] font-mono text-muted-foreground",
1630
- children: e.toolName
1631
- }) : null]
1632
- });
1633
- return /* @__PURE__ */ q(xr, {
1634
- defaultOpen: t === "output-error" || t === "approval-requested",
1635
- children: [/* @__PURE__ */ K(Cr, {
1636
- type: n,
1637
- state: t,
1638
- title: c
1639
- }), /* @__PURE__ */ q(wr, { children: [
1640
- e.args === void 0 ? null : /* @__PURE__ */ K(Tr, { input: e.args }),
1641
- a ? null : /* @__PURE__ */ K(Wr, {
1642
- output: s,
1643
- errorText: e.errorText
2345
+ let t = e.role === "user", n = e.toolInvocations ?? [], r = e.reasoning?.trim(), i = e.sources ?? [], a = t ? void 0 : e.buildProgress, o = !t && !!e.streaming && !e.content && n.length === 0 && !r && !a, c = !t && H === "summary" ? n.filter((e) => !Oi(e)) : [], l = !t && H === "debug" ? n : !t && H !== "debug" ? n.filter(Oi) : [];
2346
+ return /* @__PURE__ */ Q(zn, {
2347
+ from: Ti(e.role),
2348
+ children: /* @__PURE__ */ $("div", {
2349
+ className: J("flex w-full gap-2.5", p ? t ? "flex-row-reverse items-start" : "flex-row items-start" : "flex-col"),
2350
+ children: [p ? /* @__PURE__ */ Q(Ni, {
2351
+ isUser: t,
2352
+ url: t ? m : g,
2353
+ fallback: t ? h : _
2354
+ }) : null, /* @__PURE__ */ $("div", {
2355
+ className: J("flex min-w-0 flex-col gap-2", p && !t && "flex-1"),
2356
+ children: [/* @__PURE__ */ $(Bn, { children: [
2357
+ a ? /* @__PURE__ */ Q(Hi, {
2358
+ progress: a,
2359
+ onOpenBuiltApp: re,
2360
+ openBuiltAppLabel: ie,
2361
+ onPreviewDraftApp: ae,
2362
+ previewDraftLabel: L,
2363
+ waitingLabel: q.connectionWaiting
2364
+ }) : null,
2365
+ !t && H === "debug" && r ? /* @__PURE__ */ $(gi, {
2366
+ isStreaming: !!e.streaming && !e.content,
2367
+ className: "mb-2",
2368
+ children: [/* @__PURE__ */ Q(vi, {}), /* @__PURE__ */ Q(yi, { children: r })]
2369
+ }) : null,
2370
+ !t && H === "summary" && c.length > 0 ? /* @__PURE__ */ Q(Ui, {
2371
+ groups: Ai(c),
2372
+ labels: q
2373
+ }) : null,
2374
+ !t && l.length > 0 ? l.map(Ke) : null,
2375
+ t ? e.content ? /* @__PURE__ */ Q("div", {
2376
+ className: "whitespace-pre-wrap break-words",
2377
+ children: e.content
2378
+ }) : null : o ? /* @__PURE__ */ Q(Fi, {}) : e.content ? /* @__PURE__ */ Q(Zn, { children: e.content }) : null,
2379
+ e.streaming && !o ? /* @__PURE__ */ Q("span", {
2380
+ "aria-hidden": !0,
2381
+ className: "ml-0.5 inline-block w-[2px] h-4 align-middle bg-current animate-pulse"
2382
+ }) : null,
2383
+ !t && (e.charts?.length ?? 0) > 0 ? /* @__PURE__ */ Q("div", {
2384
+ className: "mt-2 flex flex-col gap-3",
2385
+ "data-testid": "chat-charts",
2386
+ children: e.charts.map((e, t) => /* @__PURE__ */ $("div", {
2387
+ className: "rounded-lg border bg-background p-3",
2388
+ style: { width: "min(520px, 80vw)" },
2389
+ "data-testid": "chat-chart",
2390
+ children: [e.title ? /* @__PURE__ */ Q("div", {
2391
+ className: "mb-2 text-sm font-medium text-foreground",
2392
+ children: e.title
2393
+ }) : null, /* @__PURE__ */ Q(xt, { schema: {
2394
+ type: "chart",
2395
+ chartType: e.chartType ?? "bar",
2396
+ data: e.data,
2397
+ xAxisKey: e.xAxisKey,
2398
+ series: e.series
2399
+ } })]
2400
+ }, t))
2401
+ }) : null,
2402
+ !t && i.length > 0 ? /* @__PURE__ */ $(bi, { children: [/* @__PURE__ */ Q(xi, { count: i.length }), /* @__PURE__ */ Q(Si, { children: i.map((e, t) => /* @__PURE__ */ Q(Ci, {
2403
+ href: e.url,
2404
+ title: e.title ?? e.url
2405
+ }, e.id ?? e.url ?? t)) })] }) : null,
2406
+ f && e.timestamp ? /* @__PURE__ */ Q("div", {
2407
+ className: "text-[10px] opacity-70 mt-1",
2408
+ children: e.timestamp
2409
+ }) : null
2410
+ ] }), !t && !o ? /* @__PURE__ */ $(Vn, {
2411
+ className: "opacity-0 transition-opacity group-focus-within:opacity-100 group-hover:opacity-100",
2412
+ children: [
2413
+ /* @__PURE__ */ Q(Hn, {
2414
+ label: K === e.id ? q.copied : q.copy,
2415
+ tooltip: K === e.id ? q.copied : q.copy,
2416
+ onClick: () => We(e),
2417
+ children: K === e.id ? /* @__PURE__ */ Q(Pe, { className: "size-3.5" }) : /* @__PURE__ */ Q(Ge, { className: "size-3.5" })
1644
2418
  }),
1645
- r ? /* @__PURE__ */ q("div", {
1646
- className: "flex items-center gap-2 p-3 border-t text-xs " + (r.state === "error" ? "bg-destructive/10 text-destructive" : r.state === "success" ? "bg-emerald-500/10 text-emerald-700 dark:text-emerald-400" : "bg-muted/30 text-muted-foreground"),
1647
- children: [/* @__PURE__ */ K("span", {
1648
- "aria-hidden": "true",
1649
- children: r.state === "pending" ? "⏳" : r.state === "success" ? "✓" : "✗"
1650
- }), /* @__PURE__ */ K("span", { children: r.message ?? (r.state === "pending" ? "Submitting decision…" : r.state === "success" ? "Action approved and executed." : "Decision failed.") })]
2419
+ s ? /* @__PURE__ */ Q(Hn, {
2420
+ label: q.regenerate,
2421
+ tooltip: q.regenerate,
2422
+ onClick: s,
2423
+ children: /* @__PURE__ */ Q(st, { className: "size-3.5" })
1651
2424
  }) : null,
1652
- i ? /* @__PURE__ */ q("div", {
1653
- className: "flex gap-2 p-3 border-t bg-muted/30",
1654
- children: [/* @__PURE__ */ K("button", {
1655
- type: "button",
1656
- onClick: () => O?.(e.toolCallId, !0),
1657
- className: "inline-flex h-7 items-center rounded-md bg-primary px-3 text-xs font-medium text-primary-foreground hover:bg-primary/90",
1658
- children: k
1659
- }), /* @__PURE__ */ K("button", {
1660
- type: "button",
1661
- onClick: () => O?.(e.toolCallId, !1, j),
1662
- className: "inline-flex h-7 items-center rounded-md border bg-background px-3 text-xs font-medium hover:bg-accent",
1663
- children: A
1664
- })]
2425
+ H === "debug" && e.traceId ? /* @__PURE__ */ Q("a", {
2426
+ href: `#trace/${e.traceId}`,
2427
+ "data-trace-id": e.traceId,
2428
+ className: "text-[10px] text-muted-foreground hover:text-foreground ml-1 underline",
2429
+ title: q.viewTrace,
2430
+ children: q.trace
1665
2431
  }) : null
1666
- ] })]
1667
- }, e.toolCallId);
1668
- }) : null,
1669
- t ? e.content ? /* @__PURE__ */ K("div", {
1670
- className: "whitespace-pre-wrap break-words",
1671
- children: e.content
1672
- }) : null : e.content ? /* @__PURE__ */ K(X, { children: e.content }) : null,
1673
- e.streaming ? /* @__PURE__ */ K("span", {
1674
- "aria-hidden": !0,
1675
- className: "ml-0.5 inline-block w-[2px] h-4 align-middle bg-current animate-pulse"
1676
- }) : null,
1677
- !t && i.length > 0 ? /* @__PURE__ */ q(Ir, { children: [/* @__PURE__ */ K(Lr, { count: i.length }), /* @__PURE__ */ K(Rr, { children: i.map((e, t) => /* @__PURE__ */ K(zr, {
1678
- href: e.url,
1679
- title: e.title ?? e.url
1680
- }, e.id ?? e.url ?? t)) })] }) : null,
1681
- d && e.timestamp ? /* @__PURE__ */ K("div", {
1682
- className: "text-[10px] opacity-70 mt-1",
1683
- children: e.timestamp
1684
- }) : null
1685
- ] }), t ? null : /* @__PURE__ */ q(sn, { children: [
1686
- /* @__PURE__ */ K(cn, {
1687
- label: "Copy",
1688
- tooltip: "Copy",
1689
- onClick: () => ne(e),
1690
- children: I === e.id ? /* @__PURE__ */ K(ze, { className: "size-3.5" }) : /* @__PURE__ */ K(Ye, { className: "size-3.5" })
1691
- }),
1692
- s ? /* @__PURE__ */ K(cn, {
1693
- label: "Regenerate",
1694
- tooltip: "Regenerate",
1695
- onClick: s,
1696
- children: /* @__PURE__ */ K(ct, { className: "size-3.5" })
1697
- }) : null,
1698
- e.traceId ? /* @__PURE__ */ K("a", {
1699
- href: `#trace/${e.traceId}`,
1700
- "data-trace-id": e.traceId,
1701
- className: "text-[10px] text-muted-foreground hover:text-foreground ml-1 underline",
1702
- title: "View trace",
1703
- children: "trace"
1704
- }) : null
1705
- ] })]
2432
+ ]
2433
+ }) : null]
2434
+ })]
2435
+ })
1706
2436
  }, e.id);
1707
- })
1708
- }), /* @__PURE__ */ K(en, {})]
2437
+ }), u && !n.some((e) => e.streaming) ? /* @__PURE__ */ Q(Pi, {
2438
+ showAvatar: p,
2439
+ assistantAvatarUrl: g,
2440
+ assistantAvatarFallback: _,
2441
+ waitingLabel: q.connectionWaiting
2442
+ }) : null]
2443
+ }), /* @__PURE__ */ Q(Fn, {})]
1709
2444
  }),
1710
- u ? /* @__PURE__ */ K(Ur, {
1711
- error: u,
1712
- onReload: s
2445
+ d ? /* @__PURE__ */ Q(Ki, {
2446
+ error: d,
2447
+ onReload: s,
2448
+ onUpgrade: c
1713
2449
  }) : null,
1714
- /* @__PURE__ */ q("div", {
1715
- className: "relative",
1716
- children: [E ? /* @__PURE__ */ K("div", {
2450
+ /* @__PURE__ */ $("div", {
2451
+ ref: Be,
2452
+ className: J("relative", G && "mx-auto w-full max-w-2xl px-4 pb-4 sm:px-0"),
2453
+ children: [A ? /* @__PURE__ */ Q("div", {
1717
2454
  className: "absolute bottom-full left-0 right-0 z-10 px-3 pb-1",
1718
- children: E
1719
- }) : null, /* @__PURE__ */ q(In, {
1720
- accept: y,
1721
- maxFileSize: b,
1722
- onSubmit: ee,
2455
+ children: A
2456
+ }) : null, /* @__PURE__ */ $(yr, {
2457
+ accept: S,
2458
+ fileInputLabel: q.uploadFiles,
2459
+ maxFileSize: C,
2460
+ onSubmit: Re,
1723
2461
  onError: (e) => {
1724
2462
  console.warn("[plugin-chatbot] prompt-input error", e);
1725
2463
  },
1726
2464
  children: [
1727
- v ? /* @__PURE__ */ K(Ln, { children: /* @__PURE__ */ K(Pn, { children: (e) => /* @__PURE__ */ K(Nn, { data: e }) }) }) : null,
1728
- /* @__PURE__ */ K(Rn, {
2465
+ x ? /* @__PURE__ */ Q(br, { children: /* @__PURE__ */ Q(_r, { children: (e) => /* @__PURE__ */ Q(gr, { data: e }) }) }) : null,
2466
+ /* @__PURE__ */ Q(xr, {
1729
2467
  placeholder: r,
1730
- disabled: c || F === "streaming",
1731
- onChange: D ? (e) => D(e.currentTarget.value) : void 0
2468
+ disabled: l || W === "streaming",
2469
+ onChange: j ? (e) => j(e.currentTarget.value) : void 0
1732
2470
  }),
1733
- /* @__PURE__ */ q(Bn, { children: [/* @__PURE__ */ q(Vn, { children: [
1734
- v ? /* @__PURE__ */ q(Un, { children: [/* @__PURE__ */ K(Wn, {}), /* @__PURE__ */ K(Gn, { children: /* @__PURE__ */ K(Fn, {}) })] }) : null,
1735
- S && S.length > 0 ? /* @__PURE__ */ K("select", {
1736
- "aria-label": "Model",
1737
- value: C ?? S[0].id,
1738
- onChange: (e) => w?.(e.target.value),
2471
+ /* @__PURE__ */ $(Cr, { children: [/* @__PURE__ */ $(wr, { children: [
2472
+ x ? /* @__PURE__ */ $(Er, { children: [/* @__PURE__ */ Q(Dr, {}), /* @__PURE__ */ Q(Or, { children: /* @__PURE__ */ Q(vr, {}) })] }) : null,
2473
+ E && E.length > 0 ? /* @__PURE__ */ Q("select", {
2474
+ "aria-label": q.model,
2475
+ value: D ?? E[0].id,
2476
+ onChange: (e) => O?.(e.target.value),
1739
2477
  className: "h-7 rounded-md border bg-background px-2 text-xs text-muted-foreground hover:text-foreground focus:outline-none focus:ring-1 focus:ring-ring",
1740
- children: S.map((e) => /* @__PURE__ */ q("option", {
2478
+ children: E.map((e) => /* @__PURE__ */ $("option", {
1741
2479
  value: e.id,
1742
2480
  children: [e.label ?? e.id, e.provider ? ` · ${e.provider}` : ""]
1743
2481
  }, e.id))
1744
2482
  }) : null,
1745
- /* @__PURE__ */ q("span", {
2483
+ /* @__PURE__ */ $("span", {
1746
2484
  className: "hidden items-center gap-1 text-[10px] text-muted-foreground sm:inline-flex",
1747
2485
  "aria-hidden": "true",
1748
2486
  children: [
1749
- /* @__PURE__ */ K("kbd", {
2487
+ /* @__PURE__ */ Q("kbd", {
1750
2488
  className: "inline-flex h-4 items-center rounded border bg-muted px-1 font-mono text-[10px] leading-none",
1751
2489
  children: "⌘"
1752
2490
  }),
1753
- /* @__PURE__ */ K(Ze, { className: "h-3 w-3" }),
1754
- /* @__PURE__ */ K("span", {
2491
+ /* @__PURE__ */ Q(qe, { className: "h-3 w-3" }),
2492
+ /* @__PURE__ */ Q("span", {
1755
2493
  className: "opacity-70",
1756
- children: "to send"
2494
+ children: q.sendHint
1757
2495
  })
1758
2496
  ]
1759
2497
  })
1760
- ] }), /* @__PURE__ */ K(qn, {
1761
- status: F,
1762
- disabled: c,
1763
- onClick: F === "streaming" ? o : void 0
2498
+ ] }), /* @__PURE__ */ Q(Ar, {
2499
+ "aria-label": W === "streaming" ? q.stopResponse : q.submit,
2500
+ status: W,
2501
+ disabled: l,
2502
+ onClick: W === "streaming" ? o : void 0,
2503
+ type: W === "streaming" ? "button" : "submit"
1764
2504
  })] })
1765
2505
  ]
1766
2506
  })]
1767
- }),
1768
- /* @__PURE__ */ K("span", {
1769
- hidden: !0,
1770
- "data-avatar-user": f ?? p,
1771
- "data-avatar-assistant": m ?? h
1772
2507
  })
1773
2508
  ]
1774
2509
  });
1775
2510
  });
1776
- $.displayName = "ChatbotEnhanced";
1777
- function Ur({ error: t, onReload: n }) {
1778
- let { summary: r, details: i } = e.useMemo(() => Xt(t), [t]), [a, o] = e.useState(!1);
1779
- return /* @__PURE__ */ q("div", {
1780
- className: "flex flex-col gap-1 border-t bg-destructive/10 px-4 py-2 text-destructive text-sm",
1781
- role: "alert",
1782
- children: [/* @__PURE__ */ q("div", {
1783
- className: "flex items-center gap-2",
1784
- children: [
1785
- /* @__PURE__ */ K(Pe, { className: "h-4 w-4 shrink-0" }),
1786
- /* @__PURE__ */ K("span", {
1787
- className: "flex-1 leading-snug",
1788
- children: r || "An error occurred"
1789
- }),
1790
- i ? /* @__PURE__ */ K("button", {
2511
+ Mi.displayName = "ChatbotEnhanced";
2512
+ function Ni({ isUser: e, url: t, fallback: n }) {
2513
+ return /* @__PURE__ */ Q("div", {
2514
+ className: J("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"),
2515
+ "aria-hidden": "true",
2516
+ children: t ? /* @__PURE__ */ Q("img", {
2517
+ src: t,
2518
+ alt: "",
2519
+ className: "size-full object-cover"
2520
+ }) : e ? n?.trim()?.charAt(0)?.toUpperCase() || "U" : /* @__PURE__ */ Q(Me, { className: "size-4" })
2521
+ });
2522
+ }
2523
+ function Pi({ showAvatar: e, assistantAvatarUrl: t, assistantAvatarFallback: n, waitingLabel: r }) {
2524
+ return /* @__PURE__ */ Q(zn, {
2525
+ from: "assistant",
2526
+ "aria-live": "polite",
2527
+ children: /* @__PURE__ */ $("div", {
2528
+ className: J("flex w-full gap-2.5", e ? "flex-row items-start" : "flex-col"),
2529
+ children: [e ? /* @__PURE__ */ Q(Ni, {
2530
+ isUser: !1,
2531
+ url: t,
2532
+ fallback: n
2533
+ }) : null, /* @__PURE__ */ Q(Bn, {
2534
+ className: "rounded-lg border bg-muted/30 px-3 py-2 text-muted-foreground",
2535
+ children: /* @__PURE__ */ $("span", {
2536
+ className: "inline-flex items-center gap-2",
2537
+ children: [/* @__PURE__ */ Q(Fi, {}), /* @__PURE__ */ Q(zi, {
2538
+ active: !0,
2539
+ pending: !0,
2540
+ activityKey: 0,
2541
+ waitingLabel: r
2542
+ })]
2543
+ })
2544
+ })]
2545
+ })
2546
+ });
2547
+ }
2548
+ function Fi() {
2549
+ return /* @__PURE__ */ $(Z, { children: [/* @__PURE__ */ Q("span", {
2550
+ className: "sr-only",
2551
+ children: "Assistant is responding"
2552
+ }), /* @__PURE__ */ $("span", {
2553
+ "aria-hidden": "true",
2554
+ className: "inline-flex items-center gap-1",
2555
+ children: [
2556
+ /* @__PURE__ */ Q("span", { className: "size-1.5 rounded-full bg-current animate-pulse" }),
2557
+ /* @__PURE__ */ Q("span", { className: "size-1.5 rounded-full bg-current animate-pulse" }),
2558
+ /* @__PURE__ */ Q("span", { className: "size-1.5 rounded-full bg-current animate-pulse" })
2559
+ ]
2560
+ })] });
2561
+ }
2562
+ function Ii(e) {
2563
+ let t = Math.floor(e / 60), n = e % 60;
2564
+ return `${t}:${String(n).padStart(2, "0")}`;
2565
+ }
2566
+ var Li = 6;
2567
+ function Ri(t, n) {
2568
+ let r = e.useRef(0), i = e.useRef(0), [a, o] = e.useState({
2569
+ elapsed: 0,
2570
+ quiet: 0
2571
+ });
2572
+ return e.useEffect(() => {
2573
+ let e = Date.now();
2574
+ r.current = e, i.current = e;
2575
+ }, []), e.useEffect(() => {
2576
+ let e = Date.now();
2577
+ i.current = e, o({
2578
+ elapsed: Math.floor((e - r.current) / 1e3),
2579
+ quiet: 0
2580
+ });
2581
+ }, [n]), e.useEffect(() => {
2582
+ if (!t) return;
2583
+ let e = () => {
2584
+ let e = Date.now();
2585
+ o({
2586
+ elapsed: Math.floor((e - r.current) / 1e3),
2587
+ quiet: Math.floor((e - i.current) / 1e3)
2588
+ });
2589
+ };
2590
+ e();
2591
+ let n = setInterval(e, 1e3);
2592
+ return () => clearInterval(n);
2593
+ }, [t]), {
2594
+ elapsedSeconds: a.elapsed,
2595
+ quietSeconds: a.quiet,
2596
+ live: a.quiet < Li
2597
+ };
2598
+ }
2599
+ function zi({ active: e, activityKey: t, pending: n = !1, waitingLabel: r }) {
2600
+ let { elapsedSeconds: i, quietSeconds: a, live: o } = Ri(e, t), s = o ? n ? "waiting" : "receiving" : "stalled";
2601
+ return /* @__PURE__ */ $("span", {
2602
+ className: J("inline-flex items-center gap-1.5 text-xs font-normal tabular-nums", s === "stalled" ? "text-amber-600" : "text-muted-foreground"),
2603
+ "aria-live": "polite",
2604
+ title: s === "receiving" ? `Receiving from server · ${Ii(i)} elapsed` : s === "waiting" ? `${r} · ${Ii(i)} elapsed` : `${r} (${a}s with no response)`,
2605
+ children: [/* @__PURE__ */ Q("span", {
2606
+ "aria-hidden": !0,
2607
+ className: J("size-1.5 shrink-0 rounded-full", s === "receiving" ? "bg-emerald-500 animate-pulse" : s === "waiting" ? "bg-muted-foreground/50 animate-pulse" : "bg-amber-500")
2608
+ }), s === "receiving" ? /* @__PURE__ */ $(Z, { children: [/* @__PURE__ */ Q(Ue, {
2609
+ className: "size-3 shrink-0",
2610
+ "aria-hidden": !0
2611
+ }), Ii(i)] }) : s === "waiting" ? /* @__PURE__ */ Q("span", { children: r }) : /* @__PURE__ */ $("span", { children: [
2612
+ r,
2613
+ " ",
2614
+ a,
2615
+ "s"
2616
+ ] })]
2617
+ });
2618
+ }
2619
+ var Bi = [
2620
+ "object",
2621
+ "view",
2622
+ "dashboard",
2623
+ "app",
2624
+ "seed"
2625
+ ], Vi = {
2626
+ object: "Objects",
2627
+ view: "Views",
2628
+ dashboard: "Dashboards",
2629
+ app: "App",
2630
+ seed: "Sample data"
2631
+ };
2632
+ function Hi({ progress: e, onOpenBuiltApp: t, openBuiltAppLabel: n = "Open app", onPreviewDraftApp: r, previewDraftLabel: i = "Preview", waitingLabel: a = "Waiting for server…" }) {
2633
+ let { phase: o, appLabel: s, items: c, done: l, total: u, seq: d } = e, f = o === "done", p = d ?? `${o}:${l}:${c.length}`, m = c.find((e) => e.type === "app"), h = u > 0 ? Math.min(100, Math.round(l / u * 100)) : f ? 100 : 6, g = /* @__PURE__ */ new Map();
2634
+ for (let e of c) {
2635
+ let t = g.get(e.type) ?? [];
2636
+ t.push(e.name.replace(/_sample$/, "")), g.set(e.type, t);
2637
+ }
2638
+ let _ = [...Bi.filter((e) => g.has(e)), ...[...g.keys()].filter((e) => !Bi.includes(e))];
2639
+ return /* @__PURE__ */ $("div", {
2640
+ className: "rounded-lg border bg-muted/30 p-3 text-sm",
2641
+ "data-testid": "build-progress",
2642
+ children: [
2643
+ /* @__PURE__ */ $("div", {
2644
+ className: "mb-2 flex items-center gap-2 font-medium",
2645
+ children: [
2646
+ f ? /* @__PURE__ */ Q(Y, { className: "size-4 shrink-0 text-emerald-600" }) : /* @__PURE__ */ Q(et, { className: "size-4 shrink-0 animate-spin text-primary" }),
2647
+ /* @__PURE__ */ Q("span", { children: f ? `Built ${s ?? "your app"}` : `Building ${s ?? "your app"}…` }),
2648
+ !f && o === "data" ? /* @__PURE__ */ Q("span", {
2649
+ className: "text-xs font-normal text-muted-foreground",
2650
+ children: "adding sample data"
2651
+ }) : null,
2652
+ f ? null : /* @__PURE__ */ Q("span", {
2653
+ className: "ml-auto",
2654
+ children: /* @__PURE__ */ Q(zi, {
2655
+ active: !0,
2656
+ activityKey: p,
2657
+ waitingLabel: a
2658
+ })
2659
+ })
2660
+ ]
2661
+ }),
2662
+ /* @__PURE__ */ Q("div", {
2663
+ className: "mb-2 h-1.5 w-full overflow-hidden rounded-full bg-muted",
2664
+ children: /* @__PURE__ */ Q("div", {
2665
+ className: J("h-full rounded-full transition-all duration-500", f ? "bg-emerald-500" : "bg-primary"),
2666
+ style: { width: `${h}%` }
2667
+ })
2668
+ }),
2669
+ /* @__PURE__ */ Q("ul", {
2670
+ className: "space-y-1",
2671
+ children: _.map((e) => {
2672
+ let t = g.get(e);
2673
+ return /* @__PURE__ */ $("li", {
2674
+ className: "flex items-start gap-2",
2675
+ children: [/* @__PURE__ */ Q(Y, { className: "mt-0.5 size-3.5 shrink-0 text-emerald-600" }), /* @__PURE__ */ $("span", {
2676
+ className: "min-w-0 text-muted-foreground",
2677
+ children: [
2678
+ /* @__PURE__ */ Q("span", {
2679
+ className: "font-medium text-foreground",
2680
+ children: Vi[e] ?? e
2681
+ }),
2682
+ " ",
2683
+ t.slice(0, 6).join(", "),
2684
+ t.length > 6 ? ` +${t.length - 6} more` : ""
2685
+ ]
2686
+ })]
2687
+ }, e);
2688
+ })
2689
+ }),
2690
+ f && m && (t || r) ? /* @__PURE__ */ $("div", {
2691
+ className: "mt-3 flex items-center gap-2",
2692
+ children: [t ? /* @__PURE__ */ $("button", {
1791
2693
  type: "button",
1792
- onClick: () => o((e) => !e),
1793
- className: "text-xs underline hover:no-underline",
1794
- "aria-expanded": a,
1795
- children: a ? "Hide details" : "Details"
1796
- }) : null,
1797
- n ? /* @__PURE__ */ q("button", {
2694
+ onClick: () => t(m.name),
2695
+ className: "inline-flex h-7 items-center gap-1.5 rounded-md bg-primary px-3 text-xs font-medium text-primary-foreground hover:bg-primary/90",
2696
+ "data-testid": "build-progress-open-app",
2697
+ children: [n, /* @__PURE__ */ Q(Ae, { className: "size-3.5" })]
2698
+ }) : null, r ? /* @__PURE__ */ $("button", {
1798
2699
  type: "button",
1799
- onClick: n,
1800
- className: "inline-flex h-7 items-center rounded-md border border-destructive/30 bg-destructive/10 px-2 text-xs font-medium hover:bg-destructive/20",
1801
- children: [/* @__PURE__ */ K(ct, { className: "mr-1 h-3 w-3" }), "Retry"]
1802
- }) : null
1803
- ]
1804
- }), a && i ? /* @__PURE__ */ K("pre", {
1805
- className: "max-h-32 overflow-auto whitespace-pre-wrap break-words rounded bg-destructive/5 px-2 py-1 font-mono text-[11px] leading-snug text-destructive/90",
1806
- children: i
1807
- }) : null]
2700
+ onClick: () => r(m.name),
2701
+ className: "inline-flex h-7 items-center gap-1.5 rounded-md border px-3 text-xs font-medium hover:bg-muted",
2702
+ "data-testid": "build-progress-preview-app",
2703
+ children: [/* @__PURE__ */ Q(Ye, { className: "size-3.5" }), i]
2704
+ }) : null]
2705
+ }) : null
2706
+ ]
2707
+ });
2708
+ }
2709
+ function Ui({ groups: e, labels: t }) {
2710
+ return e.length === 0 ? null : /* @__PURE__ */ Q("div", {
2711
+ className: "not-prose mb-2 border-l border-border/70 pl-3",
2712
+ children: /* @__PURE__ */ Q("div", {
2713
+ className: "space-y-1",
2714
+ children: e.map((e) => /* @__PURE__ */ $("div", {
2715
+ className: "flex min-h-6 items-center justify-between gap-3 text-xs",
2716
+ children: [/* @__PURE__ */ $("div", {
2717
+ className: "flex min-w-0 items-center gap-2",
2718
+ children: [
2719
+ /* @__PURE__ */ Q(Wi, { state: e.state }),
2720
+ /* @__PURE__ */ Q("span", {
2721
+ className: "truncate font-medium text-foreground",
2722
+ children: e.title
2723
+ }),
2724
+ e.count > 1 ? /* @__PURE__ */ $("span", {
2725
+ className: "shrink-0 text-[10px] text-muted-foreground",
2726
+ children: ["x", e.count]
2727
+ }) : null
2728
+ ]
2729
+ }), /* @__PURE__ */ Q("span", {
2730
+ className: J("shrink-0 text-[10px] font-medium", e.state === "failed" ? "text-destructive" : e.state === "completed" ? "text-emerald-700 dark:text-emerald-400" : "text-muted-foreground"),
2731
+ children: Gi(e.state, t)
2732
+ })]
2733
+ }, e.key))
2734
+ })
2735
+ });
2736
+ }
2737
+ function Wi({ state: e }) {
2738
+ 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" });
2739
+ }
2740
+ function Gi(e, t) {
2741
+ switch (e) {
2742
+ case "failed": return t.toolFailed;
2743
+ case "awaiting": return t.toolAwaitingApproval;
2744
+ case "running": return t.toolRunning;
2745
+ case "completed": return t.toolCompleted;
2746
+ }
2747
+ }
2748
+ function Ki({ error: t, onReload: n, onUpgrade: r }) {
2749
+ let i = e.useMemo(() => jn(t), [t]), { summary: a, details: o } = e.useMemo(() => kn(t), [t]), [s, c] = e.useState(!1);
2750
+ if (i) {
2751
+ 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";
2752
+ return /* @__PURE__ */ Q("div", {
2753
+ className: "border-t bg-background px-3 py-2 text-sm",
2754
+ role: "alert",
2755
+ children: /* @__PURE__ */ Q("div", {
2756
+ className: "rounded-md border border-amber-300/40 bg-amber-50/60 px-3 py-2 text-foreground dark:bg-amber-950/20",
2757
+ children: /* @__PURE__ */ $("div", {
2758
+ className: "flex items-start gap-2",
2759
+ children: [/* @__PURE__ */ $("div", {
2760
+ className: "min-w-0 flex-1",
2761
+ children: [/* @__PURE__ */ Q("div", {
2762
+ className: "font-medium leading-snug text-foreground",
2763
+ children: e ? "需要升级" : "Upgrade needed"
2764
+ }), /* @__PURE__ */ Q("div", {
2765
+ className: "mt-0.5 break-words leading-snug text-muted-foreground",
2766
+ children: t
2767
+ })]
2768
+ }), r ? /* @__PURE__ */ Q("button", {
2769
+ type: "button",
2770
+ onClick: r,
2771
+ className: "inline-flex h-7 shrink-0 items-center rounded-md border border-amber-400/50 bg-background px-2 text-xs font-medium text-amber-700 hover:bg-amber-100/60 dark:text-amber-300",
2772
+ children: n
2773
+ }) : null]
2774
+ })
2775
+ })
2776
+ });
2777
+ }
2778
+ return /* @__PURE__ */ Q("div", {
2779
+ className: "border-t bg-background px-3 py-2 text-sm",
2780
+ role: "alert",
2781
+ children: /* @__PURE__ */ $("div", {
2782
+ className: "rounded-md border border-destructive/20 bg-destructive/5 px-3 py-2 text-foreground",
2783
+ children: [/* @__PURE__ */ $("div", {
2784
+ className: "flex items-start gap-2",
2785
+ children: [
2786
+ /* @__PURE__ */ Q(Oe, { className: "mt-0.5 h-4 w-4 shrink-0 text-destructive" }),
2787
+ /* @__PURE__ */ $("div", {
2788
+ className: "min-w-0 flex-1",
2789
+ children: [/* @__PURE__ */ Q("div", {
2790
+ className: "font-medium leading-snug text-destructive",
2791
+ children: "Response failed"
2792
+ }), /* @__PURE__ */ Q("div", {
2793
+ className: "mt-0.5 break-words leading-snug text-muted-foreground",
2794
+ children: a || "Something went wrong. Please try again."
2795
+ })]
2796
+ }),
2797
+ /* @__PURE__ */ $("div", {
2798
+ className: "flex shrink-0 items-center gap-1",
2799
+ children: [o ? /* @__PURE__ */ Q("button", {
2800
+ type: "button",
2801
+ onClick: () => c((e) => !e),
2802
+ className: "inline-flex h-7 items-center rounded-md px-2 text-xs font-medium text-muted-foreground hover:bg-destructive/10 hover:text-foreground",
2803
+ "aria-expanded": s,
2804
+ children: s ? "Hide" : "Details"
2805
+ }) : null, n ? /* @__PURE__ */ $("button", {
2806
+ type: "button",
2807
+ onClick: n,
2808
+ className: "inline-flex h-7 items-center rounded-md border border-destructive/30 bg-background px-2 text-xs font-medium text-destructive hover:bg-destructive/10",
2809
+ children: [/* @__PURE__ */ Q(st, { className: "mr-1 h-3 w-3" }), "Retry"]
2810
+ }) : null]
2811
+ })
2812
+ ]
2813
+ }), s && o ? /* @__PURE__ */ Q("pre", {
2814
+ className: "mt-2 max-h-28 overflow-auto whitespace-pre-wrap break-words rounded border bg-background px-2 py-1 font-mono text-[11px] leading-snug text-muted-foreground",
2815
+ children: o
2816
+ }) : null]
2817
+ })
1808
2818
  });
1809
2819
  }
1810
- function Wr({ output: e, errorText: t }) {
1811
- return t ? /* @__PURE__ */ K(Er, {
2820
+ function qi({ output: e, errorText: t }) {
2821
+ return t ? /* @__PURE__ */ Q(ui, {
1812
2822
  output: void 0,
1813
2823
  errorText: t
1814
- }) : e == null || e === "" ? null : typeof e == "string" && !Hr(e) ? /* @__PURE__ */ q("div", {
2824
+ }) : e == null || e === "" ? null : typeof e == "string" && !Ei(e) ? /* @__PURE__ */ $("div", {
1815
2825
  className: "space-y-2 p-4",
1816
- children: [/* @__PURE__ */ K("h4", {
2826
+ children: [/* @__PURE__ */ Q("h4", {
1817
2827
  className: "font-medium text-muted-foreground text-xs uppercase tracking-wide",
1818
2828
  children: "Result"
1819
- }), /* @__PURE__ */ K("div", {
2829
+ }), /* @__PURE__ */ Q("div", {
1820
2830
  className: "overflow-x-auto rounded-md bg-muted/40 px-3 py-2 text-sm text-foreground",
1821
- children: /* @__PURE__ */ K(X, { children: e })
2831
+ children: /* @__PURE__ */ Q(Zn, { children: e })
1822
2832
  })]
1823
- }) : /* @__PURE__ */ K(Er, {
2833
+ }) : /* @__PURE__ */ Q(ui, {
1824
2834
  output: e,
1825
2835
  errorText: void 0
1826
2836
  });
1827
2837
  }
1828
2838
  //#endregion
1829
2839
  //#region src/FloatingChatbot.tsx
1830
- function Gr({ floatingConfig: t, headerExtra: n, headerActions: r, ...i }) {
2840
+ function Ji({ floatingConfig: t, headerExtra: n, headerActions: r, ...i }) {
1831
2841
  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);
1832
2842
  e.useEffect(() => {
1833
2843
  let e = document.getElementById("floating-chatbot-portal");
@@ -1835,29 +2845,29 @@ function Gr({ floatingConfig: t, headerExtra: n, headerActions: r, ...i }) {
1835
2845
  e && e.parentNode && !e.hasChildNodes() && e.parentNode.removeChild(e);
1836
2846
  };
1837
2847
  }, []);
1838
- let p = /* @__PURE__ */ q(Ht, {
2848
+ let p = /* @__PURE__ */ $(pn, {
1839
2849
  defaultOpen: o,
1840
- children: [/* @__PURE__ */ K(Gt, {
2850
+ children: [/* @__PURE__ */ Q(yn, {
1841
2851
  position: a,
1842
2852
  size: u
1843
- }), /* @__PURE__ */ K(Kt, {
2853
+ }), /* @__PURE__ */ Q(Tn, {
1844
2854
  title: l,
1845
2855
  position: a,
1846
2856
  width: s,
1847
2857
  height: c,
1848
2858
  headerExtra: n,
1849
2859
  headerActions: r,
1850
- children: /* @__PURE__ */ K($, {
2860
+ children: /* @__PURE__ */ Q(Mi, {
1851
2861
  ...i,
1852
2862
  maxHeight: "100%",
1853
2863
  className: "h-full border-0 rounded-none"
1854
2864
  })
1855
2865
  })]
1856
2866
  });
1857
- return d ? gt.createPortal(p, d) : p;
2867
+ return d ? bt.createPortal(p, d) : p;
1858
2868
  }
1859
- Dt.register("chatbot", ({ schema: e, className: t, ...n }) => {
1860
- let { messages: r, isLoading: i, sendMessage: a } = J({
2869
+ Mt.register("chatbot", ({ schema: e, className: t, ...n }) => {
2870
+ let { messages: r, isLoading: i, sendMessage: a } = $t({
1861
2871
  api: e.api,
1862
2872
  initialMessages: e.messages,
1863
2873
  conversationId: e.conversationId,
@@ -1874,7 +2884,7 @@ Dt.register("chatbot", ({ schema: e, className: t, ...n }) => {
1874
2884
  autoResponseDelay: e.autoResponseDelay,
1875
2885
  onSend: e.onSend
1876
2886
  });
1877
- return /* @__PURE__ */ K(fi, {
2887
+ return /* @__PURE__ */ Q(ha, {
1878
2888
  messages: r,
1879
2889
  placeholder: e.placeholder,
1880
2890
  onSendMessage: (e) => {
@@ -2022,8 +3032,8 @@ Dt.register("chatbot", ({ schema: e, className: t, ...n }) => {
2022
3032
  autoResponseDelay: 1e3,
2023
3033
  className: "w-full max-w-2xl"
2024
3034
  }
2025
- }), Dt.register("chatbot-enhanced", ({ schema: e, className: t, ...n }) => {
2026
- let { messages: r, isLoading: i, error: a, sendMessage: o, stop: s, reload: c, clear: l, isApiMode: u } = J({
3035
+ }), Mt.register("chatbot-enhanced", ({ schema: e, className: t, ...n }) => {
3036
+ let { messages: r, isLoading: i, error: a, sendMessage: o, stop: s, reload: c, clear: l, isApiMode: u } = $t({
2027
3037
  api: e.api,
2028
3038
  initialMessages: e.messages,
2029
3039
  conversationId: e.conversationId,
@@ -2040,7 +3050,7 @@ Dt.register("chatbot", ({ schema: e, className: t, ...n }) => {
2040
3050
  autoResponseDelay: e.autoResponseDelay,
2041
3051
  onSend: e.onSend
2042
3052
  });
2043
- return /* @__PURE__ */ K($, {
3053
+ return /* @__PURE__ */ Q(Mi, {
2044
3054
  messages: r,
2045
3055
  placeholder: e.placeholder,
2046
3056
  onSendMessage: (e, t) => {
@@ -2062,6 +3072,7 @@ Dt.register("chatbot", ({ schema: e, className: t, ...n }) => {
2062
3072
  maxHeight: e.maxHeight,
2063
3073
  enableMarkdown: e.enableMarkdown ?? !0,
2064
3074
  enableFileUpload: e.enableFileUpload ?? !1,
3075
+ processVisibility: e.processVisibility,
2065
3076
  className: t,
2066
3077
  ...n
2067
3078
  });
@@ -2104,6 +3115,12 @@ Dt.register("chatbot", ({ schema: e, className: t, ...n }) => {
2104
3115
  label: "Enable File Upload",
2105
3116
  defaultValue: !1
2106
3117
  },
3118
+ {
3119
+ name: "processVisibility",
3120
+ type: "enum",
3121
+ label: "Agent Process Visibility",
3122
+ defaultValue: "summary"
3123
+ },
2107
3124
  {
2108
3125
  name: "userAvatarUrl",
2109
3126
  type: "string",
@@ -2202,8 +3219,8 @@ Dt.register("chatbot", ({ schema: e, className: t, ...n }) => {
2202
3219
  autoResponseDelay: 1e3,
2203
3220
  className: "w-full max-w-2xl"
2204
3221
  }
2205
- }), Dt.register("chatbot-floating", ({ schema: e, className: t, ...n }) => {
2206
- let { messages: r, isLoading: i, error: a, sendMessage: o, stop: s, reload: c, clear: l, isApiMode: u } = J({
3222
+ }), Mt.register("chatbot-floating", ({ schema: e, className: t, ...n }) => {
3223
+ let { messages: r, isLoading: i, error: a, sendMessage: o, stop: s, reload: c, clear: l, isApiMode: u } = $t({
2207
3224
  api: e.api,
2208
3225
  initialMessages: e.messages,
2209
3226
  conversationId: e.conversationId,
@@ -2220,7 +3237,7 @@ Dt.register("chatbot", ({ schema: e, className: t, ...n }) => {
2220
3237
  autoResponseDelay: e.autoResponseDelay,
2221
3238
  onSend: e.onSend
2222
3239
  });
2223
- return /* @__PURE__ */ K(Gr, {
3240
+ return /* @__PURE__ */ Q(Ji, {
2224
3241
  floatingConfig: e.floatingConfig,
2225
3242
  messages: r,
2226
3243
  placeholder: e.placeholder,
@@ -2392,71 +3409,71 @@ Dt.register("chatbot", ({ schema: e, className: t, ...n }) => {
2392
3409
  });
2393
3410
  //#endregion
2394
3411
  //#region src/elements/loader.tsx
2395
- var Kr = ({ size: e = 16 }) => /* @__PURE__ */ q("svg", {
3412
+ var Yi = ({ size: e = 16 }) => /* @__PURE__ */ $("svg", {
2396
3413
  height: e,
2397
3414
  strokeLinejoin: "round",
2398
3415
  style: { color: "currentcolor" },
2399
3416
  viewBox: "0 0 16 16",
2400
3417
  width: e,
2401
3418
  children: [
2402
- /* @__PURE__ */ K("title", { children: "Loader" }),
2403
- /* @__PURE__ */ q("g", {
3419
+ /* @__PURE__ */ Q("title", { children: "Loader" }),
3420
+ /* @__PURE__ */ $("g", {
2404
3421
  clipPath: "url(#clip0_2393_1490)",
2405
3422
  children: [
2406
- /* @__PURE__ */ K("path", {
3423
+ /* @__PURE__ */ Q("path", {
2407
3424
  d: "M8 0V4",
2408
3425
  stroke: "currentColor",
2409
3426
  strokeWidth: "1.5"
2410
3427
  }),
2411
- /* @__PURE__ */ K("path", {
3428
+ /* @__PURE__ */ Q("path", {
2412
3429
  d: "M8 16V12",
2413
3430
  opacity: "0.5",
2414
3431
  stroke: "currentColor",
2415
3432
  strokeWidth: "1.5"
2416
3433
  }),
2417
- /* @__PURE__ */ K("path", {
3434
+ /* @__PURE__ */ Q("path", {
2418
3435
  d: "M3.29773 1.52783L5.64887 4.7639",
2419
3436
  opacity: "0.9",
2420
3437
  stroke: "currentColor",
2421
3438
  strokeWidth: "1.5"
2422
3439
  }),
2423
- /* @__PURE__ */ K("path", {
3440
+ /* @__PURE__ */ Q("path", {
2424
3441
  d: "M12.7023 1.52783L10.3511 4.7639",
2425
3442
  opacity: "0.1",
2426
3443
  stroke: "currentColor",
2427
3444
  strokeWidth: "1.5"
2428
3445
  }),
2429
- /* @__PURE__ */ K("path", {
3446
+ /* @__PURE__ */ Q("path", {
2430
3447
  d: "M12.7023 14.472L10.3511 11.236",
2431
3448
  opacity: "0.4",
2432
3449
  stroke: "currentColor",
2433
3450
  strokeWidth: "1.5"
2434
3451
  }),
2435
- /* @__PURE__ */ K("path", {
3452
+ /* @__PURE__ */ Q("path", {
2436
3453
  d: "M3.29773 14.472L5.64887 11.236",
2437
3454
  opacity: "0.6",
2438
3455
  stroke: "currentColor",
2439
3456
  strokeWidth: "1.5"
2440
3457
  }),
2441
- /* @__PURE__ */ K("path", {
3458
+ /* @__PURE__ */ Q("path", {
2442
3459
  d: "M15.6085 5.52783L11.8043 6.7639",
2443
3460
  opacity: "0.2",
2444
3461
  stroke: "currentColor",
2445
3462
  strokeWidth: "1.5"
2446
3463
  }),
2447
- /* @__PURE__ */ K("path", {
3464
+ /* @__PURE__ */ Q("path", {
2448
3465
  d: "M0.391602 10.472L4.19583 9.23598",
2449
3466
  opacity: "0.7",
2450
3467
  stroke: "currentColor",
2451
3468
  strokeWidth: "1.5"
2452
3469
  }),
2453
- /* @__PURE__ */ K("path", {
3470
+ /* @__PURE__ */ Q("path", {
2454
3471
  d: "M15.6085 10.4722L11.8043 9.2361",
2455
3472
  opacity: "0.3",
2456
3473
  stroke: "currentColor",
2457
3474
  strokeWidth: "1.5"
2458
3475
  }),
2459
- /* @__PURE__ */ K("path", {
3476
+ /* @__PURE__ */ Q("path", {
2460
3477
  d: "M0.391602 5.52783L4.19583 6.7639",
2461
3478
  opacity: "0.8",
2462
3479
  stroke: "currentColor",
@@ -2464,106 +3481,106 @@ var Kr = ({ size: e = 16 }) => /* @__PURE__ */ q("svg", {
2464
3481
  })
2465
3482
  ]
2466
3483
  }),
2467
- /* @__PURE__ */ K("defs", { children: /* @__PURE__ */ K("clipPath", {
3484
+ /* @__PURE__ */ Q("defs", { children: /* @__PURE__ */ Q("clipPath", {
2468
3485
  id: "clip0_2393_1490",
2469
- children: /* @__PURE__ */ K("rect", {
3486
+ children: /* @__PURE__ */ Q("rect", {
2470
3487
  fill: "white",
2471
3488
  height: "16",
2472
3489
  width: "16"
2473
3490
  })
2474
3491
  }) })
2475
3492
  ]
2476
- }), qr = ({ className: e, size: t = 16, ...n }) => /* @__PURE__ */ K("div", {
2477
- className: H("inline-flex animate-spin items-center justify-center", e),
3493
+ }), Xi = ({ className: e, size: t = 16, ...n }) => /* @__PURE__ */ Q("div", {
3494
+ className: J("inline-flex animate-spin items-center justify-center", e),
2478
3495
  ...n,
2479
- children: /* @__PURE__ */ K(Kr, { size: t })
2480
- }), Jr = /* @__PURE__ */ kt({
2481
- CodeBlock: () => Q,
2482
- CodeBlockCopyButton: () => br,
2483
- Conversation: () => Zt,
2484
- ConversationContent: () => Qt,
2485
- ConversationEmptyState: () => $t,
2486
- ConversationScrollButton: () => en,
2487
- Loader: () => qr,
2488
- Message: () => an,
2489
- MessageAction: () => cn,
2490
- MessageActions: () => sn,
2491
- MessageAttachment: () => gn,
2492
- MessageAttachments: () => _n,
2493
- MessageBranch: () => un,
2494
- MessageBranchContent: () => dn,
2495
- MessageBranchNext: () => mn,
2496
- MessageBranchPage: () => hn,
2497
- MessageBranchPrevious: () => pn,
2498
- MessageBranchSelector: () => fn,
2499
- MessageContent: () => on,
2500
- MessageResponse: () => X,
2501
- MessageToolbar: () => vn,
2502
- PromptInput: () => In,
2503
- PromptInputActionAddAttachments: () => Fn,
2504
- PromptInputActionMenu: () => Un,
2505
- PromptInputActionMenuContent: () => Gn,
2506
- PromptInputActionMenuItem: () => Kn,
2507
- PromptInputActionMenuTrigger: () => Wn,
2508
- PromptInputAttachment: () => Nn,
2509
- PromptInputAttachments: () => Pn,
2510
- PromptInputBody: () => Ln,
2511
- PromptInputButton: () => Hn,
2512
- PromptInputCommand: () => cr,
2513
- PromptInputCommandEmpty: () => dr,
2514
- PromptInputCommandGroup: () => fr,
2515
- PromptInputCommandInput: () => lr,
2516
- PromptInputCommandItem: () => pr,
2517
- PromptInputCommandList: () => ur,
2518
- PromptInputCommandSeparator: () => mr,
2519
- PromptInputFooter: () => Bn,
2520
- PromptInputHeader: () => zn,
2521
- PromptInputHoverCard: () => er,
2522
- PromptInputHoverCardContent: () => nr,
2523
- PromptInputHoverCardTrigger: () => tr,
2524
- PromptInputProvider: () => jn,
2525
- PromptInputSelect: () => Yn,
2526
- PromptInputSelectContent: () => Zn,
2527
- PromptInputSelectItem: () => Qn,
2528
- PromptInputSelectTrigger: () => Xn,
2529
- PromptInputSelectValue: () => $n,
2530
- PromptInputSpeechButton: () => Jn,
2531
- PromptInputSubmit: () => qn,
2532
- PromptInputTab: () => ir,
2533
- PromptInputTabBody: () => or,
2534
- PromptInputTabItem: () => sr,
2535
- PromptInputTabLabel: () => ar,
2536
- PromptInputTabsList: () => rr,
2537
- PromptInputTextarea: () => Rn,
2538
- PromptInputTools: () => Vn,
2539
- Reasoning: () => Mr,
2540
- ReasoningContent: () => Fr,
2541
- ReasoningTrigger: () => Pr,
2542
- Shimmer: () => Dr,
2543
- Source: () => zr,
2544
- Sources: () => Ir,
2545
- SourcesContent: () => Rr,
2546
- SourcesTrigger: () => Lr,
2547
- Suggestion: () => gr,
2548
- Suggestions: () => hr,
2549
- Tool: () => xr,
2550
- ToolContent: () => wr,
2551
- ToolHeader: () => Cr,
2552
- ToolInput: () => Tr,
2553
- ToolOutput: () => Er,
2554
- highlightCode: () => yr,
2555
- usePromptInputAttachments: () => Z,
2556
- usePromptInputController: () => Dn,
2557
- useProviderAttachments: () => kn,
2558
- useReasoning: () => kr
2559
- }), Yr = "/api/v1/ai";
2560
- function Xr(e, t, n) {
3496
+ children: /* @__PURE__ */ Q(Yi, { size: t })
3497
+ }), Zi = /* @__PURE__ */ Pt({
3498
+ CodeBlock: () => ri,
3499
+ CodeBlockCopyButton: () => ii,
3500
+ Conversation: () => Mn,
3501
+ ConversationContent: () => Nn,
3502
+ ConversationEmptyState: () => Pn,
3503
+ ConversationScrollButton: () => Fn,
3504
+ Loader: () => Xi,
3505
+ Message: () => zn,
3506
+ MessageAction: () => Hn,
3507
+ MessageActions: () => Vn,
3508
+ MessageAttachment: () => Qn,
3509
+ MessageAttachments: () => $n,
3510
+ MessageBranch: () => Gn,
3511
+ MessageBranchContent: () => Kn,
3512
+ MessageBranchNext: () => Yn,
3513
+ MessageBranchPage: () => Xn,
3514
+ MessageBranchPrevious: () => Jn,
3515
+ MessageBranchSelector: () => qn,
3516
+ MessageContent: () => Bn,
3517
+ MessageResponse: () => Zn,
3518
+ MessageToolbar: () => er,
3519
+ PromptInput: () => yr,
3520
+ PromptInputActionAddAttachments: () => vr,
3521
+ PromptInputActionMenu: () => Er,
3522
+ PromptInputActionMenuContent: () => Or,
3523
+ PromptInputActionMenuItem: () => kr,
3524
+ PromptInputActionMenuTrigger: () => Dr,
3525
+ PromptInputAttachment: () => gr,
3526
+ PromptInputAttachments: () => _r,
3527
+ PromptInputBody: () => br,
3528
+ PromptInputButton: () => Tr,
3529
+ PromptInputCommand: () => Gr,
3530
+ PromptInputCommandEmpty: () => Jr,
3531
+ PromptInputCommandGroup: () => Yr,
3532
+ PromptInputCommandInput: () => Kr,
3533
+ PromptInputCommandItem: () => Xr,
3534
+ PromptInputCommandList: () => qr,
3535
+ PromptInputCommandSeparator: () => Zr,
3536
+ PromptInputFooter: () => Cr,
3537
+ PromptInputHeader: () => Sr,
3538
+ PromptInputHoverCard: () => Lr,
3539
+ PromptInputHoverCardContent: () => zr,
3540
+ PromptInputHoverCardTrigger: () => Rr,
3541
+ PromptInputProvider: () => pr,
3542
+ PromptInputSelect: () => Mr,
3543
+ PromptInputSelectContent: () => Pr,
3544
+ PromptInputSelectItem: () => Fr,
3545
+ PromptInputSelectTrigger: () => Nr,
3546
+ PromptInputSelectValue: () => Ir,
3547
+ PromptInputSpeechButton: () => jr,
3548
+ PromptInputSubmit: () => Ar,
3549
+ PromptInputTab: () => Vr,
3550
+ PromptInputTabBody: () => Ur,
3551
+ PromptInputTabItem: () => Wr,
3552
+ PromptInputTabLabel: () => Hr,
3553
+ PromptInputTabsList: () => Br,
3554
+ PromptInputTextarea: () => xr,
3555
+ PromptInputTools: () => wr,
3556
+ Reasoning: () => gi,
3557
+ ReasoningContent: () => yi,
3558
+ ReasoningTrigger: () => vi,
3559
+ Shimmer: () => di,
3560
+ Source: () => Ci,
3561
+ Sources: () => bi,
3562
+ SourcesContent: () => Si,
3563
+ SourcesTrigger: () => xi,
3564
+ Suggestion: () => $r,
3565
+ Suggestions: () => Qr,
3566
+ Tool: () => ai,
3567
+ ToolContent: () => ci,
3568
+ ToolHeader: () => si,
3569
+ ToolInput: () => li,
3570
+ ToolOutput: () => ui,
3571
+ highlightCode: () => ni,
3572
+ usePromptInputAttachments: () => hr,
3573
+ usePromptInputController: () => lr,
3574
+ useProviderAttachments: () => dr,
3575
+ useReasoning: () => pi
3576
+ }), Qi = "/api/v1/ai";
3577
+ function $i(e, t, n) {
2561
3578
  let r = e.replace(/\/$/, ""), i = new URLSearchParams();
2562
3579
  if (n) for (let [e, t] of Object.entries(n)) t == null || t === "" || i.set(e, String(t));
2563
3580
  let a = i.toString();
2564
3581
  return `${r}${t}${a ? `?${a}` : ""}`;
2565
3582
  }
2566
- async function Zr(e, t, n) {
3583
+ async function ea(e, t, n) {
2567
3584
  let r = await fetch(e, {
2568
3585
  credentials: "include",
2569
3586
  ...t,
@@ -2583,8 +3600,8 @@ async function Zr(e, t, n) {
2583
3600
  }
2584
3601
  return i;
2585
3602
  }
2586
- function Qr(t = {}) {
2587
- let { apiBase: n = Yr, 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({
3603
+ function ta(t = {}) {
3604
+ let { apiBase: n = Qi, 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({
2588
3605
  apiBase: n,
2589
3606
  status: r,
2590
3607
  conversationId: i,
@@ -2602,7 +3619,7 @@ function Qr(t = {}) {
2602
3619
  let { apiBase: e, status: t, conversationId: n, limit: r, headers: i } = _.current;
2603
3620
  m(!0), g(void 0);
2604
3621
  try {
2605
- let a = await Zr(Xr(e, "/pending-actions", {
3622
+ let a = await ea($i(e, "/pending-actions", {
2606
3623
  status: t && t !== "all" ? t : void 0,
2607
3624
  conversationId: n,
2608
3625
  limit: r
@@ -2614,9 +3631,9 @@ function Qr(t = {}) {
2614
3631
  m(!1);
2615
3632
  }
2616
3633
  }, []), y = e.useCallback(async (e) => {
2617
- let { apiBase: t, headers: n } = _.current, r = Xr(t, `/pending-actions/${encodeURIComponent(e)}/approve`);
3634
+ let { apiBase: t, headers: n } = _.current, r = $i(t, `/pending-actions/${encodeURIComponent(e)}/approve`);
2618
3635
  try {
2619
- return await Zr(r, {
3636
+ return await ea(r, {
2620
3637
  method: "POST",
2621
3638
  body: "{}"
2622
3639
  }, n);
@@ -2624,9 +3641,9 @@ function Qr(t = {}) {
2624
3641
  v();
2625
3642
  }
2626
3643
  }, [v]), b = e.useCallback(async (e, t) => {
2627
- let { apiBase: n, headers: r } = _.current, i = Xr(n, `/pending-actions/${encodeURIComponent(e)}/reject`);
3644
+ let { apiBase: n, headers: r } = _.current, i = $i(n, `/pending-actions/${encodeURIComponent(e)}/reject`);
2628
3645
  try {
2629
- return await Zr(i, {
3646
+ return await ea(i, {
2630
3647
  method: "POST",
2631
3648
  body: JSON.stringify(t ? { reason: t } : {})
2632
3649
  }, r);
@@ -2660,7 +3677,7 @@ function Qr(t = {}) {
2660
3677
  }
2661
3678
  //#endregion
2662
3679
  //#region src/AiPendingActionsInbox.tsx
2663
- var $r = {
3680
+ var na = {
2664
3681
  pending: {
2665
3682
  variant: "secondary",
2666
3683
  label: "Pending"
@@ -2682,17 +3699,17 @@ var $r = {
2682
3699
  label: "Rejected"
2683
3700
  }
2684
3701
  };
2685
- function ei({ status: e }) {
2686
- let t = $r[e] ?? {
3702
+ function ra({ status: e }) {
3703
+ let t = na[e] ?? {
2687
3704
  variant: "outline",
2688
3705
  label: e
2689
3706
  };
2690
- return /* @__PURE__ */ K(_, {
3707
+ return /* @__PURE__ */ Q(_, {
2691
3708
  variant: t.variant,
2692
3709
  children: t.label
2693
3710
  });
2694
3711
  }
2695
- function ti(e) {
3712
+ function ia(e) {
2696
3713
  if (!e) return "—";
2697
3714
  let t = Date.parse(e);
2698
3715
  if (Number.isNaN(t)) return e;
@@ -2710,7 +3727,7 @@ function ti(e) {
2710
3727
  return e;
2711
3728
  }
2712
3729
  }
2713
- function ni(e) {
3730
+ function aa(e) {
2714
3731
  if (!e) return null;
2715
3732
  try {
2716
3733
  return JSON.parse(e);
@@ -2718,35 +3735,35 @@ function ni(e) {
2718
3735
  return e;
2719
3736
  }
2720
3737
  }
2721
- function ri({ value: e, max: t = 320 }) {
3738
+ function oa({ value: e, max: t = 320 }) {
2722
3739
  let n = typeof e == "string" ? e : JSON.stringify(e, null, 2);
2723
- return n == null || n === "" ? /* @__PURE__ */ K("span", {
3740
+ return n == null || n === "" ? /* @__PURE__ */ Q("span", {
2724
3741
  className: "text-muted-foreground text-xs",
2725
3742
  children: "—"
2726
- }) : /* @__PURE__ */ K("pre", {
3743
+ }) : /* @__PURE__ */ Q("pre", {
2727
3744
  className: "bg-muted/40 rounded text-xs p-2 overflow-auto whitespace-pre-wrap break-all",
2728
3745
  style: { maxHeight: t },
2729
3746
  children: n
2730
3747
  });
2731
3748
  }
2732
- function ii(e) {
3749
+ function sa(e) {
2733
3750
  switch (e) {
2734
3751
  case "pending": return "pending";
2735
3752
  case "all": return "all";
2736
3753
  case "decided": return "all";
2737
3754
  }
2738
3755
  }
2739
- function ai({ 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 }) {
2740
- 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 } = Qr({
3756
+ function ca({ 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 }) {
3757
+ 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: ee, approve: te, reject: P } = ta({
2741
3758
  apiBase: t,
2742
3759
  headers: n,
2743
3760
  pollInterval: r,
2744
3761
  conversationId: i,
2745
- status: ii(l)
2746
- }), L = e.useMemo(() => l === "decided" ? j.filter((e) => e.status !== "pending") : j, [j, l]), R = e.useMemo(() => d ? j.find((e) => e.id === d) ?? null : null, [d, j]), ae = e.useCallback(async (e) => {
3762
+ status: sa(l)
3763
+ }), F = e.useMemo(() => l === "decided" ? j.filter((e) => e.status !== "pending") : j, [j, l]), L = e.useMemo(() => d ? j.find((e) => e.id === d) ?? null : null, [d, j]), R = e.useCallback(async (e) => {
2747
3764
  E(e), O(null);
2748
3765
  try {
2749
- let t = await F(e), n = t.status === "executed";
3766
+ let t = await te(e), n = t.status === "executed";
2750
3767
  A({
2751
3768
  id: e,
2752
3769
  kind: "approve",
@@ -2764,10 +3781,10 @@ function ai({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
2764
3781
  } finally {
2765
3782
  E(null);
2766
3783
  }
2767
- }, [F]), oe = e.useCallback(async (e, t) => {
3784
+ }, [te]), z = e.useCallback(async (e, t) => {
2768
3785
  E(e), O(null);
2769
3786
  try {
2770
- await I(e, t.trim() || void 0), A({
3787
+ await P(e, t.trim() || void 0), A({
2771
3788
  id: e,
2772
3789
  kind: "reject",
2773
3790
  ok: !0,
@@ -2784,52 +3801,52 @@ function ai({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
2784
3801
  } finally {
2785
3802
  E(null);
2786
3803
  }
2787
- }, [I]), se = /* @__PURE__ */ q("div", {
3804
+ }, [P]), oe = /* @__PURE__ */ $("div", {
2788
3805
  className: "space-y-3",
2789
3806
  children: [
2790
- /* @__PURE__ */ q("div", {
3807
+ /* @__PURE__ */ $("div", {
2791
3808
  className: "flex items-center justify-between gap-2",
2792
- children: [/* @__PURE__ */ K(Ee, {
3809
+ children: [/* @__PURE__ */ Q(xe, {
2793
3810
  value: l,
2794
3811
  onValueChange: (e) => u(e),
2795
- children: /* @__PURE__ */ q(De, { children: [
2796
- /* @__PURE__ */ K(Oe, {
3812
+ children: /* @__PURE__ */ $(q, { children: [
3813
+ /* @__PURE__ */ Q(Se, {
2797
3814
  value: "pending",
2798
3815
  children: "Pending"
2799
3816
  }),
2800
- /* @__PURE__ */ K(Oe, {
3817
+ /* @__PURE__ */ Q(Se, {
2801
3818
  value: "decided",
2802
3819
  children: "Decided"
2803
3820
  }),
2804
- /* @__PURE__ */ K(Oe, {
3821
+ /* @__PURE__ */ Q(Se, {
2805
3822
  value: "all",
2806
3823
  children: "All"
2807
3824
  })
2808
3825
  ] })
2809
- }), /* @__PURE__ */ q(v, {
3826
+ }), /* @__PURE__ */ $(v, {
2810
3827
  variant: "outline",
2811
3828
  size: "sm",
2812
- onClick: () => void P(),
3829
+ onClick: () => void ee(),
2813
3830
  disabled: M,
2814
3831
  "data-testid": "ai-inbox-refresh",
2815
- children: [/* @__PURE__ */ K(ct, { className: `h-3.5 w-3.5 mr-1.5 ${M ? "animate-spin" : ""}` }), "Refresh"]
3832
+ children: [/* @__PURE__ */ Q(st, { className: `h-3.5 w-3.5 mr-1.5 ${M ? "animate-spin" : ""}` }), "Refresh"]
2816
3833
  })]
2817
3834
  }),
2818
- N ? /* @__PURE__ */ q(f, {
3835
+ N ? /* @__PURE__ */ $(f, {
2819
3836
  variant: "destructive",
2820
- children: [/* @__PURE__ */ K(Pe, { className: "h-4 w-4" }), /* @__PURE__ */ K(p, { children: N.message })]
3837
+ children: [/* @__PURE__ */ Q(Oe, { className: "h-4 w-4" }), /* @__PURE__ */ Q(p, { children: N.message })]
2821
3838
  }) : null,
2822
- D ? /* @__PURE__ */ q(f, {
3839
+ D ? /* @__PURE__ */ $(f, {
2823
3840
  variant: "destructive",
2824
- children: [/* @__PURE__ */ K(Pe, { className: "h-4 w-4" }), /* @__PURE__ */ K(p, { children: D })]
3841
+ children: [/* @__PURE__ */ Q(Oe, { className: "h-4 w-4" }), /* @__PURE__ */ Q(p, { children: D })]
2825
3842
  }) : null,
2826
- k && !D ? /* @__PURE__ */ q(f, {
3843
+ k && !D ? /* @__PURE__ */ $(f, {
2827
3844
  variant: k.ok ? "default" : "destructive",
2828
- children: [k.ok ? /* @__PURE__ */ K(Be, { className: "h-4 w-4" }) : /* @__PURE__ */ K(U, { className: "h-4 w-4" }), /* @__PURE__ */ q(p, { children: [
3845
+ children: [k.ok ? /* @__PURE__ */ Q(Y, { className: "h-4 w-4" }) : /* @__PURE__ */ Q(X, { className: "h-4 w-4" }), /* @__PURE__ */ $(p, { children: [
2829
3846
  k.kind === "approve" ? "Approve" : "Reject",
2830
3847
  " for",
2831
3848
  " ",
2832
- /* @__PURE__ */ q("code", {
3849
+ /* @__PURE__ */ $("code", {
2833
3850
  className: "text-xs",
2834
3851
  children: [k.id.slice(0, 8), "…"]
2835
3852
  }),
@@ -2838,89 +3855,89 @@ function ai({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
2838
3855
  k.message ?? (k.ok ? "OK" : "Failed")
2839
3856
  ] })]
2840
3857
  }) : null,
2841
- M && L.length === 0 ? /* @__PURE__ */ q("div", {
3858
+ M && F.length === 0 ? /* @__PURE__ */ $("div", {
2842
3859
  className: "space-y-2",
2843
3860
  children: [
2844
- /* @__PURE__ */ K(xe, { className: "h-10 w-full" }),
2845
- /* @__PURE__ */ K(xe, { className: "h-10 w-full" }),
2846
- /* @__PURE__ */ K(xe, { className: "h-10 w-full" })
3861
+ /* @__PURE__ */ Q(H, { className: "h-10 w-full" }),
3862
+ /* @__PURE__ */ Q(H, { className: "h-10 w-full" }),
3863
+ /* @__PURE__ */ Q(H, { className: "h-10 w-full" })
2847
3864
  ]
2848
- }) : L.length === 0 ? /* @__PURE__ */ K(ee, { children: /* @__PURE__ */ q(ne, { children: [
2849
- /* @__PURE__ */ K(re, { children: /* @__PURE__ */ K(tt, { className: "h-8 w-8 text-muted-foreground" }) }),
2850
- /* @__PURE__ */ K(ie, { children: "No actions waiting" }),
2851
- /* @__PURE__ */ K(te, { children: "When the AI proposes a sensitive action it will appear here for review." })
2852
- ] }) }) : /* @__PURE__ */ K("div", {
3865
+ }) : F.length === 0 ? /* @__PURE__ */ Q(ne, { children: /* @__PURE__ */ $(re, { children: [
3866
+ /* @__PURE__ */ Q(ie, { children: /* @__PURE__ */ Q($e, { className: "h-8 w-8 text-muted-foreground" }) }),
3867
+ /* @__PURE__ */ Q(ae, { children: "No actions waiting" }),
3868
+ /* @__PURE__ */ Q(I, { children: "When the AI proposes a sensitive action it will appear here for review." })
3869
+ ] }) }) : /* @__PURE__ */ Q("div", {
2853
3870
  className: "rounded-md border",
2854
- children: /* @__PURE__ */ q(Se, { children: [/* @__PURE__ */ K(we, { children: /* @__PURE__ */ q(Te, { children: [
2855
- /* @__PURE__ */ K(V, {
3871
+ children: /* @__PURE__ */ $(ye, { children: [/* @__PURE__ */ Q(G, { children: /* @__PURE__ */ $(K, { children: [
3872
+ /* @__PURE__ */ Q(W, {
2856
3873
  className: "w-[140px]",
2857
3874
  children: "Tool"
2858
3875
  }),
2859
- /* @__PURE__ */ K(V, {
3876
+ /* @__PURE__ */ Q(W, {
2860
3877
  className: "w-[140px]",
2861
3878
  children: "Action"
2862
3879
  }),
2863
- /* @__PURE__ */ K(V, {
3880
+ /* @__PURE__ */ Q(W, {
2864
3881
  className: "w-[120px]",
2865
3882
  children: "Object"
2866
3883
  }),
2867
- /* @__PURE__ */ K(V, {
3884
+ /* @__PURE__ */ Q(W, {
2868
3885
  className: "w-[110px]",
2869
3886
  children: "Status"
2870
3887
  }),
2871
- /* @__PURE__ */ K(V, {
3888
+ /* @__PURE__ */ Q(W, {
2872
3889
  className: "w-[110px]",
2873
3890
  children: "Proposed"
2874
3891
  }),
2875
- /* @__PURE__ */ K(V, {
3892
+ /* @__PURE__ */ Q(W, {
2876
3893
  className: "w-[260px] text-right",
2877
3894
  children: "Decision"
2878
3895
  })
2879
- ] }) }), /* @__PURE__ */ K(Ce, { children: L.map((e) => {
3896
+ ] }) }), /* @__PURE__ */ Q(be, { children: F.map((e) => {
2880
3897
  let t = e.status === "pending", n = T === e.id;
2881
- return /* @__PURE__ */ q(Te, { children: [
2882
- /* @__PURE__ */ K(B, {
3898
+ return /* @__PURE__ */ $(K, { children: [
3899
+ /* @__PURE__ */ Q(U, {
2883
3900
  className: "font-mono text-xs",
2884
3901
  children: e.tool_name
2885
3902
  }),
2886
- /* @__PURE__ */ K(B, {
3903
+ /* @__PURE__ */ Q(U, {
2887
3904
  className: "text-sm",
2888
3905
  children: e.action_name
2889
3906
  }),
2890
- /* @__PURE__ */ K(B, {
3907
+ /* @__PURE__ */ Q(U, {
2891
3908
  className: "text-sm",
2892
3909
  children: e.object_name
2893
3910
  }),
2894
- /* @__PURE__ */ K(B, { children: /* @__PURE__ */ K(ei, { status: e.status }) }),
2895
- /* @__PURE__ */ K(B, {
3911
+ /* @__PURE__ */ Q(U, { children: /* @__PURE__ */ Q(ra, { status: e.status }) }),
3912
+ /* @__PURE__ */ Q(U, {
2896
3913
  className: "text-xs text-muted-foreground",
2897
- children: /* @__PURE__ */ q("span", {
3914
+ children: /* @__PURE__ */ $("span", {
2898
3915
  className: "inline-flex items-center gap-1",
2899
3916
  children: [
2900
- /* @__PURE__ */ K(qe, { className: "h-3 w-3" }),
3917
+ /* @__PURE__ */ Q(He, { className: "h-3 w-3" }),
2901
3918
  " ",
2902
- ti(e.proposed_at)
3919
+ ia(e.proposed_at)
2903
3920
  ]
2904
3921
  })
2905
3922
  }),
2906
- /* @__PURE__ */ K(B, {
3923
+ /* @__PURE__ */ Q(U, {
2907
3924
  className: "text-right",
2908
- children: /* @__PURE__ */ q("div", {
3925
+ children: /* @__PURE__ */ $("div", {
2909
3926
  className: "inline-flex gap-1.5",
2910
- children: [/* @__PURE__ */ q(v, {
3927
+ children: [/* @__PURE__ */ $(v, {
2911
3928
  size: "sm",
2912
3929
  variant: "ghost",
2913
3930
  onClick: () => m(e.id),
2914
3931
  "data-testid": `ai-inbox-view-${e.id}`,
2915
- children: [/* @__PURE__ */ K($e, { className: "h-3.5 w-3.5 mr-1" }), " View"]
2916
- }), t ? /* @__PURE__ */ q(G, { children: [/* @__PURE__ */ q(v, {
3932
+ children: [/* @__PURE__ */ Q(Ye, { className: "h-3.5 w-3.5 mr-1" }), " View"]
3933
+ }), t ? /* @__PURE__ */ $(Z, { children: [/* @__PURE__ */ $(v, {
2917
3934
  size: "sm",
2918
3935
  variant: "default",
2919
3936
  disabled: n,
2920
- onClick: () => void ae(e.id),
3937
+ onClick: () => void R(e.id),
2921
3938
  "data-testid": `ai-inbox-approve-${e.id}`,
2922
- children: [/* @__PURE__ */ K(Be, { className: "h-3.5 w-3.5 mr-1" }), n ? "Working…" : "Approve"]
2923
- }), /* @__PURE__ */ q(v, {
3939
+ children: [/* @__PURE__ */ Q(Y, { className: "h-3.5 w-3.5 mr-1" }), n ? "Working…" : "Approve"]
3940
+ }), /* @__PURE__ */ $(v, {
2924
3941
  size: "sm",
2925
3942
  variant: "destructive",
2926
3943
  disabled: n,
@@ -2928,7 +3945,7 @@ function ai({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
2928
3945
  g(e.id), w("");
2929
3946
  },
2930
3947
  "data-testid": `ai-inbox-reject-${e.id}`,
2931
- children: [/* @__PURE__ */ K(U, { className: "h-3.5 w-3.5 mr-1" }), "Reject"]
3948
+ children: [/* @__PURE__ */ Q(X, { className: "h-3.5 w-3.5 mr-1" }), "Reject"]
2932
3949
  })] }) : null]
2933
3950
  })
2934
3951
  })
@@ -2937,174 +3954,174 @@ function ai({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
2937
3954
  })
2938
3955
  ]
2939
3956
  });
2940
- return /* @__PURE__ */ q(G, { children: [
2941
- a === "card" ? /* @__PURE__ */ q(y, {
3957
+ return /* @__PURE__ */ $(Z, { children: [
3958
+ a === "card" ? /* @__PURE__ */ $(y, {
2942
3959
  className: c,
2943
- children: [/* @__PURE__ */ q(S, {
3960
+ children: [/* @__PURE__ */ $(S, {
2944
3961
  className: "pb-3",
2945
- children: [/* @__PURE__ */ q(C, {
3962
+ children: [/* @__PURE__ */ $(C, {
2946
3963
  className: "flex items-center gap-2",
2947
3964
  children: [
2948
- /* @__PURE__ */ K(Le, { className: "h-4 w-4" }),
3965
+ /* @__PURE__ */ Q(Me, { className: "h-4 w-4" }),
2949
3966
  " ",
2950
3967
  o
2951
3968
  ]
2952
- }), s ? /* @__PURE__ */ K(x, { children: s }) : null]
2953
- }), /* @__PURE__ */ K(b, { children: se })]
2954
- }) : /* @__PURE__ */ K("div", {
3969
+ }), s ? /* @__PURE__ */ Q(x, { children: s }) : null]
3970
+ }), /* @__PURE__ */ Q(b, { children: oe })]
3971
+ }) : /* @__PURE__ */ Q("div", {
2955
3972
  className: c,
2956
- children: se
3973
+ children: oe
2957
3974
  }),
2958
- /* @__PURE__ */ K(ge, {
3975
+ /* @__PURE__ */ Q(he, {
2959
3976
  open: !!d,
2960
3977
  onOpenChange: (e) => {
2961
3978
  e || m(null);
2962
3979
  },
2963
- children: /* @__PURE__ */ q(_e, {
3980
+ children: /* @__PURE__ */ $(ge, {
2964
3981
  className: "sm:max-w-[560px] overflow-y-auto",
2965
- children: [/* @__PURE__ */ q(ye, { children: [/* @__PURE__ */ q(be, {
3982
+ children: [/* @__PURE__ */ $(V, { children: [/* @__PURE__ */ $(ve, {
2966
3983
  className: "flex items-center gap-2",
2967
- children: [/* @__PURE__ */ K(Le, { className: "h-4 w-4" }), R ? R.action_name : "Pending action"]
2968
- }), /* @__PURE__ */ K(ve, { children: R ? /* @__PURE__ */ q(G, { children: [
3984
+ children: [/* @__PURE__ */ Q(Me, { className: "h-4 w-4" }), L ? L.action_name : "Pending action"]
3985
+ }), /* @__PURE__ */ Q(_e, { children: L ? /* @__PURE__ */ $(Z, { children: [
2969
3986
  "Tool ",
2970
- /* @__PURE__ */ K("code", {
3987
+ /* @__PURE__ */ Q("code", {
2971
3988
  className: "text-xs",
2972
- children: R.tool_name
3989
+ children: L.tool_name
2973
3990
  }),
2974
3991
  " on",
2975
3992
  " ",
2976
- /* @__PURE__ */ K("code", {
3993
+ /* @__PURE__ */ Q("code", {
2977
3994
  className: "text-xs",
2978
- children: R.object_name
3995
+ children: L.object_name
2979
3996
  })
2980
- ] }) : "Loading…" })] }), R ? /* @__PURE__ */ q("div", {
3997
+ ] }) : "Loading…" })] }), L ? /* @__PURE__ */ $("div", {
2981
3998
  className: "px-4 space-y-4 mt-4",
2982
3999
  children: [
2983
- /* @__PURE__ */ q("div", {
4000
+ /* @__PURE__ */ $("div", {
2984
4001
  className: "grid grid-cols-2 gap-3 text-sm",
2985
4002
  children: [
2986
- /* @__PURE__ */ q("div", { children: [/* @__PURE__ */ K(z, {
4003
+ /* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q(B, {
2987
4004
  className: "text-xs text-muted-foreground",
2988
4005
  children: "Status"
2989
- }), /* @__PURE__ */ K("div", {
4006
+ }), /* @__PURE__ */ Q("div", {
2990
4007
  className: "mt-1",
2991
- children: /* @__PURE__ */ K(ei, { status: R.status })
4008
+ children: /* @__PURE__ */ Q(ra, { status: L.status })
2992
4009
  })] }),
2993
- /* @__PURE__ */ q("div", { children: [/* @__PURE__ */ K(z, {
4010
+ /* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q(B, {
2994
4011
  className: "text-xs text-muted-foreground",
2995
4012
  children: "Proposed"
2996
- }), /* @__PURE__ */ K("div", {
4013
+ }), /* @__PURE__ */ Q("div", {
2997
4014
  className: "mt-1 text-xs",
2998
- children: ti(R.proposed_at)
4015
+ children: ia(L.proposed_at)
2999
4016
  })] }),
3000
- /* @__PURE__ */ q("div", { children: [/* @__PURE__ */ K(z, {
4017
+ /* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q(B, {
3001
4018
  className: "text-xs text-muted-foreground",
3002
4019
  children: "Proposed by"
3003
- }), /* @__PURE__ */ K("div", {
4020
+ }), /* @__PURE__ */ Q("div", {
3004
4021
  className: "mt-1 text-xs font-mono break-all",
3005
- children: R.proposed_by ?? "—"
4022
+ children: L.proposed_by ?? "—"
3006
4023
  })] }),
3007
- /* @__PURE__ */ q("div", { children: [/* @__PURE__ */ K(z, {
4024
+ /* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q(B, {
3008
4025
  className: "text-xs text-muted-foreground",
3009
4026
  children: "Decided by"
3010
- }), /* @__PURE__ */ K("div", {
4027
+ }), /* @__PURE__ */ Q("div", {
3011
4028
  className: "mt-1 text-xs font-mono break-all",
3012
- children: R.decided_by ?? "—"
4029
+ children: L.decided_by ?? "—"
3013
4030
  })] }),
3014
- R.conversation_id ? /* @__PURE__ */ q("div", {
4031
+ L.conversation_id ? /* @__PURE__ */ $("div", {
3015
4032
  className: "col-span-2",
3016
- children: [/* @__PURE__ */ K(z, {
4033
+ children: [/* @__PURE__ */ Q(B, {
3017
4034
  className: "text-xs text-muted-foreground",
3018
4035
  children: "Conversation"
3019
- }), /* @__PURE__ */ K("div", {
4036
+ }), /* @__PURE__ */ Q("div", {
3020
4037
  className: "mt-1 text-xs font-mono break-all",
3021
- children: R.conversation_id
4038
+ children: L.conversation_id
3022
4039
  })]
3023
4040
  }) : null
3024
4041
  ]
3025
4042
  }),
3026
- /* @__PURE__ */ K(he, {}),
3027
- /* @__PURE__ */ q("div", { children: [/* @__PURE__ */ K(z, {
4043
+ /* @__PURE__ */ Q(me, {}),
4044
+ /* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q(B, {
3028
4045
  className: "text-xs",
3029
4046
  children: "Tool input"
3030
- }), /* @__PURE__ */ K("div", {
4047
+ }), /* @__PURE__ */ Q("div", {
3031
4048
  className: "mt-1.5",
3032
- children: /* @__PURE__ */ K(ri, { value: ni(R.tool_input) })
4049
+ children: /* @__PURE__ */ Q(oa, { value: aa(L.tool_input) })
3033
4050
  })] }),
3034
- R.result ? /* @__PURE__ */ q("div", { children: [/* @__PURE__ */ K(z, {
4051
+ L.result ? /* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q(B, {
3035
4052
  className: "text-xs",
3036
4053
  children: "Result"
3037
- }), /* @__PURE__ */ K("div", {
4054
+ }), /* @__PURE__ */ Q("div", {
3038
4055
  className: "mt-1.5",
3039
- children: /* @__PURE__ */ K(ri, { value: ni(R.result) })
4056
+ children: /* @__PURE__ */ Q(oa, { value: aa(L.result) })
3040
4057
  })] }) : null,
3041
- R.error ? /* @__PURE__ */ q("div", { children: [/* @__PURE__ */ K(z, {
4058
+ L.error ? /* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q(B, {
3042
4059
  className: "text-xs text-destructive",
3043
4060
  children: "Error"
3044
- }), /* @__PURE__ */ K("div", {
4061
+ }), /* @__PURE__ */ Q("div", {
3045
4062
  className: "mt-1.5",
3046
- children: /* @__PURE__ */ K(ri, { value: R.error })
4063
+ children: /* @__PURE__ */ Q(oa, { value: L.error })
3047
4064
  })] }) : null,
3048
- R.rejection_reason ? /* @__PURE__ */ q("div", { children: [/* @__PURE__ */ K(z, {
4065
+ L.rejection_reason ? /* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q(B, {
3049
4066
  className: "text-xs",
3050
4067
  children: "Rejection reason"
3051
- }), /* @__PURE__ */ K("div", {
4068
+ }), /* @__PURE__ */ Q("div", {
3052
4069
  className: "mt-1.5 text-sm",
3053
- children: R.rejection_reason
4070
+ children: L.rejection_reason
3054
4071
  })] }) : null,
3055
- R.status === "pending" ? /* @__PURE__ */ q("div", {
4072
+ L.status === "pending" ? /* @__PURE__ */ $("div", {
3056
4073
  className: "pt-2 flex gap-2",
3057
- children: [/* @__PURE__ */ q(v, {
4074
+ children: [/* @__PURE__ */ $(v, {
3058
4075
  size: "sm",
3059
- onClick: () => void ae(R.id),
3060
- disabled: T === R.id,
3061
- children: [/* @__PURE__ */ K(Be, { className: "h-3.5 w-3.5 mr-1" }), "Approve & Execute"]
3062
- }), /* @__PURE__ */ q(v, {
4076
+ onClick: () => void R(L.id),
4077
+ disabled: T === L.id,
4078
+ children: [/* @__PURE__ */ Q(Y, { className: "h-3.5 w-3.5 mr-1" }), "Approve & Execute"]
4079
+ }), /* @__PURE__ */ $(v, {
3063
4080
  size: "sm",
3064
4081
  variant: "destructive",
3065
4082
  onClick: () => {
3066
- g(R.id), w("");
4083
+ g(L.id), w("");
3067
4084
  },
3068
- disabled: T === R.id,
3069
- children: [/* @__PURE__ */ K(U, { className: "h-3.5 w-3.5 mr-1" }), "Reject"]
4085
+ disabled: T === L.id,
4086
+ children: [/* @__PURE__ */ Q(X, { className: "h-3.5 w-3.5 mr-1" }), "Reject"]
3070
4087
  })]
3071
4088
  }) : null
3072
4089
  ]
3073
4090
  }) : null]
3074
4091
  })
3075
4092
  }),
3076
- /* @__PURE__ */ K(ge, {
4093
+ /* @__PURE__ */ Q(he, {
3077
4094
  open: !!h,
3078
4095
  onOpenChange: (e) => {
3079
4096
  e || (g(null), w(""));
3080
4097
  },
3081
- children: /* @__PURE__ */ q(_e, {
4098
+ children: /* @__PURE__ */ $(ge, {
3082
4099
  side: "bottom",
3083
4100
  className: "max-h-[40vh]",
3084
- children: [/* @__PURE__ */ q(ye, { children: [/* @__PURE__ */ K(be, { children: "Reject this action?" }), /* @__PURE__ */ K(ve, { children: "The reason is shown back to the AI so it can adjust its next response." })] }), /* @__PURE__ */ q("div", {
4101
+ children: [/* @__PURE__ */ $(V, { children: [/* @__PURE__ */ Q(ve, { children: "Reject this action?" }), /* @__PURE__ */ Q(_e, { children: "The reason is shown back to the AI so it can adjust its next response." })] }), /* @__PURE__ */ $("div", {
3085
4102
  className: "px-4 mt-3 space-y-3",
3086
- children: [/* @__PURE__ */ K(ke, {
4103
+ children: [/* @__PURE__ */ Q(Ce, {
3087
4104
  value: _,
3088
4105
  onChange: (e) => w(e.target.value),
3089
4106
  placeholder: "Optional reason (e.g. 'Wrong record id — please confirm with the user first.')",
3090
4107
  rows: 4,
3091
4108
  "data-testid": "ai-inbox-reject-reason"
3092
- }), /* @__PURE__ */ q("div", {
4109
+ }), /* @__PURE__ */ $("div", {
3093
4110
  className: "flex justify-end gap-2",
3094
- children: [/* @__PURE__ */ K(v, {
4111
+ children: [/* @__PURE__ */ Q(v, {
3095
4112
  variant: "outline",
3096
4113
  size: "sm",
3097
4114
  onClick: () => {
3098
4115
  g(null), w("");
3099
4116
  },
3100
4117
  children: "Cancel"
3101
- }), /* @__PURE__ */ q(v, {
4118
+ }), /* @__PURE__ */ $(v, {
3102
4119
  variant: "destructive",
3103
4120
  size: "sm",
3104
- onClick: () => h && void oe(h, _),
4121
+ onClick: () => h && void z(h, _),
3105
4122
  disabled: !h || T === h,
3106
4123
  "data-testid": "ai-inbox-reject-confirm",
3107
- children: [/* @__PURE__ */ K(U, { className: "h-3.5 w-3.5 mr-1" }), "Reject"]
4124
+ children: [/* @__PURE__ */ Q(X, { className: "h-3.5 w-3.5 mr-1" }), "Reject"]
3108
4125
  })]
3109
4126
  })]
3110
4127
  })]
@@ -3114,14 +4131,14 @@ function ai({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
3114
4131
  }
3115
4132
  //#endregion
3116
4133
  //#region src/useHitlInChat.ts
3117
- function oi(e) {
4134
+ function la(e) {
3118
4135
  return !e || e.length === 0 ? "/api/v1/ai" : e.endsWith("/") ? e.slice(0, -1) : e;
3119
4136
  }
3120
- function si(e, t) {
4137
+ function ua(e, t) {
3121
4138
  let n = { ...e ?? {} };
3122
4139
  return t && (n["Content-Type"] = "application/json"), n;
3123
4140
  }
3124
- async function ci(e) {
4141
+ async function da(e) {
3125
4142
  let t = await e.text();
3126
4143
  if (!t) return null;
3127
4144
  try {
@@ -3130,8 +4147,8 @@ async function ci(e) {
3130
4147
  return { raw: t };
3131
4148
  }
3132
4149
  }
3133
- function li(t) {
3134
- let { messages: n, apiBase: r, headers: i, onDecided: a, continueConversation: o } = t, s = oi(r), c = e.useMemo(() => {
4150
+ function fa(t) {
4151
+ let { messages: n, apiBase: r, headers: i, onDecided: a, continueConversation: o } = t, s = la(r), c = e.useMemo(() => {
3135
4152
  let e = /* @__PURE__ */ new Map();
3136
4153
  for (let t of n) {
3137
4154
  let n = t.toolInvocations ?? [];
@@ -3174,9 +4191,9 @@ function li(t) {
3174
4191
  let r = `${s}/pending-actions/${encodeURIComponent(l)}/${t ? "approve" : "reject"}`, c = t ? "{}" : JSON.stringify({ reason: n ?? "" }), d = await fetch(r, {
3175
4192
  method: "POST",
3176
4193
  credentials: "include",
3177
- headers: si(i, !0),
4194
+ headers: ua(i, !0),
3178
4195
  body: c
3179
- }), f = await ci(d) ?? {};
4196
+ }), f = await da(d) ?? {};
3180
4197
  if (!d.ok) {
3181
4198
  let t = typeof f.error == "string" ? f.error : `Approval failed: HTTP ${d.status}`;
3182
4199
  m(e, {
@@ -3203,7 +4220,7 @@ function li(t) {
3203
4220
  state: "success",
3204
4221
  message: `Status: ${p}`
3205
4222
  }), h = !0), a?.(e, f), h && o) {
3206
- let r = ui({
4223
+ let r = pa({
3207
4224
  approved: t,
3208
4225
  status: p,
3209
4226
  toolName: u,
@@ -3238,24 +4255,24 @@ function li(t) {
3238
4255
  isDeciding: f
3239
4256
  };
3240
4257
  }
3241
- function ui(e) {
4258
+ function pa(e) {
3242
4259
  let { approved: t, status: n, toolName: r, pendingActionId: i, outcome: a, reason: o } = e, s = `[HITL ${i}]`;
3243
4260
  if (t && n === "executed") {
3244
4261
  let e = a.result;
3245
- return `${s} The operator approved the \`${r}\` call. It executed successfully with result: ${e == null ? "(no payload)" : typeof e == "string" ? e : di(JSON.stringify(e), 800)}. Acknowledge the outcome concisely and continue the user's task.`;
4262
+ return `${s} The operator approved the \`${r}\` call. It executed successfully with result: ${e == null ? "(no payload)" : typeof e == "string" ? e : ma(JSON.stringify(e), 800)}. Acknowledge the outcome concisely and continue the user's task.`;
3246
4263
  }
3247
4264
  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.`;
3248
4265
  if (n === "failed") {
3249
4266
  let e = a.error;
3250
- return `${s} The \`${r}\` call was approved but execution failed: ${typeof e == "string" ? e : di(JSON.stringify(e ?? {}), 400)}. Apologize concisely and offer alternatives.`;
4267
+ return `${s} The \`${r}\` call was approved but execution failed: ${typeof e == "string" ? e : ma(JSON.stringify(e ?? {}), 400)}. Apologize concisely and offer alternatives.`;
3251
4268
  }
3252
4269
  }
3253
- function di(e, t) {
4270
+ function ma(e, t) {
3254
4271
  return e.length <= t ? e : `${e.slice(0, t - 1)}…`;
3255
4272
  }
3256
4273
  //#endregion
3257
4274
  //#region src/index.tsx
3258
- var fi = 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) => {
4275
+ var ha = 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) => {
3259
4276
  let [m, h] = e.useState(""), g = e.useRef(null), _ = e.useRef(null);
3260
4277
  e.useEffect(() => {
3261
4278
  if (g.current) {
@@ -3268,20 +4285,20 @@ var fi = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
3268
4285
  }, b = (e) => {
3269
4286
  e.key === "Enter" && !e.shiftKey && (e.preventDefault(), y());
3270
4287
  };
3271
- return /* @__PURE__ */ q("div", {
4288
+ return /* @__PURE__ */ $("div", {
3272
4289
  ref: p,
3273
- className: H("flex flex-col border rounded-lg bg-background overflow-hidden", t),
4290
+ className: J("flex flex-col border rounded-lg bg-background overflow-hidden", t),
3274
4291
  style: { maxHeight: d },
3275
4292
  ...f,
3276
- children: [/* @__PURE__ */ K(ce, {
4293
+ children: [/* @__PURE__ */ Q(se, {
3277
4294
  ref: g,
3278
4295
  className: "flex-1 p-4",
3279
- children: /* @__PURE__ */ K("div", {
4296
+ children: /* @__PURE__ */ Q("div", {
3280
4297
  className: "space-y-4",
3281
- children: n.length === 0 ? /* @__PURE__ */ K("div", {
4298
+ children: n.length === 0 ? /* @__PURE__ */ Q("div", {
3282
4299
  className: "flex items-center justify-center h-32 text-muted-foreground text-sm",
3283
4300
  children: "No messages yet. Start a conversation!"
3284
- }) : n.map((e) => /* @__PURE__ */ K(pi, {
4301
+ }) : n.map((e) => /* @__PURE__ */ Q(ga, {
3285
4302
  message: e,
3286
4303
  showTimestamp: o,
3287
4304
  userAvatarUrl: s,
@@ -3290,11 +4307,11 @@ var fi = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
3290
4307
  assistantAvatarFallback: u
3291
4308
  }, e.id))
3292
4309
  })
3293
- }), /* @__PURE__ */ K("div", {
4310
+ }), /* @__PURE__ */ Q("div", {
3294
4311
  className: "border-t p-4",
3295
- children: /* @__PURE__ */ q("div", {
4312
+ children: /* @__PURE__ */ $("div", {
3296
4313
  className: "flex gap-2",
3297
- children: [/* @__PURE__ */ K(se, {
4314
+ children: [/* @__PURE__ */ Q(oe, {
3298
4315
  ref: _,
3299
4316
  value: m,
3300
4317
  onChange: (e) => h(e.target.value),
@@ -3302,71 +4319,71 @@ var fi = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
3302
4319
  placeholder: r,
3303
4320
  disabled: a,
3304
4321
  className: "flex-1"
3305
- }), /* @__PURE__ */ K(v, {
4322
+ }), /* @__PURE__ */ Q(v, {
3306
4323
  onClick: y,
3307
4324
  disabled: a || !m.trim(),
3308
4325
  size: "icon",
3309
- children: /* @__PURE__ */ K(lt, { className: "h-4 w-4" })
4326
+ children: /* @__PURE__ */ Q(lt, { className: "h-4 w-4" })
3310
4327
  })]
3311
4328
  })
3312
4329
  })]
3313
4330
  });
3314
4331
  });
3315
- fi.displayName = "Chatbot";
3316
- var pi = ({ message: e, showTimestamp: t, userAvatarUrl: n, userAvatarFallback: r, assistantAvatarUrl: i, assistantAvatarFallback: a }) => {
4332
+ ha.displayName = "Chatbot";
4333
+ var ga = ({ message: e, showTimestamp: t, userAvatarUrl: n, userAvatarFallback: r, assistantAvatarUrl: i, assistantAvatarFallback: a }) => {
3317
4334
  let o = e.role === "user";
3318
- if (e.role === "system") return /* @__PURE__ */ K("div", {
4335
+ if (e.role === "system") return /* @__PURE__ */ Q("div", {
3319
4336
  className: "flex justify-center",
3320
- children: /* @__PURE__ */ K("div", {
4337
+ children: /* @__PURE__ */ Q("div", {
3321
4338
  className: "text-xs text-muted-foreground bg-muted px-3 py-1 rounded-full",
3322
4339
  children: e.content
3323
4340
  })
3324
4341
  });
3325
4342
  let s = o ? e.avatar || n : e.avatar || i, c = o ? e.avatarFallback || r : e.avatarFallback || a;
3326
- return /* @__PURE__ */ q("div", {
3327
- className: H("flex gap-3", o ? "flex-row-reverse" : "flex-row"),
3328
- children: [/* @__PURE__ */ q(m, {
4343
+ return /* @__PURE__ */ $("div", {
4344
+ className: J("flex gap-3", o ? "flex-row-reverse" : "flex-row"),
4345
+ children: [/* @__PURE__ */ $(m, {
3329
4346
  className: "h-8 w-8",
3330
- children: [/* @__PURE__ */ K(g, { src: s }), /* @__PURE__ */ K(h, {
4347
+ children: [/* @__PURE__ */ Q(g, { src: s }), /* @__PURE__ */ Q(h, {
3331
4348
  className: "text-xs",
3332
4349
  children: c
3333
4350
  })]
3334
- }), /* @__PURE__ */ q("div", {
3335
- className: H("flex flex-col gap-1", o ? "items-end" : "items-start"),
3336
- children: [/* @__PURE__ */ K("div", {
3337
- className: H("rounded-lg px-4 py-2 max-w-[70%] break-words", o ? "bg-primary text-primary-foreground" : "bg-muted"),
3338
- children: /* @__PURE__ */ K("p", {
4351
+ }), /* @__PURE__ */ $("div", {
4352
+ className: J("flex flex-col gap-1", o ? "items-end" : "items-start"),
4353
+ children: [/* @__PURE__ */ Q("div", {
4354
+ className: J("rounded-lg px-4 py-2 max-w-[70%] break-words", o ? "bg-primary text-primary-foreground" : "bg-muted"),
4355
+ children: /* @__PURE__ */ Q("p", {
3339
4356
  className: "text-sm whitespace-pre-wrap",
3340
4357
  children: e.content
3341
4358
  })
3342
- }), t && e.timestamp && /* @__PURE__ */ K("span", {
4359
+ }), t && e.timestamp && /* @__PURE__ */ Q("span", {
3343
4360
  className: "text-xs text-muted-foreground",
3344
4361
  children: e.timestamp
3345
4362
  })]
3346
4363
  })]
3347
4364
  });
3348
- }, mi = e.forwardRef(({ className: e, avatarSrc: t, avatarFallback: n = "AI", ...r }, i) => /* @__PURE__ */ q("div", {
4365
+ }, _a = e.forwardRef(({ className: e, avatarSrc: t, avatarFallback: n = "AI", ...r }, i) => /* @__PURE__ */ $("div", {
3349
4366
  ref: i,
3350
- className: H("flex gap-3", e),
4367
+ className: J("flex gap-3", e),
3351
4368
  ...r,
3352
- children: [/* @__PURE__ */ q(m, {
4369
+ children: [/* @__PURE__ */ $(m, {
3353
4370
  className: "h-8 w-8",
3354
- children: [/* @__PURE__ */ K(g, { src: t }), /* @__PURE__ */ K(h, {
4371
+ children: [/* @__PURE__ */ Q(g, { src: t }), /* @__PURE__ */ Q(h, {
3355
4372
  className: "text-xs",
3356
4373
  children: n
3357
4374
  })]
3358
- }), /* @__PURE__ */ K("div", {
4375
+ }), /* @__PURE__ */ Q("div", {
3359
4376
  className: "flex items-center bg-muted rounded-lg px-4 py-2",
3360
- children: /* @__PURE__ */ q("div", {
4377
+ children: /* @__PURE__ */ $("div", {
3361
4378
  className: "flex gap-1",
3362
4379
  children: [
3363
- /* @__PURE__ */ K("span", { className: "w-2 h-2 bg-muted-foreground rounded-full animate-bounce [animation-delay:-0.3s]" }),
3364
- /* @__PURE__ */ K("span", { className: "w-2 h-2 bg-muted-foreground rounded-full animate-bounce [animation-delay:-0.15s]" }),
3365
- /* @__PURE__ */ K("span", { className: "w-2 h-2 bg-muted-foreground rounded-full animate-bounce" })
4380
+ /* @__PURE__ */ Q("span", { className: "w-2 h-2 bg-muted-foreground rounded-full animate-bounce [animation-delay:-0.3s]" }),
4381
+ /* @__PURE__ */ Q("span", { className: "w-2 h-2 bg-muted-foreground rounded-full animate-bounce [animation-delay:-0.15s]" }),
4382
+ /* @__PURE__ */ Q("span", { className: "w-2 h-2 bg-muted-foreground rounded-full animate-bounce" })
3366
4383
  ]
3367
4384
  })
3368
4385
  })]
3369
4386
  }));
3370
- mi.displayName = "TypingIndicator";
4387
+ _a.displayName = "TypingIndicator";
3371
4388
  //#endregion
3372
- export { Jr as AIElements, ai as AiPendingActionsInbox, fi as Chatbot, $ as ChatbotEnhanced, Gr as FloatingChatbot, Kt as FloatingChatbotPanel, Ht as FloatingChatbotProvider, Gt as FloatingChatbotTrigger, mi as TypingIndicator, Jt as humanizeToolName, Xt as summarizeChatError, It as uiMessageToChatMessage, Lt as uiMessagesToChatMessages, Yt as unwrapToolResult, Bt as useAgents, Ut as useFloatingChatbot, li as useHitlInChat, J as useObjectChat, Qr as usePendingActions };
4389
+ export { en as AGENT_ALIAS_GROUPS, Zi as AIElements, ca as AiPendingActionsInbox, ha as Chatbot, Mi as ChatbotEnhanced, Ji as FloatingChatbot, Tn as FloatingChatbotPanel, pn as FloatingChatbotProvider, yn as FloatingChatbotTrigger, cn as PLATFORM_DEFAULT_AGENT, _a as TypingIndicator, tn as agentAliasGroup, nn as agentRouteName, Wt as buildProgressFromDraftReview, Ht as detectDraftResult, Vt as detectProposedPlan, Dn as humanizeToolName, sn as isAskAgent, on as isBuildAgent, an as isBuiltinAgentName, wi as publishHealthFromResponse, rn as resolveAgentParam, ln as resolveDefaultAgentName, kn as summarizeChatError, Yt as uiMessageToChatMessage, Xt as uiMessagesToChatMessages, On as unwrapToolResult, dn as useAgents, mn as useFloatingChatbot, fa as useHitlInChat, $t as useObjectChat, ta as usePendingActions };