part of 'water_heater_bloc.dart';

sealed class WaterHeaterState extends Equatable {
  const WaterHeaterState();

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

final class WaterHeaterInitial extends WaterHeaterState {}

final class WaterHeaterLoadingState extends WaterHeaterState {}

final class ScheduleLoadingState extends WaterHeaterState {}

class WaterHeaterDeviceStatusLoaded extends WaterHeaterState {
  final WaterHeaterStatusModel status;
  final ScheduleModes? scheduleMode;

  // Countdown-specific
  final int? countdownHours;
  final int? countdownMinutes;
  final Duration? countdownRemaining;
  final bool? isCountdownActive;

  // Inching-specific
  final int? inchingHours;
  final int? inchingMinutes;
  final bool? isInchingActive;

  final List<ScheduleModel> schedules;
  final List<bool> selectedDays;
  final TimeOfDay? selectedTime;
  final bool functionOn;
  final bool isEditing;

  const WaterHeaterDeviceStatusLoaded(
    this.status, {
    this.scheduleMode,
    this.countdownHours,
    this.countdownMinutes,
    this.countdownRemaining,
    this.isCountdownActive,
    this.inchingHours,
    this.inchingMinutes,
    this.isInchingActive,
    this.schedules = const [],
    this.selectedDays = const [false, false, false, false, false, false, false],
    this.selectedTime,
    this.functionOn = false,
    this.isEditing = false,
  });

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

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

final class WaterHeaterFailedState extends WaterHeaterState {
  final String error;

  const WaterHeaterFailedState({required this.error});

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

final class WaterHeaterBatchFailedState extends WaterHeaterState {
  final String error;

  const WaterHeaterBatchFailedState({required this.error});

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