import 'package:freezed_annotation/freezed_annotation.dart';
import '../../domain/entities/message.dart';

part 'chat_event.freezed.dart';

@freezed
class ChatEvent with _$ChatEvent {
  const factory ChatEvent.started({String? userId}) = ChatEventStarted;
  const factory ChatEvent.chatsLoaded({String? currentUserId}) = ChatEventChatsLoaded;
  const factory ChatEvent.chatSelected(String chatId) = ChatEventChatSelected;
  const factory ChatEvent.messagesRequested(String chatId, {String? cursor}) = ChatEventMessagesRequested;
  const factory ChatEvent.messageReceived(Message message) = ChatEventMessageReceived;
  const factory ChatEvent.messageSent(String chatId, String content) = ChatEventMessageSent;
  const factory ChatEvent.favoritesRequested() = ChatEventFavoritesRequested;
  const factory ChatEvent.typingUpdated(String chatId, String userId, bool isTyping) = ChatEventTypingUpdated;
  const factory ChatEvent.userStatusChanged(String userId, bool isOnline, {DateTime? lastSeen}) = ChatEventUserStatusChanged;
  const factory ChatEvent.refreshPresence() = ChatEventRefreshPresence;
  const factory ChatEvent.sendTypingStatus(String chatId, bool isTyping) = ChatEventSendTypingStatus;
  const factory ChatEvent.markAsRead(String chatId, String messageId, int sequenceId) = ChatEventMarkAsRead;
  const factory ChatEvent.readReceiptReceived({
    required String chatId,
    required String userId,
    required String lastReadMessageId,
    required int lastReadSequenceId,
  }) = ChatEventReadReceiptReceived;
  const factory ChatEvent.messageStatusUpdated(String messageId, MessageStatus status) = ChatEventMessageStatusUpdated;
  const factory ChatEvent.messageReplaced(String tempId, Message realMessage) = ChatEventMessageReplaced;
  const factory ChatEvent.cacheCleared() = ChatEventCacheCleared;
}
