@copilotkit/react-ui 0.15.0-alpha.1 → 0.15.0-alpha.3

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 (315) hide show
  1. package/.turbo/turbo-build.log +192 -288
  2. package/CHANGELOG.md +28 -1
  3. package/dist/{chunk-ZVAH2Z2W.mjs → chunk-3M4HWSE7.mjs} +3 -3
  4. package/dist/chunk-3M4HWSE7.mjs.map +1 -0
  5. package/dist/{chunk-Y2RUG4B3.mjs → chunk-5O2MCJZ2.mjs} +2 -2
  6. package/dist/chunk-5O2MCJZ2.mjs.map +1 -0
  7. package/dist/{chunk-X3Z2EVFV.mjs → chunk-CKJXXQ2W.mjs} +5 -5
  8. package/dist/chunk-CKJXXQ2W.mjs.map +1 -0
  9. package/dist/{chunk-NXWVWC33.mjs → chunk-DPRH4HX3.mjs} +11 -24
  10. package/dist/chunk-DPRH4HX3.mjs.map +1 -0
  11. package/dist/{chunk-UIRFLYXI.mjs → chunk-GWGHQNRI.mjs} +14 -13
  12. package/dist/chunk-GWGHQNRI.mjs.map +1 -0
  13. package/dist/chunk-JD7BAH7U.mjs +3 -0
  14. package/dist/{chunk-X4T6ZUVM.mjs → chunk-KBGIPFXA.mjs} +5 -5
  15. package/dist/chunk-KBGIPFXA.mjs.map +1 -0
  16. package/dist/{chunk-DN3OI5WF.mjs → chunk-NNVWLSYK.mjs} +9 -9
  17. package/dist/chunk-NNVWLSYK.mjs.map +1 -0
  18. package/dist/{chunk-QFASQEFJ.mjs → chunk-NYLOXKYT.mjs} +2 -2
  19. package/dist/chunk-NYLOXKYT.mjs.map +1 -0
  20. package/dist/{chunk-6H3Y2XEI.mjs → chunk-OF66AL5Z.mjs} +1 -1
  21. package/dist/chunk-OF66AL5Z.mjs.map +1 -0
  22. package/dist/{chunk-DPUPEOGG.mjs → chunk-UWPFPWAW.mjs} +2 -2
  23. package/dist/chunk-UWPFPWAW.mjs.map +1 -0
  24. package/dist/{chunk-GPEJCUWA.mjs → chunk-Z34F3WLK.mjs} +2 -2
  25. package/dist/chunk-Z34F3WLK.mjs.map +1 -0
  26. package/dist/components/chat/Button.d.ts +2 -3
  27. package/dist/components/chat/Button.js +38 -0
  28. package/dist/components/chat/Button.js.map +1 -0
  29. package/dist/components/chat/Button.mjs +2 -2
  30. package/dist/components/chat/Chat.d.ts +15 -14
  31. package/dist/components/chat/Chat.js +800 -0
  32. package/dist/components/chat/Chat.js.map +1 -0
  33. package/dist/components/chat/Chat.mjs +9 -9
  34. package/dist/components/chat/ChatContext.d.ts +21 -21
  35. package/dist/components/chat/ChatContext.js +220 -0
  36. package/dist/components/chat/ChatContext.js.map +1 -0
  37. package/dist/components/chat/ChatContext.mjs +1 -1
  38. package/dist/components/chat/CodeBlock.js +221 -0
  39. package/dist/components/chat/CodeBlock.js.map +1 -0
  40. package/dist/components/chat/CodeBlock.mjs +1 -1
  41. package/dist/components/chat/Header.d.ts +2 -3
  42. package/dist/components/chat/Header.js +31 -0
  43. package/dist/components/chat/Header.js.map +1 -0
  44. package/dist/components/chat/Header.mjs +2 -2
  45. package/dist/components/chat/Icons.d.ts +4 -4
  46. package/dist/components/chat/Icons.js +233 -0
  47. package/dist/components/chat/Icons.js.map +1 -0
  48. package/dist/components/chat/Input.d.ts +2 -3
  49. package/dist/components/chat/Input.js +111 -0
  50. package/dist/components/chat/Input.js.map +1 -0
  51. package/dist/components/chat/Input.mjs +2 -2
  52. package/dist/components/chat/Markdown.d.ts +1 -3
  53. package/dist/components/chat/Markdown.js +269 -0
  54. package/dist/components/chat/Markdown.js.map +1 -0
  55. package/dist/components/chat/Markdown.mjs +2 -2
  56. package/dist/components/chat/Messages.d.ts +2 -3
  57. package/dist/components/chat/Messages.js +331 -0
  58. package/dist/components/chat/Messages.js.map +1 -0
  59. package/dist/components/chat/Messages.mjs +4 -4
  60. package/dist/components/chat/Popup.d.ts +5 -4
  61. package/dist/components/chat/Popup.js +806 -0
  62. package/dist/components/chat/Popup.js.map +1 -0
  63. package/dist/components/chat/Popup.mjs +10 -10
  64. package/dist/components/chat/Response.d.ts +2 -3
  65. package/dist/components/chat/Response.js +31 -0
  66. package/dist/components/chat/Response.js.map +1 -0
  67. package/dist/components/chat/Response.mjs +2 -2
  68. package/dist/components/chat/Sidebar.d.ts +7 -6
  69. package/dist/components/chat/Sidebar.js +817 -0
  70. package/dist/components/chat/Sidebar.js.map +1 -0
  71. package/dist/components/chat/Sidebar.mjs +10 -10
  72. package/dist/components/chat/Textarea.d.ts +4 -4
  73. package/dist/components/chat/Textarea.js +55 -0
  74. package/dist/components/chat/Textarea.js.map +1 -0
  75. package/dist/components/chat/Window.d.ts +1 -1
  76. package/dist/components/chat/Window.js +116 -0
  77. package/dist/components/chat/Window.js.map +1 -0
  78. package/dist/components/chat/index.d.ts +5 -4
  79. package/dist/components/chat/index.js +824 -0
  80. package/dist/components/chat/index.js.map +1 -0
  81. package/dist/components/chat/index.mjs +11 -11
  82. package/dist/components/chat/props.d.ts +1 -1
  83. package/dist/components/chat/props.js +4 -0
  84. package/dist/components/index.d.ts +5 -11
  85. package/dist/components/index.js +824 -0
  86. package/dist/components/index.js.map +1 -0
  87. package/dist/components/index.mjs +12 -33
  88. package/dist/context/index.js +4 -0
  89. package/dist/hooks/index.js +4 -0
  90. package/dist/hooks/use-copy-to-clipboard.js +47 -0
  91. package/dist/hooks/use-copy-to-clipboard.js.map +1 -0
  92. package/dist/index.css +112 -916
  93. package/dist/index.css.map +1 -1
  94. package/dist/index.d.ts +5 -11
  95. package/dist/index.js +824 -0
  96. package/dist/index.js.map +1 -0
  97. package/dist/index.mjs +13 -34
  98. package/dist/lib/utils.js +64 -0
  99. package/dist/lib/utils.js.map +1 -0
  100. package/dist/lib/utils.mjs +38 -2
  101. package/dist/lib/utils.mjs.map +1 -1
  102. package/dist/lib/utils.test.js +10 -0
  103. package/dist/lib/utils.test.js.map +1 -0
  104. package/dist/types/index.js +4 -0
  105. package/dist/types/types.d.ts +1 -1
  106. package/dist/types/types.js +4 -0
  107. package/package.json +10 -9
  108. package/src/components/chat/Button.tsx +1 -2
  109. package/src/components/chat/Chat.tsx +7 -7
  110. package/src/components/chat/ChatContext.tsx +10 -10
  111. package/src/components/chat/CodeBlock.tsx +12 -36
  112. package/src/components/chat/Header.tsx +1 -2
  113. package/src/components/chat/Input.tsx +1 -1
  114. package/src/components/chat/Markdown.tsx +17 -11
  115. package/src/components/chat/Messages.tsx +2 -2
  116. package/src/components/chat/Popup.tsx +3 -4
  117. package/src/components/chat/Response.tsx +1 -2
  118. package/src/components/chat/Sidebar.tsx +4 -4
  119. package/src/components/chat/index.tsx +2 -2
  120. package/src/components/chat/props.ts +1 -1
  121. package/src/components/index.ts +0 -8
  122. package/src/css/animations.css +6 -0
  123. package/src/css/markdown.css +123 -0
  124. package/src/styles.css +1 -0
  125. package/src/types/types.ts +1 -1
  126. package/tsup.config.ts +1 -2
  127. package/dist/chunk-2KAF7NKC.mjs +0 -484
  128. package/dist/chunk-2KAF7NKC.mjs.map +0 -1
  129. package/dist/chunk-5KEDV5VC.mjs +0 -27
  130. package/dist/chunk-5KEDV5VC.mjs.map +0 -1
  131. package/dist/chunk-6H3Y2XEI.mjs.map +0 -1
  132. package/dist/chunk-6LAZQHEB.mjs +0 -129
  133. package/dist/chunk-6LAZQHEB.mjs.map +0 -1
  134. package/dist/chunk-C34L4AWW.mjs +0 -39
  135. package/dist/chunk-C34L4AWW.mjs.map +0 -1
  136. package/dist/chunk-CF3BK4OX.mjs +0 -53
  137. package/dist/chunk-CF3BK4OX.mjs.map +0 -1
  138. package/dist/chunk-CNQX2VY3.mjs +0 -66
  139. package/dist/chunk-CNQX2VY3.mjs.map +0 -1
  140. package/dist/chunk-DN3OI5WF.mjs.map +0 -1
  141. package/dist/chunk-DPUPEOGG.mjs.map +0 -1
  142. package/dist/chunk-FZRTAML3.mjs +0 -3
  143. package/dist/chunk-GCOPYGHH.mjs +0 -27
  144. package/dist/chunk-GCOPYGHH.mjs.map +0 -1
  145. package/dist/chunk-GPEJCUWA.mjs.map +0 -1
  146. package/dist/chunk-IJLMKBSZ.mjs +0 -25
  147. package/dist/chunk-IJLMKBSZ.mjs.map +0 -1
  148. package/dist/chunk-INCNMGJ7.mjs +0 -72
  149. package/dist/chunk-INCNMGJ7.mjs.map +0 -1
  150. package/dist/chunk-M3CZWJI3.mjs +0 -44
  151. package/dist/chunk-M3CZWJI3.mjs.map +0 -1
  152. package/dist/chunk-MC6KTH4X.mjs +0 -12
  153. package/dist/chunk-MC6KTH4X.mjs.map +0 -1
  154. package/dist/chunk-NXWVWC33.mjs.map +0 -1
  155. package/dist/chunk-OHWEJUCS.mjs +0 -18
  156. package/dist/chunk-OHWEJUCS.mjs.map +0 -1
  157. package/dist/chunk-OOBQC5H6.mjs +0 -34
  158. package/dist/chunk-OOBQC5H6.mjs.map +0 -1
  159. package/dist/chunk-Q6YO7LDK.mjs +0 -40
  160. package/dist/chunk-Q6YO7LDK.mjs.map +0 -1
  161. package/dist/chunk-QFASQEFJ.mjs.map +0 -1
  162. package/dist/chunk-RPTRCFSO.mjs +0 -42
  163. package/dist/chunk-RPTRCFSO.mjs.map +0 -1
  164. package/dist/chunk-SEH5PQVW.mjs +0 -52
  165. package/dist/chunk-SEH5PQVW.mjs.map +0 -1
  166. package/dist/chunk-SHOTWRKC.mjs +0 -18
  167. package/dist/chunk-SHOTWRKC.mjs.map +0 -1
  168. package/dist/chunk-SRBUGQTM.mjs +0 -109
  169. package/dist/chunk-SRBUGQTM.mjs.map +0 -1
  170. package/dist/chunk-TEYIQHMK.mjs +0 -12
  171. package/dist/chunk-TEYIQHMK.mjs.map +0 -1
  172. package/dist/chunk-UIRFLYXI.mjs.map +0 -1
  173. package/dist/chunk-VGX2W5ZB.mjs +0 -28
  174. package/dist/chunk-VGX2W5ZB.mjs.map +0 -1
  175. package/dist/chunk-X3Z2EVFV.mjs.map +0 -1
  176. package/dist/chunk-X4T6ZUVM.mjs.map +0 -1
  177. package/dist/chunk-XGUBRIUV.mjs +0 -72
  178. package/dist/chunk-XGUBRIUV.mjs.map +0 -1
  179. package/dist/chunk-Y2RUG4B3.mjs.map +0 -1
  180. package/dist/chunk-ZVAH2Z2W.mjs.map +0 -1
  181. package/dist/chunk-ZYC5YVDO.mjs +0 -21
  182. package/dist/chunk-ZYC5YVDO.mjs.map +0 -1
  183. package/dist/components/chat-components/chat-list.d.ts +0 -8
  184. package/dist/components/chat-components/chat-list.mjs +0 -13
  185. package/dist/components/chat-components/chat-message-actions.d.ts +0 -8
  186. package/dist/components/chat-components/chat-message-actions.mjs +0 -8
  187. package/dist/components/chat-components/chat-message.d.ts +0 -8
  188. package/dist/components/chat-components/chat-message.mjs +0 -11
  189. package/dist/components/chat-components/chat-panel.d.ts +0 -8
  190. package/dist/components/chat-components/chat-panel.mjs +0 -10
  191. package/dist/components/chat-components/chat-scroll-anchor.d.ts +0 -6
  192. package/dist/components/chat-components/chat-scroll-anchor.mjs +0 -5
  193. package/dist/components/chat-components/clear-history.d.ts +0 -9
  194. package/dist/components/chat-components/clear-history.mjs +0 -56
  195. package/dist/components/chat-components/clear-history.mjs.map +0 -1
  196. package/dist/components/chat-components/copilot-chat.d.ts +0 -12
  197. package/dist/components/chat-components/copilot-chat.mjs +0 -22
  198. package/dist/components/chat-components/copilot-chat.mjs.map +0 -1
  199. package/dist/components/chat-components/default-empty-screen.d.ts +0 -8
  200. package/dist/components/chat-components/default-empty-screen.mjs +0 -8
  201. package/dist/components/chat-components/default-empty-screen.mjs.map +0 -1
  202. package/dist/components/chat-components/external-link.d.ts +0 -6
  203. package/dist/components/chat-components/external-link.mjs +0 -4
  204. package/dist/components/chat-components/external-link.mjs.map +0 -1
  205. package/dist/components/chat-components/markdown.d.ts +0 -6
  206. package/dist/components/chat-components/markdown.mjs +0 -4
  207. package/dist/components/chat-components/markdown.mjs.map +0 -1
  208. package/dist/components/chat-components/prompt-form.d.ts +0 -9
  209. package/dist/components/chat-components/prompt-form.mjs +0 -9
  210. package/dist/components/chat-components/prompt-form.mjs.map +0 -1
  211. package/dist/components/chat-components/theme-toggle.d.ts +0 -3
  212. package/dist/components/chat-components/theme-toggle.mjs +0 -32
  213. package/dist/components/chat-components/theme-toggle.mjs.map +0 -1
  214. package/dist/components/chat-components/toaster.d.ts +0 -1
  215. package/dist/components/chat-components/toaster.mjs +0 -4
  216. package/dist/components/chat-components/toaster.mjs.map +0 -1
  217. package/dist/components/chat-components/ui/alert-dialog.d.ts +0 -20
  218. package/dist/components/chat-components/ui/alert-dialog.mjs +0 -6
  219. package/dist/components/chat-components/ui/alert-dialog.mjs.map +0 -1
  220. package/dist/components/chat-components/ui/badge.d.ts +0 -12
  221. package/dist/components/chat-components/ui/badge.mjs +0 -29
  222. package/dist/components/chat-components/ui/badge.mjs.map +0 -1
  223. package/dist/components/chat-components/ui/button.d.ts +0 -14
  224. package/dist/components/chat-components/ui/button.mjs +0 -5
  225. package/dist/components/chat-components/ui/button.mjs.map +0 -1
  226. package/dist/components/chat-components/ui/codeblock.d.ts +0 -14
  227. package/dist/components/chat-components/ui/codeblock.mjs +0 -8
  228. package/dist/components/chat-components/ui/codeblock.mjs.map +0 -1
  229. package/dist/components/chat-components/ui/dialog.d.ts +0 -18
  230. package/dist/components/chat-components/ui/dialog.mjs +0 -94
  231. package/dist/components/chat-components/ui/dialog.mjs.map +0 -1
  232. package/dist/components/chat-components/ui/dropdown-menu.d.ts +0 -24
  233. package/dist/components/chat-components/ui/dropdown-menu.mjs +0 -87
  234. package/dist/components/chat-components/ui/dropdown-menu.mjs.map +0 -1
  235. package/dist/components/chat-components/ui/icons.d.ts +0 -33
  236. package/dist/components/chat-components/ui/icons.mjs +0 -5
  237. package/dist/components/chat-components/ui/icons.mjs.map +0 -1
  238. package/dist/components/chat-components/ui/input.d.ts +0 -7
  239. package/dist/components/chat-components/ui/input.mjs +0 -26
  240. package/dist/components/chat-components/ui/input.mjs.map +0 -1
  241. package/dist/components/chat-components/ui/label.d.ts +0 -8
  242. package/dist/components/chat-components/ui/label.mjs +0 -19
  243. package/dist/components/chat-components/ui/label.mjs.map +0 -1
  244. package/dist/components/chat-components/ui/select.d.ts +0 -13
  245. package/dist/components/chat-components/ui/select.mjs +0 -101
  246. package/dist/components/chat-components/ui/select.mjs.map +0 -1
  247. package/dist/components/chat-components/ui/separator.d.ts +0 -6
  248. package/dist/components/chat-components/ui/separator.mjs +0 -5
  249. package/dist/components/chat-components/ui/separator.mjs.map +0 -1
  250. package/dist/components/chat-components/ui/sheet.d.ts +0 -19
  251. package/dist/components/chat-components/ui/sheet.mjs +0 -93
  252. package/dist/components/chat-components/ui/sheet.mjs.map +0 -1
  253. package/dist/components/chat-components/ui/switch.d.ts +0 -6
  254. package/dist/components/chat-components/ui/switch.mjs +0 -33
  255. package/dist/components/chat-components/ui/switch.mjs.map +0 -1
  256. package/dist/components/chat-components/ui/textarea.d.ts +0 -7
  257. package/dist/components/chat-components/ui/textarea.mjs +0 -25
  258. package/dist/components/chat-components/ui/textarea.mjs.map +0 -1
  259. package/dist/components/chat-components/ui/tooltip.d.ts +0 -9
  260. package/dist/components/chat-components/ui/tooltip.mjs +0 -5
  261. package/dist/components/chat-components/ui/tooltip.mjs.map +0 -1
  262. package/dist/components/sidebar/copilot-sidebar-ui-provider.d.ts +0 -8
  263. package/dist/components/sidebar/copilot-sidebar-ui-provider.mjs +0 -25
  264. package/dist/components/sidebar/copilot-sidebar-ui-provider.mjs.map +0 -1
  265. package/dist/components/sidebar/copilot-sidebar.d.ts +0 -6
  266. package/dist/components/sidebar/copilot-sidebar.mjs +0 -23
  267. package/dist/components/sidebar/copilot-sidebar.mjs.map +0 -1
  268. package/dist/components/sidebar/sidebar-context.d.ts +0 -9
  269. package/dist/components/sidebar/sidebar-context.mjs +0 -4
  270. package/dist/components/sidebar/sidebar-context.mjs.map +0 -1
  271. package/dist/hooks/use-at-bottom.d.ts +0 -3
  272. package/dist/hooks/use-at-bottom.mjs +0 -4
  273. package/dist/hooks/use-at-bottom.mjs.map +0 -1
  274. package/dist/hooks/use-enter-submit.d.ts +0 -8
  275. package/dist/hooks/use-enter-submit.mjs +0 -4
  276. package/dist/hooks/use-enter-submit.mjs.map +0 -1
  277. package/src/components/chat-components/chat-list.tsx +0 -28
  278. package/src/components/chat-components/chat-message-actions.tsx +0 -36
  279. package/src/components/chat-components/chat-message.tsx +0 -70
  280. package/src/components/chat-components/chat-panel.tsx +0 -64
  281. package/src/components/chat-components/chat-scroll-anchor.tsx +0 -29
  282. package/src/components/chat-components/clear-history.tsx +0 -72
  283. package/src/components/chat-components/copilot-chat.tsx +0 -57
  284. package/src/components/chat-components/default-empty-screen.tsx +0 -57
  285. package/src/components/chat-components/external-link.tsx +0 -17
  286. package/src/components/chat-components/markdown.tsx +0 -8
  287. package/src/components/chat-components/prompt-form.tsx +0 -85
  288. package/src/components/chat-components/theme-toggle.tsx +0 -31
  289. package/src/components/chat-components/toaster.tsx +0 -3
  290. package/src/components/chat-components/ui/alert-dialog.tsx +0 -126
  291. package/src/components/chat-components/ui/badge.tsx +0 -33
  292. package/src/components/chat-components/ui/button.tsx +0 -49
  293. package/src/components/chat-components/ui/codeblock.tsx +0 -137
  294. package/src/components/chat-components/ui/dialog.tsx +0 -106
  295. package/src/components/chat-components/ui/dropdown-menu.tsx +0 -117
  296. package/src/components/chat-components/ui/icons.tsx +0 -484
  297. package/src/components/chat-components/ui/input.tsx +0 -24
  298. package/src/components/chat-components/ui/label.tsx +0 -21
  299. package/src/components/chat-components/ui/select.tsx +0 -119
  300. package/src/components/chat-components/ui/separator.tsx +0 -26
  301. package/src/components/chat-components/ui/sheet.tsx +0 -106
  302. package/src/components/chat-components/ui/switch.tsx +0 -29
  303. package/src/components/chat-components/ui/textarea.tsx +0 -23
  304. package/src/components/chat-components/ui/tooltip.tsx +0 -30
  305. package/src/components/sidebar/copilot-sidebar-ui-provider.tsx +0 -73
  306. package/src/components/sidebar/copilot-sidebar.tsx +0 -38
  307. package/src/components/sidebar/sidebar-context.tsx +0 -11
  308. package/src/hooks/use-at-bottom.tsx +0 -20
  309. package/src/hooks/use-enter-submit.tsx +0 -17
  310. /package/dist/{chunk-FZRTAML3.mjs.map → chunk-JD7BAH7U.mjs.map} +0 -0
  311. /package/dist/components/{chat-components/chat-list.mjs.map → chat/props.js.map} +0 -0
  312. /package/dist/{components/chat-components/chat-message-actions.mjs.map → context/index.js.map} +0 -0
  313. /package/dist/{components/chat-components/chat-message.mjs.map → hooks/index.js.map} +0 -0
  314. /package/dist/{components/chat-components/chat-panel.mjs.map → types/index.js.map} +0 -0
  315. /package/dist/{components/chat-components/chat-scroll-anchor.mjs.map → types/types.js.map} +0 -0
@@ -0,0 +1,817 @@
1
+ 'use strict';
2
+
3
+ var React = require('react');
4
+ var jsxRuntime = require('react/jsx-runtime');
5
+ var reactCore = require('@copilotkit/react-core');
6
+ var nanoid = require('nanoid');
7
+ var ReactMarkdown = require('react-markdown');
8
+ var reactSyntaxHighlighter = require('react-syntax-highlighter');
9
+ var prism = require('react-syntax-highlighter/dist/esm/styles/prism');
10
+ var remarkGfm = require('remark-gfm');
11
+ var remarkMath = require('remark-math');
12
+
13
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
14
+
15
+ function _interopNamespace(e) {
16
+ if (e && e.__esModule) return e;
17
+ var n = Object.create(null);
18
+ if (e) {
19
+ Object.keys(e).forEach(function (k) {
20
+ if (k !== 'default') {
21
+ var d = Object.getOwnPropertyDescriptor(e, k);
22
+ Object.defineProperty(n, k, d.get ? d : {
23
+ enumerable: true,
24
+ get: function () { return e[k]; }
25
+ });
26
+ }
27
+ });
28
+ }
29
+ n.default = e;
30
+ return Object.freeze(n);
31
+ }
32
+
33
+ var React__namespace = /*#__PURE__*/_interopNamespace(React);
34
+ var ReactMarkdown__default = /*#__PURE__*/_interopDefault(ReactMarkdown);
35
+ var remarkGfm__default = /*#__PURE__*/_interopDefault(remarkGfm);
36
+ var remarkMath__default = /*#__PURE__*/_interopDefault(remarkMath);
37
+
38
+ var __defProp = Object.defineProperty;
39
+ var __defProps = Object.defineProperties;
40
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
41
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
42
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
43
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
44
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
45
+ var __spreadValues = (a, b) => {
46
+ for (var prop in b || (b = {}))
47
+ if (__hasOwnProp.call(b, prop))
48
+ __defNormalProp(a, prop, b[prop]);
49
+ if (__getOwnPropSymbols)
50
+ for (var prop of __getOwnPropSymbols(b)) {
51
+ if (__propIsEnum.call(b, prop))
52
+ __defNormalProp(a, prop, b[prop]);
53
+ }
54
+ return a;
55
+ };
56
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
57
+ var __objRest = (source, exclude) => {
58
+ var target = {};
59
+ for (var prop in source)
60
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
61
+ target[prop] = source[prop];
62
+ if (source != null && __getOwnPropSymbols)
63
+ for (var prop of __getOwnPropSymbols(source)) {
64
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
65
+ target[prop] = source[prop];
66
+ }
67
+ return target;
68
+ };
69
+ var __async = (__this, __arguments, generator) => {
70
+ return new Promise((resolve, reject) => {
71
+ var fulfilled = (value) => {
72
+ try {
73
+ step(generator.next(value));
74
+ } catch (e) {
75
+ reject(e);
76
+ }
77
+ };
78
+ var rejected = (value) => {
79
+ try {
80
+ step(generator.throw(value));
81
+ } catch (e) {
82
+ reject(e);
83
+ }
84
+ };
85
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
86
+ step((generator = generator.apply(__this, __arguments)).next());
87
+ });
88
+ };
89
+ var OpenIcon = /* @__PURE__ */ jsxRuntime.jsx(
90
+ "svg",
91
+ {
92
+ xmlns: "http://www.w3.org/2000/svg",
93
+ viewBox: "0 0 24 24",
94
+ fill: "currentColor",
95
+ width: "24",
96
+ height: "24",
97
+ children: /* @__PURE__ */ jsxRuntime.jsx("g", { transform: "translate(24, 0) scale(-1, 1)", children: /* @__PURE__ */ jsxRuntime.jsx(
98
+ "path",
99
+ {
100
+ fillRule: "evenodd",
101
+ d: "M5.337 21.718a6.707 6.707 0 01-.533-.074.75.75 0 01-.44-1.223 3.73 3.73 0 00.814-1.686c.023-.115-.022-.317-.254-.543C3.274 16.587 2.25 14.41 2.25 12c0-5.03 4.428-9 9.75-9s9.75 3.97 9.75 9c0 5.03-4.428 9-9.75 9-.833 0-1.643-.097-2.417-.279a6.721 6.721 0 01-4.246.997z",
102
+ clipRule: "evenodd"
103
+ }
104
+ ) })
105
+ }
106
+ );
107
+ var CloseIcon = /* @__PURE__ */ jsxRuntime.jsx(
108
+ "svg",
109
+ {
110
+ xmlns: "http://www.w3.org/2000/svg",
111
+ fill: "none",
112
+ viewBox: "0 0 24 24",
113
+ strokeWidth: "1.5",
114
+ stroke: "currentColor",
115
+ width: "24",
116
+ height: "24",
117
+ children: /* @__PURE__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M19.5 8.25l-7.5 7.5-7.5-7.5" })
118
+ }
119
+ );
120
+ var HeaderCloseIcon = /* @__PURE__ */ jsxRuntime.jsx(
121
+ "svg",
122
+ {
123
+ xmlns: "http://www.w3.org/2000/svg",
124
+ fill: "none",
125
+ viewBox: "0 0 24 24",
126
+ strokeWidth: "1.5",
127
+ stroke: "currentColor",
128
+ width: "24",
129
+ height: "24",
130
+ children: /* @__PURE__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M6 18L18 6M6 6l12 12" })
131
+ }
132
+ );
133
+ var SendIcon = /* @__PURE__ */ jsxRuntime.jsx(
134
+ "svg",
135
+ {
136
+ xmlns: "http://www.w3.org/2000/svg",
137
+ fill: "none",
138
+ viewBox: "0 0 24 24",
139
+ strokeWidth: 1.5,
140
+ stroke: "currentColor",
141
+ width: "24",
142
+ height: "24",
143
+ children: /* @__PURE__ */ jsxRuntime.jsx(
144
+ "path",
145
+ {
146
+ strokeLinecap: "round",
147
+ strokeLinejoin: "round",
148
+ d: "M6 12L3.269 3.126A59.768 59.768 0 0121.485 12 59.77 59.77 0 013.27 20.876L5.999 12zm0 0h7.5"
149
+ }
150
+ )
151
+ }
152
+ );
153
+ var SpinnerIcon = /* @__PURE__ */ jsxRuntime.jsxs(
154
+ "svg",
155
+ {
156
+ style: {
157
+ animation: "copilotKitSpinAnimation 1s linear infinite",
158
+ color: "rgb(107 114 128)"
159
+ },
160
+ width: "24",
161
+ height: "24",
162
+ xmlns: "http://www.w3.org/2000/svg",
163
+ fill: "none",
164
+ viewBox: "0 0 24 24",
165
+ children: [
166
+ /* @__PURE__ */ jsxRuntime.jsx(
167
+ "circle",
168
+ {
169
+ style: { opacity: 0.25 },
170
+ cx: "12",
171
+ cy: "12",
172
+ r: "10",
173
+ stroke: "currentColor",
174
+ strokeWidth: "4"
175
+ }
176
+ ),
177
+ /* @__PURE__ */ jsxRuntime.jsx(
178
+ "path",
179
+ {
180
+ style: { opacity: 0.75 },
181
+ fill: "currentColor",
182
+ d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
183
+ }
184
+ )
185
+ ]
186
+ }
187
+ );
188
+ var ActivityIcon = /* @__PURE__ */ jsxRuntime.jsxs(
189
+ "svg",
190
+ {
191
+ style: {
192
+ display: "inline-block",
193
+ marginLeft: "0.25rem",
194
+ marginRight: "0.25rem"
195
+ },
196
+ height: "24",
197
+ width: "24",
198
+ viewBox: "0 0 27 27",
199
+ xmlns: "http://www.w3.org/2000/svg",
200
+ fill: "currentColor",
201
+ children: [
202
+ /* @__PURE__ */ jsxRuntime.jsx("circle", { className: "copilotKitActivityDot1", cx: "4", cy: "12", r: "3" }),
203
+ /* @__PURE__ */ jsxRuntime.jsx("circle", { className: "copilotKitActivityDot1 copilotKitActivityDot2", cx: "12", cy: "12", r: "3" }),
204
+ /* @__PURE__ */ jsxRuntime.jsx("circle", { className: "copilotKitActivityDot1 copilotKitActivityDot3", cx: "20", cy: "12", r: "3" })
205
+ ]
206
+ }
207
+ );
208
+ function CheckIcon(_a) {
209
+ var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
210
+ return /* @__PURE__ */ jsxRuntime.jsx(
211
+ "svg",
212
+ __spreadProps(__spreadValues({
213
+ xmlns: "http://www.w3.org/2000/svg",
214
+ viewBox: "0 0 256 256",
215
+ fill: "currentColor",
216
+ style: { height: "1rem", width: "1rem" },
217
+ className
218
+ }, props), {
219
+ children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "m229.66 77.66-128 128a8 8 0 0 1-11.32 0l-56-56a8 8 0 0 1 11.32-11.32L96 188.69 218.34 66.34a8 8 0 0 1 11.32 11.32Z" })
220
+ })
221
+ );
222
+ }
223
+ function DownloadIcon(_a) {
224
+ var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
225
+ return /* @__PURE__ */ jsxRuntime.jsx(
226
+ "svg",
227
+ __spreadProps(__spreadValues({
228
+ xmlns: "http://www.w3.org/2000/svg",
229
+ viewBox: "0 0 256 256",
230
+ fill: "currentColor",
231
+ style: { height: "1rem", width: "1rem" },
232
+ className
233
+ }, props), {
234
+ children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M224 152v56a16 16 0 0 1-16 16H48a16 16 0 0 1-16-16v-56a8 8 0 0 1 16 0v56h160v-56a8 8 0 0 1 16 0Zm-101.66 5.66a8 8 0 0 0 11.32 0l40-40a8 8 0 0 0-11.32-11.32L136 132.69V40a8 8 0 0 0-16 0v92.69l-26.34-26.35a8 8 0 0 0-11.32 11.32Z" })
235
+ })
236
+ );
237
+ }
238
+ function CopyIcon(_a) {
239
+ var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
240
+ return /* @__PURE__ */ jsxRuntime.jsx(
241
+ "svg",
242
+ __spreadProps(__spreadValues({
243
+ xmlns: "http://www.w3.org/2000/svg",
244
+ viewBox: "0 0 256 256",
245
+ fill: "currentColor",
246
+ style: { height: "1rem", width: "1rem" },
247
+ className
248
+ }, props), {
249
+ children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M216 32H88a8 8 0 0 0-8 8v40H40a8 8 0 0 0-8 8v128a8 8 0 0 0 8 8h128a8 8 0 0 0 8-8v-40h40a8 8 0 0 0 8-8V40a8 8 0 0 0-8-8Zm-56 176H48V96h112Zm48-48h-32V88a8 8 0 0 0-8-8H96V48h112Z" })
250
+ })
251
+ );
252
+ }
253
+ var StopIcon = /* @__PURE__ */ jsxRuntime.jsx(
254
+ "svg",
255
+ {
256
+ xmlns: "http://www.w3.org/2000/svg",
257
+ viewBox: "0 0 256 256",
258
+ fill: "currentColor",
259
+ style: { height: "1rem", width: "1rem" },
260
+ children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M128 24a104 104 0 1 0 104 104A104.11 104.11 0 0 0 128 24Zm0 192a88 88 0 1 1 88-88 88.1 88.1 0 0 1-88 88Zm24-120h-48a8 8 0 0 0-8 8v48a8 8 0 0 0 8 8h48a8 8 0 0 0 8-8v-48a8 8 0 0 0-8-8Zm-8 48h-32v-32h32Z" })
261
+ }
262
+ );
263
+ var RegenerateIcon = /* @__PURE__ */ jsxRuntime.jsx(
264
+ "svg",
265
+ {
266
+ xmlns: "http://www.w3.org/2000/svg",
267
+ viewBox: "0 0 256 256",
268
+ fill: "currentColor",
269
+ style: { height: "1rem", width: "1rem" },
270
+ children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M197.67 186.37a8 8 0 0 1 0 11.29C196.58 198.73 170.82 224 128 224c-37.39 0-64.53-22.4-80-39.85V208a8 8 0 0 1-16 0v-48a8 8 0 0 1 8-8h48a8 8 0 0 1 0 16H55.44C67.76 183.35 93 208 128 208c36 0 58.14-21.46 58.36-21.68a8 8 0 0 1 11.31.05ZM216 40a8 8 0 0 0-8 8v23.85C192.53 54.4 165.39 32 128 32c-42.82 0-68.58 25.27-69.66 26.34a8 8 0 0 0 11.3 11.34C69.86 69.46 92 48 128 48c35 0 60.24 24.65 72.56 40H168a8 8 0 0 0 0 16h48a8 8 0 0 0 8-8V48a8 8 0 0 0-8-8Z" })
271
+ }
272
+ );
273
+ var ChatContext = React__namespace.default.createContext(void 0);
274
+ function useChatContext() {
275
+ const context = React__namespace.default.useContext(ChatContext);
276
+ if (context === void 0) {
277
+ throw new Error(
278
+ "Context not found. Did you forget to wrap your app in a <ChatContextProvider> component?"
279
+ );
280
+ }
281
+ return context;
282
+ }
283
+ var ChatContextProvider = ({
284
+ // temperature,
285
+ // instructions,
286
+ // maxFeedback,
287
+ labels,
288
+ icons,
289
+ children
290
+ }) => {
291
+ const context = React.useMemo(
292
+ () => ({
293
+ labels: __spreadValues(__spreadValues({}, {
294
+ initial: "",
295
+ title: "CopilotKit",
296
+ placeholder: "Type a message...",
297
+ thinking: "Thinking...",
298
+ done: "\u2705 Done",
299
+ error: "\u274C An error occurred. Please try again.",
300
+ stopGenerating: "Stop generating",
301
+ regenerateResponse: "Regenerate response"
302
+ }), labels),
303
+ icons: __spreadProps(__spreadValues({}, {
304
+ openIcon: OpenIcon,
305
+ closeIcon: CloseIcon,
306
+ headerCloseIcon: HeaderCloseIcon,
307
+ sendIcon: SendIcon,
308
+ activityIcon: ActivityIcon,
309
+ spinnerIcon: SpinnerIcon,
310
+ stopIcon: StopIcon,
311
+ regenerateIcon: RegenerateIcon
312
+ }), {
313
+ icons
314
+ })
315
+ }),
316
+ [labels, icons]
317
+ );
318
+ return /* @__PURE__ */ jsxRuntime.jsx(ChatContext.Provider, { value: context, children });
319
+ };
320
+ var Window = ({
321
+ open,
322
+ setOpen,
323
+ children,
324
+ clickOutsideToClose,
325
+ hotkey,
326
+ hitEscapeToClose
327
+ }) => {
328
+ const windowRef = React__namespace.default.useRef(null);
329
+ const handleClickOutside = React.useCallback(
330
+ (event) => {
331
+ var _a;
332
+ if (!clickOutsideToClose) {
333
+ return;
334
+ }
335
+ const parentElement = (_a = windowRef.current) == null ? void 0 : _a.parentElement;
336
+ if (open && parentElement && !parentElement.contains(event.target)) {
337
+ setOpen(false);
338
+ }
339
+ },
340
+ [clickOutsideToClose, open, setOpen]
341
+ );
342
+ const handleKeyDown = React.useCallback(
343
+ (event) => {
344
+ var _a;
345
+ const target = event.target;
346
+ const isInput = target.tagName === "INPUT" || target.tagName === "SELECT" || target.tagName === "TEXTAREA" || target.isContentEditable;
347
+ const isDescendantOfWrapper = (_a = windowRef.current) == null ? void 0 : _a.contains(target);
348
+ if (open && event.key === "Escape" && (!isInput || isDescendantOfWrapper) && hitEscapeToClose) {
349
+ setOpen(false);
350
+ } else if (event.key === hotkey && (isMacOS() && event.metaKey || !isMacOS() && event.ctrlKey) && (!isInput || isDescendantOfWrapper)) {
351
+ setOpen(!open);
352
+ }
353
+ },
354
+ [hitEscapeToClose, hotkey, open, setOpen]
355
+ );
356
+ const adjustForMobile = React.useCallback(() => {
357
+ const copilotKitWindow = windowRef.current;
358
+ const vv = window.visualViewport;
359
+ if (!copilotKitWindow || !vv) {
360
+ return;
361
+ }
362
+ if (window.innerWidth < 640 && open) {
363
+ copilotKitWindow.style.height = `${vv.height}px`;
364
+ copilotKitWindow.style.left = `${vv.offsetLeft}px`;
365
+ copilotKitWindow.style.top = `${vv.offsetTop}px`;
366
+ document.body.style.position = "fixed";
367
+ document.body.style.width = "100%";
368
+ document.body.style.height = `${window.innerHeight}px`;
369
+ document.body.style.overflow = "hidden";
370
+ document.body.style.touchAction = "none";
371
+ document.body.addEventListener("touchmove", preventScroll, {
372
+ passive: false
373
+ });
374
+ } else {
375
+ copilotKitWindow.style.height = "";
376
+ copilotKitWindow.style.left = "";
377
+ copilotKitWindow.style.top = "";
378
+ document.body.style.position = "";
379
+ document.body.style.height = "";
380
+ document.body.style.width = "";
381
+ document.body.style.overflow = "";
382
+ document.body.style.top = "";
383
+ document.body.style.touchAction = "";
384
+ document.body.removeEventListener("touchmove", preventScroll);
385
+ }
386
+ }, [open]);
387
+ React.useEffect(() => {
388
+ document.addEventListener("mousedown", handleClickOutside);
389
+ document.addEventListener("keydown", handleKeyDown);
390
+ if (window.visualViewport) {
391
+ window.visualViewport.addEventListener("resize", adjustForMobile);
392
+ adjustForMobile();
393
+ }
394
+ return () => {
395
+ document.removeEventListener("mousedown", handleClickOutside);
396
+ document.removeEventListener("keydown", handleKeyDown);
397
+ if (window.visualViewport) {
398
+ window.visualViewport.removeEventListener("resize", adjustForMobile);
399
+ }
400
+ };
401
+ }, [adjustForMobile, handleClickOutside, handleKeyDown]);
402
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: `copilotKitWindow${open ? " open" : ""}`, ref: windowRef, children });
403
+ };
404
+ var preventScroll = (event) => {
405
+ let targetElement = event.target;
406
+ const hasParentWithClass = (element, className) => {
407
+ while (element && element !== document.body) {
408
+ if (element.classList.contains(className)) {
409
+ return true;
410
+ }
411
+ element = element.parentElement;
412
+ }
413
+ return false;
414
+ };
415
+ if (!hasParentWithClass(targetElement, "copilotKitMessages")) {
416
+ event.preventDefault();
417
+ }
418
+ };
419
+ function isMacOS() {
420
+ return /Mac|iMac|Macintosh/i.test(navigator.userAgent);
421
+ }
422
+ var Button = ({ open, setOpen }) => {
423
+ const context = useChatContext();
424
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { onClick: () => setOpen(!open), children: /* @__PURE__ */ jsxRuntime.jsxs(
425
+ "button",
426
+ {
427
+ className: `copilotKitButton ${open ? "open" : ""}`,
428
+ "aria-label": open ? "Close Chat" : "Open Chat",
429
+ children: [
430
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "copilotKitButtonIcon copilotKitButtonIconOpen", children: context.icons.openIcon }),
431
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "copilotKitButtonIcon copilotKitButtonIconClose", children: context.icons.closeIcon })
432
+ ]
433
+ }
434
+ ) });
435
+ };
436
+ var Header = ({ setOpen }) => {
437
+ const context = useChatContext();
438
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "copilotKitHeader", children: [
439
+ /* @__PURE__ */ jsxRuntime.jsx("div", { children: context.labels.title }),
440
+ /* @__PURE__ */ jsxRuntime.jsx("button", { onClick: () => setOpen(false), "aria-label": "Close", children: context.icons.headerCloseIcon })
441
+ ] });
442
+ };
443
+ function useCopyToClipboard({ timeout = 2e3 }) {
444
+ const [isCopied, setIsCopied] = React__namespace.useState(false);
445
+ const copyToClipboard = (value) => {
446
+ var _a;
447
+ if (typeof window === "undefined" || !((_a = navigator.clipboard) == null ? void 0 : _a.writeText)) {
448
+ return;
449
+ }
450
+ if (!value) {
451
+ return;
452
+ }
453
+ navigator.clipboard.writeText(value).then(() => {
454
+ setIsCopied(true);
455
+ setTimeout(() => {
456
+ setIsCopied(false);
457
+ }, timeout);
458
+ });
459
+ };
460
+ return { isCopied, copyToClipboard };
461
+ }
462
+ var programmingLanguages = {
463
+ javascript: ".js",
464
+ python: ".py",
465
+ java: ".java",
466
+ c: ".c",
467
+ cpp: ".cpp",
468
+ "c++": ".cpp",
469
+ "c#": ".cs",
470
+ ruby: ".rb",
471
+ php: ".php",
472
+ swift: ".swift",
473
+ "objective-c": ".m",
474
+ kotlin: ".kt",
475
+ typescript: ".ts",
476
+ go: ".go",
477
+ perl: ".pl",
478
+ rust: ".rs",
479
+ scala: ".scala",
480
+ haskell: ".hs",
481
+ lua: ".lua",
482
+ shell: ".sh",
483
+ sql: ".sql",
484
+ html: ".html",
485
+ css: ".css"
486
+ // add more file extensions here, make sure the key is same as language prop in CodeBlock.tsx component
487
+ };
488
+ var generateRandomString = (length, lowercase = false) => {
489
+ const chars = "ABCDEFGHJKLMNPQRSTUVWXY3456789";
490
+ let result = "";
491
+ for (let i = 0; i < length; i++) {
492
+ result += chars.charAt(Math.floor(Math.random() * chars.length));
493
+ }
494
+ return lowercase ? result.toLowerCase() : result;
495
+ };
496
+ var CodeBlock = React.memo(({ language, value }) => {
497
+ const { isCopied, copyToClipboard } = useCopyToClipboard({ timeout: 2e3 });
498
+ const downloadAsFile = () => {
499
+ if (typeof window === "undefined") {
500
+ return;
501
+ }
502
+ const fileExtension = programmingLanguages[language] || ".file";
503
+ const suggestedFileName = `file-${generateRandomString(3, true)}${fileExtension}`;
504
+ const fileName = window.prompt("Enter file name", suggestedFileName);
505
+ if (!fileName) {
506
+ return;
507
+ }
508
+ const blob = new Blob([value], { type: "text/plain" });
509
+ const url = URL.createObjectURL(blob);
510
+ const link = document.createElement("a");
511
+ link.download = fileName;
512
+ link.href = url;
513
+ link.style.display = "none";
514
+ document.body.appendChild(link);
515
+ link.click();
516
+ document.body.removeChild(link);
517
+ URL.revokeObjectURL(url);
518
+ };
519
+ const onCopy = () => {
520
+ if (isCopied)
521
+ return;
522
+ copyToClipboard(value);
523
+ };
524
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "copilotKitCodeBlock", children: [
525
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "copilotKitCodeBlockToolbar", children: [
526
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "copilotKitCodeBlockToolbarLanguage", children: language }),
527
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "copilotKitCodeBlockToolbarButtons", children: [
528
+ /* @__PURE__ */ jsxRuntime.jsxs("button", { className: "copilotKitCodeBlockToolbarButton", onClick: downloadAsFile, children: [
529
+ /* @__PURE__ */ jsxRuntime.jsx(DownloadIcon, {}),
530
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Download" })
531
+ ] }),
532
+ /* @__PURE__ */ jsxRuntime.jsxs("button", { className: "copilotKitCodeBlockToolbarButton", onClick: onCopy, children: [
533
+ isCopied ? /* @__PURE__ */ jsxRuntime.jsx(CheckIcon, {}) : /* @__PURE__ */ jsxRuntime.jsx(CopyIcon, {}),
534
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Copy code" })
535
+ ] })
536
+ ] })
537
+ ] }),
538
+ /* @__PURE__ */ jsxRuntime.jsx(
539
+ reactSyntaxHighlighter.Prism,
540
+ {
541
+ language,
542
+ style: prism.vscDarkPlus,
543
+ PreTag: "div",
544
+ customStyle: {
545
+ margin: 0,
546
+ borderBottomLeftRadius: "0.375rem",
547
+ borderBottomRightRadius: "0.375rem"
548
+ },
549
+ children: value
550
+ }
551
+ )
552
+ ] });
553
+ });
554
+ CodeBlock.displayName = "CodeBlock";
555
+ var MemoizedReactMarkdown = React.memo(
556
+ ReactMarkdown__default.default,
557
+ (prevProps, nextProps) => prevProps.children === nextProps.children && prevProps.className === nextProps.className
558
+ );
559
+ var Markdown = ({ content }) => {
560
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "copilotKitMarkdown", children: /* @__PURE__ */ jsxRuntime.jsx(MemoizedReactMarkdown, { components, remarkPlugins: [remarkGfm__default.default, remarkMath__default.default], children: content }) });
561
+ };
562
+ var components = {
563
+ p({ children }) {
564
+ return /* @__PURE__ */ jsxRuntime.jsx("p", { children });
565
+ },
566
+ code(_a) {
567
+ var _b = _a, { children, className, inline } = _b, props = __objRest(_b, ["children", "className", "inline"]);
568
+ if (children.length) {
569
+ if (children[0] == "\u258D") {
570
+ return /* @__PURE__ */ jsxRuntime.jsx(
571
+ "span",
572
+ {
573
+ style: {
574
+ animation: "pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite",
575
+ marginTop: "0.25rem"
576
+ },
577
+ children: "\u258D"
578
+ }
579
+ );
580
+ }
581
+ children[0] = children[0].replace("`\u258D`", "\u258D");
582
+ }
583
+ const match = /language-(\w+)/.exec(className || "");
584
+ if (inline) {
585
+ return /* @__PURE__ */ jsxRuntime.jsx("code", __spreadProps(__spreadValues({ className }, props), { children }));
586
+ }
587
+ return /* @__PURE__ */ jsxRuntime.jsx(
588
+ CodeBlock,
589
+ __spreadValues({
590
+ language: match && match[1] || "",
591
+ value: String(children).replace(/\n$/, "")
592
+ }, props),
593
+ Math.random()
594
+ );
595
+ }
596
+ };
597
+ var Messages = ({ messages, inProgress }) => {
598
+ const context = useChatContext();
599
+ const initialMessages = React.useMemo(
600
+ () => makeInitialMessages(context.labels.initial),
601
+ [context.labels.initial]
602
+ );
603
+ messages = [...initialMessages, ...messages];
604
+ const messagesEndRef = React__namespace.default.useRef(null);
605
+ const scrollToBottom = () => {
606
+ if (messagesEndRef.current) {
607
+ messagesEndRef.current.scrollIntoView({
608
+ behavior: "auto"
609
+ });
610
+ }
611
+ };
612
+ React.useEffect(() => {
613
+ scrollToBottom();
614
+ }, [messages]);
615
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "copilotKitMessages", children: [
616
+ messages.map((message, index) => {
617
+ const isCurrentMessage = index === messages.length - 1;
618
+ if (message.role === "user") {
619
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "copilotKitMessage copilotKitUserMessage", children: message.content }, index);
620
+ } else if (message.role == "assistant") {
621
+ if (isCurrentMessage && inProgress && !message.content) {
622
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: `copilotKitMessage copilotKitAssistantMessage`, children: context.icons.spinnerIcon }, index);
623
+ } else if ((!inProgress || index != messages.length - 1) && !message.content && message.function_call) {
624
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: `copilotKitMessage copilotKitAssistantMessage`, children: context.labels.done }, index);
625
+ } else {
626
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: `copilotKitMessage copilotKitAssistantMessage`, children: /* @__PURE__ */ jsxRuntime.jsx(Markdown, { content: message.content }) }, index);
627
+ }
628
+ }
629
+ }),
630
+ /* @__PURE__ */ jsxRuntime.jsx("div", { ref: messagesEndRef })
631
+ ] });
632
+ };
633
+ function makeInitialMessages(initial) {
634
+ let initialArray = [];
635
+ if (initial) {
636
+ if (Array.isArray(initial)) {
637
+ initialArray.push(...initial);
638
+ } else {
639
+ initialArray.push(initial);
640
+ }
641
+ }
642
+ return initialArray.map((message) => ({
643
+ id: nanoid.nanoid(),
644
+ role: "assistant",
645
+ content: message
646
+ }));
647
+ }
648
+ var AutoResizingTextarea = React.forwardRef(
649
+ ({ maxRows = 1, placeholder, value, onChange, onKeyDown, autoFocus }, ref) => {
650
+ const internalTextareaRef = React.useRef(null);
651
+ const [maxHeight, setMaxHeight] = React.useState(0);
652
+ React.useImperativeHandle(ref, () => internalTextareaRef.current);
653
+ React.useEffect(() => {
654
+ const calculateMaxHeight = () => {
655
+ const textarea = internalTextareaRef.current;
656
+ if (textarea) {
657
+ textarea.style.height = "auto";
658
+ const singleRowHeight = textarea.scrollHeight;
659
+ setMaxHeight(singleRowHeight * maxRows);
660
+ if (autoFocus) {
661
+ textarea.focus();
662
+ }
663
+ }
664
+ };
665
+ calculateMaxHeight();
666
+ }, [maxRows]);
667
+ React.useEffect(() => {
668
+ const textarea = internalTextareaRef.current;
669
+ if (textarea) {
670
+ textarea.style.height = "auto";
671
+ textarea.style.height = `${Math.min(textarea.scrollHeight, maxHeight)}px`;
672
+ }
673
+ }, [value, maxHeight]);
674
+ return /* @__PURE__ */ jsxRuntime.jsx(
675
+ "textarea",
676
+ {
677
+ ref: internalTextareaRef,
678
+ value,
679
+ onChange,
680
+ onKeyDown,
681
+ placeholder,
682
+ style: {
683
+ overflow: "hidden",
684
+ resize: "none",
685
+ maxHeight: `${maxHeight}px`
686
+ },
687
+ rows: 1
688
+ }
689
+ );
690
+ }
691
+ );
692
+ var Textarea_default = AutoResizingTextarea;
693
+ var Input = ({ inProgress, onSend, children }) => {
694
+ const context = useChatContext();
695
+ const textareaRef = React.useRef(null);
696
+ const handleDivClick = (event) => {
697
+ var _a;
698
+ if (event.target !== event.currentTarget)
699
+ return;
700
+ (_a = textareaRef.current) == null ? void 0 : _a.focus();
701
+ };
702
+ const [text, setText] = React.useState("");
703
+ const send = () => {
704
+ var _a;
705
+ if (inProgress)
706
+ return;
707
+ onSend(text);
708
+ setText("");
709
+ (_a = textareaRef.current) == null ? void 0 : _a.focus();
710
+ };
711
+ const icon = inProgress ? context.icons.activityIcon : context.icons.sendIcon;
712
+ const disabled = inProgress || text.length === 0;
713
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "copilotKitInput", onClick: handleDivClick, children: [
714
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children }),
715
+ /* @__PURE__ */ jsxRuntime.jsx("button", { className: "copilotKitSendButton", disabled, onClick: send, children: icon }),
716
+ /* @__PURE__ */ jsxRuntime.jsx(
717
+ Textarea_default,
718
+ {
719
+ ref: textareaRef,
720
+ placeholder: context.labels.placeholder,
721
+ autoFocus: true,
722
+ maxRows: 5,
723
+ value: text,
724
+ onChange: (event) => setText(event.target.value),
725
+ onKeyDown: (event) => {
726
+ if (event.key === "Enter" && !event.shiftKey) {
727
+ event.preventDefault();
728
+ send();
729
+ }
730
+ }
731
+ }
732
+ )
733
+ ] });
734
+ };
735
+ var ResponseButton = ({ onClick, inProgress }) => {
736
+ const context = useChatContext();
737
+ return /* @__PURE__ */ jsxRuntime.jsxs("button", { onClick, className: "copilotKitResponseButton", children: [
738
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: inProgress ? context.icons.stopIcon : context.icons.regenerateIcon }),
739
+ inProgress ? context.labels.stopGenerating : context.labels.regenerateResponse
740
+ ] });
741
+ };
742
+ var CopilotChat = ({
743
+ instructions,
744
+ defaultOpen = false,
745
+ clickOutsideToClose = true,
746
+ hitEscapeToClose = true,
747
+ onSetOpen,
748
+ hotkey = "e",
749
+ icons,
750
+ labels,
751
+ makeSystemMessage,
752
+ showResponseButton = true,
753
+ Window: Window2 = Window,
754
+ Button: Button2 = Button,
755
+ Header: Header2 = Header,
756
+ Messages: Messages2 = Messages,
757
+ Input: Input2 = Input,
758
+ ResponseButton: ResponseButton2 = ResponseButton,
759
+ className
760
+ }) => {
761
+ const { visibleMessages, append, reload, stop, isLoading, input, setInput } = reactCore.useCopilotChat({
762
+ id: nanoid.nanoid(),
763
+ makeSystemMessage,
764
+ additionalInstructions: instructions
765
+ });
766
+ const [openState, setOpenState] = React__namespace.default.useState(defaultOpen);
767
+ const setOpen = (open) => {
768
+ onSetOpen == null ? void 0 : onSetOpen(open);
769
+ setOpenState(open);
770
+ };
771
+ const sendMessage = (message) => __async(void 0, null, function* () {
772
+ append({
773
+ id: nanoid.nanoid(),
774
+ content: message,
775
+ role: "user"
776
+ });
777
+ });
778
+ return /* @__PURE__ */ jsxRuntime.jsx(ChatContextProvider, { icons, labels, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className, children: [
779
+ /* @__PURE__ */ jsxRuntime.jsx(Button2, { open: openState, setOpen }),
780
+ /* @__PURE__ */ jsxRuntime.jsxs(
781
+ Window2,
782
+ {
783
+ open: openState,
784
+ setOpen,
785
+ clickOutsideToClose,
786
+ hotkey,
787
+ hitEscapeToClose,
788
+ children: [
789
+ /* @__PURE__ */ jsxRuntime.jsx(Header2, { open: openState, setOpen }),
790
+ /* @__PURE__ */ jsxRuntime.jsx(Messages2, { messages: visibleMessages, inProgress: isLoading }),
791
+ /* @__PURE__ */ jsxRuntime.jsx(Input2, { inProgress: isLoading, onSend: sendMessage, children: showResponseButton && visibleMessages.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(ResponseButton2, { onClick: isLoading ? stop : reload, inProgress: isLoading }) })
792
+ ]
793
+ }
794
+ )
795
+ ] }) });
796
+ };
797
+ var CopilotSidebar = (props) => {
798
+ props = __spreadProps(__spreadValues({}, props), {
799
+ className: props.className ? props.className + " copilotKitSidebar" : "copilotKitSidebar"
800
+ });
801
+ const [expandedClassName, setExpandedClassName] = React.useState(
802
+ props.defaultOpen ? "sidebarExpanded" : ""
803
+ );
804
+ const onSetOpen = (open) => {
805
+ var _a;
806
+ (_a = props.onSetOpen) == null ? void 0 : _a.call(props, open);
807
+ setExpandedClassName(open ? "sidebarExpanded" : "");
808
+ };
809
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `copilotKitSidebarContentWrapper ${expandedClassName}`, children: [
810
+ props.children,
811
+ /* @__PURE__ */ jsxRuntime.jsx(CopilotChat, __spreadValues(__spreadValues({}, props), { onSetOpen }))
812
+ ] });
813
+ };
814
+
815
+ exports.CopilotSidebar = CopilotSidebar;
816
+ //# sourceMappingURL=out.js.map
817
+ //# sourceMappingURL=Sidebar.js.map