import 'package:equatable/equatable.dart';
import 'package:syncrow_web/pages/space_tree/model/pagination_model.dart';
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/community_model.dart';
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/space_model.dart';

class SpaceTreeEvent extends Equatable {
  const SpaceTreeEvent();

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

class InitialEvent extends SpaceTreeEvent {}

class PaginationEvent extends SpaceTreeEvent {
  final PaginationModel paginationModel;
  final List<CommunityModel> communities;

  const PaginationEvent(this.paginationModel, this.communities);

  @override
  List<Object> get props => [paginationModel, communities];
}

class SearchForSpace extends SpaceTreeEvent {
  final String searchQuery;

  const SearchForSpace(this.searchQuery);

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

class OnCommunityExpanded extends SpaceTreeEvent {
  final String communityId;

  const OnCommunityExpanded(this.communityId);

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

class OnCommunitySelected extends SpaceTreeEvent {
  final String communityId;
  final List<SpaceModel> children;

  const OnCommunitySelected(this.communityId, this.children);

  @override
  List<Object> get props => [communityId, children];
}

class OnSpaceExpanded extends SpaceTreeEvent {
  final String communityId;
  final String spaceId;

  const OnSpaceExpanded(this.communityId, this.spaceId);

  @override
  List<Object> get props => [communityId, spaceId];
}

class OnSpaceSelected extends SpaceTreeEvent {
  final String spaceId;
  final List<SpaceModel> children;
  final CommunityModel communityModel;

  const OnSpaceSelected(this.communityModel, this.spaceId, this.children);

  @override
  List<Object> get props => [communityModel, spaceId, children];
}

class SearchQueryEvent extends SpaceTreeEvent {
  final String searchQuery;

  const SearchQueryEvent(this.searchQuery);

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

class DebouncedSearchEvent extends SpaceTreeEvent {
  final String searchQuery;

  const DebouncedSearchEvent(this.searchQuery);

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

class OnCommunityAdded extends SpaceTreeEvent {
  final CommunityModel newCommunity;
  const OnCommunityAdded(this.newCommunity);

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

class OnCommunityUpdated extends SpaceTreeEvent {
  final CommunityModel updatedCommunity;
  const OnCommunityUpdated(this.updatedCommunity);

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

class ClearAllData extends SpaceTreeEvent {}

class ClearCachedData extends SpaceTreeEvent {}

class SpaceTreeClearSelectionEvent extends SpaceTreeEvent {
  const SpaceTreeClearSelectionEvent();
}

final class AnalyticsClearAllSpaceTreeSelectionsEvent extends SpaceTreeEvent {
  const AnalyticsClearAllSpaceTreeSelectionsEvent();
}
