import type { Reaction } from './message.models';

export type DirectMessageStatus = 'QUEUED' | 'SENT' | 'DELIVERED' | 'ACKNOWLEDGED';
export type DirectMessageMutationType = 'edit' | 'delete' | 'reaction-add' | 'reaction-remove';

export interface DirectMessageParticipant {
  userId: string;
  username: string;
  displayName: string;
  description?: string;
  avatarUrl?: string;
  avatarHash?: string;
  avatarMime?: string;
  avatarUpdatedAt?: number;
  profileUpdatedAt?: number;
}

export interface DirectMessage {
  id: string;
  conversationId: string;
  senderId: string;
  recipientId: string;
  recipientIds?: string[];
  content: string;
  timestamp: number;
  status: DirectMessageStatus;
  editedAt?: number;
  isDeleted?: boolean;
  reactions?: Reaction[];
  replyToId?: string;
}

export interface DirectMessageEventPayload {
  message: DirectMessage;
  sender: DirectMessageParticipant;
  participants?: DirectMessageParticipant[];
  conversationKind?: 'direct' | 'group';
  conversationTitle?: string;
}

export interface DirectMessageStatusEventPayload {
  conversationId: string;
  messageId: string;
  status: DirectMessageStatus;
  updatedAt: number;
}

export interface DirectMessageMutationEventPayload {
  conversationId: string;
  messageId: string;
  type: DirectMessageMutationType;
  content?: string;
  editedAt?: number;
  reaction?: Reaction;
  oderId?: string;
  emoji?: string;
  updatedAt: number;
}

export interface DirectMessageTypingEventPayload {
  conversationId: string;
  sender: DirectMessageParticipant;
  isTyping: boolean;
  updatedAt: number;
}

export interface DirectMessageSyncRequestEventPayload {
  conversationId: string;
  sender: DirectMessageParticipant;
  requestedAt: number;
}

export interface DirectMessageSyncEventPayload {
  conversationId: string;
  sender: DirectMessageParticipant;
  participants: DirectMessageParticipant[];
  conversationKind?: 'direct' | 'group';
  conversationTitle?: string;
  messages: DirectMessage[];
  syncedAt: number;
}
