@djangocfg/ui-tools 2.1.335 → 2.1.336

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 (193) hide show
  1. package/README.md +68 -2
  2. package/dist/ChatRoot-IIYQEWUU.mjs +5 -0
  3. package/dist/ChatRoot-IIYQEWUU.mjs.map +1 -0
  4. package/dist/ChatRoot-PNNGQCYF.css +7 -0
  5. package/dist/ChatRoot-PNNGQCYF.css.map +1 -0
  6. package/dist/ChatRoot-UUKTYM4N.cjs +14 -0
  7. package/dist/ChatRoot-UUKTYM4N.cjs.map +1 -0
  8. package/dist/{CronScheduler.client-3O3VU4CI.mjs → CronScheduler.client-DLMXCPAJ.mjs} +4 -4
  9. package/dist/{CronScheduler.client-3O3VU4CI.mjs.map → CronScheduler.client-DLMXCPAJ.mjs.map} +1 -1
  10. package/dist/{CronScheduler.client-A4GO6YBY.cjs → CronScheduler.client-WEJF4PWQ.cjs} +14 -14
  11. package/dist/{CronScheduler.client-A4GO6YBY.cjs.map → CronScheduler.client-WEJF4PWQ.cjs.map} +1 -1
  12. package/dist/{DocsLayout-XLDB6CJ2.cjs → DocsLayout-N5ZJZPBY.cjs} +200 -199
  13. package/dist/DocsLayout-N5ZJZPBY.cjs.map +1 -0
  14. package/dist/{DocsLayout-CTJINVBM.mjs → DocsLayout-VFPPNKSQ.mjs} +7 -6
  15. package/dist/DocsLayout-VFPPNKSQ.mjs.map +1 -0
  16. package/dist/JsonSchemaForm-DD7CLRIG.cjs +13 -0
  17. package/dist/{JsonSchemaForm-6WMS4CIY.cjs.map → JsonSchemaForm-DD7CLRIG.cjs.map} +1 -1
  18. package/dist/JsonSchemaForm-XKUIVELK.mjs +4 -0
  19. package/dist/{JsonSchemaForm-KX4JT3M4.mjs.map → JsonSchemaForm-XKUIVELK.mjs.map} +1 -1
  20. package/dist/JsonTree-55625VVH.mjs +5 -0
  21. package/dist/{JsonTree-F27RMYSI.cjs.map → JsonTree-55625VVH.mjs.map} +1 -1
  22. package/dist/JsonTree-DCM5QGWF.cjs +11 -0
  23. package/dist/{JsonTree-QTJYSHCV.mjs.map → JsonTree-DCM5QGWF.cjs.map} +1 -1
  24. package/dist/{LottiePlayer.client-6WVWDO75.cjs → LottiePlayer.client-2S7ISJ2S.cjs} +6 -6
  25. package/dist/{LottiePlayer.client-6WVWDO75.cjs.map → LottiePlayer.client-2S7ISJ2S.cjs.map} +1 -1
  26. package/dist/{LottiePlayer.client-B4I6WNZM.mjs → LottiePlayer.client-5LDSSJWS.mjs} +4 -4
  27. package/dist/{LottiePlayer.client-B4I6WNZM.mjs.map → LottiePlayer.client-5LDSSJWS.mjs.map} +1 -1
  28. package/dist/{MapContainer-RYG4HPH4.cjs → MapContainer-76YL2JXL.cjs} +8 -8
  29. package/dist/{MapContainer-RYG4HPH4.cjs.map → MapContainer-76YL2JXL.cjs.map} +1 -1
  30. package/dist/{MapContainer-GXQLP5WY.mjs → MapContainer-7HXBI3OH.mjs} +3 -3
  31. package/dist/{MapContainer-GXQLP5WY.mjs.map → MapContainer-7HXBI3OH.mjs.map} +1 -1
  32. package/dist/{Mermaid.client-SXRRI2YW.mjs → Mermaid.client-NL4SVR7F.mjs} +4 -4
  33. package/dist/{Mermaid.client-SXRRI2YW.mjs.map → Mermaid.client-NL4SVR7F.mjs.map} +1 -1
  34. package/dist/{Mermaid.client-W76R5AKJ.cjs → Mermaid.client-NNTI6DFX.cjs} +26 -26
  35. package/dist/{Mermaid.client-W76R5AKJ.cjs.map → Mermaid.client-NNTI6DFX.cjs.map} +1 -1
  36. package/dist/Player-BRV7XTWR.mjs +4 -0
  37. package/dist/{Player-M3GC3VPE.mjs.map → Player-BRV7XTWR.mjs.map} +1 -1
  38. package/dist/Player-PM7F7DD7.cjs +13 -0
  39. package/dist/{Player-ZL2X5LGG.cjs.map → Player-PM7F7DD7.cjs.map} +1 -1
  40. package/dist/{PrettyCode.client-RPDIE5CH.cjs → PrettyCode.client-KOHDVPPN.cjs} +13 -13
  41. package/dist/{PrettyCode.client-RPDIE5CH.cjs.map → PrettyCode.client-KOHDVPPN.cjs.map} +1 -1
  42. package/dist/{PrettyCode.client-SPMTQEG4.mjs → PrettyCode.client-ZGYGKE7G.mjs} +4 -4
  43. package/dist/{PrettyCode.client-SPMTQEG4.mjs.map → PrettyCode.client-ZGYGKE7G.mjs.map} +1 -1
  44. package/dist/TreeRoot-N72OYKXU.cjs +19 -0
  45. package/dist/{TreeRoot-A3J65L6F.mjs.map → TreeRoot-N72OYKXU.cjs.map} +1 -1
  46. package/dist/TreeRoot-VGAIXCUA.mjs +4 -0
  47. package/dist/{TreeRoot-DSK5JILT.cjs.map → TreeRoot-VGAIXCUA.mjs.map} +1 -1
  48. package/dist/chunk-2ZLKZ5VR.mjs +631 -0
  49. package/dist/chunk-2ZLKZ5VR.mjs.map +1 -0
  50. package/dist/{chunk-LFWQ36LJ.mjs → chunk-5G5YBFS6.mjs} +4 -4
  51. package/dist/{chunk-LFWQ36LJ.mjs.map → chunk-5G5YBFS6.mjs.map} +1 -1
  52. package/dist/{chunk-IHAY6FO6.cjs → chunk-5I5QNGUG.cjs} +17 -17
  53. package/dist/{chunk-IHAY6FO6.cjs.map → chunk-5I5QNGUG.cjs.map} +1 -1
  54. package/dist/{chunk-F2CMIIOH.cjs → chunk-76NNDZH6.cjs} +42 -42
  55. package/dist/{chunk-F2CMIIOH.cjs.map → chunk-76NNDZH6.cjs.map} +1 -1
  56. package/dist/chunk-B5AWZOHJ.cjs +649 -0
  57. package/dist/chunk-B5AWZOHJ.cjs.map +1 -0
  58. package/dist/{chunk-KR6B3LVY.mjs → chunk-B6IR5KSC.mjs} +3 -3
  59. package/dist/{chunk-KR6B3LVY.mjs.map → chunk-B6IR5KSC.mjs.map} +1 -1
  60. package/dist/{chunk-5LBDYFWH.mjs → chunk-C6GXVH5J.mjs} +3 -3
  61. package/dist/{chunk-5LBDYFWH.mjs.map → chunk-C6GXVH5J.mjs.map} +1 -1
  62. package/dist/{chunk-NRKD4F5X.cjs → chunk-FEN5S772.cjs} +36 -36
  63. package/dist/{chunk-NRKD4F5X.cjs.map → chunk-FEN5S772.cjs.map} +1 -1
  64. package/dist/{chunk-2SMCH62O.cjs → chunk-FP2RLYQZ.cjs} +11 -11
  65. package/dist/{chunk-2SMCH62O.cjs.map → chunk-FP2RLYQZ.cjs.map} +1 -1
  66. package/dist/{chunk-MOME6KYD.mjs → chunk-G5IEC7SR.mjs} +3 -3
  67. package/dist/{chunk-MOME6KYD.mjs.map → chunk-G5IEC7SR.mjs.map} +1 -1
  68. package/dist/{chunk-SE5IERVH.mjs → chunk-GYIO7W7M.mjs} +3 -3
  69. package/dist/{chunk-SE5IERVH.mjs.map → chunk-GYIO7W7M.mjs.map} +1 -1
  70. package/dist/{chunk-3Z3A7FHA.cjs → chunk-IEEAENLX.cjs} +48 -48
  71. package/dist/{chunk-3Z3A7FHA.cjs.map → chunk-IEEAENLX.cjs.map} +1 -1
  72. package/dist/{chunk-DFTVB66S.cjs → chunk-KNDLV4PI.cjs} +85 -85
  73. package/dist/{chunk-DFTVB66S.cjs.map → chunk-KNDLV4PI.cjs.map} +1 -1
  74. package/dist/{chunk-SSUOENAZ.mjs → chunk-KNEQRUBA.mjs} +3 -3
  75. package/dist/{chunk-SSUOENAZ.mjs.map → chunk-KNEQRUBA.mjs.map} +1 -1
  76. package/dist/chunk-KRETIZU6.mjs +2218 -0
  77. package/dist/chunk-KRETIZU6.mjs.map +1 -0
  78. package/dist/{chunk-CGILA3WO.mjs → chunk-N2XQF2OL.mjs} +5 -3
  79. package/dist/{chunk-CGILA3WO.mjs.map → chunk-N2XQF2OL.mjs.map} +1 -1
  80. package/dist/{chunk-EUADAUBQ.mjs → chunk-N4MZYNR4.mjs} +4 -4
  81. package/dist/{chunk-EUADAUBQ.mjs.map → chunk-N4MZYNR4.mjs.map} +1 -1
  82. package/dist/chunk-NRXYYO5V.cjs +2257 -0
  83. package/dist/chunk-NRXYYO5V.cjs.map +1 -0
  84. package/dist/{chunk-GGKGH5PM.mjs → chunk-OBRSGM64.mjs} +4 -4
  85. package/dist/{chunk-GGKGH5PM.mjs.map → chunk-OBRSGM64.mjs.map} +1 -1
  86. package/dist/{chunk-6JTB2X72.mjs → chunk-ODO4GMW7.mjs} +3 -3
  87. package/dist/{chunk-6JTB2X72.mjs.map → chunk-ODO4GMW7.mjs.map} +1 -1
  88. package/dist/{chunk-WGEGR3DF.cjs → chunk-OLISEQHS.cjs} +5 -2
  89. package/dist/{chunk-WGEGR3DF.cjs.map → chunk-OLISEQHS.cjs.map} +1 -1
  90. package/dist/{chunk-PZKAH7WQ.mjs → chunk-PVAX67JG.mjs} +3 -3
  91. package/dist/{chunk-PZKAH7WQ.mjs.map → chunk-PVAX67JG.mjs.map} +1 -1
  92. package/dist/{chunk-PRPG2T2E.cjs → chunk-QJ6GTUCO.cjs} +6 -6
  93. package/dist/{chunk-PRPG2T2E.cjs.map → chunk-QJ6GTUCO.cjs.map} +1 -1
  94. package/dist/chunk-QW4RBGHN.cjs +961 -0
  95. package/dist/chunk-QW4RBGHN.cjs.map +1 -0
  96. package/dist/{chunk-33AMWFBZ.cjs → chunk-SGP7V2UW.cjs} +15 -15
  97. package/dist/{chunk-33AMWFBZ.cjs.map → chunk-SGP7V2UW.cjs.map} +1 -1
  98. package/dist/{chunk-FX2QFYWF.mjs → chunk-VWQ5WOIL.mjs} +3 -3
  99. package/dist/{chunk-FX2QFYWF.mjs.map → chunk-VWQ5WOIL.mjs.map} +1 -1
  100. package/dist/{chunk-ZLQHUZDU.cjs → chunk-YDPDTOSP.cjs} +139 -139
  101. package/dist/{chunk-ZLQHUZDU.cjs.map → chunk-YDPDTOSP.cjs.map} +1 -1
  102. package/dist/{chunk-77HQWEQ6.cjs → chunk-YW5IVWHQ.cjs} +33 -33
  103. package/dist/{chunk-77HQWEQ6.cjs.map → chunk-YW5IVWHQ.cjs.map} +1 -1
  104. package/dist/{chunk-YXBOAGIM.cjs → chunk-YXZ6GU7H.cjs} +7 -7
  105. package/dist/{chunk-YXBOAGIM.cjs.map → chunk-YXZ6GU7H.cjs.map} +1 -1
  106. package/dist/{chunk-62Y65TGK.mjs → chunk-ZUFTH5IR.mjs} +8 -631
  107. package/dist/chunk-ZUFTH5IR.mjs.map +1 -0
  108. package/dist/components-EHOGXATG.cjs +22 -0
  109. package/dist/{components-5UXYNAKR.cjs.map → components-EHOGXATG.cjs.map} +1 -1
  110. package/dist/components-MQ6DR7TX.cjs +26 -0
  111. package/dist/{components-CFXOEVPN.mjs.map → components-MQ6DR7TX.cjs.map} +1 -1
  112. package/dist/components-XRX7QGLB.mjs +5 -0
  113. package/dist/{components-WYEZL5TE.cjs.map → components-XRX7QGLB.mjs.map} +1 -1
  114. package/dist/components-YATKRWLH.mjs +5 -0
  115. package/dist/{components-ZAGG2PBO.mjs.map → components-YATKRWLH.mjs.map} +1 -1
  116. package/dist/file-icon/index.cjs +6 -6
  117. package/dist/file-icon/index.mjs +1 -1
  118. package/dist/index.cjs +735 -215
  119. package/dist/index.cjs.map +1 -1
  120. package/dist/index.d.cts +972 -39
  121. package/dist/index.d.ts +972 -39
  122. package/dist/index.mjs +387 -31
  123. package/dist/index.mjs.map +1 -1
  124. package/dist/tree/index.cjs +38 -38
  125. package/dist/tree/index.d.cts +2 -2
  126. package/dist/tree/index.d.ts +2 -2
  127. package/dist/tree/index.mjs +3 -3
  128. package/package.json +6 -6
  129. package/src/index.ts +5 -0
  130. package/src/stories/index.ts +3 -1
  131. package/src/tools/Chat/Chat.story.tsx +1006 -0
  132. package/src/tools/Chat/README.md +528 -0
  133. package/src/tools/Chat/components/Attachments.tsx +192 -0
  134. package/src/tools/Chat/components/ChatRoot.tsx +201 -0
  135. package/src/tools/Chat/components/Composer.tsx +134 -0
  136. package/src/tools/Chat/components/EmptyState.tsx +47 -0
  137. package/src/tools/Chat/components/ErrorBanner.tsx +47 -0
  138. package/src/tools/Chat/components/JumpToLatest.tsx +30 -0
  139. package/src/tools/Chat/components/MessageActions.tsx +72 -0
  140. package/src/tools/Chat/components/MessageBubble.tsx +228 -0
  141. package/src/tools/Chat/components/MessageList.tsx +82 -0
  142. package/src/tools/Chat/components/Sources.tsx +55 -0
  143. package/src/tools/Chat/components/StreamingIndicator.tsx +29 -0
  144. package/src/tools/Chat/components/ToolCalls.tsx +172 -0
  145. package/src/tools/Chat/components/index.ts +24 -0
  146. package/src/tools/Chat/config.ts +55 -0
  147. package/src/tools/Chat/context/ChatProvider.tsx +122 -0
  148. package/src/tools/Chat/context/index.ts +9 -0
  149. package/src/tools/Chat/core/audio/audioBus.ts +172 -0
  150. package/src/tools/Chat/core/audio/index.ts +8 -0
  151. package/src/tools/Chat/core/audio/preferences.ts +68 -0
  152. package/src/tools/Chat/core/audio/types.ts +49 -0
  153. package/src/tools/Chat/core/ids.ts +16 -0
  154. package/src/tools/Chat/core/index.ts +5 -0
  155. package/src/tools/Chat/core/markdown.ts +56 -0
  156. package/src/tools/Chat/core/payload-dispatch.ts +54 -0
  157. package/src/tools/Chat/core/persona.ts +35 -0
  158. package/src/tools/Chat/core/reducer.ts +335 -0
  159. package/src/tools/Chat/core/transport/http.ts +167 -0
  160. package/src/tools/Chat/core/transport/index.ts +13 -0
  161. package/src/tools/Chat/core/transport/mock.ts +134 -0
  162. package/src/tools/Chat/core/transport/sse.ts +116 -0
  163. package/src/tools/Chat/core/transport/types.ts +24 -0
  164. package/src/tools/Chat/hooks/index.ts +26 -0
  165. package/src/tools/Chat/hooks/useChat.ts +440 -0
  166. package/src/tools/Chat/hooks/useChatAudio.ts +191 -0
  167. package/src/tools/Chat/hooks/useChatComposer.ts +227 -0
  168. package/src/tools/Chat/hooks/useChatHistory.ts +59 -0
  169. package/src/tools/Chat/hooks/useChatLayout.ts +111 -0
  170. package/src/tools/Chat/hooks/useChatLightbox.ts +34 -0
  171. package/src/tools/Chat/hooks/useChatScroll.ts +132 -0
  172. package/src/tools/Chat/index.ts +158 -0
  173. package/src/tools/Chat/lazy.tsx +14 -0
  174. package/src/tools/Chat/types.ts +237 -0
  175. package/src/tools/Chat/utils/collectImageAttachments.ts +13 -0
  176. package/src/tools/Map/README.md +384 -0
  177. package/dist/DocsLayout-CTJINVBM.mjs.map +0 -1
  178. package/dist/DocsLayout-XLDB6CJ2.cjs.map +0 -1
  179. package/dist/JsonSchemaForm-6WMS4CIY.cjs +0 -13
  180. package/dist/JsonSchemaForm-KX4JT3M4.mjs +0 -4
  181. package/dist/JsonTree-F27RMYSI.cjs +0 -11
  182. package/dist/JsonTree-QTJYSHCV.mjs +0 -5
  183. package/dist/Player-M3GC3VPE.mjs +0 -4
  184. package/dist/Player-ZL2X5LGG.cjs +0 -13
  185. package/dist/TreeRoot-A3J65L6F.mjs +0 -4
  186. package/dist/TreeRoot-DSK5JILT.cjs +0 -19
  187. package/dist/chunk-62Y65TGK.mjs.map +0 -1
  188. package/dist/chunk-TKSFZHCG.cjs +0 -1597
  189. package/dist/chunk-TKSFZHCG.cjs.map +0 -1
  190. package/dist/components-5UXYNAKR.cjs +0 -22
  191. package/dist/components-CFXOEVPN.mjs +0 -5
  192. package/dist/components-WYEZL5TE.cjs +0 -26
  193. package/dist/components-ZAGG2PBO.mjs +0 -5
@@ -0,0 +1,631 @@
1
+ import { __name } from './chunk-N2XQF2OL.mjs';
2
+ import React6, { lazy, useState, useMemo, useCallback, Suspense } from 'react';
3
+ import '@djangocfg/ui-core/styles/palette';
4
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
5
+ import ReactMarkdown from 'react-markdown';
6
+ import rehypeExternalLinks from 'rehype-external-links';
7
+ import rehypeRaw from 'rehype-raw';
8
+ import rehypeSanitize, { defaultSchema } from 'rehype-sanitize';
9
+ import remarkBreaks from 'remark-breaks';
10
+ import remarkEmoji from 'remark-emoji';
11
+ import remarkGfm from 'remark-gfm';
12
+ import remarkSmartypants from 'remark-smartypants';
13
+ import { CopyButton } from '@djangocfg/ui-core/components';
14
+ import { useResolvedTheme } from '@djangocfg/ui-core/hooks';
15
+
16
+ function smartTruncate(content, maxLength) {
17
+ if (content.length <= maxLength) {
18
+ return content;
19
+ }
20
+ let breakPoint = maxLength;
21
+ while (breakPoint > maxLength - 50 && breakPoint > 0) {
22
+ const char = content[breakPoint];
23
+ if (char === " " || char === "\n" || char === " ") {
24
+ break;
25
+ }
26
+ breakPoint--;
27
+ }
28
+ if (breakPoint <= maxLength - 50) {
29
+ breakPoint = maxLength;
30
+ }
31
+ let truncated = content.slice(0, breakPoint).trimEnd();
32
+ truncated = fixUnclosedMarkdown(truncated);
33
+ return truncated;
34
+ }
35
+ __name(smartTruncate, "smartTruncate");
36
+ function truncateByLines(content, maxLines) {
37
+ const lines = content.split("\n");
38
+ if (lines.length <= maxLines) {
39
+ return content;
40
+ }
41
+ let truncated = lines.slice(0, maxLines).join("\n").trimEnd();
42
+ truncated = fixUnclosedMarkdown(truncated);
43
+ return truncated;
44
+ }
45
+ __name(truncateByLines, "truncateByLines");
46
+ function fixUnclosedMarkdown(content) {
47
+ let result = content;
48
+ const countOccurrences = /* @__PURE__ */ __name((str, marker) => {
49
+ const escaped = marker.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
50
+ const matches = str.match(new RegExp(escaped, "g"));
51
+ return matches ? matches.length : 0;
52
+ }, "countOccurrences");
53
+ const boldCount = countOccurrences(result, "**");
54
+ if (boldCount % 2 !== 0) {
55
+ result += "**";
56
+ }
57
+ const withoutBold = result.replace(/\*\*/g, "");
58
+ const italicCount = countOccurrences(withoutBold, "*");
59
+ if (italicCount % 2 !== 0) {
60
+ result += "*";
61
+ }
62
+ const codeCount = countOccurrences(result, "`");
63
+ const tripleCount = countOccurrences(result, "```");
64
+ const singleCodeCount = codeCount - tripleCount * 3;
65
+ if (singleCodeCount % 2 !== 0) {
66
+ result += "`";
67
+ }
68
+ if (tripleCount % 2 !== 0) {
69
+ result += "\n```";
70
+ }
71
+ const strikeCount = countOccurrences(result, "~~");
72
+ if (strikeCount % 2 !== 0) {
73
+ result += "~~";
74
+ }
75
+ const underlineBoldCount = countOccurrences(result, "__");
76
+ if (underlineBoldCount % 2 !== 0) {
77
+ result += "__";
78
+ }
79
+ const withoutUnderlineBold = result.replace(/__/g, "");
80
+ const underlineItalicCount = countOccurrences(withoutUnderlineBold, "_");
81
+ if (underlineItalicCount % 2 !== 0) {
82
+ result += "_";
83
+ }
84
+ return result;
85
+ }
86
+ __name(fixUnclosedMarkdown, "fixUnclosedMarkdown");
87
+ function useCollapsibleContent(content, options = {}) {
88
+ const { maxLength, maxLines, defaultExpanded = false } = options;
89
+ const [isCollapsed, setIsCollapsed] = useState(!defaultExpanded);
90
+ const originalLength = content.length;
91
+ const originalLineCount = content.split("\n").length;
92
+ const { shouldCollapse, truncatedContent } = useMemo(() => {
93
+ if (maxLength === void 0 && maxLines === void 0) {
94
+ return { shouldCollapse: false, truncatedContent: content };
95
+ }
96
+ let needsCollapse = false;
97
+ let result = content;
98
+ if (maxLines !== void 0 && originalLineCount > maxLines) {
99
+ needsCollapse = true;
100
+ result = truncateByLines(result, maxLines);
101
+ }
102
+ if (maxLength !== void 0 && result.length > maxLength) {
103
+ needsCollapse = true;
104
+ result = smartTruncate(result, maxLength);
105
+ }
106
+ return { shouldCollapse: needsCollapse, truncatedContent: result };
107
+ }, [content, maxLength, maxLines, originalLineCount]);
108
+ const displayContent = useMemo(() => {
109
+ if (!shouldCollapse || !isCollapsed) {
110
+ return content;
111
+ }
112
+ return truncatedContent;
113
+ }, [content, truncatedContent, shouldCollapse, isCollapsed]);
114
+ const toggleCollapsed = useCallback(() => {
115
+ setIsCollapsed((prev) => !prev);
116
+ }, []);
117
+ const setCollapsed = useCallback((collapsed) => {
118
+ setIsCollapsed(collapsed);
119
+ }, []);
120
+ return {
121
+ isCollapsed,
122
+ toggleCollapsed,
123
+ setCollapsed,
124
+ displayContent,
125
+ shouldCollapse,
126
+ originalLength,
127
+ originalLineCount
128
+ };
129
+ }
130
+ __name(useCollapsibleContent, "useCollapsibleContent");
131
+ function extractTextFromChildren(children) {
132
+ if (typeof children === "string") return children;
133
+ if (typeof children === "number") return String(children);
134
+ if (React6.isValidElement(children)) {
135
+ const props = children.props;
136
+ return extractTextFromChildren(props.children);
137
+ }
138
+ if (Array.isArray(children)) {
139
+ return children.map(extractTextFromChildren).join("");
140
+ }
141
+ return "";
142
+ }
143
+ __name(extractTextFromChildren, "extractTextFromChildren");
144
+ function looksLikePlainProse(text) {
145
+ const trimmed = text.trim();
146
+ if (trimmed.length === 0) return true;
147
+ if (trimmed.length > 500) return false;
148
+ if (/\n\s*\n/.test(trimmed)) return false;
149
+ const newlineCount = (trimmed.match(/\n/g) || []).length;
150
+ if (newlineCount > 4) return false;
151
+ if (hasMarkdownSyntax(trimmed)) return false;
152
+ return true;
153
+ }
154
+ __name(looksLikePlainProse, "looksLikePlainProse");
155
+ function hasMarkdownSyntax(text) {
156
+ if (text.trim().includes("\n")) return true;
157
+ if (/<\/?[a-zA-Z][a-zA-Z0-9-]*(\s[^>]*)?\/?>/.test(text)) return true;
158
+ const patterns = [
159
+ /^#{1,6}\s/m,
160
+ // Headers
161
+ /\*\*[^*]+\*\*/,
162
+ // Bold
163
+ /\*[^*]+\*/,
164
+ // Italic
165
+ /__[^_]+__/,
166
+ // Bold (underscore)
167
+ /_[^_]+_/,
168
+ // Italic (underscore)
169
+ /\[.+\]\(.+\)/,
170
+ // Links
171
+ /!\[.*\]\(.+\)/,
172
+ // Images
173
+ /```[\s\S]*```/,
174
+ // Code blocks
175
+ /`[^`]+`/,
176
+ // Inline code
177
+ /^\s*[-*+]\s/m,
178
+ // Unordered lists
179
+ /^\s*\d+\.\s/m,
180
+ // Ordered lists
181
+ /^\s*>/m,
182
+ // Blockquotes
183
+ /\|.+\|/,
184
+ // Tables
185
+ /^---+$/m,
186
+ // Horizontal rules
187
+ /~~[^~]+~~/
188
+ // Strikethrough
189
+ ];
190
+ return patterns.some((p) => p.test(text));
191
+ }
192
+ __name(hasMarkdownSyntax, "hasMarkdownSyntax");
193
+ var MermaidClient = lazy(() => import('./Mermaid.client-NL4SVR7F.mjs'));
194
+ var LoadingFallback = /* @__PURE__ */ __name(() => /* @__PURE__ */ jsx("div", { className: "flex justify-center items-center min-h-[100px]", children: /* @__PURE__ */ jsx("div", { className: "animate-spin rounded-full h-6 w-6 border-b-2 border-primary" }) }), "LoadingFallback");
195
+ var Mermaid = /* @__PURE__ */ __name((props) => {
196
+ return /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(LoadingFallback, {}), children: /* @__PURE__ */ jsx(MermaidClient, { ...props }) });
197
+ }, "Mermaid");
198
+ var Mermaid_default = Mermaid;
199
+ var PrettyCodeClient = lazy(() => import('./PrettyCode.client-ZGYGKE7G.mjs'));
200
+ var LoadingFallback2 = /* @__PURE__ */ __name(() => /* @__PURE__ */ jsx("div", { className: "relative rounded-sm border border-border overflow-hidden bg-muted dark:bg-zinc-900", children: /* @__PURE__ */ jsx("div", { className: "p-4", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
201
+ /* @__PURE__ */ jsx("div", { className: "animate-pulse h-4 w-4 rounded-full bg-muted-foreground/20" }),
202
+ /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: "Loading code..." })
203
+ ] }) }) }), "LoadingFallback");
204
+ var PrettyCode = /* @__PURE__ */ __name((props) => {
205
+ return /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(LoadingFallback2, {}), children: /* @__PURE__ */ jsx(PrettyCodeClient, { ...props }) });
206
+ }, "PrettyCode");
207
+ var PrettyCode_default = PrettyCode;
208
+ var HTML_SCHEMA_BASE = {
209
+ ...defaultSchema,
210
+ tagNames: [
211
+ ...defaultSchema.tagNames ?? [],
212
+ "br",
213
+ "b",
214
+ "i",
215
+ "u",
216
+ "s",
217
+ "sub",
218
+ "sup",
219
+ "small",
220
+ "mark",
221
+ "kbd",
222
+ "code",
223
+ "pre",
224
+ "details",
225
+ "summary"
226
+ ]
227
+ };
228
+ function buildSchema(extraProtocols) {
229
+ if (!extraProtocols || extraProtocols.length === 0) return HTML_SCHEMA_BASE;
230
+ const baseProtocols = HTML_SCHEMA_BASE.protocols ?? defaultSchema.protocols ?? {};
231
+ const baseHref = baseProtocols.href ?? ["http", "https", "mailto", "xmpp", "irc", "ircs"];
232
+ return {
233
+ ...HTML_SCHEMA_BASE,
234
+ protocols: {
235
+ ...baseProtocols,
236
+ href: [...baseHref, ...extraProtocols]
237
+ }
238
+ };
239
+ }
240
+ __name(buildSchema, "buildSchema");
241
+ function buildUrlTransform(extraProtocols) {
242
+ if (!extraProtocols || extraProtocols.length === 0) return void 0;
243
+ const lower = extraProtocols.map((p) => p.toLowerCase() + ":");
244
+ return (url) => {
245
+ const u = url.trim().toLowerCase();
246
+ for (const p of lower) {
247
+ if (u.startsWith(p)) return url;
248
+ }
249
+ if (/^(https?:|mailto:|tel:|xmpp:|irc:|ircs:|#|\/|\.\/|\.\.\/|\?)/i.test(u) || /^[a-z0-9._~!$&'()*+,;=:@%-]+$/i.test(u)) {
250
+ return url;
251
+ }
252
+ return "";
253
+ };
254
+ }
255
+ __name(buildUrlTransform, "buildUrlTransform");
256
+ var CodeBlock = /* @__PURE__ */ __name(({ code, language }) => {
257
+ const theme = useResolvedTheme();
258
+ return /* @__PURE__ */ jsx("div", { className: "my-2", children: /* @__PURE__ */ jsx(
259
+ PrettyCode_default,
260
+ {
261
+ data: code,
262
+ language,
263
+ className: "text-xs",
264
+ customBg: "bg-code",
265
+ mode: theme,
266
+ isCompact: true,
267
+ scrollIsolation: false
268
+ }
269
+ ) });
270
+ }, "CodeBlock");
271
+ var CodeBlockFallback = /* @__PURE__ */ __name(({ code, isUser }) => {
272
+ const copyHoverClass = isUser ? "hover:bg-white/20 text-white" : "hover:bg-muted-foreground/20 text-muted-foreground hover:text-foreground";
273
+ const copyButtonClass = `absolute top-2 right-2 z-10 opacity-0 group-hover:opacity-100 transition-opacity h-8 w-8 ${copyHoverClass}`;
274
+ return /* @__PURE__ */ jsxs("div", { className: "relative group my-3", children: [
275
+ /* @__PURE__ */ jsx(
276
+ CopyButton,
277
+ {
278
+ value: code,
279
+ variant: "ghost",
280
+ className: copyButtonClass,
281
+ title: "Copy code"
282
+ }
283
+ ),
284
+ /* @__PURE__ */ jsx("pre", { className: "p-3 rounded text-xs font-mono overflow-x-auto bg-code text-code-foreground border border-code-border", children: /* @__PURE__ */ jsx("code", { children: code }) })
285
+ ] });
286
+ }, "CodeBlockFallback");
287
+ function createMarkdownComponents(isUser = false, isCompact = false) {
288
+ const textSize = isCompact ? "text-xs" : "text-sm";
289
+ const headingBase = isCompact ? "text-sm" : "text-base";
290
+ const headingSm = isCompact ? "text-xs" : "text-sm";
291
+ return {
292
+ h1: /* @__PURE__ */ __name(({ children }) => /* @__PURE__ */ jsx("h1", { className: `${headingBase} font-semibold mb-2 mt-3 first:mt-0`, children }), "h1"),
293
+ h2: /* @__PURE__ */ __name(({ children }) => /* @__PURE__ */ jsx("h2", { className: `${headingSm} font-semibold mb-2 mt-3 first:mt-0`, children }), "h2"),
294
+ h3: /* @__PURE__ */ __name(({ children }) => /* @__PURE__ */ jsx("h3", { className: `${headingSm} font-semibold mb-1 mt-2 first:mt-0`, children }), "h3"),
295
+ h4: /* @__PURE__ */ __name(({ children }) => /* @__PURE__ */ jsx("h4", { className: `${headingSm} font-semibold mb-1 mt-2 first:mt-0`, children }), "h4"),
296
+ h5: /* @__PURE__ */ __name(({ children }) => /* @__PURE__ */ jsx("h5", { className: `${headingSm} font-medium mb-1 mt-2 first:mt-0`, children }), "h5"),
297
+ h6: /* @__PURE__ */ __name(({ children }) => /* @__PURE__ */ jsx("h6", { className: `${headingSm} font-medium mb-1 mt-2 first:mt-0`, children }), "h6"),
298
+ p: /* @__PURE__ */ __name(({ children }) => /* @__PURE__ */ jsx("p", { className: `${textSize} mb-4 last:mb-0 leading-relaxed break-words`, children }), "p"),
299
+ ul: /* @__PURE__ */ __name(({ children }) => /* @__PURE__ */ jsx("ul", { className: `list-disc list-inside mb-2 space-y-1 ${textSize}`, children }), "ul"),
300
+ ol: /* @__PURE__ */ __name(({ children }) => /* @__PURE__ */ jsx("ol", { className: `list-decimal list-inside mb-2 space-y-1 ${textSize}`, children }), "ol"),
301
+ li: /* @__PURE__ */ __name(({ children }) => /* @__PURE__ */ jsx("li", { className: "break-words", children }), "li"),
302
+ // `target` / `rel` for external links are NOT set here — the
303
+ // rehype-external-links plugin tags them on the rehype side, so
304
+ // every `<a>` that sanitize let through gets the same security
305
+ // treatment regardless of which renderer (default vs linkRules
306
+ // override) emitted it. Doing it twice here would just duplicate
307
+ // attributes; doing it only here would miss the linkRules path.
308
+ a: /* @__PURE__ */ __name(({ href, children, ...rest }) => /* @__PURE__ */ jsx(
309
+ "a",
310
+ {
311
+ ...rest,
312
+ href,
313
+ className: `${textSize} ${isUser ? "text-white/90 underline hover:text-white" : "text-primary underline hover:text-primary/80"} transition-colors break-all`,
314
+ children
315
+ }
316
+ ), "a"),
317
+ pre: /* @__PURE__ */ __name(({ children }) => {
318
+ let codeContent = "";
319
+ let language = "plaintext";
320
+ if (React6.isValidElement(children)) {
321
+ const child = children;
322
+ if (child.type === "code" || typeof child.type === "function" && child.type.name === "code") {
323
+ const codeProps = child.props;
324
+ const rawClassName = codeProps.className;
325
+ language = rawClassName?.replace(/language-/, "").trim() || "plaintext";
326
+ codeContent = extractTextFromChildren(codeProps.children).trim();
327
+ } else {
328
+ codeContent = extractTextFromChildren(children).trim();
329
+ }
330
+ } else {
331
+ codeContent = extractTextFromChildren(children).trim();
332
+ }
333
+ if (!codeContent) {
334
+ return /* @__PURE__ */ jsx("div", { className: "my-3 p-3 bg-muted rounded text-sm text-muted-foreground", children: "No content available" });
335
+ }
336
+ if (language === "mermaid") {
337
+ return /* @__PURE__ */ jsx("div", { className: "my-3 w-full", children: /* @__PURE__ */ jsx(Mermaid_default, { chart: codeContent, isCompact }) });
338
+ }
339
+ try {
340
+ return /* @__PURE__ */ jsx(CodeBlock, { code: codeContent, language, isUser, isCompact });
341
+ } catch (error) {
342
+ console.warn("CodeBlock failed, using fallback:", error);
343
+ return /* @__PURE__ */ jsx(CodeBlockFallback, { code: codeContent, language, isUser, isCompact });
344
+ }
345
+ }, "pre"),
346
+ code: /* @__PURE__ */ __name(({ children, className }) => {
347
+ if (className?.includes("language-")) {
348
+ return /* @__PURE__ */ jsx("code", { className, children });
349
+ }
350
+ const inlineCodeClass = isUser ? "bg-primary-foreground/15 text-primary-foreground" : "bg-code-inline text-code-inline-foreground";
351
+ return /* @__PURE__ */ jsx("code", { className: `px-1 py-0.5 rounded font-mono text-[0.875em] ${inlineCodeClass} break-all`, children: extractTextFromChildren(children) });
352
+ }, "code"),
353
+ // Modern chat convention drops italic on blockquotes — italic +
354
+ // tight bubble = hard to read. Border-left at 2px (4px reads
355
+ // heavy in a 320–480px bubble). On the saturated user bubble we
356
+ // use a primary-foreground tint; on the assistant bubble we use
357
+ // the muted-foreground role for de-emphasis.
358
+ blockquote: /* @__PURE__ */ __name(({ children }) => {
359
+ const cls = isUser ? "border-primary-foreground/40 text-primary-foreground/80" : "border-border text-muted-foreground";
360
+ return /* @__PURE__ */ jsx("blockquote", { className: `${textSize} border-l-2 pl-3 my-3 break-words ${cls}`, children });
361
+ }, "blockquote"),
362
+ // Tables: outer wrapper handles overflow, inner `<table>`
363
+ // inherits the chat-density text size. Borders / header use
364
+ // semantic tokens — `border-code-border` for the assistant
365
+ // (matches the code-fence panel for visual cohesion when both
366
+ // appear in the same reply); primary-foreground/N for the user
367
+ // bubble so lines read against the saturated `bg-primary`.
368
+ table: /* @__PURE__ */ __name(({ children }) => /* @__PURE__ */ jsx("div", { className: "overflow-x-auto my-3", children: /* @__PURE__ */ jsx("table", { className: `min-w-full ${textSize} border-collapse`, children }) }), "table"),
369
+ thead: /* @__PURE__ */ __name(({ children }) => /* @__PURE__ */ jsx("thead", { className: isUser ? "bg-primary-foreground/10" : "bg-muted/40", children }), "thead"),
370
+ tbody: /* @__PURE__ */ __name(({ children }) => /* @__PURE__ */ jsx("tbody", { children }), "tbody"),
371
+ tr: /* @__PURE__ */ __name(({ children }) => /* @__PURE__ */ jsx("tr", { className: isUser ? "border-b border-primary-foreground/15" : "border-b border-border", children }), "tr"),
372
+ th: /* @__PURE__ */ __name(({ children }) => {
373
+ const borderCls = isUser ? "border-primary-foreground/25" : "border-border";
374
+ return /* @__PURE__ */ jsx("th", { className: `px-2 py-1.5 text-left font-semibold border-b ${borderCls} break-words`, children });
375
+ }, "th"),
376
+ td: /* @__PURE__ */ __name(({ children }) => /* @__PURE__ */ jsx("td", { className: "px-2 py-1.5 break-words", children }), "td"),
377
+ // Soft separator. ChatGPT / Slack / Linear strip the visible
378
+ // line, Claude.ai keeps a hairline. We follow Claude — present
379
+ // but quiet. Palette switches by role so the hairline reads on
380
+ // both surfaces.
381
+ hr: /* @__PURE__ */ __name(() => /* @__PURE__ */ jsx(
382
+ "hr",
383
+ {
384
+ className: `my-4 border-0 h-px ${isUser ? "bg-primary-foreground/20" : "bg-border"}`
385
+ }
386
+ ), "hr"),
387
+ strong: /* @__PURE__ */ __name(({ children }) => /* @__PURE__ */ jsx("strong", { className: "font-semibold", children }), "strong"),
388
+ em: /* @__PURE__ */ __name(({ children }) => /* @__PURE__ */ jsx("em", { className: "italic", children }), "em")
389
+ };
390
+ }
391
+ __name(createMarkdownComponents, "createMarkdownComponents");
392
+ var CollapseToggle = /* @__PURE__ */ __name(({
393
+ isCollapsed,
394
+ onClick,
395
+ readMoreLabel,
396
+ showLessLabel,
397
+ isUser,
398
+ isCompact
399
+ }) => {
400
+ const textSize = isCompact ? "text-xs" : "text-sm";
401
+ return /* @__PURE__ */ jsx(
402
+ "button",
403
+ {
404
+ type: "button",
405
+ onClick,
406
+ className: `
407
+ ${textSize} font-medium cursor-pointer
408
+ transition-colors duration-200
409
+ ${isUser ? "text-white/80 hover:text-white" : "text-primary hover:text-primary/80"}
410
+ inline-flex items-center gap-1
411
+ mt-1
412
+ `,
413
+ children: isCollapsed ? /* @__PURE__ */ jsxs(Fragment, { children: [
414
+ readMoreLabel,
415
+ /* @__PURE__ */ jsx(Chevron, { direction: "down" })
416
+ ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
417
+ showLessLabel,
418
+ /* @__PURE__ */ jsx(Chevron, { direction: "up" })
419
+ ] })
420
+ }
421
+ );
422
+ }, "CollapseToggle");
423
+ function Chevron({ direction }) {
424
+ return /* @__PURE__ */ jsx("svg", { className: "w-3 h-3", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx(
425
+ "path",
426
+ {
427
+ strokeLinecap: "round",
428
+ strokeLinejoin: "round",
429
+ strokeWidth: 2,
430
+ d: direction === "down" ? "M19 9l-7 7-7-7" : "M5 15l7-7 7 7"
431
+ }
432
+ ) });
433
+ }
434
+ __name(Chevron, "Chevron");
435
+ function applyPreprocess(source, rules) {
436
+ if (!rules || rules.length === 0) return source;
437
+ let s = source;
438
+ for (const rule of rules) {
439
+ if (!rule.preprocess) continue;
440
+ try {
441
+ s = rule.preprocess(s);
442
+ } catch (err) {
443
+ console.warn(
444
+ `[MarkdownMessage] linkRule "${rule.name ?? "(anonymous)"}" preprocess threw; skipping`,
445
+ err
446
+ );
447
+ }
448
+ }
449
+ return s;
450
+ }
451
+ __name(applyPreprocess, "applyPreprocess");
452
+ function collectProtocols(extraHrefProtocols, rules) {
453
+ const set = /* @__PURE__ */ new Set();
454
+ if (extraHrefProtocols) for (const p of extraHrefProtocols) set.add(p);
455
+ if (rules) {
456
+ for (const r of rules) {
457
+ if (r.protocols) for (const p of r.protocols) set.add(p);
458
+ }
459
+ }
460
+ return set.size === 0 ? void 0 : Array.from(set);
461
+ }
462
+ __name(collectProtocols, "collectProtocols");
463
+ function buildLinkRulesComponent(rules, isUser, callerA) {
464
+ const Renderer = /* @__PURE__ */ __name((props) => {
465
+ const { href, children } = props;
466
+ if (typeof href === "string") {
467
+ for (const rule of rules) {
468
+ if (rule.match(href)) {
469
+ return React6.createElement(
470
+ React6.Fragment,
471
+ null,
472
+ rule.render({ href, children, isUser })
473
+ );
474
+ }
475
+ }
476
+ }
477
+ if (callerA && typeof callerA === "function") {
478
+ const Caller = callerA;
479
+ return React6.createElement(Caller, props);
480
+ }
481
+ return React6.createElement("a", props, children);
482
+ }, "Renderer");
483
+ return Renderer;
484
+ }
485
+ __name(buildLinkRulesComponent, "buildLinkRulesComponent");
486
+ var MarkdownMessage = /* @__PURE__ */ __name(({
487
+ content,
488
+ className = "",
489
+ isUser = false,
490
+ isCompact = false,
491
+ plainText,
492
+ customComponents,
493
+ extraHrefProtocols,
494
+ linkRules,
495
+ collapsible = false,
496
+ maxLength,
497
+ maxLines,
498
+ readMoreLabel = "Read more...",
499
+ showLessLabel = "Show less",
500
+ defaultExpanded = false,
501
+ onCollapseChange
502
+ }) => {
503
+ const preprocessed = React6.useMemo(
504
+ () => applyPreprocess(content, linkRules),
505
+ [content, linkRules]
506
+ );
507
+ const effectiveProtocols = React6.useMemo(
508
+ () => collectProtocols(extraHrefProtocols, linkRules),
509
+ [extraHrefProtocols, linkRules]
510
+ );
511
+ const effectiveCustomComponents = React6.useMemo(() => {
512
+ if (!linkRules || linkRules.length === 0) return customComponents;
513
+ const callerA = customComponents?.a;
514
+ const aRenderer = buildLinkRulesComponent(linkRules, isUser, callerA);
515
+ return { ...customComponents ?? {}, a: aRenderer };
516
+ }, [customComponents, linkRules, isUser]);
517
+ const trimmedContent = preprocessed.trim();
518
+ const collapsibleOptions = React6.useMemo(() => {
519
+ if (!collapsible) return {};
520
+ return {
521
+ maxLength: maxLength ?? 1e3,
522
+ maxLines: maxLines ?? 10,
523
+ defaultExpanded
524
+ };
525
+ }, [collapsible, maxLength, maxLines, defaultExpanded]);
526
+ const { isCollapsed, toggleCollapsed, displayContent, shouldCollapse } = useCollapsibleContent(trimmedContent, collapsible ? collapsibleOptions : {});
527
+ React6.useEffect(() => {
528
+ if (collapsible && shouldCollapse && onCollapseChange) {
529
+ onCollapseChange(isCollapsed);
530
+ }
531
+ }, [isCollapsed, collapsible, shouldCollapse, onCollapseChange]);
532
+ const components = React6.useMemo(() => {
533
+ const base = createMarkdownComponents(isUser, isCompact);
534
+ return effectiveCustomComponents ? { ...base, ...effectiveCustomComponents } : base;
535
+ }, [isUser, isCompact, effectiveCustomComponents]);
536
+ const schema = React6.useMemo(() => buildSchema(effectiveProtocols), [effectiveProtocols]);
537
+ const urlTransform = React6.useMemo(
538
+ () => buildUrlTransform(effectiveProtocols),
539
+ [effectiveProtocols]
540
+ );
541
+ const textSizeClass = isCompact ? "text-xs" : "text-sm";
542
+ const proseClass = isCompact ? "prose-xs" : "prose-sm";
543
+ const customComponentsBeyondLinks = React6.useMemo(() => {
544
+ if (!customComponents) return false;
545
+ return Object.keys(customComponents).some((k) => k !== "a");
546
+ }, [customComponents]);
547
+ const isPlainText = plainText !== void 0 ? plainText : !customComponentsBeyondLinks && looksLikePlainProse(displayContent);
548
+ if (isPlainText) {
549
+ return /* @__PURE__ */ jsxs(
550
+ "div",
551
+ {
552
+ className: `${textSizeClass} font-normal antialiased leading-snug break-words whitespace-pre-wrap ${className}`,
553
+ children: [
554
+ displayContent,
555
+ collapsible && shouldCollapse && /* @__PURE__ */ jsxs(Fragment, { children: [
556
+ isCollapsed && "... ",
557
+ /* @__PURE__ */ jsx(
558
+ CollapseToggle,
559
+ {
560
+ isCollapsed,
561
+ onClick: toggleCollapsed,
562
+ readMoreLabel,
563
+ showLessLabel,
564
+ isUser,
565
+ isCompact
566
+ }
567
+ )
568
+ ] })
569
+ ]
570
+ }
571
+ );
572
+ }
573
+ return /* @__PURE__ */ jsxs("div", { className, children: [
574
+ /* @__PURE__ */ jsx(
575
+ "div",
576
+ {
577
+ className: `
578
+ prose ${proseClass} max-w-none break-words overflow-hidden ${textSizeClass} font-normal antialiased
579
+ ${isUser ? "prose-invert" : "dark:prose-invert"}
580
+ [&>*]:leading-relaxed
581
+ [&>*:first-child]:mt-0 [&>*:last-child]:mb-0
582
+ [&_p]:my-2
583
+ [&_ul]:my-2 [&_ol]:my-2 [&_ul]:pl-5 [&_ol]:pl-5
584
+ [&_li]:my-1 [&_li>p]:my-0
585
+ [&_h1]:mt-4 [&_h1]:mb-2 [&_h1]:text-base [&_h1]:font-semibold
586
+ [&_h2]:mt-3.5 [&_h2]:mb-1.5 [&_h2]:text-[15px] [&_h2]:font-semibold
587
+ [&_h3]:mt-3 [&_h3]:mb-1 [&_h3]:text-sm [&_h3]:font-medium
588
+ [&_h4]:mt-3 [&_h4]:mb-1 [&_h4]:text-sm [&_h4]:font-medium
589
+ `,
590
+ style: {
591
+ // Inherit colors from parent — fixes issues with external
592
+ // CSS variables overriding prose tokens.
593
+ "--tw-prose-body": "inherit",
594
+ "--tw-prose-headings": "inherit",
595
+ "--tw-prose-bold": "inherit",
596
+ "--tw-prose-links": "inherit",
597
+ color: "inherit"
598
+ },
599
+ children: /* @__PURE__ */ jsx(
600
+ ReactMarkdown,
601
+ {
602
+ remarkPlugins: [remarkGfm, remarkBreaks, remarkSmartypants, remarkEmoji],
603
+ rehypePlugins: [
604
+ rehypeRaw,
605
+ [rehypeSanitize, schema],
606
+ [rehypeExternalLinks, { target: "_blank", rel: ["noopener", "noreferrer"] }]
607
+ ],
608
+ components,
609
+ urlTransform,
610
+ children: displayContent
611
+ }
612
+ )
613
+ }
614
+ ),
615
+ collapsible && shouldCollapse && /* @__PURE__ */ jsx(
616
+ CollapseToggle,
617
+ {
618
+ isCollapsed,
619
+ onClick: toggleCollapsed,
620
+ readMoreLabel,
621
+ showLessLabel,
622
+ isUser,
623
+ isCompact
624
+ }
625
+ )
626
+ ] });
627
+ }, "MarkdownMessage");
628
+
629
+ export { MarkdownMessage, Mermaid_default, PrettyCode_default, extractTextFromChildren, useCollapsibleContent };
630
+ //# sourceMappingURL=chunk-2ZLKZ5VR.mjs.map
631
+ //# sourceMappingURL=chunk-2ZLKZ5VR.mjs.map