import type { ReactNode } from 'react';
import { bubbleRadius } from './collabModel';
/**
* The pieces a message of the trip chat is drawn with, shared by the Collab
* tab and the assistant chat's cards so a message looks the same in both:
* the bubble with its tail and the quote it answers, the face beside it, the
* name over a group, the day between groups, the floating reactions and the
* time under the last message. Each piece only draws; what it does on a
* click or a hover stays with the caller.
*/
/** A face beside the last message of a group: the picture, else the first letter. */
export function ChatAvatar({ name, src, size = 28 }: { name: string; src: string | null; size?: number }) {
if (src) {
return
;
}
return (
{(name || '?').charAt(0).toUpperCase()}
);
}
/** "Today", "Yesterday" or a date between two groups of messages. */
export function ChatDateSeparator({ label }: { label: string }) {
return (
{label}
);
}
/** The name over the first message of someone else's group. */
export function ChatSenderName({ children }: { children: ReactNode }) {
return (
{children}
);
}
/** One to three emoji alone, drawn large without a bubble. */
export function ChatBigEmoji({ children }: { children: ReactNode }) {
return (
{children}
);
}
/**
* The bubble: the user's own in the accent with its tail on their side, the
* others as cards on the tinted panel; the tail only on the last message of
* a group. A reply carries the quote of the message it answers on top.
*/
export function ChatBubble({
own,
lastInGroup,
reply,
text,
children,
}: {
own: boolean;
lastInGroup: boolean;
reply: { name: string; text: string } | null;
/** The message's words. */
text: ReactNode;
/** What comes under the words: images, a link preview. */
children?: ReactNode;
}) {
return (
{reply && (
{reply.name}
{/* Wrapped and cut after two lines: a quote kept on one line set the bubble's width and pushed it out of the chat. */}
{reply.text}
)}
{reply ?
{text}
: text}
{children}
);
}
/** The reactions floating under a bubble, on its side, in one pill. */
export function ChatReactions({ own, children }: { own: boolean; children: ReactNode }) {
return (
);
}
/** The time under the last message of a group, or what stands in its place. */
export function ChatTime({ children }: { children: ReactNode }) {
return (
{children}
);
}