{"version":3,"file":"VoiceRecordingPreviewSlot.mjs","names":[],"sources":["../../../../../src/components/MessageComposer/AttachmentPreviewList/VoiceRecordingPreviewSlot.tsx"],"sourcesContent":["import type { ComponentType } from 'react';\nimport React from 'react';\nimport {\n  isLocalVoiceRecordingAttachment,\n  type LocalVoiceRecordingAttachment,\n} from 'stream-chat';\nimport { useAttachmentsForPreview, useMessageComposerController } from '../hooks';\nimport { AudioAttachmentPreview } from './AudioAttachmentPreview';\nimport type { UploadAttachmentPreviewProps } from './types';\nimport { useRetryAttachmentUpload } from './useRetryAttachmentUpload';\n\nexport type VoiceRecordingPreviewProps<CustomLocalMetadata = Record<string, unknown>> =\n  UploadAttachmentPreviewProps<LocalVoiceRecordingAttachment<CustomLocalMetadata>>;\n\nexport type VoiceRecordingPreviewSlotProps = {\n  /** Component rendering the voice recording preview. Defaults to `AudioAttachmentPreview`. */\n  VoiceRecordingPreview?: ComponentType<VoiceRecordingPreviewProps>;\n};\n\n/**\n * Shows the first voice recording attachment apart from the main attachment preview list.\n */\nexport const VoiceRecordingPreviewSlot = ({\n  VoiceRecordingPreview = AudioAttachmentPreview,\n}: VoiceRecordingPreviewSlotProps) => {\n  const messageComposer = useMessageComposerController();\n  const retryUpload = useRetryAttachmentUpload();\n  const { attachments } = useAttachmentsForPreview();\n\n  const voiceAttachments = attachments.filter(isLocalVoiceRecordingAttachment);\n  const firstVoice = voiceAttachments[0];\n  if (!firstVoice) return null;\n\n  return (\n    <div\n      className='str-chat__message-composer-voice-preview-slot'\n      data-testid='voice-preview-slot'\n    >\n      <VoiceRecordingPreview\n        attachment={firstVoice}\n        handleRetry={retryUpload}\n        removeAttachments={messageComposer.attachmentManager.removeAttachments}\n      />\n    </div>\n  );\n};\n"],"mappings":";;;;;;;;;;;AAsBA,IAAa,6BAA6B,EACxC,wBAAwB,6BACY;CACpC,MAAM,kBAAkB,6BAA6B;CACrD,MAAM,cAAc,yBAAyB;CAC7C,MAAM,EAAE,gBAAgB,yBAAyB;CAGjD,MAAM,aADmB,YAAY,OAAO,+BACzB,CAAA,CAAiB;CACpC,IAAI,CAAC,YAAY,OAAO;CAExB,OACE,oBAAC,OAAD;EACE,WAAU;EACV,eAAY;YAEZ,oBAAC,uBAAD;GACE,YAAY;GACZ,aAAa;GACb,mBAAmB,gBAAgB,kBAAkB;EACtD,CAAA;CACE,CAAA;AAET"}