import { MESSAGE_CUSTOM_TYPE } from '@linktr.ee/messaging-taxonomy' import { GiftIcon } from '@phosphor-icons/react' import { LocalMessage } from 'stream-chat' interface MessageTagProps { message: LocalMessage /** When true, renders sender-side chatbot variants */ isMyMessage?: boolean /** Whether the message includes an attachment */ hasAttachment?: boolean } const SparkleIcon = ({ size = 15 }: { size?: number }) => ( ) /** Check if a message is a paid message based on metadata */ const isPaidMessage = (message: LocalMessage): boolean => { return message.metadata?.custom_type === MESSAGE_CUSTOM_TYPE.PAID } /** Check if a message is a chatbot message based on metadata */ export const isChatbotMessage = (message: LocalMessage): boolean => { return message.metadata?.custom_type === MESSAGE_CUSTOM_TYPE.CHATBOT } /** Check if a message is a locked attachment */ export const isAttachmentMessage = (message: LocalMessage): boolean => { return message.metadata?.custom_type === MESSAGE_CUSTOM_TYPE.ATTACHMENT } export const isTextAttachmentMessage = (message: LocalMessage): boolean => { return ( isAttachmentMessage(message) && message.metadata?.attachment_content_type === 'text' ) } export const isMediaAttachmentMessage = (message: LocalMessage): boolean => { return ( isAttachmentMessage(message) && message.metadata?.attachment_content_type !== 'text' ) } /** Check if the footer tag on this message already reads "Delivered with …" */ export const hasPaidDeliveryTag = (message: LocalMessage): boolean => { return isPaidMessage(message) && !!message.metadata?.amount_text } export const MessageTag = ({ message, isMyMessage = false, hasAttachment = false, }: MessageTagProps) => { const isPaid = isPaidMessage(message) const isChatbot = isChatbotMessage(message) if (!isPaid && !isChatbot) { return null } if (isPaid) { const amountText = message.metadata?.amount_text if (!amountText) return null return (