import 'package:equatable/equatable.dart';
import '../../../models/activity.dart';

/// Events pour les activités de la base de données
abstract class DbActivityEvent extends Equatable {
  const DbActivityEvent();

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

/// Charger les activités d'un voyage depuis la DB
class LoadDbActivities extends DbActivityEvent {
  final String tripId;
  final List<String> tripParticipants;

  const LoadDbActivities({
    required this.tripId,
    required this.tripParticipants,
  });

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

/// Rechercher des activités dans la DB
class SearchDbActivities extends DbActivityEvent {
  final String tripId;
  final String query;
  final List<String> tripParticipants;

  const SearchDbActivities({
    required this.tripId,
    required this.query,
    required this.tripParticipants,
  });

  @override
  List<Object?> get props => [tripId, query, tripParticipants];
}

/// Ajouter une activité à la DB
class AddDbActivity extends DbActivityEvent {
  final Activity activity;

  const AddDbActivity({required this.activity});

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

/// Ajouter plusieurs activités à la DB
class AddDbActivitiesBatch extends DbActivityEvent {
  final List<Activity> activities;

  const AddDbActivitiesBatch({required this.activities});

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

/// Voter pour une activité
class VoteForDbActivity extends DbActivityEvent {
  final String activityId;
  final String userId;
  final bool isUpvote;

  const VoteForDbActivity({
    required this.activityId,
    required this.userId,
    required this.isUpvote,
  });

  @override
  List<Object?> get props => [activityId, userId, isUpvote];
}

/// Supprimer une activité
class DeleteDbActivity extends DbActivityEvent {
  final String activityId;

  const DeleteDbActivity({required this.activityId});

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

/// Filtrer les activités
class FilterDbActivities extends DbActivityEvent {
  final String? category;
  final bool? showFavorites;

  const FilterDbActivities({
    this.category,
    this.showFavorites,
  });

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

/// Rafraîchir les activités
class RefreshDbActivities extends DbActivityEvent {
  final String tripId;
  final List<String> tripParticipants;

  const RefreshDbActivities({
    required this.tripId,
    required this.tripParticipants,
  });

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

/// Mettre à jour une activité
class UpdateDbActivity extends DbActivityEvent {
  final Activity activity;

  const UpdateDbActivity({required this.activity});

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

/// Basculer le favori d'une activité
class ToggleDbActivityFavorite extends DbActivityEvent {
  final String activityId;
  final String userId;

  const ToggleDbActivityFavorite({
    required this.activityId,
    required this.userId,
  });

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

/// Effacer les résultats de recherche
class ClearDbSearchResults extends DbActivityEvent {
  const ClearDbSearchResults();
}