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