part of 'schedule_bloc.dart';

abstract class ScheduleState extends Equatable {
  const ScheduleState();
}

class ScheduleInitial extends ScheduleState {
  @override
  List<Object> get props => [];
}

class ScheduleLoading extends ScheduleState {
  @override
  List<Object> get props => [];
}

class ScheduleLoaded extends ScheduleState {
  final List<ScheduleModel> schedules;
  final TimeOfDay? selectedTime;
  final List<bool> selectedDays;
  final bool functionOn;
  final bool isEditing;
  final String deviceId;
  final int countdownHours;
  final int countdownMinutes;
  final bool isCountdownActive;
  final int inchingHours;
  final int inchingMinutes;
  final int inchingSeconds;
  final bool isInchingActive;
  final ScheduleModes scheduleMode;
  final Duration countdownRemaining;
  final int? countdownSeconds;

  const ScheduleLoaded({
    this.countdownSeconds = 0,
    this.inchingSeconds = 0,
    required this.schedules,
    this.selectedTime,
    required this.selectedDays,
    required this.functionOn,
    required this.isEditing,
    required this.deviceId,
    this.countdownHours = 0,
    this.countdownMinutes = 0,
    this.isCountdownActive = false,
    this.inchingHours = 0,
    this.inchingMinutes = 0,
    this.isInchingActive = false,
    this.scheduleMode = ScheduleModes.countdown,
    this.countdownRemaining = Duration.zero,
  });

  ScheduleLoaded copyWith({
    List<ScheduleModel>? schedules,
    TimeOfDay? selectedTime,
    List<bool>? selectedDays,
    bool? functionOn,
    bool? isEditing,
    int? countdownHours,
    int? countdownMinutes,
    bool? isCountdownActive,
    int? inchingHours,
    int? inchingMinutes,
    bool? isInchingActive,
    ScheduleModes? scheduleMode,
    Duration? countdownRemaining,
    String? deviceId,
    int? countdownSeconds,
    int? inchingSeconds,
  }) {
    return ScheduleLoaded(
      schedules: schedules ?? this.schedules,
      selectedTime: selectedTime ?? this.selectedTime,
      selectedDays: selectedDays ?? this.selectedDays,
      functionOn: functionOn ?? this.functionOn,
      isEditing: isEditing ?? this.isEditing,
      deviceId: deviceId ?? this.deviceId,
      countdownHours: countdownHours ?? this.countdownHours,
      countdownMinutes: countdownMinutes ?? this.countdownMinutes,
      isCountdownActive: isCountdownActive ?? this.isCountdownActive,
      inchingHours: inchingHours ?? this.inchingHours,
      inchingMinutes: inchingMinutes ?? this.inchingMinutes,
      isInchingActive: isInchingActive ?? this.isInchingActive,
      scheduleMode: scheduleMode ?? this.scheduleMode,
      countdownRemaining: countdownRemaining ?? this.countdownRemaining,
      countdownSeconds: countdownSeconds ?? this.countdownSeconds,
      inchingSeconds: inchingSeconds ?? this.inchingSeconds,
    );
  }

  @override
  List<Object?> get props => [
        schedules,
        selectedTime,
        selectedDays,
        functionOn,
        isEditing,
        deviceId,
        countdownHours,
        countdownMinutes,
        isCountdownActive,
        inchingHours,
        inchingMinutes,
        isInchingActive,
        scheduleMode,
        countdownRemaining,
        countdownSeconds,
        inchingSeconds,
      ];
}

class ScheduleError extends ScheduleState {
  final String error;

  const ScheduleError(this.error);

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