/// États du BLoC Messaging
library messaging_state;

import 'package:equatable/equatable.dart';
import '../../domain/entities/conversation.dart';
import '../../domain/entities/message.dart';

abstract class MessagingState extends Equatable {
  const MessagingState();

  @override
  List<Object?> get props => [];
}

/// État initial
class MessagingInitial extends MessagingState {}

/// Chargement en cours
class MessagingLoading extends MessagingState {}

/// Conversations chargées
class ConversationsLoaded extends MessagingState {
  final List<Conversation> conversations;
  final int unreadCount;

  const ConversationsLoaded({
    required this.conversations,
    this.unreadCount = 0,
  });

  @override
  List<Object?> get props => [conversations, unreadCount];
}

/// Messages d'une conversation chargés
class MessagesLoaded extends MessagingState {
  final String conversationId;
  final List<Message> messages;
  final bool hasMore;

  const MessagesLoaded({
    required this.conversationId,
    required this.messages,
    this.hasMore = false,
  });

  @override
  List<Object?> get props => [conversationId, messages, hasMore];
}

/// Message envoyé avec succès
class MessageSent extends MessagingState {
  final Message message;

  const MessageSent(this.message);

  @override
  List<Object?> get props => [message];
}

/// Broadcast envoyé avec succès
class BroadcastSent extends MessagingState {
  final Message message;

  const BroadcastSent(this.message);

  @override
  List<Object?> get props => [message];
}

/// Conversation créée
class ConversationCreated extends MessagingState {
  final Conversation conversation;

  const ConversationCreated(this.conversation);

  @override
  List<Object?> get props => [conversation];
}

/// Compteur de non lus chargé
class UnreadCountLoaded extends MessagingState {
  final int count;

  const UnreadCountLoaded(this.count);

  @override
  List<Object?> get props => [count];
}

/// Erreur
class MessagingError extends MessagingState {
  final String message;

  const MessagingError(this.message);

  @override
  List<Object?> get props => [message];
}
