export enum MessageType {
  TEXT = 'TEXT',
  FILE = 'FILE',
  IMAGE = 'IMAGE',
  SYSTEM = 'SYSTEM',
}

export enum MessageStatus {
  SENT = 'SENT',
  DELIVERED = 'DELIVERED',
  READ = 'READ',
}

export interface OtherParty {
  id: string;
  userId?: string;
  name: string;
  avatar?: string | null;
  headline?: string;
  isOnline: boolean;
  lastSeenAt?: string | null;
}

export interface Conversation {
  id: string;
  userId: string;
  agentProfileId: string;
  lastMessageAt: string | null;
  lastMessageText: string | null;
  userUnreadCount: number;
  agentUnreadCount: number;
  unreadCount: number;
  userMuted: boolean;
  agentMuted: boolean;
  userFavorited: boolean;
  agentFavorited: boolean;
  createdAt: string;
  updatedAt: string;
  otherParty: OtherParty;
  messages?: Message[];
}

export interface MessageSender {
  id: string;
  role: string;
  userProfile?: {
    firstName: string | null;
    lastName: string | null;
    avatar: string | null;
  };
  agentProfile?: {
    firstName: string | null;
    lastName: string | null;
    avatar: string | null;
  };
}

export interface Message {
  id: string;
  conversationId: string;
  senderId: string;
  content: string;
  messageType: MessageType;
  fileUrl?: string | null;
  fileName?: string | null;
  fileSize?: number | null;
  mimeType?: string | null;
  status: MessageStatus;
  deliveredAt?: string | null;
  readAt?: string | null;
  createdAt: string;
  updatedAt: string;
  sender: MessageSender;
}

export interface CreateMessageDto {
  content: string;
  messageType?: MessageType;
  fileUrl?: string;
  fileName?: string;
  fileSize?: number;
  mimeType?: string;
}

export interface TypingIndicator {
  userId: string;
  conversationId: string;
}

export interface UserStatusChange {
  userId: string;
  isOnline: boolean;
  lastSeenAt?: string | null;
}

export interface MessagesReadEvent {
  conversationId: string;
  readBy: string;
  readAt: string;
}

export interface MessageDeliveredEvent {
  messageId?: string;
  messageIds?: string[];
  conversationId: string;
  deliveredAt: string;
}

export interface PaginationInfo {
  page: number;
  limit: number;
  total: number;
  pages: number;
}

export interface MessagesResponse {
  messages: Message[];
  pagination: PaginationInfo;
}
