@copilotkit/react-ui 0.0.0-0.0.0-max-changeset-10101010101010-20260109191632

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 (395) hide show
  1. package/CHANGELOG.md +17415 -0
  2. package/LICENSE +21 -0
  3. package/README.md +141 -0
  4. package/dist/chunk-3W6J75HS.mjs +126 -0
  5. package/dist/chunk-3W6J75HS.mjs.map +1 -0
  6. package/dist/chunk-54JAUBUJ.mjs +26 -0
  7. package/dist/chunk-54JAUBUJ.mjs.map +1 -0
  8. package/dist/chunk-7OURDQZJ.mjs +133 -0
  9. package/dist/chunk-7OURDQZJ.mjs.map +1 -0
  10. package/dist/chunk-7PR2KJDO.mjs +222 -0
  11. package/dist/chunk-7PR2KJDO.mjs.map +1 -0
  12. package/dist/chunk-BH6PCAAL.mjs +81 -0
  13. package/dist/chunk-BH6PCAAL.mjs.map +1 -0
  14. package/dist/chunk-C3GSYRC3.mjs +118 -0
  15. package/dist/chunk-C3GSYRC3.mjs.map +1 -0
  16. package/dist/chunk-DBKRAOH7.mjs +34 -0
  17. package/dist/chunk-DBKRAOH7.mjs.map +1 -0
  18. package/dist/chunk-EFZPSZWO.mjs +1 -0
  19. package/dist/chunk-EFZPSZWO.mjs.map +1 -0
  20. package/dist/chunk-ELGRNEAO.mjs +32 -0
  21. package/dist/chunk-ELGRNEAO.mjs.map +1 -0
  22. package/dist/chunk-ELUJRANC.mjs +21 -0
  23. package/dist/chunk-ELUJRANC.mjs.map +1 -0
  24. package/dist/chunk-FFJHOZX6.mjs +202 -0
  25. package/dist/chunk-FFJHOZX6.mjs.map +1 -0
  26. package/dist/chunk-GDSZGYCE.mjs +32 -0
  27. package/dist/chunk-GDSZGYCE.mjs.map +1 -0
  28. package/dist/chunk-HIW7RXCD.mjs +184 -0
  29. package/dist/chunk-HIW7RXCD.mjs.map +1 -0
  30. package/dist/chunk-IEMQ2SQW.mjs +93 -0
  31. package/dist/chunk-IEMQ2SQW.mjs.map +1 -0
  32. package/dist/chunk-IHFR6PYG.mjs +116 -0
  33. package/dist/chunk-IHFR6PYG.mjs.map +1 -0
  34. package/dist/chunk-IK2BPURM.mjs +400 -0
  35. package/dist/chunk-IK2BPURM.mjs.map +1 -0
  36. package/dist/chunk-IU3WTXLQ.mjs +1 -0
  37. package/dist/chunk-IU3WTXLQ.mjs.map +1 -0
  38. package/dist/chunk-JGMFJZMG.mjs +11 -0
  39. package/dist/chunk-JGMFJZMG.mjs.map +1 -0
  40. package/dist/chunk-JY2CSDKN.mjs +135 -0
  41. package/dist/chunk-JY2CSDKN.mjs.map +1 -0
  42. package/dist/chunk-JZ3RFQQ6.mjs +128 -0
  43. package/dist/chunk-JZ3RFQQ6.mjs.map +1 -0
  44. package/dist/chunk-KXE2JCUH.mjs +1 -0
  45. package/dist/chunk-KXE2JCUH.mjs.map +1 -0
  46. package/dist/chunk-LQEFRHRT.mjs +30 -0
  47. package/dist/chunk-LQEFRHRT.mjs.map +1 -0
  48. package/dist/chunk-MMVDU6DF.mjs +1 -0
  49. package/dist/chunk-MMVDU6DF.mjs.map +1 -0
  50. package/dist/chunk-MRXNTQOX.mjs +59 -0
  51. package/dist/chunk-MRXNTQOX.mjs.map +1 -0
  52. package/dist/chunk-NCIAFFQ2.mjs +82 -0
  53. package/dist/chunk-NCIAFFQ2.mjs.map +1 -0
  54. package/dist/chunk-NGJ32FAP.mjs +30 -0
  55. package/dist/chunk-NGJ32FAP.mjs.map +1 -0
  56. package/dist/chunk-NRA3CFEE.mjs +97 -0
  57. package/dist/chunk-NRA3CFEE.mjs.map +1 -0
  58. package/dist/chunk-O72ZB5V3.mjs +140 -0
  59. package/dist/chunk-O72ZB5V3.mjs.map +1 -0
  60. package/dist/chunk-PLHTVHUW.mjs +82 -0
  61. package/dist/chunk-PLHTVHUW.mjs.map +1 -0
  62. package/dist/chunk-Q5V6S67N.mjs +103 -0
  63. package/dist/chunk-Q5V6S67N.mjs.map +1 -0
  64. package/dist/chunk-QB3GUN2N.mjs +31 -0
  65. package/dist/chunk-QB3GUN2N.mjs.map +1 -0
  66. package/dist/chunk-QIOJXTIQ.mjs +64 -0
  67. package/dist/chunk-QIOJXTIQ.mjs.map +1 -0
  68. package/dist/chunk-QPQRLXN3.mjs +435 -0
  69. package/dist/chunk-QPQRLXN3.mjs.map +1 -0
  70. package/dist/chunk-RYUCX3ZK.mjs +32 -0
  71. package/dist/chunk-RYUCX3ZK.mjs.map +1 -0
  72. package/dist/chunk-SC6JRFAJ.mjs +1 -0
  73. package/dist/chunk-SC6JRFAJ.mjs.map +1 -0
  74. package/dist/chunk-T26KLXLH.mjs +1 -0
  75. package/dist/chunk-T26KLXLH.mjs.map +1 -0
  76. package/dist/chunk-UFN2VWSR.mjs +25 -0
  77. package/dist/chunk-UFN2VWSR.mjs.map +1 -0
  78. package/dist/chunk-V7W6IM2V.mjs +1 -0
  79. package/dist/chunk-V7W6IM2V.mjs.map +1 -0
  80. package/dist/chunk-WB3YULQ4.mjs +1 -0
  81. package/dist/chunk-WB3YULQ4.mjs.map +1 -0
  82. package/dist/chunk-XWG3L6QC.mjs +258 -0
  83. package/dist/chunk-XWG3L6QC.mjs.map +1 -0
  84. package/dist/chunk-Y4FKRAKJ.mjs +12 -0
  85. package/dist/chunk-Y4FKRAKJ.mjs.map +1 -0
  86. package/dist/components/chat/Button.d.ts +9 -0
  87. package/dist/components/chat/Button.js +71 -0
  88. package/dist/components/chat/Button.js.map +1 -0
  89. package/dist/components/chat/Button.mjs +10 -0
  90. package/dist/components/chat/Button.mjs.map +1 -0
  91. package/dist/components/chat/Chat.d.ts +204 -0
  92. package/dist/components/chat/Chat.js +2270 -0
  93. package/dist/components/chat/Chat.js.map +1 -0
  94. package/dist/components/chat/Chat.mjs +29 -0
  95. package/dist/components/chat/Chat.mjs.map +1 -0
  96. package/dist/components/chat/ChatContext.d.ts +145 -0
  97. package/dist/components/chat/ChatContext.js +329 -0
  98. package/dist/components/chat/ChatContext.js.map +1 -0
  99. package/dist/components/chat/ChatContext.mjs +13 -0
  100. package/dist/components/chat/ChatContext.mjs.map +1 -0
  101. package/dist/components/chat/CodeBlock.d.ts +14 -0
  102. package/dist/components/chat/CodeBlock.js +510 -0
  103. package/dist/components/chat/CodeBlock.js.map +1 -0
  104. package/dist/components/chat/CodeBlock.mjs +14 -0
  105. package/dist/components/chat/CodeBlock.mjs.map +1 -0
  106. package/dist/components/chat/Header.d.ts +9 -0
  107. package/dist/components/chat/Header.js +582 -0
  108. package/dist/components/chat/Header.js.map +1 -0
  109. package/dist/components/chat/Header.mjs +17 -0
  110. package/dist/components/chat/Header.mjs.map +1 -0
  111. package/dist/components/chat/Icons.d.ts +20 -0
  112. package/dist/components/chat/Icons.js +297 -0
  113. package/dist/components/chat/Icons.js.map +1 -0
  114. package/dist/components/chat/Icons.mjs +38 -0
  115. package/dist/components/chat/Icons.mjs.map +1 -0
  116. package/dist/components/chat/ImageUploadQueue.d.ts +13 -0
  117. package/dist/components/chat/ImageUploadQueue.js +106 -0
  118. package/dist/components/chat/ImageUploadQueue.js.map +1 -0
  119. package/dist/components/chat/ImageUploadQueue.mjs +8 -0
  120. package/dist/components/chat/ImageUploadQueue.mjs.map +1 -0
  121. package/dist/components/chat/Input.d.ts +9 -0
  122. package/dist/components/chat/Input.js +396 -0
  123. package/dist/components/chat/Input.js.map +1 -0
  124. package/dist/components/chat/Input.mjs +14 -0
  125. package/dist/components/chat/Input.mjs.map +1 -0
  126. package/dist/components/chat/Markdown.d.ts +10 -0
  127. package/dist/components/chat/Markdown.js +652 -0
  128. package/dist/components/chat/Markdown.js.map +1 -0
  129. package/dist/components/chat/Markdown.mjs +11 -0
  130. package/dist/components/chat/Markdown.mjs.map +1 -0
  131. package/dist/components/chat/Messages.d.ts +13 -0
  132. package/dist/components/chat/Messages.js +1195 -0
  133. package/dist/components/chat/Messages.js.map +1 -0
  134. package/dist/components/chat/Messages.mjs +20 -0
  135. package/dist/components/chat/Messages.mjs.map +1 -0
  136. package/dist/components/chat/Modal.d.ts +51 -0
  137. package/dist/components/chat/Modal.js +3075 -0
  138. package/dist/components/chat/Modal.js.map +1 -0
  139. package/dist/components/chat/Modal.mjs +38 -0
  140. package/dist/components/chat/Modal.mjs.map +1 -0
  141. package/dist/components/chat/Popup.d.ts +13 -0
  142. package/dist/components/chat/Popup.js +3086 -0
  143. package/dist/components/chat/Popup.js.map +1 -0
  144. package/dist/components/chat/Popup.mjs +39 -0
  145. package/dist/components/chat/Popup.mjs.map +1 -0
  146. package/dist/components/chat/PoweredByTag.d.ts +7 -0
  147. package/dist/components/chat/PoweredByTag.js +61 -0
  148. package/dist/components/chat/PoweredByTag.js.map +1 -0
  149. package/dist/components/chat/PoweredByTag.mjs +9 -0
  150. package/dist/components/chat/PoweredByTag.mjs.map +1 -0
  151. package/dist/components/chat/Sidebar.d.ts +13 -0
  152. package/dist/components/chat/Sidebar.js +3095 -0
  153. package/dist/components/chat/Sidebar.js.map +1 -0
  154. package/dist/components/chat/Sidebar.mjs +39 -0
  155. package/dist/components/chat/Sidebar.mjs.map +1 -0
  156. package/dist/components/chat/Suggestion.d.ts +12 -0
  157. package/dist/components/chat/Suggestion.js +56 -0
  158. package/dist/components/chat/Suggestion.js.map +1 -0
  159. package/dist/components/chat/Suggestion.mjs +9 -0
  160. package/dist/components/chat/Suggestion.mjs.map +1 -0
  161. package/dist/components/chat/Suggestions.d.ts +9 -0
  162. package/dist/components/chat/Suggestions.js +81 -0
  163. package/dist/components/chat/Suggestions.js.map +1 -0
  164. package/dist/components/chat/Suggestions.mjs +10 -0
  165. package/dist/components/chat/Suggestions.mjs.map +1 -0
  166. package/dist/components/chat/Textarea.d.ts +15 -0
  167. package/dist/components/chat/Textarea.js +84 -0
  168. package/dist/components/chat/Textarea.js.map +1 -0
  169. package/dist/components/chat/Textarea.mjs +8 -0
  170. package/dist/components/chat/Textarea.mjs.map +1 -0
  171. package/dist/components/chat/Window.d.ts +9 -0
  172. package/dist/components/chat/Window.js +164 -0
  173. package/dist/components/chat/Window.js.map +1 -0
  174. package/dist/components/chat/Window.mjs +10 -0
  175. package/dist/components/chat/Window.mjs.map +1 -0
  176. package/dist/components/chat/index.d.ts +18 -0
  177. package/dist/components/chat/index.js +3122 -0
  178. package/dist/components/chat/index.js.map +1 -0
  179. package/dist/components/chat/index.mjs +69 -0
  180. package/dist/components/chat/index.mjs.map +1 -0
  181. package/dist/components/chat/messages/AssistantMessage.d.ts +9 -0
  182. package/dist/components/chat/messages/AssistantMessage.js +775 -0
  183. package/dist/components/chat/messages/AssistantMessage.js.map +1 -0
  184. package/dist/components/chat/messages/AssistantMessage.mjs +13 -0
  185. package/dist/components/chat/messages/AssistantMessage.mjs.map +1 -0
  186. package/dist/components/chat/messages/ErrorMessage.d.ts +9 -0
  187. package/dist/components/chat/messages/ErrorMessage.js +722 -0
  188. package/dist/components/chat/messages/ErrorMessage.js.map +1 -0
  189. package/dist/components/chat/messages/ErrorMessage.mjs +66 -0
  190. package/dist/components/chat/messages/ErrorMessage.mjs.map +1 -0
  191. package/dist/components/chat/messages/ImageRenderer.d.ts +12 -0
  192. package/dist/components/chat/messages/ImageRenderer.js +58 -0
  193. package/dist/components/chat/messages/ImageRenderer.js.map +1 -0
  194. package/dist/components/chat/messages/ImageRenderer.mjs +8 -0
  195. package/dist/components/chat/messages/ImageRenderer.mjs.map +1 -0
  196. package/dist/components/chat/messages/LegacyRenderMessage.d.ts +28 -0
  197. package/dist/components/chat/messages/LegacyRenderMessage.js +1023 -0
  198. package/dist/components/chat/messages/LegacyRenderMessage.js.map +1 -0
  199. package/dist/components/chat/messages/LegacyRenderMessage.mjs +17 -0
  200. package/dist/components/chat/messages/LegacyRenderMessage.mjs.map +1 -0
  201. package/dist/components/chat/messages/RenderMessage.d.ts +9 -0
  202. package/dist/components/chat/messages/RenderMessage.js +898 -0
  203. package/dist/components/chat/messages/RenderMessage.js.map +1 -0
  204. package/dist/components/chat/messages/RenderMessage.mjs +16 -0
  205. package/dist/components/chat/messages/RenderMessage.mjs.map +1 -0
  206. package/dist/components/chat/messages/UserMessage.d.ts +9 -0
  207. package/dist/components/chat/messages/UserMessage.js +56 -0
  208. package/dist/components/chat/messages/UserMessage.js.map +1 -0
  209. package/dist/components/chat/messages/UserMessage.mjs +8 -0
  210. package/dist/components/chat/messages/UserMessage.mjs.map +1 -0
  211. package/dist/components/chat/props.d.ts +298 -0
  212. package/dist/components/chat/props.js +19 -0
  213. package/dist/components/chat/props.js.map +1 -0
  214. package/dist/components/chat/props.mjs +2 -0
  215. package/dist/components/chat/props.mjs.map +1 -0
  216. package/dist/components/dev-console/console.d.ts +11 -0
  217. package/dist/components/dev-console/console.js +537 -0
  218. package/dist/components/dev-console/console.js.map +1 -0
  219. package/dist/components/dev-console/console.mjs +17 -0
  220. package/dist/components/dev-console/console.mjs.map +1 -0
  221. package/dist/components/dev-console/icons.d.ts +9 -0
  222. package/dist/components/dev-console/icons.js +131 -0
  223. package/dist/components/dev-console/icons.js.map +1 -0
  224. package/dist/components/dev-console/icons.mjs +16 -0
  225. package/dist/components/dev-console/icons.mjs.map +1 -0
  226. package/dist/components/dev-console/index.d.ts +3 -0
  227. package/dist/components/dev-console/index.js +537 -0
  228. package/dist/components/dev-console/index.js.map +1 -0
  229. package/dist/components/dev-console/index.mjs +18 -0
  230. package/dist/components/dev-console/index.mjs.map +1 -0
  231. package/dist/components/dev-console/types.d.ts +9 -0
  232. package/dist/components/dev-console/types.js +19 -0
  233. package/dist/components/dev-console/types.js.map +1 -0
  234. package/dist/components/dev-console/types.mjs +1 -0
  235. package/dist/components/dev-console/types.mjs.map +1 -0
  236. package/dist/components/dev-console/utils.d.ts +10 -0
  237. package/dist/components/dev-console/utils.js +177 -0
  238. package/dist/components/dev-console/utils.js.map +1 -0
  239. package/dist/components/dev-console/utils.mjs +16 -0
  240. package/dist/components/dev-console/utils.mjs.map +1 -0
  241. package/dist/components/help-modal/icons.d.ts +9 -0
  242. package/dist/components/help-modal/icons.js +107 -0
  243. package/dist/components/help-modal/icons.js.map +1 -0
  244. package/dist/components/help-modal/icons.mjs +12 -0
  245. package/dist/components/help-modal/icons.mjs.map +1 -0
  246. package/dist/components/help-modal/index.d.ts +2 -0
  247. package/dist/components/help-modal/index.js +137 -0
  248. package/dist/components/help-modal/index.js.map +1 -0
  249. package/dist/components/help-modal/index.mjs +10 -0
  250. package/dist/components/help-modal/index.mjs.map +1 -0
  251. package/dist/components/help-modal/modal.d.ts +5 -0
  252. package/dist/components/help-modal/modal.js +135 -0
  253. package/dist/components/help-modal/modal.js.map +1 -0
  254. package/dist/components/help-modal/modal.mjs +9 -0
  255. package/dist/components/help-modal/modal.mjs.map +1 -0
  256. package/dist/components/index.d.ts +19 -0
  257. package/dist/components/index.js +3126 -0
  258. package/dist/components/index.js.map +1 -0
  259. package/dist/components/index.mjs +76 -0
  260. package/dist/components/index.mjs.map +1 -0
  261. package/dist/context/index.d.ts +2 -0
  262. package/dist/context/index.js +19 -0
  263. package/dist/context/index.js.map +1 -0
  264. package/dist/context/index.mjs +2 -0
  265. package/dist/context/index.mjs.map +1 -0
  266. package/dist/hooks/index.d.ts +2 -0
  267. package/dist/hooks/index.js +36 -0
  268. package/dist/hooks/index.js.map +1 -0
  269. package/dist/hooks/index.mjs +9 -0
  270. package/dist/hooks/index.mjs.map +1 -0
  271. package/dist/hooks/use-copilot-chat-suggestions.d.ts +66 -0
  272. package/dist/hooks/use-copilot-chat-suggestions.js +34 -0
  273. package/dist/hooks/use-copilot-chat-suggestions.js.map +1 -0
  274. package/dist/hooks/use-copilot-chat-suggestions.mjs +8 -0
  275. package/dist/hooks/use-copilot-chat-suggestions.mjs.map +1 -0
  276. package/dist/hooks/use-copy-to-clipboard.d.ts +9 -0
  277. package/dist/hooks/use-copy-to-clipboard.js +60 -0
  278. package/dist/hooks/use-copy-to-clipboard.js.map +1 -0
  279. package/dist/hooks/use-copy-to-clipboard.mjs +8 -0
  280. package/dist/hooks/use-copy-to-clipboard.mjs.map +1 -0
  281. package/dist/hooks/use-dark-mode.d.ts +3 -0
  282. package/dist/hooks/use-dark-mode.js +35 -0
  283. package/dist/hooks/use-dark-mode.js.map +1 -0
  284. package/dist/hooks/use-dark-mode.mjs +8 -0
  285. package/dist/hooks/use-dark-mode.mjs.map +1 -0
  286. package/dist/hooks/use-push-to-talk.d.ts +19 -0
  287. package/dist/hooks/use-push-to-talk.js +195 -0
  288. package/dist/hooks/use-push-to-talk.js.map +1 -0
  289. package/dist/hooks/use-push-to-talk.mjs +12 -0
  290. package/dist/hooks/use-push-to-talk.mjs.map +1 -0
  291. package/dist/index.css +1258 -0
  292. package/dist/index.css.map +1 -0
  293. package/dist/index.d.ts +21 -0
  294. package/dist/index.js +3135 -0
  295. package/dist/index.js.map +1 -0
  296. package/dist/index.mjs +84 -0
  297. package/dist/index.mjs.map +1 -0
  298. package/dist/lib/utils.d.ts +4 -0
  299. package/dist/lib/utils.js +76 -0
  300. package/dist/lib/utils.js.map +1 -0
  301. package/dist/lib/utils.mjs +34 -0
  302. package/dist/lib/utils.mjs.map +1 -0
  303. package/dist/types/css.d.ts +22 -0
  304. package/dist/types/css.js +19 -0
  305. package/dist/types/css.js.map +1 -0
  306. package/dist/types/css.mjs +1 -0
  307. package/dist/types/css.mjs.map +1 -0
  308. package/dist/types/index.d.ts +3 -0
  309. package/dist/types/index.js +19 -0
  310. package/dist/types/index.js.map +1 -0
  311. package/dist/types/index.mjs +2 -0
  312. package/dist/types/index.mjs.map +1 -0
  313. package/dist/types/suggestions.d.ts +9 -0
  314. package/dist/types/suggestions.js +19 -0
  315. package/dist/types/suggestions.js.map +1 -0
  316. package/dist/types/suggestions.mjs +1 -0
  317. package/dist/types/suggestions.mjs.map +1 -0
  318. package/dist/v2/index.css +4 -0
  319. package/dist/v2/index.css.map +1 -0
  320. package/dist/v2/index.d.ts +2 -0
  321. package/dist/v2/index.js +2 -0
  322. package/dist/v2/index.js.map +1 -0
  323. package/dist/v2/index.mjs +2 -0
  324. package/dist/v2/index.mjs.map +1 -0
  325. package/jest.config.js +5 -0
  326. package/package.json +83 -0
  327. package/postcss.config.js +60 -0
  328. package/src/components/chat/Button.tsx +18 -0
  329. package/src/components/chat/Chat.tsx +795 -0
  330. package/src/components/chat/ChatContext.tsx +248 -0
  331. package/src/components/chat/CodeBlock.tsx +418 -0
  332. package/src/components/chat/Header.tsx +24 -0
  333. package/src/components/chat/Icons.tsx +237 -0
  334. package/src/components/chat/ImageUploadQueue.tsx +77 -0
  335. package/src/components/chat/Input.tsx +156 -0
  336. package/src/components/chat/Markdown.tsx +144 -0
  337. package/src/components/chat/Messages.tsx +206 -0
  338. package/src/components/chat/Modal.tsx +220 -0
  339. package/src/components/chat/Popup.tsx +77 -0
  340. package/src/components/chat/PoweredByTag.tsx +42 -0
  341. package/src/components/chat/Sidebar.tsx +96 -0
  342. package/src/components/chat/Suggestion.tsx +29 -0
  343. package/src/components/chat/Suggestions.tsx +23 -0
  344. package/src/components/chat/Textarea.tsx +77 -0
  345. package/src/components/chat/Window.tsx +152 -0
  346. package/src/components/chat/index.tsx +11 -0
  347. package/src/components/chat/messages/AssistantMessage.tsx +118 -0
  348. package/src/components/chat/messages/ErrorMessage.tsx +59 -0
  349. package/src/components/chat/messages/ImageRenderer.tsx +37 -0
  350. package/src/components/chat/messages/LegacyRenderMessage.tsx +150 -0
  351. package/src/components/chat/messages/RenderMessage.tsx +61 -0
  352. package/src/components/chat/messages/UserMessage.tsx +46 -0
  353. package/src/components/chat/props.ts +353 -0
  354. package/src/components/dev-console/console.tsx +242 -0
  355. package/src/components/dev-console/icons.tsx +99 -0
  356. package/src/components/dev-console/index.tsx +2 -0
  357. package/src/components/dev-console/types.ts +7 -0
  358. package/src/components/dev-console/utils.ts +142 -0
  359. package/src/components/help-modal/icons.tsx +68 -0
  360. package/src/components/help-modal/index.tsx +1 -0
  361. package/src/components/help-modal/modal.tsx +101 -0
  362. package/src/components/index.ts +2 -0
  363. package/src/context/index.ts +1 -0
  364. package/src/css/animations.css +35 -0
  365. package/src/css/button.css +67 -0
  366. package/src/css/colors.css +78 -0
  367. package/src/css/console.css +166 -0
  368. package/src/css/crew.css +277 -0
  369. package/src/css/header.css +65 -0
  370. package/src/css/input.css +152 -0
  371. package/src/css/markdown.css +150 -0
  372. package/src/css/messages.css +244 -0
  373. package/src/css/panel.css +39 -0
  374. package/src/css/popup.css +22 -0
  375. package/src/css/sidebar.css +34 -0
  376. package/src/css/suggestions.css +43 -0
  377. package/src/css/window.css +60 -0
  378. package/src/hooks/index.ts +1 -0
  379. package/src/hooks/use-copilot-chat-suggestions.tsx +71 -0
  380. package/src/hooks/use-copy-to-clipboard.tsx +29 -0
  381. package/src/hooks/use-dark-mode.ts +10 -0
  382. package/src/hooks/use-push-to-talk.tsx +167 -0
  383. package/src/index.tsx +7 -0
  384. package/src/lib/utils.test.ts +7 -0
  385. package/src/lib/utils.ts +27 -0
  386. package/src/styles.css +14 -0
  387. package/src/types/css.ts +21 -0
  388. package/src/types/index.ts +2 -0
  389. package/src/types/suggestions.ts +7 -0
  390. package/src/v2/index.ts +1 -0
  391. package/src/v2/styles.css +1 -0
  392. package/tailwind.config.js +7 -0
  393. package/tsconfig.json +12 -0
  394. package/tsup.config.ts +11 -0
  395. package/typedoc.json +4 -0
@@ -0,0 +1,3095 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __defProps = Object.defineProperties;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
7
+ var __getOwnPropNames = Object.getOwnPropertyNames;
8
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
9
+ var __getProtoOf = Object.getPrototypeOf;
10
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
11
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
12
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
13
+ var __spreadValues = (a, b) => {
14
+ for (var prop in b || (b = {}))
15
+ if (__hasOwnProp.call(b, prop))
16
+ __defNormalProp(a, prop, b[prop]);
17
+ if (__getOwnPropSymbols)
18
+ for (var prop of __getOwnPropSymbols(b)) {
19
+ if (__propIsEnum.call(b, prop))
20
+ __defNormalProp(a, prop, b[prop]);
21
+ }
22
+ return a;
23
+ };
24
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
25
+ var __objRest = (source, exclude) => {
26
+ var target = {};
27
+ for (var prop in source)
28
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
29
+ target[prop] = source[prop];
30
+ if (source != null && __getOwnPropSymbols)
31
+ for (var prop of __getOwnPropSymbols(source)) {
32
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
33
+ target[prop] = source[prop];
34
+ }
35
+ return target;
36
+ };
37
+ var __export = (target, all) => {
38
+ for (var name in all)
39
+ __defProp(target, name, { get: all[name], enumerable: true });
40
+ };
41
+ var __copyProps = (to, from, except, desc) => {
42
+ if (from && typeof from === "object" || typeof from === "function") {
43
+ for (let key of __getOwnPropNames(from))
44
+ if (!__hasOwnProp.call(to, key) && key !== except)
45
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
46
+ }
47
+ return to;
48
+ };
49
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
50
+ // If the importer is in node compatibility mode or this is not an ESM
51
+ // file that has been converted to a CommonJS file using a Babel-
52
+ // compatible transform (i.e. "__esModule" has not been set), then set
53
+ // "default" to the CommonJS "module.exports" for node compatibility.
54
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
55
+ mod
56
+ ));
57
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
58
+ var __async = (__this, __arguments, generator) => {
59
+ return new Promise((resolve, reject) => {
60
+ var fulfilled = (value) => {
61
+ try {
62
+ step(generator.next(value));
63
+ } catch (e) {
64
+ reject(e);
65
+ }
66
+ };
67
+ var rejected = (value) => {
68
+ try {
69
+ step(generator.throw(value));
70
+ } catch (e) {
71
+ reject(e);
72
+ }
73
+ };
74
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
75
+ step((generator = generator.apply(__this, __arguments)).next());
76
+ });
77
+ };
78
+
79
+ // src/components/chat/Sidebar.tsx
80
+ var Sidebar_exports = {};
81
+ __export(Sidebar_exports, {
82
+ CopilotSidebar: () => CopilotSidebar
83
+ });
84
+ module.exports = __toCommonJS(Sidebar_exports);
85
+ var import_react17 = require("react");
86
+
87
+ // src/components/chat/Modal.tsx
88
+ var import_react16 = __toESM(require("react"));
89
+
90
+ // src/components/chat/ChatContext.tsx
91
+ var import_react = __toESM(require("react"));
92
+
93
+ // src/components/chat/Icons.tsx
94
+ var import_jsx_runtime = require("react/jsx-runtime");
95
+ var OpenIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
96
+ "svg",
97
+ {
98
+ xmlns: "http://www.w3.org/2000/svg",
99
+ viewBox: "0 0 24 24",
100
+ fill: "currentColor",
101
+ width: "24",
102
+ height: "24",
103
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("g", { transform: "translate(24, 0) scale(-1, 1)", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
104
+ "path",
105
+ {
106
+ fillRule: "evenodd",
107
+ 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",
108
+ clipRule: "evenodd"
109
+ }
110
+ ) })
111
+ }
112
+ );
113
+ var CloseIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
114
+ "svg",
115
+ {
116
+ xmlns: "http://www.w3.org/2000/svg",
117
+ fill: "none",
118
+ viewBox: "0 0 24 24",
119
+ strokeWidth: "1.5",
120
+ stroke: "currentColor",
121
+ width: "24",
122
+ height: "24",
123
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M19.5 8.25l-7.5 7.5-7.5-7.5" })
124
+ }
125
+ );
126
+ var HeaderCloseIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
127
+ "svg",
128
+ {
129
+ xmlns: "http://www.w3.org/2000/svg",
130
+ fill: "none",
131
+ viewBox: "0 0 24 24",
132
+ strokeWidth: "1.5",
133
+ stroke: "currentColor",
134
+ width: "24",
135
+ height: "24",
136
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M6 18L18 6M6 6l12 12" })
137
+ }
138
+ );
139
+ var SendIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
140
+ "svg",
141
+ {
142
+ xmlns: "http://www.w3.org/2000/svg",
143
+ fill: "none",
144
+ viewBox: "0 0 24 24",
145
+ strokeWidth: "1.5",
146
+ stroke: "currentColor",
147
+ width: "24",
148
+ height: "24",
149
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M12 19V5m0 0l-7 7m7-7l7 7" })
150
+ }
151
+ );
152
+ var MicrophoneIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
153
+ "svg",
154
+ {
155
+ xmlns: "http://www.w3.org/2000/svg",
156
+ fill: "none",
157
+ viewBox: "0 0 24 24",
158
+ strokeWidth: "1.5",
159
+ stroke: "currentColor",
160
+ width: "24",
161
+ height: "24",
162
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
163
+ "path",
164
+ {
165
+ strokeLinecap: "round",
166
+ strokeLinejoin: "round",
167
+ d: "M12 18.75a6 6 0 006-6v-1.5m-6 7.5a6 6 0 01-6-6v-1.5m6 7.5v3.75m-3.75 0h7.5M12 15.75a3 3 0 01-3-3V4.5a3 3 0 116 0v8.25a3 3 0 01-3 3z"
168
+ }
169
+ )
170
+ }
171
+ );
172
+ var StopIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
173
+ "svg",
174
+ {
175
+ xmlns: "http://www.w3.org/2000/svg",
176
+ fill: "none",
177
+ viewBox: "0 0 24 24",
178
+ strokeWidth: "1.5",
179
+ stroke: "currentColor",
180
+ width: "24",
181
+ height: "24",
182
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
183
+ "path",
184
+ {
185
+ strokeLinecap: "round",
186
+ strokeLinejoin: "round",
187
+ d: "M5.25 7.5A2.25 2.25 0 017.5 5.25h9a2.25 2.25 0 012.25 2.25v9a2.25 2.25 0 01-2.25 2.25h-9a2.25 2.25 0 01-2.25-2.25v-9z"
188
+ }
189
+ )
190
+ }
191
+ );
192
+ var RegenerateIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
193
+ "svg",
194
+ {
195
+ xmlns: "http://www.w3.org/2000/svg",
196
+ fill: "none",
197
+ viewBox: "0 0 24 24",
198
+ strokeWidth: "2",
199
+ stroke: "currentColor",
200
+ width: "16",
201
+ height: "16",
202
+ style: { minWidth: "16px", minHeight: "16px" },
203
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
204
+ "path",
205
+ {
206
+ strokeLinecap: "round",
207
+ strokeLinejoin: "round",
208
+ d: "M16.023 9.348h4.992v-.001M2.985 19.644v-4.992m0 0h4.992m-4.993 0l3.181 3.183a8.25 8.25 0 0013.803-3.7M4.031 9.865a8.25 8.25 0 0113.803-3.7l3.181 3.182m0-4.991v4.99"
209
+ }
210
+ )
211
+ }
212
+ );
213
+ var CopyIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
214
+ "svg",
215
+ {
216
+ xmlns: "http://www.w3.org/2000/svg",
217
+ fill: "none",
218
+ viewBox: "0 0 24 24",
219
+ strokeWidth: "2",
220
+ stroke: "currentColor",
221
+ width: "16",
222
+ height: "16",
223
+ style: { minWidth: "16px", minHeight: "16px" },
224
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
225
+ "path",
226
+ {
227
+ strokeLinecap: "round",
228
+ strokeLinejoin: "round",
229
+ d: "M15.75 17.25v3.375c0 .621-.504 1.125-1.125 1.125h-9.75a1.125 1.125 0 01-1.125-1.125V7.875c0-.621.504-1.125 1.125-1.125H6.75a9.06 9.06 0 011.5.124m7.5 10.376h3.375c.621 0 1.125-.504 1.125-1.125V11.25c0-4.46-3.243-8.161-7.5-8.876a9.06 9.06 0 00-1.5-.124H9.375c-.621 0-1.125.504-1.125 1.125v3.5m7.5 10.375H9.375a1.125 1.125 0 01-1.125-1.125v-9.25m12 6.625v-1.875a3.375 3.375 0 00-3.375-3.375h-1.5a1.125 1.125 0 01-1.125-1.125v-1.5a3.375 3.375 0 00-3.375-3.375H9.75"
230
+ }
231
+ )
232
+ }
233
+ );
234
+ var SmallSpinnerIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "copilotKitSpinner", style: { width: "13px", height: "13px" } });
235
+ var SpinnerIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "copilotKitSpinner", style: { width: "24px", height: "24px" } });
236
+ var ActivityIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "4px" }, children: [
237
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "copilotKitActivityDot", style: { animationDelay: "0s" } }),
238
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "copilotKitActivityDot", style: { animationDelay: "0.2s" } }),
239
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "copilotKitActivityDot", style: { animationDelay: "0.4s" } })
240
+ ] });
241
+ var ThumbsUpIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
242
+ "svg",
243
+ {
244
+ xmlns: "http://www.w3.org/2000/svg",
245
+ fill: "none",
246
+ viewBox: "0 0 24 24",
247
+ strokeWidth: "2",
248
+ stroke: "currentColor",
249
+ width: "16",
250
+ height: "16",
251
+ style: { minWidth: "16px", minHeight: "16px" },
252
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
253
+ "path",
254
+ {
255
+ strokeLinecap: "round",
256
+ strokeLinejoin: "round",
257
+ d: "M6.633 10.5c.806 0 1.533-.446 2.031-1.08a9.041 9.041 0 012.861-2.4c.723-.384 1.35-.956 1.653-1.715a4.498 4.498 0 00.322-1.672V3a.75.75 0 01.75-.75A2.25 2.25 0 0116.5 4.5c0 1.152-.26 2.243-.723 3.218-.266.558.107 1.282.725 1.282h3.126c1.026 0 1.945.694 2.054 1.715.045.422.068.85.068 1.285a11.95 11.95 0 01-2.649 7.521c-.388.482-.987.729-1.605.729H13.48c-.483 0-.964-.078-1.423-.23l-3.114-1.04a4.501 4.501 0 00-1.423-.23H5.904M14.25 9h2.25M5.904 18.75c.083.205.173.405.27.602.197.4-.078.898-.523.898h-.908c-.889 0-1.713-.518-1.972-1.368a12 12 0 01-.521-3.507c0-1.553.295-3.036.831-4.398C3.387 10.203 4.167 9.75 5 9.75h1.053c.472 0 .745.556.5.96a8.958 8.958 0 00-1.302 4.665c0 1.194.232 2.333.654 3.375z"
258
+ }
259
+ )
260
+ }
261
+ );
262
+ var ThumbsDownIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
263
+ "svg",
264
+ {
265
+ xmlns: "http://www.w3.org/2000/svg",
266
+ fill: "none",
267
+ viewBox: "0 0 24 24",
268
+ strokeWidth: "2",
269
+ stroke: "currentColor",
270
+ width: "16",
271
+ height: "16",
272
+ style: { minWidth: "16px", minHeight: "16px" },
273
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
274
+ "path",
275
+ {
276
+ strokeLinecap: "round",
277
+ strokeLinejoin: "round",
278
+ d: "M7.5 15h2.25m8.024-9.75c.011.05.028.1.052.148.591 1.2.924 2.55.924 3.977a8.96 8.96 0 01-.999 4.125m.023-8.25c-.076-.365.183-.75.575-.75h.908c.889 0 1.713.518 1.972 1.368.339 1.11.521 2.287.521 3.507 0 1.553-.295 3.036-.831 4.398C20.613 14.547 19.833 15 19 15h-1.053c-.472 0-.745-.556-.5-.96a8.95 8.95 0 00.303-.54m.023-8.25H16.48a4.5 4.5 0 01-1.423-.23l-3.114-1.04a4.5 4.5 0 00-1.423-.23H6.504c-.618 0-1.217.247-1.605.729A11.95 11.95 0 002.25 12c0 .434.023.863.068 1.285C2.427 14.306 3.346 15 4.372 15h3.126c.618 0 .991.724.725 1.282A7.471 7.471 0 007.5 19.5a2.25 2.25 0 002.25 2.25.75.75 0 00.75-.75v-.633c0-.573.11-1.14.322-1.672.304-.76.93-1.33 1.653-1.715a9.04 9.04 0 002.86-2.4c.498-.634 1.226-1.08 2.032-1.08h.384"
279
+ }
280
+ )
281
+ }
282
+ );
283
+ var DownloadIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
284
+ "svg",
285
+ {
286
+ xmlns: "http://www.w3.org/2000/svg",
287
+ fill: "none",
288
+ viewBox: "0 0 24 24",
289
+ strokeWidth: "2",
290
+ stroke: "currentColor",
291
+ width: "16",
292
+ height: "16",
293
+ style: { minWidth: "16px", minHeight: "16px" },
294
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
295
+ "path",
296
+ {
297
+ strokeLinecap: "round",
298
+ strokeLinejoin: "round",
299
+ d: "M3 16.5v2.25A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75V16.5M16.5 12L12 16.5m0 0L7.5 12m4.5 4.5V3"
300
+ }
301
+ )
302
+ }
303
+ );
304
+ var UploadIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
305
+ "svg",
306
+ {
307
+ xmlns: "http://www.w3.org/2000/svg",
308
+ fill: "none",
309
+ viewBox: "0 0 24 24",
310
+ strokeWidth: "1.5",
311
+ stroke: "currentColor",
312
+ width: "24",
313
+ height: "24",
314
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M12 4.5v15m7.5-7.5h-15" })
315
+ }
316
+ );
317
+ var CheckIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
318
+ "svg",
319
+ {
320
+ xmlns: "http://www.w3.org/2000/svg",
321
+ fill: "none",
322
+ viewBox: "0 0 24 24",
323
+ strokeWidth: "2",
324
+ stroke: "currentColor",
325
+ width: "16",
326
+ height: "16",
327
+ style: { minWidth: "16px", minHeight: "16px" },
328
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M4.5 12.75l6 6 9-13.5" })
329
+ }
330
+ );
331
+
332
+ // src/components/chat/ChatContext.tsx
333
+ var import_jsx_runtime2 = require("react/jsx-runtime");
334
+ var ChatContext = import_react.default.createContext(void 0);
335
+ function useChatContext() {
336
+ const context = import_react.default.useContext(ChatContext);
337
+ if (context === void 0) {
338
+ throw new Error(
339
+ "Context not found. Did you forget to wrap your app in a <ChatContextProvider> component?"
340
+ );
341
+ }
342
+ return context;
343
+ }
344
+ var ChatContextProvider = ({
345
+ // temperature,
346
+ // instructions,
347
+ // maxFeedback,
348
+ labels,
349
+ icons,
350
+ children,
351
+ open,
352
+ setOpen
353
+ }) => {
354
+ const memoizedLabels = (0, import_react.useMemo)(
355
+ () => __spreadValues(__spreadValues({}, {
356
+ initial: "",
357
+ title: "CopilotKit",
358
+ placeholder: "Type a message...",
359
+ error: "\u274C An error occurred. Please try again.",
360
+ stopGenerating: "Stop generating",
361
+ regenerateResponse: "Regenerate response",
362
+ copyToClipboard: "Copy to clipboard",
363
+ thumbsUp: "Thumbs up",
364
+ thumbsDown: "Thumbs down",
365
+ copied: "Copied!"
366
+ }), labels),
367
+ [labels]
368
+ );
369
+ const memoizedIcons = (0, import_react.useMemo)(
370
+ () => __spreadValues(__spreadValues({}, {
371
+ openIcon: OpenIcon,
372
+ closeIcon: CloseIcon,
373
+ headerCloseIcon: HeaderCloseIcon,
374
+ sendIcon: SendIcon,
375
+ activityIcon: ActivityIcon,
376
+ spinnerIcon: SpinnerIcon,
377
+ stopIcon: StopIcon,
378
+ regenerateIcon: RegenerateIcon,
379
+ pushToTalkIcon: MicrophoneIcon,
380
+ copyIcon: CopyIcon,
381
+ thumbsUpIcon: ThumbsUpIcon,
382
+ thumbsDownIcon: ThumbsDownIcon,
383
+ uploadIcon: UploadIcon
384
+ }), icons),
385
+ [icons]
386
+ );
387
+ const context = (0, import_react.useMemo)(
388
+ () => ({
389
+ labels: memoizedLabels,
390
+ icons: memoizedIcons,
391
+ open,
392
+ setOpen
393
+ }),
394
+ [memoizedLabels, memoizedIcons, open, setOpen]
395
+ );
396
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ChatContext.Provider, { value: context, children });
397
+ };
398
+
399
+ // src/components/chat/Window.tsx
400
+ var import_react2 = __toESM(require("react"));
401
+ var import_react_core = require("@copilotkit/react-core");
402
+ var import_shared = require("@copilotkit/shared");
403
+ var import_jsx_runtime3 = require("react/jsx-runtime");
404
+ var Window = ({
405
+ children,
406
+ clickOutsideToClose,
407
+ shortcut,
408
+ hitEscapeToClose
409
+ }) => {
410
+ const windowRef = import_react2.default.useRef(null);
411
+ const context = (0, import_react_core.useCopilotContext)();
412
+ const { open, setOpen } = useChatContext();
413
+ const handleClickOutside = (0, import_react2.useCallback)(
414
+ (event) => {
415
+ var _a;
416
+ if (!clickOutsideToClose) {
417
+ return;
418
+ }
419
+ const parentElement = (_a = windowRef.current) == null ? void 0 : _a.parentElement;
420
+ let className = "";
421
+ if (event.target instanceof HTMLElement) {
422
+ className = event.target.className;
423
+ }
424
+ if (open && parentElement && !parentElement.contains(event.target) && // prevent closing the window when clicking on the debug menu
425
+ !className.includes("copilotKitDebugMenu")) {
426
+ setOpen(false);
427
+ }
428
+ },
429
+ [clickOutsideToClose, open, setOpen]
430
+ );
431
+ const handleKeyDown = (0, import_react2.useCallback)(
432
+ (event) => {
433
+ var _a;
434
+ const target = event.target;
435
+ const isInput = target.tagName === "INPUT" || target.tagName === "SELECT" || target.tagName === "TEXTAREA" || target.isContentEditable;
436
+ const isDescendantOfWrapper = (_a = windowRef.current) == null ? void 0 : _a.contains(target);
437
+ if (open && event.key === "Escape" && (!isInput || isDescendantOfWrapper) && hitEscapeToClose) {
438
+ setOpen(false);
439
+ } else if (event.key === shortcut && ((0, import_shared.isMacOS)() && event.metaKey || !(0, import_shared.isMacOS)() && event.ctrlKey) && (!isInput || isDescendantOfWrapper)) {
440
+ setOpen(!open);
441
+ }
442
+ },
443
+ [hitEscapeToClose, shortcut, open, setOpen]
444
+ );
445
+ const adjustForMobile = (0, import_react2.useCallback)(() => {
446
+ const copilotKitWindow = windowRef.current;
447
+ const vv = window.visualViewport;
448
+ if (!copilotKitWindow || !vv) {
449
+ return;
450
+ }
451
+ if (window.innerWidth < 640 && open) {
452
+ copilotKitWindow.style.height = `${vv.height}px`;
453
+ copilotKitWindow.style.left = `${vv.offsetLeft}px`;
454
+ copilotKitWindow.style.top = `${vv.offsetTop}px`;
455
+ document.body.style.position = "fixed";
456
+ document.body.style.width = "100%";
457
+ document.body.style.height = `${window.innerHeight}px`;
458
+ document.body.style.overflow = "hidden";
459
+ document.body.style.touchAction = "none";
460
+ document.body.addEventListener("touchmove", preventScroll, {
461
+ passive: false
462
+ });
463
+ } else {
464
+ copilotKitWindow.style.height = "";
465
+ copilotKitWindow.style.left = "";
466
+ copilotKitWindow.style.top = "";
467
+ document.body.style.position = "";
468
+ document.body.style.height = "";
469
+ document.body.style.width = "";
470
+ document.body.style.overflow = "";
471
+ document.body.style.top = "";
472
+ document.body.style.touchAction = "";
473
+ document.body.removeEventListener("touchmove", preventScroll);
474
+ }
475
+ }, [open]);
476
+ (0, import_react2.useEffect)(() => {
477
+ document.addEventListener("mousedown", handleClickOutside);
478
+ document.addEventListener("keydown", handleKeyDown);
479
+ if (window.visualViewport) {
480
+ window.visualViewport.addEventListener("resize", adjustForMobile);
481
+ adjustForMobile();
482
+ }
483
+ return () => {
484
+ document.removeEventListener("mousedown", handleClickOutside);
485
+ document.removeEventListener("keydown", handleKeyDown);
486
+ if (window.visualViewport) {
487
+ window.visualViewport.removeEventListener("resize", adjustForMobile);
488
+ }
489
+ };
490
+ }, [adjustForMobile, handleClickOutside, handleKeyDown]);
491
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: `copilotKitWindow ${open ? " open" : ""}`, ref: windowRef, children });
492
+ };
493
+ var preventScroll = (event) => {
494
+ let targetElement = event.target;
495
+ const hasParentWithClass = (element, className) => {
496
+ while (element && element !== document.body) {
497
+ if (element.classList.contains(className)) {
498
+ return true;
499
+ }
500
+ element = element.parentElement;
501
+ }
502
+ return false;
503
+ };
504
+ if (!hasParentWithClass(targetElement, "copilotKitMessages")) {
505
+ event.preventDefault();
506
+ }
507
+ };
508
+
509
+ // src/components/chat/Button.tsx
510
+ var import_jsx_runtime4 = require("react/jsx-runtime");
511
+ var Button = ({}) => {
512
+ const { open, setOpen, icons } = useChatContext();
513
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { onClick: () => setOpen(!open), children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
514
+ "button",
515
+ {
516
+ className: `copilotKitButton ${open ? "open" : ""}`,
517
+ "aria-label": open ? "Close Chat" : "Open Chat",
518
+ children: [
519
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "copilotKitButtonIcon copilotKitButtonIconOpen", children: icons.openIcon }),
520
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "copilotKitButtonIcon copilotKitButtonIconClose", children: icons.closeIcon })
521
+ ]
522
+ }
523
+ ) });
524
+ };
525
+
526
+ // src/components/dev-console/utils.ts
527
+ var import_react_core2 = require("@copilotkit/react-core");
528
+ var import_react_core3 = require("@copilotkit/react-core");
529
+ function getPublishedCopilotKitVersion(current, forceCheck = false) {
530
+ return __async(this, null, function* () {
531
+ const LOCAL_STORAGE_KEY = "__copilotkit_version_check__";
532
+ const serializedVersion = localStorage.getItem(LOCAL_STORAGE_KEY);
533
+ if (serializedVersion && !forceCheck) {
534
+ try {
535
+ const parsedVersion = JSON.parse(serializedVersion);
536
+ const oneHour = 60 * 60 * 1e3;
537
+ const now = (/* @__PURE__ */ new Date()).getTime();
538
+ if (parsedVersion.current === current && now - new Date(parsedVersion.lastChecked).getTime() < oneHour) {
539
+ return parsedVersion;
540
+ }
541
+ } catch (error) {
542
+ console.error("Failed to parse CopilotKitVersion from localStorage", error);
543
+ }
544
+ }
545
+ try {
546
+ const response = yield fetch("https://api.cloud.copilotkit.ai/check-for-updates", {
547
+ method: "POST",
548
+ headers: {
549
+ "Content-Type": "application/json"
550
+ },
551
+ body: JSON.stringify({
552
+ packages: [
553
+ {
554
+ packageName: "@copilotkit/shared",
555
+ packageVersion: current
556
+ }
557
+ ]
558
+ })
559
+ });
560
+ const data = yield response.json();
561
+ const version = {
562
+ current,
563
+ lastChecked: (/* @__PURE__ */ new Date()).getTime(),
564
+ latest: data.packages[0].latestVersion,
565
+ severity: data.packages[0].severity,
566
+ advisory: data.packages[0].advisory || null
567
+ };
568
+ localStorage.setItem(LOCAL_STORAGE_KEY, JSON.stringify(version));
569
+ return version;
570
+ } catch (error) {
571
+ console.error("Failed to check for updates", error);
572
+ throw error;
573
+ }
574
+ });
575
+ }
576
+ function logReadables(context) {
577
+ console.log("%cCurrent Readables:", "font-size: 16px; font-weight: bold;");
578
+ const readables = context.getContextString([], import_react_core2.defaultCopilotContextCategories).trim();
579
+ if (readables.length === 0) {
580
+ console.log("No readables found");
581
+ return;
582
+ }
583
+ console.log(readables);
584
+ }
585
+ function logActions(context) {
586
+ console.log("%cCurrent Actions:", "font-size: 16px; font-weight: bold;");
587
+ if (Object.values(context.actions).length === 0) {
588
+ console.log("No actions found");
589
+ return;
590
+ }
591
+ for (const action of Object.values(context.actions)) {
592
+ console.group(action.name);
593
+ console.log("name", action.name);
594
+ console.log("description", action.description);
595
+ console.log("parameters", action.parameters);
596
+ console.groupEnd();
597
+ }
598
+ }
599
+ function logMessages(context) {
600
+ console.log("%cCurrent Messages:", "font-size: 16px; font-weight: bold;");
601
+ if (context.messages.length === 0) {
602
+ console.log("No messages found");
603
+ return;
604
+ }
605
+ const tableData = context.messages.map((message) => {
606
+ if (message.isTextMessage()) {
607
+ return {
608
+ id: message.id,
609
+ type: "TextMessage",
610
+ role: message.role,
611
+ name: void 0,
612
+ scope: void 0,
613
+ content: message.content
614
+ };
615
+ } else if (message.isActionExecutionMessage()) {
616
+ return {
617
+ id: message.id,
618
+ type: "ActionExecutionMessage",
619
+ role: void 0,
620
+ name: message.name,
621
+ scope: message.parentMessageId,
622
+ content: message.arguments
623
+ };
624
+ } else if (message.isResultMessage()) {
625
+ return {
626
+ id: message.id,
627
+ type: "ResultMessage",
628
+ role: void 0,
629
+ name: message.actionName,
630
+ scope: message.actionExecutionId,
631
+ content: message.result
632
+ };
633
+ } else if (message.isAgentStateMessage()) {
634
+ return {
635
+ id: message.id,
636
+ type: `AgentStateMessage (running: ${message.running})`,
637
+ role: message.role,
638
+ name: void 0,
639
+ scope: message.threadId,
640
+ content: message.state
641
+ };
642
+ }
643
+ });
644
+ console.table(tableData);
645
+ }
646
+
647
+ // src/components/dev-console/console.tsx
648
+ var import_react_core4 = require("@copilotkit/react-core");
649
+ var import_react4 = require("react");
650
+
651
+ // src/components/dev-console/icons.tsx
652
+ var import_jsx_runtime5 = require("react/jsx-runtime");
653
+ var ExclamationMarkTriangleIcon = /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
654
+ "svg",
655
+ {
656
+ width: "13.3967723px",
657
+ height: "12px",
658
+ viewBox: "0 0 13.3967723 12",
659
+ version: "1.1",
660
+ xmlns: "http://www.w3.org/2000/svg",
661
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("g", { id: "Page-1", stroke: "none", strokeWidth: "1", fill: "none", fillRule: "evenodd", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("g", { id: "exclamation-triangle", fill: "#CD2121", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
662
+ "path",
663
+ {
664
+ d: "M5.39935802,0.75 C5.97670802,-0.25 7.42007802,-0.25 7.99742802,0.75 L13.193588,9.75 C13.770888,10.75 13.049288,12 11.894588,12 L1.50223802,12 C0.34753802,12 -0.37414898,10.75 0.20319802,9.75 L5.39935802,0.75 Z M6.69838802,2.5 C7.11260802,2.5 7.44838802,2.83579 7.44838802,3.25 L7.44838802,6.25 C7.44838802,6.66421 7.11260802,7 6.69838802,7 C6.28417802,7 5.94838802,6.66421 5.94838802,6.25 L5.94838802,3.25 C5.94838802,2.83579 6.28417802,2.5 6.69838802,2.5 Z M6.69838802,10.5 C7.25067802,10.5 7.69838802,10.0523 7.69838802,9.5 C7.69838802,8.9477 7.25067802,8.5 6.69838802,8.5 C6.14610802,8.5 5.69838802,8.9477 5.69838802,9.5 C5.69838802,10.0523 6.14610802,10.5 6.69838802,10.5 Z",
665
+ id: "Shape"
666
+ }
667
+ ) }) })
668
+ }
669
+ );
670
+ var ExclamationMarkIcon = /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
671
+ "svg",
672
+ {
673
+ width: "14px",
674
+ height: "14px",
675
+ viewBox: "0 0 14 14",
676
+ version: "1.1",
677
+ xmlns: "http://www.w3.org/2000/svg",
678
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("g", { id: "Page-1", stroke: "none", strokeWidth: "1", fill: "none", fillRule: "evenodd", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("g", { id: "exclamation-circle", fill: "#EC662C", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
679
+ "path",
680
+ {
681
+ d: "M7,14 C10.866,14 14,10.866 14,7 C14,3.13401 10.866,0 7,0 C3.13401,0 0,3.13401 0,7 C0,10.866 3.13401,14 7,14 Z M7,3 C7.41421,3 7.75,3.33579 7.75,3.75 L7.75,6.75 C7.75,7.16421 7.41421,7.5 7,7.5 C6.58579,7.5 6.25,7.16421 6.25,6.75 L6.25,3.75 C6.25,3.33579 6.58579,3 7,3 Z M7,11 C7.55228,11 8,10.5523 8,10 C8,9.4477 7.55228,9 7,9 C6.44772,9 6,9.4477 6,10 C6,10.5523 6.44772,11 7,11 Z",
682
+ id: "Shape"
683
+ }
684
+ ) }) })
685
+ }
686
+ );
687
+ var ChevronDownIcon = /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
688
+ "svg",
689
+ {
690
+ width: "7px",
691
+ height: "4px",
692
+ viewBox: "0 0 7 4",
693
+ version: "1.1",
694
+ xmlns: "http://www.w3.org/2000/svg",
695
+ fill: "currentColor",
696
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("g", { id: "Page-1", stroke: "none", strokeWidth: "1", fill: "none", fillRule: "evenodd", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("g", { id: "Group", fill: "currentColor", fillRule: "nonzero", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
697
+ "path",
698
+ {
699
+ d: "M3.71690723,3.90271086 C3.59268176,4.03242971 3.39143629,4.03242971 3.26721082,3.90271086 L0.0853966595,0.57605615 C-0.0314221035,0.444981627 -0.0279751448,0.240725043 0.0931934622,0.114040675 C0.214362069,-0.0126436935 0.409725445,-0.0162475626 0.535093061,0.105888951 L3.49205902,3.19746006 L6.44902499,0.105888951 C6.52834574,0.0168884389 6.64780588,-0.0197473458 6.7605411,0.0103538404 C6.87327633,0.0404550266 6.96130636,0.132492308 6.99009696,0.250359396 C7.01888756,0.368226483 6.98384687,0.493124608 6.89872139,0.57605615 L3.71690723,3.90271086 Z",
700
+ id: "Path"
701
+ }
702
+ ) }) })
703
+ }
704
+ );
705
+ var CheckIcon2 = /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
706
+ "svg",
707
+ {
708
+ width: "14px",
709
+ height: "14px",
710
+ viewBox: "0 0 14 14",
711
+ version: "1.1",
712
+ xmlns: "http://www.w3.org/2000/svg",
713
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("g", { id: "Page-1", stroke: "none", strokeWidth: "1", fill: "none", fillRule: "evenodd", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("g", { id: "Group-2", transform: "translate(-118, 0)", fill: "#1BC030", fillRule: "nonzero", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("g", { id: "Group", transform: "translate(118, 0)", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
714
+ "path",
715
+ {
716
+ d: "M0,7 C0,3.13384615 3.13384615,0 7,0 C10.8661538,0 14,3.13384615 14,7 C14,10.8661538 10.8661538,14 7,14 C3.13384615,14 0,10.8661538 0,7 Z M9.59179487,5.69764103 C9.70905818,5.54139023 9.73249341,5.33388318 9.65303227,5.15541491 C9.57357113,4.97694665 9.40367989,4.85551619 9.20909814,4.83811118 C9.01451638,4.82070616 8.82577109,4.91005717 8.71589744,5.07158974 L6.39261538,8.32389744 L5.22666667,7.15794872 C5.01450582,6.96025518 4.68389046,6.9660885 4.47883563,7.17114332 C4.27378081,7.37619815 4.26794748,7.70681351 4.46564103,7.91897436 L6.08102564,9.53435897 C6.19289944,9.64614839 6.3482622,9.70310251 6.50588106,9.69010587 C6.66349993,9.67710922 6.80743532,9.59547613 6.89948718,9.46687179 L9.59179487,5.69764103 L9.59179487,5.69764103 Z",
717
+ id: "Shape"
718
+ }
719
+ ) }) }) })
720
+ }
721
+ );
722
+
723
+ // src/components/dev-console/console.tsx
724
+ var import_react5 = require("@headlessui/react");
725
+ var import_shared2 = require("@copilotkit/shared");
726
+
727
+ // src/components/help-modal/modal.tsx
728
+ var import_react3 = require("react");
729
+
730
+ // src/components/help-modal/icons.tsx
731
+ var import_jsx_runtime6 = require("react/jsx-runtime");
732
+ var CloseIcon2 = () => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
733
+ "svg",
734
+ {
735
+ xmlns: "http://www.w3.org/2000/svg",
736
+ fill: "none",
737
+ viewBox: "0 0 24 24",
738
+ strokeWidth: "1.5",
739
+ stroke: "currentColor",
740
+ width: "20",
741
+ height: "20",
742
+ children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M6 18L18 6M6 6l12 12" })
743
+ }
744
+ );
745
+
746
+ // src/components/help-modal/modal.tsx
747
+ var import_jsx_runtime7 = require("react/jsx-runtime");
748
+ function CopilotKitHelpModal() {
749
+ const [showHelpModal, setShowHelpModal] = (0, import_react3.useState)(false);
750
+ const buttonRef = (0, import_react3.useRef)(null);
751
+ const popoverRef = (0, import_react3.useRef)(null);
752
+ (0, import_react3.useEffect)(() => {
753
+ const handleClickOutside = (event) => {
754
+ if (popoverRef.current && !popoverRef.current.contains(event.target) && buttonRef.current && !buttonRef.current.contains(event.target)) {
755
+ setShowHelpModal(false);
756
+ }
757
+ };
758
+ if (showHelpModal) {
759
+ document.addEventListener("mousedown", handleClickOutside);
760
+ }
761
+ return () => {
762
+ document.removeEventListener("mousedown", handleClickOutside);
763
+ };
764
+ }, [showHelpModal]);
765
+ const HelpButton = () => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
766
+ "button",
767
+ {
768
+ ref: buttonRef,
769
+ onClick: () => setShowHelpModal(!showHelpModal),
770
+ className: "copilotKitDebugMenuTriggerButton relative",
771
+ "aria-label": "Open Help",
772
+ children: "Help"
773
+ }
774
+ );
775
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "relative", children: [
776
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(HelpButton, {}),
777
+ showHelpModal && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
778
+ "div",
779
+ {
780
+ ref: popoverRef,
781
+ className: "absolute mt-2 z-50",
782
+ style: {
783
+ top: "100%",
784
+ right: "-120px",
785
+ width: "380px"
786
+ },
787
+ children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "copilotKitHelpModal rounded-lg shadow-xl w-full p-4 flex-col relative", children: [
788
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
789
+ "button",
790
+ {
791
+ className: "copilotKitHelpModalCloseButton absolute text-gray-400 hover:text-gray-600 focus:outline-none",
792
+ style: { top: "10px", right: "10px" },
793
+ onClick: () => setShowHelpModal(false),
794
+ "aria-label": "Close",
795
+ children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CloseIcon2, {})
796
+ }
797
+ ),
798
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "w-full flex mb-6 justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("h2", { className: "text-2xl font-bold", children: "Help Options" }) }),
799
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "space-y-4 mb-4", children: [
800
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "copilotKitHelpItemButton", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
801
+ "a",
802
+ {
803
+ href: "https://docs.copilotkit.ai/coagents/troubleshooting/common-issues",
804
+ target: "_blank",
805
+ rel: "noopener noreferrer",
806
+ children: "Visit the Troubleshooting and FAQ section in the docs"
807
+ }
808
+ ) }),
809
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "copilotKitHelpItemButton", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
810
+ "a",
811
+ {
812
+ href: "https://go.copilotkit.ai/dev-console-support-discord",
813
+ target: "_blank",
814
+ rel: "noopener noreferrer",
815
+ children: "Go to Discord Support Channel (Community Support)"
816
+ }
817
+ ) }),
818
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "copilotKitHelpItemButton", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
819
+ "a",
820
+ {
821
+ href: "https://go.copilotkit.ai/dev-console-support-slack",
822
+ target: "_blank",
823
+ rel: "noopener noreferrer",
824
+ children: "Apply for Priority Direct Slack Support"
825
+ }
826
+ ) })
827
+ ] })
828
+ ] })
829
+ }
830
+ )
831
+ ] });
832
+ }
833
+
834
+ // src/components/dev-console/console.tsx
835
+ var import_jsx_runtime8 = require("react/jsx-runtime");
836
+ function CopilotDevConsole() {
837
+ const currentVersion = import_shared2.COPILOTKIT_VERSION;
838
+ const context = (0, import_react_core4.useCopilotContext)();
839
+ const [showDevConsole, setShowDevConsole] = (0, import_react4.useState)(false);
840
+ (0, import_react4.useEffect)(() => {
841
+ setShowDevConsole((0, import_react_core3.shouldShowDevConsole)(context.showDevConsole));
842
+ }, [context.showDevConsole]);
843
+ const dontRunTwiceInDevMode = (0, import_react4.useRef)(false);
844
+ const [versionStatus, setVersionStatus] = (0, import_react4.useState)("unknown");
845
+ const [latestVersion, setLatestVersion] = (0, import_react4.useState)("");
846
+ const consoleRef = (0, import_react4.useRef)(null);
847
+ const [debugButtonMode, setDebugButtonMode] = (0, import_react4.useState)("full");
848
+ const checkForUpdates = (force = false) => {
849
+ setVersionStatus("checking");
850
+ getPublishedCopilotKitVersion(currentVersion, force).then((v) => {
851
+ setLatestVersion(v.latest);
852
+ let versionOk = false;
853
+ if (v.current === v.latest) {
854
+ versionOk = true;
855
+ } else if (/[a-zA-Z]/.test(v.current)) {
856
+ versionOk = true;
857
+ }
858
+ if (versionOk) {
859
+ setVersionStatus("latest");
860
+ } else if (v.severity !== "low") {
861
+ setVersionStatus("outdated");
862
+ } else {
863
+ setVersionStatus("update-available");
864
+ }
865
+ }).catch((e) => {
866
+ console.error(e);
867
+ setVersionStatus("unknown");
868
+ });
869
+ };
870
+ (0, import_react4.useEffect)(() => {
871
+ if (dontRunTwiceInDevMode.current === true) {
872
+ return;
873
+ }
874
+ dontRunTwiceInDevMode.current = true;
875
+ checkForUpdates();
876
+ }, []);
877
+ if (!showDevConsole) {
878
+ return null;
879
+ }
880
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
881
+ "div",
882
+ {
883
+ ref: consoleRef,
884
+ className: "copilotKitDevConsole " + (versionStatus === "update-available" ? "copilotKitDevConsoleUpgrade" : "") + (versionStatus === "outdated" ? "copilotKitDevConsoleWarnOutdated" : ""),
885
+ children: [
886
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
887
+ VersionInfo,
888
+ {
889
+ showDevConsole: context.showDevConsole,
890
+ versionStatus,
891
+ currentVersion,
892
+ latestVersion
893
+ }
894
+ ),
895
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(CopilotKitHelpModal, {}),
896
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
897
+ DebugMenuButton,
898
+ {
899
+ setShowDevConsole,
900
+ checkForUpdates,
901
+ mode: debugButtonMode
902
+ }
903
+ )
904
+ ]
905
+ }
906
+ );
907
+ }
908
+ function VersionInfo({
909
+ showDevConsole,
910
+ versionStatus,
911
+ currentVersion,
912
+ latestVersion
913
+ }) {
914
+ const [copyStatus, setCopyStatus] = (0, import_react4.useState)("");
915
+ let versionLabel = "";
916
+ let versionIcon = "";
917
+ let currentVersionLabel = currentVersion;
918
+ if (versionStatus === "latest") {
919
+ versionLabel = "latest";
920
+ versionIcon = CheckIcon2;
921
+ } else if (versionStatus === "checking") {
922
+ versionLabel = "checking";
923
+ versionIcon = SmallSpinnerIcon;
924
+ } else if (versionStatus === "update-available") {
925
+ versionLabel = "update available";
926
+ versionIcon = ExclamationMarkIcon;
927
+ currentVersionLabel = `${currentVersion} \u2192 ${latestVersion}`;
928
+ } else if (versionStatus === "outdated") {
929
+ versionLabel = "outdated";
930
+ versionIcon = ExclamationMarkTriangleIcon;
931
+ currentVersionLabel = `${currentVersion} \u2192 ${latestVersion}`;
932
+ }
933
+ let asideLabel = "";
934
+ if (showDevConsole === true) {
935
+ asideLabel = "(enabled)";
936
+ }
937
+ const installCommand = [
938
+ `npm install`,
939
+ `@copilotkit/react-core@${latestVersion}`,
940
+ `@copilotkit/react-ui@${latestVersion}`,
941
+ `@copilotkit/react-textarea@${latestVersion}`,
942
+ `&& npm install @copilotkit/runtime@${latestVersion}`
943
+ ].join(" ");
944
+ const handleCopyClick = () => {
945
+ navigator.clipboard.writeText(installCommand.trim()).then(() => {
946
+ setCopyStatus("Command copied to clipboard!");
947
+ setTimeout(() => setCopyStatus(""), 1e3);
948
+ });
949
+ };
950
+ if (versionStatus === "update-available" || versionStatus === "outdated") {
951
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "copilotKitVersionInfo", children: [
952
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("p", { children: [
953
+ currentVersionLabel,
954
+ " ",
955
+ versionIcon
956
+ ] }),
957
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { onClick: handleCopyClick, children: copyStatus || installCommand })
958
+ ] });
959
+ }
960
+ return null;
961
+ }
962
+ function DebugMenuButton({
963
+ setShowDevConsole,
964
+ checkForUpdates,
965
+ mode
966
+ }) {
967
+ const context = (0, import_react_core4.useCopilotContext)();
968
+ const messagesContext = (0, import_react_core4.useCopilotMessagesContext)();
969
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_jsx_runtime8.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_react5.Menu, { children: [
970
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
971
+ import_react5.MenuButton,
972
+ {
973
+ className: `copilotKitDebugMenuTriggerButton ${mode === "compact" ? "compact" : ""}`,
974
+ children: mode == "compact" ? "Debug" : /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
975
+ "Debug ",
976
+ ChevronDownIcon
977
+ ] })
978
+ }
979
+ ),
980
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
981
+ import_react5.MenuItems,
982
+ {
983
+ transition: true,
984
+ anchor: "bottom end",
985
+ className: "copilotKitDebugMenu",
986
+ style: { zIndex: 40 },
987
+ children: [
988
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react5.MenuItem, { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { className: "copilotKitDebugMenuItem", onClick: () => logReadables(context), children: "Log Readables" }) }),
989
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react5.MenuItem, { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { className: "copilotKitDebugMenuItem", onClick: () => logActions(context), children: "Log Actions" }) }),
990
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react5.MenuItem, { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
991
+ "button",
992
+ {
993
+ className: "copilotKitDebugMenuItem",
994
+ onClick: () => logMessages(messagesContext),
995
+ children: "Log Messages"
996
+ }
997
+ ) }),
998
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react5.MenuItem, { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { className: "copilotKitDebugMenuItem", onClick: () => checkForUpdates(true), children: "Check for Updates" }) }),
999
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("hr", {}),
1000
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react5.MenuItem, { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { className: "copilotKitDebugMenuItem", onClick: () => setShowDevConsole(false), children: "Hide Dev Console" }) })
1001
+ ]
1002
+ }
1003
+ )
1004
+ ] }) });
1005
+ }
1006
+
1007
+ // src/components/chat/Header.tsx
1008
+ var import_jsx_runtime9 = require("react/jsx-runtime");
1009
+ var Header = ({}) => {
1010
+ const { setOpen, icons, labels } = useChatContext();
1011
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "copilotKitHeader", children: [
1012
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { children: labels.title }),
1013
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "copilotKitHeaderControls", children: [
1014
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(CopilotDevConsole, {}),
1015
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1016
+ "button",
1017
+ {
1018
+ onClick: () => setOpen(false),
1019
+ "aria-label": "Close",
1020
+ className: "copilotKitHeaderCloseButton",
1021
+ children: icons.headerCloseIcon
1022
+ }
1023
+ )
1024
+ ] })
1025
+ ] });
1026
+ };
1027
+
1028
+ // src/components/chat/Messages.tsx
1029
+ var import_react10 = require("react");
1030
+ var import_react_core5 = require("@copilotkit/react-core");
1031
+
1032
+ // src/components/chat/messages/UserMessage.tsx
1033
+ var import_jsx_runtime10 = require("react/jsx-runtime");
1034
+ var getTextContent = (content) => {
1035
+ if (typeof content === "undefined") {
1036
+ return void 0;
1037
+ }
1038
+ if (typeof content === "string") {
1039
+ return content;
1040
+ }
1041
+ return content.map((part) => {
1042
+ if (part.type === "text") {
1043
+ return part.text;
1044
+ }
1045
+ return void 0;
1046
+ }).filter((value) => typeof value === "string" && value.length > 0).join(" ").trim() || void 0;
1047
+ };
1048
+ var UserMessage = (props) => {
1049
+ const { message, ImageRenderer: ImageRenderer2 } = props;
1050
+ const isImageMessage = message && "image" in message && Boolean(message.image);
1051
+ if (isImageMessage) {
1052
+ const imageMessage = message;
1053
+ const content2 = getTextContent(imageMessage == null ? void 0 : imageMessage.content);
1054
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "copilotKitMessage copilotKitUserMessage", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ImageRenderer2, { image: imageMessage.image, content: content2 }) });
1055
+ }
1056
+ const content = getTextContent(message == null ? void 0 : message.content);
1057
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "copilotKitMessage copilotKitUserMessage", children: content });
1058
+ };
1059
+
1060
+ // src/components/chat/Markdown.tsx
1061
+ var import_react7 = require("react");
1062
+ var import_react_markdown = __toESM(require("react-markdown"));
1063
+
1064
+ // src/components/chat/CodeBlock.tsx
1065
+ var import_react6 = require("react");
1066
+ var import_react_syntax_highlighter = require("react-syntax-highlighter");
1067
+
1068
+ // src/hooks/use-copy-to-clipboard.tsx
1069
+ var React5 = __toESM(require("react"));
1070
+ function useCopyToClipboard({ timeout = 2e3 }) {
1071
+ const [isCopied, setIsCopied] = React5.useState(false);
1072
+ const copyToClipboard = (value) => {
1073
+ var _a;
1074
+ if (typeof window === "undefined" || !((_a = navigator.clipboard) == null ? void 0 : _a.writeText)) {
1075
+ return;
1076
+ }
1077
+ if (!value) {
1078
+ return;
1079
+ }
1080
+ navigator.clipboard.writeText(value).then(() => {
1081
+ setIsCopied(true);
1082
+ setTimeout(() => {
1083
+ setIsCopied(false);
1084
+ }, timeout);
1085
+ });
1086
+ };
1087
+ return { isCopied, copyToClipboard };
1088
+ }
1089
+
1090
+ // src/components/chat/CodeBlock.tsx
1091
+ var import_jsx_runtime11 = require("react/jsx-runtime");
1092
+ var programmingLanguages = {
1093
+ javascript: ".js",
1094
+ python: ".py",
1095
+ java: ".java",
1096
+ c: ".c",
1097
+ cpp: ".cpp",
1098
+ "c++": ".cpp",
1099
+ "c#": ".cs",
1100
+ ruby: ".rb",
1101
+ php: ".php",
1102
+ swift: ".swift",
1103
+ "objective-c": ".m",
1104
+ kotlin: ".kt",
1105
+ typescript: ".ts",
1106
+ go: ".go",
1107
+ perl: ".pl",
1108
+ rust: ".rs",
1109
+ scala: ".scala",
1110
+ haskell: ".hs",
1111
+ lua: ".lua",
1112
+ shell: ".sh",
1113
+ sql: ".sql",
1114
+ html: ".html",
1115
+ css: ".css"
1116
+ // add more file extensions here, make sure the key is same as language prop in CodeBlock.tsx component
1117
+ };
1118
+ var generateRandomString = (length, lowercase = false) => {
1119
+ const chars = "ABCDEFGHJKLMNPQRSTUVWXY3456789";
1120
+ let result = "";
1121
+ for (let i = 0; i < length; i++) {
1122
+ result += chars.charAt(Math.floor(Math.random() * chars.length));
1123
+ }
1124
+ return lowercase ? result.toLowerCase() : result;
1125
+ };
1126
+ var CodeBlock = (0, import_react6.memo)(({ language, value }) => {
1127
+ const { isCopied, copyToClipboard } = useCopyToClipboard({ timeout: 2e3 });
1128
+ const [SyntaxHighlighter, setSyntaxHighlighter] = (0, import_react6.useState)(
1129
+ () => import_react_syntax_highlighter.Light
1130
+ );
1131
+ (0, import_react6.useEffect)(() => {
1132
+ try {
1133
+ new RegExp("(?<=#)\\w+");
1134
+ setSyntaxHighlighter(() => import_react_syntax_highlighter.Prism);
1135
+ } catch (e) {
1136
+ setSyntaxHighlighter(() => import_react_syntax_highlighter.Light);
1137
+ }
1138
+ }, []);
1139
+ const downloadAsFile = () => {
1140
+ if (typeof window === "undefined") {
1141
+ return;
1142
+ }
1143
+ const fileExtension = programmingLanguages[language] || ".file";
1144
+ const suggestedFileName = `file-${generateRandomString(3, true)}${fileExtension}`;
1145
+ const fileName = window.prompt("Enter file name", suggestedFileName);
1146
+ if (!fileName) {
1147
+ return;
1148
+ }
1149
+ const blob = new Blob([value], { type: "text/plain" });
1150
+ const url = URL.createObjectURL(blob);
1151
+ const link = document.createElement("a");
1152
+ link.download = fileName;
1153
+ link.href = url;
1154
+ link.style.display = "none";
1155
+ document.body.appendChild(link);
1156
+ link.click();
1157
+ document.body.removeChild(link);
1158
+ URL.revokeObjectURL(url);
1159
+ };
1160
+ const onCopy = () => {
1161
+ if (isCopied)
1162
+ return;
1163
+ copyToClipboard(value);
1164
+ };
1165
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "copilotKitCodeBlock", children: [
1166
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "copilotKitCodeBlockToolbar", children: [
1167
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "copilotKitCodeBlockToolbarLanguage", children: language }),
1168
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "copilotKitCodeBlockToolbarButtons", children: [
1169
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("button", { className: "copilotKitCodeBlockToolbarButton", onClick: downloadAsFile, children: DownloadIcon }),
1170
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("button", { className: "copilotKitCodeBlockToolbarButton", onClick: onCopy, children: isCopied ? CheckIcon : CopyIcon })
1171
+ ] })
1172
+ ] }),
1173
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1174
+ SyntaxHighlighter,
1175
+ {
1176
+ language,
1177
+ style: highlightStyle,
1178
+ PreTag: "div",
1179
+ customStyle: {
1180
+ margin: 0,
1181
+ borderBottomLeftRadius: "0.375rem",
1182
+ borderBottomRightRadius: "0.375rem"
1183
+ },
1184
+ children: value
1185
+ }
1186
+ )
1187
+ ] });
1188
+ });
1189
+ CodeBlock.displayName = "CodeBlock";
1190
+ var highlightStyle = {
1191
+ 'pre[class*="language-"]': {
1192
+ color: "#d4d4d4",
1193
+ fontSize: "13px",
1194
+ textShadow: "none",
1195
+ fontFamily: 'Menlo, Monaco, Consolas, "Andale Mono", "Ubuntu Mono", "Courier New", monospace',
1196
+ direction: "ltr",
1197
+ textAlign: "left",
1198
+ whiteSpace: "pre",
1199
+ wordSpacing: "normal",
1200
+ wordBreak: "normal",
1201
+ lineHeight: "1.5",
1202
+ MozTabSize: "4",
1203
+ OTabSize: "4",
1204
+ tabSize: "4",
1205
+ WebkitHyphens: "none",
1206
+ MozHyphens: "none",
1207
+ msHyphens: "none",
1208
+ hyphens: "none",
1209
+ padding: "1em",
1210
+ margin: ".5em 0",
1211
+ overflow: "auto",
1212
+ background: "#1e1e1e"
1213
+ },
1214
+ 'code[class*="language-"]': {
1215
+ color: "#d4d4d4",
1216
+ fontSize: "13px",
1217
+ textShadow: "none",
1218
+ fontFamily: 'Menlo, Monaco, Consolas, "Andale Mono", "Ubuntu Mono", "Courier New", monospace',
1219
+ direction: "ltr",
1220
+ textAlign: "left",
1221
+ whiteSpace: "pre",
1222
+ wordSpacing: "normal",
1223
+ wordBreak: "normal",
1224
+ lineHeight: "1.5",
1225
+ MozTabSize: "4",
1226
+ OTabSize: "4",
1227
+ tabSize: "4",
1228
+ WebkitHyphens: "none",
1229
+ MozHyphens: "none",
1230
+ msHyphens: "none",
1231
+ hyphens: "none"
1232
+ },
1233
+ 'pre[class*="language-"]::selection': {
1234
+ textShadow: "none",
1235
+ background: "#264F78"
1236
+ },
1237
+ 'code[class*="language-"]::selection': {
1238
+ textShadow: "none",
1239
+ background: "#264F78"
1240
+ },
1241
+ 'pre[class*="language-"] *::selection': {
1242
+ textShadow: "none",
1243
+ background: "#264F78"
1244
+ },
1245
+ 'code[class*="language-"] *::selection': {
1246
+ textShadow: "none",
1247
+ background: "#264F78"
1248
+ },
1249
+ ':not(pre) > code[class*="language-"]': {
1250
+ padding: ".1em .3em",
1251
+ borderRadius: ".3em",
1252
+ color: "#db4c69",
1253
+ background: "#1e1e1e"
1254
+ },
1255
+ ".namespace": {
1256
+ Opacity: ".7"
1257
+ },
1258
+ "doctype.doctype-tag": {
1259
+ color: "#569CD6"
1260
+ },
1261
+ "doctype.name": {
1262
+ color: "#9cdcfe"
1263
+ },
1264
+ comment: {
1265
+ color: "#6a9955"
1266
+ },
1267
+ prolog: {
1268
+ color: "#6a9955"
1269
+ },
1270
+ punctuation: {
1271
+ color: "#d4d4d4"
1272
+ },
1273
+ ".language-html .language-css .token.punctuation": {
1274
+ color: "#d4d4d4"
1275
+ },
1276
+ ".language-html .language-javascript .token.punctuation": {
1277
+ color: "#d4d4d4"
1278
+ },
1279
+ property: {
1280
+ color: "#9cdcfe"
1281
+ },
1282
+ tag: {
1283
+ color: "#569cd6"
1284
+ },
1285
+ boolean: {
1286
+ color: "#569cd6"
1287
+ },
1288
+ number: {
1289
+ color: "#b5cea8"
1290
+ },
1291
+ constant: {
1292
+ color: "#9cdcfe"
1293
+ },
1294
+ symbol: {
1295
+ color: "#b5cea8"
1296
+ },
1297
+ inserted: {
1298
+ color: "#b5cea8"
1299
+ },
1300
+ unit: {
1301
+ color: "#b5cea8"
1302
+ },
1303
+ selector: {
1304
+ color: "#d7ba7d"
1305
+ },
1306
+ "attr-name": {
1307
+ color: "#9cdcfe"
1308
+ },
1309
+ string: {
1310
+ color: "#ce9178"
1311
+ },
1312
+ char: {
1313
+ color: "#ce9178"
1314
+ },
1315
+ builtin: {
1316
+ color: "#ce9178"
1317
+ },
1318
+ deleted: {
1319
+ color: "#ce9178"
1320
+ },
1321
+ ".language-css .token.string.url": {
1322
+ textDecoration: "underline"
1323
+ },
1324
+ operator: {
1325
+ color: "#d4d4d4"
1326
+ },
1327
+ entity: {
1328
+ color: "#569cd6"
1329
+ },
1330
+ "operator.arrow": {
1331
+ color: "#569CD6"
1332
+ },
1333
+ atrule: {
1334
+ color: "#ce9178"
1335
+ },
1336
+ "atrule.rule": {
1337
+ color: "#c586c0"
1338
+ },
1339
+ "atrule.url": {
1340
+ color: "#9cdcfe"
1341
+ },
1342
+ "atrule.url.function": {
1343
+ color: "#dcdcaa"
1344
+ },
1345
+ "atrule.url.punctuation": {
1346
+ color: "#d4d4d4"
1347
+ },
1348
+ keyword: {
1349
+ color: "#569CD6"
1350
+ },
1351
+ "keyword.module": {
1352
+ color: "#c586c0"
1353
+ },
1354
+ "keyword.control-flow": {
1355
+ color: "#c586c0"
1356
+ },
1357
+ function: {
1358
+ color: "#dcdcaa"
1359
+ },
1360
+ "function.maybe-class-name": {
1361
+ color: "#dcdcaa"
1362
+ },
1363
+ regex: {
1364
+ color: "#d16969"
1365
+ },
1366
+ important: {
1367
+ color: "#569cd6"
1368
+ },
1369
+ italic: {
1370
+ fontStyle: "italic"
1371
+ },
1372
+ "class-name": {
1373
+ color: "#4ec9b0"
1374
+ },
1375
+ "maybe-class-name": {
1376
+ color: "#4ec9b0"
1377
+ },
1378
+ console: {
1379
+ color: "#9cdcfe"
1380
+ },
1381
+ parameter: {
1382
+ color: "#9cdcfe"
1383
+ },
1384
+ interpolation: {
1385
+ color: "#9cdcfe"
1386
+ },
1387
+ "punctuation.interpolation-punctuation": {
1388
+ color: "#569cd6"
1389
+ },
1390
+ variable: {
1391
+ color: "#9cdcfe"
1392
+ },
1393
+ "imports.maybe-class-name": {
1394
+ color: "#9cdcfe"
1395
+ },
1396
+ "exports.maybe-class-name": {
1397
+ color: "#9cdcfe"
1398
+ },
1399
+ escape: {
1400
+ color: "#d7ba7d"
1401
+ },
1402
+ "tag.punctuation": {
1403
+ color: "#808080"
1404
+ },
1405
+ cdata: {
1406
+ color: "#808080"
1407
+ },
1408
+ "attr-value": {
1409
+ color: "#ce9178"
1410
+ },
1411
+ "attr-value.punctuation": {
1412
+ color: "#ce9178"
1413
+ },
1414
+ "attr-value.punctuation.attr-equals": {
1415
+ color: "#d4d4d4"
1416
+ },
1417
+ namespace: {
1418
+ color: "#4ec9b0"
1419
+ },
1420
+ 'pre[class*="language-javascript"]': {
1421
+ color: "#9cdcfe"
1422
+ },
1423
+ 'code[class*="language-javascript"]': {
1424
+ color: "#9cdcfe"
1425
+ },
1426
+ 'pre[class*="language-jsx"]': {
1427
+ color: "#9cdcfe"
1428
+ },
1429
+ 'code[class*="language-jsx"]': {
1430
+ color: "#9cdcfe"
1431
+ },
1432
+ 'pre[class*="language-typescript"]': {
1433
+ color: "#9cdcfe"
1434
+ },
1435
+ 'code[class*="language-typescript"]': {
1436
+ color: "#9cdcfe"
1437
+ },
1438
+ 'pre[class*="language-tsx"]': {
1439
+ color: "#9cdcfe"
1440
+ },
1441
+ 'code[class*="language-tsx"]': {
1442
+ color: "#9cdcfe"
1443
+ },
1444
+ 'pre[class*="language-css"]': {
1445
+ color: "#ce9178"
1446
+ },
1447
+ 'code[class*="language-css"]': {
1448
+ color: "#ce9178"
1449
+ },
1450
+ 'pre[class*="language-html"]': {
1451
+ color: "#d4d4d4"
1452
+ },
1453
+ 'code[class*="language-html"]': {
1454
+ color: "#d4d4d4"
1455
+ },
1456
+ ".language-regex .token.anchor": {
1457
+ color: "#dcdcaa"
1458
+ },
1459
+ ".language-html .token.punctuation": {
1460
+ color: "#808080"
1461
+ },
1462
+ 'pre[class*="language-"] > code[class*="language-"]': {
1463
+ position: "relative",
1464
+ zIndex: "1"
1465
+ },
1466
+ ".line-highlight.line-highlight": {
1467
+ background: "#f7ebc6",
1468
+ boxShadow: "inset 5px 0 0 #f7d87c",
1469
+ zIndex: "0"
1470
+ }
1471
+ };
1472
+
1473
+ // src/components/chat/Markdown.tsx
1474
+ var import_remark_gfm = __toESM(require("remark-gfm"));
1475
+ var import_remark_math = __toESM(require("remark-math"));
1476
+ var import_rehype_raw = __toESM(require("rehype-raw"));
1477
+ var import_jsx_runtime12 = require("react/jsx-runtime");
1478
+ var defaultComponents = {
1479
+ a(_a) {
1480
+ var _b = _a, { children } = _b, props = __objRest(_b, ["children"]);
1481
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("a", __spreadProps(__spreadValues({ className: "copilotKitMarkdownElement" }, props), { target: "_blank", rel: "noopener noreferrer", children }));
1482
+ },
1483
+ // @ts-expect-error -- inline
1484
+ code(_c) {
1485
+ var _d = _c, { children, className, inline } = _d, props = __objRest(_d, ["children", "className", "inline"]);
1486
+ if (Array.isArray(children) && children.length) {
1487
+ if (children[0] == "\u258D") {
1488
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1489
+ "span",
1490
+ {
1491
+ style: {
1492
+ animation: "pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite",
1493
+ marginTop: "0.25rem"
1494
+ },
1495
+ children: "\u258D"
1496
+ }
1497
+ );
1498
+ }
1499
+ children[0] = (children == null ? void 0 : children[0]).replace("`\u258D`", "\u258D");
1500
+ }
1501
+ const match = /language-(\w+)/.exec(className || "");
1502
+ const hasLanguage = match && match[1];
1503
+ const content = String(children);
1504
+ const hasNewlines = content.includes("\n");
1505
+ const isInline = !hasLanguage && !hasNewlines;
1506
+ if (isInline) {
1507
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1508
+ "code",
1509
+ __spreadProps(__spreadValues({
1510
+ className: `copilotKitMarkdownElement copilotKitInlineCode ${className || ""}`
1511
+ }, props), {
1512
+ children
1513
+ })
1514
+ );
1515
+ }
1516
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1517
+ CodeBlock,
1518
+ __spreadValues({
1519
+ language: match && match[1] || "",
1520
+ value: String(children).replace(/\n$/, "")
1521
+ }, props),
1522
+ Math.random()
1523
+ );
1524
+ },
1525
+ h1: (_e) => {
1526
+ var _f = _e, { children } = _f, props = __objRest(_f, ["children"]);
1527
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("h1", __spreadProps(__spreadValues({ className: "copilotKitMarkdownElement" }, props), { children }));
1528
+ },
1529
+ h2: (_g) => {
1530
+ var _h = _g, { children } = _h, props = __objRest(_h, ["children"]);
1531
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("h2", __spreadProps(__spreadValues({ className: "copilotKitMarkdownElement" }, props), { children }));
1532
+ },
1533
+ h3: (_i) => {
1534
+ var _j = _i, { children } = _j, props = __objRest(_j, ["children"]);
1535
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("h3", __spreadProps(__spreadValues({ className: "copilotKitMarkdownElement" }, props), { children }));
1536
+ },
1537
+ h4: (_k) => {
1538
+ var _l = _k, { children } = _l, props = __objRest(_l, ["children"]);
1539
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("h4", __spreadProps(__spreadValues({ className: "copilotKitMarkdownElement" }, props), { children }));
1540
+ },
1541
+ h5: (_m) => {
1542
+ var _n = _m, { children } = _n, props = __objRest(_n, ["children"]);
1543
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("h5", __spreadProps(__spreadValues({ className: "copilotKitMarkdownElement" }, props), { children }));
1544
+ },
1545
+ h6: (_o) => {
1546
+ var _p = _o, { children } = _p, props = __objRest(_p, ["children"]);
1547
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("h6", __spreadProps(__spreadValues({ className: "copilotKitMarkdownElement" }, props), { children }));
1548
+ },
1549
+ p: (_q) => {
1550
+ var _r = _q, { children } = _r, props = __objRest(_r, ["children"]);
1551
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", __spreadProps(__spreadValues({ className: "copilotKitMarkdownElement" }, props), { children }));
1552
+ },
1553
+ pre: (_s) => {
1554
+ var _t = _s, { children } = _t, props = __objRest(_t, ["children"]);
1555
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("pre", __spreadProps(__spreadValues({ className: "copilotKitMarkdownElement" }, props), { children }));
1556
+ },
1557
+ blockquote: (_u) => {
1558
+ var _v = _u, { children } = _v, props = __objRest(_v, ["children"]);
1559
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("blockquote", __spreadProps(__spreadValues({ className: "copilotKitMarkdownElement" }, props), { children }));
1560
+ },
1561
+ ul: (_w) => {
1562
+ var _x = _w, { children } = _x, props = __objRest(_x, ["children"]);
1563
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("ul", __spreadProps(__spreadValues({ className: "copilotKitMarkdownElement" }, props), { children }));
1564
+ },
1565
+ li: (_y) => {
1566
+ var _z = _y, { children } = _z, props = __objRest(_z, ["children"]);
1567
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("li", __spreadProps(__spreadValues({ className: "copilotKitMarkdownElement" }, props), { children }));
1568
+ }
1569
+ };
1570
+ var MemoizedReactMarkdown = (0, import_react7.memo)(
1571
+ import_react_markdown.default,
1572
+ (prevProps, nextProps) => prevProps.children === nextProps.children && prevProps.components === nextProps.components
1573
+ );
1574
+ var Markdown = ({ content, components }) => {
1575
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "copilotKitMarkdown", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1576
+ MemoizedReactMarkdown,
1577
+ {
1578
+ components: __spreadValues(__spreadValues({}, defaultComponents), components),
1579
+ remarkPlugins: [import_remark_gfm.default, [import_remark_math.default, { singleDollarTextMath: false }]],
1580
+ rehypePlugins: [import_rehype_raw.default],
1581
+ children: content
1582
+ }
1583
+ ) });
1584
+ };
1585
+
1586
+ // src/components/chat/messages/AssistantMessage.tsx
1587
+ var import_react8 = require("react");
1588
+ var import_jsx_runtime13 = require("react/jsx-runtime");
1589
+ var AssistantMessage = (props) => {
1590
+ var _a;
1591
+ const { icons, labels } = useChatContext();
1592
+ const {
1593
+ message,
1594
+ isLoading,
1595
+ onRegenerate,
1596
+ onCopy,
1597
+ onThumbsUp,
1598
+ onThumbsDown,
1599
+ isCurrentMessage,
1600
+ feedback,
1601
+ markdownTagRenderers
1602
+ } = props;
1603
+ const [copied, setCopied] = (0, import_react8.useState)(false);
1604
+ const handleCopy = () => {
1605
+ const content2 = (message == null ? void 0 : message.content) || "";
1606
+ if (content2 && onCopy) {
1607
+ navigator.clipboard.writeText(content2);
1608
+ setCopied(true);
1609
+ onCopy(content2);
1610
+ setTimeout(() => setCopied(false), 2e3);
1611
+ } else if (content2) {
1612
+ navigator.clipboard.writeText(content2);
1613
+ setCopied(true);
1614
+ setTimeout(() => setCopied(false), 2e3);
1615
+ }
1616
+ };
1617
+ const handleRegenerate = () => {
1618
+ if (onRegenerate)
1619
+ onRegenerate();
1620
+ };
1621
+ const handleThumbsUp = () => {
1622
+ if (onThumbsUp && message) {
1623
+ onThumbsUp(message);
1624
+ }
1625
+ };
1626
+ const handleThumbsDown = () => {
1627
+ if (onThumbsDown && message) {
1628
+ onThumbsDown(message);
1629
+ }
1630
+ };
1631
+ const LoadingIcon = () => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { children: icons.activityIcon });
1632
+ const content = (message == null ? void 0 : message.content) || "";
1633
+ const subComponent = (_a = message == null ? void 0 : message.generativeUI) == null ? void 0 : _a.call(message);
1634
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
1635
+ content && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "copilotKitMessage copilotKitAssistantMessage", children: [
1636
+ content && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Markdown, { content, components: markdownTagRenderers }),
1637
+ content && !isLoading && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
1638
+ "div",
1639
+ {
1640
+ className: `copilotKitMessageControls ${isCurrentMessage ? "currentMessage" : ""}`,
1641
+ children: [
1642
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1643
+ "button",
1644
+ {
1645
+ className: "copilotKitMessageControlButton",
1646
+ onClick: handleRegenerate,
1647
+ "aria-label": labels.regenerateResponse,
1648
+ title: labels.regenerateResponse,
1649
+ children: icons.regenerateIcon
1650
+ }
1651
+ ),
1652
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1653
+ "button",
1654
+ {
1655
+ className: "copilotKitMessageControlButton",
1656
+ onClick: handleCopy,
1657
+ "aria-label": labels.copyToClipboard,
1658
+ title: labels.copyToClipboard,
1659
+ children: copied ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { style: { fontSize: "10px", fontWeight: "bold" }, children: "\u2713" }) : icons.copyIcon
1660
+ }
1661
+ ),
1662
+ onThumbsUp && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1663
+ "button",
1664
+ {
1665
+ className: `copilotKitMessageControlButton ${feedback === "thumbsUp" ? "active" : ""}`,
1666
+ onClick: handleThumbsUp,
1667
+ "aria-label": labels.thumbsUp,
1668
+ title: labels.thumbsUp,
1669
+ children: icons.thumbsUpIcon
1670
+ }
1671
+ ),
1672
+ onThumbsDown && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1673
+ "button",
1674
+ {
1675
+ className: `copilotKitMessageControlButton ${feedback === "thumbsDown" ? "active" : ""}`,
1676
+ onClick: handleThumbsDown,
1677
+ "aria-label": labels.thumbsDown,
1678
+ title: labels.thumbsDown,
1679
+ children: icons.thumbsDownIcon
1680
+ }
1681
+ )
1682
+ ]
1683
+ }
1684
+ )
1685
+ ] }),
1686
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { style: { marginBottom: "0.5rem" }, children: subComponent }),
1687
+ isLoading && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(LoadingIcon, {})
1688
+ ] });
1689
+ };
1690
+
1691
+ // src/components/chat/messages/ImageRenderer.tsx
1692
+ var import_react9 = require("react");
1693
+ var import_jsx_runtime14 = require("react/jsx-runtime");
1694
+ var ImageRenderer = ({ image, content, className = "" }) => {
1695
+ const [imageError, setImageError] = (0, import_react9.useState)(false);
1696
+ const imageSrc = `data:image/${image.format};base64,${image.bytes}`;
1697
+ const altText = content || "User uploaded image";
1698
+ const handleImageError = () => {
1699
+ setImageError(true);
1700
+ };
1701
+ if (imageError) {
1702
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: `copilotKitImageRendering copilotKitImageRenderingError ${className}`, children: [
1703
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "copilotKitImageRenderingErrorMessage", children: "Failed to load image" }),
1704
+ content && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "copilotKitImageRenderingContent", children: content })
1705
+ ] });
1706
+ }
1707
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: `copilotKitImageRendering ${className}`, children: [
1708
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1709
+ "img",
1710
+ {
1711
+ src: imageSrc,
1712
+ alt: altText,
1713
+ className: "copilotKitImageRenderingImage",
1714
+ onError: handleImageError
1715
+ }
1716
+ ),
1717
+ content && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "copilotKitImageRenderingContent", children: content })
1718
+ ] });
1719
+ };
1720
+
1721
+ // src/components/chat/messages/RenderMessage.tsx
1722
+ var import_jsx_runtime15 = require("react/jsx-runtime");
1723
+ function RenderMessage(_a) {
1724
+ var _b = _a, {
1725
+ UserMessage: UserMessage2 = UserMessage,
1726
+ AssistantMessage: AssistantMessage2 = AssistantMessage,
1727
+ ImageRenderer: ImageRenderer2 = ImageRenderer
1728
+ } = _b, props = __objRest(_b, [
1729
+ "UserMessage",
1730
+ "AssistantMessage",
1731
+ "ImageRenderer"
1732
+ ]);
1733
+ var _a2;
1734
+ const {
1735
+ message,
1736
+ messages,
1737
+ inProgress,
1738
+ index,
1739
+ isCurrentMessage,
1740
+ onRegenerate,
1741
+ onCopy,
1742
+ onThumbsUp,
1743
+ onThumbsDown,
1744
+ messageFeedback,
1745
+ markdownTagRenderers
1746
+ } = props;
1747
+ switch (message.role) {
1748
+ case "user":
1749
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
1750
+ UserMessage2,
1751
+ {
1752
+ rawData: message,
1753
+ "data-message-role": "user",
1754
+ message,
1755
+ ImageRenderer: ImageRenderer2
1756
+ },
1757
+ index
1758
+ );
1759
+ case "assistant":
1760
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
1761
+ AssistantMessage2,
1762
+ {
1763
+ "data-message-role": "assistant",
1764
+ subComponent: (_a2 = message.generativeUI) == null ? void 0 : _a2.call(message),
1765
+ rawData: message,
1766
+ message,
1767
+ messages,
1768
+ isLoading: inProgress && isCurrentMessage && !message.content,
1769
+ isGenerating: inProgress && isCurrentMessage && !!message.content,
1770
+ isCurrentMessage,
1771
+ onRegenerate: () => onRegenerate == null ? void 0 : onRegenerate(message.id),
1772
+ onCopy,
1773
+ onThumbsUp,
1774
+ onThumbsDown,
1775
+ feedback: (messageFeedback == null ? void 0 : messageFeedback[message.id]) || null,
1776
+ markdownTagRenderers,
1777
+ ImageRenderer: ImageRenderer2
1778
+ },
1779
+ index
1780
+ );
1781
+ default:
1782
+ return null;
1783
+ }
1784
+ }
1785
+
1786
+ // src/components/chat/messages/LegacyRenderMessage.tsx
1787
+ var import_runtime_client_gql = require("@copilotkit/runtime-client-gql");
1788
+ var import_jsx_runtime16 = require("react/jsx-runtime");
1789
+ var LegacyRenderMessage = ({
1790
+ message,
1791
+ messages,
1792
+ inProgress,
1793
+ index,
1794
+ isCurrentMessage,
1795
+ actionResult,
1796
+ AssistantMessage: AssistantMessage2,
1797
+ UserMessage: UserMessage2,
1798
+ ImageRenderer: ImageRenderer2,
1799
+ onRegenerate,
1800
+ onCopy,
1801
+ onThumbsUp,
1802
+ onThumbsDown,
1803
+ markdownTagRenderers,
1804
+ legacyProps
1805
+ }) => {
1806
+ var _a;
1807
+ const {
1808
+ RenderTextMessage,
1809
+ RenderActionExecutionMessage,
1810
+ RenderAgentStateMessage,
1811
+ RenderResultMessage,
1812
+ RenderImageMessage
1813
+ } = legacyProps;
1814
+ const deprecatedMessage = (_a = (0, import_runtime_client_gql.aguiToGQL)(message)[0]) != null ? _a : void 0;
1815
+ if (deprecatedMessage.isTextMessage() && RenderTextMessage) {
1816
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1817
+ RenderTextMessage,
1818
+ {
1819
+ message,
1820
+ messages,
1821
+ inProgress,
1822
+ index,
1823
+ isCurrentMessage,
1824
+ AssistantMessage: AssistantMessage2,
1825
+ UserMessage: UserMessage2,
1826
+ onRegenerate,
1827
+ onCopy,
1828
+ onThumbsUp,
1829
+ onThumbsDown,
1830
+ markdownTagRenderers
1831
+ }
1832
+ );
1833
+ }
1834
+ if (deprecatedMessage.isActionExecutionMessage() && RenderActionExecutionMessage) {
1835
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1836
+ RenderActionExecutionMessage,
1837
+ {
1838
+ messages,
1839
+ message,
1840
+ inProgress,
1841
+ index,
1842
+ isCurrentMessage,
1843
+ actionResult,
1844
+ AssistantMessage: AssistantMessage2,
1845
+ UserMessage: UserMessage2
1846
+ }
1847
+ );
1848
+ }
1849
+ if (deprecatedMessage.isAgentStateMessage() && RenderAgentStateMessage) {
1850
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1851
+ RenderAgentStateMessage,
1852
+ {
1853
+ messages,
1854
+ message,
1855
+ inProgress,
1856
+ index,
1857
+ isCurrentMessage,
1858
+ AssistantMessage: AssistantMessage2,
1859
+ UserMessage: UserMessage2
1860
+ }
1861
+ );
1862
+ }
1863
+ if (deprecatedMessage.isResultMessage() && RenderResultMessage) {
1864
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1865
+ RenderResultMessage,
1866
+ {
1867
+ messages,
1868
+ message,
1869
+ inProgress,
1870
+ index,
1871
+ isCurrentMessage,
1872
+ AssistantMessage: AssistantMessage2,
1873
+ UserMessage: UserMessage2
1874
+ }
1875
+ );
1876
+ }
1877
+ if (deprecatedMessage.isImageMessage() && RenderImageMessage) {
1878
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1879
+ RenderImageMessage,
1880
+ {
1881
+ messages,
1882
+ message,
1883
+ inProgress,
1884
+ index,
1885
+ isCurrentMessage,
1886
+ AssistantMessage: AssistantMessage2,
1887
+ UserMessage: UserMessage2
1888
+ }
1889
+ );
1890
+ }
1891
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1892
+ RenderMessage,
1893
+ {
1894
+ messages,
1895
+ message,
1896
+ inProgress,
1897
+ index,
1898
+ isCurrentMessage,
1899
+ AssistantMessage: AssistantMessage2,
1900
+ UserMessage: UserMessage2,
1901
+ ImageRenderer: ImageRenderer2,
1902
+ onRegenerate,
1903
+ onCopy,
1904
+ onThumbsUp,
1905
+ onThumbsDown,
1906
+ markdownTagRenderers
1907
+ }
1908
+ );
1909
+ };
1910
+
1911
+ // src/components/chat/Messages.tsx
1912
+ var import_jsx_runtime17 = require("react/jsx-runtime");
1913
+ var Messages = ({
1914
+ inProgress,
1915
+ children,
1916
+ RenderMessage: RenderMessage2,
1917
+ AssistantMessage: AssistantMessage2,
1918
+ UserMessage: UserMessage2,
1919
+ ErrorMessage,
1920
+ ImageRenderer: ImageRenderer2,
1921
+ onRegenerate,
1922
+ onCopy,
1923
+ onThumbsUp,
1924
+ onThumbsDown,
1925
+ messageFeedback,
1926
+ markdownTagRenderers,
1927
+ chatError,
1928
+ // Legacy props
1929
+ RenderTextMessage,
1930
+ RenderActionExecutionMessage,
1931
+ RenderAgentStateMessage,
1932
+ RenderResultMessage,
1933
+ RenderImageMessage
1934
+ }) => {
1935
+ var _a;
1936
+ const { labels, icons } = useChatContext();
1937
+ const { messages: visibleMessages, interrupt } = (0, import_react_core5.useCopilotChatInternal)();
1938
+ const initialMessages = (0, import_react10.useMemo)(() => makeInitialMessages(labels.initial), [labels.initial]);
1939
+ const messages = [...initialMessages, ...visibleMessages];
1940
+ const { messagesContainerRef, messagesEndRef } = useScrollToBottom(messages);
1941
+ const hasLegacyProps = !!(RenderTextMessage || RenderActionExecutionMessage || RenderAgentStateMessage || RenderResultMessage || RenderImageMessage);
1942
+ (0, import_react10.useEffect)(() => {
1943
+ if (hasLegacyProps) {
1944
+ console.warn(
1945
+ "[CopilotKit] Legacy message render props (RenderTextMessage, RenderActionExecutionMessage, etc.) are deprecated. Please use the unified 'RenderMessage' prop instead. See migration guide: https://docs.copilotkit.ai/migration/render-message"
1946
+ );
1947
+ }
1948
+ }, [hasLegacyProps]);
1949
+ const legacyProps = (0, import_react10.useMemo)(
1950
+ () => ({
1951
+ RenderTextMessage,
1952
+ RenderActionExecutionMessage,
1953
+ RenderAgentStateMessage,
1954
+ RenderResultMessage,
1955
+ RenderImageMessage
1956
+ }),
1957
+ [
1958
+ RenderTextMessage,
1959
+ RenderActionExecutionMessage,
1960
+ RenderAgentStateMessage,
1961
+ RenderResultMessage,
1962
+ RenderImageMessage
1963
+ ]
1964
+ );
1965
+ const MessageRenderer = hasLegacyProps ? (props) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(LegacyRenderMessage, __spreadProps(__spreadValues({}, props), { legacyProps })) : RenderMessage2;
1966
+ const LoadingIcon = () => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { children: icons.activityIcon });
1967
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "copilotKitMessages", ref: messagesContainerRef, children: [
1968
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "copilotKitMessagesContainer", children: [
1969
+ messages.map((message, index) => {
1970
+ const isCurrentMessage = index === messages.length - 1;
1971
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
1972
+ MessageRenderer,
1973
+ {
1974
+ message,
1975
+ messages,
1976
+ inProgress,
1977
+ index,
1978
+ isCurrentMessage,
1979
+ AssistantMessage: AssistantMessage2,
1980
+ UserMessage: UserMessage2,
1981
+ ImageRenderer: ImageRenderer2,
1982
+ onRegenerate,
1983
+ onCopy,
1984
+ onThumbsUp,
1985
+ onThumbsDown,
1986
+ messageFeedback,
1987
+ markdownTagRenderers
1988
+ },
1989
+ index
1990
+ );
1991
+ }),
1992
+ ((_a = messages[messages.length - 1]) == null ? void 0 : _a.role) === "user" && inProgress && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(LoadingIcon, {}),
1993
+ interrupt,
1994
+ chatError && ErrorMessage && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ErrorMessage, { error: chatError, isCurrentMessage: true })
1995
+ ] }),
1996
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("footer", { className: "copilotKitMessagesFooter", ref: messagesEndRef, children })
1997
+ ] });
1998
+ };
1999
+ function makeInitialMessages(initial) {
2000
+ if (!initial)
2001
+ return [];
2002
+ if (Array.isArray(initial)) {
2003
+ return initial.map((message) => {
2004
+ return {
2005
+ id: message,
2006
+ role: "assistant",
2007
+ content: message
2008
+ };
2009
+ });
2010
+ }
2011
+ return [
2012
+ {
2013
+ id: initial,
2014
+ role: "assistant",
2015
+ content: initial
2016
+ }
2017
+ ];
2018
+ }
2019
+ function useScrollToBottom(messages) {
2020
+ const messagesEndRef = (0, import_react10.useRef)(null);
2021
+ const messagesContainerRef = (0, import_react10.useRef)(null);
2022
+ const isProgrammaticScrollRef = (0, import_react10.useRef)(false);
2023
+ const isUserScrollUpRef = (0, import_react10.useRef)(false);
2024
+ const scrollToBottom = () => {
2025
+ if (messagesContainerRef.current && messagesEndRef.current) {
2026
+ isProgrammaticScrollRef.current = true;
2027
+ messagesContainerRef.current.scrollTop = messagesContainerRef.current.scrollHeight;
2028
+ }
2029
+ };
2030
+ const handleScroll = () => {
2031
+ if (isProgrammaticScrollRef.current) {
2032
+ isProgrammaticScrollRef.current = false;
2033
+ return;
2034
+ }
2035
+ if (messagesContainerRef.current) {
2036
+ const { scrollTop, scrollHeight, clientHeight } = messagesContainerRef.current;
2037
+ isUserScrollUpRef.current = scrollTop + clientHeight < scrollHeight;
2038
+ }
2039
+ };
2040
+ (0, import_react10.useEffect)(() => {
2041
+ const container = messagesContainerRef.current;
2042
+ if (container) {
2043
+ container.addEventListener("scroll", handleScroll);
2044
+ }
2045
+ return () => {
2046
+ if (container) {
2047
+ container.removeEventListener("scroll", handleScroll);
2048
+ }
2049
+ };
2050
+ }, []);
2051
+ (0, import_react10.useEffect)(() => {
2052
+ const container = messagesContainerRef.current;
2053
+ if (!container) {
2054
+ return;
2055
+ }
2056
+ const mutationObserver = new MutationObserver(() => {
2057
+ if (!isUserScrollUpRef.current) {
2058
+ scrollToBottom();
2059
+ }
2060
+ });
2061
+ mutationObserver.observe(container, {
2062
+ childList: true,
2063
+ subtree: true,
2064
+ characterData: true
2065
+ });
2066
+ return () => {
2067
+ mutationObserver.disconnect();
2068
+ };
2069
+ }, []);
2070
+ (0, import_react10.useEffect)(() => {
2071
+ isUserScrollUpRef.current = false;
2072
+ scrollToBottom();
2073
+ }, [messages.filter((m) => m.role === "user").length]);
2074
+ return { messagesEndRef, messagesContainerRef };
2075
+ }
2076
+
2077
+ // src/components/chat/Input.tsx
2078
+ var import_react14 = require("react");
2079
+
2080
+ // src/components/chat/Textarea.tsx
2081
+ var import_react11 = require("react");
2082
+ var import_jsx_runtime18 = require("react/jsx-runtime");
2083
+ var AutoResizingTextarea = (0, import_react11.forwardRef)(
2084
+ ({
2085
+ maxRows = 1,
2086
+ placeholder,
2087
+ value,
2088
+ onChange,
2089
+ onKeyDown,
2090
+ onCompositionStart,
2091
+ onCompositionEnd,
2092
+ autoFocus
2093
+ }, ref) => {
2094
+ const internalTextareaRef = (0, import_react11.useRef)(null);
2095
+ const [maxHeight, setMaxHeight] = (0, import_react11.useState)(0);
2096
+ (0, import_react11.useImperativeHandle)(ref, () => internalTextareaRef.current);
2097
+ (0, import_react11.useEffect)(() => {
2098
+ const calculateMaxHeight = () => {
2099
+ const textarea = internalTextareaRef.current;
2100
+ if (textarea) {
2101
+ textarea.style.height = "auto";
2102
+ const singleRowHeight = textarea.scrollHeight;
2103
+ setMaxHeight(singleRowHeight * maxRows);
2104
+ if (autoFocus) {
2105
+ textarea.focus();
2106
+ }
2107
+ }
2108
+ };
2109
+ calculateMaxHeight();
2110
+ }, [maxRows]);
2111
+ (0, import_react11.useEffect)(() => {
2112
+ const textarea = internalTextareaRef.current;
2113
+ if (textarea) {
2114
+ textarea.style.height = "auto";
2115
+ textarea.style.height = `${Math.min(textarea.scrollHeight, maxHeight)}px`;
2116
+ }
2117
+ }, [value, maxHeight]);
2118
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2119
+ "textarea",
2120
+ {
2121
+ ref: internalTextareaRef,
2122
+ value,
2123
+ onChange,
2124
+ onKeyDown,
2125
+ onCompositionStart,
2126
+ onCompositionEnd,
2127
+ placeholder,
2128
+ style: {
2129
+ overflow: "auto",
2130
+ resize: "none",
2131
+ maxHeight: `${maxHeight}px`
2132
+ },
2133
+ rows: 1
2134
+ }
2135
+ );
2136
+ }
2137
+ );
2138
+ var Textarea_default = AutoResizingTextarea;
2139
+
2140
+ // src/hooks/use-push-to-talk.tsx
2141
+ var import_react_core6 = require("@copilotkit/react-core");
2142
+ var import_runtime_client_gql2 = require("@copilotkit/runtime-client-gql");
2143
+ var import_react12 = require("react");
2144
+ var startRecording = (mediaStreamRef, mediaRecorderRef, audioContextRef, recordedChunks, onStop) => __async(void 0, null, function* () {
2145
+ if (!mediaStreamRef.current || !audioContextRef.current) {
2146
+ mediaStreamRef.current = yield navigator.mediaDevices.getUserMedia({ audio: true });
2147
+ audioContextRef.current = new window.AudioContext();
2148
+ yield audioContextRef.current.resume();
2149
+ }
2150
+ mediaRecorderRef.current = new MediaRecorder(mediaStreamRef.current);
2151
+ mediaRecorderRef.current.start(1e3);
2152
+ mediaRecorderRef.current.ondataavailable = (event) => {
2153
+ recordedChunks.push(event.data);
2154
+ };
2155
+ mediaRecorderRef.current.onstop = onStop;
2156
+ });
2157
+ var stopRecording = (mediaRecorderRef) => {
2158
+ if (mediaRecorderRef.current && mediaRecorderRef.current.state !== "inactive") {
2159
+ mediaRecorderRef.current.stop();
2160
+ }
2161
+ };
2162
+ var transcribeAudio = (recordedChunks, transcribeAudioUrl) => __async(void 0, null, function* () {
2163
+ const completeBlob = new Blob(recordedChunks, { type: "audio/mp4" });
2164
+ const formData = new FormData();
2165
+ formData.append("file", completeBlob, "recording.mp4");
2166
+ const response = yield fetch(transcribeAudioUrl, {
2167
+ method: "POST",
2168
+ body: formData
2169
+ });
2170
+ if (!response.ok) {
2171
+ throw new Error(`Error: ${response.statusText}`);
2172
+ }
2173
+ const transcription = yield response.json();
2174
+ return transcription.text;
2175
+ });
2176
+ var playAudioResponse = (text, textToSpeechUrl, audioContext) => {
2177
+ const encodedText = encodeURIComponent(text);
2178
+ const url = `${textToSpeechUrl}?text=${encodedText}`;
2179
+ fetch(url).then((response) => response.arrayBuffer()).then((arrayBuffer) => audioContext.decodeAudioData(arrayBuffer)).then((audioBuffer) => {
2180
+ const source = audioContext.createBufferSource();
2181
+ source.buffer = audioBuffer;
2182
+ source.connect(audioContext.destination);
2183
+ source.start(0);
2184
+ }).catch((error) => {
2185
+ console.error("Error with decoding audio data", error);
2186
+ });
2187
+ };
2188
+ var usePushToTalk = ({
2189
+ sendFunction,
2190
+ inProgress
2191
+ }) => {
2192
+ const [pushToTalkState, setPushToTalkState] = (0, import_react12.useState)("idle");
2193
+ const mediaStreamRef = (0, import_react12.useRef)(null);
2194
+ const audioContextRef = (0, import_react12.useRef)(null);
2195
+ const mediaRecorderRef = (0, import_react12.useRef)(null);
2196
+ const recordedChunks = (0, import_react12.useRef)([]);
2197
+ const generalContext = (0, import_react_core6.useCopilotContext)();
2198
+ const messagesContext = (0, import_react_core6.useCopilotMessagesContext)();
2199
+ const context = __spreadValues(__spreadValues({}, generalContext), messagesContext);
2200
+ const [startReadingFromMessageId, setStartReadingFromMessageId] = (0, import_react12.useState)(null);
2201
+ (0, import_react12.useEffect)(() => {
2202
+ if (pushToTalkState === "recording") {
2203
+ startRecording(
2204
+ mediaStreamRef,
2205
+ mediaRecorderRef,
2206
+ audioContextRef,
2207
+ recordedChunks.current,
2208
+ () => {
2209
+ setPushToTalkState("transcribing");
2210
+ }
2211
+ );
2212
+ } else {
2213
+ stopRecording(mediaRecorderRef);
2214
+ if (pushToTalkState === "transcribing") {
2215
+ transcribeAudio(recordedChunks.current, context.copilotApiConfig.transcribeAudioUrl).then(
2216
+ (transcription) => __async(void 0, null, function* () {
2217
+ recordedChunks.current = [];
2218
+ setPushToTalkState("idle");
2219
+ const message = yield sendFunction(transcription);
2220
+ setStartReadingFromMessageId(message.id);
2221
+ })
2222
+ );
2223
+ }
2224
+ }
2225
+ return () => {
2226
+ stopRecording(mediaRecorderRef);
2227
+ };
2228
+ }, [pushToTalkState]);
2229
+ (0, import_react12.useEffect)(() => {
2230
+ if (inProgress === false && startReadingFromMessageId) {
2231
+ const lastMessageIndex = context.messages.findIndex(
2232
+ (message) => message.id === startReadingFromMessageId
2233
+ );
2234
+ const aguiMessages = (0, import_runtime_client_gql2.gqlToAGUI)(context.messages);
2235
+ const messagesAfterLast = aguiMessages.slice(lastMessageIndex + 1).filter((message) => message.role === "assistant");
2236
+ const text = messagesAfterLast.map((message) => message.content).join("\n");
2237
+ playAudioResponse(text, context.copilotApiConfig.textToSpeechUrl, audioContextRef.current);
2238
+ setStartReadingFromMessageId(null);
2239
+ }
2240
+ }, [startReadingFromMessageId, inProgress]);
2241
+ return { pushToTalkState, setPushToTalkState };
2242
+ };
2243
+
2244
+ // src/components/chat/Input.tsx
2245
+ var import_react_core7 = require("@copilotkit/react-core");
2246
+
2247
+ // src/components/chat/PoweredByTag.tsx
2248
+ var import_react13 = require("react");
2249
+
2250
+ // src/hooks/use-dark-mode.ts
2251
+ var useDarkMode = () => {
2252
+ if (typeof window === "undefined")
2253
+ return false;
2254
+ return document.documentElement.classList.contains("dark") || document.body.classList.contains("dark") || document.documentElement.getAttribute("data-theme") === "dark" || document.body.getAttribute("data-theme") === "dark" || window.matchMedia("(prefers-color-scheme: dark)").matches;
2255
+ };
2256
+
2257
+ // src/components/chat/PoweredByTag.tsx
2258
+ var import_jsx_runtime19 = require("react/jsx-runtime");
2259
+ function PoweredByTag({ showPoweredBy = true }) {
2260
+ const [mounted, setMounted] = (0, import_react13.useState)(false);
2261
+ const isDark = useDarkMode();
2262
+ (0, import_react13.useEffect)(() => {
2263
+ setMounted(true);
2264
+ }, []);
2265
+ if (!showPoweredBy) {
2266
+ return null;
2267
+ }
2268
+ const poweredByStyle = {
2269
+ visibility: "visible",
2270
+ display: "block",
2271
+ position: "static",
2272
+ textAlign: "center",
2273
+ fontSize: "12px",
2274
+ padding: "3px 0",
2275
+ color: mounted && isDark ? "rgb(69, 69, 69)" : "rgb(214, 214, 214)"
2276
+ };
2277
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("p", { className: "poweredBy", style: poweredByStyle, children: "Powered by CopilotKit" }) });
2278
+ }
2279
+
2280
+ // src/components/chat/Input.tsx
2281
+ var import_jsx_runtime20 = require("react/jsx-runtime");
2282
+ var MAX_NEWLINES = 6;
2283
+ var Input = ({
2284
+ inProgress,
2285
+ onSend,
2286
+ chatReady = false,
2287
+ onStop,
2288
+ onUpload,
2289
+ hideStopButton = false
2290
+ }) => {
2291
+ var _a;
2292
+ const context = useChatContext();
2293
+ const copilotContext = (0, import_react_core7.useCopilotContext)();
2294
+ const showPoweredBy = !((_a = copilotContext.copilotApiConfig) == null ? void 0 : _a.publicApiKey);
2295
+ const pushToTalkConfigured = copilotContext.copilotApiConfig.textToSpeechUrl !== void 0 && copilotContext.copilotApiConfig.transcribeAudioUrl !== void 0;
2296
+ const textareaRef = (0, import_react14.useRef)(null);
2297
+ const [isComposing, setIsComposing] = (0, import_react14.useState)(false);
2298
+ const handleDivClick = (event) => {
2299
+ var _a2;
2300
+ const target = event.target;
2301
+ if (target.closest("button"))
2302
+ return;
2303
+ if (target.tagName === "TEXTAREA")
2304
+ return;
2305
+ (_a2 = textareaRef.current) == null ? void 0 : _a2.focus();
2306
+ };
2307
+ const [text, setText] = (0, import_react14.useState)("");
2308
+ const send = () => {
2309
+ var _a2;
2310
+ if (inProgress)
2311
+ return;
2312
+ onSend(text);
2313
+ setText("");
2314
+ (_a2 = textareaRef.current) == null ? void 0 : _a2.focus();
2315
+ };
2316
+ const { pushToTalkState, setPushToTalkState } = usePushToTalk({
2317
+ sendFunction: onSend,
2318
+ inProgress
2319
+ });
2320
+ const isInProgress = inProgress || pushToTalkState === "transcribing";
2321
+ const { buttonIcon, buttonAlt } = (0, import_react14.useMemo)(() => {
2322
+ if (!chatReady)
2323
+ return { buttonIcon: context.icons.spinnerIcon, buttonAlt: "Loading" };
2324
+ return isInProgress && !hideStopButton && chatReady ? { buttonIcon: context.icons.stopIcon, buttonAlt: "Stop" } : { buttonIcon: context.icons.sendIcon, buttonAlt: "Send" };
2325
+ }, [isInProgress, chatReady, hideStopButton, context.icons.stopIcon, context.icons.sendIcon]);
2326
+ const showPushToTalk = pushToTalkConfigured && (pushToTalkState === "idle" || pushToTalkState === "recording") && !inProgress;
2327
+ const { interrupt } = (0, import_react_core7.useCopilotChatInternal)();
2328
+ const canSend = (0, import_react14.useMemo)(() => {
2329
+ return !isInProgress && text.trim().length > 0 && pushToTalkState === "idle" && !interrupt;
2330
+ }, [interrupt, isInProgress, text, pushToTalkState]);
2331
+ const canStop = (0, import_react14.useMemo)(() => {
2332
+ return isInProgress && !hideStopButton;
2333
+ }, [isInProgress, hideStopButton]);
2334
+ const sendDisabled = !canSend && !canStop;
2335
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: `copilotKitInputContainer ${showPoweredBy ? "poweredByContainer" : ""}`, children: [
2336
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "copilotKitInput", onClick: handleDivClick, children: [
2337
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
2338
+ Textarea_default,
2339
+ {
2340
+ ref: textareaRef,
2341
+ placeholder: context.labels.placeholder,
2342
+ autoFocus: false,
2343
+ maxRows: MAX_NEWLINES,
2344
+ value: text,
2345
+ onChange: (event) => setText(event.target.value),
2346
+ onCompositionStart: () => setIsComposing(true),
2347
+ onCompositionEnd: () => setIsComposing(false),
2348
+ onKeyDown: (event) => {
2349
+ if (event.key === "Enter" && !event.shiftKey && !isComposing) {
2350
+ event.preventDefault();
2351
+ if (canSend) {
2352
+ send();
2353
+ }
2354
+ }
2355
+ }
2356
+ }
2357
+ ),
2358
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "copilotKitInputControls", children: [
2359
+ onUpload && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("button", { onClick: onUpload, className: "copilotKitInputControlButton", children: context.icons.uploadIcon }),
2360
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { style: { flexGrow: 1 } }),
2361
+ showPushToTalk && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
2362
+ "button",
2363
+ {
2364
+ onClick: () => setPushToTalkState(pushToTalkState === "idle" ? "recording" : "transcribing"),
2365
+ className: pushToTalkState === "recording" ? "copilotKitInputControlButton copilotKitPushToTalkRecording" : "copilotKitInputControlButton",
2366
+ children: context.icons.pushToTalkIcon
2367
+ }
2368
+ ),
2369
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
2370
+ "button",
2371
+ {
2372
+ disabled: sendDisabled,
2373
+ onClick: isInProgress && !hideStopButton ? onStop : send,
2374
+ "data-copilotkit-in-progress": inProgress,
2375
+ "data-test-id": inProgress ? "copilot-chat-request-in-progress" : "copilot-chat-ready",
2376
+ className: "copilotKitInputControlButton",
2377
+ "aria-label": buttonAlt,
2378
+ children: buttonIcon
2379
+ }
2380
+ )
2381
+ ] })
2382
+ ] }),
2383
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(PoweredByTag, { showPoweredBy })
2384
+ ] });
2385
+ };
2386
+
2387
+ // src/components/chat/Chat.tsx
2388
+ var import_react15 = __toESM(require("react"));
2389
+ var import_react_core9 = require("@copilotkit/react-core");
2390
+ var import_shared3 = require("@copilotkit/shared");
2391
+
2392
+ // src/components/chat/ImageUploadQueue.tsx
2393
+ var import_jsx_runtime21 = require("react/jsx-runtime");
2394
+ var ImageUploadQueue = ({
2395
+ images,
2396
+ onRemoveImage,
2397
+ className = ""
2398
+ }) => {
2399
+ if (images.length === 0)
2400
+ return null;
2401
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2402
+ "div",
2403
+ {
2404
+ className: `copilotKitImageUploadQueue ${className}`,
2405
+ style: {
2406
+ display: "flex",
2407
+ flexWrap: "wrap",
2408
+ gap: "8px",
2409
+ margin: "8px",
2410
+ padding: "8px"
2411
+ },
2412
+ children: images.map((image, index) => /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
2413
+ "div",
2414
+ {
2415
+ className: "copilotKitImageUploadQueueItem",
2416
+ style: {
2417
+ position: "relative",
2418
+ display: "inline-block",
2419
+ width: "60px",
2420
+ height: "60px",
2421
+ borderRadius: "4px",
2422
+ overflow: "hidden"
2423
+ },
2424
+ children: [
2425
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2426
+ "img",
2427
+ {
2428
+ src: `data:${image.contentType};base64,${image.bytes}`,
2429
+ alt: `Selected image ${index + 1}`,
2430
+ style: {
2431
+ width: "100%",
2432
+ height: "100%",
2433
+ objectFit: "cover"
2434
+ }
2435
+ }
2436
+ ),
2437
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2438
+ "button",
2439
+ {
2440
+ onClick: () => onRemoveImage(index),
2441
+ className: "copilotKitImageUploadQueueRemoveButton",
2442
+ style: {
2443
+ position: "absolute",
2444
+ top: "2px",
2445
+ right: "2px",
2446
+ background: "rgba(0,0,0,0.6)",
2447
+ color: "white",
2448
+ border: "none",
2449
+ borderRadius: "50%",
2450
+ width: "18px",
2451
+ height: "18px",
2452
+ display: "flex",
2453
+ alignItems: "center",
2454
+ justifyContent: "center",
2455
+ cursor: "pointer",
2456
+ fontSize: "10px",
2457
+ padding: 0
2458
+ },
2459
+ children: "\u2715"
2460
+ }
2461
+ )
2462
+ ]
2463
+ },
2464
+ index
2465
+ ))
2466
+ }
2467
+ );
2468
+ };
2469
+
2470
+ // src/components/chat/Suggestion.tsx
2471
+ var import_react_core8 = require("@copilotkit/react-core");
2472
+ var import_jsx_runtime22 = require("react/jsx-runtime");
2473
+ function Suggestion({ title, onClick, partial, className }) {
2474
+ if (!title)
2475
+ return null;
2476
+ const { isLoading } = (0, import_react_core8.useCopilotChatInternal)();
2477
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
2478
+ "button",
2479
+ {
2480
+ disabled: partial || isLoading,
2481
+ onClick: (e) => {
2482
+ e.preventDefault();
2483
+ onClick();
2484
+ },
2485
+ className: className || (partial ? "suggestion loading" : "suggestion"),
2486
+ "data-test-id": "suggestion",
2487
+ children: partial ? SmallSpinnerIcon : /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { children: title })
2488
+ }
2489
+ );
2490
+ }
2491
+
2492
+ // src/components/chat/Suggestions.tsx
2493
+ var import_jsx_runtime23 = require("react/jsx-runtime");
2494
+ function Suggestions({
2495
+ suggestions,
2496
+ onSuggestionClick,
2497
+ isLoading
2498
+ }) {
2499
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "suggestions", children: suggestions.map((suggestion, index) => {
2500
+ var _a, _b;
2501
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
2502
+ Suggestion,
2503
+ {
2504
+ title: suggestion.title,
2505
+ message: suggestion.message,
2506
+ partial: (_b = (_a = suggestion.isLoading) != null ? _a : suggestion.partial) != null ? _b : isLoading,
2507
+ className: suggestion.className,
2508
+ onClick: () => onSuggestionClick(suggestion.message)
2509
+ },
2510
+ index
2511
+ );
2512
+ }) });
2513
+ }
2514
+
2515
+ // src/components/chat/Chat.tsx
2516
+ var import_jsx_runtime24 = require("react/jsx-runtime");
2517
+ function CopilotChat({
2518
+ instructions,
2519
+ suggestions = "auto",
2520
+ onSubmitMessage,
2521
+ makeSystemMessage,
2522
+ disableSystemMessage,
2523
+ onInProgress,
2524
+ onStopGeneration,
2525
+ onReloadMessages,
2526
+ onRegenerate,
2527
+ onCopy,
2528
+ onThumbsUp,
2529
+ onThumbsDown,
2530
+ markdownTagRenderers,
2531
+ Messages: Messages2 = Messages,
2532
+ RenderMessage: RenderMessage2 = RenderMessage,
2533
+ RenderSuggestionsList = Suggestions,
2534
+ Input: Input2 = Input,
2535
+ className,
2536
+ icons,
2537
+ labels,
2538
+ AssistantMessage: AssistantMessage2 = AssistantMessage,
2539
+ UserMessage: UserMessage2 = UserMessage,
2540
+ ImageRenderer: ImageRenderer2 = ImageRenderer,
2541
+ ErrorMessage,
2542
+ imageUploadsEnabled,
2543
+ inputFileAccept = "image/*",
2544
+ hideStopButton,
2545
+ observabilityHooks,
2546
+ renderError,
2547
+ onError,
2548
+ // Legacy props - deprecated
2549
+ RenderTextMessage,
2550
+ RenderActionExecutionMessage,
2551
+ RenderAgentStateMessage,
2552
+ RenderResultMessage,
2553
+ RenderImageMessage
2554
+ }) {
2555
+ const {
2556
+ additionalInstructions,
2557
+ setChatInstructions,
2558
+ copilotApiConfig,
2559
+ setBannerError,
2560
+ setInternalErrorHandler,
2561
+ removeInternalErrorHandler
2562
+ } = (0, import_react_core9.useCopilotContext)();
2563
+ const { publicApiKey, chatApiEndpoint } = copilotApiConfig;
2564
+ const [selectedImages, setSelectedImages] = (0, import_react15.useState)([]);
2565
+ const [chatError, setChatError] = (0, import_react15.useState)(null);
2566
+ const [messageFeedback, setMessageFeedback] = (0, import_react15.useState)(
2567
+ {}
2568
+ );
2569
+ const fileInputRef = (0, import_react15.useRef)(null);
2570
+ const triggerObservabilityHook = (0, import_react15.useCallback)(
2571
+ (hookName, ...args) => {
2572
+ if (publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks[hookName])) {
2573
+ observabilityHooks[hookName](...args);
2574
+ }
2575
+ if ((observabilityHooks == null ? void 0 : observabilityHooks[hookName]) && !publicApiKey) {
2576
+ setBannerError(
2577
+ new import_shared3.CopilotKitError({
2578
+ message: "observabilityHooks requires a publicApiKey to function.",
2579
+ code: import_shared3.CopilotKitErrorCode.MISSING_PUBLIC_API_KEY_ERROR,
2580
+ severity: import_shared3.Severity.CRITICAL,
2581
+ visibility: import_shared3.ErrorVisibility.BANNER
2582
+ })
2583
+ );
2584
+ import_shared3.styledConsole.publicApiKeyRequired("observabilityHooks");
2585
+ }
2586
+ },
2587
+ [publicApiKey, observabilityHooks, setBannerError]
2588
+ );
2589
+ const triggerChatError = (0, import_react15.useCallback)(
2590
+ (error, operation, originalError) => {
2591
+ const errorMessage = (error == null ? void 0 : error.message) || (error == null ? void 0 : error.toString()) || "An error occurred";
2592
+ setChatError({
2593
+ message: errorMessage,
2594
+ operation,
2595
+ timestamp: Date.now()
2596
+ });
2597
+ const errorEvent = {
2598
+ type: "error",
2599
+ timestamp: Date.now(),
2600
+ context: {
2601
+ source: "ui",
2602
+ request: {
2603
+ operation,
2604
+ url: chatApiEndpoint,
2605
+ startTime: Date.now()
2606
+ },
2607
+ technical: {
2608
+ environment: "browser",
2609
+ userAgent: typeof navigator !== "undefined" ? navigator.userAgent : void 0,
2610
+ stackTrace: originalError instanceof Error ? originalError.stack : void 0
2611
+ }
2612
+ },
2613
+ error
2614
+ };
2615
+ if (onError) {
2616
+ onError(errorEvent);
2617
+ }
2618
+ if (publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks.onError)) {
2619
+ observabilityHooks.onError(errorEvent);
2620
+ }
2621
+ if ((observabilityHooks == null ? void 0 : observabilityHooks.onError) && !publicApiKey) {
2622
+ setBannerError(
2623
+ new import_shared3.CopilotKitError({
2624
+ message: "observabilityHooks.onError requires a publicApiKey to function.",
2625
+ code: import_shared3.CopilotKitErrorCode.MISSING_PUBLIC_API_KEY_ERROR,
2626
+ severity: import_shared3.Severity.CRITICAL,
2627
+ visibility: import_shared3.ErrorVisibility.BANNER
2628
+ })
2629
+ );
2630
+ import_shared3.styledConsole.publicApiKeyRequired("observabilityHooks.onError");
2631
+ }
2632
+ },
2633
+ [publicApiKey, chatApiEndpoint, observabilityHooks, setBannerError]
2634
+ );
2635
+ (0, import_react15.useEffect)(() => {
2636
+ const id = "chat-component";
2637
+ setInternalErrorHandler({
2638
+ [id]: (error) => {
2639
+ if (!error)
2640
+ return;
2641
+ triggerChatError(error.error, "sendMessage");
2642
+ }
2643
+ });
2644
+ return () => {
2645
+ removeInternalErrorHandler == null ? void 0 : removeInternalErrorHandler(id);
2646
+ };
2647
+ }, [triggerChatError, setInternalErrorHandler, removeInternalErrorHandler]);
2648
+ (0, import_react15.useEffect)(() => {
2649
+ if (!imageUploadsEnabled)
2650
+ return;
2651
+ const handlePaste = (e) => __async(this, null, function* () {
2652
+ var _a, _b;
2653
+ const target = e.target;
2654
+ if (!((_a = target.parentElement) == null ? void 0 : _a.classList.contains("copilotKitInput")))
2655
+ return;
2656
+ const items = Array.from(((_b = e.clipboardData) == null ? void 0 : _b.items) || []);
2657
+ const imageItems = items.filter((item) => item.type.startsWith("image/"));
2658
+ if (imageItems.length === 0)
2659
+ return;
2660
+ e.preventDefault();
2661
+ const imagePromises = imageItems.map((item) => {
2662
+ const file = item.getAsFile();
2663
+ if (!file)
2664
+ return Promise.resolve(null);
2665
+ return new Promise((resolve, reject) => {
2666
+ const reader = new FileReader();
2667
+ reader.onload = (e2) => {
2668
+ var _a2, _b2;
2669
+ const base64String = (_b2 = (_a2 = e2.target) == null ? void 0 : _a2.result) == null ? void 0 : _b2.split(",")[1];
2670
+ if (base64String) {
2671
+ resolve({
2672
+ contentType: file.type,
2673
+ bytes: base64String
2674
+ });
2675
+ } else {
2676
+ resolve(null);
2677
+ }
2678
+ };
2679
+ reader.onerror = reject;
2680
+ reader.readAsDataURL(file);
2681
+ });
2682
+ });
2683
+ try {
2684
+ const loadedImages = (yield Promise.all(imagePromises)).filter((img) => img !== null);
2685
+ setSelectedImages((prev) => [...prev, ...loadedImages]);
2686
+ } catch (error) {
2687
+ triggerChatError(error, "processClipboardImages", error);
2688
+ console.error("Error processing pasted images:", error);
2689
+ }
2690
+ });
2691
+ document.addEventListener("paste", handlePaste);
2692
+ return () => document.removeEventListener("paste", handlePaste);
2693
+ }, [imageUploadsEnabled, triggerChatError]);
2694
+ (0, import_react15.useEffect)(() => {
2695
+ if (!(additionalInstructions == null ? void 0 : additionalInstructions.length)) {
2696
+ setChatInstructions(instructions || "");
2697
+ return;
2698
+ }
2699
+ const combinedAdditionalInstructions = [
2700
+ instructions,
2701
+ "Additionally, follow these instructions:",
2702
+ ...additionalInstructions.map((instruction) => `- ${instruction}`)
2703
+ ];
2704
+ setChatInstructions(combinedAdditionalInstructions.join("\n") || "");
2705
+ }, [instructions, additionalInstructions]);
2706
+ const {
2707
+ messages,
2708
+ isLoading,
2709
+ sendMessage,
2710
+ stopGeneration,
2711
+ reloadMessages,
2712
+ suggestions: currentSuggestions,
2713
+ isLoadingSuggestions,
2714
+ agent
2715
+ } = (0, import_react_core9.useCopilotChatInternal)({
2716
+ suggestions,
2717
+ onInProgress,
2718
+ onSubmitMessage,
2719
+ onStopGeneration,
2720
+ onReloadMessages
2721
+ });
2722
+ const prevIsLoading = (0, import_react15.useRef)(isLoading);
2723
+ (0, import_react15.useEffect)(() => {
2724
+ if (prevIsLoading.current !== isLoading) {
2725
+ if (isLoading) {
2726
+ triggerObservabilityHook("onChatStarted");
2727
+ } else {
2728
+ triggerObservabilityHook("onChatStopped");
2729
+ }
2730
+ prevIsLoading.current = isLoading;
2731
+ }
2732
+ }, [isLoading, triggerObservabilityHook]);
2733
+ const handleSendMessage = (text) => {
2734
+ const images = selectedImages;
2735
+ setSelectedImages([]);
2736
+ if (fileInputRef.current) {
2737
+ fileInputRef.current.value = "";
2738
+ }
2739
+ triggerObservabilityHook("onMessageSent", text);
2740
+ return sendMessage({
2741
+ id: (0, import_shared3.randomUUID)(),
2742
+ content: text,
2743
+ role: "user"
2744
+ });
2745
+ };
2746
+ const chatContext = import_react15.default.useContext(ChatContext);
2747
+ const isVisible = chatContext ? chatContext.open : true;
2748
+ const handleRegenerate = (messageId) => {
2749
+ if (onRegenerate) {
2750
+ onRegenerate(messageId);
2751
+ }
2752
+ triggerObservabilityHook("onMessageRegenerated", messageId);
2753
+ reloadMessages(messageId);
2754
+ };
2755
+ const handleCopy = (message) => {
2756
+ if (onCopy) {
2757
+ onCopy(message);
2758
+ }
2759
+ triggerObservabilityHook("onMessageCopied", message);
2760
+ };
2761
+ const handleImageUpload = (event) => __async(this, null, function* () {
2762
+ if (!event.target.files || event.target.files.length === 0) {
2763
+ return;
2764
+ }
2765
+ const files = Array.from(event.target.files).filter((file) => file.type.startsWith("image/"));
2766
+ if (files.length === 0)
2767
+ return;
2768
+ const fileReadPromises = files.map((file) => {
2769
+ return new Promise((resolve, reject) => {
2770
+ const reader = new FileReader();
2771
+ reader.onload = (e) => {
2772
+ var _a, _b;
2773
+ const base64String = ((_b = (_a = e.target) == null ? void 0 : _a.result) == null ? void 0 : _b.split(",")[1]) || "";
2774
+ if (base64String) {
2775
+ resolve({
2776
+ contentType: file.type,
2777
+ bytes: base64String
2778
+ });
2779
+ }
2780
+ };
2781
+ reader.onerror = reject;
2782
+ reader.readAsDataURL(file);
2783
+ });
2784
+ });
2785
+ try {
2786
+ const loadedImages = yield Promise.all(fileReadPromises);
2787
+ setSelectedImages((prev) => [...prev, ...loadedImages]);
2788
+ } catch (error) {
2789
+ triggerChatError(error, "processUploadedImages", error);
2790
+ console.error("Error reading files:", error);
2791
+ }
2792
+ });
2793
+ const removeSelectedImage = (index) => {
2794
+ setSelectedImages((prev) => prev.filter((_, i) => i !== index));
2795
+ };
2796
+ const handleThumbsUp = (message) => {
2797
+ if (onThumbsUp) {
2798
+ onThumbsUp(message);
2799
+ }
2800
+ setMessageFeedback((prev) => __spreadProps(__spreadValues({}, prev), {
2801
+ [message.id]: "thumbsUp"
2802
+ }));
2803
+ triggerObservabilityHook("onFeedbackGiven", message.id, "thumbsUp");
2804
+ };
2805
+ const handleThumbsDown = (message) => {
2806
+ if (onThumbsDown) {
2807
+ onThumbsDown(message);
2808
+ }
2809
+ setMessageFeedback((prev) => __spreadProps(__spreadValues({}, prev), {
2810
+ [message.id]: "thumbsDown"
2811
+ }));
2812
+ triggerObservabilityHook("onFeedbackGiven", message.id, "thumbsDown");
2813
+ };
2814
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(WrappedCopilotChat, { icons, labels, className, children: [
2815
+ chatError && renderError && renderError(__spreadProps(__spreadValues({}, chatError), {
2816
+ onDismiss: () => setChatError(null),
2817
+ onRetry: () => {
2818
+ setChatError(null);
2819
+ }
2820
+ })),
2821
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
2822
+ Messages2,
2823
+ {
2824
+ AssistantMessage: AssistantMessage2,
2825
+ UserMessage: UserMessage2,
2826
+ RenderMessage: RenderMessage2,
2827
+ messages,
2828
+ inProgress: isLoading,
2829
+ onRegenerate: handleRegenerate,
2830
+ onCopy: handleCopy,
2831
+ onThumbsUp: handleThumbsUp,
2832
+ onThumbsDown: handleThumbsDown,
2833
+ messageFeedback,
2834
+ markdownTagRenderers,
2835
+ ImageRenderer: ImageRenderer2,
2836
+ ErrorMessage,
2837
+ chatError,
2838
+ RenderTextMessage,
2839
+ RenderActionExecutionMessage,
2840
+ RenderAgentStateMessage,
2841
+ RenderResultMessage,
2842
+ RenderImageMessage,
2843
+ children: currentSuggestions.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
2844
+ RenderSuggestionsList,
2845
+ {
2846
+ onSuggestionClick: handleSendMessage,
2847
+ suggestions: currentSuggestions,
2848
+ isLoading: isLoadingSuggestions
2849
+ }
2850
+ )
2851
+ }
2852
+ ),
2853
+ imageUploadsEnabled && /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(import_jsx_runtime24.Fragment, { children: [
2854
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(ImageUploadQueue, { images: selectedImages, onRemoveImage: removeSelectedImage }),
2855
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
2856
+ "input",
2857
+ {
2858
+ type: "file",
2859
+ multiple: true,
2860
+ ref: fileInputRef,
2861
+ onChange: handleImageUpload,
2862
+ accept: inputFileAccept,
2863
+ style: { display: "none" }
2864
+ }
2865
+ )
2866
+ ] }),
2867
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
2868
+ Input2,
2869
+ {
2870
+ inProgress: isLoading,
2871
+ chatReady: Boolean(agent),
2872
+ onSend: handleSendMessage,
2873
+ isVisible,
2874
+ onStop: stopGeneration,
2875
+ onUpload: imageUploadsEnabled ? () => {
2876
+ var _a;
2877
+ return (_a = fileInputRef.current) == null ? void 0 : _a.click();
2878
+ } : void 0,
2879
+ hideStopButton
2880
+ }
2881
+ )
2882
+ ] });
2883
+ }
2884
+ function WrappedCopilotChat({
2885
+ children,
2886
+ icons,
2887
+ labels,
2888
+ className
2889
+ }) {
2890
+ const chatContext = import_react15.default.useContext(ChatContext);
2891
+ if (!chatContext) {
2892
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(ChatContextProvider, { icons, labels, open: true, setOpen: () => {
2893
+ }, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: `copilotKitChat ${className != null ? className : ""}`, children }) });
2894
+ }
2895
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_jsx_runtime24.Fragment, { children });
2896
+ }
2897
+
2898
+ // src/components/chat/Modal.tsx
2899
+ var import_react_core10 = require("@copilotkit/react-core");
2900
+ var import_shared4 = require("@copilotkit/shared");
2901
+ var import_jsx_runtime25 = require("react/jsx-runtime");
2902
+ var CopilotModalInner = (_a) => {
2903
+ var _b = _a, {
2904
+ observabilityHooks,
2905
+ onSetOpen,
2906
+ clickOutsideToClose,
2907
+ hitEscapeToClose,
2908
+ shortcut,
2909
+ className,
2910
+ children,
2911
+ Window: Window2,
2912
+ Button: Button2,
2913
+ Header: Header2
2914
+ } = _b, chatProps = __objRest(_b, [
2915
+ "observabilityHooks",
2916
+ "onSetOpen",
2917
+ "clickOutsideToClose",
2918
+ "hitEscapeToClose",
2919
+ "shortcut",
2920
+ "className",
2921
+ "children",
2922
+ "Window",
2923
+ "Button",
2924
+ "Header"
2925
+ ]);
2926
+ const { copilotApiConfig, setBannerError } = (0, import_react_core10.useCopilotContext)();
2927
+ const { publicApiKey } = copilotApiConfig;
2928
+ const triggerObservabilityHook = (0, import_react16.useCallback)(
2929
+ (hookName, ...args) => {
2930
+ if (publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks[hookName])) {
2931
+ observabilityHooks[hookName](...args);
2932
+ }
2933
+ if ((observabilityHooks == null ? void 0 : observabilityHooks[hookName]) && !publicApiKey) {
2934
+ setBannerError(
2935
+ new import_shared4.CopilotKitError({
2936
+ message: "observabilityHooks requires a publicApiKey to function.",
2937
+ code: import_shared4.CopilotKitErrorCode.MISSING_PUBLIC_API_KEY_ERROR,
2938
+ severity: import_shared4.Severity.CRITICAL,
2939
+ visibility: import_shared4.ErrorVisibility.BANNER
2940
+ })
2941
+ );
2942
+ import_shared4.styledConsole.publicApiKeyRequired("observabilityHooks");
2943
+ }
2944
+ },
2945
+ [publicApiKey, observabilityHooks, setBannerError]
2946
+ );
2947
+ const { open } = useChatContext();
2948
+ const prevOpen = (0, import_react16.useRef)(open);
2949
+ (0, import_react16.useEffect)(() => {
2950
+ if (prevOpen.current !== open) {
2951
+ onSetOpen == null ? void 0 : onSetOpen(open);
2952
+ if (open) {
2953
+ triggerObservabilityHook("onChatExpanded");
2954
+ } else {
2955
+ triggerObservabilityHook("onChatMinimized");
2956
+ }
2957
+ prevOpen.current = open;
2958
+ }
2959
+ }, [open, onSetOpen, triggerObservabilityHook]);
2960
+ const memoizedHeader = (0, import_react16.useMemo)(() => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Header2, {}), [Header2]);
2961
+ const memoizedChildren = (0, import_react16.useMemo)(() => children, [children]);
2962
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(import_jsx_runtime25.Fragment, { children: [
2963
+ memoizedChildren,
2964
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className, children: [
2965
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Button2, {}),
2966
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
2967
+ Window2,
2968
+ {
2969
+ clickOutsideToClose,
2970
+ shortcut,
2971
+ hitEscapeToClose,
2972
+ children: [
2973
+ memoizedHeader,
2974
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(CopilotChat, __spreadProps(__spreadValues({}, chatProps), { observabilityHooks }))
2975
+ ]
2976
+ }
2977
+ )
2978
+ ] })
2979
+ ] });
2980
+ };
2981
+ var CopilotModal = (_a) => {
2982
+ var _b = _a, {
2983
+ instructions,
2984
+ defaultOpen = false,
2985
+ clickOutsideToClose = true,
2986
+ hitEscapeToClose = true,
2987
+ onSetOpen,
2988
+ onSubmitMessage,
2989
+ onStopGeneration,
2990
+ onReloadMessages,
2991
+ shortcut = "/",
2992
+ icons,
2993
+ labels,
2994
+ makeSystemMessage,
2995
+ onInProgress,
2996
+ Window: Window2 = Window,
2997
+ Button: Button2 = Button,
2998
+ Header: Header2 = Header,
2999
+ Messages: Messages2 = Messages,
3000
+ Input: Input2 = Input,
3001
+ AssistantMessage: AssistantMessage2 = AssistantMessage,
3002
+ UserMessage: UserMessage2 = UserMessage,
3003
+ onThumbsUp,
3004
+ onThumbsDown,
3005
+ onCopy,
3006
+ onRegenerate,
3007
+ markdownTagRenderers,
3008
+ className,
3009
+ children,
3010
+ observabilityHooks
3011
+ } = _b, props = __objRest(_b, [
3012
+ "instructions",
3013
+ "defaultOpen",
3014
+ "clickOutsideToClose",
3015
+ "hitEscapeToClose",
3016
+ "onSetOpen",
3017
+ "onSubmitMessage",
3018
+ "onStopGeneration",
3019
+ "onReloadMessages",
3020
+ "shortcut",
3021
+ "icons",
3022
+ "labels",
3023
+ "makeSystemMessage",
3024
+ "onInProgress",
3025
+ "Window",
3026
+ "Button",
3027
+ "Header",
3028
+ "Messages",
3029
+ "Input",
3030
+ "AssistantMessage",
3031
+ "UserMessage",
3032
+ "onThumbsUp",
3033
+ "onThumbsDown",
3034
+ "onCopy",
3035
+ "onRegenerate",
3036
+ "markdownTagRenderers",
3037
+ "className",
3038
+ "children",
3039
+ "observabilityHooks"
3040
+ ]);
3041
+ const [openState, setOpenState] = import_react16.default.useState(defaultOpen);
3042
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ChatContextProvider, { icons, labels, open: openState, setOpen: setOpenState, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
3043
+ CopilotModalInner,
3044
+ __spreadProps(__spreadValues({
3045
+ observabilityHooks,
3046
+ onSetOpen,
3047
+ clickOutsideToClose: clickOutsideToClose != null ? clickOutsideToClose : true,
3048
+ hitEscapeToClose: hitEscapeToClose != null ? hitEscapeToClose : true,
3049
+ shortcut: shortcut != null ? shortcut : "/",
3050
+ className,
3051
+ Window: Window2,
3052
+ Button: Button2,
3053
+ Header: Header2,
3054
+ instructions,
3055
+ onSubmitMessage,
3056
+ onStopGeneration,
3057
+ onReloadMessages,
3058
+ makeSystemMessage,
3059
+ onInProgress,
3060
+ Messages: Messages2,
3061
+ Input: Input2,
3062
+ AssistantMessage: AssistantMessage2,
3063
+ UserMessage: UserMessage2,
3064
+ onThumbsUp,
3065
+ onThumbsDown,
3066
+ onCopy,
3067
+ onRegenerate,
3068
+ markdownTagRenderers
3069
+ }, props), {
3070
+ children
3071
+ })
3072
+ ) });
3073
+ };
3074
+
3075
+ // src/components/chat/Sidebar.tsx
3076
+ var import_jsx_runtime26 = require("react/jsx-runtime");
3077
+ function CopilotSidebar(props) {
3078
+ props = __spreadProps(__spreadValues({}, props), {
3079
+ className: props.className ? props.className + " copilotKitSidebar" : "copilotKitSidebar"
3080
+ });
3081
+ const [expandedClassName, setExpandedClassName] = (0, import_react17.useState)(
3082
+ props.defaultOpen ? "sidebarExpanded" : ""
3083
+ );
3084
+ const onSetOpen = (open) => {
3085
+ var _a;
3086
+ (_a = props.onSetOpen) == null ? void 0 : _a.call(props, open);
3087
+ setExpandedClassName(open ? "sidebarExpanded" : "");
3088
+ };
3089
+ return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: `copilotKitSidebarContentWrapper ${expandedClassName}`, children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(CopilotModal, __spreadProps(__spreadValues(__spreadValues({}, props), { onSetOpen }), { children: props.children })) });
3090
+ }
3091
+ // Annotate the CommonJS export names for ESM import in node:
3092
+ 0 && (module.exports = {
3093
+ CopilotSidebar
3094
+ });
3095
+ //# sourceMappingURL=Sidebar.js.map