import 'package:equatable/equatable.dart';

abstract class FileBrowserEvent extends Equatable {
  const FileBrowserEvent();

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

class LoadDirectory extends FileBrowserEvent {
  final String orgId;
  final String path;

  const LoadDirectory({required this.orgId, required this.path});

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

class NavigateToFolder extends FileBrowserEvent {
  final String folderId;

  const NavigateToFolder(this.folderId);

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

class RefreshDirectory extends FileBrowserEvent {}

class ApplySort extends FileBrowserEvent {
  final String sortBy; // name, date, size, type
  final bool isAscending;

  const ApplySort(this.sortBy, {this.isAscending = true});

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

class ApplyFilter extends FileBrowserEvent {
  final String filter;

  const ApplyFilter(this.filter);

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

class CreateFolder extends FileBrowserEvent {
  final String orgId;
  final String parentPath;
  final String folderName;

  const CreateFolder({
    required this.orgId,
    required this.parentPath,
    required this.folderName,
  });

  @override
  List<Object> get props => [orgId, parentPath, folderName];
}

class ResetFileBrowser extends FileBrowserEvent {
  final String nextOrgId;

  const ResetFileBrowser(this.nextOrgId);

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

class LoadPage extends FileBrowserEvent {
  final int page;

  const LoadPage(this.page);

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

class ChangePageSize extends FileBrowserEvent {
  final int pageSize;

  const ChangePageSize(this.pageSize);

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

class SearchFiles extends FileBrowserEvent {
  final String orgId;
  final String query;

  const SearchFiles({required this.orgId, required this.query});

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

class MoveFile extends FileBrowserEvent {
  final String orgId;
  final String sourcePath;
  final String targetPath;

  const MoveFile({
    required this.orgId,
    required this.sourcePath,
    required this.targetPath,
  });

  @override
  List<Object> get props => [orgId, sourcePath, targetPath];
}

class RenameFile extends FileBrowserEvent {
  final String orgId;
  final String path;
  final String newName;

  const RenameFile({
    required this.orgId,
    required this.path,
    required this.newName,
  });

  @override
  List<Object> get props => [orgId, path, newName];
}

class DeleteFile extends FileBrowserEvent {
  final String orgId;
  final String path;

  const DeleteFile({required this.orgId, required this.path});

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