import 'package:flutter/material.dart';

/// Tutte le azioni disponibili nella Collection.
/// Versione ultra‑ottimizzata, senza album, senza filter_grids.
enum EntryAction {
  // Navigazione
  configureView,
  searchCollection,
  map,
  slideshow,
  stats,
  rescan,

  // Selezione
  select,
  selectAll,
  selectNone,

  // Cast
  cast,

  // File operations
  share,
  delete,
  copy,
  move,
  rename,
  convert,

  // Metadata
  toggleFavourite,
  rotateCW,
  rotateCCW,
  flip,
  editDate,
  editLocation,
  editTitleDescription,
  editRating,
  editTags,
  removeMetadata,
}

/// Categoria per raggruppare le azioni nel menu.
enum EntryActionCategory {
  navigation,
  selection,
  cast,
  fileOps,
  metadata,
}

/// Mappa azione → categoria
const Map<EntryAction, EntryActionCategory> entryActionCategory = {
  // Navigazione
  EntryAction.configureView: EntryActionCategory.navigation,
  EntryAction.searchCollection: EntryActionCategory.navigation,
  EntryAction.map: EntryActionCategory.navigation,
  EntryAction.slideshow: EntryActionCategory.navigation,
  EntryAction.stats: EntryActionCategory.navigation,
  EntryAction.rescan: EntryActionCategory.navigation,

  // Selezione
  EntryAction.select: EntryActionCategory.selection,
  EntryAction.selectAll: EntryActionCategory.selection,
  EntryAction.selectNone: EntryActionCategory.selection,

  // Cast
  EntryAction.cast: EntryActionCategory.cast,

  // File operations
  EntryAction.share: EntryActionCategory.fileOps,
  EntryAction.delete: EntryActionCategory.fileOps,
  EntryAction.copy: EntryActionCategory.fileOps,
  EntryAction.move: EntryActionCategory.fileOps,
  EntryAction.rename: EntryActionCategory.fileOps,
  EntryAction.convert: EntryActionCategory.fileOps,

  // Metadata
  EntryAction.toggleFavourite: EntryActionCategory.metadata,
  EntryAction.rotateCW: EntryActionCategory.metadata,
  EntryAction.rotateCCW: EntryActionCategory.metadata,
  EntryAction.flip: EntryActionCategory.metadata,
  EntryAction.editDate: EntryActionCategory.metadata,
  EntryAction.editLocation: EntryActionCategory.metadata,
  EntryAction.editTitleDescription: EntryActionCategory.metadata,
  EntryAction.editRating: EntryActionCategory.metadata,
  EntryAction.editTags: EntryActionCategory.metadata,
  EntryAction.removeMetadata: EntryActionCategory.metadata,
};

/// Icone per ogni azione
const Map<EntryAction, IconData> entryActionIcon = {
  // Navigazione
  EntryAction.configureView: Icons.tune,
  EntryAction.searchCollection: Icons.search,
  EntryAction.map: Icons.map,
  EntryAction.slideshow: Icons.slideshow,
  EntryAction.stats: Icons.bar_chart,
  EntryAction.rescan: Icons.refresh,

  // Selezione
  EntryAction.select: Icons.check_circle,
  EntryAction.selectAll: Icons.select_all,
  EntryAction.selectNone: Icons.remove_done,

  // Cast
  EntryAction.cast: Icons.cast,

  // File operations
  EntryAction.share: Icons.share,
  EntryAction.delete: Icons.delete,
  EntryAction.copy: Icons.copy,
  EntryAction.move: Icons.drive_file_move,
  EntryAction.rename: Icons.edit,
  EntryAction.convert: Icons.transform,

  // Metadata
  EntryAction.toggleFavourite: Icons.favorite,
  EntryAction.rotateCW: Icons.rotate_right,
  EntryAction.rotateCCW: Icons.rotate_left,
  EntryAction.flip: Icons.flip,
  EntryAction.editDate: Icons.event,
  EntryAction.editLocation: Icons.place,
  EntryAction.editTitleDescription: Icons.text_fields,
  EntryAction.editRating: Icons.star,
  EntryAction.editTags: Icons.label,
  EntryAction.removeMetadata: Icons.no_accounts,
};

/// Etichette leggibili
String entryActionLabel(EntryAction action) {
  switch (action) {
    case EntryAction.configureView:
      return 'Configura vista';
    case EntryAction.searchCollection:
      return 'Cerca';
    case EntryAction.map:
      return 'Mappa';
    case EntryAction.slideshow:
      return 'Slideshow';
    case EntryAction.stats:
      return 'Statistiche';
    case EntryAction.rescan:
      return 'Riscansiona';

    case EntryAction.select:
      return 'Seleziona';
    case EntryAction.selectAll:
      return 'Seleziona tutto';
    case EntryAction.selectNone:
      return 'Deseleziona tutto';

    case EntryAction.cast:
      return 'Cast';

    case EntryAction.share:
      return 'Condividi';
    case EntryAction.delete:
      return 'Elimina';
    case EntryAction.copy:
      return 'Copia';
    case EntryAction.move:
      return 'Sposta';
    case EntryAction.rename:
      return 'Rinomina';
    case EntryAction.convert:
      return 'Converti';

    case EntryAction.toggleFavourite:
      return 'Preferito';
    case EntryAction.rotateCW:
      return 'Ruota CW';
    case EntryAction.rotateCCW:
      return 'Ruota CCW';
    case EntryAction.flip:
      return 'Specchia';
    case EntryAction.editDate:
      return 'Modifica data';
    case EntryAction.editLocation:
      return 'Modifica posizione';
    case EntryAction.editTitleDescription:
      return 'Modifica titolo/descrizione';
    case EntryAction.editRating:
      return 'Modifica rating';
    case EntryAction.editTags:
      return 'Modifica tag';
    case EntryAction.removeMetadata:
      return 'Rimuovi metadata';
  }
}
