@copilotkit/react-textarea 0.21.0-alpha.0 → 0.21.0-alpha.1

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 (290) hide show
  1. package/.turbo/turbo-build.log +279 -249
  2. package/CHANGELOG.md +11 -0
  3. package/dist/chunk-2NURR2DX.mjs +16 -8
  4. package/dist/chunk-2NURR2DX.mjs.map +1 -1
  5. package/dist/{chunk-YXA3UPMI.mjs → chunk-34D4UIYX.mjs} +59 -23
  6. package/dist/chunk-34D4UIYX.mjs.map +1 -0
  7. package/dist/chunk-463BFNUP.mjs +16 -5
  8. package/dist/chunk-463BFNUP.mjs.map +1 -1
  9. package/dist/chunk-4S5ZJH3I.mjs +3 -2
  10. package/dist/chunk-4S5ZJH3I.mjs.map +1 -1
  11. package/dist/chunk-5EJ5XOGP.mjs +16 -8
  12. package/dist/chunk-5EJ5XOGP.mjs.map +1 -1
  13. package/dist/chunk-5FO6ISW4.mjs +0 -2
  14. package/dist/chunk-5FO6ISW4.mjs.map +1 -1
  15. package/dist/{chunk-5DU2QDHZ.mjs → chunk-7JO276KU.mjs} +9 -5
  16. package/dist/chunk-7JO276KU.mjs.map +1 -0
  17. package/dist/chunk-AXN37AHC.mjs +5 -2
  18. package/dist/chunk-AXN37AHC.mjs.map +1 -1
  19. package/dist/chunk-CSGFJU3L.mjs +11 -6
  20. package/dist/chunk-CSGFJU3L.mjs.map +1 -1
  21. package/dist/chunk-DE5K76I2.mjs +0 -2
  22. package/dist/chunk-DE5K76I2.mjs.map +1 -1
  23. package/dist/chunk-DYGPLRY3.mjs +15 -7
  24. package/dist/chunk-DYGPLRY3.mjs.map +1 -1
  25. package/dist/chunk-F2TIBXML.mjs +19 -7
  26. package/dist/chunk-F2TIBXML.mjs.map +1 -1
  27. package/dist/chunk-F3MHL6ZY.mjs +4 -4
  28. package/dist/chunk-F3MHL6ZY.mjs.map +1 -1
  29. package/dist/{chunk-O7G7E3E3.mjs → chunk-F4WZCQG6.mjs} +35 -13
  30. package/dist/chunk-F4WZCQG6.mjs.map +1 -0
  31. package/dist/chunk-GCMQHIRF.mjs +6 -3
  32. package/dist/chunk-GCMQHIRF.mjs.map +1 -1
  33. package/dist/chunk-H4VKQGVU.mjs +0 -2
  34. package/dist/chunk-H4VKQGVU.mjs.map +1 -1
  35. package/dist/{chunk-24SYR4JB.mjs → chunk-IPM5WWPW.mjs} +25 -11
  36. package/dist/chunk-IPM5WWPW.mjs.map +1 -0
  37. package/dist/chunk-IU3WTXLQ.mjs +0 -2
  38. package/dist/chunk-IU3WTXLQ.mjs.map +1 -1
  39. package/dist/chunk-IXJ2HCOA.mjs +14 -4
  40. package/dist/chunk-IXJ2HCOA.mjs.map +1 -1
  41. package/dist/chunk-JAFCXEPU.mjs +6 -3
  42. package/dist/chunk-JAFCXEPU.mjs.map +1 -1
  43. package/dist/chunk-JHTAOLEW.mjs +5 -2
  44. package/dist/chunk-JHTAOLEW.mjs.map +1 -1
  45. package/dist/chunk-KCHYD3EB.mjs +6 -5
  46. package/dist/chunk-KCHYD3EB.mjs.map +1 -1
  47. package/dist/chunk-KGKLUWKW.mjs +15 -6
  48. package/dist/chunk-KGKLUWKW.mjs.map +1 -1
  49. package/dist/chunk-L7VVZH4Q.mjs +0 -2
  50. package/dist/chunk-L7VVZH4Q.mjs.map +1 -1
  51. package/dist/chunk-LNAIMEB2.mjs +9 -4
  52. package/dist/chunk-LNAIMEB2.mjs.map +1 -1
  53. package/dist/{chunk-KLROO6ID.mjs → chunk-LRXRD5KU.mjs} +24 -12
  54. package/dist/chunk-LRXRD5KU.mjs.map +1 -0
  55. package/dist/chunk-MMVDU6DF.mjs +0 -2
  56. package/dist/chunk-MMVDU6DF.mjs.map +1 -1
  57. package/dist/chunk-MPME5BW2.mjs +4 -4
  58. package/dist/chunk-MPME5BW2.mjs.map +1 -1
  59. package/dist/chunk-MRXNTQOX.mjs +6 -2
  60. package/dist/chunk-MRXNTQOX.mjs.map +1 -1
  61. package/dist/chunk-ND5PXTAW.mjs +4 -4
  62. package/dist/chunk-ND5PXTAW.mjs.map +1 -1
  63. package/dist/chunk-NKW5OU2S.mjs +6 -3
  64. package/dist/chunk-NKW5OU2S.mjs.map +1 -1
  65. package/dist/chunk-O5OWT5GE.mjs +23 -8
  66. package/dist/chunk-O5OWT5GE.mjs.map +1 -1
  67. package/dist/chunk-OD7ZMOVE.mjs +11 -7
  68. package/dist/chunk-OD7ZMOVE.mjs.map +1 -1
  69. package/dist/chunk-OELUUJZY.mjs +10 -4
  70. package/dist/chunk-OELUUJZY.mjs.map +1 -1
  71. package/dist/chunk-QJDMIGLU.mjs +12 -4
  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 +5 -2
  76. package/dist/chunk-RR6OQGTI.mjs.map +1 -1
  77. package/dist/chunk-S6JUGJK2.mjs +3 -2
  78. package/dist/chunk-S6JUGJK2.mjs.map +1 -1
  79. package/dist/{chunk-63FSISXT.mjs → chunk-TIBMW3DC.mjs} +12 -7
  80. package/dist/chunk-TIBMW3DC.mjs.map +1 -0
  81. package/dist/chunk-UHD44NC5.mjs +17 -7
  82. package/dist/chunk-UHD44NC5.mjs.map +1 -1
  83. package/dist/chunk-WADHCMPK.mjs +0 -2
  84. package/dist/chunk-WADHCMPK.mjs.map +1 -1
  85. package/dist/chunk-WJHSY5T6.mjs +0 -2
  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 +42 -22
  90. package/dist/chunk-WLPYYGES.mjs.map +1 -1
  91. package/dist/chunk-WPIA53HF.mjs +15 -7
  92. package/dist/chunk-WPIA53HF.mjs.map +1 -1
  93. package/dist/chunk-XHUMROEY.mjs +17 -7
  94. package/dist/chunk-XHUMROEY.mjs.map +1 -1
  95. package/dist/chunk-YQU7WG7T.mjs +12 -6
  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 +6 -5
  100. package/dist/chunk-YW3REYX6.mjs.map +1 -1
  101. package/dist/components/base-copilot-textarea/base-copilot-textarea.d.ts +14 -0
  102. package/dist/components/base-copilot-textarea/base-copilot-textarea.mjs +39 -35
  103. package/dist/components/base-copilot-textarea/base-copilot-textarea.mjs.map +1 -1
  104. package/dist/components/base-copilot-textarea/render-element.d.ts +6 -0
  105. package/dist/components/base-copilot-textarea/render-element.mjs +7 -3
  106. package/dist/components/base-copilot-textarea/render-element.mjs.map +1 -1
  107. package/dist/components/base-copilot-textarea/render-placeholder.d.ts +6 -0
  108. package/dist/components/base-copilot-textarea/render-placeholder.mjs +7 -3
  109. package/dist/components/base-copilot-textarea/render-placeholder.mjs.map +1 -1
  110. package/dist/components/base-copilot-textarea/track-cursor-moved-since-last-text-change.d.ts +6 -0
  111. package/dist/components/base-copilot-textarea/track-cursor-moved-since-last-text-change.mjs +8 -4
  112. package/dist/components/base-copilot-textarea/track-cursor-moved-since-last-text-change.mjs.map +1 -1
  113. package/dist/components/base-copilot-textarea/use-add-branding-css.d.ts +3 -0
  114. package/dist/components/base-copilot-textarea/use-add-branding-css.mjs +7 -3
  115. package/dist/components/base-copilot-textarea/use-add-branding-css.mjs.map +1 -1
  116. package/dist/components/copilot-textarea/copilot-textarea.d.ts +20 -0
  117. package/dist/components/copilot-textarea/copilot-textarea.mjs +51 -47
  118. package/dist/components/copilot-textarea/copilot-textarea.mjs.map +1 -1
  119. package/dist/components/hovering-toolbar/hovering-editor-provider.d.ts +13 -0
  120. package/dist/components/hovering-toolbar/hovering-editor-provider.mjs +9 -3
  121. package/dist/components/hovering-toolbar/hovering-editor-provider.mjs.map +1 -1
  122. package/dist/components/hovering-toolbar/hovering-toolbar-components.d.ts +18 -0
  123. package/dist/components/hovering-toolbar/hovering-toolbar-components.mjs +15 -3
  124. package/dist/components/hovering-toolbar/hovering-toolbar-components.mjs.map +1 -1
  125. package/dist/components/hovering-toolbar/hovering-toolbar.d.ts +10 -0
  126. package/dist/components/hovering-toolbar/hovering-toolbar.mjs +22 -18
  127. package/dist/components/hovering-toolbar/hovering-toolbar.mjs.map +1 -1
  128. package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.d.ts +16 -0
  129. package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.mjs +16 -12
  130. package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.mjs.map +1 -1
  131. package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.d.ts +14 -0
  132. package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.mjs +17 -13
  133. package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.mjs.map +1 -1
  134. package/dist/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.d.ts +15 -0
  135. package/dist/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.mjs +11 -5
  136. package/dist/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.mjs.map +1 -1
  137. package/dist/components/hovering-toolbar/text-insertion-prompt-box/index.d.ts +4 -0
  138. package/dist/components/hovering-toolbar/text-insertion-prompt-box/index.mjs +18 -14
  139. package/dist/components/hovering-toolbar/text-insertion-prompt-box/index.mjs.map +1 -1
  140. package/dist/components/index.d.ts +15 -0
  141. package/dist/components/index.mjs +55 -48
  142. package/dist/components/index.mjs.map +1 -1
  143. package/dist/components/manual-ui/chip-with-icon.d.ts +10 -0
  144. package/dist/components/manual-ui/chip-with-icon.mjs +6 -5
  145. package/dist/components/manual-ui/chip-with-icon.mjs.map +1 -1
  146. package/dist/components/source-search-box/source-search-box.d.ts +15 -0
  147. package/dist/components/source-search-box/source-search-box.mjs +12 -6
  148. package/dist/components/source-search-box/source-search-box.mjs.map +1 -1
  149. package/dist/components/ui/button.d.ts +14 -0
  150. package/dist/components/ui/button.mjs +10 -4
  151. package/dist/components/ui/button.mjs.map +1 -1
  152. package/dist/components/ui/card.d.ts +10 -0
  153. package/dist/components/ui/card.mjs +18 -7
  154. package/dist/components/ui/card.mjs.map +1 -1
  155. package/dist/components/ui/command.d.ts +48 -0
  156. package/dist/components/ui/command.mjs +25 -5
  157. package/dist/components/ui/command.mjs.map +1 -1
  158. package/dist/components/ui/dialog.d.ts +18 -0
  159. package/dist/components/ui/dialog.mjs +20 -4
  160. package/dist/components/ui/dialog.mjs.map +1 -1
  161. package/dist/components/ui/label.d.ts +8 -0
  162. package/dist/components/ui/label.mjs +8 -4
  163. package/dist/components/ui/label.mjs.map +1 -1
  164. package/dist/components/ui/separator.d.ts +6 -0
  165. package/dist/components/ui/separator.mjs +15 -8
  166. package/dist/components/ui/separator.mjs.map +1 -1
  167. package/dist/components/ui/textarea.d.ts +7 -0
  168. package/dist/components/ui/textarea.mjs +13 -7
  169. package/dist/components/ui/textarea.mjs.map +1 -1
  170. package/dist/context/index.d.ts +1 -0
  171. package/dist/context/index.mjs +1 -2
  172. package/dist/context/index.mjs.map +1 -1
  173. package/dist/hooks/base-copilot-textarea-implementation/use-autosuggestions.d.ts +14 -0
  174. package/dist/hooks/base-copilot-textarea-implementation/use-autosuggestions.mjs +10 -6
  175. package/dist/hooks/base-copilot-textarea-implementation/use-autosuggestions.mjs.map +1 -1
  176. package/dist/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.d.ts +8 -0
  177. package/dist/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.mjs +8 -4
  178. package/dist/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.mjs.map +1 -1
  179. package/dist/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.d.ts +7 -0
  180. package/dist/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.mjs +9 -5
  181. package/dist/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.mjs.map +1 -1
  182. package/dist/hooks/index.d.ts +1 -0
  183. package/dist/hooks/index.mjs +1 -2
  184. package/dist/hooks/index.mjs.map +1 -1
  185. package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.d.ts +22 -0
  186. package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.mjs +18 -14
  187. package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.mjs.map +1 -1
  188. package/dist/hooks/make-autosuggestions-function/use-make-standard-insertion-function.d.ts +23 -0
  189. package/dist/hooks/make-autosuggestions-function/use-make-standard-insertion-function.mjs +18 -14
  190. package/dist/hooks/make-autosuggestions-function/use-make-standard-insertion-function.mjs.map +1 -1
  191. package/dist/hooks/misc/use-autosize-textarea.d.ts +5 -0
  192. package/dist/hooks/misc/use-autosize-textarea.mjs +7 -3
  193. package/dist/hooks/misc/use-autosize-textarea.mjs.map +1 -1
  194. package/dist/index.d.ts +16 -0
  195. package/dist/index.mjs +66 -50
  196. package/dist/index.mjs.map +1 -1
  197. package/dist/lib/debouncer.d.ts +11 -0
  198. package/dist/lib/debouncer.mjs +7 -3
  199. package/dist/lib/debouncer.mjs.map +1 -1
  200. package/dist/lib/editor-to-text.d.ts +7 -0
  201. package/dist/lib/editor-to-text.mjs +7 -3
  202. package/dist/lib/editor-to-text.mjs.map +1 -1
  203. package/dist/lib/get-text-around-cursor.d.ts +15 -0
  204. package/dist/lib/get-text-around-cursor.mjs +13 -3
  205. package/dist/lib/get-text-around-cursor.mjs.map +1 -1
  206. package/dist/lib/retry.d.ts +3 -0
  207. package/dist/lib/retry.mjs +7 -3
  208. package/dist/lib/retry.mjs.map +1 -1
  209. package/dist/lib/slatejs-edits/add-autocompletions.d.ts +8 -0
  210. package/dist/lib/slatejs-edits/add-autocompletions.mjs +7 -3
  211. package/dist/lib/slatejs-edits/add-autocompletions.mjs.map +1 -1
  212. package/dist/lib/slatejs-edits/clear-autocompletions.d.ts +8 -0
  213. package/dist/lib/slatejs-edits/clear-autocompletions.mjs +7 -3
  214. package/dist/lib/slatejs-edits/clear-autocompletions.mjs.map +1 -1
  215. package/dist/lib/slatejs-edits/replace-text.d.ts +5 -0
  216. package/dist/lib/slatejs-edits/replace-text.mjs +7 -3
  217. package/dist/lib/slatejs-edits/replace-text.mjs.map +1 -1
  218. package/dist/lib/slatejs-edits/with-partial-history.d.ts +10 -0
  219. package/dist/lib/slatejs-edits/with-partial-history.mjs +9 -3
  220. package/dist/lib/slatejs-edits/with-partial-history.mjs.map +1 -1
  221. package/dist/lib/stream-promise-flatten.d.ts +12 -0
  222. package/dist/lib/stream-promise-flatten.mjs +7 -3
  223. package/dist/lib/stream-promise-flatten.mjs.map +1 -1
  224. package/dist/lib/utils.d.ts +10 -0
  225. package/dist/lib/utils.mjs +17 -3
  226. package/dist/lib/utils.mjs.map +1 -1
  227. package/dist/lib/utils.test.d.ts +1 -0
  228. package/dist/lib/utils.test.mjs +0 -1
  229. package/dist/lib/utils.test.mjs.map +1 -1
  230. package/dist/types/autosuggestions-config/autosuggestions-config-user-specified.d.ts +23 -0
  231. package/dist/types/autosuggestions-config/autosuggestions-config-user-specified.mjs +0 -2
  232. package/dist/types/autosuggestions-config/autosuggestions-config-user-specified.mjs.map +1 -1
  233. package/dist/types/autosuggestions-config/autosuggestions-config.d.ts +20 -0
  234. package/dist/types/autosuggestions-config/autosuggestions-config.mjs +12 -8
  235. package/dist/types/autosuggestions-config/autosuggestions-config.mjs.map +1 -1
  236. package/dist/types/autosuggestions-config/editing-api-config.d.ts +15 -0
  237. package/dist/types/autosuggestions-config/editing-api-config.mjs +11 -3
  238. package/dist/types/autosuggestions-config/editing-api-config.mjs.map +1 -1
  239. package/dist/types/autosuggestions-config/index.d.ts +11 -0
  240. package/dist/types/autosuggestions-config/index.mjs +17 -10
  241. package/dist/types/autosuggestions-config/index.mjs.map +1 -1
  242. package/dist/types/autosuggestions-config/insertions-api-config.d.ts +15 -0
  243. package/dist/types/autosuggestions-config/insertions-api-config.mjs +11 -3
  244. package/dist/types/autosuggestions-config/insertions-api-config.mjs.map +1 -1
  245. package/dist/types/autosuggestions-config/subtypes/chatlike-api-endpoint.d.ts +27 -0
  246. package/dist/types/autosuggestions-config/subtypes/chatlike-api-endpoint.mjs +7 -3
  247. package/dist/types/autosuggestions-config/subtypes/chatlike-api-endpoint.mjs.map +1 -1
  248. package/dist/types/autosuggestions-config/subtypes/make-system-prompt.d.ts +3 -0
  249. package/dist/types/autosuggestions-config/subtypes/make-system-prompt.mjs +0 -2
  250. package/dist/types/autosuggestions-config/subtypes/make-system-prompt.mjs.map +1 -1
  251. package/dist/types/autosuggestions-config/subtypes/minimal-chat-gpt-message.d.ts +7 -0
  252. package/dist/types/autosuggestions-config/subtypes/minimal-chat-gpt-message.mjs +0 -2
  253. package/dist/types/autosuggestions-config/subtypes/minimal-chat-gpt-message.mjs.map +1 -1
  254. package/dist/types/autosuggestions-config/suggestions-api-config.d.ts +15 -0
  255. package/dist/types/autosuggestions-config/suggestions-api-config.mjs +11 -3
  256. package/dist/types/autosuggestions-config/suggestions-api-config.mjs.map +1 -1
  257. package/dist/types/base/autosuggestion-state.d.ts +8 -0
  258. package/dist/types/base/autosuggestion-state.mjs +0 -2
  259. package/dist/types/base/autosuggestion-state.mjs.map +1 -1
  260. package/dist/types/base/autosuggestions-bare-function.d.ts +19 -0
  261. package/dist/types/base/autosuggestions-bare-function.mjs +0 -2
  262. package/dist/types/base/autosuggestions-bare-function.mjs.map +1 -1
  263. package/dist/types/base/base-autosuggestions-config.d.ts +16 -0
  264. package/dist/types/base/base-autosuggestions-config.mjs +7 -3
  265. package/dist/types/base/base-autosuggestions-config.mjs.map +1 -1
  266. package/dist/types/base/base-copilot-textarea-props.d.ts +41 -0
  267. package/dist/types/base/base-copilot-textarea-props.mjs +0 -2
  268. package/dist/types/base/base-copilot-textarea-props.mjs.map +1 -1
  269. package/dist/types/base/custom-editor.d.ts +29 -0
  270. package/dist/types/base/custom-editor.mjs +0 -2
  271. package/dist/types/base/custom-editor.mjs.map +1 -1
  272. package/dist/types/base/editor-autocomplete-state.d.ts +10 -0
  273. package/dist/types/base/editor-autocomplete-state.mjs +8 -4
  274. package/dist/types/base/editor-autocomplete-state.mjs.map +1 -1
  275. package/dist/types/base/index.d.ts +5 -0
  276. package/dist/types/base/index.mjs +8 -4
  277. package/dist/types/base/index.mjs.map +1 -1
  278. package/dist/types/html-copilot-textarea-element.d.ts +7 -0
  279. package/dist/types/html-copilot-textarea-element.mjs +1 -2
  280. package/dist/types/html-copilot-textarea-element.mjs.map +1 -1
  281. package/dist/types/index.d.ts +14 -0
  282. package/dist/types/index.mjs +22 -12
  283. package/dist/types/index.mjs.map +1 -1
  284. package/package.json +5 -5
  285. package/dist/chunk-24SYR4JB.mjs.map +0 -1
  286. package/dist/chunk-5DU2QDHZ.mjs.map +0 -1
  287. package/dist/chunk-63FSISXT.mjs.map +0 -1
  288. package/dist/chunk-KLROO6ID.mjs.map +0 -1
  289. package/dist/chunk-O7G7E3E3.mjs.map +0 -1
  290. package/dist/chunk-YXA3UPMI.mjs.map +0 -1
@@ -1,14 +1,35 @@
1
- import { IncludedFilesPreview } from './chunk-63FSISXT.mjs';
2
- import { use_autosize_textarea_default } from './chunk-ND5PXTAW.mjs';
3
- import { Button } from './chunk-2NURR2DX.mjs';
4
- import { Label } from './chunk-5EJ5XOGP.mjs';
5
- import { SourceSearchBox } from './chunk-463BFNUP.mjs';
6
- import { streamPromiseFlatten } from './chunk-GCMQHIRF.mjs';
7
- import { __async } from './chunk-MRXNTQOX.mjs';
8
- import { useContext, useState, useRef, useEffect, useCallback } from 'react';
9
- import { CopilotContext } from '@copilotkit/react-core';
10
- import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
1
+ import {
2
+ IncludedFilesPreview
3
+ } from "./chunk-TIBMW3DC.mjs";
4
+ import {
5
+ use_autosize_textarea_default
6
+ } from "./chunk-ND5PXTAW.mjs";
7
+ import {
8
+ Button
9
+ } from "./chunk-2NURR2DX.mjs";
10
+ import {
11
+ Label
12
+ } from "./chunk-5EJ5XOGP.mjs";
13
+ import {
14
+ SourceSearchBox
15
+ } from "./chunk-463BFNUP.mjs";
16
+ import {
17
+ streamPromiseFlatten
18
+ } from "./chunk-GCMQHIRF.mjs";
19
+ import {
20
+ __async
21
+ } from "./chunk-MRXNTQOX.mjs";
11
22
 
23
+ // src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.tsx
24
+ import {
25
+ useCallback,
26
+ useContext,
27
+ useEffect,
28
+ useRef,
29
+ useState
30
+ } from "react";
31
+ import { CopilotContext } from "@copilotkit/react-core";
32
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
12
33
  var HoveringInsertionPromptBoxCore = ({
13
34
  performInsertion,
14
35
  state,
@@ -219,6 +240,7 @@ var HoveringInsertionPromptBoxCore = ({
219
240
  });
220
241
  };
221
242
 
222
- export { HoveringInsertionPromptBoxCore };
223
- //# sourceMappingURL=out.js.map
224
- //# sourceMappingURL=chunk-O7G7E3E3.mjs.map
243
+ export {
244
+ HoveringInsertionPromptBoxCore
245
+ };
246
+ //# sourceMappingURL=chunk-F4WZCQG6.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.tsx"],"sourcesContent":["import useAutosizeTextArea from \"../../../hooks/misc/use-autosize-textarea\";\nimport { MinimalChatGPTMessage } from \"../../../types\";\nimport {\n EditingEditorState,\n Generator_InsertionOrEditingSuggestion,\n} from \"../../../types/base/autosuggestions-bare-function\";\nimport { SourceSearchBox } from \"../../source-search-box/source-search-box\";\nimport { DocumentPointer } from \"@copilotkit/react-core\";\nimport { Button } from \"../../ui/button\";\nimport { Label } from \"../../ui/label\";\nimport React, {\n useCallback,\n useContext,\n useEffect,\n useRef,\n useState,\n} from \"react\";\n\nimport { streamPromiseFlatten } from \"../../../lib/stream-promise-flatten\";\nimport { CopilotContext } from \"@copilotkit/react-core\";\nimport { IncludedFilesPreview } from \"./included-files-preview\";\n\nexport type SuggestionState = {\n editorState: EditingEditorState;\n};\n\nexport interface HoveringInsertionPromptBoxCoreProps {\n state: SuggestionState;\n performInsertion: (insertedText: string) => void;\n insertionOrEditingFunction: Generator_InsertionOrEditingSuggestion;\n contextCategories: string[];\n}\n\nexport const HoveringInsertionPromptBoxCore: React.FC<\n HoveringInsertionPromptBoxCoreProps\n> = ({\n performInsertion,\n state,\n insertionOrEditingFunction,\n contextCategories,\n}) => {\n const { getDocumentsContext } = useContext(CopilotContext);\n\n const [editSuggestion, setEditSuggestion] = useState<string>(\"\");\n const [suggestionIsLoading, setSuggestionIsLoading] =\n useState<boolean>(false);\n\n const [adjustmentPrompt, setAdjustmentPrompt] = useState<string>(\"\");\n\n const [generatingSuggestion, setGeneratingSuggestion] =\n useState<ReadableStream<string> | null>(null);\n\n const adjustmentTextAreaRef = useRef<HTMLTextAreaElement>(null);\n const suggestionTextAreaRef = useRef<HTMLTextAreaElement>(null);\n\n const [filePointers, setFilePointers] = useState<DocumentPointer[]>([]);\n\n const [suggestedFiles, setSuggestedFiles] = useState<DocumentPointer[]>([]);\n useEffect(() => {\n setSuggestedFiles(getDocumentsContext(contextCategories));\n }, [contextCategories, getDocumentsContext]);\n\n useAutosizeTextArea(suggestionTextAreaRef, editSuggestion || \"\");\n useAutosizeTextArea(adjustmentTextAreaRef, adjustmentPrompt || \"\");\n\n // initially focus on the adjustment prompt text area\n useEffect(() => {\n adjustmentTextAreaRef.current?.focus();\n }, []);\n\n // continuously read the generating suggestion stream and update the edit suggestion\n useEffect(() => {\n // if no generating suggestion, do nothing\n if (!generatingSuggestion) {\n return;\n }\n\n // Check if the stream is already locked (i.e. already reading from it)\n if (generatingSuggestion.locked) {\n return;\n }\n\n // reset the edit suggestion\n setEditSuggestion(\"\");\n\n // read the generating suggestion stream and continuously update the edit suggestion\n const reader = generatingSuggestion.getReader();\n const read = async () => {\n setSuggestionIsLoading(true);\n while (true) {\n const { done, value } = await reader.read();\n if (done) {\n break;\n }\n setEditSuggestion((prev) => {\n const newSuggestion = prev + value;\n\n // Scroll to the bottom of the textarea. We call this here to make sure scroll-to-bottom is synchronous with the state update.\n if (suggestionTextAreaRef.current) {\n suggestionTextAreaRef.current.scrollTop =\n suggestionTextAreaRef.current.scrollHeight;\n }\n return newSuggestion;\n });\n }\n\n setSuggestionIsLoading(false);\n };\n read();\n\n return () => {\n // release the lock if the reader is not closed on unmount\n const releaseLockIfNotClosed = async () => {\n try {\n await reader.closed;\n } catch {\n reader.releaseLock();\n }\n };\n\n releaseLockIfNotClosed();\n };\n }, [generatingSuggestion]);\n\n // generate an adjustment to the completed text, based on the adjustment prompt\n const beginGeneratingAdjustment = useCallback(async () => {\n // don't generate text if the prompt is empty\n if (!adjustmentPrompt.trim()) {\n return;\n }\n\n // editor state includes the text being edited, and the text before/after the selection\n // if the current edit suggestion is not empty, then use *it* as the \"selected text\" - instead of the editor state's selected text\n let modificationState = state.editorState;\n if (editSuggestion !== \"\") {\n modificationState.selectedText = editSuggestion;\n }\n\n // generate the adjustment suggestion\n const adjustmentSuggestionTextStreamPromise = insertionOrEditingFunction(\n modificationState,\n adjustmentPrompt,\n filePointers,\n new AbortController().signal\n );\n const adjustmentSuggestionTextStream = streamPromiseFlatten(\n adjustmentSuggestionTextStreamPromise\n );\n\n setGeneratingSuggestion(adjustmentSuggestionTextStream);\n }, [\n adjustmentPrompt,\n editSuggestion,\n state.editorState,\n insertionOrEditingFunction,\n filePointers,\n ]);\n\n const isLoading = suggestionIsLoading;\n\n const textToEdit = editSuggestion || state.editorState.selectedText;\n const adjustmentLabel =\n textToEdit === \"\"\n ? \"Describe the text you want to insert\"\n : \"Describe adjustments to the suggested text\";\n const placeholder =\n textToEdit === \"\"\n ? \"e.g. 'summarize the client's top 3 pain-points from @CallTranscript'\"\n : \"e.g. 'make it more formal', 'be more specific', ...\";\n\n const AdjustmentPromptComponent = (\n <>\n <Label className=\"\">{adjustmentLabel}</Label>\n <div className=\"relative w-full flex items-center\">\n <textarea\n disabled={suggestionIsLoading}\n ref={adjustmentTextAreaRef}\n value={adjustmentPrompt}\n onChange={(e) => setAdjustmentPrompt(e.target.value)}\n onKeyDown={(e) => {\n if (e.key === \"Enter\" && e.shiftKey) {\n e.preventDefault();\n setAdjustmentPrompt(adjustmentPrompt + \"\\n\");\n } else if (e.key === \"Enter\") {\n e.preventDefault();\n beginGeneratingAdjustment();\n }\n }}\n placeholder={placeholder}\n style={{ minHeight: \"3rem\" }}\n 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]\"\n rows={1}\n />\n <button\n onClick={beginGeneratingAdjustment}\n className=\"absolute right-2 bg-blue-500 text-white w-8 h-8 rounded-full flex items-center justify-center\"\n >\n <i className=\"material-icons\">arrow_forward</i>\n </button>\n </div>\n </>\n );\n\n const SuggestionComponent = (\n <>\n <div className=\"flex justify-between items-end w-full\">\n <Label className=\"mt-4\">Suggested:</Label>\n <div className=\"ml-auto\">\n {isLoading && (\n <div className=\"flex justify-center items-center\">\n <div\n 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]\"\n role=\"status\"\n >\n <span className=\"!absolute !-m-px !h-px !w-px !overflow-hidden !whitespace-nowrap !border-0 !p-0 ![clip:rect(0,0,0,0)]\">\n Loading...\n </span>\n </div>\n </div>\n )}\n </div>\n </div>\n <textarea\n ref={suggestionTextAreaRef}\n value={editSuggestion}\n disabled={suggestionIsLoading}\n onChange={(e) => setEditSuggestion(e.target.value)}\n className=\"w-full text-base p-2 border border-gray-300 rounded-md resize-none bg-green-50\"\n style={{ overflow: \"auto\", maxHeight: \"10em\" }}\n />\n </>\n );\n\n const SubmitComponent = (\n <div className=\"flex w-full gap-4 justify-start\">\n <Button\n className=\" bg-green-700 text-white\"\n onClick={() => {\n performInsertion(editSuggestion);\n }}\n >\n Insert <i className=\"material-icons\">check</i>\n </Button>\n </div>\n );\n\n // show source search if the last word in the adjustment prompt BEGINS with an @\n const sourceSearchCandidate = adjustmentPrompt.split(\" \").pop();\n // if the candidate is @someCandidate, then 'someCandidate', otherwise undefined\n const sourceSearchWord = sourceSearchCandidate?.startsWith(\"@\")\n ? sourceSearchCandidate.slice(1)\n : undefined;\n\n return (\n <div className=\"w-full flex flex-col items-start relative gap-2\">\n {AdjustmentPromptComponent}\n {filePointers.length > 0 && (\n <IncludedFilesPreview\n includedFiles={filePointers}\n setIncludedFiles={setFilePointers}\n />\n )}\n {sourceSearchWord !== undefined && (\n <SourceSearchBox\n searchTerm={sourceSearchWord}\n suggestedFiles={suggestedFiles}\n onSelectedFile={(filePointer) => {\n setAdjustmentPrompt(\n adjustmentPrompt.replace(new RegExp(`@${sourceSearchWord}$`), \"\")\n );\n setFilePointers((prev) => [...prev, filePointer]);\n\n // focus back on the adjustment prompt, and move the cursor to the end\n adjustmentTextAreaRef.current?.focus();\n }}\n />\n )}\n {generatingSuggestion ? SuggestionComponent : null}\n {generatingSuggestion ? SubmitComponent : null}\n </div>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAUA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP,SAAS,sBAAsB;AAwJ3B,mBACE,KACA,YAFF;AA1IG,IAAM,iCAET,CAAC;AAAA,EACH;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAM;AACJ,QAAM,EAAE,oBAAoB,IAAI,WAAW,cAAc;AAEzD,QAAM,CAAC,gBAAgB,iBAAiB,IAAI,SAAiB,EAAE;AAC/D,QAAM,CAAC,qBAAqB,sBAAsB,IAChD,SAAkB,KAAK;AAEzB,QAAM,CA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,qBAAqB,UACpB,oBAAC;AAAA,QACC,YAAY;AAAA,QACZ;AAAA,QACA,gBAAgB,CAAC,gBAAgB;AA1Q3C;AA2QY;AAAA,YACE,iBAAiB,QAAQ,IAAI,OAAO,IAAI,mBAAmB,GAAG,EAAE;AAAA,UAClE;AACA,0BAAgB,CAAC,SAAS,CAAC,GAAG,MAAM,WAAW,CAAC;AAGhD,sCAAsB,YAAtB,mBAA+B;AAAA,QACjC;AAAA,OACF;AAAA,MAED,uBAAuB,sBAAsB;AAAA,MAC7C,uBAAuB,kBAAkB;AAAA;AAAA,GAC5C;AAEJ;","names":[]}
@@ -1,4 +1,6 @@
1
- import { __async } from './chunk-MRXNTQOX.mjs';
1
+ import {
2
+ __async
3
+ } from "./chunk-MRXNTQOX.mjs";
2
4
 
3
5
  // src/lib/stream-promise-flatten.ts
4
6
  function streamPromiseFlatten(promise) {
@@ -24,6 +26,7 @@ function streamPromiseFlatten(promise) {
24
26
  });
25
27
  }
26
28
 
27
- export { streamPromiseFlatten };
28
- //# sourceMappingURL=out.js.map
29
+ export {
30
+ streamPromiseFlatten
31
+ };
29
32
  //# sourceMappingURL=chunk-GCMQHIRF.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/lib/stream-promise-flatten.ts"],"names":[],"mappings":";;;;;AAUO,SAAS,qBACd,SACmB;AACnB,SAAO,IAAI,eAAkB;AAAA,IACrB,MAAM,YAAY;AAAA;AACtB,YAAI;AACF,gBAAM,SAAS,MAAM;AACrB,gBAAM,SAAS,OAAO,UAAU;AAEhC,iBAAO,MAAM;AACX,kBAAM,EAAE,MAAM,MAAM,IAAI,MAAM,OAAO,KAAK;AAE1C,gBAAI,MAAM;AACR,yBAAW,MAAM;AACjB;AAAA,YACF;AAEA,uBAAW,QAAQ,KAAK;AAAA,UAC1B;AAAA,QACF,SAAS,OAAP;AACA,qBAAW,MAAM,KAAK;AAAA,QACxB;AAAA,MACF;AAAA;AAAA,EACF,CAAC;AACH","sourcesContent":["/**\n * Flatten a promise of a stream, into a stream.\n *\n * Useful because a stream already includes the notion of async value delivery,\n * so it often makes sense to simply await the values rather than the generator of the values.\n *\n * @param {Promise<ReadableStream<A>>} promise - The promise to flatten.\n * @returns {ReadableStream<A>} - The flattened stream.\n */\n\nexport function streamPromiseFlatten<A>(\n promise: Promise<ReadableStream<A>>\n): ReadableStream<A> {\n return new ReadableStream<A>({\n async start(controller) {\n try {\n const stream = await promise;\n const reader = stream.getReader();\n\n while (true) {\n const { done, value } = await reader.read();\n\n if (done) {\n controller.close();\n return;\n }\n\n controller.enqueue(value);\n }\n } catch (error) {\n controller.error(error);\n }\n },\n });\n}\n"]}
1
+ {"version":3,"sources":["../src/lib/stream-promise-flatten.ts"],"sourcesContent":["/**\n * Flatten a promise of a stream, into a stream.\n *\n * Useful because a stream already includes the notion of async value delivery,\n * so it often makes sense to simply await the values rather than the generator of the values.\n *\n * @param {Promise<ReadableStream<A>>} promise - The promise to flatten.\n * @returns {ReadableStream<A>} - The flattened stream.\n */\n\nexport function streamPromiseFlatten<A>(\n promise: Promise<ReadableStream<A>>\n): ReadableStream<A> {\n return new ReadableStream<A>({\n async start(controller) {\n try {\n const stream = await promise;\n const reader = stream.getReader();\n\n while (true) {\n const { done, value } = await reader.read();\n\n if (done) {\n controller.close();\n return;\n }\n\n controller.enqueue(value);\n }\n } catch (error) {\n controller.error(error);\n }\n },\n });\n}\n"],"mappings":";;;;;AAUO,SAAS,qBACd,SACmB;AACnB,SAAO,IAAI,eAAkB;AAAA,IACrB,MAAM,YAAY;AAAA;AACtB,YAAI;AACF,gBAAM,SAAS,MAAM;AACrB,gBAAM,SAAS,OAAO,UAAU;AAEhC,iBAAO,MAAM;AACX,kBAAM,EAAE,MAAM,MAAM,IAAI,MAAM,OAAO,KAAK;AAE1C,gBAAI,MAAM;AACR,yBAAW,MAAM;AACjB;AAAA,YACF;AAEA,uBAAW,QAAQ,KAAK;AAAA,UAC1B;AAAA,QACF,SAAS,OAAP;AACA,qBAAW,MAAM,KAAK;AAAA,QACxB;AAAA,MACF;AAAA;AAAA,EACF,CAAC;AACH;","names":[]}
@@ -1,3 +1 @@
1
-
2
- //# sourceMappingURL=out.js.map
3
1
  //# sourceMappingURL=chunk-H4VKQGVU.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":""}
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,12 +1,25 @@
1
- import { useMakeStandardAutosuggestionFunction } from './chunk-DYGPLRY3.mjs';
2
- import { useMakeStandardInsertionOrEditingFunction } from './chunk-WPIA53HF.mjs';
3
- import { defaultAutosuggestionsConfig } from './chunk-F2TIBXML.mjs';
4
- import { BaseCopilotTextarea } from './chunk-YXA3UPMI.mjs';
5
- import { __objRest, __spreadProps, __spreadValues } from './chunk-MRXNTQOX.mjs';
6
- import React from 'react';
7
- import merge from 'lodash.merge';
8
- import { jsx, Fragment } from 'react/jsx-runtime';
1
+ import {
2
+ useMakeStandardAutosuggestionFunction
3
+ } from "./chunk-DYGPLRY3.mjs";
4
+ import {
5
+ useMakeStandardInsertionOrEditingFunction
6
+ } from "./chunk-WPIA53HF.mjs";
7
+ import {
8
+ defaultAutosuggestionsConfig
9
+ } from "./chunk-F2TIBXML.mjs";
10
+ import {
11
+ BaseCopilotTextarea
12
+ } from "./chunk-34D4UIYX.mjs";
13
+ import {
14
+ __objRest,
15
+ __spreadProps,
16
+ __spreadValues
17
+ } from "./chunk-MRXNTQOX.mjs";
9
18
 
19
+ // src/components/copilot-textarea/copilot-textarea.tsx
20
+ import React from "react";
21
+ import merge from "lodash.merge";
22
+ import { Fragment, jsx } from "react/jsx-runtime";
10
23
  var CopilotTextarea = React.forwardRef(
11
24
  (props, ref) => {
12
25
  const _a = props, {
@@ -44,6 +57,7 @@ var CopilotTextarea = React.forwardRef(
44
57
  }
45
58
  );
46
59
 
47
- export { CopilotTextarea };
48
- //# sourceMappingURL=out.js.map
49
- //# sourceMappingURL=chunk-24SYR4JB.mjs.map
60
+ export {
61
+ CopilotTextarea
62
+ };
63
+ //# sourceMappingURL=chunk-IPM5WWPW.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/copilot-textarea/copilot-textarea.tsx"],"sourcesContent":["// This example is for an Editor with `ReactEditor` and `HistoryEditor`\nimport React from \"react\";\nimport { useMakeStandardAutosuggestionFunction } from \"../../hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function\";\nimport { HTMLCopilotTextAreaElement } from \"../../types\";\nimport { BaseCopilotTextareaProps } from \"../../types/base/base-copilot-textarea-props\";\nimport {\n AutosuggestionsConfig,\n defaultAutosuggestionsConfig,\n} from \"../../types/autosuggestions-config\";\nimport { BaseCopilotTextarea } from \"../base-copilot-textarea/base-copilot-textarea\";\nimport { useMakeStandardInsertionOrEditingFunction } from \"../../hooks/make-autosuggestions-function/use-make-standard-insertion-function\";\nimport merge from \"lodash.merge\";\nimport { AutosuggestionsConfigUserSpecified } from \"../../types/autosuggestions-config/autosuggestions-config-user-specified\";\n\n// Like the base copilot textarea props,\n// but with baseAutosuggestionsConfig replaced with autosuggestionsConfig.\nexport interface CopilotTextareaProps\n extends Omit<BaseCopilotTextareaProps, \"baseAutosuggestionsConfig\"> {\n autosuggestionsConfig: AutosuggestionsConfigUserSpecified;\n}\n\nexport const CopilotTextarea = React.forwardRef(\n (\n props: CopilotTextareaProps,\n ref: React.Ref<HTMLCopilotTextAreaElement>\n ): JSX.Element => {\n // separate the AutosuggestionsConfigUserSpecified from the rest of the props\n const {\n autosuggestionsConfig: autosuggestionsConfigUserSpecified,\n ...forwardedProps\n } = props;\n\n const autosuggestionsConfig: AutosuggestionsConfig = merge(\n defaultAutosuggestionsConfig,\n autosuggestionsConfigUserSpecified\n );\n\n const autosuggestionsFunction = useMakeStandardAutosuggestionFunction(\n autosuggestionsConfig.textareaPurpose,\n autosuggestionsConfig.externalContextCategories,\n autosuggestionsConfig.chatApiConfigs.suggestionsApiConfig\n );\n\n const insertionOrEditingFunction =\n useMakeStandardInsertionOrEditingFunction(\n autosuggestionsConfig.textareaPurpose,\n autosuggestionsConfig.externalContextCategories,\n autosuggestionsConfig.chatApiConfigs.insertionApiConfig,\n autosuggestionsConfig.chatApiConfigs.editingApiConfig\n );\n\n return (\n <>\n <BaseCopilotTextarea\n ref={ref}\n {...forwardedProps}\n baseAutosuggestionsConfig={{\n ...autosuggestionsConfig,\n apiConfig: {\n insertionOrEditingFunction: insertionOrEditingFunction,\n autosuggestionsFunction: autosuggestionsFunction,\n },\n }}\n />\n </>\n );\n }\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;AACA,OAAO,WAAW;AAUlB,OAAO,WAAW;AAyCZ,mBACE,WADF;AA/BC,IAAM,kBAAkB,MAAM;AAAA,EACnC,CACE,OACA,QACgB;AAEhB,UAGI,YAFF;AAAA,6BAAuB;AAAA,IA5B7B,IA8BQ,IADC,2BACD,IADC;AAAA,MADH;AAAA;AAIF,UAAM,wBAA+C;AAAA,MACnD;AAAA,MACA;AAAA,IACF;AAEA,UAAM,0BAA0B;AAAA,MAC9B,sBAAsB;AAAA,MACtB,sBAAsB;AAAA,MACtB,sBAAsB,eAAe;AAAA,IACvC;AAEA,UAAM,6BACJ;AAAA,MACE,sBAAsB;AAAA,MACtB,sBAAsB;AAAA,MACtB,sBAAsB,eAAe;AAAA,MACrC,sBAAsB,eAAe;AAAA,IACvC;AAEF,WACE;AAAA,MACE,8BAAC;AAAA,QACC;AAAA,SACI,iBAFL;AAAA,QAGC,2BAA2B,iCACtB,wBADsB;AAAA,UAEzB,WAAW;AAAA,YACT;AAAA,YACA;AAAA,UACF;AAAA,QACF;AAAA,QACF;AAAA,KACF;AAAA,EAEJ;AACF;","names":[]}
@@ -1,3 +1 @@
1
-
2
- //# sourceMappingURL=out.js.map
3
1
  //# sourceMappingURL=chunk-IU3WTXLQ.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":""}
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,6 +1,12 @@
1
- import { Range, Editor, Text, Element, Path, Point } from 'slate';
2
-
3
1
  // src/lib/get-text-around-cursor.ts
2
+ import {
3
+ Editor,
4
+ Path,
5
+ Range,
6
+ Text,
7
+ Element,
8
+ Point
9
+ } from "slate";
4
10
  function getTextAroundCollapsedCursor(editor) {
5
11
  const { selection } = editor;
6
12
  if (!selection || !Range.isCollapsed(selection)) {
@@ -96,6 +102,10 @@ function wellOrderedRange(range) {
96
102
  };
97
103
  }
98
104
 
99
- export { extractTextWithNewlines, getFullEditorTextWithNewlines, getTextAroundCollapsedCursor, getTextAroundSelection };
100
- //# sourceMappingURL=out.js.map
105
+ export {
106
+ getTextAroundCollapsedCursor,
107
+ getTextAroundSelection,
108
+ getFullEditorTextWithNewlines,
109
+ extractTextWithNewlines
110
+ };
101
111
  //# sourceMappingURL=chunk-IXJ2HCOA.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/lib/get-text-around-cursor.ts"],"names":[],"mappings":";AAAA;AAAA,EACE;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAGA;AAAA,OACK;AAWA,SAAS,6BACd,QACgC;AAChC,QAAM,EAAE,UAAU,IAAI;AACtB,MAAI,CAAC,aAAa,CAAC,MAAM,YAAY,SAAS,GAAG;AAC/C,WAAO;AAAA,EACT;AAEA,QAAM,cAAc,UAAU;AAG9B,QAAM,cAAqB;AAAA,IACzB,QAAQ,OAAO,MAAM,QAAQ,CAAC,CAAC;AAAA,IAC/B,OAAO;AAAA,EACT;AACA,QAAM,aAAoB;AAAA,IACxB,QAAQ;AAAA,IACR,OAAO,OAAO,IAAI,QAAQ,CAAC,CAAC;AAAA,EAC9B;AAGA,QAAM,SAAS,wBAAwB,QAAQ,WAAW;AAC1D,QAAM,QAAQ,wBAAwB,QAAQ,UAAU;AAExD,SAAO;AAAA,IACL;AAAA,IACA,kBAAkB;AAAA,IAClB,iBAAiB;AAAA,EACnB;AACF;AAEO,S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AC,KAAK,CAAC,IAAI;AAGX,QAAI,cAAc,SAAS,OAAO;AAEhC,UAAI,WAAW;AACb,gBAAQ;AAAA,MACV;AACA,kBAAY;AAAA,IACd;AAEA,QAAI,KAAK,OAAO,MAAM,IAAI,IAAI,GAAG;AAC/B,UAAI,EAAE,MAAM,GAAG,IAAI,MAAM;AAAA,IAC3B;AAEA,QAAI,KAAK,OAAO,MAAM,MAAM,IAAI,GAAG;AACjC,UAAI,EAAE,MAAM,MAAM,MAAM;AAAA,IAC1B;AAEA,YAAQ;AAAA,EACV;AAEA,SAAO;AACT;AAEA,SAAS,iBAAiB,OAA6B;AACrD,QAAM,EAAE,QAAQ,MAAM,IAAI;AAE1B,MAAI,MAAM,SAAS,QAAQ,KAAK,GAAG;AACjC,WAAO;AAAA,EACT;AAGA,SAAO;AAAA,IACL,QAAQ;AAAA,IACR,OAAO;AAAA,EACT;AACF","sourcesContent":["import {\n Editor,\n Node,\n Path,\n Range,\n Text,\n Element,\n BasePoint,\n BaseRange,\n Point,\n} from \"slate\";\nimport { EditorAutocompleteState } from \"../types/base/editor-autocomplete-state\";\n\nexport interface EditorTextState {\n selection: BaseRange;\n\n textBeforeCursor: string;\n selectedText: string;\n textAfterCursor: string;\n}\n\nexport function getTextAroundCollapsedCursor(\n editor: Editor\n): EditorAutocompleteState | null {\n const { selection } = editor;\n if (!selection || !Range.isCollapsed(selection)) {\n return null;\n }\n\n const cursorPoint = selection.anchor;\n\n // Create two ranges: one before the anchor and one after\n const beforeRange: Range = {\n anchor: Editor.start(editor, []),\n focus: cursorPoint,\n };\n const afterRange: Range = {\n anchor: cursorPoint,\n focus: Editor.end(editor, []),\n };\n\n // Extract text for these ranges\n const before = extractTextWithNewlines(editor, beforeRange);\n const after = extractTextWithNewlines(editor, afterRange);\n\n return {\n cursorPoint: cursorPoint,\n textBeforeCursor: before,\n textAfterCursor: after,\n };\n}\n\nexport function getTextAroundSelection(editor: Editor): EditorTextState | null {\n const { selection } = editor;\n if (!selection) {\n return null;\n }\n\n const wellOrderedSelection = wellOrderedRange(selection);\n\n // Create two ranges: one before the anchor and one after\n const beforeRange: Range = {\n anchor: Editor.start(editor, []),\n focus: wellOrderedSelection.anchor,\n };\n const afterRange: Range = {\n anchor: wellOrderedSelection.focus,\n focus: Editor.end(editor, []),\n };\n\n // Extract text for these ranges\n const before = extractTextWithNewlines(editor, beforeRange);\n const after = extractTextWithNewlines(editor, afterRange);\n const selectedText = extractTextWithNewlines(editor, wellOrderedSelection);\n\n return {\n selection: wellOrderedSelection,\n textBeforeCursor: before,\n selectedText,\n textAfterCursor: after,\n };\n}\n\nexport function getFullEditorTextWithNewlines(editor: Editor): string {\n const fullDocumentRange: Range = {\n anchor: Editor.start(editor, []),\n focus: Editor.end(editor, []),\n };\n return extractTextWithNewlines(editor, fullDocumentRange);\n}\n\n// Helper function to extract text with newlines\nexport function extractTextWithNewlines(editor: Editor, range: Range): string {\n const voids = false;\n const [start, end] = Range.edges(range);\n let text = \"\";\n let lastBlock: Node | null = null;\n\n for (const [node, path] of Editor.nodes(editor, {\n at: range,\n match: Text.isText,\n voids,\n })) {\n let t = node.text;\n\n // Determine the parent block of the current text node\n const [block] = Editor.above(editor, {\n at: path,\n match: (n) => Element.isElement(n) && n.type === \"paragraph\",\n }) || [null];\n\n // If we encounter a new block, prepend a newline\n if (lastBlock !== block && block) {\n // check that lastBlock is not null to avoid adding a newline at the beginning\n if (lastBlock) {\n text += \"\\n\";\n }\n lastBlock = block;\n }\n\n if (Path.equals(path, end.path)) {\n t = t.slice(0, end.offset);\n }\n\n if (Path.equals(path, start.path)) {\n t = t.slice(start.offset);\n }\n\n text += t;\n }\n\n return text;\n}\n\nfunction wellOrderedRange(range: BaseRange): BaseRange {\n const { anchor, focus } = range;\n // if anchor is before focus, return range as is\n if (Point.isBefore(anchor, focus)) {\n return range;\n }\n\n // if focus is before anchor, return range with anchor and focus swapped\n return {\n anchor: focus,\n focus: anchor,\n };\n}\n"]}
1
+ {"version":3,"sources":["../src/lib/get-text-around-cursor.ts"],"sourcesContent":["import {\n Editor,\n Node,\n Path,\n Range,\n Text,\n Element,\n BasePoint,\n BaseRange,\n Point,\n} from \"slate\";\nimport { EditorAutocompleteState } from \"../types/base/editor-autocomplete-state\";\n\nexport interface EditorTextState {\n selection: BaseRange;\n\n textBeforeCursor: string;\n selectedText: string;\n textAfterCursor: string;\n}\n\nexport function getTextAroundCollapsedCursor(\n editor: Editor\n): EditorAutocompleteState | null {\n const { selection } = editor;\n if (!selection || !Range.isCollapsed(selection)) {\n return null;\n }\n\n const cursorPoint = selection.anchor;\n\n // Create two ranges: one before the anchor and one after\n const beforeRange: Range = {\n anchor: Editor.start(editor, []),\n focus: cursorPoint,\n };\n const afterRange: Range = {\n anchor: cursorPoint,\n focus: Editor.end(editor, []),\n };\n\n // Extract text for these ranges\n const before = extractTextWithNewlines(editor, beforeRange);\n const after = extractTextWithNewlines(editor, afterRange);\n\n return {\n cursorPoint: cursorPoint,\n textBeforeCursor: before,\n textAfterCursor: after,\n };\n}\n\nexport function getTextAroundSelection(editor: Editor): EditorTextState | null {\n const { selection } = editor;\n if (!selection) {\n return null;\n }\n\n const wellOrderedSelection = wellOrderedRange(selection);\n\n // Create two ranges: one before the anchor and one after\n const beforeRange: Range = {\n anchor: Editor.start(editor, []),\n focus: wellOrderedSelection.anchor,\n };\n const afterRange: Range = {\n anchor: wellOrderedSelection.focus,\n focus: Editor.end(editor, []),\n };\n\n // Extract text for these ranges\n const before = extractTextWithNewlines(editor, beforeRange);\n const after = extractTextWithNewlines(editor, afterRange);\n const selectedText = extractTextWithNewlines(editor, wellOrderedSelection);\n\n return {\n selection: wellOrderedSelection,\n textBeforeCursor: before,\n selectedText,\n textAfterCursor: after,\n };\n}\n\nexport function getFullEditorTextWithNewlines(editor: Editor): string {\n const fullDocumentRange: Range = {\n anchor: Editor.start(editor, []),\n focus: Editor.end(editor, []),\n };\n return extractTextWithNewlines(editor, fullDocumentRange);\n}\n\n// Helper function to extract text with newlines\nexport function extractTextWithNewlines(editor: Editor, range: Range): string {\n const voids = false;\n const [start, end] = Range.edges(range);\n let text = \"\";\n let lastBlock: Node | null = null;\n\n for (const [node, path] of Editor.nodes(editor, {\n at: range,\n match: Text.isText,\n voids,\n })) {\n let t = node.text;\n\n // Determine the parent block of the current text node\n const [block] = Editor.above(editor, {\n at: path,\n match: (n) => Element.isElement(n) && n.type === \"paragraph\",\n }) || [null];\n\n // If we encounter a new block, prepend a newline\n if (lastBlock !== block && block) {\n // check that lastBlock is not null to avoid adding a newline at the beginning\n if (lastBlock) {\n text += \"\\n\";\n }\n lastBlock = block;\n }\n\n if (Path.equals(path, end.path)) {\n t = t.slice(0, end.offset);\n }\n\n if (Path.equals(path, start.path)) {\n t = t.slice(start.offset);\n }\n\n text += t;\n }\n\n return text;\n}\n\nfunction wellOrderedRange(range: BaseRange): BaseRange {\n const { anchor, focus } = range;\n // if anchor is before focus, return range as is\n if (Point.isBefore(anchor, focus)) {\n return range;\n }\n\n // if focus is before anchor, return range with anchor and focus swapped\n return {\n anchor: focus,\n focus: anchor,\n };\n}\n"],"mappings":";AAAA;AAAA,EACE;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAGA;AAAA,OACK;AAWA,SAAS,6BACd,QACgC;AAChC,QAAM,EAAE,UAAU,IAAI;AACtB,MAAI,CAAC,aAAa,CAAC,MAAM,YAAY,SAAS,GAAG;AAC/C,WAAO;AAAA,EACT;AAEA,QAAM,cAAc,UAAU;AAG9B,QAAM,cAAqB;AAAA,IACzB,QAAQ,OAAO,MAAM,QAAQ,CAAC,CAAC;AAAA,IAC/B,OAAO;AAAA,EACT;AACA,QAAM,aAAoB;AAAA,IACxB,QAAQ;AAAA,IACR,OAAO,OAAO,IAAI,QAAQ,CAAC,CAAC;AAAA,EAC9B;AAGA,QAAM,SAAS,wBAAwB,QAAQ,WAAW;AAC1D,QAAM,QAAQ,wBAAwB,QAAQ,UAAU;AAExD,SAAO;AAAA,IACL;AAAA,IACA,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,QAAQ,UAAU,CAAC,KAAK,EAAE,SAAS;AAAA,IACnD,CAAC,KAAK,CAAC,IAAI;AAGX,QAAI,cAAc,SAAS,OAAO;AAEhC,UAAI,WAAW;AACb,gBAAQ;AAAA,MACV;AACA,kBAAY;AAAA,IACd;AAEA,QAAI,KAAK,OAAO,MAAM,IAAI,IAAI,GAAG;AAC/B,UAAI,EAAE,MAAM,GAAG,IAAI,MAAM;AAAA,IAC3B;AAEA,QAAI,KAAK,OAAO,MAAM,MAAM,IAAI,GAAG;AACjC,UAAI,EAAE,MAAM,MAAM,MAAM;AAAA,IAC1B;AAEA,YAAQ;AAAA,EACV;AAEA,SAAO;AACT;AAEA,SAAS,iBAAiB,OAA6B;AACrD,QAAM,EAAE,QAAQ,MAAM,IAAI;AAE1B,MAAI,MAAM,SAAS,QAAQ,KAAK,GAAG;AACjC,WAAO;AAAA,EACT;AAGA,SAAO;AAAA,IACL,QAAQ;AAAA,IACR,OAAO;AAAA,EACT;AACF;","names":[]}
@@ -1,10 +1,13 @@
1
- import { arraysAreEqual } from './chunk-KGKLUWKW.mjs';
1
+ import {
2
+ arraysAreEqual
3
+ } from "./chunk-KGKLUWKW.mjs";
2
4
 
3
5
  // src/types/base/editor-autocomplete-state.ts
4
6
  function areEqual_autocompleteState(prev, next) {
5
7
  return prev.cursorPoint.offset === next.cursorPoint.offset && arraysAreEqual(prev.cursorPoint.path, next.cursorPoint.path) && prev.textBeforeCursor === next.textBeforeCursor && prev.textAfterCursor === next.textAfterCursor;
6
8
  }
7
9
 
8
- export { areEqual_autocompleteState };
9
- //# sourceMappingURL=out.js.map
10
+ export {
11
+ areEqual_autocompleteState
12
+ };
10
13
  //# sourceMappingURL=chunk-JAFCXEPU.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/types/base/editor-autocomplete-state.ts"],"names":[],"mappings":";;;;;AASO,SAAS,2BACd,MACA,MACA;AACA,SACE,KAAK,YAAY,WAAW,KAAK,YAAY,UAC7C,eAAe,KAAK,YAAY,MAAM,KAAK,YAAY,IAAI,KAC3D,KAAK,qBAAqB,KAAK,oBAC/B,KAAK,oBAAoB,KAAK;AAElC","sourcesContent":["import { BasePoint } from \"slate\";\nimport { arraysAreEqual } from \"../../lib/utils\";\n\nexport interface EditorAutocompleteState {\n cursorPoint: BasePoint;\n textBeforeCursor: string;\n textAfterCursor: string;\n}\n\nexport function areEqual_autocompleteState(\n prev: EditorAutocompleteState,\n next: EditorAutocompleteState\n) {\n return (\n prev.cursorPoint.offset === next.cursorPoint.offset &&\n arraysAreEqual(prev.cursorPoint.path, next.cursorPoint.path) &&\n prev.textBeforeCursor === next.textBeforeCursor &&\n prev.textAfterCursor === next.textAfterCursor\n );\n}\n"]}
1
+ {"version":3,"sources":["../src/types/base/editor-autocomplete-state.ts"],"sourcesContent":["import { BasePoint } from \"slate\";\nimport { arraysAreEqual } from \"../../lib/utils\";\n\nexport interface EditorAutocompleteState {\n cursorPoint: BasePoint;\n textBeforeCursor: string;\n textAfterCursor: string;\n}\n\nexport function areEqual_autocompleteState(\n prev: EditorAutocompleteState,\n next: EditorAutocompleteState\n) {\n return (\n prev.cursorPoint.offset === next.cursorPoint.offset &&\n arraysAreEqual(prev.cursorPoint.path, next.cursorPoint.path) &&\n prev.textBeforeCursor === next.textBeforeCursor &&\n prev.textAfterCursor === next.textAfterCursor\n );\n}\n"],"mappings":";;;;;AASO,SAAS,2BACd,MACA,MACA;AACA,SACE,KAAK,YAAY,WAAW,KAAK,YAAY,UAC7C,eAAe,KAAK,YAAY,MAAM,KAAK,YAAY,IAAI,KAC3D,KAAK,qBAAqB,KAAK,oBAC/B,KAAK,oBAAoB,KAAK;AAElC;","names":[]}
@@ -58,6 +58,9 @@ var defaultSuggestionsApiConfig = {
58
58
  forwardedParams: void 0
59
59
  };
60
60
 
61
- export { defaultSuggestionsApiConfig, defaultSuggestionsFewShotMessages, defaultSuggestionsMakeSystemPrompt };
62
- //# sourceMappingURL=out.js.map
61
+ export {
62
+ defaultSuggestionsMakeSystemPrompt,
63
+ defaultSuggestionsFewShotMessages,
64
+ defaultSuggestionsApiConfig
65
+ };
63
66
  //# sourceMappingURL=chunk-JHTAOLEW.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/types/autosuggestions-config/suggestions-api-config.tsx"],"names":[],"mappings":";AASO,IAAM,qCAAuD,CAClE,iBACA,kBACG;AACH,SAAO;AAAA;AAAA;AAAA,mBAGW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAgBlB;AAAA;AAAA;AAGF;AAEO,IAAM,oCAA6D;AAAA,EACxE;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SACE;AAAA,EACJ;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,SAAS;AAAA,EACX;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,SACE;AAAA,EACJ;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SACE;AAAA,EACJ;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SACE;AAAA,EACJ;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,SACE;AAAA,EACJ;AACF;AAEO,IAAM,8BAAoD;AAAA,EAC/D,kBAAkB;AAAA,EAClB,iBAAiB;AAAA,EACjB,iBAAiB;AACnB","sourcesContent":["import { MinimalChatGPTMessage } from \"./subtypes/minimal-chat-gpt-message\";\nimport { MakeSystemPrompt } from \"./subtypes/make-system-prompt\";\n\nexport interface SuggestionsApiConfig {\n makeSystemPrompt: MakeSystemPrompt;\n fewShotMessages: MinimalChatGPTMessage[];\n forwardedParams: { [key: string]: any } | undefined;\n}\n\nexport const defaultSuggestionsMakeSystemPrompt: MakeSystemPrompt = (\n textareaPurpose,\n contextString\n) => {\n return `You are a versatile writing assistant.\n \nThe user is writing some text.\nThe purpose is: \\\"${textareaPurpose}\\\"\n\nYour job is to guess what the user will write next AS BEST YOU CAN.\nOnly guess a SHORT distance ahead. Usually 1 sentence, or at most 1 paragraph.\n\nAdjust yourself to the user's style and implied intent.\n\nThe 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.\n<TextAfterCursor>\n<TextBeforeCursor>\n<YourSuggestion>\n\nIf we need to add a whitespace character to the suggested text, make sure to explicitly add it in.\n\nThe following external context is also provided. Use it to help you make better suggestions!!!\n\\`\\`\\`\n${contextString}\n\\`\\`\\`\n`;\n};\n\nexport const defaultSuggestionsFewShotMessages: MinimalChatGPTMessage[] = [\n {\n role: \"user\",\n name: \"TextAfterCursor\",\n content:\n \"While I was there I also picked up some apples, oranges, and bananas.\",\n },\n {\n role: \"user\",\n content: \"This morning I woke up and went straight to the grocery store.\",\n },\n {\n role: \"assistant\",\n content:\n \" When I arrived I went straight to the produce section and picked out a big watermelon. \",\n },\n {\n role: \"user\",\n name: \"TextAfterCursor\",\n content:\n \"and (iii) to the appointment of the Equityholders' Representative pursuant to Section 10.7 of the Merger Agreement and to the provisions thereof.\",\n },\n {\n role: \"user\",\n name: \"TextBeforeCursor\",\n content:\n '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;',\n },\n {\n role: \"assistant\",\n content:\n ' (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\"; ',\n },\n];\n\nexport const defaultSuggestionsApiConfig: SuggestionsApiConfig = {\n makeSystemPrompt: defaultSuggestionsMakeSystemPrompt,\n fewShotMessages: defaultSuggestionsFewShotMessages,\n forwardedParams: undefined,\n};\n"]}
1
+ {"version":3,"sources":["../src/types/autosuggestions-config/suggestions-api-config.tsx"],"sourcesContent":["import { MinimalChatGPTMessage } from \"./subtypes/minimal-chat-gpt-message\";\nimport { MakeSystemPrompt } from \"./subtypes/make-system-prompt\";\n\nexport interface SuggestionsApiConfig {\n makeSystemPrompt: MakeSystemPrompt;\n fewShotMessages: MinimalChatGPTMessage[];\n forwardedParams: { [key: string]: any } | undefined;\n}\n\nexport const defaultSuggestionsMakeSystemPrompt: MakeSystemPrompt = (\n textareaPurpose,\n contextString\n) => {\n return `You are a versatile writing assistant.\n \nThe user is writing some text.\nThe purpose is: \\\"${textareaPurpose}\\\"\n\nYour job is to guess what the user will write next AS BEST YOU CAN.\nOnly guess a SHORT distance ahead. Usually 1 sentence, or at most 1 paragraph.\n\nAdjust yourself to the user's style and implied intent.\n\nThe 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.\n<TextAfterCursor>\n<TextBeforeCursor>\n<YourSuggestion>\n\nIf we need to add a whitespace character to the suggested text, make sure to explicitly add it in.\n\nThe following external context is also provided. Use it to help you make better suggestions!!!\n\\`\\`\\`\n${contextString}\n\\`\\`\\`\n`;\n};\n\nexport const defaultSuggestionsFewShotMessages: MinimalChatGPTMessage[] = [\n {\n role: \"user\",\n name: \"TextAfterCursor\",\n content:\n \"While I was there I also picked up some apples, oranges, and bananas.\",\n },\n {\n role: \"user\",\n content: \"This morning I woke up and went straight to the grocery store.\",\n },\n {\n role: \"assistant\",\n content:\n \" When I arrived I went straight to the produce section and picked out a big watermelon. \",\n },\n {\n role: \"user\",\n name: \"TextAfterCursor\",\n content:\n \"and (iii) to the appointment of the Equityholders' Representative pursuant to Section 10.7 of the Merger Agreement and to the provisions thereof.\",\n },\n {\n role: \"user\",\n name: \"TextBeforeCursor\",\n content:\n '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;',\n },\n {\n role: \"assistant\",\n content:\n ' (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\"; ',\n },\n];\n\nexport const defaultSuggestionsApiConfig: SuggestionsApiConfig = {\n makeSystemPrompt: defaultSuggestionsMakeSystemPrompt,\n fewShotMessages: defaultSuggestionsFewShotMessages,\n forwardedParams: undefined,\n};\n"],"mappings":";AASO,IAAM,qCAAuD,CAClE,iBACA,kBACG;AACH,SAAO;AAAA;AAAA;AAAA,mBAGW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAgBlB;AAAA;AAAA;AAGF;AAEO,IAAM,oCAA6D;AAAA,EACxE;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SACE;AAAA,EACJ;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,SAAS;AAAA,EACX;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,SACE;AAAA,EACJ;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SACE;AAAA,EACJ;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SACE;AAAA,EACJ;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,SACE;AAAA,EACJ;AACF;AAEO,IAAM,8BAAoD;AAAA,EAC/D,kBAAkB;AAAA,EAClB,iBAAiB;AAAA,EACjB,iBAAiB;AACnB;","names":[]}
@@ -1,7 +1,6 @@
1
- import { Transforms, Editor, Operation, Path } from 'slate';
2
- import { HistoryEditor } from 'slate-history';
3
-
4
1
  // src/lib/slatejs-edits/with-partial-history.ts
2
+ import { Editor, Operation, Path, Transforms } from "slate";
3
+ import { HistoryEditor } from "slate-history";
5
4
  var withPartialHistory = (editor, shouldSave) => {
6
5
  const e = editor;
7
6
  const { apply } = e;
@@ -102,6 +101,8 @@ var defaultShouldSave = (op, prev) => {
102
101
  return true;
103
102
  };
104
103
 
105
- export { defaultShouldSave, withPartialHistory };
106
- //# sourceMappingURL=out.js.map
104
+ export {
105
+ withPartialHistory,
106
+ defaultShouldSave
107
+ };
107
108
  //# sourceMappingURL=chunk-KCHYD3EB.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/lib/slatejs-edits/with-partial-history.ts"],"names":[],"mappings":";AAAA,SAAS,QAAQ,WAAW,MAAa,kBAAkB;AAC3D,SAAS,qBAAqB;AASvB,IAAM,qBAAqB,CAChC,QACA,eACG;AACH,QAAM,IAAI;AACV,QAAM,EAAE,MAAM,IAAI;AAClB,IAAE,UAAU,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,EAAE;AAEnC,IAAE,OAAO,MAAM;AACb,UAAM,EAAE,QAAQ,IAAI;AACpB,UAAM,EAAE,MAAM,IAAI;AAElB,QAAI,MAAM,SAAS,GAAG;AACpB,YAAM,QAAQ,MAAM,MAAM,SAAS;AAEnC,UAAI,MAAM,iBAAiB;AACzB,mBAAW,aAAa,GAAG,MAAM,eAAe;AAAA,MAClD;AAEA,oBAAc,cAAc,GAAG,MAAM;AACnC,eAAO,mBAAmB,GAAG,MAAM;AACjC,qBAAW,MAAM,MAAM,YAAY;AACjC,cAAE,MAAM,EAAE;AAAA,UACZ;AAAA,QACF,CAAC;AAAA,MACH,CAAC;AAED,cAAQ,MAAM,IAAI;AAClB,QAAE,aAAa,SAAS,KAAK;AAAA,IAC/B;AAAA,EACF;AAEA,IAAE,OAAO,MAAM;AACb,UAAM,EAAE,QAAQ,IAAI;AACpB,UAAM,EAAE,MAAM,IAAI;AAElB,QAAI,MAAM,SAAS,GAAG;AACpB,YAAM,QAAQ,MAAM,MAAM,SAAS;AAEnC,oBAAc,cAAc,GAAG,MAAM;AACnC,eAAO,mBAAmB,GAAG,MAAM;AACjC,gBAAM,aAAa,MAAM,WAAW,IAAI,UAAU,OAAO,EAAE,QAAQ;AAEnE,qBAAW,MAAM,YAAY;AAC3B,cAAE,MAAM,EAAE;AA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Z,KAAK,SAAS,iBACd,GAAG,WAAW,KAAK,SAAS,KAAK,KAAK,UACtC,KAAK,OAAO,GAAG,MAAM,KAAK,IAAI,GAC9B;AACA,WAAO;AAAA,EACT;AAEA,MACE,QACA,GAAG,SAAS,iBACZ,KAAK,SAAS,iBACd,GAAG,SAAS,GAAG,KAAK,WAAW,KAAK,UACpC,KAAK,OAAO,GAAG,MAAM,KAAK,IAAI,GAC9B;AACA,WAAO;AAAA,EACT;AAEA,SAAO;AACT;AAEO,IAAM,oBAAoB,CAC/B,IACA,SACY;AACZ,MAAI,GAAG,SAAS,iBAAiB;AAC/B,WAAO;AAAA,EACT;AAEA,SAAO;AACT","sourcesContent":["import { Editor, Operation, Path, Range, Transforms } from \"slate\";\nimport { HistoryEditor } from \"slate-history\";\n\n// Copy-pasted from `https://github.com/ianstormtaylor/slate/blob/main/packages/slate-history/src/with-history.ts`\n// With one exception: the `shouldSave` function is passed in as an argument to `withPartialHistory` instead of being hardcoded\nexport type ShouldSaveToHistory = (\n op: Operation,\n prev: Operation | undefined\n) => boolean;\n\nexport const withPartialHistory = <T extends Editor>(\n editor: T,\n shouldSave: ShouldSaveToHistory\n) => {\n const e = editor as T & HistoryEditor;\n const { apply } = e;\n e.history = { undos: [], redos: [] };\n\n e.redo = () => {\n const { history } = e;\n const { redos } = history;\n\n if (redos.length > 0) {\n const batch = redos[redos.length - 1];\n\n if (batch.selectionBefore) {\n Transforms.setSelection(e, batch.selectionBefore);\n }\n\n HistoryEditor.withoutSaving(e, () => {\n Editor.withoutNormalizing(e, () => {\n for (const op of batch.operations) {\n e.apply(op);\n }\n });\n });\n\n history.redos.pop();\n e.writeHistory(\"undos\", batch);\n }\n };\n\n e.undo = () => {\n const { history } = e;\n const { undos } = history;\n\n if (undos.length > 0) {\n const batch = undos[undos.length - 1];\n\n HistoryEditor.withoutSaving(e, () => {\n Editor.withoutNormalizing(e, () => {\n const inverseOps = batch.operations.map(Operation.inverse).reverse();\n\n for (const op of inverseOps) {\n e.apply(op);\n }\n if (batch.selectionBefore) {\n Transforms.setSelection(e, batch.selectionBefore);\n }\n });\n });\n\n e.writeHistory(\"redos\", batch);\n history.undos.pop();\n }\n };\n\n e.apply = (op: Operation) => {\n const { operations, history } = e;\n const { undos } = history;\n const lastBatch = undos[undos.length - 1];\n const lastOp =\n lastBatch && lastBatch.operations[lastBatch.operations.length - 1];\n let save = HistoryEditor.isSaving(e);\n let merge = HistoryEditor.isMerging(e);\n\n if (save == null) {\n save = shouldSave(op, lastOp);\n }\n\n if (save) {\n if (merge == null) {\n if (lastBatch == null) {\n merge = false;\n } else if (operations.length !== 0) {\n merge = true;\n } else {\n merge = shouldMerge(op, lastOp);\n }\n }\n\n if (lastBatch && merge) {\n lastBatch.operations.push(op);\n } else {\n const batch = {\n operations: [op],\n selectionBefore: e.selection,\n };\n e.writeHistory(\"undos\", batch);\n }\n\n while (undos.length > 100) {\n undos.shift();\n }\n\n history.redos = [];\n }\n\n apply(op);\n };\n\n e.writeHistory = (stack: \"undos\" | \"redos\", batch: any) => {\n e.history[stack].push(batch);\n };\n\n return e;\n};\n\n/**\n * Check whether to merge an operation into the previous operation.\n */\n\nconst shouldMerge = (op: Operation, prev: Operation | undefined): boolean => {\n if (\n prev &&\n op.type === \"insert_text\" &&\n prev.type === \"insert_text\" &&\n op.offset === prev.offset + prev.text.length &&\n Path.equals(op.path, prev.path)\n ) {\n return true;\n }\n\n if (\n prev &&\n op.type === \"remove_text\" &&\n prev.type === \"remove_text\" &&\n op.offset + op.text.length === prev.offset &&\n Path.equals(op.path, prev.path)\n ) {\n return true;\n }\n\n return false;\n};\n\nexport const defaultShouldSave = (\n op: Operation,\n prev: Operation | undefined\n): boolean => {\n if (op.type === \"set_selection\") {\n return false;\n }\n\n return true;\n};\n"]}
1
+ {"version":3,"sources":["../src/lib/slatejs-edits/with-partial-history.ts"],"sourcesContent":["import { Editor, Operation, Path, Range, Transforms } from \"slate\";\nimport { HistoryEditor } from \"slate-history\";\n\n// Copy-pasted from `https://github.com/ianstormtaylor/slate/blob/main/packages/slate-history/src/with-history.ts`\n// With one exception: the `shouldSave` function is passed in as an argument to `withPartialHistory` instead of being hardcoded\nexport type ShouldSaveToHistory = (\n op: Operation,\n prev: Operation | undefined\n) => boolean;\n\nexport const withPartialHistory = <T extends Editor>(\n editor: T,\n shouldSave: ShouldSaveToHistory\n) => {\n const e = editor as T & HistoryEditor;\n const { apply } = e;\n e.history = { undos: [], redos: [] };\n\n e.redo = () => {\n const { history } = e;\n const { redos } = history;\n\n if (redos.length > 0) {\n const batch = redos[redos.length - 1];\n\n if (batch.selectionBefore) {\n Transforms.setSelection(e, batch.selectionBefore);\n }\n\n HistoryEditor.withoutSaving(e, () => {\n Editor.withoutNormalizing(e, () => {\n for (const op of batch.operations) {\n e.apply(op);\n }\n });\n });\n\n history.redos.pop();\n e.writeHistory(\"undos\", batch);\n }\n };\n\n e.undo = () => {\n const { history } = e;\n const { undos } = history;\n\n if (undos.length > 0) {\n const batch = undos[undos.length - 1];\n\n HistoryEditor.withoutSaving(e, () => {\n Editor.withoutNormalizing(e, () => {\n const inverseOps = batch.operations.map(Operation.inverse).reverse();\n\n for (const op of inverseOps) {\n e.apply(op);\n }\n if (batch.selectionBefore) {\n Transforms.setSelection(e, batch.selectionBefore);\n }\n });\n });\n\n e.writeHistory(\"redos\", batch);\n history.undos.pop();\n }\n };\n\n e.apply = (op: Operation) => {\n const { operations, history } = e;\n const { undos } = history;\n const lastBatch = undos[undos.length - 1];\n const lastOp =\n lastBatch && lastBatch.operations[lastBatch.operations.length - 1];\n let save = HistoryEditor.isSaving(e);\n let merge = HistoryEditor.isMerging(e);\n\n if (save == null) {\n save = shouldSave(op, lastOp);\n }\n\n if (save) {\n if (merge == null) {\n if (lastBatch == null) {\n merge = false;\n } else if (operations.length !== 0) {\n merge = true;\n } else {\n merge = shouldMerge(op, lastOp);\n }\n }\n\n if (lastBatch && merge) {\n lastBatch.operations.push(op);\n } else {\n const batch = {\n operations: [op],\n selectionBefore: e.selection,\n };\n e.writeHistory(\"undos\", batch);\n }\n\n while (undos.length > 100) {\n undos.shift();\n }\n\n history.redos = [];\n }\n\n apply(op);\n };\n\n e.writeHistory = (stack: \"undos\" | \"redos\", batch: any) => {\n e.history[stack].push(batch);\n };\n\n return e;\n};\n\n/**\n * Check whether to merge an operation into the previous operation.\n */\n\nconst shouldMerge = (op: Operation, prev: Operation | undefined): boolean => {\n if (\n prev &&\n op.type === \"insert_text\" &&\n prev.type === \"insert_text\" &&\n op.offset === prev.offset + prev.text.length &&\n Path.equals(op.path, prev.path)\n ) {\n return true;\n }\n\n if (\n prev &&\n op.type === \"remove_text\" &&\n prev.type === \"remove_text\" &&\n op.offset + op.text.length === prev.offset &&\n Path.equals(op.path, prev.path)\n ) {\n return true;\n }\n\n return false;\n};\n\nexport const defaultShouldSave = (\n op: Operation,\n prev: Operation | undefined\n): boolean => {\n if (op.type === \"set_selection\") {\n return false;\n }\n\n return true;\n};\n"],"mappings":";AAAA,SAAS,QAAQ,WAAW,MAAa,kBAAkB;AAC3D,SAAS,qBAAqB;AASvB,IAAM,qBAAqB,CAChC,QACA,eACG;AACH,QAAM,IAAI;AACV,QAAM,EAAE,MAAM,IAAI;AAClB,IAAE,UAAU,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,EAAE;AAEnC,IAAE,OAAO,MAAM;AACb,UAAM,EAAE,QAAQ,IAAI;AACpB,UAAM,EAAE,MAAM,IAAI;AAElB,QAAI,MAAM,SAAS,GAAG;AACpB,YAAM,QAAQ,MAAM,MAAM,SAAS;AAEnC,UAAI,MAAM,iBAAiB;AACzB,mBAAW,aAAa,GAAG,MAAM,eAAe;AAAA,MAClD;AAEA,oBAAc,cAAc,GAAG,MAAM;AACnC,eAAO,mBAAmB,GAAG,MAAM;AACjC,qBAAW,MAAM,MAAM,YAAY;AACjC,cAAE,MAAM,EAAE;AAAA,UACZ;AAAA,QACF,CAAC;AAAA,MACH,CAAC;AAED,cAAQ,MAAM,IAAI;AAClB,QAA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AA,UACf,iBAAiB,EAAE;AAAA,QACrB;AACA,UAAE,aAAa,SAAS,KAAK;AAAA,MAC/B;AAEA,aAAO,MAAM,SAAS,KAAK;AACzB,cAAM,MAAM;AAAA,MACd;AAEA,cAAQ,QAAQ,CAAC;AAAA,IACnB;AAEA,UAAM,EAAE;AAAA,EACV;AAEA,IAAE,eAAe,CAAC,OAA0B,UAAe;AACzD,MAAE,QAAQ,OAAO,KAAK,KAAK;AAAA,EAC7B;AAEA,SAAO;AACT;AAMA,IAAM,cAAc,CAAC,IAAe,SAAyC;AAC3E,MACE,QACA,GAAG,SAAS,iBACZ,KAAK,SAAS,iBACd,GAAG,WAAW,KAAK,SAAS,KAAK,KAAK,UACtC,KAAK,OAAO,GAAG,MAAM,KAAK,IAAI,GAC9B;AACA,WAAO;AAAA,EACT;AAEA,MACE,QACA,GAAG,SAAS,iBACZ,KAAK,SAAS,iBACd,GAAG,SAAS,GAAG,KAAK,WAAW,KAAK,UACpC,KAAK,OAAO,GAAG,MAAM,KAAK,IAAI,GAC9B;AACA,WAAO;AAAA,EACT;AAEA,SAAO;AACT;AAEO,IAAM,oBAAoB,CAC/B,IACA,SACY;AACZ,MAAI,GAAG,SAAS,iBAAiB;AAC/B,WAAO;AAAA,EACT;AAEA,SAAO;AACT;","names":[]}
@@ -1,8 +1,11 @@
1
- import { __async } from './chunk-MRXNTQOX.mjs';
2
- import { clsx } from 'clsx';
3
- import { customAlphabet } from 'nanoid';
4
- import { twMerge } from 'tailwind-merge';
1
+ import {
2
+ __async
3
+ } from "./chunk-MRXNTQOX.mjs";
5
4
 
5
+ // src/lib/utils.ts
6
+ import { clsx } from "clsx";
7
+ import { customAlphabet } from "nanoid";
8
+ import { twMerge } from "tailwind-merge";
6
9
  function cn(...inputs) {
7
10
  return twMerge(clsx(inputs));
8
11
  }
@@ -42,6 +45,12 @@ function nullableCompatibleEqualityCheck(naiveEqualityCheck, a, b) {
42
45
  return naiveEqualityCheck(a, b);
43
46
  }
44
47
 
45
- export { arraysAreEqual, cn, fetcher, formatDate, nanoid, nullableCompatibleEqualityCheck };
46
- //# sourceMappingURL=out.js.map
48
+ export {
49
+ cn,
50
+ nanoid,
51
+ fetcher,
52
+ formatDate,
53
+ arraysAreEqual,
54
+ nullableCompatibleEqualityCheck
55
+ };
47
56
  //# sourceMappingURL=chunk-KGKLUWKW.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/lib/utils.ts"],"names":[],"mappings":";;;;;AAAA,SAAS,YAA6B;AACtC,SAAS,sBAAsB;AAC/B,SAAS,eAAe;AAEjB,SAAS,MAAM,QAAsB;AAC1C,SAAO,QAAQ,KAAK,MAAM,CAAC;AAC7B;AAEO,IAAM,SAAS;AAAA,EACpB;AAAA,EACA;AACF;AAEA,SAAsB,QACpB,OACA,MACe;AAAA;AACf,UAAM,MAAM,MAAM,MAAM,OAAO,IAAI;AAEnC,QAAI,CAAC,IAAI,IAAI;AACX,YAAM,OAAO,MAAM,IAAI,KAAK;AAC5B,UAAI,KAAK,OAAO;AACd,cAAM,QAAQ,IAAI,MAAM,KAAK,KAAK;AAGlC,cAAM,SAAS,IAAI;AACnB,cAAM;AAAA,MACR,OAAO;AACL,cAAM,IAAI,MAAM,8BAA8B;AAAA,MAChD;AAAA,IACF;AAEA,WAAO,IAAI,KAAK;AAAA,EAClB;AAAA;AAEO,SAAS,WAAW,OAAuC;AAChE,QAAM,OAAO,IAAI,KAAK,KAAK;AAC3B,SAAO,KAAK,mBAAmB,SAAS;AAAA,IACtC,OAAO;AAAA,IACP,KAAK;AAAA,IACL,MAAM;AAAA,EACR,CAAC;AACH;AAEO,IAAM,iBAAiB,CAAC,MAAgB,SAC7C,KAAK,WAAW,KAAK,UACrB,KAAK,MAAM,CAAC,OAAO,UAAU,UAAU,KAAK,MAAM;AAE7C,SAAS,gCACd,oBACA,GACA,GACS;AACT,MAAI,MAAM,QAAQ,MAAM,UAAa,MAAM,QAAQ,MAAM,QAAW;AAClE,WAAO,MAAM;AAAA,EACf;AAEA,SAAO,mBAAmB,GAAG,CAAC;AAChC","sourcesContent":["import { clsx, type ClassValue } from \"clsx\";\nimport { customAlphabet } from \"nanoid\";\nimport { twMerge } from \"tailwind-merge\";\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n\nexport const nanoid = customAlphabet(\n \"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\",\n 7\n); // 7-character random string\n\nexport async function fetcher<JSON = any>(\n input: RequestInfo,\n init?: RequestInit\n): Promise<JSON> {\n const res = await fetch(input, init);\n\n if (!res.ok) {\n const json = await res.json();\n if (json.error) {\n const error = new Error(json.error) as Error & {\n status: number;\n };\n error.status = res.status;\n throw error;\n } else {\n throw new Error(\"An unexpected error occurred\");\n }\n }\n\n return res.json();\n}\n\nexport function formatDate(input: string | number | Date): string {\n const date = new Date(input);\n return date.toLocaleDateString(\"en-US\", {\n month: \"long\",\n day: \"numeric\",\n year: \"numeric\",\n });\n}\n\nexport const arraysAreEqual = (arr1: number[], arr2: number[]): boolean =>\n arr1.length === arr2.length &&\n arr1.every((value, index) => value === arr2[index]);\n\nexport function nullableCompatibleEqualityCheck<T>(\n naiveEqualityCheck: (a: T, b: T) => boolean,\n a: T | null | undefined,\n b: T | null | undefined\n): boolean {\n if (a === null || a === undefined || b === null || b === undefined) {\n return a === b;\n }\n\n return naiveEqualityCheck(a, b);\n}\n"]}
1
+ {"version":3,"sources":["../src/lib/utils.ts"],"sourcesContent":["import { clsx, type ClassValue } from \"clsx\";\nimport { customAlphabet } from \"nanoid\";\nimport { twMerge } from \"tailwind-merge\";\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n\nexport const nanoid = customAlphabet(\n \"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\",\n 7\n); // 7-character random string\n\nexport async function fetcher<JSON = any>(\n input: RequestInfo,\n init?: RequestInit\n): Promise<JSON> {\n const res = await fetch(input, init);\n\n if (!res.ok) {\n const json = await res.json();\n if (json.error) {\n const error = new Error(json.error) as Error & {\n status: number;\n };\n error.status = res.status;\n throw error;\n } else {\n throw new Error(\"An unexpected error occurred\");\n }\n }\n\n return res.json();\n}\n\nexport function formatDate(input: string | number | Date): string {\n const date = new Date(input);\n return date.toLocaleDateString(\"en-US\", {\n month: \"long\",\n day: \"numeric\",\n year: \"numeric\",\n });\n}\n\nexport const arraysAreEqual = (arr1: number[], arr2: number[]): boolean =>\n arr1.length === arr2.length &&\n arr1.every((value, index) => value === arr2[index]);\n\nexport function nullableCompatibleEqualityCheck<T>(\n naiveEqualityCheck: (a: T, b: T) => boolean,\n a: T | null | undefined,\n b: T | null | undefined\n): boolean {\n if (a === null || a === undefined || b === null || b === undefined) {\n return a === b;\n }\n\n return naiveEqualityCheck(a, b);\n}\n"],"mappings":";;;;;AAAA,SAAS,YAA6B;AACtC,SAAS,sBAAsB;AAC/B,SAAS,eAAe;AAEjB,SAAS,MAAM,QAAsB;AAC1C,SAAO,QAAQ,KAAK,MAAM,CAAC;AAC7B;AAEO,IAAM,SAAS;AAAA,EACpB;AAAA,EACA;AACF;AAEA,SAAsB,QACpB,OACA,MACe;AAAA;AACf,UAAM,MAAM,MAAM,MAAM,OAAO,IAAI;AAEnC,QAAI,CAAC,IAAI,IAAI;AACX,YAAM,OAAO,MAAM,IAAI,KAAK;AAC5B,UAAI,KAAK,OAAO;AACd,cAAM,QAAQ,IAAI,MAAM,KAAK,KAAK;AAGlC,cAAM,SAAS,IAAI;AACnB,cAAM;AAAA,MACR,OAAO;AACL,cAAM,IAAI,MAAM,8BAA8B;AAAA,MAChD;AAAA,IACF;AAEA,WAAO,IAAI,KAAK;AAAA,EAClB;AAAA;AAEO,SAAS,WAAW,OAAuC;AAChE,QAAM,OAAO,IAAI,KAAK,KAAK;AAC3B,SAAO,KAAK,mBAAmB,SAAS;AAAA,IACtC,OAAO;AAAA,IACP,KAAK;AAAA,IACL,MAAM;AAAA,EACR,CAAC;AACH;AAEO,IAAM,iBAAiB,CAAC,MAAgB,SAC7C,KAAK,WAAW,KAAK,UACrB,KAAK,MAAM,CAAC,OAAO,UAAU,UAAU,KAAK,MAAM;AAE7C,SAAS,gCACd,oBACA,GACA,GACS;AACT,MAAI,MAAM,QAAQ,MAAM,UAAa,MAAM,QAAQ,MAAM,QAAW;AAClE,WAAO,MAAM;AAAA,EACf;AAEA,SAAO,mBAAmB,GAAG,CAAC;AAChC;","names":[]}
@@ -1,3 +1 @@
1
-
2
- //# sourceMappingURL=out.js.map
3
1
  //# sourceMappingURL=chunk-L7VVZH4Q.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":""}
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,6 +1,10 @@
1
- import { __spreadProps, __spreadValues } from './chunk-MRXNTQOX.mjs';
2
- import { jsx, jsxs } from 'react/jsx-runtime';
1
+ import {
2
+ __spreadProps,
3
+ __spreadValues
4
+ } from "./chunk-MRXNTQOX.mjs";
3
5
 
6
+ // src/components/base-copilot-textarea/render-element.tsx
7
+ import { jsx, jsxs } from "react/jsx-runtime";
4
8
  function makeRenderElementFunction(suggestionsStyle) {
5
9
  return (props) => {
6
10
  switch (props.element.type) {
@@ -29,6 +33,7 @@ var SuggestionElement = (props) => {
29
33
  }));
30
34
  };
31
35
 
32
- export { makeRenderElementFunction };
33
- //# sourceMappingURL=out.js.map
36
+ export {
37
+ makeRenderElementFunction
38
+ };
34
39
  //# sourceMappingURL=chunk-LNAIMEB2.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/base-copilot-textarea/render-element.tsx"],"names":[],"mappings":";;;;;;AAUe,cAkBX,YAlBW;AANR,SAAS,0BACd,kBACuB;AACvB,SAAO,CAAC,UAA8B;AACpC,YAAQ,MAAM,QAAQ,MAAM;AAAA,MAC1B,KAAK;AACH,eAAO,oBAAC,mCAAmB,MAAO;AAAA,MACpC,KAAK;AACH,eACE,oBAAC,oDAAsB,QAAtB;AAAA,UAA6B;AAAA,UAAoC;AAAA,IAExE;AAAA,EACF;AACF;AAEA,IAAM,iBAAiB,CAAC,UAA8B;AACpD,SAAO,oBAAC,wCAAQ,MAAM,aAAd;AAAA,IAA2B,gBAAM;AAAA,IAAS;AACpD;AACA,IAAM,oBAAoB,CACxB,UAGG;AACH,SACE,qBAAC,yCACK,MAAM,aADX;AAAA,IAEC,OAAO,mBACF,MAAM;AAAA,IAEX,iBAAiB;AAAA,IAEhB;AAAA,YAAM;AAAA,MACN,MAAM,QAAQ,SAAS,gBAAgB,MAAM,QAAQ;AAAA;AAAA,IACxD;AAEJ","sourcesContent":["import { RenderElementProps } from \"slate-react\";\n\nexport type RenderElementFunction = (props: RenderElementProps) => JSX.Element;\n\nexport function makeRenderElementFunction(\n suggestionsStyle: React.CSSProperties\n): RenderElementFunction {\n return (props: RenderElementProps) => {\n switch (props.element.type) {\n case \"paragraph\":\n return <DefaultElement {...props} />;\n case \"suggestion\":\n return (\n <SuggestionElement {...props} suggestionsStyle={suggestionsStyle} />\n );\n }\n };\n}\n\nconst DefaultElement = (props: RenderElementProps) => {\n return <div {...props.attributes}>{props.children}</div>;\n};\nconst SuggestionElement = (\n props: RenderElementProps & {\n suggestionsStyle: React.CSSProperties;\n }\n) => {\n return (\n <span\n {...props.attributes}\n style={{\n ...props.suggestionsStyle,\n }}\n contentEditable={false}\n >\n {props.children /* https://github.com/ianstormtaylor/slate/issues/3930 */}\n {props.element.type === \"suggestion\" && props.element.content}\n </span>\n );\n};\n"]}
1
+ {"version":3,"sources":["../src/components/base-copilot-textarea/render-element.tsx"],"sourcesContent":["import { RenderElementProps } from \"slate-react\";\n\nexport type RenderElementFunction = (props: RenderElementProps) => JSX.Element;\n\nexport function makeRenderElementFunction(\n suggestionsStyle: React.CSSProperties\n): RenderElementFunction {\n return (props: RenderElementProps) => {\n switch (props.element.type) {\n case \"paragraph\":\n return <DefaultElement {...props} />;\n case \"suggestion\":\n return (\n <SuggestionElement {...props} suggestionsStyle={suggestionsStyle} />\n );\n }\n };\n}\n\nconst DefaultElement = (props: RenderElementProps) => {\n return <div {...props.attributes}>{props.children}</div>;\n};\nconst SuggestionElement = (\n props: RenderElementProps & {\n suggestionsStyle: React.CSSProperties;\n }\n) => {\n return (\n <span\n {...props.attributes}\n style={{\n ...props.suggestionsStyle,\n }}\n contentEditable={false}\n >\n {props.children /* https://github.com/ianstormtaylor/slate/issues/3930 */}\n {props.element.type === \"suggestion\" && props.element.content}\n </span>\n );\n};\n"],"mappings":";;;;;;AAUe,cAkBX,YAlBW;AANR,SAAS,0BACd,kBACuB;AACvB,SAAO,CAAC,UAA8B;AACpC,YAAQ,MAAM,QAAQ,MAAM;AAAA,MAC1B,KAAK;AACH,eAAO,oBAAC,mCAAmB,MAAO;AAAA,MACpC,KAAK;AACH,eACE,oBAAC,oDAAsB,QAAtB;AAAA,UAA6B;AAAA,UAAoC;AAAA,IAExE;AAAA,EACF;AACF;AAEA,IAAM,iBAAiB,CAAC,UAA8B;AACpD,SAAO,oBAAC,wCAAQ,MAAM,aAAd;AAAA,IAA2B,gBAAM;AAAA,IAAS;AACpD;AACA,IAAM,oBAAoB,CACxB,UAGG;AACH,SACE,qBAAC,yCACK,MAAM,aADX;AAAA,IAEC,OAAO,mBACF,MAAM;AAAA,IAEX,iBAAiB;AAAA,IAEhB;AAAA,YAAM;AAAA,MACN,MAAM,QAAQ,SAAS,gBAAgB,MAAM,QAAQ;AAAA;AAAA,IACxD;AAEJ;","names":[]}
@@ -1,12 +1,23 @@
1
- import { HoveringInsertionPromptBox } from './chunk-5DU2QDHZ.mjs';
2
- import { useHoveringEditorContext } from './chunk-YW3REYX6.mjs';
3
- import { Portal, Menu } from './chunk-XHUMROEY.mjs';
4
- import { getTextAroundSelection, getFullEditorTextWithNewlines } from './chunk-IXJ2HCOA.mjs';
5
- import { useRef, useState, useEffect } from 'react';
6
- import { Transforms } from 'slate';
7
- import { useSlate, useSlateSelection } from 'slate-react';
8
- import { jsx } from 'react/jsx-runtime';
1
+ import {
2
+ HoveringInsertionPromptBox
3
+ } from "./chunk-7JO276KU.mjs";
4
+ import {
5
+ useHoveringEditorContext
6
+ } from "./chunk-YW3REYX6.mjs";
7
+ import {
8
+ Menu,
9
+ Portal
10
+ } from "./chunk-XHUMROEY.mjs";
11
+ import {
12
+ getFullEditorTextWithNewlines,
13
+ getTextAroundSelection
14
+ } from "./chunk-IXJ2HCOA.mjs";
9
15
 
16
+ // src/components/hovering-toolbar/hovering-toolbar.tsx
17
+ import { useEffect, useRef, useState } from "react";
18
+ import { Transforms } from "slate";
19
+ import { useSlate, useSlateSelection } from "slate-react";
20
+ import { jsx } from "react/jsx-runtime";
10
21
  var HoveringToolbar = (props) => {
11
22
  const ref = useRef(null);
12
23
  const editor = useSlate();
@@ -73,7 +84,7 @@ var HoveringToolbar = (props) => {
73
84
  ref,
74
85
  className: "p-2 absolute z-10 top-[-10000px] left-[-10000px] mt-[-6px] opacity-0 transition-opacity duration-700",
75
86
  children: isDisplayed && selection && /* @__PURE__ */ jsx(HoveringInsertionPromptBox, {
76
- editorState: editorState(editor),
87
+ editorState: editorState(editor, selection),
77
88
  apiConfig: props.apiConfig,
78
89
  closeWindow: () => {
79
90
  setIsDisplayed(false);
@@ -103,6 +114,7 @@ function editorState(editor, selection) {
103
114
  };
104
115
  }
105
116
 
106
- export { HoveringToolbar };
107
- //# sourceMappingURL=out.js.map
108
- //# sourceMappingURL=chunk-KLROO6ID.mjs.map
117
+ export {
118
+ HoveringToolbar
119
+ };
120
+ //# sourceMappingURL=chunk-LRXRD5KU.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/hovering-toolbar/hovering-toolbar.tsx"],"sourcesContent":["import { css } from \"@emotion/css\";\nimport { useEffect, useMemo, useRef, useState } from \"react\";\nimport { BaseSelection, Editor, Range, Location, Transforms } from \"slate\";\nimport { useSlate, useSlateSelection } from \"slate-react\";\nimport { HoveringInsertionPromptBox } from \"./text-insertion-prompt-box\";\nimport { Button, Icon, Menu, Portal } from \"./hovering-toolbar-components\";\nimport { useHoveringEditorContext } from \"./hovering-editor-provider\";\nimport {\n getFullEditorTextWithNewlines,\n getTextAroundSelection,\n} from \"../../lib/get-text-around-cursor\";\nimport {\n EditingEditorState,\n InsertionEditorApiConfig,\n} from \"../../types/base/autosuggestions-bare-function\";\n\nexport interface HoveringToolbarProps {\n apiConfig: InsertionEditorApiConfig;\n contextCategories: string[];\n}\n\nexport const HoveringToolbar: (\n props: HoveringToolbarProps\n) => JSX.Element | null = (props) => {\n const ref = useRef<HTMLDivElement>(null);\n const editor = useSlate();\n const selection = useSlateSelection();\n const { isDisplayed, setIsDisplayed } = useHoveringEditorContext();\n\n // only render on client\n const [isClient, setIsClient] = useState(false);\n useEffect(() => {\n setIsClient(true);\n }, []);\n\n useEffect(() => {\n const el = ref.current;\n const { selection } = editor;\n\n if (!el) {\n return;\n }\n\n if (!selection) {\n el.removeAttribute(\"style\");\n return;\n }\n\n const domSelection = window.getSelection();\n if (!domSelection) {\n return;\n }\n\n const domRange = domSelection.getRangeAt(0);\n const rect = domRange.getBoundingClientRect();\n\n // We use window = (0,0,0,0) as a signal that the selection is not in the original copilot-textarea,\n // but inside the hovering window.\n //\n // in such case, we simply do nothing.\n if (\n rect.top === 0 &&\n rect.left === 0 &&\n rect.width === 0 &&\n rect.height === 0\n ) {\n return;\n }\n\n const minGapFromEdge = 60;\n const verticalOffsetFromCorner = 35;\n const horizontalOffsetFromCorner = 15;\n let top =\n rect.top + window.scrollY - el.offsetHeight + verticalOffsetFromCorner;\n // make sure top is in the viewport and not too close to the edge\n if (top < minGapFromEdge) {\n top = rect.bottom + window.scrollY + minGapFromEdge;\n } else if (top + el.offsetHeight > window.innerHeight - minGapFromEdge) {\n top = rect.top + window.scrollY - el.offsetHeight - minGapFromEdge;\n }\n\n let left =\n rect.left +\n window.scrollX -\n el.offsetWidth / 2 +\n rect.width / 2 +\n horizontalOffsetFromCorner;\n // make sure left is in the viewport and not too close to the edge\n if (left < minGapFromEdge) {\n left = minGapFromEdge;\n } else if (left + el.offsetWidth > window.innerWidth - minGapFromEdge) {\n left = window.innerWidth - el.offsetWidth - minGapFromEdge;\n }\n\n el.style.opacity = \"1\";\n el.style.top = `${top}px`;\n el.style.left = `${left}px`;\n });\n\n useEffect(() => {\n const handleClickOutside = (event: MouseEvent) => {\n if (ref.current && !ref.current.contains(event.target as Node)) {\n setIsDisplayed(false);\n }\n };\n\n document.addEventListener(\"mousedown\", handleClickOutside);\n return () => {\n document.removeEventListener(\"mousedown\", handleClickOutside);\n };\n }, [ref, setIsDisplayed]);\n\n if (!isClient) {\n return null;\n }\n\n return (\n <Portal>\n <Menu\n ref={ref}\n className=\"p-2 absolute z-10 top-[-10000px] left-[-10000px] mt-[-6px] opacity-0 transition-opacity duration-700\"\n >\n {isDisplayed && selection && (\n <HoveringInsertionPromptBox\n editorState={editorState(editor, selection)}\n apiConfig={props.apiConfig}\n closeWindow={() => {\n setIsDisplayed(false);\n }}\n performInsertion={(insertedText) => {\n console.log(\"inserted text\", insertedText);\n // replace the selection with the inserted text\n Transforms.delete(editor, { at: selection });\n Transforms.insertText(editor, insertedText, {\n at: selection,\n });\n setIsDisplayed(false);\n }}\n contextCategories={props.contextCategories}\n />\n )}\n </Menu>\n </Portal>\n );\n};\n\nfunction editorState(editor: Editor, selection: Location): EditingEditorState {\n const textAroundCursor = getTextAroundSelection(editor);\n if (textAroundCursor) {\n return textAroundCursor;\n }\n\n return {\n textBeforeCursor: getFullEditorTextWithNewlines(editor),\n textAfterCursor: \"\",\n selectedText: \"\",\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;AACA,SAAS,WAAoB,QAAQ,gBAAgB;AACrD,SAAiD,kBAAkB;AACnE,SAAS,UAAU,yBAAyB;AAwHlC;AAtGH,IAAM,kBAEa,CAAC,UAAU;AACnC,QAAM,MAAM,OAAuB,IAAI;AACvC,QAAM,SAAS,SAAS;AACxB,QAAM,YAAY,kBAA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BAAqB,CAAC,UAAsB;AAChD,UAAI,IAAI,WAAW,CAAC,IAAI,QAAQ,SAAS,MAAM,MAAc,GAAG;AAC9D,uBAAe,KAAK;AAAA,MACtB;AAAA,IACF;AAEA,aAAS,iBAAiB,aAAa,kBAAkB;AACzD,WAAO,MAAM;AACX,eAAS,oBAAoB,aAAa,kBAAkB;AAAA,IAC9D;AAAA,EACF,GAAG,CAAC,KAAK,cAAc,CAAC;AAExB,MAAI,CAAC,UAAU;AACb,WAAO;AAAA,EACT;AAEA,SACE,oBAAC;AAAA,IACC,8BAAC;AAAA,MACC;AAAA,MACA,WAAU;AAAA,MAET,yBAAe,aACd,oBAAC;AAAA,QACC,aAAa,YAAY,QAAQ,SAAS;AAAA,QAC1C,WAAW,MAAM;AAAA,QACjB,aAAa,MAAM;AACjB,yBAAe,KAAK;AAAA,QACtB;AAAA,QACA,kBAAkB,CAAC,iBAAiB;AAClC,kBAAQ,IAAI,iBAAiB,YAAY;AAEzC,qBAAW,OAAO,QAAQ,EAAE,IAAI,UAAU,CAAC;AAC3C,qBAAW,WAAW,QAAQ,cAAc;AAAA,YAC1C,IAAI;AAAA,UACN,CAAC;AACD,yBAAe,KAAK;AAAA,QACtB;AAAA,QACA,mBAAmB,MAAM;AAAA,OAC3B;AAAA,KAEJ;AAAA,GACF;AAEJ;AAEA,SAAS,YAAY,QAAgB,WAAyC;AAC5E,QAAM,mBAAmB,uBAAuB,MAAM;AACtD,MAAI,kBAAkB;AACpB,WAAO;AAAA,EACT;AAEA,SAAO;AAAA,IACL,kBAAkB,8BAA8B,MAAM;AAAA,IACtD,iBAAiB;AAAA,IACjB,cAAc;AAAA,EAChB;AACF;","names":["selection"]}
@@ -1,3 +1 @@
1
-
2
- //# sourceMappingURL=out.js.map
3
1
  //# sourceMappingURL=chunk-MMVDU6DF.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":""}
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,6 +1,5 @@
1
- import { useEffect } from 'react';
2
-
3
1
  // src/components/base-copilot-textarea/use-add-branding-css.tsx
2
+ import { useEffect } from "react";
4
3
  function useAddBrandingCss(suggestionStyleAugmented, disableBranding) {
5
4
  const cssSelector = ".copilot-textarea.with-branding";
6
5
  useEffect(() => {
@@ -54,6 +53,7 @@ function useAddBrandingCss(suggestionStyleAugmented, disableBranding) {
54
53
  }, [disableBranding, suggestionStyleAugmented]);
55
54
  }
56
55
 
57
- export { useAddBrandingCss };
58
- //# sourceMappingURL=out.js.map
56
+ export {
57
+ useAddBrandingCss
58
+ };
59
59
  //# sourceMappingURL=chunk-MPME5BW2.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/base-copilot-textarea/use-add-branding-css.tsx"],"names":["styleEl"],"mappings":";AAAA,SAAS,iBAAiB;AAEnB,SAAS,kBACd,0BACA,iBACA;AACA,QAAM,cAAc;AACpB,YAAU,MAAM;AACd,QAAI,iBAAiB;AACnB;AAAA,IACF;AAIA,UAAM,UAAU,SAAS,cAAc,OAAO;AAC9C,YAAQ,KAAK;AAGb,QAAI,gBAAgB,OAAO,QAAQ,wBAAwB,EACxD,IAAI,CAAC,CAAC,KAAK,KAAK,MAAM;AACrB,YAAM,eAAe,IAClB,QAAQ,gCAAgC,OAAO,EAC/C,YAAY;AACf,aAAO,GAAG,iBAAiB;AAAA,IAC7B,CAAC,EACA,KAAK,GAAG;AAGX,qBAAiB;AACjB,qBAAiB;AACjB,qBAAiB;AACjB,qBAAiB;AACjB,qBAAiB;AACjB,qBAAiB;AACjB,qBAAiB;AACjB,qBAAiB;AACjB,qBAAiB;AACjB,qBAAiB;AACjB,qBAAiB;AAGjB,YAAQ,YAAY;AAAA,QAChB;AAAA,UACE;AAAA;AAAA;AAIN,aAAS,KAAK,YAAY,OAAO;AAIjC,UAAM,WAAW,SAAS,cAAc,WAAW;AACnD,UAAM,eAAe,MAAM;AACzB,YAAMA,WAAU,SAAS,eAAe,gBAAgB;AACxD,UAAIA,YAAW,UAAU;AACvB,cAAM,mBAAmB,CAAC,SAAS,YAAY;AAC/C,cAAM,kBAAkB,CAAC,SAAS,aAAa;AAC/C,QAAAA,SAAQ,YAAY;AAAA,YAChB;AAAA,cACE;AAAA,sBACQ;AAAA,qBACD;AAAA;AAAA;AAAA,MAGf;AAAA,IACF;AAEA,yCAAU,iBAAiB,UAAU;AAGrC,WAAO,MAAM;AAtEjB;AAuEM,qBAAS,eAAe,gBAAgB,MAAxC,mBAA2C;AAC3C,2CAAU,oBAAoB,UAAU;AAAA,IAC1C;AAAA,EACF,GAAG,CAAC,iBAAiB,wBAAwB,CAAC;AAChD","sourcesContent":["import { useEffect } from \"react\";\n\nexport function useAddBrandingCss(\n suggestionStyleAugmented: React.CSSProperties,\n disableBranding: boolean | undefined\n) {\n const cssSelector = \".copilot-textarea.with-branding\";\n useEffect(() => {\n if (disableBranding) {\n return;\n }\n\n // ---\n // 1: Add the CSS to the DOM\n const styleEl = document.createElement(\"style\");\n styleEl.id = \"dynamic-styles\";\n\n // Build the CSS string dynamically\n let dynamicStyles = Object.entries(suggestionStyleAugmented)\n .map(([key, value]) => {\n const kebabCaseKey = key\n .replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, \"$1-$2\")\n .toLowerCase();\n return `${kebabCaseKey}: ${value};`;\n })\n .join(\" \");\n\n // Append overrides for italics and font-size\n dynamicStyles += `font-style: normal; font-size: x-small;`;\n dynamicStyles += `content: \"CopilotKit\";`;\n dynamicStyles += `bottom: 6px;`;\n dynamicStyles += `right: 6px;`;\n dynamicStyles += `pointer-events: none;`;\n dynamicStyles += `font-weight: 200;`;\n dynamicStyles += `padding: 0;`;\n dynamicStyles += `margin: 0;`;\n dynamicStyles += `border: 0;`;\n dynamicStyles += `line-height: 1;`;\n dynamicStyles += `position: absolute;`;\n\n // Append it to the ::after class\n styleEl.innerHTML = `\n ${cssSelector}::after {\n ${dynamicStyles}\n }\n `;\n\n document.head.appendChild(styleEl);\n\n // ---\n // 2: Add the scroll listener (to keep the branding in the bottom right as the textarea scrolls)\n const textarea = document.querySelector(cssSelector);\n const handleScroll = () => {\n const styleEl = document.getElementById(\"dynamic-styles\");\n if (styleEl && textarea) {\n const offsetFromBottom = -textarea.scrollTop + 6;\n const offsetFromRight = -textarea.scrollLeft + 6;\n styleEl.innerHTML = `\n ${cssSelector}::after {\n ${dynamicStyles}\n bottom: ${offsetFromBottom}px;\n right: ${offsetFromRight}px;\n }\n `;\n }\n };\n\n textarea?.addEventListener(\"scroll\", handleScroll);\n\n // Cleanup\n return () => {\n document.getElementById(\"dynamic-styles\")?.remove();\n textarea?.removeEventListener(\"scroll\", handleScroll);\n };\n }, [disableBranding, suggestionStyleAugmented]);\n}\n"]}
1
+ {"version":3,"sources":["../src/components/base-copilot-textarea/use-add-branding-css.tsx"],"sourcesContent":["import { useEffect } from \"react\";\n\nexport function useAddBrandingCss(\n suggestionStyleAugmented: React.CSSProperties,\n disableBranding: boolean | undefined\n) {\n const cssSelector = \".copilot-textarea.with-branding\";\n useEffect(() => {\n if (disableBranding) {\n return;\n }\n\n // ---\n // 1: Add the CSS to the DOM\n const styleEl = document.createElement(\"style\");\n styleEl.id = \"dynamic-styles\";\n\n // Build the CSS string dynamically\n let dynamicStyles = Object.entries(suggestionStyleAugmented)\n .map(([key, value]) => {\n const kebabCaseKey = key\n .replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, \"$1-$2\")\n .toLowerCase();\n return `${kebabCaseKey}: ${value};`;\n })\n .join(\" \");\n\n // Append overrides for italics and font-size\n dynamicStyles += `font-style: normal; font-size: x-small;`;\n dynamicStyles += `content: \"CopilotKit\";`;\n dynamicStyles += `bottom: 6px;`;\n dynamicStyles += `right: 6px;`;\n dynamicStyles += `pointer-events: none;`;\n dynamicStyles += `font-weight: 200;`;\n dynamicStyles += `padding: 0;`;\n dynamicStyles += `margin: 0;`;\n dynamicStyles += `border: 0;`;\n dynamicStyles += `line-height: 1;`;\n dynamicStyles += `position: absolute;`;\n\n // Append it to the ::after class\n styleEl.innerHTML = `\n ${cssSelector}::after {\n ${dynamicStyles}\n }\n `;\n\n document.head.appendChild(styleEl);\n\n // ---\n // 2: Add the scroll listener (to keep the branding in the bottom right as the textarea scrolls)\n const textarea = document.querySelector(cssSelector);\n const handleScroll = () => {\n const styleEl = document.getElementById(\"dynamic-styles\");\n if (styleEl && textarea) {\n const offsetFromBottom = -textarea.scrollTop + 6;\n const offsetFromRight = -textarea.scrollLeft + 6;\n styleEl.innerHTML = `\n ${cssSelector}::after {\n ${dynamicStyles}\n bottom: ${offsetFromBottom}px;\n right: ${offsetFromRight}px;\n }\n `;\n }\n };\n\n textarea?.addEventListener(\"scroll\", handleScroll);\n\n // Cleanup\n return () => {\n document.getElementById(\"dynamic-styles\")?.remove();\n textarea?.removeEventListener(\"scroll\", handleScroll);\n };\n }, [disableBranding, suggestionStyleAugmented]);\n}\n"],"mappings":";AAAA,SAAS,iBAAiB;AAEnB,SAAS,kBACd,0BACA,iBACA;AACA,QAAM,cAAc;AACpB,YAAU,MAAM;AACd,QAAI,iBAAiB;AACnB;AAAA,IACF;AAIA,UAAM,UAAU,SAAS,cAAc,OAAO;AAC9C,YAAQ,KAAK;AAGb,QAAI,gBAAgB,OAAO,QAAQ,wBAAwB,EACxD,IAAI,CAAC,CAAC,KAAK,KAAK,MAAM;AACrB,YAAM,eAAe,IAClB,QAAQ,gCAAgC,OAAO,EAC/C,YAAY;AACf,aAAO,GAAG,iBAAiB;AAAA,IAC7B,CAAC,EACA,KAAK,GAAG;AAGX,qBAAiB;AACjB,qBAAiB;AACjB,qBAAiB;AACjB,qBAAiB;AACjB,qBAAiB;AACjB,qBAAiB;AACjB,qBAAiB;AACjB,qBAAiB;AACjB,qBAAiB;AACjB,qBAAiB;AACjB,qBAAiB;AAGjB,YAAQ,YAAY;AAAA,QAChB;AAAA,UACE;AAAA;AAAA;AAIN,aAAS,KAAK,YAAY,OAAO;AAIjC,UAAM,WAAW,SAAS,cAAc,WAAW;AACnD,UAAM,eAAe,MAAM;AACzB,YAAMA,WAAU,SAAS,eAAe,gBAAgB;AACxD,UAAIA,YAAW,UAAU;AACvB,cAAM,mBAAmB,CAAC,SAAS,YAAY;AAC/C,cAAM,kBAAkB,CAAC,SAAS,aAAa;AAC/C,QAAAA,SAAQ,YAAY;AAAA,YAChB;AAAA,cACE;AAAA,sBACQ;AAAA,qBACD;AAAA;AAAA;AAAA,MAGf;AAAA,IACF;AAEA,yCAAU,iBAAiB,UAAU;AAGrC,WAAO,MAAM;AAtEjB;AAuEM,qBAAS,eAAe,gBAAgB,MAAxC,mBAA2C;AAC3C,2CAAU,oBAAoB,UAAU;AAAA,IAC1C;AAAA,EACF,GAAG,CAAC,iBAAiB,wBAAwB,CAAC;AAChD;","names":["styleEl"]}
@@ -50,6 +50,10 @@ var __async = (__this, __arguments, generator) => {
50
50
  });
51
51
  };
52
52
 
53
- export { __async, __objRest, __spreadProps, __spreadValues };
54
- //# sourceMappingURL=out.js.map
53
+ export {
54
+ __spreadValues,
55
+ __spreadProps,
56
+ __objRest,
57
+ __async
58
+ };
55
59
  //# sourceMappingURL=chunk-MRXNTQOX.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}