import { _ as __assign } from '../../chunks/bundle-B9I7KCZ2.js';
import React__default from 'react';
import { useIIFE } from '@sendbird/uikit-tools';
import { useSendbirdStateContext } from '../../useSendbirdStateContext.js';
import { k as isSendableMessage, g as getSuggestedReplies } from '../../chunks/bundle-BGoByD2z.js';
import { i as isDisabledBecauseFrozen, a as isDisabledBecauseMuted } from '../../chunks/bundle-CGLnBajI.js';
import { useGroupChannelContext } from '../context.js';
import { M as MessageView } from '../../chunks/bundle-B2UBtdMc.js';
import { FileViewer } from './FileViewer.js';
import { RemoveMessageModal } from './RemoveMessageModal.js';
import { T as ThreadReplySelectType } from '../../chunks/bundle-De1BnkR0.js';
import '../../withSendbird.js';
import '@sendbird/chat/groupChannel';
import '../../utils/message/getOutgoingMessageState.js';
import '../../chunks/bundle-ByuZy4m8.js';
import '../../chunks/bundle-DnVyKahm.js';
import '@sendbird/chat/message';
import '../../chunks/bundle-DUd6AS_D.js';
import '../../chunks/bundle-DayOnVaB.js';
import '../../chunks/bundle-2aNchqYM.js';
import '../../chunks/bundle-D4NnyBWz.js';
import '../../chunks/bundle-D6I-uHp_.js';
import '../../chunks/bundle-Mfnn12A9.js';
import '../../chunks/bundle-Cpt2mEbq.js';
import '../../chunks/bundle-Cme8jJ5D.js';
import '../../chunks/bundle-CMgJTzYH.js';
import '../../chunks/bundle-BPLoGpIy.js';
import '../../chunks/bundle-BwafidOs.js';
import '../../Message/hooks/useDirtyGetMentions.js';
import '../../ui/DateSeparator.js';
import '../../chunks/bundle-DDIIh2iG.js';
import '../../chunks/bundle-B1gHpFXu.js';
import '../../ui/MessageInput.js';
import '../../chunks/bundle-DqJ40nCa.js';
import '../../ui/IconButton.js';
import '../../ui/Button.js';
import '../../chunks/bundle-D3w6q-9W.js';
import 'dompurify';
import '../../chunks/bundle-BT8XMu5e.js';
import '../../chunks/bundle-CpcTBaG-.js';
import '../../chunks/bundle-BQqQX3na.js';
import '../../ui/Icon.js';
import '../../chunks/bundle-B628FXKZ.js';
import '../../chunks/bundle-bbk4ulub.js';
import '../../ui/MessageContent.js';
import '../../chunks/bundle-CQdKG76t.js';
import '../../ui/Loader.js';
import '../../chunks/bundle-K3w8yQDQ.js';
import '../../chunks/bundle-B3xAJZu1.js';
import '../../chunks/bundle-1icRt_y4.js';
import '../../chunks/bundle-BfonFE4n.js';
import 'react-dom';
import '@sendbird/chat';
import '@sendbird/chat/openChannel';
import '../../ui/SortByRow.js';
import '../../chunks/bundle-B97onQ-B.js';
import '../../ui/MessageItemReactionMenu.js';
import '../../ui/ImageRenderer.js';
import '../../ui/ReactionButton.js';
import '../../chunks/bundle-C6OwelAY.js';
import '../../chunks/bundle-BydEbpDQ.js';
import '../../ui/EmojiReactions.js';
import '../../ui/ReactionBadge.js';
import '../../ui/BottomSheet.js';
import '../../chunks/bundle-DAF0GGlr.js';
import 'css-vars-ponyfill';
import '../../chunks/bundle-jVDgtxRn.js';
import '../../ui/UserListItem.js';
import '../../chunks/bundle-D89r5O-w.js';
import '../../chunks/bundle-DVCGbhaI.js';
import '../../ui/MutedAvatarOverlay.js';
import '../../ui/Checkbox.js';
import '../../ui/UserProfile.js';
import '../../sendbirdSelectors.js';
import '../../ui/Tooltip.js';
import '../../ui/TooltipWrapper.js';
import '../../Message/context.js';
import '../../ui/AdminMessage.js';
import '../../ui/QuoteMessage.js';
import '../../chunks/bundle-CO34LgiE.js';
import '../../ui/MobileMenu.js';
import '../../ui/ThreadReplies.js';
import '../../ui/OGMessageItemBody.js';
import '../../chunks/bundle-C8uZHDqp.js';
import '../../ui/MentionLabel.js';
import '../../ui/LinkLabel.js';
import '../../ui/TextMessageItemBody.js';
import '../../ui/FileMessageItemBody.js';
import '../../ui/TextButton.js';
import '../../chunks/bundle-DeqlERYT.js';
import '../../ui/FileViewer.js';
import '../../chunks/bundle-l8sVpQGm.js';
import '../../ui/VoiceMessageItemBody.js';
import '../../ui/ProgressBar.js';
import '../../VoicePlayer/useVoicePlayer.js';
import '../../ui/PlaybackTime.js';
import '../../ui/ThumbnailMessageItemBody.js';
import '../../ui/UnknownMessageItemBody.js';
import '../../ui/TemplateMessageItemBody.js';
import '../../chunks/bundle-CsdXzHvl.js';
import '../../ui/FallbackTemplateMessageItemBody.tsx.js';
import '../../ui/LoadingTemplateMessageItemBody.tsx.js';
import '../../ui/FeedbackIconButton.js';
import '../../ui/MobileFeedbackMenu.js';
import '../../ui/MessageFeedbackModal.js';
import '../../ui/Input.js';
import '../../ui/MessageFeedbackFailedModal.js';
import './SuggestedReplies.js';
import '../../chunks/bundle-Dv9mmt4u.js';
import '../../chunks/bundle-Bsa2gylF.js';
import '../../chunks/bundle-D9OMPv_x.js';
import '../../chunks/bundle-BiG6myo3.js';

var Message = function (props) {
    var _a = useSendbirdStateContext(), config = _a.config, emojiManager = _a.emojiManager;
    var _b = useGroupChannelContext(), loading = _b.loading, currentChannel = _b.currentChannel, animatedMessageId = _b.animatedMessageId, setAnimatedMessageId = _b.setAnimatedMessageId, scrollToMessage = _b.scrollToMessage, replyType = _b.replyType, threadReplySelectType = _b.threadReplySelectType, isReactionEnabled = _b.isReactionEnabled, toggleReaction = _b.toggleReaction, nicknamesMap = _b.nicknamesMap, setQuoteMessage = _b.setQuoteMessage, renderUserMentionItem = _b.renderUserMentionItem, onQuoteMessageClick = _b.onQuoteMessageClick, onReplyInThreadClick = _b.onReplyInThreadClick, onMessageAnimated = _b.onMessageAnimated, onBeforeDownloadFileMessage = _b.onBeforeDownloadFileMessage, messages = _b.messages, updateUserMessage = _b.updateUserMessage, sendUserMessage = _b.sendUserMessage, resendMessage = _b.resendMessage, deleteMessage = _b.deleteMessage;
    var message = props.message;
    var initialized = !loading && Boolean(currentChannel);
    var shouldRenderSuggestedReplies = useIIFE(function () {
        var _a;
        var _b = config.groupChannel, enableSuggestedReplies = _b.enableSuggestedReplies, showSuggestedRepliesFor = _b.showSuggestedRepliesFor;
        var lastMessageInView = messages[messages.length - 1];
        var hasUnsentMessage = isSendableMessage(lastMessageInView) && lastMessageInView.sendingStatus !== 'succeeded';
        var showSuggestedReplies = showSuggestedRepliesFor === 'all_messages' ? true : message.messageId === ((_a = currentChannel === null || currentChannel === void 0 ? void 0 : currentChannel.lastMessage) === null || _a === void 0 ? void 0 : _a.messageId);
        return enableSuggestedReplies && getSuggestedReplies(message).length > 0 && !hasUnsentMessage && showSuggestedReplies;
    });
    return (React__default.createElement(MessageView, __assign({}, props, { channel: currentChannel, emojiContainer: 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, scrollToMessage: scrollToMessage, toggleReaction: toggleReaction, setQuoteMessage: setQuoteMessage, onQuoteMessageClick: onQuoteMessageClick, onReplyInThreadClick: onReplyInThreadClick, sendUserMessage: sendUserMessage, updateUserMessage: updateUserMessage, resendMessage: resendMessage, deleteMessage: deleteMessage, 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
