@arbidocs/react 0.3.184 → 0.4.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 (41) hide show
  1. package/dist/chunk-3CLGHHME.js +3882 -0
  2. package/dist/chunk-3CLGHHME.js.map +1 -0
  3. package/dist/chunk-6ALMBER7.js +176 -0
  4. package/dist/chunk-6ALMBER7.js.map +1 -0
  5. package/dist/chunk-BXP6S34V.cjs +284 -0
  6. package/dist/chunk-BXP6S34V.cjs.map +1 -0
  7. package/dist/chunk-EJ2BMHYK.js +272 -0
  8. package/dist/chunk-EJ2BMHYK.js.map +1 -0
  9. package/dist/chunk-OU2QLIKS.cjs +4060 -0
  10. package/dist/chunk-OU2QLIKS.cjs.map +1 -0
  11. package/dist/chunk-RZQACYNQ.cjs +218 -0
  12. package/dist/chunk-RZQACYNQ.cjs.map +1 -0
  13. package/dist/index-CcbVSNSP.d.cts +116 -0
  14. package/dist/index-CcbVSNSP.d.ts +116 -0
  15. package/dist/index.cjs +955 -2796
  16. package/dist/index.cjs.map +1 -1
  17. package/dist/index.d.cts +13 -901
  18. package/dist/index.d.ts +13 -901
  19. package/dist/index.js +312 -2303
  20. package/dist/index.js.map +1 -1
  21. package/dist/shell/index.cjs +29 -0
  22. package/dist/shell/index.cjs.map +1 -0
  23. package/dist/shell/index.d.cts +4 -0
  24. package/dist/shell/index.d.ts +4 -0
  25. package/dist/shell/index.js +4 -0
  26. package/dist/shell/index.js.map +1 -0
  27. package/dist/ui/index.cjs +288 -147
  28. package/dist/ui/index.d.cts +878 -3
  29. package/dist/ui/index.d.ts +878 -3
  30. package/dist/ui/index.js +2 -1
  31. package/dist/viewers/index.cjs +327 -76
  32. package/dist/viewers/index.cjs.map +1 -1
  33. package/dist/viewers/index.d.cts +90 -4
  34. package/dist/viewers/index.d.ts +90 -4
  35. package/dist/viewers/index.js +316 -78
  36. package/dist/viewers/index.js.map +1 -1
  37. package/package.json +12 -3
  38. package/dist/chunk-FIPS3VPH.cjs +0 -1975
  39. package/dist/chunk-FIPS3VPH.cjs.map +0 -1
  40. package/dist/chunk-I256BUCX.js +0 -1819
  41. package/dist/chunk-I256BUCX.js.map +0 -1
@@ -1,1819 +0,0 @@
1
- import { clsx } from 'clsx';
2
- import { twMerge } from 'tailwind-merge';
3
- import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
4
- import * as React2 from 'react';
5
- import React2__default, { createContext, useMemo, useContext, useState, useRef, useEffect, useCallback } from 'react';
6
- import Markdown from 'react-markdown';
7
- import remarkGfm from 'remark-gfm';
8
- import rehypeRaw from 'rehype-raw';
9
- import { Circle, Check, X, ChevronRight, ChevronDown, ChevronUp, Search, Loader2, Square, Mic, Copy, Minus, Plus } from 'lucide-react';
10
- import { createPortal } from 'react-dom';
11
- import * as AvatarPrimitive from '@radix-ui/react-avatar';
12
- import { cva } from 'class-variance-authority';
13
- import { Slot } from '@radix-ui/react-slot';
14
- import * as HoverCardPrimitive from '@radix-ui/react-hover-card';
15
- import * as SeparatorPrimitive from '@radix-ui/react-separator';
16
- import * as CollapsiblePrimitive from '@radix-ui/react-collapsible';
17
- import * as ProgressPrimitive from '@radix-ui/react-progress';
18
- import * as ScrollAreaPrimitive from '@radix-ui/react-scroll-area';
19
- import * as RadioGroupPrimitive from '@radix-ui/react-radio-group';
20
- import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
21
- import * as SwitchPrimitives from '@radix-ui/react-switch';
22
- import * as TabsPrimitive from '@radix-ui/react-tabs';
23
- import * as SliderPrimitive from '@radix-ui/react-slider';
24
- import * as TogglePrimitive from '@radix-ui/react-toggle';
25
- import * as ToggleGroupPrimitive from '@radix-ui/react-toggle-group';
26
- import * as DialogPrimitive from '@radix-ui/react-dialog';
27
- import * as PopoverPrimitive from '@radix-ui/react-popover';
28
- import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
29
- import * as SelectPrimitive from '@radix-ui/react-select';
30
- import { Command as Command$1 } from 'cmdk';
31
-
32
- // src/lib/utils.ts
33
- function cn(...inputs) {
34
- return twMerge(clsx(inputs));
35
- }
36
- var markdownBaseComponents = {
37
- h1: ({ children, ...props }) => /* @__PURE__ */ jsx("h1", { className: "text-lg font-semibold", "data-testid": "markdown-heading-1", ...props, children }),
38
- h2: ({ children, ...props }) => /* @__PURE__ */ jsx("h2", { className: "font-semibold text-base", "data-testid": "markdown-heading-2", ...props, children }),
39
- h3: ({ children, ...props }) => /* @__PURE__ */ jsx("h3", { className: "font-semibold text-base", "data-testid": "markdown-heading-3", ...props, children }),
40
- h4: ({ children, ...props }) => /* @__PURE__ */ jsx("h4", { className: "font-semibold text-base", ...props, children }),
41
- h5: ({ children, ...props }) => /* @__PURE__ */ jsx("h5", { className: "font-medium", ...props, children }),
42
- strong: ({ children, ...props }) => /* @__PURE__ */ jsx("strong", { className: "font-semibold", ...props, children }),
43
- blockquote: ({ children, ...props }) => /* @__PURE__ */ jsx("blockquote", { className: "border-l-2 border-primary pl-4", ...props, children }),
44
- ol: ({ children, ...props }) => /* @__PURE__ */ jsx("ol", { className: "list-decimal space-y-2 pl-6", "data-testid": "markdown-ordered-list", ...props, children }),
45
- ul: ({ children, ...props }) => /* @__PURE__ */ jsx("ul", { className: "list-none space-y-2 pl-6", "data-testid": "markdown-unordered-list", ...props, children }),
46
- li: ({ children, ...props }) => /* @__PURE__ */ jsx("li", { className: "my-1.5", ...props, children }),
47
- table: ({ children, ...props }) => /* @__PURE__ */ jsx("table", { "data-testid": "markdown-table", ...props, children }),
48
- th: ({ children, ...props }) => /* @__PURE__ */ jsx("th", { ...props, children }),
49
- td: ({ children, ...props }) => /* @__PURE__ */ jsx("td", { ...props, children }),
50
- tr: ({ children, ...props }) => /* @__PURE__ */ jsx("tr", { ...props, children }),
51
- p: ({ children, ...props }) => /* @__PURE__ */ jsx("p", { className: "whitespace-pre-wrap", ...props, children }),
52
- hr: (props) => /* @__PURE__ */ jsx("hr", { className: "border-foreground/20", ...props }),
53
- sup: ({ children, ...props }) => /* @__PURE__ */ jsx("sup", { className: "text-xs", ...props, children }),
54
- sub: ({ children, ...props }) => /* @__PURE__ */ jsx("sub", { className: "text-xs", ...props, children }),
55
- div: ({ children, className, ...props }) => /* @__PURE__ */ jsx("div", { className, ...props, children }),
56
- br: (props) => /* @__PURE__ */ jsx("br", { ...props }),
57
- kbd: ({ children, ...props }) => /* @__PURE__ */ jsx(
58
- "kbd",
59
- {
60
- className: "px-1.5 py-0.5 text-xs font-mono bg-muted border border-border rounded",
61
- ...props,
62
- children
63
- }
64
- ),
65
- abbr: ({ children, title, ...props }) => /* @__PURE__ */ jsx("abbr", { title, className: "underline decoration-dotted cursor-help", ...props, children }),
66
- cite: ({ children, ...props }) => /* @__PURE__ */ jsx("cite", { className: "italic", ...props, children })
67
- };
68
- var MarkdownStreamingContext = createContext(false);
69
-
70
- // src/ai/split-markdown-blocks.ts
71
- var LIST_ITEM_RE = /^\s*([-*+]|\d+[.)])\s/;
72
- var BLOCKQUOTE_RE = /^\s*>/;
73
- function splitMarkdownBlocks(content) {
74
- if (!content) return [];
75
- const blocks = [];
76
- let start = 0;
77
- let inFence = false;
78
- let i = 0;
79
- while (i < content.length) {
80
- if (content.startsWith("```", i)) {
81
- inFence = !inFence;
82
- i += 3;
83
- continue;
84
- }
85
- if (!inFence && content[i] === "\n" && content[i + 1] === "\n") {
86
- const before = content.slice(start, i);
87
- const lastLine = before.slice(before.lastIndexOf("\n") + 1);
88
- const afterStart = i + 2;
89
- const nextNewline = content.indexOf("\n", afterStart);
90
- const nextLine = content.slice(afterStart, nextNewline === -1 ? void 0 : nextNewline);
91
- const bothListItems = LIST_ITEM_RE.test(lastLine) && LIST_ITEM_RE.test(nextLine);
92
- const bothBlockquotes = BLOCKQUOTE_RE.test(lastLine) && BLOCKQUOTE_RE.test(nextLine);
93
- if (bothListItems || bothBlockquotes) {
94
- i += 2;
95
- continue;
96
- }
97
- blocks.push(content.slice(start, afterStart));
98
- start = afterStart;
99
- i = afterStart;
100
- continue;
101
- }
102
- i++;
103
- }
104
- if (start < content.length) blocks.push(content.slice(start));
105
- return blocks;
106
- }
107
- function CodeBlock({ language, code }) {
108
- const [copied, setCopied] = useState(false);
109
- const handleCopy = async () => {
110
- try {
111
- await navigator.clipboard.writeText(code);
112
- setCopied(true);
113
- setTimeout(() => setCopied(false), 2e3);
114
- } catch {
115
- }
116
- };
117
- return /* @__PURE__ */ jsxs(
118
- "div",
119
- {
120
- className: "code-block relative my-3 overflow-hidden rounded-md border border-border bg-muted",
121
- "data-testid": "markdown-code-block",
122
- children: [
123
- /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between border-b border-border px-3 py-1.5", children: [
124
- /* @__PURE__ */ jsx("span", { className: "font-mono text-xs text-muted-foreground", children: language || "code" }),
125
- /* @__PURE__ */ jsxs(
126
- "button",
127
- {
128
- type: "button",
129
- onClick: handleCopy,
130
- className: "flex items-center gap-1 text-xs text-muted-foreground transition-colors hover:text-foreground",
131
- title: copied ? "Copied!" : "Copy code",
132
- children: [
133
- copied ? /* @__PURE__ */ jsx(Check, { size: 12 }) : /* @__PURE__ */ jsx(Copy, { size: 12 }),
134
- /* @__PURE__ */ jsx("span", { children: copied ? "Copied" : "Copy" })
135
- ]
136
- }
137
- )
138
- ] }),
139
- /* @__PURE__ */ jsx("pre", { className: "overflow-x-auto p-3 text-sm leading-relaxed", children: /* @__PURE__ */ jsx("code", { className: cn("font-mono text-foreground", language && `language-${language}`), children: code }) })
140
- ]
141
- }
142
- );
143
- }
144
- var defaultComponents = {
145
- ...markdownBaseComponents,
146
- a: ({ href, children, ...props }) => {
147
- const isInternal = !href || href.startsWith("#") || href.startsWith("cite:");
148
- return /* @__PURE__ */ jsx(
149
- "a",
150
- {
151
- className: "text-primary underline underline-offset-2",
152
- href,
153
- ...isInternal ? {} : { target: "_blank", rel: "noopener noreferrer" },
154
- ...props,
155
- children
156
- }
157
- );
158
- },
159
- em: ({ children, ...props }) => /* @__PURE__ */ jsx("em", { className: "italic", ...props, children }),
160
- code: function MarkdownCode({
161
- className,
162
- children,
163
- ...props
164
- }) {
165
- const match = /language-(\w+)/.exec(className || "");
166
- if (!match) {
167
- return /* @__PURE__ */ jsx(
168
- "code",
169
- {
170
- className: "rounded bg-muted px-1 py-0.5 font-mono text-[0.9em]",
171
- "data-testid": "markdown-inline-code",
172
- ...props,
173
- children
174
- }
175
- );
176
- }
177
- return /* @__PURE__ */ jsx(CodeBlock, { language: match[1], code: String(children).replace(/\n$/, "") });
178
- },
179
- // The CodeBlock renders its own <pre>; unwrap react-markdown's wrapper so we
180
- // don't nest <pre><pre>.
181
- pre: ({ children }) => /* @__PURE__ */ jsx(Fragment, { children }),
182
- blockquote: ({ children, ...props }) => /* @__PURE__ */ jsx("blockquote", { className: "border-l-2 border-border pl-4 italic text-muted-foreground", ...props, children }),
183
- table: ({ children, ...props }) => /* @__PURE__ */ jsx("div", { className: "my-3 overflow-x-auto rounded-lg border border-border", children: /* @__PURE__ */ jsx("table", { "data-testid": "markdown-table", className: "w-full border-collapse text-sm", ...props, children }) }),
184
- thead: ({ children, ...props }) => /* @__PURE__ */ jsx("thead", { className: "bg-muted", ...props, children }),
185
- th: ({ children, ...props }) => /* @__PURE__ */ jsx(
186
- "th",
187
- {
188
- className: "border-b border-border px-3 py-2 text-left font-semibold text-foreground",
189
- ...props,
190
- children
191
- }
192
- ),
193
- td: ({ children, ...props }) => /* @__PURE__ */ jsx("td", { className: "border-b border-border px-3 py-2 align-top", ...props, children }),
194
- // General emphasis marks (GFM `~~strikethrough~~` → <del>, raw <ins>/<mark>).
195
- del: ({ children, ...props }) => /* @__PURE__ */ jsx("del", { className: "text-muted-foreground line-through", ...props, children }),
196
- ins: ({ children, ...props }) => /* @__PURE__ */ jsx("ins", { className: "underline decoration-primary/60", ...props, children }),
197
- mark: ({ children, ...props }) => /* @__PURE__ */ jsx("mark", { className: "rounded bg-primary/15 px-0.5 text-foreground", ...props, children })
198
- };
199
- var remarkPlugins = [remarkGfm];
200
- var rehypePlugins = [rehypeRaw];
201
- var MemoizedBlock = React2__default.memo(function MarkdownBlock({
202
- content,
203
- components
204
- }) {
205
- return /* @__PURE__ */ jsx(Markdown, { remarkPlugins, rehypePlugins, components, children: content });
206
- });
207
- var MarkdownErrorBoundary = class extends React2__default.Component {
208
- state = { hasError: false };
209
- static getDerivedStateFromError() {
210
- return { hasError: true };
211
- }
212
- render() {
213
- return this.state.hasError ? this.props.fallback : this.props.children;
214
- }
215
- };
216
- function MarkdownRendererComponent({
217
- children,
218
- components: customComponents,
219
- isStreaming = false,
220
- className,
221
- testId = "markdown-renderer"
222
- }) {
223
- const components = useMemo(
224
- () => customComponents ? { ...defaultComponents, ...customComponents } : defaultComponents,
225
- [customComponents]
226
- );
227
- const blocks = useMemo(() => splitMarkdownBlocks(children), [children]);
228
- return /* @__PURE__ */ jsx(
229
- MarkdownErrorBoundary,
230
- {
231
- fallback: /* @__PURE__ */ jsx("div", { className: cn("whitespace-pre-wrap break-words text-foreground", className), children }),
232
- children: /* @__PURE__ */ jsx(MarkdownStreamingContext.Provider, { value: isStreaming, children: /* @__PURE__ */ jsx(
233
- "div",
234
- {
235
- className: cn(
236
- "markdown-content space-y-3 break-words leading-relaxed text-foreground",
237
- className
238
- ),
239
- "data-testid": testId,
240
- children: blocks.map((block, index) => /* @__PURE__ */ jsx(MemoizedBlock, { content: block, components }, index))
241
- }
242
- ) })
243
- }
244
- );
245
- }
246
- var MarkdownRenderer = React2__default.memo(MarkdownRendererComponent);
247
- var TooltipContext = React2.createContext(null);
248
- var DEFAULT_DELAY = 300;
249
- var TooltipConfigContext = React2.createContext({
250
- delayDuration: DEFAULT_DELAY
251
- });
252
- var TooltipProvider = ({ children, delayDuration = DEFAULT_DELAY }) => {
253
- const value = React2.useMemo(() => ({ delayDuration }), [delayDuration]);
254
- return /* @__PURE__ */ jsx(TooltipConfigContext.Provider, { value, children });
255
- };
256
- function Tooltip({ children, delayDuration }) {
257
- const config = React2.useContext(TooltipConfigContext);
258
- const delay = delayDuration ?? config.delayDuration;
259
- const [open, setOpen] = React2.useState(false);
260
- const triggerRef = React2.useRef(null);
261
- const timer = React2.useRef(null);
262
- const contentId = React2.useId();
263
- const clearTimer = () => {
264
- if (timer.current) {
265
- clearTimeout(timer.current);
266
- timer.current = null;
267
- }
268
- };
269
- const show = React2.useCallback(() => {
270
- clearTimer();
271
- timer.current = setTimeout(() => setOpen(true), delay);
272
- }, [delay]);
273
- const hide = React2.useCallback(() => {
274
- clearTimer();
275
- setOpen(false);
276
- }, []);
277
- const setTrigger = React2.useCallback((el) => {
278
- triggerRef.current = el;
279
- }, []);
280
- React2.useEffect(() => () => clearTimer(), []);
281
- const value = React2.useMemo(
282
- () => ({ open, show, hide, setTrigger, triggerRef, contentId }),
283
- [open, show, hide, setTrigger, contentId]
284
- );
285
- return /* @__PURE__ */ jsx(TooltipContext.Provider, { value, children });
286
- }
287
- function TooltipTrigger({ asChild, children, ...props }) {
288
- const ctx = React2.useContext(TooltipContext);
289
- if (!ctx) return /* @__PURE__ */ jsx(Fragment, { children });
290
- const triggerHandlers = {
291
- onPointerEnter: (e) => {
292
- props.onPointerEnter?.(e);
293
- ctx.show();
294
- },
295
- onPointerLeave: (e) => {
296
- props.onPointerLeave?.(e);
297
- ctx.hide();
298
- },
299
- onFocus: (e) => {
300
- props.onFocus?.(e);
301
- ctx.show();
302
- },
303
- onBlur: (e) => {
304
- props.onBlur?.(e);
305
- ctx.hide();
306
- },
307
- "aria-describedby": ctx.open ? ctx.contentId : void 0,
308
- "data-state": ctx.open ? "open" : "closed"
309
- };
310
- if (asChild && React2.isValidElement(children)) {
311
- const child = children;
312
- return React2.cloneElement(child, {
313
- ...props,
314
- ...triggerHandlers,
315
- ref: ctx.setTrigger
316
- });
317
- }
318
- return /* @__PURE__ */ jsx(
319
- "button",
320
- {
321
- type: "button",
322
- ...props,
323
- ...triggerHandlers,
324
- ref: ctx.setTrigger,
325
- children
326
- }
327
- );
328
- }
329
- var TRANSFORM_BY_SIDE = {
330
- top: "translate(-50%, -100%)",
331
- bottom: "translate(-50%, 0)",
332
- left: "translate(-100%, -50%)",
333
- right: "translate(0, -50%)"
334
- };
335
- var TooltipContent = React2.forwardRef(
336
- ({ className, side = "top", sideOffset = 4, style, ...props }, ref) => {
337
- const ctx = React2.useContext(TooltipContext);
338
- const innerRef = React2.useRef(null);
339
- const [coords, setCoords] = React2.useState(null);
340
- React2.useLayoutEffect(() => {
341
- if (!ctx?.open || !ctx.triggerRef.current) {
342
- setCoords(null);
343
- return;
344
- }
345
- const r = ctx.triggerRef.current.getBoundingClientRect();
346
- const c = innerRef.current?.getBoundingClientRect();
347
- const ch = c?.height ?? 0;
348
- const cw = c?.width ?? 0;
349
- const vh = window.innerHeight;
350
- const vw = window.innerWidth;
351
- let s = side;
352
- if (s === "top" && r.top - sideOffset - ch < 0) s = "bottom";
353
- else if (s === "bottom" && r.bottom + sideOffset + ch > vh) s = "top";
354
- else if (s === "left" && r.left - sideOffset - cw < 0) s = "right";
355
- else if (s === "right" && r.right + sideOffset + cw > vw) s = "left";
356
- setCoords({
357
- top: s === "top" ? r.top - sideOffset : s === "bottom" ? r.bottom + sideOffset : r.top + r.height / 2,
358
- left: s === "left" ? r.left - sideOffset : s === "right" ? r.right + sideOffset : r.left + r.width / 2,
359
- transform: TRANSFORM_BY_SIDE[s]
360
- });
361
- }, [ctx?.open, side, sideOffset, ctx?.triggerRef]);
362
- if (!ctx?.open) return null;
363
- const setRefs = (node) => {
364
- innerRef.current = node;
365
- if (typeof ref === "function") ref(node);
366
- else if (ref) ref.current = node;
367
- };
368
- return createPortal(
369
- /* @__PURE__ */ jsx(
370
- "div",
371
- {
372
- ref: setRefs,
373
- id: ctx.contentId,
374
- role: "tooltip",
375
- className: cn(
376
- // The kit owns the tooltip's look: semantic tokens only, so it is
377
- // legible in every app without one of them defining a global class.
378
- // The `tooltip-content` hook is kept last-but-one so a host stylesheet
379
- // can still restyle every tooltip in one place (the ARBI app does, with
380
- // `!important` rules that win over these defaults).
381
- "pointer-events-none max-w-[300px] break-words rounded-md border border-border bg-popover px-3 py-2 text-sm font-normal text-popover-foreground shadow-lg",
382
- "tooltip-content",
383
- className
384
- ),
385
- style: {
386
- position: "fixed",
387
- top: coords?.top ?? -9999,
388
- left: coords?.left ?? -9999,
389
- transform: coords?.transform ?? TRANSFORM_BY_SIDE[side],
390
- opacity: coords ? void 0 : 0,
391
- zIndex: 9999,
392
- ...style
393
- },
394
- ...props
395
- }
396
- ),
397
- document.body
398
- );
399
- }
400
- );
401
- TooltipContent.displayName = "TooltipContent";
402
- function IconToggle({
403
- icon: Icon2,
404
- isActive,
405
- onToggle,
406
- colors,
407
- fillWhenActive = false,
408
- disabled = false,
409
- disabledTooltip,
410
- showLabel = false,
411
- label,
412
- tooltipActive,
413
- tooltipInactive,
414
- tooltipMixed,
415
- isMixed = false,
416
- showTooltip = true,
417
- "data-testid": dataTestId
418
- }) {
419
- const handleClick = (e) => {
420
- e.stopPropagation();
421
- onToggle(!isActive);
422
- };
423
- const { bg: bgColorClass } = colors;
424
- const tooltipText = disabled ? disabledTooltip : isMixed ? tooltipMixed : isActive ? tooltipActive : tooltipInactive;
425
- const { text: textColorClass } = colors;
426
- const button = /* @__PURE__ */ jsx("div", { className: "inline-flex items-center gap-2", children: /* @__PURE__ */ jsxs(
427
- "button",
428
- {
429
- type: "button",
430
- onClick: handleClick,
431
- disabled,
432
- "data-testid": dataTestId,
433
- "aria-pressed": isMixed ? "mixed" : isActive,
434
- className: `
435
- group/toggle relative inline-flex items-center h-4 w-8 rounded-full
436
- transition-colors cursor-pointer
437
- disabled:opacity-50 disabled:cursor-not-allowed
438
- ${isActive ? bgColorClass : isMixed ? "bg-gray-400" : "bg-muted"}
439
- `,
440
- children: [
441
- isActive && !disabled && /* @__PURE__ */ jsx("div", { className: "absolute left-0 w-4 h-4 flex items-center justify-center", children: /* @__PURE__ */ jsx(Minus, { className: "w-2.5 h-2.5 text-white/70 hidden group-hover/toggle:block" }) }),
442
- !isActive && !disabled && /* @__PURE__ */ jsx("div", { className: "absolute right-0 w-4 h-4 flex items-center justify-center", children: /* @__PURE__ */ jsx(Plus, { className: "w-2.5 h-2.5 text-muted-foreground hidden group-hover/toggle:block" }) }),
443
- /* @__PURE__ */ jsx(
444
- "div",
445
- {
446
- className: `
447
- absolute h-4 w-4 rounded-full bg-white shadow-sm
448
- flex items-center justify-center
449
- transition-transform duration-200
450
- ${isActive ? "translate-x-4" : "translate-x-0"}
451
- `,
452
- children: /* @__PURE__ */ jsx(
453
- Icon2,
454
- {
455
- className: `w-2.5 h-2.5 ${isActive ? textColorClass : "text-muted-foreground"} ${isActive && fillWhenActive ? "fill-current" : ""}`
456
- }
457
- )
458
- }
459
- )
460
- ]
461
- }
462
- ) });
463
- return /* @__PURE__ */ jsxs("div", { className: "inline-flex items-center gap-2", children: [
464
- showLabel && label && /* @__PURE__ */ jsx("span", { className: "font-semibold text-sm text-primary", children: label }),
465
- tooltipText && showTooltip ? /* @__PURE__ */ jsxs(Tooltip, { children: [
466
- /* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, onFocusCapture: (e) => e.stopPropagation(), children: button }),
467
- /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: tooltipText }) })
468
- ] }) : button
469
- ] });
470
- }
471
- var DictateContext = createContext(null);
472
- function DictateProvider({
473
- transcribe,
474
- onError,
475
- children
476
- }) {
477
- return /* @__PURE__ */ jsx(DictateContext.Provider, { value: { transcribe, onError }, children });
478
- }
479
- function useDictateContext() {
480
- return useContext(DictateContext);
481
- }
482
- var Avatar = React2.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
483
- AvatarPrimitive.Root,
484
- {
485
- ref,
486
- className: cn("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full", className),
487
- ...props
488
- }
489
- ));
490
- Avatar.displayName = AvatarPrimitive.Root.displayName;
491
- var AvatarImage = React2.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
492
- AvatarPrimitive.Image,
493
- {
494
- ref,
495
- className: cn("aspect-square h-full w-full object-cover", className),
496
- ...props
497
- }
498
- ));
499
- AvatarImage.displayName = AvatarPrimitive.Image.displayName;
500
- var AvatarFallback = React2.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
501
- AvatarPrimitive.Fallback,
502
- {
503
- ref,
504
- className: cn(
505
- "flex h-full w-full items-center justify-center rounded-full bg-muted",
506
- className
507
- ),
508
- ...props
509
- }
510
- ));
511
- AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName;
512
- var badgeVariants = cva(
513
- "inline-flex items-center rounded-md border px-2.5 py-0.5 text-sm font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
514
- {
515
- variants: {
516
- variant: {
517
- default: "border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",
518
- accent: "border-transparent bg-ai-accent-soft text-ai-accent",
519
- secondary: "border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",
520
- destructive: "border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",
521
- outline: "text-foreground"
522
- }
523
- },
524
- defaultVariants: {
525
- variant: "default"
526
- }
527
- }
528
- );
529
- function Badge({ className, variant, ...props }) {
530
- return /* @__PURE__ */ jsx("div", { className: cn(badgeVariants({ variant }), className), ...props });
531
- }
532
- var buttonVariants = cva(
533
- "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-base font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0",
534
- {
535
- variants: {
536
- variant: {
537
- default: "bg-primary text-primary-foreground shadow hover:bg-primary/90",
538
- accent: "bg-ai-accent text-ai-accent-foreground shadow hover:bg-ai-accent/90",
539
- destructive: "bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",
540
- outline: "border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",
541
- secondary: "bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",
542
- ghost: "hover:bg-accent hover:text-accent-foreground",
543
- link: "text-primary underline-offset-4 hover:underline"
544
- },
545
- size: {
546
- default: "h-9 px-4 py-2",
547
- sm: "h-8 rounded-md px-3",
548
- lg: "h-10 rounded-md px-8",
549
- icon: "h-9 w-9"
550
- }
551
- },
552
- defaultVariants: {
553
- variant: "default",
554
- size: "default"
555
- }
556
- }
557
- );
558
- var Button = React2.forwardRef(
559
- ({ className, variant, size, asChild = false, ...props }, ref) => {
560
- const Comp = asChild ? Slot : "button";
561
- return /* @__PURE__ */ jsx(Comp, { className: cn(buttonVariants({ variant, size, className })), ref, ...props });
562
- }
563
- );
564
- Button.displayName = "Button";
565
- var HoverCard = HoverCardPrimitive.Root;
566
- var HoverCardTrigger = HoverCardPrimitive.Trigger;
567
- var HoverCardContent = React2.forwardRef(({ className, align = "center", sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsx(HoverCardPrimitive.Portal, { children: /* @__PURE__ */ jsx(
568
- HoverCardPrimitive.Content,
569
- {
570
- ref,
571
- align,
572
- sideOffset,
573
- className: cn(
574
- "z-50 w-64 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-hover-card-content-transform-origin]",
575
- className
576
- ),
577
- ...props
578
- }
579
- ) }));
580
- HoverCardContent.displayName = HoverCardPrimitive.Content.displayName;
581
- var cardVariants = cva("rounded-lg bg-card text-card-foreground", {
582
- variants: {
583
- variant: {
584
- flat: "",
585
- outline: "border",
586
- elevated: "border shadow-sm"
587
- }
588
- },
589
- defaultVariants: {
590
- variant: "flat"
591
- }
592
- });
593
- var Card = React2.forwardRef(
594
- ({ className, variant, ...props }, ref) => /* @__PURE__ */ jsx(
595
- "div",
596
- {
597
- ref,
598
- "data-slot": "card",
599
- className: cn(cardVariants({ variant }), className),
600
- ...props
601
- }
602
- )
603
- );
604
- Card.displayName = "Card";
605
- var CardHeader = React2.forwardRef(
606
- ({ className, ...props }, ref) => /* @__PURE__ */ jsx(
607
- "div",
608
- {
609
- ref,
610
- "data-slot": "card-header",
611
- className: cn("flex flex-col space-y-1.5 p-6", className),
612
- ...props
613
- }
614
- )
615
- );
616
- CardHeader.displayName = "CardHeader";
617
- var CardTitle = React2.forwardRef(
618
- ({ className, ...props }, ref) => /* @__PURE__ */ jsx(
619
- "div",
620
- {
621
- ref,
622
- "data-slot": "card-title",
623
- className: cn("font-semibold leading-none tracking-tight", className),
624
- ...props
625
- }
626
- )
627
- );
628
- CardTitle.displayName = "CardTitle";
629
- var CardDescription = React2.forwardRef(
630
- ({ className, ...props }, ref) => /* @__PURE__ */ jsx(
631
- "div",
632
- {
633
- ref,
634
- "data-slot": "card-description",
635
- className: cn("text-sm text-muted-foreground", className),
636
- ...props
637
- }
638
- )
639
- );
640
- CardDescription.displayName = "CardDescription";
641
- var CardContent = React2.forwardRef(
642
- ({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { ref, "data-slot": "card-content", className: cn("p-6 pt-0", className), ...props })
643
- );
644
- CardContent.displayName = "CardContent";
645
- var CardFooter = React2.forwardRef(
646
- ({ className, ...props }, ref) => /* @__PURE__ */ jsx(
647
- "div",
648
- {
649
- ref,
650
- "data-slot": "card-footer",
651
- className: cn("flex items-center p-6 pt-0", className),
652
- ...props
653
- }
654
- )
655
- );
656
- CardFooter.displayName = "CardFooter";
657
-
658
- // src/documents/media-error.ts
659
- function classifyMediaError(err, kind) {
660
- const label = kind === "camera" ? "Camera" : "Microphone";
661
- const name = err instanceof DOMException ? err.name : void 0;
662
- if (name === "NotAllowedError" || name === "SecurityError") {
663
- return `${label} access is blocked. Allow ${kind} permission in your browser settings to use this feature.`;
664
- }
665
- if (name === "NotFoundError" || name === "DevicesNotFoundError") {
666
- return `No ${kind} found on this device.`;
667
- }
668
- if (!navigator.mediaDevices?.getUserMedia) {
669
- return `${kind === "camera" ? "Camera" : "Voice"} input is not supported in this browser.`;
670
- }
671
- return `Could not access the ${kind}. Please try again.`;
672
- }
673
-
674
- // src/documents/useAudioRecorder.ts
675
- var LEVEL_UPDATE_INTERVAL_MS = 50;
676
- function useAudioRecorder() {
677
- const [state, setState] = useState("idle");
678
- const [level, setLevel] = useState(0);
679
- const [elapsedMs, setElapsedMs] = useState(0);
680
- const [blob, setBlob] = useState(null);
681
- const [mimeType, setMimeType] = useState(null);
682
- const [error, setError] = useState(null);
683
- const mediaRecorderRef = useRef(null);
684
- const chunksRef = useRef([]);
685
- const streamRef = useRef(null);
686
- const stateRef = useRef("idle");
687
- stateRef.current = state;
688
- const segmentStartRef = useRef(0);
689
- const accumulatedMsRef = useRef(0);
690
- const audioContextRef = useRef(null);
691
- const analyserRef = useRef(null);
692
- const levelRafRef = useRef(null);
693
- const stopMeter = useCallback(() => {
694
- if (levelRafRef.current !== null) cancelAnimationFrame(levelRafRef.current);
695
- levelRafRef.current = null;
696
- analyserRef.current = null;
697
- void audioContextRef.current?.close().catch(() => {
698
- });
699
- audioContextRef.current = null;
700
- }, []);
701
- const startMeter = useCallback((stream) => {
702
- const audioContext = new AudioContext();
703
- const source = audioContext.createMediaStreamSource(stream);
704
- const analyser = audioContext.createAnalyser();
705
- analyser.fftSize = 256;
706
- source.connect(analyser);
707
- audioContextRef.current = audioContext;
708
- analyserRef.current = analyser;
709
- const data = new Uint8Array(analyser.frequencyBinCount);
710
- let lastUpdate = 0;
711
- const tick = (t) => {
712
- const active = analyserRef.current;
713
- if (!active) return;
714
- if (t - lastUpdate >= LEVEL_UPDATE_INTERVAL_MS) {
715
- lastUpdate = t;
716
- active.getByteTimeDomainData(data);
717
- let sumSquares = 0;
718
- for (let i = 0; i < data.length; i++) {
719
- const centered = (data[i] - 128) / 128;
720
- sumSquares += centered * centered;
721
- }
722
- const rms = Math.sqrt(sumSquares / data.length);
723
- setLevel(Math.sqrt(Math.min(1, rms * 8)));
724
- setElapsedMs(accumulatedMsRef.current + (t - segmentStartRef.current));
725
- }
726
- levelRafRef.current = requestAnimationFrame(tick);
727
- };
728
- levelRafRef.current = requestAnimationFrame(tick);
729
- }, []);
730
- const stopTracks = useCallback(() => {
731
- streamRef.current?.getTracks().forEach((t) => t.stop());
732
- streamRef.current = null;
733
- }, []);
734
- useEffect(
735
- () => () => {
736
- stopTracks();
737
- stopMeter();
738
- },
739
- [stopTracks, stopMeter]
740
- );
741
- const start = useCallback(async () => {
742
- if (stateRef.current === "recording" || stateRef.current === "paused") return;
743
- setError(null);
744
- try {
745
- const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
746
- streamRef.current = stream;
747
- const mt = MediaRecorder.isTypeSupported("audio/webm") ? "audio/webm" : "audio/mp4";
748
- const recorder = new MediaRecorder(stream, { mimeType: mt });
749
- chunksRef.current = [];
750
- recorder.ondataavailable = (e) => {
751
- if (e.data.size > 0) chunksRef.current.push(e.data);
752
- };
753
- mediaRecorderRef.current = recorder;
754
- setMimeType(mt);
755
- setBlob(null);
756
- accumulatedMsRef.current = 0;
757
- segmentStartRef.current = performance.now();
758
- recorder.start();
759
- setState("recording");
760
- startMeter(stream);
761
- } catch (err) {
762
- stopTracks();
763
- setError(classifyMediaError(err, "microphone"));
764
- }
765
- }, [startMeter, stopTracks]);
766
- const pause = useCallback(() => {
767
- const recorder = mediaRecorderRef.current;
768
- if (!recorder || recorder.state !== "recording") return;
769
- recorder.pause();
770
- accumulatedMsRef.current += performance.now() - segmentStartRef.current;
771
- stopMeter();
772
- setLevel(0);
773
- setState("paused");
774
- }, [stopMeter]);
775
- const resume = useCallback(() => {
776
- const recorder = mediaRecorderRef.current;
777
- if (!recorder || recorder.state !== "paused") return;
778
- recorder.resume();
779
- segmentStartRef.current = performance.now();
780
- setState("recording");
781
- if (streamRef.current) startMeter(streamRef.current);
782
- }, [startMeter]);
783
- const stop = useCallback(() => {
784
- const recorder = mediaRecorderRef.current;
785
- if (!recorder || recorder.state === "inactive") return;
786
- const finalElapsed = recorder.state === "paused" ? accumulatedMsRef.current : accumulatedMsRef.current + (performance.now() - segmentStartRef.current);
787
- stopMeter();
788
- recorder.onstop = () => {
789
- stopTracks();
790
- const finalBlob = chunksRef.current.length ? new Blob(chunksRef.current, { type: recorder.mimeType }) : null;
791
- setBlob(finalBlob);
792
- setElapsedMs(finalElapsed);
793
- setLevel(0);
794
- setState("stopped");
795
- };
796
- recorder.stop();
797
- }, [stopMeter, stopTracks]);
798
- const reset = useCallback(() => {
799
- setState("idle");
800
- setBlob(null);
801
- setElapsedMs(0);
802
- setLevel(0);
803
- setMimeType(null);
804
- setError(null);
805
- }, []);
806
- return { state, level, elapsedMs, blob, mimeType, error, start, pause, resume, stop, reset };
807
- }
808
-
809
- // src/documents/format-elapsed.ts
810
- function formatElapsed(ms) {
811
- const totalSeconds = Math.max(0, Math.floor(ms / 1e3));
812
- const minutes = Math.floor(totalSeconds / 60);
813
- const seconds = totalSeconds % 60;
814
- return `${String(minutes).padStart(2, "0")}:${String(seconds).padStart(2, "0")}`;
815
- }
816
- var BAR_WEIGHTS = [
817
- 0.25,
818
- 0.32,
819
- 0.48,
820
- 0.62,
821
- 0.82,
822
- 0.56,
823
- 0.92,
824
- 0.72,
825
- 1,
826
- 0.86,
827
- 0.62,
828
- 0.96,
829
- 0.76,
830
- 0.5,
831
- 0.84,
832
- 0.66,
833
- 0.42,
834
- 0.56,
835
- 0.36,
836
- 0.28,
837
- 0.22
838
- ];
839
- var MIN_BAR_PX = 3;
840
- var MAX_BAR_PX = 40;
841
- function MicWaveformIndicator({
842
- level,
843
- elapsedMs,
844
- paused = false
845
- }) {
846
- return /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center gap-3", "data-testid": "mic-waveform-indicator", children: [
847
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
848
- /* @__PURE__ */ jsxs("span", { className: "relative flex h-2 w-2", children: [
849
- !paused && /* @__PURE__ */ jsx("span", { className: "absolute inline-flex h-full w-full animate-ping rounded-full bg-red-500 opacity-75" }),
850
- /* @__PURE__ */ jsx(
851
- "span",
852
- {
853
- className: `relative inline-flex h-2 w-2 rounded-full ${paused ? "bg-muted-foreground" : "bg-red-500"}`
854
- }
855
- )
856
- ] }),
857
- /* @__PURE__ */ jsx(
858
- "span",
859
- {
860
- className: `text-xs font-semibold uppercase tracking-wide ${paused ? "text-muted-foreground" : "text-red-500"}`,
861
- children: paused ? "Paused" : "Rec"
862
- }
863
- ),
864
- /* @__PURE__ */ jsx("span", { className: "font-mono text-xs tabular-nums text-muted-foreground", children: formatElapsed(elapsedMs) })
865
- ] }),
866
- /* @__PURE__ */ jsx("div", { className: "flex h-10 items-end gap-[3px]", "data-testid": "mic-waveform-indicator-bars", children: BAR_WEIGHTS.map((weight, i) => /* @__PURE__ */ jsx(
867
- "span",
868
- {
869
- className: "w-1 rounded-full bg-secondary transition-[height] duration-75 ease-out",
870
- style: {
871
- height: Math.min(MAX_BAR_PX, Math.max(MIN_BAR_PX, level * weight * MAX_BAR_PX))
872
- }
873
- },
874
- i
875
- )) })
876
- ] });
877
- }
878
- function MicRecordingOverlay({
879
- level,
880
- elapsedMs,
881
- paused,
882
- caption = "Keep button pressed while speaking"
883
- }) {
884
- if (typeof document === "undefined") return null;
885
- return createPortal(
886
- /* @__PURE__ */ jsx(
887
- "div",
888
- {
889
- "aria-hidden": true,
890
- className: "pointer-events-none fixed inset-0 z-[2147483647] flex items-center justify-center",
891
- "data-testid": "mic-recording-overlay",
892
- children: /* @__PURE__ */ jsxs("div", { className: "flex w-72 flex-col items-center gap-3 rounded-2xl bg-background/95 px-6 py-5 shadow-2xl ring-1 ring-border backdrop-blur-sm", children: [
893
- /* @__PURE__ */ jsx(MicWaveformIndicator, { level, elapsedMs, paused }),
894
- /* @__PURE__ */ jsx("p", { className: "text-center text-sm font-medium text-muted-foreground", children: caption })
895
- ] })
896
- }
897
- ),
898
- document.body
899
- );
900
- }
901
- var HOLD_THRESHOLD_MS = 350;
902
- function InlineMicButton({
903
- focused,
904
- onTranscript,
905
- onError,
906
- transcribe,
907
- className
908
- }) {
909
- const recorder = useAudioRecorder();
910
- const [isTranscribing, setIsTranscribing] = useState(false);
911
- const [latched, setLatched] = useState(false);
912
- const pressedAtRef = useRef(0);
913
- useEffect(() => {
914
- if (recorder.error) onError?.(recorder.error);
915
- }, [recorder.error]);
916
- useEffect(() => {
917
- if (recorder.state !== "stopped" || !recorder.blob) return;
918
- const blob = recorder.blob;
919
- setIsTranscribing(true);
920
- transcribe(blob).then((text) => {
921
- if (text.trim()) onTranscript(text.trim());
922
- }).catch((err) => {
923
- onError?.(err instanceof Error ? err.message : "Could not transcribe audio.");
924
- }).finally(() => {
925
- setIsTranscribing(false);
926
- setLatched(false);
927
- recorder.reset();
928
- });
929
- }, [recorder.state, recorder.blob]);
930
- const isRecording = recorder.state === "recording";
931
- const isBusy = isTranscribing;
932
- if (!focused && !isRecording && !isBusy) return null;
933
- const handlePointerDown = (e) => {
934
- e.preventDefault();
935
- if (isRecording) return;
936
- pressedAtRef.current = Date.now();
937
- void recorder.start();
938
- };
939
- const handlePointerUp = () => {
940
- if (!isRecording) return;
941
- if (latched) {
942
- recorder.stop();
943
- setLatched(false);
944
- return;
945
- }
946
- const held = Date.now() - pressedAtRef.current;
947
- if (held >= HOLD_THRESHOLD_MS) {
948
- recorder.stop();
949
- } else {
950
- setLatched(true);
951
- }
952
- };
953
- const handlePointerLeave = () => {
954
- if (isRecording && !latched) recorder.stop();
955
- };
956
- return /* @__PURE__ */ jsxs(Fragment, { children: [
957
- /* @__PURE__ */ jsx(
958
- "button",
959
- {
960
- type: "button",
961
- onPointerDown: handlePointerDown,
962
- onPointerUp: handlePointerUp,
963
- onPointerLeave: handlePointerLeave,
964
- onPointerCancel: handlePointerLeave,
965
- disabled: isBusy,
966
- title: isRecording ? "Release to stop, or tap again if hands-free" : "Hold, or tap to dictate",
967
- "data-testid": "inline-mic-button",
968
- className: `inline-flex items-center justify-center rounded-full transition-colors disabled:pointer-events-none ${isRecording ? "h-7 w-7 bg-red-500 text-white shadow-sm hover:bg-red-600" : isBusy ? "h-6 w-6 text-muted-foreground" : "h-6 w-6 text-muted-foreground/50 hover:bg-muted hover:text-muted-foreground"} ${className ?? ""}`,
969
- children: isBusy ? /* @__PURE__ */ jsx(Loader2, { className: "h-3.5 w-3.5 animate-spin" }) : isRecording ? /* @__PURE__ */ jsx(Square, { className: "h-3 w-3 fill-current" }) : /* @__PURE__ */ jsx(Mic, { className: "h-3.5 w-3.5" })
970
- }
971
- ),
972
- isRecording && /* @__PURE__ */ jsx(
973
- MicRecordingOverlay,
974
- {
975
- level: recorder.level,
976
- elapsedMs: recorder.elapsedMs,
977
- caption: latched ? "Tap the mic again to stop" : "Release to stop, or keep holding"
978
- }
979
- )
980
- ] });
981
- }
982
- var Input = React2.forwardRef(
983
- ({ className, type, dictate, onFocus, onBlur, ...props }, forwardedRef) => {
984
- const dictateCtx = useDictateContext();
985
- const [focused, setFocused] = React2.useState(false);
986
- const innerRef = React2.useRef(null);
987
- React2.useImperativeHandle(forwardedRef, () => innerRef.current);
988
- const showDictate = dictate && !!dictateCtx && !props.disabled && !props.readOnly;
989
- const input = /* @__PURE__ */ jsx(
990
- "input",
991
- {
992
- type,
993
- "data-slot": "input",
994
- className: cn(
995
- "flex h-9 w-full rounded-md border border-input bg-background px-3 py-1 text-base shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground/60 focus-visible:outline-none focus-visible:border-ring/50 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
996
- showDictate && "pr-9",
997
- className
998
- ),
999
- ref: innerRef,
1000
- onFocus: (e) => {
1001
- setFocused(true);
1002
- onFocus?.(e);
1003
- },
1004
- onBlur: (e) => {
1005
- setFocused(false);
1006
- onBlur?.(e);
1007
- },
1008
- ...props
1009
- }
1010
- );
1011
- if (!showDictate) return input;
1012
- return /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
1013
- input,
1014
- /* @__PURE__ */ jsx(
1015
- InlineMicButton,
1016
- {
1017
- focused,
1018
- transcribe: dictateCtx.transcribe,
1019
- onError: dictateCtx.onError,
1020
- className: "absolute right-1.5 top-1/2 -translate-y-1/2",
1021
- onTranscript: (text) => {
1022
- const el = innerRef.current;
1023
- if (!el) return;
1024
- const next = el.value ? `${el.value} ${text}` : text;
1025
- const setter = Object.getOwnPropertyDescriptor(
1026
- window.HTMLInputElement.prototype,
1027
- "value"
1028
- )?.set;
1029
- setter?.call(el, next);
1030
- el.dispatchEvent(new Event("input", { bubbles: true }));
1031
- }
1032
- }
1033
- )
1034
- ] });
1035
- }
1036
- );
1037
- Input.displayName = "Input";
1038
- var Label = React2.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
1039
- "label",
1040
- {
1041
- ref,
1042
- className: `text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70 ${className || ""}`,
1043
- ...props
1044
- }
1045
- ));
1046
- Label.displayName = "Label";
1047
- var Separator = React2.forwardRef(({ className, orientation = "horizontal", decorative = true, ...props }, ref) => /* @__PURE__ */ jsx(
1048
- SeparatorPrimitive.Root,
1049
- {
1050
- ref,
1051
- decorative,
1052
- orientation,
1053
- className: cn(
1054
- "shrink-0 bg-border",
1055
- orientation === "horizontal" ? "h-[1px] w-full" : "h-full w-[1px]",
1056
- className
1057
- ),
1058
- ...props
1059
- }
1060
- ));
1061
- Separator.displayName = SeparatorPrimitive.Root.displayName;
1062
- var Textarea = React2.forwardRef(
1063
- ({ className, dictate, onFocus, onBlur, ...props }, forwardedRef) => {
1064
- const dictateCtx = useDictateContext();
1065
- const [focused, setFocused] = React2.useState(false);
1066
- const innerRef = React2.useRef(null);
1067
- React2.useImperativeHandle(forwardedRef, () => innerRef.current);
1068
- const showDictate = dictate && !!dictateCtx && !props.disabled && !props.readOnly;
1069
- const textarea = /* @__PURE__ */ jsx(
1070
- "textarea",
1071
- {
1072
- className: cn(
1073
- "flex min-h-[60px] w-full rounded-md border border-input bg-background px-3 py-2 text-base shadow-sm placeholder:text-muted-foreground/60 focus-visible:outline-none focus-visible:border-ring/50 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
1074
- showDictate && "pr-9",
1075
- className
1076
- ),
1077
- ref: innerRef,
1078
- onFocus: (e) => {
1079
- setFocused(true);
1080
- onFocus?.(e);
1081
- },
1082
- onBlur: (e) => {
1083
- setFocused(false);
1084
- onBlur?.(e);
1085
- },
1086
- ...props
1087
- }
1088
- );
1089
- if (!showDictate) return textarea;
1090
- return /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
1091
- textarea,
1092
- /* @__PURE__ */ jsx(
1093
- InlineMicButton,
1094
- {
1095
- focused,
1096
- transcribe: dictateCtx.transcribe,
1097
- onError: dictateCtx.onError,
1098
- className: "absolute right-1.5 top-1.5",
1099
- onTranscript: (text) => {
1100
- const el = innerRef.current;
1101
- if (!el) return;
1102
- const next = el.value ? `${el.value} ${text}` : text;
1103
- const setter = Object.getOwnPropertyDescriptor(
1104
- window.HTMLTextAreaElement.prototype,
1105
- "value"
1106
- )?.set;
1107
- setter?.call(el, next);
1108
- el.dispatchEvent(new Event("input", { bubbles: true }));
1109
- }
1110
- }
1111
- )
1112
- ] });
1113
- }
1114
- );
1115
- Textarea.displayName = "Textarea";
1116
- var Collapsible = CollapsiblePrimitive.Root;
1117
- var CollapsibleTrigger2 = CollapsiblePrimitive.CollapsibleTrigger;
1118
- var CollapsibleContent2 = CollapsiblePrimitive.CollapsibleContent;
1119
- var Progress = React2.forwardRef(({ className, value, ...props }, ref) => /* @__PURE__ */ jsx(
1120
- ProgressPrimitive.Root,
1121
- {
1122
- ref,
1123
- className: cn("relative h-2 w-full overflow-hidden rounded-full bg-primary/20", className),
1124
- ...props,
1125
- children: /* @__PURE__ */ jsx(
1126
- ProgressPrimitive.Indicator,
1127
- {
1128
- className: "h-full w-full flex-1 bg-primary transition-all",
1129
- style: { transform: `translateX(-${100 - (value || 0)}%)` }
1130
- }
1131
- )
1132
- }
1133
- ));
1134
- Progress.displayName = ProgressPrimitive.Root.displayName;
1135
- var ScrollArea = React2.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs(
1136
- ScrollAreaPrimitive.Root,
1137
- {
1138
- ref,
1139
- className: cn("relative overflow-hidden", className),
1140
- ...props,
1141
- children: [
1142
- /* @__PURE__ */ jsx(ScrollAreaPrimitive.Viewport, { className: "h-full w-full rounded-[inherit]", children }),
1143
- /* @__PURE__ */ jsx(ScrollBar, {}),
1144
- /* @__PURE__ */ jsx(ScrollAreaPrimitive.Corner, {})
1145
- ]
1146
- }
1147
- ));
1148
- ScrollArea.displayName = ScrollAreaPrimitive.Root.displayName;
1149
- var ScrollBar = React2.forwardRef(({ className, orientation = "vertical", ...props }, ref) => /* @__PURE__ */ jsx(
1150
- ScrollAreaPrimitive.ScrollAreaScrollbar,
1151
- {
1152
- ref,
1153
- orientation,
1154
- className: cn(
1155
- "flex touch-none select-none transition-colors",
1156
- orientation === "vertical" && "h-full w-2.5 border-l border-l-transparent p-[1px]",
1157
- orientation === "horizontal" && "h-2.5 flex-col border-t border-t-transparent p-[1px]",
1158
- className
1159
- ),
1160
- ...props,
1161
- children: /* @__PURE__ */ jsx(ScrollAreaPrimitive.ScrollAreaThumb, { className: "relative flex-1 rounded-full bg-border" })
1162
- }
1163
- ));
1164
- ScrollBar.displayName = ScrollAreaPrimitive.ScrollAreaScrollbar.displayName;
1165
- var RadioGroup = React2.forwardRef(({ className, ...props }, ref) => {
1166
- return /* @__PURE__ */ jsx(RadioGroupPrimitive.Root, { className: cn("grid gap-2", className), ...props, ref });
1167
- });
1168
- RadioGroup.displayName = RadioGroupPrimitive.Root.displayName;
1169
- var RadioGroupItem = React2.forwardRef(({ className, ...props }, ref) => {
1170
- return /* @__PURE__ */ jsx(
1171
- RadioGroupPrimitive.Item,
1172
- {
1173
- ref,
1174
- className: cn(
1175
- "aspect-square h-4 w-4 rounded-full border border-primary text-primary focus:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",
1176
- className
1177
- ),
1178
- ...props,
1179
- children: /* @__PURE__ */ jsx(RadioGroupPrimitive.Indicator, { className: "flex items-center justify-center", children: /* @__PURE__ */ jsx(Circle, { className: "h-2.5 w-2.5 fill-current text-current" }) })
1180
- }
1181
- );
1182
- });
1183
- RadioGroupItem.displayName = RadioGroupPrimitive.Item.displayName;
1184
- var Checkbox = React2.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
1185
- CheckboxPrimitive.Root,
1186
- {
1187
- ref,
1188
- className: cn(
1189
- "peer h-4 w-4 shrink-0 rounded-sm border border-primary shadow focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",
1190
- className
1191
- ),
1192
- ...props,
1193
- children: /* @__PURE__ */ jsx(CheckboxPrimitive.Indicator, { className: cn("flex items-center justify-center text-current"), children: /* @__PURE__ */ jsx(Check, { className: "h-4 w-4" }) })
1194
- }
1195
- ));
1196
- Checkbox.displayName = CheckboxPrimitive.Root.displayName;
1197
- var Switch = React2.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
1198
- SwitchPrimitives.Root,
1199
- {
1200
- className: cn(
1201
- "peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",
1202
- className
1203
- ),
1204
- ...props,
1205
- ref,
1206
- children: /* @__PURE__ */ jsx(
1207
- SwitchPrimitives.Thumb,
1208
- {
1209
- className: cn(
1210
- "pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0"
1211
- )
1212
- }
1213
- )
1214
- }
1215
- ));
1216
- Switch.displayName = SwitchPrimitives.Root.displayName;
1217
- var Tabs = TabsPrimitive.Root;
1218
- var TabsList = React2.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
1219
- TabsPrimitive.List,
1220
- {
1221
- ref,
1222
- className: cn(
1223
- "inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",
1224
- className
1225
- ),
1226
- ...props
1227
- }
1228
- ));
1229
- TabsList.displayName = TabsPrimitive.List.displayName;
1230
- var TabsTrigger = React2.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
1231
- TabsPrimitive.Trigger,
1232
- {
1233
- ref,
1234
- className: cn(
1235
- "inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow",
1236
- className
1237
- ),
1238
- ...props
1239
- }
1240
- ));
1241
- TabsTrigger.displayName = TabsPrimitive.Trigger.displayName;
1242
- var TabsContent = React2.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
1243
- TabsPrimitive.Content,
1244
- {
1245
- ref,
1246
- className: cn(
1247
- "mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
1248
- className
1249
- ),
1250
- ...props
1251
- }
1252
- ));
1253
- TabsContent.displayName = TabsPrimitive.Content.displayName;
1254
- var Table = React2.forwardRef(
1255
- ({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { className: "relative w-full overflow-auto", children: /* @__PURE__ */ jsx("table", { ref, className: cn("w-full caption-bottom text-sm", className), ...props }) })
1256
- );
1257
- Table.displayName = "Table";
1258
- var TableHeader = React2.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("thead", { ref, className: cn("[&_tr]:border-b", className), ...props }));
1259
- TableHeader.displayName = "TableHeader";
1260
- var TableBody = React2.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("tbody", { ref, className: cn("[&_tr:last-child]:border-0", className), ...props }));
1261
- TableBody.displayName = "TableBody";
1262
- var TableFooter = React2.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
1263
- "tfoot",
1264
- {
1265
- ref,
1266
- className: cn("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0", className),
1267
- ...props
1268
- }
1269
- ));
1270
- TableFooter.displayName = "TableFooter";
1271
- var TableRow = React2.forwardRef(
1272
- ({ className, ...props }, ref) => /* @__PURE__ */ jsx(
1273
- "tr",
1274
- {
1275
- ref,
1276
- className: cn(
1277
- "border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",
1278
- className
1279
- ),
1280
- ...props
1281
- }
1282
- )
1283
- );
1284
- TableRow.displayName = "TableRow";
1285
- var TableHead = React2.forwardRef(
1286
- ({ className, ...props }, ref) => /* @__PURE__ */ jsx(
1287
- "th",
1288
- {
1289
- ref,
1290
- className: cn(
1291
- "h-10 px-2 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",
1292
- className
1293
- ),
1294
- ...props
1295
- }
1296
- )
1297
- );
1298
- TableHead.displayName = "TableHead";
1299
- var TableCell = React2.forwardRef(
1300
- ({ className, ...props }, ref) => /* @__PURE__ */ jsx(
1301
- "td",
1302
- {
1303
- ref,
1304
- className: cn(
1305
- "p-2 align-middle [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",
1306
- className
1307
- ),
1308
- ...props
1309
- }
1310
- )
1311
- );
1312
- TableCell.displayName = "TableCell";
1313
- var TableCaption = React2.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("caption", { ref, className: cn("mt-4 text-sm text-muted-foreground", className), ...props }));
1314
- TableCaption.displayName = "TableCaption";
1315
- var Slider = React2.forwardRef(
1316
- ({ className, rangeClassName, ...props }, ref) => /* @__PURE__ */ jsxs(
1317
- SliderPrimitive.Root,
1318
- {
1319
- ref,
1320
- className: cn("relative flex w-full touch-none select-none items-center", className),
1321
- ...props,
1322
- children: [
1323
- /* @__PURE__ */ jsx(SliderPrimitive.Track, { className: "relative h-1.5 w-full grow overflow-hidden rounded-full bg-primary/20", children: /* @__PURE__ */ jsx(SliderPrimitive.Range, { className: cn("absolute h-full bg-primary", rangeClassName) }) }),
1324
- /* @__PURE__ */ jsx(SliderPrimitive.Thumb, { className: "block h-4 w-4 rounded-full border border-primary/50 bg-background shadow transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50" })
1325
- ]
1326
- }
1327
- )
1328
- );
1329
- Slider.displayName = SliderPrimitive.Root.displayName;
1330
- var toggleVariants = cva(
1331
- "inline-flex items-center justify-center gap-2 rounded-md text-sm font-medium transition-colors hover:bg-muted hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
1332
- {
1333
- variants: {
1334
- variant: {
1335
- default: "bg-transparent",
1336
- outline: "border border-input bg-transparent shadow-sm hover:bg-accent hover:text-accent-foreground"
1337
- },
1338
- size: {
1339
- default: "h-9 px-2 min-w-9",
1340
- sm: "h-8 px-1.5 min-w-8",
1341
- lg: "h-10 px-2.5 min-w-10"
1342
- }
1343
- },
1344
- defaultVariants: {
1345
- variant: "default",
1346
- size: "default"
1347
- }
1348
- }
1349
- );
1350
- var Toggle = React2.forwardRef(({ className, variant, size, ...props }, ref) => /* @__PURE__ */ jsx(
1351
- TogglePrimitive.Root,
1352
- {
1353
- ref,
1354
- className: cn(toggleVariants({ variant, size, className })),
1355
- ...props
1356
- }
1357
- ));
1358
- Toggle.displayName = TogglePrimitive.Root.displayName;
1359
- var ToggleGroupContext = React2.createContext({
1360
- size: "default",
1361
- variant: "default"
1362
- });
1363
- var ToggleGroup = React2.forwardRef(({ className, variant, size, children, ...props }, ref) => /* @__PURE__ */ jsx(
1364
- ToggleGroupPrimitive.Root,
1365
- {
1366
- ref,
1367
- className: cn("flex items-center justify-center gap-1", className),
1368
- ...props,
1369
- children: /* @__PURE__ */ jsx(ToggleGroupContext.Provider, { value: { variant, size }, children })
1370
- }
1371
- ));
1372
- ToggleGroup.displayName = ToggleGroupPrimitive.Root.displayName;
1373
- var ToggleGroupItem = React2.forwardRef(({ className, children, variant, size, ...props }, ref) => {
1374
- const context = React2.useContext(ToggleGroupContext);
1375
- return /* @__PURE__ */ jsx(
1376
- ToggleGroupPrimitive.Item,
1377
- {
1378
- ref,
1379
- className: cn(
1380
- toggleVariants({
1381
- variant: context.variant || variant,
1382
- size: context.size || size
1383
- }),
1384
- className
1385
- ),
1386
- ...props,
1387
- children
1388
- }
1389
- );
1390
- });
1391
- ToggleGroupItem.displayName = ToggleGroupPrimitive.Item.displayName;
1392
- var Dialog = DialogPrimitive.Root;
1393
- var DialogTrigger = DialogPrimitive.Trigger;
1394
- var DialogPortal = DialogPrimitive.Portal;
1395
- var DialogClose = DialogPrimitive.Close;
1396
- var DialogOverlay = React2.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
1397
- DialogPrimitive.Overlay,
1398
- {
1399
- ref,
1400
- className: cn(
1401
- "fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
1402
- className
1403
- ),
1404
- ...props
1405
- }
1406
- ));
1407
- DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
1408
- var DialogContent = React2.forwardRef(({ className, children, hideCloseButton, ...props }, ref) => /* @__PURE__ */ jsxs(DialogPortal, { children: [
1409
- /* @__PURE__ */ jsx(DialogOverlay, {}),
1410
- /* @__PURE__ */ jsxs(
1411
- DialogPrimitive.Content,
1412
- {
1413
- ref,
1414
- className: cn(
1415
- "fixed left-[50%] top-[50%] z-50 grid w-[calc(100%-2rem)] max-w-lg max-h-[90vh] translate-x-[-50%] translate-y-[-50%] gap-4 overflow-y-auto border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 rounded-md",
1416
- className
1417
- ),
1418
- ...props,
1419
- children: [
1420
- children,
1421
- !hideCloseButton && /* @__PURE__ */ jsxs(
1422
- DialogPrimitive.Close,
1423
- {
1424
- className: "absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",
1425
- "data-testid": "dialog-close-button",
1426
- children: [
1427
- /* @__PURE__ */ jsx(X, { className: "h-4 w-4" }),
1428
- /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Close dialog" })
1429
- ]
1430
- }
1431
- )
1432
- ]
1433
- }
1434
- )
1435
- ] }));
1436
- DialogContent.displayName = DialogPrimitive.Content.displayName;
1437
- var DialogHeader = ({ className, ...props }) => /* @__PURE__ */ jsx("div", { className: cn("flex flex-col space-y-1.5 text-center sm:text-left", className), ...props });
1438
- DialogHeader.displayName = "DialogHeader";
1439
- var DialogFooter = ({ className, ...props }) => /* @__PURE__ */ jsx(
1440
- "div",
1441
- {
1442
- className: cn("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2", className),
1443
- ...props
1444
- }
1445
- );
1446
- DialogFooter.displayName = "DialogFooter";
1447
- var DialogTitle = React2.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
1448
- DialogPrimitive.Title,
1449
- {
1450
- ref,
1451
- className: cn("text-lg font-semibold leading-none tracking-tight", className),
1452
- ...props
1453
- }
1454
- ));
1455
- DialogTitle.displayName = DialogPrimitive.Title.displayName;
1456
- var DialogDescription = React2.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
1457
- DialogPrimitive.Description,
1458
- {
1459
- ref,
1460
- className: cn("text-sm text-muted-foreground", className),
1461
- ...props
1462
- }
1463
- ));
1464
- DialogDescription.displayName = DialogPrimitive.Description.displayName;
1465
- var Popover = PopoverPrimitive.Root;
1466
- var PopoverTrigger = PopoverPrimitive.Trigger;
1467
- var PopoverAnchor = PopoverPrimitive.Anchor;
1468
- var PopoverContent = React2.forwardRef(({ className, align = "center", sideOffset = 4, container, ...props }, ref) => /* @__PURE__ */ jsx(PopoverPrimitive.Portal, { container: container ?? void 0, children: /* @__PURE__ */ jsx(
1469
- PopoverPrimitive.Content,
1470
- {
1471
- ref,
1472
- align,
1473
- sideOffset,
1474
- className: cn(
1475
- "z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-popover-content-transform-origin]",
1476
- className
1477
- ),
1478
- ...props
1479
- }
1480
- ) }));
1481
- PopoverContent.displayName = PopoverPrimitive.Content.displayName;
1482
- var DropdownMenu = DropdownMenuPrimitive.Root;
1483
- var DropdownMenuTrigger = DropdownMenuPrimitive.Trigger;
1484
- var DropdownMenuGroup = DropdownMenuPrimitive.Group;
1485
- var DropdownMenuPortal = DropdownMenuPrimitive.Portal;
1486
- var DropdownMenuSub = DropdownMenuPrimitive.Sub;
1487
- var DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup;
1488
- var DropdownMenuSubTrigger = React2.forwardRef(({ className, inset, children, ...props }, ref) => /* @__PURE__ */ jsxs(
1489
- DropdownMenuPrimitive.SubTrigger,
1490
- {
1491
- ref,
1492
- className: cn(
1493
- "flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
1494
- inset && "pl-8",
1495
- className
1496
- ),
1497
- ...props,
1498
- children: [
1499
- children,
1500
- /* @__PURE__ */ jsx(ChevronRight, { className: "ml-auto" })
1501
- ]
1502
- }
1503
- ));
1504
- DropdownMenuSubTrigger.displayName = DropdownMenuPrimitive.SubTrigger.displayName;
1505
- var DropdownMenuSubContent = React2.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
1506
- DropdownMenuPrimitive.SubContent,
1507
- {
1508
- ref,
1509
- className: cn(
1510
- "z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-dropdown-menu-content-transform-origin]",
1511
- className
1512
- ),
1513
- ...props
1514
- }
1515
- ));
1516
- DropdownMenuSubContent.displayName = DropdownMenuPrimitive.SubContent.displayName;
1517
- var DropdownMenuContent = React2.forwardRef(({ className, sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsx(DropdownMenuPrimitive.Portal, { children: /* @__PURE__ */ jsx(
1518
- DropdownMenuPrimitive.Content,
1519
- {
1520
- ref,
1521
- sideOffset,
1522
- className: cn(
1523
- "z-50 max-h-[var(--radix-dropdown-menu-content-available-height)] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md",
1524
- "data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-dropdown-menu-content-transform-origin]",
1525
- className
1526
- ),
1527
- ...props
1528
- }
1529
- ) }));
1530
- DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName;
1531
- var DropdownMenuItem = React2.forwardRef(({ className, inset, ...props }, ref) => /* @__PURE__ */ jsx(
1532
- DropdownMenuPrimitive.Item,
1533
- {
1534
- ref,
1535
- className: cn(
1536
- "relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&>svg]:size-4 [&>svg]:shrink-0",
1537
- inset && "pl-8",
1538
- className
1539
- ),
1540
- ...props
1541
- }
1542
- ));
1543
- DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName;
1544
- var DropdownMenuCheckboxItem = React2.forwardRef(({ className, children, checked, ...props }, ref) => /* @__PURE__ */ jsxs(
1545
- DropdownMenuPrimitive.CheckboxItem,
1546
- {
1547
- ref,
1548
- className: cn(
1549
- "relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
1550
- className
1551
- ),
1552
- checked,
1553
- ...props,
1554
- children: [
1555
- /* @__PURE__ */ jsx("span", { className: "absolute left-2 flex h-4 w-4 items-center justify-center rounded border border-border bg-popover", children: /* @__PURE__ */ jsx(DropdownMenuPrimitive.ItemIndicator, { children: /* @__PURE__ */ jsx(Check, { className: "h-3.5 w-3.5 text-primary" }) }) }),
1556
- children
1557
- ]
1558
- }
1559
- ));
1560
- DropdownMenuCheckboxItem.displayName = DropdownMenuPrimitive.CheckboxItem.displayName;
1561
- var DropdownMenuRadioItem = React2.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs(
1562
- DropdownMenuPrimitive.RadioItem,
1563
- {
1564
- ref,
1565
- className: cn(
1566
- "relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
1567
- className
1568
- ),
1569
- ...props,
1570
- children: [
1571
- /* @__PURE__ */ jsx("span", { className: "absolute left-2 flex h-3.5 w-3.5 items-center justify-center", children: /* @__PURE__ */ jsx(DropdownMenuPrimitive.ItemIndicator, { children: /* @__PURE__ */ jsx(Circle, { className: "h-2 w-2 fill-current" }) }) }),
1572
- children
1573
- ]
1574
- }
1575
- ));
1576
- DropdownMenuRadioItem.displayName = DropdownMenuPrimitive.RadioItem.displayName;
1577
- var DropdownMenuLabel = React2.forwardRef(({ className, inset, ...props }, ref) => /* @__PURE__ */ jsx(
1578
- DropdownMenuPrimitive.Label,
1579
- {
1580
- ref,
1581
- className: cn("px-2 py-1.5 text-sm font-semibold", inset && "pl-8", className),
1582
- ...props
1583
- }
1584
- ));
1585
- DropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName;
1586
- var DropdownMenuSeparator = React2.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
1587
- DropdownMenuPrimitive.Separator,
1588
- {
1589
- ref,
1590
- className: cn("-mx-1 my-1 h-px bg-muted", className),
1591
- ...props
1592
- }
1593
- ));
1594
- DropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName;
1595
- var DropdownMenuShortcut = ({ className, ...props }) => {
1596
- return /* @__PURE__ */ jsx("span", { className: cn("ml-auto text-sm tracking-widest opacity-60", className), ...props });
1597
- };
1598
- DropdownMenuShortcut.displayName = "DropdownMenuShortcut";
1599
- var Select = SelectPrimitive.Root;
1600
- var SelectGroup = SelectPrimitive.Group;
1601
- var SelectValue = SelectPrimitive.Value;
1602
- var SelectTrigger = React2.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs(
1603
- SelectPrimitive.Trigger,
1604
- {
1605
- ref,
1606
- className: cn(
1607
- "flex h-9 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm placeholder:text-muted-foreground/60 focus:outline-none focus-visible:border-ring/50 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",
1608
- className
1609
- ),
1610
- ...props,
1611
- children: [
1612
- children,
1613
- /* @__PURE__ */ jsx(SelectPrimitive.Icon, { asChild: true, children: /* @__PURE__ */ jsx(ChevronDown, { className: "h-4 w-4 opacity-50" }) })
1614
- ]
1615
- }
1616
- ));
1617
- SelectTrigger.displayName = SelectPrimitive.Trigger.displayName;
1618
- var SelectScrollUpButton = React2.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
1619
- SelectPrimitive.ScrollUpButton,
1620
- {
1621
- ref,
1622
- className: cn("flex cursor-default items-center justify-center py-1", className),
1623
- ...props,
1624
- children: /* @__PURE__ */ jsx(ChevronUp, { className: "h-4 w-4" })
1625
- }
1626
- ));
1627
- SelectScrollUpButton.displayName = SelectPrimitive.ScrollUpButton.displayName;
1628
- var SelectScrollDownButton = React2.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
1629
- SelectPrimitive.ScrollDownButton,
1630
- {
1631
- ref,
1632
- className: cn("flex cursor-default items-center justify-center py-1", className),
1633
- ...props,
1634
- children: /* @__PURE__ */ jsx(ChevronDown, { className: "h-4 w-4" })
1635
- }
1636
- ));
1637
- SelectScrollDownButton.displayName = SelectPrimitive.ScrollDownButton.displayName;
1638
- var SelectContent = React2.forwardRef(({ className, children, position = "popper", ...props }, ref) => /* @__PURE__ */ jsx(SelectPrimitive.Portal, { children: /* @__PURE__ */ jsxs(
1639
- SelectPrimitive.Content,
1640
- {
1641
- ref,
1642
- className: cn(
1643
- "relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
1644
- position === "popper" && "data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",
1645
- className
1646
- ),
1647
- position,
1648
- ...props,
1649
- children: [
1650
- /* @__PURE__ */ jsx(SelectScrollUpButton, {}),
1651
- /* @__PURE__ */ jsx(
1652
- SelectPrimitive.Viewport,
1653
- {
1654
- className: cn(
1655
- "p-1",
1656
- position === "popper" && "h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"
1657
- ),
1658
- children
1659
- }
1660
- ),
1661
- /* @__PURE__ */ jsx(SelectScrollDownButton, {})
1662
- ]
1663
- }
1664
- ) }));
1665
- SelectContent.displayName = SelectPrimitive.Content.displayName;
1666
- var SelectLabel = React2.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
1667
- SelectPrimitive.Label,
1668
- {
1669
- ref,
1670
- className: cn("py-1.5 pl-8 pr-2 text-sm font-semibold", className),
1671
- ...props
1672
- }
1673
- ));
1674
- SelectLabel.displayName = SelectPrimitive.Label.displayName;
1675
- var SelectItem = React2.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs(
1676
- SelectPrimitive.Item,
1677
- {
1678
- ref,
1679
- className: cn(
1680
- "relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
1681
- className
1682
- ),
1683
- ...props,
1684
- children: [
1685
- /* @__PURE__ */ jsx("span", { className: "absolute left-2 flex h-3.5 w-3.5 items-center justify-center", children: /* @__PURE__ */ jsx(SelectPrimitive.ItemIndicator, { children: /* @__PURE__ */ jsx(Check, { className: "h-4 w-4" }) }) }),
1686
- /* @__PURE__ */ jsx(SelectPrimitive.ItemText, { children })
1687
- ]
1688
- }
1689
- ));
1690
- SelectItem.displayName = SelectPrimitive.Item.displayName;
1691
- var SelectSeparator = React2.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
1692
- SelectPrimitive.Separator,
1693
- {
1694
- ref,
1695
- className: cn("-mx-1 my-1 h-px bg-muted", className),
1696
- ...props
1697
- }
1698
- ));
1699
- SelectSeparator.displayName = SelectPrimitive.Separator.displayName;
1700
- var Command = React2.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
1701
- Command$1,
1702
- {
1703
- ref,
1704
- className: cn(
1705
- "flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",
1706
- className
1707
- ),
1708
- ...props
1709
- }
1710
- ));
1711
- Command.displayName = Command$1.displayName;
1712
- var CommandDialog = ({ children, ...props }) => {
1713
- return /* @__PURE__ */ jsx(Dialog, { ...props, children: /* @__PURE__ */ jsx(DialogContent, { className: "overflow-hidden p-0", children: /* @__PURE__ */ jsx(Command, { className: "[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5", children }) }) });
1714
- };
1715
- var CommandInput = React2.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxs("div", { className: "flex items-center border-b px-3", "data-cmdk-input-wrapper": "", children: [
1716
- /* @__PURE__ */ jsx(Search, { className: "mr-2 h-4 w-4 shrink-0 opacity-50" }),
1717
- /* @__PURE__ */ jsx(
1718
- Command$1.Input,
1719
- {
1720
- ref,
1721
- className: cn(
1722
- "flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",
1723
- className
1724
- ),
1725
- ...props
1726
- }
1727
- )
1728
- ] }));
1729
- CommandInput.displayName = Command$1.Input.displayName;
1730
- var CommandList = React2.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
1731
- Command$1.List,
1732
- {
1733
- ref,
1734
- className: cn("max-h-[300px] overflow-y-auto overflow-x-hidden", className),
1735
- ...props
1736
- }
1737
- ));
1738
- CommandList.displayName = Command$1.List.displayName;
1739
- var CommandEmpty = React2.forwardRef((props, ref) => /* @__PURE__ */ jsx(Command$1.Empty, { ref, className: "py-6 text-center text-sm", ...props }));
1740
- CommandEmpty.displayName = Command$1.Empty.displayName;
1741
- var CommandGroup = React2.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
1742
- Command$1.Group,
1743
- {
1744
- ref,
1745
- className: cn(
1746
- "overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-sm [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",
1747
- className
1748
- ),
1749
- ...props
1750
- }
1751
- ));
1752
- CommandGroup.displayName = Command$1.Group.displayName;
1753
- var CommandSeparator = React2.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
1754
- Command$1.Separator,
1755
- {
1756
- ref,
1757
- className: cn("-mx-1 h-px bg-border", className),
1758
- ...props
1759
- }
1760
- ));
1761
- CommandSeparator.displayName = Command$1.Separator.displayName;
1762
- var CommandItem = React2.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
1763
- Command$1.Item,
1764
- {
1765
- ref,
1766
- className: cn(
1767
- "relative flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
1768
- className
1769
- ),
1770
- ...props
1771
- }
1772
- ));
1773
- CommandItem.displayName = Command$1.Item.displayName;
1774
- var CommandShortcut = ({ className, ...props }) => {
1775
- return /* @__PURE__ */ jsx(
1776
- "span",
1777
- {
1778
- className: cn("ml-auto text-sm tracking-widest text-muted-foreground", className),
1779
- ...props
1780
- }
1781
- );
1782
- };
1783
- CommandShortcut.displayName = "CommandShortcut";
1784
- var AI_COMPONENTS = {
1785
- a: (p) => /* @__PURE__ */ jsx(
1786
- "a",
1787
- {
1788
- className: "text-ai-accent underline underline-offset-2",
1789
- target: "_blank",
1790
- rel: "noopener noreferrer",
1791
- ...p
1792
- }
1793
- ),
1794
- // Redline marks: deletions in red strike, <ins>/<mark> additions accented.
1795
- del: (p) => /* @__PURE__ */ jsx("del", { className: "rounded bg-destructive/10 text-destructive decoration-destructive/60", ...p }),
1796
- ins: (p) => /* @__PURE__ */ jsx("ins", { className: "rounded bg-ai-accent-soft px-0.5 text-ai-accent no-underline", ...p }),
1797
- mark: (p) => /* @__PURE__ */ jsx("mark", { className: "rounded bg-ai-accent-soft px-0.5 text-ai-accent", ...p }),
1798
- thead: (p) => /* @__PURE__ */ jsx("thead", { className: "bg-secondary/60", ...p })
1799
- };
1800
- function AiMarkdown({
1801
- children,
1802
- className,
1803
- isStreaming
1804
- }) {
1805
- return /* @__PURE__ */ jsx(
1806
- MarkdownRenderer,
1807
- {
1808
- className: className ?? "text-sm text-foreground",
1809
- components: AI_COMPONENTS,
1810
- isStreaming,
1811
- testId: "ai-markdown",
1812
- children
1813
- }
1814
- );
1815
- }
1816
-
1817
- export { AiMarkdown, Avatar, AvatarFallback, AvatarImage, Badge, Button, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Checkbox, Collapsible, CollapsibleContent2 as CollapsibleContent, CollapsibleTrigger2 as CollapsibleTrigger, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DictateProvider, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, HoverCard, HoverCardContent, HoverCardTrigger, IconToggle, InlineMicButton, Input, Label, MarkdownRenderer, MarkdownStreamingContext, MicRecordingOverlay, MicWaveformIndicator, Popover, PopoverAnchor, PopoverContent, PopoverTrigger, Progress, RadioGroup, RadioGroupItem, ScrollArea, ScrollBar, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Slider, Switch, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, Textarea, Toggle, ToggleGroup, ToggleGroupItem, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, badgeVariants, buttonVariants, cardVariants, classifyMediaError, cn, formatElapsed, markdownBaseComponents, splitMarkdownBlocks, toggleVariants, useAudioRecorder };
1818
- //# sourceMappingURL=chunk-I256BUCX.js.map
1819
- //# sourceMappingURL=chunk-I256BUCX.js.map