@copilotkit/react-textarea 0.28.0-alpha.7 → 0.28.0-alpha.9

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 +341 -379
  2. package/CHANGELOG.md +24 -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 slate = require('slate');
5
- var slateReact = require('slate-react');
6
- var tailwindMerge = require('tailwind-merge');
7
- var clsx = require('clsx');
8
- var nanoid = require('nanoid');
9
- var slateHistory = require('slate-history');
10
- var reactCore = require('@copilotkit/react-core');
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,23 @@ var __async = (__this, __arguments, generator) => {
98
76
  });
99
77
  };
100
78
 
79
+ // src/components/index.ts
80
+ var components_exports = {};
81
+ __export(components_exports, {
82
+ BaseCopilotTextarea: () => BaseCopilotTextarea,
83
+ CopilotTextarea: () => CopilotTextarea
84
+ });
85
+ module.exports = __toCommonJS(components_exports);
86
+
87
+ // src/components/base-copilot-textarea/base-copilot-textarea.tsx
88
+ var import_react12 = __toESM(require("react"));
89
+ var import_slate10 = require("slate");
90
+ var import_slate_react5 = require("slate-react");
91
+ var import_tailwind_merge2 = require("tailwind-merge");
92
+
93
+ // src/hooks/base-copilot-textarea-implementation/use-autosuggestions.ts
94
+ var import_react = require("react");
95
+
101
96
  // src/lib/debouncer.ts
102
97
  var Debouncer = class {
103
98
  constructor(wait) {
@@ -125,10 +120,15 @@ var Debouncer = class {
125
120
  };
126
121
  }
127
122
  };
123
+
124
+ // src/lib/utils.ts
125
+ var import_clsx = require("clsx");
126
+ var import_nanoid = require("nanoid");
127
+ var import_tailwind_merge = require("tailwind-merge");
128
128
  function cn(...inputs) {
129
- return tailwindMerge.twMerge(clsx.clsx(inputs));
129
+ return (0, import_tailwind_merge.twMerge)((0, import_clsx.clsx)(inputs));
130
130
  }
131
- nanoid.customAlphabet(
131
+ var nanoid = (0, import_nanoid.customAlphabet)(
132
132
  "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
133
133
  7
134
134
  );
@@ -147,9 +147,9 @@ function areEqual_autocompleteState(prev, next) {
147
147
 
148
148
  // src/hooks/base-copilot-textarea-implementation/use-autosuggestions.ts
149
149
  function useAutosuggestions(debounceTime, shouldAcceptAutosuggestionOnKeyPress, autosuggestionFunction, insertAutocompleteSuggestion, disableWhenEmpty, disabled) {
150
- const [previousAutocompleteState, setPreviousAutocompleteState] = React2.useState(null);
151
- const [currentAutocompleteSuggestion, setCurrentAutocompleteSuggestion] = React2.useState(null);
152
- const awaitForAndAppendSuggestion = React2.useCallback(
150
+ const [previousAutocompleteState, setPreviousAutocompleteState] = (0, import_react.useState)(null);
151
+ const [currentAutocompleteSuggestion, setCurrentAutocompleteSuggestion] = (0, import_react.useState)(null);
152
+ const awaitForAndAppendSuggestion = (0, import_react.useCallback)(
153
153
  (editorAutocompleteState, abortSignal) => __async(this, null, function* () {
154
154
  if (disabled) {
155
155
  return;
@@ -168,17 +168,17 @@ function useAutosuggestions(debounceTime, shouldAcceptAutosuggestionOnKeyPress,
168
168
  }),
169
169
  [autosuggestionFunction, setCurrentAutocompleteSuggestion, disableWhenEmpty, disabled]
170
170
  );
171
- const debouncedFunction = React2.useMemo(
171
+ const debouncedFunction = (0, import_react.useMemo)(
172
172
  () => new Debouncer(debounceTime),
173
173
  [debounceTime]
174
174
  );
175
- React2.useEffect(() => {
175
+ (0, import_react.useEffect)(() => {
176
176
  return () => {
177
177
  debouncedFunction.cancel();
178
178
  setCurrentAutocompleteSuggestion(null);
179
179
  };
180
180
  }, [debouncedFunction, disabled]);
181
- const onChange = React2.useCallback(
181
+ const onChange = (0, import_react.useCallback)(
182
182
  (newEditorState) => {
183
183
  const editorStateHasChanged = !nullableCompatibleEqualityCheck(
184
184
  areEqual_autocompleteState,
@@ -204,7 +204,7 @@ function useAutosuggestions(debounceTime, shouldAcceptAutosuggestionOnKeyPress,
204
204
  setCurrentAutocompleteSuggestion
205
205
  ]
206
206
  );
207
- const keyDownHandler = React2.useCallback(
207
+ const keyDownHandler = (0, import_react.useCallback)(
208
208
  (event) => {
209
209
  if (currentAutocompleteSuggestion) {
210
210
  if (shouldAcceptAutosuggestionOnKeyPress(event)) {
@@ -227,6 +227,15 @@ function useAutosuggestions(debounceTime, shouldAcceptAutosuggestionOnKeyPress,
227
227
  onKeyDownHandler: keyDownHandler
228
228
  };
229
229
  }
230
+
231
+ // src/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.tsx
232
+ var import_react2 = require("react");
233
+ var import_slate2 = require("slate");
234
+ var import_slate_react = require("slate-react");
235
+
236
+ // src/lib/slatejs-edits/with-partial-history.ts
237
+ var import_slate = require("slate");
238
+ var import_slate_history = require("slate-history");
230
239
  var withPartialHistory = (editor, shouldSave2) => {
231
240
  const e = editor;
232
241
  const { apply } = e;
@@ -237,10 +246,10 @@ var withPartialHistory = (editor, shouldSave2) => {
237
246
  if (redos.length > 0) {
238
247
  const batch = redos[redos.length - 1];
239
248
  if (batch.selectionBefore) {
240
- slate.Transforms.setSelection(e, batch.selectionBefore);
249
+ import_slate.Transforms.setSelection(e, batch.selectionBefore);
241
250
  }
242
- slateHistory.HistoryEditor.withoutSaving(e, () => {
243
- slate.Editor.withoutNormalizing(e, () => {
251
+ import_slate_history.HistoryEditor.withoutSaving(e, () => {
252
+ import_slate.Editor.withoutNormalizing(e, () => {
244
253
  for (const op of batch.operations) {
245
254
  e.apply(op);
246
255
  }
@@ -255,14 +264,14 @@ var withPartialHistory = (editor, shouldSave2) => {
255
264
  const { undos } = history;
256
265
  if (undos.length > 0) {
257
266
  const batch = undos[undos.length - 1];
258
- slateHistory.HistoryEditor.withoutSaving(e, () => {
259
- slate.Editor.withoutNormalizing(e, () => {
260
- const inverseOps = batch.operations.map(slate.Operation.inverse).reverse();
267
+ import_slate_history.HistoryEditor.withoutSaving(e, () => {
268
+ import_slate.Editor.withoutNormalizing(e, () => {
269
+ const inverseOps = batch.operations.map(import_slate.Operation.inverse).reverse();
261
270
  for (const op of inverseOps) {
262
271
  e.apply(op);
263
272
  }
264
273
  if (batch.selectionBefore) {
265
- slate.Transforms.setSelection(e, batch.selectionBefore);
274
+ import_slate.Transforms.setSelection(e, batch.selectionBefore);
266
275
  }
267
276
  });
268
277
  });
@@ -275,8 +284,8 @@ var withPartialHistory = (editor, shouldSave2) => {
275
284
  const { undos } = history;
276
285
  const lastBatch = undos[undos.length - 1];
277
286
  const lastOp = lastBatch && lastBatch.operations[lastBatch.operations.length - 1];
278
- let save = slateHistory.HistoryEditor.isSaving(e);
279
- let merge2 = slateHistory.HistoryEditor.isMerging(e);
287
+ let save = import_slate_history.HistoryEditor.isSaving(e);
288
+ let merge2 = import_slate_history.HistoryEditor.isMerging(e);
280
289
  if (save == null) {
281
290
  save = shouldSave2(op, lastOp);
282
291
  }
@@ -312,10 +321,10 @@ var withPartialHistory = (editor, shouldSave2) => {
312
321
  return e;
313
322
  };
314
323
  var shouldMerge = (op, prev) => {
315
- if (prev && op.type === "insert_text" && prev.type === "insert_text" && op.offset === prev.offset + prev.text.length && slate.Path.equals(op.path, prev.path)) {
324
+ 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)) {
316
325
  return true;
317
326
  }
318
- if (prev && op.type === "remove_text" && prev.type === "remove_text" && op.offset + op.text.length === prev.offset && slate.Path.equals(op.path, prev.path)) {
327
+ 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)) {
319
328
  return true;
320
329
  }
321
330
  return false;
@@ -330,10 +339,10 @@ var defaultShouldSave = (op, prev) => {
330
339
  // src/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.tsx
331
340
  var shouldSave = (op, prev) => {
332
341
  const excludedNodeType = "suggestion";
333
- if (op.type === "insert_node" && slate.Element.isElement(op.node) && op.node.type === excludedNodeType) {
342
+ if (op.type === "insert_node" && import_slate2.Element.isElement(op.node) && op.node.type === excludedNodeType) {
334
343
  return false;
335
344
  }
336
- if (op.type === "remove_node" && slate.Element.isElement(op.node) && op.node.type === excludedNodeType) {
345
+ if (op.type === "remove_node" && import_slate2.Element.isElement(op.node) && op.node.type === excludedNodeType) {
337
346
  return false;
338
347
  }
339
348
  if (op.type === "set_node" && "type" in op.newProperties && op.newProperties.type === excludedNodeType) {
@@ -348,11 +357,11 @@ var shouldSave = (op, prev) => {
348
357
  if (op.type === "split_node" && "type" in op.properties && op.properties.type === excludedNodeType) {
349
358
  return false;
350
359
  }
351
- return defaultShouldSave(op);
360
+ return defaultShouldSave(op, prev);
352
361
  };
353
362
  function useCopilotTextareaEditor() {
354
- const editor = React2.useMemo(() => {
355
- const editor2 = withPartialHistory(slateReact.withReact(slate.createEditor()), shouldSave);
363
+ const editor = (0, import_react2.useMemo)(() => {
364
+ const editor2 = withPartialHistory((0, import_slate_react.withReact)((0, import_slate2.createEditor)()), shouldSave);
356
365
  const { isVoid } = editor2;
357
366
  editor2.isVoid = (element) => {
358
367
  switch (element.type) {
@@ -384,19 +393,26 @@ function useCopilotTextareaEditor() {
384
393
  }, []);
385
394
  return editor;
386
395
  }
396
+
397
+ // src/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.ts
398
+ var import_react3 = __toESM(require("react"));
399
+ var import_slate_react2 = require("slate-react");
400
+
401
+ // src/lib/get-text-around-cursor.ts
402
+ var import_slate3 = require("slate");
387
403
  function getTextAroundCollapsedCursor(editor) {
388
404
  const { selection } = editor;
389
- if (!selection || !slate.Range.isCollapsed(selection)) {
405
+ if (!selection || !import_slate3.Range.isCollapsed(selection)) {
390
406
  return null;
391
407
  }
392
408
  const cursorPoint = selection.anchor;
393
409
  const beforeRange = {
394
- anchor: slate.Editor.start(editor, []),
410
+ anchor: import_slate3.Editor.start(editor, []),
395
411
  focus: cursorPoint
396
412
  };
397
413
  const afterRange = {
398
414
  anchor: cursorPoint,
399
- focus: slate.Editor.end(editor, [])
415
+ focus: import_slate3.Editor.end(editor, [])
400
416
  };
401
417
  const before = extractTextWithNewlines(editor, beforeRange);
402
418
  const after = extractTextWithNewlines(editor, afterRange);
@@ -413,12 +429,12 @@ function getTextAroundSelection(editor) {
413
429
  }
414
430
  const wellOrderedSelection = wellOrderedRange(selection);
415
431
  const beforeRange = {
416
- anchor: slate.Editor.start(editor, []),
432
+ anchor: import_slate3.Editor.start(editor, []),
417
433
  focus: wellOrderedSelection.anchor
418
434
  };
419
435
  const afterRange = {
420
436
  anchor: wellOrderedSelection.focus,
421
- focus: slate.Editor.end(editor, [])
437
+ focus: import_slate3.Editor.end(editor, [])
422
438
  };
423
439
  const before = extractTextWithNewlines(editor, beforeRange);
424
440
  const after = extractTextWithNewlines(editor, afterRange);
@@ -432,25 +448,25 @@ function getTextAroundSelection(editor) {
432
448
  }
433
449
  function getFullEditorTextWithNewlines(editor) {
434
450
  const fullDocumentRange = {
435
- anchor: slate.Editor.start(editor, []),
436
- focus: slate.Editor.end(editor, [])
451
+ anchor: import_slate3.Editor.start(editor, []),
452
+ focus: import_slate3.Editor.end(editor, [])
437
453
  };
438
454
  return extractTextWithNewlines(editor, fullDocumentRange);
439
455
  }
440
456
  function extractTextWithNewlines(editor, range) {
441
457
  const voids = false;
442
- const [start, end] = slate.Range.edges(range);
458
+ const [start, end] = import_slate3.Range.edges(range);
443
459
  let text = "";
444
460
  let lastBlock = null;
445
- for (const [node, path] of slate.Editor.nodes(editor, {
461
+ for (const [node, path] of import_slate3.Editor.nodes(editor, {
446
462
  at: range,
447
- match: slate.Text.isText,
463
+ match: import_slate3.Text.isText,
448
464
  voids
449
465
  })) {
450
466
  let t = node.text;
451
- const [block] = slate.Editor.above(editor, {
467
+ const [block] = import_slate3.Editor.above(editor, {
452
468
  at: path,
453
- match: (n) => slate.Element.isElement(n) && n.type === "paragraph"
469
+ match: (n) => import_slate3.Element.isElement(n) && n.type === "paragraph"
454
470
  }) || [null];
455
471
  if (lastBlock !== block && block) {
456
472
  if (lastBlock) {
@@ -458,10 +474,10 @@ function extractTextWithNewlines(editor, range) {
458
474
  }
459
475
  lastBlock = block;
460
476
  }
461
- if (slate.Path.equals(path, end.path)) {
477
+ if (import_slate3.Path.equals(path, end.path)) {
462
478
  t = t.slice(0, end.offset);
463
479
  }
464
- if (slate.Path.equals(path, start.path)) {
480
+ if (import_slate3.Path.equals(path, start.path)) {
465
481
  t = t.slice(start.offset);
466
482
  }
467
483
  text += t;
@@ -470,7 +486,7 @@ function extractTextWithNewlines(editor, range) {
470
486
  }
471
487
  function wellOrderedRange(range) {
472
488
  const { anchor, focus } = range;
473
- if (slate.Point.isBefore(anchor, focus)) {
489
+ if (import_slate3.Point.isBefore(anchor, focus)) {
474
490
  return range;
475
491
  }
476
492
  return {
@@ -478,15 +494,18 @@ function wellOrderedRange(range) {
478
494
  focus: anchor
479
495
  };
480
496
  }
497
+
498
+ // src/lib/slatejs-edits/replace-text.ts
499
+ var import_slate4 = require("slate");
481
500
  function replaceEditorText(editor, newText) {
482
- slate.Transforms.delete(editor, {
501
+ import_slate4.Transforms.delete(editor, {
483
502
  at: {
484
- anchor: slate.Editor.start(editor, []),
485
- focus: slate.Editor.end(editor, [])
503
+ anchor: import_slate4.Editor.start(editor, []),
504
+ focus: import_slate4.Editor.end(editor, [])
486
505
  }
487
506
  });
488
507
  if (newText && newText !== "") {
489
- slate.Transforms.insertNodes(
508
+ import_slate4.Transforms.insertNodes(
490
509
  editor,
491
510
  [
492
511
  {
@@ -503,7 +522,7 @@ function replaceEditorText(editor, newText) {
503
522
 
504
523
  // src/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.ts
505
524
  function usePopulateCopilotTextareaRef(editor, ref) {
506
- React2__namespace.default.useImperativeHandle(
525
+ import_react3.default.useImperativeHandle(
507
526
  ref,
508
527
  () => {
509
528
  class Combined {
@@ -556,10 +575,10 @@ function usePopulateCopilotTextareaRef(editor, ref) {
556
575
  this.editor = editor2;
557
576
  }
558
577
  focus() {
559
- slateReact.ReactEditor.focus(this.editor);
578
+ import_slate_react2.ReactEditor.focus(this.editor);
560
579
  }
561
580
  blur() {
562
- slateReact.ReactEditor.blur(this.editor);
581
+ import_slate_react2.ReactEditor.blur(this.editor);
563
582
  }
564
583
  get value() {
565
584
  return getFullEditorTextWithNewlines(this.editor);
@@ -568,7 +587,7 @@ function usePopulateCopilotTextareaRef(editor, ref) {
568
587
  replaceEditorText(this.editor, value);
569
588
  }
570
589
  }
571
- const editorHtmlElement = slateReact.ReactEditor.toDOMNode(editor, editor);
590
+ const editorHtmlElement = import_slate_react2.ReactEditor.toDOMNode(editor, editor);
572
591
  const customMethods = new CustomMethods(editor);
573
592
  const combined = new Combined(customMethods, editorHtmlElement);
574
593
  return new Proxy(combined, handler);
@@ -576,9 +595,12 @@ function usePopulateCopilotTextareaRef(editor, ref) {
576
595
  [editor]
577
596
  );
578
597
  }
598
+
599
+ // src/lib/slatejs-edits/add-autocompletions.ts
600
+ var import_slate5 = require("slate");
579
601
  function addAutocompletionsToEditor(editor, newSuggestion, point) {
580
602
  const editorPosition = editor.selection;
581
- slate.Transforms.insertNodes(
603
+ import_slate5.Transforms.insertNodes(
582
604
  editor,
583
605
  [
584
606
  {
@@ -596,21 +618,27 @@ function addAutocompletionsToEditor(editor, newSuggestion, point) {
596
618
  editor.selection = editorPosition;
597
619
  }
598
620
  }
621
+
622
+ // src/lib/slatejs-edits/clear-autocompletions.ts
623
+ var import_slate6 = require("slate");
599
624
  function clearAutocompletionsFromEditor(editor) {
600
625
  const paths = [];
601
- for (const [node, path] of slate.Node.nodes(editor)) {
602
- if (slate.Element.isElement(node) && node.type === "suggestion") {
626
+ for (const [node, path] of import_slate6.Node.nodes(editor)) {
627
+ if (import_slate6.Element.isElement(node) && node.type === "suggestion") {
603
628
  paths.push(path);
604
629
  }
605
630
  }
606
631
  for (const path of paths) {
607
632
  try {
608
- slate.Transforms.removeNodes(editor, { at: path });
633
+ import_slate6.Transforms.removeNodes(editor, { at: path });
609
634
  } catch (e) {
610
635
  console.log("CopilotTextarea.clearAutocompletionsFromEditor: error removing node", e);
611
636
  }
612
637
  }
613
638
  }
639
+
640
+ // src/types/base/base-autosuggestions-config.tsx
641
+ var import_react_core = require("@copilotkit/react-core");
614
642
  var defaultShouldToggleHoveringEditorOnKeyPress = (event) => {
615
643
  if (event.key === "k" && event.metaKey) {
616
644
  return true;
@@ -625,15 +653,23 @@ var defaultShouldAcceptAutosuggestionOnKeyPress = (event) => {
625
653
  };
626
654
  var defaultBaseAutosuggestionsConfig = {
627
655
  debounceTime: 250,
628
- contextCategories: reactCore.defaultCopilotContextCategories,
656
+ contextCategories: import_react_core.defaultCopilotContextCategories,
629
657
  disableWhenEmpty: true,
630
658
  disabled: false,
631
659
  temporarilyDisableWhenMovingCursorWithoutChangingText: true,
632
660
  shouldToggleHoveringEditorOnKeyPress: defaultShouldToggleHoveringEditorOnKeyPress,
633
661
  shouldAcceptAutosuggestionOnKeyPress: defaultShouldAcceptAutosuggestionOnKeyPress
634
662
  };
663
+
664
+ // src/components/hovering-toolbar/hovering-toolbar.tsx
665
+ var import_react9 = require("react");
666
+ var import_slate7 = require("slate");
667
+ var import_slate_react3 = require("slate-react");
668
+
669
+ // src/hooks/misc/use-autosize-textarea.tsx
670
+ var import_react4 = require("react");
635
671
  var useAutosizeTextArea = (textAreaRef, value) => {
636
- React2.useEffect(() => {
672
+ (0, import_react4.useEffect)(() => {
637
673
  if (textAreaRef.current !== null) {
638
674
  textAreaRef.current.style.height = "0px";
639
675
  const scrollHeight = textAreaRef.current.scrollHeight;
@@ -642,10 +678,18 @@ var useAutosizeTextArea = (textAreaRef, value) => {
642
678
  }, [textAreaRef, value]);
643
679
  };
644
680
  var use_autosize_textarea_default = useAutosizeTextArea;
645
- var Command = React2__namespace.forwardRef((_a, ref) => {
681
+
682
+ // src/components/source-search-box/source-search-box.tsx
683
+ var import_react5 = require("react");
684
+
685
+ // src/components/ui/command.tsx
686
+ var React2 = __toESM(require("react"));
687
+ var import_cmdk = require("cmdk");
688
+ var import_jsx_runtime = require("react/jsx-runtime");
689
+ var Command = React2.forwardRef((_a, ref) => {
646
690
  var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
647
- return /* @__PURE__ */ jsxRuntime.jsx(
648
- cmdk.Command,
691
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
692
+ import_cmdk.Command,
649
693
  __spreadValues({
650
694
  ref,
651
695
  className: cn(
@@ -655,11 +699,11 @@ var Command = React2__namespace.forwardRef((_a, ref) => {
655
699
  }, props)
656
700
  );
657
701
  });
658
- Command.displayName = cmdk.Command.displayName;
659
- var CommandInput = React2__namespace.forwardRef((_a, ref) => {
702
+ Command.displayName = import_cmdk.Command.displayName;
703
+ var CommandInput = React2.forwardRef((_a, ref) => {
660
704
  var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
661
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center border-b px-3", "cmdk-input-wrapper": "", children: /* @__PURE__ */ jsxRuntime.jsx(
662
- cmdk.Command.Input,
705
+ 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)(
706
+ import_cmdk.Command.Input,
663
707
  __spreadValues({
664
708
  ref,
665
709
  className: cn(
@@ -669,24 +713,24 @@ var CommandInput = React2__namespace.forwardRef((_a, ref) => {
669
713
  }, props)
670
714
  ) });
671
715
  });
672
- CommandInput.displayName = cmdk.Command.Input.displayName;
673
- var CommandList = React2__namespace.forwardRef((_a, ref) => {
716
+ CommandInput.displayName = import_cmdk.Command.Input.displayName;
717
+ var CommandList = React2.forwardRef((_a, ref) => {
674
718
  var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
675
- return /* @__PURE__ */ jsxRuntime.jsx(
676
- cmdk.Command.List,
719
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
720
+ import_cmdk.Command.List,
677
721
  __spreadValues({
678
722
  ref,
679
723
  className: cn("max-h-[300px] overflow-y-auto overflow-x-hidden pb-2", className)
680
724
  }, props)
681
725
  );
682
726
  });
683
- CommandList.displayName = cmdk.Command.List.displayName;
684
- var CommandEmpty = React2__namespace.forwardRef((props, ref) => /* @__PURE__ */ jsxRuntime.jsx(cmdk.Command.Empty, __spreadValues({ ref, className: "py-6 text-center text-sm" }, props)));
685
- CommandEmpty.displayName = cmdk.Command.Empty.displayName;
686
- var CommandGroup = React2__namespace.forwardRef((_a, ref) => {
727
+ CommandList.displayName = import_cmdk.Command.List.displayName;
728
+ 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)));
729
+ CommandEmpty.displayName = import_cmdk.Command.Empty.displayName;
730
+ var CommandGroup = React2.forwardRef((_a, ref) => {
687
731
  var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
688
- return /* @__PURE__ */ jsxRuntime.jsx(
689
- cmdk.Command.Group,
732
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
733
+ import_cmdk.Command.Group,
690
734
  __spreadValues({
691
735
  ref,
692
736
  className: cn(
@@ -696,22 +740,22 @@ var CommandGroup = React2__namespace.forwardRef((_a, ref) => {
696
740
  }, props)
697
741
  );
698
742
  });
699
- CommandGroup.displayName = cmdk.Command.Group.displayName;
700
- var CommandSeparator = React2__namespace.forwardRef((_a, ref) => {
743
+ CommandGroup.displayName = import_cmdk.Command.Group.displayName;
744
+ var CommandSeparator = React2.forwardRef((_a, ref) => {
701
745
  var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
702
- return /* @__PURE__ */ jsxRuntime.jsx(
703
- cmdk.Command.Separator,
746
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
747
+ import_cmdk.Command.Separator,
704
748
  __spreadValues({
705
749
  ref,
706
750
  className: cn("-mx-1 h-px bg-border", className)
707
751
  }, props)
708
752
  );
709
753
  });
710
- CommandSeparator.displayName = cmdk.Command.Separator.displayName;
711
- var CommandItem = React2__namespace.forwardRef((_a, ref) => {
754
+ CommandSeparator.displayName = import_cmdk.Command.Separator.displayName;
755
+ var CommandItem = React2.forwardRef((_a, ref) => {
712
756
  var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
713
- return /* @__PURE__ */ jsxRuntime.jsx(
714
- cmdk.Command.Item,
757
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
758
+ import_cmdk.Command.Item,
715
759
  __spreadValues({
716
760
  ref,
717
761
  className: cn(
@@ -721,10 +765,23 @@ var CommandItem = React2__namespace.forwardRef((_a, ref) => {
721
765
  }, props)
722
766
  );
723
767
  });
724
- CommandItem.displayName = cmdk.Command.Item.displayName;
768
+ CommandItem.displayName = import_cmdk.Command.Item.displayName;
769
+ var CommandShortcut = (_a) => {
770
+ var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
771
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
772
+ "span",
773
+ __spreadValues({
774
+ className: cn("ml-auto text-xs tracking-widest text-muted-foreground", className)
775
+ }, props)
776
+ );
777
+ };
778
+ CommandShortcut.displayName = "CommandShortcut";
779
+
780
+ // src/components/source-search-box/source-search-box.tsx
781
+ var import_jsx_runtime2 = require("react/jsx-runtime");
725
782
  function SourceSearchBox(props) {
726
- const [selectedValue, setSelectedValue] = React2.useState("");
727
- return /* @__PURE__ */ jsxRuntime.jsxs(
783
+ const [selectedValue, setSelectedValue] = (0, import_react5.useState)("");
784
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
728
785
  Command,
729
786
  {
730
787
  className: "rounded-lg border shadow-md",
@@ -740,7 +797,7 @@ function SourceSearchBox(props) {
740
797
  return 0;
741
798
  },
742
799
  children: [
743
- /* @__PURE__ */ jsxRuntime.jsx(
800
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
744
801
  CommandInput,
745
802
  {
746
803
  value: props.searchTerm,
@@ -748,18 +805,18 @@ function SourceSearchBox(props) {
748
805
  placeholder: "Search for a command..."
749
806
  }
750
807
  ),
751
- /* @__PURE__ */ jsxRuntime.jsxs(CommandList, { children: [
752
- /* @__PURE__ */ jsxRuntime.jsx(CommandEmpty, { children: "No results found." }),
753
- /* @__PURE__ */ jsxRuntime.jsx(CommandGroup, { heading: "Available resources", children: props.suggestedFiles.map((filePointer) => {
754
- return /* @__PURE__ */ jsxRuntime.jsx(
808
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(CommandList, { children: [
809
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(CommandEmpty, { children: "No results found." }),
810
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(CommandGroup, { heading: "Available resources", children: props.suggestedFiles.map((filePointer) => {
811
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
755
812
  CommandItem,
756
813
  {
757
814
  value: filePointer.name,
758
815
  onSelect: (value) => {
759
816
  props.onSelectedFile(filePointer);
760
817
  },
761
- children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: " px-3 flex flex-row gap-1 items-center", children: [
762
- /* @__PURE__ */ jsxRuntime.jsx(Logo, { width: "20px", height: "20px", children: /* @__PURE__ */ jsxRuntime.jsx(
818
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: " px-3 flex flex-row gap-1 items-center", children: [
819
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Logo, { width: "20px", height: "20px", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
763
820
  "img",
764
821
  {
765
822
  src: filePointer.iconImageUri,
@@ -773,7 +830,7 @@ function SourceSearchBox(props) {
773
830
  `word-${filePointer.sourceApplication}.${filePointer.name}`
774
831
  );
775
832
  }) }),
776
- /* @__PURE__ */ jsxRuntime.jsx(CommandSeparator, {})
833
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(CommandSeparator, {})
777
834
  ] })
778
835
  ]
779
836
  }
@@ -784,9 +841,15 @@ function Logo({
784
841
  width,
785
842
  height
786
843
  }) {
787
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-center", style: { width, height }, children });
844
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "flex items-center justify-center", style: { width, height }, children });
788
845
  }
789
- var buttonVariants = classVarianceAuthority.cva(
846
+
847
+ // src/components/ui/button.tsx
848
+ var React3 = __toESM(require("react"));
849
+ var import_react_slot = require("@radix-ui/react-slot");
850
+ var import_class_variance_authority = require("class-variance-authority");
851
+ var import_jsx_runtime3 = require("react/jsx-runtime");
852
+ var buttonVariants = (0, import_class_variance_authority.cva)(
790
853
  "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",
791
854
  {
792
855
  variants: {
@@ -811,22 +874,31 @@ var buttonVariants = classVarianceAuthority.cva(
811
874
  }
812
875
  }
813
876
  );
814
- var Button = React2__namespace.forwardRef(
877
+ var Button = React3.forwardRef(
815
878
  (_a, ref) => {
816
879
  var _b = _a, { className, variant, size, asChild = false } = _b, props = __objRest(_b, ["className", "variant", "size", "asChild"]);
817
- const Comp = asChild ? reactSlot.Slot : "button";
818
- return /* @__PURE__ */ jsxRuntime.jsx(Comp, __spreadValues({ className: cn(buttonVariants({ variant, size, className })), ref }, props));
880
+ const Comp = asChild ? import_react_slot.Slot : "button";
881
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Comp, __spreadValues({ className: cn(buttonVariants({ variant, size, className })), ref }, props));
819
882
  }
820
883
  );
821
884
  Button.displayName = "Button";
822
- var labelVariants = classVarianceAuthority.cva(
885
+
886
+ // src/components/ui/label.tsx
887
+ var React4 = __toESM(require("react"));
888
+ var LabelPrimitive = __toESM(require("@radix-ui/react-label"));
889
+ var import_class_variance_authority2 = require("class-variance-authority");
890
+ var import_jsx_runtime4 = require("react/jsx-runtime");
891
+ var labelVariants = (0, import_class_variance_authority2.cva)(
823
892
  "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
824
893
  );
825
- var Label = React2__namespace.forwardRef((_a, ref) => {
894
+ var Label = React4.forwardRef((_a, ref) => {
826
895
  var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
827
- return /* @__PURE__ */ jsxRuntime.jsx(LabelPrimitive__namespace.Root, __spreadValues({ ref, className: cn(labelVariants(), className) }, props));
896
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(LabelPrimitive.Root, __spreadValues({ ref, className: cn(labelVariants(), className) }, props));
828
897
  });
829
- Label.displayName = LabelPrimitive__namespace.Root.displayName;
898
+ Label.displayName = LabelPrimitive.Root.displayName;
899
+
900
+ // src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.tsx
901
+ var import_react6 = require("react");
830
902
 
831
903
  // src/lib/stream-promise-flatten.ts
832
904
  function streamPromiseFlatten(promise) {
@@ -851,14 +923,22 @@ function streamPromiseFlatten(promise) {
851
923
  }
852
924
  });
853
925
  }
926
+
927
+ // src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.tsx
928
+ var import_react_core2 = require("@copilotkit/react-core");
929
+
930
+ // src/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.tsx
931
+ var import_Chip = __toESM(require("@mui/material/Chip/Chip.js"));
932
+ var import_Avatar = __toESM(require("@mui/material/Avatar/Avatar.js"));
933
+ var import_jsx_runtime5 = require("react/jsx-runtime");
854
934
  var IncludedFilesPreview = ({
855
935
  includedFiles,
856
936
  setIncludedFiles
857
937
  }) => {
858
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2 mt-2", children: [
859
- /* @__PURE__ */ jsxRuntime.jsx(Label, { className: "", children: "Included context:" }),
860
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-wrap gap-2", children: includedFiles.map((filePointer, index) => {
861
- return /* @__PURE__ */ jsxRuntime.jsx(
938
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex flex-col gap-2 mt-2", children: [
939
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Label, { className: "", children: "Included context:" }),
940
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "flex flex-wrap gap-2", children: includedFiles.map((filePointer, index) => {
941
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
862
942
  FileChipPreview,
863
943
  {
864
944
  filePointer,
@@ -872,13 +952,13 @@ var IncludedFilesPreview = ({
872
952
  ] });
873
953
  };
874
954
  var FileChipPreview = ({ filePointer, onDelete }) => {
875
- return /* @__PURE__ */ jsxRuntime.jsx(
876
- Chip__default.default,
955
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
956
+ import_Chip.default,
877
957
  {
878
958
  label: filePointer.name,
879
959
  onDelete,
880
- avatar: /* @__PURE__ */ jsxRuntime.jsx(
881
- Avatar__default.default,
960
+ avatar: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
961
+ import_Avatar.default,
882
962
  {
883
963
  src: filePointer.iconImageUri,
884
964
  alt: filePointer.sourceApplication,
@@ -888,35 +968,38 @@ var FileChipPreview = ({ filePointer, onDelete }) => {
888
968
  }
889
969
  );
890
970
  };
971
+
972
+ // src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.tsx
973
+ var import_jsx_runtime6 = require("react/jsx-runtime");
891
974
  var HoveringInsertionPromptBoxCore = ({
892
975
  performInsertion,
893
976
  state,
894
977
  insertionOrEditingFunction,
895
978
  contextCategories
896
979
  }) => {
897
- const { getDocumentsContext } = React2.useContext(reactCore.CopilotContext);
898
- const [editSuggestion, setEditSuggestion] = React2.useState("");
899
- const [suggestionIsLoading, setSuggestionIsLoading] = React2.useState(false);
900
- const [adjustmentPrompt, setAdjustmentPrompt] = React2.useState("");
901
- const [generatingSuggestion, setGeneratingSuggestion] = React2.useState(
980
+ const { getDocumentsContext } = (0, import_react6.useContext)(import_react_core2.CopilotContext);
981
+ const [editSuggestion, setEditSuggestion] = (0, import_react6.useState)("");
982
+ const [suggestionIsLoading, setSuggestionIsLoading] = (0, import_react6.useState)(false);
983
+ const [adjustmentPrompt, setAdjustmentPrompt] = (0, import_react6.useState)("");
984
+ const [generatingSuggestion, setGeneratingSuggestion] = (0, import_react6.useState)(
902
985
  null
903
986
  );
904
- const adjustmentTextAreaRef = React2.useRef(null);
905
- const suggestionTextAreaRef = React2.useRef(null);
906
- const [filePointers, setFilePointers] = React2.useState([]);
907
- const [suggestedFiles, setSuggestedFiles] = React2.useState([]);
908
- React2.useEffect(() => {
987
+ const adjustmentTextAreaRef = (0, import_react6.useRef)(null);
988
+ const suggestionTextAreaRef = (0, import_react6.useRef)(null);
989
+ const [filePointers, setFilePointers] = (0, import_react6.useState)([]);
990
+ const [suggestedFiles, setSuggestedFiles] = (0, import_react6.useState)([]);
991
+ (0, import_react6.useEffect)(() => {
909
992
  setSuggestedFiles(getDocumentsContext(contextCategories));
910
993
  }, [contextCategories, getDocumentsContext]);
911
994
  use_autosize_textarea_default(suggestionTextAreaRef, editSuggestion || "");
912
995
  use_autosize_textarea_default(adjustmentTextAreaRef, adjustmentPrompt || "");
913
- React2.useEffect(() => {
996
+ (0, import_react6.useEffect)(() => {
914
997
  setTimeout(() => {
915
998
  var _a;
916
999
  (_a = adjustmentTextAreaRef.current) == null ? void 0 : _a.focus();
917
1000
  }, 0);
918
1001
  }, []);
919
- React2.useEffect(() => {
1002
+ (0, import_react6.useEffect)(() => {
920
1003
  if (!generatingSuggestion) {
921
1004
  return;
922
1005
  }
@@ -954,7 +1037,7 @@ var HoveringInsertionPromptBoxCore = ({
954
1037
  releaseLockIfNotClosed();
955
1038
  };
956
1039
  }, [generatingSuggestion]);
957
- const beginGeneratingAdjustment = React2.useCallback(() => __async(void 0, null, function* () {
1040
+ const beginGeneratingAdjustment = (0, import_react6.useCallback)(() => __async(void 0, null, function* () {
958
1041
  if (!adjustmentPrompt.trim()) {
959
1042
  return;
960
1043
  }
@@ -983,10 +1066,10 @@ var HoveringInsertionPromptBoxCore = ({
983
1066
  const textToEdit = editSuggestion || state.editorState.selectedText;
984
1067
  const adjustmentLabel = textToEdit === "" ? "Describe the text you want to insert" : "Describe adjustments to the suggested text";
985
1068
  const placeholder = textToEdit === "" ? "e.g. 'summarize the client's top 3 pain-points from @CallTranscript'" : "e.g. 'make it more formal', 'be more specific', ...";
986
- const AdjustmentPromptComponent = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
987
- /* @__PURE__ */ jsxRuntime.jsx(Label, { className: "", children: adjustmentLabel }),
988
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative w-full flex items-center", children: [
989
- /* @__PURE__ */ jsxRuntime.jsx(
1069
+ const AdjustmentPromptComponent = /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
1070
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Label, { className: "", children: adjustmentLabel }),
1071
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "relative w-full flex items-center", children: [
1072
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
990
1073
  "textarea",
991
1074
  {
992
1075
  disabled: suggestionIsLoading,
@@ -1008,29 +1091,29 @@ var HoveringInsertionPromptBoxCore = ({
1008
1091
  rows: 1
1009
1092
  }
1010
1093
  ),
1011
- /* @__PURE__ */ jsxRuntime.jsx(
1094
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1012
1095
  "button",
1013
1096
  {
1014
1097
  onClick: beginGeneratingAdjustment,
1015
1098
  className: "absolute right-2 bg-blue-500 text-white w-8 h-8 rounded-full flex items-center justify-center",
1016
- children: /* @__PURE__ */ jsxRuntime.jsx("i", { className: "material-icons", children: "arrow_forward" })
1099
+ children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("i", { className: "material-icons", children: "arrow_forward" })
1017
1100
  }
1018
1101
  )
1019
1102
  ] })
1020
1103
  ] });
1021
- const SuggestionComponent = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1022
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-between items-end w-full", children: [
1023
- /* @__PURE__ */ jsxRuntime.jsx(Label, { className: "mt-4", children: "Suggested:" }),
1024
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ml-auto", children: isLoading && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center items-center", children: /* @__PURE__ */ jsxRuntime.jsx(
1104
+ const SuggestionComponent = /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
1105
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "flex justify-between items-end w-full", children: [
1106
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Label, { className: "mt-4", children: "Suggested:" }),
1107
+ /* @__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)(
1025
1108
  "div",
1026
1109
  {
1027
1110
  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]",
1028
1111
  role: "status",
1029
- 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..." })
1112
+ 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..." })
1030
1113
  }
1031
1114
  ) }) })
1032
1115
  ] }),
1033
- /* @__PURE__ */ jsxRuntime.jsx(
1116
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1034
1117
  "textarea",
1035
1118
  {
1036
1119
  ref: suggestionTextAreaRef,
@@ -1042,7 +1125,7 @@ var HoveringInsertionPromptBoxCore = ({
1042
1125
  }
1043
1126
  )
1044
1127
  ] });
1045
- const SubmitComponent = /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex w-full gap-4 justify-start", children: /* @__PURE__ */ jsxRuntime.jsxs(
1128
+ const SubmitComponent = /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "flex w-full gap-4 justify-start", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
1046
1129
  Button,
1047
1130
  {
1048
1131
  className: " bg-green-700 text-white",
@@ -1051,16 +1134,16 @@ var HoveringInsertionPromptBoxCore = ({
1051
1134
  },
1052
1135
  children: [
1053
1136
  "Insert ",
1054
- /* @__PURE__ */ jsxRuntime.jsx("i", { className: "material-icons", children: "check" })
1137
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("i", { className: "material-icons", children: "check" })
1055
1138
  ]
1056
1139
  }
1057
1140
  ) });
1058
1141
  const sourceSearchCandidate = adjustmentPrompt.split(" ").pop();
1059
1142
  const sourceSearchWord = (sourceSearchCandidate == null ? void 0 : sourceSearchCandidate.startsWith("@")) ? sourceSearchCandidate.slice(1) : void 0;
1060
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-full flex flex-col items-start relative gap-2", children: [
1143
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "w-full flex flex-col items-start relative gap-2", children: [
1061
1144
  AdjustmentPromptComponent,
1062
- filePointers.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(IncludedFilesPreview, { includedFiles: filePointers, setIncludedFiles: setFilePointers }),
1063
- sourceSearchWord !== void 0 && /* @__PURE__ */ jsxRuntime.jsx(
1145
+ filePointers.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(IncludedFilesPreview, { includedFiles: filePointers, setIncludedFiles: setFilePointers }),
1146
+ sourceSearchWord !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1064
1147
  SourceSearchBox,
1065
1148
  {
1066
1149
  searchTerm: sourceSearchWord,
@@ -1077,13 +1160,16 @@ var HoveringInsertionPromptBoxCore = ({
1077
1160
  generatingSuggestion ? SubmitComponent : null
1078
1161
  ] });
1079
1162
  };
1163
+
1164
+ // src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.tsx
1165
+ var import_jsx_runtime7 = require("react/jsx-runtime");
1080
1166
  var HoveringInsertionPromptBox = (props) => {
1081
- return /* @__PURE__ */ jsxRuntime.jsx(
1167
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1082
1168
  "div",
1083
1169
  {
1084
1170
  className: "flex flex-col justify-center items-center space-y-4 rounded-md border shadow-lg p-4 border-gray- bg-white",
1085
1171
  style: { width: "35rem" },
1086
- children: /* @__PURE__ */ jsxRuntime.jsx(
1172
+ children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1087
1173
  HoveringInsertionPromptBoxCore,
1088
1174
  {
1089
1175
  state: {
@@ -1097,7 +1183,13 @@ var HoveringInsertionPromptBox = (props) => {
1097
1183
  }
1098
1184
  );
1099
1185
  };
1100
- React2__namespace.default.forwardRef(
1186
+
1187
+ // src/components/hovering-toolbar/hovering-toolbar-components.tsx
1188
+ var import_css = require("@emotion/css");
1189
+ var import_react7 = __toESM(require("react"));
1190
+ var import_react_dom = __toESM(require("react-dom"));
1191
+ var import_jsx_runtime8 = require("react/jsx-runtime");
1192
+ var Button2 = import_react7.default.forwardRef(
1101
1193
  (_a, ref) => {
1102
1194
  var _b = _a, {
1103
1195
  className,
@@ -1108,13 +1200,13 @@ React2__namespace.default.forwardRef(
1108
1200
  "active",
1109
1201
  "reversed"
1110
1202
  ]);
1111
- return /* @__PURE__ */ jsxRuntime.jsx(
1203
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1112
1204
  "span",
1113
1205
  __spreadProps(__spreadValues({}, props), {
1114
1206
  ref,
1115
- className: css.cx(
1207
+ className: (0, import_css.cx)(
1116
1208
  className,
1117
- css.css`
1209
+ import_css.css`
1118
1210
  cursor: pointer;
1119
1211
  color: ${reversed ? active ? "white" : "#aaa" : active ? "black" : "#ccc"};
1120
1212
  `
@@ -1123,17 +1215,17 @@ React2__namespace.default.forwardRef(
1123
1215
  );
1124
1216
  }
1125
1217
  );
1126
- React2__namespace.default.forwardRef(
1218
+ var Icon = import_react7.default.forwardRef(
1127
1219
  (_a, ref) => {
1128
1220
  var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
1129
- return /* @__PURE__ */ jsxRuntime.jsx(
1221
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1130
1222
  "span",
1131
1223
  __spreadProps(__spreadValues({}, props), {
1132
1224
  ref,
1133
- className: css.cx(
1225
+ className: (0, import_css.cx)(
1134
1226
  "material-icons",
1135
1227
  className,
1136
- css.css`
1228
+ import_css.css`
1137
1229
  font-size: 18px;
1138
1230
  vertical-align: text-bottom;
1139
1231
  `
@@ -1142,17 +1234,17 @@ React2__namespace.default.forwardRef(
1142
1234
  );
1143
1235
  }
1144
1236
  );
1145
- var Menu = React2__namespace.default.forwardRef(
1237
+ var Menu = import_react7.default.forwardRef(
1146
1238
  (_a, ref) => {
1147
1239
  var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
1148
- return /* @__PURE__ */ jsxRuntime.jsx(
1240
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1149
1241
  "div",
1150
1242
  __spreadProps(__spreadValues({}, props), {
1151
1243
  "data-test-id": "menu",
1152
1244
  ref,
1153
- className: css.cx(
1245
+ className: (0, import_css.cx)(
1154
1246
  className,
1155
- css.css`
1247
+ import_css.css`
1156
1248
  & > * {
1157
1249
  display: inline-block;
1158
1250
  }
@@ -1167,18 +1259,18 @@ var Menu = React2__namespace.default.forwardRef(
1167
1259
  }
1168
1260
  );
1169
1261
  var Portal = ({ children }) => {
1170
- return typeof document === "object" ? ReactDOM__default.default.createPortal(children, document.body) : null;
1262
+ return typeof document === "object" ? import_react_dom.default.createPortal(children, document.body) : null;
1171
1263
  };
1172
- React2__namespace.default.forwardRef(
1264
+ var Toolbar = import_react7.default.forwardRef(
1173
1265
  (_a, ref) => {
1174
1266
  var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
1175
- return /* @__PURE__ */ jsxRuntime.jsx(
1267
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1176
1268
  Menu,
1177
1269
  __spreadProps(__spreadValues({}, props), {
1178
1270
  ref,
1179
- className: css.cx(
1271
+ className: (0, import_css.cx)(
1180
1272
  className,
1181
- css.css`
1273
+ import_css.css`
1182
1274
  position: relative;
1183
1275
  padding: 1px 18px 17px;
1184
1276
  margin: 0 -20px;
@@ -1190,26 +1282,33 @@ React2__namespace.default.forwardRef(
1190
1282
  );
1191
1283
  }
1192
1284
  );
1193
- var HoveringEditorContext = React2.createContext({
1285
+
1286
+ // src/components/hovering-toolbar/hovering-editor-provider.tsx
1287
+ var import_react8 = require("react");
1288
+ var import_jsx_runtime9 = require("react/jsx-runtime");
1289
+ var HoveringEditorContext = (0, import_react8.createContext)({
1194
1290
  isDisplayed: false,
1195
1291
  setIsDisplayed: () => {
1196
1292
  }
1197
1293
  });
1198
1294
  var HoveringEditorProvider = ({ children }) => {
1199
- const [isDisplayed, setIsDisplayed] = React2.useState(false);
1200
- return /* @__PURE__ */ jsxRuntime.jsx(HoveringEditorContext.Provider, { value: { isDisplayed, setIsDisplayed }, children });
1295
+ const [isDisplayed, setIsDisplayed] = (0, import_react8.useState)(false);
1296
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(HoveringEditorContext.Provider, { value: { isDisplayed, setIsDisplayed }, children });
1201
1297
  };
1202
- var useHoveringEditorContext = () => React2.useContext(HoveringEditorContext);
1298
+ var useHoveringEditorContext = () => (0, import_react8.useContext)(HoveringEditorContext);
1299
+
1300
+ // src/components/hovering-toolbar/hovering-toolbar.tsx
1301
+ var import_jsx_runtime10 = require("react/jsx-runtime");
1203
1302
  var HoveringToolbar = (props) => {
1204
- const ref = React2.useRef(null);
1205
- const editor = slateReact.useSlate();
1206
- const selection = slateReact.useSlateSelection();
1303
+ const ref = (0, import_react9.useRef)(null);
1304
+ const editor = (0, import_slate_react3.useSlate)();
1305
+ const selection = (0, import_slate_react3.useSlateSelection)();
1207
1306
  const { isDisplayed, setIsDisplayed } = useHoveringEditorContext();
1208
- const [isClient, setIsClient] = React2.useState(false);
1209
- React2.useEffect(() => {
1307
+ const [isClient, setIsClient] = (0, import_react9.useState)(false);
1308
+ (0, import_react9.useEffect)(() => {
1210
1309
  setIsClient(true);
1211
1310
  }, []);
1212
- React2.useEffect(() => {
1311
+ (0, import_react9.useEffect)(() => {
1213
1312
  const el = ref.current;
1214
1313
  const { selection: selection2 } = editor;
1215
1314
  if (!el) {
@@ -1247,7 +1346,7 @@ var HoveringToolbar = (props) => {
1247
1346
  el.style.top = `${top}px`;
1248
1347
  el.style.left = `${left}px`;
1249
1348
  });
1250
- React2.useEffect(() => {
1349
+ (0, import_react9.useEffect)(() => {
1251
1350
  const handleClickOutside = (event) => {
1252
1351
  if (ref.current && !ref.current.contains(event.target)) {
1253
1352
  setIsDisplayed(false);
@@ -1261,23 +1360,23 @@ var HoveringToolbar = (props) => {
1261
1360
  if (!isClient) {
1262
1361
  return null;
1263
1362
  }
1264
- return /* @__PURE__ */ jsxRuntime.jsx(Portal, { children: /* @__PURE__ */ jsxRuntime.jsx(
1363
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1265
1364
  Menu,
1266
1365
  {
1267
1366
  ref,
1268
1367
  className: props.hoverMenuClassname || "p-2 absolute z-10 top-[-10000px] left-[-10000px] mt-[-6px] opacity-0 transition-opacity duration-700",
1269
- children: isDisplayed && selection && /* @__PURE__ */ jsxRuntime.jsx(
1368
+ children: isDisplayed && selection && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1270
1369
  HoveringInsertionPromptBox,
1271
1370
  {
1272
- editorState: editorState(editor),
1371
+ editorState: editorState(editor, selection),
1273
1372
  apiConfig: props.apiConfig,
1274
1373
  closeWindow: () => {
1275
1374
  setIsDisplayed(false);
1276
1375
  },
1277
1376
  performInsertion: (insertedText) => {
1278
1377
  console.log("inserted text", insertedText);
1279
- slate.Transforms.delete(editor, { at: selection });
1280
- slate.Transforms.insertText(editor, insertedText, {
1378
+ import_slate7.Transforms.delete(editor, { at: selection });
1379
+ import_slate7.Transforms.insertText(editor, insertedText, {
1281
1380
  at: selection
1282
1381
  });
1283
1382
  setIsDisplayed(false);
@@ -1299,21 +1398,24 @@ function editorState(editor, selection) {
1299
1398
  selectedText: ""
1300
1399
  };
1301
1400
  }
1401
+
1402
+ // src/components/base-copilot-textarea/render-element.tsx
1403
+ var import_jsx_runtime11 = require("react/jsx-runtime");
1302
1404
  function makeRenderElementFunction(suggestionsStyle) {
1303
1405
  return (props) => {
1304
1406
  switch (props.element.type) {
1305
1407
  case "paragraph":
1306
- return /* @__PURE__ */ jsxRuntime.jsx(DefaultElement, __spreadValues({}, props));
1408
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(DefaultElement, __spreadValues({}, props));
1307
1409
  case "suggestion":
1308
- return /* @__PURE__ */ jsxRuntime.jsx(SuggestionElement, __spreadProps(__spreadValues({}, props), { suggestionsStyle }));
1410
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(SuggestionElement, __spreadProps(__spreadValues({}, props), { suggestionsStyle }));
1309
1411
  }
1310
1412
  };
1311
1413
  }
1312
1414
  var DefaultElement = (props) => {
1313
- return /* @__PURE__ */ jsxRuntime.jsx("div", __spreadProps(__spreadValues({}, props.attributes), { children: props.children }));
1415
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", __spreadProps(__spreadValues({}, props.attributes), { children: props.children }));
1314
1416
  };
1315
1417
  var SuggestionElement = (props) => {
1316
- return /* @__PURE__ */ jsxRuntime.jsxs(
1418
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
1317
1419
  "span",
1318
1420
  __spreadProps(__spreadValues({}, props.attributes), {
1319
1421
  style: __spreadValues({}, props.suggestionsStyle),
@@ -1325,10 +1427,13 @@ var SuggestionElement = (props) => {
1325
1427
  })
1326
1428
  );
1327
1429
  };
1430
+
1431
+ // src/components/base-copilot-textarea/render-placeholder.tsx
1432
+ var import_jsx_runtime12 = require("react/jsx-runtime");
1328
1433
  function makeRenderPlaceholderFunction(placeholderStyle) {
1329
1434
  return (props) => {
1330
1435
  const _a = props.attributes, { style } = _a, restAttributes = __objRest(_a, ["style"]);
1331
- return /* @__PURE__ */ jsxRuntime.jsx(
1436
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1332
1437
  "div",
1333
1438
  __spreadProps(__spreadValues({}, restAttributes), {
1334
1439
  style: __spreadValues(__spreadValues({}, style), placeholderStyle),
@@ -1337,9 +1442,12 @@ function makeRenderPlaceholderFunction(placeholderStyle) {
1337
1442
  );
1338
1443
  };
1339
1444
  }
1445
+
1446
+ // src/components/base-copilot-textarea/use-add-branding-css.tsx
1447
+ var import_react10 = require("react");
1340
1448
  function useAddBrandingCss(suggestionStyleAugmented, disableBranding) {
1341
1449
  const cssSelector = ".copilot-textarea.with-branding";
1342
- React2.useEffect(() => {
1450
+ (0, import_react10.useEffect)(() => {
1343
1451
  if (disableBranding) {
1344
1452
  return;
1345
1453
  }
@@ -1389,10 +1497,18 @@ function useAddBrandingCss(suggestionStyleAugmented, disableBranding) {
1389
1497
  };
1390
1498
  }, [disableBranding, suggestionStyleAugmented]);
1391
1499
  }
1500
+
1501
+ // src/components/base-copilot-textarea/track-cursor-moved-since-last-text-change.tsx
1502
+ var import_react11 = require("react");
1503
+ var import_slate_react4 = require("slate-react");
1504
+ var import_slate9 = require("slate");
1505
+
1506
+ // src/lib/editor-to-text.ts
1507
+ var import_slate8 = require("slate");
1392
1508
  function nodeChildrenToTextComponents(editor, nodes) {
1393
1509
  const indeciesOfInlineElements = new Set(
1394
1510
  nodes.map((node, index) => {
1395
- if (slate.Element.isElement(node) && editor.isInline(node)) {
1511
+ if (import_slate8.Element.isElement(node) && editor.isInline(node)) {
1396
1512
  return index;
1397
1513
  }
1398
1514
  return -1;
@@ -1410,7 +1526,7 @@ function nodeChildrenToTextComponents(editor, nodes) {
1410
1526
  return true;
1411
1527
  });
1412
1528
  return nonIgnorableItems.map((node) => {
1413
- if (slate.Element.isElement(node)) {
1529
+ if (import_slate8.Element.isElement(node)) {
1414
1530
  switch (node.type) {
1415
1531
  case "paragraph":
1416
1532
  return nodeChildrenToTextComponents(editor, node.children);
@@ -1427,13 +1543,16 @@ var editorToText = (editor) => {
1427
1543
  const text = flattened.map((textComponent) => textComponent.text).join("\n");
1428
1544
  return text;
1429
1545
  };
1546
+
1547
+ // src/components/base-copilot-textarea/track-cursor-moved-since-last-text-change.tsx
1548
+ var import_jsx_runtime13 = require("react/jsx-runtime");
1430
1549
  function TrackerTextEditedSinceLastCursorMovement(props) {
1431
- const cursorState = slateReact.useSlateSelector((state) => ({
1550
+ const cursorState = (0, import_slate_react4.useSlateSelector)((state) => ({
1432
1551
  selection: state.selection,
1433
1552
  text: editorToText(state)
1434
1553
  }));
1435
1554
  const previousState = usePrevious(cursorState);
1436
- React2.useEffect(() => {
1555
+ (0, import_react11.useEffect)(() => {
1437
1556
  if (!previousState) {
1438
1557
  return;
1439
1558
  }
@@ -1441,7 +1560,7 @@ function TrackerTextEditedSinceLastCursorMovement(props) {
1441
1560
  props.setCursorMovedSinceLastTextChange(true);
1442
1561
  }
1443
1562
  }, [props.setCursorMovedSinceLastTextChange, cursorState]);
1444
- return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {});
1563
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_jsx_runtime13.Fragment, {});
1445
1564
  }
1446
1565
  var cursorChangedWithoutTextChanged = (prev, next) => {
1447
1566
  const isSelectionChanged = !isSelectionEqual(prev.selection, next.selection);
@@ -1453,30 +1572,33 @@ var isSelectionEqual = (a, b) => {
1453
1572
  return true;
1454
1573
  if (!a || !b)
1455
1574
  return false;
1456
- return slate.Range.equals(a, b);
1575
+ return import_slate9.Range.equals(a, b);
1457
1576
  };
1458
1577
  function usePrevious(value) {
1459
- const ref = React2.useRef();
1460
- React2.useEffect(() => {
1578
+ const ref = (0, import_react11.useRef)();
1579
+ (0, import_react11.useEffect)(() => {
1461
1580
  ref.current = value;
1462
1581
  });
1463
1582
  return ref.current;
1464
1583
  }
1465
- var BaseCopilotTextarea = React2__namespace.default.forwardRef(
1584
+
1585
+ // src/components/base-copilot-textarea/base-copilot-textarea.tsx
1586
+ var import_jsx_runtime14 = require("react/jsx-runtime");
1587
+ var BaseCopilotTextarea = import_react12.default.forwardRef(
1466
1588
  (props, ref) => {
1467
- return /* @__PURE__ */ jsxRuntime.jsx(HoveringEditorProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(BaseCopilotTextareaWithHoveringContext, __spreadProps(__spreadValues({}, props), { ref })) });
1589
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(HoveringEditorProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(BaseCopilotTextareaWithHoveringContext, __spreadProps(__spreadValues({}, props), { ref })) });
1468
1590
  }
1469
1591
  );
1470
- var BaseCopilotTextareaWithHoveringContext = React2__namespace.default.forwardRef(
1592
+ var BaseCopilotTextareaWithHoveringContext = import_react12.default.forwardRef(
1471
1593
  (props, ref) => {
1472
1594
  const autosuggestionsConfig = __spreadValues(__spreadValues({}, defaultBaseAutosuggestionsConfig), props.baseAutosuggestionsConfig);
1473
- const valueOnInitialRender = React2.useMemo(() => {
1595
+ const valueOnInitialRender = (0, import_react12.useMemo)(() => {
1474
1596
  var _a2;
1475
1597
  return (_a2 = props.value) != null ? _a2 : "";
1476
1598
  }, []);
1477
- const [lastKnownFullEditorText, setLastKnownFullEditorText] = React2.useState(valueOnInitialRender);
1478
- const [cursorMovedSinceLastTextChange, setCursorMovedSinceLastTextChange] = React2.useState(false);
1479
- const initialValue = React2.useMemo(() => {
1599
+ const [lastKnownFullEditorText, setLastKnownFullEditorText] = (0, import_react12.useState)(valueOnInitialRender);
1600
+ const [cursorMovedSinceLastTextChange, setCursorMovedSinceLastTextChange] = (0, import_react12.useState)(false);
1601
+ const initialValue = (0, import_react12.useMemo)(() => {
1480
1602
  return [
1481
1603
  {
1482
1604
  type: "paragraph",
@@ -1486,9 +1608,9 @@ var BaseCopilotTextareaWithHoveringContext = React2__namespace.default.forwardRe
1486
1608
  }, [valueOnInitialRender]);
1487
1609
  const editor = useCopilotTextareaEditor();
1488
1610
  const { isDisplayed: hoveringEditorIsDisplayed, setIsDisplayed: setHoveringEditorIsDisplayed } = useHoveringEditorContext();
1489
- const insertText = React2.useCallback(
1611
+ const insertText = (0, import_react12.useCallback)(
1490
1612
  (autosuggestion) => {
1491
- slate.Editor.insertText(editor, autosuggestion.text, {
1613
+ import_slate10.Editor.insertText(editor, autosuggestion.text, {
1492
1614
  at: autosuggestion.point
1493
1615
  });
1494
1616
  },
@@ -1512,7 +1634,7 @@ var BaseCopilotTextareaWithHoveringContext = React2__namespace.default.forwardRe
1512
1634
  autosuggestionsConfig.disableWhenEmpty,
1513
1635
  shouldDisableAutosuggestions
1514
1636
  );
1515
- const onKeyDownHandlerForHoveringEditor = React2.useCallback(
1637
+ const onKeyDownHandlerForHoveringEditor = (0, import_react12.useCallback)(
1516
1638
  (event) => {
1517
1639
  if (autosuggestionsConfig.shouldToggleHoveringEditorOnKeyPress(event)) {
1518
1640
  event.preventDefault();
@@ -1525,7 +1647,7 @@ var BaseCopilotTextareaWithHoveringContext = React2__namespace.default.forwardRe
1525
1647
  autosuggestionsConfig.shouldToggleHoveringEditorOnKeyPress
1526
1648
  ]
1527
1649
  );
1528
- React2.useEffect(() => {
1650
+ (0, import_react12.useEffect)(() => {
1529
1651
  clearAutocompletionsFromEditor(editor);
1530
1652
  if (currentAutocompleteSuggestion) {
1531
1653
  addAutocompletionsToEditor(
@@ -1535,23 +1657,23 @@ var BaseCopilotTextareaWithHoveringContext = React2__namespace.default.forwardRe
1535
1657
  );
1536
1658
  }
1537
1659
  }, [currentAutocompleteSuggestion]);
1538
- const suggestionStyleAugmented = React2.useMemo(() => {
1660
+ const suggestionStyleAugmented = (0, import_react12.useMemo)(() => {
1539
1661
  return __spreadValues({
1540
1662
  fontStyle: "italic",
1541
1663
  color: "gray"
1542
1664
  }, props.suggestionsStyle);
1543
1665
  }, [props.suggestionsStyle]);
1544
- const renderElementMemoized = React2.useMemo(() => {
1666
+ const renderElementMemoized = (0, import_react12.useMemo)(() => {
1545
1667
  return makeRenderElementFunction(suggestionStyleAugmented);
1546
1668
  }, [suggestionStyleAugmented]);
1547
- const renderPlaceholderMemoized = React2.useMemo(() => {
1669
+ const renderPlaceholderMemoized = (0, import_react12.useMemo)(() => {
1548
1670
  const placeholderStyleSlatejsOverrides = {
1549
1671
  top: void 0
1550
1672
  };
1551
1673
  const placeholderStyleAugmented = __spreadValues(__spreadValues({}, placeholderStyleSlatejsOverrides), props.placeholderStyle);
1552
1674
  return makeRenderPlaceholderFunction(placeholderStyleAugmented);
1553
1675
  }, [props.placeholderStyle]);
1554
- React2.useEffect(() => {
1676
+ (0, import_react12.useEffect)(() => {
1555
1677
  var _a2, _b;
1556
1678
  if (props.value === lastKnownFullEditorText) {
1557
1679
  return;
@@ -1586,11 +1708,11 @@ var BaseCopilotTextareaWithHoveringContext = React2__namespace.default.forwardRe
1586
1708
  const baseClassName = "copilot-textarea";
1587
1709
  const brandingClass = disableBranding ? "no-branding" : "with-branding";
1588
1710
  const defaultTailwindClassName = "bg-white overflow-y-auto resize-y";
1589
- const mergedClassName = tailwindMerge.twMerge(defaultTailwindClassName, className != null ? className : "");
1711
+ const mergedClassName = (0, import_tailwind_merge2.twMerge)(defaultTailwindClassName, className != null ? className : "");
1590
1712
  return `${baseClassName} ${brandingClass} ${mergedClassName}`;
1591
1713
  })();
1592
- return /* @__PURE__ */ jsxRuntime.jsxs(
1593
- slateReact.Slate,
1714
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
1715
+ import_slate_react5.Slate,
1594
1716
  {
1595
1717
  editor,
1596
1718
  initialValue,
@@ -1609,13 +1731,13 @@ var BaseCopilotTextareaWithHoveringContext = React2__namespace.default.forwardRe
1609
1731
  (_b = props.onChange) == null ? void 0 : _b.call(props, makeSemiFakeReactTextAreaEvent(fullEditorText));
1610
1732
  },
1611
1733
  children: [
1612
- /* @__PURE__ */ jsxRuntime.jsx(
1734
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1613
1735
  TrackerTextEditedSinceLastCursorMovement,
1614
1736
  {
1615
1737
  setCursorMovedSinceLastTextChange
1616
1738
  }
1617
1739
  ),
1618
- /* @__PURE__ */ jsxRuntime.jsx(
1740
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1619
1741
  HoveringToolbar,
1620
1742
  {
1621
1743
  apiConfig: autosuggestionsConfig.apiConfig,
@@ -1623,8 +1745,8 @@ var BaseCopilotTextareaWithHoveringContext = React2__namespace.default.forwardRe
1623
1745
  hoverMenuClassname
1624
1746
  }
1625
1747
  ),
1626
- /* @__PURE__ */ jsxRuntime.jsx(
1627
- slateReact.Editable,
1748
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1749
+ import_slate_react5.Editable,
1628
1750
  __spreadValues({
1629
1751
  renderElement: renderElementMemoized,
1630
1752
  renderPlaceholder: renderPlaceholderMemoized,
@@ -1655,6 +1777,13 @@ function makeSemiFakeReactTextAreaEvent(currentText) {
1655
1777
  };
1656
1778
  }
1657
1779
 
1780
+ // src/components/copilot-textarea/copilot-textarea.tsx
1781
+ var import_react15 = __toESM(require("react"));
1782
+
1783
+ // src/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.tsx
1784
+ var import_react_core3 = require("@copilotkit/react-core");
1785
+ var import_react13 = require("react");
1786
+
1658
1787
  // src/lib/retry.tsx
1659
1788
  function retry(fn, retriesLeft = 2, interval = 200, backoff = 1.5) {
1660
1789
  return new Promise((resolve, reject) => {
@@ -1669,9 +1798,12 @@ function retry(fn, retriesLeft = 2, interval = 200, backoff = 1.5) {
1669
1798
  });
1670
1799
  });
1671
1800
  }
1801
+
1802
+ // src/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.tsx
1803
+ var import_react_core4 = require("@copilotkit/react-core");
1672
1804
  function useMakeStandardAutosuggestionFunction(textareaPurpose, contextCategories, apiConfig) {
1673
- const { getContextString, copilotApiConfig } = React2.useContext(reactCore.CopilotContext);
1674
- return React2.useCallback(
1805
+ const { getContextString, copilotApiConfig } = (0, import_react13.useContext)(import_react_core3.CopilotContext);
1806
+ return (0, import_react13.useCallback)(
1675
1807
  (editorState2, abortSignal) => __async(this, null, function* () {
1676
1808
  const res = yield retry(() => __async(this, null, function* () {
1677
1809
  const messages = [
@@ -1694,7 +1826,7 @@ function useMakeStandardAutosuggestionFunction(textareaPurpose, contextCategorie
1694
1826
  content: editorState2.textBeforeCursor
1695
1827
  }
1696
1828
  ];
1697
- const response = yield reactCore.fetchAndDecodeChatCompletionAsText(__spreadProps(__spreadValues({
1829
+ const response = yield (0, import_react_core4.fetchAndDecodeChatCompletionAsText)(__spreadProps(__spreadValues({
1698
1830
  messages
1699
1831
  }, apiConfig.forwardedParams), {
1700
1832
  copilotConfig: copilotApiConfig,
@@ -1936,17 +2068,25 @@ var defaultEditingApiConfig = {
1936
2068
  fewShotMessages: defaultEditingFewShotMessages,
1937
2069
  forwardedParams: void 0
1938
2070
  };
2071
+
2072
+ // src/types/autosuggestions-config/autosuggestions-config.tsx
2073
+ var import_react_core5 = require("@copilotkit/react-core");
1939
2074
  var defaultAutosuggestionsConfig = __spreadProps(__spreadValues({}, defaultBaseAutosuggestionsConfig), {
1940
- contextCategories: reactCore.defaultCopilotContextCategories,
2075
+ contextCategories: import_react_core5.defaultCopilotContextCategories,
1941
2076
  chatApiConfigs: {
1942
2077
  suggestionsApiConfig: defaultSuggestionsApiConfig,
1943
2078
  insertionApiConfig: defaultInsertionsApiConfig,
1944
2079
  editingApiConfig: defaultEditingApiConfig
1945
2080
  }
1946
2081
  });
2082
+
2083
+ // src/hooks/make-autosuggestions-function/use-make-standard-insertion-function.tsx
2084
+ var import_react_core6 = require("@copilotkit/react-core");
2085
+ var import_react14 = require("react");
2086
+ var import_react_core7 = require("@copilotkit/react-core");
1947
2087
  function useMakeStandardInsertionOrEditingFunction(textareaPurpose, contextCategories, insertionApiConfig, editingApiConfig) {
1948
- const { getContextString, copilotApiConfig } = React2.useContext(reactCore.CopilotContext);
1949
- const insertionFunction = React2.useCallback(
2088
+ const { getContextString, copilotApiConfig } = (0, import_react14.useContext)(import_react_core6.CopilotContext);
2089
+ const insertionFunction = (0, import_react14.useCallback)(
1950
2090
  (editorState2, insertionPrompt, documents, abortSignal) => __async(this, null, function* () {
1951
2091
  const res = yield retry(() => __async(this, null, function* () {
1952
2092
  const messages = [
@@ -1974,7 +2114,7 @@ function useMakeStandardInsertionOrEditingFunction(textareaPurpose, contextCateg
1974
2114
  content: insertionPrompt
1975
2115
  }
1976
2116
  ];
1977
- const stream = yield reactCore.fetchAndDecodeChatCompletionAsText(__spreadProps(__spreadValues({
2117
+ const stream = yield (0, import_react_core7.fetchAndDecodeChatCompletionAsText)(__spreadProps(__spreadValues({
1978
2118
  messages
1979
2119
  }, insertionApiConfig.forwardedParams), {
1980
2120
  copilotConfig: copilotApiConfig,
@@ -1986,7 +2126,7 @@ function useMakeStandardInsertionOrEditingFunction(textareaPurpose, contextCateg
1986
2126
  }),
1987
2127
  [insertionApiConfig, getContextString, contextCategories, textareaPurpose]
1988
2128
  );
1989
- const editingFunction = React2.useCallback(
2129
+ const editingFunction = (0, import_react14.useCallback)(
1990
2130
  (editorState2, editingPrompt, documents, abortSignal) => __async(this, null, function* () {
1991
2131
  const res = yield retry(() => __async(this, null, function* () {
1992
2132
  const messages = [
@@ -2019,7 +2159,7 @@ function useMakeStandardInsertionOrEditingFunction(textareaPurpose, contextCateg
2019
2159
  content: editingPrompt
2020
2160
  }
2021
2161
  ];
2022
- const stream = yield reactCore.fetchAndDecodeChatCompletionAsText(__spreadProps(__spreadValues({
2162
+ const stream = yield (0, import_react_core7.fetchAndDecodeChatCompletionAsText)(__spreadProps(__spreadValues({
2023
2163
  messages
2024
2164
  }, editingApiConfig.forwardedParams), {
2025
2165
  copilotConfig: copilotApiConfig,
@@ -2031,7 +2171,7 @@ function useMakeStandardInsertionOrEditingFunction(textareaPurpose, contextCateg
2031
2171
  }),
2032
2172
  [editingApiConfig, getContextString, contextCategories, textareaPurpose]
2033
2173
  );
2034
- const insertionOrEditingFunction = React2.useCallback(
2174
+ const insertionOrEditingFunction = (0, import_react14.useCallback)(
2035
2175
  (editorState2, insertionPrompt, documents, abortSignal) => __async(this, null, function* () {
2036
2176
  if (editorState2.selectedText === "") {
2037
2177
  return yield insertionFunction(editorState2, insertionPrompt, documents, abortSignal);
@@ -2043,10 +2183,14 @@ function useMakeStandardInsertionOrEditingFunction(textareaPurpose, contextCateg
2043
2183
  );
2044
2184
  return insertionOrEditingFunction;
2045
2185
  }
2046
- var CopilotTextarea = React2__namespace.default.forwardRef(
2186
+
2187
+ // src/components/copilot-textarea/copilot-textarea.tsx
2188
+ var import_lodash = __toESM(require("lodash.merge"));
2189
+ var import_jsx_runtime15 = require("react/jsx-runtime");
2190
+ var CopilotTextarea = import_react15.default.forwardRef(
2047
2191
  (props, ref) => {
2048
2192
  const _a = props, { autosuggestionsConfig: autosuggestionsConfigUserSpecified } = _a, forwardedProps = __objRest(_a, ["autosuggestionsConfig"]);
2049
- const autosuggestionsConfig = merge__default.default(
2193
+ const autosuggestionsConfig = (0, import_lodash.default)(
2050
2194
  defaultAutosuggestionsConfig,
2051
2195
  autosuggestionsConfigUserSpecified
2052
2196
  );
@@ -2061,7 +2205,7 @@ var CopilotTextarea = React2__namespace.default.forwardRef(
2061
2205
  autosuggestionsConfig.chatApiConfigs.insertionApiConfig,
2062
2206
  autosuggestionsConfig.chatApiConfigs.editingApiConfig
2063
2207
  );
2064
- return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsx(
2208
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_jsx_runtime15.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
2065
2209
  BaseCopilotTextarea,
2066
2210
  __spreadProps(__spreadValues({
2067
2211
  ref
@@ -2076,8 +2220,9 @@ var CopilotTextarea = React2__namespace.default.forwardRef(
2076
2220
  ) });
2077
2221
  }
2078
2222
  );
2079
-
2080
- exports.BaseCopilotTextarea = BaseCopilotTextarea;
2081
- exports.CopilotTextarea = CopilotTextarea;
2082
- //# sourceMappingURL=out.js.map
2223
+ // Annotate the CommonJS export names for ESM import in node:
2224
+ 0 && (module.exports = {
2225
+ BaseCopilotTextarea,
2226
+ CopilotTextarea
2227
+ });
2083
2228
  //# sourceMappingURL=index.js.map