'use strict';

var index = require('../../chunks/bundle-B9BY1g5d.js');
var Channel_utils_compareMessagesForGrouping = require('./compareMessagesForGrouping.js');
require('../../chunks/bundle-C1G0SKDq.js');
require('../../chunks/bundle-FJtjwZwh.js');
require('../../chunks/bundle-BV7y6VDn.js');
require('../../chunks/bundle-D7YiKR6i.js');
require('../../chunks/bundle-CxoFSSXv.js');
require('@sendbird/chat/groupChannel');
require('../../utils/message/getOutgoingMessageState.js');
require('../../chunks/bundle-dfqZUdij.js');
require('../../chunks/bundle-Dn0hi6OJ.js');
require('../../chunks/bundle-yU9Mr2pS.js');

/**
 * exported, should be backward compatible
 */
var getMessagePartsInfo = function (_a) {
    var allMessages = _a.allMessages, stringSet = _a.stringSet, _b = _a.isMessageGroupingEnabled, isMessageGroupingEnabled = _b === void 0 ? true : _b, _c = _a.currentIndex, currentIndex = _c === void 0 ? 0 : _c, currentMessage = _a.currentMessage, _d = _a.currentChannel, currentChannel = _d === void 0 ? null : _d, _e = _a.replyType, replyType = _e === void 0 ? '' : _e;
    var previousMessage = allMessages[currentIndex - 1];
    var nextMessage = allMessages[currentIndex + 1];
    var _f = isMessageGroupingEnabled
        ? Channel_utils_compareMessagesForGrouping.compareMessagesForGrouping(previousMessage, currentMessage, nextMessage, stringSet, currentChannel, replyType)
        : [false, false], chainTop = _f[0], chainBottom = _f[1];
    var previousMessageCreatedAt = previousMessage === null || previousMessage === void 0 ? void 0 : previousMessage.createdAt;
    var currentCreatedAt = currentMessage.createdAt;
    // NOTE: for pending/failed messages
    var isLocalMessage = 'sendingStatus' in currentMessage && (currentMessage.sendingStatus !== 'succeeded');
    // https://stackoverflow.com/a/41855608
    var hasSeparator = isLocalMessage ? false : !(previousMessageCreatedAt && (index.isSameDay(currentCreatedAt, previousMessageCreatedAt)));
    return {
        chainTop: chainTop,
        chainBottom: chainBottom,
        hasSeparator: hasSeparator,
    };
};

exports.getMessagePartsInfo = getMessagePartsInfo;
//# sourceMappingURL=getMessagePartsInfo.js.map
