// lib/pages/device_managment/garage_door/bloc/state.dart

import 'package:equatable/equatable.dart';
import 'package:flutter/material.dart';
import 'package:syncrow_web/pages/device_managment/all_devices/models/device_reports.dart';
import 'package:syncrow_web/pages/device_managment/garage_door/models/garage_door_model.dart';
import 'package:syncrow_web/pages/device_managment/water_heater/models/water_heater_status_model.dart';

abstract class GarageDoorState extends Equatable {
  const GarageDoorState();

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

class GarageDoorInitialState extends GarageDoorState {}

class GarageDoorLoadingState extends GarageDoorState {}

class GarageDoorLoadedState extends GarageDoorState {
  final GarageDoorStatusModel status;
  final Duration? delay;
  final DeviceReport? records;
  final List<bool> selectedDays;
  final TimeOfDay? selectedTime;
  final bool functionOn;
  final bool isEditing;
  final ScheduleModes? scheduleMode;

  const GarageDoorLoadedState({
    required this.status,
    this.delay,
    this.records,
    this.selectedDays = const [false, false, false, false, false, false, false],
    this.selectedTime,
    this.functionOn = false,
    this.isEditing = false,
    this.scheduleMode = ScheduleModes.schedule,
  });

  @override
  List<Object?> get props => [
        status,
        delay,
        records,
        selectedDays,
        selectedTime,
        functionOn,
        isEditing,
        scheduleMode,
      ];

  GarageDoorLoadedState copyWith({
    GarageDoorStatusModel? status,
    Duration? delay,
    DeviceReport? records,
    List<bool>? selectedDays,
    TimeOfDay? selectedTime,
    bool? functionOn,
    bool? isEditing,
    ScheduleModes? scheduleMode,
  }) {
    return GarageDoorLoadedState(
      status: status ?? this.status,
      delay: delay ?? this.delay,
      records: records ?? this.records,
      selectedDays: selectedDays ?? this.selectedDays,
      selectedTime: selectedTime,
      functionOn: functionOn ?? this.functionOn,
      isEditing: isEditing ?? this.isEditing,
      scheduleMode: scheduleMode ?? this.scheduleMode,
    );
  }
}

class GarageDoorErrorState extends GarageDoorState {
  final String message;

  const GarageDoorErrorState({required this.message});

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

class GarageDoorLoadingNewState extends GarageDoorState {
  final GarageDoorStatusModel garageDoorModel;

  const GarageDoorLoadingNewState({required this.garageDoorModel});

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

class GarageDoorReportsLoadingState extends GarageDoorState {}

class GarageDoorReportsFailedState extends GarageDoorState {
  final String error;

  const GarageDoorReportsFailedState({required this.error});

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

class GarageDoorReportsState extends GarageDoorState {
  final DeviceReport deviceReport;

  const GarageDoorReportsState({required this.deviceReport});

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

class ShowGarageDoorDescriptionState extends GarageDoorState {
  final String description;

  const ShowGarageDoorDescriptionState({required this.description});

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

class ScheduleGarageLoadingState extends GarageDoorState {}

class GarageDoorBatchStatusLoaded extends GarageDoorState {
  final GarageDoorStatusModel status;

  const GarageDoorBatchStatusLoaded(this.status);

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

class GarageDoorBatchControlError extends GarageDoorState {
  final String message;

  const GarageDoorBatchControlError(this.message);

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