@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
@@ -0,0 +1,4060 @@
1
+ 'use strict';
2
+
3
+ var chunkRZQACYNQ_cjs = require('./chunk-RZQACYNQ.cjs');
4
+ var jsxRuntime = require('react/jsx-runtime');
5
+ var React2 = require('react');
6
+ var Markdown = require('react-markdown');
7
+ var remarkGfm = require('remark-gfm');
8
+ var rehypeRaw = require('rehype-raw');
9
+ var lucideReact = require('lucide-react');
10
+ var reactDom = require('react-dom');
11
+ var AvatarPrimitive = require('@radix-ui/react-avatar');
12
+ var classVarianceAuthority = require('class-variance-authority');
13
+ var reactSlot = require('@radix-ui/react-slot');
14
+ var HoverCardPrimitive = require('@radix-ui/react-hover-card');
15
+ var SeparatorPrimitive = require('@radix-ui/react-separator');
16
+ var CollapsiblePrimitive = require('@radix-ui/react-collapsible');
17
+ var ProgressPrimitive = require('@radix-ui/react-progress');
18
+ var RadioGroupPrimitive = require('@radix-ui/react-radio-group');
19
+ var CheckboxPrimitive = require('@radix-ui/react-checkbox');
20
+ var SwitchPrimitives = require('@radix-ui/react-switch');
21
+ var TabsPrimitive = require('@radix-ui/react-tabs');
22
+ var SliderPrimitive = require('@radix-ui/react-slider');
23
+ var TogglePrimitive = require('@radix-ui/react-toggle');
24
+ var ToggleGroupPrimitive = require('@radix-ui/react-toggle-group');
25
+ var DialogPrimitive = require('@radix-ui/react-dialog');
26
+ var PopoverPrimitive = require('@radix-ui/react-popover');
27
+ var SelectPrimitive = require('@radix-ui/react-select');
28
+ var cmdk = require('cmdk');
29
+
30
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
31
+
32
+ function _interopNamespace(e) {
33
+ if (e && e.__esModule) return e;
34
+ var n = Object.create(null);
35
+ if (e) {
36
+ Object.keys(e).forEach(function (k) {
37
+ if (k !== 'default') {
38
+ var d = Object.getOwnPropertyDescriptor(e, k);
39
+ Object.defineProperty(n, k, d.get ? d : {
40
+ enumerable: true,
41
+ get: function () { return e[k]; }
42
+ });
43
+ }
44
+ });
45
+ }
46
+ n.default = e;
47
+ return Object.freeze(n);
48
+ }
49
+
50
+ var React2__namespace = /*#__PURE__*/_interopNamespace(React2);
51
+ var Markdown__default = /*#__PURE__*/_interopDefault(Markdown);
52
+ var remarkGfm__default = /*#__PURE__*/_interopDefault(remarkGfm);
53
+ var rehypeRaw__default = /*#__PURE__*/_interopDefault(rehypeRaw);
54
+ var AvatarPrimitive__namespace = /*#__PURE__*/_interopNamespace(AvatarPrimitive);
55
+ var HoverCardPrimitive__namespace = /*#__PURE__*/_interopNamespace(HoverCardPrimitive);
56
+ var SeparatorPrimitive__namespace = /*#__PURE__*/_interopNamespace(SeparatorPrimitive);
57
+ var CollapsiblePrimitive__namespace = /*#__PURE__*/_interopNamespace(CollapsiblePrimitive);
58
+ var ProgressPrimitive__namespace = /*#__PURE__*/_interopNamespace(ProgressPrimitive);
59
+ var RadioGroupPrimitive__namespace = /*#__PURE__*/_interopNamespace(RadioGroupPrimitive);
60
+ var CheckboxPrimitive__namespace = /*#__PURE__*/_interopNamespace(CheckboxPrimitive);
61
+ var SwitchPrimitives__namespace = /*#__PURE__*/_interopNamespace(SwitchPrimitives);
62
+ var TabsPrimitive__namespace = /*#__PURE__*/_interopNamespace(TabsPrimitive);
63
+ var SliderPrimitive__namespace = /*#__PURE__*/_interopNamespace(SliderPrimitive);
64
+ var TogglePrimitive__namespace = /*#__PURE__*/_interopNamespace(TogglePrimitive);
65
+ var ToggleGroupPrimitive__namespace = /*#__PURE__*/_interopNamespace(ToggleGroupPrimitive);
66
+ var DialogPrimitive__namespace = /*#__PURE__*/_interopNamespace(DialogPrimitive);
67
+ var PopoverPrimitive__namespace = /*#__PURE__*/_interopNamespace(PopoverPrimitive);
68
+ var SelectPrimitive__namespace = /*#__PURE__*/_interopNamespace(SelectPrimitive);
69
+
70
+ var markdownBaseComponents = {
71
+ h1: ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("h1", { className: "text-lg font-semibold", "data-testid": "markdown-heading-1", ...props, children }),
72
+ h2: ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "font-semibold text-base", "data-testid": "markdown-heading-2", ...props, children }),
73
+ h3: ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "font-semibold text-base", "data-testid": "markdown-heading-3", ...props, children }),
74
+ h4: ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("h4", { className: "font-semibold text-base", ...props, children }),
75
+ h5: ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("h5", { className: "font-medium", ...props, children }),
76
+ strong: ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("strong", { className: "font-semibold", ...props, children }),
77
+ blockquote: ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("blockquote", { className: "border-l-2 border-primary pl-4", ...props, children }),
78
+ ol: ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("ol", { className: "list-decimal space-y-2 pl-6", "data-testid": "markdown-ordered-list", ...props, children }),
79
+ ul: ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "list-none space-y-2 pl-6", "data-testid": "markdown-unordered-list", ...props, children }),
80
+ li: ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("li", { className: "my-1.5", ...props, children }),
81
+ table: ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("table", { "data-testid": "markdown-table", ...props, children }),
82
+ th: ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("th", { ...props, children }),
83
+ td: ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("td", { ...props, children }),
84
+ tr: ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("tr", { ...props, children }),
85
+ p: ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("p", { className: "whitespace-pre-wrap", ...props, children }),
86
+ hr: (props) => /* @__PURE__ */ jsxRuntime.jsx("hr", { className: "border-foreground/20", ...props }),
87
+ sup: ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("sup", { className: "text-xs", ...props, children }),
88
+ sub: ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("sub", { className: "text-xs", ...props, children }),
89
+ div: ({ children, className, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("div", { className, ...props, children }),
90
+ br: (props) => /* @__PURE__ */ jsxRuntime.jsx("br", { ...props }),
91
+ kbd: ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx(
92
+ "kbd",
93
+ {
94
+ className: "px-1.5 py-0.5 text-xs font-mono bg-muted border border-border rounded",
95
+ ...props,
96
+ children
97
+ }
98
+ ),
99
+ abbr: ({ children, title, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("abbr", { title, className: "underline decoration-dotted cursor-help", ...props, children }),
100
+ cite: ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("cite", { className: "italic", ...props, children })
101
+ };
102
+ var MarkdownStreamingContext = React2.createContext(false);
103
+
104
+ // src/ai/split-markdown-blocks.ts
105
+ var LIST_ITEM_RE = /^\s*([-*+]|\d+[.)])\s/;
106
+ var BLOCKQUOTE_RE = /^\s*>/;
107
+ function splitMarkdownBlocks(content) {
108
+ if (!content) return [];
109
+ const blocks = [];
110
+ let start = 0;
111
+ let inFence = false;
112
+ let i = 0;
113
+ while (i < content.length) {
114
+ if (content.startsWith("```", i)) {
115
+ inFence = !inFence;
116
+ i += 3;
117
+ continue;
118
+ }
119
+ if (!inFence && content[i] === "\n" && content[i + 1] === "\n") {
120
+ const before = content.slice(start, i);
121
+ const lastLine = before.slice(before.lastIndexOf("\n") + 1);
122
+ const afterStart = i + 2;
123
+ const nextNewline = content.indexOf("\n", afterStart);
124
+ const nextLine = content.slice(afterStart, nextNewline === -1 ? void 0 : nextNewline);
125
+ const bothListItems = LIST_ITEM_RE.test(lastLine) && LIST_ITEM_RE.test(nextLine);
126
+ const bothBlockquotes = BLOCKQUOTE_RE.test(lastLine) && BLOCKQUOTE_RE.test(nextLine);
127
+ if (bothListItems || bothBlockquotes) {
128
+ i += 2;
129
+ continue;
130
+ }
131
+ blocks.push(content.slice(start, afterStart));
132
+ start = afterStart;
133
+ i = afterStart;
134
+ continue;
135
+ }
136
+ i++;
137
+ }
138
+ if (start < content.length) blocks.push(content.slice(start));
139
+ return blocks;
140
+ }
141
+ function CodeBlock({ language, code }) {
142
+ const [copied, setCopied] = React2.useState(false);
143
+ const handleCopy = async () => {
144
+ try {
145
+ await navigator.clipboard.writeText(code);
146
+ setCopied(true);
147
+ setTimeout(() => setCopied(false), 2e3);
148
+ } catch {
149
+ }
150
+ };
151
+ return /* @__PURE__ */ jsxRuntime.jsxs(
152
+ "div",
153
+ {
154
+ className: "code-block relative my-3 overflow-hidden rounded-md border border-border bg-muted",
155
+ "data-testid": "markdown-code-block",
156
+ children: [
157
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between border-b border-border px-3 py-1.5", children: [
158
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-mono text-xs text-muted-foreground", children: language || "code" }),
159
+ /* @__PURE__ */ jsxRuntime.jsxs(
160
+ "button",
161
+ {
162
+ type: "button",
163
+ onClick: handleCopy,
164
+ className: "flex items-center gap-1 text-xs text-muted-foreground transition-colors hover:text-foreground",
165
+ title: copied ? "Copied!" : "Copy code",
166
+ children: [
167
+ copied ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, { size: 12 }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Copy, { size: 12 }),
168
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: copied ? "Copied" : "Copy" })
169
+ ]
170
+ }
171
+ )
172
+ ] }),
173
+ /* @__PURE__ */ jsxRuntime.jsx("pre", { className: "overflow-x-auto p-3 text-sm leading-relaxed", children: /* @__PURE__ */ jsxRuntime.jsx("code", { className: chunkRZQACYNQ_cjs.cn("font-mono text-foreground", language && `language-${language}`), children: code }) })
174
+ ]
175
+ }
176
+ );
177
+ }
178
+ var defaultComponents = {
179
+ ...markdownBaseComponents,
180
+ a: ({ href, children, ...props }) => {
181
+ const isInternal = !href || href.startsWith("#") || href.startsWith("cite:");
182
+ return /* @__PURE__ */ jsxRuntime.jsx(
183
+ "a",
184
+ {
185
+ className: "text-primary underline underline-offset-2",
186
+ href,
187
+ ...isInternal ? {} : { target: "_blank", rel: "noopener noreferrer" },
188
+ ...props,
189
+ children
190
+ }
191
+ );
192
+ },
193
+ em: ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("em", { className: "italic", ...props, children }),
194
+ code: function MarkdownCode({
195
+ className,
196
+ children,
197
+ ...props
198
+ }) {
199
+ const match = /language-(\w+)/.exec(className || "");
200
+ if (!match) {
201
+ return /* @__PURE__ */ jsxRuntime.jsx(
202
+ "code",
203
+ {
204
+ className: "rounded bg-muted px-1 py-0.5 font-mono text-[0.9em]",
205
+ "data-testid": "markdown-inline-code",
206
+ ...props,
207
+ children
208
+ }
209
+ );
210
+ }
211
+ return /* @__PURE__ */ jsxRuntime.jsx(CodeBlock, { language: match[1], code: String(children).replace(/\n$/, "") });
212
+ },
213
+ // The CodeBlock renders its own <pre>; unwrap react-markdown's wrapper so we
214
+ // don't nest <pre><pre>.
215
+ pre: ({ children }) => /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children }),
216
+ blockquote: ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("blockquote", { className: "border-l-2 border-border pl-4 italic text-muted-foreground", ...props, children }),
217
+ table: ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "my-3 overflow-x-auto rounded-lg border border-border", children: /* @__PURE__ */ jsxRuntime.jsx("table", { "data-testid": "markdown-table", className: "w-full border-collapse text-sm", ...props, children }) }),
218
+ thead: ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("thead", { className: "bg-muted", ...props, children }),
219
+ th: ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx(
220
+ "th",
221
+ {
222
+ className: "border-b border-border px-3 py-2 text-left font-semibold text-foreground",
223
+ ...props,
224
+ children
225
+ }
226
+ ),
227
+ td: ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("td", { className: "border-b border-border px-3 py-2 align-top", ...props, children }),
228
+ // General emphasis marks (GFM `~~strikethrough~~` → <del>, raw <ins>/<mark>).
229
+ del: ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("del", { className: "text-muted-foreground line-through", ...props, children }),
230
+ ins: ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("ins", { className: "underline decoration-primary/60", ...props, children }),
231
+ mark: ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("mark", { className: "rounded bg-primary/15 px-0.5 text-foreground", ...props, children })
232
+ };
233
+ var remarkPlugins = [remarkGfm__default.default];
234
+ var rehypePlugins = [rehypeRaw__default.default];
235
+ var MemoizedBlock = React2__namespace.default.memo(function MarkdownBlock({
236
+ content,
237
+ components
238
+ }) {
239
+ return /* @__PURE__ */ jsxRuntime.jsx(Markdown__default.default, { remarkPlugins, rehypePlugins, components, children: content });
240
+ });
241
+ var MarkdownErrorBoundary = class extends React2__namespace.default.Component {
242
+ state = { hasError: false };
243
+ static getDerivedStateFromError() {
244
+ return { hasError: true };
245
+ }
246
+ render() {
247
+ return this.state.hasError ? this.props.fallback : this.props.children;
248
+ }
249
+ };
250
+ function MarkdownRendererComponent({
251
+ children,
252
+ components: customComponents,
253
+ isStreaming = false,
254
+ className,
255
+ testId = "markdown-renderer"
256
+ }) {
257
+ const components = React2.useMemo(
258
+ () => customComponents ? { ...defaultComponents, ...customComponents } : defaultComponents,
259
+ [customComponents]
260
+ );
261
+ const blocks = React2.useMemo(() => splitMarkdownBlocks(children), [children]);
262
+ return /* @__PURE__ */ jsxRuntime.jsx(
263
+ MarkdownErrorBoundary,
264
+ {
265
+ fallback: /* @__PURE__ */ jsxRuntime.jsx("div", { className: chunkRZQACYNQ_cjs.cn("whitespace-pre-wrap break-words text-foreground", className), children }),
266
+ children: /* @__PURE__ */ jsxRuntime.jsx(MarkdownStreamingContext.Provider, { value: isStreaming, children: /* @__PURE__ */ jsxRuntime.jsx(
267
+ "div",
268
+ {
269
+ className: chunkRZQACYNQ_cjs.cn(
270
+ "markdown-content space-y-3 break-words leading-relaxed text-foreground",
271
+ className
272
+ ),
273
+ "data-testid": testId,
274
+ children: blocks.map((block, index) => /* @__PURE__ */ jsxRuntime.jsx(MemoizedBlock, { content: block, components }, index))
275
+ }
276
+ ) })
277
+ }
278
+ );
279
+ }
280
+ var MarkdownRenderer = React2__namespace.default.memo(MarkdownRendererComponent);
281
+ var TooltipContext = React2__namespace.createContext(null);
282
+ var DEFAULT_DELAY = 300;
283
+ var TooltipConfigContext = React2__namespace.createContext({
284
+ delayDuration: DEFAULT_DELAY
285
+ });
286
+ var TooltipProvider = ({ children, delayDuration = DEFAULT_DELAY }) => {
287
+ const value = React2__namespace.useMemo(() => ({ delayDuration }), [delayDuration]);
288
+ return /* @__PURE__ */ jsxRuntime.jsx(TooltipConfigContext.Provider, { value, children });
289
+ };
290
+ function Tooltip({ children, delayDuration }) {
291
+ const config = React2__namespace.useContext(TooltipConfigContext);
292
+ const delay = delayDuration ?? config.delayDuration;
293
+ const [open, setOpen] = React2__namespace.useState(false);
294
+ const triggerRef = React2__namespace.useRef(null);
295
+ const timer = React2__namespace.useRef(null);
296
+ const contentId = React2__namespace.useId();
297
+ const clearTimer = () => {
298
+ if (timer.current) {
299
+ clearTimeout(timer.current);
300
+ timer.current = null;
301
+ }
302
+ };
303
+ const suppressed = React2__namespace.useRef(false);
304
+ const show = React2__namespace.useCallback(() => {
305
+ clearTimer();
306
+ if (suppressed.current) return;
307
+ timer.current = setTimeout(() => setOpen(true), delay);
308
+ }, [delay]);
309
+ const hide = React2__namespace.useCallback(() => {
310
+ clearTimer();
311
+ setOpen(false);
312
+ }, []);
313
+ const suppress = React2__namespace.useCallback(() => {
314
+ suppressed.current = true;
315
+ clearTimer();
316
+ setOpen(false);
317
+ }, []);
318
+ const release = React2__namespace.useCallback(() => {
319
+ suppressed.current = false;
320
+ }, []);
321
+ const setTrigger = React2__namespace.useCallback((el) => {
322
+ triggerRef.current = el;
323
+ }, []);
324
+ React2__namespace.useEffect(() => () => clearTimer(), []);
325
+ const value = React2__namespace.useMemo(
326
+ () => ({ open, show, hide, suppress, release, setTrigger, triggerRef, contentId }),
327
+ [open, show, hide, suppress, release, setTrigger, contentId]
328
+ );
329
+ return /* @__PURE__ */ jsxRuntime.jsx(TooltipContext.Provider, { value, children });
330
+ }
331
+ function isKeyboardFocus(target) {
332
+ try {
333
+ return target.matches(":focus-visible");
334
+ } catch {
335
+ return true;
336
+ }
337
+ }
338
+ function showsOwnText(el) {
339
+ if (!el) return false;
340
+ const walker = document.createTreeWalker(el, NodeFilter.SHOW_TEXT);
341
+ let visible = "";
342
+ for (let node = walker.nextNode(); node; node = walker.nextNode()) {
343
+ if (node.parentElement?.closest(".sr-only")) continue;
344
+ visible += node.textContent ?? "";
345
+ }
346
+ return /\p{L}{2,}/u.test(visible);
347
+ }
348
+ function TooltipTrigger({ asChild, children, ...props }) {
349
+ const ctx = React2__namespace.useContext(TooltipContext);
350
+ if (!ctx) return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children });
351
+ const triggerHandlers = {
352
+ onPointerEnter: (e) => {
353
+ props.onPointerEnter?.(e);
354
+ if (e.pointerType === "touch") return;
355
+ if (showsOwnText(e.currentTarget)) return;
356
+ ctx.show();
357
+ },
358
+ onPointerLeave: (e) => {
359
+ props.onPointerLeave?.(e);
360
+ ctx.release();
361
+ ctx.hide();
362
+ },
363
+ onPointerDown: (e) => {
364
+ props.onPointerDown?.(e);
365
+ (asChild && React2__namespace.isValidElement(children) ? children.props.onPointerDown : void 0)?.(e);
366
+ ctx.suppress();
367
+ },
368
+ onFocus: (e) => {
369
+ props.onFocus?.(e);
370
+ if (isKeyboardFocus(e.target) && !showsOwnText(e.currentTarget)) ctx.show();
371
+ },
372
+ onBlur: (e) => {
373
+ props.onBlur?.(e);
374
+ ctx.hide();
375
+ },
376
+ "aria-describedby": ctx.open ? ctx.contentId : void 0,
377
+ "data-state": ctx.open ? "open" : "closed"
378
+ };
379
+ if (asChild && React2__namespace.isValidElement(children)) {
380
+ const child = children;
381
+ return React2__namespace.cloneElement(child, {
382
+ ...props,
383
+ ...triggerHandlers,
384
+ ref: ctx.setTrigger
385
+ });
386
+ }
387
+ return /* @__PURE__ */ jsxRuntime.jsx(
388
+ "button",
389
+ {
390
+ type: "button",
391
+ ...props,
392
+ ...triggerHandlers,
393
+ ref: ctx.setTrigger,
394
+ children
395
+ }
396
+ );
397
+ }
398
+ var TRANSFORM_BY_SIDE = {
399
+ top: "translate(-50%, -100%)",
400
+ bottom: "translate(-50%, 0)",
401
+ left: "translate(-100%, -50%)",
402
+ right: "translate(0, -50%)"
403
+ };
404
+ var TooltipContent = React2__namespace.forwardRef(
405
+ ({ className, side = "top", sideOffset = 4, collisionPadding = 8, style, ...props }, ref) => {
406
+ const ctx = React2__namespace.useContext(TooltipContext);
407
+ const innerRef = React2__namespace.useRef(null);
408
+ const [coords, setCoords] = React2__namespace.useState(null);
409
+ React2__namespace.useLayoutEffect(() => {
410
+ if (!ctx?.open || !ctx.triggerRef.current) {
411
+ setCoords(null);
412
+ return;
413
+ }
414
+ const r = ctx.triggerRef.current.getBoundingClientRect();
415
+ const c = innerRef.current?.getBoundingClientRect();
416
+ const ch = c?.height ?? 0;
417
+ const cw = c?.width ?? 0;
418
+ const vh = window.innerHeight;
419
+ const vw = window.innerWidth;
420
+ let s = side;
421
+ if (s === "top" && r.top - sideOffset - ch < 0) s = "bottom";
422
+ else if (s === "bottom" && r.bottom + sideOffset + ch > vh) s = "top";
423
+ else if (s === "left" && r.left - sideOffset - cw < 0) s = "right";
424
+ else if (s === "right" && r.right + sideOffset + cw > vw) s = "left";
425
+ const PAD = collisionPadding;
426
+ const clamp = (value, half, max) => Math.min(Math.max(value, PAD + half), Math.max(PAD + half, max - PAD - half));
427
+ const rawTop = s === "top" ? r.top - sideOffset : s === "bottom" ? r.bottom + sideOffset : r.top + r.height / 2;
428
+ const rawLeft = s === "left" ? r.left - sideOffset : s === "right" ? r.right + sideOffset : r.left + r.width / 2;
429
+ setCoords({
430
+ top: s === "left" || s === "right" ? clamp(rawTop, ch / 2, vh) : rawTop,
431
+ left: s === "top" || s === "bottom" ? clamp(rawLeft, cw / 2, vw) : rawLeft,
432
+ transform: TRANSFORM_BY_SIDE[s]
433
+ });
434
+ }, [ctx?.open, side, sideOffset, collisionPadding, ctx?.triggerRef]);
435
+ if (!ctx?.open) return null;
436
+ const setRefs = (node) => {
437
+ innerRef.current = node;
438
+ if (typeof ref === "function") ref(node);
439
+ else if (ref) ref.current = node;
440
+ };
441
+ return reactDom.createPortal(
442
+ /* @__PURE__ */ jsxRuntime.jsx(
443
+ "div",
444
+ {
445
+ ref: setRefs,
446
+ id: ctx.contentId,
447
+ role: "tooltip",
448
+ className: chunkRZQACYNQ_cjs.cn(
449
+ // The kit owns the tooltip's look: semantic tokens only, so it is
450
+ // legible in every app without one of them defining a global class.
451
+ // The `tooltip-content` hook is kept last-but-one so a host stylesheet
452
+ // can still restyle every tooltip in one place (the ARBI app does, with
453
+ // `!important` rules that win over these defaults).
454
+ "pointer-events-none w-max 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",
455
+ "tooltip-content",
456
+ className
457
+ ),
458
+ style: {
459
+ position: "fixed",
460
+ top: coords?.top ?? -9999,
461
+ left: coords?.left ?? -9999,
462
+ transform: coords?.transform ?? TRANSFORM_BY_SIDE[side],
463
+ opacity: coords ? void 0 : 0,
464
+ zIndex: 9999,
465
+ ...style
466
+ },
467
+ ...props
468
+ }
469
+ ),
470
+ document.body
471
+ );
472
+ }
473
+ );
474
+ TooltipContent.displayName = "TooltipContent";
475
+ function IconToggle({
476
+ icon: Icon2,
477
+ isActive,
478
+ onToggle,
479
+ colors,
480
+ fillWhenActive = false,
481
+ disabled = false,
482
+ disabledTooltip,
483
+ showLabel = false,
484
+ label,
485
+ tooltipActive,
486
+ tooltipInactive,
487
+ tooltipMixed,
488
+ isMixed = false,
489
+ showTooltip = true,
490
+ "data-testid": dataTestId
491
+ }) {
492
+ const handleClick = (e) => {
493
+ e.stopPropagation();
494
+ onToggle(!isActive);
495
+ };
496
+ const { bg: bgColorClass } = colors;
497
+ const tooltipText = disabled ? disabledTooltip : isMixed ? tooltipMixed : isActive ? tooltipActive : tooltipInactive;
498
+ const { text: textColorClass } = colors;
499
+ const button = /* @__PURE__ */ jsxRuntime.jsx("div", { className: "inline-flex items-center gap-2", children: /* @__PURE__ */ jsxRuntime.jsxs(
500
+ "button",
501
+ {
502
+ type: "button",
503
+ onClick: handleClick,
504
+ disabled,
505
+ "data-testid": dataTestId,
506
+ "aria-pressed": isMixed ? "mixed" : isActive,
507
+ className: `
508
+ group/toggle relative inline-flex items-center h-4 w-8 rounded-full
509
+ pointer-coarse:after:absolute pointer-coarse:after:left-1/2 pointer-coarse:after:top-1/2 pointer-coarse:after:size-11 pointer-coarse:after:-translate-x-1/2 pointer-coarse:after:-translate-y-1/2 pointer-coarse:after:content-['']
510
+ transition-colors cursor-pointer
511
+ disabled:opacity-50 disabled:cursor-not-allowed
512
+ ${isActive ? bgColorClass : isMixed ? "bg-gray-400" : "bg-muted"}
513
+ `,
514
+ children: [
515
+ isActive && !disabled && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute left-0 w-4 h-4 flex items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Minus, { className: "w-2.5 h-2.5 text-white/70 hidden group-hover/toggle:block" }) }),
516
+ !isActive && !disabled && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute right-0 w-4 h-4 flex items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Plus, { className: "w-2.5 h-2.5 text-muted-foreground hidden group-hover/toggle:block" }) }),
517
+ /* @__PURE__ */ jsxRuntime.jsx(
518
+ "div",
519
+ {
520
+ className: `
521
+ absolute h-4 w-4 rounded-full bg-white shadow-sm
522
+ flex items-center justify-center
523
+ transition-transform duration-200
524
+ ${isActive ? "translate-x-4" : "translate-x-0"}
525
+ `,
526
+ children: /* @__PURE__ */ jsxRuntime.jsx(
527
+ Icon2,
528
+ {
529
+ className: `w-2.5 h-2.5 ${isActive ? textColorClass : "text-muted-foreground"} ${isActive && fillWhenActive ? "fill-current" : ""}`
530
+ }
531
+ )
532
+ }
533
+ )
534
+ ]
535
+ }
536
+ ) });
537
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "inline-flex items-center gap-2", children: [
538
+ showLabel && label && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-semibold text-sm text-primary", children: label }),
539
+ tooltipText && showTooltip ? /* @__PURE__ */ jsxRuntime.jsxs(Tooltip, { children: [
540
+ /* @__PURE__ */ jsxRuntime.jsx(TooltipTrigger, { asChild: true, onFocusCapture: (e) => e.stopPropagation(), children: button }),
541
+ /* @__PURE__ */ jsxRuntime.jsx(TooltipContent, { children: /* @__PURE__ */ jsxRuntime.jsx("p", { children: tooltipText }) })
542
+ ] }) : button
543
+ ] });
544
+ }
545
+ var DictateContext = React2.createContext(null);
546
+ function DictateProvider({
547
+ transcribe,
548
+ onError,
549
+ children
550
+ }) {
551
+ return /* @__PURE__ */ jsxRuntime.jsx(DictateContext.Provider, { value: { transcribe, onError }, children });
552
+ }
553
+ function useDictateContext() {
554
+ return React2.useContext(DictateContext);
555
+ }
556
+ var Avatar = React2__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
557
+ AvatarPrimitive__namespace.Root,
558
+ {
559
+ ref,
560
+ className: chunkRZQACYNQ_cjs.cn("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full", className),
561
+ ...props
562
+ }
563
+ ));
564
+ Avatar.displayName = AvatarPrimitive__namespace.Root.displayName;
565
+ var AvatarImage = React2__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
566
+ AvatarPrimitive__namespace.Image,
567
+ {
568
+ ref,
569
+ className: chunkRZQACYNQ_cjs.cn("aspect-square h-full w-full object-cover", className),
570
+ ...props
571
+ }
572
+ ));
573
+ AvatarImage.displayName = AvatarPrimitive__namespace.Image.displayName;
574
+ var AvatarFallback = React2__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
575
+ AvatarPrimitive__namespace.Fallback,
576
+ {
577
+ ref,
578
+ className: chunkRZQACYNQ_cjs.cn(
579
+ "flex h-full w-full items-center justify-center rounded-full bg-muted",
580
+ className
581
+ ),
582
+ ...props
583
+ }
584
+ ));
585
+ AvatarFallback.displayName = AvatarPrimitive__namespace.Fallback.displayName;
586
+ var badgeVariants = classVarianceAuthority.cva(
587
+ "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",
588
+ {
589
+ variants: {
590
+ variant: {
591
+ default: "border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",
592
+ accent: "border-transparent bg-ai-accent-soft text-ai-accent",
593
+ secondary: "border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",
594
+ destructive: "border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",
595
+ outline: "text-foreground"
596
+ }
597
+ },
598
+ defaultVariants: {
599
+ variant: "default"
600
+ }
601
+ }
602
+ );
603
+ function Badge({ className, variant, ...props }) {
604
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: chunkRZQACYNQ_cjs.cn(badgeVariants({ variant }), className), ...props });
605
+ }
606
+ var buttonVariants = classVarianceAuthority.cva(
607
+ "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0",
608
+ {
609
+ variants: {
610
+ // One filled primary per view; everything else is tonal, hairline or ghost. No
611
+ // static shadows: separation is tone, and shadows are reserved for floating layers.
612
+ variant: {
613
+ default: "bg-primary text-primary-foreground hover:bg-primary/90",
614
+ accent: "bg-ai-accent text-ai-accent-foreground hover:bg-ai-accent/90",
615
+ destructive: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
616
+ outline: "border border-border bg-background hover:bg-muted",
617
+ secondary: "bg-muted text-foreground hover:bg-muted/70",
618
+ ghost: "hover:bg-muted",
619
+ link: "text-primary underline-offset-4 hover:underline"
620
+ },
621
+ // Touch screens get a 44px target (coarse pointers only), mouse keeps the compact 36px.
622
+ // `!` so the floor also wins over a caller's compact `h-7` or a container's
623
+ // `[&_button]:h-7` rule: a compact toolbar on a phone must still be tappable.
624
+ size: {
625
+ default: "h-9 px-4 py-2 pointer-coarse:h-11!",
626
+ sm: "h-8 rounded-md px-3 pointer-coarse:h-11! pointer-coarse:min-w-11",
627
+ lg: "h-10 rounded-md px-8 pointer-coarse:h-12!",
628
+ icon: "h-9 w-9 pointer-coarse:h-11! pointer-coarse:w-11!"
629
+ }
630
+ },
631
+ defaultVariants: {
632
+ variant: "default",
633
+ size: "default"
634
+ }
635
+ }
636
+ );
637
+ var Button = React2__namespace.forwardRef(
638
+ ({ className, variant, size, asChild = false, ...props }, ref) => {
639
+ const Comp = asChild ? reactSlot.Slot : "button";
640
+ return /* @__PURE__ */ jsxRuntime.jsx(Comp, { className: chunkRZQACYNQ_cjs.cn(buttonVariants({ variant, size, className })), ref, ...props });
641
+ }
642
+ );
643
+ Button.displayName = "Button";
644
+ var HoverCard = HoverCardPrimitive__namespace.Root;
645
+ var HoverCardTrigger = HoverCardPrimitive__namespace.Trigger;
646
+ var HoverCardContent = React2__namespace.forwardRef(({ className, align = "center", sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(HoverCardPrimitive__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsx(
647
+ HoverCardPrimitive__namespace.Content,
648
+ {
649
+ ref,
650
+ align,
651
+ sideOffset,
652
+ collisionPadding: chunkRZQACYNQ_cjs.getCollisionPadding(),
653
+ className: chunkRZQACYNQ_cjs.cn(
654
+ "z-50 w-64 max-w-[calc(100vw-1rem)] rounded-md border bg-popover p-4 text-popover-foreground shadow-lg 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]",
655
+ className
656
+ ),
657
+ ...props
658
+ }
659
+ ) }));
660
+ HoverCardContent.displayName = HoverCardPrimitive__namespace.Content.displayName;
661
+ var cardVariants = classVarianceAuthority.cva("rounded-lg bg-card text-card-foreground", {
662
+ variants: {
663
+ variant: {
664
+ flat: "",
665
+ outline: "border",
666
+ elevated: "border shadow-sm"
667
+ }
668
+ },
669
+ defaultVariants: {
670
+ variant: "flat"
671
+ }
672
+ });
673
+ var Card = React2__namespace.forwardRef(
674
+ ({ className, variant, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
675
+ "div",
676
+ {
677
+ ref,
678
+ "data-slot": "card",
679
+ className: chunkRZQACYNQ_cjs.cn(cardVariants({ variant }), className),
680
+ ...props
681
+ }
682
+ )
683
+ );
684
+ Card.displayName = "Card";
685
+ var CardHeader = React2__namespace.forwardRef(
686
+ ({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
687
+ "div",
688
+ {
689
+ ref,
690
+ "data-slot": "card-header",
691
+ className: chunkRZQACYNQ_cjs.cn("flex flex-col space-y-1.5 p-6", className),
692
+ ...props
693
+ }
694
+ )
695
+ );
696
+ CardHeader.displayName = "CardHeader";
697
+ var CardTitle = React2__namespace.forwardRef(
698
+ ({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
699
+ "div",
700
+ {
701
+ ref,
702
+ "data-slot": "card-title",
703
+ className: chunkRZQACYNQ_cjs.cn("font-semibold leading-none tracking-tight", className),
704
+ ...props
705
+ }
706
+ )
707
+ );
708
+ CardTitle.displayName = "CardTitle";
709
+ var CardDescription = React2__namespace.forwardRef(
710
+ ({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
711
+ "div",
712
+ {
713
+ ref,
714
+ "data-slot": "card-description",
715
+ className: chunkRZQACYNQ_cjs.cn("text-sm text-muted-foreground", className),
716
+ ...props
717
+ }
718
+ )
719
+ );
720
+ CardDescription.displayName = "CardDescription";
721
+ var CardContent = React2__namespace.forwardRef(
722
+ ({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("div", { ref, "data-slot": "card-content", className: chunkRZQACYNQ_cjs.cn("p-6 pt-0", className), ...props })
723
+ );
724
+ CardContent.displayName = "CardContent";
725
+ var CardFooter = React2__namespace.forwardRef(
726
+ ({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
727
+ "div",
728
+ {
729
+ ref,
730
+ "data-slot": "card-footer",
731
+ className: chunkRZQACYNQ_cjs.cn("flex items-center p-6 pt-0", className),
732
+ ...props
733
+ }
734
+ )
735
+ );
736
+ CardFooter.displayName = "CardFooter";
737
+
738
+ // src/documents/media-error.ts
739
+ function classifyMediaError(err, kind) {
740
+ const label = kind === "camera" ? "Camera" : "Microphone";
741
+ const name = err instanceof DOMException ? err.name : void 0;
742
+ if (name === "NotAllowedError" || name === "SecurityError") {
743
+ return `${label} access is blocked. Allow ${kind} permission in your browser settings to use this feature.`;
744
+ }
745
+ if (name === "NotFoundError" || name === "DevicesNotFoundError") {
746
+ return `No ${kind} found on this device.`;
747
+ }
748
+ if (!navigator.mediaDevices?.getUserMedia) {
749
+ return `${kind === "camera" ? "Camera" : "Voice"} input is not supported in this browser.`;
750
+ }
751
+ return `Could not access the ${kind}. Please try again.`;
752
+ }
753
+
754
+ // src/documents/useAudioRecorder.ts
755
+ var LEVEL_UPDATE_INTERVAL_MS = 50;
756
+ function useAudioRecorder() {
757
+ const [state, setState] = React2.useState("idle");
758
+ const [level, setLevel] = React2.useState(0);
759
+ const [elapsedMs, setElapsedMs] = React2.useState(0);
760
+ const [blob, setBlob] = React2.useState(null);
761
+ const [mimeType, setMimeType] = React2.useState(null);
762
+ const [error, setError] = React2.useState(null);
763
+ const mediaRecorderRef = React2.useRef(null);
764
+ const chunksRef = React2.useRef([]);
765
+ const streamRef = React2.useRef(null);
766
+ const stateRef = React2.useRef("idle");
767
+ stateRef.current = state;
768
+ const segmentStartRef = React2.useRef(0);
769
+ const accumulatedMsRef = React2.useRef(0);
770
+ const audioContextRef = React2.useRef(null);
771
+ const analyserRef = React2.useRef(null);
772
+ const levelRafRef = React2.useRef(null);
773
+ const stopMeter = React2.useCallback(() => {
774
+ if (levelRafRef.current !== null) cancelAnimationFrame(levelRafRef.current);
775
+ levelRafRef.current = null;
776
+ analyserRef.current = null;
777
+ void audioContextRef.current?.close().catch(() => {
778
+ });
779
+ audioContextRef.current = null;
780
+ }, []);
781
+ const startMeter = React2.useCallback((stream) => {
782
+ const audioContext = new AudioContext();
783
+ const source = audioContext.createMediaStreamSource(stream);
784
+ const analyser = audioContext.createAnalyser();
785
+ analyser.fftSize = 256;
786
+ source.connect(analyser);
787
+ audioContextRef.current = audioContext;
788
+ analyserRef.current = analyser;
789
+ const data = new Uint8Array(analyser.frequencyBinCount);
790
+ let lastUpdate = 0;
791
+ const tick = (t) => {
792
+ const active = analyserRef.current;
793
+ if (!active) return;
794
+ if (t - lastUpdate >= LEVEL_UPDATE_INTERVAL_MS) {
795
+ lastUpdate = t;
796
+ active.getByteTimeDomainData(data);
797
+ let sumSquares = 0;
798
+ for (let i = 0; i < data.length; i++) {
799
+ const centered = (data[i] - 128) / 128;
800
+ sumSquares += centered * centered;
801
+ }
802
+ const rms = Math.sqrt(sumSquares / data.length);
803
+ setLevel(Math.sqrt(Math.min(1, rms * 8)));
804
+ setElapsedMs(accumulatedMsRef.current + (t - segmentStartRef.current));
805
+ }
806
+ levelRafRef.current = requestAnimationFrame(tick);
807
+ };
808
+ levelRafRef.current = requestAnimationFrame(tick);
809
+ }, []);
810
+ const stopTracks = React2.useCallback(() => {
811
+ streamRef.current?.getTracks().forEach((t) => t.stop());
812
+ streamRef.current = null;
813
+ }, []);
814
+ React2.useEffect(
815
+ () => () => {
816
+ stopTracks();
817
+ stopMeter();
818
+ },
819
+ [stopTracks, stopMeter]
820
+ );
821
+ const start = React2.useCallback(async () => {
822
+ if (stateRef.current === "recording" || stateRef.current === "paused") return;
823
+ setError(null);
824
+ try {
825
+ const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
826
+ streamRef.current = stream;
827
+ const mt = MediaRecorder.isTypeSupported("audio/webm") ? "audio/webm" : "audio/mp4";
828
+ const recorder = new MediaRecorder(stream, { mimeType: mt });
829
+ chunksRef.current = [];
830
+ recorder.ondataavailable = (e) => {
831
+ if (e.data.size > 0) chunksRef.current.push(e.data);
832
+ };
833
+ mediaRecorderRef.current = recorder;
834
+ setMimeType(mt);
835
+ setBlob(null);
836
+ accumulatedMsRef.current = 0;
837
+ segmentStartRef.current = performance.now();
838
+ recorder.start();
839
+ setState("recording");
840
+ startMeter(stream);
841
+ } catch (err) {
842
+ stopTracks();
843
+ setError(classifyMediaError(err, "microphone"));
844
+ }
845
+ }, [startMeter, stopTracks]);
846
+ const pause = React2.useCallback(() => {
847
+ const recorder = mediaRecorderRef.current;
848
+ if (!recorder || recorder.state !== "recording") return;
849
+ recorder.pause();
850
+ accumulatedMsRef.current += performance.now() - segmentStartRef.current;
851
+ stopMeter();
852
+ setLevel(0);
853
+ setState("paused");
854
+ }, [stopMeter]);
855
+ const resume = React2.useCallback(() => {
856
+ const recorder = mediaRecorderRef.current;
857
+ if (!recorder || recorder.state !== "paused") return;
858
+ recorder.resume();
859
+ segmentStartRef.current = performance.now();
860
+ setState("recording");
861
+ if (streamRef.current) startMeter(streamRef.current);
862
+ }, [startMeter]);
863
+ const stop = React2.useCallback(() => {
864
+ const recorder = mediaRecorderRef.current;
865
+ if (!recorder || recorder.state === "inactive") return;
866
+ const finalElapsed = recorder.state === "paused" ? accumulatedMsRef.current : accumulatedMsRef.current + (performance.now() - segmentStartRef.current);
867
+ stopMeter();
868
+ recorder.onstop = () => {
869
+ stopTracks();
870
+ const finalBlob = chunksRef.current.length ? new Blob(chunksRef.current, { type: recorder.mimeType }) : null;
871
+ setBlob(finalBlob);
872
+ setElapsedMs(finalElapsed);
873
+ setLevel(0);
874
+ setState("stopped");
875
+ };
876
+ recorder.stop();
877
+ }, [stopMeter, stopTracks]);
878
+ const reset = React2.useCallback(() => {
879
+ setState("idle");
880
+ setBlob(null);
881
+ setElapsedMs(0);
882
+ setLevel(0);
883
+ setMimeType(null);
884
+ setError(null);
885
+ }, []);
886
+ return { state, level, elapsedMs, blob, mimeType, error, start, pause, resume, stop, reset };
887
+ }
888
+
889
+ // src/documents/format-elapsed.ts
890
+ function formatElapsed(ms) {
891
+ const totalSeconds = Math.max(0, Math.floor(ms / 1e3));
892
+ const minutes = Math.floor(totalSeconds / 60);
893
+ const seconds = totalSeconds % 60;
894
+ return `${String(minutes).padStart(2, "0")}:${String(seconds).padStart(2, "0")}`;
895
+ }
896
+ var BAR_WEIGHTS = [
897
+ 0.25,
898
+ 0.32,
899
+ 0.48,
900
+ 0.62,
901
+ 0.82,
902
+ 0.56,
903
+ 0.92,
904
+ 0.72,
905
+ 1,
906
+ 0.86,
907
+ 0.62,
908
+ 0.96,
909
+ 0.76,
910
+ 0.5,
911
+ 0.84,
912
+ 0.66,
913
+ 0.42,
914
+ 0.56,
915
+ 0.36,
916
+ 0.28,
917
+ 0.22
918
+ ];
919
+ var MIN_BAR_PX = 3;
920
+ var MAX_BAR_PX = 40;
921
+ function MicWaveformIndicator({
922
+ level,
923
+ elapsedMs,
924
+ paused = false
925
+ }) {
926
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-center gap-3", "data-testid": "mic-waveform-indicator", children: [
927
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
928
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "relative flex h-2 w-2", children: [
929
+ !paused && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "absolute inline-flex h-full w-full animate-ping rounded-full bg-red-500 opacity-75" }),
930
+ /* @__PURE__ */ jsxRuntime.jsx(
931
+ "span",
932
+ {
933
+ className: `relative inline-flex h-2 w-2 rounded-full ${paused ? "bg-muted-foreground" : "bg-red-500"}`
934
+ }
935
+ )
936
+ ] }),
937
+ /* @__PURE__ */ jsxRuntime.jsx(
938
+ "span",
939
+ {
940
+ className: `text-xs font-semibold uppercase tracking-wide ${paused ? "text-muted-foreground" : "text-red-500"}`,
941
+ children: paused ? "Paused" : "Rec"
942
+ }
943
+ ),
944
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-mono text-xs tabular-nums text-muted-foreground", children: formatElapsed(elapsedMs) })
945
+ ] }),
946
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex h-10 items-end gap-[3px]", "data-testid": "mic-waveform-indicator-bars", children: BAR_WEIGHTS.map((weight, i) => /* @__PURE__ */ jsxRuntime.jsx(
947
+ "span",
948
+ {
949
+ className: "w-1 rounded-full bg-secondary transition-[height] duration-75 ease-out",
950
+ style: {
951
+ height: Math.min(MAX_BAR_PX, Math.max(MIN_BAR_PX, level * weight * MAX_BAR_PX))
952
+ }
953
+ },
954
+ i
955
+ )) })
956
+ ] });
957
+ }
958
+ function MicRecordingOverlay({
959
+ level,
960
+ elapsedMs,
961
+ paused,
962
+ caption = "Keep button pressed while speaking"
963
+ }) {
964
+ if (typeof document === "undefined") return null;
965
+ return reactDom.createPortal(
966
+ /* @__PURE__ */ jsxRuntime.jsx(
967
+ "div",
968
+ {
969
+ "aria-hidden": true,
970
+ className: "pointer-events-none fixed inset-0 z-[2147483647] flex items-center justify-center",
971
+ "data-testid": "mic-recording-overlay",
972
+ children: /* @__PURE__ */ jsxRuntime.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: [
973
+ /* @__PURE__ */ jsxRuntime.jsx(MicWaveformIndicator, { level, elapsedMs, paused }),
974
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-center text-sm font-medium text-muted-foreground", children: caption })
975
+ ] })
976
+ }
977
+ ),
978
+ document.body
979
+ );
980
+ }
981
+ var HOLD_THRESHOLD_MS = 350;
982
+ function InlineMicButton({
983
+ focused,
984
+ onTranscript,
985
+ onError,
986
+ transcribe,
987
+ className
988
+ }) {
989
+ const recorder = useAudioRecorder();
990
+ const [isTranscribing, setIsTranscribing] = React2.useState(false);
991
+ const [latched, setLatched] = React2.useState(false);
992
+ const pressedAtRef = React2.useRef(0);
993
+ React2.useEffect(() => {
994
+ if (recorder.error) onError?.(recorder.error);
995
+ }, [recorder.error]);
996
+ React2.useEffect(() => {
997
+ if (recorder.state !== "stopped" || !recorder.blob) return;
998
+ const blob = recorder.blob;
999
+ setIsTranscribing(true);
1000
+ transcribe(blob).then((text) => {
1001
+ if (text.trim()) onTranscript(text.trim());
1002
+ }).catch((err) => {
1003
+ onError?.(err instanceof Error ? err.message : "Could not transcribe audio.");
1004
+ }).finally(() => {
1005
+ setIsTranscribing(false);
1006
+ setLatched(false);
1007
+ recorder.reset();
1008
+ });
1009
+ }, [recorder.state, recorder.blob]);
1010
+ const isRecording = recorder.state === "recording";
1011
+ const isBusy = isTranscribing;
1012
+ if (!focused && !isRecording && !isBusy) return null;
1013
+ const handlePointerDown = (e) => {
1014
+ e.preventDefault();
1015
+ if (isRecording) return;
1016
+ pressedAtRef.current = Date.now();
1017
+ void recorder.start();
1018
+ };
1019
+ const handlePointerUp = () => {
1020
+ if (!isRecording) return;
1021
+ if (latched) {
1022
+ recorder.stop();
1023
+ setLatched(false);
1024
+ return;
1025
+ }
1026
+ const held = Date.now() - pressedAtRef.current;
1027
+ if (held >= HOLD_THRESHOLD_MS) {
1028
+ recorder.stop();
1029
+ } else {
1030
+ setLatched(true);
1031
+ }
1032
+ };
1033
+ const handlePointerLeave = () => {
1034
+ if (isRecording && !latched) recorder.stop();
1035
+ };
1036
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1037
+ /* @__PURE__ */ jsxRuntime.jsx(
1038
+ "button",
1039
+ {
1040
+ type: "button",
1041
+ onPointerDown: handlePointerDown,
1042
+ onPointerUp: handlePointerUp,
1043
+ onPointerLeave: handlePointerLeave,
1044
+ onPointerCancel: handlePointerLeave,
1045
+ disabled: isBusy,
1046
+ title: isRecording ? "Release to stop, or tap again if hands-free" : "Hold, or tap to dictate",
1047
+ "data-testid": "inline-mic-button",
1048
+ 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 ?? ""}`,
1049
+ children: isBusy ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "h-3.5 w-3.5 animate-spin" }) : isRecording ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Square, { className: "h-3 w-3 fill-current" }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Mic, { className: "h-3.5 w-3.5" })
1050
+ }
1051
+ ),
1052
+ isRecording && /* @__PURE__ */ jsxRuntime.jsx(
1053
+ MicRecordingOverlay,
1054
+ {
1055
+ level: recorder.level,
1056
+ elapsedMs: recorder.elapsedMs,
1057
+ caption: latched ? "Tap the mic again to stop" : "Release to stop, or keep holding"
1058
+ }
1059
+ )
1060
+ ] });
1061
+ }
1062
+ var Input = React2__namespace.forwardRef(
1063
+ ({ className, type, dictate, onFocus, onBlur, ...props }, forwardedRef) => {
1064
+ const dictateCtx = useDictateContext();
1065
+ const [focused, setFocused] = React2__namespace.useState(false);
1066
+ const innerRef = React2__namespace.useRef(null);
1067
+ React2__namespace.useImperativeHandle(forwardedRef, () => innerRef.current);
1068
+ const showDictate = dictate && !!dictateCtx && !props.disabled && !props.readOnly;
1069
+ const input = /* @__PURE__ */ jsxRuntime.jsx(
1070
+ "input",
1071
+ {
1072
+ type,
1073
+ "data-slot": "input",
1074
+ className: chunkRZQACYNQ_cjs.cn(
1075
+ "flex h-9 pointer-coarse:h-11 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",
1076
+ showDictate && "pr-9",
1077
+ className
1078
+ ),
1079
+ ref: innerRef,
1080
+ onFocus: (e) => {
1081
+ setFocused(true);
1082
+ onFocus?.(e);
1083
+ },
1084
+ onBlur: (e) => {
1085
+ setFocused(false);
1086
+ onBlur?.(e);
1087
+ },
1088
+ ...props
1089
+ }
1090
+ );
1091
+ if (!showDictate) return input;
1092
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative w-full", children: [
1093
+ input,
1094
+ /* @__PURE__ */ jsxRuntime.jsx(
1095
+ InlineMicButton,
1096
+ {
1097
+ focused,
1098
+ transcribe: dictateCtx.transcribe,
1099
+ onError: dictateCtx.onError,
1100
+ className: "absolute right-1.5 top-1/2 -translate-y-1/2",
1101
+ onTranscript: (text) => {
1102
+ const el = innerRef.current;
1103
+ if (!el) return;
1104
+ const next = el.value ? `${el.value} ${text}` : text;
1105
+ const setter = Object.getOwnPropertyDescriptor(
1106
+ window.HTMLInputElement.prototype,
1107
+ "value"
1108
+ )?.set;
1109
+ setter?.call(el, next);
1110
+ el.dispatchEvent(new Event("input", { bubbles: true }));
1111
+ }
1112
+ }
1113
+ )
1114
+ ] });
1115
+ }
1116
+ );
1117
+ Input.displayName = "Input";
1118
+ var Label = React2__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1119
+ "label",
1120
+ {
1121
+ ref,
1122
+ className: `text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70 ${className || ""}`,
1123
+ ...props
1124
+ }
1125
+ ));
1126
+ Label.displayName = "Label";
1127
+ var Separator = React2__namespace.forwardRef(({ className, orientation = "horizontal", decorative = true, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1128
+ SeparatorPrimitive__namespace.Root,
1129
+ {
1130
+ ref,
1131
+ decorative,
1132
+ orientation,
1133
+ className: chunkRZQACYNQ_cjs.cn(
1134
+ "shrink-0 bg-border",
1135
+ orientation === "horizontal" ? "h-[1px] w-full" : "h-full w-[1px]",
1136
+ className
1137
+ ),
1138
+ ...props
1139
+ }
1140
+ ));
1141
+ Separator.displayName = SeparatorPrimitive__namespace.Root.displayName;
1142
+ var Textarea = React2__namespace.forwardRef(
1143
+ ({ className, dictate, onFocus, onBlur, ...props }, forwardedRef) => {
1144
+ const dictateCtx = useDictateContext();
1145
+ const [focused, setFocused] = React2__namespace.useState(false);
1146
+ const innerRef = React2__namespace.useRef(null);
1147
+ React2__namespace.useImperativeHandle(forwardedRef, () => innerRef.current);
1148
+ const showDictate = dictate && !!dictateCtx && !props.disabled && !props.readOnly;
1149
+ const textarea = /* @__PURE__ */ jsxRuntime.jsx(
1150
+ "textarea",
1151
+ {
1152
+ className: chunkRZQACYNQ_cjs.cn(
1153
+ "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",
1154
+ showDictate && "pr-9",
1155
+ className
1156
+ ),
1157
+ ref: innerRef,
1158
+ onFocus: (e) => {
1159
+ setFocused(true);
1160
+ onFocus?.(e);
1161
+ },
1162
+ onBlur: (e) => {
1163
+ setFocused(false);
1164
+ onBlur?.(e);
1165
+ },
1166
+ ...props
1167
+ }
1168
+ );
1169
+ if (!showDictate) return textarea;
1170
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative w-full", children: [
1171
+ textarea,
1172
+ /* @__PURE__ */ jsxRuntime.jsx(
1173
+ InlineMicButton,
1174
+ {
1175
+ focused,
1176
+ transcribe: dictateCtx.transcribe,
1177
+ onError: dictateCtx.onError,
1178
+ className: "absolute right-1.5 top-1.5",
1179
+ onTranscript: (text) => {
1180
+ const el = innerRef.current;
1181
+ if (!el) return;
1182
+ const next = el.value ? `${el.value} ${text}` : text;
1183
+ const setter = Object.getOwnPropertyDescriptor(
1184
+ window.HTMLTextAreaElement.prototype,
1185
+ "value"
1186
+ )?.set;
1187
+ setter?.call(el, next);
1188
+ el.dispatchEvent(new Event("input", { bubbles: true }));
1189
+ }
1190
+ }
1191
+ )
1192
+ ] });
1193
+ }
1194
+ );
1195
+ Textarea.displayName = "Textarea";
1196
+ var Collapsible = CollapsiblePrimitive__namespace.Root;
1197
+ var CollapsibleTrigger2 = CollapsiblePrimitive__namespace.CollapsibleTrigger;
1198
+ var CollapsibleContent2 = CollapsiblePrimitive__namespace.CollapsibleContent;
1199
+ var Progress = React2__namespace.forwardRef(({ className, value, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1200
+ ProgressPrimitive__namespace.Root,
1201
+ {
1202
+ ref,
1203
+ className: chunkRZQACYNQ_cjs.cn("relative h-2 w-full overflow-hidden rounded-full bg-primary/20", className),
1204
+ ...props,
1205
+ children: /* @__PURE__ */ jsxRuntime.jsx(
1206
+ ProgressPrimitive__namespace.Indicator,
1207
+ {
1208
+ className: "h-full w-full flex-1 bg-primary transition-all",
1209
+ style: { transform: `translateX(-${100 - (value || 0)}%)` }
1210
+ }
1211
+ )
1212
+ }
1213
+ ));
1214
+ Progress.displayName = ProgressPrimitive__namespace.Root.displayName;
1215
+ var RadioGroup = React2__namespace.forwardRef(({ className, ...props }, ref) => {
1216
+ return /* @__PURE__ */ jsxRuntime.jsx(RadioGroupPrimitive__namespace.Root, { className: chunkRZQACYNQ_cjs.cn("grid gap-2", className), ...props, ref });
1217
+ });
1218
+ RadioGroup.displayName = RadioGroupPrimitive__namespace.Root.displayName;
1219
+ var RadioGroupItem = React2__namespace.forwardRef(({ className, ...props }, ref) => {
1220
+ return /* @__PURE__ */ jsxRuntime.jsx(
1221
+ RadioGroupPrimitive__namespace.Item,
1222
+ {
1223
+ ref,
1224
+ className: chunkRZQACYNQ_cjs.cn(
1225
+ "relative aspect-square h-4 w-4 rounded-full border border-primary text-primary after:absolute after:left-1/2 after:top-1/2 after:hidden after:size-11 after:-translate-x-1/2 after:-translate-y-1/2 after:content-[''] pointer-coarse:after:block focus:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",
1226
+ className
1227
+ ),
1228
+ ...props,
1229
+ children: /* @__PURE__ */ jsxRuntime.jsx(RadioGroupPrimitive__namespace.Indicator, { className: "flex items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Circle, { className: "h-2.5 w-2.5 fill-current text-current" }) })
1230
+ }
1231
+ );
1232
+ });
1233
+ RadioGroupItem.displayName = RadioGroupPrimitive__namespace.Item.displayName;
1234
+ var Checkbox = React2__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1235
+ CheckboxPrimitive__namespace.Root,
1236
+ {
1237
+ ref,
1238
+ className: chunkRZQACYNQ_cjs.cn(
1239
+ "peer relative h-4 w-4 shrink-0 rounded-sm border border-muted-foreground/50 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 after:absolute after:left-1/2 after:top-1/2 after:hidden after:size-11 after:-translate-x-1/2 after:-translate-y-1/2 after:content-[''] pointer-coarse:after:block",
1240
+ className
1241
+ ),
1242
+ ...props,
1243
+ children: /* @__PURE__ */ jsxRuntime.jsx(CheckboxPrimitive__namespace.Indicator, { className: chunkRZQACYNQ_cjs.cn("flex items-center justify-center text-current"), children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, { className: "h-4 w-4" }) })
1244
+ }
1245
+ ));
1246
+ Checkbox.displayName = CheckboxPrimitive__namespace.Root.displayName;
1247
+ var Switch = React2__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1248
+ SwitchPrimitives__namespace.Root,
1249
+ {
1250
+ className: chunkRZQACYNQ_cjs.cn(
1251
+ "peer relative 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 dark:data-[state=unchecked]:bg-muted-foreground/45 after:absolute after:left-1/2 after:top-1/2 after:hidden after:size-11 after:-translate-x-1/2 after:-translate-y-1/2 after:content-[''] pointer-coarse:after:block",
1252
+ className
1253
+ ),
1254
+ ...props,
1255
+ ref,
1256
+ children: /* @__PURE__ */ jsxRuntime.jsx(
1257
+ SwitchPrimitives__namespace.Thumb,
1258
+ {
1259
+ className: chunkRZQACYNQ_cjs.cn(
1260
+ "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"
1261
+ )
1262
+ }
1263
+ )
1264
+ }
1265
+ ));
1266
+ Switch.displayName = SwitchPrimitives__namespace.Root.displayName;
1267
+ var Tabs = TabsPrimitive__namespace.Root;
1268
+ var TabsList = React2__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1269
+ TabsPrimitive__namespace.List,
1270
+ {
1271
+ ref,
1272
+ className: chunkRZQACYNQ_cjs.cn(
1273
+ "inline-flex h-9 pointer-coarse:h-auto items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",
1274
+ className
1275
+ ),
1276
+ ...props
1277
+ }
1278
+ ));
1279
+ TabsList.displayName = TabsPrimitive__namespace.List.displayName;
1280
+ var TabsTrigger = React2__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1281
+ TabsPrimitive__namespace.Trigger,
1282
+ {
1283
+ ref,
1284
+ className: chunkRZQACYNQ_cjs.cn(
1285
+ "inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm pointer-coarse:min-h-11 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",
1286
+ className
1287
+ ),
1288
+ ...props
1289
+ }
1290
+ ));
1291
+ TabsTrigger.displayName = TabsPrimitive__namespace.Trigger.displayName;
1292
+ var TabsContent = React2__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1293
+ TabsPrimitive__namespace.Content,
1294
+ {
1295
+ ref,
1296
+ className: chunkRZQACYNQ_cjs.cn(
1297
+ "mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
1298
+ className
1299
+ ),
1300
+ ...props
1301
+ }
1302
+ ));
1303
+ TabsContent.displayName = TabsPrimitive__namespace.Content.displayName;
1304
+ var Table = React2__namespace.forwardRef(
1305
+ ({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "relative w-full overflow-auto", children: /* @__PURE__ */ jsxRuntime.jsx("table", { ref, className: chunkRZQACYNQ_cjs.cn("w-full caption-bottom text-sm", className), ...props }) })
1306
+ );
1307
+ Table.displayName = "Table";
1308
+ var TableHeader = React2__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("thead", { ref, className: chunkRZQACYNQ_cjs.cn("[&_tr]:border-b", className), ...props }));
1309
+ TableHeader.displayName = "TableHeader";
1310
+ var TableBody = React2__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("tbody", { ref, className: chunkRZQACYNQ_cjs.cn("[&_tr:last-child]:border-0", className), ...props }));
1311
+ TableBody.displayName = "TableBody";
1312
+ var TableFooter = React2__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1313
+ "tfoot",
1314
+ {
1315
+ ref,
1316
+ className: chunkRZQACYNQ_cjs.cn("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0", className),
1317
+ ...props
1318
+ }
1319
+ ));
1320
+ TableFooter.displayName = "TableFooter";
1321
+ var TableRow = React2__namespace.forwardRef(
1322
+ ({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1323
+ "tr",
1324
+ {
1325
+ ref,
1326
+ className: chunkRZQACYNQ_cjs.cn(
1327
+ "border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",
1328
+ className
1329
+ ),
1330
+ ...props
1331
+ }
1332
+ )
1333
+ );
1334
+ TableRow.displayName = "TableRow";
1335
+ var TableHead = React2__namespace.forwardRef(
1336
+ ({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1337
+ "th",
1338
+ {
1339
+ ref,
1340
+ className: chunkRZQACYNQ_cjs.cn(
1341
+ "h-10 px-2 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",
1342
+ className
1343
+ ),
1344
+ ...props
1345
+ }
1346
+ )
1347
+ );
1348
+ TableHead.displayName = "TableHead";
1349
+ var TableCell = React2__namespace.forwardRef(
1350
+ ({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1351
+ "td",
1352
+ {
1353
+ ref,
1354
+ className: chunkRZQACYNQ_cjs.cn(
1355
+ "p-2 align-middle [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",
1356
+ className
1357
+ ),
1358
+ ...props
1359
+ }
1360
+ )
1361
+ );
1362
+ TableCell.displayName = "TableCell";
1363
+ var TableCaption = React2__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("caption", { ref, className: chunkRZQACYNQ_cjs.cn("mt-4 text-sm text-muted-foreground", className), ...props }));
1364
+ TableCaption.displayName = "TableCaption";
1365
+ var Slider = React2__namespace.forwardRef(
1366
+ ({ className, rangeClassName, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
1367
+ SliderPrimitive__namespace.Root,
1368
+ {
1369
+ ref,
1370
+ className: chunkRZQACYNQ_cjs.cn("relative flex w-full touch-none select-none items-center", className),
1371
+ ...props,
1372
+ children: [
1373
+ /* @__PURE__ */ jsxRuntime.jsx(SliderPrimitive__namespace.Track, { className: "relative h-1.5 w-full grow overflow-hidden rounded-full bg-primary/20", children: /* @__PURE__ */ jsxRuntime.jsx(SliderPrimitive__namespace.Range, { className: chunkRZQACYNQ_cjs.cn("absolute h-full bg-primary", rangeClassName) }) }),
1374
+ /* @__PURE__ */ jsxRuntime.jsx(SliderPrimitive__namespace.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" })
1375
+ ]
1376
+ }
1377
+ )
1378
+ );
1379
+ Slider.displayName = SliderPrimitive__namespace.Root.displayName;
1380
+ var toggleVariants = classVarianceAuthority.cva(
1381
+ "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",
1382
+ {
1383
+ variants: {
1384
+ variant: {
1385
+ default: "bg-transparent",
1386
+ outline: "border border-input bg-transparent shadow-sm hover:bg-accent hover:text-accent-foreground"
1387
+ },
1388
+ size: {
1389
+ default: "h-9 px-2 min-w-9 pointer-coarse:h-11 pointer-coarse:min-w-11",
1390
+ sm: "h-8 px-1.5 min-w-8 pointer-coarse:h-11 pointer-coarse:min-w-11",
1391
+ lg: "h-10 px-2.5 min-w-10 pointer-coarse:h-11 pointer-coarse:min-w-11"
1392
+ }
1393
+ },
1394
+ defaultVariants: {
1395
+ variant: "default",
1396
+ size: "default"
1397
+ }
1398
+ }
1399
+ );
1400
+ var Toggle = React2__namespace.forwardRef(({ className, variant, size, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1401
+ TogglePrimitive__namespace.Root,
1402
+ {
1403
+ ref,
1404
+ className: chunkRZQACYNQ_cjs.cn(toggleVariants({ variant, size, className })),
1405
+ ...props
1406
+ }
1407
+ ));
1408
+ Toggle.displayName = TogglePrimitive__namespace.Root.displayName;
1409
+ var ToggleGroupContext = React2__namespace.createContext({
1410
+ size: "default",
1411
+ variant: "default"
1412
+ });
1413
+ var ToggleGroup = React2__namespace.forwardRef(({ className, variant, size, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1414
+ ToggleGroupPrimitive__namespace.Root,
1415
+ {
1416
+ ref,
1417
+ className: chunkRZQACYNQ_cjs.cn("flex items-center justify-center gap-1", className),
1418
+ ...props,
1419
+ children: /* @__PURE__ */ jsxRuntime.jsx(ToggleGroupContext.Provider, { value: { variant, size }, children })
1420
+ }
1421
+ ));
1422
+ ToggleGroup.displayName = ToggleGroupPrimitive__namespace.Root.displayName;
1423
+ var ToggleGroupItem = React2__namespace.forwardRef(({ className, children, variant, size, ...props }, ref) => {
1424
+ const context = React2__namespace.useContext(ToggleGroupContext);
1425
+ return /* @__PURE__ */ jsxRuntime.jsx(
1426
+ ToggleGroupPrimitive__namespace.Item,
1427
+ {
1428
+ ref,
1429
+ className: chunkRZQACYNQ_cjs.cn(
1430
+ toggleVariants({
1431
+ variant: context.variant || variant,
1432
+ size: context.size || size
1433
+ }),
1434
+ className
1435
+ ),
1436
+ ...props,
1437
+ children
1438
+ }
1439
+ );
1440
+ });
1441
+ ToggleGroupItem.displayName = ToggleGroupPrimitive__namespace.Item.displayName;
1442
+
1443
+ // src/lib/toast-interaction.ts
1444
+ function isToastInteraction(event) {
1445
+ const original = event.detail?.originalEvent;
1446
+ const target = original?.target ?? event.target;
1447
+ return target instanceof Element && target.closest("[data-sonner-toaster]") !== null;
1448
+ }
1449
+ var Dialog = DialogPrimitive__namespace.Root;
1450
+ var DialogTrigger = DialogPrimitive__namespace.Trigger;
1451
+ var DialogPortal = DialogPrimitive__namespace.Portal;
1452
+ var DialogClose = DialogPrimitive__namespace.Close;
1453
+ var DialogOverlay = React2__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1454
+ DialogPrimitive__namespace.Overlay,
1455
+ {
1456
+ ref,
1457
+ className: chunkRZQACYNQ_cjs.cn(
1458
+ "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",
1459
+ className
1460
+ ),
1461
+ ...props
1462
+ }
1463
+ ));
1464
+ DialogOverlay.displayName = DialogPrimitive__namespace.Overlay.displayName;
1465
+ var PHONE_PRESENTATION = {
1466
+ center: "",
1467
+ sheet: "max-sm:top-auto max-sm:bottom-0 max-sm:left-0 max-sm:w-full max-sm:max-w-full max-sm:border-x-0 max-sm:border-b-0 max-sm:translate-x-0 max-sm:translate-y-0 max-sm:rounded-b-none max-sm:rounded-t-xl max-sm:pb-[max(1.5rem,env(safe-area-inset-bottom))] max-sm:max-h-[calc(100dvh-env(safe-area-inset-top,0px)-2.5rem)] max-sm:data-[state=open]:slide-in-from-bottom-10 max-sm:data-[state=open]:zoom-in-100 max-sm:data-[state=closed]:zoom-out-100",
1468
+ full: "max-sm:top-auto max-sm:bottom-0 max-sm:left-0 max-sm:border-x-0 max-sm:border-b-0 max-sm:h-[calc(100dvh-env(safe-area-inset-top,0px)-1rem)] max-sm:w-full max-sm:max-w-full max-sm:translate-x-0 max-sm:translate-y-0 max-sm:rounded-b-none max-sm:rounded-t-xl max-sm:pb-[max(1.5rem,env(safe-area-inset-bottom))] max-sm:max-h-none max-sm:data-[state=open]:slide-in-from-bottom-10 max-sm:data-[state=open]:zoom-in-100 max-sm:data-[state=closed]:zoom-out-100"
1469
+ };
1470
+ var DialogContent = React2__namespace.forwardRef(
1471
+ ({ className, children, hideCloseButton, presentation = "center", onInteractOutside, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(DialogPortal, { children: [
1472
+ /* @__PURE__ */ jsxRuntime.jsx(DialogOverlay, {}),
1473
+ /* @__PURE__ */ jsxRuntime.jsxs(
1474
+ DialogPrimitive__namespace.Content,
1475
+ {
1476
+ ref,
1477
+ "data-slot": "dialog-content",
1478
+ "data-presentation": presentation,
1479
+ onInteractOutside: (event) => {
1480
+ if (isToastInteraction(event)) event.preventDefault();
1481
+ onInteractOutside?.(event);
1482
+ },
1483
+ className: chunkRZQACYNQ_cjs.cn(
1484
+ // Always inside the viewport: width and height are capped by the DYNAMIC viewport (mobile
1485
+ // browser chrome) and the notch / home-indicator insets; the content scrolls inside.
1486
+ "fixed left-[50%] top-[50%] z-50 grid w-[calc(100%-2rem-env(safe-area-inset-left,0px)-env(safe-area-inset-right,0px))] max-w-lg max-h-[calc(min(100dvh,100svh,100vh)-2rem-env(safe-area-inset-top,0px)-env(safe-area-inset-bottom,0px))] translate-x-[-50%] translate-y-[-50%] will-change-transform grid-cols-[minmax(0,1fr)] gap-4 overflow-x-hidden overflow-y-auto overscroll-contain border bg-background p-6 shadow-xl 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",
1487
+ PHONE_PRESENTATION[presentation],
1488
+ className
1489
+ ),
1490
+ ...props,
1491
+ children: [
1492
+ children,
1493
+ !hideCloseButton && /* @__PURE__ */ jsxRuntime.jsxs(
1494
+ DialogPrimitive__namespace.Close,
1495
+ {
1496
+ className: "fixed right-4 top-4 z-20 inline-flex items-center justify-center rounded-sm pointer-coarse:right-2 pointer-coarse:top-2 pointer-coarse:size-11 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",
1497
+ "data-testid": "dialog-close-button",
1498
+ children: [
1499
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { className: "h-4 w-4" }),
1500
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Close dialog" })
1501
+ ]
1502
+ }
1503
+ )
1504
+ ]
1505
+ }
1506
+ )
1507
+ ] })
1508
+ );
1509
+ DialogContent.displayName = DialogPrimitive__namespace.Content.displayName;
1510
+ var DialogHeader = ({ className, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: chunkRZQACYNQ_cjs.cn("flex min-w-0 flex-col space-y-1.5 pr-8 text-left", className), ...props });
1511
+ DialogHeader.displayName = "DialogHeader";
1512
+ var DialogFooter = ({ className, ...props }) => /* @__PURE__ */ jsxRuntime.jsx(
1513
+ "div",
1514
+ {
1515
+ className: chunkRZQACYNQ_cjs.cn(
1516
+ // Sticks to the bottom of a scrolling dialog so the actions stay reachable.
1517
+ "sticky bottom-0 z-10 -mx-6 -mb-6 flex flex-col-reverse gap-2 bg-background px-6 pb-6 pt-3 sm:flex-row sm:justify-end",
1518
+ className
1519
+ ),
1520
+ ...props
1521
+ }
1522
+ );
1523
+ DialogFooter.displayName = "DialogFooter";
1524
+ var DialogTitle = React2__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1525
+ DialogPrimitive__namespace.Title,
1526
+ {
1527
+ ref,
1528
+ className: chunkRZQACYNQ_cjs.cn("break-words text-lg font-semibold leading-tight tracking-tight", className),
1529
+ ...props
1530
+ }
1531
+ ));
1532
+ DialogTitle.displayName = DialogPrimitive__namespace.Title.displayName;
1533
+ var DialogDescription = React2__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1534
+ DialogPrimitive__namespace.Description,
1535
+ {
1536
+ ref,
1537
+ className: chunkRZQACYNQ_cjs.cn("text-sm text-muted-foreground", className),
1538
+ ...props
1539
+ }
1540
+ ));
1541
+ DialogDescription.displayName = DialogPrimitive__namespace.Description.displayName;
1542
+ var Popover = PopoverPrimitive__namespace.Root;
1543
+ var PopoverTrigger = PopoverPrimitive__namespace.Trigger;
1544
+ var PopoverAnchor = PopoverPrimitive__namespace.Anchor;
1545
+ var PopoverContent = React2__namespace.forwardRef(({ className, align = "center", sideOffset = 4, container, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(PopoverPrimitive__namespace.Portal, { container: container ?? void 0, children: /* @__PURE__ */ jsxRuntime.jsx(
1546
+ PopoverPrimitive__namespace.Content,
1547
+ {
1548
+ ref,
1549
+ align,
1550
+ sideOffset,
1551
+ collisionPadding: chunkRZQACYNQ_cjs.getCollisionPadding(),
1552
+ className: chunkRZQACYNQ_cjs.cn(
1553
+ "z-50 w-72 max-w-[calc(100vw-1rem)] max-h-[var(--radix-popover-content-available-height)] overflow-y-auto overscroll-contain rounded-md border bg-popover p-4 text-popover-foreground shadow-lg 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]",
1554
+ className
1555
+ ),
1556
+ ...props
1557
+ }
1558
+ ) }));
1559
+ PopoverContent.displayName = PopoverPrimitive__namespace.Content.displayName;
1560
+ var FINE_OPEN_DELAY = 350;
1561
+ var FINE_CLOSE_DELAY = 180;
1562
+ function isFocusVisible(el) {
1563
+ try {
1564
+ return el.matches(":focus-visible");
1565
+ } catch {
1566
+ return true;
1567
+ }
1568
+ }
1569
+ function isCoarse(pointerType) {
1570
+ if (pointerType === "touch" || pointerType === "pen") return true;
1571
+ if (pointerType === "mouse") return false;
1572
+ return typeof window !== "undefined" && !!window.matchMedia?.("(pointer: coarse)").matches;
1573
+ }
1574
+ function MarkMenu({
1575
+ as = "span",
1576
+ href,
1577
+ items,
1578
+ preview,
1579
+ menuLabel,
1580
+ shouldClickRunPrimary = true,
1581
+ openDelay = FINE_OPEN_DELAY,
1582
+ closeDelay = FINE_CLOSE_DELAY,
1583
+ testId,
1584
+ menuTestId,
1585
+ triggerRef: externalRef,
1586
+ className,
1587
+ children,
1588
+ onPointerDown,
1589
+ onPointerEnter,
1590
+ onPointerLeave,
1591
+ onFocus,
1592
+ onBlur,
1593
+ onKeyDown,
1594
+ ...rest
1595
+ }) {
1596
+ const [open, setOpen] = React2.useState(false);
1597
+ const [side, setSide] = React2.useState("bottom");
1598
+ const menuId = React2.useId();
1599
+ const triggerRef = React2.useRef(null);
1600
+ const contentRef = React2.useRef(null);
1601
+ const timer = React2.useRef(null);
1602
+ const mode = React2.useRef("hover");
1603
+ const lastPointer = React2.useRef("mouse");
1604
+ const focusFirstOnOpen = React2.useRef(false);
1605
+ const isEmpty = items.length === 0 && !preview;
1606
+ const ordered = [...items].sort((a, b) => Number(!!b.primary) - Number(!!a.primary));
1607
+ const primary = ordered[0];
1608
+ const clearTimer = () => {
1609
+ if (timer.current) clearTimeout(timer.current);
1610
+ timer.current = null;
1611
+ };
1612
+ React2.useEffect(() => clearTimer, []);
1613
+ const rows = () => Array.from(contentRef.current?.querySelectorAll('[role="menuitem"]') ?? []);
1614
+ const firstItem = () => rows()[0];
1615
+ const openWith = (next, focusFirst = false) => {
1616
+ clearTimer();
1617
+ mode.current = next;
1618
+ focusFirstOnOpen.current = focusFirst;
1619
+ setSide(next === "press" && isCoarse(lastPointer.current) ? "top" : "bottom");
1620
+ setOpen(true);
1621
+ if (focusFirst) {
1622
+ requestAnimationFrame(() => firstItem()?.focus());
1623
+ }
1624
+ };
1625
+ const close = (returnFocus = false) => {
1626
+ clearTimer();
1627
+ setOpen(false);
1628
+ if (returnFocus) triggerRef.current?.focus({ preventScroll: true });
1629
+ };
1630
+ const schedule = (action, delay) => {
1631
+ clearTimer();
1632
+ timer.current = setTimeout(action, delay);
1633
+ };
1634
+ const handlePointerDown = (e) => {
1635
+ lastPointer.current = e.pointerType;
1636
+ onPointerDown?.(e);
1637
+ };
1638
+ const handlePointerEnter = (e) => {
1639
+ onPointerEnter?.(e);
1640
+ if (isCoarse(e.pointerType) || isEmpty) return;
1641
+ lastPointer.current = e.pointerType;
1642
+ schedule(() => openWith("hover"), openDelay);
1643
+ };
1644
+ const handlePointerLeave = (e) => {
1645
+ onPointerLeave?.(e);
1646
+ if (isCoarse(e.pointerType)) return;
1647
+ if (!open) return clearTimer();
1648
+ if (mode.current === "hover") schedule(() => close(), closeDelay);
1649
+ };
1650
+ const handleFocus = (e) => {
1651
+ onFocus?.(e);
1652
+ if (isEmpty) return;
1653
+ if (isFocusVisible(e.currentTarget)) schedule(() => openWith("focus"), openDelay);
1654
+ };
1655
+ const handleBlur = (e) => {
1656
+ onBlur?.(e);
1657
+ const next = e.relatedTarget;
1658
+ if (next && contentRef.current?.contains(next)) return;
1659
+ if (mode.current === "focus" || mode.current === "key") schedule(() => close(), closeDelay);
1660
+ else clearTimer();
1661
+ };
1662
+ const handleKeyDown = (e) => {
1663
+ onKeyDown?.(e);
1664
+ lastPointer.current = "keyboard";
1665
+ if (e.defaultPrevented || isEmpty) return;
1666
+ if (e.key === "Enter" || e.key === " " || e.key === "ArrowDown") {
1667
+ e.preventDefault();
1668
+ openWith("key", true);
1669
+ } else if (e.key === "Escape" && open) {
1670
+ e.preventDefault();
1671
+ e.stopPropagation();
1672
+ close(true);
1673
+ }
1674
+ };
1675
+ const handleClick = (e) => {
1676
+ if (isEmpty) return;
1677
+ if (e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) return;
1678
+ if (e.detail === 0 && lastPointer.current === "keyboard") {
1679
+ e.preventDefault();
1680
+ return;
1681
+ }
1682
+ if (isCoarse(lastPointer.current)) {
1683
+ e.preventDefault();
1684
+ if (open) close();
1685
+ else openWith("press");
1686
+ return;
1687
+ }
1688
+ if (shouldClickRunPrimary && primary?.onSelect) {
1689
+ e.preventDefault();
1690
+ close();
1691
+ primary.onSelect();
1692
+ }
1693
+ };
1694
+ const handleMenuKeyDown = (e) => {
1695
+ const list = rows();
1696
+ const index = list.indexOf(document.activeElement);
1697
+ let target;
1698
+ if (e.key === "ArrowDown") target = list[(index + 1) % list.length];
1699
+ else if (e.key === "ArrowUp") target = list[(index - 1 + list.length) % list.length];
1700
+ else if (e.key === "Home") target = list[0];
1701
+ else if (e.key === "End") target = list[list.length - 1];
1702
+ else if (e.key === "Escape") {
1703
+ e.preventDefault();
1704
+ e.stopPropagation();
1705
+ close(true);
1706
+ return;
1707
+ } else if (e.key === "Tab") {
1708
+ close();
1709
+ return;
1710
+ }
1711
+ if (target) {
1712
+ e.preventDefault();
1713
+ target.focus();
1714
+ }
1715
+ };
1716
+ const choose = (item) => {
1717
+ const wasKey = mode.current === "key";
1718
+ close(wasKey);
1719
+ item.onSelect?.();
1720
+ };
1721
+ const setTriggerRef = React2.useCallback(
1722
+ (el) => {
1723
+ triggerRef.current = el;
1724
+ if (typeof externalRef === "function") externalRef(el);
1725
+ else if (externalRef) externalRef.current = el;
1726
+ },
1727
+ [externalRef]
1728
+ );
1729
+ const triggerProps = {
1730
+ ref: setTriggerRef,
1731
+ className,
1732
+ "data-testid": testId,
1733
+ "data-slot": "mark",
1734
+ "aria-haspopup": "true",
1735
+ "aria-expanded": open,
1736
+ "aria-controls": open ? menuId : void 0,
1737
+ onPointerDown: handlePointerDown,
1738
+ onPointerEnter: handlePointerEnter,
1739
+ onPointerLeave: handlePointerLeave,
1740
+ onFocus: handleFocus,
1741
+ onBlur: handleBlur,
1742
+ onKeyDown: handleKeyDown,
1743
+ onClick: handleClick,
1744
+ ...rest
1745
+ };
1746
+ return /* @__PURE__ */ jsxRuntime.jsxs(Popover, { open: open && !isEmpty, children: [
1747
+ /* @__PURE__ */ jsxRuntime.jsx(PopoverAnchor, { asChild: true, children: as === "a" ? /* @__PURE__ */ jsxRuntime.jsx("a", { href, ...triggerProps, children }) : /* @__PURE__ */ jsxRuntime.jsx("span", { role: "button", tabIndex: 0, ...triggerProps, children }) }),
1748
+ /* @__PURE__ */ jsxRuntime.jsxs(
1749
+ PopoverContent,
1750
+ {
1751
+ ref: contentRef,
1752
+ id: menuId,
1753
+ side,
1754
+ align: "start",
1755
+ sideOffset: 6,
1756
+ collisionPadding: 8,
1757
+ role: "group",
1758
+ "data-testid": menuTestId,
1759
+ "data-slot": "mark-menu",
1760
+ className: "w-auto min-w-[12rem] max-w-[min(22rem,calc(100vw-1rem))] p-1",
1761
+ onOpenAutoFocus: (e) => {
1762
+ e.preventDefault();
1763
+ if (focusFirstOnOpen.current) firstItem()?.focus();
1764
+ },
1765
+ onCloseAutoFocus: (e) => e.preventDefault(),
1766
+ onEscapeKeyDown: (e) => {
1767
+ e.preventDefault();
1768
+ close(true);
1769
+ },
1770
+ onInteractOutside: (e) => {
1771
+ if (triggerRef.current?.contains(e.target)) e.preventDefault();
1772
+ },
1773
+ onPointerDownOutside: () => close(),
1774
+ onPointerEnter: clearTimer,
1775
+ onPointerLeave: (e) => {
1776
+ if (!isCoarse(e.pointerType) && mode.current === "hover")
1777
+ schedule(() => close(), closeDelay);
1778
+ },
1779
+ children: [
1780
+ preview && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-2 py-1.5 text-sm", children: preview }),
1781
+ ordered.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { role: "menu", "aria-label": menuLabel, onKeyDown: handleMenuKeyDown, children: ordered.map((item) => {
1782
+ const rowClass = chunkRZQACYNQ_cjs.cn(
1783
+ "flex w-full cursor-pointer items-center rounded-sm px-2 py-1.5 text-left text-sm outline-none transition-colors hover:bg-accent focus-visible:bg-accent pointer-coarse:min-h-11 pointer-coarse:px-3",
1784
+ item.primary && "font-medium pointer-coarse:text-base",
1785
+ item.destructive && "text-destructive"
1786
+ );
1787
+ return item.href && !item.onSelect ? /* @__PURE__ */ jsxRuntime.jsx(
1788
+ "a",
1789
+ {
1790
+ role: "menuitem",
1791
+ tabIndex: -1,
1792
+ href: item.href,
1793
+ className: rowClass,
1794
+ "data-testid": item.testId,
1795
+ onClick: () => close(),
1796
+ children: item.label
1797
+ },
1798
+ item.id
1799
+ ) : /* @__PURE__ */ jsxRuntime.jsx(
1800
+ "button",
1801
+ {
1802
+ type: "button",
1803
+ role: "menuitem",
1804
+ tabIndex: -1,
1805
+ className: rowClass,
1806
+ "data-testid": item.testId,
1807
+ onClick: () => choose(item),
1808
+ children: item.label
1809
+ },
1810
+ item.id
1811
+ );
1812
+ }) })
1813
+ ]
1814
+ }
1815
+ )
1816
+ ] });
1817
+ }
1818
+ var Select = SelectPrimitive__namespace.Root;
1819
+ var SelectGroup = SelectPrimitive__namespace.Group;
1820
+ var SelectValue = SelectPrimitive__namespace.Value;
1821
+ var SelectTrigger = React2__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
1822
+ SelectPrimitive__namespace.Trigger,
1823
+ {
1824
+ ref,
1825
+ className: chunkRZQACYNQ_cjs.cn(
1826
+ "flex h-9 pointer-coarse:min-h-11 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",
1827
+ className
1828
+ ),
1829
+ ...props,
1830
+ children: [
1831
+ children,
1832
+ /* @__PURE__ */ jsxRuntime.jsx(SelectPrimitive__namespace.Icon, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDown, { className: "h-4 w-4 opacity-50" }) })
1833
+ ]
1834
+ }
1835
+ ));
1836
+ SelectTrigger.displayName = SelectPrimitive__namespace.Trigger.displayName;
1837
+ var SelectScrollUpButton = React2__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1838
+ SelectPrimitive__namespace.ScrollUpButton,
1839
+ {
1840
+ ref,
1841
+ className: chunkRZQACYNQ_cjs.cn("flex cursor-default items-center justify-center py-1", className),
1842
+ ...props,
1843
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronUp, { className: "h-4 w-4" })
1844
+ }
1845
+ ));
1846
+ SelectScrollUpButton.displayName = SelectPrimitive__namespace.ScrollUpButton.displayName;
1847
+ var SelectScrollDownButton = React2__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1848
+ SelectPrimitive__namespace.ScrollDownButton,
1849
+ {
1850
+ ref,
1851
+ className: chunkRZQACYNQ_cjs.cn("flex cursor-default items-center justify-center py-1", className),
1852
+ ...props,
1853
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDown, { className: "h-4 w-4" })
1854
+ }
1855
+ ));
1856
+ SelectScrollDownButton.displayName = SelectPrimitive__namespace.ScrollDownButton.displayName;
1857
+ var SelectContent = React2__namespace.forwardRef(({ className, children, position = "popper", ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(SelectPrimitive__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsxs(
1858
+ SelectPrimitive__namespace.Content,
1859
+ {
1860
+ ref,
1861
+ className: chunkRZQACYNQ_cjs.cn(
1862
+ "relative z-50 max-h-[min(24rem,var(--radix-select-content-available-height))] min-w-[8rem] max-w-[calc(100vw-1rem)] overflow-hidden rounded-md border bg-popover 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",
1863
+ 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",
1864
+ className
1865
+ ),
1866
+ position,
1867
+ collisionPadding: chunkRZQACYNQ_cjs.getCollisionPadding(),
1868
+ ...props,
1869
+ children: [
1870
+ /* @__PURE__ */ jsxRuntime.jsx(SelectScrollUpButton, {}),
1871
+ /* @__PURE__ */ jsxRuntime.jsx(
1872
+ SelectPrimitive__namespace.Viewport,
1873
+ {
1874
+ className: chunkRZQACYNQ_cjs.cn(
1875
+ "p-1",
1876
+ position === "popper" && "h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"
1877
+ ),
1878
+ children
1879
+ }
1880
+ ),
1881
+ /* @__PURE__ */ jsxRuntime.jsx(SelectScrollDownButton, {})
1882
+ ]
1883
+ }
1884
+ ) }));
1885
+ SelectContent.displayName = SelectPrimitive__namespace.Content.displayName;
1886
+ var SelectLabel = React2__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1887
+ SelectPrimitive__namespace.Label,
1888
+ {
1889
+ ref,
1890
+ className: chunkRZQACYNQ_cjs.cn("py-1.5 pl-8 pr-2 text-sm font-semibold", className),
1891
+ ...props
1892
+ }
1893
+ ));
1894
+ SelectLabel.displayName = SelectPrimitive__namespace.Label.displayName;
1895
+ var SelectItem = React2__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
1896
+ SelectPrimitive__namespace.Item,
1897
+ {
1898
+ ref,
1899
+ className: chunkRZQACYNQ_cjs.cn(
1900
+ "relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 pointer-coarse:min-h-11 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
1901
+ className
1902
+ ),
1903
+ ...props,
1904
+ children: [
1905
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "absolute left-2 flex h-3.5 w-3.5 items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(SelectPrimitive__namespace.ItemIndicator, { children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, { className: "h-4 w-4" }) }) }),
1906
+ /* @__PURE__ */ jsxRuntime.jsx(SelectPrimitive__namespace.ItemText, { children })
1907
+ ]
1908
+ }
1909
+ ));
1910
+ SelectItem.displayName = SelectPrimitive__namespace.Item.displayName;
1911
+ var SelectSeparator = React2__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1912
+ SelectPrimitive__namespace.Separator,
1913
+ {
1914
+ ref,
1915
+ className: chunkRZQACYNQ_cjs.cn("-mx-1 my-1 h-px bg-muted", className),
1916
+ ...props
1917
+ }
1918
+ ));
1919
+ SelectSeparator.displayName = SelectPrimitive__namespace.Separator.displayName;
1920
+ var Command = React2__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1921
+ cmdk.Command,
1922
+ {
1923
+ ref,
1924
+ className: chunkRZQACYNQ_cjs.cn(
1925
+ "flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",
1926
+ className
1927
+ ),
1928
+ ...props
1929
+ }
1930
+ ));
1931
+ Command.displayName = cmdk.Command.displayName;
1932
+ var CommandDialog = ({ children, ...props }) => {
1933
+ return /* @__PURE__ */ jsxRuntime.jsx(Dialog, { ...props, children: /* @__PURE__ */ jsxRuntime.jsx(DialogContent, { className: "overflow-hidden p-0", children: /* @__PURE__ */ jsxRuntime.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 }) }) });
1934
+ };
1935
+ var CommandInput = React2__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center border-b px-3", "data-cmdk-input-wrapper": "", children: [
1936
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Search, { className: "mr-2 h-4 w-4 shrink-0 opacity-50" }),
1937
+ /* @__PURE__ */ jsxRuntime.jsx(
1938
+ cmdk.Command.Input,
1939
+ {
1940
+ ref,
1941
+ className: chunkRZQACYNQ_cjs.cn(
1942
+ "flex h-10 pointer-coarse:h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",
1943
+ className
1944
+ ),
1945
+ ...props
1946
+ }
1947
+ )
1948
+ ] }));
1949
+ CommandInput.displayName = cmdk.Command.Input.displayName;
1950
+ var CommandList = React2__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1951
+ cmdk.Command.List,
1952
+ {
1953
+ ref,
1954
+ className: chunkRZQACYNQ_cjs.cn("max-h-[min(300px,50dvh)] overflow-y-auto overflow-x-hidden", className),
1955
+ ...props
1956
+ }
1957
+ ));
1958
+ CommandList.displayName = cmdk.Command.List.displayName;
1959
+ var CommandEmpty = React2__namespace.forwardRef((props, ref) => /* @__PURE__ */ jsxRuntime.jsx(cmdk.Command.Empty, { ref, className: "py-6 text-center text-sm", ...props }));
1960
+ CommandEmpty.displayName = cmdk.Command.Empty.displayName;
1961
+ var CommandGroup = React2__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1962
+ cmdk.Command.Group,
1963
+ {
1964
+ ref,
1965
+ className: chunkRZQACYNQ_cjs.cn(
1966
+ "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",
1967
+ className
1968
+ ),
1969
+ ...props
1970
+ }
1971
+ ));
1972
+ CommandGroup.displayName = cmdk.Command.Group.displayName;
1973
+ var CommandSeparator = React2__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1974
+ cmdk.Command.Separator,
1975
+ {
1976
+ ref,
1977
+ className: chunkRZQACYNQ_cjs.cn("-mx-1 h-px bg-border", className),
1978
+ ...props
1979
+ }
1980
+ ));
1981
+ CommandSeparator.displayName = cmdk.Command.Separator.displayName;
1982
+ var CommandItem = React2__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1983
+ cmdk.Command.Item,
1984
+ {
1985
+ ref,
1986
+ className: chunkRZQACYNQ_cjs.cn(
1987
+ "relative flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 pointer-coarse:min-h-11 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",
1988
+ className
1989
+ ),
1990
+ ...props
1991
+ }
1992
+ ));
1993
+ CommandItem.displayName = cmdk.Command.Item.displayName;
1994
+ var CommandShortcut = ({ className, ...props }) => {
1995
+ return /* @__PURE__ */ jsxRuntime.jsx(
1996
+ "span",
1997
+ {
1998
+ className: chunkRZQACYNQ_cjs.cn("ml-auto text-sm tracking-widest text-muted-foreground", className),
1999
+ ...props
2000
+ }
2001
+ );
2002
+ };
2003
+ CommandShortcut.displayName = "CommandShortcut";
2004
+ var AI_COMPONENTS = {
2005
+ a: (p) => /* @__PURE__ */ jsxRuntime.jsx(
2006
+ "a",
2007
+ {
2008
+ className: "text-ai-accent underline underline-offset-2",
2009
+ target: "_blank",
2010
+ rel: "noopener noreferrer",
2011
+ ...p
2012
+ }
2013
+ ),
2014
+ // Redline marks: deletions in red strike, <ins>/<mark> additions accented.
2015
+ del: (p) => /* @__PURE__ */ jsxRuntime.jsx("del", { className: "rounded bg-destructive/10 text-destructive decoration-destructive/60", ...p }),
2016
+ ins: (p) => /* @__PURE__ */ jsxRuntime.jsx("ins", { className: "rounded bg-ai-accent-soft px-0.5 text-ai-accent no-underline", ...p }),
2017
+ mark: (p) => /* @__PURE__ */ jsxRuntime.jsx("mark", { className: "rounded bg-ai-accent-soft px-0.5 text-ai-accent", ...p }),
2018
+ thead: (p) => /* @__PURE__ */ jsxRuntime.jsx("thead", { className: "bg-secondary/60", ...p })
2019
+ };
2020
+ function AiMarkdown({
2021
+ children,
2022
+ className,
2023
+ isStreaming
2024
+ }) {
2025
+ return /* @__PURE__ */ jsxRuntime.jsx(
2026
+ MarkdownRenderer,
2027
+ {
2028
+ className: className ?? "text-sm text-foreground",
2029
+ components: AI_COMPONENTS,
2030
+ isStreaming,
2031
+ testId: "ai-markdown",
2032
+ children
2033
+ }
2034
+ );
2035
+ }
2036
+ var EntityPill = React2.forwardRef(function EntityPill2({
2037
+ icon,
2038
+ label,
2039
+ secondaryText,
2040
+ size = "sm",
2041
+ shape = "rounded",
2042
+ className,
2043
+ labelMaxWidth = "max-w-[320px]",
2044
+ labelClassName,
2045
+ fullWidth = false,
2046
+ highlight = false,
2047
+ onClick,
2048
+ onIconClick,
2049
+ onMoreClick,
2050
+ moreContent,
2051
+ href,
2052
+ disabled = false,
2053
+ tooltipContent,
2054
+ tooltipSide = "bottom",
2055
+ "data-testid": testId
2056
+ }, ref) {
2057
+ const shapeClass = shape === "pill" ? "rounded-full" : "rounded-md";
2058
+ const sizeClasses2 = size === "base" ? "gap-1.5 px-1.5 py-0.5" : "gap-1 px-1";
2059
+ const textSizeClass = size === "base" ? "text-base" : "text-sm";
2060
+ const baseClasses = chunkRZQACYNQ_cjs.cn(
2061
+ "group/pill items-center",
2062
+ fullWidth ? "flex w-full" : "inline-flex",
2063
+ sizeClasses2,
2064
+ shapeClass,
2065
+ "bg-muted",
2066
+ "border border-border",
2067
+ "transition-all",
2068
+ className
2069
+ );
2070
+ const interactiveClasses = "relative cursor-pointer hover:bg-muted/80 pointer-coarse:after:absolute pointer-coarse:after:inset-x-0 pointer-coarse:after:-inset-y-3 pointer-coarse:after:content-['']";
2071
+ const disabledClasses = "cursor-default opacity-60";
2072
+ const highlightClasses = "bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground";
2073
+ const mainContent = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2074
+ onIconClick ? /* @__PURE__ */ jsxRuntime.jsx(
2075
+ "span",
2076
+ {
2077
+ role: "button",
2078
+ tabIndex: 0,
2079
+ className: "flex-shrink-0 cursor-pointer hover:opacity-70 transition-opacity",
2080
+ onClick: (e) => {
2081
+ e.stopPropagation();
2082
+ onIconClick(e);
2083
+ },
2084
+ children: icon
2085
+ }
2086
+ ) : icon,
2087
+ /* @__PURE__ */ jsxRuntime.jsx(
2088
+ "span",
2089
+ {
2090
+ className: chunkRZQACYNQ_cjs.cn(
2091
+ textSizeClass,
2092
+ "font-medium truncate leading-tight min-w-0",
2093
+ labelMaxWidth,
2094
+ labelClassName
2095
+ ),
2096
+ children: label
2097
+ }
2098
+ ),
2099
+ secondaryText && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs text-muted-foreground flex-shrink-0 leading-none", children: secondaryText })
2100
+ ] });
2101
+ const tooltipWrap = (content, tip, side = tooltipSide, triggerClassName, triggerProps) => /* @__PURE__ */ jsxRuntime.jsxs(Tooltip, { children: [
2102
+ /* @__PURE__ */ jsxRuntime.jsx(
2103
+ TooltipTrigger,
2104
+ {
2105
+ onFocusCapture: (e) => e.stopPropagation(),
2106
+ className: triggerClassName,
2107
+ ...triggerProps,
2108
+ children: content
2109
+ }
2110
+ ),
2111
+ /* @__PURE__ */ jsxRuntime.jsx(TooltipContent, { side, className: "p-2", children: tip })
2112
+ ] });
2113
+ const mainAreaClass = chunkRZQACYNQ_cjs.cn("inline-flex items-center gap-1", fullWidth && "min-w-0 flex-1");
2114
+ const mainAreaTouchClass = chunkRZQACYNQ_cjs.cn(
2115
+ mainAreaClass,
2116
+ (onClick || href) && !disabled && "relative pointer-coarse:after:absolute pointer-coarse:after:inset-x-0 pointer-coarse:after:-inset-y-3 pointer-coarse:after:content-['']"
2117
+ );
2118
+ if (onMoreClick || moreContent) {
2119
+ let mainArea;
2120
+ if (tooltipContent) {
2121
+ mainArea = tooltipWrap(
2122
+ mainContent,
2123
+ tooltipContent,
2124
+ tooltipSide,
2125
+ chunkRZQACYNQ_cjs.cn(mainAreaTouchClass, disabled && "opacity-60"),
2126
+ {
2127
+ type: "button",
2128
+ onClick: href ? onClick : disabled ? void 0 : onClick,
2129
+ disabled: disabled || void 0
2130
+ }
2131
+ );
2132
+ } else if (href) {
2133
+ mainArea = /* @__PURE__ */ jsxRuntime.jsx(
2134
+ "a",
2135
+ {
2136
+ href,
2137
+ target: "_blank",
2138
+ rel: "noopener noreferrer",
2139
+ className: mainAreaTouchClass,
2140
+ onClick,
2141
+ children: mainContent
2142
+ }
2143
+ );
2144
+ } else if (onClick) {
2145
+ mainArea = /* @__PURE__ */ jsxRuntime.jsx(
2146
+ "button",
2147
+ {
2148
+ type: "button",
2149
+ onClick: disabled ? void 0 : onClick,
2150
+ disabled,
2151
+ className: chunkRZQACYNQ_cjs.cn(
2152
+ "relative inline-flex items-center gap-1 pointer-coarse:after:absolute pointer-coarse:after:inset-x-0 pointer-coarse:after:-inset-y-3 pointer-coarse:after:content-['']",
2153
+ disabled && "opacity-60"
2154
+ ),
2155
+ children: mainContent
2156
+ }
2157
+ );
2158
+ } else {
2159
+ mainArea = /* @__PURE__ */ jsxRuntime.jsx("span", { className: mainAreaTouchClass, children: mainContent });
2160
+ }
2161
+ const moreArea = moreContent ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex-shrink-0 leading-none", children: moreContent }) : tooltipWrap(
2162
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.MoreVertical, { className: "w-3.5 h-3.5" }),
2163
+ "Click for more",
2164
+ tooltipSide,
2165
+ "flex-shrink-0 leading-none text-muted-foreground hover:text-foreground",
2166
+ {
2167
+ type: "button",
2168
+ onClick: (e) => {
2169
+ e.stopPropagation();
2170
+ onMoreClick?.(e);
2171
+ }
2172
+ }
2173
+ );
2174
+ return /* @__PURE__ */ jsxRuntime.jsxs(
2175
+ "span",
2176
+ {
2177
+ ref,
2178
+ className: chunkRZQACYNQ_cjs.cn(
2179
+ baseClasses,
2180
+ (onClick || href) && !disabled && "cursor-pointer hover:bg-muted/80",
2181
+ highlight && highlightClasses
2182
+ ),
2183
+ "data-testid": testId,
2184
+ children: [
2185
+ mainArea,
2186
+ moreArea
2187
+ ]
2188
+ }
2189
+ );
2190
+ }
2191
+ if (tooltipContent) {
2192
+ if (href) {
2193
+ return tooltipWrap(
2194
+ /* @__PURE__ */ jsxRuntime.jsx(
2195
+ "a",
2196
+ {
2197
+ href,
2198
+ target: "_blank",
2199
+ rel: "noopener noreferrer",
2200
+ className: mainAreaClass,
2201
+ onClick,
2202
+ children: mainContent
2203
+ }
2204
+ ),
2205
+ tooltipContent,
2206
+ tooltipSide,
2207
+ chunkRZQACYNQ_cjs.cn(baseClasses, interactiveClasses),
2208
+ { "data-testid": testId }
2209
+ );
2210
+ }
2211
+ return tooltipWrap(
2212
+ mainContent,
2213
+ tooltipContent,
2214
+ tooltipSide,
2215
+ chunkRZQACYNQ_cjs.cn(
2216
+ baseClasses,
2217
+ onClick && !disabled ? interactiveClasses : "",
2218
+ disabled ? disabledClasses : "",
2219
+ highlight && highlightClasses
2220
+ ),
2221
+ {
2222
+ type: "button",
2223
+ ref,
2224
+ onClick: onClick && !disabled ? onClick : void 0,
2225
+ disabled: disabled || void 0,
2226
+ "data-testid": testId
2227
+ }
2228
+ );
2229
+ }
2230
+ if (href) {
2231
+ return /* @__PURE__ */ jsxRuntime.jsx(
2232
+ "a",
2233
+ {
2234
+ ref,
2235
+ href,
2236
+ target: "_blank",
2237
+ rel: "noopener noreferrer",
2238
+ className: chunkRZQACYNQ_cjs.cn(baseClasses, interactiveClasses),
2239
+ "data-testid": testId,
2240
+ onClick,
2241
+ children: mainContent
2242
+ }
2243
+ );
2244
+ }
2245
+ if (onClick) {
2246
+ return /* @__PURE__ */ jsxRuntime.jsx(
2247
+ "button",
2248
+ {
2249
+ ref,
2250
+ type: "button",
2251
+ onClick: disabled ? void 0 : onClick,
2252
+ disabled,
2253
+ className: chunkRZQACYNQ_cjs.cn(
2254
+ baseClasses,
2255
+ disabled ? disabledClasses : interactiveClasses,
2256
+ highlight && highlightClasses
2257
+ ),
2258
+ "data-testid": testId,
2259
+ children: mainContent
2260
+ }
2261
+ );
2262
+ }
2263
+ return /* @__PURE__ */ jsxRuntime.jsx(
2264
+ "span",
2265
+ {
2266
+ ref,
2267
+ className: chunkRZQACYNQ_cjs.cn(baseClasses, highlight && highlightClasses),
2268
+ "data-testid": testId,
2269
+ children: mainContent
2270
+ }
2271
+ );
2272
+ });
2273
+ var TAG_TYPE_LABELS = {
2274
+ checkbox: "Checkbox",
2275
+ select: "Select",
2276
+ number: "Number",
2277
+ text: "Text",
2278
+ folder: "Folder",
2279
+ search: "Saved Search",
2280
+ date: "Date",
2281
+ assistant: "AI Assistant"
2282
+ };
2283
+ var TAG_TYPE_ICONS = {
2284
+ checkbox: lucideReact.SquareCheckBig,
2285
+ select: lucideReact.List,
2286
+ number: lucideReact.Hash,
2287
+ text: lucideReact.NotebookPen,
2288
+ folder: lucideReact.Folder,
2289
+ search: lucideReact.Search,
2290
+ date: lucideReact.Calendar,
2291
+ assistant: lucideReact.Bot
2292
+ };
2293
+ function getTagTypeIcon(type) {
2294
+ return TAG_TYPE_ICONS[type ?? "text"] || lucideReact.NotebookPen;
2295
+ }
2296
+ function getTagTypeLabel(type) {
2297
+ const t = type ?? "text";
2298
+ return TAG_TYPE_LABELS[t] || t;
2299
+ }
2300
+ var BASE_COLORS = {
2301
+ "0": "#10b981",
2302
+ "1": "#3b82f6",
2303
+ "2": "#8b5cf6",
2304
+ "3": "#f43f5e",
2305
+ "4": "#f59e0b",
2306
+ "5": "#84cc16",
2307
+ "6": "#a855f7",
2308
+ "7": "#06b6d4",
2309
+ "8": "#f97316",
2310
+ "9": "#14b8a6",
2311
+ a: "#ef4444",
2312
+ b: "#6366f1",
2313
+ c: "#ec4899",
2314
+ d: "#22c55e",
2315
+ e: "#eab308",
2316
+ f: "#0ea5e9"
2317
+ };
2318
+ function getEntityColor(entityId) {
2319
+ return BASE_COLORS[entityId[4]] || BASE_COLORS["0"];
2320
+ }
2321
+ function TagEntity({
2322
+ tag,
2323
+ size = "md",
2324
+ className = "",
2325
+ onClick,
2326
+ showTooltip = true,
2327
+ tooltipContent
2328
+ }) {
2329
+ const tagType = tag.tag_type?.type ?? "text";
2330
+ const iconSize = size === "sm" ? 12 : size === "md" ? 14 : 16;
2331
+ const Icon2 = getTagTypeIcon(tagType);
2332
+ const sizeClasses2 = {
2333
+ sm: "p-0.5",
2334
+ md: "p-1",
2335
+ lg: "p-1.5"
2336
+ };
2337
+ const tagColor = tag.color ?? getEntityColor(tag.external_id);
2338
+ const iconElement = /* @__PURE__ */ jsxRuntime.jsx(
2339
+ "span",
2340
+ {
2341
+ className: `inline-flex items-center justify-center rounded-md text-white flex-shrink-0 ${sizeClasses2[size]}`,
2342
+ style: { backgroundColor: tagColor },
2343
+ children: /* @__PURE__ */ jsxRuntime.jsx(Icon2, { size: iconSize, className: "flex-shrink-0" })
2344
+ }
2345
+ );
2346
+ const pillSize = size === "lg" ? "base" : "sm";
2347
+ const defaultTooltip = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2", children: [
2348
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
2349
+ /* @__PURE__ */ jsxRuntime.jsx(
2350
+ "span",
2351
+ {
2352
+ className: "inline-flex items-center justify-center rounded-md text-white p-1",
2353
+ style: { backgroundColor: tagColor },
2354
+ children: /* @__PURE__ */ jsxRuntime.jsx(Icon2, { size: 16 })
2355
+ }
2356
+ ),
2357
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-medium text-sm", children: tag.name })
2358
+ ] }),
2359
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1.5 text-sm", children: [
2360
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
2361
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: "Type:" }),
2362
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: getTagTypeLabel(tagType) })
2363
+ ] }),
2364
+ tag.doctag_count != null && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
2365
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: "Documents:" }),
2366
+ /* @__PURE__ */ jsxRuntime.jsx(Badge, { variant: "secondary", className: "h-5 min-w-[20px] justify-center", children: tag.doctag_count ?? 0 })
2367
+ ] }),
2368
+ tag.shared != null && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: tag.shared ? "Shared" : "Private" }) })
2369
+ ] })
2370
+ ] });
2371
+ const resolvedTooltip = showTooltip ? tooltipContent ?? defaultTooltip : void 0;
2372
+ return /* @__PURE__ */ jsxRuntime.jsx(
2373
+ EntityPill,
2374
+ {
2375
+ icon: iconElement,
2376
+ label: tag.name,
2377
+ size: pillSize,
2378
+ shape: "rounded",
2379
+ labelMaxWidth: "max-w-[180px]",
2380
+ tooltipContent: resolvedTooltip,
2381
+ onClick,
2382
+ className,
2383
+ "data-testid": `tag-entity-${tag.external_id}`
2384
+ }
2385
+ );
2386
+ }
2387
+ var TIERS = [
2388
+ { min: 0.7, tone: "bg-emerald-500", label: "High relevance" },
2389
+ { min: 0.4, tone: "bg-amber-500", label: "Medium relevance" },
2390
+ { min: -Infinity, tone: "bg-muted-foreground/40", label: "Low relevance" }
2391
+ ];
2392
+ function RelevanceDot({ score }) {
2393
+ if (score == null) return null;
2394
+ const tier = TIERS.find((t) => score >= t.min) ?? TIERS[TIERS.length - 1];
2395
+ return /* @__PURE__ */ jsxRuntime.jsx(
2396
+ "span",
2397
+ {
2398
+ role: "img",
2399
+ "aria-label": tier.label,
2400
+ title: `${tier.label} (${score.toFixed(2)})`,
2401
+ className: chunkRZQACYNQ_cjs.cn("size-1.5 shrink-0 rounded-full", tier.tone),
2402
+ "data-testid": "passage-relevance"
2403
+ }
2404
+ );
2405
+ }
2406
+ function PassageCard({
2407
+ header,
2408
+ score,
2409
+ headerRight,
2410
+ active,
2411
+ onClick,
2412
+ footer,
2413
+ className,
2414
+ children,
2415
+ "data-testid": testId
2416
+ }) {
2417
+ const body = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2418
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mb-1.5 flex items-center gap-2", children: [
2419
+ header,
2420
+ (score != null || headerRight) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "ml-auto flex shrink-0 items-center gap-2", children: [
2421
+ /* @__PURE__ */ jsxRuntime.jsx(RelevanceDot, { score }),
2422
+ headerRight
2423
+ ] })
2424
+ ] }),
2425
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "[&_mark]:rounded-sm [&_mark]:bg-ai-accent/20 [&_mark]:px-0.5 [&_mark]:font-medium [&_mark]:text-foreground", children })
2426
+ ] });
2427
+ return /* @__PURE__ */ jsxRuntime.jsxs(
2428
+ "div",
2429
+ {
2430
+ className: chunkRZQACYNQ_cjs.cn(
2431
+ "group rounded-lg border border-border bg-card p-3 text-left transition-colors",
2432
+ onClick && "hover:border-ai-accent/40 focus-within:ring-2 focus-within:ring-ai-accent/40",
2433
+ active && "border-ai-accent/60 ring-1 ring-ai-accent/30",
2434
+ className
2435
+ ),
2436
+ children: [
2437
+ onClick ? /* @__PURE__ */ jsxRuntime.jsx(
2438
+ "div",
2439
+ {
2440
+ role: "button",
2441
+ tabIndex: 0,
2442
+ onClick,
2443
+ onKeyDown: (e) => {
2444
+ if (e.key === "Enter" || e.key === " ") {
2445
+ e.preventDefault();
2446
+ onClick(e);
2447
+ }
2448
+ },
2449
+ "aria-current": active || void 0,
2450
+ "data-testid": testId,
2451
+ className: "cursor-pointer focus:outline-none",
2452
+ children: body
2453
+ }
2454
+ ) : /* @__PURE__ */ jsxRuntime.jsx("div", { "aria-current": active || void 0, "data-testid": testId, children: body }),
2455
+ footer
2456
+ ]
2457
+ }
2458
+ );
2459
+ }
2460
+
2461
+ // src/icons/colors.ts
2462
+ var NEUTRAL_GRAY = "#64748b";
2463
+ var FILE_TYPE_COLORS = {
2464
+ pdf: "#ef4444",
2465
+ // red
2466
+ doc: "#3b82f6",
2467
+ // blue (Word docs)
2468
+ docx: "#3b82f6",
2469
+ // blue
2470
+ html: "#0284c7",
2471
+ // sky-600 (web files)
2472
+ img: "#8b5cf6",
2473
+ // violet-500 (images)
2474
+ vid: "#10b981",
2475
+ // emerald-500 (video)
2476
+ aud: "#f59e0b",
2477
+ // amber-500 (audio)
2478
+ xls: "#16a34a",
2479
+ // green-600 (Excel)
2480
+ eml: "#0d9488",
2481
+ // teal-600 (email)
2482
+ txt: NEUTRAL_GRAY,
2483
+ // gray (plain text)
2484
+ generic: NEUTRAL_GRAY,
2485
+ // gray (unknown)
2486
+ white: "#ffffff"
2487
+ // for strokes/text on colored backgrounds
2488
+ };
2489
+ var PdfIcon = ({ size = 16, className = "" }) => {
2490
+ return /* @__PURE__ */ jsxRuntime.jsxs(
2491
+ "svg",
2492
+ {
2493
+ width: size,
2494
+ height: size,
2495
+ viewBox: "0 0 24 24",
2496
+ fill: "none",
2497
+ xmlns: "http://www.w3.org/2000/svg",
2498
+ className,
2499
+ children: [
2500
+ /* @__PURE__ */ jsxRuntime.jsx(
2501
+ "path",
2502
+ {
2503
+ d: "M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8l-6-6z",
2504
+ fill: FILE_TYPE_COLORS.pdf,
2505
+ stroke: FILE_TYPE_COLORS.pdf,
2506
+ strokeWidth: "1",
2507
+ strokeLinecap: "round",
2508
+ strokeLinejoin: "round"
2509
+ }
2510
+ ),
2511
+ /* @__PURE__ */ jsxRuntime.jsx(
2512
+ "path",
2513
+ {
2514
+ d: "M14 2v6h6",
2515
+ fill: "none",
2516
+ stroke: FILE_TYPE_COLORS.white,
2517
+ strokeWidth: "1",
2518
+ strokeLinecap: "round",
2519
+ strokeLinejoin: "round"
2520
+ }
2521
+ ),
2522
+ /* @__PURE__ */ jsxRuntime.jsx(
2523
+ "text",
2524
+ {
2525
+ x: "12",
2526
+ y: "16",
2527
+ fontSize: "6",
2528
+ fill: "white",
2529
+ textAnchor: "middle",
2530
+ fontWeight: "bold",
2531
+ fontFamily: "Arial, sans-serif",
2532
+ children: "PDF"
2533
+ }
2534
+ )
2535
+ ]
2536
+ }
2537
+ );
2538
+ };
2539
+ var AudIcon = ({ size = 16, className = "" }) => {
2540
+ return /* @__PURE__ */ jsxRuntime.jsxs(
2541
+ "svg",
2542
+ {
2543
+ width: size,
2544
+ height: size,
2545
+ viewBox: "0 0 24 24",
2546
+ fill: "none",
2547
+ xmlns: "http://www.w3.org/2000/svg",
2548
+ className,
2549
+ children: [
2550
+ /* @__PURE__ */ jsxRuntime.jsx(
2551
+ "path",
2552
+ {
2553
+ d: "M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8l-6-6z",
2554
+ fill: FILE_TYPE_COLORS.aud,
2555
+ stroke: FILE_TYPE_COLORS.aud,
2556
+ strokeWidth: "1",
2557
+ strokeLinecap: "round",
2558
+ strokeLinejoin: "round"
2559
+ }
2560
+ ),
2561
+ /* @__PURE__ */ jsxRuntime.jsx(
2562
+ "path",
2563
+ {
2564
+ d: "M14 2v6h6",
2565
+ fill: "none",
2566
+ stroke: FILE_TYPE_COLORS.white,
2567
+ strokeWidth: "1",
2568
+ strokeLinecap: "round",
2569
+ strokeLinejoin: "round"
2570
+ }
2571
+ ),
2572
+ /* @__PURE__ */ jsxRuntime.jsx(
2573
+ "text",
2574
+ {
2575
+ x: "12",
2576
+ y: "16",
2577
+ fontSize: "6",
2578
+ fill: "white",
2579
+ textAnchor: "middle",
2580
+ fontWeight: "bold",
2581
+ fontFamily: "Arial, sans-serif",
2582
+ children: "AUD"
2583
+ }
2584
+ )
2585
+ ]
2586
+ }
2587
+ );
2588
+ };
2589
+ var ImgIcon = ({ size = 16, className = "" }) => {
2590
+ return /* @__PURE__ */ jsxRuntime.jsxs(
2591
+ "svg",
2592
+ {
2593
+ width: size,
2594
+ height: size,
2595
+ viewBox: "0 0 24 24",
2596
+ fill: "none",
2597
+ xmlns: "http://www.w3.org/2000/svg",
2598
+ className,
2599
+ children: [
2600
+ /* @__PURE__ */ jsxRuntime.jsx(
2601
+ "path",
2602
+ {
2603
+ d: "M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8l-6-6z",
2604
+ fill: FILE_TYPE_COLORS.img,
2605
+ stroke: FILE_TYPE_COLORS.img,
2606
+ strokeWidth: "1",
2607
+ strokeLinecap: "round",
2608
+ strokeLinejoin: "round"
2609
+ }
2610
+ ),
2611
+ /* @__PURE__ */ jsxRuntime.jsx(
2612
+ "path",
2613
+ {
2614
+ d: "M14 2v6h6",
2615
+ fill: "none",
2616
+ stroke: FILE_TYPE_COLORS.white,
2617
+ strokeWidth: "1",
2618
+ strokeLinecap: "round",
2619
+ strokeLinejoin: "round"
2620
+ }
2621
+ ),
2622
+ /* @__PURE__ */ jsxRuntime.jsx(
2623
+ "text",
2624
+ {
2625
+ x: "12",
2626
+ y: "16",
2627
+ fontSize: "6",
2628
+ fill: "white",
2629
+ textAnchor: "middle",
2630
+ fontWeight: "bold",
2631
+ fontFamily: "Arial, sans-serif",
2632
+ children: "IMG"
2633
+ }
2634
+ )
2635
+ ]
2636
+ }
2637
+ );
2638
+ };
2639
+ var VidIcon = ({ size = 16, className = "" }) => {
2640
+ return /* @__PURE__ */ jsxRuntime.jsxs(
2641
+ "svg",
2642
+ {
2643
+ width: size,
2644
+ height: size,
2645
+ viewBox: "0 0 24 24",
2646
+ fill: "none",
2647
+ xmlns: "http://www.w3.org/2000/svg",
2648
+ className,
2649
+ children: [
2650
+ /* @__PURE__ */ jsxRuntime.jsx(
2651
+ "path",
2652
+ {
2653
+ d: "M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8l-6-6z",
2654
+ fill: FILE_TYPE_COLORS.vid,
2655
+ stroke: FILE_TYPE_COLORS.vid,
2656
+ strokeWidth: "1",
2657
+ strokeLinecap: "round",
2658
+ strokeLinejoin: "round"
2659
+ }
2660
+ ),
2661
+ /* @__PURE__ */ jsxRuntime.jsx(
2662
+ "path",
2663
+ {
2664
+ d: "M14 2v6h6",
2665
+ fill: "none",
2666
+ stroke: FILE_TYPE_COLORS.white,
2667
+ strokeWidth: "1",
2668
+ strokeLinecap: "round",
2669
+ strokeLinejoin: "round"
2670
+ }
2671
+ ),
2672
+ /* @__PURE__ */ jsxRuntime.jsx(
2673
+ "text",
2674
+ {
2675
+ x: "12",
2676
+ y: "16",
2677
+ fontSize: "6",
2678
+ fill: "white",
2679
+ textAnchor: "middle",
2680
+ fontWeight: "bold",
2681
+ fontFamily: "Arial, sans-serif",
2682
+ children: "VID"
2683
+ }
2684
+ )
2685
+ ]
2686
+ }
2687
+ );
2688
+ };
2689
+ var EmlIcon = ({ size = 16, className = "" }) => {
2690
+ return /* @__PURE__ */ jsxRuntime.jsxs(
2691
+ "svg",
2692
+ {
2693
+ width: size,
2694
+ height: size,
2695
+ viewBox: "0 0 24 24",
2696
+ fill: "none",
2697
+ xmlns: "http://www.w3.org/2000/svg",
2698
+ className,
2699
+ children: [
2700
+ /* @__PURE__ */ jsxRuntime.jsx(
2701
+ "path",
2702
+ {
2703
+ d: "M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8l-6-6z",
2704
+ fill: FILE_TYPE_COLORS.eml,
2705
+ stroke: FILE_TYPE_COLORS.eml,
2706
+ strokeWidth: "1",
2707
+ strokeLinecap: "round",
2708
+ strokeLinejoin: "round"
2709
+ }
2710
+ ),
2711
+ /* @__PURE__ */ jsxRuntime.jsx(
2712
+ "path",
2713
+ {
2714
+ d: "M14 2v6h6",
2715
+ fill: "none",
2716
+ stroke: FILE_TYPE_COLORS.white,
2717
+ strokeWidth: "1",
2718
+ strokeLinecap: "round",
2719
+ strokeLinejoin: "round"
2720
+ }
2721
+ ),
2722
+ /* @__PURE__ */ jsxRuntime.jsx(
2723
+ "rect",
2724
+ {
2725
+ x: "7",
2726
+ y: "12",
2727
+ width: "10",
2728
+ height: "7",
2729
+ rx: "1",
2730
+ fill: "none",
2731
+ stroke: "white",
2732
+ strokeWidth: "1.2"
2733
+ }
2734
+ ),
2735
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M7 13l5 3 5-3", fill: "none", stroke: "white", strokeWidth: "1.2", strokeLinejoin: "round" })
2736
+ ]
2737
+ }
2738
+ );
2739
+ };
2740
+ var ArbiBotHeadIcon = ({ size = 24, className = "" }) => {
2741
+ const maskId = React2.useId();
2742
+ return /* @__PURE__ */ jsxRuntime.jsxs(
2743
+ "svg",
2744
+ {
2745
+ xmlns: "http://www.w3.org/2000/svg",
2746
+ width: size,
2747
+ height: size,
2748
+ viewBox: "30 -5 190 190",
2749
+ preserveAspectRatio: "xMidYMid meet",
2750
+ className,
2751
+ children: [
2752
+ /* @__PURE__ */ jsxRuntime.jsx("defs", { children: /* @__PURE__ */ jsxRuntime.jsx("mask", { id: maskId, children: /* @__PURE__ */ jsxRuntime.jsxs("g", { transform: "translate(0,250) scale(0.1,-0.1)", children: [
2753
+ /* @__PURE__ */ jsxRuntime.jsx("rect", { x: "0", y: "0", width: "2500", height: "2500", fill: "white" }),
2754
+ /* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "855", cy: "1715", r: "190", fill: "black" }),
2755
+ /* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "855", cy: "1715", r: "50", fill: "white" }),
2756
+ /* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "1665", cy: "1700", r: "190", fill: "black" }),
2757
+ /* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "1665", cy: "1700", r: "50", fill: "white" })
2758
+ ] }) }) }),
2759
+ /* @__PURE__ */ jsxRuntime.jsxs("g", { mask: `url(#${maskId})`, children: [
2760
+ /* @__PURE__ */ jsxRuntime.jsx(
2761
+ "g",
2762
+ {
2763
+ transform: "translate(0,250) scale(0.1,-0.1)",
2764
+ fill: "currentColor",
2765
+ stroke: "currentColor",
2766
+ strokeWidth: "100",
2767
+ children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M1038 2434 c-217 -39 -406 -154 -522 -318 -121 -170 -176 -376 -103 -384 l27 -3 0 -106 c0 -88 -3 -108 -17 -118 -15 -11 -16 -18 -5 -66 44 -188 209 -369 420 -459 l65 -28 -74 -7 c-283 -26 -444 -152 -535 -418 -70 -204 -73 -507 -5 -507 4 0 12 75 19 168 18 263 68 419 167 530 78 87 224 162 263 134 9 -6 43 -26 76 -43 224 -117 802 -95 948 38 38 34 165 -22 253 -111 117 -119 168 -268 187 -549 6 -92 15 -167 19 -167 89 0 53 415 -54 627 -88 173 -238 270 -458 295 l-99 11 75 32 c201 88 367 274 406 454 10 47 9 56 -5 66 -13 10 -16 32 -16 118 l0 106 28 3 c91 10 -12 297 -165 459 -202 214 -544 307 -895 243z m472 -84 c170 -43 323 -140 416 -264 47 -61 117 -197 128 -248 l6 -28 -65 0 c-64 0 -65 1 -78 33 -43 102 -109 136 -262 137 l-110 0 -38 -40 c-25 -27 -46 -40 -65 -41 -134 -5 -394 1 -410 10 -11 6 -30 24 -42 41 l-21 30 -112 0 c-156 -1 -219 -33 -262 -136 -14 -34 -14 -34 -80 -34 -76 0 -74 -7 -30 103 96 243 311 406 595 452 118 20 319 13 430 -15z m-561 -505 c97 -50 126 -174 61 -263 -118 -163 -380 -23 -309 165 35 93 162 143 248 98z m799 -15 c129 -96 69 -304 -92 -318 -189 -16 -265 218 -106 326 48 33 149 29 198 -8z m272 -389 c0 -23 -45 -110 -86 -168 -245 -343 -856 -408 -1231 -130 -90 67 -213 236 -213 294 0 11 132 13 765 13 457 0 765 -4 765 -9z" })
2768
+ }
2769
+ ),
2770
+ /* @__PURE__ */ jsxRuntime.jsxs("g", { transform: "translate(0,250) scale(0.1,-0.1)", fill: "currentColor", stroke: "none", children: [
2771
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M785 1777 c-60 -60 -59 -134 1 -186 92 -82 236 9 204 128 -25 93 -138 125 -205 58z m161 -29 c7 -22 -19 -52 -40 -45 -21 7 -30 35 -17 51 19 23 48 20 57 -6z" }),
2772
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M1591 1803 c-128 -67 -85 -243 60 -243 83 0 141 99 105 178 -32 69 -103 97 -165 65z m127 -59 c4 -25 -19 -47 -41 -38 -22 8 -30 34 -16 51 17 20 53 12 57 -13z" }),
2773
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M843 1347 c-9 -15 9 -63 41 -108 148 -202 565 -209 730 -12 37 44 60 103 47 116 -13 13 -810 17 -818 4z" })
2774
+ ] })
2775
+ ] })
2776
+ ]
2777
+ }
2778
+ );
2779
+ };
2780
+ function getDocumentTitle(document2, defaultValue = "") {
2781
+ if (!document2) return defaultValue;
2782
+ return document2.doc_metadata?.title || document2.file_name || defaultValue;
2783
+ }
2784
+ var MAX_LABEL_CHARS = 30;
2785
+ function clampLabel(text) {
2786
+ return text.length > MAX_LABEL_CHARS ? `${text.slice(0, MAX_LABEL_CHARS).trimEnd()}\u2026` : text;
2787
+ }
2788
+ var IMAGE_EXTENSIONS = /* @__PURE__ */ new Set(["jpg", "jpeg", "png", "gif", "bmp", "tiff", "tif", "webp"]);
2789
+ var VIDEO_EXTENSIONS = /* @__PURE__ */ new Set(["mp4", "mpeg", "mpg", "webm", "mov", "avi", "mkv"]);
2790
+ var AUDIO_EXTENSIONS = /* @__PURE__ */ new Set(["mp3", "wav", "m4a", "aac", "ogg", "flac"]);
2791
+ var EMAIL_EXTENSIONS = /* @__PURE__ */ new Set(["eml", "msg"]);
2792
+ function getDocIcon(fileName, iconSize = 14) {
2793
+ const ext = fileName?.split(".").pop()?.toLowerCase();
2794
+ if (ext && VIDEO_EXTENSIONS.has(ext)) return /* @__PURE__ */ jsxRuntime.jsx(VidIcon, { size: iconSize, className: "flex-shrink-0" });
2795
+ if (ext && AUDIO_EXTENSIONS.has(ext)) return /* @__PURE__ */ jsxRuntime.jsx(AudIcon, { size: iconSize, className: "flex-shrink-0" });
2796
+ if (ext && IMAGE_EXTENSIONS.has(ext)) return /* @__PURE__ */ jsxRuntime.jsx(ImgIcon, { size: iconSize, className: "flex-shrink-0" });
2797
+ if (ext && EMAIL_EXTENSIONS.has(ext)) return /* @__PURE__ */ jsxRuntime.jsx(EmlIcon, { size: iconSize, className: "flex-shrink-0" });
2798
+ return /* @__PURE__ */ jsxRuntime.jsx(PdfIcon, { size: iconSize, className: "flex-shrink-0" });
2799
+ }
2800
+ function DocumentEntity({
2801
+ doc,
2802
+ icon,
2803
+ size = "sm",
2804
+ labelMaxWidth,
2805
+ labelClassName,
2806
+ onClick,
2807
+ onIconClick,
2808
+ viewing,
2809
+ iconBadge,
2810
+ actions,
2811
+ tooltipContent,
2812
+ className,
2813
+ fullWidth,
2814
+ noClamp,
2815
+ "data-testid": testId
2816
+ }) {
2817
+ const title = getDocumentTitle(doc);
2818
+ const ext = doc.file_name?.split(".").pop()?.toLowerCase();
2819
+ const iconSize = size === "base" ? 16 : 14;
2820
+ const eyeSizeClass = size === "base" ? "h-4 w-4" : "h-3.5 w-3.5";
2821
+ const baseIcon = icon ?? getDocIcon(doc.file_name, iconSize);
2822
+ const displayIcon = viewing || iconBadge ? /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "relative inline-flex flex-shrink-0 items-center justify-center", children: [
2823
+ viewing ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Eye, { className: chunkRZQACYNQ_cjs.cn("text-primary-foreground", eyeSizeClass) }) : baseIcon,
2824
+ iconBadge
2825
+ ] }) : baseIcon;
2826
+ const defaultTooltip = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1 text-xs max-w-[440px]", children: [
2827
+ doc.folder && // `flex-wrap` so a deep folder path wraps WITHIN the balloon instead of
2828
+ // spilling out of it (each path segment is atomic and wraps as a unit;
2829
+ // `min-w-0` + `break-all` lets a single over-long segment break too).
2830
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex flex-wrap items-center gap-0.5 text-muted-foreground", children: [
2831
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.FolderOpen, { className: "h-3 w-3 text-yellow-600 shrink-0" }),
2832
+ doc.folder.split("/").map((part, i, arr) => /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex min-w-0 items-center gap-0.5", children: [
2833
+ i > 0 && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground/50 mx-0.5", children: "/" }),
2834
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: `break-all ${i < arr.length - 1 ? "text-muted-foreground/70" : ""}`, children: part })
2835
+ ] }, i))
2836
+ ] }),
2837
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "font-medium break-words", children: [
2838
+ title,
2839
+ ext ? `.${ext}` : ""
2840
+ ] })
2841
+ ] });
2842
+ return /* @__PURE__ */ jsxRuntime.jsx(
2843
+ EntityPill,
2844
+ {
2845
+ icon: displayIcon,
2846
+ size,
2847
+ label: fullWidth || noClamp ? title : clampLabel(title),
2848
+ labelMaxWidth: labelMaxWidth ?? "max-w-[140px]",
2849
+ labelClassName,
2850
+ fullWidth,
2851
+ onClick,
2852
+ onIconClick,
2853
+ moreContent: actions,
2854
+ className,
2855
+ highlight: viewing,
2856
+ "data-testid": testId,
2857
+ tooltipContent: tooltipContent ?? defaultTooltip
2858
+ }
2859
+ );
2860
+ }
2861
+ var VARIANT_STYLES = {
2862
+ "mine-paid": {
2863
+ pill: "bg-primary/10 text-primary border-border/60",
2864
+ icon: "text-primary"
2865
+ },
2866
+ other: {
2867
+ pill: "bg-secondary/10 text-secondary border-border/60",
2868
+ icon: "text-secondary"
2869
+ },
2870
+ "mine-free": {
2871
+ pill: "bg-muted-foreground/10 text-muted-foreground border-border/60",
2872
+ icon: "text-muted-foreground"
2873
+ },
2874
+ common: {
2875
+ pill: "",
2876
+ icon: "text-muted-foreground"
2877
+ }
2878
+ };
2879
+ function resolveVariant(relation, paid, hasCollaborators) {
2880
+ if (relation === "common") return "common";
2881
+ if (relation === "other") return "other";
2882
+ if (relation === "mine") return paid ? "mine-paid" : "mine-free";
2883
+ if (paid) return hasCollaborators ? "other" : "mine-paid";
2884
+ return "mine-free";
2885
+ }
2886
+ function ProjectEntity({
2887
+ name,
2888
+ label,
2889
+ icon,
2890
+ subscription = "none",
2891
+ hasCollaborators = false,
2892
+ size = "sm",
2893
+ className,
2894
+ onClick,
2895
+ relation,
2896
+ isPaid,
2897
+ tooltipContent
2898
+ }) {
2899
+ const paid = isPaid ?? (subscription === "active" || subscription === "past_due" || subscription === "dev");
2900
+ const variant = resolveVariant(relation, paid, hasCollaborators);
2901
+ const { pill, icon: iconClass } = VARIANT_STYLES[variant];
2902
+ const iconSizeClass = size === "base" ? "h-4 w-4" : "h-3.5 w-3.5";
2903
+ const iconNode = icon ?? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CreditCard, { className: chunkRZQACYNQ_cjs.cn(iconSizeClass, iconClass) });
2904
+ return /* @__PURE__ */ jsxRuntime.jsx(
2905
+ EntityPill,
2906
+ {
2907
+ icon: iconNode,
2908
+ label: label ?? name,
2909
+ size,
2910
+ shape: "rounded",
2911
+ className: chunkRZQACYNQ_cjs.cn(pill, className),
2912
+ onClick,
2913
+ tooltipContent
2914
+ }
2915
+ );
2916
+ }
2917
+ var sizeClasses = {
2918
+ xs: "h-5 w-5",
2919
+ sm: "h-6 w-6",
2920
+ md: "h-8 w-8",
2921
+ lg: "h-10 w-10"
2922
+ };
2923
+ var textSizeClasses = {
2924
+ xs: "text-xs",
2925
+ sm: "text-xs",
2926
+ md: "text-xs",
2927
+ lg: "text-sm"
2928
+ };
2929
+ var presenceDotClasses = {
2930
+ xs: "w-2 h-2 border",
2931
+ sm: "w-2.5 h-2.5 border",
2932
+ md: "w-3 h-3 border-2",
2933
+ lg: "w-3.5 h-3.5 border-2"
2934
+ };
2935
+ var presencePositionClasses = {
2936
+ xs: "-right-1 bottom-0",
2937
+ sm: "-right-1 bottom-0",
2938
+ md: "-right-1.5 -bottom-0.5",
2939
+ lg: "-right-1.5 -bottom-0.5"
2940
+ };
2941
+ var PRESENCE_LABELS = {
2942
+ connected: "Online",
2943
+ connecting: "Connecting",
2944
+ disconnected: "Offline",
2945
+ error: "Connection problem",
2946
+ hidden: "Status hidden"
2947
+ };
2948
+ var presenceColorClasses = {
2949
+ connected: "bg-status-online",
2950
+ connecting: "bg-status-connecting",
2951
+ disconnected: "bg-status-away",
2952
+ error: "bg-status-busy",
2953
+ hidden: "bg-status-offline"
2954
+ };
2955
+ var UserEntity = React2.memo(function UserEntity2({
2956
+ size = "md",
2957
+ variant = "pill",
2958
+ className,
2959
+ showTooltip = true,
2960
+ interactive = true,
2961
+ hasUnreadMessages = false,
2962
+ initials = "",
2963
+ displayName = "",
2964
+ picture,
2965
+ colorClass = "",
2966
+ isAgent = false,
2967
+ agentStyle,
2968
+ avatarStyle,
2969
+ isMe = false,
2970
+ displayStatus,
2971
+ onClick,
2972
+ tooltipContent,
2973
+ empty = false
2974
+ }) {
2975
+ if (empty) {
2976
+ return /* @__PURE__ */ jsxRuntime.jsx(
2977
+ Avatar,
2978
+ {
2979
+ className: chunkRZQACYNQ_cjs.cn(sizeClasses[size], "border border-border", className),
2980
+ "data-testid": "user-entity",
2981
+ children: /* @__PURE__ */ jsxRuntime.jsx(AvatarFallback, { className: "bg-status-empty text-muted-foreground text-xs font-semibold", children: "?" })
2982
+ }
2983
+ );
2984
+ }
2985
+ const agentBadge = isAgent ? /* @__PURE__ */ jsxRuntime.jsx(ArbiBotHeadIcon, { className: "w-3.5 h-3.5 text-muted-foreground" }) : void 0;
2986
+ const canMessage = interactive && !isMe && !isAgent;
2987
+ const showUnread = hasUnreadMessages && !isMe && !isAgent;
2988
+ const surfaceStyle = avatarStyle ?? agentStyle;
2989
+ const avatarCore = /* @__PURE__ */ jsxRuntime.jsxs(
2990
+ Avatar,
2991
+ {
2992
+ className: chunkRZQACYNQ_cjs.cn(
2993
+ sizeClasses[size],
2994
+ isAgent ? "rounded-full border-2 border-dashed" : "border border-white"
2995
+ ),
2996
+ style: surfaceStyle,
2997
+ "data-testid": "user-entity",
2998
+ children: [
2999
+ picture && /* @__PURE__ */ jsxRuntime.jsx(AvatarImage, { src: picture, alt: initials }),
3000
+ /* @__PURE__ */ jsxRuntime.jsx(
3001
+ AvatarFallback,
3002
+ {
3003
+ className: chunkRZQACYNQ_cjs.cn(
3004
+ textSizeClasses[size],
3005
+ "font-semibold leading-none",
3006
+ isAgent ? "rounded-full bg-transparent" : `text-white ${colorClass}`
3007
+ ),
3008
+ style: surfaceStyle,
3009
+ children: initials
3010
+ }
3011
+ )
3012
+ ]
3013
+ }
3014
+ );
3015
+ const statusDot = showUnread || displayStatus ? /* @__PURE__ */ jsxRuntime.jsx(
3016
+ "span",
3017
+ {
3018
+ className: chunkRZQACYNQ_cjs.cn(
3019
+ "absolute rounded-full border-white",
3020
+ presenceDotClasses[size],
3021
+ presencePositionClasses[size],
3022
+ !showUnread && displayStatus ? presenceColorClasses[displayStatus] : ""
3023
+ ),
3024
+ style: showUnread ? { backgroundColor: "#00adef" } : void 0,
3025
+ "data-testid": "user-entity-presence",
3026
+ role: "img",
3027
+ "aria-label": showUnread ? "Unread messages" : PRESENCE_LABELS[displayStatus],
3028
+ title: showUnread ? "Unread messages" : PRESENCE_LABELS[displayStatus]
3029
+ }
3030
+ ) : null;
3031
+ const avatarElement = statusDot ? /* @__PURE__ */ jsxRuntime.jsxs(
3032
+ "div",
3033
+ {
3034
+ className: chunkRZQACYNQ_cjs.cn(
3035
+ "relative inline-block",
3036
+ sizeClasses[size],
3037
+ variant === "pill" ? "" : className
3038
+ ),
3039
+ children: [
3040
+ avatarCore,
3041
+ statusDot
3042
+ ]
3043
+ }
3044
+ ) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: chunkRZQACYNQ_cjs.cn("inline-block", variant === "pill" ? "" : className), children: avatarCore });
3045
+ const pillAvatar = (
3046
+ // shrink-0: when the pill is squeezed the NAME truncates away — the avatar
3047
+ // must never collapse under it and overflow onto neighbouring text.
3048
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: chunkRZQACYNQ_cjs.cn("relative inline-block shrink-0", sizeClasses[size]), children: [
3049
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: chunkRZQACYNQ_cjs.cn("block transition-opacity", canMessage && "group-hover/pill:opacity-0"), children: avatarCore }),
3050
+ canMessage && /* @__PURE__ */ jsxRuntime.jsx(
3051
+ "span",
3052
+ {
3053
+ "aria-hidden": true,
3054
+ className: "absolute inset-0 flex items-center justify-center rounded-full bg-muted text-foreground opacity-0 transition-opacity group-hover/pill:opacity-100",
3055
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.MessageCircleMore, { className: size === "xs" ? "h-3 w-3" : "h-4 w-4" })
3056
+ }
3057
+ ),
3058
+ statusDot
3059
+ ] })
3060
+ );
3061
+ const resolvedTooltip = showTooltip ? tooltipContent : void 0;
3062
+ if (variant === "pill") {
3063
+ const row = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
3064
+ pillAvatar,
3065
+ displayName && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "min-w-0 max-w-[320px] truncate text-sm leading-tight", children: displayName }),
3066
+ agentBadge
3067
+ ] });
3068
+ const rowClass = "group/pill inline-flex min-w-0 items-center gap-2";
3069
+ const clickable = interactive && !!onClick;
3070
+ const clickableClass = "relative cursor-pointer rounded-md px-1 py-0.5 -mx-1 transition-colors hover:bg-muted/60 pointer-coarse:after:absolute pointer-coarse:after:inset-x-0 pointer-coarse:after:-inset-y-3 pointer-coarse:after:content-['']";
3071
+ if (resolvedTooltip) {
3072
+ return /* @__PURE__ */ jsxRuntime.jsxs(Tooltip, { children: [
3073
+ /* @__PURE__ */ jsxRuntime.jsx(
3074
+ TooltipTrigger,
3075
+ {
3076
+ type: "button",
3077
+ onClick: clickable ? onClick : void 0,
3078
+ onFocusCapture: (e) => e.stopPropagation(),
3079
+ className: chunkRZQACYNQ_cjs.cn(rowClass, clickable && clickableClass, className),
3080
+ "data-testid": "user-entity-pill",
3081
+ children: row
3082
+ }
3083
+ ),
3084
+ /* @__PURE__ */ jsxRuntime.jsx(TooltipContent, { className: "p-2", children: resolvedTooltip })
3085
+ ] });
3086
+ }
3087
+ if (clickable) {
3088
+ return /* @__PURE__ */ jsxRuntime.jsx(
3089
+ "button",
3090
+ {
3091
+ type: "button",
3092
+ onClick,
3093
+ className: chunkRZQACYNQ_cjs.cn(rowClass, clickableClass, className),
3094
+ "data-testid": "user-entity-pill",
3095
+ children: row
3096
+ }
3097
+ );
3098
+ }
3099
+ return /* @__PURE__ */ jsxRuntime.jsx("span", { className: chunkRZQACYNQ_cjs.cn(rowClass, className), "data-testid": "user-entity-pill", children: row });
3100
+ }
3101
+ if (showTooltip) {
3102
+ return /* @__PURE__ */ jsxRuntime.jsxs(Tooltip, { children: [
3103
+ /* @__PURE__ */ jsxRuntime.jsx(
3104
+ TooltipTrigger,
3105
+ {
3106
+ onFocusCapture: (e) => e.stopPropagation(),
3107
+ className: "touch-hit inline-flex",
3108
+ children: avatarElement
3109
+ }
3110
+ ),
3111
+ /* @__PURE__ */ jsxRuntime.jsx(TooltipContent, { className: "p-2", children: tooltipContent })
3112
+ ] });
3113
+ }
3114
+ return avatarElement;
3115
+ });
3116
+ function AgentBadge({ className }) {
3117
+ return /* @__PURE__ */ jsxRuntime.jsxs(
3118
+ "span",
3119
+ {
3120
+ "data-testid": "agent-badge",
3121
+ className: chunkRZQACYNQ_cjs.cn(
3122
+ "inline-flex shrink-0 items-center gap-1 rounded-full border border-ai-accent/50",
3123
+ "bg-ai-accent-soft px-2 py-0.5 text-xs font-bold uppercase tracking-wider text-ai-accent",
3124
+ className
3125
+ ),
3126
+ children: [
3127
+ /* @__PURE__ */ jsxRuntime.jsx(ArbiBotHeadIcon, { size: 14, className: "text-ai-accent" }),
3128
+ "Agent"
3129
+ ]
3130
+ }
3131
+ );
3132
+ }
3133
+ var PRESENCE_WORDS = {
3134
+ connected: "Online",
3135
+ connecting: "Connecting",
3136
+ disconnected: "Offline",
3137
+ error: "Connection problem",
3138
+ hidden: null
3139
+ };
3140
+ function PresenceLabel({
3141
+ status,
3142
+ className
3143
+ }) {
3144
+ if (!status) return null;
3145
+ const word = PRESENCE_WORDS[status];
3146
+ if (!word) return null;
3147
+ const online = status === "connected";
3148
+ return /* @__PURE__ */ jsxRuntime.jsxs(
3149
+ "span",
3150
+ {
3151
+ "data-testid": "presence-label",
3152
+ className: chunkRZQACYNQ_cjs.cn("inline-flex shrink-0 items-center gap-1 text-xs", className),
3153
+ children: [
3154
+ /* @__PURE__ */ jsxRuntime.jsx(
3155
+ "span",
3156
+ {
3157
+ className: chunkRZQACYNQ_cjs.cn(
3158
+ "size-1.5 rounded-full",
3159
+ online ? "bg-status-online" : "bg-muted-foreground/50"
3160
+ ),
3161
+ "aria-hidden": "true"
3162
+ }
3163
+ ),
3164
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: online ? "font-medium text-status-online" : "text-muted-foreground", children: word })
3165
+ ]
3166
+ }
3167
+ );
3168
+ }
3169
+ var PACKAGE_BADGE_VARIANTS = [
3170
+ "default",
3171
+ "accent",
3172
+ "secondary",
3173
+ "destructive",
3174
+ "outline"
3175
+ ];
3176
+ function isPackageBadgeVariant(v) {
3177
+ return PACKAGE_BADGE_VARIANTS.some((known) => known === v);
3178
+ }
3179
+ function PackageStatusBadge({ variant, ...rest }) {
3180
+ return /* @__PURE__ */ jsxRuntime.jsx(Badge, { variant: isPackageBadgeVariant(variant) ? variant : "outline", ...rest });
3181
+ }
3182
+ var registry = {
3183
+ variants: {},
3184
+ fallback: "outline",
3185
+ Badge: PackageStatusBadge
3186
+ };
3187
+ function configureStatusRegistry(map, opts) {
3188
+ Object.assign(registry.variants, map);
3189
+ if (opts?.fallback) registry.fallback = opts.fallback;
3190
+ if (opts?.Badge) registry.Badge = opts.Badge;
3191
+ }
3192
+ function getStatusVariant(status) {
3193
+ return registry.variants[status] ?? registry.fallback;
3194
+ }
3195
+ function StatusPill({ status, label, variant, className, testId }) {
3196
+ const Badge2 = registry.Badge;
3197
+ return /* @__PURE__ */ jsxRuntime.jsx(Badge2, { variant: variant ?? getStatusVariant(status), className, "data-testid": testId, children: label ?? status });
3198
+ }
3199
+ var RAG_LABELS = { red: "At risk", amber: "Attention", green: "On track" };
3200
+ function configureRagLabels(labels) {
3201
+ RAG_LABELS = { ...RAG_LABELS, ...labels };
3202
+ }
3203
+ function RagDot({
3204
+ rag,
3205
+ withLabel,
3206
+ className
3207
+ }) {
3208
+ const color = rag === "red" ? "bg-destructive" : rag === "amber" ? "bg-warning" : "bg-success";
3209
+ return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: chunkRZQACYNQ_cjs.cn("inline-flex items-center gap-1.5", className), "data-testid": `rag-${rag}`, children: [
3210
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: chunkRZQACYNQ_cjs.cn("size-2 rounded-full", color) }),
3211
+ withLabel && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs text-muted-foreground", children: RAG_LABELS[rag] })
3212
+ ] });
3213
+ }
3214
+ var ENTITY_MAPPINGS = {
3215
+ PRODUCT: {
3216
+ NAMES: {
3217
+ SINGULAR: "ARBI Docs"
3218
+ },
3219
+ ICONS: {
3220
+ DEFAULT: lucideReact.MessageSquareLock
3221
+ }
3222
+ },
3223
+ SECTION: {
3224
+ NAMES: {
3225
+ SINGULAR: "Section"
3226
+ },
3227
+ ICONS: {
3228
+ DEFAULT: lucideReact.ChevronsDown
3229
+ }
3230
+ },
3231
+ WORKSPACE: {
3232
+ NAMES: {
3233
+ SINGULAR: "Workspace",
3234
+ PLURAL: "Workspaces"
3235
+ },
3236
+ ICONS: {
3237
+ DEFAULT: lucideReact.SquareM,
3238
+ NEW: lucideReact.SquarePlus,
3239
+ LIST: lucideReact.LayoutGrid,
3240
+ SETTINGS: lucideReact.Columns3Cog
3241
+ }
3242
+ },
3243
+ CONVERSATION: {
3244
+ NAMES: {
3245
+ SINGULAR: "Chat",
3246
+ PLURAL: "Chats",
3247
+ NEW: "New ARBI Chat"
3248
+ },
3249
+ ICONS: {
3250
+ DEFAULT: lucideReact.MessagesSquare,
3251
+ OFF: lucideReact.MessageSquareOff,
3252
+ ACTIVE: lucideReact.MessageSquareText,
3253
+ NEW: lucideReact.MessageSquarePlus,
3254
+ LIST: lucideReact.MessageSquareMore
3255
+ }
3256
+ },
3257
+ DOCUMENT: {
3258
+ NAMES: {
3259
+ SINGULAR: "File",
3260
+ PLURAL: "Files"
3261
+ },
3262
+ ICONS: {
3263
+ DEFAULT: lucideReact.FolderOpen,
3264
+ OFF: lucideReact.CaptionsOff
3265
+ }
3266
+ },
3267
+ VIEWER: {
3268
+ NAMES: {
3269
+ SINGULAR: "Viewer",
3270
+ PLURAL: "Viewers"
3271
+ },
3272
+ ICONS: {
3273
+ DEFAULT: lucideReact.Eye,
3274
+ OFF: lucideReact.EyeOff
3275
+ }
3276
+ },
3277
+ TAG: {
3278
+ NAMES: {
3279
+ SINGULAR: "Field",
3280
+ PLURAL: "Fields"
3281
+ },
3282
+ ICONS: {
3283
+ DEFAULT: lucideReact.Hash,
3284
+ NEW: lucideReact.FolderPlus
3285
+ }
3286
+ },
3287
+ ANNOTATION: {
3288
+ NAMES: {
3289
+ SINGULAR: "Annotation",
3290
+ PLURAL: "Annotations"
3291
+ },
3292
+ ICONS: {
3293
+ DEFAULT: lucideReact.StickyNote,
3294
+ NEW: lucideReact.StickyNote
3295
+ }
3296
+ },
3297
+ // Workspace knowledge the assistant retains and recalls — durable free text,
3298
+ // optionally grounded in source passages. Distinct from ANNOTATION, which is
3299
+ // attached TO a document field; a NOTE is workspace-scoped and stands alone.
3300
+ // Stored server-side as `memories` (mem-*); "Note" is the user-facing name.
3301
+ NOTE: {
3302
+ NAMES: {
3303
+ SINGULAR: "Note",
3304
+ PLURAL: "Notes"
3305
+ },
3306
+ ICONS: {
3307
+ DEFAULT: lucideReact.NotebookText,
3308
+ NEW: lucideReact.NotebookPen
3309
+ }
3310
+ },
3311
+ USER: {
3312
+ NAMES: {
3313
+ SINGULAR: "User",
3314
+ PLURAL: "Users"
3315
+ },
3316
+ ICONS: {
3317
+ DEFAULT: lucideReact.User,
3318
+ NEW: lucideReact.UserPlus,
3319
+ SETTINGS: lucideReact.Settings2
3320
+ }
3321
+ },
3322
+ WORKSPACEUSER: {
3323
+ NAMES: {
3324
+ SINGULAR: "Member",
3325
+ PLURAL: "Members"
3326
+ },
3327
+ ICONS: {
3328
+ DEFAULT: lucideReact.User,
3329
+ PLURAL: lucideReact.Users,
3330
+ NEW: lucideReact.UserPlus,
3331
+ SETTINGS: lucideReact.Settings2
3332
+ }
3333
+ },
3334
+ CONTACT: {
3335
+ NAMES: {
3336
+ SINGULAR: "Contact",
3337
+ PLURAL: "Contacts"
3338
+ },
3339
+ ICONS: {
3340
+ // A starred person, not an address-book card: contacts here are the
3341
+ // people you talk to, and the star reads as "your people".
3342
+ DEFAULT: lucideReact.UserStar,
3343
+ NEW: lucideReact.UserPlus
3344
+ }
3345
+ },
3346
+ TASK: {
3347
+ NAMES: {
3348
+ SINGULAR: "Job",
3349
+ PLURAL: "Jobs"
3350
+ },
3351
+ ICONS: {
3352
+ DEFAULT: lucideReact.ClipboardList
3353
+ }
3354
+ },
3355
+ PROJECT: {
3356
+ NAMES: {
3357
+ SINGULAR: "Project",
3358
+ PLURAL: "Projects"
3359
+ },
3360
+ ICONS: {
3361
+ DEFAULT: lucideReact.CreditCard
3362
+ }
3363
+ },
3364
+ SKILL: {
3365
+ NAMES: {
3366
+ SINGULAR: "Skill",
3367
+ PLURAL: "Skills"
3368
+ },
3369
+ ICONS: {
3370
+ DEFAULT: lucideReact.Wrench
3371
+ }
3372
+ },
3373
+ ACCOUNT: {
3374
+ NAMES: {
3375
+ SINGULAR: "Account"
3376
+ },
3377
+ ICONS: {
3378
+ DEFAULT: lucideReact.CircleUserRound
3379
+ }
3380
+ },
3381
+ NOTIFICATIONS: {
3382
+ NAMES: {
3383
+ SINGULAR: "Activity",
3384
+ PLURAL: "Activities"
3385
+ },
3386
+ ICONS: {
3387
+ DEFAULT: lucideReact.Bell
3388
+ }
3389
+ },
3390
+ MESSAGE: {
3391
+ NAMES: {
3392
+ SINGULAR: "Message",
3393
+ PLURAL: "Messages"
3394
+ },
3395
+ ICONS: {
3396
+ DEFAULT: lucideReact.MessageSquare
3397
+ }
3398
+ },
3399
+ NOTIFICATION: {
3400
+ NAMES: {
3401
+ SINGULAR: "Notification",
3402
+ PLURAL: "Notifications"
3403
+ },
3404
+ ICONS: {
3405
+ DEFAULT: lucideReact.Bell
3406
+ }
3407
+ },
3408
+ APP: {
3409
+ NAMES: {
3410
+ SINGULAR: "Application",
3411
+ PLURAL: "Applications"
3412
+ },
3413
+ ICONS: {
3414
+ DEFAULT: lucideReact.LayoutGrid,
3415
+ HOME: lucideReact.LayoutGrid,
3416
+ LOGOUT: lucideReact.LogOut,
3417
+ UPLOAD: lucideReact.Upload
3418
+ }
3419
+ },
3420
+ HELP: {
3421
+ NAMES: {
3422
+ SINGULAR: "Help",
3423
+ PLURAL: "Help"
3424
+ },
3425
+ ICONS: {
3426
+ DEFAULT: lucideReact.MessageSquareLock,
3427
+ DOCS: lucideReact.BookOpen,
3428
+ FAQ: lucideReact.FileQuestion,
3429
+ ABOUT: lucideReact.Info
3430
+ }
3431
+ },
3432
+ USERSHIELD: {
3433
+ NAMES: {
3434
+ SINGULAR: "User Shield",
3435
+ PLURAL: "User Shields"
3436
+ },
3437
+ ICONS: {
3438
+ DEFAULT: lucideReact.MessageSquareLock
3439
+ }
3440
+ }
3441
+ };
3442
+ function configureEntityRegistry(overrides) {
3443
+ for (const [type, def] of Object.entries(overrides)) {
3444
+ const target = ENTITY_MAPPINGS[type];
3445
+ if (!target) continue;
3446
+ if (def?.NAMES) Object.assign(target.NAMES, def.NAMES);
3447
+ if (def?.ICONS) Object.assign(target.ICONS, def.ICONS);
3448
+ }
3449
+ }
3450
+ var getEntityIcon = (entityType, variant = "DEFAULT") => {
3451
+ const icons = ENTITY_MAPPINGS[entityType]?.ICONS;
3452
+ return icons?.[variant] || icons?.DEFAULT;
3453
+ };
3454
+ var getEntityLabel = (entityType, form = "SINGULAR") => {
3455
+ const entityMapping = ENTITY_MAPPINGS[entityType];
3456
+ if (!entityMapping) return "";
3457
+ const names = entityMapping.NAMES;
3458
+ const singularName = names.SINGULAR || "";
3459
+ if (form === "NEW") return names.NEW !== void 0 ? names.NEW : "New " + singularName;
3460
+ if (form === "SHORT")
3461
+ return names.SHORT !== void 0 ? names.SHORT : singularName.substring(0, 3) + ".";
3462
+ if (form === "PLURAL") return names.PLURAL !== void 0 ? names.PLURAL : singularName + "s";
3463
+ return singularName;
3464
+ };
3465
+ var EntityIcon = ({ entityType, variant = "DEFAULT", ...props }) => {
3466
+ const IconComponent = getEntityIcon(entityType, variant);
3467
+ return IconComponent ? React2__namespace.default.createElement(IconComponent, props) : null;
3468
+ };
3469
+ var VISIBILITY_ICONS = {
3470
+ PRIVATE: lucideReact.MessageSquareLock,
3471
+ SHARED: lucideReact.Users
3472
+ };
3473
+ var VisibilityIcon = ({
3474
+ isShared,
3475
+ ...props
3476
+ }) => {
3477
+ const IconComponent = isShared ? VISIBILITY_ICONS.SHARED : VISIBILITY_ICONS.PRIVATE;
3478
+ return React2__namespace.default.createElement(IconComponent, props);
3479
+ };
3480
+
3481
+ // src/entities/colors.ts
3482
+ var OPACITY_LIGHT = 0.15;
3483
+ var OPACITY_MEDIUM = 1;
3484
+ var OPACITY_BORDER = 0.3;
3485
+ var PLACEHOLDER_COLOR = "#9ca3af";
3486
+ var NEUTRAL_GRAY2 = "#64748b";
3487
+ var BASE_COLORS2 = {
3488
+ "0": "#10b981",
3489
+ "1": "#3b82f6",
3490
+ "2": "#8b5cf6",
3491
+ "3": "#f43f5e",
3492
+ "4": "#f59e0b",
3493
+ "5": "#84cc16",
3494
+ "6": "#a855f7",
3495
+ "7": "#06b6d4",
3496
+ "8": "#f97316",
3497
+ "9": "#14b8a6",
3498
+ a: "#ef4444",
3499
+ b: "#6366f1",
3500
+ c: "#ec4899",
3501
+ d: "#22c55e",
3502
+ e: "#eab308",
3503
+ f: "#0ea5e9"
3504
+ };
3505
+ function hexToRgba(hex, opacity) {
3506
+ const r = parseInt(hex.slice(1, 3), 16);
3507
+ const g = parseInt(hex.slice(3, 5), 16);
3508
+ const b = parseInt(hex.slice(5, 7), 16);
3509
+ return `rgba(${r}, ${g}, ${b}, ${opacity})`;
3510
+ }
3511
+ function getEntityColor2(entityId, variant = "medium") {
3512
+ const baseColor = BASE_COLORS2[entityId[4]] || BASE_COLORS2["0"];
3513
+ switch (variant) {
3514
+ case "light":
3515
+ return hexToRgba(baseColor, OPACITY_LIGHT);
3516
+ case "medium":
3517
+ return hexToRgba(baseColor, OPACITY_MEDIUM);
3518
+ case "text":
3519
+ return baseColor;
3520
+ }
3521
+ }
3522
+ function getEntityColorStyles(entityId) {
3523
+ const baseColor = BASE_COLORS2[entityId[4]] || BASE_COLORS2["0"];
3524
+ return {
3525
+ backgroundColor: getEntityColor2(entityId, "light"),
3526
+ color: baseColor,
3527
+ borderColor: hexToRgba(baseColor, OPACITY_BORDER)
3528
+ };
3529
+ }
3530
+ var getWorkspaceColor = (workspaceId, useWorkspaceColors) => {
3531
+ const shouldUseWorkspaceColors = useWorkspaceColors !== void 0 ? useWorkspaceColors : true;
3532
+ if (!shouldUseWorkspaceColors) return "hsl(var(--primary))";
3533
+ const isValidId = workspaceId && workspaceId.startsWith("wrk-") && workspaceId.length >= 5;
3534
+ if (!isValidId) return "hsl(var(--primary))";
3535
+ return getEntityColor2(workspaceId, "medium");
3536
+ };
3537
+ function nameInitials(name) {
3538
+ const parts = name.trim().split(/\s+/).filter(Boolean);
3539
+ if (!parts.length) return "?";
3540
+ return parts.slice(0, 2).map((p) => p[0]?.toUpperCase() ?? "").join("");
3541
+ }
3542
+ var STATUS_DOT = {
3543
+ online: "bg-emerald-500",
3544
+ busy: "bg-amber-500",
3545
+ offline: "bg-destructive"
3546
+ };
3547
+ function UserMenu({
3548
+ user,
3549
+ status,
3550
+ items = [],
3551
+ onLogout,
3552
+ logoutLabel = "Sign out",
3553
+ align = "end",
3554
+ side = "bottom",
3555
+ variant = "avatar",
3556
+ showChevron = true,
3557
+ classNames,
3558
+ testId = "user-menu",
3559
+ logoutTestId
3560
+ }) {
3561
+ return /* @__PURE__ */ jsxRuntime.jsxs(chunkRZQACYNQ_cjs.DropdownMenu, { children: [
3562
+ /* @__PURE__ */ jsxRuntime.jsx(chunkRZQACYNQ_cjs.DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(
3563
+ "button",
3564
+ {
3565
+ type: "button",
3566
+ className: chunkRZQACYNQ_cjs.cn(
3567
+ "flex items-center gap-2 rounded-md transition-colors hover:bg-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
3568
+ variant === "account" ? "w-full min-w-0 p-1 text-left pointer-coarse:min-h-11" : "px-1.5 py-1 pointer-coarse:min-h-11 pointer-coarse:min-w-11 pointer-coarse:justify-center",
3569
+ classNames?.trigger
3570
+ ),
3571
+ "data-testid": testId,
3572
+ "data-variant": variant,
3573
+ "aria-label": variant === "avatar" ? "Account menu" : void 0,
3574
+ title: variant === "avatar" ? user.name : void 0,
3575
+ children: [
3576
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "relative", children: [
3577
+ /* @__PURE__ */ jsxRuntime.jsxs(Avatar, { className: "size-8", children: [
3578
+ user.picture ? /* @__PURE__ */ jsxRuntime.jsx(AvatarImage, { src: user.picture, alt: user.name }) : null,
3579
+ /* @__PURE__ */ jsxRuntime.jsx(
3580
+ AvatarFallback,
3581
+ {
3582
+ className: chunkRZQACYNQ_cjs.cn("bg-primary text-primary-foreground", classNames?.fallback),
3583
+ children: nameInitials(user.name)
3584
+ }
3585
+ )
3586
+ ] }),
3587
+ status && /* @__PURE__ */ jsxRuntime.jsx(
3588
+ "span",
3589
+ {
3590
+ className: chunkRZQACYNQ_cjs.cn(
3591
+ "absolute -bottom-0.5 -right-0.5 size-2.5 rounded-full border-2 border-background",
3592
+ STATUS_DOT[status.tone]
3593
+ ),
3594
+ title: status.detail ? `${status.label} \xB7 ${status.detail}` : status.label,
3595
+ "data-testid": status.testId ? `${status.testId}-dot` : void 0
3596
+ }
3597
+ )
3598
+ ] }),
3599
+ variant === "account" ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
3600
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "min-w-0 flex-1 truncate text-sm font-medium text-foreground", children: user.name }),
3601
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronsUpDown, { className: "mr-1 size-4 shrink-0 text-muted-foreground" })
3602
+ ] }) : showChevron && /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDown, { className: "size-4 text-muted-foreground" })
3603
+ ]
3604
+ }
3605
+ ) }),
3606
+ /* @__PURE__ */ jsxRuntime.jsxs(
3607
+ chunkRZQACYNQ_cjs.DropdownMenuContent,
3608
+ {
3609
+ align,
3610
+ side,
3611
+ sideOffset: 8,
3612
+ collisionPadding: 12,
3613
+ className: "w-60 rounded-lg border-border/60 shadow-lg",
3614
+ "data-testid": "user-menu-panel",
3615
+ "data-topbar-popover": "",
3616
+ children: [
3617
+ /* @__PURE__ */ jsxRuntime.jsxs(chunkRZQACYNQ_cjs.DropdownMenuLabel, { className: "relative pr-8 pointer-coarse:pr-12", children: [
3618
+ /* @__PURE__ */ jsxRuntime.jsx(
3619
+ chunkRZQACYNQ_cjs.DropdownMenuItem,
3620
+ {
3621
+ className: "absolute right-1 top-1 flex size-6 items-center justify-center rounded-md p-0 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus:bg-accent pointer-coarse:right-0 pointer-coarse:top-0 pointer-coarse:size-11",
3622
+ "aria-label": "Close account menu",
3623
+ "data-testid": "user-menu-close",
3624
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { className: "size-3.5" })
3625
+ }
3626
+ ),
3627
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "truncate font-medium text-foreground", title: user.name, children: user.name }),
3628
+ user.email && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "truncate text-xs font-normal text-muted-foreground", title: user.email, children: user.email }),
3629
+ status && /* @__PURE__ */ jsxRuntime.jsxs(
3630
+ "div",
3631
+ {
3632
+ className: "mt-1 text-xs font-normal text-muted-foreground",
3633
+ "data-testid": status.testId,
3634
+ children: [
3635
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex items-center gap-1.5", children: [
3636
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: chunkRZQACYNQ_cjs.cn("size-2 shrink-0 rounded-full", STATUS_DOT[status.tone]) }),
3637
+ status.label
3638
+ ] }),
3639
+ status.detail && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-0.5 truncate pl-3.5 text-xs leading-tight text-muted-foreground/70", children: status.detail })
3640
+ ]
3641
+ }
3642
+ )
3643
+ ] }),
3644
+ /* @__PURE__ */ jsxRuntime.jsx(chunkRZQACYNQ_cjs.DropdownMenuSeparator, {}),
3645
+ items.map((item) => /* @__PURE__ */ jsxRuntime.jsxs(React2.Fragment, { children: [
3646
+ item.separatorBefore && /* @__PURE__ */ jsxRuntime.jsx(chunkRZQACYNQ_cjs.DropdownMenuSeparator, {}),
3647
+ /* @__PURE__ */ jsxRuntime.jsxs(
3648
+ chunkRZQACYNQ_cjs.DropdownMenuItem,
3649
+ {
3650
+ onClick: item.onSelect,
3651
+ "data-testid": item.testId,
3652
+ className: "pointer-coarse:min-h-11",
3653
+ ...item.checked !== void 0 ? { role: "menuitemcheckbox", "aria-checked": item.checked } : {},
3654
+ children: [
3655
+ item.icon && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "relative flex shrink-0", children: [
3656
+ /* @__PURE__ */ jsxRuntime.jsx(item.icon, { className: "size-4" }),
3657
+ item.dot && /* @__PURE__ */ jsxRuntime.jsx(
3658
+ "span",
3659
+ {
3660
+ className: "absolute -right-0.5 -top-0.5 size-2 rounded-full bg-primary ring-2 ring-popover",
3661
+ "aria-hidden": true
3662
+ }
3663
+ )
3664
+ ] }),
3665
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "min-w-0 flex-1 truncate", children: item.label }),
3666
+ item.badge !== void 0 && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "rounded-full bg-muted px-1.5 text-xs font-medium tabular-nums text-muted-foreground", children: item.badge }),
3667
+ item.checked !== void 0 && /* @__PURE__ */ jsxRuntime.jsx(
3668
+ "span",
3669
+ {
3670
+ "aria-hidden": true,
3671
+ className: chunkRZQACYNQ_cjs.cn(
3672
+ "flex h-4 w-7 shrink-0 items-center rounded-full p-0.5 transition-colors",
3673
+ item.checked ? "bg-primary" : "bg-border"
3674
+ ),
3675
+ children: /* @__PURE__ */ jsxRuntime.jsx(
3676
+ "span",
3677
+ {
3678
+ className: chunkRZQACYNQ_cjs.cn(
3679
+ "size-3 rounded-full bg-background transition-transform",
3680
+ item.checked && "translate-x-3"
3681
+ )
3682
+ }
3683
+ )
3684
+ }
3685
+ )
3686
+ ]
3687
+ }
3688
+ )
3689
+ ] }, item.label)),
3690
+ /* @__PURE__ */ jsxRuntime.jsx(chunkRZQACYNQ_cjs.DropdownMenuSeparator, {}),
3691
+ /* @__PURE__ */ jsxRuntime.jsxs(
3692
+ chunkRZQACYNQ_cjs.DropdownMenuItem,
3693
+ {
3694
+ onClick: onLogout,
3695
+ "data-testid": logoutTestId ?? `${testId}-logout`,
3696
+ className: "pointer-coarse:min-h-11",
3697
+ children: [
3698
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.LogOut, { className: "size-4" }),
3699
+ logoutLabel
3700
+ ]
3701
+ }
3702
+ )
3703
+ ]
3704
+ }
3705
+ )
3706
+ ] });
3707
+ }
3708
+ var ACTIVE_STATUSES = /* @__PURE__ */ new Set([
3709
+ "queued",
3710
+ "processing",
3711
+ "parsing",
3712
+ "encrypting",
3713
+ "indexing",
3714
+ "analysing"
3715
+ ]);
3716
+ var TERMINAL_STATUSES = /* @__PURE__ */ new Set(["completed", "failed", "skipped", "empty", "low-content"]);
3717
+ var STATUS_LABEL = {
3718
+ queued: "Queued",
3719
+ processing: "Processing",
3720
+ parsing: "Parsing",
3721
+ encrypting: "Encrypting",
3722
+ indexing: "Indexing",
3723
+ analysing: "Analysing"
3724
+ };
3725
+ var IMAGE_EXTENSIONS2 = /* @__PURE__ */ new Set(["jpg", "jpeg", "png", "gif", "bmp", "tiff", "tif", "webp"]);
3726
+ var VIDEO_EXTENSIONS2 = /* @__PURE__ */ new Set(["mp4", "mpeg", "mpg", "webm", "mov", "avi", "mkv"]);
3727
+ var AUDIO_EXTENSIONS2 = /* @__PURE__ */ new Set(["mp3", "wav", "m4a", "aac", "ogg", "flac"]);
3728
+ var EMAIL_EXTENSIONS2 = /* @__PURE__ */ new Set(["eml", "msg"]);
3729
+ function fileIcon(fileName, size) {
3730
+ const ext = fileName?.split(".").pop()?.toLowerCase();
3731
+ if (ext && VIDEO_EXTENSIONS2.has(ext)) return /* @__PURE__ */ jsxRuntime.jsx(VidIcon, { size });
3732
+ if (ext && AUDIO_EXTENSIONS2.has(ext)) return /* @__PURE__ */ jsxRuntime.jsx(AudIcon, { size });
3733
+ if (ext && IMAGE_EXTENSIONS2.has(ext)) return /* @__PURE__ */ jsxRuntime.jsx(ImgIcon, { size });
3734
+ if (ext && EMAIL_EXTENSIONS2.has(ext)) return /* @__PURE__ */ jsxRuntime.jsx(EmlIcon, { size });
3735
+ return /* @__PURE__ */ jsxRuntime.jsx(PdfIcon, { size });
3736
+ }
3737
+ function RenameField({
3738
+ seed,
3739
+ onCommit,
3740
+ onCancel,
3741
+ testId
3742
+ }) {
3743
+ const done = React2__namespace.default.useRef(false);
3744
+ const commit = (value) => {
3745
+ if (done.current) return;
3746
+ done.current = true;
3747
+ const trimmed = value.trim();
3748
+ if (trimmed && trimmed !== seed) onCommit(trimmed);
3749
+ else onCancel();
3750
+ };
3751
+ return /* @__PURE__ */ jsxRuntime.jsx(
3752
+ "input",
3753
+ {
3754
+ autoFocus: true,
3755
+ defaultValue: seed,
3756
+ "data-testid": testId,
3757
+ onFocus: (e) => e.currentTarget.select(),
3758
+ onClick: (e) => e.stopPropagation(),
3759
+ onKeyDown: (e) => {
3760
+ if (e.key === "Enter") {
3761
+ e.preventDefault();
3762
+ commit(e.currentTarget.value);
3763
+ } else if (e.key === "Escape") {
3764
+ e.preventDefault();
3765
+ done.current = true;
3766
+ onCancel();
3767
+ }
3768
+ },
3769
+ onBlur: (e) => commit(e.currentTarget.value),
3770
+ className: "w-full rounded border border-primary bg-background px-1 py-0.5 text-xs text-foreground outline-none"
3771
+ }
3772
+ );
3773
+ }
3774
+ function StatusMarker({ status, testId }) {
3775
+ let icon = null;
3776
+ let title = "";
3777
+ switch (status) {
3778
+ case "completed":
3779
+ icon = /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CheckCircle, { className: "size-4 text-success", strokeWidth: 2.75 });
3780
+ title = "Ready";
3781
+ break;
3782
+ case "failed":
3783
+ icon = /* @__PURE__ */ jsxRuntime.jsx(lucideReact.XCircle, { className: "size-4 text-destructive", strokeWidth: 2.75 });
3784
+ title = "Failed";
3785
+ break;
3786
+ case "skipped":
3787
+ icon = /* @__PURE__ */ jsxRuntime.jsx(lucideReact.SkipForward, { className: "size-4 text-muted-foreground", strokeWidth: 2.75 });
3788
+ title = "Skipped";
3789
+ break;
3790
+ case "empty":
3791
+ icon = /* @__PURE__ */ jsxRuntime.jsx(lucideReact.FileX, { className: "size-4 text-warning", strokeWidth: 2.75 });
3792
+ title = "Empty \u2014 no extractable content";
3793
+ break;
3794
+ case "low-content":
3795
+ icon = /* @__PURE__ */ jsxRuntime.jsx(lucideReact.AlertTriangle, { className: "size-4 text-warning", strokeWidth: 2.75 });
3796
+ title = "Low content \u2014 minimal extractable content";
3797
+ break;
3798
+ default:
3799
+ return null;
3800
+ }
3801
+ return /* @__PURE__ */ jsxRuntime.jsx(
3802
+ "span",
3803
+ {
3804
+ title,
3805
+ "data-testid": testId,
3806
+ className: "flex size-6 items-center justify-center rounded-full bg-background shadow-sm",
3807
+ children: icon
3808
+ }
3809
+ );
3810
+ }
3811
+ function DocumentCard({
3812
+ doc,
3813
+ thumbnailUrl,
3814
+ status,
3815
+ selected = false,
3816
+ onToggleSelect,
3817
+ viewing = false,
3818
+ onOpen,
3819
+ actions,
3820
+ renaming = false,
3821
+ onCommitRename,
3822
+ onCancelRename,
3823
+ tooltipContent,
3824
+ marker,
3825
+ testId = "document-card",
3826
+ className
3827
+ }) {
3828
+ const normalised = (status ?? "").toLowerCase();
3829
+ const isProcessing = ACTIVE_STATUSES.has(normalised);
3830
+ const showStatusMarker = !isProcessing && TERMINAL_STATUSES.has(normalised);
3831
+ const [thumbFailed, setThumbFailed] = React2__namespace.default.useState(false);
3832
+ const [thumbLandscape, setThumbLandscape] = React2__namespace.default.useState(false);
3833
+ const showThumbnail = !!thumbnailUrl && !thumbFailed && !isProcessing;
3834
+ return /* @__PURE__ */ jsxRuntime.jsxs(
3835
+ "div",
3836
+ {
3837
+ "data-testid": testId,
3838
+ className: chunkRZQACYNQ_cjs.cn(
3839
+ // Square corners and a portrait-page aspect (height = 1.3 × width), so a
3840
+ // cover-page thumbnail reads edge-to-edge.
3841
+ "group relative aspect-[10/13] select-none overflow-hidden border bg-muted/20 transition",
3842
+ selected ? "border-primary bg-primary/10" : "border-border shadow-sm hover:border-border/80 hover:bg-muted/50",
3843
+ className
3844
+ ),
3845
+ children: [
3846
+ showThumbnail ? /* @__PURE__ */ jsxRuntime.jsx(
3847
+ "img",
3848
+ {
3849
+ src: thumbnailUrl,
3850
+ alt: "",
3851
+ loading: "lazy",
3852
+ draggable: false,
3853
+ onError: () => setThumbFailed(true),
3854
+ onLoad: (e) => setThumbLandscape(e.currentTarget.naturalWidth > e.currentTarget.naturalHeight),
3855
+ className: chunkRZQACYNQ_cjs.cn(
3856
+ "absolute inset-0 size-full bg-white",
3857
+ thumbLandscape ? "object-contain" : "object-cover object-top"
3858
+ )
3859
+ }
3860
+ ) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute inset-0 flex items-center justify-center text-muted-foreground", children: fileIcon(doc.file_name, 44) }),
3861
+ isProcessing && /* @__PURE__ */ jsxRuntime.jsxs(
3862
+ "div",
3863
+ {
3864
+ "data-testid": `${testId}-processing`,
3865
+ className: "absolute inset-0 z-10 flex flex-col items-center justify-center gap-1.5 bg-background/80 px-3",
3866
+ children: [
3867
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-1.5 w-full overflow-hidden rounded-sm bg-muted", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-full w-1/3 animate-pulse rounded-sm bg-primary" }) }),
3868
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs font-medium text-primary", children: STATUS_LABEL[normalised] ?? normalised })
3869
+ ]
3870
+ }
3871
+ ),
3872
+ onToggleSelect && /* @__PURE__ */ jsxRuntime.jsx(
3873
+ Checkbox,
3874
+ {
3875
+ checked: selected,
3876
+ onCheckedChange: () => onToggleSelect(),
3877
+ onClick: (e) => e.stopPropagation(),
3878
+ "aria-label": selected ? "Deselect" : "Select",
3879
+ "data-testid": `${testId}-select`,
3880
+ className: chunkRZQACYNQ_cjs.cn(
3881
+ "absolute left-1.5 top-1.5 z-20 size-6 rounded-none border-muted-foreground/60 bg-background shadow-sm transition",
3882
+ selected ? "opacity-100" : "opacity-40 group-hover:opacity-100"
3883
+ )
3884
+ }
3885
+ ),
3886
+ actions && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute right-1.5 top-1.5 z-20", children: actions }),
3887
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "absolute inset-x-1.5 bottom-1.5 z-20 flex flex-col gap-1", children: [
3888
+ (marker || showStatusMarker) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center", children: [
3889
+ marker,
3890
+ showStatusMarker && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ml-auto flex", children: /* @__PURE__ */ jsxRuntime.jsx(StatusMarker, { status: normalised, testId: `${testId}-status` }) })
3891
+ ] }),
3892
+ renaming ? /* @__PURE__ */ jsxRuntime.jsx(
3893
+ RenameField,
3894
+ {
3895
+ seed: doc.doc_metadata?.title || doc.file_name || "",
3896
+ onCommit: (name) => onCommitRename?.(name),
3897
+ onCancel: () => onCancelRename?.(),
3898
+ testId: `${testId}-rename-input`
3899
+ }
3900
+ ) : /* @__PURE__ */ jsxRuntime.jsx(
3901
+ DocumentEntity,
3902
+ {
3903
+ doc,
3904
+ fullWidth: true,
3905
+ viewing,
3906
+ tooltipContent,
3907
+ labelClassName: "font-semibold",
3908
+ className: "w-full min-w-0 max-w-full bg-background/90 backdrop-blur-sm",
3909
+ onClick: (e) => {
3910
+ e.stopPropagation();
3911
+ onOpen?.();
3912
+ }
3913
+ }
3914
+ )
3915
+ ] })
3916
+ ]
3917
+ }
3918
+ );
3919
+ }
3920
+
3921
+ exports.AgentBadge = AgentBadge;
3922
+ exports.AiMarkdown = AiMarkdown;
3923
+ exports.ArbiBotHeadIcon = ArbiBotHeadIcon;
3924
+ exports.AudIcon = AudIcon;
3925
+ exports.Avatar = Avatar;
3926
+ exports.AvatarFallback = AvatarFallback;
3927
+ exports.AvatarImage = AvatarImage;
3928
+ exports.BASE_COLORS = BASE_COLORS2;
3929
+ exports.Badge = Badge;
3930
+ exports.Button = Button;
3931
+ exports.Card = Card;
3932
+ exports.CardContent = CardContent;
3933
+ exports.CardDescription = CardDescription;
3934
+ exports.CardFooter = CardFooter;
3935
+ exports.CardHeader = CardHeader;
3936
+ exports.CardTitle = CardTitle;
3937
+ exports.Checkbox = Checkbox;
3938
+ exports.Collapsible = Collapsible;
3939
+ exports.CollapsibleContent = CollapsibleContent2;
3940
+ exports.CollapsibleTrigger = CollapsibleTrigger2;
3941
+ exports.Command = Command;
3942
+ exports.CommandDialog = CommandDialog;
3943
+ exports.CommandEmpty = CommandEmpty;
3944
+ exports.CommandGroup = CommandGroup;
3945
+ exports.CommandInput = CommandInput;
3946
+ exports.CommandItem = CommandItem;
3947
+ exports.CommandList = CommandList;
3948
+ exports.CommandSeparator = CommandSeparator;
3949
+ exports.CommandShortcut = CommandShortcut;
3950
+ exports.Dialog = Dialog;
3951
+ exports.DialogClose = DialogClose;
3952
+ exports.DialogContent = DialogContent;
3953
+ exports.DialogDescription = DialogDescription;
3954
+ exports.DialogFooter = DialogFooter;
3955
+ exports.DialogHeader = DialogHeader;
3956
+ exports.DialogOverlay = DialogOverlay;
3957
+ exports.DialogPortal = DialogPortal;
3958
+ exports.DialogTitle = DialogTitle;
3959
+ exports.DialogTrigger = DialogTrigger;
3960
+ exports.DictateProvider = DictateProvider;
3961
+ exports.DocumentCard = DocumentCard;
3962
+ exports.DocumentEntity = DocumentEntity;
3963
+ exports.ENTITY_MAPPINGS = ENTITY_MAPPINGS;
3964
+ exports.EmlIcon = EmlIcon;
3965
+ exports.EntityIcon = EntityIcon;
3966
+ exports.EntityPill = EntityPill;
3967
+ exports.FILE_TYPE_COLORS = FILE_TYPE_COLORS;
3968
+ exports.HoverCard = HoverCard;
3969
+ exports.HoverCardContent = HoverCardContent;
3970
+ exports.HoverCardTrigger = HoverCardTrigger;
3971
+ exports.IconToggle = IconToggle;
3972
+ exports.ImgIcon = ImgIcon;
3973
+ exports.InlineMicButton = InlineMicButton;
3974
+ exports.Input = Input;
3975
+ exports.Label = Label;
3976
+ exports.MarkMenu = MarkMenu;
3977
+ exports.MarkdownRenderer = MarkdownRenderer;
3978
+ exports.MarkdownStreamingContext = MarkdownStreamingContext;
3979
+ exports.MicRecordingOverlay = MicRecordingOverlay;
3980
+ exports.MicWaveformIndicator = MicWaveformIndicator;
3981
+ exports.NEUTRAL_GRAY = NEUTRAL_GRAY2;
3982
+ exports.PLACEHOLDER_COLOR = PLACEHOLDER_COLOR;
3983
+ exports.PassageCard = PassageCard;
3984
+ exports.PdfIcon = PdfIcon;
3985
+ exports.Popover = Popover;
3986
+ exports.PopoverAnchor = PopoverAnchor;
3987
+ exports.PopoverContent = PopoverContent;
3988
+ exports.PopoverTrigger = PopoverTrigger;
3989
+ exports.PresenceLabel = PresenceLabel;
3990
+ exports.Progress = Progress;
3991
+ exports.ProjectEntity = ProjectEntity;
3992
+ exports.RadioGroup = RadioGroup;
3993
+ exports.RadioGroupItem = RadioGroupItem;
3994
+ exports.RagDot = RagDot;
3995
+ exports.RelevanceDot = RelevanceDot;
3996
+ exports.Select = Select;
3997
+ exports.SelectContent = SelectContent;
3998
+ exports.SelectGroup = SelectGroup;
3999
+ exports.SelectItem = SelectItem;
4000
+ exports.SelectLabel = SelectLabel;
4001
+ exports.SelectScrollDownButton = SelectScrollDownButton;
4002
+ exports.SelectScrollUpButton = SelectScrollUpButton;
4003
+ exports.SelectSeparator = SelectSeparator;
4004
+ exports.SelectTrigger = SelectTrigger;
4005
+ exports.SelectValue = SelectValue;
4006
+ exports.Separator = Separator;
4007
+ exports.Slider = Slider;
4008
+ exports.StatusPill = StatusPill;
4009
+ exports.Switch = Switch;
4010
+ exports.TAG_TYPE_ICONS = TAG_TYPE_ICONS;
4011
+ exports.TAG_TYPE_LABELS = TAG_TYPE_LABELS;
4012
+ exports.Table = Table;
4013
+ exports.TableBody = TableBody;
4014
+ exports.TableCaption = TableCaption;
4015
+ exports.TableCell = TableCell;
4016
+ exports.TableFooter = TableFooter;
4017
+ exports.TableHead = TableHead;
4018
+ exports.TableHeader = TableHeader;
4019
+ exports.TableRow = TableRow;
4020
+ exports.Tabs = Tabs;
4021
+ exports.TabsContent = TabsContent;
4022
+ exports.TabsList = TabsList;
4023
+ exports.TabsTrigger = TabsTrigger;
4024
+ exports.TagEntity = TagEntity;
4025
+ exports.Textarea = Textarea;
4026
+ exports.Toggle = Toggle;
4027
+ exports.ToggleGroup = ToggleGroup;
4028
+ exports.ToggleGroupItem = ToggleGroupItem;
4029
+ exports.Tooltip = Tooltip;
4030
+ exports.TooltipContent = TooltipContent;
4031
+ exports.TooltipProvider = TooltipProvider;
4032
+ exports.TooltipTrigger = TooltipTrigger;
4033
+ exports.UserEntity = UserEntity;
4034
+ exports.UserMenu = UserMenu;
4035
+ exports.VISIBILITY_ICONS = VISIBILITY_ICONS;
4036
+ exports.VidIcon = VidIcon;
4037
+ exports.VisibilityIcon = VisibilityIcon;
4038
+ exports.badgeVariants = badgeVariants;
4039
+ exports.buttonVariants = buttonVariants;
4040
+ exports.cardVariants = cardVariants;
4041
+ exports.classifyMediaError = classifyMediaError;
4042
+ exports.configureEntityRegistry = configureEntityRegistry;
4043
+ exports.configureRagLabels = configureRagLabels;
4044
+ exports.configureStatusRegistry = configureStatusRegistry;
4045
+ exports.formatElapsed = formatElapsed;
4046
+ exports.getDocIcon = getDocIcon;
4047
+ exports.getEntityColor = getEntityColor2;
4048
+ exports.getEntityColorStyles = getEntityColorStyles;
4049
+ exports.getEntityIcon = getEntityIcon;
4050
+ exports.getEntityLabel = getEntityLabel;
4051
+ exports.getStatusVariant = getStatusVariant;
4052
+ exports.getTagTypeIcon = getTagTypeIcon;
4053
+ exports.getTagTypeLabel = getTagTypeLabel;
4054
+ exports.getWorkspaceColor = getWorkspaceColor;
4055
+ exports.markdownBaseComponents = markdownBaseComponents;
4056
+ exports.splitMarkdownBlocks = splitMarkdownBlocks;
4057
+ exports.toggleVariants = toggleVariants;
4058
+ exports.useAudioRecorder = useAudioRecorder;
4059
+ //# sourceMappingURL=chunk-OU2QLIKS.cjs.map
4060
+ //# sourceMappingURL=chunk-OU2QLIKS.cjs.map