fi-glass 1.1.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.
@@ -0,0 +1,213 @@
1
+ import * as react from 'react';
2
+ import { ReactNode } from 'react';
3
+
4
+ /**
5
+ * fi-glass · message style configuration
6
+ * Copied verbatim from aurity ui/message/styles/message-styles.ts on 2026-06-01
7
+ * (Plutonio). Class strings are identical so rendering is unchanged.
8
+ *
9
+ * Dense style inspired by Claude.ai / ChatGPT:
10
+ * - No bubbles, text is protagonist
11
+ * - Minimal spacing, subtle avatars
12
+ *
13
+ * NOTE: values are duplicated with aurity's local copy during the migration —
14
+ * known debt, same call as the theme tokens. Apps override per-instance via the
15
+ * className props on each primitive, so they never need to touch this file.
16
+ */
17
+ declare const messageStyles: {
18
+ readonly container: {
19
+ readonly base: "space-y-0.5";
20
+ readonly padding: "px-4";
21
+ };
22
+ readonly message: {
23
+ readonly base: "group relative py-3 px-4 -mx-4 transition-colors duration-150";
24
+ readonly user: "bg-transparent hover:bg-white/[0.02]";
25
+ readonly assistant: "bg-white/[0.02] hover:bg-white/[0.04]";
26
+ readonly borderRadius: "rounded-lg";
27
+ };
28
+ readonly avatar: {
29
+ readonly size: "w-6 h-6";
30
+ readonly base: "rounded-md flex items-center justify-center text-[10px] font-semibold flex-shrink-0";
31
+ readonly user: "bg-violet-600/80 text-white";
32
+ readonly assistant: "bg-amber-500/80 text-slate-900";
33
+ };
34
+ readonly meta: {
35
+ readonly container: "flex items-baseline gap-2";
36
+ readonly name: "text-[13px] font-medium text-slate-300";
37
+ readonly time: "text-[11px] text-slate-500 tabular-nums";
38
+ };
39
+ readonly content: {
40
+ readonly base: "text-[14px] leading-relaxed";
41
+ readonly user: "text-slate-200";
42
+ readonly assistant: "text-slate-100";
43
+ readonly indent: "pl-8";
44
+ };
45
+ readonly actions: {
46
+ readonly container: "\n absolute top-2 right-2\n flex items-center gap-0.5\n opacity-0 group-hover:opacity-100\n transition-opacity duration-150\n bg-slate-800/95 backdrop-blur-sm rounded-md p-0.5\n border border-slate-700/50 shadow-lg\n ";
47
+ readonly button: {
48
+ readonly base: "p-1 rounded transition-colors duration-150";
49
+ readonly idle: "hover:bg-slate-700 text-slate-400 hover:text-slate-200";
50
+ readonly active: "bg-emerald-500/20 text-emerald-400";
51
+ readonly speaking: "bg-amber-500/20 text-amber-400";
52
+ };
53
+ readonly icon: "w-3 h-3";
54
+ };
55
+ readonly dateDivider: {
56
+ readonly container: "my-4 flex items-center gap-3";
57
+ readonly line: "flex-1 h-px bg-gradient-to-r from-transparent via-slate-700/30 to-transparent";
58
+ readonly label: "px-3 py-1 text-[10px] text-slate-500 font-medium bg-slate-900/50 rounded-full";
59
+ };
60
+ readonly typing: {
61
+ readonly container: "flex items-center gap-2 px-4 py-2";
62
+ readonly dot: "w-1.5 h-1.5 bg-amber-400/80 rounded-full";
63
+ readonly animation: "animate-bounce";
64
+ };
65
+ };
66
+ declare const markdownStyles: {
67
+ readonly p: "mb-3 last:mb-0";
68
+ readonly strong: "font-semibold text-white";
69
+ readonly em: "italic text-slate-300";
70
+ readonly code: "px-1 py-0.5 bg-slate-800/80 rounded text-amber-300/90 font-mono text-[13px]";
71
+ readonly pre: "my-3 p-3 bg-slate-900/80 rounded-lg border border-slate-700/30 overflow-x-auto text-[13px]";
72
+ readonly ul: "my-2 ml-0.5 space-y-1.5";
73
+ readonly ol: "my-2 ml-0.5 space-y-1.5 list-decimal list-inside";
74
+ readonly li: "flex gap-1.5 text-slate-200";
75
+ readonly bullet: "text-slate-500 select-none text-[10px] mt-1";
76
+ readonly h1: "text-lg font-semibold text-white mt-4 mb-2";
77
+ readonly h2: "text-base font-semibold text-white mt-3 mb-1.5";
78
+ readonly h3: "text-sm font-semibold text-slate-100 mt-2 mb-1";
79
+ readonly blockquote: "my-3 pl-3 border-l-2 border-slate-600/50 text-slate-400 italic text-[13px]";
80
+ readonly link: "text-amber-400/90 hover:text-amber-300 underline underline-offset-2 transition-colors";
81
+ };
82
+
83
+ interface MessageContentProps {
84
+ /** Is this a user message */
85
+ isUser: boolean;
86
+ /** Message content */
87
+ content: string;
88
+ /** Show streaming cursor */
89
+ isStreaming?: boolean;
90
+ /** Override how assistant content is rendered (default: markdown). */
91
+ renderMarkdown?: (content: string) => ReactNode;
92
+ /**
93
+ * B3-FIGLASS-12 — clamp long content behind a "show more" disclosure
94
+ * (ChatGPT parity for long pasted user messages). Never combine with
95
+ * `isStreaming`: a live answer must stay fully visible while it grows.
96
+ */
97
+ collapsible?: boolean;
98
+ /** Collapsed max height in px when `collapsible`. Default 264. */
99
+ collapsedMaxHeight?: number;
100
+ /** Disclosure copy (app-owned). Defaults: "Mostrar más" / "Mostrar menos". */
101
+ showMoreLabel?: string;
102
+ showLessLabel?: string;
103
+ /** Class for the disclosure toggle button. */
104
+ collapseToggleClassName?: string;
105
+ }
106
+ declare const MessageContent: react.NamedExoticComponent<MessageContentProps>;
107
+
108
+ /**
109
+ * normalizeStreamedMarkdown — repair chunk-boundary glue in streamed LLM output
110
+ * before markdown rendering (B3-FIGLASS-9).
111
+ *
112
+ * The staging audit showed an assistant reply rendering "…las herramientas
113
+ * necesarias.## Respuesta sobre…" — the backend concatenated the pre-tool text
114
+ * and the post-tool response without a newline, so the ATX heading never starts
115
+ * a line and CommonMark (correctly) treats it as paragraph text.
116
+ *
117
+ * This is a NORMALIZER, not a parser: one conservative repair, applied only
118
+ * outside fenced code blocks.
119
+ *
120
+ * Repair rule: a heading marker (`#{1,6} `) glued directly onto sentence-ending
121
+ * punctuation gets a blank line inserted before it. Requiring the punctuation
122
+ * (no whitespace in between) is what keeps false positives out:
123
+ * - `C# is nice` → untouched (letter before `#`)
124
+ * - `issue #123` → untouched (no space after `#`)
125
+ * - `use the # key` → untouched (whitespace before `#`)
126
+ * - `fin.## Título` → `fin.\n\n## Título` (the streaming-glue case)
127
+ */
128
+ declare function normalizeStreamedMarkdown(content: string): string;
129
+
130
+ interface CopyButtonProps {
131
+ /** Text to copy to the clipboard. */
132
+ content: string;
133
+ /** Called if the Clipboard API rejects (default: silent). */
134
+ onError?: (error: unknown) => void;
135
+ /** Override the button base class. */
136
+ className?: string;
137
+ /** Override the idle-state class. */
138
+ idleClassName?: string;
139
+ /** Override the copied-state class. */
140
+ activeClassName?: string;
141
+ /** Override the icon class. */
142
+ iconClassName?: string;
143
+ /** Tooltip/label before copy (default: "Copiar"). */
144
+ copyLabel?: string;
145
+ /** Tooltip/label after copy (default: "Copiado"). */
146
+ copiedLabel?: string;
147
+ /** Milliseconds before the check resets to copy (default: 2000). */
148
+ resetMs?: number;
149
+ }
150
+ declare const CopyButton: react.NamedExoticComponent<CopyButtonProps>;
151
+
152
+ interface MessageBubbleProps {
153
+ /** Drives alignment/background (user vs assistant). */
154
+ role: 'user' | 'assistant';
155
+ /** The message body (required). */
156
+ children: ReactNode;
157
+ /** Avatar + author/timestamp row. */
158
+ header?: ReactNode;
159
+ /** Reasoning / chain-of-thought block (rendered above the body). */
160
+ reasoning?: ReactNode;
161
+ /** Badge/chip rendered below the body (e.g. model, sources). */
162
+ badge?: ReactNode;
163
+ /** Hover action toolbar (e.g. copy, speak). */
164
+ actions?: ReactNode;
165
+ /** Extra classes appended to the article. */
166
+ className?: string;
167
+ /** Accessible label for the article. */
168
+ ariaLabel?: string;
169
+ }
170
+ declare const MessageBubble: react.NamedExoticComponent<MessageBubbleProps>;
171
+
172
+ interface CollapsibleTextProps {
173
+ children: ReactNode;
174
+ /** Collapsed max height in px. Default 264 (11 lines at 24px leading). */
175
+ maxHeight?: number;
176
+ /** Height in px of the fade-out mask at the bottom of clamped content. Default 48. */
177
+ fadeHeight?: number;
178
+ /** Toggle copy when collapsed. Default: "Mostrar más". */
179
+ showMoreLabel?: string;
180
+ /** Toggle copy when expanded. Default: "Mostrar menos". */
181
+ showLessLabel?: string;
182
+ /** Wrapper class (style hook for the app). */
183
+ className?: string;
184
+ /** Toggle button class. When set, the unstyled default is dropped. */
185
+ toggleClassName?: string;
186
+ }
187
+ declare function CollapsibleText({ children, maxHeight, fadeHeight, showMoreLabel, showLessLabel, className, toggleClassName, }: CollapsibleTextProps): react.JSX.Element;
188
+
189
+ interface MessageListGroup<T> {
190
+ /** Stable key for the group (also passed to renderDivider). */
191
+ key: string;
192
+ /** Items belonging to this group. */
193
+ items: T[];
194
+ }
195
+ interface MessageListProps<T> {
196
+ /** Pre-grouped items (app decides the grouping strategy). */
197
+ groups: MessageListGroup<T>[];
198
+ /** Render a single item. Return value should carry its own React key. */
199
+ renderItem: (item: T, index: number) => ReactNode;
200
+ /** Optional per-group divider (e.g. a date separator). */
201
+ renderDivider?: (key: string) => ReactNode;
202
+ /** Class for the scroll/list container. */
203
+ containerClassName?: string;
204
+ /** Class for each group's inner item wrapper. */
205
+ groupClassName?: string;
206
+ /** Slot rendered before the groups. */
207
+ header?: ReactNode;
208
+ /** Slot rendered after the groups (streaming row, typing dots, spacer…). */
209
+ footer?: ReactNode;
210
+ }
211
+ declare function MessageList<T>({ groups, renderItem, renderDivider, containerClassName, groupClassName, header, footer, }: MessageListProps<T>): react.JSX.Element;
212
+
213
+ export { CollapsibleText, type CollapsibleTextProps, CopyButton, type CopyButtonProps, MessageBubble, type MessageBubbleProps, MessageContent, type MessageContentProps, MessageList, type MessageListGroup, type MessageListProps, markdownStyles, messageStyles, normalizeStreamedMarkdown };
@@ -0,0 +1,337 @@
1
+ 'use client';
2
+
3
+ // src/messages/styles.ts
4
+ var messageStyles = {
5
+ // Container
6
+ container: {
7
+ base: "space-y-0.5",
8
+ padding: "px-4"
9
+ },
10
+ // Message row
11
+ message: {
12
+ base: "group relative py-3 px-4 -mx-4 transition-colors duration-150",
13
+ user: "bg-transparent hover:bg-white/[0.02]",
14
+ assistant: "bg-white/[0.02] hover:bg-white/[0.04]",
15
+ borderRadius: "rounded-lg"
16
+ },
17
+ // Avatar
18
+ avatar: {
19
+ size: "w-6 h-6",
20
+ base: "rounded-md flex items-center justify-center text-[10px] font-semibold flex-shrink-0",
21
+ user: "bg-violet-600/80 text-white",
22
+ assistant: "bg-amber-500/80 text-slate-900"
23
+ },
24
+ // Meta (name + time)
25
+ meta: {
26
+ container: "flex items-baseline gap-2",
27
+ name: "text-[13px] font-medium text-slate-300",
28
+ time: "text-[11px] text-slate-500 tabular-nums"
29
+ },
30
+ // Content
31
+ content: {
32
+ base: "text-[14px] leading-relaxed",
33
+ user: "text-slate-200",
34
+ assistant: "text-slate-100",
35
+ indent: "pl-8"
36
+ // Align with avatar
37
+ },
38
+ // Actions toolbar
39
+ actions: {
40
+ container: `
41
+ absolute top-2 right-2
42
+ flex items-center gap-0.5
43
+ opacity-0 group-hover:opacity-100
44
+ transition-opacity duration-150
45
+ bg-slate-800/95 backdrop-blur-sm rounded-md p-0.5
46
+ border border-slate-700/50 shadow-lg
47
+ `,
48
+ button: {
49
+ base: "p-1 rounded transition-colors duration-150",
50
+ idle: "hover:bg-slate-700 text-slate-400 hover:text-slate-200",
51
+ active: "bg-emerald-500/20 text-emerald-400",
52
+ speaking: "bg-amber-500/20 text-amber-400"
53
+ },
54
+ icon: "w-3 h-3"
55
+ },
56
+ // Date divider
57
+ dateDivider: {
58
+ container: "my-4 flex items-center gap-3",
59
+ line: "flex-1 h-px bg-gradient-to-r from-transparent via-slate-700/30 to-transparent",
60
+ label: "px-3 py-1 text-[10px] text-slate-500 font-medium bg-slate-900/50 rounded-full"
61
+ },
62
+ // Typing indicator
63
+ typing: {
64
+ container: "flex items-center gap-2 px-4 py-2",
65
+ dot: "w-1.5 h-1.5 bg-amber-400/80 rounded-full",
66
+ animation: "animate-bounce"
67
+ }
68
+ };
69
+ var markdownStyles = {
70
+ p: "mb-3 last:mb-0",
71
+ strong: "font-semibold text-white",
72
+ em: "italic text-slate-300",
73
+ code: "px-1 py-0.5 bg-slate-800/80 rounded text-amber-300/90 font-mono text-[13px]",
74
+ pre: "my-3 p-3 bg-slate-900/80 rounded-lg border border-slate-700/30 overflow-x-auto text-[13px]",
75
+ ul: "my-2 ml-0.5 space-y-1.5",
76
+ ol: "my-2 ml-0.5 space-y-1.5 list-decimal list-inside",
77
+ li: "flex gap-1.5 text-slate-200",
78
+ bullet: "text-slate-500 select-none text-[10px] mt-1",
79
+ h1: "text-lg font-semibold text-white mt-4 mb-2",
80
+ h2: "text-base font-semibold text-white mt-3 mb-1.5",
81
+ h3: "text-sm font-semibold text-slate-100 mt-2 mb-1",
82
+ blockquote: "my-3 pl-3 border-l-2 border-slate-600/50 text-slate-400 italic text-[13px]",
83
+ link: "text-amber-400/90 hover:text-amber-300 underline underline-offset-2 transition-colors"
84
+ };
85
+
86
+ // src/messages/MessageContent.tsx
87
+ import { memo } from "react";
88
+ import ReactMarkdown from "react-markdown";
89
+ import remarkGfm from "remark-gfm";
90
+
91
+ // src/messages/normalizeStreamedMarkdown.ts
92
+ var FENCE_SPLIT = /(```[\s\S]*?(?:```|$))/;
93
+ var GLUED_HEADING = /([.!?:;,)\]"'»…])(#{1,6} )/g;
94
+ function normalizeStreamedMarkdown(content) {
95
+ if (!content.includes("#")) return content;
96
+ return content.split(FENCE_SPLIT).map(
97
+ (segment, i) => i % 2 === 1 ? segment : segment.replace(GLUED_HEADING, "$1\n\n$2")
98
+ ).join("");
99
+ }
100
+
101
+ // src/messages/CollapsibleText.tsx
102
+ import { useEffect, useId, useRef, useState } from "react";
103
+ import { jsx, jsxs } from "react/jsx-runtime";
104
+ var OVERFLOW_TOLERANCE_PX = 16;
105
+ function CollapsibleText({
106
+ children,
107
+ maxHeight = 264,
108
+ fadeHeight = 48,
109
+ showMoreLabel = "Mostrar m\xE1s",
110
+ showLessLabel = "Mostrar menos",
111
+ className,
112
+ toggleClassName
113
+ }) {
114
+ const contentId = useId();
115
+ const contentRef = useRef(null);
116
+ const [expanded, setExpanded] = useState(false);
117
+ const [overflowing, setOverflowing] = useState(false);
118
+ useEffect(() => {
119
+ const el = contentRef.current;
120
+ if (!el) return;
121
+ const measure = () => setOverflowing(el.scrollHeight > maxHeight + OVERFLOW_TOLERANCE_PX);
122
+ measure();
123
+ if (typeof ResizeObserver === "undefined") return;
124
+ const ro = new ResizeObserver(measure);
125
+ ro.observe(el);
126
+ return () => ro.disconnect();
127
+ }, [maxHeight]);
128
+ const clamped = overflowing && !expanded;
129
+ const mask = `linear-gradient(rgb(0,0,0) calc(100% - ${fadeHeight}px), transparent)`;
130
+ return /* @__PURE__ */ jsxs("div", { className, children: [
131
+ /* @__PURE__ */ jsx(
132
+ "div",
133
+ {
134
+ id: contentId,
135
+ ref: contentRef,
136
+ style: clamped ? {
137
+ maxHeight,
138
+ overflow: "hidden",
139
+ maskImage: mask,
140
+ WebkitMaskImage: mask
141
+ } : void 0,
142
+ children
143
+ }
144
+ ),
145
+ overflowing && /* @__PURE__ */ jsx(
146
+ "button",
147
+ {
148
+ type: "button",
149
+ "aria-expanded": expanded,
150
+ "aria-controls": contentId,
151
+ onClick: () => setExpanded((e) => !e),
152
+ className: toggleClassName,
153
+ style: toggleClassName ? void 0 : {
154
+ marginTop: "0.25rem",
155
+ padding: 0,
156
+ border: "none",
157
+ background: "transparent",
158
+ color: "#94a3b8",
159
+ fontSize: "0.8rem",
160
+ cursor: "pointer",
161
+ textDecoration: "underline",
162
+ textUnderlineOffset: 2
163
+ },
164
+ children: expanded ? showLessLabel : showMoreLabel
165
+ }
166
+ )
167
+ ] });
168
+ }
169
+
170
+ // src/messages/MessageContent.tsx
171
+ import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
172
+ var mdComponents = {
173
+ p: ({ children }) => /* @__PURE__ */ jsx2("p", { className: markdownStyles.p, children }),
174
+ strong: ({ children }) => /* @__PURE__ */ jsx2("strong", { className: markdownStyles.strong, children }),
175
+ em: ({ children }) => /* @__PURE__ */ jsx2("em", { className: markdownStyles.em, children }),
176
+ code: ({ children }) => /* @__PURE__ */ jsx2("code", { className: markdownStyles.code, children }),
177
+ pre: ({ children }) => /* @__PURE__ */ jsx2("pre", { className: markdownStyles.pre, children }),
178
+ ul: ({ children }) => /* @__PURE__ */ jsx2("ul", { className: markdownStyles.ul, children }),
179
+ ol: ({ children }) => /* @__PURE__ */ jsx2("ol", { className: markdownStyles.ol, children }),
180
+ li: ({ children }) => /* @__PURE__ */ jsxs2("li", { className: markdownStyles.li, children: [
181
+ /* @__PURE__ */ jsx2("span", { className: markdownStyles.bullet, children: "\u2022" }),
182
+ /* @__PURE__ */ jsx2("span", { className: "flex-1", children })
183
+ ] }),
184
+ h1: ({ children }) => /* @__PURE__ */ jsx2("h1", { className: markdownStyles.h1, children }),
185
+ h2: ({ children }) => /* @__PURE__ */ jsx2("h2", { className: markdownStyles.h2, children }),
186
+ h3: ({ children }) => /* @__PURE__ */ jsx2("h3", { className: markdownStyles.h3, children }),
187
+ blockquote: ({ children }) => /* @__PURE__ */ jsx2("blockquote", { className: markdownStyles.blockquote, children }),
188
+ a: ({ href, children }) => /* @__PURE__ */ jsx2("a", { href, className: markdownStyles.link, target: "_blank", rel: "noopener noreferrer", children })
189
+ };
190
+ function defaultRenderMarkdown(content) {
191
+ return /* @__PURE__ */ jsx2(ReactMarkdown, { remarkPlugins: [remarkGfm], components: mdComponents, children: normalizeStreamedMarkdown(content) });
192
+ }
193
+ var MessageContent = memo(function MessageContent2({
194
+ isUser,
195
+ content,
196
+ isStreaming = false,
197
+ renderMarkdown = defaultRenderMarkdown,
198
+ collapsible = false,
199
+ collapsedMaxHeight,
200
+ showMoreLabel,
201
+ showLessLabel,
202
+ collapseToggleClassName
203
+ }) {
204
+ const { content: styles } = messageStyles;
205
+ const body = isUser ? (
206
+ // User: plain text, preserve whitespace
207
+ /* @__PURE__ */ jsx2("p", { className: "whitespace-pre-wrap", children: content })
208
+ ) : (
209
+ // Assistant: markdown (overridable)
210
+ renderMarkdown(content)
211
+ );
212
+ return /* @__PURE__ */ jsxs2(
213
+ "div",
214
+ {
215
+ className: `${styles.base} ${isUser ? styles.user : styles.assistant} ${styles.indent}`,
216
+ children: [
217
+ collapsible && !isStreaming ? /* @__PURE__ */ jsx2(
218
+ CollapsibleText,
219
+ {
220
+ maxHeight: collapsedMaxHeight,
221
+ showMoreLabel,
222
+ showLessLabel,
223
+ toggleClassName: collapseToggleClassName,
224
+ children: body
225
+ }
226
+ ) : body,
227
+ isStreaming && /* @__PURE__ */ jsx2("span", { className: "inline-block w-1.5 h-4 bg-amber-400/80 ml-0.5 animate-pulse rounded-sm" })
228
+ ]
229
+ }
230
+ );
231
+ });
232
+
233
+ // src/messages/CopyButton.tsx
234
+ import { memo as memo2, useCallback, useState as useState2 } from "react";
235
+ import { Copy, Check } from "lucide-react";
236
+ import { jsx as jsx3 } from "react/jsx-runtime";
237
+ var CopyButton = memo2(function CopyButton2({
238
+ content,
239
+ onError,
240
+ className,
241
+ idleClassName,
242
+ activeClassName,
243
+ iconClassName,
244
+ copyLabel = "Copiar",
245
+ copiedLabel = "Copiado",
246
+ resetMs = 2e3
247
+ }) {
248
+ const [copied, setCopied] = useState2(false);
249
+ const { actions } = messageStyles;
250
+ const base = className ?? actions.button.base;
251
+ const idle = idleClassName ?? actions.button.idle;
252
+ const active = activeClassName ?? actions.button.active;
253
+ const icon = iconClassName ?? actions.icon;
254
+ const handleCopy = useCallback(async () => {
255
+ try {
256
+ await navigator.clipboard.writeText(content);
257
+ setCopied(true);
258
+ setTimeout(() => setCopied(false), resetMs);
259
+ } catch (err) {
260
+ onError?.(err);
261
+ }
262
+ }, [content, onError, resetMs]);
263
+ return /* @__PURE__ */ jsx3(
264
+ "button",
265
+ {
266
+ onClick: handleCopy,
267
+ className: `${base} ${copied ? active : idle}`,
268
+ title: copied ? copiedLabel : copyLabel,
269
+ "aria-label": copied ? copiedLabel : `${copyLabel} mensaje`,
270
+ children: copied ? /* @__PURE__ */ jsx3(Check, { className: icon }) : /* @__PURE__ */ jsx3(Copy, { className: icon })
271
+ }
272
+ );
273
+ });
274
+
275
+ // src/messages/MessageBubble.tsx
276
+ import { memo as memo3 } from "react";
277
+ import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
278
+ var MessageBubble = memo3(function MessageBubble2({
279
+ role,
280
+ children,
281
+ header,
282
+ reasoning,
283
+ badge,
284
+ actions,
285
+ className,
286
+ ariaLabel
287
+ }) {
288
+ const { message: styles } = messageStyles;
289
+ const isUser = role === "user";
290
+ return /* @__PURE__ */ jsxs3(
291
+ "article",
292
+ {
293
+ className: `fi-msg-appear ${styles.base} ${styles.borderRadius} ${isUser ? styles.user : styles.assistant} ${className || ""}`,
294
+ role: "article",
295
+ "aria-label": ariaLabel,
296
+ children: [
297
+ header && /* @__PURE__ */ jsx4("div", { className: "flex items-center gap-2 mb-1", children: header }),
298
+ reasoning && /* @__PURE__ */ jsx4("div", { className: "mt-3 mb-3", children: reasoning }),
299
+ children,
300
+ badge && /* @__PURE__ */ jsx4("div", { className: "mt-2", children: badge }),
301
+ actions
302
+ ]
303
+ }
304
+ );
305
+ });
306
+
307
+ // src/messages/MessageList.tsx
308
+ import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
309
+ function MessageList({
310
+ groups,
311
+ renderItem,
312
+ renderDivider,
313
+ containerClassName,
314
+ groupClassName,
315
+ header,
316
+ footer
317
+ }) {
318
+ return /* @__PURE__ */ jsxs4("div", { className: containerClassName, children: [
319
+ header,
320
+ groups.map((group) => /* @__PURE__ */ jsxs4("div", { children: [
321
+ renderDivider?.(group.key),
322
+ /* @__PURE__ */ jsx5("div", { className: groupClassName, children: group.items.map((item, idx) => renderItem(item, idx)) })
323
+ ] }, group.key)),
324
+ footer
325
+ ] });
326
+ }
327
+ export {
328
+ CollapsibleText,
329
+ CopyButton,
330
+ MessageBubble,
331
+ MessageContent,
332
+ MessageList,
333
+ markdownStyles,
334
+ messageStyles,
335
+ normalizeStreamedMarkdown
336
+ };
337
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/messages/styles.ts","../../src/messages/MessageContent.tsx","../../src/messages/normalizeStreamedMarkdown.ts","../../src/messages/CollapsibleText.tsx","../../src/messages/CopyButton.tsx","../../src/messages/MessageBubble.tsx","../../src/messages/MessageList.tsx"],"sourcesContent":["/**\n * fi-glass · message style configuration\n * Copied verbatim from aurity ui/message/styles/message-styles.ts on 2026-06-01\n * (Plutonio). Class strings are identical so rendering is unchanged.\n *\n * Dense style inspired by Claude.ai / ChatGPT:\n * - No bubbles, text is protagonist\n * - Minimal spacing, subtle avatars\n *\n * NOTE: values are duplicated with aurity's local copy during the migration —\n * known debt, same call as the theme tokens. Apps override per-instance via the\n * className props on each primitive, so they never need to touch this file.\n */\nexport const messageStyles = {\n // Container\n container: {\n base: 'space-y-0.5',\n padding: 'px-4',\n },\n\n // Message row\n message: {\n base: 'group relative py-3 px-4 -mx-4 transition-colors duration-150',\n user: 'bg-transparent hover:bg-white/[0.02]',\n assistant: 'bg-white/[0.02] hover:bg-white/[0.04]',\n borderRadius: 'rounded-lg',\n },\n\n // Avatar\n avatar: {\n size: 'w-6 h-6',\n base: 'rounded-md flex items-center justify-center text-[10px] font-semibold flex-shrink-0',\n user: 'bg-violet-600/80 text-white',\n assistant: 'bg-amber-500/80 text-slate-900',\n },\n\n // Meta (name + time)\n meta: {\n container: 'flex items-baseline gap-2',\n name: 'text-[13px] font-medium text-slate-300',\n time: 'text-[11px] text-slate-500 tabular-nums',\n },\n\n // Content\n content: {\n base: 'text-[14px] leading-relaxed',\n user: 'text-slate-200',\n assistant: 'text-slate-100',\n indent: 'pl-8', // Align with avatar\n },\n\n // Actions toolbar\n actions: {\n container: `\n absolute top-2 right-2\n flex items-center gap-0.5\n opacity-0 group-hover:opacity-100\n transition-opacity duration-150\n bg-slate-800/95 backdrop-blur-sm rounded-md p-0.5\n border border-slate-700/50 shadow-lg\n `,\n button: {\n base: 'p-1 rounded transition-colors duration-150',\n idle: 'hover:bg-slate-700 text-slate-400 hover:text-slate-200',\n active: 'bg-emerald-500/20 text-emerald-400',\n speaking: 'bg-amber-500/20 text-amber-400',\n },\n icon: 'w-3 h-3',\n },\n\n // Date divider\n dateDivider: {\n container: 'my-4 flex items-center gap-3',\n line: 'flex-1 h-px bg-gradient-to-r from-transparent via-slate-700/30 to-transparent',\n label: 'px-3 py-1 text-[10px] text-slate-500 font-medium bg-slate-900/50 rounded-full',\n },\n\n // Typing indicator\n typing: {\n container: 'flex items-center gap-2 px-4 py-2',\n dot: 'w-1.5 h-1.5 bg-amber-400/80 rounded-full',\n animation: 'animate-bounce',\n },\n} as const;\n\n// Markdown component styles\nexport const markdownStyles = {\n p: 'mb-3 last:mb-0',\n strong: 'font-semibold text-white',\n em: 'italic text-slate-300',\n code: 'px-1 py-0.5 bg-slate-800/80 rounded text-amber-300/90 font-mono text-[13px]',\n pre: 'my-3 p-3 bg-slate-900/80 rounded-lg border border-slate-700/30 overflow-x-auto text-[13px]',\n ul: 'my-2 ml-0.5 space-y-1.5',\n ol: 'my-2 ml-0.5 space-y-1.5 list-decimal list-inside',\n li: 'flex gap-1.5 text-slate-200',\n bullet: 'text-slate-500 select-none text-[10px] mt-1',\n h1: 'text-lg font-semibold text-white mt-4 mb-2',\n h2: 'text-base font-semibold text-white mt-3 mb-1.5',\n h3: 'text-sm font-semibold text-slate-100 mt-2 mb-1',\n blockquote: 'my-3 pl-3 border-l-2 border-slate-600/50 text-slate-400 italic text-[13px]',\n link: 'text-amber-400/90 hover:text-amber-300 underline underline-offset-2 transition-colors',\n} as const;\n","'use client';\n\n/**\n * fi-glass · MessageContent — rendered message body primitive.\n *\n * User messages: plain text (whitespace preserved).\n * Assistant messages: markdown (react-markdown + remark-gfm by default).\n *\n * CONFIGURABILITY (fire test): an app swaps the markdown engine via the\n * `renderMarkdown` slot without touching fi-glass. Default reproduces aurity's\n * exact markdown component overrides.\n */\n\nimport { memo, type ReactNode } from 'react';\nimport ReactMarkdown, { type Components } from 'react-markdown';\nimport remarkGfm from 'remark-gfm';\nimport { messageStyles, markdownStyles } from './styles';\nimport { normalizeStreamedMarkdown } from './normalizeStreamedMarkdown';\nimport { CollapsibleText } from './CollapsibleText';\n\nexport interface MessageContentProps {\n /** Is this a user message */\n isUser: boolean;\n /** Message content */\n content: string;\n /** Show streaming cursor */\n isStreaming?: boolean;\n /** Override how assistant content is rendered (default: markdown). */\n renderMarkdown?: (content: string) => ReactNode;\n /**\n * B3-FIGLASS-12 — clamp long content behind a \"show more\" disclosure\n * (ChatGPT parity for long pasted user messages). Never combine with\n * `isStreaming`: a live answer must stay fully visible while it grows.\n */\n collapsible?: boolean;\n /** Collapsed max height in px when `collapsible`. Default 264. */\n collapsedMaxHeight?: number;\n /** Disclosure copy (app-owned). Defaults: \"Mostrar más\" / \"Mostrar menos\". */\n showMoreLabel?: string;\n showLessLabel?: string;\n /** Class for the disclosure toggle button. */\n collapseToggleClassName?: string;\n}\n\n/** Default markdown component overrides (glass styling).\n * Props are inferred from the Partial<Components> context so each slot\n * accepts ExtraProps (node?) without an explicit annotation. */\nconst mdComponents: Partial<Components> = {\n p: ({ children }) => <p className={markdownStyles.p}>{children}</p>,\n strong: ({ children }) => <strong className={markdownStyles.strong}>{children}</strong>,\n em: ({ children }) => <em className={markdownStyles.em}>{children}</em>,\n code: ({ children }) => <code className={markdownStyles.code}>{children}</code>,\n pre: ({ children }) => <pre className={markdownStyles.pre}>{children}</pre>,\n ul: ({ children }) => <ul className={markdownStyles.ul}>{children}</ul>,\n ol: ({ children }) => <ol className={markdownStyles.ol}>{children}</ol>,\n li: ({ children }) => (\n <li className={markdownStyles.li}>\n <span className={markdownStyles.bullet}>•</span>\n <span className=\"flex-1\">{children}</span>\n </li>\n ),\n h1: ({ children }) => <h1 className={markdownStyles.h1}>{children}</h1>,\n h2: ({ children }) => <h2 className={markdownStyles.h2}>{children}</h2>,\n h3: ({ children }) => <h3 className={markdownStyles.h3}>{children}</h3>,\n blockquote: ({ children }) => <blockquote className={markdownStyles.blockquote}>{children}</blockquote>,\n a: ({ href, children }) => (\n <a href={href} className={markdownStyles.link} target=\"_blank\" rel=\"noopener noreferrer\">\n {children}\n </a>\n ),\n};\n\nfunction defaultRenderMarkdown(content: string): ReactNode {\n return (\n <ReactMarkdown remarkPlugins={[remarkGfm]} components={mdComponents}>\n {/* B3-FIGLASS-9: repair chunk-boundary glue (e.g. \"fin.## Título\") so a\n heading the stream stuck onto the previous sentence still renders as a\n heading. Pure + fence-safe; see normalizeStreamedMarkdown. */}\n {normalizeStreamedMarkdown(content)}\n </ReactMarkdown>\n );\n}\n\nexport const MessageContent = memo(function MessageContent({\n isUser,\n content,\n isStreaming = false,\n renderMarkdown = defaultRenderMarkdown,\n collapsible = false,\n collapsedMaxHeight,\n showMoreLabel,\n showLessLabel,\n collapseToggleClassName,\n}: MessageContentProps) {\n const { content: styles } = messageStyles;\n\n const body = isUser ? (\n // User: plain text, preserve whitespace\n <p className=\"whitespace-pre-wrap\">{content}</p>\n ) : (\n // Assistant: markdown (overridable)\n renderMarkdown(content)\n );\n\n return (\n <div\n className={`${styles.base} ${isUser ? styles.user : styles.assistant} ${styles.indent}`}\n >\n {collapsible && !isStreaming ? (\n <CollapsibleText\n maxHeight={collapsedMaxHeight}\n showMoreLabel={showMoreLabel}\n showLessLabel={showLessLabel}\n toggleClassName={collapseToggleClassName}\n >\n {body}\n </CollapsibleText>\n ) : (\n body\n )}\n\n {/* Streaming cursor */}\n {isStreaming && (\n <span className=\"inline-block w-1.5 h-4 bg-amber-400/80 ml-0.5 animate-pulse rounded-sm\" />\n )}\n </div>\n );\n});\n","/**\n * normalizeStreamedMarkdown — repair chunk-boundary glue in streamed LLM output\n * before markdown rendering (B3-FIGLASS-9).\n *\n * The staging audit showed an assistant reply rendering \"…las herramientas\n * necesarias.## Respuesta sobre…\" — the backend concatenated the pre-tool text\n * and the post-tool response without a newline, so the ATX heading never starts\n * a line and CommonMark (correctly) treats it as paragraph text.\n *\n * This is a NORMALIZER, not a parser: one conservative repair, applied only\n * outside fenced code blocks.\n *\n * Repair rule: a heading marker (`#{1,6} `) glued directly onto sentence-ending\n * punctuation gets a blank line inserted before it. Requiring the punctuation\n * (no whitespace in between) is what keeps false positives out:\n * - `C# is nice` → untouched (letter before `#`)\n * - `issue #123` → untouched (no space after `#`)\n * - `use the # key` → untouched (whitespace before `#`)\n * - `fin.## Título` → `fin.\\n\\n## Título` (the streaming-glue case)\n */\n\n/** Split keeping fences as odd segments. An unterminated fence (streaming!) runs to the end. */\nconst FENCE_SPLIT = /(```[\\s\\S]*?(?:```|$))/;\n\n/** Sentence punctuation immediately followed by an ATX heading marker. */\nconst GLUED_HEADING = /([.!?:;,)\\]\"'»…])(#{1,6} )/g;\n\nexport function normalizeStreamedMarkdown(content: string): string {\n if (!content.includes('#')) return content;\n return content\n .split(FENCE_SPLIT)\n .map((segment, i) =>\n i % 2 === 1 ? segment : segment.replace(GLUED_HEADING, '$1\\n\\n$2'),\n )\n .join('');\n}\n","'use client';\n\n/**\n * fi-glass · CollapsibleText — ChatGPT-style disclosure clamp for long content.\n *\n * Long content is clamped to `maxHeight` with a CSS mask-image gradient fading\n * out the last `fadeHeight` pixels (the text itself fades — no overlay), plus a\n * \"show more / show less\" toggle wired as a WAI-ARIA disclosure\n * (aria-expanded + aria-controls). Reverse-engineered from chatgpt.com's\n * collapsed user messages (max-height 264px = 11 lines × 24px leading,\n * mask-image linear-gradient over the final 48px).\n *\n * Measurement is content-driven: a ResizeObserver compares scrollHeight against\n * the clamp, so the toggle only renders when the content actually overflows.\n * SSR-safe — the first paint renders unclamped and clamps on mount.\n */\n\nimport { useEffect, useId, useRef, useState, type ReactNode } from 'react';\n\n// A message one line over the clamp reads better whole than clamped with a\n// toggle that reveals a single hidden line — so overflow only counts past this.\nconst OVERFLOW_TOLERANCE_PX = 16;\n\nexport interface CollapsibleTextProps {\n children: ReactNode;\n /** Collapsed max height in px. Default 264 (11 lines at 24px leading). */\n maxHeight?: number;\n /** Height in px of the fade-out mask at the bottom of clamped content. Default 48. */\n fadeHeight?: number;\n /** Toggle copy when collapsed. Default: \"Mostrar más\". */\n showMoreLabel?: string;\n /** Toggle copy when expanded. Default: \"Mostrar menos\". */\n showLessLabel?: string;\n /** Wrapper class (style hook for the app). */\n className?: string;\n /** Toggle button class. When set, the unstyled default is dropped. */\n toggleClassName?: string;\n}\n\nexport function CollapsibleText({\n children,\n maxHeight = 264,\n fadeHeight = 48,\n showMoreLabel = 'Mostrar más',\n showLessLabel = 'Mostrar menos',\n className,\n toggleClassName,\n}: CollapsibleTextProps) {\n const contentId = useId();\n const contentRef = useRef<HTMLDivElement>(null);\n const [expanded, setExpanded] = useState(false);\n const [overflowing, setOverflowing] = useState(false);\n\n useEffect(() => {\n const el = contentRef.current;\n if (!el) return;\n const measure = () =>\n setOverflowing(el.scrollHeight > maxHeight + OVERFLOW_TOLERANCE_PX);\n measure();\n if (typeof ResizeObserver === 'undefined') return;\n const ro = new ResizeObserver(measure);\n ro.observe(el);\n return () => ro.disconnect();\n }, [maxHeight]);\n\n const clamped = overflowing && !expanded;\n const mask = `linear-gradient(rgb(0,0,0) calc(100% - ${fadeHeight}px), transparent)`;\n\n return (\n <div className={className}>\n <div\n id={contentId}\n ref={contentRef}\n style={\n clamped\n ? {\n maxHeight,\n overflow: 'hidden',\n maskImage: mask,\n WebkitMaskImage: mask,\n }\n : undefined\n }\n >\n {children}\n </div>\n {overflowing && (\n <button\n type=\"button\"\n aria-expanded={expanded}\n aria-controls={contentId}\n onClick={() => setExpanded((e) => !e)}\n className={toggleClassName}\n style={\n toggleClassName\n ? undefined\n : {\n marginTop: '0.25rem',\n padding: 0,\n border: 'none',\n background: 'transparent',\n color: '#94a3b8',\n fontSize: '0.8rem',\n cursor: 'pointer',\n textDecoration: 'underline',\n textUnderlineOffset: 2,\n }\n }\n >\n {expanded ? showLessLabel : showMoreLabel}\n </button>\n )}\n </div>\n );\n}\n","'use client';\n\n/**\n * fi-glass · CopyButton — copy-to-clipboard action with check feedback.\n *\n * Pure primitive: Clipboard API + lucide icons. No app dependencies.\n *\n * CONFIGURABILITY (fire test): an app restyles via className props, relabels via\n * label props, handles failures via `onError`, or drops it entirely (just don't\n * render it) — all without touching fi-glass. Defaults reproduce aurity's exact\n * copy-button look and 2s reset.\n */\n\nimport { memo, useCallback, useState } from 'react';\nimport { Copy, Check } from 'lucide-react';\nimport { messageStyles } from './styles';\n\nexport interface CopyButtonProps {\n /** Text to copy to the clipboard. */\n content: string;\n /** Called if the Clipboard API rejects (default: silent). */\n onError?: (error: unknown) => void;\n /** Override the button base class. */\n className?: string;\n /** Override the idle-state class. */\n idleClassName?: string;\n /** Override the copied-state class. */\n activeClassName?: string;\n /** Override the icon class. */\n iconClassName?: string;\n /** Tooltip/label before copy (default: \"Copiar\"). */\n copyLabel?: string;\n /** Tooltip/label after copy (default: \"Copiado\"). */\n copiedLabel?: string;\n /** Milliseconds before the check resets to copy (default: 2000). */\n resetMs?: number;\n}\n\nexport const CopyButton = memo(function CopyButton({\n content,\n onError,\n className,\n idleClassName,\n activeClassName,\n iconClassName,\n copyLabel = 'Copiar',\n copiedLabel = 'Copiado',\n resetMs = 2000,\n}: CopyButtonProps) {\n const [copied, setCopied] = useState(false);\n const { actions } = messageStyles;\n\n const base = className ?? actions.button.base;\n const idle = idleClassName ?? actions.button.idle;\n const active = activeClassName ?? actions.button.active;\n const icon = iconClassName ?? actions.icon;\n\n const handleCopy = useCallback(async () => {\n try {\n await navigator.clipboard.writeText(content);\n setCopied(true);\n setTimeout(() => setCopied(false), resetMs);\n } catch (err) {\n onError?.(err);\n }\n }, [content, onError, resetMs]);\n\n return (\n <button\n onClick={handleCopy}\n className={`${base} ${copied ? active : idle}`}\n title={copied ? copiedLabel : copyLabel}\n aria-label={copied ? copiedLabel : `${copyLabel} mensaje`}\n >\n {copied ? <Check className={icon} /> : <Copy className={icon} />}\n </button>\n );\n});\n","'use client';\n\n/**\n * fi-glass · MessageBubble — generic message layout shell.\n *\n * Reproduces aurity's `<article>` message row EXACTLY, but every app-specific\n * region is a slot. The bubble owns ONLY structure + spacing; it knows nothing\n * about auth, personas, TTS, reasoning, or model badges.\n *\n * CONFIGURABILITY (fire test): turn off any region by passing nothing; change\n * any region's content by passing your own node. Nothing here needs editing to\n * reshape a message.\n *\n * header → avatar + author/meta row (omit to hide)\n * reasoning→ chain-of-thought block (omit to hide)\n * children → the message body (required: e.g. <MessageContent/>)\n * badge → model/provenance chip (omit to hide)\n * actions → hover toolbar (copy, TTS…) (omit to hide)\n */\n\nimport { memo, type ReactNode } from 'react';\nimport { messageStyles } from './styles';\n\nexport interface MessageBubbleProps {\n /** Drives alignment/background (user vs assistant). */\n role: 'user' | 'assistant';\n /** The message body (required). */\n children: ReactNode;\n /** Avatar + author/timestamp row. */\n header?: ReactNode;\n /** Reasoning / chain-of-thought block (rendered above the body). */\n reasoning?: ReactNode;\n /** Badge/chip rendered below the body (e.g. model, sources). */\n badge?: ReactNode;\n /** Hover action toolbar (e.g. copy, speak). */\n actions?: ReactNode;\n /** Extra classes appended to the article. */\n className?: string;\n /** Accessible label for the article. */\n ariaLabel?: string;\n}\n\nexport const MessageBubble = memo(function MessageBubble({\n role,\n children,\n header,\n reasoning,\n badge,\n actions,\n className,\n ariaLabel,\n}: MessageBubbleProps) {\n const { message: styles } = messageStyles;\n const isUser = role === 'user';\n\n return (\n <article\n // fi-msg-appear: 0.3s opacity fade-in on mount (B3-FIGLASS-12, ChatGPT\n // parity). Defined in theme/glass-chat.css — a consumer that doesn't\n // import it gets an instant appear (graceful no-op). Opacity only: a\n // transform here would suppress native CSS scroll anchoring.\n className={`fi-msg-appear ${styles.base} ${styles.borderRadius} ${isUser ? styles.user : styles.assistant} ${className || ''}`}\n role=\"article\"\n aria-label={ariaLabel}\n >\n {header && <div className=\"flex items-center gap-2 mb-1\">{header}</div>}\n\n {reasoning && <div className=\"mt-3 mb-3\">{reasoning}</div>}\n\n {children}\n\n {badge && <div className=\"mt-2\">{badge}</div>}\n\n {actions}\n </article>\n );\n});\n","'use client';\n\n/**\n * fi-glass · MessageList — generic grouped message container.\n *\n * Structure only: it maps pre-grouped items to rows and positions an optional\n * divider per group plus header/footer slots. It owns NO data logic — grouping,\n * streaming rows, typing indicators, and scroll all stay in the app and arrive\n * via slots. Generic over the item type so it never depends on a message shape.\n *\n * CONFIGURABILITY (fire test): the app controls grouping (`groups`), how each\n * item renders (`renderItem`), dividers (`renderDivider`), and everything below\n * the list (`footer`) — without touching fi-glass.\n */\n\nimport { type ReactNode } from 'react';\n\nexport interface MessageListGroup<T> {\n /** Stable key for the group (also passed to renderDivider). */\n key: string;\n /** Items belonging to this group. */\n items: T[];\n}\n\nexport interface MessageListProps<T> {\n /** Pre-grouped items (app decides the grouping strategy). */\n groups: MessageListGroup<T>[];\n /** Render a single item. Return value should carry its own React key. */\n renderItem: (item: T, index: number) => ReactNode;\n /** Optional per-group divider (e.g. a date separator). */\n renderDivider?: (key: string) => ReactNode;\n /** Class for the scroll/list container. */\n containerClassName?: string;\n /** Class for each group's inner item wrapper. */\n groupClassName?: string;\n /** Slot rendered before the groups. */\n header?: ReactNode;\n /** Slot rendered after the groups (streaming row, typing dots, spacer…). */\n footer?: ReactNode;\n}\n\nexport function MessageList<T>({\n groups,\n renderItem,\n renderDivider,\n containerClassName,\n groupClassName,\n header,\n footer,\n}: MessageListProps<T>) {\n return (\n <div className={containerClassName}>\n {header}\n\n {groups.map((group) => (\n <div key={group.key}>\n {renderDivider?.(group.key)}\n <div className={groupClassName}>\n {group.items.map((item, idx) => renderItem(item, idx))}\n </div>\n </div>\n ))}\n\n {footer}\n </div>\n );\n}\n"],"mappings":";AAaO,IAAM,gBAAgB;AAAA;AAAA,EAE3B,WAAW;AAAA,IACT,MAAM;AAAA,IACN,SAAS;AAAA,EACX;AAAA;AAAA,EAGA,SAAS;AAAA,IACP,MAAM;AAAA,IACN,MAAM;AAAA,IACN,WAAW;AAAA,IACX,cAAc;AAAA,EAChB;AAAA;AAAA,EAGA,QAAQ;AAAA,IACN,MAAM;AAAA,IACN,MAAM;AAAA,IACN,MAAM;AAAA,IACN,WAAW;AAAA,EACb;AAAA;AAAA,EAGA,MAAM;AAAA,IACJ,WAAW;AAAA,IACX,MAAM;AAAA,IACN,MAAM;AAAA,EACR;AAAA;AAAA,EA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MAEX;AAAA,kBAAU,gBAAAD,KAAC,SAAI,WAAU,gCAAgC,kBAAO;AAAA,QAEhE,aAAa,gBAAAA,KAAC,SAAI,WAAU,aAAa,qBAAU;AAAA,QAEnD;AAAA,QAEA,SAAS,gBAAAA,KAAC,SAAI,WAAU,QAAQ,iBAAM;AAAA,QAEtC;AAAA;AAAA;AAAA,EACH;AAEJ,CAAC;;;ACrBO,SAEE,OAAAI,MAFF,QAAAC,aAAA;AAdD,SAAS,YAAe;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAwB;AACtB,SACE,gBAAAA,MAAC,SAAI,WAAW,oBACb;AAAA;AAAA,IAEA,OAAO,IAAI,CAAC,UACX,gBAAAA,MAAC,SACE;AAAA,sBAAgB,MAAM,GAAG;AAAA,MAC1B,gBAAAD,KAAC,SAAI,WAAW,gBACb,gBAAM,MAAM,IAAI,CAAC,MAAM,QAAQ,WAAW,MAAM,GAAG,CAAC,GACvD;AAAA,SAJQ,MAAM,GAKhB,CACD;AAAA,IAEA;AAAA,KACH;AAEJ;","names":["jsx","jsxs","MessageContent","memo","useState","jsx","memo","CopyButton","useState","memo","jsx","jsxs","memo","MessageBubble","jsx","jsxs"]}
@@ -0,0 +1,54 @@
1
+ import * as react from 'react';
2
+ import { ReactNode } from 'react';
3
+
4
+ interface PersonaSlotContext {
5
+ /** Whether the persona this slot renders is the selected one. */
6
+ selected: boolean;
7
+ }
8
+ interface PersonaSelectorProps<T> {
9
+ /** Available personas (opaque to fi-glass). */
10
+ personas: T[];
11
+ /** Currently selected persona id. */
12
+ selected: string;
13
+ /** Called with the chosen persona id. */
14
+ onSelect: (personaId: string) => void;
15
+ /** How to read the stable id off a persona. */
16
+ getPersonaId: (persona: T) => string;
17
+ /** Loading state — renders renderLoading() (or a minimal default). */
18
+ loading?: boolean;
19
+ /** The persona label shown in the option row. */
20
+ getPersonaLabel?: (persona: T) => ReactNode;
21
+ /** Optional description line under the label. */
22
+ getPersonaDescription?: (persona: T) => ReactNode;
23
+ /** Leading icon for the option row. Receives `{ selected }` for state color. */
24
+ renderPersonaIcon?: (persona: T, ctx: PersonaSlotContext) => ReactNode;
25
+ /** Badge (e.g. model · voice) for the option row. */
26
+ renderPersonaBadge?: (persona: T, ctx: PersonaSlotContext) => ReactNode;
27
+ /** Metadata chips row (e.g. temp / tokens). */
28
+ renderPersonaMeta?: (persona: T) => ReactNode;
29
+ /** The trigger's inner content (before the chevron). Defaults to placeholder. */
30
+ renderTriggerValue?: (selected: T | undefined, isOpen: boolean) => ReactNode;
31
+ /** Dropdown header (e.g. title + count). */
32
+ renderHeader?: (ctx: {
33
+ count: number;
34
+ }) => ReactNode;
35
+ /** Dropdown footer (e.g. an "edit personas" link). `close()` shuts the menu. */
36
+ renderFooter?: (ctx: {
37
+ close: () => void;
38
+ }) => ReactNode;
39
+ /** Loading-state renderer (default: minimal text). */
40
+ renderLoading?: () => ReactNode;
41
+ /** Trigger content when nothing is selected and no renderTriggerValue given. */
42
+ placeholder?: ReactNode;
43
+ /** Root wrapper class. */
44
+ className?: string;
45
+ /** Trigger button class — pass the exact legacy string for byte-identical look. */
46
+ triggerClassName?: string;
47
+ /** Extra class appended to the portalled content panel. */
48
+ contentClassName?: string;
49
+ /** Accessible label for the trigger. */
50
+ ariaLabel?: string;
51
+ }
52
+ declare function PersonaSelector<T>({ personas, selected, onSelect, getPersonaId, loading, getPersonaLabel, getPersonaDescription, renderPersonaIcon, renderPersonaBadge, renderPersonaMeta, renderTriggerValue, renderHeader, renderFooter, renderLoading, placeholder, className, triggerClassName, contentClassName, ariaLabel, }: PersonaSelectorProps<T>): react.JSX.Element;
53
+
54
+ export { PersonaSelector, type PersonaSelectorProps, type PersonaSlotContext };