@aigentyc/chat-sdk 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/context7.json +1 -1
  2. package/dist/{ChatInterface--yaDB5yp.d.ts → ChatInterface-2MN5cpYB.d.ts} +1 -1
  3. package/dist/{ChatInterface-0rq8D5-8.d.cts → ChatInterface-BnVyOUG5.d.cts} +1 -1
  4. package/dist/{SlotsContext-CWTjP0mA.d.ts → SlotsContext-BZBi51ZT.d.ts} +89 -4
  5. package/dist/{SlotsContext-u5CFB7MS.d.cts → SlotsContext-D_C7zlUA.d.cts} +89 -4
  6. package/dist/ai-elements.cjs +163 -566
  7. package/dist/ai-elements.cjs.map +1 -1
  8. package/dist/ai-elements.d.cts +10 -2
  9. package/dist/ai-elements.d.ts +10 -2
  10. package/dist/ai-elements.js +16 -461
  11. package/dist/ai-elements.js.map +1 -1
  12. package/dist/{chunk-LSKOJ7SH.js → chunk-3H4CX3MS.js} +8 -5
  13. package/dist/chunk-3H4CX3MS.js.map +1 -0
  14. package/dist/{chunk-46MUOYPR.cjs → chunk-52ZHMTAA.cjs} +8 -5
  15. package/dist/chunk-52ZHMTAA.cjs.map +1 -0
  16. package/dist/{chunk-B27JIQ4Z.js → chunk-5XF3NEFB.js} +576 -6
  17. package/dist/chunk-5XF3NEFB.js.map +1 -0
  18. package/dist/{chunk-LVWSWTI3.cjs → chunk-7ESWDFF5.cjs} +92 -58
  19. package/dist/chunk-7ESWDFF5.cjs.map +1 -0
  20. package/dist/{chunk-RAQVW2D7.js → chunk-BWWN5LSE.js} +62 -28
  21. package/dist/chunk-BWWN5LSE.js.map +1 -0
  22. package/dist/chunk-BYTPAQ7F.js +70 -0
  23. package/dist/chunk-BYTPAQ7F.js.map +1 -0
  24. package/dist/{chunk-3EN3DMUL.js → chunk-D75TDRBH.js} +8 -5
  25. package/dist/chunk-D75TDRBH.js.map +1 -0
  26. package/dist/chunk-DDATCJ3O.cjs +75 -0
  27. package/dist/chunk-DDATCJ3O.cjs.map +1 -0
  28. package/dist/{chunk-NYQSM3EB.cjs → chunk-DVWX2UGY.cjs} +16 -2
  29. package/dist/chunk-DVWX2UGY.cjs.map +1 -0
  30. package/dist/{chunk-TZ7EM3EG.cjs → chunk-EMVZ7HWM.cjs} +44 -2
  31. package/dist/chunk-EMVZ7HWM.cjs.map +1 -0
  32. package/dist/{chunk-6ZZTTD5E.js → chunk-FJZL33KP.js} +3 -3
  33. package/dist/{chunk-6ZZTTD5E.js.map → chunk-FJZL33KP.js.map} +1 -1
  34. package/dist/{chunk-JHWSG5IB.js → chunk-JAOD6CNW.js} +38 -3
  35. package/dist/chunk-JAOD6CNW.js.map +1 -0
  36. package/dist/{chunk-4WOBNRRB.cjs → chunk-KTYYLZN7.cjs} +592 -8
  37. package/dist/chunk-KTYYLZN7.cjs.map +1 -0
  38. package/dist/{chunk-AWRQSM42.cjs → chunk-NBZDBH4M.cjs} +8 -5
  39. package/dist/chunk-NBZDBH4M.cjs.map +1 -0
  40. package/dist/{chunk-5F3O3ZJH.js → chunk-P7UR37HP.js} +17 -4
  41. package/dist/chunk-P7UR37HP.js.map +1 -0
  42. package/dist/{chunk-OEEDYJTV.cjs → chunk-Q3UJEIBN.cjs} +6 -6
  43. package/dist/{chunk-OEEDYJTV.cjs.map → chunk-Q3UJEIBN.cjs.map} +1 -1
  44. package/dist/{chunk-3KSMOHNY.js → chunk-R3TYC66R.js} +46 -81
  45. package/dist/chunk-R3TYC66R.js.map +1 -0
  46. package/dist/{chunk-OU5OZKYH.cjs → chunk-Y4B45DW4.cjs} +48 -90
  47. package/dist/chunk-Y4B45DW4.cjs.map +1 -0
  48. package/dist/components.cjs +18 -18
  49. package/dist/components.d.cts +3 -3
  50. package/dist/components.d.ts +3 -3
  51. package/dist/components.js +7 -7
  52. package/dist/core.d.cts +2 -2
  53. package/dist/core.d.ts +2 -2
  54. package/dist/hooks.cjs +31 -10
  55. package/dist/hooks.cjs.map +1 -1
  56. package/dist/hooks.d.cts +2 -2
  57. package/dist/hooks.d.ts +2 -2
  58. package/dist/hooks.js +4 -3
  59. package/dist/hooks.js.map +1 -1
  60. package/dist/i18n.d.cts +1 -1
  61. package/dist/i18n.d.ts +1 -1
  62. package/dist/index.cjs +52 -31
  63. package/dist/index.cjs.map +1 -1
  64. package/dist/index.d.cts +4 -4
  65. package/dist/index.d.ts +4 -4
  66. package/dist/index.js +11 -10
  67. package/dist/index.js.map +1 -1
  68. package/dist/llms-full.txt +9 -9
  69. package/dist/styles.css +1 -1
  70. package/dist/theme.d.cts +1 -1
  71. package/dist/theme.d.ts +1 -1
  72. package/dist/tools.cjs +5 -5
  73. package/dist/tools.d.cts +2 -2
  74. package/dist/tools.d.ts +2 -2
  75. package/dist/tools.js +2 -2
  76. package/dist/{types-DQCjs81O.d.cts → types-bsR_-fq8.d.cts} +24 -1
  77. package/dist/{types-DQCjs81O.d.ts → types-bsR_-fq8.d.ts} +24 -1
  78. package/dist/ui.cjs +52 -52
  79. package/dist/ui.js +2 -2
  80. package/package.json +1 -1
  81. package/dist/chunk-3EN3DMUL.js.map +0 -1
  82. package/dist/chunk-3KSMOHNY.js.map +0 -1
  83. package/dist/chunk-46MUOYPR.cjs.map +0 -1
  84. package/dist/chunk-4WOBNRRB.cjs.map +0 -1
  85. package/dist/chunk-5F3O3ZJH.js.map +0 -1
  86. package/dist/chunk-AWRQSM42.cjs.map +0 -1
  87. package/dist/chunk-B27JIQ4Z.js.map +0 -1
  88. package/dist/chunk-JHWSG5IB.js.map +0 -1
  89. package/dist/chunk-LSKOJ7SH.js.map +0 -1
  90. package/dist/chunk-LVWSWTI3.cjs.map +0 -1
  91. package/dist/chunk-NYQSM3EB.cjs.map +0 -1
  92. package/dist/chunk-OU5OZKYH.cjs.map +0 -1
  93. package/dist/chunk-RAQVW2D7.js.map +0 -1
  94. package/dist/chunk-TZ7EM3EG.cjs.map +0 -1
@@ -671,8 +671,16 @@ declare global {
671
671
  type PromptInputSpeechButtonProps = ComponentProps<typeof PromptInputButton> & {
672
672
  textareaRef?: RefObject<HTMLTextAreaElement | null>;
673
673
  onTranscriptionChange?: (text: string) => void;
674
- };
675
- declare const PromptInputSpeechButton: ({ className, textareaRef, onTranscriptionChange, ...props }: PromptInputSpeechButtonProps) => react_jsx_runtime.JSX.Element;
674
+ /**
675
+ * BCP-47 tag the recogniser dictates in, e.g. `"he-IL"`.
676
+ *
677
+ * Defaults to the language of what the visitor has typed so far — the script
678
+ * of their own characters is the only signal the web gives for which keyboard
679
+ * is active — falling back to the browser's language. Pass a value to pin it.
680
+ */
681
+ lang?: string;
682
+ };
683
+ declare const PromptInputSpeechButton: ({ className, textareaRef, onTranscriptionChange, lang, ...props }: PromptInputSpeechButtonProps) => react_jsx_runtime.JSX.Element;
676
684
  type PromptInputSelectProps = ComponentProps<typeof Select>;
677
685
  declare const PromptInputSelect: (props: PromptInputSelectProps) => react_jsx_runtime.JSX.Element;
678
686
  type PromptInputSelectTriggerProps = ComponentProps<typeof SelectTrigger>;
@@ -671,8 +671,16 @@ declare global {
671
671
  type PromptInputSpeechButtonProps = ComponentProps<typeof PromptInputButton> & {
672
672
  textareaRef?: RefObject<HTMLTextAreaElement | null>;
673
673
  onTranscriptionChange?: (text: string) => void;
674
- };
675
- declare const PromptInputSpeechButton: ({ className, textareaRef, onTranscriptionChange, ...props }: PromptInputSpeechButtonProps) => react_jsx_runtime.JSX.Element;
674
+ /**
675
+ * BCP-47 tag the recogniser dictates in, e.g. `"he-IL"`.
676
+ *
677
+ * Defaults to the language of what the visitor has typed so far — the script
678
+ * of their own characters is the only signal the web gives for which keyboard
679
+ * is active — falling back to the browser's language. Pass a value to pin it.
680
+ */
681
+ lang?: string;
682
+ };
683
+ declare const PromptInputSpeechButton: ({ className, textareaRef, onTranscriptionChange, lang, ...props }: PromptInputSpeechButtonProps) => react_jsx_runtime.JSX.Element;
676
684
  type PromptInputSelectProps = ComponentProps<typeof Select>;
677
685
  declare const PromptInputSelect: (props: PromptInputSelectProps) => react_jsx_runtime.JSX.Element;
678
686
  type PromptInputSelectTriggerProps = ComponentProps<typeof SelectTrigger>;
@@ -1,477 +1,29 @@
1
1
  "use client";
2
- export { Conversation, ConversationContent, ConversationEmptyState, ConversationScrollButton, Loader, MessageFeedback, Source, Sources, SourcesContent, SourcesTrigger, SpinnerLoader } from './chunk-B27JIQ4Z.js';
2
+ import { detectLanguage, LATIN } from './chunk-BYTPAQ7F.js';
3
+ export { Conversation, ConversationContent, ConversationEmptyState, ConversationScrollButton, Loader, Message, MessageAction, MessageActions, MessageAttachment, MessageAttachments, MessageBranch, MessageBranchContent, MessageBranchNext, MessageBranchPage, MessageBranchPrevious, MessageBranchSelector, MessageContent, MessageFeedback, MessageResponse, MessageToolbar, Source, Sources, SourcesContent, SourcesTrigger, SpinnerLoader } from './chunk-5XF3NEFB.js';
3
4
  import './chunk-MZQKGNWF.js';
4
5
  import './chunk-QYCEHFAB.js';
5
6
  import { processImagesInHtml } from './chunk-PS3U7T37.js';
6
- import { Badge, TooltipProvider, Tooltip, TooltipTrigger, TooltipContent, Input, Carousel, CarouselContent, CarouselItem, ScrollArea, ScrollBar, Progress, Alert, AlertDescription, Dialog, DialogTrigger, DialogContent, DialogTitle, DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger, Select, SelectTrigger, SelectContent, SelectItem, SelectValue, Separator } from './chunk-3KSMOHNY.js';
7
- import { Collapsible, CollapsibleTrigger, CollapsibleContent, Button, Textarea } from './chunk-JHWSG5IB.js';
7
+ import { Badge, Input, Carousel, CarouselContent, CarouselItem, ScrollArea, ScrollBar, Progress, Alert, AlertDescription, Dialog, DialogTrigger, DialogContent, DialogTitle, DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger, Select, SelectTrigger, SelectContent, SelectItem, SelectValue } from './chunk-R3TYC66R.js';
8
+ import { Collapsible, CollapsibleTrigger, CollapsibleContent, Button, TooltipProvider, Tooltip, TooltipTrigger, TooltipContent, Separator, Textarea } from './chunk-JAOD6CNW.js';
8
9
  import { Card, CardHeader, CardTitle, CardDescription, CardAction, CardContent, CardFooter } from './chunk-NPJKLYLV.js';
9
10
  import { cn } from './chunk-3RW7O444.js';
10
- import { Slot } from '@radix-ui/react-slot';
11
- import { cva } from 'class-variance-authority';
12
- import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
13
- import { BrainIcon, ChevronDownIcon, DotIcon, Search, ChevronLeftIcon, ChevronRightIcon, XIcon, PaperclipIcon, CheckIcon, CopyIcon, ArrowLeftIcon, ArrowRightIcon, ChevronsUpDownIcon, ImageIcon, PlusIcon, MicIcon, SearchIcon, WrenchIcon, BookmarkIcon, CornerDownLeftIcon, Loader2Icon, SquareIcon, ExternalLinkIcon, MessageCircleIcon, XCircleIcon, CheckCircleIcon, ClockIcon, CircleIcon } from 'lucide-react';
14
11
  import * as React2 from 'react';
15
12
  import { createContext, memo, useState, useEffect, useMemo, useContext, useId, useRef, useSyncExternalStore, useCallback, Fragment as Fragment$1, Children, isValidElement } from 'react';
16
- import { Streamdown } from 'streamdown';
13
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
14
+ import { BrainIcon, ChevronDownIcon, DotIcon, Search, XIcon, CheckIcon, CopyIcon, ArrowLeftIcon, ArrowRightIcon, ChevronsUpDownIcon, PaperclipIcon, ImageIcon, PlusIcon, MicIcon, SearchIcon, WrenchIcon, BookmarkIcon, CornerDownLeftIcon, Loader2Icon, SquareIcon, ExternalLinkIcon, MessageCircleIcon, XCircleIcon, CheckCircleIcon, ClockIcon, CircleIcon } from 'lucide-react';
17
15
  import { codeToHtml } from 'shiki';
18
16
  import * as HoverCardPrimitive from '@radix-ui/react-hover-card';
19
17
  import { useControllableState } from '@radix-ui/react-use-controllable-state';
18
+ import { Streamdown } from 'streamdown';
20
19
  import { motion } from 'motion/react';
21
20
  import { getUsage } from 'tokenlens';
22
21
  import { Controls as Controls$1, Panel as Panel$1, NodeToolbar, Position, ReactFlow, Background, getSimpleBezierPath, BaseEdge, useInternalNode, getBezierPath, Handle } from '@xyflow/react';
23
22
  import { Command as Command$1 } from 'cmdk';
23
+ import { cva } from 'class-variance-authority';
24
24
  import { nanoid } from 'nanoid';
25
25
  import '@xyflow/react/dist/style.css';
26
26
 
27
- var buttonGroupVariants = cva(
28
- "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",
29
- {
30
- variants: {
31
- orientation: {
32
- horizontal: "[&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none",
33
- vertical: "flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none"
34
- }
35
- },
36
- defaultVariants: {
37
- orientation: "horizontal"
38
- }
39
- }
40
- );
41
- function ButtonGroup({
42
- className,
43
- orientation,
44
- ...props
45
- }) {
46
- return /* @__PURE__ */ jsx(
47
- "div",
48
- {
49
- role: "group",
50
- "data-slot": "button-group",
51
- "data-orientation": orientation,
52
- className: cn(buttonGroupVariants({ orientation }), className),
53
- ...props
54
- }
55
- );
56
- }
57
- function ButtonGroupText({
58
- className,
59
- asChild = false,
60
- ...props
61
- }) {
62
- const Comp = asChild ? Slot : "div";
63
- return /* @__PURE__ */ jsx(
64
- Comp,
65
- {
66
- className: cn(
67
- "bg-muted shadow-xs flex items-center gap-2 rounded-md border px-4 text-sm font-medium [&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none",
68
- className
69
- ),
70
- ...props
71
- }
72
- );
73
- }
74
- var Message = ({ className, from, fullWidth, ...props }) => /* @__PURE__ */ jsx(
75
- "div",
76
- {
77
- className: cn(
78
- "group flex w-full flex-col gap-2",
79
- fullWidth ? "" : from === "assistant" ? "max-w-[var(--ac-assistant-max-width,95%)]" : "max-w-[95%]",
80
- from === "user" ? "is-user justify-end" : "is-assistant",
81
- className
82
- ),
83
- ...props
84
- }
85
- );
86
- var MessageContent = ({
87
- children,
88
- className,
89
- fullWidth,
90
- ...props
91
- }) => /* @__PURE__ */ jsx(
92
- "div",
93
- {
94
- className: cn(
95
- "flex min-w-0 flex-col gap-2 overflow-hidden",
96
- fullWidth ? "w-full" : "w-fit max-w-full",
97
- "group-[.is-user]:ml-auto group-[.is-user]:px-6 group-[.is-user]:py-4 group-[.is-user]:text-foreground group-[.is-user]:rounded-bl-[24px] group-[.is-user]:rounded-br-[24px] group-[.is-user]:rounded-tl-[4px] group-[.is-user]:rounded-tr-[24px] group-[.is-user]:bg-[var(--ac-user-bubble-bg,#f0f4f8)]",
98
- "group-[.is-assistant]:text-foreground group-[.is-assistant]:w-full",
99
- className
100
- ),
101
- ...props,
102
- children
103
- }
104
- );
105
- var MessageActions = ({
106
- className,
107
- children,
108
- ...props
109
- }) => /* @__PURE__ */ jsx("div", { className: cn("flex items-center gap-1", className), ...props, children });
110
- var MessageAction = ({
111
- tooltip,
112
- children,
113
- label,
114
- variant = "ghost",
115
- size = "icon-sm",
116
- ...props
117
- }) => {
118
- const button = /* @__PURE__ */ jsxs(Button, { size, type: "button", variant, ...props, children: [
119
- children,
120
- /* @__PURE__ */ jsx("span", { className: "sr-only", children: label || tooltip })
121
- ] });
122
- if (tooltip) {
123
- return /* @__PURE__ */ jsx(TooltipProvider, { children: /* @__PURE__ */ jsxs(Tooltip, { children: [
124
- /* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: button }),
125
- /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: tooltip }) })
126
- ] }) });
127
- }
128
- return button;
129
- };
130
- var MessageBranchContext = createContext(
131
- null
132
- );
133
- var useMessageBranch = () => {
134
- const context = useContext(MessageBranchContext);
135
- if (!context) {
136
- throw new Error(
137
- "MessageBranch components must be used within MessageBranch"
138
- );
139
- }
140
- return context;
141
- };
142
- var MessageBranch = ({
143
- defaultBranch = 0,
144
- onBranchChange,
145
- className,
146
- ...props
147
- }) => {
148
- const [currentBranch, setCurrentBranch] = useState(defaultBranch);
149
- const [branches, setBranches] = useState([]);
150
- const handleBranchChange = (newBranch) => {
151
- setCurrentBranch(newBranch);
152
- onBranchChange?.(newBranch);
153
- };
154
- const goToPrevious = () => {
155
- const newBranch = currentBranch > 0 ? currentBranch - 1 : branches.length - 1;
156
- handleBranchChange(newBranch);
157
- };
158
- const goToNext = () => {
159
- const newBranch = currentBranch < branches.length - 1 ? currentBranch + 1 : 0;
160
- handleBranchChange(newBranch);
161
- };
162
- const contextValue = {
163
- currentBranch,
164
- totalBranches: branches.length,
165
- goToPrevious,
166
- goToNext,
167
- branches,
168
- setBranches
169
- };
170
- return /* @__PURE__ */ jsx(MessageBranchContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx(
171
- "div",
172
- {
173
- className: cn("grid w-full gap-2 [&>div]:pb-0", className),
174
- ...props
175
- }
176
- ) });
177
- };
178
- var MessageBranchContent = ({
179
- children,
180
- ...props
181
- }) => {
182
- const { currentBranch, setBranches, branches } = useMessageBranch();
183
- const childrenArray = Array.isArray(children) ? children : [children];
184
- useEffect(() => {
185
- if (branches.length !== childrenArray.length) {
186
- setBranches(childrenArray);
187
- }
188
- }, [childrenArray, branches, setBranches]);
189
- return childrenArray.map((branch, index) => /* @__PURE__ */ jsx(
190
- "div",
191
- {
192
- className: cn(
193
- "grid gap-2 overflow-hidden [&>div]:pb-0",
194
- index === currentBranch ? "block" : "hidden"
195
- ),
196
- ...props,
197
- children: branch
198
- },
199
- branch.key
200
- ));
201
- };
202
- var MessageBranchSelector = ({
203
- className,
204
- from,
205
- ...props
206
- }) => {
207
- const { totalBranches } = useMessageBranch();
208
- if (totalBranches <= 1) {
209
- return null;
210
- }
211
- return /* @__PURE__ */ jsx(
212
- ButtonGroup,
213
- {
214
- className: "[&>*:not(:first-child)]:rounded-l-md [&>*:not(:last-child)]:rounded-r-md",
215
- orientation: "horizontal",
216
- ...props
217
- }
218
- );
219
- };
220
- var MessageBranchPrevious = ({
221
- children,
222
- ...props
223
- }) => {
224
- const { goToPrevious, totalBranches } = useMessageBranch();
225
- return /* @__PURE__ */ jsx(
226
- Button,
227
- {
228
- "aria-label": "Previous branch",
229
- disabled: totalBranches <= 1,
230
- onClick: goToPrevious,
231
- size: "icon-sm",
232
- type: "button",
233
- variant: "ghost",
234
- ...props,
235
- children: children ?? /* @__PURE__ */ jsx(ChevronLeftIcon, { size: 14 })
236
- }
237
- );
238
- };
239
- var MessageBranchNext = ({
240
- children,
241
- className,
242
- ...props
243
- }) => {
244
- const { goToNext, totalBranches } = useMessageBranch();
245
- return /* @__PURE__ */ jsx(
246
- Button,
247
- {
248
- "aria-label": "Next branch",
249
- disabled: totalBranches <= 1,
250
- onClick: goToNext,
251
- size: "icon-sm",
252
- type: "button",
253
- variant: "ghost",
254
- ...props,
255
- children: children ?? /* @__PURE__ */ jsx(ChevronRightIcon, { size: 14 })
256
- }
257
- );
258
- };
259
- var MessageBranchPage = ({
260
- className,
261
- ...props
262
- }) => {
263
- const { currentBranch, totalBranches } = useMessageBranch();
264
- return /* @__PURE__ */ jsxs(
265
- ButtonGroupText,
266
- {
267
- className: cn(
268
- "border-none bg-transparent text-muted-foreground shadow-none",
269
- className
270
- ),
271
- ...props,
272
- children: [
273
- currentBranch + 1,
274
- " of ",
275
- totalBranches
276
- ]
277
- }
278
- );
279
- };
280
- function addUtmParams(url) {
281
- try {
282
- const urlObj = new URL(url);
283
- urlObj.searchParams.set("utm_source", "chat");
284
- urlObj.searchParams.set("utm_medium", "referral");
285
- return urlObj.toString();
286
- } catch {
287
- return url;
288
- }
289
- }
290
- var CustomLink = ({ href, children, ...props }) => /* @__PURE__ */ jsx(
291
- "a",
292
- {
293
- href: href ? addUtmParams(href) : href,
294
- target: "_blank",
295
- rel: "noopener noreferrer",
296
- className: "hover:underline hover:opacity-80 transition-opacity font-medium",
297
- ...props,
298
- children
299
- }
300
- );
301
- var CustomImage = ({ src, alt, ...props }) => /* @__PURE__ */ jsx(
302
- "img",
303
- {
304
- src,
305
- alt: alt || "",
306
- loading: "lazy",
307
- className: "rounded-xl max-w-full h-auto my-4",
308
- ...props
309
- }
310
- );
311
- var CustomTable = ({ children, ...props }) => /* @__PURE__ */ jsx("div", { className: "my-4 overflow-x-auto", children: /* @__PURE__ */ jsx(
312
- "table",
313
- {
314
- className: "w-full text-sm rounded-xl border border-black/[0.08] overflow-hidden",
315
- ...props,
316
- children
317
- }
318
- ) });
319
- var CustomThead = ({ children, ...props }) => /* @__PURE__ */ jsx("thead", { className: "bg-black/[0.04]", ...props, children });
320
- var CustomTh = ({ children, ...props }) => /* @__PURE__ */ jsx(
321
- "th",
322
- {
323
- className: "px-4 py-3 text-start text-xs font-medium uppercase tracking-wider opacity-60 border-b border-black/[0.08]",
324
- ...props,
325
- children
326
- }
327
- );
328
- var CustomTd = ({ children, ...props }) => /* @__PURE__ */ jsx(
329
- "td",
330
- {
331
- className: "px-4 py-3 border-b border-black/[0.08]",
332
- ...props,
333
- children
334
- }
335
- );
336
- var CustomTr = ({ children, ...props }) => /* @__PURE__ */ jsx(
337
- "tr",
338
- {
339
- className: "hover:bg-black/[0.02] transition-colors",
340
- ...props,
341
- children
342
- }
343
- );
344
- var MessageResponse = memo(
345
- ({ className, ...props }) => /* @__PURE__ */ jsx(
346
- Streamdown,
347
- {
348
- className: cn(
349
- "message-response size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",
350
- className
351
- ),
352
- components: {
353
- a: CustomLink,
354
- img: CustomImage,
355
- table: CustomTable,
356
- thead: CustomThead,
357
- th: CustomTh,
358
- td: CustomTd,
359
- tr: CustomTr
360
- },
361
- linkSafety: { enabled: false },
362
- ...props
363
- }
364
- ),
365
- (prevProps, nextProps) => prevProps.children === nextProps.children
366
- );
367
- MessageResponse.displayName = "MessageResponse";
368
- function MessageAttachment({
369
- data,
370
- className,
371
- onRemove,
372
- ...props
373
- }) {
374
- const filename = data.filename || "";
375
- const mediaType = data.mediaType?.startsWith("image/") && data.url ? "image" : "file";
376
- const isImage = mediaType === "image";
377
- const attachmentLabel = filename || (isImage ? "Image" : "Attachment");
378
- return /* @__PURE__ */ jsx(
379
- "div",
380
- {
381
- className: cn(
382
- "group relative size-24 overflow-hidden rounded-lg",
383
- className
384
- ),
385
- ...props,
386
- children: isImage ? /* @__PURE__ */ jsxs(Fragment, { children: [
387
- /* @__PURE__ */ jsx(
388
- "img",
389
- {
390
- alt: filename || "attachment",
391
- className: "size-full object-cover",
392
- height: 100,
393
- src: data.url,
394
- width: 100
395
- }
396
- ),
397
- onRemove && /* @__PURE__ */ jsxs(
398
- Button,
399
- {
400
- "aria-label": "Remove attachment",
401
- className: "absolute top-2 right-2 size-6 rounded-full bg-background/80 p-0 opacity-0 backdrop-blur-sm transition-opacity hover:bg-background group-hover:opacity-100 [&>svg]:size-3",
402
- onClick: (e) => {
403
- e.stopPropagation();
404
- onRemove();
405
- },
406
- type: "button",
407
- variant: "ghost",
408
- children: [
409
- /* @__PURE__ */ jsx(XIcon, {}),
410
- /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Remove" })
411
- ]
412
- }
413
- )
414
- ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
415
- /* @__PURE__ */ jsxs(Tooltip, { children: [
416
- /* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx("div", { className: "flex size-full shrink-0 items-center justify-center rounded-lg bg-muted text-muted-foreground", children: /* @__PURE__ */ jsx(PaperclipIcon, { className: "size-4" }) }) }),
417
- /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: attachmentLabel }) })
418
- ] }),
419
- onRemove && /* @__PURE__ */ jsxs(
420
- Button,
421
- {
422
- "aria-label": "Remove attachment",
423
- className: "size-6 shrink-0 rounded-full p-0 opacity-0 transition-opacity hover:bg-accent group-hover:opacity-100 [&>svg]:size-3",
424
- onClick: (e) => {
425
- e.stopPropagation();
426
- onRemove();
427
- },
428
- type: "button",
429
- variant: "ghost",
430
- children: [
431
- /* @__PURE__ */ jsx(XIcon, {}),
432
- /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Remove" })
433
- ]
434
- }
435
- )
436
- ] })
437
- }
438
- );
439
- }
440
- function MessageAttachments({
441
- children,
442
- className,
443
- ...props
444
- }) {
445
- if (!children) {
446
- return null;
447
- }
448
- return /* @__PURE__ */ jsx(
449
- "div",
450
- {
451
- className: cn(
452
- "ml-auto flex w-fit flex-wrap items-start gap-2",
453
- className
454
- ),
455
- ...props,
456
- children
457
- }
458
- );
459
- }
460
- var MessageToolbar = ({
461
- className,
462
- children,
463
- ...props
464
- }) => /* @__PURE__ */ jsx(
465
- "div",
466
- {
467
- className: cn(
468
- "mt-4 flex w-full items-center justify-between gap-4",
469
- className
470
- ),
471
- ...props,
472
- children
473
- }
474
- );
475
27
  var MOBILE_BREAKPOINT = 768;
476
28
  function subscribeToResize(cb) {
477
29
  if (typeof window === "undefined") return () => {
@@ -3293,6 +2845,7 @@ var PromptInputSpeechButton = ({
3293
2845
  className,
3294
2846
  textareaRef,
3295
2847
  onTranscriptionChange,
2848
+ lang,
3296
2849
  ...props
3297
2850
  }) => {
3298
2851
  const [isListening, setIsListening] = useState(false);
@@ -3306,7 +2859,6 @@ var PromptInputSpeechButton = ({
3306
2859
  const speechRecognition = new SpeechRecognition();
3307
2860
  speechRecognition.continuous = true;
3308
2861
  speechRecognition.interimResults = true;
3309
- speechRecognition.lang = "en-US";
3310
2862
  speechRecognition.onstart = () => {
3311
2863
  setIsListening(true);
3312
2864
  };
@@ -3349,10 +2901,13 @@ var PromptInputSpeechButton = ({
3349
2901
  }
3350
2902
  if (isListening) {
3351
2903
  recognition.stop();
3352
- } else {
3353
- recognition.start();
2904
+ return;
3354
2905
  }
3355
- }, [recognition, isListening]);
2906
+ const browserLang = typeof navigator !== "undefined" ? navigator.language : "en-US";
2907
+ const typed = detectLanguage(textareaRef?.current?.value ?? "");
2908
+ recognition.lang = lang ?? (typed === null || typed === LATIN ? browserLang : typed);
2909
+ recognition.start();
2910
+ }, [recognition, isListening, lang, textareaRef]);
3356
2911
  return /* @__PURE__ */ jsx(
3357
2912
  PromptInputButton,
3358
2913
  {
@@ -4021,6 +3576,6 @@ var Image = ({
4021
3576
  }
4022
3577
  );
4023
3578
 
4024
- export { Image as AIImage, Artifact, ArtifactAction, ArtifactActions, ArtifactClose, ArtifactContent, ArtifactDescription, ArtifactHeader, ArtifactTitle, Canvas, ChainOfThought, ChainOfThoughtContent, ChainOfThoughtHeader, ChainOfThoughtImage, ChainOfThoughtSearchResult, ChainOfThoughtSearchResults, ChainOfThoughtStep, Checkpoint, CheckpointIcon, CheckpointTrigger, CodeBlock, CodeBlockCopyButton, ComponentRenderer, Confirmation, ConfirmationAccepted, ConfirmationAction, ConfirmationActions, ConfirmationRejected, ConfirmationRequest, ConfirmationTitle, Connection, Context, ContextCacheUsage, ContextContent, ContextContentBody, ContextContentFooter, ContextContentHeader, ContextInputUsage, ContextOutputUsage, ContextReasoningUsage, ContextTrigger, Controls, Edge, FollowupButtons, InlineCitation, InlineCitationCard, InlineCitationCardBody, InlineCitationCardTrigger, InlineCitationCarousel, InlineCitationCarouselContent, InlineCitationCarouselHeader, InlineCitationCarouselIndex, InlineCitationCarouselItem, InlineCitationCarouselNext, InlineCitationCarouselPrev, InlineCitationQuote, InlineCitationSource, InlineCitationText, Message, MessageAction, MessageActions, MessageAttachment, MessageAttachments, MessageBranch, MessageBranchContent, MessageBranchNext, MessageBranchPage, MessageBranchPrevious, MessageBranchSelector, MessageContent, MessageResponse, MessageToolbar, ModelSelector, ModelSelectorContent, ModelSelectorDialog, ModelSelectorEmpty, ModelSelectorGroup, ModelSelectorInput, ModelSelectorItem, ModelSelectorList, ModelSelectorLogo, ModelSelectorLogoGroup, ModelSelectorName, ModelSelectorSeparator, ModelSelectorShortcut, ModelSelectorTrigger, Node, NodeAction, NodeContent, NodeDescription, NodeFooter, NodeHeader, NodeTitle, OpenIn, OpenInChatGPT, OpenInClaude, OpenInContent, OpenInCursor, OpenInItem, OpenInLabel, OpenInScira, OpenInSeparator, OpenInT3, OpenInTrigger, OpenInv0, Panel, Plan, PlanAction, PlanContent, PlanDescription, PlanFooter, PlanHeader, PlanTitle, PlanTrigger, PromptInput, PromptInputActionAddAttachments, PromptInputActionMenu, PromptInputActionMenuContent, PromptInputActionMenuItem, PromptInputActionMenuTrigger, PromptInputAttachment, PromptInputAttachments, PromptInputBody, PromptInputButton, PromptInputCommand, PromptInputCommandEmpty, PromptInputCommandGroup, PromptInputCommandInput, PromptInputCommandItem, PromptInputCommandList, PromptInputCommandSeparator, PromptInputFooter, PromptInputHeader, PromptInputHoverCard, PromptInputHoverCardContent, PromptInputHoverCardTrigger, PromptInputProvider, PromptInputSelect, PromptInputSelectContent, PromptInputSelectItem, PromptInputSelectTrigger, PromptInputSelectValue, PromptInputSpeechButton, PromptInputSubmit, PromptInputTab, PromptInputTabBody, PromptInputTabItem, PromptInputTabLabel, PromptInputTabsList, PromptInputTextarea, PromptInputTools, Queue, QueueItem, QueueItemAction, QueueItemActions, QueueItemAttachment, QueueItemContent, QueueItemDescription, QueueItemFile, QueueItemImage, QueueItemIndicator, QueueList, QueueSection, QueueSectionContent, QueueSectionLabel, QueueSectionTrigger, Reasoning, ReasoningContent, ReasoningTrigger, Shimmer, Suggestion, Suggestions, Task, TaskContent, TaskItem, TaskItemFile, TaskTrigger, ThinkingSpinner, Tool, ToolContent, ToolHeader, ToolInput, ToolOutput, Toolbar, WebPreview, WebPreviewBody, WebPreviewConsole, WebPreviewNavigation, WebPreviewNavigationButton, WebPreviewUrl, highlightCode, usePromptInputAttachments, usePromptInputController, useProviderAttachments, useReasoning };
3579
+ export { Image as AIImage, Artifact, ArtifactAction, ArtifactActions, ArtifactClose, ArtifactContent, ArtifactDescription, ArtifactHeader, ArtifactTitle, Canvas, ChainOfThought, ChainOfThoughtContent, ChainOfThoughtHeader, ChainOfThoughtImage, ChainOfThoughtSearchResult, ChainOfThoughtSearchResults, ChainOfThoughtStep, Checkpoint, CheckpointIcon, CheckpointTrigger, CodeBlock, CodeBlockCopyButton, ComponentRenderer, Confirmation, ConfirmationAccepted, ConfirmationAction, ConfirmationActions, ConfirmationRejected, ConfirmationRequest, ConfirmationTitle, Connection, Context, ContextCacheUsage, ContextContent, ContextContentBody, ContextContentFooter, ContextContentHeader, ContextInputUsage, ContextOutputUsage, ContextReasoningUsage, ContextTrigger, Controls, Edge, FollowupButtons, InlineCitation, InlineCitationCard, InlineCitationCardBody, InlineCitationCardTrigger, InlineCitationCarousel, InlineCitationCarouselContent, InlineCitationCarouselHeader, InlineCitationCarouselIndex, InlineCitationCarouselItem, InlineCitationCarouselNext, InlineCitationCarouselPrev, InlineCitationQuote, InlineCitationSource, InlineCitationText, ModelSelector, ModelSelectorContent, ModelSelectorDialog, ModelSelectorEmpty, ModelSelectorGroup, ModelSelectorInput, ModelSelectorItem, ModelSelectorList, ModelSelectorLogo, ModelSelectorLogoGroup, ModelSelectorName, ModelSelectorSeparator, ModelSelectorShortcut, ModelSelectorTrigger, Node, NodeAction, NodeContent, NodeDescription, NodeFooter, NodeHeader, NodeTitle, OpenIn, OpenInChatGPT, OpenInClaude, OpenInContent, OpenInCursor, OpenInItem, OpenInLabel, OpenInScira, OpenInSeparator, OpenInT3, OpenInTrigger, OpenInv0, Panel, Plan, PlanAction, PlanContent, PlanDescription, PlanFooter, PlanHeader, PlanTitle, PlanTrigger, PromptInput, PromptInputActionAddAttachments, PromptInputActionMenu, PromptInputActionMenuContent, PromptInputActionMenuItem, PromptInputActionMenuTrigger, PromptInputAttachment, PromptInputAttachments, PromptInputBody, PromptInputButton, PromptInputCommand, PromptInputCommandEmpty, PromptInputCommandGroup, PromptInputCommandInput, PromptInputCommandItem, PromptInputCommandList, PromptInputCommandSeparator, PromptInputFooter, PromptInputHeader, PromptInputHoverCard, PromptInputHoverCardContent, PromptInputHoverCardTrigger, PromptInputProvider, PromptInputSelect, PromptInputSelectContent, PromptInputSelectItem, PromptInputSelectTrigger, PromptInputSelectValue, PromptInputSpeechButton, PromptInputSubmit, PromptInputTab, PromptInputTabBody, PromptInputTabItem, PromptInputTabLabel, PromptInputTabsList, PromptInputTextarea, PromptInputTools, Queue, QueueItem, QueueItemAction, QueueItemActions, QueueItemAttachment, QueueItemContent, QueueItemDescription, QueueItemFile, QueueItemImage, QueueItemIndicator, QueueList, QueueSection, QueueSectionContent, QueueSectionLabel, QueueSectionTrigger, Reasoning, ReasoningContent, ReasoningTrigger, Shimmer, Suggestion, Suggestions, Task, TaskContent, TaskItem, TaskItemFile, TaskTrigger, ThinkingSpinner, Tool, ToolContent, ToolHeader, ToolInput, ToolOutput, Toolbar, WebPreview, WebPreviewBody, WebPreviewConsole, WebPreviewNavigation, WebPreviewNavigationButton, WebPreviewUrl, highlightCode, usePromptInputAttachments, usePromptInputController, useProviderAttachments, useReasoning };
4025
3580
  //# sourceMappingURL=ai-elements.js.map
4026
3581
  //# sourceMappingURL=ai-elements.js.map