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

/// Abstract base class for all expense-related states.
/// 
/// This class extends [Equatable] to enable value equality for state comparison.
/// All expense states in the application should inherit from this class.
abstract class ExpenseState extends Equatable {
  /// Creates a new [ExpenseState].
  const ExpenseState();

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

/// Initial state of the expense bloc.
/// 
/// This state represents the initial state before any expense
/// operations have been performed.
class ExpenseInitial extends ExpenseState {}

/// State indicating that an expense operation is in progress.
/// 
/// This state is used to show loading indicators during expense
/// operations like loading, creating, updating, or deleting expenses.
class ExpenseLoading extends ExpenseState {}

/// State indicating that expenses have been successfully loaded.
/// 
/// This state contains the list of expenses for a group and
/// exchange rates for currency conversion calculations.
class ExpensesLoaded extends ExpenseState {
  /// List of expenses for the current group.
  final List<Expense> expenses;
  
  /// Exchange rates for currency conversion.
  /// 
  /// Maps currency codes to their exchange rates relative to EUR.
  /// Used for converting different currencies to a common base for calculations.
  final Map<String, double> exchangeRates;

  /// Creates an [ExpensesLoaded] state with expenses and exchange rates.
  /// 
  /// [exchangeRates] defaults to common rates if not provided.
  const ExpensesLoaded({
    required this.expenses,
    this.exchangeRates = const {'EUR': 1.0, 'USD': 0.85, 'GBP': 1.15},
  });

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

/// State indicating that an expense operation has completed successfully.
/// 
/// This state is used to show success messages after operations like
/// creating, updating, deleting, or archiving expenses.
class ExpenseOperationSuccess extends ExpenseState {
  /// Success message to display to the user.
  final String message;

  /// Creates an [ExpenseOperationSuccess] state with the given [message].
  const ExpenseOperationSuccess(this.message);

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

/// State indicating that an expense operation has failed.
/// 
/// This state contains an error message that can be displayed to the user
/// when expense operations fail.
class ExpenseError extends ExpenseState {
  /// The error message describing what went wrong.
  final String message;

  /// Creates an [ExpenseError] state with the given error [message].
  const ExpenseError(this.message);

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