import { _ as __assign } from '../../chunks/bundle-yl5d1NoZ.js';
import React__default from 'react';
import { useIIFE } from '@sendbird/uikit-tools';
import { m as isSendableMessage, g as getSuggestedReplies } from '../../chunks/bundle-vmZ9LoYK.js';
import { i as isDisabledBecauseFrozen, a as isDisabledBecauseMuted } from '../../chunks/bundle-CzwYTfhQ.js';
import { M as MessageView } from '../../chunks/bundle-CRpOTB7B.js';
import { FileViewer } from './FileViewer.js';
import { RemoveMessageModal } from './RemoveMessageModal.js';
import { T as ThreadReplySelectType } from '../../chunks/bundle-BEx1sWnS.js';
import { u as useGroupChannel } from '../../chunks/bundle-CmmJVpwV.js';
import { u as useSendbird } from '../../chunks/bundle-i_3w58Zd.js';
import '@sendbird/chat/groupChannel';
import '../../utils/message/getOutgoingMessageState.js';
import '../../chunks/bundle-DgosLQK9.js';
import '../../chunks/bundle-DEuCwnTn.js';
import '../../chunks/bundle-fdEQfX2s.js';
import '../../chunks/bundle-CqLLOVG5.js';
import '../../chunks/bundle-mGsud0ec.js';
import '../../chunks/bundle-BZGITC2g.js';
import '../../chunks/bundle-Del33VzI.js';
import '../../chunks/bundle-C1dqPUnT.js';
import '../../Message/hooks/useDirtyGetMentions.js';
import '../../ui/DateSeparator.js';
import '../../chunks/bundle-Bokm7tQ9.js';
import '../../chunks/bundle-viBng0Kh.js';
import '../../ui/MessageInput.js';
import '../../chunks/bundle-BNtO7aXk.js';
import '../../ui/IconButton.js';
import '../../ui/Button.js';
import '../../chunks/bundle-CN_mZmg1.js';
import 'dompurify';
import '../../chunks/bundle-D6b2YGeE.js';
import '../../chunks/bundle-B6udMinl.js';
import '../../chunks/bundle-Cc1gzgza.js';
import '../../ui/Icon.js';
import '../../chunks/bundle-MlG9piGf.js';
import '../../chunks/bundle-BwvurfUT.js';
import '../../ui/MessageContent.js';
import '../../chunks/bundle-2U8QpYXo.js';
import '../../ui/Loader.js';
import '../../chunks/bundle-BhhLSKSz.js';
import '../../chunks/bundle-Cl9rtdlj.js';
import '../../chunks/bundle-CQ_-cyp9.js';
import '../../chunks/bundle-Bch_Ry4S.js';
import 'react-dom';
import '@sendbird/chat';
import '@sendbird/chat/openChannel';
import '../../ui/SortByRow.js';
import '../../chunks/bundle-DGh2T5IL.js';
import '../../chunks/bundle-BUYU9H94.js';
import '../../ui/MessageItemReactionMenu.js';
import '../../ui/ImageRenderer.js';
import '../../ui/ReactionButton.js';
import '../../chunks/bundle-Ba_cV-Zm.js';
import '../../chunks/bundle-DBhJIxHw.js';
import '../../ui/EmojiReactions.js';
import '../../ui/ReactionBadge.js';
import '../../ui/BottomSheet.js';
import '../../hooks/useModal.js';
import '../../chunks/bundle-CtQtfJlT.js';
import '../../ui/UserListItem.js';
import '../../chunks/bundle-B0s_McF0.js';
import '../../chunks/bundle-CAEBoiEz.js';
import '../../chunks/bundle-Dl_v8XoN.js';
import '../../ui/MutedAvatarOverlay.js';
import '../../ui/Checkbox.js';
import '../../ui/UserProfile.js';
import '../../sendbirdSelectors.js';
import '../../chunks/bundle-BOykFtQ3.js';
import '../../ui/Tooltip.js';
import '../../ui/TooltipWrapper.js';
import '../../Message/context.js';
import '../../chunks/bundle-BSy5MmTl.js';
import '../../ui/AdminMessage.js';
import '../../ui/QuoteMessage.js';
import '../../chunks/bundle-h6bAY7E9.js';
import '@sendbird/chat/message';
import '../../ui/MobileMenu.js';
import '../../ui/ThreadReplies.js';
import '../../chunks/bundle-BdQWhaHB.js';
import '../../ui/OGMessageItemBody.js';
import '../../chunks/bundle-DcLgcUpC.js';
import '../../ui/MentionLabel.js';
import '../../ui/LinkLabel.js';
import '../../ui/TextMessageItemBody.js';
import '../../ui/FileMessageItemBody.js';
import '../../ui/TextButton.js';
import '../../chunks/bundle-HwtLrcpn.js';
import '../../ui/FileViewer.js';
import '../../chunks/bundle-Ha1krmtK.js';
import '../../ui/VoiceMessageItemBody.js';
import '../../ui/ProgressBar.js';
import '../../VoicePlayer/useVoicePlayer.js';
import '../../chunks/bundle-BrBLR_c-.js';
import '../../VoiceRecorder/context.js';
import '../../ui/PlaybackTime.js';
import '../../ui/ThumbnailMessageItemBody.js';
import '../../ui/UnknownMessageItemBody.js';
import '../../ui/TemplateMessageItemBody.js';
import '../../chunks/bundle-BJYztm64.js';
import '../../ui/FallbackTemplateMessageItemBody.tsx.js';
import '../../ui/LoadingTemplateMessageItemBody.tsx.js';
import '../../ui/MessageFeedbackFailedModal.js';
import '../../ui/FeedbackIconButton.js';
import '../../ui/MobileFeedbackMenu.js';
import '../../ui/MessageFeedbackModal.js';
import '../../ui/Input.js';
import '../../chunks/bundle-C8U5aHBw.js';
import './SuggestedReplies.js';
import '../../chunks/bundle-sf0POh6_.js';
import '../../chunks/bundle-c7SN5XJA.js';
import '../../chunks/bundle-So54Aj7k.js';
import '../../chunks/bundle-BxzlMlCv.js';
import '../../chunks/bundle-D1nuDKhb.js';
import '../../chunks/bundle-DK3-aB7E.js';
import '../../chunks/bundle-BmoSvBYM.js';

var Message = function (props) {
    var state = useSendbird().state;
    var config = state.config, emojiManager = state.emojiManager;
    var _a = useGroupChannel(), _b = _a.state, loading = _b.loading, currentChannel = _b.currentChannel, animatedMessageId = _b.animatedMessageId, replyType = _b.replyType, threadReplySelectType = _b.threadReplySelectType, isReactionEnabled = _b.isReactionEnabled, nicknamesMap = _b.nicknamesMap, renderUserMentionItem = _b.renderUserMentionItem, filterEmojiCategoryIds = _b.filterEmojiCategoryIds, onQuoteMessageClick = _b.onQuoteMessageClick, onReplyInThreadClick = _b.onReplyInThreadClick, onMessageAnimated = _b.onMessageAnimated, onBeforeDownloadFileMessage = _b.onBeforeDownloadFileMessage, messages = _b.messages, markAsUnread = _b.markAsUnread, _c = _a.actions, toggleReaction = _c.toggleReaction, setQuoteMessage = _c.setQuoteMessage, setAnimatedMessageId = _c.setAnimatedMessageId, scrollToMessage = _c.scrollToMessage, updateUserMessage = _c.updateUserMessage, sendUserMessage = _c.sendUserMessage, resendMessage = _c.resendMessage, deleteMessage = _c.deleteMessage;
    var message = props.message;
    var initialized = !loading && Boolean(currentChannel);
    var shouldRenderSuggestedReplies = useIIFE(function () {
        var _a = config.groupChannel, enableSuggestedReplies = _a.enableSuggestedReplies, showSuggestedRepliesFor = _a.showSuggestedRepliesFor;
        // Use `allMessages[allMessages.length - 1]` instead of `currentGroupChannel.lastMessage`
        // because lastMessage is not updated when **Bot** sends messages
        var lastMessageInView = messages[messages.length - 1];
        var hasUnsentMessage = isSendableMessage(lastMessageInView) && (lastMessageInView === null || lastMessageInView === void 0 ? void 0 : lastMessageInView.sendingStatus) !== 'succeeded';
        var showSuggestedReplies = showSuggestedRepliesFor === 'all_messages'
            ? true
            : message.messageId === (lastMessageInView === null || lastMessageInView === void 0 ? void 0 : lastMessageInView.messageId);
        return enableSuggestedReplies && getSuggestedReplies(message).length > 0 && !hasUnsentMessage && showSuggestedReplies;
    });
    return (React__default.createElement(MessageView, __assign({}, props, { channel: currentChannel, emojiContainer: emojiManager === null || emojiManager === void 0 ? void 0 : emojiManager.emojiContainer, editInputDisabled: !initialized
            || isDisabledBecauseFrozen(currentChannel !== null && currentChannel !== void 0 ? currentChannel : undefined)
            || isDisabledBecauseMuted(currentChannel !== null && currentChannel !== void 0 ? currentChannel : undefined)
            || !config.isOnline, shouldRenderSuggestedReplies: shouldRenderSuggestedReplies, isReactionEnabled: isReactionEnabled !== null && isReactionEnabled !== void 0 ? isReactionEnabled : false, replyType: replyType !== null && replyType !== void 0 ? replyType : 'NONE', threadReplySelectType: threadReplySelectType !== null && threadReplySelectType !== void 0 ? threadReplySelectType : ThreadReplySelectType.PARENT, nicknamesMap: nicknamesMap, renderUserMentionItem: renderUserMentionItem, filterEmojiCategoryIds: filterEmojiCategoryIds, scrollToMessage: scrollToMessage, toggleReaction: toggleReaction, setQuoteMessage: setQuoteMessage, onQuoteMessageClick: onQuoteMessageClick, onReplyInThreadClick: onReplyInThreadClick, sendUserMessage: sendUserMessage, updateUserMessage: updateUserMessage, resendMessage: resendMessage, deleteMessage: deleteMessage, markAsUnread: markAsUnread, animatedMessageId: animatedMessageId, setAnimatedMessageId: setAnimatedMessageId, onMessageAnimated: onMessageAnimated, renderFileViewer: function (props) { return React__default.createElement(FileViewer, __assign({}, props)); }, renderRemoveMessageModal: function (props) { return React__default.createElement(RemoveMessageModal, __assign({}, props)); }, usedInLegacy: false, onBeforeDownloadFileMessage: onBeforeDownloadFileMessage })));
};

export { Message, Message as default };
//# sourceMappingURL=Message.js.map
