import 'package:equatable/equatable.dart';
import 'package:flutter/cupertino.dart';
import 'package:syncrow_web/pages/visitor_password/model/device_model.dart';

abstract class VisitorPasswordEvent extends Equatable {
  const VisitorPasswordEvent();

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

class SelectPasswordType extends VisitorPasswordEvent {
  final String type;

  const SelectPasswordType(this.type);

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

class SelectUsageFrequency extends VisitorPasswordEvent {
  final String usageType;

  const SelectUsageFrequency(this.usageType);

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

class SelectTimeVisitorPassword extends VisitorPasswordEvent {
  final BuildContext context;
  final bool isStart;
  final bool isRepeat;

  const SelectTimeVisitorPassword(
      {required this.context, required this.isStart, required this.isRepeat});

  @override
  List<Object> get props => [context, isStart, isRepeat];
}

class ToggleDaySelectionEvent extends VisitorPasswordEvent {
  final String key;

  const ToggleDaySelectionEvent({required this.key});
  @override
  List<Object> get props => [key];
}

class ToggleRepeatEvent extends VisitorPasswordEvent {}

class GeneratePasswordEvent extends VisitorPasswordEvent {}

class FetchDevice extends VisitorPasswordEvent {}

//online password
class OnlineOneTimePasswordEvent extends VisitorPasswordEvent {
  final String? email;
  final String? passwordName;
  final BuildContext? context;

  const OnlineOneTimePasswordEvent(
      {this.email, this.passwordName, this.context});

  @override
  List<Object> get props => [
        email!,
        passwordName!,
      ];
}

class OnlineMultipleTimePasswordEvent extends VisitorPasswordEvent {
  final String? email;
  final String? passwordName;
  final String? invalidTime;
  final String? effectiveTime;
  final BuildContext? context;
  const OnlineMultipleTimePasswordEvent(
      {this.email,
      this.passwordName,
      this.invalidTime,
      this.effectiveTime,
      this.context});
  @override
  List<Object> get props =>
      [email!, passwordName!, invalidTime!, effectiveTime!, context!];
}

//offline password
class OfflineOneTimePasswordEvent extends VisitorPasswordEvent {
  final BuildContext? context;
  final String? email;
  final String? passwordName;
  const OfflineOneTimePasswordEvent(
      {this.email, this.passwordName, this.context});
  @override
  List<Object> get props => [
        email!,
        passwordName!,
        context!,
      ];
}

class OfflineMultipleTimePasswordEvent extends VisitorPasswordEvent {
  final String? email;
  final String? passwordName;
  final String? invalidTime;
  final String? effectiveTime;
  final BuildContext? context;

  const OfflineMultipleTimePasswordEvent(
      {this.context,
      this.email,
      this.passwordName,
      this.invalidTime,
      this.effectiveTime});

  @override
  List<Object> get props =>
      [email!, passwordName!, invalidTime!, effectiveTime!, context!];
}

class SelectDeviceEvent extends VisitorPasswordEvent {
  final String deviceId;
  const SelectDeviceEvent(this.deviceId);
}

class FilterDataEvent extends VisitorPasswordEvent {
  final String? passwordName;
  final int? startTime;
  final int? endTime;

  const FilterDataEvent({
    this.passwordName,
    this.startTime,
    this.endTime,
  });
}

class UpdateFilteredDevicesEvent extends VisitorPasswordEvent {
  final List<DeviceModel> filteredData;

  UpdateFilteredDevicesEvent(this.filteredData);
}

class SelectTimeEvent extends VisitorPasswordEvent {
  final BuildContext context;
  final bool isEffective;
  const SelectTimeEvent({required this.context, required this.isEffective});
  @override
  List<Object> get props => [context, isEffective];
}

class ChangeTimeEvent extends VisitorPasswordEvent {
  final dynamic val;
  final bool isStartEndTime;

  const ChangeTimeEvent({required this.val, required this.isStartEndTime});
  @override
  List<Object> get props => [val, isStartEndTime];
}
