@copilotkit/react-textarea 1.51.4-next.7 → 1.51.4-next.8

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 (250) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/README.md +18 -12
  3. package/dist/{chunk-D47EKHIF.mjs → chunk-2X3CZVEP.mjs} +9 -3
  4. package/dist/chunk-2X3CZVEP.mjs.map +1 -0
  5. package/dist/{chunk-GU5LTWGL.mjs → chunk-3WLGLZTY.mjs} +19 -13
  6. package/dist/chunk-3WLGLZTY.mjs.map +1 -0
  7. package/dist/{chunk-DRV2FOHZ.mjs → chunk-7GZWOXE4.mjs} +2 -2
  8. package/dist/chunk-7GZWOXE4.mjs.map +1 -0
  9. package/dist/{chunk-NAFNY4FL.mjs → chunk-7V4ORVQX.mjs} +1 -1
  10. package/dist/chunk-7V4ORVQX.mjs.map +1 -0
  11. package/dist/{chunk-ECR45NSD.mjs → chunk-A6YGJFQI.mjs} +9 -2
  12. package/dist/chunk-A6YGJFQI.mjs.map +1 -0
  13. package/dist/{chunk-WGWQRALG.mjs → chunk-AHNPJMBR.mjs} +10 -3
  14. package/dist/chunk-AHNPJMBR.mjs.map +1 -0
  15. package/dist/{chunk-VSVQZUPW.mjs → chunk-ARLBRSB7.mjs} +23 -7
  16. package/dist/chunk-ARLBRSB7.mjs.map +1 -0
  17. package/dist/{chunk-72GJNLCO.mjs → chunk-AZ7RF6ED.mjs} +5 -5
  18. package/dist/chunk-AZ7RF6ED.mjs.map +1 -0
  19. package/dist/{chunk-I72DKFHD.mjs → chunk-CFCMZVQ2.mjs} +29 -7
  20. package/dist/chunk-CFCMZVQ2.mjs.map +1 -0
  21. package/dist/{chunk-T6MTDQZ7.mjs → chunk-CMKGYQFX.mjs} +1 -1
  22. package/dist/chunk-CMKGYQFX.mjs.map +1 -0
  23. package/dist/{chunk-DFTV4TST.mjs → chunk-DZMQBOPG.mjs} +1 -1
  24. package/dist/chunk-DZMQBOPG.mjs.map +1 -0
  25. package/dist/{chunk-CLGAJCZ5.mjs → chunk-E7C63KQP.mjs} +10 -6
  26. package/dist/chunk-E7C63KQP.mjs.map +1 -0
  27. package/dist/{chunk-GQN2HYFJ.mjs → chunk-EGBZSVLK.mjs} +5 -2
  28. package/dist/{chunk-GQN2HYFJ.mjs.map → chunk-EGBZSVLK.mjs.map} +1 -1
  29. package/dist/{chunk-3QJOFG3V.mjs → chunk-FTG7P3NP.mjs} +1 -1
  30. package/dist/chunk-FTG7P3NP.mjs.map +1 -0
  31. package/dist/{chunk-KMVGEY7Q.mjs → chunk-IBZTDP72.mjs} +9 -4
  32. package/dist/chunk-IBZTDP72.mjs.map +1 -0
  33. package/dist/{chunk-4PDYALMP.mjs → chunk-LYNGBKJR.mjs} +9 -3
  34. package/dist/chunk-LYNGBKJR.mjs.map +1 -0
  35. package/dist/{chunk-DL3JWL2E.mjs → chunk-M7GTVHFB.mjs} +26 -8
  36. package/dist/chunk-M7GTVHFB.mjs.map +1 -0
  37. package/dist/chunk-MQBPYOOZ.mjs +97 -0
  38. package/dist/chunk-MQBPYOOZ.mjs.map +1 -0
  39. package/dist/{chunk-6SGWO63I.mjs → chunk-MQXYWOE2.mjs} +3 -3
  40. package/dist/chunk-MQXYWOE2.mjs.map +1 -0
  41. package/dist/{chunk-F2ULK22F.mjs → chunk-NFMCLTJU.mjs} +1 -1
  42. package/dist/chunk-NFMCLTJU.mjs.map +1 -0
  43. package/dist/{chunk-F6RLSVG3.mjs → chunk-O4WCM57A.mjs} +1 -1
  44. package/dist/chunk-O4WCM57A.mjs.map +1 -0
  45. package/dist/{chunk-4NHVQZ67.mjs → chunk-PDFIUPCS.mjs} +1 -1
  46. package/dist/chunk-PDFIUPCS.mjs.map +1 -0
  47. package/dist/{chunk-7NOLZ5T3.mjs → chunk-SWX3MRZ4.mjs} +31 -22
  48. package/dist/chunk-SWX3MRZ4.mjs.map +1 -0
  49. package/dist/{chunk-QJNFNPWH.mjs → chunk-TGN3YVSO.mjs} +2 -2
  50. package/dist/chunk-TGN3YVSO.mjs.map +1 -0
  51. package/dist/{chunk-LYB4B6MK.mjs → chunk-UB4Y22EF.mjs} +4 -2
  52. package/dist/chunk-UB4Y22EF.mjs.map +1 -0
  53. package/dist/{chunk-ZQSEYPNN.mjs → chunk-UIBUYQPG.mjs} +7 -2
  54. package/dist/chunk-UIBUYQPG.mjs.map +1 -0
  55. package/dist/{chunk-AJ5OMEXM.mjs → chunk-VBPZTMXB.mjs} +2 -2
  56. package/dist/{chunk-EJGGLWWR.mjs → chunk-VH7INUR5.mjs} +1 -1
  57. package/dist/{chunk-EJGGLWWR.mjs.map → chunk-VH7INUR5.mjs.map} +1 -1
  58. package/dist/{chunk-7LSRNPNI.mjs → chunk-VVRGAA43.mjs} +1 -1
  59. package/dist/chunk-VVRGAA43.mjs.map +1 -0
  60. package/dist/{chunk-YLFAIYRY.mjs → chunk-VYLLLBUP.mjs} +1 -1
  61. package/dist/chunk-VYLLLBUP.mjs.map +1 -0
  62. package/dist/{chunk-2QDCE7PD.mjs → chunk-WXKPRNNO.mjs} +1 -1
  63. package/dist/chunk-WXKPRNNO.mjs.map +1 -0
  64. package/dist/{chunk-JLOABKLH.mjs → chunk-YINY56BI.mjs} +2 -2
  65. package/dist/{chunk-23Q6A46J.mjs → chunk-ZBP4SABT.mjs} +22 -8
  66. package/dist/chunk-ZBP4SABT.mjs.map +1 -0
  67. package/dist/{chunk-H5ZNEKUR.mjs → chunk-ZWI5KPQ5.mjs} +2 -2
  68. package/dist/components/base-copilot-textarea/base-copilot-textarea.js +154 -86
  69. package/dist/components/base-copilot-textarea/base-copilot-textarea.js.map +1 -1
  70. package/dist/components/base-copilot-textarea/base-copilot-textarea.mjs +29 -29
  71. package/dist/components/base-copilot-textarea/render-element.js.map +1 -1
  72. package/dist/components/base-copilot-textarea/render-element.mjs +1 -1
  73. package/dist/components/base-copilot-textarea/render-placeholder.js.map +1 -1
  74. package/dist/components/base-copilot-textarea/render-placeholder.mjs +1 -1
  75. package/dist/components/base-copilot-textarea/track-cursor-moved-since-last-text-change.js.map +1 -1
  76. package/dist/components/base-copilot-textarea/track-cursor-moved-since-last-text-change.mjs +2 -2
  77. package/dist/components/base-copilot-textarea/use-add-branding-css.js.map +1 -1
  78. package/dist/components/base-copilot-textarea/use-add-branding-css.mjs +1 -1
  79. package/dist/components/copilot-textarea/copilot-textarea.js +190 -95
  80. package/dist/components/copilot-textarea/copilot-textarea.js.map +1 -1
  81. package/dist/components/copilot-textarea/copilot-textarea.mjs +34 -34
  82. package/dist/components/hovering-toolbar/hovering-editor-provider.d.ts +1 -1
  83. package/dist/components/hovering-toolbar/hovering-editor-provider.js +3 -1
  84. package/dist/components/hovering-toolbar/hovering-editor-provider.js.map +1 -1
  85. package/dist/components/hovering-toolbar/hovering-editor-provider.mjs +1 -1
  86. package/dist/components/hovering-toolbar/hovering-toolbar-components.js +57 -63
  87. package/dist/components/hovering-toolbar/hovering-toolbar-components.js.map +1 -1
  88. package/dist/components/hovering-toolbar/hovering-toolbar-components.mjs +1 -1
  89. package/dist/components/hovering-toolbar/hovering-toolbar.js +117 -77
  90. package/dist/components/hovering-toolbar/hovering-toolbar.js.map +1 -1
  91. package/dist/components/hovering-toolbar/hovering-toolbar.mjs +15 -15
  92. package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.js +60 -14
  93. package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.js.map +1 -1
  94. package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.mjs +11 -11
  95. package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.js +60 -14
  96. package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.js.map +1 -1
  97. package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.mjs +12 -12
  98. package/dist/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.d.ts +1 -1
  99. package/dist/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.js +14 -3
  100. package/dist/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.js.map +1 -1
  101. package/dist/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.mjs +3 -3
  102. package/dist/components/hovering-toolbar/text-insertion-prompt-box/index.js +60 -14
  103. package/dist/components/hovering-toolbar/text-insertion-prompt-box/index.js.map +1 -1
  104. package/dist/components/hovering-toolbar/text-insertion-prompt-box/index.mjs +12 -12
  105. package/dist/components/index.js +190 -95
  106. package/dist/components/index.js.map +1 -1
  107. package/dist/components/index.mjs +34 -34
  108. package/dist/components/manual-ui/chip-with-icon.d.ts +1 -1
  109. package/dist/components/manual-ui/chip-with-icon.js +13 -2
  110. package/dist/components/manual-ui/chip-with-icon.js.map +1 -1
  111. package/dist/components/manual-ui/chip-with-icon.mjs +13 -2
  112. package/dist/components/manual-ui/chip-with-icon.mjs.map +1 -1
  113. package/dist/components/source-search-box/source-search-box.js +28 -5
  114. package/dist/components/source-search-box/source-search-box.js.map +1 -1
  115. package/dist/components/source-search-box/source-search-box.mjs +4 -4
  116. package/dist/components/ui/button.js +7 -1
  117. package/dist/components/ui/button.js.map +1 -1
  118. package/dist/components/ui/button.mjs +2 -2
  119. package/dist/components/ui/command.js +47 -9
  120. package/dist/components/ui/command.js.map +1 -1
  121. package/dist/components/ui/command.mjs +3 -3
  122. package/dist/components/ui/dialog.js +27 -5
  123. package/dist/components/ui/dialog.js.map +1 -1
  124. package/dist/components/ui/dialog.mjs +2 -2
  125. package/dist/components/ui/label.js +7 -1
  126. package/dist/components/ui/label.js.map +1 -1
  127. package/dist/components/ui/label.mjs +2 -2
  128. package/dist/hooks/base-copilot-textarea-implementation/use-autosuggestions.js +18 -4
  129. package/dist/hooks/base-copilot-textarea-implementation/use-autosuggestions.js.map +1 -1
  130. package/dist/hooks/base-copilot-textarea-implementation/use-autosuggestions.mjs +4 -4
  131. package/dist/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.js.map +1 -1
  132. package/dist/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.mjs +2 -2
  133. package/dist/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.js.map +1 -1
  134. package/dist/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.mjs +2 -2
  135. package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.js +6 -1
  136. package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.js.map +1 -1
  137. package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.mjs +1 -1
  138. package/dist/hooks/make-autosuggestions-function/use-make-standard-insertion-function.js +25 -7
  139. package/dist/hooks/make-autosuggestions-function/use-make-standard-insertion-function.js.map +1 -1
  140. package/dist/hooks/make-autosuggestions-function/use-make-standard-insertion-function.mjs +1 -1
  141. package/dist/hooks/misc/use-autosize-textarea.js.map +1 -1
  142. package/dist/hooks/misc/use-autosize-textarea.mjs +1 -1
  143. package/dist/index.js +190 -95
  144. package/dist/index.js.map +1 -1
  145. package/dist/index.mjs +35 -35
  146. package/dist/index.umd.js +16 -16
  147. package/dist/index.umd.js.map +1 -1
  148. package/dist/lib/debouncer.js.map +1 -1
  149. package/dist/lib/debouncer.mjs +1 -1
  150. package/dist/lib/editor-to-text.js.map +1 -1
  151. package/dist/lib/editor-to-text.mjs +1 -1
  152. package/dist/lib/get-text-around-cursor.js.map +1 -1
  153. package/dist/lib/get-text-around-cursor.mjs +1 -1
  154. package/dist/lib/slatejs-edits/clear-autocompletions.js +4 -1
  155. package/dist/lib/slatejs-edits/clear-autocompletions.js.map +1 -1
  156. package/dist/lib/slatejs-edits/clear-autocompletions.mjs +1 -1
  157. package/dist/lib/slatejs-edits/with-partial-history.js.map +1 -1
  158. package/dist/lib/slatejs-edits/with-partial-history.mjs +1 -1
  159. package/dist/lib/stream-promise-flatten.js.map +1 -1
  160. package/dist/lib/stream-promise-flatten.mjs +1 -1
  161. package/dist/lib/utils.js.map +1 -1
  162. package/dist/lib/utils.mjs +1 -1
  163. package/dist/types/autosuggestions-config/autosuggestions-config-user-specified.js.map +1 -1
  164. package/dist/types/autosuggestions-config/autosuggestions-config.js.map +1 -1
  165. package/dist/types/autosuggestions-config/autosuggestions-config.mjs +3 -3
  166. package/dist/types/autosuggestions-config/editing-api-config.js.map +1 -1
  167. package/dist/types/autosuggestions-config/editing-api-config.mjs +1 -1
  168. package/dist/types/autosuggestions-config/index.js.map +1 -1
  169. package/dist/types/autosuggestions-config/index.mjs +3 -3
  170. package/dist/types/autosuggestions-config/subtypes/make-system-prompt.js.map +1 -1
  171. package/dist/types/base/base-autosuggestions-config.js.map +1 -1
  172. package/dist/types/base/base-autosuggestions-config.mjs +1 -1
  173. package/dist/types/base/base-copilot-textarea-props.js.map +1 -1
  174. package/dist/types/base/editor-autocomplete-state.js.map +1 -1
  175. package/dist/types/base/editor-autocomplete-state.mjs +2 -2
  176. package/dist/types/base/index.js.map +1 -1
  177. package/dist/types/base/index.mjs +1 -1
  178. package/dist/types/index.js.map +1 -1
  179. package/dist/types/index.mjs +3 -3
  180. package/package.json +5 -5
  181. package/src/components/base-copilot-textarea/base-copilot-textarea.tsx +30 -10
  182. package/src/components/base-copilot-textarea/render-element.tsx +6 -2
  183. package/src/components/base-copilot-textarea/render-placeholder.tsx +3 -1
  184. package/src/components/base-copilot-textarea/use-add-branding-css.tsx +3 -1
  185. package/src/components/copilot-textarea/copilot-textarea.tsx +15 -9
  186. package/src/components/hovering-toolbar/hovering-editor-provider.tsx +3 -1
  187. package/src/components/hovering-toolbar/hovering-toolbar-components.tsx +63 -52
  188. package/src/components/hovering-toolbar/hovering-toolbar.tsx +21 -5
  189. package/src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.tsx +13 -7
  190. package/src/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.tsx +7 -2
  191. package/src/components/manual-ui/chip-with-icon.tsx +12 -3
  192. package/src/components/source-search-box/source-search-box.tsx +12 -2
  193. package/src/components/ui/button.tsx +13 -5
  194. package/src/components/ui/command.tsx +17 -4
  195. package/src/components/ui/dialog.tsx +23 -5
  196. package/src/components/ui/label.tsx +7 -2
  197. package/src/hooks/base-copilot-textarea-implementation/use-autosuggestions.ts +35 -9
  198. package/src/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.tsx +5 -1
  199. package/src/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.ts +5 -1
  200. package/src/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.tsx +9 -2
  201. package/src/hooks/make-autosuggestions-function/use-make-standard-insertion-function.tsx +24 -6
  202. package/src/hooks/misc/use-autosize-textarea.tsx +4 -1
  203. package/src/lib/debouncer.ts +3 -1
  204. package/src/lib/editor-to-text.ts +5 -2
  205. package/src/lib/get-text-around-cursor.ts +14 -2
  206. package/src/lib/slatejs-edits/clear-autocompletions.ts +4 -1
  207. package/src/lib/slatejs-edits/with-partial-history.ts +10 -3
  208. package/src/lib/stream-promise-flatten.ts +3 -1
  209. package/src/lib/utils.ts +6 -2
  210. package/src/types/autosuggestions-config/autosuggestions-config-user-specified.tsx +3 -2
  211. package/src/types/autosuggestions-config/autosuggestions-config.tsx +20 -5
  212. package/src/types/autosuggestions-config/editing-api-config.tsx +2 -1
  213. package/src/types/autosuggestions-config/subtypes/make-system-prompt.ts +4 -1
  214. package/src/types/base/base-autosuggestions-config.tsx +10 -4
  215. package/src/types/base/base-copilot-textarea-props.tsx +4 -2
  216. package/tsconfig.json +1 -1
  217. package/tsup.config.ts +5 -1
  218. package/dist/chunk-23Q6A46J.mjs.map +0 -1
  219. package/dist/chunk-2IWVZ4PP.mjs +0 -103
  220. package/dist/chunk-2IWVZ4PP.mjs.map +0 -1
  221. package/dist/chunk-2QDCE7PD.mjs.map +0 -1
  222. package/dist/chunk-3QJOFG3V.mjs.map +0 -1
  223. package/dist/chunk-4NHVQZ67.mjs.map +0 -1
  224. package/dist/chunk-4PDYALMP.mjs.map +0 -1
  225. package/dist/chunk-6SGWO63I.mjs.map +0 -1
  226. package/dist/chunk-72GJNLCO.mjs.map +0 -1
  227. package/dist/chunk-7LSRNPNI.mjs.map +0 -1
  228. package/dist/chunk-7NOLZ5T3.mjs.map +0 -1
  229. package/dist/chunk-CLGAJCZ5.mjs.map +0 -1
  230. package/dist/chunk-D47EKHIF.mjs.map +0 -1
  231. package/dist/chunk-DFTV4TST.mjs.map +0 -1
  232. package/dist/chunk-DL3JWL2E.mjs.map +0 -1
  233. package/dist/chunk-DRV2FOHZ.mjs.map +0 -1
  234. package/dist/chunk-ECR45NSD.mjs.map +0 -1
  235. package/dist/chunk-F2ULK22F.mjs.map +0 -1
  236. package/dist/chunk-F6RLSVG3.mjs.map +0 -1
  237. package/dist/chunk-GU5LTWGL.mjs.map +0 -1
  238. package/dist/chunk-I72DKFHD.mjs.map +0 -1
  239. package/dist/chunk-KMVGEY7Q.mjs.map +0 -1
  240. package/dist/chunk-LYB4B6MK.mjs.map +0 -1
  241. package/dist/chunk-NAFNY4FL.mjs.map +0 -1
  242. package/dist/chunk-QJNFNPWH.mjs.map +0 -1
  243. package/dist/chunk-T6MTDQZ7.mjs.map +0 -1
  244. package/dist/chunk-VSVQZUPW.mjs.map +0 -1
  245. package/dist/chunk-WGWQRALG.mjs.map +0 -1
  246. package/dist/chunk-YLFAIYRY.mjs.map +0 -1
  247. package/dist/chunk-ZQSEYPNN.mjs.map +0 -1
  248. /package/dist/{chunk-AJ5OMEXM.mjs.map → chunk-VBPZTMXB.mjs.map} +0 -0
  249. /package/dist/{chunk-JLOABKLH.mjs.map → chunk-YINY56BI.mjs.map} +0 -0
  250. /package/dist/{chunk-H5ZNEKUR.mjs.map → chunk-ZWI5KPQ5.mjs.map} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # ui
2
2
 
3
+ ## 1.51.4-next.8
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [9bc868d]
8
+ - @copilotkit/react-core@1.51.4-next.8
9
+ - @copilotkit/runtime-client-gql@1.51.4-next.8
10
+ - @copilotkit/shared@1.51.4-next.8
11
+
3
12
  ## 1.51.4-next.7
4
13
 
5
14
  ### Patch Changes
package/README.md CHANGED
@@ -48,9 +48,9 @@
48
48
  const { visibleMessages, appendMessage, setMessages, ... } = useCopilotChat();
49
49
 
50
50
  // Pre-built components with deep customization options (CSS + pass custom sub-components)
51
- <CopilotPopup
52
- instructions={"You are assisting the user as best as you can. Answer in the best way possible given the data you have."}
53
- labels={{ title: "Popup Assistant", initial: "Need any help?" }}
51
+ <CopilotPopup
52
+ instructions={"You are assisting the user as best as you can. Answer in the best way possible given the data you have."}
53
+ labels={{ title: "Popup Assistant", initial: "Need any help?" }}
54
54
  />
55
55
  ```
56
56
 
@@ -71,9 +71,9 @@ useCopilotAction({
71
71
 
72
72
  ```ts
73
73
  // Share state between app and agent
74
- const { agentState } = useCoAgent({
75
- name: "basic_agent",
76
- initialState: { input: "NYC" }
74
+ const { agentState } = useCoAgent({
75
+ name: "basic_agent",
76
+ initialState: { input: "NYC" }
77
77
  });
78
78
 
79
79
  // agentic generative UI
@@ -114,14 +114,20 @@ useCopilotAction({
114
114
  ```ts
115
115
  // intermediate agent state streaming (supports both LangGraph.js + LangGraph python)
116
116
  const modifiedConfig = copilotKitCustomizeConfig(config, {
117
- emitIntermediateState: [{
118
- stateKey: "outline",
119
- tool: "set_outline",
120
- toolArgument: "outline"
121
- }],
117
+ emitIntermediateState: [
118
+ {
119
+ stateKey: "outline",
120
+ tool: "set_outline",
121
+ toolArgument: "outline",
122
+ },
123
+ ],
122
124
  });
123
- const response = await ChatOpenAI({ model: "gpt-4o" }).invoke(messages, modifiedConfig);
125
+ const response = await ChatOpenAI({ model: "gpt-4o" }).invoke(
126
+ messages,
127
+ modifiedConfig,
128
+ );
124
129
  ```
130
+
125
131
  ## 🏆 Featured Examples
126
132
 
127
133
  <p align="center">
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  cn
3
- } from "./chunk-YLFAIYRY.mjs";
3
+ } from "./chunk-VYLLLBUP.mjs";
4
4
  import {
5
5
  __objRest,
6
6
  __spreadValues
@@ -16,11 +16,17 @@ var labelVariants = cva(
16
16
  );
17
17
  var Label = React.forwardRef((_a, ref) => {
18
18
  var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
19
- return /* @__PURE__ */ jsx(LabelPrimitive.Root, __spreadValues({ ref, className: cn(labelVariants(), className) }, props));
19
+ return /* @__PURE__ */ jsx(
20
+ LabelPrimitive.Root,
21
+ __spreadValues({
22
+ ref,
23
+ className: cn(labelVariants(), className)
24
+ }, props)
25
+ );
20
26
  });
21
27
  Label.displayName = LabelPrimitive.Root.displayName;
22
28
 
23
29
  export {
24
30
  Label
25
31
  };
26
- //# sourceMappingURL=chunk-D47EKHIF.mjs.map
32
+ //# sourceMappingURL=chunk-2X3CZVEP.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/ui/label.tsx"],"sourcesContent":["import * as React from \"react\";\nimport * as LabelPrimitive from \"@radix-ui/react-label\";\nimport { cva, type VariantProps } from \"class-variance-authority\";\n\nimport { cn } from \"../../lib/utils\";\n\nconst labelVariants = cva(\n \"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70\",\n);\n\nconst Label = React.forwardRef<\n React.ElementRef<typeof LabelPrimitive.Root>,\n React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> &\n VariantProps<typeof labelVariants>\n>(({ className, ...props }, ref) => (\n <LabelPrimitive.Root\n ref={ref}\n className={cn(labelVariants(), className)}\n {...props}\n />\n));\nLabel.displayName = LabelPrimitive.Root.displayName;\n\nexport { Label };\n"],"mappings":";;;;;;;;;AAAA,YAAY,WAAW;AACvB,YAAY,oBAAoB;AAChC,SAAS,WAA8B;AAarC;AATF,IAAM,gBAAgB;AAAA,EACpB;AACF;AAEA,IAAM,QAAc,iBAIlB,CAAC,IAAyB,QAAK;AAA9B,eAAE,YAdL,IAcG,IAAgB,kBAAhB,IAAgB,CAAd;AACH;AAAA,IAAgB;AAAA,IAAf;AAAA,MACC;AAAA,MACA,WAAW,GAAG,cAAc,GAAG,SAAS;AAAA,OACpC;AAAA,EACN;AAAA,CACD;AACD,MAAM,cAA6B,oBAAK;","names":[]}
@@ -1,24 +1,24 @@
1
1
  import {
2
2
  IncludedFilesPreview
3
- } from "./chunk-KMVGEY7Q.mjs";
3
+ } from "./chunk-IBZTDP72.mjs";
4
4
  import {
5
5
  use_autosize_textarea_default
6
- } from "./chunk-NAFNY4FL.mjs";
6
+ } from "./chunk-7V4ORVQX.mjs";
7
7
  import {
8
8
  Label
9
- } from "./chunk-D47EKHIF.mjs";
9
+ } from "./chunk-2X3CZVEP.mjs";
10
10
  import {
11
11
  useHoveringEditorContext
12
- } from "./chunk-LYB4B6MK.mjs";
12
+ } from "./chunk-UB4Y22EF.mjs";
13
13
  import {
14
14
  SourceSearchBox
15
- } from "./chunk-WGWQRALG.mjs";
15
+ } from "./chunk-AHNPJMBR.mjs";
16
16
  import {
17
17
  Button
18
- } from "./chunk-4PDYALMP.mjs";
18
+ } from "./chunk-LYNGBKJR.mjs";
19
19
  import {
20
20
  streamPromiseFlatten
21
- } from "./chunk-2QDCE7PD.mjs";
21
+ } from "./chunk-WXKPRNNO.mjs";
22
22
  import {
23
23
  __async
24
24
  } from "./chunk-MRXNTQOX.mjs";
@@ -37,9 +37,7 @@ var HoveringInsertionPromptBoxCore = ({
37
37
  const [editSuggestion, setEditSuggestion] = useState("");
38
38
  const [suggestionIsLoading, setSuggestionIsLoading] = useState(false);
39
39
  const [adjustmentPrompt, setAdjustmentPrompt] = useState("");
40
- const [generatingSuggestion, setGeneratingSuggestion] = useState(
41
- null
42
- );
40
+ const [generatingSuggestion, setGeneratingSuggestion] = useState(null);
43
41
  const adjustmentTextAreaRef = useRef(null);
44
42
  const suggestionTextAreaRef = useRef(null);
45
43
  const [filePointers, setFilePointers] = useState([]);
@@ -201,7 +199,13 @@ var HoveringInsertionPromptBoxCore = ({
201
199
  const sourceSearchWord = (sourceSearchCandidate == null ? void 0 : sourceSearchCandidate.startsWith("@")) ? sourceSearchCandidate.slice(1) : void 0;
202
200
  return /* @__PURE__ */ jsxs("div", { className: "w-full flex flex-col items-start relative gap-2", children: [
203
201
  AdjustmentPromptComponent,
204
- filePointers.length > 0 && /* @__PURE__ */ jsx(IncludedFilesPreview, { includedFiles: filePointers, setIncludedFiles: setFilePointers }),
202
+ filePointers.length > 0 && /* @__PURE__ */ jsx(
203
+ IncludedFilesPreview,
204
+ {
205
+ includedFiles: filePointers,
206
+ setIncludedFiles: setFilePointers
207
+ }
208
+ ),
205
209
  sourceSearchWord !== void 0 && /* @__PURE__ */ jsx(
206
210
  SourceSearchBox,
207
211
  {
@@ -209,7 +213,9 @@ var HoveringInsertionPromptBoxCore = ({
209
213
  suggestedFiles,
210
214
  onSelectedFile: (filePointer) => {
211
215
  var _a;
212
- setAdjustmentPrompt(adjustmentPrompt.replace(new RegExp(`@${sourceSearchWord}$`), ""));
216
+ setAdjustmentPrompt(
217
+ adjustmentPrompt.replace(new RegExp(`@${sourceSearchWord}$`), "")
218
+ );
213
219
  setFilePointers((prev) => [...prev, filePointer]);
214
220
  (_a = adjustmentTextAreaRef.current) == null ? void 0 : _a.focus();
215
221
  }
@@ -223,4 +229,4 @@ var HoveringInsertionPromptBoxCore = ({
223
229
  export {
224
230
  HoveringInsertionPromptBoxCore
225
231
  };
226
- //# sourceMappingURL=chunk-GU5LTWGL.mjs.map
232
+ //# sourceMappingURL=chunk-3WLGLZTY.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 {\n EditingEditorState,\n Generator_InsertionOrEditingSuggestion,\n} from \"../../../types/base/autosuggestions-bare-function\";\nimport { SourceSearchBox } from \"../../source-search-box/source-search-box\";\nimport { DocumentPointer, useCopilotContext } from \"@copilotkit/react-core\";\nimport { Button } from \"../../ui/button\";\nimport { Label } from \"../../ui/label\";\nimport { useCallback, useEffect, useRef, useState } from \"react\";\n\nimport { streamPromiseFlatten } from \"../../../lib/stream-promise-flatten\";\nimport { IncludedFilesPreview } from \"./included-files-preview\";\nimport { useHoveringEditorContext } from \"../hovering-editor-provider\";\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 = ({\n performInsertion,\n state,\n insertionOrEditingFunction,\n contextCategories,\n}: HoveringInsertionPromptBoxCoreProps) => {\n const { getDocumentsContext } = useCopilotContext();\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 { setIsDisplayed } = useHoveringEditorContext();\n\n const AdjustmentPromptComponent = (\n <>\n <Label className=\"\">{adjustmentLabel}</Label>\n <div className=\"relative w-full flex items-center\">\n <textarea\n data-testid=\"adjustment-prompt\"\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 data-testid=\"generate-button\"\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 data-testid=\"suggestion-result\"\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 data-testid=\"insert-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":";;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,SAA0B,yBAAyB;AAGnD,SAAS,aAAa,WAAW,QAAQ,gBAAgB;AA2JrD,mBACE,KACA,YAFF;AA1IG,IAAM,iCAAiC,CAAC;AAAA,EAC7C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAA2C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,MAAM,CAAC,IAC7B;AAEJ,SACE,qBAAC,SAAI,WAAU,mDACZ;AAAA;AAAA,IACA,aAAa,SAAS,KACrB;AAAA,MAAC;AAAA;AAAA,QACC,eAAe;AAAA,QACf,kBAAkB;AAAA;AAAA,IACpB;AAAA,IAED,qBAAqB,UACpB;AAAA,MAAC;AAAA;AAAA,QACC,YAAY;AAAA,QACZ;AAAA,QACA,gBAAgB,CAAC,gBAAgB;AAvQ3C;AAwQY;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;AAAA,IACF;AAAA,IAED,uBAAuB,sBAAsB;AAAA,IAC7C,uBAAuB,kBAAkB;AAAA,KAC5C;AAEJ;","names":[]}
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  defaultShouldSave,
3
3
  withPartialHistory
4
- } from "./chunk-4NHVQZ67.mjs";
4
+ } from "./chunk-PDFIUPCS.mjs";
5
5
 
6
6
  // src/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.tsx
7
7
  import { useMemo } from "react";
@@ -67,4 +67,4 @@ function useCopilotTextareaEditor() {
67
67
  export {
68
68
  useCopilotTextareaEditor
69
69
  };
70
- //# sourceMappingURL=chunk-DRV2FOHZ.mjs.map
70
+ //# sourceMappingURL=chunk-7GZWOXE4.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.tsx"],"sourcesContent":["import { useMemo } from \"react\";\nimport { createEditor, Element } from \"slate\";\nimport { withReact } from \"slate-react\";\nimport {\n defaultShouldSave,\n ShouldSaveToHistory,\n withPartialHistory,\n} from \"../../lib/slatejs-edits/with-partial-history\";\nimport { CustomEditor } from \"../../types/base/custom-editor\";\n\nconst shouldSave: ShouldSaveToHistory = (op, prev) => {\n const excludedNodeType = \"suggestion\";\n // Check if the operation involves the suggestion inline node type\n if (\n op.type === \"insert_node\" &&\n Element.isElement(op.node) &&\n op.node.type === excludedNodeType\n ) {\n return false;\n }\n\n if (\n op.type === \"remove_node\" &&\n Element.isElement(op.node) &&\n op.node.type === excludedNodeType\n ) {\n return false;\n }\n\n if (\n op.type === \"set_node\" &&\n \"type\" in op.newProperties &&\n op.newProperties.type === excludedNodeType\n ) {\n return false;\n }\n\n if (\n op.type == \"set_node\" &&\n \"type\" in op.properties &&\n op.properties.type === excludedNodeType\n ) {\n return false;\n }\n\n if (\n op.type === \"merge_node\" &&\n \"type\" in op.properties &&\n op.properties.type === excludedNodeType\n ) {\n return false;\n }\n\n if (\n op.type === \"split_node\" &&\n \"type\" in op.properties &&\n op.properties.type === excludedNodeType\n ) {\n return false;\n }\n\n // Otherwise, save the operation to history\n return defaultShouldSave(op, prev);\n};\n\nexport function useCopilotTextareaEditor(): CustomEditor {\n const editor = useMemo(() => {\n const editor = withPartialHistory(withReact(createEditor()), shouldSave);\n\n const { isVoid } = editor;\n editor.isVoid = (element) => {\n switch (element.type) {\n case \"suggestion\":\n return true;\n default:\n return isVoid(element);\n }\n };\n\n const { markableVoid } = editor;\n editor.markableVoid = (element) => {\n switch (element.type) {\n case \"suggestion\":\n return true;\n default:\n return markableVoid(element);\n }\n };\n\n const { isInline } = editor;\n editor.isInline = (element) => {\n switch (element.type) {\n case \"suggestion\":\n return element.inline;\n default:\n return isInline(element);\n }\n };\n\n return editor;\n }, []);\n\n return editor;\n}\n"],"mappings":";;;;;;AAAA,SAAS,eAAe;AACxB,SAAS,cAAc,eAAe;AACtC,SAAS,iBAAiB;AAQ1B,IAAM,aAAkC,CAAC,IAAI,SAAS;AACpD,QAAM,mBAAmB;AAEzB,MACE,GAAG,SAAS,iBACZ,QAAQ,UAAU,GAAG,IAAI,KACzB,GAAG,KAAK,SAAS,kBACjB;AACA,WAAO;AAAA,EACT;AAEA,MACE,GAAG,SAAS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;","names":["editor"]}
@@ -14,4 +14,4 @@ var use_autosize_textarea_default = useAutosizeTextArea;
14
14
  export {
15
15
  use_autosize_textarea_default
16
16
  };
17
- //# sourceMappingURL=chunk-NAFNY4FL.mjs.map
17
+ //# sourceMappingURL=chunk-7V4ORVQX.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/hooks/misc/use-autosize-textarea.tsx"],"sourcesContent":["import { Ref, RefObject, useEffect } from \"react\";\n\n// Updates the height of a <textarea> when the value changes.\nconst useAutosizeTextArea = (\n textAreaRef: RefObject<HTMLTextAreaElement | null>,\n value: string,\n) => {\n useEffect(() => {\n if (textAreaRef.current !== null) {\n // We need to reset the height momentarily to get the correct scrollHeight for the textarea\n textAreaRef.current.style.height = \"0px\";\n const scrollHeight = textAreaRef.current.scrollHeight;\n\n // We then set the height directly, outside of the render loop\n // Trying to set this with state or a ref will product an incorrect value.\n textAreaRef.current.style.height = scrollHeight + \"px\";\n }\n }, [textAreaRef, value]);\n};\n\nexport default useAutosizeTextArea;\n"],"mappings":";AAAA,SAAyB,iBAAiB;AAG1C,IAAM,sBAAsB,CAC1B,aACA,UACG;AACH,YAAU,MAAM;AACd,QAAI,YAAY,YAAY,MAAM;AAEhC,kBAAY,QAAQ,MAAM,SAAS;AACnC,YAAM,eAAe,YAAY,QAAQ;AAIzC,kBAAY,QAAQ,MAAM,SAAS,eAAe;AAAA,IACpD;AAAA,EACF,GAAG,CAAC,aAAa,KAAK,CAAC;AACzB;AAEA,IAAO,gCAAQ;","names":[]}
@@ -1,5 +1,12 @@
1
1
  // src/lib/get-text-around-cursor.ts
2
- import { Editor, Path, Range, Text, Element, Point } from "slate";
2
+ import {
3
+ Editor,
4
+ Path,
5
+ Range,
6
+ Text,
7
+ Element,
8
+ Point
9
+ } from "slate";
3
10
  function getTextAroundCollapsedCursor(editor) {
4
11
  const { selection } = editor;
5
12
  if (!selection || !Range.isCollapsed(selection)) {
@@ -101,4 +108,4 @@ export {
101
108
  getFullEditorTextWithNewlines,
102
109
  extractTextWithNewlines
103
110
  };
104
- //# sourceMappingURL=chunk-ECR45NSD.mjs.map
111
+ //# sourceMappingURL=chunk-A6YGJFQI.mjs.map
@@ -0,0 +1 @@
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,O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AAK;AAAA,IACZ;AAAA,EACF,CAAC,GAAG;AACF,QAAI,IAAI,KAAK;AAGb,UAAM,CAAC,KAAK,IAAI,OAAO,MAAM,QAAQ;AAAA,MACnC,IAAI;AAAA,MACJ,OAAO,CAAC,MAAM,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":[]}
@@ -6,7 +6,7 @@ import {
6
6
  CommandItem,
7
7
  CommandList,
8
8
  CommandSeparator
9
- } from "./chunk-VSVQZUPW.mjs";
9
+ } from "./chunk-ARLBRSB7.mjs";
10
10
 
11
11
  // src/components/source-search-box/source-search-box.tsx
12
12
  import { useState } from "react";
@@ -73,11 +73,18 @@ function Logo({
73
73
  width,
74
74
  height
75
75
  }) {
76
- return /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center", style: { width, height }, children });
76
+ return /* @__PURE__ */ jsx(
77
+ "div",
78
+ {
79
+ className: "flex items-center justify-center",
80
+ style: { width, height },
81
+ children
82
+ }
83
+ );
77
84
  }
78
85
 
79
86
  export {
80
87
  SourceSearchBox,
81
88
  Logo
82
89
  };
83
- //# sourceMappingURL=chunk-WGWQRALG.mjs.map
90
+ //# sourceMappingURL=chunk-AHNPJMBR.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/source-search-box/source-search-box.tsx"],"sourcesContent":["import { useState } from \"react\";\nimport {\n Command,\n CommandDialog,\n CommandEmpty,\n CommandGroup,\n CommandInput,\n CommandItem,\n CommandList,\n CommandSeparator,\n CommandShortcut,\n} from \"../ui/command\";\n\nimport {\n Calculator,\n Calendar,\n CreditCard,\n Settings,\n Smile,\n User,\n} from \"lucide-react\";\n\nimport { DocumentPointer } from \"@copilotkit/react-core\";\n\nexport interface SourceSearchBoxProps {\n searchTerm: string;\n suggestedFiles: DocumentPointer[];\n onSelectedFile: (filePointer: DocumentPointer) => void;\n}\n\nexport function SourceSearchBox(props: SourceSearchBoxProps) {\n const [selectedValue, setSelectedValue] = useState<string>(\"\");\n\n return (\n <Command\n className=\"rounded-lg border shadow-md\"\n value={selectedValue}\n onValueChange={(value) => {\n setSelectedValue(value);\n }}\n filter={(value, search) => {\n // if the search term is empty, show all commands\n if (props.searchTerm === \"\") return 1;\n\n // if the search term is a prefix of the command, show it\n if (value.startsWith(props.searchTerm)) return 1;\n\n // otherwise, don't show it\n return 0;\n }}\n >\n <CommandInput\n value={props.searchTerm}\n className=\"rounded-t-lg hidden\"\n placeholder=\"Search for a command...\"\n />\n <CommandList>\n <CommandEmpty>No results found.</CommandEmpty>\n\n <CommandGroup heading=\"Available resources\">\n {props.suggestedFiles.map((filePointer) => {\n return (\n <CommandItem\n key={`word-${filePointer.sourceApplication}.${filePointer.name}`}\n value={filePointer.name}\n onSelect={(value) => {\n props.onSelectedFile(filePointer);\n }}\n >\n <div className=\" px-3 flex flex-row gap-1 items-center\">\n <Logo width=\"20px\" height=\"20px\">\n <img\n src={filePointer.iconImageUri}\n alt={filePointer.sourceApplication}\n className=\"w-full h-full\"\n />\n </Logo>\n {filePointer.name}\n </div>\n </CommandItem>\n );\n })}\n </CommandGroup>\n\n {/* <CommandGroup heading=\"Suggestions\">\n <CommandItem\n onSelect={(value) => {\n console.log(value);\n console.log(value);\n }}\n >\n <Calendar className=\"mr-2 h-4 w-4\" />\n <span>Calendar</span>\n </CommandItem>\n <CommandItem>\n <Smile className=\"mr-2 h-4 w-4\" />\n <span>Search Emoji</span>\n </CommandItem>\n <CommandItem>\n <Calculator className=\"mr-2 h-4 w-4\" />\n <span>Calculator</span>\n </CommandItem>\n </CommandGroup> */}\n <CommandSeparator />\n </CommandList>\n </Command>\n );\n}\n\nexport function Logo({\n children,\n width,\n height,\n}: {\n children: React.ReactNode;\n width: string;\n height: string;\n}) {\n return (\n <div\n className=\"flex items-center justify-center\"\n style={{ width: width, height: height }}\n >\n {children}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;AAAA,SAAS,gBAAgB;AAmDnB,cAkBU,YAlBV;AArBC,SAAS,gBAAgB,OAA6B;AAC3D,QAAM,CAAC,eAAe,gBAAgB,IAAI,SAAiB,EAAE;AAE7D,SACE;AAAA,IAAC;AAAA;AAAA,MACC,WAAU;AAAA,MACV,OAAO;AAAA,MACP,eAAe,CAAC,UAAU;AACxB,yBAAiB,KAAK;AAAA,MACxB;AAAA,MACA,QAAQ,CAAC,OAAO,WAAW;AAEzB,YAAI,MAAM,eAAe;AAAI,iBAAO;AAGpC,YAAI,MAAM,WAAW,MAAM,UAAU;AAAG,iBAAO;AAG/C,eAAO;AAAA,MACT;AAAA,MAEA;AAAA;AAAA,UAAC;AAAA;AAAA,YACC,OAAO,MAAM;AAAA,YACb,WAAU;AAAA,YACV,aAAY;AAAA;AAAA,QACd;AAAA,QACA,qBAAC,eACC;AAAA,8BAAC,gBAAa,+BAAiB;AAAA,UAE/B,oBAAC,gBAAa,SAAQ,uBACnB,gBAAM,eAAe,IAAI,CAAC,gBAAgB;AACzC,mBACE;AAAA,cAAC;AAAA;AAAA,gBAEC,OAAO,YAAY;AAAA,gBACnB,UAAU,CAAC,UAAU;AACnB,wBAAM,eAAe,WAAW;AAAA,gBAClC;AAAA,gBAEA,+BAAC,SAAI,WAAU,2CACb;AAAA,sCAAC,QAAK,OAAM,QAAO,QAAO,QACxB;AAAA,oBAAC;AAAA;AAAA,sBACC,KAAK,YAAY;AAAA,sBACjB,KAAK,YAAY;AAAA,sBACjB,WAAU;AAAA;AAAA,kBACZ,GACF;AAAA,kBACC,YAAY;AAAA,mBACf;AAAA;AAAA,cAfK,QAAQ,YAAY,qBAAqB,YAAY;AAAA,YAgB5D;AAAA,UAEJ,CAAC,GACH;AAAA,UAqBA,oBAAC,oBAAiB;AAAA,WACpB;AAAA;AAAA;AAAA,EACF;AAEJ;AAEO,SAAS,KAAK;AAAA,EACnB;AAAA,EACA;AAAA,EACA;AACF,GAIG;AACD,SACE;AAAA,IAAC;AAAA;AAAA,MACC,WAAU;AAAA,MACV,OAAO,EAAE,OAAc,OAAe;AAAA,MAErC;AAAA;AAAA,EACH;AAEJ;","names":[]}
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  Dialog,
3
3
  DialogContent
4
- } from "./chunk-I72DKFHD.mjs";
4
+ } from "./chunk-CFCMZVQ2.mjs";
5
5
  import {
6
6
  cn
7
- } from "./chunk-YLFAIYRY.mjs";
7
+ } from "./chunk-VYLLLBUP.mjs";
8
8
  import {
9
9
  __objRest,
10
10
  __spreadProps,
@@ -53,12 +53,21 @@ var CommandList = React.forwardRef((_a, ref) => {
53
53
  CommandPrimitive.List,
54
54
  __spreadValues({
55
55
  ref,
56
- className: cn("max-h-[300px] overflow-y-auto overflow-x-hidden pb-2", className)
56
+ className: cn(
57
+ "max-h-[300px] overflow-y-auto overflow-x-hidden pb-2",
58
+ className
59
+ )
57
60
  }, props)
58
61
  );
59
62
  });
60
63
  CommandList.displayName = CommandPrimitive.List.displayName;
61
- var CommandEmpty = React.forwardRef((props, ref) => /* @__PURE__ */ jsx(CommandPrimitive.Empty, __spreadValues({ ref, className: "py-6 text-center text-sm" }, props)));
64
+ var CommandEmpty = React.forwardRef((props, ref) => /* @__PURE__ */ jsx(
65
+ CommandPrimitive.Empty,
66
+ __spreadValues({
67
+ ref,
68
+ className: "py-6 text-center text-sm"
69
+ }, props)
70
+ ));
62
71
  CommandEmpty.displayName = CommandPrimitive.Empty.displayName;
63
72
  var CommandGroup = React.forwardRef((_a, ref) => {
64
73
  var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
@@ -100,11 +109,18 @@ var CommandItem = React.forwardRef((_a, ref) => {
100
109
  });
101
110
  CommandItem.displayName = CommandPrimitive.Item.displayName;
102
111
  var CommandShortcut = (_a) => {
103
- var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
112
+ var _b = _a, {
113
+ className
114
+ } = _b, props = __objRest(_b, [
115
+ "className"
116
+ ]);
104
117
  return /* @__PURE__ */ jsx(
105
118
  "span",
106
119
  __spreadValues({
107
- className: cn("ml-auto text-xs tracking-widest text-muted-foreground", className)
120
+ className: cn(
121
+ "ml-auto text-xs tracking-widest text-muted-foreground",
122
+ className
123
+ )
108
124
  }, props)
109
125
  );
110
126
  };
@@ -121,4 +137,4 @@ export {
121
137
  CommandItem,
122
138
  CommandShortcut
123
139
  };
124
- //# sourceMappingURL=chunk-VSVQZUPW.mjs.map
140
+ //# sourceMappingURL=chunk-ARLBRSB7.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/ui/command.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { DialogProps } from \"@radix-ui/react-dialog\";\nimport { Command as CommandPrimitive } from \"cmdk\";\nimport { cn } from \"../../lib/utils\";\nimport { Dialog, DialogContent } from \"./dialog\";\n\nconst Command = React.forwardRef<\n React.ElementRef<typeof CommandPrimitive>,\n React.ComponentPropsWithoutRef<typeof CommandPrimitive>\n>(({ className, ...props }, ref) => (\n <CommandPrimitive\n ref={ref}\n className={cn(\n \"flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground\",\n className,\n )}\n {...props}\n />\n));\nCommand.displayName = CommandPrimitive.displayName;\n\ninterface CommandDialogProps extends DialogProps {}\n\nconst CommandDialog = ({ children, ...props }: CommandDialogProps) => {\n return (\n <Dialog {...props}>\n <DialogContent className=\"overflow-hidden p-0 shadow-lg\">\n <Command className=\"[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5\">\n {children}\n </Command>\n </DialogContent>\n </Dialog>\n );\n};\n\nconst CommandInput = React.forwardRef<\n React.ElementRef<typeof CommandPrimitive.Input>,\n React.ComponentPropsWithoutRef<typeof CommandPrimitive.Input>\n>(({ className, ...props }, ref) => (\n <div className=\"flex items-center border-b px-3\" cmdk-input-wrapper=\"\">\n {/* <Search className=\"mr-2 h-4 w-4 shrink-0 opacity-50\" /> */}\n <CommandPrimitive.Input\n ref={ref}\n className={cn(\n \"flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50\",\n className,\n )}\n {...props}\n />\n </div>\n));\n\nCommandInput.displayName = CommandPrimitive.Input.displayName;\n\nconst CommandList = React.forwardRef<\n React.ElementRef<typeof CommandPrimitive.List>,\n React.ComponentPropsWithoutRef<typeof CommandPrimitive.List>\n>(({ className, ...props }, ref) => (\n <CommandPrimitive.List\n ref={ref}\n className={cn(\n \"max-h-[300px] overflow-y-auto overflow-x-hidden pb-2\",\n className,\n )}\n {...props}\n />\n));\n\nCommandList.displayName = CommandPrimitive.List.displayName;\n\nconst CommandEmpty = React.forwardRef<\n React.ElementRef<typeof CommandPrimitive.Empty>,\n React.ComponentPropsWithoutRef<typeof CommandPrimitive.Empty>\n>((props, ref) => (\n <CommandPrimitive.Empty\n ref={ref}\n className=\"py-6 text-center text-sm\"\n {...props}\n />\n));\n\nCommandEmpty.displayName = CommandPrimitive.Empty.displayName;\n\nconst CommandGroup = React.forwardRef<\n React.ElementRef<typeof CommandPrimitive.Group>,\n React.ComponentPropsWithoutRef<typeof CommandPrimitive.Group>\n>(({ className, ...props }, ref) => (\n <CommandPrimitive.Group\n ref={ref}\n className={cn(\n \"overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground\",\n className,\n )}\n {...props}\n />\n));\n\nCommandGroup.displayName = CommandPrimitive.Group.displayName;\n\nconst CommandSeparator = React.forwardRef<\n React.ElementRef<typeof CommandPrimitive.Separator>,\n React.ComponentPropsWithoutRef<typeof CommandPrimitive.Separator>\n>(({ className, ...props }, ref) => (\n <CommandPrimitive.Separator\n ref={ref}\n className={cn(\"-mx-1 h-px bg-border\", className)}\n {...props}\n />\n));\nCommandSeparator.displayName = CommandPrimitive.Separator.displayName;\n\nconst CommandItem = React.forwardRef<\n React.ElementRef<typeof CommandPrimitive.Item>,\n React.ComponentPropsWithoutRef<typeof CommandPrimitive.Item>\n>(({ className, ...props }, ref) => (\n <CommandPrimitive.Item\n ref={ref}\n className={cn(\n \"relative flex cursor-default select-none items-center rounded-sm text-sm outline-none aria-selected:bg-accent aria-selected:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50\",\n className,\n )}\n {...props}\n />\n));\n\nCommandItem.displayName = CommandPrimitive.Item.displayName;\n\nconst CommandShortcut = ({\n className,\n ...props\n}: React.HTMLAttributes<HTMLSpanElement>) => {\n return (\n <span\n className={cn(\n \"ml-auto text-xs tracking-widest text-muted-foreground\",\n className,\n )}\n {...props}\n />\n );\n};\nCommandShortcut.displayName = \"CommandShortcut\";\n\nexport {\n Command,\n CommandDialog,\n CommandInput,\n CommandList,\n CommandEmpty,\n CommandGroup,\n CommandItem,\n CommandShortcut,\n CommandSeparator,\n};\n"],"mappings":";;;;;;;;;;;;;;AAAA,YAAY,WAAW;AAEvB,SAAS,WAAW,wBAAwB;AAQ1C;AAJF,IAAM,UAAgB,iBAGpB,CAAC,IAAyB,QAAK;AAA9B,eAAE,YATL,IASG,IAAgB,kBAAhB,IAAgB,CAAd;AACH;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA,WAAW;AAAA,QACT;AAAA,QACA;AAAA,MACF;AAAA,OACI;AAAA,EACN;AAAA,CACD;AACD,QAAQ,cAAc,iBAAiB;AAIvC,IAAM,gBAAgB,CAAC,OAA+C;AAA/C,eAAE,WAvBzB,IAuBuB,IAAe,kBAAf,IAAe,CAAb;AACvB,SACE,oBAAC,yCAAW,QAAX,EACC,8BAAC,iBAAc,WAAU,iCACvB,8BAAC,WAAQ,WAAU,+WAChB,UACH,GACF,IACF;AAEJ;AAEA,IAAM,eAAqB,iBAGzB,CAAC,IAAyB,QAAK;AAA9B,eAAE,YAtCL,IAsCG,IAAgB,kBAAhB,IAAgB,CAAd;AACH,6BAAC,SAAI,WAAU,mCAAkC,sBAAmB,IAElE;AAAA,IAAC,iBAAiB;AAAA,IAAjB;AAAA,MACC;AAAA,MACA,WAAW;AAAA,QACT;AAAA,QACA;AAAA,MACF;AAAA,OACI;AAAA,EACN,GACF;AAAA,CACD;AAED,aAAa,cAAc,iBAAiB,MAAM;AAElD,IAAM,cAAoB,iBAGxB,CAAC,IAAyB,QAAK;AAA9B,eAAE,YAzDL,IAyDG,IAAgB,kBAAhB,IAAgB,CAAd;AACH;AAAA,IAAC,iBAAiB;AAAA,IAAjB;AAAA,MACC;AAAA,MACA,WAAW;AAAA,QACT;AAAA,QACA;AAAA,MACF;AAAA,OACI;AAAA,EACN;AAAA,CACD;AAED,YAAY,cAAc,iBAAiB,KAAK;AAEhD,IAAM,eAAqB,iBAGzB,CAAC,OAAO,QACR;AA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js";
3
+ } from "./chunk-ZWI5KPQ5.mjs";
4
4
  import {
5
5
  useHoveringEditorContext
6
- } from "./chunk-LYB4B6MK.mjs";
6
+ } from "./chunk-UB4Y22EF.mjs";
7
7
  import {
8
8
  Menu,
9
9
  Portal
10
- } from "./chunk-2IWVZ4PP.mjs";
10
+ } from "./chunk-MQBPYOOZ.mjs";
11
11
  import {
12
12
  getFullEditorTextWithNewlines,
13
13
  getTextAroundSelection
14
- } from "./chunk-ECR45NSD.mjs";
14
+ } from "./chunk-A6YGJFQI.mjs";
15
15
 
16
16
  // src/components/hovering-toolbar/hovering-toolbar.tsx
17
17
  import { useEffect, useLayoutEffect, useRef, useState } from "react";
@@ -117,4 +117,4 @@ function editorState(editor, selection) {
117
117
  export {
118
118
  HoveringToolbar
119
119
  };
120
- //# sourceMappingURL=chunk-72GJNLCO.mjs.map
120
+ //# sourceMappingURL=chunk-AZ7RF6ED.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/hovering-toolbar/hovering-toolbar.tsx"],"sourcesContent":["import { useEffect, useLayoutEffect, useRef, useState } from \"react\";\nimport { Editor, Location, Transforms } from \"slate\";\nimport { useSlate, useSlateSelection } from \"slate-react\";\nimport {\n getFullEditorTextWithNewlines,\n getTextAroundSelection,\n} from \"../../lib/get-text-around-cursor\";\nimport {\n EditingEditorState,\n InsertionEditorApiConfig,\n} from \"../../types/base/autosuggestions-bare-function\";\nimport { useHoveringEditorContext } from \"./hovering-editor-provider\";\nimport { Menu, Portal } from \"./hovering-toolbar-components\";\nimport { HoveringInsertionPromptBox } from \"./text-insertion-prompt-box\";\n\nexport interface HoveringToolbarProps {\n apiConfig: InsertionEditorApiConfig;\n contextCategories: string[];\n hoverMenuClassname: string | undefined;\n}\n\nexport const HoveringToolbar = (props: HoveringToolbarProps) => {\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 const isShown = isClient && isDisplayed && selection;\n\n useLayoutEffect(() => {\n const el = ref.current;\n const { selection } = editor;\n\n if (!el || !isShown) {\n return;\n }\n\n if (!selection) {\n el.removeAttribute(\"style\");\n return;\n }\n\n const domSelection = window.getSelection();\n if (!domSelection || domSelection.rangeCount === 0) {\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 verticalOffsetFromCorner = 0;\n const horizontalOffsetFromCorner = 0;\n\n // position the toolbar below the selection\n let top = rect.bottom + window.scrollY + verticalOffsetFromCorner;\n\n // no space left at bottom, move up\n if (\n rect.bottom + el.offsetHeight >\n window.innerHeight - verticalOffsetFromCorner\n ) {\n top =\n rect.top + window.scrollY - el.offsetHeight - verticalOffsetFromCorner;\n }\n\n // position the toolbar in the center of the selection\n let left =\n rect.left +\n window.scrollX -\n el.offsetWidth / 2 +\n rect.width / 2 +\n horizontalOffsetFromCorner;\n\n // no space left at left, move right\n if (left < horizontalOffsetFromCorner) {\n left = horizontalOffsetFromCorner;\n }\n // no space left at right, move left\n else if (\n left + el.offsetWidth >\n window.innerWidth - horizontalOffsetFromCorner\n ) {\n left = window.innerWidth - el.offsetWidth - horizontalOffsetFromCorner;\n }\n\n el.style.opacity = \"1\";\n el.style.position = \"absolute\";\n\n el.style.top = `${top}px`;\n el.style.left = `${left}px`;\n }, [isShown]);\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\n return () => {\n document.removeEventListener(\"mousedown\", handleClickOutside);\n };\n }, [ref, setIsDisplayed]);\n\n if (!isShown) {\n return null;\n }\n\n return (\n <Portal>\n <Menu\n ref={ref}\n className={\n \"copilot-kit-textarea-css-scope \" +\n (props.hoverMenuClassname ||\n \"p-2 absolute z-10 top-[-10000px] left-[-10000px] mt-[-6px] opacity-0 transition-opacity duration-700\")\n }\n data-testid=\"hovering-toolbar\"\n >\n <HoveringInsertionPromptBox\n editorState={editorState(editor, selection)}\n apiConfig={props.apiConfig}\n performInsertion={(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 </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":";;;;;;;;;;;;;;;;AAAA,SAAS,WAAW,iBAAiB,QAAQ,gBAAgB;AAC7D,SAA2B,kBAAkB;AAC7C,SAAS,UAAU,yBAAyB;AA0IpC;AAvHD,IAAM,kBAAkB,CAAC,UAAgC;AAC9D,QAAM,MAAM,OAAuB,IAAI;AACvC,QAAM,SAAS,SAAS;AACxB,QAAM,YAAY,kBAAkB;AACpC,QAAM,EAAE,aAAa,eAAe,IAAI,yBAAyB;AAGjE,QAAM,CAAC,UAAU,WAAW,IAAI,SAAS,KAAK;AAC9C,YAAU,MAAM;AACd,gBAAY,IAAI;AAAA,EAClB,GAAG,CAAC,CAAC;AAEL,QAAM,UAAU,YAAY,eAAe;AAE3C,kBAAgB,MAAM;AACpB,UAAM,KAAK,IAAI;AACf,UAAM,EAAE,WAAAA,WAAU,IAAI;AAEtB,QAAI,CAAC,MAAM,CAAC,SAAS;AACnB;AAAA,IACF;AAEA,QAAI,CAACA,YAA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ACC;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA,WACE,qCACC,MAAM,sBACL;AAAA,MAEJ,eAAY;AAAA,MAEZ;AAAA,QAAC;AAAA;AAAA,UACC,aAAa,YAAY,QAAQ,SAAS;AAAA,UAC1C,WAAW,MAAM;AAAA,UACjB,kBAAkB,CAAC,iBAAiB;AAElC,uBAAW,OAAO,QAAQ,EAAE,IAAI,UAAU,CAAC;AAC3C,uBAAW,WAAW,QAAQ,cAAc;AAAA,cAC1C,IAAI;AAAA,YACN,CAAC;AACD,2BAAe,KAAK;AAAA,UACtB;AAAA,UACA,mBAAmB,MAAM;AAAA;AAAA,MAC3B;AAAA;AAAA,EACF,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,6 +1,6 @@
1
1
  import {
2
2
  cn
3
- } from "./chunk-YLFAIYRY.mjs";
3
+ } from "./chunk-VYLLLBUP.mjs";
4
4
  import {
5
5
  __objRest,
6
6
  __spreadProps,
@@ -65,16 +65,35 @@ var DialogContent = React.forwardRef((_a, ref) => {
65
65
  });
66
66
  DialogContent.displayName = DialogPrimitive.Content.displayName;
67
67
  var DialogHeader = (_a) => {
68
- var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
69
- return /* @__PURE__ */ jsx("div", __spreadValues({ className: cn("flex flex-col space-y-1.5 text-center sm:text-left", className) }, props));
68
+ var _b = _a, {
69
+ className
70
+ } = _b, props = __objRest(_b, [
71
+ "className"
72
+ ]);
73
+ return /* @__PURE__ */ jsx(
74
+ "div",
75
+ __spreadValues({
76
+ className: cn(
77
+ "flex flex-col space-y-1.5 text-center sm:text-left",
78
+ className
79
+ )
80
+ }, props)
81
+ );
70
82
  };
71
83
  DialogHeader.displayName = "DialogHeader";
72
84
  var DialogFooter = (_a) => {
73
- var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
85
+ var _b = _a, {
86
+ className
87
+ } = _b, props = __objRest(_b, [
88
+ "className"
89
+ ]);
74
90
  return /* @__PURE__ */ jsx(
75
91
  "div",
76
92
  __spreadValues({
77
- className: cn("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2", className)
93
+ className: cn(
94
+ "flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",
95
+ className
96
+ )
78
97
  }, props)
79
98
  );
80
99
  };
@@ -85,7 +104,10 @@ var DialogTitle = React.forwardRef((_a, ref) => {
85
104
  DialogPrimitive.Title,
86
105
  __spreadValues({
87
106
  ref,
88
- className: cn("text-lg font-semibold leading-none tracking-tight", className)
107
+ className: cn(
108
+ "text-lg font-semibold leading-none tracking-tight",
109
+ className
110
+ )
89
111
  }, props)
90
112
  );
91
113
  });
@@ -111,4 +133,4 @@ export {
111
133
  DialogTitle,
112
134
  DialogDescription
113
135
  };
114
- //# sourceMappingURL=chunk-I72DKFHD.mjs.map
136
+ //# sourceMappingURL=chunk-CFCMZVQ2.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/ui/dialog.tsx"],"sourcesContent":["import * as React from \"react\";\nimport * as DialogPrimitive from \"@radix-ui/react-dialog\";\nimport { X } from \"lucide-react\";\n\nimport { cn } from \"../../lib/utils\";\n\nconst Dialog = DialogPrimitive.Root;\n\nconst DialogTrigger = DialogPrimitive.Trigger;\n\nconst DialogPortal = ({\n className,\n children,\n ...props\n}: DialogPrimitive.DialogPortalProps & { className?: string }) => (\n <DialogPrimitive.Portal {...props}>\n <div className={cn(className)}>{children}</div>\n </DialogPrimitive.Portal>\n);\n\nDialogPortal.displayName = DialogPrimitive.Portal.displayName;\n\nconst DialogOverlay = React.forwardRef<\n React.ElementRef<typeof DialogPrimitive.Overlay>,\n React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>\n>(({ className, ...props }, ref) => (\n <DialogPrimitive.Overlay\n ref={ref}\n className={cn(\n \"fixed inset-0 z-50 bg-background/80 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0\",\n className,\n )}\n {...props}\n />\n));\nDialogOverlay.displayName = DialogPrimitive.Overlay.displayName;\n\nconst DialogContent = React.forwardRef<\n React.ElementRef<typeof DialogPrimitive.Content>,\n React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>\n>(({ className, children, ...props }, ref) => (\n <DialogPortal>\n <DialogOverlay />\n <DialogPrimitive.Content\n ref={ref}\n className={cn(\n \"fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg md:w-full\",\n className,\n )}\n {...props}\n >\n {children}\n <DialogPrimitive.Close className=\"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground\">\n <X className=\"h-4 w-4\" />\n <span className=\"sr-only\">Close</span>\n </DialogPrimitive.Close>\n </DialogPrimitive.Content>\n </DialogPortal>\n));\nDialogContent.displayName = DialogPrimitive.Content.displayName;\n\nconst DialogHeader = ({\n className,\n ...props\n}: React.HTMLAttributes<HTMLDivElement>) => (\n <div\n className={cn(\n \"flex flex-col space-y-1.5 text-center sm:text-left\",\n className,\n )}\n {...props}\n />\n);\nDialogHeader.displayName = \"DialogHeader\";\n\nconst DialogFooter = ({\n className,\n ...props\n}: React.HTMLAttributes<HTMLDivElement>) => (\n <div\n className={cn(\n \"flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2\",\n className,\n )}\n {...props}\n />\n);\nDialogFooter.displayName = \"DialogFooter\";\n\nconst DialogTitle = React.forwardRef<\n React.ElementRef<typeof DialogPrimitive.Title>,\n React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>\n>(({ className, ...props }, ref) => (\n <DialogPrimitive.Title\n ref={ref}\n className={cn(\n \"text-lg font-semibold leading-none tracking-tight\",\n className,\n )}\n {...props}\n />\n));\nDialogTitle.displayName = DialogPrimitive.Title.displayName;\n\nconst DialogDescription = React.forwardRef<\n React.ElementRef<typeof DialogPrimitive.Description>,\n React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description>\n>(({ className, ...props }, ref) => (\n <DialogPrimitive.Description\n ref={ref}\n className={cn(\"text-sm text-muted-foreground\", className)}\n {...props}\n />\n));\nDialogDescription.displayName = DialogPrimitive.Description.displayName;\n\nexport {\n Dialog,\n DialogTrigger,\n DialogContent,\n DialogHeader,\n DialogFooter,\n DialogTitle,\n DialogDescription,\n};\n"],"mappings":";;;;;;;;;;AAAA,YAAY,WAAW;AACvB,YAAY,qBAAqB;AACjC,SAAS,SAAS;AAcd,cAoCE,YApCF;AAVJ,IAAM,SAAyB;AAE/B,IAAM,gBAAgC;AAEtC,IAAM,eAAe,CAAC,OAIyC;AAJzC,eACpB;AAAA;AAAA,IACA;AAAA,EAZF,IAUsB,IAGjB,kBAHiB,IAGjB;AAAA,IAFH;AAAA,IACA;AAAA;AAGA,6BAAiB,wBAAhB,iCAA2B,QAA3B,EACC,8BAAC,SAAI,WAAW,GAAG,SAAS,GAAI,UAAS,IAC3C;AAAA;AAGF,aAAa,cAA8B,uBAAO;AAElD,IAAM,gBAAsB,iBAG1B,CAAC,IAAyB,QAAK;AAA9B,eAAE,YAzBL,IAyBG,IAAgB,kBAAhB,IAAgB,CA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AAiB;AAAA,IAAhB;AAAA,MACC;AAAA,MACA,WAAW;AAAA,QACT;AAAA,QACA;AAAA,MACF;AAAA,OACI;AAAA,EACN;AAAA,CACD;AACD,YAAY,cAA8B,sBAAM;AAEhD,IAAM,oBAA0B,iBAG9B,CAAC,IAAyB,QAAK;AAA9B,eAAE,YA3GL,IA2GG,IAAgB,kBAAhB,IAAgB,CAAd;AACH;AAAA,IAAiB;AAAA,IAAhB;AAAA,MACC;AAAA,MACA,WAAW,GAAG,iCAAiC,SAAS;AAAA,OACpD;AAAA,EACN;AAAA,CACD;AACD,kBAAkB,cAA8B,4BAAY;","names":[]}
@@ -42,4 +42,4 @@ var editorToText = (editor) => {
42
42
  export {
43
43
  editorToText
44
44
  };
45
- //# sourceMappingURL=chunk-T6MTDQZ7.mjs.map
45
+ //# sourceMappingURL=chunk-CMKGYQFX.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/lib/editor-to-text.ts"],"sourcesContent":["import { BaseEditor, Descendant, Element } from \"slate\";\nimport { HistoryEditor } from \"slate-history\";\nimport { ReactEditor } from \"slate-react\";\nimport { SuggestionAwareText } from \"../types/base/custom-editor\";\n\nfunction nodeChildrenToTextComponents(\n editor: BaseEditor & ReactEditor & HistoryEditor,\n nodes: Descendant[],\n): SuggestionAwareText[] {\n // find inlineable elements\n const indeciesOfInlineElements = new Set(\n nodes\n .map((node, index) => {\n if (Element.isElement(node) && editor.isInline(node)) {\n return index;\n }\n return -1;\n })\n .filter((index) => index !== -1),\n );\n\n // ignorable elements = inline elements,\n // or neighbors of inline elements that are {text: \"\"}\n const nonIgnorableItems = nodes.filter((node, index) => {\n const isInline = indeciesOfInlineElements.has(index);\n if (isInline) {\n return false;\n }\n\n const isNeighbourOfInline =\n indeciesOfInlineElements.has(index - 1) ||\n indeciesOfInlineElements.has(index + 1);\n if (isNeighbourOfInline) {\n return (node as any).text !== \"\";\n }\n\n return true;\n });\n\n return nonIgnorableItems\n .map((node) => {\n if (Element.isElement(node)) {\n switch (node.type) {\n case \"paragraph\":\n return nodeChildrenToTextComponents(editor, node.children);\n case \"suggestion\":\n return [];\n }\n } else {\n return [node];\n }\n })\n .reduce((acc, val) => acc.concat(val), []);\n}\n\nexport const editorToText = (\n editor: BaseEditor & ReactEditor & HistoryEditor,\n) => {\n const flattened = nodeChildrenToTextComponents(editor, editor.children);\n\n const text = flattened.map((textComponent) => textComponent.text).join(\"\\n\");\n\n return text;\n};\n"],"mappings":";AAAA,SAAiC,eAAe;AAKhD,SAAS,6BACP,QACA,OACuB;AAEvB,QAAM,2BAA2B,IAAI;AAAA,IACnC,MACG,IAAI,CAAC,MAAM,UAAU;AACpB,UAAI,QAAQ,UAAU,IAAI,KAAK,OAAO,SAAS,IAAI,GAAG;AACpD,eAAO;AAAA,MACT;AACA,aAAO;AAAA,IACT,CAAC,EACA,OAAO,CAAC,UAAU,UAAU,EAAE;AAAA,EACnC;AAIA,QAAM,oBAAoB,MAAM,OAAO,CAAC,MAAM,UAAU;AACtD,UAAM,WAAW,yBAAyB,IAAI,KAAK;AACnD,QAAI,UAAU;AACZ,aAAO;AAAA,IACT;AAEA,UAAM,sBACJ,yBAAyB,IAAI,QAAQ,CAAC,KACtC,yBAAyB,IAAI,QAAQ,CAAC;AACxC,QAAI,qBAAqB;AACvB,aAAQ,KAAa,SAAS;AAAA,IAChC;AAEA,WAAO;AAAA,EACT,CAAC;AAED,SAAO,kBACJ,IAAI,CAAC,SAAS;AACb,QAAI,QAAQ,UAAU,IAAI,GAAG;AAC3B,cAAQ,KAAK,MAAM;AAAA,QACjB,KAAK;AACH,iBAAO,6BAA6B,QAAQ,KAAK,QAAQ;AAAA,QAC3D,KAAK;AACH,iBAAO,CAAC;AAAA,MACZ;AAAA,IACF,OAAO;AACL,aAAO,CAAC,IAAI;AAAA,IACd;AAAA,EACF,CAAC,EACA,OAAO,CAAC,KAAK,QAAQ,IAAI,OAAO,GAAG,GAAG,CAAC,CAAC;AAC7C;AAEO,IAAM,eAAe,CAC1B,WACG;AACH,QAAM,YAAY,6BAA6B,QAAQ,OAAO,QAAQ;AAEtE,QAAM,OAAO,UAAU,IAAI,CAAC,kBAAkB,cAAc,IAAI,EAAE,KAAK,IAAI;AAE3E,SAAO;AACT;","names":[]}
@@ -33,4 +33,4 @@ var Debouncer = class {
33
33
  export {
34
34
  Debouncer
35
35
  };
36
- //# sourceMappingURL=chunk-DFTV4TST.mjs.map
36
+ //# sourceMappingURL=chunk-DZMQBOPG.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/lib/debouncer.ts"],"sourcesContent":["export type AsyncFunction<T extends any[]> = (\n ...args: [...T, AbortSignal]\n) => Promise<void>;\n\nexport class Debouncer<T extends any[]> {\n private timeoutId?: ReturnType<typeof setTimeout>;\n private activeAbortController?: AbortController;\n\n constructor(private wait: number) {}\n\n debounce = async (func: AsyncFunction<T>, ...args: T) => {\n // Abort the previous promise immediately\n this.cancel();\n\n this.timeoutId = setTimeout(async () => {\n try {\n this.activeAbortController = new AbortController();\n\n // Pass the signal to the async function, assuming it supports it\n await func(...args, this.activeAbortController.signal);\n\n this.activeAbortController = undefined;\n } catch (error) {}\n }, this.wait);\n };\n\n cancel = () => {\n if (this.activeAbortController) {\n this.activeAbortController.abort();\n this.activeAbortController = undefined;\n }\n\n if (this.timeoutId !== undefined) {\n clearTimeout(this.timeoutId);\n this.timeoutId = undefined;\n }\n };\n}\n"],"mappings":";;;;;AAIO,IAAM,YAAN,MAAiC;AAAA,EAItC,YAAoB,MAAc;AAAd;AAEpB,oBAAW,CAAO,SAA2B,SAAY;AAEvD,WAAK,OAAO;AAEZ,WAAK,YAAY,WAAW,MAAY;AACtC,YAAI;AACF,eAAK,wBAAwB,IAAI,gBAAgB;AAGjD,gBAAM,KAAK,GAAG,MAAM,KAAK,sBAAsB,MAAM;AAErD,eAAK,wBAAwB;AAAA,QAC/B,SAAS,OAAP;AAAA,QAAe;AAAA,MACnB,IAAG,KAAK,IAAI;AAAA,IACd;AAEA,kBAAS,MAAM;AACb,UAAI,KAAK,uBAAuB;AAC9B,aAAK,sBAAsB,MAAM;AACjC,aAAK,wBAAwB;AAAA,MAC/B;AAEA,UAAI,KAAK,cAAc,QAAW;AAChC,qBAAa,KAAK,SAAS;AAC3B,aAAK,YAAY;AAAA,MACnB;AAAA,IACF;AAAA,EA5BmC;AA6BrC;","names":[]}
@@ -1,15 +1,15 @@
1
1
  import {
2
2
  useMakeStandardAutosuggestionFunction
3
- } from "./chunk-ZQSEYPNN.mjs";
3
+ } from "./chunk-UIBUYQPG.mjs";
4
4
  import {
5
5
  useMakeStandardInsertionOrEditingFunction
6
- } from "./chunk-DL3JWL2E.mjs";
6
+ } from "./chunk-M7GTVHFB.mjs";
7
7
  import {
8
8
  defaultAutosuggestionsConfig
9
- } from "./chunk-6SGWO63I.mjs";
9
+ } from "./chunk-MQXYWOE2.mjs";
10
10
  import {
11
11
  BaseCopilotTextarea
12
- } from "./chunk-7NOLZ5T3.mjs";
12
+ } from "./chunk-SWX3MRZ4.mjs";
13
13
  import {
14
14
  __objRest,
15
15
  __spreadProps,
@@ -22,7 +22,11 @@ import merge from "lodash.merge";
22
22
  import { Fragment, jsx } from "react/jsx-runtime";
23
23
  var CopilotTextarea = React.forwardRef(
24
24
  (props, ref) => {
25
- const _a = props, { autosuggestionsConfig: autosuggestionsConfigUserSpecified } = _a, forwardedProps = __objRest(_a, ["autosuggestionsConfig"]);
25
+ const _a = props, {
26
+ autosuggestionsConfig: autosuggestionsConfigUserSpecified
27
+ } = _a, forwardedProps = __objRest(_a, [
28
+ "autosuggestionsConfig"
29
+ ]);
26
30
  const autosuggestionsConfig = merge(
27
31
  defaultAutosuggestionsConfig,
28
32
  autosuggestionsConfigUserSpecified
@@ -57,4 +61,4 @@ var CopilotTextarea = React.forwardRef(
57
61
  export {
58
62
  CopilotTextarea
59
63
  };
60
- //# sourceMappingURL=chunk-CLGAJCZ5.mjs.map
64
+ //# sourceMappingURL=chunk-E7C63KQP.mjs.map