// End of third-party imports import { compact } from 'lodash' import { FileCodeIcon, PlusIcon, XIcon } from 'lucide-react' import { useCallback, useEffect, useMemo, useRef, useState, type ChangeEvent, type RefObject, } from 'react' import { toast } from 'sonner' import { cn, Tooltip, TooltipContent, TooltipTrigger } from 'ui' import { createSupportStorageClient } from './support-storage-client' import { InlineLink } from '@/components/ui/InlineLink' import { useGenerateAttachmentURLsMutation } from '@/data/support/generate-attachment-urls-mutation' import { uuidv4 } from '@/lib/helpers' import { useProfile } from '@/lib/profile' const MAX_ATTACHMENTS = 5 const ALLOWED_FILE_EXTENSIONS = ['.txt', '.log', '.png', '.jpg', '.jpeg', '.pdf', '.json', '.har'] const IMAGE_FILE_EXTENSIONS = ['.png', '.jpg', '.jpeg'] const getFileExtension = (filename: string) => { const extension = filename.split('.').pop() return extension ? `.${extension.toLowerCase()}` : '' } const isAllowedFile = (file: File) => ALLOWED_FILE_EXTENSIONS.includes(getFileExtension(file.name)) const isImageFile = (file: File) => IMAGE_FILE_EXTENSIONS.includes(getFileExtension(file.name)) const removeAttachmentButtonClassName = cn( 'absolute -top-1 -right-1 size-4 shrink-0 rounded-full bg-red-900 p-0 cursor-pointer', 'focus-ring' ) const RemoveAttachmentIcon = () => (