@copilotkit/react-textarea 0.28.0-alpha.8 → 0.28.0

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 (339) hide show
  1. package/.turbo/turbo-build.log +429 -467
  2. package/CHANGELOG.md +45 -0
  3. package/dist/chunk-224UKA7C.mjs +9 -4
  4. package/dist/chunk-224UKA7C.mjs.map +1 -1
  5. package/dist/chunk-2C7O2EVM.mjs +4 -4
  6. package/dist/chunk-2C7O2EVM.mjs.map +1 -1
  7. package/dist/chunk-2QDCE7PD.mjs +6 -3
  8. package/dist/chunk-2QDCE7PD.mjs.map +1 -1
  9. package/dist/chunk-3PQ7GSFE.mjs +4 -4
  10. package/dist/chunk-3PQ7GSFE.mjs.map +1 -1
  11. package/dist/chunk-4NHVQZ67.mjs +6 -5
  12. package/dist/chunk-4NHVQZ67.mjs.map +1 -1
  13. package/dist/chunk-4OJ3H65F.mjs +5 -2
  14. package/dist/chunk-4OJ3H65F.mjs.map +1 -1
  15. package/dist/chunk-5J3UZV77.mjs +23 -11
  16. package/dist/chunk-5J3UZV77.mjs.map +1 -1
  17. package/dist/chunk-5UNJXFUO.mjs +4 -4
  18. package/dist/chunk-5UNJXFUO.mjs.map +1 -1
  19. package/dist/chunk-72P3KOHZ.mjs +17 -7
  20. package/dist/chunk-72P3KOHZ.mjs.map +1 -1
  21. package/dist/chunk-7LSRNPNI.mjs +4 -4
  22. package/dist/chunk-7LSRNPNI.mjs.map +1 -1
  23. package/dist/chunk-7SUZ6CXM.mjs +15 -6
  24. package/dist/chunk-7SUZ6CXM.mjs.map +1 -1
  25. package/dist/chunk-AZHILHKM.mjs +21 -8
  26. package/dist/chunk-AZHILHKM.mjs.map +1 -1
  27. package/dist/chunk-B6TKVDDY.mjs +58 -22
  28. package/dist/chunk-B6TKVDDY.mjs.map +1 -1
  29. package/dist/chunk-BBZ7AWOB.mjs +8 -4
  30. package/dist/chunk-BBZ7AWOB.mjs.map +1 -1
  31. package/dist/chunk-DE5K76I2.mjs +0 -2
  32. package/dist/chunk-DE5K76I2.mjs.map +1 -1
  33. package/dist/chunk-DRV2FOHZ.mjs +11 -6
  34. package/dist/chunk-DRV2FOHZ.mjs.map +1 -1
  35. package/dist/chunk-ECR45NSD.mjs +7 -4
  36. package/dist/chunk-ECR45NSD.mjs.map +1 -1
  37. package/dist/chunk-FJNUPSQK.mjs +16 -5
  38. package/dist/chunk-FJNUPSQK.mjs.map +1 -1
  39. package/dist/chunk-FP2EKU3L.mjs +4 -4
  40. package/dist/chunk-FP2EKU3L.mjs.map +1 -1
  41. package/dist/chunk-GQN2HYFJ.mjs +4 -4
  42. package/dist/chunk-GQN2HYFJ.mjs.map +1 -1
  43. package/dist/chunk-H4VKQGVU.mjs +0 -2
  44. package/dist/chunk-H4VKQGVU.mjs.map +1 -1
  45. package/dist/chunk-IU3WTXLQ.mjs +0 -2
  46. package/dist/chunk-IU3WTXLQ.mjs.map +1 -1
  47. package/dist/chunk-JJLQVT7S.mjs +6 -3
  48. package/dist/chunk-JJLQVT7S.mjs.map +1 -1
  49. package/dist/chunk-KDVMG3XF.mjs +5 -2
  50. package/dist/chunk-KDVMG3XF.mjs.map +1 -1
  51. package/dist/chunk-KFQZHRPJ.mjs +15 -8
  52. package/dist/chunk-KFQZHRPJ.mjs.map +1 -1
  53. package/dist/chunk-KNQIEOFP.mjs +3 -2
  54. package/dist/chunk-KNQIEOFP.mjs.map +1 -1
  55. package/dist/chunk-L7VVZH4Q.mjs +0 -2
  56. package/dist/chunk-L7VVZH4Q.mjs.map +1 -1
  57. package/dist/chunk-LQ2OWQU7.mjs +11 -7
  58. package/dist/chunk-LQ2OWQU7.mjs.map +1 -1
  59. package/dist/chunk-LYB4B6MK.mjs +6 -5
  60. package/dist/chunk-LYB4B6MK.mjs.map +1 -1
  61. package/dist/chunk-M2DR4KVB.mjs +6 -3
  62. package/dist/chunk-M2DR4KVB.mjs.map +1 -1
  63. package/dist/chunk-MMVDU6DF.mjs +0 -2
  64. package/dist/chunk-MMVDU6DF.mjs.map +1 -1
  65. package/dist/chunk-MRXNTQOX.mjs +6 -2
  66. package/dist/chunk-MRXNTQOX.mjs.map +1 -1
  67. package/dist/chunk-P4QVFRLY.mjs +17 -7
  68. package/dist/chunk-P4QVFRLY.mjs.map +1 -1
  69. package/dist/chunk-PTZVE6NC.mjs +22 -8
  70. package/dist/chunk-PTZVE6NC.mjs.map +1 -1
  71. package/dist/chunk-QCPS6IYI.mjs +15 -6
  72. package/dist/chunk-QCPS6IYI.mjs.map +1 -1
  73. package/dist/chunk-RKQ6RTZM.mjs +5 -2
  74. package/dist/chunk-RKQ6RTZM.mjs.map +1 -1
  75. package/dist/chunk-RT4UTBH3.mjs +15 -6
  76. package/dist/chunk-RT4UTBH3.mjs.map +1 -1
  77. package/dist/chunk-RUV6NBIF.mjs +0 -2
  78. package/dist/chunk-RUV6NBIF.mjs.map +1 -1
  79. package/dist/chunk-SNQEBH5I.mjs +24 -10
  80. package/dist/chunk-SNQEBH5I.mjs.map +1 -1
  81. package/dist/chunk-SX6NY5FW.mjs +11 -6
  82. package/dist/chunk-SX6NY5FW.mjs.map +1 -1
  83. package/dist/chunk-T6MTDQZ7.mjs +4 -4
  84. package/dist/chunk-T6MTDQZ7.mjs.map +1 -1
  85. package/dist/chunk-VB4VNCIQ.mjs +28 -12
  86. package/dist/chunk-VB4VNCIQ.mjs.map +1 -1
  87. package/dist/chunk-VPEH6V7T.mjs +12 -6
  88. package/dist/chunk-VPEH6V7T.mjs.map +1 -1
  89. package/dist/chunk-WADHCMPK.mjs +0 -2
  90. package/dist/chunk-WADHCMPK.mjs.map +1 -1
  91. package/dist/chunk-WFTAAA7R.mjs +16 -8
  92. package/dist/chunk-WFTAAA7R.mjs.map +1 -1
  93. package/dist/chunk-WJHSY5T6.mjs +0 -2
  94. package/dist/chunk-WJHSY5T6.mjs.map +1 -1
  95. package/dist/chunk-WTASPE2W.mjs +41 -22
  96. package/dist/chunk-WTASPE2W.mjs.map +1 -1
  97. package/dist/chunk-XW3ICO4S.mjs +10 -4
  98. package/dist/chunk-XW3ICO4S.mjs.map +1 -1
  99. package/dist/components/base-copilot-textarea/base-copilot-textarea.js +379 -257
  100. package/dist/components/base-copilot-textarea/base-copilot-textarea.js.map +1 -1
  101. package/dist/components/base-copilot-textarea/base-copilot-textarea.mjs +39 -35
  102. package/dist/components/base-copilot-textarea/base-copilot-textarea.mjs.map +1 -1
  103. package/dist/components/base-copilot-textarea/render-element.js +32 -11
  104. package/dist/components/base-copilot-textarea/render-element.js.map +1 -1
  105. package/dist/components/base-copilot-textarea/render-element.mjs +7 -3
  106. package/dist/components/base-copilot-textarea/render-element.mjs.map +1 -1
  107. package/dist/components/base-copilot-textarea/render-placeholder.js +29 -8
  108. package/dist/components/base-copilot-textarea/render-placeholder.js.map +1 -1
  109. package/dist/components/base-copilot-textarea/render-placeholder.mjs +7 -3
  110. package/dist/components/base-copilot-textarea/render-placeholder.mjs.map +1 -1
  111. package/dist/components/base-copilot-textarea/track-cursor-moved-since-last-text-change.js +44 -17
  112. package/dist/components/base-copilot-textarea/track-cursor-moved-since-last-text-change.js.map +1 -1
  113. package/dist/components/base-copilot-textarea/track-cursor-moved-since-last-text-change.mjs +8 -4
  114. package/dist/components/base-copilot-textarea/track-cursor-moved-since-last-text-change.mjs.map +1 -1
  115. package/dist/components/base-copilot-textarea/use-add-branding-css.js +29 -7
  116. package/dist/components/base-copilot-textarea/use-add-branding-css.js.map +1 -1
  117. package/dist/components/base-copilot-textarea/use-add-branding-css.mjs +7 -3
  118. package/dist/components/base-copilot-textarea/use-add-branding-css.mjs.map +1 -1
  119. package/dist/components/copilot-textarea/copilot-textarea.js +414 -272
  120. package/dist/components/copilot-textarea/copilot-textarea.js.map +1 -1
  121. package/dist/components/copilot-textarea/copilot-textarea.mjs +48 -44
  122. package/dist/components/copilot-textarea/copilot-textarea.mjs.map +1 -1
  123. package/dist/components/hovering-toolbar/hovering-editor-provider.js +35 -12
  124. package/dist/components/hovering-toolbar/hovering-editor-provider.js.map +1 -1
  125. package/dist/components/hovering-toolbar/hovering-editor-provider.mjs +9 -3
  126. package/dist/components/hovering-toolbar/hovering-editor-provider.mjs.map +1 -1
  127. package/dist/components/hovering-toolbar/hovering-toolbar-components.js +66 -36
  128. package/dist/components/hovering-toolbar/hovering-toolbar-components.js.map +1 -1
  129. package/dist/components/hovering-toolbar/hovering-toolbar-components.mjs +15 -3
  130. package/dist/components/hovering-toolbar/hovering-toolbar-components.mjs.map +1 -1
  131. package/dist/components/hovering-toolbar/hovering-toolbar.js +247 -179
  132. package/dist/components/hovering-toolbar/hovering-toolbar.js.map +1 -1
  133. package/dist/components/hovering-toolbar/hovering-toolbar.mjs +22 -18
  134. package/dist/components/hovering-toolbar/hovering-toolbar.mjs.map +1 -1
  135. package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.js +180 -129
  136. package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.js.map +1 -1
  137. package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.mjs +16 -12
  138. package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.mjs.map +1 -1
  139. package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.js +185 -131
  140. package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.js.map +1 -1
  141. package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.mjs +17 -13
  142. package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.mjs.map +1 -1
  143. package/dist/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.js +71 -55
  144. package/dist/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.js.map +1 -1
  145. package/dist/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.mjs +11 -5
  146. package/dist/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.mjs.map +1 -1
  147. package/dist/components/hovering-toolbar/text-insertion-prompt-box/index.js +185 -131
  148. package/dist/components/hovering-toolbar/text-insertion-prompt-box/index.js.map +1 -1
  149. package/dist/components/hovering-toolbar/text-insertion-prompt-box/index.mjs +18 -14
  150. package/dist/components/hovering-toolbar/text-insertion-prompt-box/index.mjs.map +1 -1
  151. package/dist/components/index.js +418 -273
  152. package/dist/components/index.js.map +1 -1
  153. package/dist/components/index.mjs +52 -45
  154. package/dist/components/index.mjs.map +1 -1
  155. package/dist/components/manual-ui/chip-with-icon.js +31 -9
  156. package/dist/components/manual-ui/chip-with-icon.js.map +1 -1
  157. package/dist/components/manual-ui/chip-with-icon.mjs +6 -5
  158. package/dist/components/manual-ui/chip-with-icon.mjs.map +1 -1
  159. package/dist/components/source-search-box/source-search-box.js +104 -72
  160. package/dist/components/source-search-box/source-search-box.js.map +1 -1
  161. package/dist/components/source-search-box/source-search-box.mjs +12 -6
  162. package/dist/components/source-search-box/source-search-box.mjs.map +1 -1
  163. package/dist/components/ui/button.js +56 -40
  164. package/dist/components/ui/button.js.map +1 -1
  165. package/dist/components/ui/button.mjs +10 -4
  166. package/dist/components/ui/button.mjs.map +1 -1
  167. package/dist/components/ui/card.js +70 -50
  168. package/dist/components/ui/card.js.map +1 -1
  169. package/dist/components/ui/card.mjs +18 -7
  170. package/dist/components/ui/card.mjs.map +1 -1
  171. package/dist/components/ui/command.js +139 -97
  172. package/dist/components/ui/command.js.map +1 -1
  173. package/dist/components/ui/command.mjs +26 -5
  174. package/dist/components/ui/command.mjs.map +1 -1
  175. package/dist/components/ui/dialog.js +90 -69
  176. package/dist/components/ui/dialog.js.map +1 -1
  177. package/dist/components/ui/dialog.mjs +21 -4
  178. package/dist/components/ui/dialog.mjs.map +1 -1
  179. package/dist/components/ui/label.js +55 -40
  180. package/dist/components/ui/label.js.map +1 -1
  181. package/dist/components/ui/label.mjs +9 -4
  182. package/dist/components/ui/label.mjs.map +1 -1
  183. package/dist/components/ui/separator.js +54 -39
  184. package/dist/components/ui/separator.js.map +1 -1
  185. package/dist/components/ui/separator.mjs +15 -8
  186. package/dist/components/ui/separator.mjs.map +1 -1
  187. package/dist/components/ui/textarea.js +50 -35
  188. package/dist/components/ui/textarea.js.map +1 -1
  189. package/dist/components/ui/textarea.mjs +13 -7
  190. package/dist/components/ui/textarea.mjs.map +1 -1
  191. package/dist/context/index.js +17 -2
  192. package/dist/context/index.js.map +1 -1
  193. package/dist/context/index.mjs +1 -2
  194. package/dist/context/index.mjs.map +1 -1
  195. package/dist/hooks/base-copilot-textarea-implementation/use-autosuggestions.js +43 -18
  196. package/dist/hooks/base-copilot-textarea-implementation/use-autosuggestions.js.map +1 -1
  197. package/dist/hooks/base-copilot-textarea-implementation/use-autosuggestions.mjs +10 -6
  198. package/dist/hooks/base-copilot-textarea-implementation/use-autosuggestions.mjs.map +1 -1
  199. package/dist/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.js +50 -25
  200. package/dist/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.js.map +1 -1
  201. package/dist/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.mjs +8 -4
  202. package/dist/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.mjs.map +1 -1
  203. package/dist/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.js +62 -29
  204. package/dist/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.js.map +1 -1
  205. package/dist/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.mjs +9 -5
  206. package/dist/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.mjs.map +1 -1
  207. package/dist/hooks/index.js +17 -2
  208. package/dist/hooks/index.js.map +1 -1
  209. package/dist/hooks/index.mjs +1 -2
  210. package/dist/hooks/index.mjs.map +1 -1
  211. package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.js +35 -11
  212. package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.js.map +1 -1
  213. package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.mjs +8 -4
  214. package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.mjs.map +1 -1
  215. package/dist/hooks/make-autosuggestions-function/use-make-standard-insertion-function.js +38 -14
  216. package/dist/hooks/make-autosuggestions-function/use-make-standard-insertion-function.js.map +1 -1
  217. package/dist/hooks/make-autosuggestions-function/use-make-standard-insertion-function.mjs +8 -4
  218. package/dist/hooks/make-autosuggestions-function/use-make-standard-insertion-function.mjs.map +1 -1
  219. package/dist/hooks/misc/use-autosize-textarea.js +25 -7
  220. package/dist/hooks/misc/use-autosize-textarea.js.map +1 -1
  221. package/dist/hooks/misc/use-autosize-textarea.mjs +7 -3
  222. package/dist/hooks/misc/use-autosize-textarea.mjs.map +1 -1
  223. package/dist/index.js +422 -275
  224. package/dist/index.js.map +1 -1
  225. package/dist/index.mjs +62 -49
  226. package/dist/index.mjs.map +1 -1
  227. package/dist/lib/debouncer.js +27 -5
  228. package/dist/lib/debouncer.js.map +1 -1
  229. package/dist/lib/debouncer.mjs +7 -3
  230. package/dist/lib/debouncer.mjs.map +1 -1
  231. package/dist/lib/editor-to-text.js +30 -8
  232. package/dist/lib/editor-to-text.js.map +1 -1
  233. package/dist/lib/editor-to-text.mjs +7 -3
  234. package/dist/lib/editor-to-text.mjs.map +1 -1
  235. package/dist/lib/get-text-around-cursor.js +49 -24
  236. package/dist/lib/get-text-around-cursor.js.map +1 -1
  237. package/dist/lib/get-text-around-cursor.mjs +13 -3
  238. package/dist/lib/get-text-around-cursor.mjs.map +1 -1
  239. package/dist/lib/retry.js +27 -4
  240. package/dist/lib/retry.js.map +1 -1
  241. package/dist/lib/retry.mjs +7 -3
  242. package/dist/lib/retry.mjs.map +1 -1
  243. package/dist/lib/slatejs-edits/add-autocompletions.js +29 -7
  244. package/dist/lib/slatejs-edits/add-autocompletions.js.map +1 -1
  245. package/dist/lib/slatejs-edits/add-autocompletions.mjs +7 -3
  246. package/dist/lib/slatejs-edits/add-autocompletions.mjs.map +1 -1
  247. package/dist/lib/slatejs-edits/clear-autocompletions.js +31 -9
  248. package/dist/lib/slatejs-edits/clear-autocompletions.js.map +1 -1
  249. package/dist/lib/slatejs-edits/clear-autocompletions.mjs +7 -3
  250. package/dist/lib/slatejs-edits/clear-autocompletions.mjs.map +1 -1
  251. package/dist/lib/slatejs-edits/replace-text.js +32 -10
  252. package/dist/lib/slatejs-edits/replace-text.js.map +1 -1
  253. package/dist/lib/slatejs-edits/replace-text.mjs +7 -3
  254. package/dist/lib/slatejs-edits/replace-text.mjs.map +1 -1
  255. package/dist/lib/slatejs-edits/with-partial-history.js +42 -19
  256. package/dist/lib/slatejs-edits/with-partial-history.js.map +1 -1
  257. package/dist/lib/slatejs-edits/with-partial-history.mjs +9 -3
  258. package/dist/lib/slatejs-edits/with-partial-history.mjs.map +1 -1
  259. package/dist/lib/stream-promise-flatten.js +27 -5
  260. package/dist/lib/stream-promise-flatten.js.map +1 -1
  261. package/dist/lib/stream-promise-flatten.mjs +7 -3
  262. package/dist/lib/stream-promise-flatten.mjs.map +1 -1
  263. package/dist/lib/utils.js +44 -16
  264. package/dist/lib/utils.js.map +1 -1
  265. package/dist/lib/utils.mjs +17 -3
  266. package/dist/lib/utils.mjs.map +1 -1
  267. package/dist/lib/utils.test.js +1 -2
  268. package/dist/lib/utils.test.js.map +1 -1
  269. package/dist/lib/utils.test.mjs +0 -1
  270. package/dist/lib/utils.test.mjs.map +1 -1
  271. package/dist/types/autosuggestions-config/autosuggestions-config-user-specified.js +17 -2
  272. package/dist/types/autosuggestions-config/autosuggestions-config-user-specified.js.map +1 -1
  273. package/dist/types/autosuggestions-config/autosuggestions-config-user-specified.mjs +0 -2
  274. package/dist/types/autosuggestions-config/autosuggestions-config-user-specified.mjs.map +1 -1
  275. package/dist/types/autosuggestions-config/autosuggestions-config.js +35 -9
  276. package/dist/types/autosuggestions-config/autosuggestions-config.js.map +1 -1
  277. package/dist/types/autosuggestions-config/autosuggestions-config.mjs +12 -8
  278. package/dist/types/autosuggestions-config/autosuggestions-config.mjs.map +1 -1
  279. package/dist/types/autosuggestions-config/editing-api-config.js +31 -6
  280. package/dist/types/autosuggestions-config/editing-api-config.js.map +1 -1
  281. package/dist/types/autosuggestions-config/editing-api-config.mjs +11 -3
  282. package/dist/types/autosuggestions-config/editing-api-config.mjs.map +1 -1
  283. package/dist/types/autosuggestions-config/index.js +35 -9
  284. package/dist/types/autosuggestions-config/index.js.map +1 -1
  285. package/dist/types/autosuggestions-config/index.mjs +13 -9
  286. package/dist/types/autosuggestions-config/index.mjs.map +1 -1
  287. package/dist/types/autosuggestions-config/insertions-api-config.js +31 -6
  288. package/dist/types/autosuggestions-config/insertions-api-config.js.map +1 -1
  289. package/dist/types/autosuggestions-config/insertions-api-config.mjs +11 -3
  290. package/dist/types/autosuggestions-config/insertions-api-config.mjs.map +1 -1
  291. package/dist/types/autosuggestions-config/subtypes/make-system-prompt.js +17 -2
  292. package/dist/types/autosuggestions-config/subtypes/make-system-prompt.js.map +1 -1
  293. package/dist/types/autosuggestions-config/subtypes/make-system-prompt.mjs +0 -2
  294. package/dist/types/autosuggestions-config/subtypes/make-system-prompt.mjs.map +1 -1
  295. package/dist/types/autosuggestions-config/subtypes/minimal-chat-gpt-message.js +17 -2
  296. package/dist/types/autosuggestions-config/subtypes/minimal-chat-gpt-message.js.map +1 -1
  297. package/dist/types/autosuggestions-config/subtypes/minimal-chat-gpt-message.mjs +0 -2
  298. package/dist/types/autosuggestions-config/subtypes/minimal-chat-gpt-message.mjs.map +1 -1
  299. package/dist/types/autosuggestions-config/suggestions-api-config.js +31 -6
  300. package/dist/types/autosuggestions-config/suggestions-api-config.js.map +1 -1
  301. package/dist/types/autosuggestions-config/suggestions-api-config.mjs +11 -3
  302. package/dist/types/autosuggestions-config/suggestions-api-config.mjs.map +1 -1
  303. package/dist/types/base/autosuggestion-state.js +17 -2
  304. package/dist/types/base/autosuggestion-state.js.map +1 -1
  305. package/dist/types/base/autosuggestion-state.mjs +0 -2
  306. package/dist/types/base/autosuggestion-state.mjs.map +1 -1
  307. package/dist/types/base/autosuggestions-bare-function.js +17 -2
  308. package/dist/types/base/autosuggestions-bare-function.js.map +1 -1
  309. package/dist/types/base/autosuggestions-bare-function.mjs +0 -2
  310. package/dist/types/base/autosuggestions-bare-function.mjs.map +1 -1
  311. package/dist/types/base/base-autosuggestions-config.js +29 -7
  312. package/dist/types/base/base-autosuggestions-config.js.map +1 -1
  313. package/dist/types/base/base-autosuggestions-config.mjs +7 -3
  314. package/dist/types/base/base-autosuggestions-config.mjs.map +1 -1
  315. package/dist/types/base/base-copilot-textarea-props.js +17 -2
  316. package/dist/types/base/base-copilot-textarea-props.js.map +1 -1
  317. package/dist/types/base/base-copilot-textarea-props.mjs +0 -2
  318. package/dist/types/base/base-copilot-textarea-props.mjs.map +1 -1
  319. package/dist/types/base/custom-editor.js +17 -2
  320. package/dist/types/base/custom-editor.js.map +1 -1
  321. package/dist/types/base/custom-editor.mjs +0 -2
  322. package/dist/types/base/custom-editor.mjs.map +1 -1
  323. package/dist/types/base/editor-autocomplete-state.js +32 -8
  324. package/dist/types/base/editor-autocomplete-state.js.map +1 -1
  325. package/dist/types/base/editor-autocomplete-state.mjs +8 -4
  326. package/dist/types/base/editor-autocomplete-state.mjs.map +1 -1
  327. package/dist/types/base/index.js +30 -6
  328. package/dist/types/base/index.js.map +1 -1
  329. package/dist/types/base/index.mjs +8 -4
  330. package/dist/types/base/index.mjs.map +1 -1
  331. package/dist/types/html-copilot-textarea-element.js +17 -2
  332. package/dist/types/html-copilot-textarea-element.js.map +1 -1
  333. package/dist/types/html-copilot-textarea-element.mjs +1 -2
  334. package/dist/types/html-copilot-textarea-element.mjs.map +1 -1
  335. package/dist/types/index.js +37 -10
  336. package/dist/types/index.js.map +1 -1
  337. package/dist/types/index.mjs +18 -11
  338. package/dist/types/index.mjs.map +1 -1
  339. package/package.json +8 -8
@@ -1,55 +1,12 @@
1
- 'use strict';
2
-
3
- var React2 = require('react');
4
- var reactCore = require('@copilotkit/react-core');
5
- var slate = require('slate');
6
- var slateReact = require('slate-react');
7
- var tailwindMerge = require('tailwind-merge');
8
- var clsx = require('clsx');
9
- var nanoid = require('nanoid');
10
- var slateHistory = require('slate-history');
11
- var cmdk = require('cmdk');
12
- var jsxRuntime = require('react/jsx-runtime');
13
- var reactSlot = require('@radix-ui/react-slot');
14
- var classVarianceAuthority = require('class-variance-authority');
15
- var LabelPrimitive = require('@radix-ui/react-label');
16
- var Chip = require('@mui/material/Chip/Chip.js');
17
- var Avatar = require('@mui/material/Avatar/Avatar.js');
18
- var css = require('@emotion/css');
19
- var ReactDOM = require('react-dom');
20
- var merge = require('lodash.merge');
21
-
22
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
23
-
24
- function _interopNamespace(e) {
25
- if (e && e.__esModule) return e;
26
- var n = Object.create(null);
27
- if (e) {
28
- Object.keys(e).forEach(function (k) {
29
- if (k !== 'default') {
30
- var d = Object.getOwnPropertyDescriptor(e, k);
31
- Object.defineProperty(n, k, d.get ? d : {
32
- enumerable: true,
33
- get: function () { return e[k]; }
34
- });
35
- }
36
- });
37
- }
38
- n.default = e;
39
- return Object.freeze(n);
40
- }
41
-
42
- var React2__namespace = /*#__PURE__*/_interopNamespace(React2);
43
- var LabelPrimitive__namespace = /*#__PURE__*/_interopNamespace(LabelPrimitive);
44
- var Chip__default = /*#__PURE__*/_interopDefault(Chip);
45
- var Avatar__default = /*#__PURE__*/_interopDefault(Avatar);
46
- var ReactDOM__default = /*#__PURE__*/_interopDefault(ReactDOM);
47
- var merge__default = /*#__PURE__*/_interopDefault(merge);
48
-
1
+ "use strict";
2
+ var __create = Object.create;
49
3
  var __defProp = Object.defineProperty;
50
4
  var __defProps = Object.defineProperties;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
51
6
  var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
7
+ var __getOwnPropNames = Object.getOwnPropertyNames;
52
8
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
9
+ var __getProtoOf = Object.getPrototypeOf;
53
10
  var __hasOwnProp = Object.prototype.hasOwnProperty;
54
11
  var __propIsEnum = Object.prototype.propertyIsEnumerable;
55
12
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
@@ -77,6 +34,27 @@ var __objRest = (source, exclude) => {
77
34
  }
78
35
  return target;
79
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);
80
58
  var __async = (__this, __arguments, generator) => {
81
59
  return new Promise((resolve, reject) => {
82
60
  var fulfilled = (value) => {
@@ -98,6 +76,18 @@ var __async = (__this, __arguments, generator) => {
98
76
  });
99
77
  };
100
78
 
79
+ // src/components/copilot-textarea/copilot-textarea.tsx
80
+ var copilot_textarea_exports = {};
81
+ __export(copilot_textarea_exports, {
82
+ CopilotTextarea: () => CopilotTextarea
83
+ });
84
+ module.exports = __toCommonJS(copilot_textarea_exports);
85
+ var import_react15 = __toESM(require("react"));
86
+
87
+ // src/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.tsx
88
+ var import_react_core = require("@copilotkit/react-core");
89
+ var import_react = require("react");
90
+
101
91
  // src/lib/retry.tsx
102
92
  function retry(fn, retriesLeft = 2, interval = 200, backoff = 1.5) {
103
93
  return new Promise((resolve, reject) => {
@@ -112,9 +102,12 @@ function retry(fn, retriesLeft = 2, interval = 200, backoff = 1.5) {
112
102
  });
113
103
  });
114
104
  }
105
+
106
+ // src/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.tsx
107
+ var import_react_core2 = require("@copilotkit/react-core");
115
108
  function useMakeStandardAutosuggestionFunction(textareaPurpose, contextCategories, apiConfig) {
116
- const { getContextString, copilotApiConfig } = React2.useContext(reactCore.CopilotContext);
117
- return React2.useCallback(
109
+ const { getContextString, copilotApiConfig } = (0, import_react.useContext)(import_react_core.CopilotContext);
110
+ return (0, import_react.useCallback)(
118
111
  (editorState2, abortSignal) => __async(this, null, function* () {
119
112
  const res = yield retry(() => __async(this, null, function* () {
120
113
  const messages = [
@@ -137,7 +130,7 @@ function useMakeStandardAutosuggestionFunction(textareaPurpose, contextCategorie
137
130
  content: editorState2.textBeforeCursor
138
131
  }
139
132
  ];
140
- const response = yield reactCore.fetchAndDecodeChatCompletionAsText(__spreadProps(__spreadValues({
133
+ const response = yield (0, import_react_core2.fetchAndDecodeChatCompletionAsText)(__spreadProps(__spreadValues({
141
134
  messages
142
135
  }, apiConfig.forwardedParams), {
143
136
  copilotConfig: copilotApiConfig,
@@ -162,6 +155,9 @@ function useMakeStandardAutosuggestionFunction(textareaPurpose, contextCategorie
162
155
  [apiConfig, getContextString, contextCategories, textareaPurpose]
163
156
  );
164
157
  }
158
+
159
+ // src/types/base/base-autosuggestions-config.tsx
160
+ var import_react_core3 = require("@copilotkit/react-core");
165
161
  var defaultShouldToggleHoveringEditorOnKeyPress = (event) => {
166
162
  if (event.key === "k" && event.metaKey) {
167
163
  return true;
@@ -176,7 +172,7 @@ var defaultShouldAcceptAutosuggestionOnKeyPress = (event) => {
176
172
  };
177
173
  var defaultBaseAutosuggestionsConfig = {
178
174
  debounceTime: 250,
179
- contextCategories: reactCore.defaultCopilotContextCategories,
175
+ contextCategories: import_react_core3.defaultCopilotContextCategories,
180
176
  disableWhenEmpty: true,
181
177
  disabled: false,
182
178
  temporarilyDisableWhenMovingCursorWithoutChangingText: true,
@@ -400,8 +396,11 @@ var defaultEditingApiConfig = {
400
396
  fewShotMessages: defaultEditingFewShotMessages,
401
397
  forwardedParams: void 0
402
398
  };
399
+
400
+ // src/types/autosuggestions-config/autosuggestions-config.tsx
401
+ var import_react_core4 = require("@copilotkit/react-core");
403
402
  var defaultAutosuggestionsConfig = __spreadProps(__spreadValues({}, defaultBaseAutosuggestionsConfig), {
404
- contextCategories: reactCore.defaultCopilotContextCategories,
403
+ contextCategories: import_react_core4.defaultCopilotContextCategories,
405
404
  chatApiConfigs: {
406
405
  suggestionsApiConfig: defaultSuggestionsApiConfig,
407
406
  insertionApiConfig: defaultInsertionsApiConfig,
@@ -409,6 +408,15 @@ var defaultAutosuggestionsConfig = __spreadProps(__spreadValues({}, defaultBaseA
409
408
  }
410
409
  });
411
410
 
411
+ // src/components/base-copilot-textarea/base-copilot-textarea.tsx
412
+ var import_react13 = __toESM(require("react"));
413
+ var import_slate10 = require("slate");
414
+ var import_slate_react5 = require("slate-react");
415
+ var import_tailwind_merge2 = require("tailwind-merge");
416
+
417
+ // src/hooks/base-copilot-textarea-implementation/use-autosuggestions.ts
418
+ var import_react2 = require("react");
419
+
412
420
  // src/lib/debouncer.ts
413
421
  var Debouncer = class {
414
422
  constructor(wait) {
@@ -436,10 +444,15 @@ var Debouncer = class {
436
444
  };
437
445
  }
438
446
  };
447
+
448
+ // src/lib/utils.ts
449
+ var import_clsx = require("clsx");
450
+ var import_nanoid = require("nanoid");
451
+ var import_tailwind_merge = require("tailwind-merge");
439
452
  function cn(...inputs) {
440
- return tailwindMerge.twMerge(clsx.clsx(inputs));
453
+ return (0, import_tailwind_merge.twMerge)((0, import_clsx.clsx)(inputs));
441
454
  }
442
- nanoid.customAlphabet(
455
+ var nanoid = (0, import_nanoid.customAlphabet)(
443
456
  "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
444
457
  7
445
458
  );
@@ -458,9 +471,9 @@ function areEqual_autocompleteState(prev, next) {
458
471
 
459
472
  // src/hooks/base-copilot-textarea-implementation/use-autosuggestions.ts
460
473
  function useAutosuggestions(debounceTime, shouldAcceptAutosuggestionOnKeyPress, autosuggestionFunction, insertAutocompleteSuggestion, disableWhenEmpty, disabled) {
461
- const [previousAutocompleteState, setPreviousAutocompleteState] = React2.useState(null);
462
- const [currentAutocompleteSuggestion, setCurrentAutocompleteSuggestion] = React2.useState(null);
463
- const awaitForAndAppendSuggestion = React2.useCallback(
474
+ const [previousAutocompleteState, setPreviousAutocompleteState] = (0, import_react2.useState)(null);
475
+ const [currentAutocompleteSuggestion, setCurrentAutocompleteSuggestion] = (0, import_react2.useState)(null);
476
+ const awaitForAndAppendSuggestion = (0, import_react2.useCallback)(
464
477
  (editorAutocompleteState, abortSignal) => __async(this, null, function* () {
465
478
  if (disabled) {
466
479
  return;
@@ -479,17 +492,17 @@ function useAutosuggestions(debounceTime, shouldAcceptAutosuggestionOnKeyPress,
479
492
  }),
480
493
  [autosuggestionFunction, setCurrentAutocompleteSuggestion, disableWhenEmpty, disabled]
481
494
  );
482
- const debouncedFunction = React2.useMemo(
495
+ const debouncedFunction = (0, import_react2.useMemo)(
483
496
  () => new Debouncer(debounceTime),
484
497
  [debounceTime]
485
498
  );
486
- React2.useEffect(() => {
499
+ (0, import_react2.useEffect)(() => {
487
500
  return () => {
488
501
  debouncedFunction.cancel();
489
502
  setCurrentAutocompleteSuggestion(null);
490
503
  };
491
504
  }, [debouncedFunction, disabled]);
492
- const onChange = React2.useCallback(
505
+ const onChange = (0, import_react2.useCallback)(
493
506
  (newEditorState) => {
494
507
  const editorStateHasChanged = !nullableCompatibleEqualityCheck(
495
508
  areEqual_autocompleteState,
@@ -515,7 +528,7 @@ function useAutosuggestions(debounceTime, shouldAcceptAutosuggestionOnKeyPress,
515
528
  setCurrentAutocompleteSuggestion
516
529
  ]
517
530
  );
518
- const keyDownHandler = React2.useCallback(
531
+ const keyDownHandler = (0, import_react2.useCallback)(
519
532
  (event) => {
520
533
  if (currentAutocompleteSuggestion) {
521
534
  if (shouldAcceptAutosuggestionOnKeyPress(event)) {
@@ -538,6 +551,15 @@ function useAutosuggestions(debounceTime, shouldAcceptAutosuggestionOnKeyPress,
538
551
  onKeyDownHandler: keyDownHandler
539
552
  };
540
553
  }
554
+
555
+ // src/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.tsx
556
+ var import_react3 = require("react");
557
+ var import_slate2 = require("slate");
558
+ var import_slate_react = require("slate-react");
559
+
560
+ // src/lib/slatejs-edits/with-partial-history.ts
561
+ var import_slate = require("slate");
562
+ var import_slate_history = require("slate-history");
541
563
  var withPartialHistory = (editor, shouldSave2) => {
542
564
  const e = editor;
543
565
  const { apply } = e;
@@ -548,10 +570,10 @@ var withPartialHistory = (editor, shouldSave2) => {
548
570
  if (redos.length > 0) {
549
571
  const batch = redos[redos.length - 1];
550
572
  if (batch.selectionBefore) {
551
- slate.Transforms.setSelection(e, batch.selectionBefore);
573
+ import_slate.Transforms.setSelection(e, batch.selectionBefore);
552
574
  }
553
- slateHistory.HistoryEditor.withoutSaving(e, () => {
554
- slate.Editor.withoutNormalizing(e, () => {
575
+ import_slate_history.HistoryEditor.withoutSaving(e, () => {
576
+ import_slate.Editor.withoutNormalizing(e, () => {
555
577
  for (const op of batch.operations) {
556
578
  e.apply(op);
557
579
  }
@@ -566,14 +588,14 @@ var withPartialHistory = (editor, shouldSave2) => {
566
588
  const { undos } = history;
567
589
  if (undos.length > 0) {
568
590
  const batch = undos[undos.length - 1];
569
- slateHistory.HistoryEditor.withoutSaving(e, () => {
570
- slate.Editor.withoutNormalizing(e, () => {
571
- const inverseOps = batch.operations.map(slate.Operation.inverse).reverse();
591
+ import_slate_history.HistoryEditor.withoutSaving(e, () => {
592
+ import_slate.Editor.withoutNormalizing(e, () => {
593
+ const inverseOps = batch.operations.map(import_slate.Operation.inverse).reverse();
572
594
  for (const op of inverseOps) {
573
595
  e.apply(op);
574
596
  }
575
597
  if (batch.selectionBefore) {
576
- slate.Transforms.setSelection(e, batch.selectionBefore);
598
+ import_slate.Transforms.setSelection(e, batch.selectionBefore);
577
599
  }
578
600
  });
579
601
  });
@@ -586,8 +608,8 @@ var withPartialHistory = (editor, shouldSave2) => {
586
608
  const { undos } = history;
587
609
  const lastBatch = undos[undos.length - 1];
588
610
  const lastOp = lastBatch && lastBatch.operations[lastBatch.operations.length - 1];
589
- let save = slateHistory.HistoryEditor.isSaving(e);
590
- let merge2 = slateHistory.HistoryEditor.isMerging(e);
611
+ let save = import_slate_history.HistoryEditor.isSaving(e);
612
+ let merge2 = import_slate_history.HistoryEditor.isMerging(e);
591
613
  if (save == null) {
592
614
  save = shouldSave2(op, lastOp);
593
615
  }
@@ -623,10 +645,10 @@ var withPartialHistory = (editor, shouldSave2) => {
623
645
  return e;
624
646
  };
625
647
  var shouldMerge = (op, prev) => {
626
- if (prev && op.type === "insert_text" && prev.type === "insert_text" && op.offset === prev.offset + prev.text.length && slate.Path.equals(op.path, prev.path)) {
648
+ if (prev && op.type === "insert_text" && prev.type === "insert_text" && op.offset === prev.offset + prev.text.length && import_slate.Path.equals(op.path, prev.path)) {
627
649
  return true;
628
650
  }
629
- if (prev && op.type === "remove_text" && prev.type === "remove_text" && op.offset + op.text.length === prev.offset && slate.Path.equals(op.path, prev.path)) {
651
+ if (prev && op.type === "remove_text" && prev.type === "remove_text" && op.offset + op.text.length === prev.offset && import_slate.Path.equals(op.path, prev.path)) {
630
652
  return true;
631
653
  }
632
654
  return false;
@@ -641,10 +663,10 @@ var defaultShouldSave = (op, prev) => {
641
663
  // src/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.tsx
642
664
  var shouldSave = (op, prev) => {
643
665
  const excludedNodeType = "suggestion";
644
- if (op.type === "insert_node" && slate.Element.isElement(op.node) && op.node.type === excludedNodeType) {
666
+ if (op.type === "insert_node" && import_slate2.Element.isElement(op.node) && op.node.type === excludedNodeType) {
645
667
  return false;
646
668
  }
647
- if (op.type === "remove_node" && slate.Element.isElement(op.node) && op.node.type === excludedNodeType) {
669
+ if (op.type === "remove_node" && import_slate2.Element.isElement(op.node) && op.node.type === excludedNodeType) {
648
670
  return false;
649
671
  }
650
672
  if (op.type === "set_node" && "type" in op.newProperties && op.newProperties.type === excludedNodeType) {
@@ -659,11 +681,11 @@ var shouldSave = (op, prev) => {
659
681
  if (op.type === "split_node" && "type" in op.properties && op.properties.type === excludedNodeType) {
660
682
  return false;
661
683
  }
662
- return defaultShouldSave(op);
684
+ return defaultShouldSave(op, prev);
663
685
  };
664
686
  function useCopilotTextareaEditor() {
665
- const editor = React2.useMemo(() => {
666
- const editor2 = withPartialHistory(slateReact.withReact(slate.createEditor()), shouldSave);
687
+ const editor = (0, import_react3.useMemo)(() => {
688
+ const editor2 = withPartialHistory((0, import_slate_react.withReact)((0, import_slate2.createEditor)()), shouldSave);
667
689
  const { isVoid } = editor2;
668
690
  editor2.isVoid = (element) => {
669
691
  switch (element.type) {
@@ -695,19 +717,26 @@ function useCopilotTextareaEditor() {
695
717
  }, []);
696
718
  return editor;
697
719
  }
720
+
721
+ // src/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.ts
722
+ var import_react4 = __toESM(require("react"));
723
+ var import_slate_react2 = require("slate-react");
724
+
725
+ // src/lib/get-text-around-cursor.ts
726
+ var import_slate3 = require("slate");
698
727
  function getTextAroundCollapsedCursor(editor) {
699
728
  const { selection } = editor;
700
- if (!selection || !slate.Range.isCollapsed(selection)) {
729
+ if (!selection || !import_slate3.Range.isCollapsed(selection)) {
701
730
  return null;
702
731
  }
703
732
  const cursorPoint = selection.anchor;
704
733
  const beforeRange = {
705
- anchor: slate.Editor.start(editor, []),
734
+ anchor: import_slate3.Editor.start(editor, []),
706
735
  focus: cursorPoint
707
736
  };
708
737
  const afterRange = {
709
738
  anchor: cursorPoint,
710
- focus: slate.Editor.end(editor, [])
739
+ focus: import_slate3.Editor.end(editor, [])
711
740
  };
712
741
  const before = extractTextWithNewlines(editor, beforeRange);
713
742
  const after = extractTextWithNewlines(editor, afterRange);
@@ -724,12 +753,12 @@ function getTextAroundSelection(editor) {
724
753
  }
725
754
  const wellOrderedSelection = wellOrderedRange(selection);
726
755
  const beforeRange = {
727
- anchor: slate.Editor.start(editor, []),
756
+ anchor: import_slate3.Editor.start(editor, []),
728
757
  focus: wellOrderedSelection.anchor
729
758
  };
730
759
  const afterRange = {
731
760
  anchor: wellOrderedSelection.focus,
732
- focus: slate.Editor.end(editor, [])
761
+ focus: import_slate3.Editor.end(editor, [])
733
762
  };
734
763
  const before = extractTextWithNewlines(editor, beforeRange);
735
764
  const after = extractTextWithNewlines(editor, afterRange);
@@ -743,25 +772,25 @@ function getTextAroundSelection(editor) {
743
772
  }
744
773
  function getFullEditorTextWithNewlines(editor) {
745
774
  const fullDocumentRange = {
746
- anchor: slate.Editor.start(editor, []),
747
- focus: slate.Editor.end(editor, [])
775
+ anchor: import_slate3.Editor.start(editor, []),
776
+ focus: import_slate3.Editor.end(editor, [])
748
777
  };
749
778
  return extractTextWithNewlines(editor, fullDocumentRange);
750
779
  }
751
780
  function extractTextWithNewlines(editor, range) {
752
781
  const voids = false;
753
- const [start, end] = slate.Range.edges(range);
782
+ const [start, end] = import_slate3.Range.edges(range);
754
783
  let text = "";
755
784
  let lastBlock = null;
756
- for (const [node, path] of slate.Editor.nodes(editor, {
785
+ for (const [node, path] of import_slate3.Editor.nodes(editor, {
757
786
  at: range,
758
- match: slate.Text.isText,
787
+ match: import_slate3.Text.isText,
759
788
  voids
760
789
  })) {
761
790
  let t = node.text;
762
- const [block] = slate.Editor.above(editor, {
791
+ const [block] = import_slate3.Editor.above(editor, {
763
792
  at: path,
764
- match: (n) => slate.Element.isElement(n) && n.type === "paragraph"
793
+ match: (n) => import_slate3.Element.isElement(n) && n.type === "paragraph"
765
794
  }) || [null];
766
795
  if (lastBlock !== block && block) {
767
796
  if (lastBlock) {
@@ -769,10 +798,10 @@ function extractTextWithNewlines(editor, range) {
769
798
  }
770
799
  lastBlock = block;
771
800
  }
772
- if (slate.Path.equals(path, end.path)) {
801
+ if (import_slate3.Path.equals(path, end.path)) {
773
802
  t = t.slice(0, end.offset);
774
803
  }
775
- if (slate.Path.equals(path, start.path)) {
804
+ if (import_slate3.Path.equals(path, start.path)) {
776
805
  t = t.slice(start.offset);
777
806
  }
778
807
  text += t;
@@ -781,7 +810,7 @@ function extractTextWithNewlines(editor, range) {
781
810
  }
782
811
  function wellOrderedRange(range) {
783
812
  const { anchor, focus } = range;
784
- if (slate.Point.isBefore(anchor, focus)) {
813
+ if (import_slate3.Point.isBefore(anchor, focus)) {
785
814
  return range;
786
815
  }
787
816
  return {
@@ -789,15 +818,18 @@ function wellOrderedRange(range) {
789
818
  focus: anchor
790
819
  };
791
820
  }
821
+
822
+ // src/lib/slatejs-edits/replace-text.ts
823
+ var import_slate4 = require("slate");
792
824
  function replaceEditorText(editor, newText) {
793
- slate.Transforms.delete(editor, {
825
+ import_slate4.Transforms.delete(editor, {
794
826
  at: {
795
- anchor: slate.Editor.start(editor, []),
796
- focus: slate.Editor.end(editor, [])
827
+ anchor: import_slate4.Editor.start(editor, []),
828
+ focus: import_slate4.Editor.end(editor, [])
797
829
  }
798
830
  });
799
831
  if (newText && newText !== "") {
800
- slate.Transforms.insertNodes(
832
+ import_slate4.Transforms.insertNodes(
801
833
  editor,
802
834
  [
803
835
  {
@@ -814,7 +846,7 @@ function replaceEditorText(editor, newText) {
814
846
 
815
847
  // src/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.ts
816
848
  function usePopulateCopilotTextareaRef(editor, ref) {
817
- React2__namespace.default.useImperativeHandle(
849
+ import_react4.default.useImperativeHandle(
818
850
  ref,
819
851
  () => {
820
852
  class Combined {
@@ -867,10 +899,10 @@ function usePopulateCopilotTextareaRef(editor, ref) {
867
899
  this.editor = editor2;
868
900
  }
869
901
  focus() {
870
- slateReact.ReactEditor.focus(this.editor);
902
+ import_slate_react2.ReactEditor.focus(this.editor);
871
903
  }
872
904
  blur() {
873
- slateReact.ReactEditor.blur(this.editor);
905
+ import_slate_react2.ReactEditor.blur(this.editor);
874
906
  }
875
907
  get value() {
876
908
  return getFullEditorTextWithNewlines(this.editor);
@@ -879,7 +911,7 @@ function usePopulateCopilotTextareaRef(editor, ref) {
879
911
  replaceEditorText(this.editor, value);
880
912
  }
881
913
  }
882
- const editorHtmlElement = slateReact.ReactEditor.toDOMNode(editor, editor);
914
+ const editorHtmlElement = import_slate_react2.ReactEditor.toDOMNode(editor, editor);
883
915
  const customMethods = new CustomMethods(editor);
884
916
  const combined = new Combined(customMethods, editorHtmlElement);
885
917
  return new Proxy(combined, handler);
@@ -887,9 +919,12 @@ function usePopulateCopilotTextareaRef(editor, ref) {
887
919
  [editor]
888
920
  );
889
921
  }
922
+
923
+ // src/lib/slatejs-edits/add-autocompletions.ts
924
+ var import_slate5 = require("slate");
890
925
  function addAutocompletionsToEditor(editor, newSuggestion, point) {
891
926
  const editorPosition = editor.selection;
892
- slate.Transforms.insertNodes(
927
+ import_slate5.Transforms.insertNodes(
893
928
  editor,
894
929
  [
895
930
  {
@@ -907,23 +942,34 @@ function addAutocompletionsToEditor(editor, newSuggestion, point) {
907
942
  editor.selection = editorPosition;
908
943
  }
909
944
  }
945
+
946
+ // src/lib/slatejs-edits/clear-autocompletions.ts
947
+ var import_slate6 = require("slate");
910
948
  function clearAutocompletionsFromEditor(editor) {
911
949
  const paths = [];
912
- for (const [node, path] of slate.Node.nodes(editor)) {
913
- if (slate.Element.isElement(node) && node.type === "suggestion") {
950
+ for (const [node, path] of import_slate6.Node.nodes(editor)) {
951
+ if (import_slate6.Element.isElement(node) && node.type === "suggestion") {
914
952
  paths.push(path);
915
953
  }
916
954
  }
917
955
  for (const path of paths) {
918
956
  try {
919
- slate.Transforms.removeNodes(editor, { at: path });
957
+ import_slate6.Transforms.removeNodes(editor, { at: path });
920
958
  } catch (e) {
921
959
  console.log("CopilotTextarea.clearAutocompletionsFromEditor: error removing node", e);
922
960
  }
923
961
  }
924
962
  }
963
+
964
+ // src/components/hovering-toolbar/hovering-toolbar.tsx
965
+ var import_react10 = require("react");
966
+ var import_slate7 = require("slate");
967
+ var import_slate_react3 = require("slate-react");
968
+
969
+ // src/hooks/misc/use-autosize-textarea.tsx
970
+ var import_react5 = require("react");
925
971
  var useAutosizeTextArea = (textAreaRef, value) => {
926
- React2.useEffect(() => {
972
+ (0, import_react5.useEffect)(() => {
927
973
  if (textAreaRef.current !== null) {
928
974
  textAreaRef.current.style.height = "0px";
929
975
  const scrollHeight = textAreaRef.current.scrollHeight;
@@ -932,10 +978,18 @@ var useAutosizeTextArea = (textAreaRef, value) => {
932
978
  }, [textAreaRef, value]);
933
979
  };
934
980
  var use_autosize_textarea_default = useAutosizeTextArea;
935
- var Command = React2__namespace.forwardRef((_a, ref) => {
981
+
982
+ // src/components/source-search-box/source-search-box.tsx
983
+ var import_react6 = require("react");
984
+
985
+ // src/components/ui/command.tsx
986
+ var React2 = __toESM(require("react"));
987
+ var import_cmdk = require("cmdk");
988
+ var import_jsx_runtime = require("react/jsx-runtime");
989
+ var Command = React2.forwardRef((_a, ref) => {
936
990
  var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
937
- return /* @__PURE__ */ jsxRuntime.jsx(
938
- cmdk.Command,
991
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
992
+ import_cmdk.Command,
939
993
  __spreadValues({
940
994
  ref,
941
995
  className: cn(
@@ -945,11 +999,11 @@ var Command = React2__namespace.forwardRef((_a, ref) => {
945
999
  }, props)
946
1000
  );
947
1001
  });
948
- Command.displayName = cmdk.Command.displayName;
949
- var CommandInput = React2__namespace.forwardRef((_a, ref) => {
1002
+ Command.displayName = import_cmdk.Command.displayName;
1003
+ var CommandInput = React2.forwardRef((_a, ref) => {
950
1004
  var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
951
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center border-b px-3", "cmdk-input-wrapper": "", children: /* @__PURE__ */ jsxRuntime.jsx(
952
- cmdk.Command.Input,
1005
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "flex items-center border-b px-3", "cmdk-input-wrapper": "", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1006
+ import_cmdk.Command.Input,
953
1007
  __spreadValues({
954
1008
  ref,
955
1009
  className: cn(
@@ -959,24 +1013,24 @@ var CommandInput = React2__namespace.forwardRef((_a, ref) => {
959
1013
  }, props)
960
1014
  ) });
961
1015
  });
962
- CommandInput.displayName = cmdk.Command.Input.displayName;
963
- var CommandList = React2__namespace.forwardRef((_a, ref) => {
1016
+ CommandInput.displayName = import_cmdk.Command.Input.displayName;
1017
+ var CommandList = React2.forwardRef((_a, ref) => {
964
1018
  var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
965
- return /* @__PURE__ */ jsxRuntime.jsx(
966
- cmdk.Command.List,
1019
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1020
+ import_cmdk.Command.List,
967
1021
  __spreadValues({
968
1022
  ref,
969
1023
  className: cn("max-h-[300px] overflow-y-auto overflow-x-hidden pb-2", className)
970
1024
  }, props)
971
1025
  );
972
1026
  });
973
- CommandList.displayName = cmdk.Command.List.displayName;
974
- var CommandEmpty = React2__namespace.forwardRef((props, ref) => /* @__PURE__ */ jsxRuntime.jsx(cmdk.Command.Empty, __spreadValues({ ref, className: "py-6 text-center text-sm" }, props)));
975
- CommandEmpty.displayName = cmdk.Command.Empty.displayName;
976
- var CommandGroup = React2__namespace.forwardRef((_a, ref) => {
1027
+ CommandList.displayName = import_cmdk.Command.List.displayName;
1028
+ var CommandEmpty = React2.forwardRef((props, ref) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_cmdk.Command.Empty, __spreadValues({ ref, className: "py-6 text-center text-sm" }, props)));
1029
+ CommandEmpty.displayName = import_cmdk.Command.Empty.displayName;
1030
+ var CommandGroup = React2.forwardRef((_a, ref) => {
977
1031
  var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
978
- return /* @__PURE__ */ jsxRuntime.jsx(
979
- cmdk.Command.Group,
1032
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1033
+ import_cmdk.Command.Group,
980
1034
  __spreadValues({
981
1035
  ref,
982
1036
  className: cn(
@@ -986,22 +1040,22 @@ var CommandGroup = React2__namespace.forwardRef((_a, ref) => {
986
1040
  }, props)
987
1041
  );
988
1042
  });
989
- CommandGroup.displayName = cmdk.Command.Group.displayName;
990
- var CommandSeparator = React2__namespace.forwardRef((_a, ref) => {
1043
+ CommandGroup.displayName = import_cmdk.Command.Group.displayName;
1044
+ var CommandSeparator = React2.forwardRef((_a, ref) => {
991
1045
  var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
992
- return /* @__PURE__ */ jsxRuntime.jsx(
993
- cmdk.Command.Separator,
1046
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1047
+ import_cmdk.Command.Separator,
994
1048
  __spreadValues({
995
1049
  ref,
996
1050
  className: cn("-mx-1 h-px bg-border", className)
997
1051
  }, props)
998
1052
  );
999
1053
  });
1000
- CommandSeparator.displayName = cmdk.Command.Separator.displayName;
1001
- var CommandItem = React2__namespace.forwardRef((_a, ref) => {
1054
+ CommandSeparator.displayName = import_cmdk.Command.Separator.displayName;
1055
+ var CommandItem = React2.forwardRef((_a, ref) => {
1002
1056
  var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
1003
- return /* @__PURE__ */ jsxRuntime.jsx(
1004
- cmdk.Command.Item,
1057
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1058
+ import_cmdk.Command.Item,
1005
1059
  __spreadValues({
1006
1060
  ref,
1007
1061
  className: cn(
@@ -1011,10 +1065,23 @@ var CommandItem = React2__namespace.forwardRef((_a, ref) => {
1011
1065
  }, props)
1012
1066
  );
1013
1067
  });
1014
- CommandItem.displayName = cmdk.Command.Item.displayName;
1068
+ CommandItem.displayName = import_cmdk.Command.Item.displayName;
1069
+ var CommandShortcut = (_a) => {
1070
+ var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
1071
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1072
+ "span",
1073
+ __spreadValues({
1074
+ className: cn("ml-auto text-xs tracking-widest text-muted-foreground", className)
1075
+ }, props)
1076
+ );
1077
+ };
1078
+ CommandShortcut.displayName = "CommandShortcut";
1079
+
1080
+ // src/components/source-search-box/source-search-box.tsx
1081
+ var import_jsx_runtime2 = require("react/jsx-runtime");
1015
1082
  function SourceSearchBox(props) {
1016
- const [selectedValue, setSelectedValue] = React2.useState("");
1017
- return /* @__PURE__ */ jsxRuntime.jsxs(
1083
+ const [selectedValue, setSelectedValue] = (0, import_react6.useState)("");
1084
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
1018
1085
  Command,
1019
1086
  {
1020
1087
  className: "rounded-lg border shadow-md",
@@ -1030,7 +1097,7 @@ function SourceSearchBox(props) {
1030
1097
  return 0;
1031
1098
  },
1032
1099
  children: [
1033
- /* @__PURE__ */ jsxRuntime.jsx(
1100
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1034
1101
  CommandInput,
1035
1102
  {
1036
1103
  value: props.searchTerm,
@@ -1038,18 +1105,18 @@ function SourceSearchBox(props) {
1038
1105
  placeholder: "Search for a command..."
1039
1106
  }
1040
1107
  ),
1041
- /* @__PURE__ */ jsxRuntime.jsxs(CommandList, { children: [
1042
- /* @__PURE__ */ jsxRuntime.jsx(CommandEmpty, { children: "No results found." }),
1043
- /* @__PURE__ */ jsxRuntime.jsx(CommandGroup, { heading: "Available resources", children: props.suggestedFiles.map((filePointer) => {
1044
- return /* @__PURE__ */ jsxRuntime.jsx(
1108
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(CommandList, { children: [
1109
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(CommandEmpty, { children: "No results found." }),
1110
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(CommandGroup, { heading: "Available resources", children: props.suggestedFiles.map((filePointer) => {
1111
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1045
1112
  CommandItem,
1046
1113
  {
1047
1114
  value: filePointer.name,
1048
1115
  onSelect: (value) => {
1049
1116
  props.onSelectedFile(filePointer);
1050
1117
  },
1051
- children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: " px-3 flex flex-row gap-1 items-center", children: [
1052
- /* @__PURE__ */ jsxRuntime.jsx(Logo, { width: "20px", height: "20px", children: /* @__PURE__ */ jsxRuntime.jsx(
1118
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: " px-3 flex flex-row gap-1 items-center", children: [
1119
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Logo, { width: "20px", height: "20px", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1053
1120
  "img",
1054
1121
  {
1055
1122
  src: filePointer.iconImageUri,
@@ -1063,7 +1130,7 @@ function SourceSearchBox(props) {
1063
1130
  `word-${filePointer.sourceApplication}.${filePointer.name}`
1064
1131
  );
1065
1132
  }) }),
1066
- /* @__PURE__ */ jsxRuntime.jsx(CommandSeparator, {})
1133
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(CommandSeparator, {})
1067
1134
  ] })
1068
1135
  ]
1069
1136
  }
@@ -1074,9 +1141,15 @@ function Logo({
1074
1141
  width,
1075
1142
  height
1076
1143
  }) {
1077
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-center", style: { width, height }, children });
1144
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "flex items-center justify-center", style: { width, height }, children });
1078
1145
  }
1079
- var buttonVariants = classVarianceAuthority.cva(
1146
+
1147
+ // src/components/ui/button.tsx
1148
+ var React3 = __toESM(require("react"));
1149
+ var import_react_slot = require("@radix-ui/react-slot");
1150
+ var import_class_variance_authority = require("class-variance-authority");
1151
+ var import_jsx_runtime3 = require("react/jsx-runtime");
1152
+ var buttonVariants = (0, import_class_variance_authority.cva)(
1080
1153
  "inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",
1081
1154
  {
1082
1155
  variants: {
@@ -1101,22 +1174,31 @@ var buttonVariants = classVarianceAuthority.cva(
1101
1174
  }
1102
1175
  }
1103
1176
  );
1104
- var Button = React2__namespace.forwardRef(
1177
+ var Button = React3.forwardRef(
1105
1178
  (_a, ref) => {
1106
1179
  var _b = _a, { className, variant, size, asChild = false } = _b, props = __objRest(_b, ["className", "variant", "size", "asChild"]);
1107
- const Comp = asChild ? reactSlot.Slot : "button";
1108
- return /* @__PURE__ */ jsxRuntime.jsx(Comp, __spreadValues({ className: cn(buttonVariants({ variant, size, className })), ref }, props));
1180
+ const Comp = asChild ? import_react_slot.Slot : "button";
1181
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Comp, __spreadValues({ className: cn(buttonVariants({ variant, size, className })), ref }, props));
1109
1182
  }
1110
1183
  );
1111
1184
  Button.displayName = "Button";
1112
- var labelVariants = classVarianceAuthority.cva(
1185
+
1186
+ // src/components/ui/label.tsx
1187
+ var React4 = __toESM(require("react"));
1188
+ var LabelPrimitive = __toESM(require("@radix-ui/react-label"));
1189
+ var import_class_variance_authority2 = require("class-variance-authority");
1190
+ var import_jsx_runtime4 = require("react/jsx-runtime");
1191
+ var labelVariants = (0, import_class_variance_authority2.cva)(
1113
1192
  "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
1114
1193
  );
1115
- var Label = React2__namespace.forwardRef((_a, ref) => {
1194
+ var Label = React4.forwardRef((_a, ref) => {
1116
1195
  var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
1117
- return /* @__PURE__ */ jsxRuntime.jsx(LabelPrimitive__namespace.Root, __spreadValues({ ref, className: cn(labelVariants(), className) }, props));
1196
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(LabelPrimitive.Root, __spreadValues({ ref, className: cn(labelVariants(), className) }, props));
1118
1197
  });
1119
- Label.displayName = LabelPrimitive__namespace.Root.displayName;
1198
+ Label.displayName = LabelPrimitive.Root.displayName;
1199
+
1200
+ // src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.tsx
1201
+ var import_react7 = require("react");
1120
1202
 
1121
1203
  // src/lib/stream-promise-flatten.ts
1122
1204
  function streamPromiseFlatten(promise) {
@@ -1141,14 +1223,22 @@ function streamPromiseFlatten(promise) {
1141
1223
  }
1142
1224
  });
1143
1225
  }
1226
+
1227
+ // src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.tsx
1228
+ var import_react_core5 = require("@copilotkit/react-core");
1229
+
1230
+ // src/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.tsx
1231
+ var import_Chip = __toESM(require("@mui/material/Chip/Chip.js"));
1232
+ var import_Avatar = __toESM(require("@mui/material/Avatar/Avatar.js"));
1233
+ var import_jsx_runtime5 = require("react/jsx-runtime");
1144
1234
  var IncludedFilesPreview = ({
1145
1235
  includedFiles,
1146
1236
  setIncludedFiles
1147
1237
  }) => {
1148
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2 mt-2", children: [
1149
- /* @__PURE__ */ jsxRuntime.jsx(Label, { className: "", children: "Included context:" }),
1150
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-wrap gap-2", children: includedFiles.map((filePointer, index) => {
1151
- return /* @__PURE__ */ jsxRuntime.jsx(
1238
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex flex-col gap-2 mt-2", children: [
1239
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Label, { className: "", children: "Included context:" }),
1240
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "flex flex-wrap gap-2", children: includedFiles.map((filePointer, index) => {
1241
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1152
1242
  FileChipPreview,
1153
1243
  {
1154
1244
  filePointer,
@@ -1162,13 +1252,13 @@ var IncludedFilesPreview = ({
1162
1252
  ] });
1163
1253
  };
1164
1254
  var FileChipPreview = ({ filePointer, onDelete }) => {
1165
- return /* @__PURE__ */ jsxRuntime.jsx(
1166
- Chip__default.default,
1255
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1256
+ import_Chip.default,
1167
1257
  {
1168
1258
  label: filePointer.name,
1169
1259
  onDelete,
1170
- avatar: /* @__PURE__ */ jsxRuntime.jsx(
1171
- Avatar__default.default,
1260
+ avatar: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1261
+ import_Avatar.default,
1172
1262
  {
1173
1263
  src: filePointer.iconImageUri,
1174
1264
  alt: filePointer.sourceApplication,
@@ -1178,35 +1268,38 @@ var FileChipPreview = ({ filePointer, onDelete }) => {
1178
1268
  }
1179
1269
  );
1180
1270
  };
1271
+
1272
+ // src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.tsx
1273
+ var import_jsx_runtime6 = require("react/jsx-runtime");
1181
1274
  var HoveringInsertionPromptBoxCore = ({
1182
1275
  performInsertion,
1183
1276
  state,
1184
1277
  insertionOrEditingFunction,
1185
1278
  contextCategories
1186
1279
  }) => {
1187
- const { getDocumentsContext } = React2.useContext(reactCore.CopilotContext);
1188
- const [editSuggestion, setEditSuggestion] = React2.useState("");
1189
- const [suggestionIsLoading, setSuggestionIsLoading] = React2.useState(false);
1190
- const [adjustmentPrompt, setAdjustmentPrompt] = React2.useState("");
1191
- const [generatingSuggestion, setGeneratingSuggestion] = React2.useState(
1280
+ const { getDocumentsContext } = (0, import_react7.useContext)(import_react_core5.CopilotContext);
1281
+ const [editSuggestion, setEditSuggestion] = (0, import_react7.useState)("");
1282
+ const [suggestionIsLoading, setSuggestionIsLoading] = (0, import_react7.useState)(false);
1283
+ const [adjustmentPrompt, setAdjustmentPrompt] = (0, import_react7.useState)("");
1284
+ const [generatingSuggestion, setGeneratingSuggestion] = (0, import_react7.useState)(
1192
1285
  null
1193
1286
  );
1194
- const adjustmentTextAreaRef = React2.useRef(null);
1195
- const suggestionTextAreaRef = React2.useRef(null);
1196
- const [filePointers, setFilePointers] = React2.useState([]);
1197
- const [suggestedFiles, setSuggestedFiles] = React2.useState([]);
1198
- React2.useEffect(() => {
1287
+ const adjustmentTextAreaRef = (0, import_react7.useRef)(null);
1288
+ const suggestionTextAreaRef = (0, import_react7.useRef)(null);
1289
+ const [filePointers, setFilePointers] = (0, import_react7.useState)([]);
1290
+ const [suggestedFiles, setSuggestedFiles] = (0, import_react7.useState)([]);
1291
+ (0, import_react7.useEffect)(() => {
1199
1292
  setSuggestedFiles(getDocumentsContext(contextCategories));
1200
1293
  }, [contextCategories, getDocumentsContext]);
1201
1294
  use_autosize_textarea_default(suggestionTextAreaRef, editSuggestion || "");
1202
1295
  use_autosize_textarea_default(adjustmentTextAreaRef, adjustmentPrompt || "");
1203
- React2.useEffect(() => {
1296
+ (0, import_react7.useEffect)(() => {
1204
1297
  setTimeout(() => {
1205
1298
  var _a;
1206
1299
  (_a = adjustmentTextAreaRef.current) == null ? void 0 : _a.focus();
1207
1300
  }, 0);
1208
1301
  }, []);
1209
- React2.useEffect(() => {
1302
+ (0, import_react7.useEffect)(() => {
1210
1303
  if (!generatingSuggestion) {
1211
1304
  return;
1212
1305
  }
@@ -1244,7 +1337,7 @@ var HoveringInsertionPromptBoxCore = ({
1244
1337
  releaseLockIfNotClosed();
1245
1338
  };
1246
1339
  }, [generatingSuggestion]);
1247
- const beginGeneratingAdjustment = React2.useCallback(() => __async(void 0, null, function* () {
1340
+ const beginGeneratingAdjustment = (0, import_react7.useCallback)(() => __async(void 0, null, function* () {
1248
1341
  if (!adjustmentPrompt.trim()) {
1249
1342
  return;
1250
1343
  }
@@ -1273,10 +1366,10 @@ var HoveringInsertionPromptBoxCore = ({
1273
1366
  const textToEdit = editSuggestion || state.editorState.selectedText;
1274
1367
  const adjustmentLabel = textToEdit === "" ? "Describe the text you want to insert" : "Describe adjustments to the suggested text";
1275
1368
  const placeholder = textToEdit === "" ? "e.g. 'summarize the client's top 3 pain-points from @CallTranscript'" : "e.g. 'make it more formal', 'be more specific', ...";
1276
- const AdjustmentPromptComponent = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1277
- /* @__PURE__ */ jsxRuntime.jsx(Label, { className: "", children: adjustmentLabel }),
1278
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative w-full flex items-center", children: [
1279
- /* @__PURE__ */ jsxRuntime.jsx(
1369
+ const AdjustmentPromptComponent = /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
1370
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Label, { className: "", children: adjustmentLabel }),
1371
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "relative w-full flex items-center", children: [
1372
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1280
1373
  "textarea",
1281
1374
  {
1282
1375
  disabled: suggestionIsLoading,
@@ -1298,29 +1391,29 @@ var HoveringInsertionPromptBoxCore = ({
1298
1391
  rows: 1
1299
1392
  }
1300
1393
  ),
1301
- /* @__PURE__ */ jsxRuntime.jsx(
1394
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1302
1395
  "button",
1303
1396
  {
1304
1397
  onClick: beginGeneratingAdjustment,
1305
1398
  className: "absolute right-2 bg-blue-500 text-white w-8 h-8 rounded-full flex items-center justify-center",
1306
- children: /* @__PURE__ */ jsxRuntime.jsx("i", { className: "material-icons", children: "arrow_forward" })
1399
+ children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("i", { className: "material-icons", children: "arrow_forward" })
1307
1400
  }
1308
1401
  )
1309
1402
  ] })
1310
1403
  ] });
1311
- const SuggestionComponent = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1312
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-between items-end w-full", children: [
1313
- /* @__PURE__ */ jsxRuntime.jsx(Label, { className: "mt-4", children: "Suggested:" }),
1314
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ml-auto", children: isLoading && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center items-center", children: /* @__PURE__ */ jsxRuntime.jsx(
1404
+ const SuggestionComponent = /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
1405
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "flex justify-between items-end w-full", children: [
1406
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Label, { className: "mt-4", children: "Suggested:" }),
1407
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "ml-auto", children: isLoading && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "flex justify-center items-center", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1315
1408
  "div",
1316
1409
  {
1317
1410
  className: "inline-block h-4 w-4 animate-spin rounded-full border-4 border-solid border-current border-r-transparent align-[-0.125em] motion-reduce:animate-[spin_1.5s_linear_infinite]",
1318
1411
  role: "status",
1319
- children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "!absolute !-m-px !h-px !w-px !overflow-hidden !whitespace-nowrap !border-0 !p-0 ![clip:rect(0,0,0,0)]", children: "Loading..." })
1412
+ children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "!absolute !-m-px !h-px !w-px !overflow-hidden !whitespace-nowrap !border-0 !p-0 ![clip:rect(0,0,0,0)]", children: "Loading..." })
1320
1413
  }
1321
1414
  ) }) })
1322
1415
  ] }),
1323
- /* @__PURE__ */ jsxRuntime.jsx(
1416
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1324
1417
  "textarea",
1325
1418
  {
1326
1419
  ref: suggestionTextAreaRef,
@@ -1332,7 +1425,7 @@ var HoveringInsertionPromptBoxCore = ({
1332
1425
  }
1333
1426
  )
1334
1427
  ] });
1335
- const SubmitComponent = /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex w-full gap-4 justify-start", children: /* @__PURE__ */ jsxRuntime.jsxs(
1428
+ const SubmitComponent = /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "flex w-full gap-4 justify-start", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
1336
1429
  Button,
1337
1430
  {
1338
1431
  className: " bg-green-700 text-white",
@@ -1341,16 +1434,16 @@ var HoveringInsertionPromptBoxCore = ({
1341
1434
  },
1342
1435
  children: [
1343
1436
  "Insert ",
1344
- /* @__PURE__ */ jsxRuntime.jsx("i", { className: "material-icons", children: "check" })
1437
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("i", { className: "material-icons", children: "check" })
1345
1438
  ]
1346
1439
  }
1347
1440
  ) });
1348
1441
  const sourceSearchCandidate = adjustmentPrompt.split(" ").pop();
1349
1442
  const sourceSearchWord = (sourceSearchCandidate == null ? void 0 : sourceSearchCandidate.startsWith("@")) ? sourceSearchCandidate.slice(1) : void 0;
1350
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-full flex flex-col items-start relative gap-2", children: [
1443
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "w-full flex flex-col items-start relative gap-2", children: [
1351
1444
  AdjustmentPromptComponent,
1352
- filePointers.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(IncludedFilesPreview, { includedFiles: filePointers, setIncludedFiles: setFilePointers }),
1353
- sourceSearchWord !== void 0 && /* @__PURE__ */ jsxRuntime.jsx(
1445
+ filePointers.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(IncludedFilesPreview, { includedFiles: filePointers, setIncludedFiles: setFilePointers }),
1446
+ sourceSearchWord !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1354
1447
  SourceSearchBox,
1355
1448
  {
1356
1449
  searchTerm: sourceSearchWord,
@@ -1367,13 +1460,16 @@ var HoveringInsertionPromptBoxCore = ({
1367
1460
  generatingSuggestion ? SubmitComponent : null
1368
1461
  ] });
1369
1462
  };
1463
+
1464
+ // src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.tsx
1465
+ var import_jsx_runtime7 = require("react/jsx-runtime");
1370
1466
  var HoveringInsertionPromptBox = (props) => {
1371
- return /* @__PURE__ */ jsxRuntime.jsx(
1467
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1372
1468
  "div",
1373
1469
  {
1374
1470
  className: "flex flex-col justify-center items-center space-y-4 rounded-md border shadow-lg p-4 border-gray- bg-white",
1375
1471
  style: { width: "35rem" },
1376
- children: /* @__PURE__ */ jsxRuntime.jsx(
1472
+ children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1377
1473
  HoveringInsertionPromptBoxCore,
1378
1474
  {
1379
1475
  state: {
@@ -1387,7 +1483,13 @@ var HoveringInsertionPromptBox = (props) => {
1387
1483
  }
1388
1484
  );
1389
1485
  };
1390
- React2__namespace.default.forwardRef(
1486
+
1487
+ // src/components/hovering-toolbar/hovering-toolbar-components.tsx
1488
+ var import_css = require("@emotion/css");
1489
+ var import_react8 = __toESM(require("react"));
1490
+ var import_react_dom = __toESM(require("react-dom"));
1491
+ var import_jsx_runtime8 = require("react/jsx-runtime");
1492
+ var Button2 = import_react8.default.forwardRef(
1391
1493
  (_a, ref) => {
1392
1494
  var _b = _a, {
1393
1495
  className,
@@ -1398,13 +1500,13 @@ React2__namespace.default.forwardRef(
1398
1500
  "active",
1399
1501
  "reversed"
1400
1502
  ]);
1401
- return /* @__PURE__ */ jsxRuntime.jsx(
1503
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1402
1504
  "span",
1403
1505
  __spreadProps(__spreadValues({}, props), {
1404
1506
  ref,
1405
- className: css.cx(
1507
+ className: (0, import_css.cx)(
1406
1508
  className,
1407
- css.css`
1509
+ import_css.css`
1408
1510
  cursor: pointer;
1409
1511
  color: ${reversed ? active ? "white" : "#aaa" : active ? "black" : "#ccc"};
1410
1512
  `
@@ -1413,17 +1515,17 @@ React2__namespace.default.forwardRef(
1413
1515
  );
1414
1516
  }
1415
1517
  );
1416
- React2__namespace.default.forwardRef(
1518
+ var Icon = import_react8.default.forwardRef(
1417
1519
  (_a, ref) => {
1418
1520
  var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
1419
- return /* @__PURE__ */ jsxRuntime.jsx(
1521
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1420
1522
  "span",
1421
1523
  __spreadProps(__spreadValues({}, props), {
1422
1524
  ref,
1423
- className: css.cx(
1525
+ className: (0, import_css.cx)(
1424
1526
  "material-icons",
1425
1527
  className,
1426
- css.css`
1528
+ import_css.css`
1427
1529
  font-size: 18px;
1428
1530
  vertical-align: text-bottom;
1429
1531
  `
@@ -1432,17 +1534,17 @@ React2__namespace.default.forwardRef(
1432
1534
  );
1433
1535
  }
1434
1536
  );
1435
- var Menu = React2__namespace.default.forwardRef(
1537
+ var Menu = import_react8.default.forwardRef(
1436
1538
  (_a, ref) => {
1437
1539
  var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
1438
- return /* @__PURE__ */ jsxRuntime.jsx(
1540
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1439
1541
  "div",
1440
1542
  __spreadProps(__spreadValues({}, props), {
1441
1543
  "data-test-id": "menu",
1442
1544
  ref,
1443
- className: css.cx(
1545
+ className: (0, import_css.cx)(
1444
1546
  className,
1445
- css.css`
1547
+ import_css.css`
1446
1548
  & > * {
1447
1549
  display: inline-block;
1448
1550
  }
@@ -1457,18 +1559,18 @@ var Menu = React2__namespace.default.forwardRef(
1457
1559
  }
1458
1560
  );
1459
1561
  var Portal = ({ children }) => {
1460
- return typeof document === "object" ? ReactDOM__default.default.createPortal(children, document.body) : null;
1562
+ return typeof document === "object" ? import_react_dom.default.createPortal(children, document.body) : null;
1461
1563
  };
1462
- React2__namespace.default.forwardRef(
1564
+ var Toolbar = import_react8.default.forwardRef(
1463
1565
  (_a, ref) => {
1464
1566
  var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
1465
- return /* @__PURE__ */ jsxRuntime.jsx(
1567
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1466
1568
  Menu,
1467
1569
  __spreadProps(__spreadValues({}, props), {
1468
1570
  ref,
1469
- className: css.cx(
1571
+ className: (0, import_css.cx)(
1470
1572
  className,
1471
- css.css`
1573
+ import_css.css`
1472
1574
  position: relative;
1473
1575
  padding: 1px 18px 17px;
1474
1576
  margin: 0 -20px;
@@ -1480,26 +1582,33 @@ React2__namespace.default.forwardRef(
1480
1582
  );
1481
1583
  }
1482
1584
  );
1483
- var HoveringEditorContext = React2.createContext({
1585
+
1586
+ // src/components/hovering-toolbar/hovering-editor-provider.tsx
1587
+ var import_react9 = require("react");
1588
+ var import_jsx_runtime9 = require("react/jsx-runtime");
1589
+ var HoveringEditorContext = (0, import_react9.createContext)({
1484
1590
  isDisplayed: false,
1485
1591
  setIsDisplayed: () => {
1486
1592
  }
1487
1593
  });
1488
1594
  var HoveringEditorProvider = ({ children }) => {
1489
- const [isDisplayed, setIsDisplayed] = React2.useState(false);
1490
- return /* @__PURE__ */ jsxRuntime.jsx(HoveringEditorContext.Provider, { value: { isDisplayed, setIsDisplayed }, children });
1595
+ const [isDisplayed, setIsDisplayed] = (0, import_react9.useState)(false);
1596
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(HoveringEditorContext.Provider, { value: { isDisplayed, setIsDisplayed }, children });
1491
1597
  };
1492
- var useHoveringEditorContext = () => React2.useContext(HoveringEditorContext);
1598
+ var useHoveringEditorContext = () => (0, import_react9.useContext)(HoveringEditorContext);
1599
+
1600
+ // src/components/hovering-toolbar/hovering-toolbar.tsx
1601
+ var import_jsx_runtime10 = require("react/jsx-runtime");
1493
1602
  var HoveringToolbar = (props) => {
1494
- const ref = React2.useRef(null);
1495
- const editor = slateReact.useSlate();
1496
- const selection = slateReact.useSlateSelection();
1603
+ const ref = (0, import_react10.useRef)(null);
1604
+ const editor = (0, import_slate_react3.useSlate)();
1605
+ const selection = (0, import_slate_react3.useSlateSelection)();
1497
1606
  const { isDisplayed, setIsDisplayed } = useHoveringEditorContext();
1498
- const [isClient, setIsClient] = React2.useState(false);
1499
- React2.useEffect(() => {
1607
+ const [isClient, setIsClient] = (0, import_react10.useState)(false);
1608
+ (0, import_react10.useEffect)(() => {
1500
1609
  setIsClient(true);
1501
1610
  }, []);
1502
- React2.useEffect(() => {
1611
+ (0, import_react10.useEffect)(() => {
1503
1612
  const el = ref.current;
1504
1613
  const { selection: selection2 } = editor;
1505
1614
  if (!el) {
@@ -1537,7 +1646,7 @@ var HoveringToolbar = (props) => {
1537
1646
  el.style.top = `${top}px`;
1538
1647
  el.style.left = `${left}px`;
1539
1648
  });
1540
- React2.useEffect(() => {
1649
+ (0, import_react10.useEffect)(() => {
1541
1650
  const handleClickOutside = (event) => {
1542
1651
  if (ref.current && !ref.current.contains(event.target)) {
1543
1652
  setIsDisplayed(false);
@@ -1551,23 +1660,23 @@ var HoveringToolbar = (props) => {
1551
1660
  if (!isClient) {
1552
1661
  return null;
1553
1662
  }
1554
- return /* @__PURE__ */ jsxRuntime.jsx(Portal, { children: /* @__PURE__ */ jsxRuntime.jsx(
1663
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1555
1664
  Menu,
1556
1665
  {
1557
1666
  ref,
1558
1667
  className: props.hoverMenuClassname || "p-2 absolute z-10 top-[-10000px] left-[-10000px] mt-[-6px] opacity-0 transition-opacity duration-700",
1559
- children: isDisplayed && selection && /* @__PURE__ */ jsxRuntime.jsx(
1668
+ children: isDisplayed && selection && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1560
1669
  HoveringInsertionPromptBox,
1561
1670
  {
1562
- editorState: editorState(editor),
1671
+ editorState: editorState(editor, selection),
1563
1672
  apiConfig: props.apiConfig,
1564
1673
  closeWindow: () => {
1565
1674
  setIsDisplayed(false);
1566
1675
  },
1567
1676
  performInsertion: (insertedText) => {
1568
1677
  console.log("inserted text", insertedText);
1569
- slate.Transforms.delete(editor, { at: selection });
1570
- slate.Transforms.insertText(editor, insertedText, {
1678
+ import_slate7.Transforms.delete(editor, { at: selection });
1679
+ import_slate7.Transforms.insertText(editor, insertedText, {
1571
1680
  at: selection
1572
1681
  });
1573
1682
  setIsDisplayed(false);
@@ -1589,21 +1698,24 @@ function editorState(editor, selection) {
1589
1698
  selectedText: ""
1590
1699
  };
1591
1700
  }
1701
+
1702
+ // src/components/base-copilot-textarea/render-element.tsx
1703
+ var import_jsx_runtime11 = require("react/jsx-runtime");
1592
1704
  function makeRenderElementFunction(suggestionsStyle) {
1593
1705
  return (props) => {
1594
1706
  switch (props.element.type) {
1595
1707
  case "paragraph":
1596
- return /* @__PURE__ */ jsxRuntime.jsx(DefaultElement, __spreadValues({}, props));
1708
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(DefaultElement, __spreadValues({}, props));
1597
1709
  case "suggestion":
1598
- return /* @__PURE__ */ jsxRuntime.jsx(SuggestionElement, __spreadProps(__spreadValues({}, props), { suggestionsStyle }));
1710
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(SuggestionElement, __spreadProps(__spreadValues({}, props), { suggestionsStyle }));
1599
1711
  }
1600
1712
  };
1601
1713
  }
1602
1714
  var DefaultElement = (props) => {
1603
- return /* @__PURE__ */ jsxRuntime.jsx("div", __spreadProps(__spreadValues({}, props.attributes), { children: props.children }));
1715
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", __spreadProps(__spreadValues({}, props.attributes), { children: props.children }));
1604
1716
  };
1605
1717
  var SuggestionElement = (props) => {
1606
- return /* @__PURE__ */ jsxRuntime.jsxs(
1718
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
1607
1719
  "span",
1608
1720
  __spreadProps(__spreadValues({}, props.attributes), {
1609
1721
  style: __spreadValues({}, props.suggestionsStyle),
@@ -1615,10 +1727,13 @@ var SuggestionElement = (props) => {
1615
1727
  })
1616
1728
  );
1617
1729
  };
1730
+
1731
+ // src/components/base-copilot-textarea/render-placeholder.tsx
1732
+ var import_jsx_runtime12 = require("react/jsx-runtime");
1618
1733
  function makeRenderPlaceholderFunction(placeholderStyle) {
1619
1734
  return (props) => {
1620
1735
  const _a = props.attributes, { style } = _a, restAttributes = __objRest(_a, ["style"]);
1621
- return /* @__PURE__ */ jsxRuntime.jsx(
1736
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1622
1737
  "div",
1623
1738
  __spreadProps(__spreadValues({}, restAttributes), {
1624
1739
  style: __spreadValues(__spreadValues({}, style), placeholderStyle),
@@ -1627,9 +1742,12 @@ function makeRenderPlaceholderFunction(placeholderStyle) {
1627
1742
  );
1628
1743
  };
1629
1744
  }
1745
+
1746
+ // src/components/base-copilot-textarea/use-add-branding-css.tsx
1747
+ var import_react11 = require("react");
1630
1748
  function useAddBrandingCss(suggestionStyleAugmented, disableBranding) {
1631
1749
  const cssSelector = ".copilot-textarea.with-branding";
1632
- React2.useEffect(() => {
1750
+ (0, import_react11.useEffect)(() => {
1633
1751
  if (disableBranding) {
1634
1752
  return;
1635
1753
  }
@@ -1679,10 +1797,18 @@ function useAddBrandingCss(suggestionStyleAugmented, disableBranding) {
1679
1797
  };
1680
1798
  }, [disableBranding, suggestionStyleAugmented]);
1681
1799
  }
1800
+
1801
+ // src/components/base-copilot-textarea/track-cursor-moved-since-last-text-change.tsx
1802
+ var import_react12 = require("react");
1803
+ var import_slate_react4 = require("slate-react");
1804
+ var import_slate9 = require("slate");
1805
+
1806
+ // src/lib/editor-to-text.ts
1807
+ var import_slate8 = require("slate");
1682
1808
  function nodeChildrenToTextComponents(editor, nodes) {
1683
1809
  const indeciesOfInlineElements = new Set(
1684
1810
  nodes.map((node, index) => {
1685
- if (slate.Element.isElement(node) && editor.isInline(node)) {
1811
+ if (import_slate8.Element.isElement(node) && editor.isInline(node)) {
1686
1812
  return index;
1687
1813
  }
1688
1814
  return -1;
@@ -1700,7 +1826,7 @@ function nodeChildrenToTextComponents(editor, nodes) {
1700
1826
  return true;
1701
1827
  });
1702
1828
  return nonIgnorableItems.map((node) => {
1703
- if (slate.Element.isElement(node)) {
1829
+ if (import_slate8.Element.isElement(node)) {
1704
1830
  switch (node.type) {
1705
1831
  case "paragraph":
1706
1832
  return nodeChildrenToTextComponents(editor, node.children);
@@ -1717,13 +1843,16 @@ var editorToText = (editor) => {
1717
1843
  const text = flattened.map((textComponent) => textComponent.text).join("\n");
1718
1844
  return text;
1719
1845
  };
1846
+
1847
+ // src/components/base-copilot-textarea/track-cursor-moved-since-last-text-change.tsx
1848
+ var import_jsx_runtime13 = require("react/jsx-runtime");
1720
1849
  function TrackerTextEditedSinceLastCursorMovement(props) {
1721
- const cursorState = slateReact.useSlateSelector((state) => ({
1850
+ const cursorState = (0, import_slate_react4.useSlateSelector)((state) => ({
1722
1851
  selection: state.selection,
1723
1852
  text: editorToText(state)
1724
1853
  }));
1725
1854
  const previousState = usePrevious(cursorState);
1726
- React2.useEffect(() => {
1855
+ (0, import_react12.useEffect)(() => {
1727
1856
  if (!previousState) {
1728
1857
  return;
1729
1858
  }
@@ -1731,7 +1860,7 @@ function TrackerTextEditedSinceLastCursorMovement(props) {
1731
1860
  props.setCursorMovedSinceLastTextChange(true);
1732
1861
  }
1733
1862
  }, [props.setCursorMovedSinceLastTextChange, cursorState]);
1734
- return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {});
1863
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_jsx_runtime13.Fragment, {});
1735
1864
  }
1736
1865
  var cursorChangedWithoutTextChanged = (prev, next) => {
1737
1866
  const isSelectionChanged = !isSelectionEqual(prev.selection, next.selection);
@@ -1743,30 +1872,33 @@ var isSelectionEqual = (a, b) => {
1743
1872
  return true;
1744
1873
  if (!a || !b)
1745
1874
  return false;
1746
- return slate.Range.equals(a, b);
1875
+ return import_slate9.Range.equals(a, b);
1747
1876
  };
1748
1877
  function usePrevious(value) {
1749
- const ref = React2.useRef();
1750
- React2.useEffect(() => {
1878
+ const ref = (0, import_react12.useRef)();
1879
+ (0, import_react12.useEffect)(() => {
1751
1880
  ref.current = value;
1752
1881
  });
1753
1882
  return ref.current;
1754
1883
  }
1755
- var BaseCopilotTextarea = React2__namespace.default.forwardRef(
1884
+
1885
+ // src/components/base-copilot-textarea/base-copilot-textarea.tsx
1886
+ var import_jsx_runtime14 = require("react/jsx-runtime");
1887
+ var BaseCopilotTextarea = import_react13.default.forwardRef(
1756
1888
  (props, ref) => {
1757
- return /* @__PURE__ */ jsxRuntime.jsx(HoveringEditorProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(BaseCopilotTextareaWithHoveringContext, __spreadProps(__spreadValues({}, props), { ref })) });
1889
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(HoveringEditorProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(BaseCopilotTextareaWithHoveringContext, __spreadProps(__spreadValues({}, props), { ref })) });
1758
1890
  }
1759
1891
  );
1760
- var BaseCopilotTextareaWithHoveringContext = React2__namespace.default.forwardRef(
1892
+ var BaseCopilotTextareaWithHoveringContext = import_react13.default.forwardRef(
1761
1893
  (props, ref) => {
1762
1894
  const autosuggestionsConfig = __spreadValues(__spreadValues({}, defaultBaseAutosuggestionsConfig), props.baseAutosuggestionsConfig);
1763
- const valueOnInitialRender = React2.useMemo(() => {
1895
+ const valueOnInitialRender = (0, import_react13.useMemo)(() => {
1764
1896
  var _a2;
1765
1897
  return (_a2 = props.value) != null ? _a2 : "";
1766
1898
  }, []);
1767
- const [lastKnownFullEditorText, setLastKnownFullEditorText] = React2.useState(valueOnInitialRender);
1768
- const [cursorMovedSinceLastTextChange, setCursorMovedSinceLastTextChange] = React2.useState(false);
1769
- const initialValue = React2.useMemo(() => {
1899
+ const [lastKnownFullEditorText, setLastKnownFullEditorText] = (0, import_react13.useState)(valueOnInitialRender);
1900
+ const [cursorMovedSinceLastTextChange, setCursorMovedSinceLastTextChange] = (0, import_react13.useState)(false);
1901
+ const initialValue = (0, import_react13.useMemo)(() => {
1770
1902
  return [
1771
1903
  {
1772
1904
  type: "paragraph",
@@ -1776,9 +1908,9 @@ var BaseCopilotTextareaWithHoveringContext = React2__namespace.default.forwardRe
1776
1908
  }, [valueOnInitialRender]);
1777
1909
  const editor = useCopilotTextareaEditor();
1778
1910
  const { isDisplayed: hoveringEditorIsDisplayed, setIsDisplayed: setHoveringEditorIsDisplayed } = useHoveringEditorContext();
1779
- const insertText = React2.useCallback(
1911
+ const insertText = (0, import_react13.useCallback)(
1780
1912
  (autosuggestion) => {
1781
- slate.Editor.insertText(editor, autosuggestion.text, {
1913
+ import_slate10.Editor.insertText(editor, autosuggestion.text, {
1782
1914
  at: autosuggestion.point
1783
1915
  });
1784
1916
  },
@@ -1802,7 +1934,7 @@ var BaseCopilotTextareaWithHoveringContext = React2__namespace.default.forwardRe
1802
1934
  autosuggestionsConfig.disableWhenEmpty,
1803
1935
  shouldDisableAutosuggestions
1804
1936
  );
1805
- const onKeyDownHandlerForHoveringEditor = React2.useCallback(
1937
+ const onKeyDownHandlerForHoveringEditor = (0, import_react13.useCallback)(
1806
1938
  (event) => {
1807
1939
  if (autosuggestionsConfig.shouldToggleHoveringEditorOnKeyPress(event)) {
1808
1940
  event.preventDefault();
@@ -1815,7 +1947,7 @@ var BaseCopilotTextareaWithHoveringContext = React2__namespace.default.forwardRe
1815
1947
  autosuggestionsConfig.shouldToggleHoveringEditorOnKeyPress
1816
1948
  ]
1817
1949
  );
1818
- React2.useEffect(() => {
1950
+ (0, import_react13.useEffect)(() => {
1819
1951
  clearAutocompletionsFromEditor(editor);
1820
1952
  if (currentAutocompleteSuggestion) {
1821
1953
  addAutocompletionsToEditor(
@@ -1825,23 +1957,23 @@ var BaseCopilotTextareaWithHoveringContext = React2__namespace.default.forwardRe
1825
1957
  );
1826
1958
  }
1827
1959
  }, [currentAutocompleteSuggestion]);
1828
- const suggestionStyleAugmented = React2.useMemo(() => {
1960
+ const suggestionStyleAugmented = (0, import_react13.useMemo)(() => {
1829
1961
  return __spreadValues({
1830
1962
  fontStyle: "italic",
1831
1963
  color: "gray"
1832
1964
  }, props.suggestionsStyle);
1833
1965
  }, [props.suggestionsStyle]);
1834
- const renderElementMemoized = React2.useMemo(() => {
1966
+ const renderElementMemoized = (0, import_react13.useMemo)(() => {
1835
1967
  return makeRenderElementFunction(suggestionStyleAugmented);
1836
1968
  }, [suggestionStyleAugmented]);
1837
- const renderPlaceholderMemoized = React2.useMemo(() => {
1969
+ const renderPlaceholderMemoized = (0, import_react13.useMemo)(() => {
1838
1970
  const placeholderStyleSlatejsOverrides = {
1839
1971
  top: void 0
1840
1972
  };
1841
1973
  const placeholderStyleAugmented = __spreadValues(__spreadValues({}, placeholderStyleSlatejsOverrides), props.placeholderStyle);
1842
1974
  return makeRenderPlaceholderFunction(placeholderStyleAugmented);
1843
1975
  }, [props.placeholderStyle]);
1844
- React2.useEffect(() => {
1976
+ (0, import_react13.useEffect)(() => {
1845
1977
  var _a2, _b;
1846
1978
  if (props.value === lastKnownFullEditorText) {
1847
1979
  return;
@@ -1876,11 +2008,11 @@ var BaseCopilotTextareaWithHoveringContext = React2__namespace.default.forwardRe
1876
2008
  const baseClassName = "copilot-textarea";
1877
2009
  const brandingClass = disableBranding ? "no-branding" : "with-branding";
1878
2010
  const defaultTailwindClassName = "bg-white overflow-y-auto resize-y";
1879
- const mergedClassName = tailwindMerge.twMerge(defaultTailwindClassName, className != null ? className : "");
2011
+ const mergedClassName = (0, import_tailwind_merge2.twMerge)(defaultTailwindClassName, className != null ? className : "");
1880
2012
  return `${baseClassName} ${brandingClass} ${mergedClassName}`;
1881
2013
  })();
1882
- return /* @__PURE__ */ jsxRuntime.jsxs(
1883
- slateReact.Slate,
2014
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
2015
+ import_slate_react5.Slate,
1884
2016
  {
1885
2017
  editor,
1886
2018
  initialValue,
@@ -1899,13 +2031,13 @@ var BaseCopilotTextareaWithHoveringContext = React2__namespace.default.forwardRe
1899
2031
  (_b = props.onChange) == null ? void 0 : _b.call(props, makeSemiFakeReactTextAreaEvent(fullEditorText));
1900
2032
  },
1901
2033
  children: [
1902
- /* @__PURE__ */ jsxRuntime.jsx(
2034
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1903
2035
  TrackerTextEditedSinceLastCursorMovement,
1904
2036
  {
1905
2037
  setCursorMovedSinceLastTextChange
1906
2038
  }
1907
2039
  ),
1908
- /* @__PURE__ */ jsxRuntime.jsx(
2040
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1909
2041
  HoveringToolbar,
1910
2042
  {
1911
2043
  apiConfig: autosuggestionsConfig.apiConfig,
@@ -1913,8 +2045,8 @@ var BaseCopilotTextareaWithHoveringContext = React2__namespace.default.forwardRe
1913
2045
  hoverMenuClassname
1914
2046
  }
1915
2047
  ),
1916
- /* @__PURE__ */ jsxRuntime.jsx(
1917
- slateReact.Editable,
2048
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2049
+ import_slate_react5.Editable,
1918
2050
  __spreadValues({
1919
2051
  renderElement: renderElementMemoized,
1920
2052
  renderPlaceholder: renderPlaceholderMemoized,
@@ -1944,9 +2076,14 @@ function makeSemiFakeReactTextAreaEvent(currentText) {
1944
2076
  }
1945
2077
  };
1946
2078
  }
2079
+
2080
+ // src/hooks/make-autosuggestions-function/use-make-standard-insertion-function.tsx
2081
+ var import_react_core6 = require("@copilotkit/react-core");
2082
+ var import_react14 = require("react");
2083
+ var import_react_core7 = require("@copilotkit/react-core");
1947
2084
  function useMakeStandardInsertionOrEditingFunction(textareaPurpose, contextCategories, insertionApiConfig, editingApiConfig) {
1948
- const { getContextString, copilotApiConfig } = React2.useContext(reactCore.CopilotContext);
1949
- const insertionFunction = React2.useCallback(
2085
+ const { getContextString, copilotApiConfig } = (0, import_react14.useContext)(import_react_core6.CopilotContext);
2086
+ const insertionFunction = (0, import_react14.useCallback)(
1950
2087
  (editorState2, insertionPrompt, documents, abortSignal) => __async(this, null, function* () {
1951
2088
  const res = yield retry(() => __async(this, null, function* () {
1952
2089
  const messages = [
@@ -1974,7 +2111,7 @@ function useMakeStandardInsertionOrEditingFunction(textareaPurpose, contextCateg
1974
2111
  content: insertionPrompt
1975
2112
  }
1976
2113
  ];
1977
- const stream = yield reactCore.fetchAndDecodeChatCompletionAsText(__spreadProps(__spreadValues({
2114
+ const stream = yield (0, import_react_core7.fetchAndDecodeChatCompletionAsText)(__spreadProps(__spreadValues({
1978
2115
  messages
1979
2116
  }, insertionApiConfig.forwardedParams), {
1980
2117
  copilotConfig: copilotApiConfig,
@@ -1986,7 +2123,7 @@ function useMakeStandardInsertionOrEditingFunction(textareaPurpose, contextCateg
1986
2123
  }),
1987
2124
  [insertionApiConfig, getContextString, contextCategories, textareaPurpose]
1988
2125
  );
1989
- const editingFunction = React2.useCallback(
2126
+ const editingFunction = (0, import_react14.useCallback)(
1990
2127
  (editorState2, editingPrompt, documents, abortSignal) => __async(this, null, function* () {
1991
2128
  const res = yield retry(() => __async(this, null, function* () {
1992
2129
  const messages = [
@@ -2019,7 +2156,7 @@ function useMakeStandardInsertionOrEditingFunction(textareaPurpose, contextCateg
2019
2156
  content: editingPrompt
2020
2157
  }
2021
2158
  ];
2022
- const stream = yield reactCore.fetchAndDecodeChatCompletionAsText(__spreadProps(__spreadValues({
2159
+ const stream = yield (0, import_react_core7.fetchAndDecodeChatCompletionAsText)(__spreadProps(__spreadValues({
2023
2160
  messages
2024
2161
  }, editingApiConfig.forwardedParams), {
2025
2162
  copilotConfig: copilotApiConfig,
@@ -2031,7 +2168,7 @@ function useMakeStandardInsertionOrEditingFunction(textareaPurpose, contextCateg
2031
2168
  }),
2032
2169
  [editingApiConfig, getContextString, contextCategories, textareaPurpose]
2033
2170
  );
2034
- const insertionOrEditingFunction = React2.useCallback(
2171
+ const insertionOrEditingFunction = (0, import_react14.useCallback)(
2035
2172
  (editorState2, insertionPrompt, documents, abortSignal) => __async(this, null, function* () {
2036
2173
  if (editorState2.selectedText === "") {
2037
2174
  return yield insertionFunction(editorState2, insertionPrompt, documents, abortSignal);
@@ -2043,10 +2180,14 @@ function useMakeStandardInsertionOrEditingFunction(textareaPurpose, contextCateg
2043
2180
  );
2044
2181
  return insertionOrEditingFunction;
2045
2182
  }
2046
- var CopilotTextarea = React2__namespace.default.forwardRef(
2183
+
2184
+ // src/components/copilot-textarea/copilot-textarea.tsx
2185
+ var import_lodash = __toESM(require("lodash.merge"));
2186
+ var import_jsx_runtime15 = require("react/jsx-runtime");
2187
+ var CopilotTextarea = import_react15.default.forwardRef(
2047
2188
  (props, ref) => {
2048
2189
  const _a = props, { autosuggestionsConfig: autosuggestionsConfigUserSpecified } = _a, forwardedProps = __objRest(_a, ["autosuggestionsConfig"]);
2049
- const autosuggestionsConfig = merge__default.default(
2190
+ const autosuggestionsConfig = (0, import_lodash.default)(
2050
2191
  defaultAutosuggestionsConfig,
2051
2192
  autosuggestionsConfigUserSpecified
2052
2193
  );
@@ -2061,7 +2202,7 @@ var CopilotTextarea = React2__namespace.default.forwardRef(
2061
2202
  autosuggestionsConfig.chatApiConfigs.insertionApiConfig,
2062
2203
  autosuggestionsConfig.chatApiConfigs.editingApiConfig
2063
2204
  );
2064
- return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsx(
2205
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_jsx_runtime15.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
2065
2206
  BaseCopilotTextarea,
2066
2207
  __spreadProps(__spreadValues({
2067
2208
  ref
@@ -2076,7 +2217,8 @@ var CopilotTextarea = React2__namespace.default.forwardRef(
2076
2217
  ) });
2077
2218
  }
2078
2219
  );
2079
-
2080
- exports.CopilotTextarea = CopilotTextarea;
2081
- //# sourceMappingURL=out.js.map
2220
+ // Annotate the CommonJS export names for ESM import in node:
2221
+ 0 && (module.exports = {
2222
+ CopilotTextarea
2223
+ });
2082
2224
  //# sourceMappingURL=copilot-textarea.js.map