export interface MessageAttachment {
  file_name: string;
  file_type: string; // 'image', 'audio', 'video', 'file'
  file_url: string;
  file_size?: number;
}

export interface OutgoingMessage {
  type:
    | 'SendMessage'
    | 'JoinConversation'
    | 'LeaveConversation'
    | 'MarkAsRead'
    | 'Typing'
    | 'AddReaction'
    | 'RemoveReaction'
    | 'Ping';
  conversation_id?: string;
  content?: string;
  parent_message_id?: string | null;
  message_id?: string;
  is_typing?: boolean;
  emoji?: string;
  attachments?: MessageAttachment[];
}

export interface IncomingMessage {
  type:
    | 'NewMessage'
    | 'ActionConfirmed'
    | 'Error'
    | 'Pong'
    | 'UserTyping'
    | 'ReactionAdded'
    | 'ReactionRemoved'
    | 'MessageRead'
    | 'MessageDelivered'
    | 'HistoryChunk';
  conversation_id: string;
  message_id?: string;
  sender_id?: string;
  user_id?: string;
  sender_username?: string;
  content?: string;
  created_at?: string;
  action?: string;
  success?: boolean;
  message?: string;
  is_typing?: boolean;
  emoji?: string;
  attachments?: MessageAttachment[];
  messages?: HistoryMessage[]; // For HistoryChunk
  has_more_before?: boolean;
  has_more_after?: boolean;
}

export interface HistoryMessage {
  id: string;
  conversation_id: string;
  sender_id: string;
  sender_username: string;
  content: string;
  created_at: string;
  reactions?: Record<string, string[]>;
  attachments?: MessageAttachment[];
}
