{"version":3,"file":"MessageComposerPreviews.defaults.mjs","names":[],"sources":["../../../../src/components/MessageComposer/MessageComposerPreviews.defaults.tsx"],"sourcesContent":["/* eslint-disable sort-keys */\nimport React from 'react';\nimport {\n  isLocalVoiceRecordingAttachment,\n  isVoiceRecordingAttachment,\n  type LocationComposerState,\n  type MessageComposerState,\n} from 'stream-chat';\n\nimport { useComponentContext } from '../../context/ComponentContext';\nimport { useStateStore } from '../../store';\nimport {\n  AttachmentPreviewList as DefaultAttachmentPreviewList,\n  VoiceRecordingPreviewSlot as DefaultVoiceRecordingPreviewSlot,\n} from './AttachmentPreviewList';\nimport { GeolocationPreview } from './AttachmentPreviewList/GeolocationPreview';\nimport { EditedMessagePreview as DefaultEditedMessagePreview } from './EditedMessagePreview';\nimport { useMessageComposerController } from './hooks';\nimport { LinkPreviewList as DefaultLinkPreviewList } from './LinkPreviewList';\nimport type { MessageComposerPreviewSetItem } from './MessageComposerPreviews';\nimport { restorePreEditSnapshot } from './preEditSnapshot';\nimport { QuotedMessagePreview as DefaultQuotedMessagePreview } from './QuotedMessagePreview';\n\nconst editedMessageSelector = ({ editedMessage }: MessageComposerState) => ({\n  editedMessage,\n});\n\nconst locationSelector = ({ location }: LocationComposerState) => ({ location });\n\nconst DefaultMessageComposerPreviewComponents = {\n  EditedMessage() {\n    const { EditedMessagePreview = DefaultEditedMessagePreview } = useComponentContext();\n    const messageComposer = useMessageComposerController();\n    const { editedMessage } = useStateStore(messageComposer.state, editedMessageSelector);\n\n    if (!editedMessage) return null;\n\n    return (\n      <EditedMessagePreview\n        message={editedMessage}\n        onCancel={() => {\n          restorePreEditSnapshot(messageComposer);\n        }}\n      />\n    );\n  },\n  QuotedMessage() {\n    const { QuotedMessagePreview = DefaultQuotedMessagePreview } = useComponentContext();\n    return <QuotedMessagePreview />;\n  },\n  VoiceRecording() {\n    const { VoiceRecordingPreviewSlot = DefaultVoiceRecordingPreviewSlot } =\n      useComponentContext();\n    return <VoiceRecordingPreviewSlot />;\n  },\n  Attachments() {\n    const { AttachmentPreviewList = DefaultAttachmentPreviewList } =\n      useComponentContext();\n    return <AttachmentPreviewList />;\n  },\n  LinkPreviews() {\n    const { LinkPreviewList = DefaultLinkPreviewList } = useComponentContext();\n    return <LinkPreviewList />;\n  },\n  Location() {\n    const messageComposer = useMessageComposerController();\n    const { location } = useStateStore(\n      messageComposer.locationComposer.state,\n      locationSelector,\n    );\n    const { editedMessage } = useStateStore(messageComposer.state, editedMessageSelector);\n\n    if (!location) return null;\n\n    return (\n      <GeolocationPreview\n        location={location}\n        // `shared_location` cannot be nullified, so there is no remove action while editing.\n        remove={editedMessage ? undefined : messageComposer.locationComposer.initState}\n      />\n    );\n  },\n};\n\n/**\n * The previews `MessageComposerPreviews` renders by default, in render order. Filter, reorder or\n * extend it and pass the result as `messageComposerPreviewSet`.\n */\nexport const defaultMessageComposerPreviewSet: MessageComposerPreviewSetItem[] = [\n  {\n    Component: DefaultMessageComposerPreviewComponents.EditedMessage,\n    isVisible: ({ editedMessage }) => !!editedMessage,\n    type: 'editedMessage',\n  },\n  {\n    Component: DefaultMessageComposerPreviewComponents.QuotedMessage,\n    // The edited message preview takes the quoted message's place while editing.\n    isVisible: ({ editedMessage, quotedMessage }) => !editedMessage && !!quotedMessage,\n    type: 'quotedMessage',\n  },\n  {\n    Component: DefaultMessageComposerPreviewComponents.VoiceRecording,\n    isVisible: ({ attachments }) => attachments.some(isLocalVoiceRecordingAttachment),\n    type: 'voiceRecording',\n  },\n  {\n    Component: DefaultMessageComposerPreviewComponents.Attachments,\n    // Voice recordings render in the `voiceRecording` preview instead.\n    isVisible: ({ attachments }) =>\n      attachments.some((attachment) => !isVoiceRecordingAttachment(attachment)),\n    type: 'attachments',\n  },\n  {\n    Component: DefaultMessageComposerPreviewComponents.LinkPreviews,\n    isVisible: ({ linkPreviews }) => linkPreviews.length > 0,\n    type: 'linkPreviews',\n  },\n  {\n    Component: DefaultMessageComposerPreviewComponents.Location,\n    isVisible: ({ location }) => !!location,\n    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