//ignore_for_file: constant_identifier_names
import 'dart:ui';
import 'package:syncrow_app/features/app_layout/bloc/home_cubit.dart';
import 'package:syncrow_app/features/devices/model/function_model.dart';
import 'package:syncrow_app/features/menu/bloc/privacy_policy.dart';
import 'package:syncrow_app/features/menu/bloc/user_agreement.dart';
// import 'package:syncrow_app/features/menu/view/widgets/create_home/create_home_view.dart';
import 'package:syncrow_app/features/menu/view/widgets/join_home/join_home_view.dart';
import 'package:syncrow_app/features/menu/view/widgets/manage_home/manage_home_view.dart';
import 'package:syncrow_app/features/menu/view/widgets/securty/view/securty_view.dart';
import 'package:syncrow_app/generated/assets.dart';
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';

abstract class Constants {
  static const String appName = "Syncrow App";

  static const String languageCode = "en";

  static const String countryCode = "US";

  static const double appBarHeightPercentage = 0.1;
  static const double bottomNavBarHeightPercentage = 0.1;
  static late double appBarHeight;
  static late double bottomNavBarHeight;

  static const double defaultPadding = 16;

  static const String token = '';
}

enum SpaceType { Unit, Building, Floor, Room, Community }

Map<String, SpaceType> spaceTypesMap = {
  "unit": SpaceType.Unit,
  "building": SpaceType.Building,
  "floor": SpaceType.Floor,
  "room": SpaceType.Room,
  "community": SpaceType.Community,
};

enum DeviceType {
  AC,
  LightBulb,
  DoorLock,
  Curtain,
  Blind,
  OneGang,
  TwoGang,
  ThreeGang,
  Gateway,
  CeilingSensor,
  WallSensor,
  WH,
  DS,
  OneTouch,
  TowTouch,
  ThreeTouch,
  GarageDoor,
  WaterLeak,
  PC,
  FourScene,
  SixScene,
  SOS,
  Other,
  FlushMountedSensor,
}

enum FunctionType { Boolean, Enum, Integer, Raw, String }

enum ValueACRange { LOW, MIDDLE, HIGH, AUTO }

Map<String, FunctionType> functionTypesMap = {
  "Boolean": FunctionType.Boolean,
  "Enum": FunctionType.Enum,
  "Integer": FunctionType.Integer,
  "Raw": FunctionType.Raw,
  "String": FunctionType.String,
};
Map<String, DeviceType> devicesTypesMap = {
  "AC": DeviceType.AC,
  "GW": DeviceType.Gateway,
  "CPS": DeviceType.CeilingSensor,
  "DL": DeviceType.DoorLock,
  "WPS": DeviceType.WallSensor,
  "3G": DeviceType.ThreeGang,
  "2G": DeviceType.TwoGang,
  "1G": DeviceType.OneGang,
  "CUR": DeviceType.Curtain,
  "WH": DeviceType.WH,
  "DS": DeviceType.DS,
  "1GT": DeviceType.OneTouch,
  "2GT": DeviceType.TowTouch,
  "3GT": DeviceType.ThreeTouch,
  "GD": DeviceType.GarageDoor,
  "WL": DeviceType.WaterLeak,
  "PC": DeviceType.PC,
  "4S": DeviceType.FourScene,
  "6S": DeviceType.SixScene,
  "SOS": DeviceType.SOS,
  "NCPS": DeviceType.FlushMountedSensor,
};

Map<DeviceType, List<FunctionModel>> devicesFunctionsMap = {
  DeviceType.AC: [
    FunctionModel(
        code: 'switch',
        type: functionTypesMap['Boolean'],
        values: ValueModel.fromJson({})),
    FunctionModel(
        code: 'mode',
        type: functionTypesMap['Enum'],
        values: ValueModel.fromJson({
          // "range": ["cold", "hot", "wind"]
        })),
    FunctionModel(
      code: 'temp_set',
      type: functionTypesMap['Integer'],
      values: ValueModel.fromJson(
        {
          // "unit": {"min": 200, "max": 300, "scale": 1, "step": 5},
        },
      ),
    ),
    FunctionModel(
        code: 'level',
        type: functionTypesMap['Enum'],
        values: ValueModel.fromJson({
          // "range": ["low", "middle", "high", "auto"]
        })),
    FunctionModel(
        code: 'child_lock',
        type: functionTypesMap['Boolean'],
        values: ValueModel.fromJson({})),
  ],
  DeviceType.Gateway: [
    FunctionModel(
        code: 'switch_alarm_sound',
        type: functionTypesMap['Boolean'],
        values: ValueModel.fromJson({})),
    FunctionModel(
        code: 'master_state',
        type: functionTypesMap['Enum'],
        values: ValueModel.fromJson({
          "range": ["normal", "alarm"]
        })),
    FunctionModel(
        code: 'factory_reset',
        type: functionTypesMap['Boolean'],
        values: ValueModel.fromJson({})),
    FunctionModel(
        code: 'alarm_active',
        type: functionTypesMap['String'],
        values: ValueModel.fromJson({"maxlen": 255})),
  ],
  DeviceType.CeilingSensor: [
    FunctionModel(
        code: 'sensitivity',
        type: functionTypesMap['Integer'],
        values: ValueModel.fromJson(
            {"unit": "", "min": 1, "max": 10, "scale": 0, "step": 1})),
  ],
  DeviceType.DoorLock: [
    FunctionModel(
        code: 'remote_no_pd_setkey',
        type: functionTypesMap['Raw'],
        values: ValueModel.fromJson({})),
    FunctionModel(
        code: 'remote_no_dp_key',
        type: functionTypesMap['Raw'],
        values: ValueModel.fromJson({})),
    FunctionModel(
        code: 'normal_open_switch',
        type: functionTypesMap['Boolean'],
        values: ValueModel.fromJson({})),
  ],
  DeviceType.WallSensor: [
    FunctionModel(
        code: 'far_detection',
        type: functionTypesMap['Integer'],
        values: ValueModel.fromJson(
            {"unit": "cm", "min": 75, "max": 600, "scale": 0, "step": 75})),
    FunctionModel(
        code: 'presence_time',
        type: functionTypesMap['Integer'],
        values: ValueModel.fromJson(
            {"unit": "Min", "min": 0, "max": 65535, "scale": 0, "step": 1})),
    FunctionModel(
        code: 'motion_sensitivity_value',
        type: functionTypesMap['Integer'],
        values: ValueModel.fromJson(
            {"unit": "", "min": 1, "max": 5, "scale": 0, "step": 1})),
    FunctionModel(
        code: 'motionless_sensitivity',
        type: functionTypesMap['Integer'],
        values: ValueModel.fromJson(
            {"unit": "", "min": 1, "max": 5, "scale": 0, "step": 1})),
    FunctionModel(
        code: 'indicator',
        type: functionTypesMap['Boolean'],
        values: ValueModel.fromJson({})),
  ],
  DeviceType.OneGang: [
    FunctionModel(
        code: 'switch_1',
        type: functionTypesMap['Boolean'],
        values: ValueModel.fromJson({})),
    FunctionModel(
        code: 'countdown_1',
        type: functionTypesMap['Integer'],
        values: ValueModel.fromJson(
            {"unit": "s", "min": 0, "max": 43200, "scale": 0, "step": 1})),
  ],
  DeviceType.TwoGang: [
    FunctionModel(
        code: 'switch_1',
        type: functionTypesMap['Boolean'],
        values: ValueModel.fromJson({})),
    FunctionModel(
        code: 'switch_2',
        type: functionTypesMap['Boolean'],
        values: ValueModel.fromJson({})),
    FunctionModel(
        code: 'countdown_1',
        type: functionTypesMap['Integer'],
        values: ValueModel.fromJson(
            {"unit": "s", "min": 0, "max": 43200, "scale": 0, "step": 1})),
    FunctionModel(
        code: 'countdown_2',
        type: functionTypesMap['Integer'],
        values: ValueModel.fromJson(
            {"unit": "s", "min": 0, "max": 43200, "scale": 0, "step": 1})),
  ],
  DeviceType.ThreeGang: [
    FunctionModel(
        code: 'switch_1',
        type: functionTypesMap['Boolean'],
        values: ValueModel.fromJson({})),
    FunctionModel(
        code: 'switch_2',
        type: functionTypesMap['Boolean'],
        values: ValueModel.fromJson({})),
    FunctionModel(
        code: 'switch_3',
        type: functionTypesMap['Boolean'],
        values: ValueModel.fromJson({})),
    FunctionModel(
        code: 'countdown_1',
        type: functionTypesMap['Integer'],
        values: ValueModel.fromJson(
            {"unit": "s", "min": 0, "max": 43200, "scale": 0, "step": 1})),
    FunctionModel(
        code: 'countdown_2',
        type: functionTypesMap['Integer'],
        values: ValueModel.fromJson(
            {"unit": "s", "min": 0, "max": 43200, "scale": 0, "step": 1})),
    FunctionModel(
        code: 'countdown_3',
        type: functionTypesMap['Integer'],
        values: ValueModel.fromJson(
            {"unit": "s", "min": 0, "max": 43200, "scale": 0, "step": 1})),
  ],
  DeviceType.Curtain: [
    FunctionModel(
        code: 'control',
        type: functionTypesMap['Enum'],
        values: ValueModel.fromJson({
          "range": ["open", "stop", "close"]
        })),
    FunctionModel(
        code: 'percent_control',
        type: functionTypesMap['Integer'],
        values: ValueModel.fromJson(
            {"unit": "%", "min": 0, "max": 100, "scale": 0, "step": 1})),
  ],
  DeviceType.WH: [
    FunctionModel(
        code: 'switch_1',
        type: functionTypesMap['Boolean'],
        values: ValueModel.fromJson({})),
    FunctionModel(
        code: 'countdown_1',
        type: functionTypesMap['Integer'],
        values: ValueModel.fromJson(
            {"unit": "s", "min": 0, "max": 43200, "scale": 0, "step": 1})),
    FunctionModel(
        code: 'relay_status',
        type: functionTypesMap['Enum'],
        values: ValueModel.fromJson({
          "range": ["off", "on"]
        })),
    FunctionModel(
        code: 'switch_backlight',
        type: functionTypesMap['Boolean'],
        values: ValueModel.fromJson({})),
    FunctionModel(
        code: 'switch_inching',
        type: functionTypesMap['String'],
        values: ValueModel.fromJson({
          "maxlen": 255,
        })),
    FunctionModel(
        code: 'cycle_timing',
        type: functionTypesMap['Raw'],
        values: ValueModel.fromJson({"maxlen": 255})),
  ],
  DeviceType.DS: [
    FunctionModel(
        code: 'doorcontact_state',
        type: functionTypesMap['Raw'],
        values: ValueModel.fromJson({})),
    FunctionModel(
        code: 'battery_percentage',
        type: functionTypesMap['Integer'],
        values: ValueModel.fromJson({})),
  ],
  DeviceType.OneTouch: [
    FunctionModel(
        code: 'switch_1',
        type: functionTypesMap['Boolean'],
        values: ValueModel.fromJson({})),
    FunctionModel(
        code: 'countdown_1',
        type: functionTypesMap['Integer'],
        values: ValueModel.fromJson(
            {"unit": "s", "min": 0, "max": 43200, "scale": 0, "step": 1})),
    FunctionModel(
        code: 'relay_status',
        type: functionTypesMap['Enum'],
        values: ValueModel.fromJson({
          "range": ['power_off', 'power_on', 'last']
        })),
    FunctionModel(
        code: 'light_mode',
        type: functionTypesMap['Enum'],
        values: ValueModel.fromJson({
          "range": ['none', 'relay', 'pos']
        })),
    FunctionModel(
        code: 'relay_status_1',
        type: functionTypesMap['Enum'],
        values: ValueModel.fromJson({
          "range": ['power_off', 'power_on', 'last']
        })),
  ],
  DeviceType.TowTouch: [
    FunctionModel(
        code: 'switch_1',
        type: functionTypesMap['Boolean'],
        values: ValueModel.fromJson({})),
    FunctionModel(
        code: 'switch_2',
        type: functionTypesMap['Boolean'],
        values: ValueModel.fromJson({})),
    FunctionModel(
        code: 'countdown_1',
        type: functionTypesMap['Integer'],
        values: ValueModel.fromJson(
            {"unit": "s", "min": 0, "max": 43200, "scale": 0, "step": 1})),
    FunctionModel(
        code: 'countdown_2',
        type: functionTypesMap['Integer'],
        values: ValueModel.fromJson(
            {"unit": "s", "min": 0, "max": 43200, "scale": 0, "step": 1})),
    FunctionModel(
        code: 'relay_status',
        type: functionTypesMap['Enum'],
        values: ValueModel.fromJson({
          "range": ['power_off', 'power_on', 'last']
        })),
    FunctionModel(
        code: 'light_mode',
        type: functionTypesMap['Enum'],
        values: ValueModel.fromJson({
          "range": ['none', 'relay', 'pos']
        })),
    FunctionModel(
        code: 'relay_status_1',
        type: functionTypesMap['Enum'],
        values: ValueModel.fromJson({
          "range": ['power_off', 'power_on', 'last']
        })),
    FunctionModel(
        code: 'relay_status_2',
        type: functionTypesMap['Enum'],
        values: ValueModel.fromJson({
          "range": ['power_off', 'power_on', 'last']
        })),
  ],
  DeviceType.ThreeTouch: [
    FunctionModel(
        code: 'switch_1',
        type: functionTypesMap['Boolean'],
        values: ValueModel.fromJson({})),
    FunctionModel(
        code: 'switch_2',
        type: functionTypesMap['Boolean'],
        values: ValueModel.fromJson({})),
    FunctionModel(
        code: 'switch_3',
        type: functionTypesMap['Boolean'],
        values: ValueModel.fromJson({})),
    FunctionModel(
        code: 'countdown_1',
        type: functionTypesMap['Integer'],
        values: ValueModel.fromJson(
            {"unit": "s", "min": 0, "max": 43200, "scale": 0, "step": 1})),
    FunctionModel(
        code: 'countdown_2',
        type: functionTypesMap['Integer'],
        values: ValueModel.fromJson(
            {"unit": "s", "min": 0, "max": 43200, "scale": 0, "step": 1})),
    FunctionModel(
        code: 'countdown_3',
        type: functionTypesMap['Integer'],
        values: ValueModel.fromJson(
            {"unit": "s", "min": 0, "max": 43200, "scale": 0, "step": 1})),
    FunctionModel(
        code: 'relay_status',
        type: functionTypesMap['Enum'],
        values: ValueModel.fromJson({
          "range": ['power_off', 'power_on', 'last']
        })),
    FunctionModel(
        code: 'light_mode',
        type: functionTypesMap['Enum'],
        values: ValueModel.fromJson({
          "range": ['none', 'relay', 'pos']
        })),
    FunctionModel(
        code: 'relay_status_1',
        type: functionTypesMap['Enum'],
        values: ValueModel.fromJson({
          "range": ['power_off', 'power_on', 'last']
        })),
    FunctionModel(
        code: 'relay_status_2',
        type: functionTypesMap['Enum'],
        values: ValueModel.fromJson({
          "range": ['power_off', 'power_on', 'last']
        })),
    FunctionModel(
        code: 'relay_status_3',
        type: functionTypesMap['Enum'],
        values: ValueModel.fromJson({
          "range": ['power_off', 'power_on', 'last']
        })),
  ],
  DeviceType.GarageDoor: [
    FunctionModel(
        code: 'switch_1',
        type: functionTypesMap['Boolean'],
        values: ValueModel.fromJson({})),
    FunctionModel(
        code: 'countdown_1',
        type: functionTypesMap['Integer'],
        values: ValueModel.fromJson(
            {"unit": "s", "min": 0, "max": 86400, "scale": 0, "step": 1})),
    FunctionModel(
        code: 'tr_timecon',
        type: functionTypesMap['Integer'],
        values: ValueModel.fromJson(
            {"unit": "s", "min": 0, "max": 120, "scale": 0, "step": 1})),
    FunctionModel(
        code: 'countdown_alarm',
        type: functionTypesMap['Integer'],
        values: ValueModel.fromJson(
            {"unit": "s", "min": 0, "max": 86400, "scale": 0, "step": 1})),
    FunctionModel(
        code: 'door_control_1',
        type: functionTypesMap['Enum'],
        values: ValueModel.fromJson({
          "range": ['open', 'open']
        })),
    FunctionModel(
        code: 'voice_control_1',
        type: functionTypesMap['Boolean'],
        values: ValueModel.fromJson({})),
    FunctionModel(
        code: 'door_state_1',
        type: functionTypesMap['Enum'],
        values: ValueModel.fromJson({
          "range": ["unclosed_time", "close_time_alarm", "none"]
        })),
  ],
  DeviceType.WaterLeak: [],
  DeviceType.PC: [
    FunctionModel(
        code: 'switch_1',
        type: functionTypesMap['Boolean'],
        values: ValueModel.fromJson({})),
    FunctionModel(
        code: 'countdown_1',
        type: functionTypesMap['Integer'],
        values: ValueModel.fromJson(
            {"unit": "s", "min": 0, "max": 86400, "scale": 0, "step": 1})),
    FunctionModel(
        code: 'tr_timecon',
        type: functionTypesMap['Integer'],
        values: ValueModel.fromJson(
            {"unit": "s", "min": 0, "max": 120, "scale": 0, "step": 1})),
    FunctionModel(
        code: 'countdown_alarm',
        type: functionTypesMap['Integer'],
        values: ValueModel.fromJson(
            {"unit": "s", "min": 0, "max": 86400, "scale": 0, "step": 1})),
    FunctionModel(
        code: 'door_control_1',
        type: functionTypesMap['Enum'],
        values: ValueModel.fromJson({
          "range": ['open', 'open']
        })),
    FunctionModel(
        code: 'voice_control_1',
        type: functionTypesMap['Boolean'],
        values: ValueModel.fromJson({})),
    FunctionModel(
        code: 'door_state_1',
        type: functionTypesMap['Enum'],
        values: ValueModel.fromJson({
          "range": ["unclosed_time", "close_time_alarm", "none"]
        })),
  ],
  DeviceType.FourScene: [
    FunctionModel(
        code: 'scene_1',
        type: functionTypesMap['Boolean'],
        values: ValueModel.fromJson({
          "range": ["scene"]
        })),
    FunctionModel(
        code: 'scene_2',
        type: functionTypesMap['Integer'],
        values: ValueModel.fromJson({
          "range": ["scene"]
        })),
    FunctionModel(
        code: 'scene_3',
        type: functionTypesMap['Integer'],
        values: ValueModel.fromJson({
          "range": ["scene"]
        })),
    FunctionModel(
        code: 'scene_4',
        type: functionTypesMap['Integer'],
        values: ValueModel.fromJson({
          "range": ["scene"]
        })),
    FunctionModel(
        code: 'scene_id_group_id',
        type: functionTypesMap['Raw'],
        values: ValueModel.fromJson({})),
    FunctionModel(
        code: 'switch_backlight',
        type: functionTypesMap['Enum'],
        values: ValueModel.fromJson({})),
  ],
  DeviceType.SixScene: [
    FunctionModel(
        code: 'scene_1',
        type: functionTypesMap['Boolean'],
        values: ValueModel.fromJson({
          "range": ["scene"]
        })),
    FunctionModel(
        code: 'scene_2',
        type: functionTypesMap['Integer'],
        values: ValueModel.fromJson({
          "range": ["scene"]
        })),
    FunctionModel(
        code: 'scene_3',
        type: functionTypesMap['Integer'],
        values: ValueModel.fromJson({
          "range": ["scene"]
        })),
    FunctionModel(
        code: 'scene_4',
        type: functionTypesMap['Integer'],
        values: ValueModel.fromJson({
          "range": ["scene"]
        })),
    FunctionModel(
        code: 'scene_5',
        type: functionTypesMap['Integer'],
        values: ValueModel.fromJson({
          "range": ["scene"]
        })),
    FunctionModel(
        code: 'scene_6',
        type: functionTypesMap['Integer'],
        values: ValueModel.fromJson({
          "range": ["scene"]
        })),
    FunctionModel(
        code: 'scene_id_group_id',
        type: functionTypesMap['Raw'],
        values: ValueModel.fromJson({})),
    FunctionModel(
        code: 'switch_backlight',
        type: functionTypesMap['Enum'],
        values: ValueModel.fromJson({})),
  ],
  DeviceType.SOS: [
    FunctionModel(
        code: 'contact_state',
        type: functionTypesMap['Raw'],
        values: ValueModel.fromJson({})),
    FunctionModel(
        code: 'battery_percentage',
        type: functionTypesMap['Integer'],
        values: ValueModel.fromJson({})),
  ],
};

enum TempModes { hot, cold, wind }

enum FanSpeeds { auto, low, middle, high }

final Map<FanSpeeds, String> fanSpeedsIconMap = {
  FanSpeeds.auto: Assets.assetsIconsFan0,
  FanSpeeds.low: Assets.assetsIconsFan1,
  FanSpeeds.middle: Assets.assetsIconsFan2,
  FanSpeeds.high: Assets.assetsIconsFan3,
};

final Map<TempModes, String> tempModesIconMap = {
  TempModes.hot: Assets.assetsIconsSunnyMode,
  TempModes.cold: Assets.assetsIconsColdMode,
  TempModes.wind: Assets.assetsIconsWindyMode,
};

final Map<String, FanSpeeds> fanSpeedsMap = {
  'auto': FanSpeeds.auto,
  'low': FanSpeeds.low,
  'middle': FanSpeeds.middle,
  'high': FanSpeeds.high,
};

final Map<String, TempModes> tempModesMap = {
  'hot': TempModes.hot,
  'cold': TempModes.cold,
  'wind': TempModes.wind,
};

final Map<FanSpeeds, String> reversedFanSpeedsMap =
    fanSpeedsMap.map((key, value) => MapEntry(value, key));

final Map<TempModes, String> reversedTempModesMap =
    tempModesMap.map((key, value) => MapEntry(value, key));

String getNextFanSpeedKey(FanSpeeds currentFanSpeed) {
  const List<FanSpeeds> speeds = FanSpeeds.values;
  final int currentIndex = speeds.indexOf(currentFanSpeed);

  // Return null if currentFanSpeed is the last value
  if (currentIndex == speeds.length - 1) {
    return reversedFanSpeedsMap[FanSpeeds.auto]!;
  }

  final FanSpeeds nextSpeed = speeds[currentIndex + 1];
  return reversedFanSpeedsMap[nextSpeed]!;
}

K? getNextItem<K, V>(Map<K, V> map, V value) {
  // Iterate over the map entries
  for (var entry in map.entries) {
    // If the current value matches the provided value
    if (entry.value == value) {
      // Get the index of the current entry
      final index = map.keys.toList().indexOf(entry.key);
      // If the index is not the last item, return the next item
      if (index < map.length - 1) {
        return map.keys.elementAt(index + 1);
      }
      // If it's the last item, return null
      return map.keys.elementAt(0);
    }
  }
  // If the value is not found, return null
  return null;
}

enum MemberRole {
  FamilyMember,
  OtherMember,
}

List<Map<String, Object>> members = [
  {
    'name': 'member 1',
    'role': MemberRole.FamilyMember,
  },
  {
    'name': 'member 2',
    'role': MemberRole.OtherMember,
  },
  {
    'name': 'member 3',
    'role': MemberRole.FamilyMember,
  },
  {
    'name': 'member 4',
    'role': MemberRole.OtherMember,
  },
  {
    'name': 'member 5',
    'role': MemberRole.FamilyMember,
  },
  {
    'name': 'member 6',
    'role': MemberRole.OtherMember,
  },
  {
    'name': 'member 7',
    'role': MemberRole.FamilyMember,
  },
  {
    'name': 'member 8',
    'role': MemberRole.OtherMember,
  },
  {
    'name': 'member 9',
    'role': MemberRole.FamilyMember,
  },
  {
    'name': 'member 10',
    'role': MemberRole.OtherMember,
  },
  {
    'name': 'member 11',
    'role': MemberRole.FamilyMember,
  },
  {
    'name': 'member 12',
    'role': MemberRole.OtherMember,
  },
  {
    'name': 'member 13',
    'role': MemberRole.FamilyMember,
  },
  {
    'name': 'member 14',
    'role': MemberRole.OtherMember,
  },
  {
    'name': 'member 15',
    'role': MemberRole.FamilyMember,
  },
  {
    'name': 'member 16',
    'role': MemberRole.OtherMember,
  },
  {
    'name': 'member 17',
    'role': MemberRole.FamilyMember,
  },
  {
    'name': 'member 18',
    'role': MemberRole.OtherMember,
  },
  {
    'name': 'member 19',
    'role': MemberRole.FamilyMember,
  },
  {
    'name': 'member 20',
    'role': MemberRole.OtherMember,
  },
  {
    'name': 'member 21',
    'role': MemberRole.FamilyMember,
  },
  {
    'name': 'member 22',
    'role': MemberRole.OtherMember,
  },
  {
    'name': 'member 23',
    'role': MemberRole.FamilyMember,
  },
];

enum status {
  on,
  off,
  restart,
}

extension StatusExtension on status {
  String get value {
    switch (this) {
      case status.off:
        return "Power Off";
      case status.on:
        return "Power On";
      case status.restart:
        return "Restart Memory";
    }
  }

  static status fromString(String value) {
    switch (value) {
      case "power_off":
        return status.off;
      case "power_on":
        return status.on;
      case "last":
        return status.restart;
      default:
        throw ArgumentError("Invalid access type: $value");
    }
  }
}

enum lightStatus {
  off,
  on_off,
  switchPosition,
}

extension lightStatusExtension on lightStatus {
  String get value {
    switch (this) {
      case lightStatus.off:
        return "Off";
      case lightStatus.switchPosition:
        return "On/Off Status";
      case lightStatus.on_off:
        return "Switch Position";
    }
  }

  static lightStatus fromString(String value) {
    switch (value) {
      case "none":
        return lightStatus.off;
      case "relay":
        return lightStatus.switchPosition;
      case "pos":
        return lightStatus.on_off;
      default:
        throw ArgumentError("Invalid access type: $value");
    }
  }
}
