@copilotkit/react-textarea 0.21.0-alpha.6 → 0.21.0-alpha.7

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 (352) hide show
  1. package/.turbo/turbo-build.log +246 -363
  2. package/CHANGELOG.md +11 -0
  3. package/dist/chunk-2NURR2DX.mjs +8 -16
  4. package/dist/chunk-2NURR2DX.mjs.map +1 -1
  5. package/dist/chunk-463BFNUP.mjs +5 -16
  6. package/dist/chunk-463BFNUP.mjs.map +1 -1
  7. package/dist/chunk-4S5ZJH3I.mjs +2 -3
  8. package/dist/chunk-4S5ZJH3I.mjs.map +1 -1
  9. package/dist/chunk-5EJ5XOGP.mjs +8 -16
  10. package/dist/chunk-5EJ5XOGP.mjs.map +1 -1
  11. package/dist/chunk-5FO6ISW4.mjs +2 -0
  12. package/dist/chunk-5FO6ISW4.mjs.map +1 -1
  13. package/dist/chunk-AXN37AHC.mjs +2 -5
  14. package/dist/chunk-AXN37AHC.mjs.map +1 -1
  15. package/dist/chunk-CSGFJU3L.mjs +6 -11
  16. package/dist/chunk-CSGFJU3L.mjs.map +1 -1
  17. package/dist/chunk-DE5K76I2.mjs +2 -0
  18. package/dist/chunk-DE5K76I2.mjs.map +1 -1
  19. package/dist/chunk-DYGPLRY3.mjs +7 -15
  20. package/dist/chunk-DYGPLRY3.mjs.map +1 -1
  21. package/dist/chunk-F2TIBXML.mjs +7 -19
  22. package/dist/chunk-F2TIBXML.mjs.map +1 -1
  23. package/dist/chunk-F3MHL6ZY.mjs +4 -4
  24. package/dist/chunk-F3MHL6ZY.mjs.map +1 -1
  25. package/dist/chunk-GCMQHIRF.mjs +3 -6
  26. package/dist/chunk-GCMQHIRF.mjs.map +1 -1
  27. package/dist/chunk-H4VKQGVU.mjs +2 -0
  28. package/dist/chunk-H4VKQGVU.mjs.map +1 -1
  29. package/dist/{chunk-DB5KKYRC.mjs → chunk-IJC2EXRO.mjs} +12 -24
  30. package/dist/chunk-IJC2EXRO.mjs.map +1 -0
  31. package/dist/chunk-IU3WTXLQ.mjs +2 -0
  32. package/dist/chunk-IU3WTXLQ.mjs.map +1 -1
  33. package/dist/chunk-IXJ2HCOA.mjs +4 -14
  34. package/dist/chunk-IXJ2HCOA.mjs.map +1 -1
  35. package/dist/chunk-JAFCXEPU.mjs +3 -6
  36. package/dist/chunk-JAFCXEPU.mjs.map +1 -1
  37. package/dist/{chunk-MPAJBVBL.mjs → chunk-JBI2MZB4.mjs} +23 -59
  38. package/dist/chunk-JBI2MZB4.mjs.map +1 -0
  39. package/dist/chunk-JHTAOLEW.mjs +2 -5
  40. package/dist/chunk-JHTAOLEW.mjs.map +1 -1
  41. package/dist/chunk-KCHYD3EB.mjs +5 -6
  42. package/dist/chunk-KCHYD3EB.mjs.map +1 -1
  43. package/dist/chunk-KGKLUWKW.mjs +6 -15
  44. package/dist/chunk-KGKLUWKW.mjs.map +1 -1
  45. package/dist/chunk-L7VVZH4Q.mjs +2 -0
  46. package/dist/chunk-L7VVZH4Q.mjs.map +1 -1
  47. package/dist/chunk-LNAIMEB2.mjs +4 -9
  48. package/dist/chunk-LNAIMEB2.mjs.map +1 -1
  49. package/dist/chunk-MMVDU6DF.mjs +2 -0
  50. package/dist/chunk-MMVDU6DF.mjs.map +1 -1
  51. package/dist/chunk-MPME5BW2.mjs +4 -4
  52. package/dist/chunk-MPME5BW2.mjs.map +1 -1
  53. package/dist/{chunk-XHFJMEFG.mjs → chunk-MRPRZQMN.mjs} +13 -35
  54. package/dist/chunk-MRPRZQMN.mjs.map +1 -0
  55. package/dist/chunk-MRXNTQOX.mjs +2 -6
  56. package/dist/chunk-MRXNTQOX.mjs.map +1 -1
  57. package/dist/chunk-ND5PXTAW.mjs +4 -4
  58. package/dist/chunk-ND5PXTAW.mjs.map +1 -1
  59. package/dist/chunk-NKW5OU2S.mjs +3 -6
  60. package/dist/chunk-NKW5OU2S.mjs.map +1 -1
  61. package/dist/{chunk-FCN4H6UP.mjs → chunk-NO3EYPQH.mjs} +5 -9
  62. package/dist/chunk-NO3EYPQH.mjs.map +1 -0
  63. package/dist/chunk-O5OWT5GE.mjs +8 -23
  64. package/dist/chunk-O5OWT5GE.mjs.map +1 -1
  65. package/dist/chunk-OD7ZMOVE.mjs +7 -11
  66. package/dist/chunk-OD7ZMOVE.mjs.map +1 -1
  67. package/dist/chunk-OELUUJZY.mjs +4 -10
  68. package/dist/chunk-OELUUJZY.mjs.map +1 -1
  69. package/dist/{chunk-TIBMW3DC.mjs → chunk-PGGR6HL5.mjs} +7 -12
  70. package/dist/chunk-PGGR6HL5.mjs.map +1 -0
  71. package/dist/chunk-QJDMIGLU.mjs +4 -12
  72. package/dist/chunk-QJDMIGLU.mjs.map +1 -1
  73. package/dist/chunk-RQHOUUXQ.mjs +4 -4
  74. package/dist/chunk-RQHOUUXQ.mjs.map +1 -1
  75. package/dist/chunk-RR6OQGTI.mjs +2 -5
  76. package/dist/chunk-RR6OQGTI.mjs.map +1 -1
  77. package/dist/chunk-S6JUGJK2.mjs +2 -3
  78. package/dist/chunk-S6JUGJK2.mjs.map +1 -1
  79. package/dist/chunk-UHD44NC5.mjs +7 -17
  80. package/dist/chunk-UHD44NC5.mjs.map +1 -1
  81. package/dist/{chunk-7KHNUXA4.mjs → chunk-UIN6BEVR.mjs} +11 -25
  82. package/dist/chunk-UIN6BEVR.mjs.map +1 -0
  83. package/dist/chunk-WADHCMPK.mjs +2 -0
  84. package/dist/chunk-WADHCMPK.mjs.map +1 -1
  85. package/dist/chunk-WJHSY5T6.mjs +2 -0
  86. package/dist/chunk-WJHSY5T6.mjs.map +1 -1
  87. package/dist/chunk-WJYQWL4I.mjs +4 -4
  88. package/dist/chunk-WJYQWL4I.mjs.map +1 -1
  89. package/dist/chunk-WLPYYGES.mjs +22 -42
  90. package/dist/chunk-WLPYYGES.mjs.map +1 -1
  91. package/dist/chunk-WPIA53HF.mjs +7 -15
  92. package/dist/chunk-WPIA53HF.mjs.map +1 -1
  93. package/dist/chunk-XHUMROEY.mjs +7 -17
  94. package/dist/chunk-XHUMROEY.mjs.map +1 -1
  95. package/dist/chunk-YQU7WG7T.mjs +6 -12
  96. package/dist/chunk-YQU7WG7T.mjs.map +1 -1
  97. package/dist/chunk-YTOPHPSG.mjs +4 -4
  98. package/dist/chunk-YTOPHPSG.mjs.map +1 -1
  99. package/dist/chunk-YW3REYX6.mjs +5 -6
  100. package/dist/chunk-YW3REYX6.mjs.map +1 -1
  101. package/dist/components/base-copilot-textarea/base-copilot-textarea.mjs +35 -39
  102. package/dist/components/base-copilot-textarea/base-copilot-textarea.mjs.map +1 -1
  103. package/dist/components/base-copilot-textarea/render-element.mjs +3 -7
  104. package/dist/components/base-copilot-textarea/render-element.mjs.map +1 -1
  105. package/dist/components/base-copilot-textarea/render-placeholder.mjs +3 -7
  106. package/dist/components/base-copilot-textarea/render-placeholder.mjs.map +1 -1
  107. package/dist/components/base-copilot-textarea/track-cursor-moved-since-last-text-change.mjs +4 -8
  108. package/dist/components/base-copilot-textarea/track-cursor-moved-since-last-text-change.mjs.map +1 -1
  109. package/dist/components/base-copilot-textarea/use-add-branding-css.mjs +3 -7
  110. package/dist/components/base-copilot-textarea/use-add-branding-css.mjs.map +1 -1
  111. package/dist/components/copilot-textarea/copilot-textarea.mjs +47 -51
  112. package/dist/components/copilot-textarea/copilot-textarea.mjs.map +1 -1
  113. package/dist/components/hovering-toolbar/hovering-editor-provider.mjs +3 -9
  114. package/dist/components/hovering-toolbar/hovering-editor-provider.mjs.map +1 -1
  115. package/dist/components/hovering-toolbar/hovering-toolbar-components.mjs +3 -15
  116. package/dist/components/hovering-toolbar/hovering-toolbar-components.mjs.map +1 -1
  117. package/dist/components/hovering-toolbar/hovering-toolbar.mjs +18 -22
  118. package/dist/components/hovering-toolbar/hovering-toolbar.mjs.map +1 -1
  119. package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.mjs +12 -16
  120. package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.mjs.map +1 -1
  121. package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.mjs +13 -17
  122. package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.mjs.map +1 -1
  123. package/dist/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.mjs +5 -11
  124. package/dist/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.mjs.map +1 -1
  125. package/dist/components/hovering-toolbar/text-insertion-prompt-box/index.mjs +14 -18
  126. package/dist/components/hovering-toolbar/text-insertion-prompt-box/index.mjs.map +1 -1
  127. package/dist/components/index.mjs +48 -55
  128. package/dist/components/index.mjs.map +1 -1
  129. package/dist/components/manual-ui/chip-with-icon.mjs +5 -6
  130. package/dist/components/manual-ui/chip-with-icon.mjs.map +1 -1
  131. package/dist/components/source-search-box/source-search-box.mjs +6 -12
  132. package/dist/components/source-search-box/source-search-box.mjs.map +1 -1
  133. package/dist/components/ui/button.mjs +4 -10
  134. package/dist/components/ui/button.mjs.map +1 -1
  135. package/dist/components/ui/card.mjs +7 -18
  136. package/dist/components/ui/card.mjs.map +1 -1
  137. package/dist/components/ui/command.mjs +5 -25
  138. package/dist/components/ui/command.mjs.map +1 -1
  139. package/dist/components/ui/dialog.mjs +4 -20
  140. package/dist/components/ui/dialog.mjs.map +1 -1
  141. package/dist/components/ui/label.mjs +4 -8
  142. package/dist/components/ui/label.mjs.map +1 -1
  143. package/dist/components/ui/separator.mjs +8 -15
  144. package/dist/components/ui/separator.mjs.map +1 -1
  145. package/dist/components/ui/textarea.mjs +7 -13
  146. package/dist/components/ui/textarea.mjs.map +1 -1
  147. package/dist/context/index.mjs +2 -1
  148. package/dist/context/index.mjs.map +1 -1
  149. package/dist/hooks/base-copilot-textarea-implementation/use-autosuggestions.mjs +6 -10
  150. package/dist/hooks/base-copilot-textarea-implementation/use-autosuggestions.mjs.map +1 -1
  151. package/dist/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.mjs +4 -8
  152. package/dist/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.mjs.map +1 -1
  153. package/dist/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.mjs +5 -9
  154. package/dist/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.mjs.map +1 -1
  155. package/dist/hooks/index.mjs +2 -1
  156. package/dist/hooks/index.mjs.map +1 -1
  157. package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.mjs +14 -18
  158. package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.mjs.map +1 -1
  159. package/dist/hooks/make-autosuggestions-function/use-make-standard-insertion-function.mjs +14 -18
  160. package/dist/hooks/make-autosuggestions-function/use-make-standard-insertion-function.mjs.map +1 -1
  161. package/dist/hooks/misc/use-autosize-textarea.mjs +3 -7
  162. package/dist/hooks/misc/use-autosize-textarea.mjs.map +1 -1
  163. package/dist/index.mjs +50 -66
  164. package/dist/index.mjs.map +1 -1
  165. package/dist/lib/debouncer.mjs +3 -7
  166. package/dist/lib/debouncer.mjs.map +1 -1
  167. package/dist/lib/editor-to-text.mjs +3 -7
  168. package/dist/lib/editor-to-text.mjs.map +1 -1
  169. package/dist/lib/get-text-around-cursor.mjs +3 -13
  170. package/dist/lib/get-text-around-cursor.mjs.map +1 -1
  171. package/dist/lib/retry.mjs +3 -7
  172. package/dist/lib/retry.mjs.map +1 -1
  173. package/dist/lib/slatejs-edits/add-autocompletions.mjs +3 -7
  174. package/dist/lib/slatejs-edits/add-autocompletions.mjs.map +1 -1
  175. package/dist/lib/slatejs-edits/clear-autocompletions.mjs +3 -7
  176. package/dist/lib/slatejs-edits/clear-autocompletions.mjs.map +1 -1
  177. package/dist/lib/slatejs-edits/replace-text.mjs +3 -7
  178. package/dist/lib/slatejs-edits/replace-text.mjs.map +1 -1
  179. package/dist/lib/slatejs-edits/with-partial-history.mjs +3 -9
  180. package/dist/lib/slatejs-edits/with-partial-history.mjs.map +1 -1
  181. package/dist/lib/stream-promise-flatten.mjs +3 -7
  182. package/dist/lib/stream-promise-flatten.mjs.map +1 -1
  183. package/dist/lib/utils.mjs +3 -17
  184. package/dist/lib/utils.mjs.map +1 -1
  185. package/dist/lib/utils.test.mjs +1 -0
  186. package/dist/lib/utils.test.mjs.map +1 -1
  187. package/dist/types/autosuggestions-config/autosuggestions-config-user-specified.mjs +2 -0
  188. package/dist/types/autosuggestions-config/autosuggestions-config-user-specified.mjs.map +1 -1
  189. package/dist/types/autosuggestions-config/autosuggestions-config.mjs +8 -12
  190. package/dist/types/autosuggestions-config/autosuggestions-config.mjs.map +1 -1
  191. package/dist/types/autosuggestions-config/editing-api-config.mjs +3 -11
  192. package/dist/types/autosuggestions-config/editing-api-config.mjs.map +1 -1
  193. package/dist/types/autosuggestions-config/index.mjs +10 -17
  194. package/dist/types/autosuggestions-config/index.mjs.map +1 -1
  195. package/dist/types/autosuggestions-config/insertions-api-config.mjs +3 -11
  196. package/dist/types/autosuggestions-config/insertions-api-config.mjs.map +1 -1
  197. package/dist/types/autosuggestions-config/subtypes/chatlike-api-endpoint.mjs +3 -7
  198. package/dist/types/autosuggestions-config/subtypes/chatlike-api-endpoint.mjs.map +1 -1
  199. package/dist/types/autosuggestions-config/subtypes/make-system-prompt.mjs +2 -0
  200. package/dist/types/autosuggestions-config/subtypes/make-system-prompt.mjs.map +1 -1
  201. package/dist/types/autosuggestions-config/subtypes/minimal-chat-gpt-message.mjs +2 -0
  202. package/dist/types/autosuggestions-config/subtypes/minimal-chat-gpt-message.mjs.map +1 -1
  203. package/dist/types/autosuggestions-config/suggestions-api-config.mjs +3 -11
  204. package/dist/types/autosuggestions-config/suggestions-api-config.mjs.map +1 -1
  205. package/dist/types/base/autosuggestion-state.mjs +2 -0
  206. package/dist/types/base/autosuggestion-state.mjs.map +1 -1
  207. package/dist/types/base/autosuggestions-bare-function.mjs +2 -0
  208. package/dist/types/base/autosuggestions-bare-function.mjs.map +1 -1
  209. package/dist/types/base/base-autosuggestions-config.mjs +3 -7
  210. package/dist/types/base/base-autosuggestions-config.mjs.map +1 -1
  211. package/dist/types/base/base-copilot-textarea-props.mjs +2 -0
  212. package/dist/types/base/base-copilot-textarea-props.mjs.map +1 -1
  213. package/dist/types/base/custom-editor.mjs +2 -0
  214. package/dist/types/base/custom-editor.mjs.map +1 -1
  215. package/dist/types/base/editor-autocomplete-state.mjs +4 -8
  216. package/dist/types/base/editor-autocomplete-state.mjs.map +1 -1
  217. package/dist/types/base/index.mjs +4 -8
  218. package/dist/types/base/index.mjs.map +1 -1
  219. package/dist/types/html-copilot-textarea-element.mjs +2 -1
  220. package/dist/types/html-copilot-textarea-element.mjs.map +1 -1
  221. package/dist/types/index.mjs +12 -22
  222. package/dist/types/index.mjs.map +1 -1
  223. package/package.json +4 -4
  224. package/src/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.tsx +2 -2
  225. package/dist/chunk-7KHNUXA4.mjs.map +0 -1
  226. package/dist/chunk-DB5KKYRC.mjs.map +0 -1
  227. package/dist/chunk-FCN4H6UP.mjs.map +0 -1
  228. package/dist/chunk-MPAJBVBL.mjs.map +0 -1
  229. package/dist/chunk-TIBMW3DC.mjs.map +0 -1
  230. package/dist/chunk-XHFJMEFG.mjs.map +0 -1
  231. package/dist/components/base-copilot-textarea/base-copilot-textarea.js +0 -1772
  232. package/dist/components/base-copilot-textarea/base-copilot-textarea.js.map +0 -1
  233. package/dist/components/base-copilot-textarea/render-element.js +0 -75
  234. package/dist/components/base-copilot-textarea/render-element.js.map +0 -1
  235. package/dist/components/base-copilot-textarea/render-placeholder.js +0 -69
  236. package/dist/components/base-copilot-textarea/render-placeholder.js.map +0 -1
  237. package/dist/components/base-copilot-textarea/track-cursor-moved-since-last-text-change.js +0 -112
  238. package/dist/components/base-copilot-textarea/track-cursor-moved-since-last-text-change.js.map +0 -1
  239. package/dist/components/base-copilot-textarea/use-add-branding-css.js +0 -83
  240. package/dist/components/base-copilot-textarea/use-add-branding-css.js.map +0 -1
  241. package/dist/components/copilot-textarea/copilot-textarea.js +0 -2246
  242. package/dist/components/copilot-textarea/copilot-textarea.js.map +0 -1
  243. package/dist/components/hovering-toolbar/hovering-editor-provider.js +0 -49
  244. package/dist/components/hovering-toolbar/hovering-editor-provider.js.map +0 -1
  245. package/dist/components/hovering-toolbar/hovering-toolbar-components.js +0 -158
  246. package/dist/components/hovering-toolbar/hovering-toolbar-components.js.map +0 -1
  247. package/dist/components/hovering-toolbar/hovering-toolbar.js +0 -915
  248. package/dist/components/hovering-toolbar/hovering-toolbar.js.map +0 -1
  249. package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.js +0 -622
  250. package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.js.map +0 -1
  251. package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.js +0 -639
  252. package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.js.map +0 -1
  253. package/dist/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.js +0 -140
  254. package/dist/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.js.map +0 -1
  255. package/dist/components/hovering-toolbar/text-insertion-prompt-box/index.js +0 -639
  256. package/dist/components/hovering-toolbar/text-insertion-prompt-box/index.js.map +0 -1
  257. package/dist/components/index.js +0 -2250
  258. package/dist/components/index.js.map +0 -1
  259. package/dist/components/manual-ui/chip-with-icon.js +0 -53
  260. package/dist/components/manual-ui/chip-with-icon.js.map +0 -1
  261. package/dist/components/source-search-box/source-search-box.js +0 -243
  262. package/dist/components/source-search-box/source-search-box.js.map +0 -1
  263. package/dist/components/ui/button.js +0 -118
  264. package/dist/components/ui/button.js.map +0 -1
  265. package/dist/components/ui/card.js +0 -142
  266. package/dist/components/ui/card.js.map +0 -1
  267. package/dist/components/ui/command.js +0 -306
  268. package/dist/components/ui/command.js.map +0 -1
  269. package/dist/components/ui/dialog.js +0 -199
  270. package/dist/components/ui/dialog.js.map +0 -1
  271. package/dist/components/ui/label.js +0 -92
  272. package/dist/components/ui/label.js.map +0 -1
  273. package/dist/components/ui/separator.js +0 -96
  274. package/dist/components/ui/separator.js.map +0 -1
  275. package/dist/components/ui/textarea.js +0 -91
  276. package/dist/components/ui/textarea.js.map +0 -1
  277. package/dist/context/index.js +0 -19
  278. package/dist/context/index.js.map +0 -1
  279. package/dist/hooks/base-copilot-textarea-implementation/use-autosuggestions.js +0 -193
  280. package/dist/hooks/base-copilot-textarea-implementation/use-autosuggestions.js.map +0 -1
  281. package/dist/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.js +0 -194
  282. package/dist/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.js.map +0 -1
  283. package/dist/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.js +0 -180
  284. package/dist/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.js.map +0 -1
  285. package/dist/hooks/index.js +0 -19
  286. package/dist/hooks/index.js.map +0 -1
  287. package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.js +0 -167
  288. package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.js.map +0 -1
  289. package/dist/hooks/make-autosuggestions-function/use-make-standard-insertion-function.js +0 -227
  290. package/dist/hooks/make-autosuggestions-function/use-make-standard-insertion-function.js.map +0 -1
  291. package/dist/hooks/misc/use-autosize-textarea.js +0 -39
  292. package/dist/hooks/misc/use-autosize-textarea.js.map +0 -1
  293. package/dist/index.js +0 -2256
  294. package/dist/index.js.map +0 -1
  295. package/dist/lib/debouncer.js +0 -76
  296. package/dist/lib/debouncer.js.map +0 -1
  297. package/dist/lib/editor-to-text.js +0 -69
  298. package/dist/lib/editor-to-text.js.map +0 -1
  299. package/dist/lib/get-text-around-cursor.js +0 -131
  300. package/dist/lib/get-text-around-cursor.js.map +0 -1
  301. package/dist/lib/retry.js +0 -43
  302. package/dist/lib/retry.js.map +0 -1
  303. package/dist/lib/slatejs-edits/add-autocompletions.js +0 -51
  304. package/dist/lib/slatejs-edits/add-autocompletions.js.map +0 -1
  305. package/dist/lib/slatejs-edits/clear-autocompletions.js +0 -49
  306. package/dist/lib/slatejs-edits/clear-autocompletions.js.map +0 -1
  307. package/dist/lib/slatejs-edits/replace-text.js +0 -53
  308. package/dist/lib/slatejs-edits/replace-text.js.map +0 -1
  309. package/dist/lib/slatejs-edits/with-partial-history.js +0 -133
  310. package/dist/lib/slatejs-edits/with-partial-history.js.map +0 -1
  311. package/dist/lib/stream-promise-flatten.js +0 -72
  312. package/dist/lib/stream-promise-flatten.js.map +0 -1
  313. package/dist/lib/utils.js +0 -101
  314. package/dist/lib/utils.js.map +0 -1
  315. package/dist/lib/utils.test.js +0 -9
  316. package/dist/lib/utils.test.js.map +0 -1
  317. package/dist/types/autosuggestions-config/autosuggestions-config-user-specified.js +0 -19
  318. package/dist/types/autosuggestions-config/autosuggestions-config-user-specified.js.map +0 -1
  319. package/dist/types/autosuggestions-config/autosuggestions-config.js +0 -275
  320. package/dist/types/autosuggestions-config/autosuggestions-config.js.map +0 -1
  321. package/dist/types/autosuggestions-config/editing-api-config.js +0 -109
  322. package/dist/types/autosuggestions-config/editing-api-config.js.map +0 -1
  323. package/dist/types/autosuggestions-config/index.js +0 -331
  324. package/dist/types/autosuggestions-config/index.js.map +0 -1
  325. package/dist/types/autosuggestions-config/insertions-api-config.js +0 -103
  326. package/dist/types/autosuggestions-config/insertions-api-config.js.map +0 -1
  327. package/dist/types/autosuggestions-config/subtypes/chatlike-api-endpoint.js +0 -99
  328. package/dist/types/autosuggestions-config/subtypes/chatlike-api-endpoint.js.map +0 -1
  329. package/dist/types/autosuggestions-config/subtypes/make-system-prompt.js +0 -19
  330. package/dist/types/autosuggestions-config/subtypes/make-system-prompt.js.map +0 -1
  331. package/dist/types/autosuggestions-config/subtypes/minimal-chat-gpt-message.js +0 -19
  332. package/dist/types/autosuggestions-config/subtypes/minimal-chat-gpt-message.js.map +0 -1
  333. package/dist/types/autosuggestions-config/suggestions-api-config.js +0 -92
  334. package/dist/types/autosuggestions-config/suggestions-api-config.js.map +0 -1
  335. package/dist/types/base/autosuggestion-state.js +0 -19
  336. package/dist/types/base/autosuggestion-state.js.map +0 -1
  337. package/dist/types/base/autosuggestions-bare-function.js +0 -19
  338. package/dist/types/base/autosuggestions-bare-function.js.map +0 -1
  339. package/dist/types/base/base-autosuggestions-config.js +0 -38
  340. package/dist/types/base/base-autosuggestions-config.js.map +0 -1
  341. package/dist/types/base/base-copilot-textarea-props.js +0 -19
  342. package/dist/types/base/base-copilot-textarea-props.js.map +0 -1
  343. package/dist/types/base/custom-editor.js +0 -19
  344. package/dist/types/base/custom-editor.js.map +0 -1
  345. package/dist/types/base/editor-autocomplete-state.js +0 -45
  346. package/dist/types/base/editor-autocomplete-state.js.map +0 -1
  347. package/dist/types/base/index.js +0 -40
  348. package/dist/types/base/index.js.map +0 -1
  349. package/dist/types/html-copilot-textarea-element.js +0 -19
  350. package/dist/types/html-copilot-textarea-element.js.map +0 -1
  351. package/dist/types/index.js +0 -333
  352. package/dist/types/index.js.map +0 -1
package/dist/index.js DELETED
@@ -1,2256 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __defProps = Object.defineProperties;
5
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
7
- var __getOwnPropNames = Object.getOwnPropertyNames;
8
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
9
- var __getProtoOf = Object.getPrototypeOf;
10
- var __hasOwnProp = Object.prototype.hasOwnProperty;
11
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
12
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
13
- var __spreadValues = (a, b) => {
14
- for (var prop in b || (b = {}))
15
- if (__hasOwnProp.call(b, prop))
16
- __defNormalProp(a, prop, b[prop]);
17
- if (__getOwnPropSymbols)
18
- for (var prop of __getOwnPropSymbols(b)) {
19
- if (__propIsEnum.call(b, prop))
20
- __defNormalProp(a, prop, b[prop]);
21
- }
22
- return a;
23
- };
24
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
25
- var __objRest = (source, exclude) => {
26
- var target = {};
27
- for (var prop in source)
28
- if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
29
- target[prop] = source[prop];
30
- if (source != null && __getOwnPropSymbols)
31
- for (var prop of __getOwnPropSymbols(source)) {
32
- if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
33
- target[prop] = source[prop];
34
- }
35
- return target;
36
- };
37
- var __export = (target, all) => {
38
- for (var name in all)
39
- __defProp(target, name, { get: all[name], enumerable: true });
40
- };
41
- var __copyProps = (to, from, except, desc) => {
42
- if (from && typeof from === "object" || typeof from === "function") {
43
- for (let key of __getOwnPropNames(from))
44
- if (!__hasOwnProp.call(to, key) && key !== except)
45
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
46
- }
47
- return to;
48
- };
49
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
50
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
51
- mod
52
- ));
53
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
54
- var __async = (__this, __arguments, generator) => {
55
- return new Promise((resolve, reject) => {
56
- var fulfilled = (value) => {
57
- try {
58
- step(generator.next(value));
59
- } catch (e) {
60
- reject(e);
61
- }
62
- };
63
- var rejected = (value) => {
64
- try {
65
- step(generator.throw(value));
66
- } catch (e) {
67
- reject(e);
68
- }
69
- };
70
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
71
- step((generator = generator.apply(__this, __arguments)).next());
72
- });
73
- };
74
-
75
- // src/index.tsx
76
- var src_exports = {};
77
- __export(src_exports, {
78
- BaseCopilotTextarea: () => BaseCopilotTextarea,
79
- ChatlikeApiEndpoint: () => ChatlikeApiEndpoint,
80
- CopilotTextarea: () => CopilotTextarea,
81
- defaultAutosuggestionsConfig: () => defaultAutosuggestionsConfig,
82
- defaultBaseAutosuggestionsConfig: () => defaultBaseAutosuggestionsConfig
83
- });
84
- module.exports = __toCommonJS(src_exports);
85
-
86
- // src/components/base-copilot-textarea/base-copilot-textarea.tsx
87
- var import_react12 = __toESM(require("react"));
88
- var import_slate10 = require("slate");
89
- var import_slate_react5 = require("slate-react");
90
- var import_tailwind_merge2 = require("tailwind-merge");
91
-
92
- // src/hooks/base-copilot-textarea-implementation/use-autosuggestions.ts
93
- var import_react = require("react");
94
-
95
- // src/lib/debouncer.ts
96
- var Debouncer = class {
97
- constructor(wait) {
98
- this.wait = wait;
99
- this.debounce = (func, ...args) => __async(this, null, function* () {
100
- this.cancel();
101
- this.timeoutId = setTimeout(() => __async(this, null, function* () {
102
- try {
103
- this.activeAbortController = new AbortController();
104
- yield func(...args, this.activeAbortController.signal);
105
- this.activeAbortController = void 0;
106
- } catch (error) {
107
- }
108
- }), this.wait);
109
- });
110
- this.cancel = () => {
111
- if (this.activeAbortController) {
112
- this.activeAbortController.abort();
113
- this.activeAbortController = void 0;
114
- }
115
- if (this.timeoutId !== void 0) {
116
- clearTimeout(this.timeoutId);
117
- this.timeoutId = void 0;
118
- }
119
- };
120
- }
121
- };
122
-
123
- // src/lib/utils.ts
124
- var import_clsx = require("clsx");
125
- var import_nanoid = require("nanoid");
126
- var import_tailwind_merge = require("tailwind-merge");
127
- function cn(...inputs) {
128
- return (0, import_tailwind_merge.twMerge)((0, import_clsx.clsx)(inputs));
129
- }
130
- var nanoid = (0, import_nanoid.customAlphabet)(
131
- "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
132
- 7
133
- );
134
- var arraysAreEqual = (arr1, arr2) => arr1.length === arr2.length && arr1.every((value, index) => value === arr2[index]);
135
- function nullableCompatibleEqualityCheck(naiveEqualityCheck, a, b) {
136
- if (a === null || a === void 0 || b === null || b === void 0) {
137
- return a === b;
138
- }
139
- return naiveEqualityCheck(a, b);
140
- }
141
-
142
- // src/types/base/editor-autocomplete-state.ts
143
- function areEqual_autocompleteState(prev, next) {
144
- return prev.cursorPoint.offset === next.cursorPoint.offset && arraysAreEqual(prev.cursorPoint.path, next.cursorPoint.path) && prev.textBeforeCursor === next.textBeforeCursor && prev.textAfterCursor === next.textAfterCursor;
145
- }
146
-
147
- // src/hooks/base-copilot-textarea-implementation/use-autosuggestions.ts
148
- function useAutosuggestions(debounceTime, acceptAutosuggestionKey, autosuggestionFunction, insertAutocompleteSuggestion, disableWhenEmpty, disabled) {
149
- const [previousAutocompleteState, setPreviousAutocompleteState] = (0, import_react.useState)(null);
150
- const [currentAutocompleteSuggestion, setCurrentAutocompleteSuggestion] = (0, import_react.useState)(null);
151
- const awaitForAndAppendSuggestion = (0, import_react.useCallback)(
152
- (editorAutocompleteState, abortSignal) => __async(this, null, function* () {
153
- if (disabled) {
154
- return;
155
- }
156
- if (disableWhenEmpty && editorAutocompleteState.textBeforeCursor === "" && editorAutocompleteState.textAfterCursor === "") {
157
- return;
158
- }
159
- const suggestion = yield autosuggestionFunction(
160
- editorAutocompleteState,
161
- abortSignal
162
- );
163
- if (!suggestion || abortSignal.aborted) {
164
- throw new DOMException("Aborted", "AbortError");
165
- }
166
- setCurrentAutocompleteSuggestion({
167
- text: suggestion,
168
- point: editorAutocompleteState.cursorPoint
169
- });
170
- }),
171
- [
172
- autosuggestionFunction,
173
- setCurrentAutocompleteSuggestion,
174
- disableWhenEmpty,
175
- disabled
176
- ]
177
- );
178
- const debouncedFunction = (0, import_react.useMemo)(
179
- () => new Debouncer(
180
- debounceTime
181
- ),
182
- [debounceTime]
183
- );
184
- (0, import_react.useEffect)(() => {
185
- return () => {
186
- debouncedFunction.cancel();
187
- setCurrentAutocompleteSuggestion(null);
188
- };
189
- }, [debouncedFunction, disabled]);
190
- const onChange = (0, import_react.useCallback)(
191
- (newEditorState) => {
192
- const editorStateHasChanged = !nullableCompatibleEqualityCheck(
193
- areEqual_autocompleteState,
194
- previousAutocompleteState,
195
- newEditorState
196
- );
197
- setPreviousAutocompleteState(newEditorState);
198
- if (!editorStateHasChanged) {
199
- return;
200
- }
201
- setCurrentAutocompleteSuggestion(null);
202
- if (newEditorState) {
203
- debouncedFunction.debounce(awaitForAndAppendSuggestion, newEditorState);
204
- } else {
205
- debouncedFunction.cancel();
206
- }
207
- },
208
- [
209
- previousAutocompleteState,
210
- setPreviousAutocompleteState,
211
- debouncedFunction,
212
- awaitForAndAppendSuggestion,
213
- setCurrentAutocompleteSuggestion
214
- ]
215
- );
216
- const keyDownHandler = (0, import_react.useCallback)(
217
- (event) => {
218
- if (currentAutocompleteSuggestion) {
219
- if (event.key === acceptAutosuggestionKey) {
220
- event.preventDefault();
221
- insertAutocompleteSuggestion(currentAutocompleteSuggestion);
222
- setCurrentAutocompleteSuggestion(null);
223
- }
224
- }
225
- },
226
- [
227
- currentAutocompleteSuggestion,
228
- setCurrentAutocompleteSuggestion,
229
- insertAutocompleteSuggestion,
230
- acceptAutosuggestionKey
231
- ]
232
- );
233
- return {
234
- currentAutocompleteSuggestion,
235
- onChangeHandler: onChange,
236
- onKeyDownHandler: keyDownHandler
237
- };
238
- }
239
-
240
- // src/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.tsx
241
- var import_react2 = require("react");
242
- var import_slate2 = require("slate");
243
- var import_slate_react = require("slate-react");
244
-
245
- // src/lib/slatejs-edits/with-partial-history.ts
246
- var import_slate = require("slate");
247
- var import_slate_history = require("slate-history");
248
- var withPartialHistory = (editor, shouldSave2) => {
249
- const e = editor;
250
- const { apply } = e;
251
- e.history = { undos: [], redos: [] };
252
- e.redo = () => {
253
- const { history } = e;
254
- const { redos } = history;
255
- if (redos.length > 0) {
256
- const batch = redos[redos.length - 1];
257
- if (batch.selectionBefore) {
258
- import_slate.Transforms.setSelection(e, batch.selectionBefore);
259
- }
260
- import_slate_history.HistoryEditor.withoutSaving(e, () => {
261
- import_slate.Editor.withoutNormalizing(e, () => {
262
- for (const op of batch.operations) {
263
- e.apply(op);
264
- }
265
- });
266
- });
267
- history.redos.pop();
268
- e.writeHistory("undos", batch);
269
- }
270
- };
271
- e.undo = () => {
272
- const { history } = e;
273
- const { undos } = history;
274
- if (undos.length > 0) {
275
- const batch = undos[undos.length - 1];
276
- import_slate_history.HistoryEditor.withoutSaving(e, () => {
277
- import_slate.Editor.withoutNormalizing(e, () => {
278
- const inverseOps = batch.operations.map(import_slate.Operation.inverse).reverse();
279
- for (const op of inverseOps) {
280
- e.apply(op);
281
- }
282
- if (batch.selectionBefore) {
283
- import_slate.Transforms.setSelection(e, batch.selectionBefore);
284
- }
285
- });
286
- });
287
- e.writeHistory("redos", batch);
288
- history.undos.pop();
289
- }
290
- };
291
- e.apply = (op) => {
292
- const { operations, history } = e;
293
- const { undos } = history;
294
- const lastBatch = undos[undos.length - 1];
295
- const lastOp = lastBatch && lastBatch.operations[lastBatch.operations.length - 1];
296
- let save = import_slate_history.HistoryEditor.isSaving(e);
297
- let merge2 = import_slate_history.HistoryEditor.isMerging(e);
298
- if (save == null) {
299
- save = shouldSave2(op, lastOp);
300
- }
301
- if (save) {
302
- if (merge2 == null) {
303
- if (lastBatch == null) {
304
- merge2 = false;
305
- } else if (operations.length !== 0) {
306
- merge2 = true;
307
- } else {
308
- merge2 = shouldMerge(op, lastOp);
309
- }
310
- }
311
- if (lastBatch && merge2) {
312
- lastBatch.operations.push(op);
313
- } else {
314
- const batch = {
315
- operations: [op],
316
- selectionBefore: e.selection
317
- };
318
- e.writeHistory("undos", batch);
319
- }
320
- while (undos.length > 100) {
321
- undos.shift();
322
- }
323
- history.redos = [];
324
- }
325
- apply(op);
326
- };
327
- e.writeHistory = (stack, batch) => {
328
- e.history[stack].push(batch);
329
- };
330
- return e;
331
- };
332
- var shouldMerge = (op, prev) => {
333
- 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)) {
334
- return true;
335
- }
336
- 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)) {
337
- return true;
338
- }
339
- return false;
340
- };
341
- var defaultShouldSave = (op, prev) => {
342
- if (op.type === "set_selection") {
343
- return false;
344
- }
345
- return true;
346
- };
347
-
348
- // src/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.tsx
349
- var shouldSave = (op, prev) => {
350
- const excludedNodeType = "suggestion";
351
- if (op.type === "insert_node" && import_slate2.Element.isElement(op.node) && op.node.type === excludedNodeType) {
352
- return false;
353
- }
354
- if (op.type === "remove_node" && import_slate2.Element.isElement(op.node) && op.node.type === excludedNodeType) {
355
- return false;
356
- }
357
- if (op.type === "set_node" && "type" in op.newProperties && op.newProperties.type === excludedNodeType) {
358
- return false;
359
- }
360
- if (op.type == "set_node" && "type" in op.properties && op.properties.type === excludedNodeType) {
361
- return false;
362
- }
363
- if (op.type === "merge_node" && "type" in op.properties && op.properties.type === excludedNodeType) {
364
- return false;
365
- }
366
- if (op.type === "split_node" && "type" in op.properties && op.properties.type === excludedNodeType) {
367
- return false;
368
- }
369
- return defaultShouldSave(op, prev);
370
- };
371
- function useCopilotTextareaEditor() {
372
- const editor = (0, import_react2.useMemo)(() => {
373
- const editor2 = withPartialHistory((0, import_slate_react.withReact)((0, import_slate2.createEditor)()), shouldSave);
374
- const { isVoid } = editor2;
375
- editor2.isVoid = (element) => {
376
- switch (element.type) {
377
- case "suggestion":
378
- return true;
379
- default:
380
- return isVoid(element);
381
- }
382
- };
383
- const { markableVoid } = editor2;
384
- editor2.markableVoid = (element) => {
385
- switch (element.type) {
386
- case "suggestion":
387
- return true;
388
- default:
389
- return markableVoid(element);
390
- }
391
- };
392
- const { isInline } = editor2;
393
- editor2.isInline = (element) => {
394
- switch (element.type) {
395
- case "suggestion":
396
- return element.inline;
397
- default:
398
- return isInline(element);
399
- }
400
- };
401
- return editor2;
402
- }, []);
403
- return editor;
404
- }
405
-
406
- // src/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.ts
407
- var import_react3 = __toESM(require("react"));
408
- var import_slate_react2 = require("slate-react");
409
-
410
- // src/lib/get-text-around-cursor.ts
411
- var import_slate3 = require("slate");
412
- function getTextAroundCollapsedCursor(editor) {
413
- const { selection } = editor;
414
- if (!selection || !import_slate3.Range.isCollapsed(selection)) {
415
- return null;
416
- }
417
- const cursorPoint = selection.anchor;
418
- const beforeRange = {
419
- anchor: import_slate3.Editor.start(editor, []),
420
- focus: cursorPoint
421
- };
422
- const afterRange = {
423
- anchor: cursorPoint,
424
- focus: import_slate3.Editor.end(editor, [])
425
- };
426
- const before = extractTextWithNewlines(editor, beforeRange);
427
- const after = extractTextWithNewlines(editor, afterRange);
428
- return {
429
- cursorPoint,
430
- textBeforeCursor: before,
431
- textAfterCursor: after
432
- };
433
- }
434
- function getTextAroundSelection(editor) {
435
- const { selection } = editor;
436
- if (!selection) {
437
- return null;
438
- }
439
- const wellOrderedSelection = wellOrderedRange(selection);
440
- const beforeRange = {
441
- anchor: import_slate3.Editor.start(editor, []),
442
- focus: wellOrderedSelection.anchor
443
- };
444
- const afterRange = {
445
- anchor: wellOrderedSelection.focus,
446
- focus: import_slate3.Editor.end(editor, [])
447
- };
448
- const before = extractTextWithNewlines(editor, beforeRange);
449
- const after = extractTextWithNewlines(editor, afterRange);
450
- const selectedText = extractTextWithNewlines(editor, wellOrderedSelection);
451
- return {
452
- selection: wellOrderedSelection,
453
- textBeforeCursor: before,
454
- selectedText,
455
- textAfterCursor: after
456
- };
457
- }
458
- function getFullEditorTextWithNewlines(editor) {
459
- const fullDocumentRange = {
460
- anchor: import_slate3.Editor.start(editor, []),
461
- focus: import_slate3.Editor.end(editor, [])
462
- };
463
- return extractTextWithNewlines(editor, fullDocumentRange);
464
- }
465
- function extractTextWithNewlines(editor, range) {
466
- const voids = false;
467
- const [start, end] = import_slate3.Range.edges(range);
468
- let text = "";
469
- let lastBlock = null;
470
- for (const [node, path] of import_slate3.Editor.nodes(editor, {
471
- at: range,
472
- match: import_slate3.Text.isText,
473
- voids
474
- })) {
475
- let t = node.text;
476
- const [block] = import_slate3.Editor.above(editor, {
477
- at: path,
478
- match: (n) => import_slate3.Element.isElement(n) && n.type === "paragraph"
479
- }) || [null];
480
- if (lastBlock !== block && block) {
481
- if (lastBlock) {
482
- text += "\n";
483
- }
484
- lastBlock = block;
485
- }
486
- if (import_slate3.Path.equals(path, end.path)) {
487
- t = t.slice(0, end.offset);
488
- }
489
- if (import_slate3.Path.equals(path, start.path)) {
490
- t = t.slice(start.offset);
491
- }
492
- text += t;
493
- }
494
- return text;
495
- }
496
- function wellOrderedRange(range) {
497
- const { anchor, focus } = range;
498
- if (import_slate3.Point.isBefore(anchor, focus)) {
499
- return range;
500
- }
501
- return {
502
- anchor: focus,
503
- focus: anchor
504
- };
505
- }
506
-
507
- // src/lib/slatejs-edits/replace-text.ts
508
- var import_slate4 = require("slate");
509
- function replaceEditorText(editor, newText) {
510
- import_slate4.Transforms.delete(editor, {
511
- at: {
512
- anchor: import_slate4.Editor.start(editor, []),
513
- focus: import_slate4.Editor.end(editor, [])
514
- }
515
- });
516
- if (newText && newText !== "") {
517
- import_slate4.Transforms.insertNodes(
518
- editor,
519
- [
520
- {
521
- type: "paragraph",
522
- children: [{ text: newText }]
523
- }
524
- ],
525
- {
526
- at: [0]
527
- }
528
- );
529
- }
530
- }
531
-
532
- // src/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.ts
533
- function usePopulateCopilotTextareaRef(editor, ref) {
534
- import_react3.default.useImperativeHandle(
535
- ref,
536
- () => {
537
- class Combined {
538
- constructor(customMethods2, editorHtmlElement2) {
539
- this.customMethods = customMethods2;
540
- this.editorHtmlElement = editorHtmlElement2;
541
- }
542
- get(target, propKey) {
543
- if (this.isKeyOfCustomMethods(propKey)) {
544
- const value = this.customMethods[propKey];
545
- if (typeof value === "function") {
546
- return value.bind(this.customMethods);
547
- }
548
- return value;
549
- } else if (this.isKeyOfHTMLElement(propKey)) {
550
- const value = this.editorHtmlElement[propKey];
551
- if (typeof value === "function") {
552
- return value.bind(this.editorHtmlElement);
553
- }
554
- return value;
555
- }
556
- }
557
- set(target, propKey, value) {
558
- if (this.isKeyOfCustomMethods(propKey)) {
559
- this.customMethods[propKey] = value;
560
- } else if (this.isKeyOfHTMLElement(propKey)) {
561
- this.editorHtmlElement[propKey] = value;
562
- } else {
563
- target[propKey] = value;
564
- }
565
- return true;
566
- }
567
- isKeyOfCustomMethods(key) {
568
- return key in this.customMethods;
569
- }
570
- isKeyOfHTMLElement(key) {
571
- return key in this.editorHtmlElement;
572
- }
573
- }
574
- const handler = {
575
- get(target, propKey) {
576
- return target.get(target, propKey);
577
- },
578
- set(target, propKey, value) {
579
- return target.set(target, propKey, value);
580
- }
581
- };
582
- class CustomMethods {
583
- constructor(editor2) {
584
- this.editor = editor2;
585
- }
586
- focus() {
587
- import_slate_react2.ReactEditor.focus(this.editor);
588
- }
589
- blur() {
590
- import_slate_react2.ReactEditor.blur(this.editor);
591
- }
592
- get value() {
593
- return getFullEditorTextWithNewlines(this.editor);
594
- }
595
- set value(value) {
596
- replaceEditorText(this.editor, value);
597
- }
598
- }
599
- const editorHtmlElement = import_slate_react2.ReactEditor.toDOMNode(editor, editor);
600
- const customMethods = new CustomMethods(editor);
601
- const combined = new Combined(customMethods, editorHtmlElement);
602
- return new Proxy(combined, handler);
603
- },
604
- [editor]
605
- );
606
- }
607
-
608
- // src/lib/slatejs-edits/add-autocompletions.ts
609
- var import_slate5 = require("slate");
610
- function addAutocompletionsToEditor(editor, newSuggestion, point) {
611
- const editorPosition = editor.selection;
612
- import_slate5.Transforms.insertNodes(
613
- editor,
614
- [
615
- {
616
- type: "suggestion",
617
- inline: true,
618
- content: newSuggestion,
619
- children: [{ text: "" }]
620
- }
621
- ],
622
- {
623
- at: point
624
- }
625
- );
626
- if (editorPosition) {
627
- editor.selection = editorPosition;
628
- }
629
- }
630
-
631
- // src/lib/slatejs-edits/clear-autocompletions.ts
632
- var import_slate6 = require("slate");
633
- function clearAutocompletionsFromEditor(editor) {
634
- const paths = [];
635
- for (const [node, path] of import_slate6.Node.nodes(editor)) {
636
- if (import_slate6.Element.isElement(node) && node.type === "suggestion") {
637
- paths.push(path);
638
- }
639
- }
640
- for (const path of paths) {
641
- try {
642
- import_slate6.Transforms.removeNodes(editor, { at: path });
643
- } catch (e) {
644
- console.log(
645
- "CopilotTextarea.clearAutocompletionsFromEditor: error removing node",
646
- e
647
- );
648
- }
649
- }
650
- }
651
-
652
- // src/types/base/base-autosuggestions-config.tsx
653
- var defaultBaseAutosuggestionsConfig = {
654
- debounceTime: 250,
655
- contextCategories: ["global"],
656
- acceptAutosuggestionKey: "Tab",
657
- disableWhenEmpty: true,
658
- disabled: false,
659
- temporarilyDisableWhenMovingCursorWithoutChangingText: true
660
- };
661
-
662
- // src/components/hovering-toolbar/hovering-toolbar.tsx
663
- var import_react9 = require("react");
664
- var import_slate7 = require("slate");
665
- var import_slate_react3 = require("slate-react");
666
-
667
- // src/hooks/misc/use-autosize-textarea.tsx
668
- var import_react4 = require("react");
669
- var useAutosizeTextArea = (textAreaRef, value) => {
670
- (0, import_react4.useEffect)(() => {
671
- if (textAreaRef.current !== null) {
672
- textAreaRef.current.style.height = "0px";
673
- const scrollHeight = textAreaRef.current.scrollHeight;
674
- textAreaRef.current.style.height = scrollHeight + "px";
675
- }
676
- }, [textAreaRef, value]);
677
- };
678
- var use_autosize_textarea_default = useAutosizeTextArea;
679
-
680
- // src/components/source-search-box/source-search-box.tsx
681
- var import_react5 = require("react");
682
-
683
- // src/components/ui/command.tsx
684
- var React2 = __toESM(require("react"));
685
- var import_cmdk = require("cmdk");
686
- var import_jsx_runtime = require("react/jsx-runtime");
687
- "use client";
688
- var Command = React2.forwardRef((_a, ref) => {
689
- var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
690
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_cmdk.Command, __spreadValues({
691
- ref,
692
- className: cn(
693
- "flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",
694
- className
695
- )
696
- }, props));
697
- });
698
- Command.displayName = import_cmdk.Command.displayName;
699
- var CommandInput = React2.forwardRef((_a, ref) => {
700
- var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
701
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
702
- className: "flex items-center border-b px-3",
703
- "cmdk-input-wrapper": "",
704
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_cmdk.Command.Input, __spreadValues({
705
- ref,
706
- className: cn(
707
- "flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",
708
- className
709
- )
710
- }, props))
711
- });
712
- });
713
- CommandInput.displayName = import_cmdk.Command.Input.displayName;
714
- var CommandList = React2.forwardRef((_a, ref) => {
715
- var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
716
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_cmdk.Command.List, __spreadValues({
717
- ref,
718
- className: cn(
719
- "max-h-[300px] overflow-y-auto overflow-x-hidden pb-2",
720
- className
721
- )
722
- }, props));
723
- });
724
- CommandList.displayName = import_cmdk.Command.List.displayName;
725
- var CommandEmpty = React2.forwardRef((props, ref) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_cmdk.Command.Empty, __spreadValues({
726
- ref,
727
- className: "py-6 text-center text-sm"
728
- }, props)));
729
- CommandEmpty.displayName = import_cmdk.Command.Empty.displayName;
730
- var CommandGroup = React2.forwardRef((_a, ref) => {
731
- var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
732
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_cmdk.Command.Group, __spreadValues({
733
- ref,
734
- className: cn(
735
- "overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",
736
- className
737
- )
738
- }, props));
739
- });
740
- CommandGroup.displayName = import_cmdk.Command.Group.displayName;
741
- var CommandSeparator = React2.forwardRef((_a, ref) => {
742
- var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
743
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_cmdk.Command.Separator, __spreadValues({
744
- ref,
745
- className: cn("-mx-1 h-px bg-border", className)
746
- }, props));
747
- });
748
- CommandSeparator.displayName = import_cmdk.Command.Separator.displayName;
749
- var CommandItem = React2.forwardRef((_a, ref) => {
750
- var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
751
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_cmdk.Command.Item, __spreadValues({
752
- ref,
753
- className: cn(
754
- "relative flex cursor-default select-none items-center rounded-sm text-sm outline-none aria-selected:bg-accent aria-selected:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
755
- className
756
- )
757
- }, props));
758
- });
759
- CommandItem.displayName = import_cmdk.Command.Item.displayName;
760
- var CommandShortcut = (_a) => {
761
- var _b = _a, {
762
- className
763
- } = _b, props = __objRest(_b, [
764
- "className"
765
- ]);
766
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", __spreadValues({
767
- className: cn(
768
- "ml-auto text-xs tracking-widest text-muted-foreground",
769
- className
770
- )
771
- }, props));
772
- };
773
- CommandShortcut.displayName = "CommandShortcut";
774
-
775
- // src/components/source-search-box/source-search-box.tsx
776
- var import_jsx_runtime2 = require("react/jsx-runtime");
777
- function SourceSearchBox(props) {
778
- const [selectedValue, setSelectedValue] = (0, import_react5.useState)("");
779
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Command, {
780
- className: "rounded-lg border shadow-md",
781
- value: selectedValue,
782
- onValueChange: (value) => {
783
- setSelectedValue(value);
784
- },
785
- filter: (value, search) => {
786
- if (props.searchTerm === "")
787
- return 1;
788
- if (value.startsWith(props.searchTerm))
789
- return 1;
790
- return 0;
791
- },
792
- children: [
793
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(CommandInput, {
794
- value: props.searchTerm,
795
- className: "rounded-t-lg hidden",
796
- placeholder: "Search for a command..."
797
- }),
798
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(CommandList, {
799
- children: [
800
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(CommandEmpty, {
801
- children: "No results found."
802
- }),
803
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(CommandGroup, {
804
- heading: "Available resources",
805
- children: props.suggestedFiles.map((filePointer) => {
806
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(CommandItem, {
807
- value: filePointer.name,
808
- onSelect: (value) => {
809
- props.onSelectedFile(filePointer);
810
- },
811
- children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", {
812
- className: " px-3 flex flex-row gap-1 items-center",
813
- children: [
814
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Logo, {
815
- width: "20px",
816
- height: "20px",
817
- children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("img", {
818
- src: filePointer.iconImageUri,
819
- alt: filePointer.sourceApplication,
820
- className: "w-full h-full"
821
- })
822
- }),
823
- filePointer.name
824
- ]
825
- })
826
- }, `word-${filePointer.sourceApplication}.${filePointer.name}`);
827
- })
828
- }),
829
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(CommandSeparator, {})
830
- ]
831
- })
832
- ]
833
- });
834
- }
835
- function Logo({
836
- children,
837
- width,
838
- height
839
- }) {
840
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", {
841
- className: "flex items-center justify-center",
842
- style: { width, height },
843
- children
844
- });
845
- }
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)(
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",
854
- {
855
- variants: {
856
- variant: {
857
- default: "bg-primary text-primary-foreground hover:bg-primary/90",
858
- destructive: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
859
- outline: "border border-input bg-background hover:bg-accent hover:text-accent-foreground",
860
- secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
861
- ghost: "hover:bg-accent hover:text-accent-foreground",
862
- link: "text-primary underline-offset-4 hover:underline"
863
- },
864
- size: {
865
- default: "h-10 px-4 py-2",
866
- sm: "h-9 rounded-md px-3",
867
- lg: "h-11 rounded-md px-8",
868
- icon: "h-10 w-10"
869
- }
870
- },
871
- defaultVariants: {
872
- variant: "default",
873
- size: "default"
874
- }
875
- }
876
- );
877
- var Button = React3.forwardRef(
878
- (_a, ref) => {
879
- var _b = _a, { className, variant, size, asChild = false } = _b, props = __objRest(_b, ["className", "variant", "size", "asChild"]);
880
- const Comp = asChild ? import_react_slot.Slot : "button";
881
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Comp, __spreadValues({
882
- className: cn(buttonVariants({ variant, size, className })),
883
- ref
884
- }, props));
885
- }
886
- );
887
- Button.displayName = "Button";
888
-
889
- // src/components/ui/label.tsx
890
- var React4 = __toESM(require("react"));
891
- var LabelPrimitive = __toESM(require("@radix-ui/react-label"));
892
- var import_class_variance_authority2 = require("class-variance-authority");
893
- var import_jsx_runtime4 = require("react/jsx-runtime");
894
- "use client";
895
- var labelVariants = (0, import_class_variance_authority2.cva)(
896
- "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
897
- );
898
- var Label = React4.forwardRef((_a, ref) => {
899
- var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
900
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(LabelPrimitive.Root, __spreadValues({
901
- ref,
902
- className: cn(labelVariants(), className)
903
- }, props));
904
- });
905
- Label.displayName = LabelPrimitive.Root.displayName;
906
-
907
- // src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.tsx
908
- var import_react6 = require("react");
909
-
910
- // src/lib/stream-promise-flatten.ts
911
- function streamPromiseFlatten(promise) {
912
- return new ReadableStream({
913
- start(controller) {
914
- return __async(this, null, function* () {
915
- try {
916
- const stream = yield promise;
917
- const reader = stream.getReader();
918
- while (true) {
919
- const { done, value } = yield reader.read();
920
- if (done) {
921
- controller.close();
922
- return;
923
- }
924
- controller.enqueue(value);
925
- }
926
- } catch (error) {
927
- controller.error(error);
928
- }
929
- });
930
- }
931
- });
932
- }
933
-
934
- // src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.tsx
935
- var import_react_core = require("@copilotkit/react-core");
936
-
937
- // src/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.tsx
938
- var import_Chip = __toESM(require("@mui/material/Chip"));
939
- var import_Avatar = __toESM(require("@mui/material/Avatar"));
940
- var import_jsx_runtime5 = require("react/jsx-runtime");
941
- var IncludedFilesPreview = ({
942
- includedFiles,
943
- setIncludedFiles
944
- }) => {
945
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", {
946
- className: "flex flex-col gap-2 mt-2",
947
- children: [
948
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Label, {
949
- className: "",
950
- children: "Included context:"
951
- }),
952
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", {
953
- className: "flex flex-wrap gap-2",
954
- children: includedFiles.map((filePointer, index) => {
955
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(FileChipPreview, {
956
- filePointer,
957
- onDelete: () => {
958
- setIncludedFiles(
959
- (prev) => prev.filter((fp) => fp !== filePointer)
960
- );
961
- }
962
- }, `file-${filePointer.sourceApplication}.${filePointer.name}`);
963
- })
964
- })
965
- ]
966
- });
967
- };
968
- var FileChipPreview = ({
969
- filePointer,
970
- onDelete
971
- }) => {
972
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_Chip.default, {
973
- label: filePointer.name,
974
- onDelete,
975
- avatar: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_Avatar.default, {
976
- sx: { backgroundColor: "transparent" }
977
- })
978
- });
979
- };
980
-
981
- // src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.tsx
982
- var import_jsx_runtime6 = require("react/jsx-runtime");
983
- var HoveringInsertionPromptBoxCore = ({
984
- performInsertion,
985
- state,
986
- insertionOrEditingFunction,
987
- contextCategories
988
- }) => {
989
- const { getDocumentsContext } = (0, import_react6.useContext)(import_react_core.CopilotContext);
990
- const [editSuggestion, setEditSuggestion] = (0, import_react6.useState)("");
991
- const [suggestionIsLoading, setSuggestionIsLoading] = (0, import_react6.useState)(false);
992
- const [adjustmentPrompt, setAdjustmentPrompt] = (0, import_react6.useState)("");
993
- const [generatingSuggestion, setGeneratingSuggestion] = (0, import_react6.useState)(null);
994
- const adjustmentTextAreaRef = (0, import_react6.useRef)(null);
995
- const suggestionTextAreaRef = (0, import_react6.useRef)(null);
996
- const [filePointers, setFilePointers] = (0, import_react6.useState)([]);
997
- const [suggestedFiles, setSuggestedFiles] = (0, import_react6.useState)([]);
998
- (0, import_react6.useEffect)(() => {
999
- setSuggestedFiles(getDocumentsContext(contextCategories));
1000
- }, [contextCategories, getDocumentsContext]);
1001
- use_autosize_textarea_default(suggestionTextAreaRef, editSuggestion || "");
1002
- use_autosize_textarea_default(adjustmentTextAreaRef, adjustmentPrompt || "");
1003
- (0, import_react6.useEffect)(() => {
1004
- var _a;
1005
- (_a = adjustmentTextAreaRef.current) == null ? void 0 : _a.focus();
1006
- }, []);
1007
- (0, import_react6.useEffect)(() => {
1008
- if (!generatingSuggestion) {
1009
- return;
1010
- }
1011
- if (generatingSuggestion.locked) {
1012
- return;
1013
- }
1014
- setEditSuggestion("");
1015
- const reader = generatingSuggestion.getReader();
1016
- const read = () => __async(void 0, null, function* () {
1017
- setSuggestionIsLoading(true);
1018
- while (true) {
1019
- const { done, value } = yield reader.read();
1020
- if (done) {
1021
- break;
1022
- }
1023
- setEditSuggestion((prev) => {
1024
- const newSuggestion = prev + value;
1025
- if (suggestionTextAreaRef.current) {
1026
- suggestionTextAreaRef.current.scrollTop = suggestionTextAreaRef.current.scrollHeight;
1027
- }
1028
- return newSuggestion;
1029
- });
1030
- }
1031
- setSuggestionIsLoading(false);
1032
- });
1033
- read();
1034
- return () => {
1035
- const releaseLockIfNotClosed = () => __async(void 0, null, function* () {
1036
- try {
1037
- yield reader.closed;
1038
- } catch (e) {
1039
- reader.releaseLock();
1040
- }
1041
- });
1042
- releaseLockIfNotClosed();
1043
- };
1044
- }, [generatingSuggestion]);
1045
- const beginGeneratingAdjustment = (0, import_react6.useCallback)(() => __async(void 0, null, function* () {
1046
- if (!adjustmentPrompt.trim()) {
1047
- return;
1048
- }
1049
- let modificationState = state.editorState;
1050
- if (editSuggestion !== "") {
1051
- modificationState.selectedText = editSuggestion;
1052
- }
1053
- const adjustmentSuggestionTextStreamPromise = insertionOrEditingFunction(
1054
- modificationState,
1055
- adjustmentPrompt,
1056
- filePointers,
1057
- new AbortController().signal
1058
- );
1059
- const adjustmentSuggestionTextStream = streamPromiseFlatten(
1060
- adjustmentSuggestionTextStreamPromise
1061
- );
1062
- setGeneratingSuggestion(adjustmentSuggestionTextStream);
1063
- }), [
1064
- adjustmentPrompt,
1065
- editSuggestion,
1066
- state.editorState,
1067
- insertionOrEditingFunction,
1068
- filePointers
1069
- ]);
1070
- const isLoading = suggestionIsLoading;
1071
- const textToEdit = editSuggestion || state.editorState.selectedText;
1072
- const adjustmentLabel = textToEdit === "" ? "Describe the text you want to insert" : "Describe adjustments to the suggested text";
1073
- const placeholder = textToEdit === "" ? "e.g. 'summarize the client's top 3 pain-points from @CallTranscript'" : "e.g. 'make it more formal', 'be more specific', ...";
1074
- const AdjustmentPromptComponent = /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, {
1075
- children: [
1076
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Label, {
1077
- className: "",
1078
- children: adjustmentLabel
1079
- }),
1080
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", {
1081
- className: "relative w-full flex items-center",
1082
- children: [
1083
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("textarea", {
1084
- disabled: suggestionIsLoading,
1085
- ref: adjustmentTextAreaRef,
1086
- value: adjustmentPrompt,
1087
- onChange: (e) => setAdjustmentPrompt(e.target.value),
1088
- onKeyDown: (e) => {
1089
- if (e.key === "Enter" && e.shiftKey) {
1090
- e.preventDefault();
1091
- setAdjustmentPrompt(adjustmentPrompt + "\n");
1092
- } else if (e.key === "Enter") {
1093
- e.preventDefault();
1094
- beginGeneratingAdjustment();
1095
- }
1096
- },
1097
- placeholder,
1098
- style: { minHeight: "3rem" },
1099
- className: "w-full bg-slate-100 h-auto h-min-14 text-sm p-2 rounded-md resize-none overflow-visible focus:outline-none focus:ring-0 focus:border-non pr-[3rem]",
1100
- rows: 1
1101
- }),
1102
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", {
1103
- onClick: beginGeneratingAdjustment,
1104
- className: "absolute right-2 bg-blue-500 text-white w-8 h-8 rounded-full flex items-center justify-center",
1105
- children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("i", {
1106
- className: "material-icons",
1107
- children: "arrow_forward"
1108
- })
1109
- })
1110
- ]
1111
- })
1112
- ]
1113
- });
1114
- const SuggestionComponent = /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, {
1115
- children: [
1116
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", {
1117
- className: "flex justify-between items-end w-full",
1118
- children: [
1119
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Label, {
1120
- className: "mt-4",
1121
- children: "Suggested:"
1122
- }),
1123
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", {
1124
- className: "ml-auto",
1125
- children: isLoading && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", {
1126
- className: "flex justify-center items-center",
1127
- children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", {
1128
- 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]",
1129
- role: "status",
1130
- children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", {
1131
- className: "!absolute !-m-px !h-px !w-px !overflow-hidden !whitespace-nowrap !border-0 !p-0 ![clip:rect(0,0,0,0)]",
1132
- children: "Loading..."
1133
- })
1134
- })
1135
- })
1136
- })
1137
- ]
1138
- }),
1139
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("textarea", {
1140
- ref: suggestionTextAreaRef,
1141
- value: editSuggestion,
1142
- disabled: suggestionIsLoading,
1143
- onChange: (e) => setEditSuggestion(e.target.value),
1144
- className: "w-full text-base p-2 border border-gray-300 rounded-md resize-none bg-green-50",
1145
- style: { overflow: "auto", maxHeight: "10em" }
1146
- })
1147
- ]
1148
- });
1149
- const SubmitComponent = /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", {
1150
- className: "flex w-full gap-4 justify-start",
1151
- children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Button, {
1152
- className: " bg-green-700 text-white",
1153
- onClick: () => {
1154
- performInsertion(editSuggestion);
1155
- },
1156
- children: [
1157
- "Insert ",
1158
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("i", {
1159
- className: "material-icons",
1160
- children: "check"
1161
- })
1162
- ]
1163
- })
1164
- });
1165
- const sourceSearchCandidate = adjustmentPrompt.split(" ").pop();
1166
- const sourceSearchWord = (sourceSearchCandidate == null ? void 0 : sourceSearchCandidate.startsWith("@")) ? sourceSearchCandidate.slice(1) : void 0;
1167
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", {
1168
- className: "w-full flex flex-col items-start relative gap-2",
1169
- children: [
1170
- AdjustmentPromptComponent,
1171
- filePointers.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(IncludedFilesPreview, {
1172
- includedFiles: filePointers,
1173
- setIncludedFiles: setFilePointers
1174
- }),
1175
- sourceSearchWord !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(SourceSearchBox, {
1176
- searchTerm: sourceSearchWord,
1177
- suggestedFiles,
1178
- onSelectedFile: (filePointer) => {
1179
- var _a;
1180
- setAdjustmentPrompt(
1181
- adjustmentPrompt.replace(new RegExp(`@${sourceSearchWord}$`), "")
1182
- );
1183
- setFilePointers((prev) => [...prev, filePointer]);
1184
- (_a = adjustmentTextAreaRef.current) == null ? void 0 : _a.focus();
1185
- }
1186
- }),
1187
- generatingSuggestion ? SuggestionComponent : null,
1188
- generatingSuggestion ? SubmitComponent : null
1189
- ]
1190
- });
1191
- };
1192
-
1193
- // src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.tsx
1194
- var import_jsx_runtime7 = require("react/jsx-runtime");
1195
- var HoveringInsertionPromptBox = (props) => {
1196
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", {
1197
- className: "flex flex-col justify-center items-center space-y-4 rounded-md border shadow-lg p-4 border-gray- bg-white",
1198
- style: { width: "35rem" },
1199
- children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(HoveringInsertionPromptBoxCore, {
1200
- state: {
1201
- editorState: props.editorState
1202
- },
1203
- insertionOrEditingFunction: props.apiConfig.insertionOrEditingFunction,
1204
- performInsertion: props.performInsertion,
1205
- contextCategories: props.contextCategories
1206
- })
1207
- });
1208
- };
1209
-
1210
- // src/components/hovering-toolbar/hovering-toolbar-components.tsx
1211
- var import_css = require("@emotion/css");
1212
- var import_react7 = __toESM(require("react"));
1213
- var import_react_dom = __toESM(require("react-dom"));
1214
- var import_jsx_runtime8 = require("react/jsx-runtime");
1215
- var Button2 = import_react7.default.forwardRef(
1216
- (_a, ref) => {
1217
- var _b = _a, {
1218
- className,
1219
- active,
1220
- reversed
1221
- } = _b, props = __objRest(_b, [
1222
- "className",
1223
- "active",
1224
- "reversed"
1225
- ]);
1226
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", __spreadProps(__spreadValues({}, props), {
1227
- ref,
1228
- className: (0, import_css.cx)(
1229
- className,
1230
- import_css.css`
1231
- cursor: pointer;
1232
- color: ${reversed ? active ? "white" : "#aaa" : active ? "black" : "#ccc"};
1233
- `
1234
- )
1235
- }));
1236
- }
1237
- );
1238
- var Icon = import_react7.default.forwardRef(
1239
- (_a, ref) => {
1240
- var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
1241
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", __spreadProps(__spreadValues({}, props), {
1242
- ref,
1243
- className: (0, import_css.cx)(
1244
- "material-icons",
1245
- className,
1246
- import_css.css`
1247
- font-size: 18px;
1248
- vertical-align: text-bottom;
1249
- `
1250
- )
1251
- }));
1252
- }
1253
- );
1254
- var Menu = import_react7.default.forwardRef(
1255
- (_a, ref) => {
1256
- var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
1257
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", __spreadProps(__spreadValues({}, props), {
1258
- "data-test-id": "menu",
1259
- ref,
1260
- className: (0, import_css.cx)(
1261
- className,
1262
- import_css.css`
1263
- & > * {
1264
- display: inline-block;
1265
- }
1266
-
1267
- & > * + * {
1268
- margin-left: 15px;
1269
- }
1270
- `
1271
- )
1272
- }));
1273
- }
1274
- );
1275
- var Portal = ({ children }) => {
1276
- return typeof document === "object" ? import_react_dom.default.createPortal(children, document.body) : null;
1277
- };
1278
- var Toolbar = import_react7.default.forwardRef(
1279
- (_a, ref) => {
1280
- var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
1281
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Menu, __spreadProps(__spreadValues({}, props), {
1282
- ref,
1283
- className: (0, import_css.cx)(
1284
- className,
1285
- import_css.css`
1286
- position: relative;
1287
- padding: 1px 18px 17px;
1288
- margin: 0 -20px;
1289
- border-bottom: 2px solid #eee;
1290
- margin-bottom: 20px;
1291
- `
1292
- )
1293
- }));
1294
- }
1295
- );
1296
-
1297
- // src/components/hovering-toolbar/hovering-editor-provider.tsx
1298
- var import_react8 = require("react");
1299
- var import_jsx_runtime9 = require("react/jsx-runtime");
1300
- var HoveringEditorContext = (0, import_react8.createContext)({
1301
- isDisplayed: false,
1302
- setIsDisplayed: () => {
1303
- }
1304
- });
1305
- var HoveringEditorProvider = ({
1306
- children
1307
- }) => {
1308
- const [isDisplayed, setIsDisplayed] = (0, import_react8.useState)(false);
1309
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(HoveringEditorContext.Provider, {
1310
- value: { isDisplayed, setIsDisplayed },
1311
- children
1312
- });
1313
- };
1314
- var useHoveringEditorContext = () => (0, import_react8.useContext)(HoveringEditorContext);
1315
-
1316
- // src/components/hovering-toolbar/hovering-toolbar.tsx
1317
- var import_jsx_runtime10 = require("react/jsx-runtime");
1318
- var HoveringToolbar = (props) => {
1319
- const ref = (0, import_react9.useRef)(null);
1320
- const editor = (0, import_slate_react3.useSlate)();
1321
- const selection = (0, import_slate_react3.useSlateSelection)();
1322
- const { isDisplayed, setIsDisplayed } = useHoveringEditorContext();
1323
- const [isClient, setIsClient] = (0, import_react9.useState)(false);
1324
- (0, import_react9.useEffect)(() => {
1325
- setIsClient(true);
1326
- }, []);
1327
- (0, import_react9.useEffect)(() => {
1328
- const el = ref.current;
1329
- const { selection: selection2 } = editor;
1330
- if (!el) {
1331
- return;
1332
- }
1333
- if (!selection2) {
1334
- el.removeAttribute("style");
1335
- return;
1336
- }
1337
- const domSelection = window.getSelection();
1338
- if (!domSelection) {
1339
- return;
1340
- }
1341
- const domRange = domSelection.getRangeAt(0);
1342
- const rect = domRange.getBoundingClientRect();
1343
- if (rect.top === 0 && rect.left === 0 && rect.width === 0 && rect.height === 0) {
1344
- return;
1345
- }
1346
- const minGapFromEdge = 60;
1347
- const verticalOffsetFromCorner = 35;
1348
- const horizontalOffsetFromCorner = 15;
1349
- let top = rect.top + window.scrollY - el.offsetHeight + verticalOffsetFromCorner;
1350
- if (top < minGapFromEdge) {
1351
- top = rect.bottom + window.scrollY + minGapFromEdge;
1352
- } else if (top + el.offsetHeight > window.innerHeight - minGapFromEdge) {
1353
- top = rect.top + window.scrollY - el.offsetHeight - minGapFromEdge;
1354
- }
1355
- let left = rect.left + window.scrollX - el.offsetWidth / 2 + rect.width / 2 + horizontalOffsetFromCorner;
1356
- if (left < minGapFromEdge) {
1357
- left = minGapFromEdge;
1358
- } else if (left + el.offsetWidth > window.innerWidth - minGapFromEdge) {
1359
- left = window.innerWidth - el.offsetWidth - minGapFromEdge;
1360
- }
1361
- el.style.opacity = "1";
1362
- el.style.top = `${top}px`;
1363
- el.style.left = `${left}px`;
1364
- });
1365
- (0, import_react9.useEffect)(() => {
1366
- const handleClickOutside = (event) => {
1367
- if (ref.current && !ref.current.contains(event.target)) {
1368
- setIsDisplayed(false);
1369
- }
1370
- };
1371
- document.addEventListener("mousedown", handleClickOutside);
1372
- return () => {
1373
- document.removeEventListener("mousedown", handleClickOutside);
1374
- };
1375
- }, [ref, setIsDisplayed]);
1376
- if (!isClient) {
1377
- return null;
1378
- }
1379
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Portal, {
1380
- children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Menu, {
1381
- ref,
1382
- className: "p-2 absolute z-10 top-[-10000px] left-[-10000px] mt-[-6px] opacity-0 transition-opacity duration-700",
1383
- children: isDisplayed && selection && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(HoveringInsertionPromptBox, {
1384
- editorState: editorState(editor, selection),
1385
- apiConfig: props.apiConfig,
1386
- closeWindow: () => {
1387
- setIsDisplayed(false);
1388
- },
1389
- performInsertion: (insertedText) => {
1390
- console.log("inserted text", insertedText);
1391
- import_slate7.Transforms.delete(editor, { at: selection });
1392
- import_slate7.Transforms.insertText(editor, insertedText, {
1393
- at: selection
1394
- });
1395
- setIsDisplayed(false);
1396
- },
1397
- contextCategories: props.contextCategories
1398
- })
1399
- })
1400
- });
1401
- };
1402
- function editorState(editor, selection) {
1403
- const textAroundCursor = getTextAroundSelection(editor);
1404
- if (textAroundCursor) {
1405
- return textAroundCursor;
1406
- }
1407
- return {
1408
- textBeforeCursor: getFullEditorTextWithNewlines(editor),
1409
- textAfterCursor: "",
1410
- selectedText: ""
1411
- };
1412
- }
1413
-
1414
- // src/components/base-copilot-textarea/render-element.tsx
1415
- var import_jsx_runtime11 = require("react/jsx-runtime");
1416
- function makeRenderElementFunction(suggestionsStyle) {
1417
- return (props) => {
1418
- switch (props.element.type) {
1419
- case "paragraph":
1420
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(DefaultElement, __spreadValues({}, props));
1421
- case "suggestion":
1422
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(SuggestionElement, __spreadProps(__spreadValues({}, props), {
1423
- suggestionsStyle
1424
- }));
1425
- }
1426
- };
1427
- }
1428
- var DefaultElement = (props) => {
1429
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", __spreadProps(__spreadValues({}, props.attributes), {
1430
- children: props.children
1431
- }));
1432
- };
1433
- var SuggestionElement = (props) => {
1434
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("span", __spreadProps(__spreadValues({}, props.attributes), {
1435
- style: __spreadValues({}, props.suggestionsStyle),
1436
- contentEditable: false,
1437
- children: [
1438
- props.children,
1439
- props.element.type === "suggestion" && props.element.content
1440
- ]
1441
- }));
1442
- };
1443
-
1444
- // src/components/base-copilot-textarea/render-placeholder.tsx
1445
- var import_jsx_runtime12 = require("react/jsx-runtime");
1446
- function makeRenderPlaceholderFunction(placeholderStyle) {
1447
- return (props) => {
1448
- const _a = props.attributes, { style } = _a, restAttributes = __objRest(_a, ["style"]);
1449
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", __spreadProps(__spreadValues({}, restAttributes), {
1450
- style: __spreadValues(__spreadValues({}, style), placeholderStyle),
1451
- children: props.children
1452
- }));
1453
- };
1454
- }
1455
-
1456
- // src/components/base-copilot-textarea/use-add-branding-css.tsx
1457
- var import_react10 = require("react");
1458
- function useAddBrandingCss(suggestionStyleAugmented, disableBranding) {
1459
- const cssSelector = ".copilot-textarea.with-branding";
1460
- (0, import_react10.useEffect)(() => {
1461
- if (disableBranding) {
1462
- return;
1463
- }
1464
- const styleEl = document.createElement("style");
1465
- styleEl.id = "dynamic-styles";
1466
- let dynamicStyles = Object.entries(suggestionStyleAugmented).map(([key, value]) => {
1467
- const kebabCaseKey = key.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").toLowerCase();
1468
- return `${kebabCaseKey}: ${value};`;
1469
- }).join(" ");
1470
- dynamicStyles += `font-style: normal; font-size: x-small;`;
1471
- dynamicStyles += `content: "CopilotKit";`;
1472
- dynamicStyles += `bottom: 6px;`;
1473
- dynamicStyles += `right: 6px;`;
1474
- dynamicStyles += `pointer-events: none;`;
1475
- dynamicStyles += `font-weight: 200;`;
1476
- dynamicStyles += `padding: 0;`;
1477
- dynamicStyles += `margin: 0;`;
1478
- dynamicStyles += `border: 0;`;
1479
- dynamicStyles += `line-height: 1;`;
1480
- dynamicStyles += `position: absolute;`;
1481
- styleEl.innerHTML = `
1482
- ${cssSelector}::after {
1483
- ${dynamicStyles}
1484
- }
1485
- `;
1486
- document.head.appendChild(styleEl);
1487
- const textarea = document.querySelector(cssSelector);
1488
- const handleScroll = () => {
1489
- const styleEl2 = document.getElementById("dynamic-styles");
1490
- if (styleEl2 && textarea) {
1491
- const offsetFromBottom = -textarea.scrollTop + 6;
1492
- const offsetFromRight = -textarea.scrollLeft + 6;
1493
- styleEl2.innerHTML = `
1494
- ${cssSelector}::after {
1495
- ${dynamicStyles}
1496
- bottom: ${offsetFromBottom}px;
1497
- right: ${offsetFromRight}px;
1498
- }
1499
- `;
1500
- }
1501
- };
1502
- textarea == null ? void 0 : textarea.addEventListener("scroll", handleScroll);
1503
- return () => {
1504
- var _a;
1505
- (_a = document.getElementById("dynamic-styles")) == null ? void 0 : _a.remove();
1506
- textarea == null ? void 0 : textarea.removeEventListener("scroll", handleScroll);
1507
- };
1508
- }, [disableBranding, suggestionStyleAugmented]);
1509
- }
1510
-
1511
- // src/components/base-copilot-textarea/track-cursor-moved-since-last-text-change.tsx
1512
- var import_react11 = require("react");
1513
- var import_slate_react4 = require("slate-react");
1514
- var import_slate9 = require("slate");
1515
-
1516
- // src/lib/editor-to-text.ts
1517
- var import_slate8 = require("slate");
1518
- function nodeChildrenToTextComponents(editor, nodes) {
1519
- const indeciesOfInlineElements = new Set(
1520
- nodes.map((node, index) => {
1521
- if (import_slate8.Element.isElement(node) && editor.isInline(node)) {
1522
- return index;
1523
- }
1524
- return -1;
1525
- }).filter((index) => index !== -1)
1526
- );
1527
- const nonIgnorableItems = nodes.filter((node, index) => {
1528
- const isInline = indeciesOfInlineElements.has(index);
1529
- if (isInline) {
1530
- return false;
1531
- }
1532
- const isNeighbourOfInline = indeciesOfInlineElements.has(index - 1) || indeciesOfInlineElements.has(index + 1);
1533
- if (isNeighbourOfInline) {
1534
- return node.text !== "";
1535
- }
1536
- return true;
1537
- });
1538
- return nonIgnorableItems.map((node) => {
1539
- if (import_slate8.Element.isElement(node)) {
1540
- switch (node.type) {
1541
- case "paragraph":
1542
- return nodeChildrenToTextComponents(editor, node.children);
1543
- case "suggestion":
1544
- return [];
1545
- }
1546
- } else {
1547
- return [node];
1548
- }
1549
- }).reduce((acc, val) => acc.concat(val), []);
1550
- }
1551
- var editorToText = (editor) => {
1552
- const flattened = nodeChildrenToTextComponents(editor, editor.children);
1553
- const text = flattened.map((textComponent) => textComponent.text).join("\n");
1554
- return text;
1555
- };
1556
-
1557
- // src/components/base-copilot-textarea/track-cursor-moved-since-last-text-change.tsx
1558
- var import_jsx_runtime13 = require("react/jsx-runtime");
1559
- function TrackerTextEditedSinceLastCursorMovement(props) {
1560
- const cursorState = (0, import_slate_react4.useSlateSelector)((state) => ({
1561
- selection: state.selection,
1562
- text: editorToText(state)
1563
- }));
1564
- const previousState = usePrevious(cursorState);
1565
- (0, import_react11.useEffect)(() => {
1566
- if (!previousState) {
1567
- return;
1568
- }
1569
- if (cursorChangedWithoutTextChanged(previousState, cursorState)) {
1570
- props.setCursorMovedSinceLastTextChange(true);
1571
- }
1572
- }, [props.setCursorMovedSinceLastTextChange, cursorState]);
1573
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_jsx_runtime13.Fragment, {});
1574
- }
1575
- var cursorChangedWithoutTextChanged = (prev, next) => {
1576
- const isSelectionChanged = !isSelectionEqual(prev.selection, next.selection);
1577
- const isTextSame = prev.text === next.text;
1578
- return isSelectionChanged && isTextSame;
1579
- };
1580
- var isSelectionEqual = (a, b) => {
1581
- if (!a && !b)
1582
- return true;
1583
- if (!a || !b)
1584
- return false;
1585
- return import_slate9.Range.equals(a, b);
1586
- };
1587
- function usePrevious(value) {
1588
- const ref = (0, import_react11.useRef)();
1589
- (0, import_react11.useEffect)(() => {
1590
- ref.current = value;
1591
- });
1592
- return ref.current;
1593
- }
1594
-
1595
- // src/components/base-copilot-textarea/base-copilot-textarea.tsx
1596
- var import_jsx_runtime14 = require("react/jsx-runtime");
1597
- var BaseCopilotTextareaWithHoveringContext = import_react12.default.forwardRef(
1598
- (props, ref) => {
1599
- const autosuggestionsConfig = __spreadValues(__spreadValues({}, defaultBaseAutosuggestionsConfig), props.baseAutosuggestionsConfig);
1600
- const valueOnInitialRender = (0, import_react12.useMemo)(() => {
1601
- var _a2;
1602
- return (_a2 = props.value) != null ? _a2 : "";
1603
- }, []);
1604
- const [lastKnownFullEditorText, setLastKnownFullEditorText] = (0, import_react12.useState)(valueOnInitialRender);
1605
- const [cursorMovedSinceLastTextChange, setCursorMovedSinceLastTextChange] = (0, import_react12.useState)(false);
1606
- const initialValue = (0, import_react12.useMemo)(() => {
1607
- return [
1608
- {
1609
- type: "paragraph",
1610
- children: [{ text: valueOnInitialRender }]
1611
- }
1612
- ];
1613
- }, [valueOnInitialRender]);
1614
- const editor = useCopilotTextareaEditor();
1615
- const {
1616
- isDisplayed: hoveringEditorIsDisplayed,
1617
- setIsDisplayed: setHoveringEditorIsDisplayed
1618
- } = useHoveringEditorContext();
1619
- const insertText = (0, import_react12.useCallback)(
1620
- (autosuggestion) => {
1621
- import_slate10.Editor.insertText(editor, autosuggestion.text, {
1622
- at: autosuggestion.point
1623
- });
1624
- },
1625
- [editor]
1626
- );
1627
- const {
1628
- currentAutocompleteSuggestion,
1629
- onChangeHandler: onChangeHandlerForAutocomplete,
1630
- onKeyDownHandler: onKeyDownHandlerForAutocomplete
1631
- } = useAutosuggestions(
1632
- autosuggestionsConfig.debounceTime,
1633
- autosuggestionsConfig.acceptAutosuggestionKey,
1634
- autosuggestionsConfig.apiConfig.autosuggestionsFunction,
1635
- insertText,
1636
- autosuggestionsConfig.disableWhenEmpty,
1637
- autosuggestionsConfig.disabled || hoveringEditorIsDisplayed || cursorMovedSinceLastTextChange && autosuggestionsConfig.temporarilyDisableWhenMovingCursorWithoutChangingText
1638
- );
1639
- const onKeyDownHandlerForHoveringEditor = (0, import_react12.useCallback)(
1640
- (event) => {
1641
- if (event.key === "k" && event.metaKey) {
1642
- event.preventDefault();
1643
- setHoveringEditorIsDisplayed(!hoveringEditorIsDisplayed);
1644
- }
1645
- },
1646
- [hoveringEditorIsDisplayed, setHoveringEditorIsDisplayed]
1647
- );
1648
- (0, import_react12.useEffect)(() => {
1649
- clearAutocompletionsFromEditor(editor);
1650
- if (currentAutocompleteSuggestion) {
1651
- addAutocompletionsToEditor(
1652
- editor,
1653
- currentAutocompleteSuggestion.text,
1654
- currentAutocompleteSuggestion.point
1655
- );
1656
- }
1657
- }, [currentAutocompleteSuggestion]);
1658
- const suggestionStyleAugmented = (0, import_react12.useMemo)(() => {
1659
- return __spreadValues({
1660
- fontStyle: "italic",
1661
- color: "gray"
1662
- }, props.suggestionsStyle);
1663
- }, [props.suggestionsStyle]);
1664
- const renderElementMemoized = (0, import_react12.useMemo)(() => {
1665
- return makeRenderElementFunction(suggestionStyleAugmented);
1666
- }, [suggestionStyleAugmented]);
1667
- const renderPlaceholderMemoized = (0, import_react12.useMemo)(() => {
1668
- const placeholderStyleSlatejsOverrides = {
1669
- top: void 0
1670
- };
1671
- const placeholderStyleAugmented = __spreadValues(__spreadValues({}, placeholderStyleSlatejsOverrides), props.placeholderStyle);
1672
- return makeRenderPlaceholderFunction(placeholderStyleAugmented);
1673
- }, [props.placeholderStyle]);
1674
- (0, import_react12.useEffect)(() => {
1675
- var _a2, _b;
1676
- if (props.value === lastKnownFullEditorText) {
1677
- return;
1678
- }
1679
- setLastKnownFullEditorText((_a2 = props.value) != null ? _a2 : "");
1680
- replaceEditorText(editor, (_b = props.value) != null ? _b : "");
1681
- }, [props.value]);
1682
- const _a = props, {
1683
- placeholderStyle,
1684
- value,
1685
- onValueChange,
1686
- baseAutosuggestionsConfig: autosuggestionsConfigFromProps,
1687
- className,
1688
- onChange,
1689
- onKeyDown,
1690
- disableBranding
1691
- } = _a, propsToForward = __objRest(_a, [
1692
- "placeholderStyle",
1693
- "value",
1694
- "onValueChange",
1695
- "baseAutosuggestionsConfig",
1696
- "className",
1697
- "onChange",
1698
- "onKeyDown",
1699
- "disableBranding"
1700
- ]);
1701
- useAddBrandingCss(suggestionStyleAugmented, disableBranding);
1702
- usePopulateCopilotTextareaRef(editor, ref);
1703
- const moddedClassName = (() => {
1704
- const baseClassName = "copilot-textarea";
1705
- const brandingClass = disableBranding ? "no-branding" : "with-branding";
1706
- const defaultTailwindClassName = "bg-white overflow-y-auto resize-y";
1707
- const mergedClassName = (0, import_tailwind_merge2.twMerge)(
1708
- defaultTailwindClassName,
1709
- className != null ? className : ""
1710
- );
1711
- return `${baseClassName} ${brandingClass} ${mergedClassName}`;
1712
- })();
1713
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_slate_react5.Slate, {
1714
- editor,
1715
- initialValue,
1716
- onChange: (value2) => {
1717
- var _a2, _b;
1718
- const newEditorState = getTextAroundCollapsedCursor(editor);
1719
- const fullEditorText = newEditorState ? newEditorState.textBeforeCursor + newEditorState.textAfterCursor : getFullEditorTextWithNewlines(editor);
1720
- setLastKnownFullEditorText((prev) => {
1721
- if (prev !== fullEditorText) {
1722
- setCursorMovedSinceLastTextChange(false);
1723
- }
1724
- return fullEditorText;
1725
- });
1726
- onChangeHandlerForAutocomplete(newEditorState);
1727
- (_a2 = props.onValueChange) == null ? void 0 : _a2.call(props, fullEditorText);
1728
- (_b = props.onChange) == null ? void 0 : _b.call(props, makeSemiFakeReactTextAreaEvent(fullEditorText));
1729
- },
1730
- children: [
1731
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(TrackerTextEditedSinceLastCursorMovement, {
1732
- setCursorMovedSinceLastTextChange
1733
- }),
1734
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(HoveringToolbar, {
1735
- apiConfig: autosuggestionsConfig.apiConfig,
1736
- contextCategories: autosuggestionsConfig.contextCategories
1737
- }),
1738
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_slate_react5.Editable, __spreadValues({
1739
- renderElement: renderElementMemoized,
1740
- renderPlaceholder: renderPlaceholderMemoized,
1741
- onKeyDown: (event) => {
1742
- var _a2;
1743
- onKeyDownHandlerForHoveringEditor(event);
1744
- onKeyDownHandlerForAutocomplete(event);
1745
- (_a2 = props.onKeyDown) == null ? void 0 : _a2.call(props, event);
1746
- },
1747
- className: moddedClassName
1748
- }, propsToForward))
1749
- ]
1750
- });
1751
- }
1752
- );
1753
- function makeSemiFakeReactTextAreaEvent(currentText) {
1754
- return {
1755
- target: {
1756
- value: currentText,
1757
- type: "copilot-textarea"
1758
- },
1759
- currentTarget: {
1760
- value: currentText,
1761
- type: "copilot-textarea"
1762
- }
1763
- };
1764
- }
1765
- var BaseCopilotTextarea = import_react12.default.forwardRef(
1766
- (props, ref) => {
1767
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(HoveringEditorProvider, {
1768
- children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(BaseCopilotTextareaWithHoveringContext, __spreadProps(__spreadValues({}, props), {
1769
- ref
1770
- }))
1771
- });
1772
- }
1773
- );
1774
-
1775
- // src/components/copilot-textarea/copilot-textarea.tsx
1776
- var import_react15 = __toESM(require("react"));
1777
-
1778
- // src/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.tsx
1779
- var import_react_core3 = require("@copilotkit/react-core");
1780
- var import_react13 = require("react");
1781
-
1782
- // src/types/autosuggestions-config/suggestions-api-config.tsx
1783
- var defaultSuggestionsMakeSystemPrompt = (textareaPurpose, contextString) => {
1784
- return `You are a versatile writing assistant.
1785
-
1786
- The user is writing some text.
1787
- The purpose is: "${textareaPurpose}"
1788
-
1789
- Your job is to guess what the user will write next AS BEST YOU CAN.
1790
- Only guess a SHORT distance ahead. Usually 1 sentence, or at most 1 paragraph.
1791
-
1792
- Adjust yourself to the user's style and implied intent.
1793
-
1794
- The user will provide both the text before and after the cursor. You should use this to infer what the user is likely to write next.
1795
- <TextAfterCursor>
1796
- <TextBeforeCursor>
1797
- <YourSuggestion>
1798
-
1799
- If we need to add a whitespace character to the suggested text, make sure to explicitly add it in.
1800
-
1801
- The following external context is also provided. Use it to help you make better suggestions!!!
1802
- \`\`\`
1803
- ${contextString}
1804
- \`\`\`
1805
- `;
1806
- };
1807
- var defaultSuggestionsFewShotMessages = [
1808
- {
1809
- role: "user",
1810
- name: "TextAfterCursor",
1811
- content: "While I was there I also picked up some apples, oranges, and bananas."
1812
- },
1813
- {
1814
- role: "user",
1815
- content: "This morning I woke up and went straight to the grocery store."
1816
- },
1817
- {
1818
- role: "assistant",
1819
- content: " When I arrived I went straight to the produce section and picked out a big watermelon. "
1820
- },
1821
- {
1822
- role: "user",
1823
- name: "TextAfterCursor",
1824
- content: "and (iii) to the appointment of the Equityholders' Representative pursuant to Section 10.7 of the Merger Agreement and to the provisions thereof."
1825
- },
1826
- {
1827
- role: "user",
1828
- name: "TextBeforeCursor",
1829
- content: `The Optionholder, in the Optionholder's capacity as a holder of vested Options, hereby irrevocably and unconditionally agrees: (i) that the Optionholder shall be deemed an "Equityholder" under the Merger Agreement and shall be entitled to the rights and benefits, and subject to the obligations, of an "Equityholder" thereunder;`
1830
- },
1831
- {
1832
- role: "assistant",
1833
- content: ` (ii) that, for purposes of this Agreement and the Merger Agreement, the applicable percentage set forth opposite the name of the Optionholder in the Distribution Waterfall shall be such the Optionholder's "Pro Rata Share"; `
1834
- }
1835
- ];
1836
- var defaultSuggestionsApiConfig = {
1837
- makeSystemPrompt: defaultSuggestionsMakeSystemPrompt,
1838
- fewShotMessages: defaultSuggestionsFewShotMessages,
1839
- forwardedParams: void 0
1840
- };
1841
-
1842
- // src/types/autosuggestions-config/insertions-api-config.tsx
1843
- var defaultInsertionsMakeSystemPrompt = (textareaPurpose, contextString) => {
1844
- return `You are a versatile writing assistant.
1845
-
1846
- The user is writing some text.
1847
- The purpose is: "${textareaPurpose}"
1848
-
1849
- The following external context is also provided. Use it to help you make better suggestions!!!
1850
- \`\`\`
1851
- ${contextString}
1852
- \`\`\`
1853
-
1854
- The user also provides you with a prompt for INSERTIONS into the text they are writing.
1855
- Your job is to come up with an INSERTION into the text that the user would like AS BEST YOU CAN.
1856
- Only insert a SHORT segment. Usually 1 sentence, or at most 1 paragraph.
1857
-
1858
- Adjust yourself to the user's style and implied intent.
1859
-
1860
- The user will provide the text before and after the cursor, as well as the insertion prompt. You should use this to infer the best relevant insertion.
1861
- <TextAfterCursor>
1862
- <TextBeforeCursor>
1863
- <InsertionPrompt>
1864
- <YourSuggestion>
1865
- `;
1866
- };
1867
- var defaultInsertionsFewShotMessages = [
1868
- {
1869
- role: "user",
1870
- name: "TextAfterCursor",
1871
- content: "While I was there I also picked up some apples, oranges, and bananas."
1872
- },
1873
- {
1874
- role: "user",
1875
- name: "TextBeforeCursor",
1876
- content: "This morning I woke up and went straight to the grocery store."
1877
- },
1878
- {
1879
- role: "user",
1880
- name: "InsertionPrompt",
1881
- content: "I bought a big watermelon"
1882
- },
1883
- {
1884
- role: "assistant",
1885
- content: " When I arrived I went straight to the produce section and picked out a big watermelon. "
1886
- },
1887
- {
1888
- role: "user",
1889
- name: "TextAfterCursor",
1890
- content: "and (iii) to the appointment of the Equityholders' Representative pursuant to Section 10.7 of the Merger Agreement and to the provisions thereof."
1891
- },
1892
- {
1893
- role: "user",
1894
- name: "TextBeforeCursor",
1895
- content: `The Optionholder, in the Optionholder's capacity as a holder of vested Options, hereby irrevocably and unconditionally agrees: (i) that the Optionholder shall be deemed an "Equityholder" under the Merger Agreement and shall be entitled to the rights and benefits, and subject to the obligations, of an "Equityholder" thereunder;`
1896
- },
1897
- {
1898
- role: "user",
1899
- name: "InsertionPrompt",
1900
- content: "add section about the optionholder's pro rata share"
1901
- },
1902
- {
1903
- role: "assistant",
1904
- content: ` (ii) that, for purposes of this Agreement and the Merger Agreement, the applicable percentage set forth opposite the name of the Optionholder in the Distribution Waterfall shall be such the Optionholder's "Pro Rata Share"; `
1905
- }
1906
- ];
1907
- var defaultInsertionsApiConfig = {
1908
- makeSystemPrompt: defaultInsertionsMakeSystemPrompt,
1909
- fewShotMessages: defaultInsertionsFewShotMessages,
1910
- forwardedParams: void 0
1911
- };
1912
-
1913
- // src/types/autosuggestions-config/editing-api-config.tsx
1914
- var defaultEditingMakeSystemPrompt = (textareaPurpose, contextString) => {
1915
- return `You are a versatile writing assistant.
1916
-
1917
- The user is writing some text.
1918
- The purpose is: "${textareaPurpose}"
1919
-
1920
- The following external context is also provided. Use it to help you make better suggestions!!!
1921
- \`\`\`
1922
- ${contextString}
1923
- \`\`\`
1924
-
1925
- The user also provides you with a prompt for EDITING some text they are writing.
1926
- Your job is to come up with an EDIT of the text that the user would like to use - AS BEST YOU CAN.
1927
-
1928
- Adjust yourself to the user's style and implied intent.
1929
-
1930
- The user will provide the following information; use this to infer the best relevant EDIT:
1931
- <TextBeforeCursor>
1932
- <TextToEdit>
1933
- <TextAfterCursor>
1934
- <EditingPrompt>
1935
-
1936
- <YourEditSuggestion>
1937
- `;
1938
- };
1939
- var defaultEditingFewShotMessages = [
1940
- {
1941
- role: "user",
1942
- name: "TextBeforeCursor",
1943
- content: "This morning I woke up and went straight to the grocery store. "
1944
- },
1945
- {
1946
- role: "user",
1947
- name: "TextToEdit",
1948
- content: "While I was there I also picked up some apples, oranges, and bananas. "
1949
- },
1950
- {
1951
- role: "user",
1952
- name: "TextAfterCursor",
1953
- content: "The grocery store was having a sale on fruit, so I decided to stock up."
1954
- },
1955
- {
1956
- role: "user",
1957
- name: "EditingPrompt",
1958
- content: "I bought a big watermelon"
1959
- },
1960
- {
1961
- role: "assistant",
1962
- content: " When I arrived I went straight to the produce section and picked out a big watermelon. "
1963
- },
1964
- {
1965
- role: "user",
1966
- name: "TextAfterCursor",
1967
- content: "and (iii) to the appointment of the Equityholders' Representative pursuant to Section 10.7 of the Merger Agreement and to the provisions thereof."
1968
- },
1969
- {
1970
- role: "user",
1971
- name: "TextBeforeCursor",
1972
- content: `The Optionholder, in the Optionholder's capacity as a holder of vested Options, hereby irrevocably and unconditionally agrees: (i) that the Optionholder shall be deemed an "Equityholder" under the Merger Agreement and shall be entitled to the rights and benefits, and subject to the obligations, of an "Equityholder" thereunder;`
1973
- },
1974
- {
1975
- role: "user",
1976
- name: "InsertionPrompt",
1977
- content: "add section about the optionholder's pro rata share"
1978
- },
1979
- {
1980
- role: "assistant",
1981
- content: ` (ii) that, for purposes of this Agreement and the Merger Agreement, the applicable percentage set forth opposite the name of the Optionholder in the Distribution Waterfall shall be such the Optionholder's "Pro Rata Share"; `
1982
- }
1983
- ];
1984
- var defaultEditingApiConfig = {
1985
- makeSystemPrompt: defaultEditingMakeSystemPrompt,
1986
- fewShotMessages: defaultEditingFewShotMessages,
1987
- forwardedParams: void 0
1988
- };
1989
-
1990
- // src/types/autosuggestions-config/autosuggestions-config.tsx
1991
- var defaultAutosuggestionsConfig = __spreadProps(__spreadValues({}, defaultBaseAutosuggestionsConfig), {
1992
- externalContextCategories: void 0,
1993
- chatApiConfigs: {
1994
- suggestionsApiConfig: defaultSuggestionsApiConfig,
1995
- insertionApiConfig: defaultInsertionsApiConfig,
1996
- editingApiConfig: defaultEditingApiConfig
1997
- }
1998
- });
1999
-
2000
- // src/types/autosuggestions-config/subtypes/chatlike-api-endpoint.tsx
2001
- var import_react_core2 = require("@copilotkit/react-core");
2002
- var ChatlikeApiEndpoint = class {
2003
- constructor(run) {
2004
- this.run = run;
2005
- }
2006
- static fromCopilotApiConfig(copilotApiConfig) {
2007
- return new ChatlikeApiEndpoint(
2008
- (abortSignal, messages, forwardedProps) => __async(this, null, function* () {
2009
- const res = yield fetch(
2010
- (0, import_react_core2.copilotApiConfigExtrapolator)(copilotApiConfig).chatApiEndpoint,
2011
- {
2012
- method: "POST",
2013
- headers: __spreadValues({}, copilotApiConfig.headers),
2014
- body: JSON.stringify(__spreadProps(__spreadValues(__spreadValues({}, forwardedProps), copilotApiConfig.body), {
2015
- messages
2016
- })),
2017
- signal: abortSignal
2018
- }
2019
- );
2020
- const bodySteram = res.body;
2021
- if (!bodySteram) {
2022
- throw new Error("The response body is empty.");
2023
- }
2024
- const stringStream = bodySteram.pipeThrough(new TextDecoderStream());
2025
- return stringStream;
2026
- })
2027
- );
2028
- }
2029
- static custom(run) {
2030
- return new ChatlikeApiEndpoint(run);
2031
- }
2032
- };
2033
-
2034
- // src/lib/retry.tsx
2035
- function retry(fn, retriesLeft = 2, interval = 200, backoff = 1.5) {
2036
- return new Promise((resolve, reject) => {
2037
- fn().then(resolve).catch((error) => {
2038
- if (retriesLeft === 1) {
2039
- reject(error);
2040
- return;
2041
- }
2042
- setTimeout(() => {
2043
- retry(fn, retriesLeft - 1, interval * backoff, backoff).then(resolve).catch(reject);
2044
- }, interval);
2045
- });
2046
- });
2047
- }
2048
-
2049
- // src/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.tsx
2050
- function useMakeStandardAutosuggestionFunction(textareaPurpose, contextCategories, apiConfig) {
2051
- const { getContextString, copilotApiConfig } = (0, import_react13.useContext)(import_react_core3.CopilotContext);
2052
- return (0, import_react13.useCallback)(
2053
- (editorState2, abortSignal) => __async(this, null, function* () {
2054
- const res = yield retry(() => __async(this, null, function* () {
2055
- const messages = [
2056
- {
2057
- role: "system",
2058
- content: apiConfig.makeSystemPrompt(
2059
- textareaPurpose,
2060
- getContextString([], contextCategories)
2061
- )
2062
- },
2063
- ...apiConfig.fewShotMessages,
2064
- {
2065
- role: "user",
2066
- name: "TextAfterCursor",
2067
- content: editorState2.textAfterCursor
2068
- },
2069
- {
2070
- role: "user",
2071
- name: "TextBeforeCursor",
2072
- content: editorState2.textBeforeCursor
2073
- }
2074
- ];
2075
- const apiEndpoint = ChatlikeApiEndpoint.fromCopilotApiConfig(copilotApiConfig);
2076
- const stream = yield apiEndpoint.run(
2077
- abortSignal,
2078
- messages,
2079
- apiConfig.forwardedParams
2080
- );
2081
- const reader = stream.getReader();
2082
- let result = "";
2083
- while (true) {
2084
- const { done, value } = yield reader.read();
2085
- if (done) {
2086
- break;
2087
- }
2088
- result += value;
2089
- }
2090
- return result;
2091
- }));
2092
- return res;
2093
- }),
2094
- [apiConfig, getContextString, contextCategories, textareaPurpose]
2095
- );
2096
- }
2097
-
2098
- // src/hooks/make-autosuggestions-function/use-make-standard-insertion-function.tsx
2099
- var import_react_core4 = require("@copilotkit/react-core");
2100
- var import_react14 = require("react");
2101
- function useMakeStandardInsertionOrEditingFunction(textareaPurpose, contextCategories, insertionApiConfig, editingApiConfig) {
2102
- const { getContextString, copilotApiConfig } = (0, import_react14.useContext)(import_react_core4.CopilotContext);
2103
- const insertionFunction = (0, import_react14.useCallback)(
2104
- (editorState2, insertionPrompt, documents, abortSignal) => __async(this, null, function* () {
2105
- const res = yield retry(() => __async(this, null, function* () {
2106
- const messages = [
2107
- {
2108
- role: "system",
2109
- content: insertionApiConfig.makeSystemPrompt(
2110
- textareaPurpose,
2111
- getContextString(documents, contextCategories)
2112
- )
2113
- },
2114
- ...insertionApiConfig.fewShotMessages,
2115
- {
2116
- role: "user",
2117
- name: "TextAfterCursor",
2118
- content: editorState2.textAfterCursor
2119
- },
2120
- {
2121
- role: "user",
2122
- name: "TextBeforeCursor",
2123
- content: editorState2.textBeforeCursor
2124
- },
2125
- {
2126
- role: "user",
2127
- name: "InsertionPrompt",
2128
- content: insertionPrompt
2129
- }
2130
- ];
2131
- const apiEndpoint = ChatlikeApiEndpoint.fromCopilotApiConfig(copilotApiConfig);
2132
- return yield apiEndpoint.run(
2133
- abortSignal,
2134
- messages,
2135
- insertionApiConfig.forwardedParams
2136
- );
2137
- }));
2138
- return res;
2139
- }),
2140
- [insertionApiConfig, getContextString, contextCategories, textareaPurpose]
2141
- );
2142
- const editingFunction = (0, import_react14.useCallback)(
2143
- (editorState2, editingPrompt, documents, abortSignal) => __async(this, null, function* () {
2144
- const res = yield retry(() => __async(this, null, function* () {
2145
- const messages = [
2146
- {
2147
- role: "system",
2148
- content: editingApiConfig.makeSystemPrompt(
2149
- textareaPurpose,
2150
- getContextString(documents, contextCategories)
2151
- )
2152
- },
2153
- ...editingApiConfig.fewShotMessages,
2154
- {
2155
- role: "user",
2156
- name: "TextBeforeCursor",
2157
- content: editorState2.textBeforeCursor
2158
- },
2159
- {
2160
- role: "user",
2161
- name: "TextToEdit",
2162
- content: editorState2.selectedText
2163
- },
2164
- {
2165
- role: "user",
2166
- name: "TextAfterCursor",
2167
- content: editorState2.textAfterCursor
2168
- },
2169
- {
2170
- role: "user",
2171
- name: "EditingPrompt",
2172
- content: editingPrompt
2173
- }
2174
- ];
2175
- const apiEndpoint = ChatlikeApiEndpoint.fromCopilotApiConfig(copilotApiConfig);
2176
- return yield apiEndpoint.run(
2177
- abortSignal,
2178
- messages,
2179
- editingApiConfig.forwardedParams
2180
- );
2181
- }));
2182
- return res;
2183
- }),
2184
- [editingApiConfig, getContextString, contextCategories, textareaPurpose]
2185
- );
2186
- const insertionOrEditingFunction = (0, import_react14.useCallback)(
2187
- (editorState2, insertionPrompt, documents, abortSignal) => __async(this, null, function* () {
2188
- if (editorState2.selectedText === "") {
2189
- return yield insertionFunction(
2190
- editorState2,
2191
- insertionPrompt,
2192
- documents,
2193
- abortSignal
2194
- );
2195
- } else {
2196
- return yield editingFunction(
2197
- editorState2,
2198
- insertionPrompt,
2199
- documents,
2200
- abortSignal
2201
- );
2202
- }
2203
- }),
2204
- [insertionFunction, editingFunction]
2205
- );
2206
- return insertionOrEditingFunction;
2207
- }
2208
-
2209
- // src/components/copilot-textarea/copilot-textarea.tsx
2210
- var import_lodash = __toESM(require("lodash.merge"));
2211
- var import_jsx_runtime15 = require("react/jsx-runtime");
2212
- var CopilotTextarea = import_react15.default.forwardRef(
2213
- (props, ref) => {
2214
- const _a = props, {
2215
- autosuggestionsConfig: autosuggestionsConfigUserSpecified
2216
- } = _a, forwardedProps = __objRest(_a, [
2217
- "autosuggestionsConfig"
2218
- ]);
2219
- const autosuggestionsConfig = (0, import_lodash.default)(
2220
- defaultAutosuggestionsConfig,
2221
- autosuggestionsConfigUserSpecified
2222
- );
2223
- const autosuggestionsFunction = useMakeStandardAutosuggestionFunction(
2224
- autosuggestionsConfig.textareaPurpose,
2225
- autosuggestionsConfig.externalContextCategories,
2226
- autosuggestionsConfig.chatApiConfigs.suggestionsApiConfig
2227
- );
2228
- const insertionOrEditingFunction = useMakeStandardInsertionOrEditingFunction(
2229
- autosuggestionsConfig.textareaPurpose,
2230
- autosuggestionsConfig.externalContextCategories,
2231
- autosuggestionsConfig.chatApiConfigs.insertionApiConfig,
2232
- autosuggestionsConfig.chatApiConfigs.editingApiConfig
2233
- );
2234
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_jsx_runtime15.Fragment, {
2235
- children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(BaseCopilotTextarea, __spreadProps(__spreadValues({
2236
- ref
2237
- }, forwardedProps), {
2238
- baseAutosuggestionsConfig: __spreadProps(__spreadValues({}, autosuggestionsConfig), {
2239
- apiConfig: {
2240
- insertionOrEditingFunction,
2241
- autosuggestionsFunction
2242
- }
2243
- })
2244
- }))
2245
- });
2246
- }
2247
- );
2248
- // Annotate the CommonJS export names for ESM import in node:
2249
- 0 && (module.exports = {
2250
- BaseCopilotTextarea,
2251
- ChatlikeApiEndpoint,
2252
- CopilotTextarea,
2253
- defaultAutosuggestionsConfig,
2254
- defaultBaseAutosuggestionsConfig
2255
- });
2256
- //# sourceMappingURL=index.js.map