/**
 * 气泡统一入场动效 — ChatMessage / ChatBubble / IM 等主动挂载的新气泡共用。
 *
 * 时长：`--motion-enter-bubble`
 * 曲线：`@keyframes tfds-message-bubble-pop`
 * 方向（非独立 token，由修饰类 + 局部 CSS 变量控制）：
 *   - 发出/己方右侧：`tfds-message-bubble-pop--outgoing`（自右飞入，transform-origin: right）
 *   - 收到/对方左侧：`tfds-message-bubble-pop--incoming`（自左飞入，transform-origin: left）
 */

export const MOTION_ENTER_BUBBLE_VAR = '--motion-enter-bubble';
export const MESSAGE_BUBBLE_POP_KEYFRAME = 'tfds-message-bubble-pop';
export const MESSAGE_BUBBLE_POP_CLASS = 'tfds-message-bubble-pop';
export const MESSAGE_BUBBLE_POP_OUTGOING_MODIFIER = 'tfds-message-bubble-pop--outgoing';
export const MESSAGE_BUBBLE_POP_INCOMING_MODIFIER = 'tfds-message-bubble-pop--incoming';

/** @param {'incoming'|'outgoing'|'ai'|'user'} role */
export function messageBubbleEnterClass(role = 'outgoing') {
  const incoming = role === 'incoming' || role === 'ai';
  return incoming
    ? `${MESSAGE_BUBBLE_POP_CLASS} ${MESSAGE_BUBBLE_POP_INCOMING_MODIFIER}`
    : `${MESSAGE_BUBBLE_POP_CLASS} ${MESSAGE_BUBBLE_POP_OUTGOING_MODIFIER}`;
}

/** ChatConversation / Copilot 消息 kind */
export function messageBubbleEnterClassFromChatKind(kind) {
  return messageBubbleEnterClass(kind === 'user' ? 'outgoing' : 'incoming');
}
