@copilotkit/react-textarea 0.19.0-alpha.3 → 0.19.0-alpha.4

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 (222) hide show
  1. package/.turbo/turbo-build.log +147 -143
  2. package/CHANGELOG.md +6 -0
  3. package/dist/components/base-copilot-textarea/base-copilot-textarea.mjs +1870 -33
  4. package/dist/components/base-copilot-textarea/base-copilot-textarea.mjs.map +1 -1
  5. package/dist/components/base-copilot-textarea/render-element.mjs +52 -3
  6. package/dist/components/base-copilot-textarea/render-element.mjs.map +1 -1
  7. package/dist/components/base-copilot-textarea/render-placeholder.mjs +46 -3
  8. package/dist/components/base-copilot-textarea/render-placeholder.mjs.map +1 -1
  9. package/dist/components/base-copilot-textarea/track-cursor-moved-since-last-text-change.mjs +86 -4
  10. package/dist/components/base-copilot-textarea/track-cursor-moved-since-last-text-change.mjs.map +1 -1
  11. package/dist/components/base-copilot-textarea/use-add-branding-css.mjs +57 -3
  12. package/dist/components/base-copilot-textarea/use-add-branding-css.mjs.map +1 -1
  13. package/dist/components/copilot-textarea/copilot-textarea.mjs +2339 -43
  14. package/dist/components/copilot-textarea/copilot-textarea.mjs.map +1 -1
  15. package/dist/components/hovering-toolbar/hovering-editor-provider.mjs +22 -3
  16. package/dist/components/hovering-toolbar/hovering-editor-provider.mjs.map +1 -1
  17. package/dist/components/hovering-toolbar/hovering-toolbar-components.mjs +125 -3
  18. package/dist/components/hovering-toolbar/hovering-toolbar-components.mjs.map +1 -1
  19. package/dist/components/hovering-toolbar/hovering-toolbar.mjs +1015 -16
  20. package/dist/components/hovering-toolbar/hovering-toolbar.mjs.map +1 -1
  21. package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.mjs +721 -10
  22. package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.mjs.map +1 -1
  23. package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.mjs +734 -11
  24. package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.mjs.map +1 -1
  25. package/dist/components/hovering-toolbar/text-insertion-prompt-box/index.mjs +734 -12
  26. package/dist/components/hovering-toolbar/text-insertion-prompt-box/index.mjs.map +1 -1
  27. package/dist/components/index.mjs +2340 -44
  28. package/dist/components/index.mjs.map +1 -1
  29. package/dist/components/manual-ui/chip-with-icon.mjs +5 -6
  30. package/dist/components/manual-ui/chip-with-icon.mjs.map +1 -1
  31. package/dist/components/source-search-box/source-search-box.mjs +323 -10
  32. package/dist/components/source-search-box/source-search-box.mjs.map +1 -1
  33. package/dist/components/ui/button.mjs +88 -4
  34. package/dist/components/ui/button.mjs.map +1 -1
  35. package/dist/components/ui/card.mjs +53 -7
  36. package/dist/components/ui/card.mjs.map +1 -1
  37. package/dist/components/ui/command.mjs +266 -5
  38. package/dist/components/ui/command.mjs.map +1 -1
  39. package/dist/components/ui/dialog.mjs +164 -4
  40. package/dist/components/ui/dialog.mjs.map +1 -1
  41. package/dist/components/ui/label.mjs +63 -4
  42. package/dist/components/ui/label.mjs.map +1 -1
  43. package/dist/components/ui/separator.mjs +50 -8
  44. package/dist/components/ui/separator.mjs.map +1 -1
  45. package/dist/components/ui/textarea.mjs +48 -7
  46. package/dist/components/ui/textarea.mjs.map +1 -1
  47. package/dist/context/index.mjs +0 -2
  48. package/dist/context/index.mjs.map +1 -1
  49. package/dist/hooks/base-copilot-textarea-implementation/use-autosuggestions.mjs +168 -6
  50. package/dist/hooks/base-copilot-textarea-implementation/use-autosuggestions.mjs.map +1 -1
  51. package/dist/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.mjs +168 -4
  52. package/dist/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.mjs.map +1 -1
  53. package/dist/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.mjs +155 -5
  54. package/dist/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.mjs.map +1 -1
  55. package/dist/hooks/index.mjs +0 -2
  56. package/dist/hooks/index.mjs.map +1 -1
  57. package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.mjs +90 -4
  58. package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.mjs.map +1 -1
  59. package/dist/hooks/make-autosuggestions-function/use-make-standard-insertion-function.mjs +143 -4
  60. package/dist/hooks/make-autosuggestions-function/use-make-standard-insertion-function.mjs.map +1 -1
  61. package/dist/hooks/misc/use-autosize-textarea.mjs +15 -3
  62. package/dist/hooks/misc/use-autosize-textarea.mjs.map +1 -1
  63. package/dist/index.css +3 -12
  64. package/dist/index.css.map +1 -1
  65. package/dist/index.mjs +2343 -48
  66. package/dist/index.mjs.map +1 -1
  67. package/dist/lib/debouncer.mjs +51 -3
  68. package/dist/lib/debouncer.mjs.map +1 -1
  69. package/dist/lib/editor-to-text.mjs +43 -3
  70. package/dist/lib/editor-to-text.mjs.map +1 -1
  71. package/dist/lib/get-text-around-cursor.mjs +109 -3
  72. package/dist/lib/get-text-around-cursor.mjs.map +1 -1
  73. package/dist/lib/retry.mjs +17 -3
  74. package/dist/lib/retry.mjs.map +1 -1
  75. package/dist/lib/slatejs-edits/add-autocompletions.mjs +25 -3
  76. package/dist/lib/slatejs-edits/add-autocompletions.mjs.map +1 -1
  77. package/dist/lib/slatejs-edits/clear-autocompletions.mjs +23 -3
  78. package/dist/lib/slatejs-edits/clear-autocompletions.mjs.map +1 -1
  79. package/dist/lib/slatejs-edits/replace-text.mjs +27 -3
  80. package/dist/lib/slatejs-edits/replace-text.mjs.map +1 -1
  81. package/dist/lib/slatejs-edits/with-partial-history.mjs +106 -3
  82. package/dist/lib/slatejs-edits/with-partial-history.mjs.map +1 -1
  83. package/dist/lib/stream-promise-flatten.mjs +47 -3
  84. package/dist/lib/stream-promise-flatten.mjs.map +1 -1
  85. package/dist/lib/utils.mjs +71 -3
  86. package/dist/lib/utils.mjs.map +1 -1
  87. package/dist/lib/utils.test.mjs +0 -1
  88. package/dist/lib/utils.test.mjs.map +1 -1
  89. package/dist/types/autosuggestions-config/autosuggestions-config-user-specified.mjs +0 -2
  90. package/dist/types/autosuggestions-config/autosuggestions-config-user-specified.mjs.map +1 -1
  91. package/dist/types/autosuggestions-config/autosuggestions-config.mjs +312 -9
  92. package/dist/types/autosuggestions-config/autosuggestions-config.mjs.map +1 -1
  93. package/dist/types/autosuggestions-config/editing-api-config.mjs +155 -4
  94. package/dist/types/autosuggestions-config/editing-api-config.mjs.map +1 -1
  95. package/dist/types/autosuggestions-config/index.mjs +313 -10
  96. package/dist/types/autosuggestions-config/index.mjs.map +1 -1
  97. package/dist/types/autosuggestions-config/insertions-api-config.mjs +149 -4
  98. package/dist/types/autosuggestions-config/insertions-api-config.mjs.map +1 -1
  99. package/dist/types/autosuggestions-config/subtypes/chatlike-api-endpoint.mjs +71 -3
  100. package/dist/types/autosuggestions-config/subtypes/chatlike-api-endpoint.mjs.map +1 -1
  101. package/dist/types/autosuggestions-config/subtypes/make-system-prompt.mjs +0 -2
  102. package/dist/types/autosuggestions-config/subtypes/make-system-prompt.mjs.map +1 -1
  103. package/dist/types/autosuggestions-config/subtypes/minimal-chat-gpt-message.mjs +0 -2
  104. package/dist/types/autosuggestions-config/subtypes/minimal-chat-gpt-message.mjs.map +1 -1
  105. package/dist/types/autosuggestions-config/suggestions-api-config.mjs +137 -4
  106. package/dist/types/autosuggestions-config/suggestions-api-config.mjs.map +1 -1
  107. package/dist/types/base/autosuggestion-state.mjs +0 -2
  108. package/dist/types/base/autosuggestion-state.mjs.map +1 -1
  109. package/dist/types/base/autosuggestions-bare-function.mjs +0 -2
  110. package/dist/types/base/autosuggestions-bare-function.mjs.map +1 -1
  111. package/dist/types/base/base-autosuggestions-config.mjs +11 -3
  112. package/dist/types/base/base-autosuggestions-config.mjs.map +1 -1
  113. package/dist/types/base/base-copilot-textarea-props.mjs +0 -2
  114. package/dist/types/base/base-copilot-textarea-props.mjs.map +1 -1
  115. package/dist/types/base/custom-editor.mjs +0 -2
  116. package/dist/types/base/custom-editor.mjs.map +1 -1
  117. package/dist/types/base/editor-autocomplete-state.mjs +17 -4
  118. package/dist/types/base/editor-autocomplete-state.mjs.map +1 -1
  119. package/dist/types/base/index.mjs +11 -4
  120. package/dist/types/base/index.mjs.map +1 -1
  121. package/dist/types/html-copilot-textarea-element.mjs +0 -2
  122. package/dist/types/html-copilot-textarea-element.mjs.map +1 -1
  123. package/dist/types/index.mjs +314 -12
  124. package/dist/types/index.mjs.map +1 -1
  125. package/package.json +3 -3
  126. package/src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.tsx +2 -1
  127. package/src/components/source-search-box/source-search-box.tsx +6 -9
  128. package/src/components/ui/command.tsx +1 -1
  129. package/dist/chunk-23UHDUUY.mjs +0 -461
  130. package/dist/chunk-23UHDUUY.mjs.map +0 -1
  131. package/dist/chunk-2NURR2DX.mjs +0 -47
  132. package/dist/chunk-2NURR2DX.mjs.map +0 -1
  133. package/dist/chunk-3YJ63D5D.mjs +0 -106
  134. package/dist/chunk-3YJ63D5D.mjs.map +0 -1
  135. package/dist/chunk-4MDDCR32.mjs +0 -107
  136. package/dist/chunk-4MDDCR32.mjs.map +0 -1
  137. package/dist/chunk-4S5ZJH3I.mjs +0 -18
  138. package/dist/chunk-4S5ZJH3I.mjs.map +0 -1
  139. package/dist/chunk-55EGOC5T.mjs +0 -87
  140. package/dist/chunk-55EGOC5T.mjs.map +0 -1
  141. package/dist/chunk-5ARCOTW3.mjs +0 -34
  142. package/dist/chunk-5ARCOTW3.mjs.map +0 -1
  143. package/dist/chunk-5EJ5XOGP.mjs +0 -22
  144. package/dist/chunk-5EJ5XOGP.mjs.map +0 -1
  145. package/dist/chunk-5FO6ISW4.mjs +0 -3
  146. package/dist/chunk-5FO6ISW4.mjs.map +0 -1
  147. package/dist/chunk-A2RRLD23.mjs +0 -69
  148. package/dist/chunk-A2RRLD23.mjs.map +0 -1
  149. package/dist/chunk-CSGFJU3L.mjs +0 -65
  150. package/dist/chunk-CSGFJU3L.mjs.map +0 -1
  151. package/dist/chunk-CZMPLTHF.mjs +0 -20
  152. package/dist/chunk-CZMPLTHF.mjs.map +0 -1
  153. package/dist/chunk-D7SEV5PR.mjs +0 -12
  154. package/dist/chunk-D7SEV5PR.mjs.map +0 -1
  155. package/dist/chunk-DE5K76I2.mjs +0 -3
  156. package/dist/chunk-DE5K76I2.mjs.map +0 -1
  157. package/dist/chunk-F3MHL6ZY.mjs +0 -25
  158. package/dist/chunk-F3MHL6ZY.mjs.map +0 -1
  159. package/dist/chunk-FN7GDKKG.mjs +0 -29
  160. package/dist/chunk-FN7GDKKG.mjs.map +0 -1
  161. package/dist/chunk-H4VKQGVU.mjs +0 -3
  162. package/dist/chunk-H4VKQGVU.mjs.map +0 -1
  163. package/dist/chunk-HAFHLU4N.mjs +0 -55
  164. package/dist/chunk-HAFHLU4N.mjs.map +0 -1
  165. package/dist/chunk-IU3WTXLQ.mjs +0 -3
  166. package/dist/chunk-IU3WTXLQ.mjs.map +0 -1
  167. package/dist/chunk-IXJ2HCOA.mjs +0 -101
  168. package/dist/chunk-IXJ2HCOA.mjs.map +0 -1
  169. package/dist/chunk-JAFCXEPU.mjs +0 -10
  170. package/dist/chunk-JAFCXEPU.mjs.map +0 -1
  171. package/dist/chunk-KCHYD3EB.mjs +0 -107
  172. package/dist/chunk-KCHYD3EB.mjs.map +0 -1
  173. package/dist/chunk-KGKLUWKW.mjs +0 -47
  174. package/dist/chunk-KGKLUWKW.mjs.map +0 -1
  175. package/dist/chunk-L7VVZH4Q.mjs +0 -3
  176. package/dist/chunk-L7VVZH4Q.mjs.map +0 -1
  177. package/dist/chunk-LNAIMEB2.mjs +0 -34
  178. package/dist/chunk-LNAIMEB2.mjs.map +0 -1
  179. package/dist/chunk-MMVDU6DF.mjs +0 -3
  180. package/dist/chunk-MMVDU6DF.mjs.map +0 -1
  181. package/dist/chunk-MPME5BW2.mjs +0 -59
  182. package/dist/chunk-MPME5BW2.mjs.map +0 -1
  183. package/dist/chunk-MRXNTQOX.mjs +0 -55
  184. package/dist/chunk-MRXNTQOX.mjs.map +0 -1
  185. package/dist/chunk-ND5PXTAW.mjs +0 -17
  186. package/dist/chunk-ND5PXTAW.mjs.map +0 -1
  187. package/dist/chunk-NKW5OU2S.mjs +0 -33
  188. package/dist/chunk-NKW5OU2S.mjs.map +0 -1
  189. package/dist/chunk-O5OWT5GE.mjs +0 -114
  190. package/dist/chunk-O5OWT5GE.mjs.map +0 -1
  191. package/dist/chunk-OD7ZMOVE.mjs +0 -45
  192. package/dist/chunk-OD7ZMOVE.mjs.map +0 -1
  193. package/dist/chunk-OELUUJZY.mjs +0 -16
  194. package/dist/chunk-OELUUJZY.mjs.map +0 -1
  195. package/dist/chunk-OS2YW2UX.mjs +0 -201
  196. package/dist/chunk-OS2YW2UX.mjs.map +0 -1
  197. package/dist/chunk-QL2GYGG5.mjs +0 -19
  198. package/dist/chunk-QL2GYGG5.mjs.map +0 -1
  199. package/dist/chunk-RQHOUUXQ.mjs +0 -29
  200. package/dist/chunk-RQHOUUXQ.mjs.map +0 -1
  201. package/dist/chunk-U5GM2PRT.mjs +0 -44
  202. package/dist/chunk-U5GM2PRT.mjs.map +0 -1
  203. package/dist/chunk-UHD44NC5.mjs +0 -101
  204. package/dist/chunk-UHD44NC5.mjs.map +0 -1
  205. package/dist/chunk-VBIJPE3H.mjs +0 -108
  206. package/dist/chunk-VBIJPE3H.mjs.map +0 -1
  207. package/dist/chunk-WADHCMPK.mjs +0 -3
  208. package/dist/chunk-WADHCMPK.mjs.map +0 -1
  209. package/dist/chunk-WJHSY5T6.mjs +0 -3
  210. package/dist/chunk-WJHSY5T6.mjs.map +0 -1
  211. package/dist/chunk-WJYQWL4I.mjs +0 -27
  212. package/dist/chunk-WJYQWL4I.mjs.map +0 -1
  213. package/dist/chunk-XDT7BF3V.mjs +0 -81
  214. package/dist/chunk-XDT7BF3V.mjs.map +0 -1
  215. package/dist/chunk-XHUMROEY.mjs +0 -91
  216. package/dist/chunk-XHUMROEY.mjs.map +0 -1
  217. package/dist/chunk-YQU7WG7T.mjs +0 -83
  218. package/dist/chunk-YQU7WG7T.mjs.map +0 -1
  219. package/dist/chunk-YTOPHPSG.mjs +0 -45
  220. package/dist/chunk-YTOPHPSG.mjs.map +0 -1
  221. package/dist/chunk-YW3REYX6.mjs +0 -23
  222. package/dist/chunk-YW3REYX6.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":""}
1
+ {"version":3,"sources":["../../src/types/base/base-autosuggestions-config.tsx","../../src/types/autosuggestions-config/subtypes/chatlike-api-endpoint.tsx","../../src/types/autosuggestions-config/suggestions-api-config.tsx","../../src/types/autosuggestions-config/insertions-api-config.tsx","../../src/types/autosuggestions-config/editing-api-config.tsx","../../src/types/autosuggestions-config/autosuggestions-config.tsx"],"sourcesContent":["import { BaseCopilotTextareaApiConfig } from \"./autosuggestions-bare-function\";\n\nexport interface BaseAutosuggestionsConfig {\n textareaPurpose: string;\n debounceTime: number;\n acceptAutosuggestionKey: string;\n disableWhenEmpty: boolean;\n disabled: boolean;\n temporarilyDisableWhenMovingCursorWithoutChangingText: boolean;\n apiConfig: BaseCopilotTextareaApiConfig;\n}\n\nexport const defaultBaseAutosuggestionsConfig: Omit<\n BaseAutosuggestionsConfig,\n \"textareaPurpose\" | \"apiConfig\"\n> = {\n debounceTime: 250,\n acceptAutosuggestionKey: \"Tab\",\n disableWhenEmpty: true,\n disabled: false,\n temporarilyDisableWhenMovingCursorWithoutChangingText: true,\n};\n","import { MinimalChatGPTMessage } from \"./minimal-chat-gpt-message\";\n\nexport type ChatlikeApiEndpointImpl = (\n abortSignal: AbortSignal,\n messages: MinimalChatGPTMessage[],\n forwardedProps?: { [key: string]: any }\n) => Promise<string>;\n\nexport type StreamingChatlikeApiEndpointImpl = (\n abortSignal: AbortSignal,\n messages: MinimalChatGPTMessage[],\n forwardedProps?: { [key: string]: any }\n) => Promise<ReadableStream<string>>;\n\nexport class ChatlikeApiEndpoint {\n public run: StreamingChatlikeApiEndpointImpl;\n\n constructor(run: StreamingChatlikeApiEndpointImpl) {\n this.run = run;\n }\n\n /**\n * Creates a new instance of ChatlikeApiEndpoint with the provided API endpoint.\n * @param apiEndpoint The URL of the OpenAI-compatible API endpoint.\n * @returns A new instance of ChatlikeApiEndpoint.\n */\n static standardOpenAIEndpoint(apiEndpoint: string): ChatlikeApiEndpoint {\n return new ChatlikeApiEndpoint(\n async (\n abortSignal: AbortSignal,\n messages: MinimalChatGPTMessage[],\n forwardedProps?: { [key: string]: any }\n ) => {\n const res = await fetch(apiEndpoint, {\n method: \"POST\",\n body: JSON.stringify({\n ...forwardedProps,\n messages: messages,\n }),\n signal: abortSignal,\n });\n\n const bodySteram: ReadableStream<Uint8Array> | null = res.body;\n if (!bodySteram) {\n throw new Error(\"The response body is empty.\");\n }\n\n // map the stream to a stream of strings\n const stringStream = bodySteram.pipeThrough(new TextDecoderStream());\n\n return stringStream;\n }\n );\n }\n\n /**\n * Creates a fully customized instance of ChatlikeApiEndpoint.\n * @param run - The implementation of the ChatlikeApiEndpointImpl interface.\n * @returns A new instance of ChatlikeApiEndpoint .\n */\n static custom(run: StreamingChatlikeApiEndpointImpl): ChatlikeApiEndpoint {\n return new ChatlikeApiEndpoint(run);\n }\n}\n","import { MinimalChatGPTMessage } from \"./subtypes/minimal-chat-gpt-message\";\nimport { MakeSystemPrompt } from \"./subtypes/make-system-prompt\";\nimport { ChatlikeApiEndpoint } from \"./subtypes/chatlike-api-endpoint\";\n\nexport interface SuggestionsApiConfig {\n apiEndpoint: ChatlikeApiEndpoint;\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 name: \"TextBeforeCursor\",\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 apiEndpoint: ChatlikeApiEndpoint.standardOpenAIEndpoint(\n \"/api/copilotkit_chatlike\"\n ),\n makeSystemPrompt: defaultSuggestionsMakeSystemPrompt,\n fewShotMessages: defaultSuggestionsFewShotMessages,\n forwardedParams: undefined,\n};\n","import { ChatlikeApiEndpoint } from \"./subtypes/chatlike-api-endpoint\";\nimport { MakeSystemPrompt } from \"./subtypes/make-system-prompt\";\nimport { MinimalChatGPTMessage } from \"./subtypes/minimal-chat-gpt-message\";\n\nexport interface InsertionsApiConfig {\n apiEndpoint: ChatlikeApiEndpoint;\n makeSystemPrompt: MakeSystemPrompt;\n fewShotMessages: MinimalChatGPTMessage[];\n forwardedParams: { [key: string]: any } | undefined;\n}\n\nexport const defaultInsertionsMakeSystemPrompt: 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\nThe user also provides you with a prompt for INSERTIONS into the text they are writing. \nYour job is to come up with an INSERTION into the text that the user would like 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 the text before and after the cursor, as well as the insertion prompt. You should use this to infer the best relevant insertion.\n<TextAfterCursor>\n<TextBeforeCursor>\n<InsertionPrompt>\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 defaultInsertionsFewShotMessages: 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 name: \"TextBeforeCursor\",\n content: \"This morning I woke up and went straight to the grocery store.\",\n },\n {\n role: \"user\",\n name: \"InsertionPrompt\",\n content: \"I bought a big watermelon\",\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: \"user\",\n name: \"InsertionPrompt\",\n content: \"add section about the optionholder's pro rata share\",\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 defaultInsertionsApiConfig: InsertionsApiConfig = {\n apiEndpoint: ChatlikeApiEndpoint.standardOpenAIEndpoint(\n \"/api/copilotkit_chatlike\"\n ),\n makeSystemPrompt: defaultInsertionsMakeSystemPrompt,\n fewShotMessages: defaultInsertionsFewShotMessages,\n forwardedParams: undefined,\n};\n","import { ChatlikeApiEndpoint } from \"./subtypes/chatlike-api-endpoint\";\nimport { MakeSystemPrompt } from \"./subtypes/make-system-prompt\";\nimport { MinimalChatGPTMessage } from \"./subtypes/minimal-chat-gpt-message\";\n\nexport interface EditingApiConfig {\n apiEndpoint: ChatlikeApiEndpoint;\n makeSystemPrompt: MakeSystemPrompt;\n fewShotMessages: MinimalChatGPTMessage[];\n forwardedParams: { [key: string]: any } | undefined;\n}\n\nexport const defaultEditingMakeSystemPrompt: 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\nThe user also provides you with a prompt for EDITING some text they are writing. \nYour job is to come up with an EDIT of the text that the user would like to use - AS BEST YOU CAN.\n\nAdjust yourself to the user's style and implied intent.\n\nThe user will provide the following information; use this to infer the best relevant EDIT:\n<TextBeforeCursor>\n<TextToEdit>\n<TextAfterCursor>\n<EditingPrompt>\n\n<YourEditSuggestion>\n\nIf we need to add a whitespace character to the suggested edit 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 defaultEditingFewShotMessages: MinimalChatGPTMessage[] = [\n {\n role: \"user\",\n name: \"TextBeforeCursor\",\n content: \"This morning I woke up and went straight to the grocery store. \",\n },\n {\n role: \"user\",\n name: \"TextToEdit\",\n content:\n \"While I was there I also picked up some apples, oranges, and bananas. \",\n },\n {\n role: \"user\",\n name: \"TextAfterCursor\",\n content:\n \"The grocery store was having a sale on fruit, so I decided to stock up.\",\n },\n {\n role: \"user\",\n name: \"EditingPrompt\",\n content: \"I bought a big watermelon\",\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: \"user\",\n name: \"InsertionPrompt\",\n content: \"add section about the optionholder's pro rata share\",\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 defaultEditingApiConfig: EditingApiConfig = {\n apiEndpoint: ChatlikeApiEndpoint.standardOpenAIEndpoint(\n \"/api/copilotkit_chatlike\"\n ),\n makeSystemPrompt: defaultEditingMakeSystemPrompt,\n fewShotMessages: defaultEditingFewShotMessages,\n forwardedParams: undefined,\n};\n","import {\n BaseAutosuggestionsConfig,\n defaultBaseAutosuggestionsConfig,\n} from \"../base\";\nimport {\n SuggestionsApiConfig,\n defaultSuggestionsApiConfig,\n} from \"./suggestions-api-config\";\nimport {\n InsertionsApiConfig,\n defaultInsertionsApiConfig,\n} from \"./insertions-api-config\";\nimport { ChatlikeApiEndpoint } from \".\";\nimport {\n EditingApiConfig,\n defaultEditingApiConfig,\n} from \"./editing-api-config\";\n\n// Like the base autosuggestions config, with 2 additional fields:\n// 1. externalContextCategories: string[] | undefined;\n// 2. instead of apiConfigs, we have chatApiConfigs: a higher-level abstraction that uses a ChatGPT-like API endpoint.\nexport interface AutosuggestionsConfig\n extends Omit<BaseAutosuggestionsConfig, \"apiConfig\"> {\n externalContextCategories: string[] | undefined;\n chatApiConfigs: {\n suggestionsApiConfig: SuggestionsApiConfig;\n insertionApiConfig: InsertionsApiConfig;\n editingApiConfig: EditingApiConfig;\n };\n}\n\nexport const defaultAutosuggestionsConfig: Omit<\n AutosuggestionsConfig,\n \"textareaPurpose\" | \"apiEndpoint\"\n> = {\n ...defaultBaseAutosuggestionsConfig,\n externalContextCategories: undefined,\n chatApiConfigs: {\n suggestionsApiConfig: defaultSuggestionsApiConfig,\n insertionApiConfig: defaultInsertionsApiConfig,\n editingApiConfig: defaultEditingApiConfig,\n },\n};\n"],"mappings":"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","names":[]}
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "0.19.0-alpha.3",
7
+ "version": "0.19.0-alpha.4",
8
8
  "sideEffects": [
9
9
  "**/*.css"
10
10
  ],
@@ -32,9 +32,9 @@
32
32
  "ts-jest": "^29.1.1",
33
33
  "tsup": "^6.1.3",
34
34
  "typescript": "^4.9.4",
35
+ "eslint-config-custom": "0.2.0",
35
36
  "tailwind-config": "0.1.0",
36
- "tsconfig": "0.3.0",
37
- "eslint-config-custom": "0.2.0"
37
+ "tsconfig": "0.3.0"
38
38
  },
39
39
  "dependencies": {
40
40
  "@emotion/css": "^11.11.2",
@@ -263,7 +263,8 @@ export const IncludedFilesPreview: React.FC<IncludedFilesPreviewProps> = ({
263
263
  setIncludedFiles,
264
264
  }) => {
265
265
  return (
266
- <div className="flex flex-col gap-2">
266
+ <div className="flex flex-col gap-2 mt-2">
267
+ <Label className="">Included context:</Label>
267
268
  <div className="flex flex-wrap gap-2">
268
269
  {includedFiles.map((filePointer, index) => {
269
270
  return (
@@ -73,8 +73,8 @@ export function SourceSearchBox(props: SourceSearchBoxProps) {
73
73
  props.onSelectedFile(filePointer);
74
74
  }}
75
75
  >
76
- <div className="flex flex-row gap-3 items-center bg-slate-400 ">
77
- <Logo size="40px">
76
+ <div className="flex flex-row gap-3 items-center">
77
+ <Logo size="30px">
78
78
  <IconForFilePointer
79
79
  filePointer={filePointer}
80
80
  className="mx-auto my-auto"
@@ -114,20 +114,17 @@ export function SourceSearchBox(props: SourceSearchBoxProps) {
114
114
 
115
115
  export function Logo({
116
116
  children,
117
- size = "20px",
117
+ size = "30px",
118
118
  }: {
119
119
  children: React.ReactNode;
120
120
  size?: string;
121
121
  }) {
122
122
  return (
123
123
  <div
124
- className={""}
125
- style={{
126
- width: size,
127
- height: size,
128
- }}
124
+ className="flex items-center justify-center"
125
+ style={{ width: size, height: size }}
129
126
  >
130
- <div className={""}>{children}</div>
127
+ {children}
131
128
  </div>
132
129
  );
133
130
  }
@@ -117,7 +117,7 @@ const CommandItem = React.forwardRef<
117
117
  <CommandPrimitive.Item
118
118
  ref={ref}
119
119
  className={cn(
120
- "relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none aria-selected:bg-accent aria-selected:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
120
+ "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",
121
121
  className
122
122
  )}
123
123
  {...props}
@@ -1,461 +0,0 @@
1
- import { use_autosize_textarea_default } from './chunk-ND5PXTAW.mjs';
2
- import { Button } from './chunk-2NURR2DX.mjs';
3
- import { Command, CommandInput, CommandList, CommandEmpty, CommandGroup, CommandItem, CommandSeparator } from './chunk-3YJ63D5D.mjs';
4
- import { Label } from './chunk-5EJ5XOGP.mjs';
5
- import { streamPromiseFlatten } from './chunk-FN7GDKKG.mjs';
6
- import { __objRest, __spreadProps, __spreadValues, __async } from './chunk-MRXNTQOX.mjs';
7
- import { useState, useRef, useEffect } from 'react';
8
- import { Calendar, Smile, Calculator } from 'lucide-react';
9
- import Chip from '@mui/material/Chip';
10
- import Avatar from '@mui/material/Avatar';
11
- import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
12
-
13
- var HoveringInsertionPromptBoxCore = ({ performInsertion, state, insertionOrEditingFunction }) => {
14
- const [editSuggestion, setEditSuggestion] = useState("");
15
- const [suggestionIsLoading, setSuggestionIsLoading] = useState(false);
16
- const [adjustmentPrompt, setAdjustmentPrompt] = useState("");
17
- const [generatingSuggestion, setGeneratingSuggestion] = useState(null);
18
- const adjustmentTextAreaRef = useRef(null);
19
- const suggestionTextAreaRef = useRef(null);
20
- const [filePointers, setFilePointers] = useState([]);
21
- use_autosize_textarea_default(suggestionTextAreaRef, editSuggestion || "");
22
- use_autosize_textarea_default(adjustmentTextAreaRef, adjustmentPrompt || "");
23
- useEffect(() => {
24
- var _a;
25
- (_a = adjustmentTextAreaRef.current) == null ? void 0 : _a.focus();
26
- }, []);
27
- useEffect(() => {
28
- if (!generatingSuggestion) {
29
- return;
30
- }
31
- if (generatingSuggestion.locked) {
32
- return;
33
- }
34
- setEditSuggestion("");
35
- const reader = generatingSuggestion.getReader();
36
- const read = () => __async(void 0, null, function* () {
37
- setSuggestionIsLoading(true);
38
- while (true) {
39
- const { done, value } = yield reader.read();
40
- if (done) {
41
- break;
42
- }
43
- setEditSuggestion((prev) => {
44
- const newSuggestion = prev + value;
45
- if (suggestionTextAreaRef.current) {
46
- suggestionTextAreaRef.current.scrollTop = suggestionTextAreaRef.current.scrollHeight;
47
- }
48
- return newSuggestion;
49
- });
50
- }
51
- setSuggestionIsLoading(false);
52
- });
53
- read();
54
- return () => {
55
- const releaseLockIfNotClosed = () => __async(void 0, null, function* () {
56
- try {
57
- yield reader.closed;
58
- } catch (e) {
59
- reader.releaseLock();
60
- }
61
- });
62
- releaseLockIfNotClosed();
63
- };
64
- }, [generatingSuggestion]);
65
- const begingGeneratingAdjustment = () => __async(void 0, null, function* () {
66
- if (!adjustmentPrompt.trim()) {
67
- return;
68
- }
69
- let editorState = state.editorState;
70
- if (editSuggestion !== "") {
71
- editorState.selectedText = editSuggestion;
72
- }
73
- const adjustmentSuggestionTextStreamPromise = insertionOrEditingFunction(
74
- editorState,
75
- adjustmentPrompt,
76
- new AbortController().signal
77
- );
78
- const adjustmentSuggestionTextStream = streamPromiseFlatten(
79
- adjustmentSuggestionTextStreamPromise
80
- );
81
- setGeneratingSuggestion(adjustmentSuggestionTextStream);
82
- });
83
- const isLoading = suggestionIsLoading;
84
- const textToEdit = editSuggestion || state.editorState.selectedText;
85
- const adjustmentLabel = textToEdit === "" ? "Describe the text you want to insert" : "Describe adjustments to the suggested text";
86
- const placeholder = textToEdit === "" ? "e.g. 'summarize the client's top 3 pain-points from @CallTranscript'" : "e.g. 'make it more formal', 'be more specific', ...";
87
- const AdjustmentPromptComponent = /* @__PURE__ */ jsxs(Fragment, {
88
- children: [
89
- /* @__PURE__ */ jsx(Label, {
90
- className: "",
91
- children: adjustmentLabel
92
- }),
93
- /* @__PURE__ */ jsxs("div", {
94
- className: "relative w-full flex items-center",
95
- children: [
96
- /* @__PURE__ */ jsx("textarea", {
97
- disabled: suggestionIsLoading,
98
- ref: adjustmentTextAreaRef,
99
- value: adjustmentPrompt,
100
- onChange: (e) => setAdjustmentPrompt(e.target.value),
101
- onKeyDown: (e) => {
102
- if (e.key === "Enter" && e.shiftKey) {
103
- e.preventDefault();
104
- setAdjustmentPrompt(adjustmentPrompt + "\n");
105
- } else if (e.key === "Enter") {
106
- e.preventDefault();
107
- begingGeneratingAdjustment();
108
- }
109
- },
110
- placeholder,
111
- style: { minHeight: "3rem" },
112
- 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]",
113
- rows: 1
114
- }),
115
- /* @__PURE__ */ jsx("button", {
116
- onClick: begingGeneratingAdjustment,
117
- className: "absolute right-2 bg-blue-500 text-white w-8 h-8 rounded-full flex items-center justify-center",
118
- children: /* @__PURE__ */ jsx("i", {
119
- className: "material-icons",
120
- children: "arrow_forward"
121
- })
122
- })
123
- ]
124
- })
125
- ]
126
- });
127
- const SuggestionComponent = /* @__PURE__ */ jsxs(Fragment, {
128
- children: [
129
- /* @__PURE__ */ jsxs("div", {
130
- className: "flex justify-between items-end w-full",
131
- children: [
132
- /* @__PURE__ */ jsx(Label, {
133
- className: "mt-4",
134
- children: "Suggested:"
135
- }),
136
- /* @__PURE__ */ jsx("div", {
137
- className: "ml-auto",
138
- children: isLoading && /* @__PURE__ */ jsx("div", {
139
- className: "flex justify-center items-center",
140
- children: /* @__PURE__ */ jsx("div", {
141
- 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]",
142
- role: "status",
143
- children: /* @__PURE__ */ jsx("span", {
144
- className: "!absolute !-m-px !h-px !w-px !overflow-hidden !whitespace-nowrap !border-0 !p-0 ![clip:rect(0,0,0,0)]",
145
- children: "Loading..."
146
- })
147
- })
148
- })
149
- })
150
- ]
151
- }),
152
- /* @__PURE__ */ jsx("textarea", {
153
- ref: suggestionTextAreaRef,
154
- value: editSuggestion,
155
- disabled: suggestionIsLoading,
156
- onChange: (e) => setEditSuggestion(e.target.value),
157
- className: "w-full text-base p-2 border border-gray-300 rounded-md resize-none bg-green-50",
158
- style: { overflow: "auto", maxHeight: "10em" }
159
- })
160
- ]
161
- });
162
- const SubmitComponent = /* @__PURE__ */ jsx("div", {
163
- className: "flex w-full gap-4 justify-start",
164
- children: /* @__PURE__ */ jsxs(Button, {
165
- className: " bg-green-700 text-white",
166
- onClick: () => {
167
- performInsertion(editSuggestion);
168
- },
169
- children: [
170
- "Insert ",
171
- /* @__PURE__ */ jsx("i", {
172
- className: "material-icons",
173
- children: "check"
174
- })
175
- ]
176
- })
177
- });
178
- const sourceSearchCandidate = adjustmentPrompt.split(" ").pop();
179
- const sourceSearchWord = (sourceSearchCandidate == null ? void 0 : sourceSearchCandidate.startsWith("@")) ? sourceSearchCandidate.slice(1) : void 0;
180
- return /* @__PURE__ */ jsxs("div", {
181
- className: "w-full flex flex-col items-start relative gap-2",
182
- children: [
183
- AdjustmentPromptComponent,
184
- filePointers.length > 0 && /* @__PURE__ */ jsx(IncludedFilesPreview, {
185
- includedFiles: filePointers,
186
- setIncludedFiles: setFilePointers
187
- }),
188
- sourceSearchWord !== void 0 && /* @__PURE__ */ jsx(SourceSearchBox, {
189
- searchTerm: sourceSearchWord,
190
- recentFiles: mockFiles,
191
- onSelectedFile: (filePointer) => {
192
- var _a;
193
- setAdjustmentPrompt(
194
- adjustmentPrompt.replace(new RegExp(`@${sourceSearchWord}$`), "")
195
- );
196
- setFilePointers((prev) => [...prev, filePointer]);
197
- (_a = adjustmentTextAreaRef.current) == null ? void 0 : _a.focus();
198
- }
199
- }),
200
- generatingSuggestion ? SuggestionComponent : null,
201
- generatingSuggestion ? SubmitComponent : null
202
- ]
203
- });
204
- };
205
- var IncludedFilesPreview = ({
206
- includedFiles,
207
- setIncludedFiles
208
- }) => {
209
- return /* @__PURE__ */ jsx("div", {
210
- className: "flex flex-col gap-2",
211
- children: /* @__PURE__ */ jsx("div", {
212
- className: "flex flex-wrap gap-2",
213
- children: includedFiles.map((filePointer, index) => {
214
- return /* @__PURE__ */ jsx(FileChipPreview, {
215
- filePointer,
216
- onDelete: () => {
217
- setIncludedFiles(
218
- (prev) => prev.filter((fp) => fp !== filePointer)
219
- );
220
- }
221
- }, `file-${filePointer.sourceApplication}.${filePointer.name}`);
222
- })
223
- })
224
- });
225
- };
226
- var FileChipPreview = ({
227
- filePointer,
228
- onDelete
229
- }) => {
230
- return /* @__PURE__ */ jsx(Chip, {
231
- label: filePointer.name,
232
- onDelete,
233
- avatar: /* @__PURE__ */ jsx(Avatar, {
234
- sx: { backgroundColor: "transparent" },
235
- children: /* @__PURE__ */ jsx(IconForFilePointer, {
236
- filePointer,
237
- className: "w-4 h-4 object-contain"
238
- })
239
- })
240
- });
241
- };
242
- function IconForFilePointer({
243
- filePointer,
244
- className
245
- }) {
246
- if (filePointer.sourceApplication === "Salesforce") {
247
- return /* @__PURE__ */ jsx(IconSalesforce, {
248
- className
249
- });
250
- } else {
251
- return /* @__PURE__ */ jsx(IconSalesforce, {
252
- className
253
- });
254
- }
255
- }
256
- function IconSalesforce(_a) {
257
- var _b = _a, props = __objRest(_b, ["className"]);
258
- return /* @__PURE__ */ jsxs("svg", __spreadProps(__spreadValues({
259
- xmlns: "http://www.w3.org/2000/svg",
260
- xmlnsXlink: "http://www.w3.org/1999/xlink",
261
- preserveAspectRatio: "xMidYMid meet",
262
- viewBox: "0 0 273 191"
263
- }, props), {
264
- children: [
265
- /* @__PURE__ */ jsx("title", {
266
- children: "Salesforce.com logo"
267
- }),
268
- /* @__PURE__ */ jsx("defs", {
269
- children: /* @__PURE__ */ jsx("path", {
270
- id: "a",
271
- d: "M.06.5h272v190H.06z"
272
- })
273
- }),
274
- /* @__PURE__ */ jsxs("g", {
275
- fillRule: "evenodd",
276
- children: [
277
- /* @__PURE__ */ jsx("mask", {
278
- id: "b",
279
- fill: "#fff",
280
- children: /* @__PURE__ */ jsx("use", {
281
- xlinkHref: "#a"
282
- })
283
- }),
284
- /* @__PURE__ */ jsx("path", {
285
- fill: "#00A1E0",
286
- d: "M113 21.3c8.78-9.14 21-14.8 34.5-14.8 18 0 33.6 10 42 24.9a58 58 0 0 1 23.7-5.05c32.4 0 58.7 26.5 58.7 59.2s-26.3 59.2-58.7 59.2c-3.96 0-7.82-.398-11.6-1.15-7.35 13.1-21.4 22-37.4 22a42.7 42.7 0 0 1-18.8-4.32c-7.45 17.5-24.8 29.8-45 29.8-21.1 0-39-13.3-45.9-32a45.1 45.1 0 0 1-9.34.972c-25.1 0-45.4-20.6-45.4-45.9 0-17 9.14-31.8 22.7-39.8a52.6 52.6 0 0 1-4.35-21c0-29.2 23.7-52.8 52.9-52.8 17.1 0 32.4 8.15 42 20.8",
287
- mask: "url(#b)"
288
- }),
289
- /* @__PURE__ */ jsx("path", {
290
- fill: "#FFFFFE",
291
- d: "M39.4 99.3c-.171.446.061.539.116.618.511.37 1.03.638 1.55.939 2.78 1.47 5.4 1.9 8.14 1.9 5.58 0 9.05-2.97 9.05-7.75v-.094c0-4.42-3.92-6.03-7.58-7.18l-.479-.155c-2.77-.898-5.16-1.68-5.16-3.5v-.093c0-1.56 1.4-2.71 3.56-2.71 2.4 0 5.26.799 7.09 1.81 0 0 .542.35.739-.173.107-.283 1.04-2.78 1.14-3.06.106-.293-.08-.514-.271-.628-2.1-1.28-5-2.15-8-2.15l-.557.002c-5.11 0-8.68 3.09-8.68 7.51v.095c0 4.66 3.94 6.18 7.62 7.23l.592.184c2.68.824 5 1.54 5 3.42v.094c0 1.73-1.51 3.02-3.93 3.02-.941 0-3.94-.016-7.19-2.07-.393-.229-.617-.394-.92-.579-.16-.097-.56-.272-.734.252l-1.1 3.06m81.7 0c-.171.446.061.539.118.618.509.37 1.03.638 1.55.939 2.78 1.47 5.4 1.9 8.14 1.9 5.58 0 9.05-2.97 9.05-7.75v-.094c0-4.42-3.91-6.03-7.58-7.18l-.479-.155c-2.77-.898-5.16-1.68-5.16-3.5v-.093c0-1.56 1.4-2.71 3.56-2.71 2.4 0 5.25.799 7.09 1.81 0 0 .542.35.74-.173.106-.283 1.04-2.78 1.13-3.06.107-.293-.08-.514-.27-.628-2.1-1.28-5-2.15-8-2.15l-.558.002c-5.11 0-8.68 3.09-8.68 7.51v.095c0 4.66 3.94 6.18 7.62 7.23l.591.184c2.69.824 5 1.54 5 3.42v.094c0 1.73-1.51 3.02-3.93 3.02-.943 0-3.95-.016-7.19-2.07-.393-.229-.623-.387-.921-.579-.101-.064-.572-.248-.733.252l-1.1 3.06m55.8-9.36c0 2.7-.504 4.83-1.49 6.34-.984 1.49-2.47 2.22-4.54 2.22s-3.55-.724-4.52-2.21c-.977-1.5-1.47-3.64-1.47-6.34 0-2.7.496-4.82 1.47-6.31.968-1.48 2.44-2.19 4.52-2.19s3.56.717 4.54 2.19c.992 1.49 1.49 3.61 1.49 6.31m4.66-5.01c-.459-1.55-1.17-2.91-2.12-4.05a10.151 10.151 0 0 0-3.58-2.72c-1.42-.665-3.1-1-5-1s-3.57.337-5 1c-1.42.664-2.63 1.58-3.58 2.72-.948 1.14-1.66 2.5-2.12 4.05-.455 1.54-.686 3.22-.686 5.01 0 1.79.231 3.47.686 5.01.457 1.55 1.17 2.91 2.12 4.05.951 1.14 2.16 2.05 3.58 2.7 1.43.648 3.11.978 5 .978 1.89 0 3.57-.33 4.99-.978 1.42-.648 2.63-1.56 3.58-2.7.949-1.14 1.66-2.5 2.12-4.05.454-1.54.685-3.22.685-5.01 0-1.78-.231-3.47-.685-5.01m38.3 12.8c-.153-.453-.595-.282-.595-.282-.677.259-1.4.499-2.17.619-.776.122-1.64.183-2.55.183-2.25 0-4.05-.671-5.33-2-1.29-1.33-2.01-3.47-2-6.37.007-2.64.645-4.62 1.79-6.14 1.13-1.5 2.87-2.28 5.17-2.28 1.92 0 3.39.223 4.93.705 0 0 .365.159.54-.322.409-1.13.711-1.94 1.15-3.18.124-.355-.18-.505-.291-.548-.604-.236-2.03-.623-3.11-.786-1.01-.154-2.18-.234-3.5-.234-1.96 0-3.7.335-5.19.999-1.49.663-2.75 1.58-3.75 2.72-1 1.14-1.76 2.5-2.27 4.05-.505 1.54-.76 3.23-.76 5.02 0 3.86 1.04 6.99 3.1 9.28 2.06 2.3 5.16 3.46 9.2 3.46 2.39 0 4.84-.483 6.6-1.18 0 0 .336-.162.19-.554l-1.15-3.16m8.15-10.4c.223-1.5.634-2.75 1.28-3.72.967-1.48 2.44-2.29 4.51-2.29s3.44.814 4.42 2.29c.65.975.934 2.27 1.04 3.72l-11.3-.002zm15.7-3.3c-.397-1.49-1.38-3-2.02-3.69-1.02-1.09-2.01-1.86-3-2.28a11.5 11.5 0 0 0-4.52-.917c-1.97 0-3.76.333-5.21 1.01-1.45.682-2.67 1.61-3.63 2.77-.959 1.16-1.68 2.53-2.14 4.1-.46 1.55-.692 3.25-.692 5.03 0 1.82.241 3.51.715 5.04.479 1.54 1.25 2.89 2.29 4.01 1.04 1.13 2.37 2.01 3.97 2.63 1.59.615 3.52.934 5.73.927 4.56-.015 6.96-1.03 7.94-1.58.175-.098.34-.267.134-.754l-1.03-2.89c-.158-.431-.594-.275-.594-.275-1.13.422-2.73 1.18-6.48 1.17-2.45-.004-4.26-.727-5.4-1.86-1.16-1.16-1.74-2.85-1.83-5.25l15.8.012s.416-.004.459-.41c.017-.168.541-3.24-.471-6.79zm-142 3.3c.223-1.5.635-2.75 1.28-3.72.968-1.48 2.44-2.29 4.51-2.29s3.44.814 4.42 2.29c.649.975.933 2.27 1.04 3.72l-11.3-.002zm15.7-3.3c-.396-1.49-1.38-3-2.02-3.69-1.02-1.09-2.01-1.86-3-2.28a11.5 11.5 0 0 0-4.52-.917c-1.97 0-3.76.333-5.21 1.01-1.45.682-2.67 1.61-3.63 2.77-.957 1.16-1.68 2.53-2.14 4.1-.459 1.55-.69 3.25-.69 5.03 0 1.82.239 3.51.716 5.04.478 1.54 1.25 2.89 2.28 4.01 1.04 1.13 2.37 2.01 3.97 2.63 1.59.615 3.51.934 5.73.927 4.56-.015 6.96-1.03 7.94-1.58.174-.098.34-.267.133-.754l-1.03-2.89c-.159-.431-.595-.275-.595-.275-1.13.422-2.73 1.18-6.48 1.17-2.44-.004-4.26-.727-5.4-1.86-1.16-1.16-1.74-2.85-1.83-5.25l15.8.012s.416-.004.459-.41c.017-.168.541-3.24-.472-6.79zm-49.8 13.6c-.619-.494-.705-.615-.91-.936-.313-.483-.473-1.17-.473-2.05 0-1.38.46-2.38 1.41-3.05-.01.002 1.36-1.18 4.58-1.14a32 32 0 0 1 4.28.365v7.17h.002s-2 .431-4.26.567c-3.21.193-4.63-.924-4.62-.921zm6.28-11.1c-.64-.047-1.47-.07-2.46-.07-1.35 0-2.66.168-3.88.498-1.23.332-2.34.846-3.29 1.53a7.63 7.63 0 0 0-2.29 2.6c-.559 1.04-.844 2.26-.844 3.64 0 1.4.243 2.61.723 3.6a6.54 6.54 0 0 0 2.06 2.47c.877.638 1.96 1.11 3.21 1.39 1.24.283 2.64.426 4.18.426 1.62 0 3.23-.136 4.79-.399a95.1 95.1 0 0 0 3.97-.772c.526-.121 1.11-.28 1.11-.28.39-.099.36-.516.36-.516l-.009-14.4c0-3.16-.844-5.51-2.51-6.96-1.66-1.45-4.09-2.18-7.24-2.18-1.18 0-3.09.16-4.23.389 0 0-3.44.668-4.86 1.78 0 0-.312.192-.142.627l1.12 3c.139.389.518.256.518.256s.119-.047.259-.13c3.03-1.65 6.87-1.6 6.87-1.6 1.7 0 3.02.345 3.9 1.02.861.661 1.3 1.66 1.3 3.76v.667c-1.35-.196-2.6-.309-2.6-.309zm127-8.13a.428.428 0 0 0-.237-.568c-.269-.102-1.61-.385-2.64-.449-1.98-.124-3.08.21-4.07.654-.978.441-2.06 1.15-2.66 1.97l-.002-1.92c0-.264-.187-.477-.453-.477h-4.04c-.262 0-.452.213-.452.477v23.5a.48.48 0 0 0 .479.479h4.14a.479.479 0 0 0 .478-.479v-11.8c0-1.58.174-3.15.521-4.14.342-.979.807-1.76 1.38-2.32a4.79 4.79 0 0 1 1.95-1.17 7.68 7.68 0 0 1 2.12-.298c.825 0 1.73.212 1.73.212.304.034.473-.152.576-.426.271-.721 1.04-2.88 1.19-3.31"
292
- }),
293
- /* @__PURE__ */ jsx("path", {
294
- fill: "#FFFFFE",
295
- d: "M162.201 67.548a13.258 13.258 0 0 0-1.559-.37 12.217 12.217 0 0 0-2.144-.166c-2.853 0-5.102.806-6.681 2.398-1.568 1.58-2.635 3.987-3.17 7.154l-.193 1.069h-3.581s-.437-.018-.529.459l-.588 3.28c-.041.314.094.51.514.508h3.486l-3.537 19.743c-.277 1.59-.594 2.898-.945 3.889-.346.978-.684 1.711-1.1 2.243-.403.515-.785.894-1.444 1.115-.544.183-1.17.267-1.856.267-.382 0-.89-.064-1.265-.139-.375-.074-.57-.158-.851-.276 0 0-.409-.156-.57.254-.131.335-1.06 2.89-1.17 3.206-.112.312.045.558.243.629.464.166.809.272 1.441.421.878.207 1.618.22 2.311.22 1.452 0 2.775-.204 3.872-.6 1.104-.399 2.065-1.094 2.915-2.035.919-1.015 1.497-2.078 2.05-3.528.547-1.437 1.013-3.221 1.386-5.3l3.554-20.109h5.196s.438.016.529-.459l.588-3.28c.041-.314-.093-.51-.515-.508h-5.043c.025-.114.254-1.888.833-3.558.247-.713.712-1.288 1.106-1.683a3.273 3.273 0 0 1 1.321-.822 5.48 5.48 0 0 1 1.693-.244c.475 0 .941.057 1.296.131.489.104.679.159.807.197.514.157.583.005.684-.244l1.206-3.312c.124-.356-.178-.506-.29-.55m-70.474 34.117c0 .264-.188.479-.452.479h-4.183c-.265 0-.453-.215-.453-.479V67.997c0-.263.188-.476.453-.476h4.183c.264 0 .452.213.452.476v33.668"
296
- })
297
- ]
298
- })
299
- ]
300
- }));
301
- }
302
- var mockFiles = [
303
- {
304
- name: "prospecting call transcript",
305
- sourceApplication: "Salesforce",
306
- getContents: () => __async(void 0, null, function* () {
307
- return "some contents";
308
- })
309
- },
310
- {
311
- name: "customer feedback",
312
- sourceApplication: "Zendesk",
313
- getContents: () => __async(void 0, null, function* () {
314
- return "some contents";
315
- })
316
- },
317
- {
318
- name: "product specifications",
319
- sourceApplication: "Google Docs",
320
- getContents: () => __async(void 0, null, function* () {
321
- return "some contents";
322
- })
323
- },
324
- {
325
- name: "meeting minutes",
326
- sourceApplication: "Microsoft Teams",
327
- getContents: () => __async(void 0, null, function* () {
328
- return "some contents";
329
- })
330
- },
331
- {
332
- name: "project plan",
333
- sourceApplication: "Trello",
334
- getContents: () => __async(void 0, null, function* () {
335
- return "some contents";
336
- })
337
- },
338
- {
339
- name: "code review comments",
340
- sourceApplication: "Github",
341
- getContents: () => __async(void 0, null, function* () {
342
- return "some contents";
343
- })
344
- }
345
- ];
346
- function SourceSearchBox(props) {
347
- const [selectedValue, setSelectedValue] = useState("");
348
- return /* @__PURE__ */ jsxs(Command, {
349
- className: "rounded-lg border shadow-md",
350
- value: selectedValue,
351
- onValueChange: (value) => {
352
- setSelectedValue(value);
353
- },
354
- filter: (value, search) => {
355
- if (props.searchTerm === "")
356
- return 1;
357
- if (value.startsWith(props.searchTerm))
358
- return 1;
359
- return 0;
360
- },
361
- children: [
362
- /* @__PURE__ */ jsx(CommandInput, {
363
- value: props.searchTerm,
364
- className: "rounded-t-lg hidden",
365
- placeholder: "Search for a command..."
366
- }),
367
- /* @__PURE__ */ jsxs(CommandList, {
368
- children: [
369
- /* @__PURE__ */ jsx(CommandEmpty, {
370
- children: "No results found."
371
- }),
372
- /* @__PURE__ */ jsx(CommandGroup, {
373
- heading: "Recents",
374
- children: props.recentFiles.map((filePointer) => {
375
- return /* @__PURE__ */ jsx(CommandItem, {
376
- value: filePointer.name,
377
- onSelect: (value) => {
378
- console.log(filePointer.name);
379
- props.onSelectedFile(filePointer);
380
- },
381
- children: /* @__PURE__ */ jsxs("div", {
382
- className: "flex flex-row gap-3 items-center bg-slate-400 ",
383
- children: [
384
- /* @__PURE__ */ jsx(Logo, {
385
- size: "40px",
386
- children: /* @__PURE__ */ jsx(IconForFilePointer, {
387
- filePointer,
388
- className: "mx-auto my-auto"
389
- })
390
- }),
391
- filePointer.name
392
- ]
393
- })
394
- }, `word-${filePointer.sourceApplication}.${filePointer.name}`);
395
- })
396
- }),
397
- /* @__PURE__ */ jsxs(CommandGroup, {
398
- heading: "Suggestions",
399
- children: [
400
- /* @__PURE__ */ jsxs(CommandItem, {
401
- onSelect: (value) => {
402
- console.log(value);
403
- console.log(value);
404
- },
405
- children: [
406
- /* @__PURE__ */ jsx(Calendar, {
407
- className: "mr-2 h-4 w-4"
408
- }),
409
- /* @__PURE__ */ jsx("span", {
410
- children: "Calendar"
411
- })
412
- ]
413
- }),
414
- /* @__PURE__ */ jsxs(CommandItem, {
415
- children: [
416
- /* @__PURE__ */ jsx(Smile, {
417
- className: "mr-2 h-4 w-4"
418
- }),
419
- /* @__PURE__ */ jsx("span", {
420
- children: "Search Emoji"
421
- })
422
- ]
423
- }),
424
- /* @__PURE__ */ jsxs(CommandItem, {
425
- children: [
426
- /* @__PURE__ */ jsx(Calculator, {
427
- className: "mr-2 h-4 w-4"
428
- }),
429
- /* @__PURE__ */ jsx("span", {
430
- children: "Calculator"
431
- })
432
- ]
433
- })
434
- ]
435
- }),
436
- /* @__PURE__ */ jsx(CommandSeparator, {})
437
- ]
438
- })
439
- ]
440
- });
441
- }
442
- function Logo({
443
- children,
444
- size = "20px"
445
- }) {
446
- return /* @__PURE__ */ jsx("div", {
447
- className: "",
448
- style: {
449
- width: size,
450
- height: size
451
- },
452
- children: /* @__PURE__ */ jsx("div", {
453
- className: "",
454
- children
455
- })
456
- });
457
- }
458
-
459
- export { FileChipPreview, HoveringInsertionPromptBoxCore, IconForFilePointer, IncludedFilesPreview, Logo, SourceSearchBox };
460
- //# sourceMappingURL=out.js.map
461
- //# sourceMappingURL=chunk-23UHDUUY.mjs.map