import 'package:equatable/equatable.dart';
import 'package:staff_authentication/src/domain/ui_entities/auth_mode.dart';

/// Abstract base class for all authentication events.
abstract class AuthEvent extends Equatable {
  const AuthEvent();
  @override
  List<Object?> get props => <Object?>[];
}

/// Event for requesting a sign-in with a phone number.
class AuthSignInRequested extends AuthEvent {
  /// The phone number provided by the user.
  final String? phoneNumber;

  /// The authentication mode (login or signup).
  final AuthMode mode;

  const AuthSignInRequested({this.phoneNumber, required this.mode});

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

/// Event for submitting an OTP (One-Time Password) for verification.
///
/// This event is dispatched after the user has received an OTP and
/// submits it for verification.
class AuthOtpSubmitted extends AuthEvent {
  /// The verification ID received after the phone number submission.
  final String verificationId;

  /// The SMS code (OTP) entered by the user.
  final String smsCode;

  /// The authentication mode (login or signup).
  final AuthMode mode;

  const AuthOtpSubmitted({
    required this.verificationId,
    required this.smsCode,
    required this.mode,
  });

  @override
  List<Object?> get props => <Object?>[verificationId, smsCode, mode];
}

/// Event for clearing any authentication error in the state.
class AuthErrorCleared extends AuthEvent {}

/// Event for resetting the authentication flow back to initial.
class AuthResetRequested extends AuthEvent {
  /// The authentication mode (login or signup).
  final AuthMode mode;

  const AuthResetRequested({required this.mode});

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

/// Event for ticking down the resend cooldown.
class AuthCooldownTicked extends AuthEvent {
  final int secondsRemaining;

  const AuthCooldownTicked(this.secondsRemaining);

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

/// Event for updating the current draft OTP in the state.
class AuthOtpUpdated extends AuthEvent {
  /// The current draft OTP.
  final String otp;

  const AuthOtpUpdated(this.otp);

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

/// Event for updating the current draft phone number in the state.
class AuthPhoneUpdated extends AuthEvent {
  /// The current draft phone number.
  final String phoneNumber;

  const AuthPhoneUpdated(this.phoneNumber);

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