@object-ui/plugin-chatbot 11.0.0 → 11.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,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 ee, DropdownMenuItem as F, DropdownMenuTrigger as I, Empty as te, EmptyDescription as ne, EmptyHeader as L, 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 B, TableBody as Se, TableCell as V, TableHead as H, TableHeader as Ce, TableRow as we, Tabs as U, TabsList as W, TabsTrigger as G, Textarea as Te, Tooltip as K, TooltipContent as Ee, TooltipProvider as De, TooltipTrigger as Oe, cn as q } from "@object-ui/components";
4
- import { AlertCircle as ke, ArrowDownIcon as Ae, ArrowRight as je, BookIcon as Me, Bot as Ne, BrainIcon as Pe, Check as Fe, CheckCircle2 as J, CheckCircleIcon as Y, 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, WifiOff as mt, WrenchIcon as ht, X as gt, XCircle as X, XCircleIcon as _t, XIcon as vt } from "lucide-react";
3
+ import { Alert as f, AlertDescription as p, Avatar as m, AvatarFallback as h, AvatarImage as g, Badge as _, Button as v, Card as y, CardContent as b, CardDescription as x, CardHeader as S, CardTitle as C, Collapsible as w, CollapsibleContent as T, CollapsibleTrigger as E, Command as D, CommandEmpty as O, CommandGroup as k, CommandInput as A, CommandItem as j, CommandList as M, CommandSeparator as N, DropdownMenu as P, DropdownMenuContent as F, DropdownMenuItem as I, DropdownMenuTrigger as L, Empty as ee, EmptyDescription as te, EmptyHeader as R, EmptyMedia as ne, EmptyTitle as re, HoverCard as z, HoverCardContent as ie, HoverCardTrigger as ae, Input as B, Label as V, ScrollArea as oe, ScrollBar as se, Select as ce, SelectContent as le, SelectItem as ue, SelectTrigger as de, SelectValue as fe, Separator as pe, Sheet as me, SheetContent as he, SheetDescription as ge, SheetHeader as _e, SheetTitle as ve, Skeleton as ye, Table as be, TableBody as xe, TableCell as H, TableHead as U, TableHeader as W, TableRow as Se, Tabs as Ce, TabsList as we, TabsTrigger as G, Textarea as K, Tooltip as Te, TooltipContent as Ee, TooltipProvider as De, TooltipTrigger as Oe, cn as q } from "@object-ui/components";
4
+ import { AlertCircle as ke, ArrowDownIcon as J, ArrowRight as Ae, BookIcon as je, Bot as Me, BrainIcon as Ne, Check as Pe, CheckCircle2 as Y, CheckCircleIcon as Fe, CheckIcon as Ie, ChevronDownIcon as Le, ChevronLeftIcon as Re, ChevronRightIcon as ze, CircleIcon as Be, ClipboardList as Ve, Clock as He, Clock3 as Ue, ClockIcon as We, Copy as Ge, CopyIcon as Ke, CornerDownLeft as qe, CornerDownLeftIcon as Je, Eye as Ye, GitCompareArrows as Xe, HelpCircle as Ze, Hourglass as Qe, ImageIcon as $e, Inbox as et, Loader2 as tt, Loader2Icon as nt, Maximize2 as rt, MicIcon as it, Minimize2 as at, PaperclipIcon as ot, PlusIcon as st, RefreshCw as ct, Rocket as lt, Send as ut, ShieldCheck as dt, Sparkles as ft, SquareIcon as pt, Table2 as mt, TriangleAlert as ht, WifiOff as gt, WrenchIcon as _t, X as vt, XCircle as X, XCircleIcon as yt, XIcon as bt } from "lucide-react";
5
5
  import { Fragment as Z, jsx as Q, jsxs as $ } from "react/jsx-runtime";
6
- import { useChat as yt } from "@ai-sdk/react";
7
- import { DefaultChatTransport as bt } from "ai";
8
- import * as xt from "react-dom";
9
- import { SchemaRenderer as St, useObjectTranslation as Ct } from "@object-ui/react";
10
- import { StickToBottom as wt, useStickToBottomContext as Tt } from "use-stick-to-bottom";
11
- import { cva as Et } from "class-variance-authority";
12
- import { Slot as Dt } from "@radix-ui/react-slot";
13
- import { Streamdown as Ot } from "streamdown";
14
- import { nanoid as kt } from "nanoid";
15
- import { codeToHtml as At } from "shiki";
16
- import { useControllableState as jt } from "@radix-ui/react-use-controllable-state";
17
- import { motion as Mt } from "motion/react";
18
- import { ComponentRegistry as Nt } from "@object-ui/core";
6
+ import { useChat as xt } from "@ai-sdk/react";
7
+ import { DefaultChatTransport as St } from "ai";
8
+ import * as Ct from "react-dom";
9
+ import { SchemaRenderer as wt, useObjectTranslation as Tt } from "@object-ui/react";
10
+ import { StickToBottom as Et, useStickToBottomContext as Dt } from "use-stick-to-bottom";
11
+ import { cva as Ot } from "class-variance-authority";
12
+ import { Slot as kt } from "@radix-ui/react-slot";
13
+ import { Streamdown as At } from "streamdown";
14
+ import { nanoid as jt } from "nanoid";
15
+ import { codeToHtml as Mt } from "shiki";
16
+ import { useControllableState as Nt } from "@radix-ui/react-use-controllable-state";
17
+ import { motion as Pt } from "motion/react";
18
+ import { ComponentRegistry as Ft } from "@object-ui/core";
19
19
  //#region \0rolldown/runtime.js
20
- var Pt = Object.defineProperty, Ft = (e, t) => {
20
+ var It = Object.defineProperty, Lt = (e, t) => {
21
21
  let n = {};
22
- for (var r in e) Pt(n, r, {
22
+ for (var r in e) It(n, r, {
23
23
  get: e[r],
24
24
  enumerable: !0
25
25
  });
26
- return t || Pt(n, Symbol.toStringTag, { value: "Module" }), n;
26
+ return t || It(n, Symbol.toStringTag, { value: "Module" }), n;
27
27
  };
28
28
  //#endregion
29
29
  //#region src/utils.ts
30
- function It(e = "msg") {
30
+ function Rt(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 Lt(e, t) {
35
+ function zt(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 Rt(e) {
38
+ function Bt(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 zt(e) {
42
+ function Vt(e) {
43
43
  let t = (e) => {
44
44
  if (e && typeof e == "object") return e;
45
45
  if (typeof e != "string") return;
@@ -62,8 +62,8 @@ function zt(e) {
62
62
  }
63
63
  return r;
64
64
  }
65
- function Bt(e) {
66
- let t = zt(e);
65
+ function Ht(e) {
66
+ let t = Vt(e);
67
67
  if (!t) return;
68
68
  let n = t.pendingActionId;
69
69
  if (t.status === "pending_approval" && typeof n == "string" && n.length > 0) return {
@@ -71,11 +71,11 @@ function Bt(e) {
71
71
  raw: t
72
72
  };
73
73
  }
74
- function Vt(e) {
74
+ function Ut(e) {
75
75
  return Array.isArray(e) ? e.filter((e) => typeof e == "string" && e.trim().length > 0) : [];
76
76
  }
77
- function Ht(e) {
78
- let t = zt(e);
77
+ function Wt(e) {
78
+ let t = Vt(e);
79
79
  if (!t || t.status !== "blueprint_proposed") return;
80
80
  let n = t.blueprint, r = n && typeof n == "object" ? n : {}, i = (Array.isArray(r.objects) ? r.objects : []).flatMap((e) => {
81
81
  let t = e;
@@ -91,7 +91,7 @@ function Ht(e) {
91
91
  views: a(o.views, Array.isArray(r.views) ? r.views.length : 0),
92
92
  dashboards: a(o.dashboards, Array.isArray(r.dashboards) ? r.dashboards.length : 0),
93
93
  seedData: a(o.seedData, Array.isArray(r.seedData) ? r.seedData.length : 0)
94
- }, c = Vt(t.questions), l = t.questionChoices, u = Array.isArray(l) ? l.flatMap((e) => {
94
+ }, c = Ut(t.questions), l = t.questionChoices, u = Array.isArray(l) ? l.flatMap((e) => {
95
95
  let t = e;
96
96
  if (typeof t?.text != "string" || !t.text) return [];
97
97
  let n = Array.isArray(t.options) ? t.options.filter((e) => typeof e == "string" && e.trim().length > 0) : [];
@@ -104,14 +104,14 @@ function Ht(e) {
104
104
  ...d ? { summary: d } : {},
105
105
  objects: i,
106
106
  counts: s,
107
- questions: c.length ? c : Vt(r.questions),
107
+ questions: c.length ? c : Ut(r.questions),
108
108
  ...u.length ? { questionChoices: u } : {},
109
- assumptions: Vt(r.assumptions),
109
+ assumptions: Ut(r.assumptions),
110
110
  ...typeof f == "string" && f ? { targetApp: f } : {}
111
111
  };
112
112
  }
113
- function Ut(e) {
114
- let t = zt(e);
113
+ function Gt(e) {
114
+ let t = Vt(e);
115
115
  if (!t || t.status !== "changes_proposed") return;
116
116
  let n = (e) => typeof e == "string" && e ? e : void 0, r = t.changes, i = (Array.isArray(r) ? r : []).flatMap((e) => {
117
117
  let t = e;
@@ -129,8 +129,8 @@ function Ut(e) {
129
129
  changes: i
130
130
  };
131
131
  }
132
- function Wt(e) {
133
- let t = zt(e);
132
+ function Kt(e) {
133
+ let t = Vt(e);
134
134
  if (!t || t.status !== "drafted") return;
135
135
  let n = [];
136
136
  if (Array.isArray(t.drafted)) {
@@ -170,23 +170,23 @@ function Wt(e) {
170
170
  ...s.length ? { issues: s } : {}
171
171
  };
172
172
  }
173
- function Gt(e) {
173
+ function qt(e) {
174
174
  return e.replace(/[._-]+/g, " ").replace(/\s+/g, " ").trim().replace(/\b\w/g, (e) => e.toUpperCase());
175
175
  }
176
- function Kt(e) {
176
+ function Jt(e) {
177
177
  if (!e || !Array.isArray(e.items) || e.items.length === 0) return;
178
178
  let t = e.items.find((e) => e.type === "app");
179
179
  if (t) return {
180
180
  phase: "done",
181
- appLabel: Gt(t.name),
181
+ appLabel: qt(t.name),
182
182
  items: e.items,
183
183
  done: e.items.length,
184
184
  total: e.items.length
185
185
  };
186
186
  }
187
- function qt(e, t = {}) {
187
+ function Yt(e, t = {}) {
188
188
  return e.filter((e) => e.type === "dynamic-tool" ? !0 : typeof e.type == "string" && e.type.startsWith("tool-")).map((e) => {
189
- let n = e.type === "dynamic-tool" ? e.toolName ?? "tool" : typeof e.type == "string" ? e.type.replace(/^tool-/, "") : "tool", r = e.output ?? e.result, i = Bt(r), a = Wt(r), o = Ht(r), s = Ut(r), c = e.state, l = (c === "input-available" || c === "input-streaming") && (r !== void 0 || !t.liveTail) ? "output-available" : c, u = i && l !== "output-error" ? "approval-requested" : l;
189
+ let n = e.type === "dynamic-tool" ? e.toolName ?? "tool" : typeof e.type == "string" ? e.type.replace(/^tool-/, "") : "tool", r = e.output ?? e.result, i = Ht(r), a = Kt(r), o = Wt(r), s = Gt(r), c = e.state, l = (c === "input-available" || c === "input-streaming") && (r !== void 0 || !t.liveTail) ? "output-available" : c, u = i && l !== "output-error" ? "approval-requested" : l;
190
190
  return {
191
191
  toolCallId: e.toolCallId ?? e.id ?? `${e.type ?? "tool"}-${Math.random().toString(36).slice(2, 8)}`,
192
192
  toolName: n,
@@ -201,7 +201,7 @@ function qt(e, t = {}) {
201
201
  };
202
202
  });
203
203
  }
204
- function Jt(e) {
204
+ function Xt(e) {
205
205
  let t = e.filter((e) => e.type === "source-url" || e.type === "source").map((e) => ({
206
206
  id: e.id,
207
207
  title: e.title,
@@ -209,7 +209,7 @@ function Jt(e) {
209
209
  })).filter((e) => !!e.url);
210
210
  return t.length > 0 ? t : void 0;
211
211
  }
212
- function Yt(e) {
212
+ function Zt(e) {
213
213
  let t = e.filter((e) => e.type === "data-build-progress").pop()?.data;
214
214
  if (!t || typeof t != "object") return;
215
215
  let n = t, r = Array.isArray(n.items) ? n.items.filter((e) => typeof e?.type == "string" && typeof e?.name == "string").map((e) => ({
@@ -225,7 +225,29 @@ function Yt(e) {
225
225
  ...typeof n.seq == "number" ? { seq: n.seq } : {}
226
226
  };
227
227
  }
228
- function Xt(e) {
228
+ function Qt(e) {
229
+ let t = e.filter((e) => e.type === "data-blueprint-progress").pop()?.data;
230
+ if (!t || typeof t != "object") return;
231
+ let n = t, r = Array.isArray(n.objects) ? n.objects.filter((e) => typeof e?.name == "string").map((e) => ({
232
+ name: e.name,
233
+ ...typeof e.label == "string" ? { label: e.label } : {},
234
+ ...typeof e.fields == "number" ? { fields: e.fields } : {}
235
+ })) : [], i = n.phase === "done" ? "done" : "designing", a;
236
+ if (n.counts && typeof n.counts == "object") {
237
+ let e = n.counts, t = {};
238
+ typeof e.objects == "number" && (t.objects = e.objects), typeof e.views == "number" && (t.views = e.views), typeof e.dashboards == "number" && (t.dashboards = e.dashboards), Object.keys(t).length > 0 && (a = t);
239
+ }
240
+ return {
241
+ phase: i,
242
+ ...typeof n.summary == "string" ? { summary: n.summary } : {},
243
+ ...typeof n.appLabel == "string" ? { appLabel: n.appLabel } : {},
244
+ ...typeof n.targetApp == "string" ? { targetApp: n.targetApp } : {},
245
+ objects: r,
246
+ ...a ? { counts: a } : {},
247
+ ...typeof n.seq == "number" ? { seq: n.seq } : {}
248
+ };
249
+ }
250
+ function $t(e) {
229
251
  let t = [];
230
252
  for (let n of e) {
231
253
  if (n.type !== "data-chart") continue;
@@ -245,28 +267,47 @@ function Xt(e) {
245
267
  }
246
268
  return t.length > 0 ? t : void 0;
247
269
  }
248
- function Zt(e, t = {}) {
249
- let n = Array.isArray(e.parts) ? e.parts : [], r = qt(n, { liveTail: t.streaming }), i = Array.isArray(e.toolInvocations) ? e.toolInvocations : [], a = r.length > 0 ? r : i, o = Yt(n) ?? a.map((e) => Kt(e.draftReview)).find((e) => !!e);
270
+ function en(e, t = {}) {
271
+ let n = Array.isArray(e.parts) ? e.parts : [], r = Yt(n, { liveTail: t.streaming }), i = Array.isArray(e.toolInvocations) ? e.toolInvocations : [], a = r.length > 0 ? r : i, o = Zt(n) ?? a.map((e) => Jt(e.draftReview)).find((e) => !!e);
250
272
  return {
251
273
  id: e.id ?? `msg-${Math.random().toString(36).slice(2, 8)}`,
252
274
  role: e.role ?? "assistant",
253
- content: Lt(e, n),
254
- reasoning: Rt(n),
275
+ content: zt(e, n),
276
+ reasoning: Bt(n),
255
277
  toolInvocations: a,
256
- sources: Jt(n),
278
+ sources: Xt(n),
257
279
  buildProgress: o,
258
- charts: Xt(n),
280
+ blueprintProgress: Qt(n),
281
+ charts: $t(n),
259
282
  streaming: t.streaming
260
283
  };
261
284
  }
262
- function Qt(e, t = {}) {
285
+ function tn(e, t = {}) {
263
286
  if (!Array.isArray(e) || e.length === 0) return [];
264
287
  let n = e.length - 1;
265
- return e.map((e, r) => Zt(e, { streaming: !!t.isStreaming && r === n && e.role === "assistant" }));
288
+ return e.map((e, r) => en(e, { streaming: !!t.isStreaming && r === n && e.role === "assistant" }));
266
289
  }
267
290
  //#endregion
268
291
  //#region src/useObjectChat.ts
269
- function $t(e) {
292
+ async function nn(e, t) {
293
+ let n;
294
+ try {
295
+ n = await fetch(e, t);
296
+ } catch (e) {
297
+ let t = e instanceof Error ? e : Error(String(e));
298
+ throw t.notSent = !0, t;
299
+ }
300
+ if (!n.ok) {
301
+ let e = "";
302
+ try {
303
+ e = await n.text();
304
+ } catch {}
305
+ let t = Error(e || n.statusText || `Request failed with status ${n.status}`);
306
+ throw t.status = n.status, t.notSent = !0, t;
307
+ }
308
+ return n;
309
+ }
310
+ function rn(e) {
270
311
  let t = [...e.messages].reverse().find((e) => e.role === "user");
271
312
  return { body: {
272
313
  ...e.body ?? {},
@@ -277,7 +318,7 @@ function $t(e) {
277
318
  ...t ? { turnId: t.id } : {}
278
319
  } };
279
320
  }
280
- function en(e) {
321
+ function an(e) {
281
322
  return (e ?? []).map((e, t) => ({
282
323
  id: e.id || `msg-${t}`,
283
324
  role: e.role || "user",
@@ -288,14 +329,14 @@ function en(e) {
288
329
  toolInvocations: e.toolInvocations
289
330
  }));
290
331
  }
291
- function tn(e = {}) {
332
+ function on(e = {}) {
292
333
  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) => {
293
334
  if (Array.isArray(e.parts) && e.parts.length > 0) return {
294
335
  id: e.id || `msg-${t}`,
295
336
  role: e.role || "user",
296
337
  parts: e.parts
297
338
  };
298
- let n = en([e])[0], r = [];
339
+ let n = an([e])[0], r = [];
299
340
  n.content && r.push({
300
341
  type: "text",
301
342
  text: n.content
@@ -322,48 +363,55 @@ function tn(e = {}) {
322
363
  };
323
364
  }), []), C = u(a);
324
365
  C.current = a;
325
- let w = yt({
326
- transport: l(() => {
327
- if (x) return new bt({
328
- api: t,
329
- headers: { ...f },
330
- body: {
331
- ...p,
332
- ...r ? { conversationId: r } : {},
333
- ...a ? { model: a } : {},
334
- ...i ? { systemPrompt: i } : {},
335
- ...s === void 0 ? {} : { stream: s }
336
- },
337
- prepareSendMessagesRequest: ({ id: e, body: t, messages: n, trigger: r, messageId: i }) => {
338
- let a = $t({
339
- id: e,
340
- body: t,
341
- messages: n,
342
- trigger: r,
343
- messageId: i
344
- });
345
- return C.current && (a.body.model = C.current), a;
346
- }
347
- });
348
- }, [
349
- x,
350
- t,
351
- f,
352
- p,
353
- a,
354
- i,
355
- s,
356
- r
357
- ]),
366
+ let w = l(() => {
367
+ if (x) return new St({
368
+ api: t,
369
+ fetch: nn,
370
+ headers: { ...f },
371
+ body: {
372
+ ...p,
373
+ ...r ? { conversationId: r } : {},
374
+ ...a ? { model: a } : {},
375
+ ...i ? { systemPrompt: i } : {},
376
+ ...s === void 0 ? {} : { stream: s }
377
+ },
378
+ prepareSendMessagesRequest: ({ id: e, body: t, messages: n, trigger: r, messageId: i }) => {
379
+ let a = rn({
380
+ id: e,
381
+ body: t,
382
+ messages: n,
383
+ trigger: r,
384
+ messageId: i
385
+ });
386
+ return C.current && (a.body.model = C.current), a;
387
+ }
388
+ });
389
+ }, [
390
+ x,
391
+ t,
392
+ f,
393
+ p,
394
+ a,
395
+ i,
396
+ s,
397
+ r
398
+ ]), T = u(null), E = xt({
399
+ transport: w,
358
400
  messages: x && S.length > 0 ? S : void 0,
359
401
  onError: x ? (e) => {
402
+ if (e.notSent) {
403
+ let e = T.current, t = e?.messages;
404
+ e?.setMessages && t && t.length > 0 && t[t.length - 1]?.role === "user" && e.setMessages(t.slice(0, -1));
405
+ }
360
406
  h?.(e);
361
407
  } : void 0
362
- }), [T, E] = d(() => en(n)), [D, O] = d(!1), [k, A] = d(""), [j, M] = d(""), N = u(null);
408
+ });
409
+ T.current = E;
410
+ let [D, O] = d(() => an(n)), [k, A] = d(!1), [j, M] = d(""), [N, P] = d(""), F = u(null);
363
411
  if (c(() => () => {
364
- N.current &&= (clearTimeout(N.current), null);
412
+ F.current &&= (clearTimeout(F.current), null);
365
413
  }, []), x) {
366
- let { messages: e, status: t, error: n, sendMessage: r, regenerate: i, stop: a, setMessages: s } = w, c = t === "submitted" || t === "streaming", l = Qt(e, { isStreaming: c }).map((t, n) => ({
414
+ let { messages: e, status: t, error: n, sendMessage: r, regenerate: i, stop: a, setMessages: s } = E, c = t === "submitted" || t === "streaming", l = tn(e, { isStreaming: c }).map((t, n) => ({
367
415
  ...t,
368
416
  metadata: e[n]?.metadata
369
417
  }));
@@ -375,11 +423,11 @@ function tn(e = {}) {
375
423
  let t = e.trim();
376
424
  if (!t) return;
377
425
  let n = [...l, {
378
- id: It("msg"),
426
+ id: Rt("msg"),
379
427
  role: "user",
380
428
  content: t
381
429
  }];
382
- r({ text: t }), M(""), b?.(t, n);
430
+ r({ text: t }), P(""), b?.(t, n);
383
431
  }, [
384
432
  r,
385
433
  b,
@@ -392,39 +440,39 @@ function tn(e = {}) {
392
440
  }, [s]),
393
441
  setMessages: s,
394
442
  isApiMode: !0,
395
- input: j,
396
- setInput: M,
443
+ input: N,
444
+ setInput: P,
397
445
  handleInputChange: o((e) => {
398
- M(e.target.value);
446
+ P(e.target.value);
399
447
  }, [])
400
448
  };
401
449
  }
402
- let P = o(() => {
403
- N.current &&= (clearTimeout(N.current), null), O(!1);
450
+ let I = o(() => {
451
+ F.current &&= (clearTimeout(F.current), null), A(!1);
404
452
  }, []);
405
453
  return {
406
- messages: T,
407
- isLoading: D,
454
+ messages: D,
455
+ isLoading: k,
408
456
  error: void 0,
409
457
  sendMessage: o((e) => {
410
458
  if (!e.trim()) return;
411
459
  let t = {
412
- id: It("msg"),
460
+ id: Rt("msg"),
413
461
  role: "user",
414
462
  content: e.trim(),
415
463
  timestamp: g ? (/* @__PURE__ */ new Date()).toLocaleTimeString() : void 0
416
464
  };
417
- E((n) => {
465
+ O((n) => {
418
466
  let r = [...n, t];
419
467
  return b?.(e.trim(), r), r;
420
- }), A(""), _ && (O(!0), N.current = setTimeout(() => {
468
+ }), M(""), _ && (A(!0), F.current = setTimeout(() => {
421
469
  let e = {
422
- id: It("msg"),
470
+ id: Rt("msg"),
423
471
  role: "assistant",
424
472
  content: v || "Thank you for your message!",
425
473
  timestamp: g ? (/* @__PURE__ */ new Date()).toLocaleTimeString() : void 0
426
474
  };
427
- E((t) => [...t, e]), O(!1);
475
+ O((t) => [...t, e]), A(!1);
428
476
  }, y));
429
477
  }, [
430
478
  g,
@@ -433,56 +481,56 @@ function tn(e = {}) {
433
481
  y,
434
482
  b
435
483
  ]),
436
- stop: P,
484
+ stop: I,
437
485
  reload: o(() => {}, []),
438
486
  clear: o(() => {
439
- P(), E([]);
440
- }, [P]),
487
+ I(), O([]);
488
+ }, [I]),
441
489
  isApiMode: !1,
442
- input: k,
443
- setInput: A,
490
+ input: j,
491
+ setInput: M,
444
492
  handleInputChange: o((e) => {
445
- A(e.target.value);
493
+ M(e.target.value);
446
494
  }, [])
447
495
  };
448
496
  }
449
497
  //#endregion
450
498
  //#region src/agentAliases.ts
451
- var nn = [["build", "metadata_assistant"], ["ask", "data_chat"]];
452
- function rn(e) {
453
- return nn.find((t) => t.includes(e)) ?? [e];
499
+ var sn = [["build", "metadata_assistant"], ["ask", "data_chat"]];
500
+ function cn(e) {
501
+ return sn.find((t) => t.includes(e)) ?? [e];
454
502
  }
455
- function an(e) {
456
- return rn(e)[0];
503
+ function ln(e) {
504
+ return cn(e)[0];
457
505
  }
458
- function on(e, t) {
506
+ function un(e, t) {
459
507
  if (e) {
460
508
  if (t.includes(e)) return e;
461
- for (let n of rn(e)) if (t.includes(n)) return n;
509
+ for (let n of cn(e)) if (t.includes(n)) return n;
462
510
  }
463
511
  }
464
- function sn(e) {
465
- return e != null && nn.some((t) => t.includes(e));
512
+ function dn(e) {
513
+ return e != null && sn.some((t) => t.includes(e));
466
514
  }
467
- function cn(e) {
468
- return e != null && an(e) === "build";
515
+ function fn(e) {
516
+ return e != null && ln(e) === "build";
469
517
  }
470
- function ln(e) {
471
- return e != null && an(e) === "ask";
518
+ function pn(e) {
519
+ return e != null && ln(e) === "ask";
472
520
  }
473
521
  //#endregion
474
522
  //#region src/useAgents.ts
475
- var un = "ask";
476
- function dn(e, t) {
523
+ var mn = "ask";
524
+ function hn(e, t) {
477
525
  if (e.length === 0) return;
478
526
  let n = e.map((e) => e.name);
479
527
  if (t) {
480
- let e = on(t, n);
528
+ let e = un(t, n);
481
529
  if (e) return e;
482
530
  }
483
- return on("ask", n) || e[0].name;
531
+ return un("ask", n) || e[0].name;
484
532
  }
485
- function fn(e) {
533
+ function gn(e) {
486
534
  return e.filter((e) => typeof e?.name == "string" && e.name.length > 0).map((e) => ({
487
535
  name: e.name,
488
536
  label: e.label || e.name,
@@ -491,7 +539,7 @@ function fn(e) {
491
539
  active: e.active !== !1
492
540
  }));
493
541
  }
494
- function pn(e = {}) {
542
+ function _n(e = {}) {
495
543
  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);
496
544
  return _.current = n, c(() => {
497
545
  if (!r || !t) return;
@@ -511,7 +559,7 @@ function pn(e = {}) {
511
559
  return e.json();
512
560
  }).then((e) => {
513
561
  if (n) return;
514
- let t = fn(Array.isArray(e) ? e : e?.agents ?? []);
562
+ let t = gn(Array.isArray(e) ? e : e?.agents ?? []);
515
563
  s(t.length > 0 ? t : i);
516
564
  }).catch((e) => {
517
565
  n || e.name === "AbortError" || (m(e), s(i));
@@ -533,13 +581,13 @@ function pn(e = {}) {
533
581
  }
534
582
  //#endregion
535
583
  //#region src/useAiModels.ts
536
- function mn(e) {
584
+ function vn(e) {
537
585
  return e.filter((e) => typeof e?.id == "string" && e.id.length > 0).map((e) => ({
538
586
  id: e.id,
539
587
  label: e.label || e.id
540
588
  }));
541
589
  }
542
- function hn(e = {}) {
590
+ function yn(e = {}) {
543
591
  let { apiBase: t, headers: n, enabled: r = !0 } = e, [i, a] = d([]), [s, l] = d(void 0), [f, p] = d(!1), [m, h] = d(void 0), [g, _] = d(0), v = u(n);
544
592
  return v.current = n, c(() => {
545
593
  if (!r || !t) return;
@@ -559,7 +607,7 @@ function hn(e = {}) {
559
607
  if (!t.ok) throw Error(`Failed to load AI models (${t.status})`);
560
608
  let r = await t.json();
561
609
  if (n) return;
562
- let c = Array.isArray(r) ? r : r?.models ?? [], u = Array.isArray(r) ? void 0 : r?.defaultModel, d = mn(c);
610
+ let c = Array.isArray(r) ? r : r?.models ?? [], u = Array.isArray(r) ? void 0 : r?.defaultModel, d = vn(c);
563
611
  a(d), l(u ?? c.find((e) => e?.default)?.id ?? c[0]?.id), p(!1), d.length === 0 && o < 5 && !n && (o += 1, setTimeout(() => {
564
612
  s();
565
613
  }, 1200));
@@ -588,8 +636,8 @@ function hn(e = {}) {
588
636
  }
589
637
  //#endregion
590
638
  //#region src/FloatingChatbotProvider.tsx
591
- var gn = e.createContext(null);
592
- function _n({ defaultOpen: t = !1, children: n }) {
639
+ var bn = e.createContext(null);
640
+ function xn({ defaultOpen: t = !1, children: n }) {
593
641
  let [r, i] = e.useState(t), [a, o] = e.useState(!1), s = e.useMemo(() => ({
594
642
  isOpen: r,
595
643
  isFullscreen: a,
@@ -600,21 +648,21 @@ function _n({ defaultOpen: t = !1, children: n }) {
600
648
  toggle: () => i((e) => !e),
601
649
  toggleFullscreen: () => o((e) => !e)
602
650
  }), [r, a]);
603
- return /* @__PURE__ */ Q(gn.Provider, {
651
+ return /* @__PURE__ */ Q(bn.Provider, {
604
652
  value: s,
605
653
  children: n
606
654
  });
607
655
  }
608
- function vn() {
609
- let t = e.useContext(gn);
656
+ function Sn() {
657
+ let t = e.useContext(bn);
610
658
  if (!t) throw Error("useFloatingChatbot must be used within a <FloatingChatbotProvider>");
611
659
  return t;
612
660
  }
613
661
  //#endregion
614
662
  //#region src/FloatingChatbotTrigger.tsx
615
- function yn() {
663
+ function Cn() {
616
664
  try {
617
- let { t: e } = Ct();
665
+ let { t: e } = Tt();
618
666
  return (t, n) => {
619
667
  let r = e(`common.${t}`);
620
668
  return !r || r === `common.${t}` ? n : r;
@@ -623,7 +671,7 @@ function yn() {
623
671
  return (e, t) => t;
624
672
  }
625
673
  }
626
- var bn = {
674
+ var wn = {
627
675
  32: "size-8",
628
676
  36: "size-9",
629
677
  40: "size-10",
@@ -636,26 +684,26 @@ var bn = {
636
684
  72: "size-[72px]",
637
685
  80: "size-20"
638
686
  };
639
- function xn(e, t) {
687
+ function Tn(e, t) {
640
688
  return t.reduce((t, n) => Math.abs(n - e) < Math.abs(t - e) ? n : t);
641
689
  }
642
- function Sn(e) {
643
- return bn[e] ?? bn[xn(e, Object.keys(bn).map(Number))];
690
+ function En(e) {
691
+ return wn[e] ?? wn[Tn(e, Object.keys(wn).map(Number))];
644
692
  }
645
- function Cn({ position: e = "bottom-right", size: t = 56, className: n }) {
646
- let { isOpen: r, toggle: i } = vn(), a = yn();
693
+ function Dn({ position: e = "bottom-right", size: t = 56, className: n }) {
694
+ let { isOpen: r, toggle: i } = Sn(), a = Cn();
647
695
  return /* @__PURE__ */ Q(v, {
648
696
  onClick: i,
649
- className: q("fixed z-50 rounded-full shadow-lg transition-transform hover:scale-105", Sn(t), r && "hidden", e === "bottom-right" ? "right-6 bottom-20 sm:bottom-6" : "left-6 bottom-20 sm:bottom-6", n),
697
+ className: q("fixed z-50 rounded-full shadow-lg transition-transform hover:scale-105", En(t), r && "hidden", e === "bottom-right" ? "right-6 bottom-20 sm:bottom-6" : "left-6 bottom-20 sm:bottom-6", n),
650
698
  size: "icon",
651
699
  "aria-label": r ? a("closeChat", "Close chat") : a("openChat", "Open chat"),
652
700
  "data-testid": "floating-chatbot-trigger",
653
- children: Q(r ? gt : Ne, { className: "h-6 w-6" })
701
+ children: Q(r ? vt : Me, { className: "h-6 w-6" })
654
702
  });
655
703
  }
656
704
  //#endregion
657
705
  //#region src/FloatingChatbotPanel.tsx
658
- var wn = {
706
+ var On = {
659
707
  300: "sm:w-[300px]",
660
708
  320: "sm:w-[320px]",
661
709
  340: "sm:w-[340px]",
@@ -674,7 +722,7 @@ var wn = {
674
722
  640: "sm:w-[640px]",
675
723
  720: "sm:w-[720px]",
676
724
  800: "sm:w-[800px]"
677
- }, Tn = {
725
+ }, kn = {
678
726
  360: "h-[min(360px,calc(100svh_-_6rem_-_env(safe-area-inset-bottom)))] sm:h-[360px]",
679
727
  400: "h-[min(400px,calc(100svh_-_6rem_-_env(safe-area-inset-bottom)))] sm:h-[400px]",
680
728
  420: "h-[min(420px,calc(100svh_-_6rem_-_env(safe-area-inset-bottom)))] sm:h-[420px]",
@@ -688,19 +736,19 @@ var wn = {
688
736
  720: "h-[min(720px,calc(100svh_-_6rem_-_env(safe-area-inset-bottom)))] sm:h-[720px]",
689
737
  800: "h-[min(800px,calc(100svh_-_6rem_-_env(safe-area-inset-bottom)))] sm:h-[800px]"
690
738
  };
691
- function En(e, t) {
739
+ function An(e, t) {
692
740
  return t.reduce((t, n) => Math.abs(n - e) < Math.abs(t - e) ? n : t);
693
741
  }
694
- function Dn(e) {
695
- return wn[e] ?? wn[En(e, Object.keys(wn).map(Number))];
742
+ function jn(e) {
743
+ return On[e] ?? On[An(e, Object.keys(On).map(Number))];
696
744
  }
697
- function On(e) {
698
- return Tn[e] ?? Tn[En(e, Object.keys(Tn).map(Number))];
745
+ function Mn(e) {
746
+ return kn[e] ?? kn[An(e, Object.keys(kn).map(Number))];
699
747
  }
700
- function kn({ title: e = "Chat", position: t = "bottom-right", width: n = 400, height: r = 520, children: i, className: a, headerExtra: o, headerActions: s }) {
701
- let { isOpen: c, isFullscreen: l, close: u, toggleFullscreen: d } = vn();
748
+ function Nn({ title: e = "Chat", position: t = "bottom-right", width: n = 400, height: r = 520, children: i, className: a, headerExtra: o, headerActions: s }) {
749
+ let { isOpen: c, isFullscreen: l, close: u, toggleFullscreen: d } = Sn();
702
750
  return c ? /* @__PURE__ */ $("div", {
703
- className: q("fixed z-50 flex flex-col overflow-hidden border bg-background shadow-xl transition-all", l ? "inset-0 h-svh w-screen rounded-none" : t === "bottom-right" ? q("left-3 right-3 bottom-[calc(4rem_+_env(safe-area-inset-bottom))] rounded-lg", "sm:left-auto sm:right-6 sm:bottom-20 sm:max-h-[calc(100vh_-_100px)]", Dn(n), On(r)) : q("left-3 right-3 bottom-[calc(4rem_+_env(safe-area-inset-bottom))] rounded-lg", "sm:right-auto sm:left-6 sm:bottom-20 sm:max-h-[calc(100vh_-_100px)]", Dn(n), On(r)), a),
751
+ className: q("fixed z-50 flex flex-col overflow-hidden border bg-background shadow-xl transition-all", l ? "inset-0 h-svh w-screen rounded-none" : t === "bottom-right" ? q("left-3 right-3 bottom-[calc(4rem_+_env(safe-area-inset-bottom))] rounded-lg", "sm:left-auto sm:right-6 sm:bottom-20 sm:max-h-[calc(100vh_-_100px)]", jn(n), Mn(r)) : q("left-3 right-3 bottom-[calc(4rem_+_env(safe-area-inset-bottom))] rounded-lg", "sm:right-auto sm:left-6 sm:bottom-20 sm:max-h-[calc(100vh_-_100px)]", jn(n), Mn(r)), a),
704
752
  role: "dialog",
705
753
  "aria-label": e,
706
754
  "data-testid": "floating-chatbot-panel",
@@ -727,7 +775,7 @@ function kn({ title: e = "Chat", position: t = "bottom-right", width: n = 400, h
727
775
  onClick: d,
728
776
  "aria-label": l ? "Exit fullscreen" : "Fullscreen",
729
777
  "data-testid": "floating-chatbot-fullscreen",
730
- children: Q(l ? it : nt, { className: "h-4 w-4" })
778
+ children: Q(l ? at : rt, { className: "h-4 w-4" })
731
779
  }),
732
780
  /* @__PURE__ */ Q(v, {
733
781
  variant: "ghost",
@@ -736,7 +784,7 @@ function kn({ title: e = "Chat", position: t = "bottom-right", width: n = 400, h
736
784
  onClick: u,
737
785
  "aria-label": "Close chat",
738
786
  "data-testid": "floating-chatbot-close",
739
- children: /* @__PURE__ */ Q(gt, { className: "h-4 w-4" })
787
+ children: /* @__PURE__ */ Q(vt, { className: "h-4 w-4" })
740
788
  })
741
789
  ]
742
790
  })
@@ -749,7 +797,7 @@ function kn({ title: e = "Chat", position: t = "bottom-right", width: n = 400, h
749
797
  }
750
798
  //#endregion
751
799
  //#region src/tool-display.ts
752
- var An = {
800
+ var Pn = {
753
801
  ai: "AI",
754
802
  api: "API",
755
803
  crm: "CRM",
@@ -761,17 +809,17 @@ var An = {
761
809
  url: "URL",
762
810
  utc: "UTC"
763
811
  };
764
- function jn(e) {
812
+ function Fn(e) {
765
813
  if (!e) return "";
766
814
  let t = String(e).trim();
767
815
  if (!t) return "";
768
816
  let n = t.replace(/[_-]+/g, " ").replace(/([a-z])([A-Z])/g, "$1 $2").split(/\s+/).filter(Boolean);
769
817
  return n.length === 0 ? t : n.map((e, t) => {
770
818
  let n = e.toLowerCase();
771
- return An[n] ? An[n] : t === 0 ? n.charAt(0).toUpperCase() + n.slice(1) : n;
819
+ return Pn[n] ? Pn[n] : t === 0 ? n.charAt(0).toUpperCase() + n.slice(1) : n;
772
820
  }).join(" ");
773
821
  }
774
- function Mn(e) {
822
+ function In(e) {
775
823
  if (e == null) return e;
776
824
  let t = e;
777
825
  for (let e = 0; e < 2; e++) {
@@ -789,7 +837,7 @@ function Mn(e) {
789
837
  }
790
838
  return t;
791
839
  }
792
- function Nn(e) {
840
+ function Ln(e) {
793
841
  let t = (e instanceof Error ? e.message : String(e ?? "")).replace(/\s+/g, " ").trim();
794
842
  if (!t) return { summary: "Something went wrong. Please try again." };
795
843
  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);
@@ -798,12 +846,12 @@ function Nn(e) {
798
846
  details: n.length > i.length ? n : void 0
799
847
  };
800
848
  }
801
- var Pn = new Set([
849
+ var Rn = /* @__PURE__ */ new Set([
802
850
  "ai_design_quota_exhausted",
803
851
  "ai_data_chat_trial_exhausted",
804
852
  "ai_allowance_exhausted"
805
853
  ]);
806
- function Fn(e) {
854
+ function zn(e) {
807
855
  let t = e instanceof Error ? e.message : String(e ?? "");
808
856
  if (!t) return null;
809
857
  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("}");
@@ -814,7 +862,7 @@ function Fn(e) {
814
862
  } catch {
815
863
  return null;
816
864
  }
817
- return !a || typeof a.error != "string" || !Pn.has(a.error) ? null : {
865
+ return !a || typeof a.error != "string" || !Rn.has(a.error) ? null : {
818
866
  code: a.error,
819
867
  message: typeof a.message == "string" ? a.message : "",
820
868
  messageEn: typeof a.messageEn == "string" ? a.messageEn : void 0,
@@ -822,18 +870,30 @@ function Fn(e) {
822
870
  topUp: a.topUp === !0
823
871
  };
824
872
  }
873
+ function Bn(e) {
874
+ return !!(e && typeof e == "object" && e.notSent === !0);
875
+ }
876
+ function Vn(e) {
877
+ let t = e && typeof e == "object" ? e.status : void 0;
878
+ return typeof t == "number" ? t : void 0;
879
+ }
880
+ function Hn(e) {
881
+ if (Vn(e) === 429) return !0;
882
+ let t = e instanceof Error ? e.message : typeof e == "string" ? e : "";
883
+ return /\b429\b|too many requests|rate[\s_-]?limit/i.test(t);
884
+ }
825
885
  //#endregion
826
886
  //#region src/elements/conversation.tsx
827
- var In = ({ className: e, ...t }) => /* @__PURE__ */ Q(wt, {
887
+ var Un = ({ className: e, ...t }) => /* @__PURE__ */ Q(Et, {
828
888
  className: q("relative flex-1 overflow-y-hidden", e),
829
889
  initial: "smooth",
830
890
  resize: "smooth",
831
891
  role: "log",
832
892
  ...t
833
- }), Ln = ({ className: e, ...t }) => /* @__PURE__ */ Q(wt.Content, {
893
+ }), Wn = ({ className: e, ...t }) => /* @__PURE__ */ Q(Et.Content, {
834
894
  className: q("flex flex-col gap-8 p-4", e),
835
895
  ...t
836
- }), Rn = ({ className: e, title: t = "No messages yet", description: n = "Start a conversation to see messages here", icon: r, children: i, ...a }) => /* @__PURE__ */ Q("div", {
896
+ }), Gn = ({ className: e, title: t = "No messages yet", description: n = "Start a conversation to see messages here", icon: r, children: i, ...a }) => /* @__PURE__ */ Q("div", {
837
897
  className: q("flex size-full flex-col items-center justify-center gap-3 p-8 text-center", e),
838
898
  ...a,
839
899
  children: i ?? /* @__PURE__ */ $(Z, { children: [r && /* @__PURE__ */ Q("div", {
@@ -849,8 +909,8 @@ var In = ({ className: e, ...t }) => /* @__PURE__ */ Q(wt, {
849
909
  children: n
850
910
  })]
851
911
  })] })
852
- }), zn = ({ className: e, ...t }) => {
853
- let { isAtBottom: n, scrollToBottom: r } = Tt(), i = o(() => {
912
+ }), Kn = ({ className: e, ...t }) => {
913
+ let { isAtBottom: n, scrollToBottom: r } = Dt(), i = o(() => {
854
914
  r();
855
915
  }, [r]);
856
916
  return !n && /* @__PURE__ */ Q(v, {
@@ -860,44 +920,44 @@ var In = ({ className: e, ...t }) => /* @__PURE__ */ Q(wt, {
860
920
  type: "button",
861
921
  variant: "outline",
862
922
  ...t,
863
- children: /* @__PURE__ */ Q(Ae, { className: "size-4" })
923
+ children: /* @__PURE__ */ Q(J, { className: "size-4" })
864
924
  });
865
- }, Bn = Et("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", {
925
+ }, qn = Ot("flex w-fit items-stretch has-[>[data-slot=button-group]]:gap-2 [&>*]:focus-visible:relative [&>*]:focus-visible:z-10 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-md [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1", {
866
926
  variants: { orientation: {
867
927
  horizontal: "[&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none",
868
928
  vertical: "flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none"
869
929
  } },
870
930
  defaultVariants: { orientation: "horizontal" }
871
931
  });
872
- function Vn({ className: e, orientation: t, ...n }) {
932
+ function Jn({ className: e, orientation: t, ...n }) {
873
933
  return /* @__PURE__ */ Q("div", {
874
934
  role: "group",
875
935
  "data-slot": "button-group",
876
936
  "data-orientation": t,
877
- className: q(Bn({ orientation: t }), e),
937
+ className: q(qn({ orientation: t }), e),
878
938
  ...n
879
939
  });
880
940
  }
881
- function Hn({ className: e, asChild: t = !1, ...n }) {
882
- return /* @__PURE__ */ Q(t ? Dt : "div", {
941
+ function Yn({ className: e, asChild: t = !1, ...n }) {
942
+ return /* @__PURE__ */ Q(t ? kt : "div", {
883
943
  className: q("flex items-center gap-2 rounded-md border bg-muted px-4 text-sm font-medium shadow-xs [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4", e),
884
944
  ...n
885
945
  });
886
946
  }
887
947
  //#endregion
888
948
  //#region src/elements/message.tsx
889
- var Un = ({ className: e, from: t, ...n }) => /* @__PURE__ */ Q("div", {
949
+ var Xn = ({ className: e, from: t, ...n }) => /* @__PURE__ */ Q("div", {
890
950
  className: q("group flex w-full max-w-[95%] flex-col gap-2", t === "user" ? "is-user ml-auto justify-end" : "is-assistant", e),
891
951
  ...n
892
- }), Wn = ({ children: e, className: t, ...n }) => /* @__PURE__ */ Q("div", {
952
+ }), Zn = ({ children: e, className: t, ...n }) => /* @__PURE__ */ Q("div", {
893
953
  className: q("is-user:dark flex w-fit max-w-full min-w-0 flex-col gap-2 overflow-hidden text-sm", "group-[.is-user]:ml-auto group-[.is-user]:rounded-lg group-[.is-user]:bg-secondary group-[.is-user]:px-4 group-[.is-user]:py-3 group-[.is-user]:text-foreground", "group-[.is-assistant]:text-foreground", t),
894
954
  ...n,
895
955
  children: e
896
- }), Gn = ({ className: e, children: t, ...n }) => /* @__PURE__ */ Q("div", {
956
+ }), Qn = ({ className: e, children: t, ...n }) => /* @__PURE__ */ Q("div", {
897
957
  className: q("flex items-center gap-1", e),
898
958
  ...n,
899
959
  children: t
900
- }), Kn = ({ tooltip: e, children: t, label: n, variant: r = "ghost", size: i = "icon", ...a }) => {
960
+ }), $n = ({ tooltip: e, children: t, label: n, variant: r = "ghost", size: i = "icon", ...a }) => {
901
961
  let o = /* @__PURE__ */ $(v, {
902
962
  size: i,
903
963
  type: "button",
@@ -908,15 +968,15 @@ var Un = ({ className: e, from: t, ...n }) => /* @__PURE__ */ Q("div", {
908
968
  children: n || e
909
969
  })]
910
970
  });
911
- return e ? /* @__PURE__ */ Q(De, { children: /* @__PURE__ */ $(K, { children: [/* @__PURE__ */ Q(Oe, {
971
+ return e ? /* @__PURE__ */ Q(De, { children: /* @__PURE__ */ $(Te, { children: [/* @__PURE__ */ Q(Oe, {
912
972
  asChild: !0,
913
973
  children: o
914
974
  }), /* @__PURE__ */ Q(Ee, { children: /* @__PURE__ */ Q("p", { children: e }) })] }) }) : o;
915
- }, qn = r(null), Jn = () => {
916
- let e = s(qn);
975
+ }, er = r(null), tr = () => {
976
+ let e = s(er);
917
977
  if (!e) throw Error("MessageBranch components must be used within MessageBranch");
918
978
  return e;
919
- }, Yn = ({ defaultBranch: e = 0, onBranchChange: t, className: n, ...r }) => {
979
+ }, nr = ({ defaultBranch: e = 0, onBranchChange: t, className: n, ...r }) => {
920
980
  let [i, a] = d(e), [o, s] = d([]), c = (e) => {
921
981
  a(e), t?.(e);
922
982
  }, l = {
@@ -931,15 +991,15 @@ var Un = ({ className: e, from: t, ...n }) => /* @__PURE__ */ Q("div", {
931
991
  branches: o,
932
992
  setBranches: s
933
993
  };
934
- return /* @__PURE__ */ Q(qn.Provider, {
994
+ return /* @__PURE__ */ Q(er.Provider, {
935
995
  value: l,
936
996
  children: /* @__PURE__ */ Q("div", {
937
997
  className: q("grid w-full gap-2 [&>div]:pb-0", n),
938
998
  ...r
939
999
  })
940
1000
  });
941
- }, Xn = ({ children: e, ...t }) => {
942
- let { currentBranch: n, setBranches: r, branches: i } = Jn(), a = Array.isArray(e) ? e : [e];
1001
+ }, rr = ({ children: e, ...t }) => {
1002
+ let { currentBranch: n, setBranches: r, branches: i } = tr(), a = Array.isArray(e) ? e : [e];
943
1003
  return c(() => {
944
1004
  i.length !== a.length && r(a);
945
1005
  }, [
@@ -951,15 +1011,15 @@ var Un = ({ className: e, from: t, ...n }) => /* @__PURE__ */ Q("div", {
951
1011
  ...t,
952
1012
  children: e
953
1013
  }, e.key));
954
- }, Zn = ({ className: e, from: t, ...n }) => {
955
- let { totalBranches: r } = Jn();
956
- return r <= 1 ? null : /* @__PURE__ */ Q(Vn, {
1014
+ }, ir = ({ className: e, from: t, ...n }) => {
1015
+ let { totalBranches: r } = tr();
1016
+ return r <= 1 ? null : /* @__PURE__ */ Q(Jn, {
957
1017
  className: "[&>*:not(:first-child)]:rounded-l-md [&>*:not(:last-child)]:rounded-r-md",
958
1018
  orientation: "horizontal",
959
1019
  ...n
960
1020
  });
961
- }, Qn = ({ children: e, ...t }) => {
962
- let { goToPrevious: n, totalBranches: r } = Jn();
1021
+ }, ar = ({ children: e, ...t }) => {
1022
+ let { goToPrevious: n, totalBranches: r } = tr();
963
1023
  return /* @__PURE__ */ Q(v, {
964
1024
  "aria-label": "Previous branch",
965
1025
  disabled: r <= 1,
@@ -970,8 +1030,8 @@ var Un = ({ className: e, from: t, ...n }) => /* @__PURE__ */ Q("div", {
970
1030
  ...t,
971
1031
  children: e ?? /* @__PURE__ */ Q(Re, { size: 14 })
972
1032
  });
973
- }, $n = ({ children: e, className: t, ...n }) => {
974
- let { goToNext: r, totalBranches: i } = Jn();
1033
+ }, or = ({ children: e, className: t, ...n }) => {
1034
+ let { goToNext: r, totalBranches: i } = tr();
975
1035
  return /* @__PURE__ */ Q(v, {
976
1036
  "aria-label": "Next branch",
977
1037
  disabled: i <= 1,
@@ -982,9 +1042,9 @@ var Un = ({ className: e, from: t, ...n }) => /* @__PURE__ */ Q("div", {
982
1042
  ...n,
983
1043
  children: e ?? /* @__PURE__ */ Q(ze, { size: 14 })
984
1044
  });
985
- }, er = ({ className: e, ...t }) => {
986
- let { currentBranch: n, totalBranches: r } = Jn();
987
- return /* @__PURE__ */ $(Hn, {
1045
+ }, sr = ({ className: e, ...t }) => {
1046
+ let { currentBranch: n, totalBranches: r } = tr();
1047
+ return /* @__PURE__ */ $(Yn, {
988
1048
  className: q("border-none bg-transparent text-muted-foreground shadow-none", e),
989
1049
  ...t,
990
1050
  children: [
@@ -993,12 +1053,12 @@ var Un = ({ className: e, from: t, ...n }) => /* @__PURE__ */ Q("div", {
993
1053
  r
994
1054
  ]
995
1055
  });
996
- }, tr = a(({ className: e, ...t }) => /* @__PURE__ */ Q(Ot, {
1056
+ }, cr = a(({ className: e, ...t }) => /* @__PURE__ */ Q(At, {
997
1057
  className: q("size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0", e),
998
1058
  ...t
999
1059
  }), (e, t) => e.children === t.children);
1000
- tr.displayName = "MessageResponse";
1001
- function nr({ data: e, className: t, onRemove: n, ...r }) {
1060
+ cr.displayName = "MessageResponse";
1061
+ function lr({ data: e, className: t, onRemove: n, ...r }) {
1002
1062
  let i = e.filename || "", a = (e.mediaType?.startsWith("image/") && e.url ? "image" : "file") == "image", o = i || (a ? "Image" : "Attachment");
1003
1063
  return /* @__PURE__ */ Q("div", {
1004
1064
  className: q("group relative size-24 overflow-hidden rounded-lg", t),
@@ -1017,15 +1077,15 @@ function nr({ data: e, className: t, onRemove: n, ...r }) {
1017
1077
  },
1018
1078
  type: "button",
1019
1079
  variant: "ghost",
1020
- children: [/* @__PURE__ */ Q(vt, {}), /* @__PURE__ */ Q("span", {
1080
+ children: [/* @__PURE__ */ Q(bt, {}), /* @__PURE__ */ Q("span", {
1021
1081
  className: "sr-only",
1022
1082
  children: "Remove"
1023
1083
  })]
1024
- })] }) : /* @__PURE__ */ $(Z, { children: [/* @__PURE__ */ $(K, { children: [/* @__PURE__ */ Q(Oe, {
1084
+ })] }) : /* @__PURE__ */ $(Z, { children: [/* @__PURE__ */ $(Te, { children: [/* @__PURE__ */ Q(Oe, {
1025
1085
  asChild: !0,
1026
1086
  children: /* @__PURE__ */ Q("div", {
1027
1087
  className: "flex size-full shrink-0 items-center justify-center rounded-lg bg-muted text-muted-foreground",
1028
- children: /* @__PURE__ */ Q(at, { className: "size-4" })
1088
+ children: /* @__PURE__ */ Q(ot, { className: "size-4" })
1029
1089
  })
1030
1090
  }), /* @__PURE__ */ Q(Ee, { children: /* @__PURE__ */ Q("p", { children: o }) })] }), n && /* @__PURE__ */ $(v, {
1031
1091
  "aria-label": "Remove attachment",
@@ -1035,28 +1095,28 @@ function nr({ data: e, className: t, onRemove: n, ...r }) {
1035
1095
  },
1036
1096
  type: "button",
1037
1097
  variant: "ghost",
1038
- children: [/* @__PURE__ */ Q(vt, {}), /* @__PURE__ */ Q("span", {
1098
+ children: [/* @__PURE__ */ Q(bt, {}), /* @__PURE__ */ Q("span", {
1039
1099
  className: "sr-only",
1040
1100
  children: "Remove"
1041
1101
  })]
1042
1102
  })] })
1043
1103
  });
1044
1104
  }
1045
- function rr({ children: e, className: t, ...n }) {
1105
+ function ur({ children: e, className: t, ...n }) {
1046
1106
  return e ? /* @__PURE__ */ Q("div", {
1047
1107
  className: q("ml-auto flex w-fit flex-wrap items-start gap-2", t),
1048
1108
  ...n,
1049
1109
  children: e
1050
1110
  }) : null;
1051
1111
  }
1052
- var ir = ({ className: e, children: t, ...n }) => /* @__PURE__ */ Q("div", {
1112
+ var dr = ({ className: e, children: t, ...n }) => /* @__PURE__ */ Q("div", {
1053
1113
  className: q("mt-4 flex w-full items-center justify-between gap-4", e),
1054
1114
  ...n,
1055
1115
  children: t
1056
1116
  });
1057
1117
  //#endregion
1058
1118
  //#region src/elements/ui/input-group.tsx
1059
- function ar({ className: e, ...t }) {
1119
+ function fr({ className: e, ...t }) {
1060
1120
  return /* @__PURE__ */ Q("div", {
1061
1121
  "data-slot": "input-group",
1062
1122
  role: "group",
@@ -1064,7 +1124,7 @@ function ar({ className: e, ...t }) {
1064
1124
  ...t
1065
1125
  });
1066
1126
  }
1067
- var or = Et("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", {
1127
+ var pr = Ot("flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium text-muted-foreground select-none group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-4", {
1068
1128
  variants: { align: {
1069
1129
  "inline-start": "order-first pl-3 has-[>button]:ml-[-0.45rem] has-[>kbd]:ml-[-0.35rem]",
1070
1130
  "inline-end": "order-last pr-3 has-[>button]:mr-[-0.45rem] has-[>kbd]:mr-[-0.35rem]",
@@ -1073,19 +1133,19 @@ var or = Et("flex h-auto cursor-text items-center justify-center gap-2 py-1.5 te
1073
1133
  } },
1074
1134
  defaultVariants: { align: "inline-start" }
1075
1135
  });
1076
- function sr({ className: e, align: t = "inline-start", ...n }) {
1136
+ function mr({ className: e, align: t = "inline-start", ...n }) {
1077
1137
  return /* @__PURE__ */ Q("div", {
1078
1138
  role: "group",
1079
1139
  "data-slot": "input-group-addon",
1080
1140
  "data-align": t,
1081
- className: q(or({ align: t }), e),
1141
+ className: q(pr({ align: t }), e),
1082
1142
  onClick: (e) => {
1083
1143
  e.target.closest("button") || e.currentTarget.parentElement?.querySelector("input")?.focus();
1084
1144
  },
1085
1145
  ...n
1086
1146
  });
1087
1147
  }
1088
- var cr = Et("flex items-center gap-2 text-sm shadow-none", {
1148
+ var hr = Ot("flex items-center gap-2 text-sm shadow-none", {
1089
1149
  variants: { size: {
1090
1150
  xs: "h-6 gap-1 rounded-[calc(var(--radius)-5px)] px-2 has-[>svg]:px-2 [&>svg:not([class*='size-'])]:size-3.5",
1091
1151
  sm: "h-8 gap-1.5 rounded-md px-2.5 has-[>svg]:px-2.5",
@@ -1094,17 +1154,17 @@ var cr = Et("flex items-center gap-2 text-sm shadow-none", {
1094
1154
  } },
1095
1155
  defaultVariants: { size: "xs" }
1096
1156
  });
1097
- function lr({ className: e, type: t = "button", variant: n = "ghost", size: r = "xs", ...i }) {
1157
+ function gr({ className: e, type: t = "button", variant: n = "ghost", size: r = "xs", ...i }) {
1098
1158
  return /* @__PURE__ */ Q(v, {
1099
1159
  type: t,
1100
1160
  "data-size": r,
1101
1161
  variant: n,
1102
- className: q(cr({ size: r }), e),
1162
+ className: q(hr({ size: r }), e),
1103
1163
  ...i
1104
1164
  });
1105
1165
  }
1106
- function ur({ className: e, ...t }) {
1107
- return /* @__PURE__ */ Q(Te, {
1166
+ function _r({ className: e, ...t }) {
1167
+ return /* @__PURE__ */ Q(K, {
1108
1168
  "data-slot": "input-group-control",
1109
1169
  className: q("flex-1 resize-none rounded-none border-0 bg-transparent py-3 shadow-none focus-visible:ring-0 dark:bg-transparent", e),
1110
1170
  ...t
@@ -1112,20 +1172,20 @@ function ur({ className: e, ...t }) {
1112
1172
  }
1113
1173
  //#endregion
1114
1174
  //#region src/elements/prompt-input.tsx
1115
- var dr = r(null), fr = r(null), pr = () => {
1116
- let e = s(dr);
1175
+ var vr = r(null), yr = r(null), br = () => {
1176
+ let e = s(vr);
1117
1177
  if (!e) throw Error("Wrap your component inside <PromptInputProvider> to use usePromptInputController().");
1118
1178
  return e;
1119
- }, mr = () => s(dr), hr = () => {
1120
- let e = s(fr);
1179
+ }, xr = () => s(vr), Sr = () => {
1180
+ let e = s(yr);
1121
1181
  if (!e) throw Error("Wrap your component inside <PromptInputProvider> to use useProviderAttachments().");
1122
1182
  return e;
1123
- }, gr = () => s(fr);
1124
- function _r({ initialInput: e = "", children: t }) {
1183
+ }, Cr = () => s(yr);
1184
+ function wr({ initialInput: e = "", children: t }) {
1125
1185
  let [n, r] = d(e), i = o(() => r(""), []), [a, s] = d([]), f = u(null), p = u(() => {}), m = o((e) => {
1126
1186
  let t = Array.from(e);
1127
1187
  t.length !== 0 && s((e) => e.concat(t.map((e) => ({
1128
- id: kt(),
1188
+ id: jt(),
1129
1189
  type: "file",
1130
1190
  url: URL.createObjectURL(e),
1131
1191
  mediaType: e.type,
@@ -1176,22 +1236,22 @@ function _r({ initialInput: e = "", children: t }) {
1176
1236
  y,
1177
1237
  b
1178
1238
  ]);
1179
- return /* @__PURE__ */ Q(dr.Provider, {
1239
+ return /* @__PURE__ */ Q(vr.Provider, {
1180
1240
  value: x,
1181
- children: /* @__PURE__ */ Q(fr.Provider, {
1241
+ children: /* @__PURE__ */ Q(yr.Provider, {
1182
1242
  value: y,
1183
1243
  children: t
1184
1244
  })
1185
1245
  });
1186
1246
  }
1187
- var vr = r(null), yr = () => {
1188
- let e = gr(), t = s(vr), n = e ?? t;
1247
+ var Tr = r(null), Er = () => {
1248
+ let e = Cr(), t = s(Tr), n = e ?? t;
1189
1249
  if (!n) throw Error("usePromptInputAttachments must be used within a PromptInput or PromptInputProvider");
1190
1250
  return n;
1191
1251
  };
1192
- function br({ data: e, className: t, ...n }) {
1193
- let r = yr(), i = e.filename || "", a = (e.mediaType?.startsWith("image/") && e.url ? "image" : "file") == "image", o = i || (a ? "Image" : "Attachment");
1194
- return /* @__PURE__ */ $(Vr, { children: [/* @__PURE__ */ Q(oe, {
1252
+ function Dr({ data: e, className: t, ...n }) {
1253
+ let r = Er(), i = e.filename || "", a = (e.mediaType?.startsWith("image/") && e.url ? "image" : "file") == "image", o = i || (a ? "Image" : "Attachment");
1254
+ return /* @__PURE__ */ $(Jr, { children: [/* @__PURE__ */ Q(ae, {
1195
1255
  asChild: !0,
1196
1256
  children: /* @__PURE__ */ $("div", {
1197
1257
  className: q("group relative flex h-8 cursor-pointer select-none items-center gap-1.5 rounded-md border border-border px-1.5 font-medium text-sm transition-all hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50", t),
@@ -1208,7 +1268,7 @@ function br({ data: e, className: t, ...n }) {
1208
1268
  width: 20
1209
1269
  }) : /* @__PURE__ */ Q("div", {
1210
1270
  className: "flex size-5 items-center justify-center text-muted-foreground",
1211
- children: /* @__PURE__ */ Q(at, { className: "size-3" })
1271
+ children: /* @__PURE__ */ Q(ot, { className: "size-3" })
1212
1272
  })
1213
1273
  }), /* @__PURE__ */ $(v, {
1214
1274
  "aria-label": "Remove attachment",
@@ -1218,7 +1278,7 @@ function br({ data: e, className: t, ...n }) {
1218
1278
  },
1219
1279
  type: "button",
1220
1280
  variant: "ghost",
1221
- children: [/* @__PURE__ */ Q(vt, {}), /* @__PURE__ */ Q("span", {
1281
+ children: [/* @__PURE__ */ Q(bt, {}), /* @__PURE__ */ Q("span", {
1222
1282
  className: "sr-only",
1223
1283
  children: "Remove"
1224
1284
  })]
@@ -1228,7 +1288,7 @@ function br({ data: e, className: t, ...n }) {
1228
1288
  children: o
1229
1289
  })]
1230
1290
  }, e.id)
1231
- }), /* @__PURE__ */ Q(Ur, {
1291
+ }), /* @__PURE__ */ Q(Xr, {
1232
1292
  className: "w-auto p-2",
1233
1293
  children: /* @__PURE__ */ $("div", {
1234
1294
  className: "w-auto space-y-3",
@@ -1257,29 +1317,29 @@ function br({ data: e, className: t, ...n }) {
1257
1317
  })
1258
1318
  })] });
1259
1319
  }
1260
- function xr({ children: e, className: t, ...r }) {
1261
- let i = yr();
1320
+ function Or({ children: e, className: t, ...r }) {
1321
+ let i = Er();
1262
1322
  return i.files.length ? /* @__PURE__ */ Q("div", {
1263
1323
  className: q("flex flex-wrap items-center gap-2 p-3 w-full", t),
1264
1324
  ...r,
1265
1325
  children: i.files.map((t) => /* @__PURE__ */ Q(n, { children: e(t) }, t.id))
1266
1326
  }) : null;
1267
1327
  }
1268
- var Sr = ({ label: e = "Add photos or files", ...t }) => {
1269
- let n = yr();
1270
- return /* @__PURE__ */ $(F, {
1328
+ var kr = ({ label: e = "Add photos or files", ...t }) => {
1329
+ let n = Er();
1330
+ return /* @__PURE__ */ $(I, {
1271
1331
  ...t,
1272
1332
  onSelect: (e) => {
1273
1333
  e.preventDefault(), n.openFileDialog();
1274
1334
  },
1275
1335
  children: [
1276
- /* @__PURE__ */ Q(Qe, { className: "mr-2 size-4" }),
1336
+ /* @__PURE__ */ Q($e, { className: "mr-2 size-4" }),
1277
1337
  " ",
1278
1338
  e
1279
1339
  ]
1280
1340
  });
1281
- }, Cr = ({ 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 }) => {
1282
- let _ = mr(), v = !!_, y = u(null), b = u(null), [x, S] = d([]), C = v ? _.attachments.files : x, w = u(C);
1341
+ }, Ar = ({ className: e, accept: t, multiple: n, fileInputLabel: r = "Upload files", globalDrop: i, syncHiddenInput: a, maxFiles: s, maxFileSize: f, onError: p, onSubmit: m, children: h, ...g }) => {
1342
+ let _ = xr(), v = !!_, y = u(null), b = u(null), [x, S] = d([]), C = v ? _.attachments.files : x, w = u(C);
1283
1343
  w.current = C;
1284
1344
  let T = o(() => {
1285
1345
  y.current?.click();
@@ -1314,7 +1374,7 @@ var Sr = ({ label: e = "Add photos or files", ...t }) => {
1314
1374
  });
1315
1375
  let i = [];
1316
1376
  for (let e of n) i.push({
1317
- id: kt(),
1377
+ id: jt(),
1318
1378
  type: "file",
1319
1379
  url: URL.createObjectURL(e),
1320
1380
  mediaType: e.type,
@@ -1364,7 +1424,7 @@ var Sr = ({ label: e = "Add photos or files", ...t }) => {
1364
1424
  }, [v]);
1365
1425
  let P = (e) => {
1366
1426
  e.currentTarget.files && A(e.currentTarget.files), e.currentTarget.value = "";
1367
- }, ee = async (e) => {
1427
+ }, F = async (e) => {
1368
1428
  try {
1369
1429
  let t = await (await fetch(e)).blob();
1370
1430
  return new Promise((e) => {
@@ -1374,7 +1434,7 @@ var Sr = ({ label: e = "Add photos or files", ...t }) => {
1374
1434
  } catch {
1375
1435
  return null;
1376
1436
  }
1377
- }, F = l(() => ({
1437
+ }, I = l(() => ({
1378
1438
  files: C.map((e) => ({
1379
1439
  ...e,
1380
1440
  id: e.id
@@ -1390,7 +1450,7 @@ var Sr = ({ label: e = "Add photos or files", ...t }) => {
1390
1450
  j,
1391
1451
  M,
1392
1452
  N
1393
- ]), I = /* @__PURE__ */ $(Z, { children: [/* @__PURE__ */ Q("input", {
1453
+ ]), L = /* @__PURE__ */ $(Z, { children: [/* @__PURE__ */ Q("input", {
1394
1454
  accept: t,
1395
1455
  "aria-label": r,
1396
1456
  className: "hidden",
@@ -1406,7 +1466,7 @@ var Sr = ({ label: e = "Add photos or files", ...t }) => {
1406
1466
  let t = e.currentTarget, n = v ? _.textInput.value : new FormData(t).get("message") || "";
1407
1467
  v || t.reset(), Promise.all(C.map(async ({ id: e, ...t }) => {
1408
1468
  if (t.url && t.url.startsWith("blob:")) {
1409
- let e = await ee(t.url);
1469
+ let e = await F(t.url);
1410
1470
  return {
1411
1471
  ...t,
1412
1472
  url: e ?? t.url
@@ -1427,20 +1487,20 @@ var Sr = ({ label: e = "Add photos or files", ...t }) => {
1427
1487
  },
1428
1488
  ref: b,
1429
1489
  ...g,
1430
- children: /* @__PURE__ */ Q(ar, {
1490
+ children: /* @__PURE__ */ Q(fr, {
1431
1491
  className: "overflow-hidden",
1432
1492
  children: h
1433
1493
  })
1434
1494
  })] });
1435
- return v ? I : /* @__PURE__ */ Q(vr.Provider, {
1436
- value: F,
1437
- children: I
1495
+ return v ? L : /* @__PURE__ */ Q(Tr.Provider, {
1496
+ value: I,
1497
+ children: L
1438
1498
  });
1439
- }, wr = ({ className: e, ...t }) => /* @__PURE__ */ Q("div", {
1499
+ }, jr = ({ className: e, ...t }) => /* @__PURE__ */ Q("div", {
1440
1500
  className: q("contents", e),
1441
1501
  ...t
1442
- }), Tr = ({ onChange: e, className: t, placeholder: n = "What would you like to know?", ...r }) => {
1443
- let i = mr(), a = yr(), [o, s] = d(!1), c = (e) => {
1502
+ }), Mr = ({ onChange: e, className: t, placeholder: n = "What would you like to know?", ...r }) => {
1503
+ let i = xr(), a = Er(), [o, s] = d(!1), c = (e) => {
1444
1504
  if (e.key === "Enter") {
1445
1505
  if (o || e.nativeEvent.isComposing || e.shiftKey) return;
1446
1506
  e.preventDefault();
@@ -1468,7 +1528,7 @@ var Sr = ({ label: e = "Add photos or files", ...t }) => {
1468
1528
  i.textInput.setInput(t.currentTarget.value), e?.(t);
1469
1529
  }
1470
1530
  } : { onChange: e };
1471
- return /* @__PURE__ */ Q(ur, {
1531
+ return /* @__PURE__ */ Q(_r, {
1472
1532
  className: q("field-sizing-content max-h-48 min-h-16", t),
1473
1533
  name: "message",
1474
1534
  onCompositionEnd: () => s(!1),
@@ -1479,43 +1539,43 @@ var Sr = ({ label: e = "Add photos or files", ...t }) => {
1479
1539
  ...r,
1480
1540
  ...u
1481
1541
  });
1482
- }, Er = ({ className: e, ...t }) => /* @__PURE__ */ Q(sr, {
1542
+ }, Nr = ({ className: e, ...t }) => /* @__PURE__ */ Q(mr, {
1483
1543
  align: "block-end",
1484
1544
  className: q("order-first flex-wrap gap-1", e),
1485
1545
  ...t
1486
- }), Dr = ({ className: e, ...t }) => /* @__PURE__ */ Q(sr, {
1546
+ }), Pr = ({ className: e, ...t }) => /* @__PURE__ */ Q(mr, {
1487
1547
  align: "block-end",
1488
1548
  className: q("justify-between gap-1", e),
1489
1549
  ...t
1490
- }), Or = ({ className: e, ...t }) => /* @__PURE__ */ Q("div", {
1550
+ }), Fr = ({ className: e, ...t }) => /* @__PURE__ */ Q("div", {
1491
1551
  className: q("flex items-center gap-1", e),
1492
1552
  ...t
1493
- }), kr = ({ variant: e = "ghost", className: n, size: r, ...i }) => {
1553
+ }), Ir = ({ variant: e = "ghost", className: n, size: r, ...i }) => {
1494
1554
  let a = r ?? (t.count(i.children) > 1 ? "sm" : "icon-sm");
1495
- return /* @__PURE__ */ Q(lr, {
1555
+ return /* @__PURE__ */ Q(gr, {
1496
1556
  className: q(n),
1497
1557
  size: a,
1498
1558
  type: "button",
1499
1559
  variant: e,
1500
1560
  ...i
1501
1561
  });
1502
- }, Ar = (e) => /* @__PURE__ */ Q(P, { ...e }), jr = ({ className: e, children: t, ...n }) => /* @__PURE__ */ Q(I, {
1562
+ }, Lr = (e) => /* @__PURE__ */ Q(P, { ...e }), Rr = ({ className: e, children: t, ...n }) => /* @__PURE__ */ Q(L, {
1503
1563
  asChild: !0,
1504
- children: /* @__PURE__ */ Q(kr, {
1564
+ children: /* @__PURE__ */ Q(Ir, {
1505
1565
  className: e,
1506
1566
  ...n,
1507
- children: t ?? /* @__PURE__ */ Q(ot, { className: "size-4" })
1567
+ children: t ?? /* @__PURE__ */ Q(st, { className: "size-4" })
1508
1568
  })
1509
- }), Mr = ({ className: e, ...t }) => /* @__PURE__ */ Q(ee, {
1569
+ }), zr = ({ className: e, ...t }) => /* @__PURE__ */ Q(F, {
1510
1570
  align: "start",
1511
1571
  className: q(e),
1512
1572
  ...t
1513
- }), Nr = ({ className: e, ...t }) => /* @__PURE__ */ Q(F, {
1573
+ }), Br = ({ className: e, ...t }) => /* @__PURE__ */ Q(I, {
1514
1574
  className: q(e),
1515
1575
  ...t
1516
- }), Pr = ({ className: e, variant: t = "default", size: n = "icon-sm", status: r, children: i, ...a }) => {
1576
+ }), Vr = ({ className: e, variant: t = "default", size: n = "icon-sm", status: r, children: i, ...a }) => {
1517
1577
  let o = /* @__PURE__ */ Q(Je, { className: "size-4" });
1518
- 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(vt, { className: "size-4" })), /* @__PURE__ */ Q(lr, {
1578
+ return r === "submitted" ? o = /* @__PURE__ */ Q(nt, { className: "size-4 animate-spin" }) : r === "streaming" ? o = /* @__PURE__ */ Q(pt, { className: "size-4" }) : r === "error" && (o = /* @__PURE__ */ Q(bt, { className: "size-4" })), /* @__PURE__ */ Q(gr, {
1519
1579
  "aria-label": "Submit",
1520
1580
  className: q(e),
1521
1581
  size: n,
@@ -1524,7 +1584,7 @@ var Sr = ({ label: e = "Add photos or files", ...t }) => {
1524
1584
  ...a,
1525
1585
  children: i ?? o
1526
1586
  });
1527
- }, Fr = ({ className: e, textareaRef: t, onTranscriptionChange: n, ...r }) => {
1587
+ }, Hr = ({ className: e, textareaRef: t, onTranscriptionChange: n, ...r }) => {
1528
1588
  let [i, a] = d(!1), [s, l] = d(null), f = u(null);
1529
1589
  c(() => {
1530
1590
  if (typeof window < "u" && ("SpeechRecognition" in window || "webkitSpeechRecognition" in window)) {
@@ -1554,79 +1614,79 @@ var Sr = ({ label: e = "Add photos or files", ...t }) => {
1554
1614
  let p = o(() => {
1555
1615
  s && (i ? s.stop() : s.start());
1556
1616
  }, [s, i]);
1557
- return /* @__PURE__ */ Q(kr, {
1617
+ return /* @__PURE__ */ Q(Ir, {
1558
1618
  className: q("relative transition-all duration-200", i && "animate-pulse bg-accent text-accent-foreground", e),
1559
1619
  disabled: !s,
1560
1620
  onClick: p,
1561
1621
  ...r,
1562
- children: /* @__PURE__ */ Q(rt, { className: "size-4" })
1622
+ children: /* @__PURE__ */ Q(it, { className: "size-4" })
1563
1623
  });
1564
- }, Ir = (e) => /* @__PURE__ */ Q(ue, { ...e }), Lr = ({ className: e, ...t }) => /* @__PURE__ */ Q(pe, {
1624
+ }, Ur = (e) => /* @__PURE__ */ Q(ce, { ...e }), Wr = ({ className: e, ...t }) => /* @__PURE__ */ Q(de, {
1565
1625
  className: q("border-none bg-transparent font-medium text-muted-foreground shadow-none transition-colors", "hover:bg-accent hover:text-foreground aria-expanded:bg-accent aria-expanded:text-foreground", e),
1566
1626
  ...t
1567
- }), Rr = ({ className: e, ...t }) => /* @__PURE__ */ Q(de, {
1627
+ }), Gr = ({ className: e, ...t }) => /* @__PURE__ */ Q(le, {
1568
1628
  className: q(e),
1569
1629
  ...t
1570
- }), zr = ({ className: e, ...t }) => /* @__PURE__ */ Q(fe, {
1630
+ }), Kr = ({ className: e, ...t }) => /* @__PURE__ */ Q(ue, {
1571
1631
  className: q(e),
1572
1632
  ...t
1573
- }), Br = ({ className: e, ...t }) => /* @__PURE__ */ Q(me, {
1633
+ }), qr = ({ className: e, ...t }) => /* @__PURE__ */ Q(fe, {
1574
1634
  className: q(e),
1575
1635
  ...t
1576
- }), Vr = ({ openDelay: e = 0, closeDelay: t = 0, ...n }) => /* @__PURE__ */ Q(R, {
1636
+ }), Jr = ({ openDelay: e = 0, closeDelay: t = 0, ...n }) => /* @__PURE__ */ Q(z, {
1577
1637
  closeDelay: t,
1578
1638
  openDelay: e,
1579
1639
  ...n
1580
- }), Hr = (e) => /* @__PURE__ */ Q(oe, { ...e }), Ur = ({ align: e = "start", ...t }) => /* @__PURE__ */ Q(ae, {
1640
+ }), Yr = (e) => /* @__PURE__ */ Q(ae, { ...e }), Xr = ({ align: e = "start", ...t }) => /* @__PURE__ */ Q(ie, {
1581
1641
  align: e,
1582
1642
  ...t
1583
- }), Wr = ({ className: e, ...t }) => /* @__PURE__ */ Q("div", {
1643
+ }), Zr = ({ className: e, ...t }) => /* @__PURE__ */ Q("div", {
1584
1644
  className: q(e),
1585
1645
  ...t
1586
- }), Gr = ({ className: e, ...t }) => /* @__PURE__ */ Q("div", {
1646
+ }), Qr = ({ className: e, ...t }) => /* @__PURE__ */ Q("div", {
1587
1647
  className: q(e),
1588
1648
  ...t
1589
- }), Kr = ({ className: e, ...t }) => /* @__PURE__ */ Q("h3", {
1649
+ }), $r = ({ className: e, ...t }) => /* @__PURE__ */ Q("h3", {
1590
1650
  className: q("mb-2 px-3 font-medium text-muted-foreground text-xs", e),
1591
1651
  ...t
1592
- }), qr = ({ className: e, ...t }) => /* @__PURE__ */ Q("div", {
1652
+ }), ei = ({ className: e, ...t }) => /* @__PURE__ */ Q("div", {
1593
1653
  className: q("space-y-1", e),
1594
1654
  ...t
1595
- }), Jr = ({ className: e, ...t }) => /* @__PURE__ */ Q("div", {
1655
+ }), ti = ({ className: e, ...t }) => /* @__PURE__ */ Q("div", {
1596
1656
  className: q("flex items-center gap-2 px-3 py-2 text-xs hover:bg-accent", e),
1597
1657
  ...t
1598
- }), Yr = ({ className: e, ...t }) => /* @__PURE__ */ Q(D, {
1658
+ }), ni = ({ className: e, ...t }) => /* @__PURE__ */ Q(D, {
1599
1659
  className: q(e),
1600
1660
  ...t
1601
- }), Xr = ({ className: e, ...t }) => /* @__PURE__ */ Q(A, {
1661
+ }), ri = ({ className: e, ...t }) => /* @__PURE__ */ Q(A, {
1602
1662
  className: q(e),
1603
1663
  ...t
1604
- }), Zr = ({ className: e, ...t }) => /* @__PURE__ */ Q(M, {
1664
+ }), ii = ({ className: e, ...t }) => /* @__PURE__ */ Q(M, {
1605
1665
  className: q(e),
1606
1666
  ...t
1607
- }), Qr = ({ className: e, ...t }) => /* @__PURE__ */ Q(O, {
1667
+ }), ai = ({ className: e, ...t }) => /* @__PURE__ */ Q(O, {
1608
1668
  className: q(e),
1609
1669
  ...t
1610
- }), $r = ({ className: e, ...t }) => /* @__PURE__ */ Q(k, {
1670
+ }), oi = ({ className: e, ...t }) => /* @__PURE__ */ Q(k, {
1611
1671
  className: q(e),
1612
1672
  ...t
1613
- }), ei = ({ className: e, ...t }) => /* @__PURE__ */ Q(j, {
1673
+ }), si = ({ className: e, ...t }) => /* @__PURE__ */ Q(j, {
1614
1674
  className: q(e),
1615
1675
  ...t
1616
- }), ti = ({ className: e, ...t }) => /* @__PURE__ */ Q(N, {
1676
+ }), ci = ({ className: e, ...t }) => /* @__PURE__ */ Q(N, {
1617
1677
  className: q(e),
1618
1678
  ...t
1619
- }), ni = ({ className: e, children: t, ...n }) => /* @__PURE__ */ $(ce, {
1679
+ }), li = ({ className: e, children: t, ...n }) => /* @__PURE__ */ $(oe, {
1620
1680
  className: "w-full overflow-x-auto whitespace-nowrap",
1621
1681
  ...n,
1622
1682
  children: [/* @__PURE__ */ Q("div", {
1623
1683
  className: q("flex w-max flex-nowrap items-center gap-2", e),
1624
1684
  children: t
1625
- }), /* @__PURE__ */ Q(le, {
1685
+ }), /* @__PURE__ */ Q(se, {
1626
1686
  className: "hidden",
1627
1687
  orientation: "horizontal"
1628
1688
  })]
1629
- }), ri = ({ suggestion: e, onClick: t, className: n, variant: r = "outline", size: i = "sm", children: a, ...o }) => /* @__PURE__ */ Q(v, {
1689
+ }), ui = ({ suggestion: e, onClick: t, className: n, variant: r = "outline", size: i = "sm", children: a, ...o }) => /* @__PURE__ */ Q(v, {
1630
1690
  className: q("cursor-pointer rounded-full px-4", n),
1631
1691
  onClick: () => {
1632
1692
  t?.(e);
@@ -1636,7 +1696,7 @@ var Sr = ({ label: e = "Add photos or files", ...t }) => {
1636
1696
  variant: r,
1637
1697
  ...o,
1638
1698
  children: a || e
1639
- }), ii = r({ code: "" }), ai = {
1699
+ }), di = r({ code: "" }), fi = {
1640
1700
  name: "line-numbers",
1641
1701
  line(e, t) {
1642
1702
  e.children.unshift({
@@ -1657,21 +1717,21 @@ var Sr = ({ label: e = "Add photos or files", ...t }) => {
1657
1717
  });
1658
1718
  }
1659
1719
  };
1660
- async function oi(e, t, n = !1) {
1661
- let r = n ? [ai] : [];
1662
- return await Promise.all([At(e, {
1720
+ async function pi(e, t, n = !1) {
1721
+ let r = n ? [fi] : [];
1722
+ return await Promise.all([Mt(e, {
1663
1723
  lang: t,
1664
1724
  theme: "one-light",
1665
1725
  transformers: r
1666
- }), At(e, {
1726
+ }), Mt(e, {
1667
1727
  lang: t,
1668
1728
  theme: "one-dark-pro",
1669
1729
  transformers: r
1670
1730
  })]);
1671
1731
  }
1672
- var si = ({ code: e, language: t, showLineNumbers: n = !1, className: r, children: i, ...a }) => {
1732
+ var mi = ({ code: e, language: t, showLineNumbers: n = !1, className: r, children: i, ...a }) => {
1673
1733
  let [o, s] = d(""), [l, f] = d(""), p = u(!1);
1674
- return c(() => (oi(e, t, n).then(([e, t]) => {
1734
+ return c(() => (pi(e, t, n).then(([e, t]) => {
1675
1735
  p.current ||= (s(e), f(t), !0);
1676
1736
  }), () => {
1677
1737
  p.current = !1;
@@ -1679,7 +1739,7 @@ var si = ({ code: e, language: t, showLineNumbers: n = !1, className: r, childre
1679
1739
  e,
1680
1740
  t,
1681
1741
  n
1682
- ]), /* @__PURE__ */ Q(ii.Provider, {
1742
+ ]), /* @__PURE__ */ Q(di.Provider, {
1683
1743
  value: { code: e },
1684
1744
  children: /* @__PURE__ */ Q("div", {
1685
1745
  className: q("group relative w-full overflow-hidden rounded-md border bg-background text-foreground", r),
@@ -1703,8 +1763,8 @@ var si = ({ code: e, language: t, showLineNumbers: n = !1, className: r, childre
1703
1763
  })
1704
1764
  })
1705
1765
  });
1706
- }, ci = ({ onCopy: e, onError: t, timeout: n = 2e3, children: r, className: i, ...a }) => {
1707
- let [o, c] = d(!1), { code: l } = s(ii), u = async () => {
1766
+ }, hi = ({ onCopy: e, onError: t, timeout: n = 2e3, children: r, className: i, ...a }) => {
1767
+ let [o, c] = d(!1), { code: l } = s(di), u = async () => {
1708
1768
  if (typeof window > "u" || !navigator?.clipboard?.writeText) {
1709
1769
  t?.(/* @__PURE__ */ Error("Clipboard API not available"));
1710
1770
  return;
@@ -1723,20 +1783,20 @@ var si = ({ code: e, language: t, showLineNumbers: n = !1, className: r, childre
1723
1783
  ...a,
1724
1784
  children: r ?? /* @__PURE__ */ Q(f, { size: 14 })
1725
1785
  });
1726
- }, li = ({ className: e, ...t }) => /* @__PURE__ */ Q(w, {
1786
+ }, gi = ({ className: e, ...t }) => /* @__PURE__ */ Q(w, {
1727
1787
  className: q("not-prose mb-4 w-full rounded-md border", e),
1728
1788
  ...t
1729
- }), ui = (e) => /* @__PURE__ */ $(_, {
1789
+ }), _i = (e) => /* @__PURE__ */ $(_, {
1730
1790
  className: "gap-1.5 rounded-full text-xs",
1731
1791
  variant: "secondary",
1732
1792
  children: [{
1733
1793
  "input-streaming": /* @__PURE__ */ Q(Be, { className: "size-4" }),
1734
1794
  "input-available": /* @__PURE__ */ Q(We, { className: "size-4 animate-pulse" }),
1735
1795
  "approval-requested": /* @__PURE__ */ Q(We, { className: "size-4 text-yellow-600" }),
1736
- "approval-responded": /* @__PURE__ */ Q(Y, { className: "size-4 text-blue-600" }),
1737
- "output-available": /* @__PURE__ */ Q(Y, { className: "size-4 text-green-600" }),
1738
- "output-error": /* @__PURE__ */ Q(_t, { className: "size-4 text-red-600" }),
1739
- "output-denied": /* @__PURE__ */ Q(_t, { className: "size-4 text-orange-600" })
1796
+ "approval-responded": /* @__PURE__ */ Q(Fe, { className: "size-4 text-blue-600" }),
1797
+ "output-available": /* @__PURE__ */ Q(Fe, { className: "size-4 text-green-600" }),
1798
+ "output-error": /* @__PURE__ */ Q(yt, { className: "size-4 text-red-600" }),
1799
+ "output-denied": /* @__PURE__ */ Q(yt, { className: "size-4 text-orange-600" })
1740
1800
  }[e], {
1741
1801
  "input-streaming": "Pending",
1742
1802
  "input-available": "Running",
@@ -1746,24 +1806,24 @@ var si = ({ code: e, language: t, showLineNumbers: n = !1, className: r, childre
1746
1806
  "output-error": "Error",
1747
1807
  "output-denied": "Denied"
1748
1808
  }[e]]
1749
- }), di = ({ className: e, title: t, type: n, state: r, ...i }) => /* @__PURE__ */ $(E, {
1809
+ }), vi = ({ className: e, title: t, type: n, state: r, ...i }) => /* @__PURE__ */ $(E, {
1750
1810
  className: q("flex w-full items-center justify-between gap-4 p-3", e),
1751
1811
  ...i,
1752
1812
  children: [/* @__PURE__ */ $("div", {
1753
1813
  className: "flex items-center gap-2",
1754
1814
  children: [
1755
- /* @__PURE__ */ Q(ht, { className: "size-4 text-muted-foreground" }),
1815
+ /* @__PURE__ */ Q(_t, { className: "size-4 text-muted-foreground" }),
1756
1816
  /* @__PURE__ */ Q("span", {
1757
1817
  className: "font-medium text-sm",
1758
1818
  children: t ?? n.split("-").slice(1).join("-")
1759
1819
  }),
1760
- ui(r)
1820
+ _i(r)
1761
1821
  ]
1762
1822
  }), /* @__PURE__ */ Q(Le, { className: "size-4 text-muted-foreground transition-transform group-data-[state=open]:rotate-180" })]
1763
- }), fi = ({ className: e, ...t }) => /* @__PURE__ */ Q(T, {
1823
+ }), yi = ({ className: e, ...t }) => /* @__PURE__ */ Q(T, {
1764
1824
  className: q("data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-popover-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in", e),
1765
1825
  ...t
1766
- }), pi = ({ className: e, input: t, ...n }) => /* @__PURE__ */ $("div", {
1826
+ }), bi = ({ className: e, input: t, ...n }) => /* @__PURE__ */ $("div", {
1767
1827
  className: q("space-y-2 overflow-hidden p-4", e),
1768
1828
  ...n,
1769
1829
  children: [/* @__PURE__ */ Q("h4", {
@@ -1771,18 +1831,18 @@ var si = ({ code: e, language: t, showLineNumbers: n = !1, className: r, childre
1771
1831
  children: "Parameters"
1772
1832
  }), /* @__PURE__ */ Q("div", {
1773
1833
  className: "rounded-md bg-muted/50",
1774
- children: /* @__PURE__ */ Q(si, {
1834
+ children: /* @__PURE__ */ Q(mi, {
1775
1835
  code: JSON.stringify(t, null, 2),
1776
1836
  language: "json"
1777
1837
  })
1778
1838
  })]
1779
- }), mi = ({ className: e, output: t, errorText: n, ...r }) => {
1839
+ }), xi = ({ className: e, output: t, errorText: n, ...r }) => {
1780
1840
  if (!(t || n)) return null;
1781
1841
  let a = /* @__PURE__ */ Q("div", { children: t });
1782
- return typeof t == "object" && !i(t) ? a = /* @__PURE__ */ Q(si, {
1842
+ return typeof t == "object" && !i(t) ? a = /* @__PURE__ */ Q(mi, {
1783
1843
  code: JSON.stringify(t, null, 2),
1784
1844
  language: "json"
1785
- }) : typeof t == "string" && (a = /* @__PURE__ */ Q(si, {
1845
+ }) : typeof t == "string" && (a = /* @__PURE__ */ Q(mi, {
1786
1846
  code: t,
1787
1847
  language: "json"
1788
1848
  })), /* @__PURE__ */ $("div", {
@@ -1796,8 +1856,8 @@ var si = ({ code: e, language: t, showLineNumbers: n = !1, className: r, childre
1796
1856
  children: [n && /* @__PURE__ */ Q("div", { children: n }), a]
1797
1857
  })]
1798
1858
  });
1799
- }, hi = a(({ children: e, as: t = "p", className: n, duration: r = 2, spread: i = 2 }) => {
1800
- let a = Mt.create(t), o = l(() => (e?.length ?? 0) * i, [e, i]);
1859
+ }, Si = a(({ children: e, as: t = "p", className: n, duration: r = 2, spread: i = 2 }) => {
1860
+ let a = Pt.create(t), o = l(() => (e?.length ?? 0) * i, [e, i]);
1801
1861
  return /* @__PURE__ */ Q(a, {
1802
1862
  animate: { backgroundPosition: "0% center" },
1803
1863
  className: q("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),
@@ -1813,21 +1873,21 @@ var si = ({ code: e, language: t, showLineNumbers: n = !1, className: r, childre
1813
1873
  },
1814
1874
  children: e
1815
1875
  });
1816
- }), gi = r(null), _i = () => {
1817
- let e = s(gi);
1876
+ }), Ci = r(null), wi = () => {
1877
+ let e = s(Ci);
1818
1878
  if (!e) throw Error("Reasoning components must be used within Reasoning");
1819
1879
  return e;
1820
- }, vi = 1e3, yi = 1e3, bi = a(({ className: e, isStreaming: t = !1, open: n, defaultOpen: r = !0, onOpenChange: i, duration: a, children: o, ...s }) => {
1821
- let [l, u] = jt({
1880
+ }, Ti = 1e3, Ei = 1e3, Di = a(({ className: e, isStreaming: t = !1, open: n, defaultOpen: r = !0, onOpenChange: i, duration: a, children: o, ...s }) => {
1881
+ let [l, u] = Nt({
1822
1882
  prop: n,
1823
1883
  defaultProp: r,
1824
1884
  onChange: i
1825
- }), [f, p] = jt({
1885
+ }), [f, p] = Nt({
1826
1886
  prop: a,
1827
1887
  defaultProp: void 0
1828
1888
  }), [m, h] = d(!1), [g, _] = d(null);
1829
1889
  return c(() => {
1830
- t ? g === null && _(Date.now()) : g !== null && (p(Math.ceil((Date.now() - g) / yi)), _(null));
1890
+ t ? g === null && _(Date.now()) : g !== null && (p(Math.ceil((Date.now() - g) / Ei)), _(null));
1831
1891
  }, [
1832
1892
  t,
1833
1893
  g,
@@ -1836,7 +1896,7 @@ var si = ({ code: e, language: t, showLineNumbers: n = !1, className: r, childre
1836
1896
  if (r && !t && l && !m) {
1837
1897
  let e = setTimeout(() => {
1838
1898
  u(!1), h(!0);
1839
- }, vi);
1899
+ }, Ti);
1840
1900
  return () => clearTimeout(e);
1841
1901
  }
1842
1902
  }, [
@@ -1845,7 +1905,7 @@ var si = ({ code: e, language: t, showLineNumbers: n = !1, className: r, childre
1845
1905
  r,
1846
1906
  u,
1847
1907
  m
1848
- ]), /* @__PURE__ */ Q(gi.Provider, {
1908
+ ]), /* @__PURE__ */ Q(Ci.Provider, {
1849
1909
  value: {
1850
1910
  isStreaming: t,
1851
1911
  isOpen: l,
@@ -1862,36 +1922,36 @@ var si = ({ code: e, language: t, showLineNumbers: n = !1, className: r, childre
1862
1922
  children: o
1863
1923
  })
1864
1924
  });
1865
- }), xi = (e, t) => e || t === 0 ? /* @__PURE__ */ Q(hi, {
1925
+ }), Oi = (e, t) => e || t === 0 ? /* @__PURE__ */ Q(Si, {
1866
1926
  duration: 1,
1867
1927
  children: "Thinking..."
1868
1928
  }) : t === void 0 ? /* @__PURE__ */ Q("p", { children: "Thought for a few seconds" }) : /* @__PURE__ */ $("p", { children: [
1869
1929
  "Thought for ",
1870
1930
  t,
1871
1931
  " seconds"
1872
- ] }), Si = a(({ className: e, children: t, getThinkingMessage: n = xi, ...r }) => {
1873
- let { isStreaming: i, isOpen: a, duration: o } = _i();
1932
+ ] }), ki = a(({ className: e, children: t, getThinkingMessage: n = Oi, ...r }) => {
1933
+ let { isStreaming: i, isOpen: a, duration: o } = wi();
1874
1934
  return /* @__PURE__ */ Q(E, {
1875
1935
  className: q("flex w-full items-center gap-2 text-muted-foreground text-sm transition-colors hover:text-foreground", e),
1876
1936
  ...r,
1877
1937
  children: t ?? /* @__PURE__ */ $(Z, { children: [
1878
- /* @__PURE__ */ Q(Pe, { className: "size-4" }),
1938
+ /* @__PURE__ */ Q(Ne, { className: "size-4" }),
1879
1939
  n(i, o),
1880
1940
  /* @__PURE__ */ Q(Le, { className: q("size-4 transition-transform", a ? "rotate-180" : "rotate-0") })
1881
1941
  ] })
1882
1942
  });
1883
- }), Ci = a(({ className: e, children: t, ...n }) => /* @__PURE__ */ Q(T, {
1943
+ }), Ai = a(({ className: e, children: t, ...n }) => /* @__PURE__ */ Q(T, {
1884
1944
  className: q("mt-4 text-sm", "data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-muted-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in", e),
1885
1945
  ...n,
1886
- children: /* @__PURE__ */ Q(Ot, { children: t })
1946
+ children: /* @__PURE__ */ Q(At, { children: t })
1887
1947
  }));
1888
- bi.displayName = "Reasoning", Si.displayName = "ReasoningTrigger", Ci.displayName = "ReasoningContent";
1948
+ Di.displayName = "Reasoning", ki.displayName = "ReasoningTrigger", Ai.displayName = "ReasoningContent";
1889
1949
  //#endregion
1890
1950
  //#region src/elements/sources.tsx
1891
- var wi = ({ className: e, ...t }) => /* @__PURE__ */ Q(w, {
1951
+ var ji = ({ className: e, ...t }) => /* @__PURE__ */ Q(w, {
1892
1952
  className: q("not-prose mb-4 text-primary text-xs", e),
1893
1953
  ...t
1894
- }), Ti = ({ className: e, count: t, children: n, ...r }) => /* @__PURE__ */ Q(E, {
1954
+ }), Mi = ({ className: e, count: t, children: n, ...r }) => /* @__PURE__ */ Q(E, {
1895
1955
  className: q("flex items-center gap-2", e),
1896
1956
  ...r,
1897
1957
  children: n ?? /* @__PURE__ */ $(Z, { children: [/* @__PURE__ */ $("p", {
@@ -1902,23 +1962,23 @@ var wi = ({ className: e, ...t }) => /* @__PURE__ */ Q(w, {
1902
1962
  " sources"
1903
1963
  ]
1904
1964
  }), /* @__PURE__ */ Q(Le, { className: "h-4 w-4" })] })
1905
- }), Ei = ({ className: e, ...t }) => /* @__PURE__ */ Q(T, {
1965
+ }), Ni = ({ className: e, ...t }) => /* @__PURE__ */ Q(T, {
1906
1966
  className: q("mt-3 flex w-fit flex-col gap-2", "data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 outline-none data-[state=closed]:animate-out data-[state=open]:animate-in", e),
1907
1967
  ...t
1908
- }), Di = ({ href: e, title: t, children: n, ...r }) => /* @__PURE__ */ Q("a", {
1968
+ }), Pi = ({ href: e, title: t, children: n, ...r }) => /* @__PURE__ */ Q("a", {
1909
1969
  className: "flex items-center gap-2",
1910
1970
  href: e,
1911
1971
  rel: "noreferrer",
1912
1972
  target: "_blank",
1913
1973
  ...r,
1914
- children: n ?? /* @__PURE__ */ $(Z, { children: [/* @__PURE__ */ Q(Me, { className: "h-4 w-4" }), /* @__PURE__ */ Q("span", {
1974
+ children: n ?? /* @__PURE__ */ $(Z, { children: [/* @__PURE__ */ Q(je, { className: "h-4 w-4" }), /* @__PURE__ */ Q("span", {
1915
1975
  className: "block font-medium",
1916
1976
  children: t
1917
1977
  })] })
1918
1978
  });
1919
1979
  //#endregion
1920
1980
  //#region src/ChatbotEnhanced.tsx
1921
- function Oi(e) {
1981
+ function Fi(e) {
1922
1982
  let t = e ?? {}, n = t.data && typeof t.data == "object" ? t.data : t, r = n.seedApplied, i = n.probes;
1923
1983
  if (!r && !i) return;
1924
1984
  let a = {};
@@ -1932,10 +1992,10 @@ function Oi(e) {
1932
1992
  message: String(e.message)
1933
1993
  }))), a;
1934
1994
  }
1935
- function ki(e) {
1995
+ function Ii(e) {
1936
1996
  return e === "user" ? "user" : "assistant";
1937
1997
  }
1938
- function Ai(e) {
1998
+ function Li(e) {
1939
1999
  let t = e.trim();
1940
2000
  if (t.length < 2 || !(t.startsWith("{") || t.startsWith("[")) || !(t.endsWith("}") || t.endsWith("]"))) return !1;
1941
2001
  try {
@@ -1944,11 +2004,11 @@ function Ai(e) {
1944
2004
  return !1;
1945
2005
  }
1946
2006
  }
1947
- function ji(e) {
2007
+ function Ri(e) {
1948
2008
  let t = e.state ?? (e.errorText ? "output-error" : e.result === void 0 ? "input-available" : "output-available");
1949
2009
  return t === "output-error" || t === "output-denied" ? "failed" : t === "approval-requested" || t === "approval-responded" ? "awaiting" : t === "output-available" ? "completed" : "running";
1950
2010
  }
1951
- function Mi(e) {
2011
+ function zi(e) {
1952
2012
  return [
1953
2013
  {
1954
2014
  create_object: "新建对象",
@@ -1964,11 +2024,57 @@ function Mi(e) {
1964
2024
  e.details
1965
2025
  ].filter(Boolean).join(" ");
1966
2026
  }
1967
- function Ni(e) {
1968
- let t = ji(e);
1969
- return t === "awaiting" || t === "failed" || !!e.pendingActionId || !!e.draftReview?.items.length || !!e.proposedPlan || !!e.proposedChanges;
2027
+ function Bi(e) {
2028
+ return e.toolName === "propose_blueprint";
2029
+ }
2030
+ function Vi(e) {
2031
+ return Bi(e) && Ri(e) === "completed" && !e.proposedPlan && !e.proposedChanges && !e.draftReview?.items.length;
1970
2032
  }
1971
- function Pi(e) {
2033
+ var Hi = [
2034
+ "待补",
2035
+ "后续",
2036
+ "将在",
2037
+ "稍后",
2038
+ "暂不",
2039
+ "暂未",
2040
+ "尚未",
2041
+ "确认后一起补",
2042
+ "一起补",
2043
+ "另行",
2044
+ "日后",
2045
+ "not yet",
2046
+ "will be implemented",
2047
+ "will be added",
2048
+ "to be added",
2049
+ "to be implemented",
2050
+ "later",
2051
+ "deferred",
2052
+ "follow-up",
2053
+ "follow up",
2054
+ "future",
2055
+ "subsequent",
2056
+ "coming soon",
2057
+ "tbd"
2058
+ ];
2059
+ function Ui(e) {
2060
+ let t = [], n = [];
2061
+ for (let r of e) {
2062
+ if (typeof r != "string") continue;
2063
+ let e = r.trim();
2064
+ if (!e) continue;
2065
+ let i = e.toLowerCase();
2066
+ Hi.some((e) => i.includes(e)) ? n.push(e) : t.push(e);
2067
+ }
2068
+ return {
2069
+ designNotes: t,
2070
+ deferred: n
2071
+ };
2072
+ }
2073
+ function Wi(e) {
2074
+ let t = Ri(e);
2075
+ return t === "awaiting" || t === "failed" || !!e.pendingActionId || !!e.draftReview?.items.length || !!e.proposedPlan || !!e.proposedChanges || Vi(e);
2076
+ }
2077
+ function Gi(e) {
1972
2078
  switch (e) {
1973
2079
  case "failed": return 4;
1974
2080
  case "awaiting": return 3;
@@ -1976,17 +2082,17 @@ function Pi(e) {
1976
2082
  case "completed": return 1;
1977
2083
  }
1978
2084
  }
1979
- function Fi(e) {
2085
+ function Ki(e) {
1980
2086
  let t = /* @__PURE__ */ new Map();
1981
2087
  for (let n of e) {
1982
- let e = ji(n), r = `${n.toolName}:${e}`, i = t.get(r);
2088
+ let e = Ri(n), r = `${n.toolName}:${e}`, i = t.get(r);
1983
2089
  if (i) {
1984
2090
  i.count += 1, i.errorText = i.errorText ?? n.errorText;
1985
2091
  continue;
1986
2092
  }
1987
2093
  t.set(r, {
1988
2094
  key: r,
1989
- title: jn(n.toolName) || n.toolName,
2095
+ title: Fn(n.toolName) || n.toolName,
1990
2096
  rawName: n.toolName,
1991
2097
  count: 1,
1992
2098
  state: e,
@@ -1994,11 +2100,11 @@ function Fi(e) {
1994
2100
  });
1995
2101
  }
1996
2102
  return Array.from(t.values()).sort((e, t) => {
1997
- let n = Pi(t.state) - Pi(e.state);
2103
+ let n = Gi(t.state) - Gi(e.state);
1998
2104
  return n === 0 ? e.title.localeCompare(t.title) : n;
1999
2105
  });
2000
2106
  }
2001
- function Ii({ health: e }) {
2107
+ function qi({ health: e }) {
2002
2108
  if (!e) return null;
2003
2109
  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 = [];
2004
2110
  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) {
@@ -2011,7 +2117,7 @@ function Ii({ health: e }) {
2011
2117
  children: [
2012
2118
  o.length > 0 ? /* @__PURE__ */ $("div", {
2013
2119
  className: "flex items-center gap-1.5 text-xs text-emerald-700",
2014
- children: [/* @__PURE__ */ Q(J, { className: "size-3.5 shrink-0" }), /* @__PURE__ */ Q("span", { children: o.join(" · ") })]
2120
+ children: [/* @__PURE__ */ Q(Y, { className: "size-3.5 shrink-0" }), /* @__PURE__ */ Q("span", { children: o.join(" · ") })]
2015
2121
  }) : null,
2016
2122
  e.seedError ? /* @__PURE__ */ $("div", {
2017
2123
  className: "flex items-start gap-1.5 text-xs text-red-600",
@@ -2028,8 +2134,8 @@ function Ii({ health: e }) {
2028
2134
  ]
2029
2135
  });
2030
2136
  }
2031
- var Li = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type your message...", onSendMessage: i, onClear: a, onStop: o, onReload: s, onUpgrade: c, disabled: l = !1, readOnly: u = !1, isLoading: d = !1, error: f, showTimestamp: p = !1, showAvatars: m = !1, userAvatarUrl: h, userAvatarFallback: g = "You", assistantAvatarUrl: _, assistantAvatarFallback: v = "AI", hideClearBar: y = !1, maxHeight: b = "500px", enableMarkdown: x = !0, enableFileUpload: S = !1, acceptedFileTypes: C = "image/*,.pdf,.doc,.docx,.txt", maxFileSize: w = 10 * 1024 * 1024, suggestions: T, labels: E, models: D, selectedModelId: O, onModelChange: k, headerSlot: A, promptOverlaySlot: j, onInputChange: M, onToolApprove: N, toolApproveLabel: P = "Approve", toolDenyLabel: ee = "Deny", toolDenyReason: F = "User denied the operation", toolDecisions: I, onReviewDraft: te, toolReviewLabel: ne = (e) => `Review ${e} change${e === 1 ? "" : "s"}`, onPublishDrafts: L, onOpenBuiltApp: re, openBuiltAppLabel: ie = "Open app", onPreviewDraftApp: R, previewDraftLabel: ae = "Preview", onDraftArtifacts: oe, onBuildMaterialized: se, publishDraftsLabel: z = "Publish", publishedLabel: ce = "Published", verifiedLabel: le = "Verified", nextStepsLabel: ue = "What's next", planTitleLabel: de = "Proposed plan", planExtendLabel: fe = "Adding to existing app", planQuestionsLabel: pe = "Confirm before building", planAssumptionsLabel: me = "Assumptions", planApproveHintLabel: he = "Reply to approve or adjust this plan.", planApproveLabel: ge = "Build it", planAdjustLabel: _e = "Adjust", planBuiltLabel: ve = "Built", planApproveMessage: ye = "Looks good — build it as proposed.", planApproveDefaultsMessage: be = "Build it with your best assumptions; use sensible defaults for the open questions.", planAnswerMessage: xe = (e, t) => `For "${e}", go with: ${t}.`, fetchPendingDraftCount: B, autoPublishDrafts: Se = !1, processVisibility: V = "summary", surface: H = "card", ...Ce }, we) => {
2032
- let U = d ? "streaming" : "ready", W = H === "plain", [G, Te] = e.useState(null), K = e.useMemo(() => ({
2137
+ var Ji = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type your message...", onSendMessage: i, onClear: a, onStop: o, onReload: s, onUpgrade: c, disabled: l = !1, readOnly: u = !1, isLoading: d = !1, error: f, showTimestamp: p = !1, showAvatars: m = !1, userAvatarUrl: h, userAvatarFallback: g = "You", assistantAvatarUrl: _, assistantAvatarFallback: v = "AI", hideClearBar: y = !1, maxHeight: b = "500px", enableMarkdown: x = !0, enableFileUpload: S = !1, acceptedFileTypes: C = "image/*,.pdf,.doc,.docx,.txt", maxFileSize: w = 10 * 1024 * 1024, suggestions: T, labels: E, models: D, selectedModelId: O, onModelChange: k, headerSlot: A, promptOverlaySlot: j, onInputChange: M, onToolApprove: N, toolApproveLabel: P = "Approve", toolDenyLabel: F = "Deny", toolDenyReason: I = "User denied the operation", toolDecisions: L, onReviewDraft: ee, toolReviewLabel: te = (e) => `Review ${e} change${e === 1 ? "" : "s"}`, onPublishDrafts: R, onOpenBuiltApp: ne, openBuiltAppLabel: re = "Open app", onPreviewDraftApp: z, previewDraftLabel: ie = "Preview", onDraftArtifacts: ae, onBuildMaterialized: B, publishDraftsLabel: V = "Publish", publishedLabel: oe = "Published", verifiedLabel: se = "Verified", nextStepsLabel: ce = "What's next", planTitleLabel: le = "Proposed plan", planExtendLabel: ue = "Adding to existing app", planQuestionsLabel: de = "Confirm before building", planAssumptionsLabel: fe = "Assumptions", planDeferredLabel: pe = "Not yet built", planApproveHintLabel: me = "Reply to approve or adjust this plan.", planApproveLabel: he = "Build it", planAdjustLabel: ge = "Adjust", planBuiltLabel: _e = "Built", planReadyLabel: ve = "The plan is ready. Build it now, or tell me what to adjust.", planApproveMessage: ye = "Looks good — build it as proposed.", planApproveDefaultsMessage: be = "Build it with your best assumptions; use sensible defaults for the open questions.", planAnswerMessage: xe = (e, t) => `For "${e}", go with: ${t}.`, fetchPendingDraftCount: H, autoPublishDrafts: U = !1, processVisibility: W = "summary", surface: Se = "card", ...Ce }, we) => {
2138
+ let G = d ? "streaming" : "ready", K = Se === "plain", [Te, Ee] = e.useState(null), De = e.useRef(""), Oe = e.useRef(null), J = e.useMemo(() => ({
2033
2139
  emptyTitle: E?.emptyTitle ?? "Start a conversation",
2034
2140
  emptyDescription: E?.emptyDescription ?? "Ask anything — the assistant has access to your current app context.",
2035
2141
  clear: E?.clear ?? "Clear",
@@ -2047,59 +2153,63 @@ var Li = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
2047
2153
  submit: E?.submit ?? "Submit",
2048
2154
  uploadFiles: E?.uploadFiles ?? "Upload files",
2049
2155
  stopResponse: E?.stopResponse ?? "Stop response",
2156
+ sendFailedRateLimited: E?.sendFailedRateLimited ?? "You're sending messages too quickly. Your message is kept below — wait a moment and try again.",
2157
+ sendFailedGeneric: E?.sendFailedGeneric ?? "Couldn't send your message. It's kept below — please try again.",
2050
2158
  trace: E?.trace ?? "trace",
2051
2159
  viewTrace: E?.viewTrace ?? "View trace",
2052
2160
  connectionWaiting: E?.connectionWaiting ?? "Waiting for server…",
2053
2161
  connectionStalledLabel: E?.connectionStalledLabel ?? "Still working…",
2054
- connectionOfflineLabel: E?.connectionOfflineLabel ?? "Connection lost — reconnecting…"
2055
- }), [E]), [Ee, De] = e.useState(() => /* @__PURE__ */ new Set()), [Oe, Ae] = e.useState(() => /* @__PURE__ */ new Map()), [je, Me] = e.useState(() => /* @__PURE__ */ new Map()), Pe = e.useRef(/* @__PURE__ */ new Set()), Y = e.useCallback(async (e) => {
2056
- if (B) try {
2057
- let t = await B(e);
2058
- Me((n) => {
2162
+ connectionOfflineLabel: E?.connectionOfflineLabel ?? "Connection lost — reconnecting…",
2163
+ designingPlanLabel: E?.designingPlanLabel ?? "Designing your app…",
2164
+ designingPlanHints: E?.designingPlanHints ?? ra
2165
+ }), [E]), [Ae, je] = e.useState(() => /* @__PURE__ */ new Set()), [Ne, Fe] = e.useState(() => /* @__PURE__ */ new Map()), [Ie, Le] = e.useState(() => /* @__PURE__ */ new Map()), Re = e.useRef(/* @__PURE__ */ new Set()), ze = e.useCallback(async (e) => {
2166
+ if (H) try {
2167
+ let t = await H(e);
2168
+ Le((n) => {
2059
2169
  if (n.get(e) === t) return n;
2060
2170
  let r = new Map(n);
2061
2171
  return r.set(e, t), r;
2062
2172
  });
2063
2173
  } catch {}
2064
- }, [B]);
2174
+ }, [H]);
2065
2175
  e.useEffect(() => {
2066
- if (!B || d) return;
2176
+ if (!H || d) return;
2067
2177
  let e = /* @__PURE__ */ new Set();
2068
2178
  for (let t of n) for (let n of t.toolInvocations ?? []) {
2069
2179
  let t = n.draftReview?.packageId, r = n.toolCallId;
2070
- t && r && !Pe.current.has(r) && (Pe.current.add(r), e.add(t));
2180
+ t && r && !Re.current.has(r) && (Re.current.add(r), e.add(t));
2071
2181
  }
2072
- for (let t of e) Y(t);
2182
+ for (let t of e) ze(t);
2073
2183
  }, [
2074
2184
  n,
2075
2185
  d,
2076
- B,
2077
- Y
2186
+ H,
2187
+ ze
2078
2188
  ]);
2079
- let Ie = e.useCallback(async (e) => {
2080
- if (!L) return;
2189
+ let Be = e.useCallback(async (e) => {
2190
+ if (!R) return;
2081
2191
  let t = [];
2082
2192
  for (let r of n) for (let n of r.toolInvocations ?? []) n.draftReview?.packageId === e && n.toolCallId && t.push(n.toolCallId);
2083
- let r = await L(e), i = r && typeof r == "object" ? r : void 0;
2193
+ let r = await R(e), i = r && typeof r == "object" ? r : void 0;
2084
2194
  if ((i ? i.ok !== !1 : r !== !1) && t.length > 0) {
2085
- De((e) => {
2195
+ je((e) => {
2086
2196
  let n = new Set(e);
2087
2197
  for (let e of t) n.add(e);
2088
2198
  return n;
2089
2199
  });
2090
2200
  let e = i?.health;
2091
- e && Ae((n) => {
2201
+ e && Fe((n) => {
2092
2202
  let r = new Map(n);
2093
2203
  for (let n of t) r.set(n, e);
2094
2204
  return r;
2095
2205
  });
2096
2206
  }
2097
- Y(e);
2207
+ ze(e);
2098
2208
  }, [
2099
- L,
2209
+ R,
2100
2210
  n,
2101
- Y
2102
- ]), Le = e.useRef(/* @__PURE__ */ new Set()), Re = e.useRef(!1);
2211
+ ze
2212
+ ]), He = e.useRef(/* @__PURE__ */ new Set()), Ue = e.useRef(!1);
2103
2213
  e.useEffect(() => {
2104
2214
  let e = [];
2105
2215
  for (let t of n) for (let n of t.toolInvocations ?? []) {
@@ -2109,27 +2219,27 @@ var Li = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
2109
2219
  packageId: t.packageId
2110
2220
  });
2111
2221
  }
2112
- if (!Re.current) {
2113
- Re.current = !0;
2114
- for (let t of e) Le.current.add(t.key);
2222
+ if (!Ue.current) {
2223
+ Ue.current = !0;
2224
+ for (let t of e) He.current.add(t.key);
2115
2225
  return;
2116
2226
  }
2117
- if (!Se || !L || d) return;
2118
- let t = e.filter((e) => !Le.current.has(e.key));
2227
+ if (!U || !R || d) return;
2228
+ let t = e.filter((e) => !He.current.has(e.key));
2119
2229
  if (t.length !== 0) {
2120
- for (let e of t) Le.current.add(e.key);
2121
- for (let e of [...new Set(t.map((e) => e.packageId))]) Ie(e);
2230
+ for (let e of t) He.current.add(e.key);
2231
+ for (let e of [...new Set(t.map((e) => e.packageId))]) Be(e);
2122
2232
  }
2123
2233
  }, [
2124
2234
  n,
2125
2235
  d,
2126
- Se,
2127
- L,
2128
- Ie
2236
+ U,
2237
+ R,
2238
+ Be
2129
2239
  ]);
2130
- let ze = e.useRef(/* @__PURE__ */ new Set());
2240
+ let We = e.useRef(/* @__PURE__ */ new Set());
2131
2241
  e.useEffect(() => {
2132
- if (!oe) return;
2242
+ if (!ae) return;
2133
2243
  let e = /* @__PURE__ */ new Map(), t;
2134
2244
  for (let r of n) {
2135
2245
  for (let t of r.buildProgress?.items ?? []) t?.type && t?.name && e.set(`${t.type}:${t.name}`, t);
@@ -2139,44 +2249,55 @@ var Li = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
2139
2249
  r?.packageId && r.items?.some((e) => e.type === "app") && (t = r.packageId);
2140
2250
  }
2141
2251
  }
2142
- let r = ze.current, i = !1;
2252
+ let r = We.current, i = !1;
2143
2253
  for (let t of e.keys()) r.has(t) || (r.add(t), i = !0);
2144
- i && oe([...e.values()], t);
2145
- }, [n, oe]);
2146
- let Be = e.useRef(/* @__PURE__ */ new Set());
2254
+ i && ae([...e.values()], t);
2255
+ }, [n, ae]);
2256
+ let Ke = e.useRef(/* @__PURE__ */ new Set());
2147
2257
  e.useEffect(() => {
2148
- if (se) for (let e of n) for (let t of e.toolInvocations ?? []) {
2258
+ if (B) for (let e of n) for (let t of e.toolInvocations ?? []) {
2149
2259
  let e = t.draftReview;
2150
2260
  if (!e?.materialized || !t.toolCallId) continue;
2151
2261
  let n = e.items.find((e) => e.type === "app");
2152
- !n || Be.current.has(t.toolCallId) || (Be.current.add(t.toolCallId), se(n.name));
2262
+ !n || Ke.current.has(t.toolCallId) || (Ke.current.add(t.toolCallId), B(n.name));
2153
2263
  }
2154
- }, [n, se]);
2155
- let He = e.useCallback((e) => {
2264
+ }, [n, B]);
2265
+ let Je = e.useCallback((e) => {
2156
2266
  let t = !!e.text?.trim(), n = e.files?.map((e) => e.file).filter(Boolean), r = !!(n && n.length > 0);
2157
- (t || r) && i?.(e.text?.trim() ?? "", n);
2158
- }, [i]), Ue = e.useCallback((e) => {
2267
+ if (!(t || r)) return;
2268
+ let a = e.text?.trim() ?? "";
2269
+ De.current = a, Oe.current = null, i?.(a, n);
2270
+ }, [i]), $e = e.useCallback((e) => {
2159
2271
  i?.(e);
2160
- }, [i]), We = e.useRef(null), Ke = e.useCallback((e) => {
2272
+ }, [i]), et = e.useRef(null), tt = e.useCallback((e) => {
2161
2273
  i?.(e ? be : ye);
2162
2274
  }, [
2163
2275
  i,
2164
2276
  ye,
2165
2277
  be
2166
- ]), Je = e.useCallback(() => {
2167
- let e = We.current?.querySelector("textarea");
2278
+ ]), nt = e.useCallback(() => {
2279
+ let e = et.current?.querySelector("textarea");
2168
2280
  e && (e.focus(), e.scrollIntoView({ block: "nearest" }));
2169
- }, []), Qe = e.useCallback((e) => {
2170
- navigator.clipboard?.writeText(e.content), Te(e.id), window.setTimeout(() => Te((t) => t === e.id ? null : t), 1500);
2171
- }, []), $e = e.useMemo(() => {
2281
+ }, []);
2282
+ e.useEffect(() => {
2283
+ if (!f || !Bn(f) || Oe.current === f) return;
2284
+ Oe.current = f;
2285
+ let e = De.current;
2286
+ if (!e) return;
2287
+ let t = et.current?.querySelector("textarea");
2288
+ t && t.value.trim() === "" && (t.value = e, t.dispatchEvent(new Event("input", { bubbles: !0 })), t.focus());
2289
+ }, [f]);
2290
+ let rt = e.useCallback((e) => {
2291
+ navigator.clipboard?.writeText(e.content), Ee(e.id), window.setTimeout(() => Ee((t) => t === e.id ? null : t), 1500);
2292
+ }, []), it = e.useMemo(() => {
2172
2293
  let e = /* @__PURE__ */ new Set(), t = [], r = -1, i = 0;
2173
- for (let e of n) for (let n of e.toolInvocations ?? []) n.proposedPlan && n.toolCallId && t.push({
2294
+ for (let e of n) for (let n of e.toolInvocations ?? []) (n.proposedPlan || Vi(n)) && n.toolCallId && t.push({
2174
2295
  id: n.toolCallId,
2175
2296
  order: i
2176
2297
  }), n.toolName === "apply_blueprint" && (r = i), i += 1;
2177
2298
  for (let n of t) n.order < r && e.add(n.id);
2178
2299
  return e;
2179
- }, [n]), et = e.useMemo(() => {
2300
+ }, [n]), at = e.useMemo(() => {
2180
2301
  let e = /* @__PURE__ */ new Set(), t = [], r = /* @__PURE__ */ new Map(), i = 0;
2181
2302
  for (let e of n) for (let n of e.toolInvocations ?? []) n.proposedChanges && n.toolCallId ? t.push({
2182
2303
  id: n.toolCallId,
@@ -2188,27 +2309,31 @@ var Li = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
2188
2309
  t !== void 0 && t > n.order && e.add(n.id);
2189
2310
  }
2190
2311
  return e;
2191
- }, [n]), tt = (e) => {
2192
- let t = e.state ?? (e.errorText ? "output-error" : e.result === void 0 ? "input-available" : "output-available"), n = `tool-${e.toolName}`, r = I?.[e.toolCallId], a = t === "approval-requested" && !!N && !r, o = t === "approval-requested" && !!e.pendingActionId, s = jn(e.toolName), c = Mn(e.result), l = V === "debug" && s && s.toLowerCase() !== e.toolName.toLowerCase(), u = V === "debug" || a, d = e.draftReview?.packageId, f = d === void 0 ? void 0 : je.get(d), p = f === void 0 ? Ee.has(e.toolCallId) : f === 0, m = t === "input-streaming" || t === "input-available", h = /* @__PURE__ */ $("span", {
2193
- className: "inline-flex items-center gap-2",
2312
+ }, [n]), ot = (e) => {
2313
+ let t = e.state ?? (e.errorText ? "output-error" : e.result === void 0 ? "input-available" : "output-available"), n = `tool-${e.toolName}`, r = L?.[e.toolCallId], a = t === "approval-requested" && !!N && !r, o = t === "approval-requested" && !!e.pendingActionId, s = Fn(e.toolName), c = In(e.result), l = W === "debug" && s && s.toLowerCase() !== e.toolName.toLowerCase(), u = W === "debug" || a, d = e.draftReview?.packageId, f = d === void 0 ? void 0 : Ie.get(d), p = f === void 0 ? Ae.has(e.toolCallId) : f === 0, m = t === "input-streaming" || t === "input-available", h = /* @__PURE__ */ $("span", {
2314
+ className: "inline-flex min-w-0 items-center gap-2",
2194
2315
  children: [
2195
2316
  /* @__PURE__ */ Q("span", { children: s || e.toolName }),
2196
2317
  l ? /* @__PURE__ */ Q("code", {
2197
2318
  className: "rounded bg-muted px-1 py-px text-[10px] font-mono text-muted-foreground",
2198
2319
  children: e.toolName
2199
2320
  }) : null,
2200
- m ? /* @__PURE__ */ Q(Ki, { offlineLabel: K.connectionOfflineLabel }) : null
2321
+ m ? Bi(e) ? /* @__PURE__ */ Q(oa, {
2322
+ label: J.designingPlanLabel,
2323
+ hints: J.designingPlanHints,
2324
+ offlineLabel: J.connectionOfflineLabel
2325
+ }) : /* @__PURE__ */ Q(sa, { offlineLabel: J.connectionOfflineLabel }) : null
2201
2326
  ]
2202
2327
  });
2203
- return /* @__PURE__ */ $(li, {
2204
- defaultOpen: t === "output-error" || t === "approval-requested" || !!(e.draftReview && e.draftReview.items.length > 0) || !!e.proposedPlan || !!e.proposedChanges,
2205
- children: [/* @__PURE__ */ Q(di, {
2328
+ return /* @__PURE__ */ $(gi, {
2329
+ defaultOpen: t === "output-error" || t === "approval-requested" || !!(e.draftReview && e.draftReview.items.length > 0) || !!e.proposedPlan || !!e.proposedChanges || Vi(e),
2330
+ children: [/* @__PURE__ */ Q(vi, {
2206
2331
  type: n,
2207
2332
  state: t,
2208
2333
  title: h
2209
- }), /* @__PURE__ */ $(fi, { children: [
2210
- u && e.args !== void 0 ? /* @__PURE__ */ Q(pi, { input: e.args }) : null,
2211
- o ? null : u || t === "output-error" ? /* @__PURE__ */ Q(ea, {
2334
+ }), /* @__PURE__ */ $(yi, { children: [
2335
+ u && e.args !== void 0 ? /* @__PURE__ */ Q(bi, { input: e.args }) : null,
2336
+ o ? null : u || t === "output-error" ? /* @__PURE__ */ Q(_a, {
2212
2337
  output: c,
2213
2338
  errorText: e.errorText
2214
2339
  }) : null,
@@ -2228,60 +2353,60 @@ var Li = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
2228
2353
  children: P
2229
2354
  }), /* @__PURE__ */ Q("button", {
2230
2355
  type: "button",
2231
- onClick: () => N?.(e.toolCallId, !1, F),
2356
+ onClick: () => N?.(e.toolCallId, !1, I),
2232
2357
  className: "inline-flex h-7 items-center rounded-md border bg-background px-3 text-xs font-medium hover:bg-accent",
2233
- children: ee
2358
+ children: F
2234
2359
  })]
2235
2360
  }) : null,
2236
- e.draftReview && e.draftReview.items.length > 0 && (te || L && e.draftReview.packageId) ? /* @__PURE__ */ $(Z, { children: [
2361
+ e.draftReview && e.draftReview.items.length > 0 && (ee || R && e.draftReview.packageId) ? /* @__PURE__ */ $(Z, { children: [
2237
2362
  /* @__PURE__ */ $("div", {
2238
2363
  className: "flex items-center gap-2 p-3 border-t bg-muted/30",
2239
2364
  children: [
2240
- L && e.draftReview.packageId ? p ? /* @__PURE__ */ $("span", {
2365
+ R && e.draftReview.packageId ? p ? /* @__PURE__ */ $("span", {
2241
2366
  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",
2242
2367
  children: [
2243
- /* @__PURE__ */ Q(J, { className: "size-3.5" }),
2244
- ce,
2368
+ /* @__PURE__ */ Q(Y, { className: "size-3.5" }),
2369
+ oe,
2245
2370
  e.draftReview.failedCount ? ` · ${e.draftReview.failedCount} need${e.draftReview.failedCount === 1 ? "s" : ""} attention` : ""
2246
2371
  ]
2247
2372
  }) : /* @__PURE__ */ $("button", {
2248
2373
  type: "button",
2249
- onClick: () => void Ie(e.draftReview.packageId),
2374
+ onClick: () => void Be(e.draftReview.packageId),
2250
2375
  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",
2251
2376
  "data-testid": "draft-publish",
2252
2377
  children: [
2253
- /* @__PURE__ */ Q(ct, { className: "size-3.5" }),
2254
- z,
2378
+ /* @__PURE__ */ Q(lt, { className: "size-3.5" }),
2379
+ V,
2255
2380
  typeof f == "number" && f > 0 ? ` (${f})` : ""
2256
2381
  ]
2257
2382
  }) : null,
2258
- te ? /* @__PURE__ */ $("button", {
2383
+ ee ? /* @__PURE__ */ $("button", {
2259
2384
  type: "button",
2260
- onClick: () => te(e.draftReview.items),
2261
- className: L && 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",
2262
- children: [/* @__PURE__ */ Q(Xe, { className: "size-3.5" }), ne(e.draftReview.items.length)]
2385
+ onClick: () => ee(e.draftReview.items),
2386
+ className: R && 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",
2387
+ children: [/* @__PURE__ */ Q(Xe, { className: "size-3.5" }), te(e.draftReview.items.length)]
2263
2388
  }) : null,
2264
- R && !p ? (() => {
2389
+ z && !p ? (() => {
2265
2390
  let t = e.draftReview.items.find((e) => e.type === "app");
2266
2391
  return t ? /* @__PURE__ */ $("button", {
2267
2392
  type: "button",
2268
- onClick: () => R(t.name, {
2393
+ onClick: () => z(t.name, {
2269
2394
  materialized: e.draftReview.materialized === !0,
2270
2395
  appSegment: e.draftReview.packageId
2271
2396
  }),
2272
2397
  className: "inline-flex h-7 items-center gap-1.5 rounded-md border px-3 text-xs font-medium hover:bg-muted",
2273
2398
  "data-testid": "draft-preview-app",
2274
- children: [/* @__PURE__ */ Q(Ye, { className: "size-3.5" }), ae]
2399
+ children: [/* @__PURE__ */ Q(Ye, { className: "size-3.5" }), ie]
2275
2400
  }) : null;
2276
2401
  })() : null,
2277
2402
  e.draftReview.verification ? e.draftReview.verification.errors > 0 ? /* @__PURE__ */ $("span", {
2278
2403
  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",
2279
2404
  "data-testid": "draft-verification-chip",
2280
- children: [/* @__PURE__ */ Q(pt, { className: "size-3.5" }), `${e.draftReview.verification.errors} issue${e.draftReview.verification.errors === 1 ? "" : "s"}`]
2405
+ children: [/* @__PURE__ */ Q(ht, { className: "size-3.5" }), `${e.draftReview.verification.errors} issue${e.draftReview.verification.errors === 1 ? "" : "s"}`]
2281
2406
  }) : /* @__PURE__ */ $("span", {
2282
2407
  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",
2283
2408
  "data-testid": "draft-verification-chip",
2284
- children: [/* @__PURE__ */ Q(ut, { className: "size-3.5" }), le]
2409
+ children: [/* @__PURE__ */ Q(dt, { className: "size-3.5" }), se]
2285
2410
  }) : null,
2286
2411
  e.draftReview.summary ? /* @__PURE__ */ Q("span", {
2287
2412
  className: "truncate text-xs text-muted-foreground",
@@ -2300,13 +2425,13 @@ var Li = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
2300
2425
  children: [/* @__PURE__ */ Q(ke, { className: "mt-0.5 size-3.5 shrink-0" }), /* @__PURE__ */ Q("span", { children: e.message })]
2301
2426
  }, `w${t}`))]
2302
2427
  }) : null,
2303
- Ee.has(e.toolCallId) ? /* @__PURE__ */ Q(Ii, { health: Oe.get(e.toolCallId) }) : null,
2428
+ Ae.has(e.toolCallId) ? /* @__PURE__ */ Q(qi, { health: Ne.get(e.toolCallId) }) : null,
2304
2429
  e.draftReview.nextSteps && e.draftReview.nextSteps.length > 0 ? /* @__PURE__ */ $("div", {
2305
2430
  className: "flex flex-col gap-1 border-t bg-muted/20 px-3 py-2",
2306
2431
  "data-testid": "draft-next-steps",
2307
2432
  children: [/* @__PURE__ */ Q("span", {
2308
2433
  className: "text-xs font-medium text-foreground/80",
2309
- children: ue
2434
+ children: ce
2310
2435
  }), e.draftReview.nextSteps.map((e, t) => /* @__PURE__ */ $("div", {
2311
2436
  className: "flex items-start gap-1.5 text-xs text-muted-foreground",
2312
2437
  children: [/* @__PURE__ */ Q("span", {
@@ -2322,14 +2447,14 @@ var Li = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
2322
2447
  children: [
2323
2448
  /* @__PURE__ */ $("span", {
2324
2449
  className: "inline-flex items-center gap-1.5 text-xs font-medium text-foreground/80",
2325
- children: [/* @__PURE__ */ Q(Ve, { className: "size-3.5" }), de]
2450
+ children: [/* @__PURE__ */ Q(Ve, { className: "size-3.5" }), le]
2326
2451
  }),
2327
2452
  e.proposedPlan.targetApp ? /* @__PURE__ */ $("span", {
2328
2453
  className: "inline-flex w-fit items-center gap-1 rounded-md border border-blue-200 bg-blue-50 px-2 py-0.5 text-[11px] font-medium text-blue-700 dark:border-blue-900/50 dark:bg-blue-950/30 dark:text-blue-300",
2329
2454
  "data-testid": "proposed-plan-extend",
2330
2455
  children: [
2331
2456
  "+ ",
2332
- fe,
2457
+ ue,
2333
2458
  " 「",
2334
2459
  e.proposedPlan.targetApp,
2335
2460
  "」"
@@ -2345,7 +2470,7 @@ var Li = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
2345
2470
  className: "inline-flex items-center gap-1 rounded-md border bg-background px-1.5 py-0.5 text-[11px] text-foreground/80",
2346
2471
  title: e.name,
2347
2472
  children: [
2348
- /* @__PURE__ */ Q(ft, { className: "size-3 text-foreground/40" }),
2473
+ /* @__PURE__ */ Q(mt, { className: "size-3 text-foreground/40" }),
2349
2474
  e.label || e.name,
2350
2475
  e.fieldCount > 0 ? /* @__PURE__ */ $("span", {
2351
2476
  className: "text-foreground/40",
@@ -2361,25 +2486,42 @@ var Li = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
2361
2486
  children: n.join(" · ")
2362
2487
  }) : null;
2363
2488
  })(),
2364
- e.proposedPlan.assumptions.length > 0 ? /* @__PURE__ */ $("div", {
2365
- className: "flex flex-col gap-0.5",
2366
- children: [/* @__PURE__ */ Q("span", {
2367
- className: "text-[11px] font-medium text-foreground/70",
2368
- children: me
2369
- }), e.proposedPlan.assumptions.map((e, t) => /* @__PURE__ */ $("div", {
2370
- className: "flex items-start gap-1.5 text-[11px] text-muted-foreground",
2489
+ (() => {
2490
+ let { designNotes: t, deferred: n } = Ui(e.proposedPlan.assumptions);
2491
+ return /* @__PURE__ */ $(Z, { children: [t.length > 0 ? /* @__PURE__ */ $("div", {
2492
+ className: "flex flex-col gap-0.5",
2493
+ "data-testid": "proposed-plan-assumptions",
2371
2494
  children: [/* @__PURE__ */ Q("span", {
2372
- className: "mt-px shrink-0 text-foreground/40",
2373
- children: "·"
2374
- }), /* @__PURE__ */ Q("span", { children: e })]
2375
- }, t))]
2376
- }) : null,
2495
+ className: "text-[11px] font-medium text-foreground/70",
2496
+ children: fe
2497
+ }), t.map((e, t) => /* @__PURE__ */ $("div", {
2498
+ className: "flex items-start gap-1.5 text-[11px] text-muted-foreground",
2499
+ children: [/* @__PURE__ */ Q("span", {
2500
+ className: "mt-px shrink-0 text-foreground/40",
2501
+ children: "·"
2502
+ }), /* @__PURE__ */ Q("span", { children: e })]
2503
+ }, t))]
2504
+ }) : null, n.length > 0 ? /* @__PURE__ */ $("div", {
2505
+ className: "flex flex-col gap-1 rounded-md border border-dashed border-amber-300 bg-amber-50/60 px-2 py-1.5 dark:border-amber-800/60 dark:bg-amber-950/20",
2506
+ "data-testid": "proposed-plan-deferred",
2507
+ children: [/* @__PURE__ */ $("span", {
2508
+ className: "inline-flex items-center gap-1.5 text-[11px] font-medium text-amber-800 dark:text-amber-300",
2509
+ children: [/* @__PURE__ */ Q(Qe, { className: "size-3.5" }), pe]
2510
+ }), n.map((e, t) => /* @__PURE__ */ $("div", {
2511
+ className: "flex items-start gap-1.5 text-[11px] text-amber-900/90 dark:text-amber-200/90",
2512
+ children: [/* @__PURE__ */ Q("span", {
2513
+ className: "mt-px shrink-0 text-amber-500/80",
2514
+ children: "·"
2515
+ }), /* @__PURE__ */ Q("span", { children: e })]
2516
+ }, t))]
2517
+ }) : null] });
2518
+ })(),
2377
2519
  e.proposedPlan.questions.length > 0 ? /* @__PURE__ */ $("div", {
2378
2520
  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",
2379
2521
  "data-testid": "proposed-plan-questions",
2380
2522
  children: [/* @__PURE__ */ $("span", {
2381
2523
  className: "inline-flex items-center gap-1.5 text-[11px] font-medium text-amber-800 dark:text-amber-300",
2382
- children: [/* @__PURE__ */ Q(Ze, { className: "size-3.5" }), pe]
2524
+ children: [/* @__PURE__ */ Q(Ze, { className: "size-3.5" }), de]
2383
2525
  }), e.proposedPlan.questions.map((t, n) => {
2384
2526
  let r = e.proposedPlan.questionChoices?.find((e) => e.text === t);
2385
2527
  return /* @__PURE__ */ $("div", {
@@ -2403,33 +2545,75 @@ var Li = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
2403
2545
  }, n);
2404
2546
  })]
2405
2547
  }) : null,
2406
- i ? $e.has(e.toolCallId) ? /* @__PURE__ */ Q("div", {
2548
+ i ? it.has(e.toolCallId) ? /* @__PURE__ */ Q("div", {
2407
2549
  className: "flex flex-wrap items-center gap-1.5 pt-0.5",
2408
2550
  "data-testid": "proposed-plan-actions",
2409
2551
  children: /* @__PURE__ */ $("span", {
2410
2552
  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 dark:border-emerald-900/50 dark:bg-emerald-950/30 dark:text-emerald-300",
2411
2553
  "data-testid": "proposed-plan-built",
2412
- children: [/* @__PURE__ */ Q(J, { className: "size-3.5" }), ve]
2554
+ children: [/* @__PURE__ */ Q(Y, { className: "size-3.5" }), _e]
2413
2555
  })
2414
2556
  }) : /* @__PURE__ */ $("div", {
2415
2557
  className: "flex flex-wrap items-center gap-1.5 pt-0.5",
2416
2558
  "data-testid": "proposed-plan-actions",
2417
2559
  children: [/* @__PURE__ */ $("button", {
2418
2560
  type: "button",
2419
- onClick: () => Ke(e.proposedPlan.questions.length > 0),
2561
+ onClick: () => tt(e.proposedPlan.questions.length > 0),
2420
2562
  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",
2421
2563
  "data-testid": "proposed-plan-approve",
2422
- children: [/* @__PURE__ */ Q(ct, { className: "size-3.5" }), ge]
2564
+ children: [/* @__PURE__ */ Q(lt, { className: "size-3.5" }), he]
2423
2565
  }), /* @__PURE__ */ Q("button", {
2424
2566
  type: "button",
2425
- onClick: Je,
2567
+ onClick: nt,
2426
2568
  className: "inline-flex h-7 items-center rounded-md border bg-background px-3 text-xs font-medium hover:bg-accent",
2427
2569
  "data-testid": "proposed-plan-adjust",
2428
- children: _e
2570
+ children: ge
2429
2571
  })]
2430
2572
  }) : /* @__PURE__ */ Q("span", {
2431
2573
  className: "text-[11px] italic text-muted-foreground/80",
2432
- children: he
2574
+ children: me
2575
+ })
2576
+ ]
2577
+ }) : null,
2578
+ Vi(e) ? /* @__PURE__ */ $("div", {
2579
+ className: "flex flex-col gap-2 border-t bg-muted/20 px-3 py-2.5",
2580
+ "data-testid": "proposed-plan-fallback",
2581
+ children: [
2582
+ /* @__PURE__ */ $("span", {
2583
+ className: "inline-flex items-center gap-1.5 text-xs font-medium text-foreground/80",
2584
+ children: [/* @__PURE__ */ Q(Ve, { className: "size-3.5" }), le]
2585
+ }),
2586
+ /* @__PURE__ */ Q("p", {
2587
+ className: "text-xs text-muted-foreground",
2588
+ children: ve
2589
+ }),
2590
+ i ? it.has(e.toolCallId) ? /* @__PURE__ */ Q("div", {
2591
+ className: "flex flex-wrap items-center gap-1.5 pt-0.5",
2592
+ "data-testid": "proposed-plan-actions",
2593
+ children: /* @__PURE__ */ $("span", {
2594
+ 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 dark:border-emerald-900/50 dark:bg-emerald-950/30 dark:text-emerald-300",
2595
+ "data-testid": "proposed-plan-built",
2596
+ children: [/* @__PURE__ */ Q(Y, { className: "size-3.5" }), _e]
2597
+ })
2598
+ }) : /* @__PURE__ */ $("div", {
2599
+ className: "flex flex-wrap items-center gap-1.5 pt-0.5",
2600
+ "data-testid": "proposed-plan-actions",
2601
+ children: [/* @__PURE__ */ $("button", {
2602
+ type: "button",
2603
+ onClick: () => tt(!1),
2604
+ 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",
2605
+ "data-testid": "proposed-plan-approve",
2606
+ children: [/* @__PURE__ */ Q(lt, { className: "size-3.5" }), he]
2607
+ }), /* @__PURE__ */ Q("button", {
2608
+ type: "button",
2609
+ onClick: nt,
2610
+ className: "inline-flex h-7 items-center rounded-md border bg-background px-3 text-xs font-medium hover:bg-accent",
2611
+ "data-testid": "proposed-plan-adjust",
2612
+ children: ge
2613
+ })]
2614
+ }) : /* @__PURE__ */ Q("span", {
2615
+ className: "text-[11px] italic text-muted-foreground/80",
2616
+ children: me
2433
2617
  })
2434
2618
  ]
2435
2619
  }) : null,
@@ -2449,16 +2633,16 @@ var Li = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
2449
2633
  className: "flex flex-col gap-1",
2450
2634
  children: e.proposedChanges.changes.map((e, t) => /* @__PURE__ */ $("div", {
2451
2635
  className: "flex items-start gap-1.5 rounded-md border bg-background px-2 py-1 text-[11px] text-foreground/80",
2452
- children: [/* @__PURE__ */ Q(ft, { className: "mt-px size-3 shrink-0 text-foreground/40" }), /* @__PURE__ */ Q("span", { children: Mi(e) })]
2636
+ children: [/* @__PURE__ */ Q(mt, { className: "mt-px size-3 shrink-0 text-foreground/40" }), /* @__PURE__ */ Q("span", { children: zi(e) })]
2453
2637
  }, t))
2454
2638
  }),
2455
- i ? et.has(e.toolCallId) ? /* @__PURE__ */ Q("div", {
2639
+ i ? at.has(e.toolCallId) ? /* @__PURE__ */ Q("div", {
2456
2640
  className: "flex flex-wrap items-center gap-1.5 pt-0.5",
2457
2641
  "data-testid": "proposed-changes-actions",
2458
2642
  children: /* @__PURE__ */ $("span", {
2459
2643
  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 dark:border-emerald-900/50 dark:bg-emerald-950/30 dark:text-emerald-300",
2460
2644
  "data-testid": "proposed-changes-confirmed",
2461
- children: [/* @__PURE__ */ Q(J, { className: "size-3.5" }), "已确认"]
2645
+ children: [/* @__PURE__ */ Q(Y, { className: "size-3.5" }), "已确认"]
2462
2646
  })
2463
2647
  }) : /* @__PURE__ */ $("div", {
2464
2648
  className: "flex flex-wrap items-center gap-1.5 pt-0.5",
@@ -2468,10 +2652,10 @@ var Li = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
2468
2652
  onClick: () => i("确认修改,应用你刚才提议的改动。"),
2469
2653
  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",
2470
2654
  "data-testid": "proposed-changes-confirm",
2471
- children: [/* @__PURE__ */ Q(J, { className: "size-3.5" }), "确认修改"]
2655
+ children: [/* @__PURE__ */ Q(Y, { className: "size-3.5" }), "确认修改"]
2472
2656
  }), /* @__PURE__ */ Q("button", {
2473
2657
  type: "button",
2474
- onClick: Je,
2658
+ onClick: nt,
2475
2659
  className: "inline-flex h-7 items-center rounded-md border bg-background px-3 text-xs font-medium hover:bg-accent",
2476
2660
  "data-testid": "proposed-changes-adjust",
2477
2661
  children: "调整"
@@ -2487,28 +2671,28 @@ var Li = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
2487
2671
  };
2488
2672
  return /* @__PURE__ */ $("div", {
2489
2673
  ref: we,
2490
- className: q(W ? "flex min-h-0 flex-col overflow-hidden bg-background" : "flex min-h-0 flex-col overflow-hidden rounded-lg border bg-background", t),
2674
+ className: q(K ? "flex min-h-0 flex-col overflow-hidden bg-background" : "flex min-h-0 flex-col overflow-hidden rounded-lg border bg-background", t),
2491
2675
  style: { maxHeight: b },
2492
2676
  ...Ce,
2493
2677
  children: [
2494
2678
  a && !y && n.length > 0 && /* @__PURE__ */ Q("div", {
2495
- className: q("flex items-center justify-end px-4 py-2", W ? "bg-background" : "border-b bg-muted/30"),
2679
+ className: q("flex items-center justify-end px-4 py-2", K ? "bg-background" : "border-b bg-muted/30"),
2496
2680
  children: /* @__PURE__ */ Q("button", {
2497
2681
  type: "button",
2498
2682
  onClick: a,
2499
2683
  className: "text-xs text-muted-foreground hover:text-foreground transition-colors",
2500
- children: K.clear
2684
+ children: J.clear
2501
2685
  })
2502
2686
  }),
2503
2687
  A ? /* @__PURE__ */ Q("div", {
2504
- className: q("shrink-0", !W && "border-b bg-background/50"),
2688
+ className: q("shrink-0", !K && "border-b bg-background/50"),
2505
2689
  children: A
2506
2690
  }) : null,
2507
- /* @__PURE__ */ $(In, {
2691
+ /* @__PURE__ */ $(Un, {
2508
2692
  className: "flex-1 min-h-0",
2509
- children: [/* @__PURE__ */ $(Ln, {
2510
- className: q("space-y-4", W ? "mx-auto w-full max-w-2xl px-4 py-8 sm:px-0" : "px-4 py-3"),
2511
- children: [n.length === 0 ? /* @__PURE__ */ $(Rn, {
2693
+ children: [/* @__PURE__ */ $(Wn, {
2694
+ className: q("space-y-4", K ? "mx-auto w-full max-w-2xl px-4 py-8 sm:px-0" : "px-4 py-3"),
2695
+ children: [n.length === 0 ? /* @__PURE__ */ $(Gn, {
2512
2696
  className: "gap-3 px-0 py-8",
2513
2697
  children: [
2514
2698
  /* @__PURE__ */ Q("div", {
@@ -2517,65 +2701,73 @@ var Li = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
2517
2701
  src: _,
2518
2702
  alt: "",
2519
2703
  className: "size-full rounded-md object-cover"
2520
- }) : /* @__PURE__ */ Q(Ne, { className: "size-4" })
2704
+ }) : /* @__PURE__ */ Q(Me, { className: "size-4" })
2521
2705
  }),
2522
2706
  /* @__PURE__ */ $("div", {
2523
2707
  className: "space-y-1",
2524
2708
  children: [/* @__PURE__ */ Q("h3", {
2525
2709
  className: "text-sm font-medium text-foreground/90",
2526
- children: K.emptyTitle
2710
+ children: J.emptyTitle
2527
2711
  }), /* @__PURE__ */ Q("p", {
2528
2712
  className: "text-sm text-muted-foreground",
2529
- children: K.emptyDescription
2713
+ children: J.emptyDescription
2530
2714
  })]
2531
2715
  }),
2532
- T && T.length > 0 ? /* @__PURE__ */ Q(ni, {
2716
+ T && T.length > 0 ? /* @__PURE__ */ Q(li, {
2533
2717
  className: "justify-center gap-2",
2534
- children: T.map((e) => /* @__PURE__ */ Q(ri, {
2718
+ children: T.map((e) => /* @__PURE__ */ Q(ui, {
2535
2719
  className: "h-8 border-border/60 bg-background/80 px-3 text-xs font-medium text-foreground/90 shadow-none hover:bg-muted/60",
2536
2720
  suggestion: e,
2537
- onClick: Ue
2721
+ onClick: $e
2538
2722
  }, e))
2539
2723
  }) : null
2540
2724
  ]
2541
2725
  }) : n.map((e) => {
2542
- 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 && V === "summary" ? n.filter((e) => !Ni(e)) : [], l = !t && V === "debug" ? n : !t && V !== "debug" ? n.filter(Ni) : [];
2543
- return /* @__PURE__ */ Q(Un, {
2544
- from: ki(e.role),
2726
+ let t = e.role === "user", n = e.toolInvocations ?? [], r = e.reasoning?.trim(), i = e.sources ?? [], a = t ? void 0 : e.buildProgress, o = !t && !n.some((e) => !!e.proposedPlan) ? e.blueprintProgress : void 0, c = !t && !!e.streaming && !e.content && n.length === 0 && !r && !a && !o, l = !t && W === "summary" ? n.filter((e) => !Wi(e) && !(o && e.toolName === "propose_blueprint")) : [], u = !t && W === "debug" ? n : !t && W !== "debug" ? n.filter(Wi) : [];
2727
+ return /* @__PURE__ */ Q(Xn, {
2728
+ from: Ii(e.role),
2545
2729
  children: /* @__PURE__ */ $("div", {
2546
2730
  className: q("flex w-full gap-2.5", m ? t ? "flex-row-reverse items-start" : "flex-row items-start" : "flex-col"),
2547
- children: [m ? /* @__PURE__ */ Q(Ri, {
2731
+ children: [m ? /* @__PURE__ */ Q(Yi, {
2548
2732
  isUser: t,
2549
2733
  url: t ? h : _,
2550
2734
  fallback: t ? g : v
2551
2735
  }) : null, /* @__PURE__ */ $("div", {
2552
2736
  className: q("flex min-w-0 flex-col gap-2", m && !t && "flex-1"),
2553
- children: [/* @__PURE__ */ $(Wn, { children: [
2554
- a ? /* @__PURE__ */ Q(Yi, {
2737
+ children: [/* @__PURE__ */ $(Zn, { children: [
2738
+ o ? /* @__PURE__ */ Q(ua, {
2739
+ progress: o,
2740
+ designingLabel: J.designingPlanLabel,
2741
+ extendLabel: ue,
2742
+ waitingLabel: J.connectionWaiting,
2743
+ stalledLabel: J.connectionStalledLabel,
2744
+ offlineLabel: J.connectionOfflineLabel
2745
+ }) : null,
2746
+ a ? /* @__PURE__ */ Q(da, {
2555
2747
  progress: a,
2556
- onOpenBuiltApp: re,
2557
- openBuiltAppLabel: ie,
2558
- onPreviewDraftApp: R,
2559
- previewDraftLabel: ae,
2560
- waitingLabel: K.connectionWaiting,
2561
- stalledLabel: K.connectionStalledLabel,
2562
- offlineLabel: K.connectionOfflineLabel
2748
+ onOpenBuiltApp: ne,
2749
+ openBuiltAppLabel: re,
2750
+ onPreviewDraftApp: z,
2751
+ previewDraftLabel: ie,
2752
+ waitingLabel: J.connectionWaiting,
2753
+ stalledLabel: J.connectionStalledLabel,
2754
+ offlineLabel: J.connectionOfflineLabel
2563
2755
  }) : null,
2564
- !t && V === "debug" && r ? /* @__PURE__ */ $(bi, {
2756
+ !t && W === "debug" && r ? /* @__PURE__ */ $(Di, {
2565
2757
  isStreaming: !!e.streaming && !e.content,
2566
2758
  className: "mb-2",
2567
- children: [/* @__PURE__ */ Q(Si, {}), /* @__PURE__ */ Q(Ci, { children: r })]
2759
+ children: [/* @__PURE__ */ Q(ki, {}), /* @__PURE__ */ Q(Ai, { children: r })]
2568
2760
  }) : null,
2569
- !t && V === "summary" && c.length > 0 ? /* @__PURE__ */ Q(Xi, {
2570
- groups: Fi(c),
2571
- labels: K
2761
+ !t && W === "summary" && l.length > 0 ? /* @__PURE__ */ Q(fa, {
2762
+ groups: Ki(l),
2763
+ labels: J
2572
2764
  }) : null,
2573
- !t && l.length > 0 ? l.map(tt) : null,
2765
+ !t && u.length > 0 ? u.map(ot) : null,
2574
2766
  t ? e.content ? /* @__PURE__ */ Q("div", {
2575
2767
  className: "whitespace-pre-wrap break-words",
2576
2768
  children: e.content
2577
- }) : null : o ? /* @__PURE__ */ Q(Bi, {}) : e.content ? /* @__PURE__ */ Q(tr, { children: e.content }) : null,
2578
- e.streaming && !o ? /* @__PURE__ */ Q("span", {
2769
+ }) : null : c ? /* @__PURE__ */ Q(Zi, {}) : e.content ? /* @__PURE__ */ Q(cr, { children: e.content }) : null,
2770
+ e.streaming && !c ? /* @__PURE__ */ Q("span", {
2579
2771
  "aria-hidden": !0,
2580
2772
  className: "ml-0.5 inline-block w-[2px] h-4 align-middle bg-current animate-pulse"
2581
2773
  }) : null,
@@ -2589,7 +2781,7 @@ var Li = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
2589
2781
  children: [e.title ? /* @__PURE__ */ Q("div", {
2590
2782
  className: "mb-2 text-sm font-medium text-foreground",
2591
2783
  children: e.title
2592
- }) : null, /* @__PURE__ */ Q(St, { schema: {
2784
+ }) : null, /* @__PURE__ */ Q(wt, { schema: {
2593
2785
  type: "chart",
2594
2786
  chartType: e.chartType ?? "bar",
2595
2787
  data: e.data,
@@ -2598,7 +2790,7 @@ var Li = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
2598
2790
  } })]
2599
2791
  }, t))
2600
2792
  }) : null,
2601
- !t && i.length > 0 ? /* @__PURE__ */ $(wi, { children: [/* @__PURE__ */ Q(Ti, { count: i.length }), /* @__PURE__ */ Q(Ei, { children: i.map((e, t) => /* @__PURE__ */ Q(Di, {
2793
+ !t && i.length > 0 ? /* @__PURE__ */ $(ji, { children: [/* @__PURE__ */ Q(Mi, { count: i.length }), /* @__PURE__ */ Q(Ni, { children: i.map((e, t) => /* @__PURE__ */ Q(Pi, {
2602
2794
  href: e.url,
2603
2795
  title: e.title ?? e.url
2604
2796
  }, e.id ?? e.url ?? t)) })] }) : null,
@@ -2606,73 +2798,77 @@ var Li = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
2606
2798
  className: "text-[10px] opacity-70 mt-1",
2607
2799
  children: e.timestamp
2608
2800
  }) : null
2609
- ] }), !t && !o ? /* @__PURE__ */ $(Gn, {
2801
+ ] }), !t && !c ? /* @__PURE__ */ $(Qn, {
2610
2802
  className: "opacity-0 transition-opacity group-focus-within:opacity-100 group-hover:opacity-100",
2611
2803
  children: [
2612
- /* @__PURE__ */ Q(Kn, {
2613
- label: G === e.id ? K.copied : K.copy,
2614
- tooltip: G === e.id ? K.copied : K.copy,
2615
- onClick: () => Qe(e),
2616
- children: G === e.id ? /* @__PURE__ */ Q(Fe, { className: "size-3.5" }) : /* @__PURE__ */ Q(Ge, { className: "size-3.5" })
2804
+ /* @__PURE__ */ Q($n, {
2805
+ label: Te === e.id ? J.copied : J.copy,
2806
+ tooltip: Te === e.id ? J.copied : J.copy,
2807
+ onClick: () => rt(e),
2808
+ children: Te === e.id ? /* @__PURE__ */ Q(Pe, { className: "size-3.5" }) : /* @__PURE__ */ Q(Ge, { className: "size-3.5" })
2617
2809
  }),
2618
- s ? /* @__PURE__ */ Q(Kn, {
2619
- label: K.regenerate,
2620
- tooltip: K.regenerate,
2810
+ s ? /* @__PURE__ */ Q($n, {
2811
+ label: J.regenerate,
2812
+ tooltip: J.regenerate,
2621
2813
  onClick: s,
2622
- children: /* @__PURE__ */ Q(st, { className: "size-3.5" })
2814
+ children: /* @__PURE__ */ Q(ct, { className: "size-3.5" })
2623
2815
  }) : null,
2624
- V === "debug" && e.traceId ? /* @__PURE__ */ Q("a", {
2816
+ W === "debug" && e.traceId ? /* @__PURE__ */ Q("a", {
2625
2817
  href: `#trace/${e.traceId}`,
2626
2818
  "data-trace-id": e.traceId,
2627
2819
  className: "text-[10px] text-muted-foreground hover:text-foreground ml-1 underline",
2628
- title: K.viewTrace,
2629
- children: K.trace
2820
+ title: J.viewTrace,
2821
+ children: J.trace
2630
2822
  }) : null
2631
2823
  ]
2632
2824
  }) : null]
2633
2825
  })]
2634
2826
  })
2635
2827
  }, e.id);
2636
- }), d && !n.some((e) => e.streaming) ? /* @__PURE__ */ Q(zi, {
2828
+ }), d && !n.some((e) => e.streaming) ? /* @__PURE__ */ Q(Xi, {
2637
2829
  showAvatar: m,
2638
2830
  assistantAvatarUrl: _,
2639
2831
  assistantAvatarFallback: v,
2640
- waitingLabel: K.connectionWaiting,
2641
- stalledLabel: K.connectionStalledLabel,
2642
- offlineLabel: K.connectionOfflineLabel
2832
+ waitingLabel: J.connectionWaiting,
2833
+ stalledLabel: J.connectionStalledLabel,
2834
+ offlineLabel: J.connectionOfflineLabel
2643
2835
  }) : null]
2644
- }), /* @__PURE__ */ Q(zn, {})]
2836
+ }), /* @__PURE__ */ Q(Kn, {})]
2645
2837
  }),
2646
- f ? /* @__PURE__ */ Q($i, {
2838
+ f ? Bn(f) && !zn(f) ? /* @__PURE__ */ Q(ha, {
2839
+ error: f,
2840
+ rateLimitedLabel: J.sendFailedRateLimited,
2841
+ genericLabel: J.sendFailedGeneric
2842
+ }) : /* @__PURE__ */ Q(ga, {
2647
2843
  error: f,
2648
2844
  onReload: s,
2649
2845
  onUpgrade: c
2650
2846
  }) : null,
2651
2847
  u ? null : /* @__PURE__ */ $("div", {
2652
- ref: We,
2653
- className: q("relative", W && "mx-auto w-full max-w-2xl px-4 pb-4 sm:px-0"),
2848
+ ref: et,
2849
+ className: q("relative", K && "mx-auto w-full max-w-2xl px-4 pb-4 sm:px-0"),
2654
2850
  children: [j ? /* @__PURE__ */ Q("div", {
2655
2851
  className: "absolute bottom-full left-0 right-0 z-10 px-3 pb-1",
2656
2852
  children: j
2657
- }) : null, /* @__PURE__ */ $(Cr, {
2853
+ }) : null, /* @__PURE__ */ $(Ar, {
2658
2854
  accept: C,
2659
- fileInputLabel: K.uploadFiles,
2855
+ fileInputLabel: J.uploadFiles,
2660
2856
  maxFileSize: w,
2661
- onSubmit: He,
2857
+ onSubmit: Je,
2662
2858
  onError: (e) => {
2663
2859
  console.warn("[plugin-chatbot] prompt-input error", e);
2664
2860
  },
2665
2861
  children: [
2666
- S ? /* @__PURE__ */ Q(wr, { children: /* @__PURE__ */ Q(xr, { children: (e) => /* @__PURE__ */ Q(br, { data: e }) }) }) : null,
2667
- /* @__PURE__ */ Q(Tr, {
2862
+ S ? /* @__PURE__ */ Q(jr, { children: /* @__PURE__ */ Q(Or, { children: (e) => /* @__PURE__ */ Q(Dr, { data: e }) }) }) : null,
2863
+ /* @__PURE__ */ Q(Mr, {
2668
2864
  placeholder: r,
2669
- disabled: l || U === "streaming",
2865
+ disabled: l || G === "streaming",
2670
2866
  onChange: M ? (e) => M(e.currentTarget.value) : void 0
2671
2867
  }),
2672
- /* @__PURE__ */ $(Dr, { children: [/* @__PURE__ */ $(Or, { children: [
2673
- S ? /* @__PURE__ */ $(Ar, { children: [/* @__PURE__ */ Q(jr, {}), /* @__PURE__ */ Q(Mr, { children: /* @__PURE__ */ Q(Sr, {}) })] }) : null,
2674
- D && D.length > 0 ? /* @__PURE__ */ Q("select", {
2675
- "aria-label": K.model,
2868
+ /* @__PURE__ */ $(Pr, { children: [/* @__PURE__ */ $(Fr, { children: [
2869
+ S ? /* @__PURE__ */ $(Lr, { children: [/* @__PURE__ */ Q(Rr, {}), /* @__PURE__ */ Q(zr, { children: /* @__PURE__ */ Q(kr, {}) })] }) : null,
2870
+ D && D.length > 1 ? /* @__PURE__ */ Q("select", {
2871
+ "aria-label": J.model,
2676
2872
  value: O ?? D[0].id,
2677
2873
  onChange: (e) => k?.(e.target.value),
2678
2874
  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",
@@ -2692,16 +2888,16 @@ var Li = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
2692
2888
  /* @__PURE__ */ Q(qe, { className: "h-3 w-3" }),
2693
2889
  /* @__PURE__ */ Q("span", {
2694
2890
  className: "opacity-70",
2695
- children: K.sendHint
2891
+ children: J.sendHint
2696
2892
  })
2697
2893
  ]
2698
2894
  })
2699
- ] }), /* @__PURE__ */ Q(Pr, {
2700
- "aria-label": U === "streaming" ? K.stopResponse : K.submit,
2701
- status: U,
2895
+ ] }), /* @__PURE__ */ Q(Vr, {
2896
+ "aria-label": G === "streaming" ? J.stopResponse : J.submit,
2897
+ status: G,
2702
2898
  disabled: l,
2703
- onClick: U === "streaming" ? o : void 0,
2704
- type: U === "streaming" ? "button" : "submit"
2899
+ onClick: G === "streaming" ? o : void 0,
2900
+ type: G === "streaming" ? "button" : "submit"
2705
2901
  })] })
2706
2902
  ]
2707
2903
  })]
@@ -2709,8 +2905,8 @@ var Li = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
2709
2905
  ]
2710
2906
  });
2711
2907
  });
2712
- Li.displayName = "ChatbotEnhanced";
2713
- function Ri({ isUser: e, url: t, fallback: n }) {
2908
+ Ji.displayName = "ChatbotEnhanced";
2909
+ function Yi({ isUser: e, url: t, fallback: n }) {
2714
2910
  return /* @__PURE__ */ Q("div", {
2715
2911
  className: q("mt-0.5 flex size-7 shrink-0 items-center justify-center overflow-hidden rounded-full text-[11px] font-medium", e ? "bg-secondary text-secondary-foreground" : "bg-primary/10 text-primary"),
2716
2912
  "aria-hidden": "true",
@@ -2718,24 +2914,24 @@ function Ri({ isUser: e, url: t, fallback: n }) {
2718
2914
  src: t,
2719
2915
  alt: "",
2720
2916
  className: "size-full object-cover"
2721
- }) : e ? n?.trim()?.charAt(0)?.toUpperCase() || "U" : /* @__PURE__ */ Q(Ne, { className: "size-4" })
2917
+ }) : e ? n?.trim()?.charAt(0)?.toUpperCase() || "U" : /* @__PURE__ */ Q(Me, { className: "size-4" })
2722
2918
  });
2723
2919
  }
2724
- function zi({ showAvatar: e, assistantAvatarUrl: t, assistantAvatarFallback: n, waitingLabel: r, stalledLabel: i, offlineLabel: a }) {
2725
- return /* @__PURE__ */ Q(Un, {
2920
+ function Xi({ showAvatar: e, assistantAvatarUrl: t, assistantAvatarFallback: n, waitingLabel: r, stalledLabel: i, offlineLabel: a }) {
2921
+ return /* @__PURE__ */ Q(Xn, {
2726
2922
  from: "assistant",
2727
2923
  "aria-live": "polite",
2728
2924
  children: /* @__PURE__ */ $("div", {
2729
2925
  className: q("flex w-full gap-2.5", e ? "flex-row items-start" : "flex-col"),
2730
- children: [e ? /* @__PURE__ */ Q(Ri, {
2926
+ children: [e ? /* @__PURE__ */ Q(Yi, {
2731
2927
  isUser: !1,
2732
2928
  url: t,
2733
2929
  fallback: n
2734
- }) : null, /* @__PURE__ */ Q(Wn, {
2930
+ }) : null, /* @__PURE__ */ Q(Zn, {
2735
2931
  className: "rounded-lg border bg-muted/30 px-3 py-2 text-muted-foreground",
2736
2932
  children: /* @__PURE__ */ $("span", {
2737
2933
  className: "inline-flex items-center gap-2",
2738
- children: [/* @__PURE__ */ Q(Bi, {}), /* @__PURE__ */ Q(Gi, {
2934
+ children: [/* @__PURE__ */ Q(Zi, {}), /* @__PURE__ */ Q(na, {
2739
2935
  active: !0,
2740
2936
  pending: !0,
2741
2937
  activityKey: 0,
@@ -2748,7 +2944,7 @@ function zi({ showAvatar: e, assistantAvatarUrl: t, assistantAvatarFallback: n,
2748
2944
  })
2749
2945
  });
2750
2946
  }
2751
- function Bi() {
2947
+ function Zi() {
2752
2948
  return /* @__PURE__ */ $(Z, { children: [/* @__PURE__ */ Q("span", {
2753
2949
  className: "sr-only",
2754
2950
  children: "Assistant is responding"
@@ -2762,12 +2958,12 @@ function Bi() {
2762
2958
  ]
2763
2959
  })] });
2764
2960
  }
2765
- function Vi(e) {
2961
+ function Qi(e) {
2766
2962
  let t = Math.floor(e / 60), n = e % 60;
2767
2963
  return `${t}:${String(n).padStart(2, "0")}`;
2768
2964
  }
2769
- var Hi = 6;
2770
- function Ui(t, n) {
2965
+ var $i = 6;
2966
+ function ea(t, n) {
2771
2967
  let r = e.useRef(0), i = e.useRef(0), [a, o] = e.useState({
2772
2968
  elapsed: 0,
2773
2969
  quiet: 0
@@ -2796,10 +2992,10 @@ function Ui(t, n) {
2796
2992
  }, [t]), {
2797
2993
  elapsedSeconds: a.elapsed,
2798
2994
  quietSeconds: a.quiet,
2799
- live: a.quiet < Hi
2995
+ live: a.quiet < $i
2800
2996
  };
2801
2997
  }
2802
- function Wi() {
2998
+ function ta() {
2803
2999
  let [t, n] = e.useState(() => typeof navigator < "u" && navigator.onLine === !1);
2804
3000
  return e.useEffect(() => {
2805
3001
  if (typeof window > "u") return;
@@ -2809,15 +3005,15 @@ function Wi() {
2809
3005
  };
2810
3006
  }, []), t;
2811
3007
  }
2812
- function Gi({ active: e, activityKey: t, pending: n = !1, waitingLabel: r, stalledLabel: i = "Still working…", offlineLabel: a = "Connection lost — reconnecting…" }) {
2813
- let { elapsedSeconds: o, quietSeconds: s, live: c } = Ui(e, t), l = Wi() ? "offline" : c ? n ? "waiting" : "receiving" : "stalled", u = Vi(o);
3008
+ function na({ active: e, activityKey: t, pending: n = !1, waitingLabel: r, stalledLabel: i = "Still working…", offlineLabel: a = "Connection lost — reconnecting…" }) {
3009
+ let { elapsedSeconds: o, quietSeconds: s, live: c } = ea(e, t), l = ta() ? "offline" : c ? n ? "waiting" : "receiving" : "stalled", u = Qi(o);
2814
3010
  return /* @__PURE__ */ $("span", {
2815
3011
  className: q("inline-flex items-center gap-1.5 text-xs tabular-nums", l === "offline" ? "text-red-600 font-medium" : l === "stalled" ? "text-amber-600 font-medium" : "font-normal text-muted-foreground"),
2816
3012
  "aria-live": "polite",
2817
3013
  "data-liveness-tier": l,
2818
3014
  title: l === "offline" ? `${a} · ${u} elapsed` : l === "receiving" ? `Receiving from server · ${u} elapsed` : l === "stalled" ? `${i} (${s}s with no response) · ${u} elapsed` : `${r} · ${u} elapsed`,
2819
3015
  children: [
2820
- l === "offline" ? /* @__PURE__ */ Q(mt, {
3016
+ l === "offline" ? /* @__PURE__ */ Q(gt, {
2821
3017
  className: "size-3 shrink-0",
2822
3018
  "aria-hidden": !0
2823
3019
  }) : /* @__PURE__ */ Q("span", {
@@ -2833,8 +3029,61 @@ function Gi({ active: e, activityKey: t, pending: n = !1, waitingLabel: r, stall
2833
3029
  ]
2834
3030
  });
2835
3031
  }
2836
- function Ki({ offlineLabel: t }) {
2837
- let [n, r] = e.useState(0), i = Wi();
3032
+ var ra = [
3033
+ "Mapping out the data you’ll track…",
3034
+ "Shaping objects and their fields…",
3035
+ "Connecting related records…",
3036
+ "Setting up relationships and lookups…",
3037
+ "Planning the screens and views…",
3038
+ "Laying out forms and lists…",
3039
+ "Adding sensible defaults and validations…",
3040
+ "Sketching a dashboard to track it…",
3041
+ "Double-checking the structure hangs together…",
3042
+ "Pulling the plan together…"
3043
+ ], ia = 3500;
3044
+ function aa(e, t, n = ia) {
3045
+ if (t <= 0) return -1;
3046
+ if (t === 1) return 0;
3047
+ let r = Math.floor((Number.isFinite(e) && e > 0 ? e : 0) / (n > 0 ? n : ia));
3048
+ return Math.min(r, t - 1);
3049
+ }
3050
+ function oa({ label: t, hints: n, offlineLabel: r }) {
3051
+ let [i, a] = e.useState(0);
3052
+ e.useEffect(() => {
3053
+ if (n.length <= 1) return;
3054
+ let e = Date.now(), t = setInterval(() => a(Date.now() - e), ia);
3055
+ return () => clearInterval(t);
3056
+ }, [n.length]);
3057
+ let o = aa(i, n.length), s = o >= 0 ? n[o] : void 0, c = n.length > 1 && n.length <= 12;
3058
+ return /* @__PURE__ */ $("span", {
3059
+ className: "inline-flex min-w-0 items-center gap-1.5 text-xs text-muted-foreground",
3060
+ "data-testid": "build-proposal-progress",
3061
+ "aria-live": "polite",
3062
+ children: [
3063
+ /* @__PURE__ */ Q(ft, {
3064
+ className: "size-3 shrink-0 animate-pulse text-primary",
3065
+ "aria-hidden": !0
3066
+ }),
3067
+ /* @__PURE__ */ Q("span", {
3068
+ className: "font-medium text-foreground/80",
3069
+ children: t
3070
+ }),
3071
+ s ? /* @__PURE__ */ Q("span", {
3072
+ className: "truncate animate-in fade-in duration-500",
3073
+ children: s
3074
+ }, s) : null,
3075
+ c ? /* @__PURE__ */ Q("span", {
3076
+ className: "hidden shrink-0 items-center gap-0.5 sm:inline-flex",
3077
+ "data-testid": "build-proposal-progress-dots",
3078
+ "aria-hidden": !0,
3079
+ children: n.map((e, t) => /* @__PURE__ */ Q("span", { className: q("size-1 rounded-full transition-colors", t <= o ? "bg-primary/70" : "bg-muted-foreground/25") }, t))
3080
+ }) : null,
3081
+ /* @__PURE__ */ Q(sa, { offlineLabel: r })
3082
+ ]
3083
+ });
3084
+ }
3085
+ function sa({ offlineLabel: t }) {
3086
+ let [n, r] = e.useState(0), i = ta();
2838
3087
  return e.useEffect(() => {
2839
3088
  let e = Date.now(), t = setInterval(() => r(Math.floor((Date.now() - e) / 1e3)), 1e3);
2840
3089
  return () => clearInterval(t);
@@ -2843,35 +3092,99 @@ function Ki({ offlineLabel: t }) {
2843
3092
  "aria-live": "polite",
2844
3093
  "data-tool-running-timer": !0,
2845
3094
  children: [
2846
- Q(i ? mt : Ue, {
3095
+ Q(i ? gt : Ue, {
2847
3096
  className: "size-3 shrink-0",
2848
3097
  "aria-hidden": !0
2849
3098
  }),
2850
- /* @__PURE__ */ Q("span", { children: Vi(n) }),
3099
+ /* @__PURE__ */ Q("span", { children: Qi(n) }),
2851
3100
  i ? /* @__PURE__ */ $("span", { children: ["· ", t] }) : null
2852
3101
  ]
2853
3102
  });
2854
3103
  }
2855
- var qi = [
3104
+ var ca = [
2856
3105
  "object",
2857
3106
  "view",
2858
3107
  "dashboard",
2859
3108
  "app",
2860
3109
  "seed"
2861
- ], Ji = {
3110
+ ], la = {
2862
3111
  object: "Objects",
2863
3112
  view: "Views",
2864
3113
  dashboard: "Dashboards",
2865
3114
  app: "App",
2866
3115
  seed: "Sample data"
2867
3116
  };
2868
- function Yi({ progress: e, onOpenBuiltApp: t, openBuiltAppLabel: n = "Open app", onPreviewDraftApp: r, previewDraftLabel: i = "Preview", waitingLabel: a = "Waiting for server…", stalledLabel: o = "Still working…", offlineLabel: s = "Connection lost — reconnecting…" }) {
3117
+ function ua({ progress: e, designingLabel: t = "Designing your app…", extendLabel: n = "Adding to existing app", waitingLabel: r = "Waiting for server…", stalledLabel: i = "Still working…", offlineLabel: a = "Connection lost — reconnecting…" }) {
3118
+ let { phase: o, summary: s, appLabel: c, targetApp: l, objects: u, counts: d, seq: f } = e, p = o === "done", m = f ?? `${o}:${u.length}`, h = p && (s || c) || t, g = [];
3119
+ return d?.objects && g.push(`${d.objects} object${d.objects === 1 ? "" : "s"}`), d?.views && g.push(`${d.views} view${d.views === 1 ? "" : "s"}`), d?.dashboards && g.push(`${d.dashboards} dashboard${d.dashboards === 1 ? "" : "s"}`), /* @__PURE__ */ $("div", {
3120
+ className: "rounded-lg border bg-muted/30 p-3 text-sm",
3121
+ "data-testid": "blueprint-progress",
3122
+ children: [
3123
+ /* @__PURE__ */ $("div", {
3124
+ className: "mb-2 flex items-center gap-2 font-medium",
3125
+ children: [
3126
+ p ? /* @__PURE__ */ Q(Y, { className: "size-4 shrink-0 text-emerald-600" }) : /* @__PURE__ */ Q(tt, { className: "size-4 shrink-0 animate-spin text-primary" }),
3127
+ /* @__PURE__ */ Q("span", {
3128
+ className: "min-w-0 truncate",
3129
+ children: h
3130
+ }),
3131
+ l ? /* @__PURE__ */ $("span", {
3132
+ className: "inline-flex shrink-0 items-center gap-1 rounded-md border border-blue-200 bg-blue-50 px-1.5 py-0.5 text-[10px] font-medium text-blue-700 dark:border-blue-900/50 dark:bg-blue-950/30 dark:text-blue-300",
3133
+ "data-testid": "blueprint-progress-extend",
3134
+ children: [
3135
+ "+ ",
3136
+ n,
3137
+ " 「",
3138
+ l,
3139
+ "」"
3140
+ ]
3141
+ }) : null,
3142
+ p ? null : /* @__PURE__ */ Q("span", {
3143
+ className: "ml-auto shrink-0",
3144
+ children: /* @__PURE__ */ Q(na, {
3145
+ active: !0,
3146
+ activityKey: m,
3147
+ waitingLabel: r,
3148
+ stalledLabel: i,
3149
+ offlineLabel: a
3150
+ })
3151
+ })
3152
+ ]
3153
+ }),
3154
+ !p && (s || c) ? /* @__PURE__ */ Q("p", {
3155
+ className: "mb-2 text-xs text-muted-foreground",
3156
+ children: s || c
3157
+ }) : null,
3158
+ u.length > 0 ? /* @__PURE__ */ Q("div", {
3159
+ className: "flex flex-wrap gap-1.5",
3160
+ "data-testid": "blueprint-progress-objects",
3161
+ children: u.map((e) => /* @__PURE__ */ $("span", {
3162
+ className: "inline-flex animate-in fade-in items-center gap-1 rounded-md border bg-background px-1.5 py-0.5 text-[11px] text-foreground/80 duration-500",
3163
+ title: e.name,
3164
+ children: [
3165
+ /* @__PURE__ */ Q(mt, { className: "size-3 text-foreground/40" }),
3166
+ e.label || e.name,
3167
+ e.fields ? /* @__PURE__ */ $("span", {
3168
+ className: "text-foreground/40",
3169
+ children: ["· ", e.fields]
3170
+ }) : null
3171
+ ]
3172
+ }, e.name))
3173
+ }) : null,
3174
+ g.length > 0 ? /* @__PURE__ */ Q("span", {
3175
+ className: "mt-2 block text-[11px] text-muted-foreground",
3176
+ children: g.join(" · ")
3177
+ }) : null
3178
+ ]
3179
+ });
3180
+ }
3181
+ function da({ progress: e, onOpenBuiltApp: t, openBuiltAppLabel: n = "Open app", onPreviewDraftApp: r, previewDraftLabel: i = "Preview", waitingLabel: a = "Waiting for server…", stalledLabel: o = "Still working…", offlineLabel: s = "Connection lost — reconnecting…" }) {
2869
3182
  let { phase: c, appLabel: l, items: u, done: d, total: f, seq: p } = e, m = c === "done", h = p ?? `${c}:${d}:${u.length}`, g = u.find((e) => e.type === "app"), _ = f > 0 ? Math.min(100, Math.round(d / f * 100)) : m ? 100 : 6, v = /* @__PURE__ */ new Map();
2870
3183
  for (let e of u) {
2871
3184
  let t = v.get(e.type) ?? [];
2872
3185
  t.push(e.name.replace(/_sample$/, "")), v.set(e.type, t);
2873
3186
  }
2874
- let y = [...qi.filter((e) => v.has(e)), ...[...v.keys()].filter((e) => !qi.includes(e))];
3187
+ let y = [...ca.filter((e) => v.has(e)), ...[...v.keys()].filter((e) => !ca.includes(e))];
2875
3188
  return /* @__PURE__ */ $("div", {
2876
3189
  className: "rounded-lg border bg-muted/30 p-3 text-sm",
2877
3190
  "data-testid": "build-progress",
@@ -2879,7 +3192,7 @@ function Yi({ progress: e, onOpenBuiltApp: t, openBuiltAppLabel: n = "Open app",
2879
3192
  /* @__PURE__ */ $("div", {
2880
3193
  className: "mb-2 flex items-center gap-2 font-medium",
2881
3194
  children: [
2882
- m ? /* @__PURE__ */ Q(J, { className: "size-4 shrink-0 text-emerald-600" }) : /* @__PURE__ */ Q(et, { className: "size-4 shrink-0 animate-spin text-primary" }),
3195
+ m ? /* @__PURE__ */ Q(Y, { className: "size-4 shrink-0 text-emerald-600" }) : /* @__PURE__ */ Q(tt, { className: "size-4 shrink-0 animate-spin text-primary" }),
2883
3196
  /* @__PURE__ */ Q("span", { children: m ? `Built ${l ?? "your app"}` : `Building ${l ?? "your app"}…` }),
2884
3197
  !m && c === "data" ? /* @__PURE__ */ Q("span", {
2885
3198
  className: "text-xs font-normal text-muted-foreground",
@@ -2887,7 +3200,7 @@ function Yi({ progress: e, onOpenBuiltApp: t, openBuiltAppLabel: n = "Open app",
2887
3200
  }) : null,
2888
3201
  m ? null : /* @__PURE__ */ Q("span", {
2889
3202
  className: "ml-auto",
2890
- children: /* @__PURE__ */ Q(Gi, {
3203
+ children: /* @__PURE__ */ Q(na, {
2891
3204
  active: !0,
2892
3205
  activityKey: h,
2893
3206
  waitingLabel: a,
@@ -2910,12 +3223,12 @@ function Yi({ progress: e, onOpenBuiltApp: t, openBuiltAppLabel: n = "Open app",
2910
3223
  let t = v.get(e);
2911
3224
  return /* @__PURE__ */ $("li", {
2912
3225
  className: "flex items-start gap-2",
2913
- children: [/* @__PURE__ */ Q(J, { className: "mt-0.5 size-3.5 shrink-0 text-emerald-600" }), /* @__PURE__ */ $("span", {
3226
+ children: [/* @__PURE__ */ Q(Y, { className: "mt-0.5 size-3.5 shrink-0 text-emerald-600" }), /* @__PURE__ */ $("span", {
2914
3227
  className: "min-w-0 text-muted-foreground",
2915
3228
  children: [
2916
3229
  /* @__PURE__ */ Q("span", {
2917
3230
  className: "font-medium text-foreground",
2918
- children: Ji[e] ?? e
3231
+ children: la[e] ?? e
2919
3232
  }),
2920
3233
  " ",
2921
3234
  t.slice(0, 6).join(", "),
@@ -2932,7 +3245,7 @@ function Yi({ progress: e, onOpenBuiltApp: t, openBuiltAppLabel: n = "Open app",
2932
3245
  onClick: () => t(g.name),
2933
3246
  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",
2934
3247
  "data-testid": "build-progress-open-app",
2935
- children: [n, /* @__PURE__ */ Q(je, { className: "size-3.5" })]
3248
+ children: [n, /* @__PURE__ */ Q(Ae, { className: "size-3.5" })]
2936
3249
  }) : null, r ? /* @__PURE__ */ $("button", {
2937
3250
  type: "button",
2938
3251
  onClick: () => r(g.name),
@@ -2944,7 +3257,7 @@ function Yi({ progress: e, onOpenBuiltApp: t, openBuiltAppLabel: n = "Open app",
2944
3257
  ]
2945
3258
  });
2946
3259
  }
2947
- function Xi({ groups: e, labels: t }) {
3260
+ function fa({ groups: e, labels: t }) {
2948
3261
  return e.length === 0 ? null : /* @__PURE__ */ Q("div", {
2949
3262
  className: "not-prose mb-2 border-l border-border/70 pl-3",
2950
3263
  children: /* @__PURE__ */ Q("div", {
@@ -2954,7 +3267,7 @@ function Xi({ groups: e, labels: t }) {
2954
3267
  children: [/* @__PURE__ */ $("div", {
2955
3268
  className: "flex min-w-0 items-center gap-2",
2956
3269
  children: [
2957
- /* @__PURE__ */ Q(Zi, { state: e.state }),
3270
+ /* @__PURE__ */ Q(pa, { state: e.state }),
2958
3271
  /* @__PURE__ */ Q("span", {
2959
3272
  className: "truncate font-medium text-foreground",
2960
3273
  children: e.title
@@ -2964,18 +3277,22 @@ function Xi({ groups: e, labels: t }) {
2964
3277
  children: ["x", e.count]
2965
3278
  }) : null
2966
3279
  ]
2967
- }), e.state === "running" ? /* @__PURE__ */ Q(Ki, { offlineLabel: t.connectionOfflineLabel }) : /* @__PURE__ */ Q("span", {
3280
+ }), e.state === "running" ? e.rawName === "propose_blueprint" ? /* @__PURE__ */ Q(oa, {
3281
+ label: t.designingPlanLabel,
3282
+ hints: t.designingPlanHints,
3283
+ offlineLabel: t.connectionOfflineLabel
3284
+ }) : /* @__PURE__ */ Q(sa, { offlineLabel: t.connectionOfflineLabel }) : /* @__PURE__ */ Q("span", {
2968
3285
  className: q("shrink-0 text-[10px] font-medium", e.state === "failed" ? "text-destructive" : e.state === "completed" ? "text-emerald-700 dark:text-emerald-400" : "text-muted-foreground"),
2969
- children: Qi(e.state, t)
3286
+ children: ma(e.state, t)
2970
3287
  })]
2971
3288
  }, e.key))
2972
3289
  })
2973
3290
  });
2974
3291
  }
2975
- function Zi({ state: e }) {
2976
- return e === "failed" ? /* @__PURE__ */ Q(X, { className: "size-3.5 shrink-0 text-destructive" }) : e === "completed" ? /* @__PURE__ */ Q(J, { className: "size-3.5 shrink-0 text-emerald-600" }) : /* @__PURE__ */ Q(Ue, { className: "size-3.5 shrink-0 text-muted-foreground" });
3292
+ function pa({ state: e }) {
3293
+ 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" });
2977
3294
  }
2978
- function Qi(e, t) {
3295
+ function ma(e, t) {
2979
3296
  switch (e) {
2980
3297
  case "failed": return t.toolFailed;
2981
3298
  case "awaiting": return t.toolAwaitingApproval;
@@ -2983,8 +3300,30 @@ function Qi(e, t) {
2983
3300
  case "completed": return t.toolCompleted;
2984
3301
  }
2985
3302
  }
2986
- function $i({ error: t, onReload: n, onUpgrade: r }) {
2987
- let i = e.useMemo(() => Fn(t), [t]), { summary: a, details: o } = e.useMemo(() => Nn(t), [t]), [s, c] = e.useState(!1);
3303
+ function ha({ error: t, rateLimitedLabel: n, genericLabel: r }) {
3304
+ let i = e.useMemo(() => Hn(t) ? n : r, [
3305
+ t,
3306
+ n,
3307
+ r
3308
+ ]);
3309
+ return /* @__PURE__ */ Q("div", {
3310
+ className: "border-t bg-background px-3 py-2 text-sm",
3311
+ role: "alert",
3312
+ "data-testid": "chat-send-error",
3313
+ children: /* @__PURE__ */ Q("div", {
3314
+ className: "rounded-md border border-amber-300/40 bg-amber-50/60 px-3 py-2 text-foreground dark:bg-amber-950/20",
3315
+ children: /* @__PURE__ */ $("div", {
3316
+ className: "flex items-start gap-2",
3317
+ children: [/* @__PURE__ */ Q(ht, { className: "mt-0.5 h-4 w-4 shrink-0 text-amber-600" }), /* @__PURE__ */ Q("div", {
3318
+ className: "min-w-0 flex-1 break-words leading-snug",
3319
+ children: i
3320
+ })]
3321
+ })
3322
+ })
3323
+ });
3324
+ }
3325
+ function ga({ error: t, onReload: n, onUpgrade: r }) {
3326
+ let i = e.useMemo(() => zn(t), [t]), { summary: a, details: o } = e.useMemo(() => Ln(t), [t]), [s, c] = e.useState(!1);
2988
3327
  if (i) {
2989
3328
  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";
2990
3329
  return /* @__PURE__ */ Q("div", {
@@ -3044,7 +3383,7 @@ function $i({ error: t, onReload: n, onUpgrade: r }) {
3044
3383
  type: "button",
3045
3384
  onClick: n,
3046
3385
  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",
3047
- children: [/* @__PURE__ */ Q(st, { className: "mr-1 h-3 w-3" }), "Retry"]
3386
+ children: [/* @__PURE__ */ Q(ct, { className: "mr-1 h-3 w-3" }), "Retry"]
3048
3387
  }) : null]
3049
3388
  })
3050
3389
  ]
@@ -3055,27 +3394,27 @@ function $i({ error: t, onReload: n, onUpgrade: r }) {
3055
3394
  })
3056
3395
  });
3057
3396
  }
3058
- function ea({ output: e, errorText: t }) {
3059
- return t ? /* @__PURE__ */ Q(mi, {
3397
+ function _a({ output: e, errorText: t }) {
3398
+ return t ? /* @__PURE__ */ Q(xi, {
3060
3399
  output: void 0,
3061
3400
  errorText: t
3062
- }) : e == null || e === "" ? null : typeof e == "string" && !Ai(e) ? /* @__PURE__ */ $("div", {
3401
+ }) : e == null || e === "" ? null : typeof e == "string" && !Li(e) ? /* @__PURE__ */ $("div", {
3063
3402
  className: "space-y-2 p-4",
3064
3403
  children: [/* @__PURE__ */ Q("h4", {
3065
3404
  className: "font-medium text-muted-foreground text-xs uppercase tracking-wide",
3066
3405
  children: "Result"
3067
3406
  }), /* @__PURE__ */ Q("div", {
3068
3407
  className: "overflow-x-auto rounded-md bg-muted/40 px-3 py-2 text-sm text-foreground",
3069
- children: /* @__PURE__ */ Q(tr, { children: e })
3408
+ children: /* @__PURE__ */ Q(cr, { children: e })
3070
3409
  })]
3071
- }) : /* @__PURE__ */ Q(mi, {
3410
+ }) : /* @__PURE__ */ Q(xi, {
3072
3411
  output: e,
3073
3412
  errorText: void 0
3074
3413
  });
3075
3414
  }
3076
3415
  //#endregion
3077
3416
  //#region src/FloatingChatbot.tsx
3078
- function ta({ floatingConfig: t, headerExtra: n, headerActions: r, ...i }) {
3417
+ function va({ floatingConfig: t, headerExtra: n, headerActions: r, ...i }) {
3079
3418
  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);
3080
3419
  e.useEffect(() => {
3081
3420
  let e = document.getElementById("floating-chatbot-portal");
@@ -3083,29 +3422,29 @@ function ta({ floatingConfig: t, headerExtra: n, headerActions: r, ...i }) {
3083
3422
  e && e.parentNode && !e.hasChildNodes() && e.parentNode.removeChild(e);
3084
3423
  };
3085
3424
  }, []);
3086
- let p = /* @__PURE__ */ $(_n, {
3425
+ let p = /* @__PURE__ */ $(xn, {
3087
3426
  defaultOpen: o,
3088
- children: [/* @__PURE__ */ Q(Cn, {
3427
+ children: [/* @__PURE__ */ Q(Dn, {
3089
3428
  position: a,
3090
3429
  size: u
3091
- }), /* @__PURE__ */ Q(kn, {
3430
+ }), /* @__PURE__ */ Q(Nn, {
3092
3431
  title: l,
3093
3432
  position: a,
3094
3433
  width: s,
3095
3434
  height: c,
3096
3435
  headerExtra: n,
3097
3436
  headerActions: r,
3098
- children: /* @__PURE__ */ Q(Li, {
3437
+ children: /* @__PURE__ */ Q(Ji, {
3099
3438
  ...i,
3100
3439
  maxHeight: "100%",
3101
3440
  className: "h-full border-0 rounded-none"
3102
3441
  })
3103
3442
  })]
3104
3443
  });
3105
- return d ? xt.createPortal(p, d) : p;
3444
+ return d ? Ct.createPortal(p, d) : p;
3106
3445
  }
3107
- Nt.register("chatbot", ({ schema: e, className: t, ...n }) => {
3108
- let { messages: r, isLoading: i, sendMessage: a } = tn({
3446
+ Ft.register("chatbot", ({ schema: e, className: t, ...n }) => {
3447
+ let { messages: r, isLoading: i, sendMessage: a } = on({
3109
3448
  api: e.api,
3110
3449
  initialMessages: e.messages,
3111
3450
  conversationId: e.conversationId,
@@ -3122,7 +3461,7 @@ Nt.register("chatbot", ({ schema: e, className: t, ...n }) => {
3122
3461
  autoResponseDelay: e.autoResponseDelay,
3123
3462
  onSend: e.onSend
3124
3463
  });
3125
- return /* @__PURE__ */ Q(Sa, {
3464
+ return /* @__PURE__ */ Q(za, {
3126
3465
  messages: r,
3127
3466
  placeholder: e.placeholder,
3128
3467
  onSendMessage: (e) => {
@@ -3270,8 +3609,8 @@ Nt.register("chatbot", ({ schema: e, className: t, ...n }) => {
3270
3609
  autoResponseDelay: 1e3,
3271
3610
  className: "w-full max-w-2xl"
3272
3611
  }
3273
- }), Nt.register("chatbot-enhanced", ({ schema: e, className: t, ...n }) => {
3274
- let { messages: r, isLoading: i, error: a, sendMessage: o, stop: s, reload: c, clear: l, isApiMode: u } = tn({
3612
+ }), Ft.register("chatbot-enhanced", ({ schema: e, className: t, ...n }) => {
3613
+ let { messages: r, isLoading: i, error: a, sendMessage: o, stop: s, reload: c, clear: l, isApiMode: u } = on({
3275
3614
  api: e.api,
3276
3615
  initialMessages: e.messages,
3277
3616
  conversationId: e.conversationId,
@@ -3288,7 +3627,7 @@ Nt.register("chatbot", ({ schema: e, className: t, ...n }) => {
3288
3627
  autoResponseDelay: e.autoResponseDelay,
3289
3628
  onSend: e.onSend
3290
3629
  });
3291
- return /* @__PURE__ */ Q(Li, {
3630
+ return /* @__PURE__ */ Q(Ji, {
3292
3631
  messages: r,
3293
3632
  placeholder: e.placeholder,
3294
3633
  onSendMessage: (e, t) => {
@@ -3457,8 +3796,8 @@ Nt.register("chatbot", ({ schema: e, className: t, ...n }) => {
3457
3796
  autoResponseDelay: 1e3,
3458
3797
  className: "w-full max-w-2xl"
3459
3798
  }
3460
- }), Nt.register("chatbot-floating", ({ schema: e, className: t, ...n }) => {
3461
- let { messages: r, isLoading: i, error: a, sendMessage: o, stop: s, reload: c, clear: l, isApiMode: u } = tn({
3799
+ }), Ft.register("chatbot-floating", ({ schema: e, className: t, ...n }) => {
3800
+ let { messages: r, isLoading: i, error: a, sendMessage: o, stop: s, reload: c, clear: l, isApiMode: u } = on({
3462
3801
  api: e.api,
3463
3802
  initialMessages: e.messages,
3464
3803
  conversationId: e.conversationId,
@@ -3475,7 +3814,7 @@ Nt.register("chatbot", ({ schema: e, className: t, ...n }) => {
3475
3814
  autoResponseDelay: e.autoResponseDelay,
3476
3815
  onSend: e.onSend
3477
3816
  });
3478
- return /* @__PURE__ */ Q(ta, {
3817
+ return /* @__PURE__ */ Q(va, {
3479
3818
  floatingConfig: e.floatingConfig,
3480
3819
  messages: r,
3481
3820
  placeholder: e.placeholder,
@@ -3647,7 +3986,7 @@ Nt.register("chatbot", ({ schema: e, className: t, ...n }) => {
3647
3986
  });
3648
3987
  //#endregion
3649
3988
  //#region src/elements/loader.tsx
3650
- var na = ({ size: e = 16 }) => /* @__PURE__ */ $("svg", {
3989
+ var ya = ({ size: e = 16 }) => /* @__PURE__ */ $("svg", {
3651
3990
  height: e,
3652
3991
  strokeLinejoin: "round",
3653
3992
  style: { color: "currentcolor" },
@@ -3728,97 +4067,97 @@ var na = ({ size: e = 16 }) => /* @__PURE__ */ $("svg", {
3728
4067
  })
3729
4068
  }) })
3730
4069
  ]
3731
- }), ra = ({ className: e, size: t = 16, ...n }) => /* @__PURE__ */ Q("div", {
4070
+ }), ba = ({ className: e, size: t = 16, ...n }) => /* @__PURE__ */ Q("div", {
3732
4071
  className: q("inline-flex animate-spin items-center justify-center", e),
3733
4072
  ...n,
3734
- children: /* @__PURE__ */ Q(na, { size: t })
3735
- }), ia = /* @__PURE__ */ Ft({
3736
- CodeBlock: () => si,
3737
- CodeBlockCopyButton: () => ci,
3738
- Conversation: () => In,
3739
- ConversationContent: () => Ln,
3740
- ConversationEmptyState: () => Rn,
3741
- ConversationScrollButton: () => zn,
3742
- Loader: () => ra,
3743
- Message: () => Un,
3744
- MessageAction: () => Kn,
3745
- MessageActions: () => Gn,
3746
- MessageAttachment: () => nr,
3747
- MessageAttachments: () => rr,
3748
- MessageBranch: () => Yn,
3749
- MessageBranchContent: () => Xn,
3750
- MessageBranchNext: () => $n,
3751
- MessageBranchPage: () => er,
3752
- MessageBranchPrevious: () => Qn,
3753
- MessageBranchSelector: () => Zn,
3754
- MessageContent: () => Wn,
3755
- MessageResponse: () => tr,
3756
- MessageToolbar: () => ir,
3757
- PromptInput: () => Cr,
3758
- PromptInputActionAddAttachments: () => Sr,
3759
- PromptInputActionMenu: () => Ar,
3760
- PromptInputActionMenuContent: () => Mr,
3761
- PromptInputActionMenuItem: () => Nr,
3762
- PromptInputActionMenuTrigger: () => jr,
3763
- PromptInputAttachment: () => br,
3764
- PromptInputAttachments: () => xr,
3765
- PromptInputBody: () => wr,
3766
- PromptInputButton: () => kr,
3767
- PromptInputCommand: () => Yr,
3768
- PromptInputCommandEmpty: () => Qr,
3769
- PromptInputCommandGroup: () => $r,
3770
- PromptInputCommandInput: () => Xr,
3771
- PromptInputCommandItem: () => ei,
3772
- PromptInputCommandList: () => Zr,
3773
- PromptInputCommandSeparator: () => ti,
3774
- PromptInputFooter: () => Dr,
3775
- PromptInputHeader: () => Er,
3776
- PromptInputHoverCard: () => Vr,
3777
- PromptInputHoverCardContent: () => Ur,
3778
- PromptInputHoverCardTrigger: () => Hr,
3779
- PromptInputProvider: () => _r,
3780
- PromptInputSelect: () => Ir,
3781
- PromptInputSelectContent: () => Rr,
3782
- PromptInputSelectItem: () => zr,
3783
- PromptInputSelectTrigger: () => Lr,
3784
- PromptInputSelectValue: () => Br,
3785
- PromptInputSpeechButton: () => Fr,
3786
- PromptInputSubmit: () => Pr,
3787
- PromptInputTab: () => Gr,
3788
- PromptInputTabBody: () => qr,
3789
- PromptInputTabItem: () => Jr,
3790
- PromptInputTabLabel: () => Kr,
3791
- PromptInputTabsList: () => Wr,
3792
- PromptInputTextarea: () => Tr,
3793
- PromptInputTools: () => Or,
3794
- Reasoning: () => bi,
3795
- ReasoningContent: () => Ci,
3796
- ReasoningTrigger: () => Si,
3797
- Shimmer: () => hi,
3798
- Source: () => Di,
3799
- Sources: () => wi,
3800
- SourcesContent: () => Ei,
3801
- SourcesTrigger: () => Ti,
3802
- Suggestion: () => ri,
3803
- Suggestions: () => ni,
3804
- Tool: () => li,
3805
- ToolContent: () => fi,
3806
- ToolHeader: () => di,
3807
- ToolInput: () => pi,
3808
- ToolOutput: () => mi,
3809
- highlightCode: () => oi,
3810
- usePromptInputAttachments: () => yr,
3811
- usePromptInputController: () => pr,
3812
- useProviderAttachments: () => hr,
3813
- useReasoning: () => _i
3814
- }), aa = "/api/v1/ai";
3815
- function oa(e, t, n) {
4073
+ children: /* @__PURE__ */ Q(ya, { size: t })
4074
+ }), xa = /* @__PURE__ */ Lt({
4075
+ CodeBlock: () => mi,
4076
+ CodeBlockCopyButton: () => hi,
4077
+ Conversation: () => Un,
4078
+ ConversationContent: () => Wn,
4079
+ ConversationEmptyState: () => Gn,
4080
+ ConversationScrollButton: () => Kn,
4081
+ Loader: () => ba,
4082
+ Message: () => Xn,
4083
+ MessageAction: () => $n,
4084
+ MessageActions: () => Qn,
4085
+ MessageAttachment: () => lr,
4086
+ MessageAttachments: () => ur,
4087
+ MessageBranch: () => nr,
4088
+ MessageBranchContent: () => rr,
4089
+ MessageBranchNext: () => or,
4090
+ MessageBranchPage: () => sr,
4091
+ MessageBranchPrevious: () => ar,
4092
+ MessageBranchSelector: () => ir,
4093
+ MessageContent: () => Zn,
4094
+ MessageResponse: () => cr,
4095
+ MessageToolbar: () => dr,
4096
+ PromptInput: () => Ar,
4097
+ PromptInputActionAddAttachments: () => kr,
4098
+ PromptInputActionMenu: () => Lr,
4099
+ PromptInputActionMenuContent: () => zr,
4100
+ PromptInputActionMenuItem: () => Br,
4101
+ PromptInputActionMenuTrigger: () => Rr,
4102
+ PromptInputAttachment: () => Dr,
4103
+ PromptInputAttachments: () => Or,
4104
+ PromptInputBody: () => jr,
4105
+ PromptInputButton: () => Ir,
4106
+ PromptInputCommand: () => ni,
4107
+ PromptInputCommandEmpty: () => ai,
4108
+ PromptInputCommandGroup: () => oi,
4109
+ PromptInputCommandInput: () => ri,
4110
+ PromptInputCommandItem: () => si,
4111
+ PromptInputCommandList: () => ii,
4112
+ PromptInputCommandSeparator: () => ci,
4113
+ PromptInputFooter: () => Pr,
4114
+ PromptInputHeader: () => Nr,
4115
+ PromptInputHoverCard: () => Jr,
4116
+ PromptInputHoverCardContent: () => Xr,
4117
+ PromptInputHoverCardTrigger: () => Yr,
4118
+ PromptInputProvider: () => wr,
4119
+ PromptInputSelect: () => Ur,
4120
+ PromptInputSelectContent: () => Gr,
4121
+ PromptInputSelectItem: () => Kr,
4122
+ PromptInputSelectTrigger: () => Wr,
4123
+ PromptInputSelectValue: () => qr,
4124
+ PromptInputSpeechButton: () => Hr,
4125
+ PromptInputSubmit: () => Vr,
4126
+ PromptInputTab: () => Qr,
4127
+ PromptInputTabBody: () => ei,
4128
+ PromptInputTabItem: () => ti,
4129
+ PromptInputTabLabel: () => $r,
4130
+ PromptInputTabsList: () => Zr,
4131
+ PromptInputTextarea: () => Mr,
4132
+ PromptInputTools: () => Fr,
4133
+ Reasoning: () => Di,
4134
+ ReasoningContent: () => Ai,
4135
+ ReasoningTrigger: () => ki,
4136
+ Shimmer: () => Si,
4137
+ Source: () => Pi,
4138
+ Sources: () => ji,
4139
+ SourcesContent: () => Ni,
4140
+ SourcesTrigger: () => Mi,
4141
+ Suggestion: () => ui,
4142
+ Suggestions: () => li,
4143
+ Tool: () => gi,
4144
+ ToolContent: () => yi,
4145
+ ToolHeader: () => vi,
4146
+ ToolInput: () => bi,
4147
+ ToolOutput: () => xi,
4148
+ highlightCode: () => pi,
4149
+ usePromptInputAttachments: () => Er,
4150
+ usePromptInputController: () => br,
4151
+ useProviderAttachments: () => Sr,
4152
+ useReasoning: () => wi
4153
+ }), Sa = "/api/v1/ai";
4154
+ function Ca(e, t, n) {
3816
4155
  let r = e.replace(/\/$/, ""), i = new URLSearchParams();
3817
4156
  if (n) for (let [e, t] of Object.entries(n)) t == null || t === "" || i.set(e, String(t));
3818
4157
  let a = i.toString();
3819
4158
  return `${r}${t}${a ? `?${a}` : ""}`;
3820
4159
  }
3821
- async function sa(e, t, n) {
4160
+ async function wa(e, t, n) {
3822
4161
  let r = await fetch(e, {
3823
4162
  credentials: "include",
3824
4163
  ...t,
@@ -3838,8 +4177,8 @@ async function sa(e, t, n) {
3838
4177
  }
3839
4178
  return i;
3840
4179
  }
3841
- function ca(t = {}) {
3842
- let { apiBase: n = aa, 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({
4180
+ function Ta(t = {}) {
4181
+ let { apiBase: n = Sa, status: r = "pending", conversationId: i, limit: a, headers: o, pollInterval: s = 5e3, enabled: c = !0 } = t, [l, u] = e.useState([]), [d, f] = e.useState(0), [p, m] = e.useState(!1), [h, g] = e.useState(void 0), _ = e.useRef({
3843
4182
  apiBase: n,
3844
4183
  status: r,
3845
4184
  conversationId: i,
@@ -3857,7 +4196,7 @@ function ca(t = {}) {
3857
4196
  let { apiBase: e, status: t, conversationId: n, limit: r, headers: i } = _.current;
3858
4197
  m(!0), g(void 0);
3859
4198
  try {
3860
- let a = await sa(oa(e, "/pending-actions", {
4199
+ let a = await wa(Ca(e, "/pending-actions", {
3861
4200
  status: t && t !== "all" ? t : void 0,
3862
4201
  conversationId: n,
3863
4202
  limit: r
@@ -3869,9 +4208,9 @@ function ca(t = {}) {
3869
4208
  m(!1);
3870
4209
  }
3871
4210
  }, []), y = e.useCallback(async (e) => {
3872
- let { apiBase: t, headers: n } = _.current, r = oa(t, `/pending-actions/${encodeURIComponent(e)}/approve`);
4211
+ let { apiBase: t, headers: n } = _.current, r = Ca(t, `/pending-actions/${encodeURIComponent(e)}/approve`);
3873
4212
  try {
3874
- return await sa(r, {
4213
+ return await wa(r, {
3875
4214
  method: "POST",
3876
4215
  body: "{}"
3877
4216
  }, n);
@@ -3879,9 +4218,9 @@ function ca(t = {}) {
3879
4218
  v();
3880
4219
  }
3881
4220
  }, [v]), b = e.useCallback(async (e, t) => {
3882
- let { apiBase: n, headers: r } = _.current, i = oa(n, `/pending-actions/${encodeURIComponent(e)}/reject`);
4221
+ let { apiBase: n, headers: r } = _.current, i = Ca(n, `/pending-actions/${encodeURIComponent(e)}/reject`);
3883
4222
  try {
3884
- return await sa(i, {
4223
+ return await wa(i, {
3885
4224
  method: "POST",
3886
4225
  body: JSON.stringify(t ? { reason: t } : {})
3887
4226
  }, r);
@@ -3915,7 +4254,7 @@ function ca(t = {}) {
3915
4254
  }
3916
4255
  //#endregion
3917
4256
  //#region src/AiPendingActionsInbox.tsx
3918
- var la = {
4257
+ var Ea = {
3919
4258
  pending: {
3920
4259
  variant: "secondary",
3921
4260
  label: "Pending"
@@ -3937,8 +4276,8 @@ var la = {
3937
4276
  label: "Rejected"
3938
4277
  }
3939
4278
  };
3940
- function ua({ status: e }) {
3941
- let t = la[e] ?? {
4279
+ function Da({ status: e }) {
4280
+ let t = Ea[e] ?? {
3942
4281
  variant: "outline",
3943
4282
  label: e
3944
4283
  };
@@ -3947,7 +4286,7 @@ function ua({ status: e }) {
3947
4286
  children: t.label
3948
4287
  });
3949
4288
  }
3950
- function da(e) {
4289
+ function Oa(e) {
3951
4290
  if (!e) return "—";
3952
4291
  let t = Date.parse(e);
3953
4292
  if (Number.isNaN(t)) return e;
@@ -3965,7 +4304,7 @@ function da(e) {
3965
4304
  return e;
3966
4305
  }
3967
4306
  }
3968
- function fa(e) {
4307
+ function ka(e) {
3969
4308
  if (!e) return null;
3970
4309
  try {
3971
4310
  return JSON.parse(e);
@@ -3973,7 +4312,7 @@ function fa(e) {
3973
4312
  return e;
3974
4313
  }
3975
4314
  }
3976
- function pa({ value: e, max: t = 320 }) {
4315
+ function Aa({ value: e, max: t = 320 }) {
3977
4316
  let n = typeof e == "string" ? e : JSON.stringify(e, null, 2);
3978
4317
  return n == null || n === "" ? /* @__PURE__ */ Q("span", {
3979
4318
  className: "text-muted-foreground text-xs",
@@ -3984,24 +4323,24 @@ function pa({ value: e, max: t = 320 }) {
3984
4323
  children: n
3985
4324
  });
3986
4325
  }
3987
- function ma(e) {
4326
+ function ja(e) {
3988
4327
  switch (e) {
3989
4328
  case "pending": return "pending";
3990
4329
  case "all": return "all";
3991
4330
  case "decided": return "all";
3992
4331
  }
3993
4332
  }
3994
- function ha({ 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 }) {
3995
- 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: ee, reject: F } = ca({
4333
+ function Ma({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i, variant: a = "card", title: o = "AI Approvals", description: s = "Actions an AI agent proposed that need a human review before execution.", className: c }) {
4334
+ let [l, u] = e.useState("pending"), [d, m] = e.useState(null), [h, g] = e.useState(null), [_, w] = e.useState(""), [T, E] = e.useState(null), [D, O] = e.useState(null), [k, A] = e.useState(null), { items: j, isLoading: M, error: N, refresh: P, approve: F, reject: I } = Ta({
3996
4335
  apiBase: t,
3997
4336
  headers: n,
3998
4337
  pollInterval: r,
3999
4338
  conversationId: i,
4000
- status: ma(l)
4001
- }), I = 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) => {
4339
+ status: ja(l)
4340
+ }), L = e.useMemo(() => l === "decided" ? j.filter((e) => e.status !== "pending") : j, [j, l]), z = e.useMemo(() => d ? j.find((e) => e.id === d) ?? null : null, [d, j]), ie = e.useCallback(async (e) => {
4002
4341
  E(e), O(null);
4003
4342
  try {
4004
- let t = await ee(e), n = t.status === "executed";
4343
+ let t = await F(e), n = t.status === "executed";
4005
4344
  A({
4006
4345
  id: e,
4007
4346
  kind: "approve",
@@ -4019,10 +4358,10 @@ function ha({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
4019
4358
  } finally {
4020
4359
  E(null);
4021
4360
  }
4022
- }, [ee]), oe = e.useCallback(async (e, t) => {
4361
+ }, [F]), ae = e.useCallback(async (e, t) => {
4023
4362
  E(e), O(null);
4024
4363
  try {
4025
- await F(e, t.trim() || void 0), A({
4364
+ await I(e, t.trim() || void 0), A({
4026
4365
  id: e,
4027
4366
  kind: "reject",
4028
4367
  ok: !0,
@@ -4039,15 +4378,15 @@ function ha({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
4039
4378
  } finally {
4040
4379
  E(null);
4041
4380
  }
4042
- }, [F]), se = /* @__PURE__ */ $("div", {
4381
+ }, [I]), B = /* @__PURE__ */ $("div", {
4043
4382
  className: "space-y-3",
4044
4383
  children: [
4045
4384
  /* @__PURE__ */ $("div", {
4046
4385
  className: "flex items-center justify-between gap-2",
4047
- children: [/* @__PURE__ */ Q(U, {
4386
+ children: [/* @__PURE__ */ Q(Ce, {
4048
4387
  value: l,
4049
4388
  onValueChange: (e) => u(e),
4050
- children: /* @__PURE__ */ $(W, { children: [
4389
+ children: /* @__PURE__ */ $(we, { children: [
4051
4390
  /* @__PURE__ */ Q(G, {
4052
4391
  value: "pending",
4053
4392
  children: "Pending"
@@ -4067,7 +4406,7 @@ function ha({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
4067
4406
  onClick: () => void P(),
4068
4407
  disabled: M,
4069
4408
  "data-testid": "ai-inbox-refresh",
4070
- children: [/* @__PURE__ */ Q(st, { className: `h-3.5 w-3.5 mr-1.5 ${M ? "animate-spin" : ""}` }), "Refresh"]
4409
+ children: [/* @__PURE__ */ Q(ct, { className: `h-3.5 w-3.5 mr-1.5 ${M ? "animate-spin" : ""}` }), "Refresh"]
4071
4410
  })]
4072
4411
  }),
4073
4412
  N ? /* @__PURE__ */ $(f, {
@@ -4080,7 +4419,7 @@ function ha({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
4080
4419
  }) : null,
4081
4420
  k && !D ? /* @__PURE__ */ $(f, {
4082
4421
  variant: k.ok ? "default" : "destructive",
4083
- children: [k.ok ? /* @__PURE__ */ Q(J, { className: "h-4 w-4" }) : /* @__PURE__ */ Q(X, { className: "h-4 w-4" }), /* @__PURE__ */ $(p, { children: [
4422
+ children: [k.ok ? /* @__PURE__ */ Q(Y, { className: "h-4 w-4" }) : /* @__PURE__ */ Q(X, { className: "h-4 w-4" }), /* @__PURE__ */ $(p, { children: [
4084
4423
  k.kind === "approve" ? "Approve" : "Reject",
4085
4424
  " for",
4086
4425
  " ",
@@ -4093,72 +4432,72 @@ function ha({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
4093
4432
  k.message ?? (k.ok ? "OK" : "Failed")
4094
4433
  ] })]
4095
4434
  }) : null,
4096
- M && I.length === 0 ? /* @__PURE__ */ $("div", {
4435
+ M && L.length === 0 ? /* @__PURE__ */ $("div", {
4097
4436
  className: "space-y-2",
4098
4437
  children: [
4099
- /* @__PURE__ */ Q(xe, { className: "h-10 w-full" }),
4100
- /* @__PURE__ */ Q(xe, { className: "h-10 w-full" }),
4101
- /* @__PURE__ */ Q(xe, { className: "h-10 w-full" })
4438
+ /* @__PURE__ */ Q(ye, { className: "h-10 w-full" }),
4439
+ /* @__PURE__ */ Q(ye, { className: "h-10 w-full" }),
4440
+ /* @__PURE__ */ Q(ye, { className: "h-10 w-full" })
4102
4441
  ]
4103
- }) : I.length === 0 ? /* @__PURE__ */ Q(te, { children: /* @__PURE__ */ $(L, { children: [
4104
- /* @__PURE__ */ Q(re, { children: /* @__PURE__ */ Q($e, { className: "h-8 w-8 text-muted-foreground" }) }),
4105
- /* @__PURE__ */ Q(ie, { children: "No actions waiting" }),
4106
- /* @__PURE__ */ Q(ne, { children: "When the AI proposes a sensitive action it will appear here for review." })
4442
+ }) : L.length === 0 ? /* @__PURE__ */ Q(ee, { children: /* @__PURE__ */ $(R, { children: [
4443
+ /* @__PURE__ */ Q(ne, { children: /* @__PURE__ */ Q(et, { className: "h-8 w-8 text-muted-foreground" }) }),
4444
+ /* @__PURE__ */ Q(re, { children: "No actions waiting" }),
4445
+ /* @__PURE__ */ Q(te, { children: "When the AI proposes a sensitive action it will appear here for review." })
4107
4446
  ] }) }) : /* @__PURE__ */ Q("div", {
4108
4447
  className: "rounded-md border",
4109
- children: /* @__PURE__ */ $(B, { children: [/* @__PURE__ */ Q(Ce, { children: /* @__PURE__ */ $(we, { children: [
4110
- /* @__PURE__ */ Q(H, {
4448
+ children: /* @__PURE__ */ $(be, { children: [/* @__PURE__ */ Q(W, { children: /* @__PURE__ */ $(Se, { children: [
4449
+ /* @__PURE__ */ Q(U, {
4111
4450
  className: "w-[140px]",
4112
4451
  children: "Tool"
4113
4452
  }),
4114
- /* @__PURE__ */ Q(H, {
4453
+ /* @__PURE__ */ Q(U, {
4115
4454
  className: "w-[140px]",
4116
4455
  children: "Action"
4117
4456
  }),
4118
- /* @__PURE__ */ Q(H, {
4457
+ /* @__PURE__ */ Q(U, {
4119
4458
  className: "w-[120px]",
4120
4459
  children: "Object"
4121
4460
  }),
4122
- /* @__PURE__ */ Q(H, {
4461
+ /* @__PURE__ */ Q(U, {
4123
4462
  className: "w-[110px]",
4124
4463
  children: "Status"
4125
4464
  }),
4126
- /* @__PURE__ */ Q(H, {
4465
+ /* @__PURE__ */ Q(U, {
4127
4466
  className: "w-[110px]",
4128
4467
  children: "Proposed"
4129
4468
  }),
4130
- /* @__PURE__ */ Q(H, {
4469
+ /* @__PURE__ */ Q(U, {
4131
4470
  className: "w-[260px] text-right",
4132
4471
  children: "Decision"
4133
4472
  })
4134
- ] }) }), /* @__PURE__ */ Q(Se, { children: I.map((e) => {
4473
+ ] }) }), /* @__PURE__ */ Q(xe, { children: L.map((e) => {
4135
4474
  let t = e.status === "pending", n = T === e.id;
4136
- return /* @__PURE__ */ $(we, { children: [
4137
- /* @__PURE__ */ Q(V, {
4475
+ return /* @__PURE__ */ $(Se, { children: [
4476
+ /* @__PURE__ */ Q(H, {
4138
4477
  className: "font-mono text-xs",
4139
4478
  children: e.tool_name
4140
4479
  }),
4141
- /* @__PURE__ */ Q(V, {
4480
+ /* @__PURE__ */ Q(H, {
4142
4481
  className: "text-sm",
4143
4482
  children: e.action_name
4144
4483
  }),
4145
- /* @__PURE__ */ Q(V, {
4484
+ /* @__PURE__ */ Q(H, {
4146
4485
  className: "text-sm",
4147
4486
  children: e.object_name
4148
4487
  }),
4149
- /* @__PURE__ */ Q(V, { children: /* @__PURE__ */ Q(ua, { status: e.status }) }),
4150
- /* @__PURE__ */ Q(V, {
4488
+ /* @__PURE__ */ Q(H, { children: /* @__PURE__ */ Q(Da, { status: e.status }) }),
4489
+ /* @__PURE__ */ Q(H, {
4151
4490
  className: "text-xs text-muted-foreground",
4152
4491
  children: /* @__PURE__ */ $("span", {
4153
4492
  className: "inline-flex items-center gap-1",
4154
4493
  children: [
4155
4494
  /* @__PURE__ */ Q(He, { className: "h-3 w-3" }),
4156
4495
  " ",
4157
- da(e.proposed_at)
4496
+ Oa(e.proposed_at)
4158
4497
  ]
4159
4498
  })
4160
4499
  }),
4161
- /* @__PURE__ */ Q(V, {
4500
+ /* @__PURE__ */ Q(H, {
4162
4501
  className: "text-right",
4163
4502
  children: /* @__PURE__ */ $("div", {
4164
4503
  className: "inline-flex gap-1.5",
@@ -4172,9 +4511,9 @@ function ha({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
4172
4511
  size: "sm",
4173
4512
  variant: "default",
4174
4513
  disabled: n,
4175
- onClick: () => void ae(e.id),
4514
+ onClick: () => void ie(e.id),
4176
4515
  "data-testid": `ai-inbox-approve-${e.id}`,
4177
- children: [/* @__PURE__ */ Q(J, { className: "h-3.5 w-3.5 mr-1" }), n ? "Working…" : "Approve"]
4516
+ children: [/* @__PURE__ */ Q(Y, { className: "h-3.5 w-3.5 mr-1" }), n ? "Working…" : "Approve"]
4178
4517
  }), /* @__PURE__ */ $(v, {
4179
4518
  size: "sm",
4180
4519
  variant: "destructive",
@@ -4200,127 +4539,127 @@ function ha({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
4200
4539
  children: [/* @__PURE__ */ $(C, {
4201
4540
  className: "flex items-center gap-2",
4202
4541
  children: [
4203
- /* @__PURE__ */ Q(Ne, { className: "h-4 w-4" }),
4542
+ /* @__PURE__ */ Q(Me, { className: "h-4 w-4" }),
4204
4543
  " ",
4205
4544
  o
4206
4545
  ]
4207
4546
  }), s ? /* @__PURE__ */ Q(x, { children: s }) : null]
4208
- }), /* @__PURE__ */ Q(b, { children: se })]
4547
+ }), /* @__PURE__ */ Q(b, { children: B })]
4209
4548
  }) : /* @__PURE__ */ Q("div", {
4210
4549
  className: c,
4211
- children: se
4550
+ children: B
4212
4551
  }),
4213
- /* @__PURE__ */ Q(ge, {
4552
+ /* @__PURE__ */ Q(me, {
4214
4553
  open: !!d,
4215
4554
  onOpenChange: (e) => {
4216
4555
  e || m(null);
4217
4556
  },
4218
- children: /* @__PURE__ */ $(_e, {
4557
+ children: /* @__PURE__ */ $(he, {
4219
4558
  className: "sm:max-w-[560px] overflow-y-auto",
4220
- children: [/* @__PURE__ */ $(ye, { children: [/* @__PURE__ */ $(be, {
4559
+ children: [/* @__PURE__ */ $(_e, { children: [/* @__PURE__ */ $(ve, {
4221
4560
  className: "flex items-center gap-2",
4222
- children: [/* @__PURE__ */ Q(Ne, { className: "h-4 w-4" }), R ? R.action_name : "Pending action"]
4223
- }), /* @__PURE__ */ Q(ve, { children: R ? /* @__PURE__ */ $(Z, { children: [
4561
+ children: [/* @__PURE__ */ Q(Me, { className: "h-4 w-4" }), z ? z.action_name : "Pending action"]
4562
+ }), /* @__PURE__ */ Q(ge, { children: z ? /* @__PURE__ */ $(Z, { children: [
4224
4563
  "Tool ",
4225
4564
  /* @__PURE__ */ Q("code", {
4226
4565
  className: "text-xs",
4227
- children: R.tool_name
4566
+ children: z.tool_name
4228
4567
  }),
4229
4568
  " on",
4230
4569
  " ",
4231
4570
  /* @__PURE__ */ Q("code", {
4232
4571
  className: "text-xs",
4233
- children: R.object_name
4572
+ children: z.object_name
4234
4573
  })
4235
- ] }) : "Loading…" })] }), R ? /* @__PURE__ */ $("div", {
4574
+ ] }) : "Loading…" })] }), z ? /* @__PURE__ */ $("div", {
4236
4575
  className: "px-4 space-y-4 mt-4",
4237
4576
  children: [
4238
4577
  /* @__PURE__ */ $("div", {
4239
4578
  className: "grid grid-cols-2 gap-3 text-sm",
4240
4579
  children: [
4241
- /* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q(z, {
4580
+ /* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q(V, {
4242
4581
  className: "text-xs text-muted-foreground",
4243
4582
  children: "Status"
4244
4583
  }), /* @__PURE__ */ Q("div", {
4245
4584
  className: "mt-1",
4246
- children: /* @__PURE__ */ Q(ua, { status: R.status })
4585
+ children: /* @__PURE__ */ Q(Da, { status: z.status })
4247
4586
  })] }),
4248
- /* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q(z, {
4587
+ /* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q(V, {
4249
4588
  className: "text-xs text-muted-foreground",
4250
4589
  children: "Proposed"
4251
4590
  }), /* @__PURE__ */ Q("div", {
4252
4591
  className: "mt-1 text-xs",
4253
- children: da(R.proposed_at)
4592
+ children: Oa(z.proposed_at)
4254
4593
  })] }),
4255
- /* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q(z, {
4594
+ /* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q(V, {
4256
4595
  className: "text-xs text-muted-foreground",
4257
4596
  children: "Proposed by"
4258
4597
  }), /* @__PURE__ */ Q("div", {
4259
4598
  className: "mt-1 text-xs font-mono break-all",
4260
- children: R.proposed_by ?? "—"
4599
+ children: z.proposed_by ?? "—"
4261
4600
  })] }),
4262
- /* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q(z, {
4601
+ /* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q(V, {
4263
4602
  className: "text-xs text-muted-foreground",
4264
4603
  children: "Decided by"
4265
4604
  }), /* @__PURE__ */ Q("div", {
4266
4605
  className: "mt-1 text-xs font-mono break-all",
4267
- children: R.decided_by ?? "—"
4606
+ children: z.decided_by ?? "—"
4268
4607
  })] }),
4269
- R.conversation_id ? /* @__PURE__ */ $("div", {
4608
+ z.conversation_id ? /* @__PURE__ */ $("div", {
4270
4609
  className: "col-span-2",
4271
- children: [/* @__PURE__ */ Q(z, {
4610
+ children: [/* @__PURE__ */ Q(V, {
4272
4611
  className: "text-xs text-muted-foreground",
4273
4612
  children: "Conversation"
4274
4613
  }), /* @__PURE__ */ Q("div", {
4275
4614
  className: "mt-1 text-xs font-mono break-all",
4276
- children: R.conversation_id
4615
+ children: z.conversation_id
4277
4616
  })]
4278
4617
  }) : null
4279
4618
  ]
4280
4619
  }),
4281
- /* @__PURE__ */ Q(he, {}),
4282
- /* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q(z, {
4620
+ /* @__PURE__ */ Q(pe, {}),
4621
+ /* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q(V, {
4283
4622
  className: "text-xs",
4284
4623
  children: "Tool input"
4285
4624
  }), /* @__PURE__ */ Q("div", {
4286
4625
  className: "mt-1.5",
4287
- children: /* @__PURE__ */ Q(pa, { value: fa(R.tool_input) })
4626
+ children: /* @__PURE__ */ Q(Aa, { value: ka(z.tool_input) })
4288
4627
  })] }),
4289
- R.result ? /* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q(z, {
4628
+ z.result ? /* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q(V, {
4290
4629
  className: "text-xs",
4291
4630
  children: "Result"
4292
4631
  }), /* @__PURE__ */ Q("div", {
4293
4632
  className: "mt-1.5",
4294
- children: /* @__PURE__ */ Q(pa, { value: fa(R.result) })
4633
+ children: /* @__PURE__ */ Q(Aa, { value: ka(z.result) })
4295
4634
  })] }) : null,
4296
- R.error ? /* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q(z, {
4635
+ z.error ? /* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q(V, {
4297
4636
  className: "text-xs text-destructive",
4298
4637
  children: "Error"
4299
4638
  }), /* @__PURE__ */ Q("div", {
4300
4639
  className: "mt-1.5",
4301
- children: /* @__PURE__ */ Q(pa, { value: R.error })
4640
+ children: /* @__PURE__ */ Q(Aa, { value: z.error })
4302
4641
  })] }) : null,
4303
- R.rejection_reason ? /* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q(z, {
4642
+ z.rejection_reason ? /* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q(V, {
4304
4643
  className: "text-xs",
4305
4644
  children: "Rejection reason"
4306
4645
  }), /* @__PURE__ */ Q("div", {
4307
4646
  className: "mt-1.5 text-sm",
4308
- children: R.rejection_reason
4647
+ children: z.rejection_reason
4309
4648
  })] }) : null,
4310
- R.status === "pending" ? /* @__PURE__ */ $("div", {
4649
+ z.status === "pending" ? /* @__PURE__ */ $("div", {
4311
4650
  className: "pt-2 flex gap-2",
4312
4651
  children: [/* @__PURE__ */ $(v, {
4313
4652
  size: "sm",
4314
- onClick: () => void ae(R.id),
4315
- disabled: T === R.id,
4316
- children: [/* @__PURE__ */ Q(J, { className: "h-3.5 w-3.5 mr-1" }), "Approve & Execute"]
4653
+ onClick: () => void ie(z.id),
4654
+ disabled: T === z.id,
4655
+ children: [/* @__PURE__ */ Q(Y, { className: "h-3.5 w-3.5 mr-1" }), "Approve & Execute"]
4317
4656
  }), /* @__PURE__ */ $(v, {
4318
4657
  size: "sm",
4319
4658
  variant: "destructive",
4320
4659
  onClick: () => {
4321
- g(R.id), w("");
4660
+ g(z.id), w("");
4322
4661
  },
4323
- disabled: T === R.id,
4662
+ disabled: T === z.id,
4324
4663
  children: [/* @__PURE__ */ Q(X, { className: "h-3.5 w-3.5 mr-1" }), "Reject"]
4325
4664
  })]
4326
4665
  }) : null
@@ -4328,17 +4667,17 @@ function ha({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
4328
4667
  }) : null]
4329
4668
  })
4330
4669
  }),
4331
- /* @__PURE__ */ Q(ge, {
4670
+ /* @__PURE__ */ Q(me, {
4332
4671
  open: !!h,
4333
4672
  onOpenChange: (e) => {
4334
4673
  e || (g(null), w(""));
4335
4674
  },
4336
- children: /* @__PURE__ */ $(_e, {
4675
+ children: /* @__PURE__ */ $(he, {
4337
4676
  side: "bottom",
4338
4677
  className: "max-h-[40vh]",
4339
- children: [/* @__PURE__ */ $(ye, { children: [/* @__PURE__ */ Q(be, { children: "Reject this action?" }), /* @__PURE__ */ Q(ve, { children: "The reason is shown back to the AI so it can adjust its next response." })] }), /* @__PURE__ */ $("div", {
4678
+ children: [/* @__PURE__ */ $(_e, { children: [/* @__PURE__ */ Q(ve, { children: "Reject this action?" }), /* @__PURE__ */ Q(ge, { children: "The reason is shown back to the AI so it can adjust its next response." })] }), /* @__PURE__ */ $("div", {
4340
4679
  className: "px-4 mt-3 space-y-3",
4341
- children: [/* @__PURE__ */ Q(Te, {
4680
+ children: [/* @__PURE__ */ Q(K, {
4342
4681
  value: _,
4343
4682
  onChange: (e) => w(e.target.value),
4344
4683
  placeholder: "Optional reason (e.g. 'Wrong record id — please confirm with the user first.')",
@@ -4356,7 +4695,7 @@ function ha({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
4356
4695
  }), /* @__PURE__ */ $(v, {
4357
4696
  variant: "destructive",
4358
4697
  size: "sm",
4359
- onClick: () => h && void oe(h, _),
4698
+ onClick: () => h && void ae(h, _),
4360
4699
  disabled: !h || T === h,
4361
4700
  "data-testid": "ai-inbox-reject-confirm",
4362
4701
  children: [/* @__PURE__ */ Q(X, { className: "h-3.5 w-3.5 mr-1" }), "Reject"]
@@ -4369,14 +4708,14 @@ function ha({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
4369
4708
  }
4370
4709
  //#endregion
4371
4710
  //#region src/useHitlInChat.ts
4372
- function ga(e) {
4711
+ function Na(e) {
4373
4712
  return !e || e.length === 0 ? "/api/v1/ai" : e.endsWith("/") ? e.slice(0, -1) : e;
4374
4713
  }
4375
- function _a(e, t) {
4714
+ function Pa(e, t) {
4376
4715
  let n = { ...e ?? {} };
4377
4716
  return t && (n["Content-Type"] = "application/json"), n;
4378
4717
  }
4379
- async function va(e) {
4718
+ async function Fa(e) {
4380
4719
  let t = await e.text();
4381
4720
  if (!t) return null;
4382
4721
  try {
@@ -4385,8 +4724,8 @@ async function va(e) {
4385
4724
  return { raw: t };
4386
4725
  }
4387
4726
  }
4388
- function ya(t) {
4389
- let { messages: n, apiBase: r, headers: i, onDecided: a, continueConversation: o } = t, s = ga(r), c = e.useMemo(() => {
4727
+ function Ia(t) {
4728
+ let { messages: n, apiBase: r, headers: i, onDecided: a, continueConversation: o } = t, s = Na(r), c = e.useMemo(() => {
4390
4729
  let e = /* @__PURE__ */ new Map();
4391
4730
  for (let t of n) {
4392
4731
  let n = t.toolInvocations ?? [];
@@ -4429,9 +4768,9 @@ function ya(t) {
4429
4768
  let r = `${s}/pending-actions/${encodeURIComponent(l)}/${t ? "approve" : "reject"}`, c = t ? "{}" : JSON.stringify({ reason: n ?? "" }), d = await fetch(r, {
4430
4769
  method: "POST",
4431
4770
  credentials: "include",
4432
- headers: _a(i, !0),
4771
+ headers: Pa(i, !0),
4433
4772
  body: c
4434
- }), f = await va(d) ?? {};
4773
+ }), f = await Fa(d) ?? {};
4435
4774
  if (!d.ok) {
4436
4775
  let t = typeof f.error == "string" ? f.error : `Approval failed: HTTP ${d.status}`;
4437
4776
  m(e, {
@@ -4458,7 +4797,7 @@ function ya(t) {
4458
4797
  state: "success",
4459
4798
  message: `Status: ${p}`
4460
4799
  }), h = !0), a?.(e, f), h && o) {
4461
- let r = ba({
4800
+ let r = La({
4462
4801
  approved: t,
4463
4802
  status: p,
4464
4803
  toolName: u,
@@ -4493,24 +4832,24 @@ function ya(t) {
4493
4832
  isDeciding: f
4494
4833
  };
4495
4834
  }
4496
- function ba(e) {
4835
+ function La(e) {
4497
4836
  let { approved: t, status: n, toolName: r, pendingActionId: i, outcome: a, reason: o } = e, s = `[HITL ${i}]`;
4498
4837
  if (t && n === "executed") {
4499
4838
  let e = a.result;
4500
- return `${s} The operator approved the \`${r}\` call. It executed successfully with result: ${e == null ? "(no payload)" : typeof e == "string" ? e : xa(JSON.stringify(e), 800)}. Acknowledge the outcome concisely and continue the user's task.`;
4839
+ return `${s} The operator approved the \`${r}\` call. It executed successfully with result: ${e == null ? "(no payload)" : typeof e == "string" ? e : Ra(JSON.stringify(e), 800)}. Acknowledge the outcome concisely and continue the user's task.`;
4501
4840
  }
4502
4841
  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.`;
4503
4842
  if (n === "failed") {
4504
4843
  let e = a.error;
4505
- return `${s} The \`${r}\` call was approved but execution failed: ${typeof e == "string" ? e : xa(JSON.stringify(e ?? {}), 400)}. Apologize concisely and offer alternatives.`;
4844
+ return `${s} The \`${r}\` call was approved but execution failed: ${typeof e == "string" ? e : Ra(JSON.stringify(e ?? {}), 400)}. Apologize concisely and offer alternatives.`;
4506
4845
  }
4507
4846
  }
4508
- function xa(e, t) {
4847
+ function Ra(e, t) {
4509
4848
  return e.length <= t ? e : `${e.slice(0, t - 1)}…`;
4510
4849
  }
4511
4850
  //#endregion
4512
4851
  //#region src/index.tsx
4513
- var Sa = 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) => {
4852
+ var za = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type your message...", onSendMessage: i, disabled: a = !1, showTimestamp: o = !1, userAvatarUrl: s, userAvatarFallback: c = "You", assistantAvatarUrl: l, assistantAvatarFallback: u = "AI", maxHeight: d = "500px", ...f }, p) => {
4514
4853
  let [m, h] = e.useState(""), g = e.useRef(null), _ = e.useRef(null);
4515
4854
  e.useEffect(() => {
4516
4855
  if (g.current) {
@@ -4528,7 +4867,7 @@ var Sa = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
4528
4867
  className: q("flex flex-col border rounded-lg bg-background overflow-hidden", t),
4529
4868
  style: { maxHeight: d },
4530
4869
  ...f,
4531
- children: [/* @__PURE__ */ Q(ce, {
4870
+ children: [/* @__PURE__ */ Q(oe, {
4532
4871
  ref: g,
4533
4872
  className: "flex-1 p-4",
4534
4873
  children: /* @__PURE__ */ Q("div", {
@@ -4536,7 +4875,7 @@ var Sa = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
4536
4875
  children: n.length === 0 ? /* @__PURE__ */ Q("div", {
4537
4876
  className: "flex items-center justify-center h-32 text-muted-foreground text-sm",
4538
4877
  children: "No messages yet. Start a conversation!"
4539
- }) : n.map((e) => /* @__PURE__ */ Q(Ca, {
4878
+ }) : n.map((e) => /* @__PURE__ */ Q(Ba, {
4540
4879
  message: e,
4541
4880
  showTimestamp: o,
4542
4881
  userAvatarUrl: s,
@@ -4549,7 +4888,7 @@ var Sa = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
4549
4888
  className: "border-t p-4",
4550
4889
  children: /* @__PURE__ */ $("div", {
4551
4890
  className: "flex gap-2",
4552
- children: [/* @__PURE__ */ Q(se, {
4891
+ children: [/* @__PURE__ */ Q(B, {
4553
4892
  ref: _,
4554
4893
  value: m,
4555
4894
  onChange: (e) => h(e.target.value),
@@ -4561,14 +4900,14 @@ var Sa = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
4561
4900
  onClick: y,
4562
4901
  disabled: a || !m.trim(),
4563
4902
  size: "icon",
4564
- children: /* @__PURE__ */ Q(lt, { className: "h-4 w-4" })
4903
+ children: /* @__PURE__ */ Q(ut, { className: "h-4 w-4" })
4565
4904
  })]
4566
4905
  })
4567
4906
  })]
4568
4907
  });
4569
4908
  });
4570
- Sa.displayName = "Chatbot";
4571
- var Ca = ({ message: e, showTimestamp: t, userAvatarUrl: n, userAvatarFallback: r, assistantAvatarUrl: i, assistantAvatarFallback: a }) => {
4909
+ za.displayName = "Chatbot";
4910
+ var Ba = ({ message: e, showTimestamp: t, userAvatarUrl: n, userAvatarFallback: r, assistantAvatarUrl: i, assistantAvatarFallback: a }) => {
4572
4911
  let o = e.role === "user";
4573
4912
  if (e.role === "system") return /* @__PURE__ */ Q("div", {
4574
4913
  className: "flex justify-center",
@@ -4600,7 +4939,7 @@ var Ca = ({ message: e, showTimestamp: t, userAvatarUrl: n, userAvatarFallback:
4600
4939
  })]
4601
4940
  })]
4602
4941
  });
4603
- }, wa = e.forwardRef(({ className: e, avatarSrc: t, avatarFallback: n = "AI", ...r }, i) => /* @__PURE__ */ $("div", {
4942
+ }, Va = e.forwardRef(({ className: e, avatarSrc: t, avatarFallback: n = "AI", ...r }, i) => /* @__PURE__ */ $("div", {
4604
4943
  ref: i,
4605
4944
  className: q("flex gap-3", e),
4606
4945
  ...r,
@@ -4622,6 +4961,6 @@ var Ca = ({ message: e, showTimestamp: t, userAvatarUrl: n, userAvatarFallback:
4622
4961
  })
4623
4962
  })]
4624
4963
  }));
4625
- wa.displayName = "TypingIndicator";
4964
+ Va.displayName = "TypingIndicator";
4626
4965
  //#endregion
4627
- export { nn as AGENT_ALIAS_GROUPS, ia as AIElements, ha as AiPendingActionsInbox, Sa as Chatbot, Li as ChatbotEnhanced, ta as FloatingChatbot, kn as FloatingChatbotPanel, _n as FloatingChatbotProvider, Cn as FloatingChatbotTrigger, un as PLATFORM_DEFAULT_AGENT, wa as TypingIndicator, rn as agentAliasGroup, an as agentRouteName, Kt as buildProgressFromDraftReview, Wt as detectDraftResult, Ht as detectProposedPlan, jn as humanizeToolName, ln as isAskAgent, cn as isBuildAgent, sn as isBuiltinAgentName, Oi as publishHealthFromResponse, on as resolveAgentParam, dn as resolveDefaultAgentName, Nn as summarizeChatError, Zt as uiMessageToChatMessage, Qt as uiMessagesToChatMessages, Mn as unwrapToolResult, pn as useAgents, hn as useAiModels, vn as useFloatingChatbot, ya as useHitlInChat, tn as useObjectChat, ca as usePendingActions };
4966
+ export { sn as AGENT_ALIAS_GROUPS, xa as AIElements, Ma as AiPendingActionsInbox, za as Chatbot, Ji as ChatbotEnhanced, va as FloatingChatbot, Nn as FloatingChatbotPanel, xn as FloatingChatbotProvider, Dn as FloatingChatbotTrigger, mn as PLATFORM_DEFAULT_AGENT, Va as TypingIndicator, cn as agentAliasGroup, ln as agentRouteName, Jt as buildProgressFromDraftReview, Kt as detectDraftResult, Wt as detectProposedPlan, Fn as humanizeToolName, pn as isAskAgent, fn as isBuildAgent, dn as isBuiltinAgentName, Fi as publishHealthFromResponse, un as resolveAgentParam, hn as resolveDefaultAgentName, Ln as summarizeChatError, en as uiMessageToChatMessage, tn as uiMessagesToChatMessages, In as unwrapToolResult, _n as useAgents, yn as useAiModels, Sn as useFloatingChatbot, Ia as useHitlInChat, on as useObjectChat, Ta as usePendingActions };