@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
@@ -1,1597 +0,0 @@
1
- 'use strict';
2
-
3
- var chunkWGEGR3DF_cjs = require('./chunk-WGEGR3DF.cjs');
4
- var React6 = require('react');
5
- require('@djangocfg/ui-core/styles/palette');
6
- var jsxRuntime = require('react/jsx-runtime');
7
- var ReactMarkdown = require('react-markdown');
8
- var rehypeExternalLinks = require('rehype-external-links');
9
- var rehypeRaw = require('rehype-raw');
10
- var rehypeSanitize = require('rehype-sanitize');
11
- var remarkBreaks = require('remark-breaks');
12
- var remarkEmoji = require('remark-emoji');
13
- var remarkGfm = require('remark-gfm');
14
- var remarkSmartypants = require('remark-smartypants');
15
- var components = require('@djangocfg/ui-core/components');
16
- var hooks = require('@djangocfg/ui-core/hooks');
17
- var consola2 = require('consola');
18
- var openapiSampler = require('openapi-sampler');
19
-
20
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
21
-
22
- var React6__default = /*#__PURE__*/_interopDefault(React6);
23
- var ReactMarkdown__default = /*#__PURE__*/_interopDefault(ReactMarkdown);
24
- var rehypeExternalLinks__default = /*#__PURE__*/_interopDefault(rehypeExternalLinks);
25
- var rehypeRaw__default = /*#__PURE__*/_interopDefault(rehypeRaw);
26
- var rehypeSanitize__default = /*#__PURE__*/_interopDefault(rehypeSanitize);
27
- var remarkBreaks__default = /*#__PURE__*/_interopDefault(remarkBreaks);
28
- var remarkEmoji__default = /*#__PURE__*/_interopDefault(remarkEmoji);
29
- var remarkGfm__default = /*#__PURE__*/_interopDefault(remarkGfm);
30
- var remarkSmartypants__default = /*#__PURE__*/_interopDefault(remarkSmartypants);
31
- var consola2__default = /*#__PURE__*/_interopDefault(consola2);
32
-
33
- function smartTruncate(content, maxLength) {
34
- if (content.length <= maxLength) {
35
- return content;
36
- }
37
- let breakPoint = maxLength;
38
- while (breakPoint > maxLength - 50 && breakPoint > 0) {
39
- const char = content[breakPoint];
40
- if (char === " " || char === "\n" || char === " ") {
41
- break;
42
- }
43
- breakPoint--;
44
- }
45
- if (breakPoint <= maxLength - 50) {
46
- breakPoint = maxLength;
47
- }
48
- let truncated = content.slice(0, breakPoint).trimEnd();
49
- truncated = fixUnclosedMarkdown(truncated);
50
- return truncated;
51
- }
52
- chunkWGEGR3DF_cjs.__name(smartTruncate, "smartTruncate");
53
- function truncateByLines(content, maxLines) {
54
- const lines = content.split("\n");
55
- if (lines.length <= maxLines) {
56
- return content;
57
- }
58
- let truncated = lines.slice(0, maxLines).join("\n").trimEnd();
59
- truncated = fixUnclosedMarkdown(truncated);
60
- return truncated;
61
- }
62
- chunkWGEGR3DF_cjs.__name(truncateByLines, "truncateByLines");
63
- function fixUnclosedMarkdown(content) {
64
- let result = content;
65
- const countOccurrences = /* @__PURE__ */ chunkWGEGR3DF_cjs.__name((str, marker) => {
66
- const escaped = marker.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
67
- const matches = str.match(new RegExp(escaped, "g"));
68
- return matches ? matches.length : 0;
69
- }, "countOccurrences");
70
- const boldCount = countOccurrences(result, "**");
71
- if (boldCount % 2 !== 0) {
72
- result += "**";
73
- }
74
- const withoutBold = result.replace(/\*\*/g, "");
75
- const italicCount = countOccurrences(withoutBold, "*");
76
- if (italicCount % 2 !== 0) {
77
- result += "*";
78
- }
79
- const codeCount = countOccurrences(result, "`");
80
- const tripleCount = countOccurrences(result, "```");
81
- const singleCodeCount = codeCount - tripleCount * 3;
82
- if (singleCodeCount % 2 !== 0) {
83
- result += "`";
84
- }
85
- if (tripleCount % 2 !== 0) {
86
- result += "\n```";
87
- }
88
- const strikeCount = countOccurrences(result, "~~");
89
- if (strikeCount % 2 !== 0) {
90
- result += "~~";
91
- }
92
- const underlineBoldCount = countOccurrences(result, "__");
93
- if (underlineBoldCount % 2 !== 0) {
94
- result += "__";
95
- }
96
- const withoutUnderlineBold = result.replace(/__/g, "");
97
- const underlineItalicCount = countOccurrences(withoutUnderlineBold, "_");
98
- if (underlineItalicCount % 2 !== 0) {
99
- result += "_";
100
- }
101
- return result;
102
- }
103
- chunkWGEGR3DF_cjs.__name(fixUnclosedMarkdown, "fixUnclosedMarkdown");
104
- function useCollapsibleContent(content, options = {}) {
105
- const { maxLength, maxLines, defaultExpanded = false } = options;
106
- const [isCollapsed, setIsCollapsed] = React6.useState(!defaultExpanded);
107
- const originalLength = content.length;
108
- const originalLineCount = content.split("\n").length;
109
- const { shouldCollapse, truncatedContent } = React6.useMemo(() => {
110
- if (maxLength === void 0 && maxLines === void 0) {
111
- return { shouldCollapse: false, truncatedContent: content };
112
- }
113
- let needsCollapse = false;
114
- let result = content;
115
- if (maxLines !== void 0 && originalLineCount > maxLines) {
116
- needsCollapse = true;
117
- result = truncateByLines(result, maxLines);
118
- }
119
- if (maxLength !== void 0 && result.length > maxLength) {
120
- needsCollapse = true;
121
- result = smartTruncate(result, maxLength);
122
- }
123
- return { shouldCollapse: needsCollapse, truncatedContent: result };
124
- }, [content, maxLength, maxLines, originalLineCount]);
125
- const displayContent = React6.useMemo(() => {
126
- if (!shouldCollapse || !isCollapsed) {
127
- return content;
128
- }
129
- return truncatedContent;
130
- }, [content, truncatedContent, shouldCollapse, isCollapsed]);
131
- const toggleCollapsed = React6.useCallback(() => {
132
- setIsCollapsed((prev) => !prev);
133
- }, []);
134
- const setCollapsed = React6.useCallback((collapsed) => {
135
- setIsCollapsed(collapsed);
136
- }, []);
137
- return {
138
- isCollapsed,
139
- toggleCollapsed,
140
- setCollapsed,
141
- displayContent,
142
- shouldCollapse,
143
- originalLength,
144
- originalLineCount
145
- };
146
- }
147
- chunkWGEGR3DF_cjs.__name(useCollapsibleContent, "useCollapsibleContent");
148
- function extractTextFromChildren(children) {
149
- if (typeof children === "string") return children;
150
- if (typeof children === "number") return String(children);
151
- if (React6__default.default.isValidElement(children)) {
152
- const props = children.props;
153
- return extractTextFromChildren(props.children);
154
- }
155
- if (Array.isArray(children)) {
156
- return children.map(extractTextFromChildren).join("");
157
- }
158
- return "";
159
- }
160
- chunkWGEGR3DF_cjs.__name(extractTextFromChildren, "extractTextFromChildren");
161
- function looksLikePlainProse(text) {
162
- const trimmed = text.trim();
163
- if (trimmed.length === 0) return true;
164
- if (trimmed.length > 500) return false;
165
- if (/\n\s*\n/.test(trimmed)) return false;
166
- const newlineCount = (trimmed.match(/\n/g) || []).length;
167
- if (newlineCount > 4) return false;
168
- if (hasMarkdownSyntax(trimmed)) return false;
169
- return true;
170
- }
171
- chunkWGEGR3DF_cjs.__name(looksLikePlainProse, "looksLikePlainProse");
172
- function hasMarkdownSyntax(text) {
173
- if (text.trim().includes("\n")) return true;
174
- if (/<\/?[a-zA-Z][a-zA-Z0-9-]*(\s[^>]*)?\/?>/.test(text)) return true;
175
- const patterns = [
176
- /^#{1,6}\s/m,
177
- // Headers
178
- /\*\*[^*]+\*\*/,
179
- // Bold
180
- /\*[^*]+\*/,
181
- // Italic
182
- /__[^_]+__/,
183
- // Bold (underscore)
184
- /_[^_]+_/,
185
- // Italic (underscore)
186
- /\[.+\]\(.+\)/,
187
- // Links
188
- /!\[.*\]\(.+\)/,
189
- // Images
190
- /```[\s\S]*```/,
191
- // Code blocks
192
- /`[^`]+`/,
193
- // Inline code
194
- /^\s*[-*+]\s/m,
195
- // Unordered lists
196
- /^\s*\d+\.\s/m,
197
- // Ordered lists
198
- /^\s*>/m,
199
- // Blockquotes
200
- /\|.+\|/,
201
- // Tables
202
- /^---+$/m,
203
- // Horizontal rules
204
- /~~[^~]+~~/
205
- // Strikethrough
206
- ];
207
- return patterns.some((p) => p.test(text));
208
- }
209
- chunkWGEGR3DF_cjs.__name(hasMarkdownSyntax, "hasMarkdownSyntax");
210
- var MermaidClient = React6.lazy(() => import('./Mermaid.client-W76R5AKJ.cjs'));
211
- var LoadingFallback = /* @__PURE__ */ chunkWGEGR3DF_cjs.__name(() => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center items-center min-h-[100px]", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "animate-spin rounded-full h-6 w-6 border-b-2 border-primary" }) }), "LoadingFallback");
212
- var Mermaid = /* @__PURE__ */ chunkWGEGR3DF_cjs.__name((props) => {
213
- return /* @__PURE__ */ jsxRuntime.jsx(React6.Suspense, { fallback: /* @__PURE__ */ jsxRuntime.jsx(LoadingFallback, {}), children: /* @__PURE__ */ jsxRuntime.jsx(MermaidClient, { ...props }) });
214
- }, "Mermaid");
215
- var Mermaid_default = Mermaid;
216
- var PrettyCodeClient = React6.lazy(() => import('./PrettyCode.client-RPDIE5CH.cjs'));
217
- var LoadingFallback2 = /* @__PURE__ */ chunkWGEGR3DF_cjs.__name(() => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "relative rounded-sm border border-border overflow-hidden bg-muted dark:bg-zinc-900", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-4", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
218
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "animate-pulse h-4 w-4 rounded-full bg-muted-foreground/20" }),
219
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs text-muted-foreground", children: "Loading code..." })
220
- ] }) }) }), "LoadingFallback");
221
- var PrettyCode = /* @__PURE__ */ chunkWGEGR3DF_cjs.__name((props) => {
222
- return /* @__PURE__ */ jsxRuntime.jsx(React6.Suspense, { fallback: /* @__PURE__ */ jsxRuntime.jsx(LoadingFallback2, {}), children: /* @__PURE__ */ jsxRuntime.jsx(PrettyCodeClient, { ...props }) });
223
- }, "PrettyCode");
224
- var PrettyCode_default = PrettyCode;
225
- var HTML_SCHEMA_BASE = {
226
- ...rehypeSanitize.defaultSchema,
227
- tagNames: [
228
- ...rehypeSanitize.defaultSchema.tagNames ?? [],
229
- "br",
230
- "b",
231
- "i",
232
- "u",
233
- "s",
234
- "sub",
235
- "sup",
236
- "small",
237
- "mark",
238
- "kbd",
239
- "code",
240
- "pre",
241
- "details",
242
- "summary"
243
- ]
244
- };
245
- function buildSchema(extraProtocols) {
246
- if (!extraProtocols || extraProtocols.length === 0) return HTML_SCHEMA_BASE;
247
- const baseProtocols = HTML_SCHEMA_BASE.protocols ?? rehypeSanitize.defaultSchema.protocols ?? {};
248
- const baseHref = baseProtocols.href ?? ["http", "https", "mailto", "xmpp", "irc", "ircs"];
249
- return {
250
- ...HTML_SCHEMA_BASE,
251
- protocols: {
252
- ...baseProtocols,
253
- href: [...baseHref, ...extraProtocols]
254
- }
255
- };
256
- }
257
- chunkWGEGR3DF_cjs.__name(buildSchema, "buildSchema");
258
- function buildUrlTransform(extraProtocols) {
259
- if (!extraProtocols || extraProtocols.length === 0) return void 0;
260
- const lower = extraProtocols.map((p) => p.toLowerCase() + ":");
261
- return (url) => {
262
- const u = url.trim().toLowerCase();
263
- for (const p of lower) {
264
- if (u.startsWith(p)) return url;
265
- }
266
- if (/^(https?:|mailto:|tel:|xmpp:|irc:|ircs:|#|\/|\.\/|\.\.\/|\?)/i.test(u) || /^[a-z0-9._~!$&'()*+,;=:@%-]+$/i.test(u)) {
267
- return url;
268
- }
269
- return "";
270
- };
271
- }
272
- chunkWGEGR3DF_cjs.__name(buildUrlTransform, "buildUrlTransform");
273
- var CodeBlock = /* @__PURE__ */ chunkWGEGR3DF_cjs.__name(({ code, language }) => {
274
- const theme = hooks.useResolvedTheme();
275
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "my-2", children: /* @__PURE__ */ jsxRuntime.jsx(
276
- PrettyCode_default,
277
- {
278
- data: code,
279
- language,
280
- className: "text-xs",
281
- customBg: "bg-code",
282
- mode: theme,
283
- isCompact: true,
284
- scrollIsolation: false
285
- }
286
- ) });
287
- }, "CodeBlock");
288
- var CodeBlockFallback = /* @__PURE__ */ chunkWGEGR3DF_cjs.__name(({ code, isUser }) => {
289
- const copyHoverClass = isUser ? "hover:bg-white/20 text-white" : "hover:bg-muted-foreground/20 text-muted-foreground hover:text-foreground";
290
- const copyButtonClass = `absolute top-2 right-2 z-10 opacity-0 group-hover:opacity-100 transition-opacity h-8 w-8 ${copyHoverClass}`;
291
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative group my-3", children: [
292
- /* @__PURE__ */ jsxRuntime.jsx(
293
- components.CopyButton,
294
- {
295
- value: code,
296
- variant: "ghost",
297
- className: copyButtonClass,
298
- title: "Copy code"
299
- }
300
- ),
301
- /* @__PURE__ */ jsxRuntime.jsx("pre", { className: "p-3 rounded text-xs font-mono overflow-x-auto bg-code text-code-foreground border border-code-border", children: /* @__PURE__ */ jsxRuntime.jsx("code", { children: code }) })
302
- ] });
303
- }, "CodeBlockFallback");
304
- function createMarkdownComponents(isUser = false, isCompact = false) {
305
- const textSize = isCompact ? "text-xs" : "text-sm";
306
- const headingBase = isCompact ? "text-sm" : "text-base";
307
- const headingSm = isCompact ? "text-xs" : "text-sm";
308
- return {
309
- h1: /* @__PURE__ */ chunkWGEGR3DF_cjs.__name(({ children }) => /* @__PURE__ */ jsxRuntime.jsx("h1", { className: `${headingBase} font-semibold mb-2 mt-3 first:mt-0`, children }), "h1"),
310
- h2: /* @__PURE__ */ chunkWGEGR3DF_cjs.__name(({ children }) => /* @__PURE__ */ jsxRuntime.jsx("h2", { className: `${headingSm} font-semibold mb-2 mt-3 first:mt-0`, children }), "h2"),
311
- h3: /* @__PURE__ */ chunkWGEGR3DF_cjs.__name(({ children }) => /* @__PURE__ */ jsxRuntime.jsx("h3", { className: `${headingSm} font-semibold mb-1 mt-2 first:mt-0`, children }), "h3"),
312
- h4: /* @__PURE__ */ chunkWGEGR3DF_cjs.__name(({ children }) => /* @__PURE__ */ jsxRuntime.jsx("h4", { className: `${headingSm} font-semibold mb-1 mt-2 first:mt-0`, children }), "h4"),
313
- h5: /* @__PURE__ */ chunkWGEGR3DF_cjs.__name(({ children }) => /* @__PURE__ */ jsxRuntime.jsx("h5", { className: `${headingSm} font-medium mb-1 mt-2 first:mt-0`, children }), "h5"),
314
- h6: /* @__PURE__ */ chunkWGEGR3DF_cjs.__name(({ children }) => /* @__PURE__ */ jsxRuntime.jsx("h6", { className: `${headingSm} font-medium mb-1 mt-2 first:mt-0`, children }), "h6"),
315
- p: /* @__PURE__ */ chunkWGEGR3DF_cjs.__name(({ children }) => /* @__PURE__ */ jsxRuntime.jsx("p", { className: `${textSize} mb-4 last:mb-0 leading-relaxed break-words`, children }), "p"),
316
- ul: /* @__PURE__ */ chunkWGEGR3DF_cjs.__name(({ children }) => /* @__PURE__ */ jsxRuntime.jsx("ul", { className: `list-disc list-inside mb-2 space-y-1 ${textSize}`, children }), "ul"),
317
- ol: /* @__PURE__ */ chunkWGEGR3DF_cjs.__name(({ children }) => /* @__PURE__ */ jsxRuntime.jsx("ol", { className: `list-decimal list-inside mb-2 space-y-1 ${textSize}`, children }), "ol"),
318
- li: /* @__PURE__ */ chunkWGEGR3DF_cjs.__name(({ children }) => /* @__PURE__ */ jsxRuntime.jsx("li", { className: "break-words", children }), "li"),
319
- // `target` / `rel` for external links are NOT set here — the
320
- // rehype-external-links plugin tags them on the rehype side, so
321
- // every `<a>` that sanitize let through gets the same security
322
- // treatment regardless of which renderer (default vs linkRules
323
- // override) emitted it. Doing it twice here would just duplicate
324
- // attributes; doing it only here would miss the linkRules path.
325
- a: /* @__PURE__ */ chunkWGEGR3DF_cjs.__name(({ href, children, ...rest }) => /* @__PURE__ */ jsxRuntime.jsx(
326
- "a",
327
- {
328
- ...rest,
329
- href,
330
- className: `${textSize} ${isUser ? "text-white/90 underline hover:text-white" : "text-primary underline hover:text-primary/80"} transition-colors break-all`,
331
- children
332
- }
333
- ), "a"),
334
- pre: /* @__PURE__ */ chunkWGEGR3DF_cjs.__name(({ children }) => {
335
- let codeContent = "";
336
- let language = "plaintext";
337
- if (React6__default.default.isValidElement(children)) {
338
- const child = children;
339
- if (child.type === "code" || typeof child.type === "function" && child.type.name === "code") {
340
- const codeProps = child.props;
341
- const rawClassName = codeProps.className;
342
- language = rawClassName?.replace(/language-/, "").trim() || "plaintext";
343
- codeContent = extractTextFromChildren(codeProps.children).trim();
344
- } else {
345
- codeContent = extractTextFromChildren(children).trim();
346
- }
347
- } else {
348
- codeContent = extractTextFromChildren(children).trim();
349
- }
350
- if (!codeContent) {
351
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "my-3 p-3 bg-muted rounded text-sm text-muted-foreground", children: "No content available" });
352
- }
353
- if (language === "mermaid") {
354
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "my-3 w-full", children: /* @__PURE__ */ jsxRuntime.jsx(Mermaid_default, { chart: codeContent, isCompact }) });
355
- }
356
- try {
357
- return /* @__PURE__ */ jsxRuntime.jsx(CodeBlock, { code: codeContent, language, isUser, isCompact });
358
- } catch (error) {
359
- console.warn("CodeBlock failed, using fallback:", error);
360
- return /* @__PURE__ */ jsxRuntime.jsx(CodeBlockFallback, { code: codeContent, language, isUser, isCompact });
361
- }
362
- }, "pre"),
363
- code: /* @__PURE__ */ chunkWGEGR3DF_cjs.__name(({ children, className }) => {
364
- if (className?.includes("language-")) {
365
- return /* @__PURE__ */ jsxRuntime.jsx("code", { className, children });
366
- }
367
- const inlineCodeClass = isUser ? "bg-primary-foreground/15 text-primary-foreground" : "bg-code-inline text-code-inline-foreground";
368
- return /* @__PURE__ */ jsxRuntime.jsx("code", { className: `px-1 py-0.5 rounded font-mono text-[0.875em] ${inlineCodeClass} break-all`, children: extractTextFromChildren(children) });
369
- }, "code"),
370
- // Modern chat convention drops italic on blockquotes — italic +
371
- // tight bubble = hard to read. Border-left at 2px (4px reads
372
- // heavy in a 320–480px bubble). On the saturated user bubble we
373
- // use a primary-foreground tint; on the assistant bubble we use
374
- // the muted-foreground role for de-emphasis.
375
- blockquote: /* @__PURE__ */ chunkWGEGR3DF_cjs.__name(({ children }) => {
376
- const cls = isUser ? "border-primary-foreground/40 text-primary-foreground/80" : "border-border text-muted-foreground";
377
- return /* @__PURE__ */ jsxRuntime.jsx("blockquote", { className: `${textSize} border-l-2 pl-3 my-3 break-words ${cls}`, children });
378
- }, "blockquote"),
379
- // Tables: outer wrapper handles overflow, inner `<table>`
380
- // inherits the chat-density text size. Borders / header use
381
- // semantic tokens — `border-code-border` for the assistant
382
- // (matches the code-fence panel for visual cohesion when both
383
- // appear in the same reply); primary-foreground/N for the user
384
- // bubble so lines read against the saturated `bg-primary`.
385
- table: /* @__PURE__ */ chunkWGEGR3DF_cjs.__name(({ children }) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "overflow-x-auto my-3", children: /* @__PURE__ */ jsxRuntime.jsx("table", { className: `min-w-full ${textSize} border-collapse`, children }) }), "table"),
386
- thead: /* @__PURE__ */ chunkWGEGR3DF_cjs.__name(({ children }) => /* @__PURE__ */ jsxRuntime.jsx("thead", { className: isUser ? "bg-primary-foreground/10" : "bg-muted/40", children }), "thead"),
387
- tbody: /* @__PURE__ */ chunkWGEGR3DF_cjs.__name(({ children }) => /* @__PURE__ */ jsxRuntime.jsx("tbody", { children }), "tbody"),
388
- tr: /* @__PURE__ */ chunkWGEGR3DF_cjs.__name(({ children }) => /* @__PURE__ */ jsxRuntime.jsx("tr", { className: isUser ? "border-b border-primary-foreground/15" : "border-b border-border", children }), "tr"),
389
- th: /* @__PURE__ */ chunkWGEGR3DF_cjs.__name(({ children }) => {
390
- const borderCls = isUser ? "border-primary-foreground/25" : "border-border";
391
- return /* @__PURE__ */ jsxRuntime.jsx("th", { className: `px-2 py-1.5 text-left font-semibold border-b ${borderCls} break-words`, children });
392
- }, "th"),
393
- td: /* @__PURE__ */ chunkWGEGR3DF_cjs.__name(({ children }) => /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-2 py-1.5 break-words", children }), "td"),
394
- // Soft separator. ChatGPT / Slack / Linear strip the visible
395
- // line, Claude.ai keeps a hairline. We follow Claude — present
396
- // but quiet. Palette switches by role so the hairline reads on
397
- // both surfaces.
398
- hr: /* @__PURE__ */ chunkWGEGR3DF_cjs.__name(() => /* @__PURE__ */ jsxRuntime.jsx(
399
- "hr",
400
- {
401
- className: `my-4 border-0 h-px ${isUser ? "bg-primary-foreground/20" : "bg-border"}`
402
- }
403
- ), "hr"),
404
- strong: /* @__PURE__ */ chunkWGEGR3DF_cjs.__name(({ children }) => /* @__PURE__ */ jsxRuntime.jsx("strong", { className: "font-semibold", children }), "strong"),
405
- em: /* @__PURE__ */ chunkWGEGR3DF_cjs.__name(({ children }) => /* @__PURE__ */ jsxRuntime.jsx("em", { className: "italic", children }), "em")
406
- };
407
- }
408
- chunkWGEGR3DF_cjs.__name(createMarkdownComponents, "createMarkdownComponents");
409
- var CollapseToggle = /* @__PURE__ */ chunkWGEGR3DF_cjs.__name(({
410
- isCollapsed,
411
- onClick,
412
- readMoreLabel,
413
- showLessLabel,
414
- isUser,
415
- isCompact
416
- }) => {
417
- const textSize = isCompact ? "text-xs" : "text-sm";
418
- return /* @__PURE__ */ jsxRuntime.jsx(
419
- "button",
420
- {
421
- type: "button",
422
- onClick,
423
- className: `
424
- ${textSize} font-medium cursor-pointer
425
- transition-colors duration-200
426
- ${isUser ? "text-white/80 hover:text-white" : "text-primary hover:text-primary/80"}
427
- inline-flex items-center gap-1
428
- mt-1
429
- `,
430
- children: isCollapsed ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
431
- readMoreLabel,
432
- /* @__PURE__ */ jsxRuntime.jsx(Chevron, { direction: "down" })
433
- ] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
434
- showLessLabel,
435
- /* @__PURE__ */ jsxRuntime.jsx(Chevron, { direction: "up" })
436
- ] })
437
- }
438
- );
439
- }, "CollapseToggle");
440
- function Chevron({ direction }) {
441
- return /* @__PURE__ */ jsxRuntime.jsx("svg", { className: "w-3 h-3", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsxRuntime.jsx(
442
- "path",
443
- {
444
- strokeLinecap: "round",
445
- strokeLinejoin: "round",
446
- strokeWidth: 2,
447
- d: direction === "down" ? "M19 9l-7 7-7-7" : "M5 15l7-7 7 7"
448
- }
449
- ) });
450
- }
451
- chunkWGEGR3DF_cjs.__name(Chevron, "Chevron");
452
- function applyPreprocess(source, rules) {
453
- if (!rules || rules.length === 0) return source;
454
- let s = source;
455
- for (const rule of rules) {
456
- if (!rule.preprocess) continue;
457
- try {
458
- s = rule.preprocess(s);
459
- } catch (err) {
460
- console.warn(
461
- `[MarkdownMessage] linkRule "${rule.name ?? "(anonymous)"}" preprocess threw; skipping`,
462
- err
463
- );
464
- }
465
- }
466
- return s;
467
- }
468
- chunkWGEGR3DF_cjs.__name(applyPreprocess, "applyPreprocess");
469
- function collectProtocols(extraHrefProtocols, rules) {
470
- const set = /* @__PURE__ */ new Set();
471
- if (extraHrefProtocols) for (const p of extraHrefProtocols) set.add(p);
472
- if (rules) {
473
- for (const r of rules) {
474
- if (r.protocols) for (const p of r.protocols) set.add(p);
475
- }
476
- }
477
- return set.size === 0 ? void 0 : Array.from(set);
478
- }
479
- chunkWGEGR3DF_cjs.__name(collectProtocols, "collectProtocols");
480
- function buildLinkRulesComponent(rules, isUser, callerA) {
481
- const Renderer = /* @__PURE__ */ chunkWGEGR3DF_cjs.__name((props) => {
482
- const { href, children } = props;
483
- if (typeof href === "string") {
484
- for (const rule of rules) {
485
- if (rule.match(href)) {
486
- return React6__default.default.createElement(
487
- React6__default.default.Fragment,
488
- null,
489
- rule.render({ href, children, isUser })
490
- );
491
- }
492
- }
493
- }
494
- if (callerA && typeof callerA === "function") {
495
- const Caller = callerA;
496
- return React6__default.default.createElement(Caller, props);
497
- }
498
- return React6__default.default.createElement("a", props, children);
499
- }, "Renderer");
500
- return Renderer;
501
- }
502
- chunkWGEGR3DF_cjs.__name(buildLinkRulesComponent, "buildLinkRulesComponent");
503
- var MarkdownMessage = /* @__PURE__ */ chunkWGEGR3DF_cjs.__name(({
504
- content,
505
- className = "",
506
- isUser = false,
507
- isCompact = false,
508
- plainText,
509
- customComponents,
510
- extraHrefProtocols,
511
- linkRules,
512
- collapsible = false,
513
- maxLength,
514
- maxLines,
515
- readMoreLabel = "Read more...",
516
- showLessLabel = "Show less",
517
- defaultExpanded = false,
518
- onCollapseChange
519
- }) => {
520
- const preprocessed = React6__default.default.useMemo(
521
- () => applyPreprocess(content, linkRules),
522
- [content, linkRules]
523
- );
524
- const effectiveProtocols = React6__default.default.useMemo(
525
- () => collectProtocols(extraHrefProtocols, linkRules),
526
- [extraHrefProtocols, linkRules]
527
- );
528
- const effectiveCustomComponents = React6__default.default.useMemo(() => {
529
- if (!linkRules || linkRules.length === 0) return customComponents;
530
- const callerA = customComponents?.a;
531
- const aRenderer = buildLinkRulesComponent(linkRules, isUser, callerA);
532
- return { ...customComponents ?? {}, a: aRenderer };
533
- }, [customComponents, linkRules, isUser]);
534
- const trimmedContent = preprocessed.trim();
535
- const collapsibleOptions = React6__default.default.useMemo(() => {
536
- if (!collapsible) return {};
537
- return {
538
- maxLength: maxLength ?? 1e3,
539
- maxLines: maxLines ?? 10,
540
- defaultExpanded
541
- };
542
- }, [collapsible, maxLength, maxLines, defaultExpanded]);
543
- const { isCollapsed, toggleCollapsed, displayContent, shouldCollapse } = useCollapsibleContent(trimmedContent, collapsible ? collapsibleOptions : {});
544
- React6__default.default.useEffect(() => {
545
- if (collapsible && shouldCollapse && onCollapseChange) {
546
- onCollapseChange(isCollapsed);
547
- }
548
- }, [isCollapsed, collapsible, shouldCollapse, onCollapseChange]);
549
- const components = React6__default.default.useMemo(() => {
550
- const base = createMarkdownComponents(isUser, isCompact);
551
- return effectiveCustomComponents ? { ...base, ...effectiveCustomComponents } : base;
552
- }, [isUser, isCompact, effectiveCustomComponents]);
553
- const schema = React6__default.default.useMemo(() => buildSchema(effectiveProtocols), [effectiveProtocols]);
554
- const urlTransform = React6__default.default.useMemo(
555
- () => buildUrlTransform(effectiveProtocols),
556
- [effectiveProtocols]
557
- );
558
- const textSizeClass = isCompact ? "text-xs" : "text-sm";
559
- const proseClass = isCompact ? "prose-xs" : "prose-sm";
560
- const customComponentsBeyondLinks = React6__default.default.useMemo(() => {
561
- if (!customComponents) return false;
562
- return Object.keys(customComponents).some((k) => k !== "a");
563
- }, [customComponents]);
564
- const isPlainText = plainText !== void 0 ? plainText : !customComponentsBeyondLinks && looksLikePlainProse(displayContent);
565
- if (isPlainText) {
566
- return /* @__PURE__ */ jsxRuntime.jsxs(
567
- "div",
568
- {
569
- className: `${textSizeClass} font-normal antialiased leading-snug break-words whitespace-pre-wrap ${className}`,
570
- children: [
571
- displayContent,
572
- collapsible && shouldCollapse && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
573
- isCollapsed && "... ",
574
- /* @__PURE__ */ jsxRuntime.jsx(
575
- CollapseToggle,
576
- {
577
- isCollapsed,
578
- onClick: toggleCollapsed,
579
- readMoreLabel,
580
- showLessLabel,
581
- isUser,
582
- isCompact
583
- }
584
- )
585
- ] })
586
- ]
587
- }
588
- );
589
- }
590
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className, children: [
591
- /* @__PURE__ */ jsxRuntime.jsx(
592
- "div",
593
- {
594
- className: `
595
- prose ${proseClass} max-w-none break-words overflow-hidden ${textSizeClass} font-normal antialiased
596
- ${isUser ? "prose-invert" : "dark:prose-invert"}
597
- [&>*]:leading-relaxed
598
- [&>*:first-child]:mt-0 [&>*:last-child]:mb-0
599
- [&_p]:my-2
600
- [&_ul]:my-2 [&_ol]:my-2 [&_ul]:pl-5 [&_ol]:pl-5
601
- [&_li]:my-1 [&_li>p]:my-0
602
- [&_h1]:mt-4 [&_h1]:mb-2 [&_h1]:text-base [&_h1]:font-semibold
603
- [&_h2]:mt-3.5 [&_h2]:mb-1.5 [&_h2]:text-[15px] [&_h2]:font-semibold
604
- [&_h3]:mt-3 [&_h3]:mb-1 [&_h3]:text-sm [&_h3]:font-medium
605
- [&_h4]:mt-3 [&_h4]:mb-1 [&_h4]:text-sm [&_h4]:font-medium
606
- `,
607
- style: {
608
- // Inherit colors from parent — fixes issues with external
609
- // CSS variables overriding prose tokens.
610
- "--tw-prose-body": "inherit",
611
- "--tw-prose-headings": "inherit",
612
- "--tw-prose-bold": "inherit",
613
- "--tw-prose-links": "inherit",
614
- color: "inherit"
615
- },
616
- children: /* @__PURE__ */ jsxRuntime.jsx(
617
- ReactMarkdown__default.default,
618
- {
619
- remarkPlugins: [remarkGfm__default.default, remarkBreaks__default.default, remarkSmartypants__default.default, remarkEmoji__default.default],
620
- rehypePlugins: [
621
- rehypeRaw__default.default,
622
- [rehypeSanitize__default.default, schema],
623
- [rehypeExternalLinks__default.default, { target: "_blank", rel: ["noopener", "noreferrer"] }]
624
- ],
625
- components,
626
- urlTransform,
627
- children: displayContent
628
- }
629
- )
630
- }
631
- ),
632
- collapsible && shouldCollapse && /* @__PURE__ */ jsxRuntime.jsx(
633
- CollapseToggle,
634
- {
635
- isCollapsed,
636
- onClick: toggleCollapsed,
637
- readMoreLabel,
638
- showLessLabel,
639
- isUser,
640
- isCompact
641
- }
642
- )
643
- ] });
644
- }, "MarkdownMessage");
645
-
646
- // src/tools/OpenapiViewer/utils/apiKeyManager.ts
647
- function findApiKeyById(apiKeys, keyId) {
648
- return apiKeys.find((key) => key.id === keyId) || null;
649
- }
650
- chunkWGEGR3DF_cjs.__name(findApiKeyById, "findApiKeyById");
651
-
652
- // src/tools/OpenapiViewer/utils/codeSamples.ts
653
- var CODE_SAMPLE_TARGETS = [
654
- { id: "curl", label: "cURL", prism: "bash" },
655
- { id: "fetch", label: "JavaScript", prism: "javascript" },
656
- { id: "axios", label: "Node (axios)", prism: "javascript" },
657
- { id: "python", label: "Python", prism: "python" },
658
- { id: "go", label: "Go", prism: "go" },
659
- { id: "php", label: "PHP", prism: "php" },
660
- { id: "ruby", label: "Ruby", prism: "ruby" },
661
- { id: "java", label: "Java", prism: "java" }
662
- ];
663
- function goRawString(s) {
664
- return s.includes("`") ? JSON.stringify(s) : `\`${s}\``;
665
- }
666
- chunkWGEGR3DF_cjs.__name(goRawString, "goRawString");
667
- function rubyHeredoc(s) {
668
- return `<<~JSON
669
- ${s}
670
- JSON`;
671
- }
672
- chunkWGEGR3DF_cjs.__name(rubyHeredoc, "rubyHeredoc");
673
- function phpHeredoc(s) {
674
- return `<<<JSON
675
- ${s}
676
- JSON`;
677
- }
678
- chunkWGEGR3DF_cjs.__name(phpHeredoc, "phpHeredoc");
679
- function javaTextBlock(s) {
680
- if (s.includes('"""')) return JSON.stringify(s);
681
- return `"""
682
- ${s}
683
- """`;
684
- }
685
- chunkWGEGR3DF_cjs.__name(javaTextBlock, "javaTextBlock");
686
- function fullUrl(har) {
687
- if (!har.queryString.length) return har.url;
688
- const qs = har.queryString.map((p) => `${encodeURIComponent(p.name)}=${encodeURIComponent(p.value)}`).join("&");
689
- const sep = har.url.includes("?") ? "&" : "?";
690
- return `${har.url}${sep}${qs}`;
691
- }
692
- chunkWGEGR3DF_cjs.__name(fullUrl, "fullUrl");
693
- function shellEscape(value) {
694
- return `'${value.replace(/'/g, `'\\''`)}'`;
695
- }
696
- chunkWGEGR3DF_cjs.__name(shellEscape, "shellEscape");
697
- function renderCurl(har) {
698
- const lines = [`curl -X ${har.method} ${shellEscape(fullUrl(har))}`];
699
- for (const h of har.headers) {
700
- lines.push(` -H ${shellEscape(`${h.name}: ${h.value}`)}`);
701
- }
702
- if (har.postData?.text) {
703
- lines.push(` -d ${shellEscape(har.postData.text)}`);
704
- }
705
- return lines.join(" \\\n");
706
- }
707
- chunkWGEGR3DF_cjs.__name(renderCurl, "renderCurl");
708
- function jsHeadersLiteral(har, indent) {
709
- if (!har.headers.length) return "{}";
710
- const entries = har.headers.map((h) => `${indent} ${JSON.stringify(h.name)}: ${JSON.stringify(h.value)}`).join(",\n");
711
- return `{
712
- ${entries},
713
- ${indent}}`;
714
- }
715
- chunkWGEGR3DF_cjs.__name(jsHeadersLiteral, "jsHeadersLiteral");
716
- function jsTemplateLiteral(s) {
717
- if (/[`$]/.test(s)) return JSON.stringify(s);
718
- return `\`${s}\``;
719
- }
720
- chunkWGEGR3DF_cjs.__name(jsTemplateLiteral, "jsTemplateLiteral");
721
- function renderFetch(har) {
722
- const url = fullUrl(har);
723
- const options = [` method: ${JSON.stringify(har.method)}`];
724
- if (har.headers.length) {
725
- options.push(` headers: ${jsHeadersLiteral(har, " ")}`);
726
- }
727
- if (har.postData?.text) {
728
- options.push(` body: ${jsTemplateLiteral(har.postData.text)}`);
729
- }
730
- return `const response = await fetch(${JSON.stringify(url)}, {
731
- ${options.join(",\n")},
732
- });
733
- const data = await response.json();`;
734
- }
735
- chunkWGEGR3DF_cjs.__name(renderFetch, "renderFetch");
736
- function renderAxios(har) {
737
- const url = fullUrl(har);
738
- const config = [
739
- ` method: ${JSON.stringify(har.method.toLowerCase())}`,
740
- ` url: ${JSON.stringify(url)}`
741
- ];
742
- if (har.headers.length) {
743
- config.push(` headers: ${jsHeadersLiteral(har, " ")}`);
744
- }
745
- if (har.postData?.text) {
746
- config.push(` data: ${har.postData.text}`);
747
- }
748
- return `import axios from 'axios';
749
-
750
- const { data } = await axios({
751
- ${config.join(",\n")},
752
- });`;
753
- }
754
- chunkWGEGR3DF_cjs.__name(renderAxios, "renderAxios");
755
- function renderPython(har) {
756
- const lines = [`import requests`, ``];
757
- lines.push(`url = ${JSON.stringify(fullUrl(har))}`);
758
- if (har.headers.length) {
759
- const headerEntries = har.headers.map((h) => ` ${JSON.stringify(h.name)}: ${JSON.stringify(h.value)}`).join(",\n");
760
- lines.push(`headers = {
761
- ${headerEntries},
762
- }`);
763
- }
764
- if (har.postData?.text) {
765
- lines.push(`payload = ${har.postData.text}`);
766
- }
767
- const args = [`url`];
768
- if (har.headers.length) args.push(`headers=headers`);
769
- if (har.postData?.text) args.push(`json=payload`);
770
- lines.push(``, `response = requests.${har.method.toLowerCase()}(${args.join(", ")})`);
771
- lines.push(`data = response.json()`);
772
- return lines.join("\n");
773
- }
774
- chunkWGEGR3DF_cjs.__name(renderPython, "renderPython");
775
- function renderGo(har) {
776
- const url = fullUrl(har);
777
- const lines = [
778
- `package main`,
779
- ``,
780
- `import (`,
781
- ` "fmt"`,
782
- ` "io"`
783
- ];
784
- if (har.postData?.text) lines.push(` "strings"`);
785
- lines.push(` "net/http"`);
786
- lines.push(`)`, ``, `func main() {`);
787
- if (har.postData?.text) {
788
- lines.push(` payload := strings.NewReader(${goRawString(har.postData.text)})`);
789
- lines.push(` req, _ := http.NewRequest(${JSON.stringify(har.method)}, ${JSON.stringify(url)}, payload)`);
790
- } else {
791
- lines.push(` req, _ := http.NewRequest(${JSON.stringify(har.method)}, ${JSON.stringify(url)}, nil)`);
792
- }
793
- for (const h of har.headers) {
794
- lines.push(` req.Header.Add(${JSON.stringify(h.name)}, ${JSON.stringify(h.value)})`);
795
- }
796
- lines.push(
797
- ``,
798
- ` res, _ := http.DefaultClient.Do(req)`,
799
- ` defer res.Body.Close()`,
800
- ` body, _ := io.ReadAll(res.Body)`,
801
- ` fmt.Println(string(body))`,
802
- `}`
803
- );
804
- return lines.join("\n");
805
- }
806
- chunkWGEGR3DF_cjs.__name(renderGo, "renderGo");
807
- function renderPhp(har) {
808
- const lines = [`<?php`, ``, `$curl = curl_init();`, ``, `curl_setopt_array($curl, [`];
809
- lines.push(` CURLOPT_URL => ${JSON.stringify(fullUrl(har))},`);
810
- lines.push(` CURLOPT_RETURNTRANSFER => true,`);
811
- lines.push(` CURLOPT_CUSTOMREQUEST => ${JSON.stringify(har.method)},`);
812
- if (har.postData?.text) {
813
- lines.push(` CURLOPT_POSTFIELDS => ${phpHeredoc(har.postData.text)},`);
814
- }
815
- if (har.headers.length) {
816
- const headerList = har.headers.map((h) => ` ${JSON.stringify(`${h.name}: ${h.value}`)}`).join(",\n");
817
- lines.push(` CURLOPT_HTTPHEADER => [
818
- ${headerList},
819
- ],`);
820
- }
821
- lines.push(`]);`, ``, `$response = curl_exec($curl);`, `curl_close($curl);`, `echo $response;`);
822
- return lines.join("\n");
823
- }
824
- chunkWGEGR3DF_cjs.__name(renderPhp, "renderPhp");
825
- function renderRuby(har) {
826
- const lines = [
827
- `require 'net/http'`,
828
- `require 'uri'`,
829
- `require 'json'`,
830
- ``,
831
- `uri = URI(${JSON.stringify(fullUrl(har))})`,
832
- `http = Net::HTTP.new(uri.host, uri.port)`,
833
- `http.use_ssl = uri.scheme == 'https'`,
834
- ``
835
- ];
836
- const methodClass = har.method.charAt(0) + har.method.slice(1).toLowerCase();
837
- lines.push(`request = Net::HTTP::${methodClass}.new(uri)`);
838
- for (const h of har.headers) {
839
- lines.push(`request[${JSON.stringify(h.name)}] = ${JSON.stringify(h.value)}`);
840
- }
841
- if (har.postData?.text) {
842
- lines.push(`request.body = ${rubyHeredoc(har.postData.text)}`);
843
- }
844
- lines.push(``, `response = http.request(request)`, `puts response.body`);
845
- return lines.join("\n");
846
- }
847
- chunkWGEGR3DF_cjs.__name(renderRuby, "renderRuby");
848
- function renderJava(har) {
849
- const lines = [
850
- `OkHttpClient client = new OkHttpClient();`,
851
- ``
852
- ];
853
- if (har.postData?.text) {
854
- lines.push(
855
- `MediaType mediaType = MediaType.parse("application/json");`,
856
- `RequestBody body = RequestBody.create(mediaType, ${javaTextBlock(har.postData.text)});`,
857
- ``
858
- );
859
- }
860
- lines.push(`Request request = new Request.Builder()`);
861
- lines.push(` .url(${JSON.stringify(fullUrl(har))})`);
862
- if (har.postData?.text) {
863
- lines.push(` .method(${JSON.stringify(har.method)}, body)`);
864
- } else {
865
- lines.push(` .method(${JSON.stringify(har.method)}, null)`);
866
- }
867
- for (const h of har.headers) {
868
- lines.push(` .addHeader(${JSON.stringify(h.name)}, ${JSON.stringify(h.value)})`);
869
- }
870
- lines.push(` .build();`, ``, `Response response = client.newCall(request).execute();`);
871
- return lines.join("\n");
872
- }
873
- chunkWGEGR3DF_cjs.__name(renderJava, "renderJava");
874
- var RENDERERS = {
875
- curl: renderCurl,
876
- fetch: renderFetch,
877
- axios: renderAxios,
878
- python: renderPython,
879
- go: renderGo,
880
- php: renderPhp,
881
- ruby: renderRuby,
882
- java: renderJava
883
- };
884
- function renderSnippet(har, targetId) {
885
- const renderer = RENDERERS[targetId];
886
- if (!renderer) return null;
887
- try {
888
- return renderer(har);
889
- } catch {
890
- return null;
891
- }
892
- }
893
- chunkWGEGR3DF_cjs.__name(renderSnippet, "renderSnippet");
894
-
895
- // src/tools/OpenapiViewer/utils/operationToHar.ts
896
- function buildUrl(endpoint, parameters, baseUrl) {
897
- const pathParamNames = new Set(
898
- (endpoint.parameters ?? []).filter((p) => endpoint.path.includes(`{${p.name}}`)).map((p) => p.name)
899
- );
900
- let path = endpoint.path;
901
- for (const name of pathParamNames) {
902
- const value = parameters[name];
903
- if (value === void 0 || value === "") continue;
904
- path = path.replaceAll(`{${name}}`, encodeURIComponent(value));
905
- }
906
- const queryString = [];
907
- for (const param of endpoint.parameters ?? []) {
908
- if (pathParamNames.has(param.name)) continue;
909
- const value = parameters[param.name];
910
- if (value === void 0 || value === "") continue;
911
- queryString.push({ name: param.name, value });
912
- }
913
- const url = baseUrl ? `${baseUrl.replace(/\/+$/, "")}${path.startsWith("/") ? path : `/${path}`}` : path;
914
- return { url, queryString };
915
- }
916
- chunkWGEGR3DF_cjs.__name(buildUrl, "buildUrl");
917
- function buildHarRequest(input) {
918
- const { endpoint, body, parameters = {}, headers = {}, baseUrl } = input;
919
- const { url, queryString } = buildUrl(endpoint, parameters, baseUrl);
920
- const hasBody = Boolean(body && body.trim().length > 0);
921
- const bodyMime = hasBody ? "application/json" : void 0;
922
- const mergedHeaders = {};
923
- if (hasBody && bodyMime) mergedHeaders["Content-Type"] = bodyMime;
924
- mergedHeaders["Accept"] = "application/json";
925
- for (const [k, v] of Object.entries(headers)) {
926
- if (v === void 0 || v === "") continue;
927
- mergedHeaders[k] = v;
928
- }
929
- const har = {
930
- method: endpoint.method.toUpperCase(),
931
- url,
932
- httpVersion: "HTTP/1.1",
933
- headers: Object.entries(mergedHeaders).map(([name, value]) => ({ name, value })),
934
- queryString,
935
- cookies: [],
936
- headersSize: -1,
937
- bodySize: hasBody ? new TextEncoder().encode(body).length : 0
938
- };
939
- if (hasBody && bodyMime) {
940
- har.postData = { mimeType: bodyMime, text: body };
941
- }
942
- return har;
943
- }
944
- chunkWGEGR3DF_cjs.__name(buildHarRequest, "buildHarRequest");
945
-
946
- // src/tools/OpenapiViewer/utils/versionManager.ts
947
- var API_VERSIONS = [
948
- {
949
- id: "v1",
950
- name: "v1",
951
- description: "Current stable version",
952
- isDefault: true
953
- }
954
- ];
955
- var detectEndpointVersion = /* @__PURE__ */ chunkWGEGR3DF_cjs.__name((path) => {
956
- const versionMatch = path.match(/\/api\/[^/]+\/(v\d+)\//);
957
- if (versionMatch && versionMatch[1]) {
958
- return versionMatch[1];
959
- }
960
- return "v1";
961
- }, "detectEndpointVersion");
962
- var isEndpointInVersion = /* @__PURE__ */ chunkWGEGR3DF_cjs.__name((endpoint, version) => {
963
- const endpointVersion = detectEndpointVersion(endpoint.path);
964
- return endpointVersion === version;
965
- }, "isEndpointInVersion");
966
- var deduplicateEndpoints = /* @__PURE__ */ chunkWGEGR3DF_cjs.__name((endpoints, preferredVersion) => {
967
- const endpointMap = /* @__PURE__ */ new Map();
968
- const groupedEndpoints = /* @__PURE__ */ new Map();
969
- endpoints.forEach((endpoint) => {
970
- const normalizedPath = normalizeEndpointPath(endpoint.path);
971
- if (!groupedEndpoints.has(normalizedPath)) {
972
- groupedEndpoints.set(normalizedPath, []);
973
- }
974
- groupedEndpoints.get(normalizedPath).push(endpoint);
975
- });
976
- groupedEndpoints.forEach((endpointGroup, normalizedPath) => {
977
- let selectedEndpoint = null;
978
- const versionEndpoint = endpointGroup.find((ep) => isEndpointInVersion(ep, preferredVersion));
979
- if (versionEndpoint) {
980
- selectedEndpoint = versionEndpoint;
981
- } else if (endpointGroup.length > 0) {
982
- selectedEndpoint = endpointGroup[0] || null;
983
- }
984
- if (selectedEndpoint) {
985
- endpointMap.set(normalizedPath, selectedEndpoint);
986
- }
987
- });
988
- return Array.from(endpointMap.values());
989
- }, "deduplicateEndpoints");
990
- var normalizeEndpointPath = /* @__PURE__ */ chunkWGEGR3DF_cjs.__name((path) => {
991
- return path.replace(/\/v\d+\//, "/");
992
- }, "normalizeEndpointPath");
993
- var getDefaultVersion = /* @__PURE__ */ chunkWGEGR3DF_cjs.__name(() => {
994
- const defaultVersion = API_VERSIONS.find((v) => v.isDefault);
995
- if (defaultVersion) {
996
- return defaultVersion;
997
- }
998
- if (API_VERSIONS.length > 0 && API_VERSIONS[0]) {
999
- return API_VERSIONS[0];
1000
- }
1001
- throw new Error("No API versions defined");
1002
- }, "getDefaultVersion");
1003
-
1004
- // src/tools/OpenapiViewer/utils/formatters.ts
1005
- var isValidJson = /* @__PURE__ */ chunkWGEGR3DF_cjs.__name((str) => {
1006
- if (!str || typeof str !== "string") return false;
1007
- try {
1008
- JSON.parse(str);
1009
- return true;
1010
- } catch {
1011
- return false;
1012
- }
1013
- }, "isValidJson");
1014
- var parseRequestHeaders = /* @__PURE__ */ chunkWGEGR3DF_cjs.__name((headersString) => {
1015
- if (!headersString || typeof headersString !== "string") {
1016
- return { "Content-Type": "application/json" };
1017
- }
1018
- try {
1019
- const parsed = JSON.parse(headersString);
1020
- return typeof parsed === "object" && parsed !== null ? parsed : { "Content-Type": "application/json" };
1021
- } catch {
1022
- return { "Content-Type": "application/json" };
1023
- }
1024
- }, "parseRequestHeaders");
1025
- function sampleSchema(schema, options = {}, spec) {
1026
- if (!schema) return null;
1027
- try {
1028
- return openapiSampler.sample(schema, options, spec);
1029
- } catch (err) {
1030
- consola2__default.default.warn("[OpenapiViewer] sampleSchema failed:", err, { schema });
1031
- return null;
1032
- }
1033
- }
1034
- chunkWGEGR3DF_cjs.__name(sampleSchema, "sampleSchema");
1035
- function sampleSchemaJson(schema, options = {}, spec) {
1036
- const value = sampleSchema(schema, options, spec);
1037
- if (value === null || value === void 0) return void 0;
1038
- try {
1039
- return JSON.stringify(value, null, 2);
1040
- } catch {
1041
- return void 0;
1042
- }
1043
- }
1044
- chunkWGEGR3DF_cjs.__name(sampleSchemaJson, "sampleSchemaJson");
1045
-
1046
- // src/tools/OpenapiViewer/utils/url.ts
1047
- var PATH_PARAM_RE = /\{([^{}]+)\}/g;
1048
- function extractPathPlaceholders(template) {
1049
- const seen = /* @__PURE__ */ new Set();
1050
- const out = [];
1051
- for (const match of template.matchAll(PATH_PARAM_RE)) {
1052
- const name = match[1];
1053
- if (!seen.has(name)) {
1054
- seen.add(name);
1055
- out.push(name);
1056
- }
1057
- }
1058
- return out;
1059
- }
1060
- chunkWGEGR3DF_cjs.__name(extractPathPlaceholders, "extractPathPlaceholders");
1061
- function substitutePath(template, values) {
1062
- return template.replace(PATH_PARAM_RE, (whole, name) => {
1063
- const v = values[name];
1064
- return v && v.trim() !== "" ? encodeURIComponent(v) : whole;
1065
- });
1066
- }
1067
- chunkWGEGR3DF_cjs.__name(substitutePath, "substitutePath");
1068
- function unfilledPlaceholders(template, values) {
1069
- return extractPathPlaceholders(template).filter(
1070
- (name) => !(values[name] ?? "").trim()
1071
- );
1072
- }
1073
- chunkWGEGR3DF_cjs.__name(unfilledPlaceholders, "unfilledPlaceholders");
1074
- function appendQuery(url, values, pathTemplate) {
1075
- const pathNames = new Set(extractPathPlaceholders(pathTemplate));
1076
- const queryEntries = Object.entries(values).filter(
1077
- ([name, value]) => !pathNames.has(name) && value && value.trim() !== ""
1078
- );
1079
- if (queryEntries.length === 0) return url;
1080
- const [base, existingQuery = ""] = url.split("?", 2);
1081
- const params = new URLSearchParams(existingQuery);
1082
- for (const [k, v] of queryEntries) params.set(k, v);
1083
- const qs = params.toString();
1084
- return qs ? `${base}?${qs}` : base ?? url;
1085
- }
1086
- chunkWGEGR3DF_cjs.__name(appendQuery, "appendQuery");
1087
- function resolveAbsolute(url) {
1088
- if (!url) return url;
1089
- if (/^https?:\/\//i.test(url)) return url;
1090
- if (typeof window === "undefined") return url;
1091
- if (url.startsWith("//")) return `${window.location.protocol}${url}`;
1092
- if (url.startsWith("/")) return `${window.location.origin}${url}`;
1093
- return url;
1094
- }
1095
- chunkWGEGR3DF_cjs.__name(resolveAbsolute, "resolveAbsolute");
1096
- function relativePath(url) {
1097
- try {
1098
- return new URL(url).pathname.replace(/%7B/gi, "{").replace(/%7D/gi, "}");
1099
- } catch {
1100
- return url;
1101
- }
1102
- }
1103
- chunkWGEGR3DF_cjs.__name(relativePath, "relativePath");
1104
- function joinUrl(...parts) {
1105
- return parts.filter((p) => p !== void 0 && p !== null && p !== "").map((p, i) => {
1106
- if (i === 0) return String(p).replace(/\/+$/, "");
1107
- return String(p).replace(/^\/+|\/+$/g, "");
1108
- }).filter((p) => p !== "").join("/");
1109
- }
1110
- chunkWGEGR3DF_cjs.__name(joinUrl, "joinUrl");
1111
- function resolveBaseUrl(sources) {
1112
- return sources.schemaSource || sources.config || sources.fromServers || "";
1113
- }
1114
- chunkWGEGR3DF_cjs.__name(resolveBaseUrl, "resolveBaseUrl");
1115
- var _UrlBuilder = class _UrlBuilder {
1116
- constructor(endpoint, parameters) {
1117
- this.endpoint = endpoint;
1118
- this.parameters = parameters;
1119
- }
1120
- /** What ``fetch()`` receives: substituted path + query string. Origin
1121
- * is whatever the endpoint template already had (relative paths
1122
- * stay relative so the browser resolves them against the page). */
1123
- build() {
1124
- const substituted = substitutePath(this.endpoint.path, this.parameters);
1125
- return appendQuery(substituted, this.parameters, this.endpoint.path);
1126
- }
1127
- /** Same as ``build()`` but guaranteed absolute — for curl snippets
1128
- * and anywhere the URL leaves the browser context. */
1129
- buildAbsolute() {
1130
- return resolveAbsolute(this.build());
1131
- }
1132
- /** Names of required path/query params still empty. */
1133
- missingRequired() {
1134
- if (!this.endpoint.parameters) return [];
1135
- return this.endpoint.parameters.filter((p) => p.required && !(this.parameters[p.name] ?? "").trim()).map((p) => p.name);
1136
- }
1137
- /** Placeholders in the template with no matching value. Usually a
1138
- * superset of ``missingRequired`` — catches schemas that forgot
1139
- * to flag a path param as required. */
1140
- unfilledPlaceholders() {
1141
- return unfilledPlaceholders(this.endpoint.path, this.parameters);
1142
- }
1143
- };
1144
- chunkWGEGR3DF_cjs.__name(_UrlBuilder, "UrlBuilder");
1145
- var UrlBuilder = _UrlBuilder;
1146
-
1147
- // src/tools/OpenapiViewer/utils/schemaExport.ts
1148
- function dereferenceSchema(schema, maxDepth = 10) {
1149
- const root = schema;
1150
- function resolveRef(ref) {
1151
- if (!ref.startsWith("#/")) return null;
1152
- const parts = ref.slice(2).split("/");
1153
- let node = root;
1154
- for (const part of parts) {
1155
- if (node && typeof node === "object" && part in node) {
1156
- node = node[part];
1157
- } else {
1158
- return null;
1159
- }
1160
- }
1161
- return node;
1162
- }
1163
- chunkWGEGR3DF_cjs.__name(resolveRef, "resolveRef");
1164
- function walk(value, depth) {
1165
- if (depth > maxDepth) return value;
1166
- if (Array.isArray(value)) return value.map((v) => walk(v, depth + 1));
1167
- if (value && typeof value === "object") {
1168
- const obj = value;
1169
- if (typeof obj.$ref === "string") {
1170
- const resolved = resolveRef(obj.$ref);
1171
- if (resolved === null) return obj;
1172
- return walk(resolved, depth + 1);
1173
- }
1174
- const out = {};
1175
- for (const [k, v] of Object.entries(obj)) out[k] = walk(v, depth + 1);
1176
- return out;
1177
- }
1178
- return value;
1179
- }
1180
- chunkWGEGR3DF_cjs.__name(walk, "walk");
1181
- return walk(schema, 0);
1182
- }
1183
- chunkWGEGR3DF_cjs.__name(dereferenceSchema, "dereferenceSchema");
1184
- var NOISY_KEYS = /* @__PURE__ */ new Set(["xml", "example", "examples", "externalDocs"]);
1185
- var MAX_DESCRIPTION_LEN = 500;
1186
- function pruneForCompact(value) {
1187
- if (Array.isArray(value)) return value.map(pruneForCompact);
1188
- if (value && typeof value === "object") {
1189
- const out = {};
1190
- for (const [k, v] of Object.entries(value)) {
1191
- if (NOISY_KEYS.has(k)) continue;
1192
- if (k === "description" && typeof v === "string" && v.length > MAX_DESCRIPTION_LEN) {
1193
- out[k] = v.slice(0, MAX_DESCRIPTION_LEN).trimEnd() + "\u2026";
1194
- continue;
1195
- }
1196
- out[k] = pruneForCompact(v);
1197
- }
1198
- return out;
1199
- }
1200
- return value;
1201
- }
1202
- chunkWGEGR3DF_cjs.__name(pruneForCompact, "pruneForCompact");
1203
- function withResolvedBaseUrl(schema, baseUrl) {
1204
- if (!baseUrl) return schema;
1205
- return { ...schema, servers: [{ url: baseUrl }] };
1206
- }
1207
- chunkWGEGR3DF_cjs.__name(withResolvedBaseUrl, "withResolvedBaseUrl");
1208
- function toRawJson(schema, baseUrl) {
1209
- return JSON.stringify(withResolvedBaseUrl(schema, baseUrl), null, 2);
1210
- }
1211
- chunkWGEGR3DF_cjs.__name(toRawJson, "toRawJson");
1212
- function toCompactJson(schema, baseUrl) {
1213
- const resolved = dereferenceSchema(withResolvedBaseUrl(schema, baseUrl));
1214
- const pruned = pruneForCompact(resolved);
1215
- return JSON.stringify(pruned);
1216
- }
1217
- chunkWGEGR3DF_cjs.__name(toCompactJson, "toCompactJson");
1218
- function endpointToMarkdown(ep) {
1219
- const lines = [];
1220
- lines.push(`### ${ep.method} ${ep.path}`);
1221
- if (ep.description) lines.push(ep.description);
1222
- const pathParams = ep.parameters?.filter((p) => ep.path.includes(`{${p.name}}`)) ?? [];
1223
- const queryParams = ep.parameters?.filter((p) => !ep.path.includes(`{${p.name}}`)) ?? [];
1224
- if (pathParams.length > 0) {
1225
- lines.push("", "**Path parameters**");
1226
- for (const p of pathParams) {
1227
- const req = p.required ? " (required)" : "";
1228
- const desc = p.description ? ` \u2014 ${p.description}` : "";
1229
- lines.push(`- \`${p.name}\`: ${p.type}${req}${desc}`);
1230
- }
1231
- }
1232
- if (queryParams.length > 0) {
1233
- lines.push("", "**Query parameters**");
1234
- for (const p of queryParams) {
1235
- const req = p.required ? " (required)" : "";
1236
- const desc = p.description ? ` \u2014 ${p.description}` : "";
1237
- lines.push(`- \`${p.name}\`: ${p.type}${req}${desc}`);
1238
- }
1239
- }
1240
- if (ep.requestBody) {
1241
- const desc = ep.requestBody.description ? ` \u2014 ${ep.requestBody.description}` : "";
1242
- lines.push("", `**Request body:** ${ep.requestBody.type}${desc}`);
1243
- }
1244
- if (ep.responses && ep.responses.length > 0) {
1245
- lines.push("", "**Responses**");
1246
- for (const r of ep.responses) {
1247
- lines.push(`- \`${r.code}\` \u2014 ${r.description}`);
1248
- }
1249
- }
1250
- return lines.join("\n");
1251
- }
1252
- chunkWGEGR3DF_cjs.__name(endpointToMarkdown, "endpointToMarkdown");
1253
- function toMarkdown(schema, endpoints, baseUrl) {
1254
- const lines = [];
1255
- const info = schema.info;
1256
- const resolvedBase = resolveBaseUrl({
1257
- config: baseUrl,
1258
- fromServers: schema.servers?.[0]?.url
1259
- });
1260
- lines.push(`# ${info?.title ?? "API"}${info?.version ? ` (v${info.version})` : ""}`);
1261
- if (resolvedBase) lines.push("", `**Base URL:** \`${resolvedBase}\``);
1262
- if (info?.description) lines.push("", info.description.trim());
1263
- const grouped = /* @__PURE__ */ new Map();
1264
- for (const ep of endpoints) {
1265
- const arr = grouped.get(ep.category) ?? [];
1266
- arr.push(ep);
1267
- grouped.set(ep.category, arr);
1268
- }
1269
- const categories = Array.from(grouped.keys()).sort((a, b) => {
1270
- if (a === "Other") return 1;
1271
- if (b === "Other") return -1;
1272
- return a.localeCompare(b);
1273
- });
1274
- for (const category of categories) {
1275
- lines.push("", `## ${category}`);
1276
- const list = grouped.get(category);
1277
- for (const ep of list) {
1278
- const displayPath = relativePath(ep.path);
1279
- const sub = endpointToMarkdown({ ...ep, path: displayPath });
1280
- lines.push("", sub);
1281
- }
1282
- }
1283
- return lines.join("\n");
1284
- }
1285
- chunkWGEGR3DF_cjs.__name(toMarkdown, "toMarkdown");
1286
- function formatBytes(s) {
1287
- const bytes = new Blob([s]).size;
1288
- if (bytes < 1024) return `${bytes} B`;
1289
- if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
1290
- return `${(bytes / 1024 / 1024).toFixed(2)} MB`;
1291
- }
1292
- chunkWGEGR3DF_cjs.__name(formatBytes, "formatBytes");
1293
- var AUTH_KEY_STORAGE = "openapi-playground:auth:apiKeyId";
1294
- var AUTH_BEARER_STORAGE = "openapi-playground:auth:bearer";
1295
- var createInitialState = /* @__PURE__ */ chunkWGEGR3DF_cjs.__name(() => ({
1296
- currentStep: "endpoints",
1297
- steps: ["endpoints", "request", "response"],
1298
- selectedEndpoint: null,
1299
- selectedCategory: "All",
1300
- searchTerm: "",
1301
- selectedVersion: getDefaultVersion().id,
1302
- requestUrl: "",
1303
- requestMethod: "GET",
1304
- requestHeaders: '{\n "Content-Type": "application/json"\n}',
1305
- requestBody: "",
1306
- selectedApiKey: null,
1307
- manualApiToken: "",
1308
- parameters: {},
1309
- response: null,
1310
- loading: false,
1311
- sidebarOpen: false,
1312
- activeSchemaId: null
1313
- }), "createInitialState");
1314
- function reducer(state, action) {
1315
- switch (action.type) {
1316
- case "SET_STEP":
1317
- return { ...state, currentStep: action.step };
1318
- case "NEXT_STEP": {
1319
- const i = state.steps.indexOf(state.currentStep);
1320
- return i < state.steps.length - 1 ? { ...state, currentStep: state.steps[i + 1] } : state;
1321
- }
1322
- case "PREV_STEP": {
1323
- const i = state.steps.indexOf(state.currentStep);
1324
- return i > 0 ? { ...state, currentStep: state.steps[i - 1] } : state;
1325
- }
1326
- case "SELECT_ENDPOINT": {
1327
- if (!action.endpoint) return { ...state, selectedEndpoint: null };
1328
- const same = state.selectedEndpoint?.method === action.endpoint.method && state.selectedEndpoint?.path === action.endpoint.path;
1329
- const exampleBody = action.endpoint.requestBody?.example ?? "";
1330
- return {
1331
- ...state,
1332
- selectedEndpoint: action.endpoint,
1333
- requestMethod: action.endpoint.method,
1334
- requestUrl: action.endpoint.path,
1335
- parameters: same ? state.parameters : {},
1336
- requestBody: same ? state.requestBody : exampleBody,
1337
- // Switching to a different endpoint: the previous response no
1338
- // longer belongs here. Clear it so the playground panel collapses
1339
- // back to single-column until the user sends a new request.
1340
- response: same ? state.response : null,
1341
- currentStep: "request"
1342
- };
1343
- }
1344
- case "SET_CATEGORY":
1345
- return { ...state, selectedCategory: action.category };
1346
- case "SET_SEARCH":
1347
- return { ...state, searchTerm: action.term };
1348
- case "SET_VERSION":
1349
- return { ...state, selectedVersion: action.version };
1350
- case "SET_REQUEST_URL":
1351
- return { ...state, requestUrl: action.url };
1352
- case "SET_REQUEST_METHOD":
1353
- return { ...state, requestMethod: action.method };
1354
- case "SET_REQUEST_HEADERS":
1355
- return { ...state, requestHeaders: action.headers };
1356
- case "SET_REQUEST_BODY":
1357
- return { ...state, requestBody: action.body };
1358
- case "SET_API_KEY":
1359
- return { ...state, selectedApiKey: action.apiKeyId };
1360
- case "SET_MANUAL_TOKEN":
1361
- return { ...state, manualApiToken: action.token };
1362
- case "SET_PARAMETERS":
1363
- return { ...state, parameters: action.parameters };
1364
- case "SET_RESPONSE":
1365
- return { ...state, response: action.response };
1366
- case "SET_LOADING":
1367
- return { ...state, loading: action.loading };
1368
- case "REQUEST_START":
1369
- return { ...state, loading: true, response: null };
1370
- case "REQUEST_SUCCESS":
1371
- return { ...state, loading: false, response: action.response, currentStep: "response" };
1372
- case "REQUEST_ERROR":
1373
- return { ...state, loading: false, response: action.response };
1374
- case "SET_SIDEBAR":
1375
- return { ...state, sidebarOpen: action.open };
1376
- case "SET_ACTIVE_SCHEMA_ID":
1377
- return { ...state, activeSchemaId: action.id };
1378
- case "SYNC_API_KEY_HEADER":
1379
- return { ...state, requestHeaders: action.headers };
1380
- case "CLEAR_API_KEY_SELECTION":
1381
- return { ...state, selectedApiKey: null };
1382
- case "SYNC_URL":
1383
- return { ...state, requestUrl: action.url };
1384
- case "RESET":
1385
- return createInitialState();
1386
- default:
1387
- return state;
1388
- }
1389
- }
1390
- chunkWGEGR3DF_cjs.__name(reducer, "reducer");
1391
- var PlaygroundContext = React6.createContext(void 0);
1392
- var usePlaygroundContext = /* @__PURE__ */ chunkWGEGR3DF_cjs.__name(() => {
1393
- const context = React6.useContext(PlaygroundContext);
1394
- if (!context) throw new Error("usePlaygroundContext must be used within a PlaygroundProvider");
1395
- return context;
1396
- }, "usePlaygroundContext");
1397
- var PlaygroundProvider = /* @__PURE__ */ chunkWGEGR3DF_cjs.__name(({ children, config }) => {
1398
- const [state, dispatch] = React6.useReducer(reducer, void 0, createInitialState);
1399
- const abortControllerRef = React6.useRef(null);
1400
- const apiKeys = React6__default.default.useMemo(
1401
- () => config.apiKeys ?? [],
1402
- [config.apiKeys]
1403
- );
1404
- const isLoadingApiKeys = config.apiKeysLoading ?? false;
1405
- const [storedApiKeyId, setStoredApiKeyId] = hooks.useSessionStorage(
1406
- AUTH_KEY_STORAGE,
1407
- null
1408
- );
1409
- const [storedBearer, setStoredBearer] = hooks.useSessionStorage(
1410
- AUTH_BEARER_STORAGE,
1411
- ""
1412
- );
1413
- const hasHydratedAuthRef = React6.useRef(false);
1414
- React6.useEffect(() => {
1415
- if (hasHydratedAuthRef.current) return;
1416
- hasHydratedAuthRef.current = true;
1417
- if (storedApiKeyId) dispatch({ type: "SET_API_KEY", apiKeyId: storedApiKeyId });
1418
- if (storedBearer) dispatch({ type: "SET_MANUAL_TOKEN", token: storedBearer });
1419
- }, []);
1420
- React6.useEffect(() => {
1421
- if (!hasHydratedAuthRef.current) return;
1422
- setStoredApiKeyId(state.selectedApiKey);
1423
- }, [state.selectedApiKey, setStoredApiKeyId]);
1424
- React6.useEffect(() => {
1425
- if (!hasHydratedAuthRef.current) return;
1426
- setStoredBearer(state.manualApiToken);
1427
- }, [state.manualApiToken, setStoredBearer]);
1428
- React6.useEffect(() => {
1429
- if (!hasHydratedAuthRef.current) return;
1430
- if (!isLoadingApiKeys && apiKeys.length > 0 && !state.selectedApiKey && !storedApiKeyId) {
1431
- dispatch({ type: "SET_API_KEY", apiKeyId: apiKeys[0]?.id || null });
1432
- }
1433
- }, [apiKeys, isLoadingApiKeys, state.selectedApiKey, storedApiKeyId]);
1434
- React6.useEffect(() => {
1435
- try {
1436
- const headers = parseRequestHeaders(state.requestHeaders);
1437
- if (state.selectedApiKey) {
1438
- const apiKey = apiKeys.find((k) => k.id === state.selectedApiKey);
1439
- if (!apiKey) {
1440
- dispatch({ type: "CLEAR_API_KEY_SELECTION" });
1441
- return;
1442
- }
1443
- const keyValue = apiKey.secret || apiKey.id;
1444
- if (headers["X-API-Key"] !== keyValue) {
1445
- headers["X-API-Key"] = keyValue;
1446
- dispatch({ type: "SYNC_API_KEY_HEADER", headers: JSON.stringify(headers, null, 2) });
1447
- }
1448
- } else if (headers["X-API-Key"]) {
1449
- delete headers["X-API-Key"];
1450
- dispatch({ type: "SYNC_API_KEY_HEADER", headers: JSON.stringify(headers, null, 2) });
1451
- }
1452
- } catch (error) {
1453
- consola2__default.default.error("Error updating headers:", error);
1454
- }
1455
- }, [state.selectedApiKey, apiKeys]);
1456
- React6.useEffect(() => {
1457
- if (!state.selectedEndpoint) return;
1458
- const updated = new UrlBuilder(state.selectedEndpoint, state.parameters).build();
1459
- if (updated !== state.requestUrl) {
1460
- dispatch({ type: "SYNC_URL", url: updated });
1461
- }
1462
- }, [state.parameters, state.selectedEndpoint]);
1463
- const setCurrentStep = React6.useCallback((step) => dispatch({ type: "SET_STEP", step }), []);
1464
- const goToNextStep = React6.useCallback(() => dispatch({ type: "NEXT_STEP" }), []);
1465
- const goToPreviousStep = React6.useCallback(() => dispatch({ type: "PREV_STEP" }), []);
1466
- const setSelectedEndpoint = React6.useCallback((endpoint) => dispatch({ type: "SELECT_ENDPOINT", endpoint }), []);
1467
- const setSelectedCategory = React6.useCallback((category) => dispatch({ type: "SET_CATEGORY", category }), []);
1468
- const setSearchTerm = React6.useCallback((term) => dispatch({ type: "SET_SEARCH", term }), []);
1469
- const setSelectedVersion = React6.useCallback((version) => dispatch({ type: "SET_VERSION", version }), []);
1470
- const setRequestUrl = React6.useCallback((url) => dispatch({ type: "SET_REQUEST_URL", url }), []);
1471
- const setRequestMethod = React6.useCallback((method) => dispatch({ type: "SET_REQUEST_METHOD", method }), []);
1472
- const setRequestHeaders = React6.useCallback((headers) => dispatch({ type: "SET_REQUEST_HEADERS", headers }), []);
1473
- const setRequestBody = React6.useCallback((body) => dispatch({ type: "SET_REQUEST_BODY", body }), []);
1474
- const setSelectedApiKey = React6.useCallback((apiKeyId) => dispatch({ type: "SET_API_KEY", apiKeyId }), []);
1475
- const setManualApiToken = React6.useCallback((token) => dispatch({ type: "SET_MANUAL_TOKEN", token }), []);
1476
- const setParameters = React6.useCallback((parameters) => dispatch({ type: "SET_PARAMETERS", parameters }), []);
1477
- const setResponse = React6.useCallback((response) => dispatch({ type: "SET_RESPONSE", response }), []);
1478
- const setLoading = React6.useCallback((loading) => dispatch({ type: "SET_LOADING", loading }), []);
1479
- const setSidebarOpen = React6.useCallback((open) => dispatch({ type: "SET_SIDEBAR", open }), []);
1480
- const setActiveSchemaId = React6.useCallback((id) => dispatch({ type: "SET_ACTIVE_SCHEMA_ID", id }), []);
1481
- const clearAll = React6.useCallback(() => dispatch({ type: "RESET" }), []);
1482
- const sendRequest = React6.useCallback(async () => {
1483
- if (!state.requestUrl) {
1484
- consola2__default.default.error("No URL provided");
1485
- return;
1486
- }
1487
- abortControllerRef.current?.abort();
1488
- const controller = new AbortController();
1489
- abortControllerRef.current = controller;
1490
- dispatch({ type: "REQUEST_START" });
1491
- const startTime = Date.now();
1492
- try {
1493
- const headers = parseRequestHeaders(state.requestHeaders);
1494
- let bearerToken = null;
1495
- if (state.manualApiToken) {
1496
- bearerToken = state.manualApiToken;
1497
- } else if (typeof window !== "undefined") {
1498
- bearerToken = window.localStorage.getItem("auth_token");
1499
- }
1500
- if (bearerToken) headers["Authorization"] = `Bearer ${bearerToken}`;
1501
- const requestOptions = {
1502
- method: state.requestMethod,
1503
- headers,
1504
- signal: controller.signal
1505
- };
1506
- if (state.requestBody && state.requestMethod !== "GET") {
1507
- requestOptions.body = state.requestBody;
1508
- }
1509
- const response = await fetch(state.requestUrl, requestOptions);
1510
- const duration = Date.now() - startTime;
1511
- const responseText = await response.text();
1512
- let responseData;
1513
- try {
1514
- responseData = JSON.parse(responseText);
1515
- } catch {
1516
- responseData = responseText;
1517
- }
1518
- dispatch({
1519
- type: "REQUEST_SUCCESS",
1520
- response: {
1521
- status: response.status,
1522
- statusText: response.statusText,
1523
- headers: Object.fromEntries(response.headers.entries()),
1524
- data: responseData,
1525
- duration
1526
- }
1527
- });
1528
- consola2__default.default.success(`${state.requestMethod} ${state.requestUrl} \u2192 ${response.status} (${duration}ms)`);
1529
- } catch (error) {
1530
- if (error instanceof DOMException && error.name === "AbortError") return;
1531
- consola2__default.default.error("Request failed:", error);
1532
- dispatch({
1533
- type: "REQUEST_ERROR",
1534
- response: {
1535
- error: error instanceof Error ? error.message : "Request failed",
1536
- duration: Date.now() - startTime
1537
- }
1538
- });
1539
- }
1540
- }, [state.requestUrl, state.requestHeaders, state.manualApiToken, state.requestMethod, state.requestBody]);
1541
- const contextValue = {
1542
- state,
1543
- config,
1544
- apiKeys,
1545
- apiKeysLoading: isLoadingApiKeys,
1546
- setCurrentStep,
1547
- goToNextStep,
1548
- goToPreviousStep,
1549
- setSelectedEndpoint,
1550
- setSelectedCategory,
1551
- setSearchTerm,
1552
- setSelectedVersion,
1553
- setRequestUrl,
1554
- setRequestMethod,
1555
- setRequestHeaders,
1556
- setRequestBody,
1557
- setSelectedApiKey,
1558
- setManualApiToken,
1559
- setParameters,
1560
- setResponse,
1561
- setLoading,
1562
- setSidebarOpen,
1563
- setActiveSchemaId,
1564
- clearAll,
1565
- sendRequest
1566
- };
1567
- return /* @__PURE__ */ jsxRuntime.jsx(PlaygroundContext.Provider, { value: contextValue, children });
1568
- }, "PlaygroundProvider");
1569
-
1570
- exports.CODE_SAMPLE_TARGETS = CODE_SAMPLE_TARGETS;
1571
- exports.MarkdownMessage = MarkdownMessage;
1572
- exports.Mermaid_default = Mermaid_default;
1573
- exports.PlaygroundProvider = PlaygroundProvider;
1574
- exports.PrettyCode_default = PrettyCode_default;
1575
- exports.UrlBuilder = UrlBuilder;
1576
- exports.buildHarRequest = buildHarRequest;
1577
- exports.deduplicateEndpoints = deduplicateEndpoints;
1578
- exports.dereferenceSchema = dereferenceSchema;
1579
- exports.endpointToMarkdown = endpointToMarkdown;
1580
- exports.extractTextFromChildren = extractTextFromChildren;
1581
- exports.findApiKeyById = findApiKeyById;
1582
- exports.formatBytes = formatBytes;
1583
- exports.isValidJson = isValidJson;
1584
- exports.joinUrl = joinUrl;
1585
- exports.parseRequestHeaders = parseRequestHeaders;
1586
- exports.relativePath = relativePath;
1587
- exports.renderSnippet = renderSnippet;
1588
- exports.resolveAbsolute = resolveAbsolute;
1589
- exports.resolveBaseUrl = resolveBaseUrl;
1590
- exports.sampleSchemaJson = sampleSchemaJson;
1591
- exports.toCompactJson = toCompactJson;
1592
- exports.toMarkdown = toMarkdown;
1593
- exports.toRawJson = toRawJson;
1594
- exports.useCollapsibleContent = useCollapsibleContent;
1595
- exports.usePlaygroundContext = usePlaygroundContext;
1596
- //# sourceMappingURL=chunk-TKSFZHCG.cjs.map
1597
- //# sourceMappingURL=chunk-TKSFZHCG.cjs.map