@copilotkit/react-textarea 0.29.0-alpha.1 → 0.29.0

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 (65) hide show
  1. package/.turbo/turbo-build.log +428 -428
  2. package/CHANGELOG.md +16 -0
  3. package/dist/{chunk-BBZ7AWOB.mjs → chunk-4H2O7MYQ.mjs} +2 -2
  4. package/dist/{chunk-AZHILHKM.mjs → chunk-DKE57EAC.mjs} +2 -2
  5. package/dist/{chunk-VB4VNCIQ.mjs → chunk-K7GVTNZU.mjs} +8 -1
  6. package/dist/chunk-K7GVTNZU.mjs.map +1 -0
  7. package/dist/{chunk-FP2EKU3L.mjs → chunk-LCDTIJSD.mjs} +3 -3
  8. package/dist/{chunk-FP2EKU3L.mjs.map → chunk-LCDTIJSD.mjs.map} +1 -1
  9. package/dist/{chunk-SNQEBH5I.mjs → chunk-PXALH4EC.mjs} +3 -3
  10. package/dist/{chunk-5J3UZV77.mjs → chunk-W3TDW7EW.mjs} +2 -2
  11. package/dist/{chunk-B6TKVDDY.mjs → chunk-WGFQTPTF.mjs} +5 -4
  12. package/dist/chunk-WGFQTPTF.mjs.map +1 -0
  13. package/dist/components/base-copilot-textarea/base-copilot-textarea.js +67 -62
  14. package/dist/components/base-copilot-textarea/base-copilot-textarea.js.map +1 -1
  15. package/dist/components/base-copilot-textarea/base-copilot-textarea.mjs +5 -5
  16. package/dist/components/copilot-textarea/copilot-textarea.js +67 -62
  17. package/dist/components/copilot-textarea/copilot-textarea.js.map +1 -1
  18. package/dist/components/copilot-textarea/copilot-textarea.mjs +7 -7
  19. package/dist/components/hovering-toolbar/hovering-toolbar.js +59 -55
  20. package/dist/components/hovering-toolbar/hovering-toolbar.js.map +1 -1
  21. package/dist/components/hovering-toolbar/hovering-toolbar.mjs +3 -3
  22. package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.js +46 -32
  23. package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.js.map +1 -1
  24. package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.mjs +2 -1
  25. package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.js +49 -35
  26. package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.js.map +1 -1
  27. package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.mjs +3 -2
  28. package/dist/components/hovering-toolbar/text-insertion-prompt-box/index.js +49 -35
  29. package/dist/components/hovering-toolbar/text-insertion-prompt-box/index.js.map +1 -1
  30. package/dist/components/hovering-toolbar/text-insertion-prompt-box/index.mjs +3 -2
  31. package/dist/components/index.js +67 -62
  32. package/dist/components/index.js.map +1 -1
  33. package/dist/components/index.mjs +7 -7
  34. package/dist/index.js +67 -62
  35. package/dist/index.js.map +1 -1
  36. package/dist/index.mjs +7 -7
  37. package/dist/types/autosuggestions-config/autosuggestions-config.js +2 -2
  38. package/dist/types/autosuggestions-config/autosuggestions-config.js.map +1 -1
  39. package/dist/types/autosuggestions-config/autosuggestions-config.mjs +2 -2
  40. package/dist/types/autosuggestions-config/index.js +2 -2
  41. package/dist/types/autosuggestions-config/index.js.map +1 -1
  42. package/dist/types/autosuggestions-config/index.mjs +2 -2
  43. package/dist/types/base/base-autosuggestions-config.d.ts +1 -1
  44. package/dist/types/base/base-autosuggestions-config.js +2 -2
  45. package/dist/types/base/base-autosuggestions-config.js.map +1 -1
  46. package/dist/types/base/base-autosuggestions-config.mjs +1 -1
  47. package/dist/types/base/base-copilot-textarea-props.d.ts +1 -0
  48. package/dist/types/base/base-copilot-textarea-props.js.map +1 -1
  49. package/dist/types/base/index.js +2 -2
  50. package/dist/types/base/index.js.map +1 -1
  51. package/dist/types/base/index.mjs +1 -1
  52. package/dist/types/index.js +2 -2
  53. package/dist/types/index.js.map +1 -1
  54. package/dist/types/index.mjs +2 -2
  55. package/package.json +6 -6
  56. package/src/components/base-copilot-textarea/base-copilot-textarea.tsx +3 -1
  57. package/src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.tsx +6 -0
  58. package/src/types/base/base-autosuggestions-config.tsx +6 -2
  59. package/src/types/base/base-copilot-textarea-props.tsx +1 -0
  60. package/dist/chunk-B6TKVDDY.mjs.map +0 -1
  61. package/dist/chunk-VB4VNCIQ.mjs.map +0 -1
  62. /package/dist/{chunk-BBZ7AWOB.mjs.map → chunk-4H2O7MYQ.mjs.map} +0 -0
  63. /package/dist/{chunk-AZHILHKM.mjs.map → chunk-DKE57EAC.mjs.map} +0 -0
  64. /package/dist/{chunk-SNQEBH5I.mjs.map → chunk-PXALH4EC.mjs.map} +0 -0
  65. /package/dist/{chunk-5J3UZV77.mjs.map → chunk-W3TDW7EW.mjs.map} +0 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.tsx","../../../../src/hooks/misc/use-autosize-textarea.tsx","../../../../src/components/source-search-box/source-search-box.tsx","../../../../src/components/ui/command.tsx","../../../../src/lib/utils.ts","../../../../src/components/ui/button.tsx","../../../../src/components/ui/label.tsx","../../../../src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.tsx","../../../../src/lib/stream-promise-flatten.ts","../../../../src/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.tsx"],"sourcesContent":["import { HoveringInsertionPromptBoxCore } from \"./hovering-insertion-prompt-box-core\";\nimport {\n EditingEditorState,\n InsertionEditorApiConfig,\n} from \"../../../types/base/autosuggestions-bare-function\";\n\nexport interface Props {\n editorState: EditingEditorState;\n apiConfig: InsertionEditorApiConfig;\n performInsertion: (insertedText: string) => void;\n closeWindow: () => void;\n contextCategories: string[];\n}\n\nexport const HoveringInsertionPromptBox = (props: Props) => {\n return (\n <div\n className=\"flex flex-col justify-center items-center space-y-4 rounded-md border shadow-lg p-4 border-gray- bg-white\"\n style={{ width: \"35rem\" }}\n >\n <HoveringInsertionPromptBoxCore\n state={{\n editorState: props.editorState,\n }}\n insertionOrEditingFunction={props.apiConfig.insertionOrEditingFunction}\n performInsertion={props.performInsertion}\n contextCategories={props.contextCategories}\n />\n </div>\n );\n};\n","import { Ref, RefObject, useEffect } from \"react\";\n\n// Updates the height of a <textarea> when the value changes.\nconst useAutosizeTextArea = (textAreaRef: RefObject<HTMLTextAreaElement>, value: string) => {\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","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 { Calculator, Calendar, CreditCard, Settings, Smile, User } 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 className=\"flex items-center justify-center\" style={{ width: width, height: height }}>\n {children}\n </div>\n );\n}\n","\"use client\";\n\nimport * as React from \"react\";\nimport { DialogProps } from \"@radix-ui/react-dialog\";\nimport { Command as CommandPrimitive } from \"cmdk\";\nimport { Search } from \"lucide-react\";\n\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(\"max-h-[300px] overflow-y-auto overflow-x-hidden pb-2\", className)}\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 ref={ref} className=\"py-6 text-center text-sm\" {...props} />\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 = ({ className, ...props }: React.HTMLAttributes<HTMLSpanElement>) => {\n return (\n <span\n className={cn(\"ml-auto text-xs tracking-widest text-muted-foreground\", className)}\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","import { clsx, type ClassValue } from \"clsx\";\nimport { customAlphabet } from \"nanoid\";\nimport { twMerge } from \"tailwind-merge\";\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n\nexport const nanoid = customAlphabet(\n \"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\",\n 7,\n); // 7-character random string\n\nexport async function fetcher<JSON = any>(input: RequestInfo, init?: RequestInit): Promise<JSON> {\n const res = await fetch(input, init);\n\n if (!res.ok) {\n const json = await res.json();\n if (json.error) {\n const error = new Error(json.error) as Error & {\n status: number;\n };\n error.status = res.status;\n throw error;\n } else {\n throw new Error(\"An unexpected error occurred\");\n }\n }\n\n return res.json();\n}\n\nexport function formatDate(input: string | number | Date): string {\n const date = new Date(input);\n return date.toLocaleDateString(\"en-US\", {\n month: \"long\",\n day: \"numeric\",\n year: \"numeric\",\n });\n}\n\nexport const arraysAreEqual = (arr1: number[], arr2: number[]): boolean =>\n arr1.length === arr2.length && arr1.every((value, index) => value === arr2[index]);\n\nexport function nullableCompatibleEqualityCheck<T>(\n naiveEqualityCheck: (a: T, b: T) => boolean,\n a: T | null | undefined,\n b: T | null | undefined,\n): boolean {\n if (a === null || a === undefined || b === null || b === undefined) {\n return a === b;\n }\n\n return naiveEqualityCheck(a, b);\n}\n","import * as React from \"react\";\nimport { Slot } from \"@radix-ui/react-slot\";\nimport { cva, type VariantProps } from \"class-variance-authority\";\n\nimport { cn } from \"../../lib/utils\";\n\nconst buttonVariants = cva(\n \"inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50\",\n {\n variants: {\n variant: {\n default: \"bg-primary text-primary-foreground hover:bg-primary/90\",\n destructive: \"bg-destructive text-destructive-foreground hover:bg-destructive/90\",\n outline: \"border border-input bg-background hover:bg-accent hover:text-accent-foreground\",\n secondary: \"bg-secondary text-secondary-foreground hover:bg-secondary/80\",\n ghost: \"hover:bg-accent hover:text-accent-foreground\",\n link: \"text-primary underline-offset-4 hover:underline\",\n },\n size: {\n default: \"h-10 px-4 py-2\",\n sm: \"h-9 rounded-md px-3\",\n lg: \"h-11 rounded-md px-8\",\n icon: \"h-10 w-10\",\n },\n },\n defaultVariants: {\n variant: \"default\",\n size: \"default\",\n },\n },\n);\n\nexport interface ButtonProps\n extends React.ButtonHTMLAttributes<HTMLButtonElement>,\n VariantProps<typeof buttonVariants> {\n asChild?: boolean;\n}\n\nconst Button = React.forwardRef<HTMLButtonElement, ButtonProps>(\n ({ className, variant, size, asChild = false, ...props }, ref) => {\n const Comp = asChild ? Slot : \"button\";\n return (\n <Comp className={cn(buttonVariants({ variant, size, className }))} ref={ref} {...props} />\n );\n },\n);\nButton.displayName = \"Button\";\n\nexport { Button, buttonVariants };\n","\"use client\";\n\nimport * 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> & VariantProps<typeof labelVariants>\n>(({ className, ...props }, ref) => (\n <LabelPrimitive.Root ref={ref} className={cn(labelVariants(), className)} {...props} />\n));\nLabel.displayName = LabelPrimitive.Root.displayName;\n\nexport { Label };\n","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 } from \"@copilotkit/react-core\";\nimport { Button } from \"../../ui/button\";\nimport { Label } from \"../../ui/label\";\nimport { useCallback, useContext, useEffect, useRef, useState } from \"react\";\n\nimport { streamPromiseFlatten } from \"../../../lib/stream-promise-flatten\";\nimport { CopilotContext } from \"@copilotkit/react-core\";\nimport { IncludedFilesPreview } from \"./included-files-preview\";\n\nexport type SuggestionState = {\n editorState: EditingEditorState;\n};\n\nexport interface HoveringInsertionPromptBoxCoreProps {\n state: SuggestionState;\n performInsertion: (insertedText: string) => void;\n insertionOrEditingFunction: Generator_InsertionOrEditingSuggestion;\n contextCategories: string[];\n}\n\nexport const HoveringInsertionPromptBoxCore = ({\n performInsertion,\n state,\n insertionOrEditingFunction,\n contextCategories,\n}: HoveringInsertionPromptBoxCoreProps) => {\n const { getDocumentsContext } = useContext(CopilotContext);\n\n const [editSuggestion, setEditSuggestion] = useState<string>(\"\");\n const [suggestionIsLoading, setSuggestionIsLoading] = useState<boolean>(false);\n\n const [adjustmentPrompt, setAdjustmentPrompt] = useState<string>(\"\");\n\n const [generatingSuggestion, setGeneratingSuggestion] = useState<ReadableStream<string> | null>(\n null,\n );\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 // Focus in the next tick, making sure the adjustment prompt text area is rendered\n // TODO: This happens in Safari, but not in Chrome. Need to look further into this,\n // because focus() should not throw IndexSizeError.\n // this fixes https://github.com/CopilotKit/CopilotKit/issues/171\n setTimeout(() => {\n adjustmentTextAreaRef.current?.focus();\n }, 0);\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 = suggestionTextAreaRef.current.scrollHeight;\n }\n return newSuggestion;\n });\n }\n\n setSuggestionIsLoading(false);\n };\n read();\n\n return () => {\n // release the lock if the reader is not closed on unmount\n const releaseLockIfNotClosed = async () => {\n try {\n await reader.closed;\n } catch {\n reader.releaseLock();\n }\n };\n\n releaseLockIfNotClosed();\n };\n }, [generatingSuggestion]);\n\n // generate an adjustment to the completed text, based on the adjustment prompt\n const beginGeneratingAdjustment = useCallback(async () => {\n // don't generate text if the prompt is empty\n if (!adjustmentPrompt.trim()) {\n return;\n }\n\n // editor state includes the text being edited, and the text before/after the selection\n // if the current edit suggestion is not empty, then use *it* as the \"selected text\" - instead of the editor state's selected text\n let modificationState = state.editorState;\n if (editSuggestion !== \"\") {\n modificationState.selectedText = editSuggestion;\n }\n\n // generate the adjustment suggestion\n const adjustmentSuggestionTextStreamPromise = insertionOrEditingFunction(\n modificationState,\n adjustmentPrompt,\n filePointers,\n new AbortController().signal,\n );\n const adjustmentSuggestionTextStream = streamPromiseFlatten(\n adjustmentSuggestionTextStreamPromise,\n );\n\n setGeneratingSuggestion(adjustmentSuggestionTextStream);\n }, [\n adjustmentPrompt,\n editSuggestion,\n state.editorState,\n insertionOrEditingFunction,\n filePointers,\n ]);\n\n const isLoading = suggestionIsLoading;\n\n const textToEdit = editSuggestion || state.editorState.selectedText;\n const adjustmentLabel =\n textToEdit === \"\"\n ? \"Describe the text you want to insert\"\n : \"Describe adjustments to the suggested text\";\n const placeholder =\n textToEdit === \"\"\n ? \"e.g. 'summarize the client's top 3 pain-points from @CallTranscript'\"\n : \"e.g. 'make it more formal', 'be more specific', ...\";\n\n const AdjustmentPromptComponent = (\n <>\n <Label className=\"\">{adjustmentLabel}</Label>\n <div className=\"relative w-full flex items-center\">\n <textarea\n disabled={suggestionIsLoading}\n ref={adjustmentTextAreaRef}\n value={adjustmentPrompt}\n onChange={(e) => setAdjustmentPrompt(e.target.value)}\n onKeyDown={(e) => {\n if (e.key === \"Enter\" && e.shiftKey) {\n e.preventDefault();\n setAdjustmentPrompt(adjustmentPrompt + \"\\n\");\n } else if (e.key === \"Enter\") {\n e.preventDefault();\n beginGeneratingAdjustment();\n }\n }}\n placeholder={placeholder}\n style={{ minHeight: \"3rem\" }}\n className=\"w-full bg-slate-100 h-auto h-min-14 text-sm p-2 rounded-md resize-none overflow-visible focus:outline-none focus:ring-0 focus:border-non pr-[3rem]\"\n rows={1}\n />\n <button\n onClick={beginGeneratingAdjustment}\n className=\"absolute right-2 bg-blue-500 text-white w-8 h-8 rounded-full flex items-center justify-center\"\n >\n <i className=\"material-icons\">arrow_forward</i>\n </button>\n </div>\n </>\n );\n\n const SuggestionComponent = (\n <>\n <div className=\"flex justify-between items-end w-full\">\n <Label className=\"mt-4\">Suggested:</Label>\n <div className=\"ml-auto\">\n {isLoading && (\n <div className=\"flex justify-center items-center\">\n <div\n className=\"inline-block h-4 w-4 animate-spin rounded-full border-4 border-solid border-current border-r-transparent align-[-0.125em] motion-reduce:animate-[spin_1.5s_linear_infinite]\"\n role=\"status\"\n >\n <span className=\"!absolute !-m-px !h-px !w-px !overflow-hidden !whitespace-nowrap !border-0 !p-0 ![clip:rect(0,0,0,0)]\">\n Loading...\n </span>\n </div>\n </div>\n )}\n </div>\n </div>\n <textarea\n ref={suggestionTextAreaRef}\n value={editSuggestion}\n disabled={suggestionIsLoading}\n onChange={(e) => setEditSuggestion(e.target.value)}\n className=\"w-full text-base p-2 border border-gray-300 rounded-md resize-none bg-green-50\"\n style={{ overflow: \"auto\", maxHeight: \"10em\" }}\n />\n </>\n );\n\n const SubmitComponent = (\n <div className=\"flex w-full gap-4 justify-start\">\n <Button\n className=\" bg-green-700 text-white\"\n onClick={() => {\n performInsertion(editSuggestion);\n }}\n >\n Insert <i className=\"material-icons\">check</i>\n </Button>\n </div>\n );\n\n // show source search if the last word in the adjustment prompt BEGINS with an @\n const sourceSearchCandidate = adjustmentPrompt.split(\" \").pop();\n // if the candidate is @someCandidate, then 'someCandidate', otherwise undefined\n const sourceSearchWord = sourceSearchCandidate?.startsWith(\"@\")\n ? sourceSearchCandidate.slice(1)\n : undefined;\n\n return (\n <div className=\"w-full flex flex-col items-start relative gap-2\">\n {AdjustmentPromptComponent}\n {filePointers.length > 0 && (\n <IncludedFilesPreview includedFiles={filePointers} setIncludedFiles={setFilePointers} />\n )}\n {sourceSearchWord !== undefined && (\n <SourceSearchBox\n searchTerm={sourceSearchWord}\n suggestedFiles={suggestedFiles}\n onSelectedFile={(filePointer) => {\n setAdjustmentPrompt(adjustmentPrompt.replace(new RegExp(`@${sourceSearchWord}$`), \"\"));\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","/**\n * Flatten a promise of a stream, into a stream.\n *\n * Useful because a stream already includes the notion of async value delivery,\n * so it often makes sense to simply await the values rather than the generator of the values.\n *\n * @param {Promise<ReadableStream<A>>} promise - The promise to flatten.\n * @returns {ReadableStream<A>} - The flattened stream.\n */\n\nexport function streamPromiseFlatten<A>(promise: Promise<ReadableStream<A>>): ReadableStream<A> {\n return new ReadableStream<A>({\n async start(controller) {\n try {\n const stream = await promise;\n const reader = stream.getReader();\n\n while (true) {\n const { done, value } = await reader.read();\n\n if (done) {\n controller.close();\n return;\n }\n\n controller.enqueue(value);\n }\n } catch (error) {\n controller.error(error);\n }\n },\n });\n}\n","import { DocumentPointer } from \"@copilotkit/react-core\";\nimport { Label } from \"../../ui/label\";\nimport React from \"react\";\nimport Chip from \"@mui/material/Chip/Chip.js\";\nimport Avatar from \"@mui/material/Avatar/Avatar.js\";\n\nexport interface IncludedFilesPreviewProps {\n includedFiles: DocumentPointer[];\n setIncludedFiles: React.Dispatch<React.SetStateAction<DocumentPointer[]>>;\n}\n\nexport const IncludedFilesPreview = ({\n includedFiles,\n setIncludedFiles,\n}: IncludedFilesPreviewProps) => {\n return (\n <div className=\"flex flex-col gap-2 mt-2\">\n <Label className=\"\">Included context:</Label>\n <div className=\"flex flex-wrap gap-2\">\n {includedFiles.map((filePointer, index) => {\n return (\n <FileChipPreview\n key={`file-${filePointer.sourceApplication}.${filePointer.name}`}\n filePointer={filePointer}\n onDelete={() => {\n setIncludedFiles((prev) => prev.filter((fp) => fp !== filePointer));\n }}\n />\n );\n })}\n </div>\n </div>\n );\n};\n\nexport interface FileChipPreviewProps {\n filePointer: DocumentPointer;\n onDelete: () => void;\n}\n\nexport const FileChipPreview = ({ filePointer, onDelete }: FileChipPreviewProps) => {\n return (\n <Chip\n label={filePointer.name}\n onDelete={onDelete}\n avatar={\n <Avatar\n src={filePointer.iconImageUri}\n alt={filePointer.sourceApplication}\n sx={{ backgroundColor: \"transparent\" }}\n ></Avatar>\n }\n />\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAA0C;AAG1C,IAAM,sBAAsB,CAAC,aAA6C,UAAkB;AAC1F,8BAAU,MAAM;AACd,QAAI,YAAY,YAAY,MAA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B,WAAW,QACvD,sBAAsB,MAAM,CAAC,IAC7B;AAEJ,SACE,8CAAC,SAAI,WAAU,mDACZ;AAAA;AAAA,IACA,aAAa,SAAS,KACrB,6CAAC,wBAAqB,eAAe,cAAc,kBAAkB,iBAAiB;AAAA,IAEvF,qBAAqB,UACpB;AAAA,MAAC;AAAA;AAAA,QACC,YAAY;AAAA,QACZ;AAAA,QACA,gBAAgB,CAAC,gBAAgB;AAnQ3C;AAoQY,8BAAoB,iBAAiB,QAAQ,IAAI,OAAO,IAAI,mBAAmB,GAAG,EAAE,CAAC;AACrF,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;;;AP5PM,IAAAC,sBAAA;AANC,IAAM,6BAA6B,CAAC,UAAiB;AAC1D,SACE;AAAA,IAAC;AAAA;AAAA,MACC,WAAU;AAAA,MACV,OAAO,EAAE,OAAO,QAAQ;AAAA,MAExB;AAAA,QAAC;AAAA;AAAA,UACC,OAAO;AAAA,YACL,aAAa,MAAM;AAAA,UACrB;AAAA,UACA,4BAA4B,MAAM,UAAU;AAAA,UAC5C,kBAAkB,MAAM;AAAA,UACxB,mBAAmB,MAAM;AAAA;AAAA,MAC3B;AAAA;AAAA,EACF;AAEJ;","names":["import_react","CommandPrimitive","CommandPrimitive","import_jsx_runtime","React","import_jsx_runtime","React","import_class_variance_authority","import_jsx_runtime","import_react","import_jsx_runtime","Chip","Avatar","import_jsx_runtime","import_jsx_runtime"]}
1
+ {"version":3,"sources":["../../../../src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.tsx","../../../../src/hooks/misc/use-autosize-textarea.tsx","../../../../src/components/source-search-box/source-search-box.tsx","../../../../src/components/ui/command.tsx","../../../../src/lib/utils.ts","../../../../src/components/ui/button.tsx","../../../../src/components/ui/label.tsx","../../../../src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.tsx","../../../../src/lib/stream-promise-flatten.ts","../../../../src/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.tsx","../../../../src/components/hovering-toolbar/hovering-editor-provider.tsx"],"sourcesContent":["import { HoveringInsertionPromptBoxCore } from \"./hovering-insertion-prompt-box-core\";\nimport {\n EditingEditorState,\n InsertionEditorApiConfig,\n} from \"../../../types/base/autosuggestions-bare-function\";\n\nexport interface Props {\n editorState: EditingEditorState;\n apiConfig: InsertionEditorApiConfig;\n performInsertion: (insertedText: string) => void;\n closeWindow: () => void;\n contextCategories: string[];\n}\n\nexport const HoveringInsertionPromptBox = (props: Props) => {\n return (\n <div\n className=\"flex flex-col justify-center items-center space-y-4 rounded-md border shadow-lg p-4 border-gray- bg-white\"\n style={{ width: \"35rem\" }}\n >\n <HoveringInsertionPromptBoxCore\n state={{\n editorState: props.editorState,\n }}\n insertionOrEditingFunction={props.apiConfig.insertionOrEditingFunction}\n performInsertion={props.performInsertion}\n contextCategories={props.contextCategories}\n />\n </div>\n );\n};\n","import { Ref, RefObject, useEffect } from \"react\";\n\n// Updates the height of a <textarea> when the value changes.\nconst useAutosizeTextArea = (textAreaRef: RefObject<HTMLTextAreaElement>, value: string) => {\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","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 { Calculator, Calendar, CreditCard, Settings, Smile, User } 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 className=\"flex items-center justify-center\" style={{ width: width, height: height }}>\n {children}\n </div>\n );\n}\n","\"use client\";\n\nimport * as React from \"react\";\nimport { DialogProps } from \"@radix-ui/react-dialog\";\nimport { Command as CommandPrimitive } from \"cmdk\";\nimport { Search } from \"lucide-react\";\n\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(\"max-h-[300px] overflow-y-auto overflow-x-hidden pb-2\", className)}\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 ref={ref} className=\"py-6 text-center text-sm\" {...props} />\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 = ({ className, ...props }: React.HTMLAttributes<HTMLSpanElement>) => {\n return (\n <span\n className={cn(\"ml-auto text-xs tracking-widest text-muted-foreground\", className)}\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","import { clsx, type ClassValue } from \"clsx\";\nimport { customAlphabet } from \"nanoid\";\nimport { twMerge } from \"tailwind-merge\";\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n\nexport const nanoid = customAlphabet(\n \"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\",\n 7,\n); // 7-character random string\n\nexport async function fetcher<JSON = any>(input: RequestInfo, init?: RequestInit): Promise<JSON> {\n const res = await fetch(input, init);\n\n if (!res.ok) {\n const json = await res.json();\n if (json.error) {\n const error = new Error(json.error) as Error & {\n status: number;\n };\n error.status = res.status;\n throw error;\n } else {\n throw new Error(\"An unexpected error occurred\");\n }\n }\n\n return res.json();\n}\n\nexport function formatDate(input: string | number | Date): string {\n const date = new Date(input);\n return date.toLocaleDateString(\"en-US\", {\n month: \"long\",\n day: \"numeric\",\n year: \"numeric\",\n });\n}\n\nexport const arraysAreEqual = (arr1: number[], arr2: number[]): boolean =>\n arr1.length === arr2.length && arr1.every((value, index) => value === arr2[index]);\n\nexport function nullableCompatibleEqualityCheck<T>(\n naiveEqualityCheck: (a: T, b: T) => boolean,\n a: T | null | undefined,\n b: T | null | undefined,\n): boolean {\n if (a === null || a === undefined || b === null || b === undefined) {\n return a === b;\n }\n\n return naiveEqualityCheck(a, b);\n}\n","import * as React from \"react\";\nimport { Slot } from \"@radix-ui/react-slot\";\nimport { cva, type VariantProps } from \"class-variance-authority\";\n\nimport { cn } from \"../../lib/utils\";\n\nconst buttonVariants = cva(\n \"inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50\",\n {\n variants: {\n variant: {\n default: \"bg-primary text-primary-foreground hover:bg-primary/90\",\n destructive: \"bg-destructive text-destructive-foreground hover:bg-destructive/90\",\n outline: \"border border-input bg-background hover:bg-accent hover:text-accent-foreground\",\n secondary: \"bg-secondary text-secondary-foreground hover:bg-secondary/80\",\n ghost: \"hover:bg-accent hover:text-accent-foreground\",\n link: \"text-primary underline-offset-4 hover:underline\",\n },\n size: {\n default: \"h-10 px-4 py-2\",\n sm: \"h-9 rounded-md px-3\",\n lg: \"h-11 rounded-md px-8\",\n icon: \"h-10 w-10\",\n },\n },\n defaultVariants: {\n variant: \"default\",\n size: \"default\",\n },\n },\n);\n\nexport interface ButtonProps\n extends React.ButtonHTMLAttributes<HTMLButtonElement>,\n VariantProps<typeof buttonVariants> {\n asChild?: boolean;\n}\n\nconst Button = React.forwardRef<HTMLButtonElement, ButtonProps>(\n ({ className, variant, size, asChild = false, ...props }, ref) => {\n const Comp = asChild ? Slot : \"button\";\n return (\n <Comp className={cn(buttonVariants({ variant, size, className }))} ref={ref} {...props} />\n );\n },\n);\nButton.displayName = \"Button\";\n\nexport { Button, buttonVariants };\n","\"use client\";\n\nimport * 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> & VariantProps<typeof labelVariants>\n>(({ className, ...props }, ref) => (\n <LabelPrimitive.Root ref={ref} className={cn(labelVariants(), className)} {...props} />\n));\nLabel.displayName = LabelPrimitive.Root.displayName;\n\nexport { Label };\n","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 } from \"@copilotkit/react-core\";\nimport { Button } from \"../../ui/button\";\nimport { Label } from \"../../ui/label\";\nimport { useCallback, useContext, useEffect, useRef, useState } from \"react\";\n\nimport { streamPromiseFlatten } from \"../../../lib/stream-promise-flatten\";\nimport { CopilotContext } from \"@copilotkit/react-core\";\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 } = useContext(CopilotContext);\n\n const [editSuggestion, setEditSuggestion] = useState<string>(\"\");\n const [suggestionIsLoading, setSuggestionIsLoading] = useState<boolean>(false);\n\n const [adjustmentPrompt, setAdjustmentPrompt] = useState<string>(\"\");\n\n const [generatingSuggestion, setGeneratingSuggestion] = useState<ReadableStream<string> | null>(\n null,\n );\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 // Focus in the next tick, making sure the adjustment prompt text area is rendered\n // TODO: This happens in Safari, but not in Chrome. Need to look further into this,\n // because focus() should not throw IndexSizeError.\n // this fixes https://github.com/CopilotKit/CopilotKit/issues/171\n setTimeout(() => {\n adjustmentTextAreaRef.current?.focus();\n }, 0);\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 = 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 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 } else if (e.key == \"Escape\") {\n e.preventDefault();\n setIsDisplayed(false);\n }\n }}\n placeholder={placeholder}\n style={{ minHeight: \"3rem\" }}\n className=\"w-full bg-slate-100 h-auto h-min-14 text-sm p-2 rounded-md resize-none overflow-visible focus:outline-none focus:ring-0 focus:border-non pr-[3rem]\"\n rows={1}\n />\n <button\n onClick={beginGeneratingAdjustment}\n className=\"absolute right-2 bg-blue-500 text-white w-8 h-8 rounded-full flex items-center justify-center\"\n >\n <i className=\"material-icons\">arrow_forward</i>\n </button>\n </div>\n </>\n );\n\n const SuggestionComponent = (\n <>\n <div className=\"flex justify-between items-end w-full\">\n <Label className=\"mt-4\">Suggested:</Label>\n <div className=\"ml-auto\">\n {isLoading && (\n <div className=\"flex justify-center items-center\">\n <div\n className=\"inline-block h-4 w-4 animate-spin rounded-full border-4 border-solid border-current border-r-transparent align-[-0.125em] motion-reduce:animate-[spin_1.5s_linear_infinite]\"\n role=\"status\"\n >\n <span className=\"!absolute !-m-px !h-px !w-px !overflow-hidden !whitespace-nowrap !border-0 !p-0 ![clip:rect(0,0,0,0)]\">\n Loading...\n </span>\n </div>\n </div>\n )}\n </div>\n </div>\n <textarea\n ref={suggestionTextAreaRef}\n value={editSuggestion}\n disabled={suggestionIsLoading}\n onChange={(e) => setEditSuggestion(e.target.value)}\n className=\"w-full text-base p-2 border border-gray-300 rounded-md resize-none bg-green-50\"\n style={{ overflow: \"auto\", maxHeight: \"10em\" }}\n />\n </>\n );\n\n const SubmitComponent = (\n <div className=\"flex w-full gap-4 justify-start\">\n <Button\n className=\" bg-green-700 text-white\"\n onClick={() => {\n performInsertion(editSuggestion);\n }}\n >\n Insert <i className=\"material-icons\">check</i>\n </Button>\n </div>\n );\n\n // show source search if the last word in the adjustment prompt BEGINS with an @\n const sourceSearchCandidate = adjustmentPrompt.split(\" \").pop();\n // if the candidate is @someCandidate, then 'someCandidate', otherwise undefined\n const sourceSearchWord = sourceSearchCandidate?.startsWith(\"@\")\n ? sourceSearchCandidate.slice(1)\n : undefined;\n\n return (\n <div className=\"w-full flex flex-col items-start relative gap-2\">\n {AdjustmentPromptComponent}\n {filePointers.length > 0 && (\n <IncludedFilesPreview includedFiles={filePointers} setIncludedFiles={setFilePointers} />\n )}\n {sourceSearchWord !== undefined && (\n <SourceSearchBox\n searchTerm={sourceSearchWord}\n suggestedFiles={suggestedFiles}\n onSelectedFile={(filePointer) => {\n setAdjustmentPrompt(adjustmentPrompt.replace(new RegExp(`@${sourceSearchWord}$`), \"\"));\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","/**\n * Flatten a promise of a stream, into a stream.\n *\n * Useful because a stream already includes the notion of async value delivery,\n * so it often makes sense to simply await the values rather than the generator of the values.\n *\n * @param {Promise<ReadableStream<A>>} promise - The promise to flatten.\n * @returns {ReadableStream<A>} - The flattened stream.\n */\n\nexport function streamPromiseFlatten<A>(promise: Promise<ReadableStream<A>>): ReadableStream<A> {\n return new ReadableStream<A>({\n async start(controller) {\n try {\n const stream = await promise;\n const reader = stream.getReader();\n\n while (true) {\n const { done, value } = await reader.read();\n\n if (done) {\n controller.close();\n return;\n }\n\n controller.enqueue(value);\n }\n } catch (error) {\n controller.error(error);\n }\n },\n });\n}\n","import { DocumentPointer } from \"@copilotkit/react-core\";\nimport { Label } from \"../../ui/label\";\nimport React from \"react\";\nimport Chip from \"@mui/material/Chip/Chip.js\";\nimport Avatar from \"@mui/material/Avatar/Avatar.js\";\n\nexport interface IncludedFilesPreviewProps {\n includedFiles: DocumentPointer[];\n setIncludedFiles: React.Dispatch<React.SetStateAction<DocumentPointer[]>>;\n}\n\nexport const IncludedFilesPreview = ({\n includedFiles,\n setIncludedFiles,\n}: IncludedFilesPreviewProps) => {\n return (\n <div className=\"flex flex-col gap-2 mt-2\">\n <Label className=\"\">Included context:</Label>\n <div className=\"flex flex-wrap gap-2\">\n {includedFiles.map((filePointer, index) => {\n return (\n <FileChipPreview\n key={`file-${filePointer.sourceApplication}.${filePointer.name}`}\n filePointer={filePointer}\n onDelete={() => {\n setIncludedFiles((prev) => prev.filter((fp) => fp !== filePointer));\n }}\n />\n );\n })}\n </div>\n </div>\n );\n};\n\nexport interface FileChipPreviewProps {\n filePointer: DocumentPointer;\n onDelete: () => void;\n}\n\nexport const FileChipPreview = ({ filePointer, onDelete }: FileChipPreviewProps) => {\n return (\n <Chip\n label={filePointer.name}\n onDelete={onDelete}\n avatar={\n <Avatar\n src={filePointer.iconImageUri}\n alt={filePointer.sourceApplication}\n sx={{ backgroundColor: \"transparent\" }}\n ></Avatar>\n }\n />\n );\n};\n","import { createContext, useState, useContext, ReactNode } from \"react\";\n\ninterface HoveringEditorContextProps {\n isDisplayed: boolean;\n setIsDisplayed: (value: boolean) => void;\n}\n\nconst HoveringEditorContext = createContext<HoveringEditorContextProps>({\n isDisplayed: false,\n setIsDisplayed: () => {},\n});\n\nexport interface HoveringEditorProviderProps {\n children: ReactNode;\n}\n\n/**\n * A context provider for the hovering editor over the `CopilotTextarea`\n * (used to edit and insert text into the `CopilotTextarea`).\n */\nexport const HoveringEditorProvider = ({ children }: HoveringEditorProviderProps) => {\n const [isDisplayed, setIsDisplayed] = useState<boolean>(false);\n\n return (\n <HoveringEditorContext.Provider value={{ isDisplayed, setIsDisplayed }}>\n {children}\n </HoveringEditorContext.Provider>\n );\n};\n\nexport const useHoveringEditorContext = () => useContext(HoveringEditorContext);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAA0C;AAG1C,IAAM,sBAAsB,CAAC,aAA6C,UAAkB;AAC1F,8BAAU,MAAM;AACd,QAAI,YAAY,YAAY,MAAM;AAEhC,kBAAY,QAAQ,MAAM,SAAS;AACnC,YAAM,eAAe,YAAY,QAAQ;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MACC,WAAU;AAAA,MACV,SAAS,MAAM;AACb,yBAAiB,cAAc;AAAA,MACjC;AAAA,MACD;AAAA;AAAA,QACQ,6CAAC,OAAE,WAAU,kBAAiB,mBAAK;AAAA;AAAA;AAAA,EAC5C,GACF;AAIF,QAAM,wBAAwB,iBAAiB,MAAM,GAAG,EAAE,IAAI;AAE9D,QAAM,oBAAmB,+DAAuB,WAAW,QACvD,sBAAsB,MAAM,CAAC,IAC7B;AAEJ,SACE,8CAAC,SAAI,WAAU,mDACZ;AAAA;AAAA,IACA,aAAa,SAAS,KACrB,6CAAC,wBAAqB,eAAe,cAAc,kBAAkB,iBAAiB;AAAA,IAEvF,qBAAqB,UACpB;AAAA,MAAC;AAAA;AAAA,QACC,YAAY;AAAA,QACZ;AAAA,QACA,gBAAgB,CAAC,gBAAgB;AAzQ3C;AA0QY,8BAAoB,iBAAiB,QAAQ,IAAI,OAAO,IAAI,mBAAmB,GAAG,EAAE,CAAC;AACrF,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;;;APlQM,IAAAC,sBAAA;AANC,IAAM,6BAA6B,CAAC,UAAiB;AAC1D,SACE;AAAA,IAAC;AAAA;AAAA,MACC,WAAU;AAAA,MACV,OAAO,EAAE,OAAO,QAAQ;AAAA,MAExB;AAAA,QAAC;AAAA;AAAA,UACC,OAAO;AAAA,YACL,aAAa,MAAM;AAAA,UACrB;AAAA,UACA,4BAA4B,MAAM,UAAU;AAAA,UAC5C,kBAAkB,MAAM;AAAA,UACxB,mBAAmB,MAAM;AAAA;AAAA,MAC3B;AAAA;AAAA,EACF;AAEJ;","names":["import_react","CommandPrimitive","CommandPrimitive","import_jsx_runtime","React","import_jsx_runtime","React","import_class_variance_authority","import_jsx_runtime","import_react","import_jsx_runtime","Chip","Avatar","import_react","import_jsx_runtime","import_jsx_runtime","import_jsx_runtime"]}
@@ -1,11 +1,12 @@
1
1
  import {
2
2
  HoveringInsertionPromptBox
3
- } from "../../../chunk-BBZ7AWOB.mjs";
4
- import "../../../chunk-VB4VNCIQ.mjs";
3
+ } from "../../../chunk-4H2O7MYQ.mjs";
4
+ import "../../../chunk-K7GVTNZU.mjs";
5
5
  import "../../../chunk-SX6NY5FW.mjs";
6
6
  import "../../../chunk-3PQ7GSFE.mjs";
7
7
  import "../../../chunk-WFTAAA7R.mjs";
8
8
  import "../../../chunk-KFQZHRPJ.mjs";
9
+ import "../../../chunk-LYB4B6MK.mjs";
9
10
  import "../../../chunk-FJNUPSQK.mjs";
10
11
  import "../../../chunk-WTASPE2W.mjs";
11
12
  import "../../../chunk-PTZVE6NC.mjs";
@@ -326,7 +326,7 @@ var Label = React3.forwardRef((_a, ref) => {
326
326
  Label.displayName = LabelPrimitive.Root.displayName;
327
327
 
328
328
  // src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.tsx
329
- var import_react3 = require("react");
329
+ var import_react4 = require("react");
330
330
 
331
331
  // src/lib/stream-promise-flatten.ts
332
332
  function streamPromiseFlatten(promise) {
@@ -397,37 +397,47 @@ var FileChipPreview = ({ filePointer, onDelete }) => {
397
397
  );
398
398
  };
399
399
 
400
- // src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.tsx
400
+ // src/components/hovering-toolbar/hovering-editor-provider.tsx
401
+ var import_react3 = require("react");
401
402
  var import_jsx_runtime6 = require("react/jsx-runtime");
403
+ var HoveringEditorContext = (0, import_react3.createContext)({
404
+ isDisplayed: false,
405
+ setIsDisplayed: () => {
406
+ }
407
+ });
408
+ var useHoveringEditorContext = () => (0, import_react3.useContext)(HoveringEditorContext);
409
+
410
+ // src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.tsx
411
+ var import_jsx_runtime7 = require("react/jsx-runtime");
402
412
  var HoveringInsertionPromptBoxCore = ({
403
413
  performInsertion,
404
414
  state,
405
415
  insertionOrEditingFunction,
406
416
  contextCategories
407
417
  }) => {
408
- const { getDocumentsContext } = (0, import_react3.useContext)(import_react_core.CopilotContext);
409
- const [editSuggestion, setEditSuggestion] = (0, import_react3.useState)("");
410
- const [suggestionIsLoading, setSuggestionIsLoading] = (0, import_react3.useState)(false);
411
- const [adjustmentPrompt, setAdjustmentPrompt] = (0, import_react3.useState)("");
412
- const [generatingSuggestion, setGeneratingSuggestion] = (0, import_react3.useState)(
418
+ const { getDocumentsContext } = (0, import_react4.useContext)(import_react_core.CopilotContext);
419
+ const [editSuggestion, setEditSuggestion] = (0, import_react4.useState)("");
420
+ const [suggestionIsLoading, setSuggestionIsLoading] = (0, import_react4.useState)(false);
421
+ const [adjustmentPrompt, setAdjustmentPrompt] = (0, import_react4.useState)("");
422
+ const [generatingSuggestion, setGeneratingSuggestion] = (0, import_react4.useState)(
413
423
  null
414
424
  );
415
- const adjustmentTextAreaRef = (0, import_react3.useRef)(null);
416
- const suggestionTextAreaRef = (0, import_react3.useRef)(null);
417
- const [filePointers, setFilePointers] = (0, import_react3.useState)([]);
418
- const [suggestedFiles, setSuggestedFiles] = (0, import_react3.useState)([]);
419
- (0, import_react3.useEffect)(() => {
425
+ const adjustmentTextAreaRef = (0, import_react4.useRef)(null);
426
+ const suggestionTextAreaRef = (0, import_react4.useRef)(null);
427
+ const [filePointers, setFilePointers] = (0, import_react4.useState)([]);
428
+ const [suggestedFiles, setSuggestedFiles] = (0, import_react4.useState)([]);
429
+ (0, import_react4.useEffect)(() => {
420
430
  setSuggestedFiles(getDocumentsContext(contextCategories));
421
431
  }, [contextCategories, getDocumentsContext]);
422
432
  use_autosize_textarea_default(suggestionTextAreaRef, editSuggestion || "");
423
433
  use_autosize_textarea_default(adjustmentTextAreaRef, adjustmentPrompt || "");
424
- (0, import_react3.useEffect)(() => {
434
+ (0, import_react4.useEffect)(() => {
425
435
  setTimeout(() => {
426
436
  var _a;
427
437
  (_a = adjustmentTextAreaRef.current) == null ? void 0 : _a.focus();
428
438
  }, 0);
429
439
  }, []);
430
- (0, import_react3.useEffect)(() => {
440
+ (0, import_react4.useEffect)(() => {
431
441
  if (!generatingSuggestion) {
432
442
  return;
433
443
  }
@@ -465,7 +475,7 @@ var HoveringInsertionPromptBoxCore = ({
465
475
  releaseLockIfNotClosed();
466
476
  };
467
477
  }, [generatingSuggestion]);
468
- const beginGeneratingAdjustment = (0, import_react3.useCallback)(() => __async(void 0, null, function* () {
478
+ const beginGeneratingAdjustment = (0, import_react4.useCallback)(() => __async(void 0, null, function* () {
469
479
  if (!adjustmentPrompt.trim()) {
470
480
  return;
471
481
  }
@@ -494,10 +504,11 @@ var HoveringInsertionPromptBoxCore = ({
494
504
  const textToEdit = editSuggestion || state.editorState.selectedText;
495
505
  const adjustmentLabel = textToEdit === "" ? "Describe the text you want to insert" : "Describe adjustments to the suggested text";
496
506
  const placeholder = textToEdit === "" ? "e.g. 'summarize the client's top 3 pain-points from @CallTranscript'" : "e.g. 'make it more formal', 'be more specific', ...";
497
- const AdjustmentPromptComponent = /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
498
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Label, { className: "", children: adjustmentLabel }),
499
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "relative w-full flex items-center", children: [
500
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
507
+ const { setIsDisplayed } = useHoveringEditorContext();
508
+ const AdjustmentPromptComponent = /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
509
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Label, { className: "", children: adjustmentLabel }),
510
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "relative w-full flex items-center", children: [
511
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
501
512
  "textarea",
502
513
  {
503
514
  disabled: suggestionIsLoading,
@@ -511,6 +522,9 @@ var HoveringInsertionPromptBoxCore = ({
511
522
  } else if (e.key === "Enter") {
512
523
  e.preventDefault();
513
524
  beginGeneratingAdjustment();
525
+ } else if (e.key == "Escape") {
526
+ e.preventDefault();
527
+ setIsDisplayed(false);
514
528
  }
515
529
  },
516
530
  placeholder,
@@ -519,29 +533,29 @@ var HoveringInsertionPromptBoxCore = ({
519
533
  rows: 1
520
534
  }
521
535
  ),
522
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
536
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
523
537
  "button",
524
538
  {
525
539
  onClick: beginGeneratingAdjustment,
526
540
  className: "absolute right-2 bg-blue-500 text-white w-8 h-8 rounded-full flex items-center justify-center",
527
- children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("i", { className: "material-icons", children: "arrow_forward" })
541
+ children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("i", { className: "material-icons", children: "arrow_forward" })
528
542
  }
529
543
  )
530
544
  ] })
531
545
  ] });
532
- const SuggestionComponent = /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
533
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "flex justify-between items-end w-full", children: [
534
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Label, { className: "mt-4", children: "Suggested:" }),
535
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "ml-auto", children: isLoading && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "flex justify-center items-center", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
546
+ const SuggestionComponent = /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
547
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "flex justify-between items-end w-full", children: [
548
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Label, { className: "mt-4", children: "Suggested:" }),
549
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "ml-auto", children: isLoading && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "flex justify-center items-center", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
536
550
  "div",
537
551
  {
538
552
  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]",
539
553
  role: "status",
540
- children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "!absolute !-m-px !h-px !w-px !overflow-hidden !whitespace-nowrap !border-0 !p-0 ![clip:rect(0,0,0,0)]", children: "Loading..." })
554
+ children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "!absolute !-m-px !h-px !w-px !overflow-hidden !whitespace-nowrap !border-0 !p-0 ![clip:rect(0,0,0,0)]", children: "Loading..." })
541
555
  }
542
556
  ) }) })
543
557
  ] }),
544
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
558
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
545
559
  "textarea",
546
560
  {
547
561
  ref: suggestionTextAreaRef,
@@ -553,7 +567,7 @@ var HoveringInsertionPromptBoxCore = ({
553
567
  }
554
568
  )
555
569
  ] });
556
- const SubmitComponent = /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "flex w-full gap-4 justify-start", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
570
+ const SubmitComponent = /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "flex w-full gap-4 justify-start", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
557
571
  Button,
558
572
  {
559
573
  className: " bg-green-700 text-white",
@@ -562,16 +576,16 @@ var HoveringInsertionPromptBoxCore = ({
562
576
  },
563
577
  children: [
564
578
  "Insert ",
565
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("i", { className: "material-icons", children: "check" })
579
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("i", { className: "material-icons", children: "check" })
566
580
  ]
567
581
  }
568
582
  ) });
569
583
  const sourceSearchCandidate = adjustmentPrompt.split(" ").pop();
570
584
  const sourceSearchWord = (sourceSearchCandidate == null ? void 0 : sourceSearchCandidate.startsWith("@")) ? sourceSearchCandidate.slice(1) : void 0;
571
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "w-full flex flex-col items-start relative gap-2", children: [
585
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "w-full flex flex-col items-start relative gap-2", children: [
572
586
  AdjustmentPromptComponent,
573
- filePointers.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(IncludedFilesPreview, { includedFiles: filePointers, setIncludedFiles: setFilePointers }),
574
- sourceSearchWord !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
587
+ filePointers.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(IncludedFilesPreview, { includedFiles: filePointers, setIncludedFiles: setFilePointers }),
588
+ sourceSearchWord !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
575
589
  SourceSearchBox,
576
590
  {
577
591
  searchTerm: sourceSearchWord,
@@ -590,14 +604,14 @@ var HoveringInsertionPromptBoxCore = ({
590
604
  };
591
605
 
592
606
  // src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.tsx
593
- var import_jsx_runtime7 = require("react/jsx-runtime");
607
+ var import_jsx_runtime8 = require("react/jsx-runtime");
594
608
  var HoveringInsertionPromptBox = (props) => {
595
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
609
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
596
610
  "div",
597
611
  {
598
612
  className: "flex flex-col justify-center items-center space-y-4 rounded-md border shadow-lg p-4 border-gray- bg-white",
599
613
  style: { width: "35rem" },
600
- children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
614
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
601
615
  HoveringInsertionPromptBoxCore,
602
616
  {
603
617
  state: {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/components/hovering-toolbar/text-insertion-prompt-box/index.ts","../../../../src/hooks/misc/use-autosize-textarea.tsx","../../../../src/components/source-search-box/source-search-box.tsx","../../../../src/components/ui/command.tsx","../../../../src/lib/utils.ts","../../../../src/components/ui/button.tsx","../../../../src/components/ui/label.tsx","../../../../src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.tsx","../../../../src/lib/stream-promise-flatten.ts","../../../../src/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.tsx","../../../../src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.tsx"],"sourcesContent":["export { HoveringInsertionPromptBox } from \"./hovering-insertion-prompt-box\";\nexport type { Props } from \"./hovering-insertion-prompt-box\";\n","import { Ref, RefObject, useEffect } from \"react\";\n\n// Updates the height of a <textarea> when the value changes.\nconst useAutosizeTextArea = (textAreaRef: RefObject<HTMLTextAreaElement>, value: string) => {\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","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 { Calculator, Calendar, CreditCard, Settings, Smile, User } 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 className=\"flex items-center justify-center\" style={{ width: width, height: height }}>\n {children}\n </div>\n );\n}\n","\"use client\";\n\nimport * as React from \"react\";\nimport { DialogProps } from \"@radix-ui/react-dialog\";\nimport { Command as CommandPrimitive } from \"cmdk\";\nimport { Search } from \"lucide-react\";\n\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(\"max-h-[300px] overflow-y-auto overflow-x-hidden pb-2\", className)}\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 ref={ref} className=\"py-6 text-center text-sm\" {...props} />\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 = ({ className, ...props }: React.HTMLAttributes<HTMLSpanElement>) => {\n return (\n <span\n className={cn(\"ml-auto text-xs tracking-widest text-muted-foreground\", className)}\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","import { clsx, type ClassValue } from \"clsx\";\nimport { customAlphabet } from \"nanoid\";\nimport { twMerge } from \"tailwind-merge\";\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n\nexport const nanoid = customAlphabet(\n \"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\",\n 7,\n); // 7-character random string\n\nexport async function fetcher<JSON = any>(input: RequestInfo, init?: RequestInit): Promise<JSON> {\n const res = await fetch(input, init);\n\n if (!res.ok) {\n const json = await res.json();\n if (json.error) {\n const error = new Error(json.error) as Error & {\n status: number;\n };\n error.status = res.status;\n throw error;\n } else {\n throw new Error(\"An unexpected error occurred\");\n }\n }\n\n return res.json();\n}\n\nexport function formatDate(input: string | number | Date): string {\n const date = new Date(input);\n return date.toLocaleDateString(\"en-US\", {\n month: \"long\",\n day: \"numeric\",\n year: \"numeric\",\n });\n}\n\nexport const arraysAreEqual = (arr1: number[], arr2: number[]): boolean =>\n arr1.length === arr2.length && arr1.every((value, index) => value === arr2[index]);\n\nexport function nullableCompatibleEqualityCheck<T>(\n naiveEqualityCheck: (a: T, b: T) => boolean,\n a: T | null | undefined,\n b: T | null | undefined,\n): boolean {\n if (a === null || a === undefined || b === null || b === undefined) {\n return a === b;\n }\n\n return naiveEqualityCheck(a, b);\n}\n","import * as React from \"react\";\nimport { Slot } from \"@radix-ui/react-slot\";\nimport { cva, type VariantProps } from \"class-variance-authority\";\n\nimport { cn } from \"../../lib/utils\";\n\nconst buttonVariants = cva(\n \"inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50\",\n {\n variants: {\n variant: {\n default: \"bg-primary text-primary-foreground hover:bg-primary/90\",\n destructive: \"bg-destructive text-destructive-foreground hover:bg-destructive/90\",\n outline: \"border border-input bg-background hover:bg-accent hover:text-accent-foreground\",\n secondary: \"bg-secondary text-secondary-foreground hover:bg-secondary/80\",\n ghost: \"hover:bg-accent hover:text-accent-foreground\",\n link: \"text-primary underline-offset-4 hover:underline\",\n },\n size: {\n default: \"h-10 px-4 py-2\",\n sm: \"h-9 rounded-md px-3\",\n lg: \"h-11 rounded-md px-8\",\n icon: \"h-10 w-10\",\n },\n },\n defaultVariants: {\n variant: \"default\",\n size: \"default\",\n },\n },\n);\n\nexport interface ButtonProps\n extends React.ButtonHTMLAttributes<HTMLButtonElement>,\n VariantProps<typeof buttonVariants> {\n asChild?: boolean;\n}\n\nconst Button = React.forwardRef<HTMLButtonElement, ButtonProps>(\n ({ className, variant, size, asChild = false, ...props }, ref) => {\n const Comp = asChild ? Slot : \"button\";\n return (\n <Comp className={cn(buttonVariants({ variant, size, className }))} ref={ref} {...props} />\n );\n },\n);\nButton.displayName = \"Button\";\n\nexport { Button, buttonVariants };\n","\"use client\";\n\nimport * 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> & VariantProps<typeof labelVariants>\n>(({ className, ...props }, ref) => (\n <LabelPrimitive.Root ref={ref} className={cn(labelVariants(), className)} {...props} />\n));\nLabel.displayName = LabelPrimitive.Root.displayName;\n\nexport { Label };\n","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 } from \"@copilotkit/react-core\";\nimport { Button } from \"../../ui/button\";\nimport { Label } from \"../../ui/label\";\nimport { useCallback, useContext, useEffect, useRef, useState } from \"react\";\n\nimport { streamPromiseFlatten } from \"../../../lib/stream-promise-flatten\";\nimport { CopilotContext } from \"@copilotkit/react-core\";\nimport { IncludedFilesPreview } from \"./included-files-preview\";\n\nexport type SuggestionState = {\n editorState: EditingEditorState;\n};\n\nexport interface HoveringInsertionPromptBoxCoreProps {\n state: SuggestionState;\n performInsertion: (insertedText: string) => void;\n insertionOrEditingFunction: Generator_InsertionOrEditingSuggestion;\n contextCategories: string[];\n}\n\nexport const HoveringInsertionPromptBoxCore = ({\n performInsertion,\n state,\n insertionOrEditingFunction,\n contextCategories,\n}: HoveringInsertionPromptBoxCoreProps) => {\n const { getDocumentsContext } = useContext(CopilotContext);\n\n const [editSuggestion, setEditSuggestion] = useState<string>(\"\");\n const [suggestionIsLoading, setSuggestionIsLoading] = useState<boolean>(false);\n\n const [adjustmentPrompt, setAdjustmentPrompt] = useState<string>(\"\");\n\n const [generatingSuggestion, setGeneratingSuggestion] = useState<ReadableStream<string> | null>(\n null,\n );\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 // Focus in the next tick, making sure the adjustment prompt text area is rendered\n // TODO: This happens in Safari, but not in Chrome. Need to look further into this,\n // because focus() should not throw IndexSizeError.\n // this fixes https://github.com/CopilotKit/CopilotKit/issues/171\n setTimeout(() => {\n adjustmentTextAreaRef.current?.focus();\n }, 0);\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 = suggestionTextAreaRef.current.scrollHeight;\n }\n return newSuggestion;\n });\n }\n\n setSuggestionIsLoading(false);\n };\n read();\n\n return () => {\n // release the lock if the reader is not closed on unmount\n const releaseLockIfNotClosed = async () => {\n try {\n await reader.closed;\n } catch {\n reader.releaseLock();\n }\n };\n\n releaseLockIfNotClosed();\n };\n }, [generatingSuggestion]);\n\n // generate an adjustment to the completed text, based on the adjustment prompt\n const beginGeneratingAdjustment = useCallback(async () => {\n // don't generate text if the prompt is empty\n if (!adjustmentPrompt.trim()) {\n return;\n }\n\n // editor state includes the text being edited, and the text before/after the selection\n // if the current edit suggestion is not empty, then use *it* as the \"selected text\" - instead of the editor state's selected text\n let modificationState = state.editorState;\n if (editSuggestion !== \"\") {\n modificationState.selectedText = editSuggestion;\n }\n\n // generate the adjustment suggestion\n const adjustmentSuggestionTextStreamPromise = insertionOrEditingFunction(\n modificationState,\n adjustmentPrompt,\n filePointers,\n new AbortController().signal,\n );\n const adjustmentSuggestionTextStream = streamPromiseFlatten(\n adjustmentSuggestionTextStreamPromise,\n );\n\n setGeneratingSuggestion(adjustmentSuggestionTextStream);\n }, [\n adjustmentPrompt,\n editSuggestion,\n state.editorState,\n insertionOrEditingFunction,\n filePointers,\n ]);\n\n const isLoading = suggestionIsLoading;\n\n const textToEdit = editSuggestion || state.editorState.selectedText;\n const adjustmentLabel =\n textToEdit === \"\"\n ? \"Describe the text you want to insert\"\n : \"Describe adjustments to the suggested text\";\n const placeholder =\n textToEdit === \"\"\n ? \"e.g. 'summarize the client's top 3 pain-points from @CallTranscript'\"\n : \"e.g. 'make it more formal', 'be more specific', ...\";\n\n const AdjustmentPromptComponent = (\n <>\n <Label className=\"\">{adjustmentLabel}</Label>\n <div className=\"relative w-full flex items-center\">\n <textarea\n disabled={suggestionIsLoading}\n ref={adjustmentTextAreaRef}\n value={adjustmentPrompt}\n onChange={(e) => setAdjustmentPrompt(e.target.value)}\n onKeyDown={(e) => {\n if (e.key === \"Enter\" && e.shiftKey) {\n e.preventDefault();\n setAdjustmentPrompt(adjustmentPrompt + \"\\n\");\n } else if (e.key === \"Enter\") {\n e.preventDefault();\n beginGeneratingAdjustment();\n }\n }}\n placeholder={placeholder}\n style={{ minHeight: \"3rem\" }}\n className=\"w-full bg-slate-100 h-auto h-min-14 text-sm p-2 rounded-md resize-none overflow-visible focus:outline-none focus:ring-0 focus:border-non pr-[3rem]\"\n rows={1}\n />\n <button\n onClick={beginGeneratingAdjustment}\n className=\"absolute right-2 bg-blue-500 text-white w-8 h-8 rounded-full flex items-center justify-center\"\n >\n <i className=\"material-icons\">arrow_forward</i>\n </button>\n </div>\n </>\n );\n\n const SuggestionComponent = (\n <>\n <div className=\"flex justify-between items-end w-full\">\n <Label className=\"mt-4\">Suggested:</Label>\n <div className=\"ml-auto\">\n {isLoading && (\n <div className=\"flex justify-center items-center\">\n <div\n className=\"inline-block h-4 w-4 animate-spin rounded-full border-4 border-solid border-current border-r-transparent align-[-0.125em] motion-reduce:animate-[spin_1.5s_linear_infinite]\"\n role=\"status\"\n >\n <span className=\"!absolute !-m-px !h-px !w-px !overflow-hidden !whitespace-nowrap !border-0 !p-0 ![clip:rect(0,0,0,0)]\">\n Loading...\n </span>\n </div>\n </div>\n )}\n </div>\n </div>\n <textarea\n ref={suggestionTextAreaRef}\n value={editSuggestion}\n disabled={suggestionIsLoading}\n onChange={(e) => setEditSuggestion(e.target.value)}\n className=\"w-full text-base p-2 border border-gray-300 rounded-md resize-none bg-green-50\"\n style={{ overflow: \"auto\", maxHeight: \"10em\" }}\n />\n </>\n );\n\n const SubmitComponent = (\n <div className=\"flex w-full gap-4 justify-start\">\n <Button\n className=\" bg-green-700 text-white\"\n onClick={() => {\n performInsertion(editSuggestion);\n }}\n >\n Insert <i className=\"material-icons\">check</i>\n </Button>\n </div>\n );\n\n // show source search if the last word in the adjustment prompt BEGINS with an @\n const sourceSearchCandidate = adjustmentPrompt.split(\" \").pop();\n // if the candidate is @someCandidate, then 'someCandidate', otherwise undefined\n const sourceSearchWord = sourceSearchCandidate?.startsWith(\"@\")\n ? sourceSearchCandidate.slice(1)\n : undefined;\n\n return (\n <div className=\"w-full flex flex-col items-start relative gap-2\">\n {AdjustmentPromptComponent}\n {filePointers.length > 0 && (\n <IncludedFilesPreview includedFiles={filePointers} setIncludedFiles={setFilePointers} />\n )}\n {sourceSearchWord !== undefined && (\n <SourceSearchBox\n searchTerm={sourceSearchWord}\n suggestedFiles={suggestedFiles}\n onSelectedFile={(filePointer) => {\n setAdjustmentPrompt(adjustmentPrompt.replace(new RegExp(`@${sourceSearchWord}$`), \"\"));\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","/**\n * Flatten a promise of a stream, into a stream.\n *\n * Useful because a stream already includes the notion of async value delivery,\n * so it often makes sense to simply await the values rather than the generator of the values.\n *\n * @param {Promise<ReadableStream<A>>} promise - The promise to flatten.\n * @returns {ReadableStream<A>} - The flattened stream.\n */\n\nexport function streamPromiseFlatten<A>(promise: Promise<ReadableStream<A>>): ReadableStream<A> {\n return new ReadableStream<A>({\n async start(controller) {\n try {\n const stream = await promise;\n const reader = stream.getReader();\n\n while (true) {\n const { done, value } = await reader.read();\n\n if (done) {\n controller.close();\n return;\n }\n\n controller.enqueue(value);\n }\n } catch (error) {\n controller.error(error);\n }\n },\n });\n}\n","import { DocumentPointer } from \"@copilotkit/react-core\";\nimport { Label } from \"../../ui/label\";\nimport React from \"react\";\nimport Chip from \"@mui/material/Chip/Chip.js\";\nimport Avatar from \"@mui/material/Avatar/Avatar.js\";\n\nexport interface IncludedFilesPreviewProps {\n includedFiles: DocumentPointer[];\n setIncludedFiles: React.Dispatch<React.SetStateAction<DocumentPointer[]>>;\n}\n\nexport const IncludedFilesPreview = ({\n includedFiles,\n setIncludedFiles,\n}: IncludedFilesPreviewProps) => {\n return (\n <div className=\"flex flex-col gap-2 mt-2\">\n <Label className=\"\">Included context:</Label>\n <div className=\"flex flex-wrap gap-2\">\n {includedFiles.map((filePointer, index) => {\n return (\n <FileChipPreview\n key={`file-${filePointer.sourceApplication}.${filePointer.name}`}\n filePointer={filePointer}\n onDelete={() => {\n setIncludedFiles((prev) => prev.filter((fp) => fp !== filePointer));\n }}\n />\n );\n })}\n </div>\n </div>\n );\n};\n\nexport interface FileChipPreviewProps {\n filePointer: DocumentPointer;\n onDelete: () => void;\n}\n\nexport const FileChipPreview = ({ filePointer, onDelete }: FileChipPreviewProps) => {\n return (\n <Chip\n label={filePointer.name}\n onDelete={onDelete}\n avatar={\n <Avatar\n src={filePointer.iconImageUri}\n alt={filePointer.sourceApplication}\n sx={{ backgroundColor: \"transparent\" }}\n ></Avatar>\n }\n />\n );\n};\n","import { HoveringInsertionPromptBoxCore } from \"./hovering-insertion-prompt-box-core\";\nimport {\n EditingEditorState,\n InsertionEditorApiConfig,\n} from \"../../../types/base/autosuggestions-bare-function\";\n\nexport interface Props {\n editorState: EditingEditorState;\n apiConfig: InsertionEditorApiConfig;\n performInsertion: (insertedText: string) => void;\n closeWindow: () => void;\n contextCategories: string[];\n}\n\nexport const HoveringInsertionPromptBox = (props: Props) => {\n return (\n <div\n className=\"flex flex-col justify-center items-center space-y-4 rounded-md border shadow-lg p-4 border-gray- bg-white\"\n style={{ width: \"35rem\" }}\n >\n <HoveringInsertionPromptBoxCore\n state={{\n editorState: props.editorState,\n }}\n insertionOrEditingFunction={props.apiConfig.insertionOrEditingFunction}\n performInsertion={props.performInsertion}\n contextCategories={props.contextCategories}\n />\n </div>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAA0C;AAG1C,IAAM,sBAAsB,CAAC,aAA6C,UAAkB;AAC1F,8BAAU,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;;;ACjBf,IAAAA,gBAAyB;;;ACEzB,YAAuB;AAEvB,kBAA4C;;;ACJ5C,kBAAsC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AAgB;AAnQ3C;AAoQY,8BAAoB,iBAAiB,QAAQ,IAAI,OAAO,IAAI,mBAAmB,GAAG,EAAE,CAAC;AACrF,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;;;AG5PM,IAAAC,sBAAA;AANC,IAAM,6BAA6B,CAAC,UAAiB;AAC1D,SACE;AAAA,IAAC;AAAA;AAAA,MACC,WAAU;AAAA,MACV,OAAO,EAAE,OAAO,QAAQ;AAAA,MAExB;AAAA,QAAC;AAAA;AAAA,UACC,OAAO;AAAA,YACL,aAAa,MAAM;AAAA,UACrB;AAAA,UACA,4BAA4B,MAAM,UAAU;AAAA,UAC5C,kBAAkB,MAAM;AAAA,UACxB,mBAAmB,MAAM;AAAA;AAAA,MAC3B;AAAA;AAAA,EACF;AAEJ;","names":["import_react","CommandPrimitive","CommandPrimitive","import_jsx_runtime","React","import_jsx_runtime","React","import_class_variance_authority","import_jsx_runtime","import_react","import_jsx_runtime","Chip","Avatar","import_jsx_runtime","import_jsx_runtime"]}
1
+ {"version":3,"sources":["../../../../src/components/hovering-toolbar/text-insertion-prompt-box/index.ts","../../../../src/hooks/misc/use-autosize-textarea.tsx","../../../../src/components/source-search-box/source-search-box.tsx","../../../../src/components/ui/command.tsx","../../../../src/lib/utils.ts","../../../../src/components/ui/button.tsx","../../../../src/components/ui/label.tsx","../../../../src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.tsx","../../../../src/lib/stream-promise-flatten.ts","../../../../src/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.tsx","../../../../src/components/hovering-toolbar/hovering-editor-provider.tsx","../../../../src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.tsx"],"sourcesContent":["export { HoveringInsertionPromptBox } from \"./hovering-insertion-prompt-box\";\nexport type { Props } from \"./hovering-insertion-prompt-box\";\n","import { Ref, RefObject, useEffect } from \"react\";\n\n// Updates the height of a <textarea> when the value changes.\nconst useAutosizeTextArea = (textAreaRef: RefObject<HTMLTextAreaElement>, value: string) => {\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","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 { Calculator, Calendar, CreditCard, Settings, Smile, User } 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 className=\"flex items-center justify-center\" style={{ width: width, height: height }}>\n {children}\n </div>\n );\n}\n","\"use client\";\n\nimport * as React from \"react\";\nimport { DialogProps } from \"@radix-ui/react-dialog\";\nimport { Command as CommandPrimitive } from \"cmdk\";\nimport { Search } from \"lucide-react\";\n\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(\"max-h-[300px] overflow-y-auto overflow-x-hidden pb-2\", className)}\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 ref={ref} className=\"py-6 text-center text-sm\" {...props} />\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 = ({ className, ...props }: React.HTMLAttributes<HTMLSpanElement>) => {\n return (\n <span\n className={cn(\"ml-auto text-xs tracking-widest text-muted-foreground\", className)}\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","import { clsx, type ClassValue } from \"clsx\";\nimport { customAlphabet } from \"nanoid\";\nimport { twMerge } from \"tailwind-merge\";\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n\nexport const nanoid = customAlphabet(\n \"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\",\n 7,\n); // 7-character random string\n\nexport async function fetcher<JSON = any>(input: RequestInfo, init?: RequestInit): Promise<JSON> {\n const res = await fetch(input, init);\n\n if (!res.ok) {\n const json = await res.json();\n if (json.error) {\n const error = new Error(json.error) as Error & {\n status: number;\n };\n error.status = res.status;\n throw error;\n } else {\n throw new Error(\"An unexpected error occurred\");\n }\n }\n\n return res.json();\n}\n\nexport function formatDate(input: string | number | Date): string {\n const date = new Date(input);\n return date.toLocaleDateString(\"en-US\", {\n month: \"long\",\n day: \"numeric\",\n year: \"numeric\",\n });\n}\n\nexport const arraysAreEqual = (arr1: number[], arr2: number[]): boolean =>\n arr1.length === arr2.length && arr1.every((value, index) => value === arr2[index]);\n\nexport function nullableCompatibleEqualityCheck<T>(\n naiveEqualityCheck: (a: T, b: T) => boolean,\n a: T | null | undefined,\n b: T | null | undefined,\n): boolean {\n if (a === null || a === undefined || b === null || b === undefined) {\n return a === b;\n }\n\n return naiveEqualityCheck(a, b);\n}\n","import * as React from \"react\";\nimport { Slot } from \"@radix-ui/react-slot\";\nimport { cva, type VariantProps } from \"class-variance-authority\";\n\nimport { cn } from \"../../lib/utils\";\n\nconst buttonVariants = cva(\n \"inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50\",\n {\n variants: {\n variant: {\n default: \"bg-primary text-primary-foreground hover:bg-primary/90\",\n destructive: \"bg-destructive text-destructive-foreground hover:bg-destructive/90\",\n outline: \"border border-input bg-background hover:bg-accent hover:text-accent-foreground\",\n secondary: \"bg-secondary text-secondary-foreground hover:bg-secondary/80\",\n ghost: \"hover:bg-accent hover:text-accent-foreground\",\n link: \"text-primary underline-offset-4 hover:underline\",\n },\n size: {\n default: \"h-10 px-4 py-2\",\n sm: \"h-9 rounded-md px-3\",\n lg: \"h-11 rounded-md px-8\",\n icon: \"h-10 w-10\",\n },\n },\n defaultVariants: {\n variant: \"default\",\n size: \"default\",\n },\n },\n);\n\nexport interface ButtonProps\n extends React.ButtonHTMLAttributes<HTMLButtonElement>,\n VariantProps<typeof buttonVariants> {\n asChild?: boolean;\n}\n\nconst Button = React.forwardRef<HTMLButtonElement, ButtonProps>(\n ({ className, variant, size, asChild = false, ...props }, ref) => {\n const Comp = asChild ? Slot : \"button\";\n return (\n <Comp className={cn(buttonVariants({ variant, size, className }))} ref={ref} {...props} />\n );\n },\n);\nButton.displayName = \"Button\";\n\nexport { Button, buttonVariants };\n","\"use client\";\n\nimport * 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> & VariantProps<typeof labelVariants>\n>(({ className, ...props }, ref) => (\n <LabelPrimitive.Root ref={ref} className={cn(labelVariants(), className)} {...props} />\n));\nLabel.displayName = LabelPrimitive.Root.displayName;\n\nexport { Label };\n","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 } from \"@copilotkit/react-core\";\nimport { Button } from \"../../ui/button\";\nimport { Label } from \"../../ui/label\";\nimport { useCallback, useContext, useEffect, useRef, useState } from \"react\";\n\nimport { streamPromiseFlatten } from \"../../../lib/stream-promise-flatten\";\nimport { CopilotContext } from \"@copilotkit/react-core\";\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 } = useContext(CopilotContext);\n\n const [editSuggestion, setEditSuggestion] = useState<string>(\"\");\n const [suggestionIsLoading, setSuggestionIsLoading] = useState<boolean>(false);\n\n const [adjustmentPrompt, setAdjustmentPrompt] = useState<string>(\"\");\n\n const [generatingSuggestion, setGeneratingSuggestion] = useState<ReadableStream<string> | null>(\n null,\n );\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 // Focus in the next tick, making sure the adjustment prompt text area is rendered\n // TODO: This happens in Safari, but not in Chrome. Need to look further into this,\n // because focus() should not throw IndexSizeError.\n // this fixes https://github.com/CopilotKit/CopilotKit/issues/171\n setTimeout(() => {\n adjustmentTextAreaRef.current?.focus();\n }, 0);\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 = 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 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 } else if (e.key == \"Escape\") {\n e.preventDefault();\n setIsDisplayed(false);\n }\n }}\n placeholder={placeholder}\n style={{ minHeight: \"3rem\" }}\n className=\"w-full bg-slate-100 h-auto h-min-14 text-sm p-2 rounded-md resize-none overflow-visible focus:outline-none focus:ring-0 focus:border-non pr-[3rem]\"\n rows={1}\n />\n <button\n onClick={beginGeneratingAdjustment}\n className=\"absolute right-2 bg-blue-500 text-white w-8 h-8 rounded-full flex items-center justify-center\"\n >\n <i className=\"material-icons\">arrow_forward</i>\n </button>\n </div>\n </>\n );\n\n const SuggestionComponent = (\n <>\n <div className=\"flex justify-between items-end w-full\">\n <Label className=\"mt-4\">Suggested:</Label>\n <div className=\"ml-auto\">\n {isLoading && (\n <div className=\"flex justify-center items-center\">\n <div\n className=\"inline-block h-4 w-4 animate-spin rounded-full border-4 border-solid border-current border-r-transparent align-[-0.125em] motion-reduce:animate-[spin_1.5s_linear_infinite]\"\n role=\"status\"\n >\n <span className=\"!absolute !-m-px !h-px !w-px !overflow-hidden !whitespace-nowrap !border-0 !p-0 ![clip:rect(0,0,0,0)]\">\n Loading...\n </span>\n </div>\n </div>\n )}\n </div>\n </div>\n <textarea\n ref={suggestionTextAreaRef}\n value={editSuggestion}\n disabled={suggestionIsLoading}\n onChange={(e) => setEditSuggestion(e.target.value)}\n className=\"w-full text-base p-2 border border-gray-300 rounded-md resize-none bg-green-50\"\n style={{ overflow: \"auto\", maxHeight: \"10em\" }}\n />\n </>\n );\n\n const SubmitComponent = (\n <div className=\"flex w-full gap-4 justify-start\">\n <Button\n className=\" bg-green-700 text-white\"\n onClick={() => {\n performInsertion(editSuggestion);\n }}\n >\n Insert <i className=\"material-icons\">check</i>\n </Button>\n </div>\n );\n\n // show source search if the last word in the adjustment prompt BEGINS with an @\n const sourceSearchCandidate = adjustmentPrompt.split(\" \").pop();\n // if the candidate is @someCandidate, then 'someCandidate', otherwise undefined\n const sourceSearchWord = sourceSearchCandidate?.startsWith(\"@\")\n ? sourceSearchCandidate.slice(1)\n : undefined;\n\n return (\n <div className=\"w-full flex flex-col items-start relative gap-2\">\n {AdjustmentPromptComponent}\n {filePointers.length > 0 && (\n <IncludedFilesPreview includedFiles={filePointers} setIncludedFiles={setFilePointers} />\n )}\n {sourceSearchWord !== undefined && (\n <SourceSearchBox\n searchTerm={sourceSearchWord}\n suggestedFiles={suggestedFiles}\n onSelectedFile={(filePointer) => {\n setAdjustmentPrompt(adjustmentPrompt.replace(new RegExp(`@${sourceSearchWord}$`), \"\"));\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","/**\n * Flatten a promise of a stream, into a stream.\n *\n * Useful because a stream already includes the notion of async value delivery,\n * so it often makes sense to simply await the values rather than the generator of the values.\n *\n * @param {Promise<ReadableStream<A>>} promise - The promise to flatten.\n * @returns {ReadableStream<A>} - The flattened stream.\n */\n\nexport function streamPromiseFlatten<A>(promise: Promise<ReadableStream<A>>): ReadableStream<A> {\n return new ReadableStream<A>({\n async start(controller) {\n try {\n const stream = await promise;\n const reader = stream.getReader();\n\n while (true) {\n const { done, value } = await reader.read();\n\n if (done) {\n controller.close();\n return;\n }\n\n controller.enqueue(value);\n }\n } catch (error) {\n controller.error(error);\n }\n },\n });\n}\n","import { DocumentPointer } from \"@copilotkit/react-core\";\nimport { Label } from \"../../ui/label\";\nimport React from \"react\";\nimport Chip from \"@mui/material/Chip/Chip.js\";\nimport Avatar from \"@mui/material/Avatar/Avatar.js\";\n\nexport interface IncludedFilesPreviewProps {\n includedFiles: DocumentPointer[];\n setIncludedFiles: React.Dispatch<React.SetStateAction<DocumentPointer[]>>;\n}\n\nexport const IncludedFilesPreview = ({\n includedFiles,\n setIncludedFiles,\n}: IncludedFilesPreviewProps) => {\n return (\n <div className=\"flex flex-col gap-2 mt-2\">\n <Label className=\"\">Included context:</Label>\n <div className=\"flex flex-wrap gap-2\">\n {includedFiles.map((filePointer, index) => {\n return (\n <FileChipPreview\n key={`file-${filePointer.sourceApplication}.${filePointer.name}`}\n filePointer={filePointer}\n onDelete={() => {\n setIncludedFiles((prev) => prev.filter((fp) => fp !== filePointer));\n }}\n />\n );\n })}\n </div>\n </div>\n );\n};\n\nexport interface FileChipPreviewProps {\n filePointer: DocumentPointer;\n onDelete: () => void;\n}\n\nexport const FileChipPreview = ({ filePointer, onDelete }: FileChipPreviewProps) => {\n return (\n <Chip\n label={filePointer.name}\n onDelete={onDelete}\n avatar={\n <Avatar\n src={filePointer.iconImageUri}\n alt={filePointer.sourceApplication}\n sx={{ backgroundColor: \"transparent\" }}\n ></Avatar>\n }\n />\n );\n};\n","import { createContext, useState, useContext, ReactNode } from \"react\";\n\ninterface HoveringEditorContextProps {\n isDisplayed: boolean;\n setIsDisplayed: (value: boolean) => void;\n}\n\nconst HoveringEditorContext = createContext<HoveringEditorContextProps>({\n isDisplayed: false,\n setIsDisplayed: () => {},\n});\n\nexport interface HoveringEditorProviderProps {\n children: ReactNode;\n}\n\n/**\n * A context provider for the hovering editor over the `CopilotTextarea`\n * (used to edit and insert text into the `CopilotTextarea`).\n */\nexport const HoveringEditorProvider = ({ children }: HoveringEditorProviderProps) => {\n const [isDisplayed, setIsDisplayed] = useState<boolean>(false);\n\n return (\n <HoveringEditorContext.Provider value={{ isDisplayed, setIsDisplayed }}>\n {children}\n </HoveringEditorContext.Provider>\n );\n};\n\nexport const useHoveringEditorContext = () => useContext(HoveringEditorContext);\n","import { HoveringInsertionPromptBoxCore } from \"./hovering-insertion-prompt-box-core\";\nimport {\n EditingEditorState,\n InsertionEditorApiConfig,\n} from \"../../../types/base/autosuggestions-bare-function\";\n\nexport interface Props {\n editorState: EditingEditorState;\n apiConfig: InsertionEditorApiConfig;\n performInsertion: (insertedText: string) => void;\n closeWindow: () => void;\n contextCategories: string[];\n}\n\nexport const HoveringInsertionPromptBox = (props: Props) => {\n return (\n <div\n className=\"flex flex-col justify-center items-center space-y-4 rounded-md border shadow-lg p-4 border-gray- bg-white\"\n style={{ width: \"35rem\" }}\n >\n <HoveringInsertionPromptBoxCore\n state={{\n editorState: props.editorState,\n }}\n insertionOrEditingFunction={props.apiConfig.insertionOrEditingFunction}\n performInsertion={props.performInsertion}\n contextCategories={props.contextCategories}\n />\n </div>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAA0C;AAG1C,IAAM,sBAAsB,CAAC,aAA6C,UAAkB;AAC1F,8BAAU,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;;;ACjBf,IAAAA,gBAAy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AAA,EAC5C,GACF;AAIF,QAAM,wBAAwB,iBAAiB,MAAM,GAAG,EAAE,IAAI;AAE9D,QAAM,oBAAmB,+DAAuB,WAAW,QACvD,sBAAsB,MAAM,CAAC,IAC7B;AAEJ,SACE,8CAAC,SAAI,WAAU,mDACZ;AAAA;AAAA,IACA,aAAa,SAAS,KACrB,6CAAC,wBAAqB,eAAe,cAAc,kBAAkB,iBAAiB;AAAA,IAEvF,qBAAqB,UACpB;AAAA,MAAC;AAAA;AAAA,QACC,YAAY;AAAA,QACZ;AAAA,QACA,gBAAgB,CAAC,gBAAgB;AAzQ3C;AA0QY,8BAAoB,iBAAiB,QAAQ,IAAI,OAAO,IAAI,mBAAmB,GAAG,EAAE,CAAC;AACrF,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;;;AIlQM,IAAAC,sBAAA;AANC,IAAM,6BAA6B,CAAC,UAAiB;AAC1D,SACE;AAAA,IAAC;AAAA;AAAA,MACC,WAAU;AAAA,MACV,OAAO,EAAE,OAAO,QAAQ;AAAA,MAExB;AAAA,QAAC;AAAA;AAAA,UACC,OAAO;AAAA,YACL,aAAa,MAAM;AAAA,UACrB;AAAA,UACA,4BAA4B,MAAM,UAAU;AAAA,UAC5C,kBAAkB,MAAM;AAAA,UACxB,mBAAmB,MAAM;AAAA;AAAA,MAC3B;AAAA;AAAA,EACF;AAEJ;","names":["import_react","CommandPrimitive","CommandPrimitive","import_jsx_runtime","React","import_jsx_runtime","React","import_class_variance_authority","import_jsx_runtime","import_react","import_jsx_runtime","Chip","Avatar","import_react","import_jsx_runtime","import_jsx_runtime","import_jsx_runtime"]}