import 'package:syncrow_web/pages/routines/models/device_functions.dart';
import 'package:syncrow_web/utils/constants/assets.dart';

class GatewayOperationalValue {
  final String icon;
  final String description;
  final dynamic value;

  GatewayOperationalValue({
    required this.icon,
    required this.description,
    required this.value,
  });
}

abstract class GatewayFunctions extends DeviceFunction<GatewayOperationalValue> {
  final String type;

  GatewayFunctions({
    required super.deviceId,
    required super.deviceName,
    required super.code,
    required super.operationName,
    required super.icon,
    required this.type,
  });

  List<GatewayOperationalValue> getOperationalValues();
}

final class GatewaySwitchAlarmSound extends GatewayFunctions {
  GatewaySwitchAlarmSound({
    required super.deviceId,
    required super.deviceName,
    required super.type,
  }) : super(
          code: 'switch_alarm_sound',
          operationName: 'Switch Alarm Sound',
          icon: Assets.activeBell,
        );

  @override
  List<GatewayOperationalValue> getOperationalValues() => [
        GatewayOperationalValue(
          icon: Assets.assetsAcPower,
          description: "ON",
          value: true,
        ),
        GatewayOperationalValue(
          icon: Assets.assetsAcPowerOFF,
          description: "OFF",
          value: false,
        ),
      ];
}

final class GatewayMasterState extends GatewayFunctions {
  GatewayMasterState({
    required super.deviceId,
    required super.deviceName,
    required super.type,
  }) : super(
          code: 'master_state',
          operationName: 'Master State',
          icon: Assets.gear,
        );

  @override
  List<GatewayOperationalValue> getOperationalValues() {
    return [
      GatewayOperationalValue(
        icon: Assets.assetsAcPower,
        description: "Normal",
        value: 'normal',
      ),
      GatewayOperationalValue(
        icon: Assets.assetsAcPowerOFF,
        description: "Alarm",
        value: 'alarm',
      ),
    ];
  }
}

final class GatewayFactoryReset extends GatewayFunctions {
  GatewayFactoryReset({
    required super.deviceId,
    required super.deviceName,
    required super.type,
  }) : super(
          code: 'factory_reset',
          operationName: 'Factory Reset',
          icon: Assets.factoryReset,
        );

  @override
  List<GatewayOperationalValue> getOperationalValues() {
    return [
      GatewayOperationalValue(
        icon: Assets.assetsAcPower,
        description: "ON",
        value: true,
      ),
      GatewayOperationalValue(
        icon: Assets.assetsAcPowerOFF,
        description: "OFF",
        value: false,
      ),
    ];
  }
}
