// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import React from 'react';
import { ChatMessageContent } from '../ChatMessage/ChatMessageContent';
import { _AttachmentDownloadCards } from '../Attachment/AttachmentDownloadCards';
import { formatTimeForChatMessage, formatTimestampForChatMessage } from './Datetime';
import { chatMessageEditedTagStyle } from '../styles/ChatMessageComponent.styles';
/** @private
 * Return the string value for the FluentUI message attached prop based on the message's attached status.
 * @param attached - The message's attached status.
 */
export const getFluentUIAttachedValue = (messageAttachedStatus) => {
    return messageAttachedStatus === 'top' || messageAttachedStatus === false ? 'top' : 'center';
};
/**
 * @private
 *  Get the message bubble content for the message.
 */
export function getMessageBubbleContent(message, strings, userId, inlineImageOptions, 
/**
 * Optional callback to render message attachments in the message component.
 */
onRenderAttachmentDownloads, 
/**
 * Optional callback to define custom actions for attachments.
 */
actionsForAttachment) {
    return React.createElement("div", { className: "ui-chat__message__content" },
        React.createElement(ChatMessageContent, { message: message, strings: strings, inlineImageOptions: inlineImageOptions }),
        onRenderAttachmentDownloads ? onRenderAttachmentDownloads(message) : defaultOnRenderAttachmentDownloads(message, strings, actionsForAttachment));
}
/**
 * Default component for rendering attachment downloads.
 */
const defaultOnRenderAttachmentDownloads = (message, strings, actionsForAttachment) => {
    var _a;
    const attachments = 'attachments' in message ? message.attachments : undefined;
    return ((_a = attachments === null || attachments === void 0 ? void 0 : attachments.length) !== null && _a !== void 0 ? _a : 0) > 0 ? React.createElement(_AttachmentDownloadCards, { message: message, attachments: attachments, actionsForAttachment: actionsForAttachment, strings: {
            openAttachment: strings.openAttachment,
            attachmentCardGroupMessage: strings.attachmentCardGroupMessage
        } }) : React.createElement(React.Fragment, null);
};
/** @private */
export const generateDefaultTimestamp = (createdOn, showDate, strings) => {
    const formattedTimestamp = showDate ? formatTimestampForChatMessage(createdOn, new Date(), strings) : formatTimeForChatMessage(createdOn);
    return formattedTimestamp;
};
// onDisplayDateTimeString from props overwrite onDisplayDateTimeString from locale
/** @private */
export const generateCustomizedTimestamp = (createdOn, locale, onDisplayDateTimeString) => {
    return '';
};
/**
 * @private
 *  Get the edited tag for the message if it is edited.
 */
export const getMessageEditedDetails = (message, theme, editedTag) => {
    const editedOn = 'editedOn' in message ? message.editedOn : undefined;
    if (message.messageType === 'chat' && editedOn) {
        return React.createElement("div", { className: chatMessageEditedTagStyle(theme) }, editedTag);
    }
    return undefined;
};
/**
 * Removes Fluent UI keyboard navigation styles from the given HTMLDivElement.
 *
 * This function removes the 'tabindex' and 'data-tabster' attributes from the provided
 * HTMLDivElement, making it non-focusable and removing any associated keyboard navigation styles.
 *
 * @param node - The HTMLDivElement from which to remove the keyboard navigation styles. If null, the function does nothing.
 */
export const removeFluentUIKeyboardNavigationStyles = (node) => {
    if (node) {
        // Remove tabindex to make the div element non-focusable
        node.removeAttribute('tabindex');
        node.removeAttribute('data-tabster');
    }
};
//# sourceMappingURL=ChatMessageComponentUtils.js.map