@anvia/react-ui 0.4.3 → 0.5.1

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 (42) hide show
  1. package/dist/attachment/index.js +2 -2
  2. package/dist/chat/index.d.ts +3 -2
  3. package/dist/chat/index.js +4 -4
  4. package/dist/{chunk-657E5BPN.js → chunk-2N5PXLAS.js} +2 -2
  5. package/dist/{chunk-GXB4VINL.js → chunk-GZHTC36V.js} +7 -11
  6. package/dist/chunk-GZHTC36V.js.map +1 -0
  7. package/dist/{chunk-JUNV3MUR.js → chunk-KNOZLODL.js} +7 -6
  8. package/dist/chunk-KNOZLODL.js.map +1 -0
  9. package/dist/{chunk-SE7I6ZXJ.js → chunk-NGEDM4XU.js} +10 -10
  10. package/dist/chunk-NGEDM4XU.js.map +1 -0
  11. package/dist/{chunk-7L2C5UUZ.js → chunk-SWGMBZR2.js} +56 -48
  12. package/dist/chunk-SWGMBZR2.js.map +1 -0
  13. package/dist/{chunk-TOBAQM2G.js → chunk-T6GPGCK4.js} +2 -2
  14. package/dist/{chunk-32QFNRXR.js → chunk-WUMACFYS.js} +2 -2
  15. package/dist/{chunk-BCCU3VT5.js → chunk-YQJLVBQD.js} +1 -1
  16. package/dist/chunk-YQJLVBQD.js.map +1 -0
  17. package/dist/chunk-ZODMCETL.js +996 -0
  18. package/dist/chunk-ZODMCETL.js.map +1 -0
  19. package/dist/completion/index.js +2 -2
  20. package/dist/{thread-C2-Xo08o.d.ts → composer-CzsbDFPt.d.ts} +7 -10
  21. package/dist/human-input/index.js +2 -2
  22. package/dist/image/index.js +2 -2
  23. package/dist/index.d.ts +3 -2
  24. package/dist/index.js +11 -11
  25. package/dist/message/index.d.ts +11 -1
  26. package/dist/message/index.js +3 -3
  27. package/dist/selection-toolbar/index.js +2 -2
  28. package/dist/shared.d.ts +2 -1
  29. package/dist/shared.js +1 -1
  30. package/dist/thread-list/index.js +2 -2
  31. package/dist/thread-uEm8hH0s.d.ts +11 -0
  32. package/package.json +2 -2
  33. package/dist/chunk-7L2C5UUZ.js.map +0 -1
  34. package/dist/chunk-BCCU3VT5.js.map +0 -1
  35. package/dist/chunk-GXB4VINL.js.map +0 -1
  36. package/dist/chunk-JUNV3MUR.js.map +0 -1
  37. package/dist/chunk-LWH6BMAD.js +0 -580
  38. package/dist/chunk-LWH6BMAD.js.map +0 -1
  39. package/dist/chunk-SE7I6ZXJ.js.map +0 -1
  40. /package/dist/{chunk-657E5BPN.js.map → chunk-2N5PXLAS.js.map} +0 -0
  41. /package/dist/{chunk-TOBAQM2G.js.map → chunk-T6GPGCK4.js.map} +0 -0
  42. /package/dist/{chunk-32QFNRXR.js.map → chunk-WUMACFYS.js.map} +0 -0
@@ -1,580 +0,0 @@
1
- import {
2
- Attachment
3
- } from "./chunk-32QFNRXR.js";
4
- import {
5
- renderPrimitive
6
- } from "./chunk-T3ZFZ3NP.js";
7
- import {
8
- InternalAttachmentProvider,
9
- InternalMessagePartProvider,
10
- useChatContext,
11
- useMessage,
12
- useMessagePart,
13
- useOptionalMessagePart
14
- } from "./chunk-BCCU3VT5.js";
15
-
16
- // src/message/actions.tsx
17
- import { forwardRef, useCallback, useEffect, useRef, useState } from "react";
18
-
19
- // src/format/message.ts
20
- function messageText(message) {
21
- return message.parts.filter((part) => part.type === "text").map((part) => part.text).join("");
22
- }
23
-
24
- // src/format/value.ts
25
- function stringifyValue(value) {
26
- if (value === void 0) {
27
- return "";
28
- }
29
- if (typeof value === "string") {
30
- return value;
31
- }
32
- try {
33
- return JSON.stringify(value, null, 2);
34
- } catch {
35
- return String(value);
36
- }
37
- }
38
-
39
- // src/message/actions.tsx
40
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
41
- var MessageActions = forwardRef(
42
- function MessageActions2(props, ref) {
43
- return renderPrimitive(
44
- "div",
45
- {
46
- ...props,
47
- children: props.children ?? /* @__PURE__ */ jsxs(Fragment, { children: [
48
- /* @__PURE__ */ jsx(MessageCopy, {}),
49
- /* @__PURE__ */ jsx(MessageRegenerate, {})
50
- ] }),
51
- "data-anvia-message-actions": ""
52
- },
53
- ref
54
- );
55
- }
56
- );
57
- var MessageCopy = forwardRef(function MessageCopy2({ onClick, ...props }, ref) {
58
- const { message } = useMessage();
59
- const [copyState, setCopyState] = useState("idle");
60
- const text = messageText(message);
61
- const previousTextRef = useRef(text);
62
- const disabled = props.disabled ?? text.length === 0;
63
- useEffect(() => {
64
- if (previousTextRef.current !== text) {
65
- previousTextRef.current = text;
66
- setCopyState("idle");
67
- }
68
- }, [text]);
69
- const handleClick = useCallback(
70
- async (event) => {
71
- onClick?.(event);
72
- if (event.defaultPrevented || disabled) {
73
- return;
74
- }
75
- const writeText = navigator.clipboard?.writeText;
76
- if (writeText === void 0) {
77
- setCopyState("error");
78
- return;
79
- }
80
- try {
81
- await writeText.call(navigator.clipboard, text);
82
- setCopyState("copied");
83
- } catch {
84
- setCopyState("error");
85
- }
86
- },
87
- [disabled, onClick, text]
88
- );
89
- return renderPrimitive(
90
- "button",
91
- {
92
- ...props,
93
- children: props.children ?? "Copy",
94
- disabled,
95
- onClick: handleClick,
96
- type: props.type ?? "button",
97
- "data-anvia-copy": "",
98
- "data-state": copyState
99
- },
100
- ref
101
- );
102
- });
103
- var MessageRegenerate = forwardRef(
104
- function MessageRegenerate2({ onClick, ...props }, ref) {
105
- const chat = useChatContext();
106
- const { message } = useMessage();
107
- const latestAssistantMessage = [...chat.messages].reverse().find((item) => item.role === "assistant");
108
- const disabled = props.disabled ?? (chat.status === "streaming" || message.role !== "assistant" || latestAssistantMessage?.id !== message.id);
109
- const handleClick = useCallback(
110
- (event) => {
111
- onClick?.(event);
112
- if (event.defaultPrevented || disabled) {
113
- return;
114
- }
115
- void chat.regenerate();
116
- },
117
- [chat, disabled, onClick]
118
- );
119
- return renderPrimitive(
120
- "button",
121
- {
122
- ...props,
123
- children: props.children ?? "Regenerate",
124
- disabled,
125
- onClick: handleClick,
126
- type: props.type ?? "button",
127
- "data-anvia-regenerate": "",
128
- "data-state": disabled ? "disabled" : "idle"
129
- },
130
- ref
131
- );
132
- }
133
- );
134
-
135
- // src/message/parts.tsx
136
- import {
137
- useSmoothStreamText
138
- } from "@anvia/react";
139
- import { forwardRef as forwardRef2 } from "react";
140
- import ReactMarkdown from "react-markdown";
141
- import remarkGfm from "remark-gfm";
142
- import { Fragment as Fragment2, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
143
- var MessageParts = forwardRef2(function MessageParts2({ children, filter, ...props }, ref) {
144
- const { message } = useMessage();
145
- const parts = filter === void 0 ? message.parts : message.parts.filter(filter);
146
- return renderPrimitive(
147
- "div",
148
- {
149
- ...props,
150
- children: parts.map((part) => /* @__PURE__ */ jsx2(InternalMessagePartProvider, { part, children: typeof children === "function" ? children(part) : children ?? /* @__PURE__ */ jsx2(MessagePart, {}) }, part.id)),
151
- "data-anvia-message-parts": ""
152
- },
153
- ref
154
- );
155
- });
156
- var MessagePart = forwardRef2(function MessagePart2({ children, ...props }, ref) {
157
- const { part } = useMessagePart();
158
- const renderedChildren = typeof children === "function" ? children(part) : children ?? defaultPart(part);
159
- return renderPrimitive(
160
- "div",
161
- {
162
- ...props,
163
- children: renderedChildren,
164
- "data-anvia-part": "",
165
- "data-part": part.type
166
- },
167
- ref
168
- );
169
- });
170
- var MessageText = forwardRef2(function MessageText2(props, ref) {
171
- const { part } = useMessagePart();
172
- if (part.type !== "text") {
173
- return null;
174
- }
175
- return /* @__PURE__ */ jsx2(MessageTextContent, { ...props, content: part.text, ref });
176
- });
177
- var MessageTextContent = forwardRef2(
178
- function MessageTextContent2({
179
- animate = false,
180
- animationMode = "smooth",
181
- isStreaming,
182
- smoothingPreset,
183
- reducedMotion,
184
- content,
185
- ...props
186
- }, ref) {
187
- const animationEnabled = animate && props.children === void 0;
188
- const smooth = useSmoothStreamText(content, {
189
- enabled: animationEnabled,
190
- mode: animationMode,
191
- ...isStreaming === void 0 ? {} : { isStreaming },
192
- ...smoothingPreset === void 0 ? {} : { preset: smoothingPreset },
193
- ...reducedMotion === void 0 ? {} : { reducedMotion }
194
- });
195
- const animationActive = animationEnabled && animationMode !== "none" && isStreaming !== false && reducedMotion !== true;
196
- return renderPrimitive(
197
- "span",
198
- {
199
- ...props,
200
- children: props.children ?? (animationEnabled ? smooth.text : content),
201
- "data-anvia-text": "",
202
- "data-anvia-stream-animation": animationEnabled ? animationMode : void 0,
203
- "data-streaming": animationActive ? "" : void 0
204
- },
205
- ref
206
- );
207
- }
208
- );
209
- var MessageMarkdown = forwardRef2(function MessageMarkdown2({ children, ...props }, ref) {
210
- const { message } = useMessage();
211
- const partContext = useOptionalMessagePart();
212
- const part = partContext?.part;
213
- if (part !== void 0 && part.type !== "text") {
214
- return null;
215
- }
216
- const markdown = children ?? (part?.type === "text" ? part.text : message.parts.flatMap((item) => item.type === "text" ? [item.text] : []).join("\n\n"));
217
- return /* @__PURE__ */ jsx2(MessageMarkdownContent, { ...props, markdown, ref });
218
- });
219
- var MessageMarkdownContent = forwardRef2(
220
- function MessageMarkdownContent2({
221
- animate = false,
222
- animationMode = "smooth",
223
- isStreaming,
224
- smoothingPreset,
225
- reducedMotion,
226
- components,
227
- remarkPlugins,
228
- markdown,
229
- ...props
230
- }, ref) {
231
- const smooth = useSmoothStreamText(markdown, {
232
- enabled: animate,
233
- mode: animationMode,
234
- ...isStreaming === void 0 ? {} : { isStreaming },
235
- ...smoothingPreset === void 0 ? {} : { preset: smoothingPreset },
236
- ...reducedMotion === void 0 ? {} : { reducedMotion }
237
- });
238
- const animationActive = animate && animationMode !== "none" && isStreaming !== false && reducedMotion !== true;
239
- return renderPrimitive(
240
- "div",
241
- {
242
- ...props,
243
- children: /* @__PURE__ */ jsx2(
244
- ReactMarkdown,
245
- {
246
- components: { code: defaultCodeComponent, pre: defaultPreComponent, ...components },
247
- remarkPlugins: remarkPlugins ?? [remarkGfm],
248
- children: animate ? smooth.text : markdown
249
- }
250
- ),
251
- "data-anvia-markdown": "",
252
- "data-anvia-stream-animation": animate ? animationMode : void 0,
253
- "data-streaming": animationActive ? "" : void 0
254
- },
255
- ref
256
- );
257
- }
258
- );
259
- var MessageCodeBlock = forwardRef2(
260
- function MessageCodeBlock2({ children, code, language, ...props }, ref) {
261
- return renderPrimitive(
262
- "pre",
263
- {
264
- ...props,
265
- children: children ?? /* @__PURE__ */ jsx2("code", { "data-anvia-code": "", "data-language": language, children: code ?? "" }),
266
- "data-anvia-code-block": "",
267
- "data-language": language
268
- },
269
- ref
270
- );
271
- }
272
- );
273
- var MessageReasoning = forwardRef2(
274
- function MessageReasoning2(props, ref) {
275
- const { part } = useMessagePart();
276
- if (part.type !== "reasoning") {
277
- return null;
278
- }
279
- return renderPrimitive(
280
- "details",
281
- {
282
- ...props,
283
- children: props.children ?? /* @__PURE__ */ jsxs2(Fragment2, { children: [
284
- /* @__PURE__ */ jsx2("summary", { children: "Reasoning" }),
285
- /* @__PURE__ */ jsx2("pre", { children: part.text })
286
- ] }),
287
- "data-anvia-reasoning": ""
288
- },
289
- ref
290
- );
291
- }
292
- );
293
- var MessageTool = forwardRef2(function MessageTool2({ children, renderWhen = "always", ...props }, ref) {
294
- const { part } = useMessagePart();
295
- if (part.type !== "tool" || !shouldRenderTool(part, renderWhen)) {
296
- return null;
297
- }
298
- const renderedChildren = typeof children === "function" ? children(part) : children ?? defaultToolContent();
299
- return renderPrimitive(
300
- "div",
301
- {
302
- ...props,
303
- children: renderedChildren,
304
- "data-anvia-tool": "",
305
- "data-state": part.state
306
- },
307
- ref
308
- );
309
- });
310
- var MessageToolName = forwardRef2(
311
- function MessageToolName2(props, ref) {
312
- const { part } = useMessagePart();
313
- if (part.type !== "tool") {
314
- return null;
315
- }
316
- return renderPrimitive(
317
- "span",
318
- {
319
- ...props,
320
- children: props.children ?? part.toolName,
321
- "data-anvia-tool-name": ""
322
- },
323
- ref
324
- );
325
- }
326
- );
327
- var MessageToolStatus = forwardRef2(
328
- function MessageToolStatus2(props, ref) {
329
- const { part } = useMessagePart();
330
- if (part.type !== "tool") {
331
- return null;
332
- }
333
- return renderPrimitive(
334
- "span",
335
- {
336
- ...props,
337
- children: props.children ?? toolStateLabel(part.state),
338
- "data-anvia-tool-status": "",
339
- "data-state": part.state
340
- },
341
- ref
342
- );
343
- }
344
- );
345
- var MessageToolInput = forwardRef2(
346
- function MessageToolInput2(props, ref) {
347
- const { part } = useMessagePart();
348
- if (part.type !== "tool" || part.input === void 0) {
349
- return null;
350
- }
351
- return renderPrimitive(
352
- "pre",
353
- {
354
- ...props,
355
- children: props.children ?? stringifyValue(part.input),
356
- "data-anvia-tool-input": ""
357
- },
358
- ref
359
- );
360
- }
361
- );
362
- var MessageToolOutput = forwardRef2(
363
- function MessageToolOutput2(props, ref) {
364
- const { part } = useMessagePart();
365
- if (part.type !== "tool" || part.output === void 0) {
366
- return null;
367
- }
368
- return renderPrimitive(
369
- "pre",
370
- {
371
- ...props,
372
- children: props.children ?? stringifyValue(part.output),
373
- "data-anvia-tool-output": ""
374
- },
375
- ref
376
- );
377
- }
378
- );
379
- var MessageToolError = forwardRef2(
380
- function MessageToolError2(props, ref) {
381
- const { part } = useMessagePart();
382
- if (part.type !== "tool" || part.error === void 0) {
383
- return null;
384
- }
385
- return renderPrimitive(
386
- "div",
387
- {
388
- ...props,
389
- children: props.children ?? part.error.message,
390
- "data-anvia-tool-error": "",
391
- role: props.role ?? "alert"
392
- },
393
- ref
394
- );
395
- }
396
- );
397
- var MessageAttachment = forwardRef2(
398
- function MessageAttachment2({ children, ...props }, ref) {
399
- const { part } = useMessagePart();
400
- if (part.type !== "attachment") {
401
- return null;
402
- }
403
- const renderedChildren = typeof children === "function" ? children(part.attachment) : children ?? /* @__PURE__ */ jsx2(Attachment.Root, {});
404
- return /* @__PURE__ */ jsx2(InternalAttachmentProvider, { value: { attachment: part.attachment }, children: renderPrimitive(
405
- "div",
406
- {
407
- ...props,
408
- children: renderedChildren,
409
- "data-anvia-message-attachment": ""
410
- },
411
- ref
412
- ) });
413
- }
414
- );
415
- var MessageData = forwardRef2(
416
- function MessageData2(props, ref) {
417
- const { part } = useMessagePart();
418
- if (part.type !== "data") {
419
- return null;
420
- }
421
- return renderPrimitive(
422
- "pre",
423
- {
424
- ...props,
425
- children: props.children ?? stringifyValue(part.data),
426
- "data-anvia-data": "",
427
- "data-name": part.name
428
- },
429
- ref
430
- );
431
- }
432
- );
433
- var MessageError = forwardRef2(
434
- function MessageError2(props, ref) {
435
- const { part } = useMessagePart();
436
- if (part.type !== "error") {
437
- return null;
438
- }
439
- return renderPrimitive(
440
- "div",
441
- {
442
- ...props,
443
- children: props.children ?? part.error.message,
444
- "data-anvia-error": "",
445
- role: props.role ?? "alert"
446
- },
447
- ref
448
- );
449
- }
450
- );
451
- function defaultPart(part) {
452
- if (part.type === "text") {
453
- return /* @__PURE__ */ jsx2(MessageText, {});
454
- }
455
- if (part.type === "reasoning") {
456
- return /* @__PURE__ */ jsx2(MessageReasoning, {});
457
- }
458
- if (part.type === "tool") {
459
- return /* @__PURE__ */ jsx2(MessageTool, {});
460
- }
461
- if (part.type === "attachment") {
462
- return /* @__PURE__ */ jsx2(MessageAttachment, {});
463
- }
464
- if (part.type === "data") {
465
- return /* @__PURE__ */ jsx2(MessageData, {});
466
- }
467
- return /* @__PURE__ */ jsx2(MessageError, {});
468
- }
469
- function defaultToolContent() {
470
- return /* @__PURE__ */ jsxs2(Fragment2, { children: [
471
- /* @__PURE__ */ jsx2(MessageToolName, {}),
472
- /* @__PURE__ */ jsx2(MessageToolStatus, {}),
473
- /* @__PURE__ */ jsx2(MessageToolInput, {}),
474
- /* @__PURE__ */ jsx2(MessageToolOutput, {}),
475
- /* @__PURE__ */ jsx2(MessageToolError, {})
476
- ] });
477
- }
478
- function defaultCodeComponent({
479
- children,
480
- className,
481
- node: _node,
482
- ...props
483
- }) {
484
- const language = /language-(\S+)/.exec(className ?? "")?.[1];
485
- return /* @__PURE__ */ jsx2(
486
- "code",
487
- {
488
- className,
489
- "data-anvia-code": "",
490
- "data-anvia-inline-code": language === void 0 ? "" : void 0,
491
- "data-language": language,
492
- ...props,
493
- children
494
- }
495
- );
496
- }
497
- function defaultPreComponent({
498
- children,
499
- node: _node,
500
- ...props
501
- }) {
502
- return /* @__PURE__ */ jsx2(MessageCodeBlock, { ...props, children });
503
- }
504
- function shouldRenderTool(part, renderWhen) {
505
- if (renderWhen === "always") {
506
- return true;
507
- }
508
- if (renderWhen === "pending") {
509
- return part.state === "input-streaming" || part.state === "input-available";
510
- }
511
- return part.state === "output-available" || part.state === "error";
512
- }
513
- function toolStateLabel(state) {
514
- if (state === "output-available") {
515
- return "Done";
516
- }
517
- if (state === "error") {
518
- return "Error";
519
- }
520
- return "Running";
521
- }
522
-
523
- // src/message/root.tsx
524
- import { forwardRef as forwardRef3 } from "react";
525
- var MessageRoot = forwardRef3(function MessageRoot2({ children, ...props }, ref) {
526
- const { message } = useMessage();
527
- const renderedChildren = typeof children === "function" ? children(message) : children;
528
- return renderPrimitive(
529
- "article",
530
- {
531
- ...props,
532
- children: renderedChildren,
533
- "data-anvia-message": "",
534
- "data-anvia-message-id": message.id,
535
- "data-role": message.role
536
- },
537
- ref
538
- );
539
- });
540
- var MessageContent = forwardRef3(
541
- function MessageContent2(props, ref) {
542
- return renderPrimitive(
543
- "div",
544
- {
545
- ...props,
546
- "data-anvia-message-content": ""
547
- },
548
- ref
549
- );
550
- }
551
- );
552
-
553
- // src/message/index.ts
554
- var Message = {
555
- Root: MessageRoot,
556
- Content: MessageContent,
557
- Parts: MessageParts,
558
- Part: MessagePart,
559
- Text: MessageText,
560
- Markdown: MessageMarkdown,
561
- CodeBlock: MessageCodeBlock,
562
- Reasoning: MessageReasoning,
563
- Tool: MessageTool,
564
- ToolName: MessageToolName,
565
- ToolInput: MessageToolInput,
566
- ToolOutput: MessageToolOutput,
567
- ToolError: MessageToolError,
568
- ToolStatus: MessageToolStatus,
569
- Attachment: MessageAttachment,
570
- Data: MessageData,
571
- Error: MessageError,
572
- Actions: MessageActions,
573
- Copy: MessageCopy,
574
- Regenerate: MessageRegenerate
575
- };
576
-
577
- export {
578
- Message
579
- };
580
- //# sourceMappingURL=chunk-LWH6BMAD.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/message/actions.tsx","../src/format/message.ts","../src/format/value.ts","../src/message/parts.tsx","../src/message/root.tsx","../src/message/index.ts"],"sourcesContent":["import { forwardRef, type MouseEvent, useCallback, useEffect, useRef, useState } from \"react\";\n\nimport { useChatContext, useMessage } from \"../contexts\";\nimport { messageText } from \"../format\";\nimport { type PrimitiveProps, renderPrimitive } from \"../primitives\";\n\nconst MessageActions = forwardRef<HTMLDivElement, PrimitiveProps<\"div\">>(\n function MessageActions(props, ref) {\n return renderPrimitive(\n \"div\",\n {\n ...props,\n children: props.children ?? (\n <>\n <MessageCopy />\n <MessageRegenerate />\n </>\n ),\n \"data-anvia-message-actions\": \"\",\n } as PrimitiveProps<\"div\">,\n ref,\n );\n },\n);\n\ntype MessageCopyState = \"idle\" | \"copied\" | \"error\";\n\nconst MessageCopy = forwardRef<HTMLButtonElement, PrimitiveProps<\"button\">>(function MessageCopy(\n { onClick, ...props },\n ref,\n) {\n const { message } = useMessage();\n const [copyState, setCopyState] = useState<MessageCopyState>(\"idle\");\n const text = messageText(message);\n const previousTextRef = useRef(text);\n const disabled = props.disabled ?? text.length === 0;\n\n useEffect(() => {\n if (previousTextRef.current !== text) {\n previousTextRef.current = text;\n setCopyState(\"idle\");\n }\n }, [text]);\n\n const handleClick = useCallback(\n async (event: MouseEvent<HTMLButtonElement>) => {\n onClick?.(event);\n if (event.defaultPrevented || disabled) {\n return;\n }\n const writeText = navigator.clipboard?.writeText;\n if (writeText === undefined) {\n setCopyState(\"error\");\n return;\n }\n try {\n await writeText.call(navigator.clipboard, text);\n setCopyState(\"copied\");\n } catch {\n setCopyState(\"error\");\n }\n },\n [disabled, onClick, text],\n );\n\n return renderPrimitive(\n \"button\",\n {\n ...props,\n children: props.children ?? \"Copy\",\n disabled,\n onClick: handleClick,\n type: props.type ?? \"button\",\n \"data-anvia-copy\": \"\",\n \"data-state\": copyState,\n } as PrimitiveProps<\"button\">,\n ref,\n );\n});\n\nconst MessageRegenerate = forwardRef<HTMLButtonElement, PrimitiveProps<\"button\">>(\n function MessageRegenerate({ onClick, ...props }, ref) {\n const chat = useChatContext();\n const { message } = useMessage();\n const latestAssistantMessage = [...chat.messages]\n .reverse()\n .find((item) => item.role === \"assistant\");\n const disabled =\n props.disabled ??\n (chat.status === \"streaming\" ||\n message.role !== \"assistant\" ||\n latestAssistantMessage?.id !== message.id);\n\n const handleClick = useCallback(\n (event: MouseEvent<HTMLButtonElement>) => {\n onClick?.(event);\n if (event.defaultPrevented || disabled) {\n return;\n }\n void chat.regenerate();\n },\n [chat, disabled, onClick],\n );\n\n return renderPrimitive(\n \"button\",\n {\n ...props,\n children: props.children ?? \"Regenerate\",\n disabled,\n onClick: handleClick,\n type: props.type ?? \"button\",\n \"data-anvia-regenerate\": \"\",\n \"data-state\": disabled ? \"disabled\" : \"idle\",\n } as PrimitiveProps<\"button\">,\n ref,\n );\n },\n);\n\nexport { MessageActions, MessageCopy, MessageRegenerate };\n","import type { UIMessage, UIMessagePart } from \"@anvia/react\";\n\nexport function messageText(message: UIMessage): string {\n return message.parts\n .filter((part): part is Extract<UIMessagePart, { type: \"text\" }> => part.type === \"text\")\n .map((part) => part.text)\n .join(\"\");\n}\n","export function stringifyValue(value: unknown): string {\n if (value === undefined) {\n return \"\";\n }\n if (typeof value === \"string\") {\n return value;\n }\n try {\n return JSON.stringify(value, null, 2);\n } catch {\n return String(value);\n }\n}\n","import {\n type StreamAnimationMode,\n type StreamSmoothingPreset,\n type UIAttachment,\n type UIMessagePart,\n useSmoothStreamText,\n} from \"@anvia/react\";\nimport { type ComponentPropsWithoutRef, forwardRef, type ReactNode } from \"react\";\nimport ReactMarkdown, {\n type Components,\n type Options as ReactMarkdownOptions,\n} from \"react-markdown\";\nimport remarkGfm from \"remark-gfm\";\n\nimport { Attachment } from \"../attachment/index\";\nimport {\n InternalAttachmentProvider,\n InternalMessagePartProvider,\n useMessage,\n useMessagePart,\n useOptionalMessagePart,\n} from \"../contexts\";\nimport { stringifyValue } from \"../format\";\nimport { type PrimitiveProps, renderPrimitive } from \"../primitives\";\n\ntype MessagePartChildren = ReactNode | ((part: UIMessagePart) => ReactNode);\nexport type MessagePartsFilter = (part: UIMessagePart) => boolean;\nexport type MessageToolPart = Extract<UIMessagePart, { type: \"tool\" }>;\ntype MessageToolChildren = ReactNode | ((part: MessageToolPart) => ReactNode);\nexport type MessageToolRenderWhen = \"always\" | \"pending\" | \"settled\";\nexport type MessageAttachmentPart = Extract<UIMessagePart, { type: \"attachment\" }>;\ntype MessageAttachmentChildren = ReactNode | ((attachment: UIAttachment) => ReactNode);\n\ntype MessageStreamAnimationProps = {\n animate?: boolean;\n animationMode?: StreamAnimationMode;\n isStreaming?: boolean;\n smoothingPreset?: StreamSmoothingPreset;\n reducedMotion?: boolean;\n};\n\ntype MessagePartsProps = Omit<PrimitiveProps<\"div\">, \"children\"> & {\n children?: MessagePartChildren;\n filter?: MessagePartsFilter;\n};\n\nconst MessageParts = forwardRef<HTMLDivElement, MessagePartsProps>(function MessageParts(\n { children, filter, ...props },\n ref,\n) {\n const { message } = useMessage();\n const parts = filter === undefined ? message.parts : message.parts.filter(filter);\n\n return renderPrimitive(\n \"div\",\n {\n ...props,\n children: parts.map((part) => (\n <InternalMessagePartProvider key={part.id} part={part}>\n {typeof children === \"function\" ? children(part) : (children ?? <MessagePart />)}\n </InternalMessagePartProvider>\n )),\n \"data-anvia-message-parts\": \"\",\n } as PrimitiveProps<\"div\">,\n ref,\n );\n});\n\ntype MessagePartProps = Omit<PrimitiveProps<\"div\">, \"children\"> & {\n children?: MessagePartChildren;\n};\n\nconst MessagePart = forwardRef<HTMLDivElement, MessagePartProps>(function MessagePart(\n { children, ...props },\n ref,\n) {\n const { part } = useMessagePart();\n const renderedChildren =\n typeof children === \"function\" ? children(part) : (children ?? defaultPart(part));\n\n return renderPrimitive(\n \"div\",\n {\n ...props,\n children: renderedChildren,\n \"data-anvia-part\": \"\",\n \"data-part\": part.type,\n } as PrimitiveProps<\"div\">,\n ref,\n );\n});\n\ntype MessageTextProps = PrimitiveProps<\"span\"> & MessageStreamAnimationProps;\n\nconst MessageText = forwardRef<HTMLSpanElement, MessageTextProps>(function MessageText(props, ref) {\n const { part } = useMessagePart();\n if (part.type !== \"text\") {\n return null;\n }\n\n return <MessageTextContent {...props} content={part.text} ref={ref} />;\n});\n\ntype MessageTextContentProps = MessageTextProps & {\n content: string;\n};\n\nconst MessageTextContent = forwardRef<HTMLSpanElement, MessageTextContentProps>(\n function MessageTextContent(\n {\n animate = false,\n animationMode = \"smooth\",\n isStreaming,\n smoothingPreset,\n reducedMotion,\n content,\n ...props\n },\n ref,\n ) {\n const animationEnabled = animate && props.children === undefined;\n const smooth = useSmoothStreamText(content, {\n enabled: animationEnabled,\n mode: animationMode,\n ...(isStreaming === undefined ? {} : { isStreaming }),\n ...(smoothingPreset === undefined ? {} : { preset: smoothingPreset }),\n ...(reducedMotion === undefined ? {} : { reducedMotion }),\n });\n const animationActive =\n animationEnabled &&\n animationMode !== \"none\" &&\n isStreaming !== false &&\n reducedMotion !== true;\n\n return renderPrimitive(\n \"span\",\n {\n ...props,\n children: props.children ?? (animationEnabled ? smooth.text : content),\n \"data-anvia-text\": \"\",\n \"data-anvia-stream-animation\": animationEnabled ? animationMode : undefined,\n \"data-streaming\": animationActive ? \"\" : undefined,\n } as PrimitiveProps<\"span\">,\n ref,\n );\n },\n);\n\ntype MessageMarkdownProps = Omit<PrimitiveProps<\"div\">, \"children\"> &\n MessageStreamAnimationProps & {\n children?: string;\n components?: Components;\n remarkPlugins?: ReactMarkdownOptions[\"remarkPlugins\"];\n };\n\nconst MessageMarkdown = forwardRef<HTMLDivElement, MessageMarkdownProps>(function MessageMarkdown(\n { children, ...props },\n ref,\n) {\n const { message } = useMessage();\n const partContext = useOptionalMessagePart();\n const part = partContext?.part;\n if (part !== undefined && part.type !== \"text\") {\n return null;\n }\n\n const markdown =\n children ??\n (part?.type === \"text\"\n ? part.text\n : message.parts.flatMap((item) => (item.type === \"text\" ? [item.text] : [])).join(\"\\n\\n\"));\n\n return <MessageMarkdownContent {...props} markdown={markdown} ref={ref} />;\n});\n\ntype MessageMarkdownContentProps = Omit<MessageMarkdownProps, \"children\"> & {\n markdown: string;\n};\n\nconst MessageMarkdownContent = forwardRef<HTMLDivElement, MessageMarkdownContentProps>(\n function MessageMarkdownContent(\n {\n animate = false,\n animationMode = \"smooth\",\n isStreaming,\n smoothingPreset,\n reducedMotion,\n components,\n remarkPlugins,\n markdown,\n ...props\n },\n ref,\n ) {\n const smooth = useSmoothStreamText(markdown, {\n enabled: animate,\n mode: animationMode,\n ...(isStreaming === undefined ? {} : { isStreaming }),\n ...(smoothingPreset === undefined ? {} : { preset: smoothingPreset }),\n ...(reducedMotion === undefined ? {} : { reducedMotion }),\n });\n const animationActive =\n animate && animationMode !== \"none\" && isStreaming !== false && reducedMotion !== true;\n\n return renderPrimitive(\n \"div\",\n {\n ...props,\n children: (\n <ReactMarkdown\n components={{ code: defaultCodeComponent, pre: defaultPreComponent, ...components }}\n remarkPlugins={remarkPlugins ?? [remarkGfm]}\n >\n {animate ? smooth.text : markdown}\n </ReactMarkdown>\n ),\n \"data-anvia-markdown\": \"\",\n \"data-anvia-stream-animation\": animate ? animationMode : undefined,\n \"data-streaming\": animationActive ? \"\" : undefined,\n } as PrimitiveProps<\"div\">,\n ref,\n );\n },\n);\n\ntype MessageCodeBlockProps = Omit<PrimitiveProps<\"pre\">, \"children\"> & {\n children?: ReactNode;\n code?: string;\n language?: string;\n};\n\nconst MessageCodeBlock = forwardRef<HTMLPreElement, MessageCodeBlockProps>(\n function MessageCodeBlock({ children, code, language, ...props }, ref) {\n return renderPrimitive(\n \"pre\",\n {\n ...props,\n children: children ?? (\n <code data-anvia-code=\"\" data-language={language}>\n {code ?? \"\"}\n </code>\n ),\n \"data-anvia-code-block\": \"\",\n \"data-language\": language,\n } as PrimitiveProps<\"pre\">,\n ref,\n );\n },\n);\n\nconst MessageReasoning = forwardRef<HTMLDetailsElement, PrimitiveProps<\"details\">>(\n function MessageReasoning(props, ref) {\n const { part } = useMessagePart();\n if (part.type !== \"reasoning\") {\n return null;\n }\n\n return renderPrimitive(\n \"details\",\n {\n ...props,\n children: props.children ?? (\n <>\n <summary>Reasoning</summary>\n <pre>{part.text}</pre>\n </>\n ),\n \"data-anvia-reasoning\": \"\",\n } as PrimitiveProps<\"details\">,\n ref,\n );\n },\n);\n\ntype MessageToolProps = Omit<PrimitiveProps<\"div\">, \"children\"> & {\n children?: MessageToolChildren;\n renderWhen?: MessageToolRenderWhen;\n};\n\nconst MessageTool = forwardRef<HTMLDivElement, MessageToolProps>(function MessageTool(\n { children, renderWhen = \"always\", ...props },\n ref,\n) {\n const { part } = useMessagePart();\n if (part.type !== \"tool\" || !shouldRenderTool(part, renderWhen)) {\n return null;\n }\n const renderedChildren =\n typeof children === \"function\" ? children(part) : (children ?? defaultToolContent());\n\n return renderPrimitive(\n \"div\",\n {\n ...props,\n children: renderedChildren,\n \"data-anvia-tool\": \"\",\n \"data-state\": part.state,\n } as PrimitiveProps<\"div\">,\n ref,\n );\n});\n\nconst MessageToolName = forwardRef<HTMLSpanElement, PrimitiveProps<\"span\">>(\n function MessageToolName(props, ref) {\n const { part } = useMessagePart();\n if (part.type !== \"tool\") {\n return null;\n }\n\n return renderPrimitive(\n \"span\",\n {\n ...props,\n children: props.children ?? part.toolName,\n \"data-anvia-tool-name\": \"\",\n } as PrimitiveProps<\"span\">,\n ref,\n );\n },\n);\n\nconst MessageToolStatus = forwardRef<HTMLSpanElement, PrimitiveProps<\"span\">>(\n function MessageToolStatus(props, ref) {\n const { part } = useMessagePart();\n if (part.type !== \"tool\") {\n return null;\n }\n\n return renderPrimitive(\n \"span\",\n {\n ...props,\n children: props.children ?? toolStateLabel(part.state),\n \"data-anvia-tool-status\": \"\",\n \"data-state\": part.state,\n } as PrimitiveProps<\"span\">,\n ref,\n );\n },\n);\n\nconst MessageToolInput = forwardRef<HTMLPreElement, PrimitiveProps<\"pre\">>(\n function MessageToolInput(props, ref) {\n const { part } = useMessagePart();\n if (part.type !== \"tool\" || part.input === undefined) {\n return null;\n }\n\n return renderPrimitive(\n \"pre\",\n {\n ...props,\n children: props.children ?? stringifyValue(part.input),\n \"data-anvia-tool-input\": \"\",\n } as PrimitiveProps<\"pre\">,\n ref,\n );\n },\n);\n\nconst MessageToolOutput = forwardRef<HTMLPreElement, PrimitiveProps<\"pre\">>(\n function MessageToolOutput(props, ref) {\n const { part } = useMessagePart();\n if (part.type !== \"tool\" || part.output === undefined) {\n return null;\n }\n\n return renderPrimitive(\n \"pre\",\n {\n ...props,\n children: props.children ?? stringifyValue(part.output),\n \"data-anvia-tool-output\": \"\",\n } as PrimitiveProps<\"pre\">,\n ref,\n );\n },\n);\n\nconst MessageToolError = forwardRef<HTMLDivElement, PrimitiveProps<\"div\">>(\n function MessageToolError(props, ref) {\n const { part } = useMessagePart();\n if (part.type !== \"tool\" || part.error === undefined) {\n return null;\n }\n\n return renderPrimitive(\n \"div\",\n {\n ...props,\n children: props.children ?? part.error.message,\n \"data-anvia-tool-error\": \"\",\n role: props.role ?? \"alert\",\n } as PrimitiveProps<\"div\">,\n ref,\n );\n },\n);\n\ntype MessageAttachmentProps = Omit<PrimitiveProps<\"div\">, \"children\"> & {\n children?: MessageAttachmentChildren;\n};\n\nconst MessageAttachment = forwardRef<HTMLDivElement, MessageAttachmentProps>(\n function MessageAttachment({ children, ...props }, ref) {\n const { part } = useMessagePart();\n if (part.type !== \"attachment\") {\n return null;\n }\n const renderedChildren =\n typeof children === \"function\"\n ? children(part.attachment)\n : (children ?? <Attachment.Root />);\n\n return (\n <InternalAttachmentProvider value={{ attachment: part.attachment }}>\n {renderPrimitive(\n \"div\",\n {\n ...props,\n children: renderedChildren,\n \"data-anvia-message-attachment\": \"\",\n } as PrimitiveProps<\"div\">,\n ref,\n )}\n </InternalAttachmentProvider>\n );\n },\n);\n\nconst MessageData = forwardRef<HTMLPreElement, PrimitiveProps<\"pre\">>(\n function MessageData(props, ref) {\n const { part } = useMessagePart();\n if (part.type !== \"data\") {\n return null;\n }\n\n return renderPrimitive(\n \"pre\",\n {\n ...props,\n children: props.children ?? stringifyValue(part.data),\n \"data-anvia-data\": \"\",\n \"data-name\": part.name,\n } as PrimitiveProps<\"pre\">,\n ref,\n );\n },\n);\n\nconst MessageError = forwardRef<HTMLDivElement, PrimitiveProps<\"div\">>(\n function MessageError(props, ref) {\n const { part } = useMessagePart();\n if (part.type !== \"error\") {\n return null;\n }\n\n return renderPrimitive(\n \"div\",\n {\n ...props,\n children: props.children ?? part.error.message,\n \"data-anvia-error\": \"\",\n role: props.role ?? \"alert\",\n } as PrimitiveProps<\"div\">,\n ref,\n );\n },\n);\n\nfunction defaultPart(part: UIMessagePart): ReactNode {\n if (part.type === \"text\") {\n return <MessageText />;\n }\n if (part.type === \"reasoning\") {\n return <MessageReasoning />;\n }\n if (part.type === \"tool\") {\n return <MessageTool />;\n }\n if (part.type === \"attachment\") {\n return <MessageAttachment />;\n }\n if (part.type === \"data\") {\n return <MessageData />;\n }\n return <MessageError />;\n}\n\nfunction defaultToolContent(): ReactNode {\n return (\n <>\n <MessageToolName />\n <MessageToolStatus />\n <MessageToolInput />\n <MessageToolOutput />\n <MessageToolError />\n </>\n );\n}\n\nfunction defaultCodeComponent({\n children,\n className,\n node: _node,\n ...props\n}: ComponentPropsWithoutRef<\"code\"> & { node?: unknown }): ReactNode {\n const language = /language-(\\S+)/.exec(className ?? \"\")?.[1];\n\n return (\n <code\n className={className}\n data-anvia-code=\"\"\n data-anvia-inline-code={language === undefined ? \"\" : undefined}\n data-language={language}\n {...props}\n >\n {children}\n </code>\n );\n}\n\nfunction defaultPreComponent({\n children,\n node: _node,\n ...props\n}: ComponentPropsWithoutRef<\"pre\"> & { node?: unknown }): ReactNode {\n return <MessageCodeBlock {...props}>{children}</MessageCodeBlock>;\n}\n\nfunction shouldRenderTool(part: MessageToolPart, renderWhen: MessageToolRenderWhen): boolean {\n if (renderWhen === \"always\") {\n return true;\n }\n if (renderWhen === \"pending\") {\n return part.state === \"input-streaming\" || part.state === \"input-available\";\n }\n return part.state === \"output-available\" || part.state === \"error\";\n}\n\nfunction toolStateLabel(state: MessageToolPart[\"state\"]): string {\n if (state === \"output-available\") {\n return \"Done\";\n }\n if (state === \"error\") {\n return \"Error\";\n }\n return \"Running\";\n}\n\nexport {\n MessageAttachment,\n MessageCodeBlock,\n MessageData,\n MessageError,\n MessageMarkdown,\n MessagePart,\n MessageParts,\n MessageReasoning,\n MessageText,\n MessageTool,\n MessageToolError,\n MessageToolInput,\n MessageToolName,\n MessageToolOutput,\n MessageToolStatus,\n};\n","import type { UIMessage } from \"@anvia/react\";\nimport { forwardRef, type ReactNode } from \"react\";\n\nimport { useMessage } from \"../contexts\";\nimport { type PrimitiveProps, renderPrimitive } from \"../primitives\";\n\ntype MessageChildren = ReactNode | ((message: UIMessage) => ReactNode);\n\ntype MessageRootProps = Omit<PrimitiveProps<\"article\">, \"children\"> & {\n children?: MessageChildren;\n};\n\nconst MessageRoot = forwardRef<HTMLElement, MessageRootProps>(function MessageRoot(\n { children, ...props },\n ref,\n) {\n const { message } = useMessage();\n const renderedChildren = typeof children === \"function\" ? children(message) : children;\n\n return renderPrimitive(\n \"article\",\n {\n ...props,\n children: renderedChildren,\n \"data-anvia-message\": \"\",\n \"data-anvia-message-id\": message.id,\n \"data-role\": message.role,\n } as PrimitiveProps<\"article\">,\n ref,\n );\n});\n\nconst MessageContent = forwardRef<HTMLDivElement, PrimitiveProps<\"div\">>(\n function MessageContent(props, ref) {\n return renderPrimitive(\n \"div\",\n {\n ...props,\n \"data-anvia-message-content\": \"\",\n } as PrimitiveProps<\"div\">,\n ref,\n );\n },\n);\n\nexport { MessageContent, MessageRoot };\n","import { MessageActions, MessageCopy, MessageRegenerate } from \"./actions\";\nimport {\n MessageAttachment,\n MessageCodeBlock,\n MessageData,\n MessageError,\n MessageMarkdown,\n MessagePart,\n MessageParts,\n MessageReasoning,\n MessageText,\n MessageTool,\n MessageToolError,\n MessageToolInput,\n MessageToolName,\n MessageToolOutput,\n MessageToolStatus,\n} from \"./parts\";\nimport { MessageContent, MessageRoot } from \"./root\";\n\nexport const Message = {\n Root: MessageRoot,\n Content: MessageContent,\n Parts: MessageParts,\n Part: MessagePart,\n Text: MessageText,\n Markdown: MessageMarkdown,\n CodeBlock: MessageCodeBlock,\n Reasoning: MessageReasoning,\n Tool: MessageTool,\n ToolName: MessageToolName,\n ToolInput: MessageToolInput,\n ToolOutput: MessageToolOutput,\n ToolError: MessageToolError,\n ToolStatus: MessageToolStatus,\n Attachment: MessageAttachment,\n Data: MessageData,\n Error: MessageError,\n Actions: MessageActions,\n Copy: MessageCopy,\n Regenerate: MessageRegenerate,\n} as const;\n\nexport type { MessageContextValue, MessagePartContextValue } from \"../contexts\";\nexport { useChatContext, useMessage, useMessagePart } from \"../contexts\";\nexport type {\n MessageAttachmentPart,\n MessagePartsFilter,\n MessageToolPart,\n MessageToolRenderWhen,\n} from \"./parts\";\n"],"mappings":";;;;;;;;;;;;;;;;AAAA,SAAS,YAA6B,aAAa,WAAW,QAAQ,gBAAgB;;;ACE/E,SAAS,YAAY,SAA4B;AACtD,SAAO,QAAQ,MACZ,OAAO,CAAC,SAA2D,KAAK,SAAS,MAAM,EACvF,IAAI,CAAC,SAAS,KAAK,IAAI,EACvB,KAAK,EAAE;AACZ;;;ACPO,SAAS,eAAe,OAAwB;AACrD,MAAI,UAAU,QAAW;AACvB,WAAO;AAAA,EACT;AACA,MAAI,OAAO,UAAU,UAAU;AAC7B,WAAO;AAAA,EACT;AACA,MAAI;AACF,WAAO,KAAK,UAAU,OAAO,MAAM,CAAC;AAAA,EACtC,QAAQ;AACN,WAAO,OAAO,KAAK;AAAA,EACrB;AACF;;;AFCU,mBACE,KADF;AAPV,IAAM,iBAAiB;AAAA,EACrB,SAASA,gBAAe,OA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ACE,GAAG;AAAA,MACH,UAAU;AAAA,MACV,sBAAsB;AAAA,MACtB,yBAAyB,QAAQ;AAAA,MACjC,aAAa,QAAQ;AAAA,IACvB;AAAA,IACA;AAAA,EACF;AACF,CAAC;AAED,IAAM,iBAAiBD;AAAA,EACrB,SAASE,gBAAe,OAAO,KAAK;AAClC,WAAO;AAAA,MACL;AAAA,MACA;AAAA,QACE,GAAG;AAAA,QACH,8BAA8B;AAAA,MAChC;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACF;;;ACvBO,IAAM,UAAU;AAAA,EACrB,MAAM;AAAA,EACN,SAAS;AAAA,EACT,OAAO;AAAA,EACP,MAAM;AAAA,EACN,MAAM;AAAA,EACN,UAAU;AAAA,EACV,WAAW;AAAA,EACX,WAAW;AAAA,EACX,MAAM;AAAA,EACN,UAAU;AAAA,EACV,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,MAAM;AAAA,EACN,OAAO;AAAA,EACP,SAAS;AAAA,EACT,MAAM;AAAA,EACN,YAAY;AACd;","names":["MessageActions","MessageCopy","MessageRegenerate","forwardRef","Fragment","jsx","jsxs","forwardRef","MessageParts","MessagePart","MessageText","MessageTextContent","MessageMarkdown","MessageMarkdownContent","MessageCodeBlock","MessageReasoning","MessageTool","MessageToolName","MessageToolStatus","MessageToolInput","MessageToolOutput","MessageToolError","MessageAttachment","MessageData","MessageError","forwardRef","forwardRef","MessageRoot","MessageContent"]}