@copilotkitnext/react 0.0.22-alpha.3 → 0.0.22-alpha.5

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 (423) hide show
  1. package/dist/index.d.mts +635 -46
  2. package/dist/index.d.ts +635 -46
  3. package/dist/index.js +325 -22
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.mjs +4286 -109
  6. package/dist/index.mjs.map +1 -1
  7. package/package.json +6 -6
  8. package/dist/chunk-32YJ5VJ4.mjs +0 -157
  9. package/dist/chunk-32YJ5VJ4.mjs.map +0 -1
  10. package/dist/chunk-36HFWACS.mjs +0 -1
  11. package/dist/chunk-36HFWACS.mjs.map +0 -1
  12. package/dist/chunk-3TA5QBSZ.mjs +0 -122
  13. package/dist/chunk-3TA5QBSZ.mjs.map +0 -1
  14. package/dist/chunk-46BZRXWT.mjs +0 -16
  15. package/dist/chunk-46BZRXWT.mjs.map +0 -1
  16. package/dist/chunk-4UDBR75C.mjs +0 -106
  17. package/dist/chunk-4UDBR75C.mjs.map +0 -1
  18. package/dist/chunk-4XJK5IVQ.mjs +0 -83
  19. package/dist/chunk-4XJK5IVQ.mjs.map +0 -1
  20. package/dist/chunk-5AAT4Z3C.mjs +0 -107
  21. package/dist/chunk-5AAT4Z3C.mjs.map +0 -1
  22. package/dist/chunk-5JNWVLQI.mjs +0 -72
  23. package/dist/chunk-5JNWVLQI.mjs.map +0 -1
  24. package/dist/chunk-5SC3CO5Q.mjs +0 -69
  25. package/dist/chunk-5SC3CO5Q.mjs.map +0 -1
  26. package/dist/chunk-6VUKDHOD.mjs +0 -1
  27. package/dist/chunk-6VUKDHOD.mjs.map +0 -1
  28. package/dist/chunk-AEFM73CL.mjs +0 -32
  29. package/dist/chunk-AEFM73CL.mjs.map +0 -1
  30. package/dist/chunk-AI3Z3CHN.mjs +0 -97
  31. package/dist/chunk-AI3Z3CHN.mjs.map +0 -1
  32. package/dist/chunk-AXFRCGH6.mjs +0 -107
  33. package/dist/chunk-AXFRCGH6.mjs.map +0 -1
  34. package/dist/chunk-BT6C5OPU.mjs +0 -278
  35. package/dist/chunk-BT6C5OPU.mjs.map +0 -1
  36. package/dist/chunk-CGLGXQAU.mjs +0 -78
  37. package/dist/chunk-CGLGXQAU.mjs.map +0 -1
  38. package/dist/chunk-CSHBUHRW.mjs +0 -69
  39. package/dist/chunk-CSHBUHRW.mjs.map +0 -1
  40. package/dist/chunk-CZ3GI3IF.mjs +0 -283
  41. package/dist/chunk-CZ3GI3IF.mjs.map +0 -1
  42. package/dist/chunk-DVUQO72Z.mjs +0 -1
  43. package/dist/chunk-DVUQO72Z.mjs.map +0 -1
  44. package/dist/chunk-E4HD4M7R.mjs +0 -76
  45. package/dist/chunk-E4HD4M7R.mjs.map +0 -1
  46. package/dist/chunk-E56GYBP3.mjs +0 -101
  47. package/dist/chunk-E56GYBP3.mjs.map +0 -1
  48. package/dist/chunk-EJ5ZEAAN.mjs +0 -57
  49. package/dist/chunk-EJ5ZEAAN.mjs.map +0 -1
  50. package/dist/chunk-ETWJDCGE.mjs +0 -1
  51. package/dist/chunk-ETWJDCGE.mjs.map +0 -1
  52. package/dist/chunk-F43IPGPA.mjs +0 -311
  53. package/dist/chunk-F43IPGPA.mjs.map +0 -1
  54. package/dist/chunk-FIBK3DYE.mjs +0 -26
  55. package/dist/chunk-FIBK3DYE.mjs.map +0 -1
  56. package/dist/chunk-FVURPXQK.mjs +0 -45
  57. package/dist/chunk-FVURPXQK.mjs.map +0 -1
  58. package/dist/chunk-FZR2XQKR.mjs +0 -44
  59. package/dist/chunk-FZR2XQKR.mjs.map +0 -1
  60. package/dist/chunk-IA4CLXDM.mjs +0 -76
  61. package/dist/chunk-IA4CLXDM.mjs.map +0 -1
  62. package/dist/chunk-IH5VFJ4L.mjs +0 -60
  63. package/dist/chunk-IH5VFJ4L.mjs.map +0 -1
  64. package/dist/chunk-IICUCI5S.mjs +0 -43
  65. package/dist/chunk-IICUCI5S.mjs.map +0 -1
  66. package/dist/chunk-JLVGSNAO.mjs +0 -311
  67. package/dist/chunk-JLVGSNAO.mjs.map +0 -1
  68. package/dist/chunk-JWOIINVV.mjs +0 -237
  69. package/dist/chunk-JWOIINVV.mjs.map +0 -1
  70. package/dist/chunk-KCVDFZJX.mjs +0 -873
  71. package/dist/chunk-KCVDFZJX.mjs.map +0 -1
  72. package/dist/chunk-KPRUSQ3K.mjs +0 -1
  73. package/dist/chunk-KPRUSQ3K.mjs.map +0 -1
  74. package/dist/chunk-MWC5OV7Z.mjs +0 -1
  75. package/dist/chunk-MWC5OV7Z.mjs.map +0 -1
  76. package/dist/chunk-N5EP5OD5.mjs +0 -1
  77. package/dist/chunk-N5EP5OD5.mjs.map +0 -1
  78. package/dist/chunk-NASFZS3N.mjs +0 -43
  79. package/dist/chunk-NASFZS3N.mjs.map +0 -1
  80. package/dist/chunk-NB2GZAKG.mjs +0 -131
  81. package/dist/chunk-NB2GZAKG.mjs.map +0 -1
  82. package/dist/chunk-NB4DFAZH.mjs +0 -185
  83. package/dist/chunk-NB4DFAZH.mjs.map +0 -1
  84. package/dist/chunk-NNAYEAP2.mjs +0 -49
  85. package/dist/chunk-NNAYEAP2.mjs.map +0 -1
  86. package/dist/chunk-NNPKBGD6.mjs +0 -37
  87. package/dist/chunk-NNPKBGD6.mjs.map +0 -1
  88. package/dist/chunk-OMPVTGXH.mjs +0 -122
  89. package/dist/chunk-OMPVTGXH.mjs.map +0 -1
  90. package/dist/chunk-QFBM3ZT2.mjs +0 -45
  91. package/dist/chunk-QFBM3ZT2.mjs.map +0 -1
  92. package/dist/chunk-QJ6DZ645.mjs +0 -78
  93. package/dist/chunk-QJ6DZ645.mjs.map +0 -1
  94. package/dist/chunk-R5OLAA3L.mjs +0 -135
  95. package/dist/chunk-R5OLAA3L.mjs.map +0 -1
  96. package/dist/chunk-RF2CGPHQ.mjs +0 -215
  97. package/dist/chunk-RF2CGPHQ.mjs.map +0 -1
  98. package/dist/chunk-RGD2L3Z4.mjs +0 -96
  99. package/dist/chunk-RGD2L3Z4.mjs.map +0 -1
  100. package/dist/chunk-RK5P2LG6.mjs +0 -57
  101. package/dist/chunk-RK5P2LG6.mjs.map +0 -1
  102. package/dist/chunk-RRXDJCXI.mjs +0 -60
  103. package/dist/chunk-RRXDJCXI.mjs.map +0 -1
  104. package/dist/chunk-SPDE34WC.mjs +0 -283
  105. package/dist/chunk-SPDE34WC.mjs.map +0 -1
  106. package/dist/chunk-TAUOEJH2.mjs +0 -120
  107. package/dist/chunk-TAUOEJH2.mjs.map +0 -1
  108. package/dist/chunk-TKFOXPXF.mjs +0 -157
  109. package/dist/chunk-TKFOXPXF.mjs.map +0 -1
  110. package/dist/chunk-UOX5D73C.mjs +0 -22
  111. package/dist/chunk-UOX5D73C.mjs.map +0 -1
  112. package/dist/chunk-US4KNAAV.mjs +0 -1
  113. package/dist/chunk-US4KNAAV.mjs.map +0 -1
  114. package/dist/chunk-UZB3CTOY.mjs +0 -873
  115. package/dist/chunk-UZB3CTOY.mjs.map +0 -1
  116. package/dist/chunk-VBI6JXPC.mjs +0 -1
  117. package/dist/chunk-VBI6JXPC.mjs.map +0 -1
  118. package/dist/chunk-VE3SBLU7.mjs +0 -215
  119. package/dist/chunk-VE3SBLU7.mjs.map +0 -1
  120. package/dist/chunk-VUHFLJWI.mjs +0 -185
  121. package/dist/chunk-VUHFLJWI.mjs.map +0 -1
  122. package/dist/chunk-VVAXSF3M.mjs +0 -61
  123. package/dist/chunk-VVAXSF3M.mjs.map +0 -1
  124. package/dist/chunk-W5DUKRCI.mjs +0 -97
  125. package/dist/chunk-W5DUKRCI.mjs.map +0 -1
  126. package/dist/chunk-WNRDFAZ5.mjs +0 -22
  127. package/dist/chunk-WNRDFAZ5.mjs.map +0 -1
  128. package/dist/chunk-XO4IRKSC.mjs +0 -11
  129. package/dist/chunk-XO4IRKSC.mjs.map +0 -1
  130. package/dist/chunk-XU5CEPYQ.mjs +0 -75
  131. package/dist/chunk-XU5CEPYQ.mjs.map +0 -1
  132. package/dist/chunk-YPH4BHOY.mjs +0 -39
  133. package/dist/chunk-YPH4BHOY.mjs.map +0 -1
  134. package/dist/chunk-YVPPF62K.mjs +0 -32
  135. package/dist/chunk-YVPPF62K.mjs.map +0 -1
  136. package/dist/chunk-YZUPVMHC.mjs +0 -1
  137. package/dist/chunk-YZUPVMHC.mjs.map +0 -1
  138. package/dist/chunk-Z3OIGQCZ.mjs +0 -75
  139. package/dist/chunk-Z3OIGQCZ.mjs.map +0 -1
  140. package/dist/chunk-ZIDT52TM.mjs +0 -131
  141. package/dist/chunk-ZIDT52TM.mjs.map +0 -1
  142. package/dist/components/CopilotKitInspector.d.mts +0 -13
  143. package/dist/components/CopilotKitInspector.d.ts +0 -13
  144. package/dist/components/CopilotKitInspector.js +0 -69
  145. package/dist/components/CopilotKitInspector.js.map +0 -1
  146. package/dist/components/CopilotKitInspector.mjs +0 -7
  147. package/dist/components/CopilotKitInspector.mjs.map +0 -1
  148. package/dist/components/WildcardToolCallRender.d.mts +0 -7
  149. package/dist/components/WildcardToolCallRender.d.ts +0 -7
  150. package/dist/components/WildcardToolCallRender.js +0 -106
  151. package/dist/components/WildcardToolCallRender.js.map +0 -1
  152. package/dist/components/WildcardToolCallRender.mjs +0 -8
  153. package/dist/components/WildcardToolCallRender.mjs.map +0 -1
  154. package/dist/components/chat/CopilotChat.d.mts +0 -30
  155. package/dist/components/chat/CopilotChat.d.ts +0 -30
  156. package/dist/components/chat/CopilotChat.js +0 -2934
  157. package/dist/components/chat/CopilotChat.js.map +0 -1
  158. package/dist/components/chat/CopilotChat.mjs +0 -37
  159. package/dist/components/chat/CopilotChat.mjs.map +0 -1
  160. package/dist/components/chat/CopilotChatAssistantMessage.d.mts +0 -45
  161. package/dist/components/chat/CopilotChatAssistantMessage.d.ts +0 -45
  162. package/dist/components/chat/CopilotChatAssistantMessage.js +0 -735
  163. package/dist/components/chat/CopilotChatAssistantMessage.js.map +0 -1
  164. package/dist/components/chat/CopilotChatAssistantMessage.mjs +0 -29
  165. package/dist/components/chat/CopilotChatAssistantMessage.mjs.map +0 -1
  166. package/dist/components/chat/CopilotChatAudioRecorder.d.mts +0 -11
  167. package/dist/components/chat/CopilotChatAudioRecorder.d.ts +0 -11
  168. package/dist/components/chat/CopilotChatAudioRecorder.js +0 -131
  169. package/dist/components/chat/CopilotChatAudioRecorder.js.map +0 -1
  170. package/dist/components/chat/CopilotChatAudioRecorder.mjs +0 -9
  171. package/dist/components/chat/CopilotChatAudioRecorder.mjs.map +0 -1
  172. package/dist/components/chat/CopilotChatInput.d.mts +0 -67
  173. package/dist/components/chat/CopilotChatInput.d.ts +0 -67
  174. package/dist/components/chat/CopilotChatInput.js +0 -1305
  175. package/dist/components/chat/CopilotChatInput.js.map +0 -1
  176. package/dist/components/chat/CopilotChatInput.mjs +0 -16
  177. package/dist/components/chat/CopilotChatInput.mjs.map +0 -1
  178. package/dist/components/chat/CopilotChatMessageView.d.mts +0 -29
  179. package/dist/components/chat/CopilotChatMessageView.d.ts +0 -29
  180. package/dist/components/chat/CopilotChatMessageView.js +0 -1164
  181. package/dist/components/chat/CopilotChatMessageView.js.map +0 -1
  182. package/dist/components/chat/CopilotChatMessageView.mjs +0 -31
  183. package/dist/components/chat/CopilotChatMessageView.mjs.map +0 -1
  184. package/dist/components/chat/CopilotChatSuggestionPill.d.mts +0 -11
  185. package/dist/components/chat/CopilotChatSuggestionPill.d.ts +0 -11
  186. package/dist/components/chat/CopilotChatSuggestionPill.js +0 -76
  187. package/dist/components/chat/CopilotChatSuggestionPill.js.map +0 -1
  188. package/dist/components/chat/CopilotChatSuggestionPill.mjs +0 -10
  189. package/dist/components/chat/CopilotChatSuggestionPill.mjs.map +0 -1
  190. package/dist/components/chat/CopilotChatSuggestionView.d.mts +0 -33
  191. package/dist/components/chat/CopilotChatSuggestionView.d.ts +0 -33
  192. package/dist/components/chat/CopilotChatSuggestionView.js +0 -179
  193. package/dist/components/chat/CopilotChatSuggestionView.js.map +0 -1
  194. package/dist/components/chat/CopilotChatSuggestionView.mjs +0 -12
  195. package/dist/components/chat/CopilotChatSuggestionView.mjs.map +0 -1
  196. package/dist/components/chat/CopilotChatToggleButton.d.mts +0 -14
  197. package/dist/components/chat/CopilotChatToggleButton.d.ts +0 -14
  198. package/dist/components/chat/CopilotChatToggleButton.js +0 -222
  199. package/dist/components/chat/CopilotChatToggleButton.js.map +0 -1
  200. package/dist/components/chat/CopilotChatToggleButton.mjs +0 -16
  201. package/dist/components/chat/CopilotChatToggleButton.mjs.map +0 -1
  202. package/dist/components/chat/CopilotChatToolCallsView.d.mts +0 -10
  203. package/dist/components/chat/CopilotChatToolCallsView.d.ts +0 -10
  204. package/dist/components/chat/CopilotChatToolCallsView.js +0 -264
  205. package/dist/components/chat/CopilotChatToolCallsView.js.map +0 -1
  206. package/dist/components/chat/CopilotChatToolCallsView.mjs +0 -24
  207. package/dist/components/chat/CopilotChatToolCallsView.mjs.map +0 -1
  208. package/dist/components/chat/CopilotChatUserMessage.d.mts +0 -52
  209. package/dist/components/chat/CopilotChatUserMessage.d.ts +0 -52
  210. package/dist/components/chat/CopilotChatUserMessage.js +0 -523
  211. package/dist/components/chat/CopilotChatUserMessage.js.map +0 -1
  212. package/dist/components/chat/CopilotChatUserMessage.mjs +0 -14
  213. package/dist/components/chat/CopilotChatUserMessage.mjs.map +0 -1
  214. package/dist/components/chat/CopilotChatView.d.mts +0 -54
  215. package/dist/components/chat/CopilotChatView.d.ts +0 -54
  216. package/dist/components/chat/CopilotChatView.js +0 -2640
  217. package/dist/components/chat/CopilotChatView.js.map +0 -1
  218. package/dist/components/chat/CopilotChatView.mjs +0 -38
  219. package/dist/components/chat/CopilotChatView.mjs.map +0 -1
  220. package/dist/components/chat/CopilotModalHeader.d.mts +0 -22
  221. package/dist/components/chat/CopilotModalHeader.d.ts +0 -22
  222. package/dist/components/chat/CopilotModalHeader.js +0 -186
  223. package/dist/components/chat/CopilotModalHeader.js.map +0 -1
  224. package/dist/components/chat/CopilotModalHeader.mjs +0 -12
  225. package/dist/components/chat/CopilotModalHeader.mjs.map +0 -1
  226. package/dist/components/chat/CopilotPopup.d.mts +0 -33
  227. package/dist/components/chat/CopilotPopup.d.ts +0 -33
  228. package/dist/components/chat/CopilotPopup.js +0 -3343
  229. package/dist/components/chat/CopilotPopup.js.map +0 -1
  230. package/dist/components/chat/CopilotPopup.mjs +0 -43
  231. package/dist/components/chat/CopilotPopup.mjs.map +0 -1
  232. package/dist/components/chat/CopilotPopupView.d.mts +0 -30
  233. package/dist/components/chat/CopilotPopupView.d.ts +0 -30
  234. package/dist/components/chat/CopilotPopupView.js +0 -3003
  235. package/dist/components/chat/CopilotPopupView.js.map +0 -1
  236. package/dist/components/chat/CopilotPopupView.mjs +0 -41
  237. package/dist/components/chat/CopilotPopupView.mjs.map +0 -1
  238. package/dist/components/chat/CopilotSidebar.d.mts +0 -31
  239. package/dist/components/chat/CopilotSidebar.d.ts +0 -31
  240. package/dist/components/chat/CopilotSidebar.js +0 -3266
  241. package/dist/components/chat/CopilotSidebar.js.map +0 -1
  242. package/dist/components/chat/CopilotSidebar.mjs +0 -43
  243. package/dist/components/chat/CopilotSidebar.mjs.map +0 -1
  244. package/dist/components/chat/CopilotSidebarView.d.mts +0 -28
  245. package/dist/components/chat/CopilotSidebarView.d.ts +0 -28
  246. package/dist/components/chat/CopilotSidebarView.js +0 -2941
  247. package/dist/components/chat/CopilotSidebarView.js.map +0 -1
  248. package/dist/components/chat/CopilotSidebarView.mjs +0 -41
  249. package/dist/components/chat/CopilotSidebarView.mjs.map +0 -1
  250. package/dist/components/chat/index.d.mts +0 -23
  251. package/dist/components/chat/index.d.ts +0 -23
  252. package/dist/components/chat/index.js +0 -3503
  253. package/dist/components/chat/index.js.map +0 -1
  254. package/dist/components/chat/index.mjs +0 -95
  255. package/dist/components/chat/index.mjs.map +0 -1
  256. package/dist/components/index.d.mts +0 -29
  257. package/dist/components/index.d.ts +0 -29
  258. package/dist/components/index.js +0 -3583
  259. package/dist/components/index.js.map +0 -1
  260. package/dist/components/index.mjs +0 -104
  261. package/dist/components/index.mjs.map +0 -1
  262. package/dist/components/ui/button.d.mts +0 -14
  263. package/dist/components/ui/button.d.ts +0 -14
  264. package/dist/components/ui/button.js +0 -150
  265. package/dist/components/ui/button.js.map +0 -1
  266. package/dist/components/ui/button.mjs +0 -10
  267. package/dist/components/ui/button.mjs.map +0 -1
  268. package/dist/components/ui/dropdown-menu.d.mts +0 -28
  269. package/dist/components/ui/dropdown-menu.d.ts +0 -28
  270. package/dist/components/ui/dropdown-menu.js +0 -291
  271. package/dist/components/ui/dropdown-menu.js.map +0 -1
  272. package/dist/components/ui/dropdown-menu.mjs +0 -37
  273. package/dist/components/ui/dropdown-menu.mjs.map +0 -1
  274. package/dist/components/ui/tooltip.d.mts +0 -10
  275. package/dist/components/ui/tooltip.d.ts +0 -10
  276. package/dist/components/ui/tooltip.js +0 -103
  277. package/dist/components/ui/tooltip.js.map +0 -1
  278. package/dist/components/ui/tooltip.mjs +0 -14
  279. package/dist/components/ui/tooltip.mjs.map +0 -1
  280. package/dist/hooks/index.d.mts +0 -19
  281. package/dist/hooks/index.d.ts +0 -19
  282. package/dist/hooks/index.js +0 -691
  283. package/dist/hooks/index.js.map +0 -1
  284. package/dist/hooks/index.mjs +0 -45
  285. package/dist/hooks/index.mjs.map +0 -1
  286. package/dist/hooks/use-agent-context.d.mts +0 -5
  287. package/dist/hooks/use-agent-context.d.ts +0 -5
  288. package/dist/hooks/use-agent-context.js +0 -116
  289. package/dist/hooks/use-agent-context.js.map +0 -1
  290. package/dist/hooks/use-agent-context.mjs +0 -10
  291. package/dist/hooks/use-agent-context.mjs.map +0 -1
  292. package/dist/hooks/use-agent.d.mts +0 -16
  293. package/dist/hooks/use-agent.d.ts +0 -16
  294. package/dist/hooks/use-agent.js +0 -171
  295. package/dist/hooks/use-agent.js.map +0 -1
  296. package/dist/hooks/use-agent.mjs +0 -12
  297. package/dist/hooks/use-agent.mjs.map +0 -1
  298. package/dist/hooks/use-configure-suggestions.d.mts +0 -13
  299. package/dist/hooks/use-configure-suggestions.d.ts +0 -13
  300. package/dist/hooks/use-configure-suggestions.js +0 -232
  301. package/dist/hooks/use-configure-suggestions.js.map +0 -1
  302. package/dist/hooks/use-configure-suggestions.mjs +0 -11
  303. package/dist/hooks/use-configure-suggestions.mjs.map +0 -1
  304. package/dist/hooks/use-frontend-tool.d.mts +0 -8
  305. package/dist/hooks/use-frontend-tool.d.ts +0 -8
  306. package/dist/hooks/use-frontend-tool.js +0 -137
  307. package/dist/hooks/use-frontend-tool.js.map +0 -1
  308. package/dist/hooks/use-frontend-tool.mjs +0 -10
  309. package/dist/hooks/use-frontend-tool.mjs.map +0 -1
  310. package/dist/hooks/use-human-in-the-loop.d.mts +0 -7
  311. package/dist/hooks/use-human-in-the-loop.d.ts +0 -7
  312. package/dist/hooks/use-human-in-the-loop.js +0 -206
  313. package/dist/hooks/use-human-in-the-loop.js.map +0 -1
  314. package/dist/hooks/use-human-in-the-loop.mjs +0 -11
  315. package/dist/hooks/use-human-in-the-loop.mjs.map +0 -1
  316. package/dist/hooks/use-keyboard-height.d.mts +0 -15
  317. package/dist/hooks/use-keyboard-height.d.ts +0 -15
  318. package/dist/hooks/use-keyboard-height.js +0 -68
  319. package/dist/hooks/use-keyboard-height.js.map +0 -1
  320. package/dist/hooks/use-keyboard-height.mjs +0 -7
  321. package/dist/hooks/use-keyboard-height.mjs.map +0 -1
  322. package/dist/hooks/use-render-activity-message.d.mts +0 -5
  323. package/dist/hooks/use-render-activity-message.d.ts +0 -5
  324. package/dist/hooks/use-render-activity-message.js +0 -158
  325. package/dist/hooks/use-render-activity-message.js.map +0 -1
  326. package/dist/hooks/use-render-activity-message.mjs +0 -12
  327. package/dist/hooks/use-render-activity-message.mjs.map +0 -1
  328. package/dist/hooks/use-render-custom-messages.d.mts +0 -11
  329. package/dist/hooks/use-render-custom-messages.d.ts +0 -11
  330. package/dist/hooks/use-render-custom-messages.js +0 -170
  331. package/dist/hooks/use-render-custom-messages.js.map +0 -1
  332. package/dist/hooks/use-render-custom-messages.mjs +0 -12
  333. package/dist/hooks/use-render-custom-messages.mjs.map +0 -1
  334. package/dist/hooks/use-render-tool-call.d.mts +0 -16
  335. package/dist/hooks/use-render-tool-call.d.ts +0 -16
  336. package/dist/hooks/use-render-tool-call.js +0 -208
  337. package/dist/hooks/use-render-tool-call.js.map +0 -1
  338. package/dist/hooks/use-render-tool-call.mjs +0 -11
  339. package/dist/hooks/use-render-tool-call.mjs.map +0 -1
  340. package/dist/hooks/use-suggestions.d.mts +0 -14
  341. package/dist/hooks/use-suggestions.d.ts +0 -14
  342. package/dist/hooks/use-suggestions.js +0 -176
  343. package/dist/hooks/use-suggestions.js.map +0 -1
  344. package/dist/hooks/use-suggestions.mjs +0 -11
  345. package/dist/hooks/use-suggestions.mjs.map +0 -1
  346. package/dist/lib/react-core.d.mts +0 -33
  347. package/dist/lib/react-core.d.ts +0 -33
  348. package/dist/lib/react-core.js +0 -73
  349. package/dist/lib/react-core.js.map +0 -1
  350. package/dist/lib/react-core.mjs +0 -7
  351. package/dist/lib/react-core.mjs.map +0 -1
  352. package/dist/lib/slots.d.mts +0 -16
  353. package/dist/lib/slots.d.ts +0 -16
  354. package/dist/lib/slots.js +0 -60
  355. package/dist/lib/slots.js.map +0 -1
  356. package/dist/lib/slots.mjs +0 -7
  357. package/dist/lib/slots.mjs.map +0 -1
  358. package/dist/lib/utils.d.mts +0 -5
  359. package/dist/lib/utils.d.ts +0 -5
  360. package/dist/lib/utils.js +0 -35
  361. package/dist/lib/utils.js.map +0 -1
  362. package/dist/lib/utils.mjs +0 -7
  363. package/dist/lib/utils.mjs.map +0 -1
  364. package/dist/providers/CopilotChatConfigurationProvider.d.mts +0 -43
  365. package/dist/providers/CopilotChatConfigurationProvider.d.ts +0 -43
  366. package/dist/providers/CopilotChatConfigurationProvider.js +0 -109
  367. package/dist/providers/CopilotChatConfigurationProvider.js.map +0 -1
  368. package/dist/providers/CopilotChatConfigurationProvider.mjs +0 -11
  369. package/dist/providers/CopilotChatConfigurationProvider.mjs.map +0 -1
  370. package/dist/providers/CopilotKitProvider.d.mts +0 -33
  371. package/dist/providers/CopilotKitProvider.d.ts +0 -33
  372. package/dist/providers/CopilotKitProvider.js +0 -314
  373. package/dist/providers/CopilotKitProvider.js.map +0 -1
  374. package/dist/providers/CopilotKitProvider.mjs +0 -12
  375. package/dist/providers/CopilotKitProvider.mjs.map +0 -1
  376. package/dist/providers/index.d.mts +0 -13
  377. package/dist/providers/index.d.ts +0 -13
  378. package/dist/providers/index.js +0 -396
  379. package/dist/providers/index.js.map +0 -1
  380. package/dist/providers/index.mjs +0 -18
  381. package/dist/providers/index.mjs.map +0 -1
  382. package/dist/types/defineToolCallRenderer.d.mts +0 -41
  383. package/dist/types/defineToolCallRenderer.d.ts +0 -41
  384. package/dist/types/defineToolCallRenderer.js +0 -40
  385. package/dist/types/defineToolCallRenderer.js.map +0 -1
  386. package/dist/types/defineToolCallRenderer.mjs +0 -7
  387. package/dist/types/defineToolCallRenderer.mjs.map +0 -1
  388. package/dist/types/frontend-tool.d.mts +0 -9
  389. package/dist/types/frontend-tool.d.ts +0 -9
  390. package/dist/types/frontend-tool.js +0 -19
  391. package/dist/types/frontend-tool.js.map +0 -1
  392. package/dist/types/frontend-tool.mjs +0 -2
  393. package/dist/types/frontend-tool.mjs.map +0 -1
  394. package/dist/types/human-in-the-loop.d.mts +0 -29
  395. package/dist/types/human-in-the-loop.d.ts +0 -29
  396. package/dist/types/human-in-the-loop.js +0 -19
  397. package/dist/types/human-in-the-loop.js.map +0 -1
  398. package/dist/types/human-in-the-loop.mjs +0 -2
  399. package/dist/types/human-in-the-loop.mjs.map +0 -1
  400. package/dist/types/index.d.mts +0 -11
  401. package/dist/types/index.d.ts +0 -11
  402. package/dist/types/index.js +0 -42
  403. package/dist/types/index.js.map +0 -1
  404. package/dist/types/index.mjs +0 -13
  405. package/dist/types/index.mjs.map +0 -1
  406. package/dist/types/react-activity-message-renderer.d.mts +0 -29
  407. package/dist/types/react-activity-message-renderer.d.ts +0 -29
  408. package/dist/types/react-activity-message-renderer.js +0 -19
  409. package/dist/types/react-activity-message-renderer.js.map +0 -1
  410. package/dist/types/react-activity-message-renderer.mjs +0 -2
  411. package/dist/types/react-activity-message-renderer.mjs.map +0 -1
  412. package/dist/types/react-custom-message-renderer.d.mts +0 -18
  413. package/dist/types/react-custom-message-renderer.d.ts +0 -18
  414. package/dist/types/react-custom-message-renderer.js +0 -19
  415. package/dist/types/react-custom-message-renderer.js.map +0 -1
  416. package/dist/types/react-custom-message-renderer.mjs +0 -2
  417. package/dist/types/react-custom-message-renderer.mjs.map +0 -1
  418. package/dist/types/react-tool-call-renderer.d.mts +0 -30
  419. package/dist/types/react-tool-call-renderer.d.ts +0 -30
  420. package/dist/types/react-tool-call-renderer.js +0 -19
  421. package/dist/types/react-tool-call-renderer.js.map +0 -1
  422. package/dist/types/react-tool-call-renderer.mjs +0 -2
  423. package/dist/types/react-tool-call-renderer.mjs.map +0 -1
@@ -1,873 +0,0 @@
1
- import {
2
- CopilotChatAudioRecorder
3
- } from "./chunk-4UDBR75C.mjs";
4
- import {
5
- Button
6
- } from "./chunk-TAUOEJH2.mjs";
7
- import {
8
- DropdownMenu,
9
- DropdownMenuContent,
10
- DropdownMenuItem,
11
- DropdownMenuSeparator,
12
- DropdownMenuSub,
13
- DropdownMenuSubContent,
14
- DropdownMenuSubTrigger,
15
- DropdownMenuTrigger
16
- } from "./chunk-JWOIINVV.mjs";
17
- import {
18
- Tooltip,
19
- TooltipContent,
20
- TooltipTrigger
21
- } from "./chunk-VVAXSF3M.mjs";
22
- import {
23
- renderSlot
24
- } from "./chunk-FIBK3DYE.mjs";
25
- import {
26
- CopilotChatDefaultLabels,
27
- useCopilotChatConfiguration
28
- } from "./chunk-4XJK5IVQ.mjs";
29
-
30
- // src/components/chat/CopilotChatInput.tsx
31
- import {
32
- useState,
33
- useRef,
34
- useEffect,
35
- useLayoutEffect,
36
- forwardRef,
37
- useImperativeHandle,
38
- useCallback,
39
- useMemo
40
- } from "react";
41
- import { twMerge } from "tailwind-merge";
42
- import { Plus, Mic, ArrowUp, X, Check, Square } from "lucide-react";
43
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
44
- var SLASH_MENU_MAX_VISIBLE_ITEMS = 5;
45
- var SLASH_MENU_ITEM_HEIGHT_PX = 40;
46
- function CopilotChatInput({
47
- mode = "input",
48
- onSubmitMessage,
49
- onStop,
50
- isRunning = false,
51
- onStartTranscribe,
52
- onCancelTranscribe,
53
- onFinishTranscribe,
54
- onAddFile,
55
- onChange,
56
- value,
57
- toolsMenu,
58
- autoFocus = true,
59
- textArea,
60
- sendButton,
61
- startTranscribeButton,
62
- cancelTranscribeButton,
63
- finishTranscribeButton,
64
- addMenuButton,
65
- audioRecorder,
66
- children,
67
- className,
68
- ...props
69
- }) {
70
- const isControlled = value !== void 0;
71
- const [internalValue, setInternalValue] = useState(() => value ?? "");
72
- useEffect(() => {
73
- if (!isControlled && value !== void 0) {
74
- setInternalValue(value);
75
- }
76
- }, [isControlled, value]);
77
- const resolvedValue = isControlled ? value ?? "" : internalValue;
78
- const [layout, setLayout] = useState("compact");
79
- const ignoreResizeRef = useRef(false);
80
- const resizeEvaluationRafRef = useRef(null);
81
- const isExpanded = mode === "input" && layout === "expanded";
82
- const [commandQuery, setCommandQuery] = useState(null);
83
- const [slashHighlightIndex, setSlashHighlightIndex] = useState(0);
84
- const inputRef = useRef(null);
85
- const gridRef = useRef(null);
86
- const addButtonContainerRef = useRef(null);
87
- const actionsContainerRef = useRef(null);
88
- const audioRecorderRef = useRef(null);
89
- const slashMenuRef = useRef(null);
90
- const config = useCopilotChatConfiguration();
91
- const labels = config?.labels ?? CopilotChatDefaultLabels;
92
- const previousModalStateRef = useRef(void 0);
93
- const measurementCanvasRef = useRef(null);
94
- const measurementsRef = useRef({
95
- singleLineHeight: 0,
96
- maxHeight: 0,
97
- paddingLeft: 0,
98
- paddingRight: 0
99
- });
100
- const commandItems = useMemo(() => {
101
- const entries = [];
102
- const seen = /* @__PURE__ */ new Set();
103
- const pushItem = (item) => {
104
- if (item === "-") {
105
- return;
106
- }
107
- if (item.items && item.items.length > 0) {
108
- for (const nested of item.items) {
109
- pushItem(nested);
110
- }
111
- return;
112
- }
113
- if (!seen.has(item.label)) {
114
- seen.add(item.label);
115
- entries.push(item);
116
- }
117
- };
118
- if (onAddFile) {
119
- pushItem({
120
- label: labels.chatInputToolbarAddButtonLabel,
121
- action: onAddFile
122
- });
123
- }
124
- if (toolsMenu && toolsMenu.length > 0) {
125
- for (const item of toolsMenu) {
126
- pushItem(item);
127
- }
128
- }
129
- return entries;
130
- }, [labels.chatInputToolbarAddButtonLabel, onAddFile, toolsMenu]);
131
- const filteredCommands = useMemo(() => {
132
- if (commandQuery === null) {
133
- return [];
134
- }
135
- if (commandItems.length === 0) {
136
- return [];
137
- }
138
- const query = commandQuery.trim().toLowerCase();
139
- if (query.length === 0) {
140
- return commandItems;
141
- }
142
- const startsWith = [];
143
- const contains = [];
144
- for (const item of commandItems) {
145
- const label = item.label.toLowerCase();
146
- if (label.startsWith(query)) {
147
- startsWith.push(item);
148
- } else if (label.includes(query)) {
149
- contains.push(item);
150
- }
151
- }
152
- return [...startsWith, ...contains];
153
- }, [commandItems, commandQuery]);
154
- useEffect(() => {
155
- if (!autoFocus) {
156
- previousModalStateRef.current = config?.isModalOpen;
157
- return;
158
- }
159
- if (config?.isModalOpen && !previousModalStateRef.current) {
160
- inputRef.current?.focus();
161
- }
162
- previousModalStateRef.current = config?.isModalOpen;
163
- }, [config?.isModalOpen, autoFocus]);
164
- useEffect(() => {
165
- if (commandItems.length === 0 && commandQuery !== null) {
166
- setCommandQuery(null);
167
- }
168
- }, [commandItems.length, commandQuery]);
169
- const previousCommandQueryRef = useRef(null);
170
- useEffect(() => {
171
- if (commandQuery !== null && commandQuery !== previousCommandQueryRef.current && filteredCommands.length > 0) {
172
- setSlashHighlightIndex(0);
173
- }
174
- previousCommandQueryRef.current = commandQuery;
175
- }, [commandQuery, filteredCommands.length]);
176
- useEffect(() => {
177
- if (commandQuery === null) {
178
- setSlashHighlightIndex(0);
179
- return;
180
- }
181
- if (filteredCommands.length === 0) {
182
- setSlashHighlightIndex(-1);
183
- } else if (slashHighlightIndex < 0 || slashHighlightIndex >= filteredCommands.length) {
184
- setSlashHighlightIndex(0);
185
- }
186
- }, [commandQuery, filteredCommands, slashHighlightIndex]);
187
- useEffect(() => {
188
- const recorder = audioRecorderRef.current;
189
- if (!recorder) {
190
- return;
191
- }
192
- if (mode === "transcribe") {
193
- recorder.start().catch(console.error);
194
- } else {
195
- if (recorder.state === "recording") {
196
- recorder.stop().catch(console.error);
197
- }
198
- }
199
- }, [mode]);
200
- useEffect(() => {
201
- if (mode !== "input") {
202
- setLayout("compact");
203
- setCommandQuery(null);
204
- }
205
- }, [mode]);
206
- const updateSlashState = useCallback(
207
- (value2) => {
208
- if (commandItems.length === 0) {
209
- setCommandQuery((prev) => prev === null ? prev : null);
210
- return;
211
- }
212
- if (value2.startsWith("/")) {
213
- const firstLine = value2.split(/\r?\n/, 1)[0] ?? "";
214
- const query = firstLine.slice(1);
215
- setCommandQuery((prev) => prev === query ? prev : query);
216
- } else {
217
- setCommandQuery((prev) => prev === null ? prev : null);
218
- }
219
- },
220
- [commandItems.length]
221
- );
222
- useEffect(() => {
223
- updateSlashState(resolvedValue);
224
- }, [resolvedValue, updateSlashState]);
225
- const handleChange = (e) => {
226
- const nextValue = e.target.value;
227
- if (!isControlled) {
228
- setInternalValue(nextValue);
229
- }
230
- onChange?.(nextValue);
231
- updateSlashState(nextValue);
232
- };
233
- const clearInputValue = useCallback(() => {
234
- if (!isControlled) {
235
- setInternalValue("");
236
- }
237
- if (onChange) {
238
- onChange("");
239
- }
240
- }, [isControlled, onChange]);
241
- const runCommand = useCallback(
242
- (item) => {
243
- clearInputValue();
244
- item.action?.();
245
- setCommandQuery(null);
246
- setSlashHighlightIndex(0);
247
- requestAnimationFrame(() => {
248
- inputRef.current?.focus();
249
- });
250
- },
251
- [clearInputValue]
252
- );
253
- const handleKeyDown = (e) => {
254
- if (commandQuery !== null && mode === "input") {
255
- if (e.key === "ArrowDown") {
256
- if (filteredCommands.length > 0) {
257
- e.preventDefault();
258
- setSlashHighlightIndex((prev) => {
259
- if (filteredCommands.length === 0) {
260
- return prev;
261
- }
262
- const next = prev === -1 ? 0 : (prev + 1) % filteredCommands.length;
263
- return next;
264
- });
265
- }
266
- return;
267
- }
268
- if (e.key === "ArrowUp") {
269
- if (filteredCommands.length > 0) {
270
- e.preventDefault();
271
- setSlashHighlightIndex((prev) => {
272
- if (filteredCommands.length === 0) {
273
- return prev;
274
- }
275
- if (prev === -1) {
276
- return filteredCommands.length - 1;
277
- }
278
- return prev <= 0 ? filteredCommands.length - 1 : prev - 1;
279
- });
280
- }
281
- return;
282
- }
283
- if (e.key === "Enter") {
284
- const selected = slashHighlightIndex >= 0 ? filteredCommands[slashHighlightIndex] : void 0;
285
- if (selected) {
286
- e.preventDefault();
287
- runCommand(selected);
288
- return;
289
- }
290
- }
291
- if (e.key === "Escape") {
292
- e.preventDefault();
293
- setCommandQuery(null);
294
- return;
295
- }
296
- }
297
- if (e.key === "Enter" && !e.shiftKey) {
298
- e.preventDefault();
299
- if (isProcessing) {
300
- onStop?.();
301
- } else {
302
- send();
303
- }
304
- }
305
- };
306
- const send = () => {
307
- if (!onSubmitMessage) {
308
- return;
309
- }
310
- const trimmed = resolvedValue.trim();
311
- if (!trimmed) {
312
- return;
313
- }
314
- onSubmitMessage(trimmed);
315
- if (!isControlled) {
316
- setInternalValue("");
317
- onChange?.("");
318
- }
319
- if (inputRef.current) {
320
- inputRef.current.focus();
321
- }
322
- };
323
- const BoundTextArea = renderSlot(textArea, CopilotChatInput.TextArea, {
324
- ref: inputRef,
325
- value: resolvedValue,
326
- onChange: handleChange,
327
- onKeyDown: handleKeyDown,
328
- autoFocus,
329
- className: twMerge(
330
- "w-full py-3",
331
- isExpanded ? "px-5" : "pr-5"
332
- )
333
- });
334
- const isProcessing = mode !== "transcribe" && isRunning;
335
- const canSend = resolvedValue.trim().length > 0 && !!onSubmitMessage;
336
- const canStop = !!onStop;
337
- const handleSendButtonClick = () => {
338
- if (isProcessing) {
339
- onStop?.();
340
- return;
341
- }
342
- send();
343
- };
344
- const BoundAudioRecorder = renderSlot(audioRecorder, CopilotChatAudioRecorder, {
345
- ref: audioRecorderRef
346
- });
347
- const BoundSendButton = renderSlot(sendButton, CopilotChatInput.SendButton, {
348
- onClick: handleSendButtonClick,
349
- disabled: isProcessing ? !canStop : !canSend,
350
- children: isProcessing && canStop ? /* @__PURE__ */ jsx(Square, { className: "size-[18px] fill-current" }) : void 0
351
- });
352
- const BoundStartTranscribeButton = renderSlot(startTranscribeButton, CopilotChatInput.StartTranscribeButton, {
353
- onClick: onStartTranscribe
354
- });
355
- const BoundCancelTranscribeButton = renderSlot(cancelTranscribeButton, CopilotChatInput.CancelTranscribeButton, {
356
- onClick: onCancelTranscribe
357
- });
358
- const BoundFinishTranscribeButton = renderSlot(finishTranscribeButton, CopilotChatInput.FinishTranscribeButton, {
359
- onClick: onFinishTranscribe
360
- });
361
- const BoundAddMenuButton = renderSlot(addMenuButton, CopilotChatInput.AddMenuButton, {
362
- disabled: mode === "transcribe",
363
- onAddFile,
364
- toolsMenu
365
- });
366
- if (children) {
367
- const childProps = {
368
- textArea: BoundTextArea,
369
- audioRecorder: BoundAudioRecorder,
370
- sendButton: BoundSendButton,
371
- startTranscribeButton: BoundStartTranscribeButton,
372
- cancelTranscribeButton: BoundCancelTranscribeButton,
373
- finishTranscribeButton: BoundFinishTranscribeButton,
374
- addMenuButton: BoundAddMenuButton,
375
- onSubmitMessage,
376
- onStop,
377
- isRunning,
378
- onStartTranscribe,
379
- onCancelTranscribe,
380
- onFinishTranscribe,
381
- onAddFile,
382
- mode,
383
- toolsMenu,
384
- autoFocus
385
- };
386
- return /* @__PURE__ */ jsx(Fragment, { children: children(childProps) });
387
- }
388
- const handleContainerClick = (e) => {
389
- const target = e.target;
390
- if (target.tagName !== "BUTTON" && !target.closest("button") && inputRef.current && mode === "input") {
391
- inputRef.current.focus();
392
- }
393
- };
394
- const ensureMeasurements = useCallback(() => {
395
- const textarea = inputRef.current;
396
- if (!textarea) {
397
- return;
398
- }
399
- const previousValue = textarea.value;
400
- const previousHeight = textarea.style.height;
401
- textarea.style.height = "auto";
402
- const computedStyle = window.getComputedStyle(textarea);
403
- const paddingLeft = parseFloat(computedStyle.paddingLeft) || 0;
404
- const paddingRight = parseFloat(computedStyle.paddingRight) || 0;
405
- const paddingTop = parseFloat(computedStyle.paddingTop) || 0;
406
- const paddingBottom = parseFloat(computedStyle.paddingBottom) || 0;
407
- textarea.value = "";
408
- const singleLineHeight = textarea.scrollHeight;
409
- textarea.value = previousValue;
410
- const contentHeight = singleLineHeight - paddingTop - paddingBottom;
411
- const maxHeight = contentHeight * 5 + paddingTop + paddingBottom;
412
- measurementsRef.current = {
413
- singleLineHeight,
414
- maxHeight,
415
- paddingLeft,
416
- paddingRight
417
- };
418
- textarea.style.height = previousHeight;
419
- textarea.style.maxHeight = `${maxHeight}px`;
420
- }, []);
421
- const adjustTextareaHeight = useCallback(() => {
422
- const textarea = inputRef.current;
423
- if (!textarea) {
424
- return 0;
425
- }
426
- if (measurementsRef.current.singleLineHeight === 0) {
427
- ensureMeasurements();
428
- }
429
- const { maxHeight } = measurementsRef.current;
430
- if (maxHeight) {
431
- textarea.style.maxHeight = `${maxHeight}px`;
432
- }
433
- textarea.style.height = "auto";
434
- const scrollHeight = textarea.scrollHeight;
435
- if (maxHeight) {
436
- textarea.style.height = `${Math.min(scrollHeight, maxHeight)}px`;
437
- } else {
438
- textarea.style.height = `${scrollHeight}px`;
439
- }
440
- return scrollHeight;
441
- }, [ensureMeasurements]);
442
- const updateLayout = useCallback((nextLayout) => {
443
- setLayout((prev) => {
444
- if (prev === nextLayout) {
445
- return prev;
446
- }
447
- ignoreResizeRef.current = true;
448
- return nextLayout;
449
- });
450
- }, []);
451
- const evaluateLayout = useCallback(() => {
452
- if (mode !== "input") {
453
- updateLayout("compact");
454
- return;
455
- }
456
- if (typeof window !== "undefined" && typeof window.matchMedia === "function") {
457
- const isMobileViewport = window.matchMedia("(max-width: 767px)").matches;
458
- if (isMobileViewport) {
459
- ensureMeasurements();
460
- adjustTextareaHeight();
461
- updateLayout("expanded");
462
- return;
463
- }
464
- }
465
- const textarea = inputRef.current;
466
- const grid = gridRef.current;
467
- const addContainer = addButtonContainerRef.current;
468
- const actionsContainer = actionsContainerRef.current;
469
- if (!textarea || !grid || !addContainer || !actionsContainer) {
470
- return;
471
- }
472
- if (measurementsRef.current.singleLineHeight === 0) {
473
- ensureMeasurements();
474
- }
475
- const scrollHeight = adjustTextareaHeight();
476
- const baseline = measurementsRef.current.singleLineHeight;
477
- const hasExplicitBreak = resolvedValue.includes("\n");
478
- const renderedMultiline = baseline > 0 ? scrollHeight > baseline + 1 : false;
479
- let shouldExpand = hasExplicitBreak || renderedMultiline;
480
- if (!shouldExpand) {
481
- const gridStyles = window.getComputedStyle(grid);
482
- const paddingLeft = parseFloat(gridStyles.paddingLeft) || 0;
483
- const paddingRight = parseFloat(gridStyles.paddingRight) || 0;
484
- const columnGap = parseFloat(gridStyles.columnGap) || 0;
485
- const gridAvailableWidth = grid.clientWidth - paddingLeft - paddingRight;
486
- if (gridAvailableWidth > 0) {
487
- const addWidth = addContainer.getBoundingClientRect().width;
488
- const actionsWidth = actionsContainer.getBoundingClientRect().width;
489
- const compactWidth = Math.max(gridAvailableWidth - addWidth - actionsWidth - columnGap * 2, 0);
490
- const canvas = measurementCanvasRef.current ?? document.createElement("canvas");
491
- if (!measurementCanvasRef.current) {
492
- measurementCanvasRef.current = canvas;
493
- }
494
- const context = canvas.getContext("2d");
495
- if (context) {
496
- const textareaStyles = window.getComputedStyle(textarea);
497
- const font = textareaStyles.font || `${textareaStyles.fontStyle} ${textareaStyles.fontVariant} ${textareaStyles.fontWeight} ${textareaStyles.fontSize}/${textareaStyles.lineHeight} ${textareaStyles.fontFamily}`;
498
- context.font = font;
499
- const compactInnerWidth = Math.max(
500
- compactWidth - (measurementsRef.current.paddingLeft || 0) - (measurementsRef.current.paddingRight || 0),
501
- 0
502
- );
503
- if (compactInnerWidth > 0) {
504
- const lines = resolvedValue.length > 0 ? resolvedValue.split("\n") : [""];
505
- let longestWidth = 0;
506
- for (const line of lines) {
507
- const metrics = context.measureText(line || " ");
508
- if (metrics.width > longestWidth) {
509
- longestWidth = metrics.width;
510
- }
511
- }
512
- if (longestWidth > compactInnerWidth) {
513
- shouldExpand = true;
514
- }
515
- }
516
- }
517
- }
518
- }
519
- const nextLayout = shouldExpand ? "expanded" : "compact";
520
- updateLayout(nextLayout);
521
- }, [adjustTextareaHeight, ensureMeasurements, mode, resolvedValue, updateLayout]);
522
- useLayoutEffect(() => {
523
- evaluateLayout();
524
- }, [evaluateLayout]);
525
- useEffect(() => {
526
- if (typeof ResizeObserver === "undefined") {
527
- return;
528
- }
529
- const textarea = inputRef.current;
530
- const grid = gridRef.current;
531
- const addContainer = addButtonContainerRef.current;
532
- const actionsContainer = actionsContainerRef.current;
533
- if (!textarea || !grid || !addContainer || !actionsContainer) {
534
- return;
535
- }
536
- const scheduleEvaluation = () => {
537
- if (ignoreResizeRef.current) {
538
- ignoreResizeRef.current = false;
539
- return;
540
- }
541
- if (typeof window === "undefined") {
542
- evaluateLayout();
543
- return;
544
- }
545
- if (resizeEvaluationRafRef.current !== null) {
546
- cancelAnimationFrame(resizeEvaluationRafRef.current);
547
- }
548
- resizeEvaluationRafRef.current = window.requestAnimationFrame(() => {
549
- resizeEvaluationRafRef.current = null;
550
- evaluateLayout();
551
- });
552
- };
553
- const observer = new ResizeObserver(() => {
554
- scheduleEvaluation();
555
- });
556
- observer.observe(grid);
557
- observer.observe(addContainer);
558
- observer.observe(actionsContainer);
559
- observer.observe(textarea);
560
- return () => {
561
- observer.disconnect();
562
- if (typeof window !== "undefined" && resizeEvaluationRafRef.current !== null) {
563
- cancelAnimationFrame(resizeEvaluationRafRef.current);
564
- resizeEvaluationRafRef.current = null;
565
- }
566
- };
567
- }, [evaluateLayout]);
568
- const slashMenuVisible = commandQuery !== null && commandItems.length > 0;
569
- useEffect(() => {
570
- if (!slashMenuVisible || slashHighlightIndex < 0) {
571
- return;
572
- }
573
- const active = slashMenuRef.current?.querySelector(
574
- `[data-slash-index="${slashHighlightIndex}"]`
575
- );
576
- active?.scrollIntoView({ block: "nearest" });
577
- }, [slashMenuVisible, slashHighlightIndex]);
578
- const slashMenu = slashMenuVisible ? /* @__PURE__ */ jsx(
579
- "div",
580
- {
581
- "data-testid": "copilot-slash-menu",
582
- role: "listbox",
583
- "aria-label": "Slash commands",
584
- ref: slashMenuRef,
585
- className: "absolute bottom-full left-0 right-0 z-30 mb-2 max-h-64 overflow-y-auto rounded-lg border border-border bg-white shadow-lg dark:border-[#3a3a3a] dark:bg-[#1f1f1f]",
586
- style: { maxHeight: `${SLASH_MENU_MAX_VISIBLE_ITEMS * SLASH_MENU_ITEM_HEIGHT_PX}px` },
587
- children: filteredCommands.length === 0 ? /* @__PURE__ */ jsx("div", { className: "px-3 py-2 text-sm text-muted-foreground", children: "No commands found" }) : filteredCommands.map((item, index) => {
588
- const isActive = index === slashHighlightIndex;
589
- return /* @__PURE__ */ jsx(
590
- "button",
591
- {
592
- type: "button",
593
- role: "option",
594
- "aria-selected": isActive,
595
- "data-active": isActive ? "true" : void 0,
596
- "data-slash-index": index,
597
- className: twMerge(
598
- "w-full px-3 py-2 text-left text-sm transition-colors",
599
- "hover:bg-muted dark:hover:bg-[#2f2f2f]",
600
- isActive ? "bg-muted dark:bg-[#2f2f2f]" : "bg-transparent"
601
- ),
602
- onMouseEnter: () => setSlashHighlightIndex(index),
603
- onMouseDown: (event) => {
604
- event.preventDefault();
605
- runCommand(item);
606
- },
607
- children: item.label
608
- },
609
- `${item.label}-${index}`
610
- );
611
- })
612
- }
613
- ) : null;
614
- return /* @__PURE__ */ jsx(
615
- "div",
616
- {
617
- className: twMerge(
618
- // Layout
619
- "flex w-full flex-col items-center justify-center",
620
- // Interaction
621
- "cursor-text",
622
- // Overflow and clipping
623
- "overflow-visible bg-clip-padding contain-inline-size",
624
- // Background
625
- "bg-white dark:bg-[#303030]",
626
- // Visual effects
627
- "shadow-[0_4px_4px_0_#0000000a,0_0_1px_0_#0000009e] rounded-[28px]",
628
- className
629
- ),
630
- onClick: handleContainerClick,
631
- ...props,
632
- "data-layout": isExpanded ? "expanded" : "compact",
633
- children: /* @__PURE__ */ jsxs(
634
- "div",
635
- {
636
- ref: gridRef,
637
- className: twMerge(
638
- "grid w-full gap-x-3 gap-y-3 px-3 py-2",
639
- isExpanded ? "grid-cols-[auto_minmax(0,1fr)_auto] grid-rows-[auto_auto]" : "grid-cols-[auto_minmax(0,1fr)_auto] items-center"
640
- ),
641
- "data-layout": isExpanded ? "expanded" : "compact",
642
- children: [
643
- /* @__PURE__ */ jsx(
644
- "div",
645
- {
646
- ref: addButtonContainerRef,
647
- className: twMerge(
648
- "flex items-center",
649
- isExpanded ? "row-start-2" : "row-start-1",
650
- "col-start-1"
651
- ),
652
- children: BoundAddMenuButton
653
- }
654
- ),
655
- /* @__PURE__ */ jsx(
656
- "div",
657
- {
658
- className: twMerge(
659
- "relative flex min-w-0 flex-col",
660
- isExpanded ? "col-span-3 row-start-1" : "col-start-2 row-start-1"
661
- ),
662
- children: mode === "transcribe" ? BoundAudioRecorder : /* @__PURE__ */ jsxs(Fragment, { children: [
663
- BoundTextArea,
664
- slashMenu
665
- ] })
666
- }
667
- ),
668
- /* @__PURE__ */ jsx(
669
- "div",
670
- {
671
- ref: actionsContainerRef,
672
- className: twMerge(
673
- "flex items-center justify-end gap-2",
674
- isExpanded ? "col-start-3 row-start-2" : "col-start-3 row-start-1"
675
- ),
676
- children: mode === "transcribe" ? /* @__PURE__ */ jsxs(Fragment, { children: [
677
- onCancelTranscribe && BoundCancelTranscribeButton,
678
- onFinishTranscribe && BoundFinishTranscribeButton
679
- ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
680
- onStartTranscribe && BoundStartTranscribeButton,
681
- BoundSendButton
682
- ] })
683
- }
684
- )
685
- ]
686
- }
687
- )
688
- }
689
- );
690
- }
691
- ((CopilotChatInput2) => {
692
- CopilotChatInput2.SendButton = ({ className, children, ...props }) => /* @__PURE__ */ jsx("div", { className: "mr-[10px]", children: /* @__PURE__ */ jsx(
693
- Button,
694
- {
695
- type: "button",
696
- variant: "chatInputToolbarPrimary",
697
- size: "chatInputToolbarIcon",
698
- className,
699
- ...props,
700
- children: children ?? /* @__PURE__ */ jsx(ArrowUp, { className: "size-[18px]" })
701
- }
702
- ) });
703
- CopilotChatInput2.ToolbarButton = ({ icon, labelKey, defaultClassName, className, ...props }) => {
704
- const config = useCopilotChatConfiguration();
705
- const labels = config?.labels ?? CopilotChatDefaultLabels;
706
- return /* @__PURE__ */ jsxs(Tooltip, { children: [
707
- /* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
708
- Button,
709
- {
710
- type: "button",
711
- variant: "chatInputToolbarSecondary",
712
- size: "chatInputToolbarIcon",
713
- className: twMerge(defaultClassName, className),
714
- ...props,
715
- children: icon
716
- }
717
- ) }),
718
- /* @__PURE__ */ jsx(TooltipContent, { side: "bottom", children: /* @__PURE__ */ jsx("p", { children: labels[labelKey] }) })
719
- ] });
720
- };
721
- CopilotChatInput2.StartTranscribeButton = (props) => /* @__PURE__ */ jsx(
722
- CopilotChatInput2.ToolbarButton,
723
- {
724
- icon: /* @__PURE__ */ jsx(Mic, { className: "size-[18px]" }),
725
- labelKey: "chatInputToolbarStartTranscribeButtonLabel",
726
- defaultClassName: "mr-2",
727
- ...props
728
- }
729
- );
730
- CopilotChatInput2.CancelTranscribeButton = (props) => /* @__PURE__ */ jsx(
731
- CopilotChatInput2.ToolbarButton,
732
- {
733
- icon: /* @__PURE__ */ jsx(X, { className: "size-[18px]" }),
734
- labelKey: "chatInputToolbarCancelTranscribeButtonLabel",
735
- defaultClassName: "mr-2",
736
- ...props
737
- }
738
- );
739
- CopilotChatInput2.FinishTranscribeButton = (props) => /* @__PURE__ */ jsx(
740
- CopilotChatInput2.ToolbarButton,
741
- {
742
- icon: /* @__PURE__ */ jsx(Check, { className: "size-[18px]" }),
743
- labelKey: "chatInputToolbarFinishTranscribeButtonLabel",
744
- defaultClassName: "mr-[10px]",
745
- ...props
746
- }
747
- );
748
- CopilotChatInput2.AddMenuButton = ({ className, toolsMenu, onAddFile, disabled, ...props }) => {
749
- const config = useCopilotChatConfiguration();
750
- const labels = config?.labels ?? CopilotChatDefaultLabels;
751
- const menuItems = useMemo(() => {
752
- const items = [];
753
- if (onAddFile) {
754
- items.push({
755
- label: labels.chatInputToolbarAddButtonLabel,
756
- action: onAddFile
757
- });
758
- }
759
- if (toolsMenu && toolsMenu.length > 0) {
760
- if (items.length > 0) {
761
- items.push("-");
762
- }
763
- for (const item of toolsMenu) {
764
- if (item === "-") {
765
- if (items.length === 0 || items[items.length - 1] === "-") {
766
- continue;
767
- }
768
- items.push(item);
769
- } else {
770
- items.push(item);
771
- }
772
- }
773
- while (items.length > 0 && items[items.length - 1] === "-") {
774
- items.pop();
775
- }
776
- }
777
- return items;
778
- }, [onAddFile, toolsMenu, labels.chatInputToolbarAddButtonLabel]);
779
- const renderMenuItems = useCallback(
780
- (items) => items.map((item, index) => {
781
- if (item === "-") {
782
- return /* @__PURE__ */ jsx(DropdownMenuSeparator, {}, `separator-${index}`);
783
- }
784
- if (item.items && item.items.length > 0) {
785
- return /* @__PURE__ */ jsxs(DropdownMenuSub, { children: [
786
- /* @__PURE__ */ jsx(DropdownMenuSubTrigger, { children: item.label }),
787
- /* @__PURE__ */ jsx(DropdownMenuSubContent, { children: renderMenuItems(item.items) })
788
- ] }, `group-${index}`);
789
- }
790
- return /* @__PURE__ */ jsx(DropdownMenuItem, { onClick: item.action, children: item.label }, `item-${index}`);
791
- }),
792
- []
793
- );
794
- const hasMenuItems = menuItems.length > 0;
795
- const isDisabled = disabled || !hasMenuItems;
796
- return /* @__PURE__ */ jsxs(DropdownMenu, { children: [
797
- /* @__PURE__ */ jsxs(Tooltip, { children: [
798
- /* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
799
- Button,
800
- {
801
- type: "button",
802
- variant: "chatInputToolbarSecondary",
803
- size: "chatInputToolbarIcon",
804
- className: twMerge("ml-1", className),
805
- disabled: isDisabled,
806
- ...props,
807
- children: /* @__PURE__ */ jsx(Plus, { className: "size-[20px]" })
808
- }
809
- ) }) }),
810
- /* @__PURE__ */ jsx(TooltipContent, { side: "bottom", children: /* @__PURE__ */ jsxs("p", { className: "flex items-center gap-1 text-xs font-medium", children: [
811
- /* @__PURE__ */ jsx("span", { children: "Add files and more" }),
812
- /* @__PURE__ */ jsx("code", { className: "rounded bg-[#4a4a4a] px-1 py-[1px] font-mono text-[11px] text-white dark:bg-[#e0e0e0] dark:text-black", children: "/" })
813
- ] }) })
814
- ] }),
815
- hasMenuItems && /* @__PURE__ */ jsx(DropdownMenuContent, { side: "top", align: "start", children: renderMenuItems(menuItems) })
816
- ] });
817
- };
818
- CopilotChatInput2.TextArea = forwardRef(function TextArea2({ style, className, autoFocus, ...props }, ref) {
819
- const internalTextareaRef = useRef(null);
820
- const config = useCopilotChatConfiguration();
821
- const labels = config?.labels ?? CopilotChatDefaultLabels;
822
- useImperativeHandle(ref, () => internalTextareaRef.current);
823
- useEffect(() => {
824
- const textarea = internalTextareaRef.current;
825
- if (!textarea) return;
826
- const handleFocus = () => {
827
- setTimeout(() => {
828
- textarea.scrollIntoView({ behavior: "smooth", block: "nearest" });
829
- }, 300);
830
- };
831
- textarea.addEventListener("focus", handleFocus);
832
- return () => textarea.removeEventListener("focus", handleFocus);
833
- }, []);
834
- useEffect(() => {
835
- if (autoFocus) {
836
- internalTextareaRef.current?.focus();
837
- }
838
- }, [autoFocus]);
839
- return /* @__PURE__ */ jsx(
840
- "textarea",
841
- {
842
- ref: internalTextareaRef,
843
- ...props,
844
- style: {
845
- overflow: "auto",
846
- resize: "none",
847
- ...style
848
- },
849
- placeholder: labels.chatInputPlaceholder,
850
- className: twMerge(
851
- "bg-transparent outline-none antialiased font-regular leading-relaxed text-[16px] placeholder:text-[#00000077] dark:placeholder:text-[#fffc]",
852
- className
853
- ),
854
- rows: 1
855
- }
856
- );
857
- });
858
- CopilotChatInput2.AudioRecorder = CopilotChatAudioRecorder;
859
- })(CopilotChatInput || (CopilotChatInput = {}));
860
- CopilotChatInput.TextArea.displayName = "CopilotChatInput.TextArea";
861
- CopilotChatInput.SendButton.displayName = "CopilotChatInput.SendButton";
862
- CopilotChatInput.ToolbarButton.displayName = "CopilotChatInput.ToolbarButton";
863
- CopilotChatInput.StartTranscribeButton.displayName = "CopilotChatInput.StartTranscribeButton";
864
- CopilotChatInput.CancelTranscribeButton.displayName = "CopilotChatInput.CancelTranscribeButton";
865
- CopilotChatInput.FinishTranscribeButton.displayName = "CopilotChatInput.FinishTranscribeButton";
866
- CopilotChatInput.AddMenuButton.displayName = "CopilotChatInput.AddMenuButton";
867
- var CopilotChatInput_default = CopilotChatInput;
868
-
869
- export {
870
- CopilotChatInput,
871
- CopilotChatInput_default
872
- };
873
- //# sourceMappingURL=chunk-KCVDFZJX.mjs.map