// enum APPSTATUS {
//   loading,
//   unAuthenticated,
//   authenticated,
//   unverified,
// }

import 'package:hmg_patient_app_new/core/app_state.dart';
import 'package:hmg_patient_app_new/core/dependencies.dart';

enum AuthMethodTypesEnum { sms, whatsApp, fingerPrint, faceID, moreOptions }

enum ViewStateEnum { hide, idle, busy, error, busyLocal, errorLocal }

enum CountryEnum { saudiArabia, unitedArabEmirates }

enum CalenderEnum { gregorian, hijri }

enum SelectionTypeEnum { dropdown, calendar, search }

enum GenderTypeEnum { male, female }

enum MaritalStatusTypeEnum { single, married, divorced, widowed }

enum ChipTypeEnum { success, error, alert, info, warning, lightBg, primaryRed }

enum OTPTypeEnum { sms, whatsapp, faceIDFingerprint }

enum LoginTypeEnum { sms, whatsapp, face, fingerprint }

enum AppEnvironmentTypeEnum { dev, uat, preProd, qa, staging, prod }

enum FamilyFileEnum { active, inactive, blocked, deleted, pending, rejected }

extension CalenderExtension on CalenderEnum {
  int get toInt {
    switch (this) {
      case CalenderEnum.hijri:
        return 1;
      case CalenderEnum.gregorian:
        return 0;
    }
  }

  String get displayName {
    switch (this) {
      case CalenderEnum.hijri:
        return 'Hijri';
      case CalenderEnum.gregorian:
        return 'Gregorian';
    }
  }

  static LoginTypeEnum? fromValue(int value) {
    switch (value) {
      case 1:
        return LoginTypeEnum.sms;
      case 2:
        return LoginTypeEnum.fingerprint;
      case 3:
        return LoginTypeEnum.face;
      case 4:
        return LoginTypeEnum.whatsapp;
      default:
        return null;
    }
  }
}

extension LoginTypeExtension on LoginTypeEnum {
  int get toInt {
    switch (this) {
      case LoginTypeEnum.sms:
        return 1;
      case LoginTypeEnum.whatsapp:
        return 4;
      case LoginTypeEnum.face:
        return 3;
      case LoginTypeEnum.fingerprint:
        return 2;
    }
  }

  String get displayName {
    AppState appState = getIt.get<AppState>();
    bool isArabic = appState.getLanguageID() == 1 ? true : false;
    switch (this) {
      case LoginTypeEnum.sms:
        return isArabic ? 'رسالة نصية' : 'SMS';
      case LoginTypeEnum.whatsapp:
        return isArabic ? 'واتساب' : 'WhatsApp';
      case LoginTypeEnum.face:
        return isArabic ? 'القياسات الحيوية' : 'Biometric'; // Or 'بصمة الوجه'
      case LoginTypeEnum.fingerprint:
        return isArabic ? 'بصمة الإصبع' : 'Fingerprint';
    }
  }

  static LoginTypeEnum? fromValue(int value) {
    switch (value) {
      case 0:
        return LoginTypeEnum.sms;
      case 1:
        return LoginTypeEnum.sms;
      case 2:
        return LoginTypeEnum.fingerprint;
      case 3:
        return LoginTypeEnum.face;
      case 4:
        return LoginTypeEnum.whatsapp;
      default:
        return null;
    }
  }
}

extension OTPTypeEnumExtension on OTPTypeEnum {
  /// Convert enum to int
  int toInt() {
    switch (this) {
      case OTPTypeEnum.sms:
        return 1;
      case OTPTypeEnum.whatsapp:
        return 2;
      case OTPTypeEnum.faceIDFingerprint:
        return 0;
    }
  }

  /// Convert int to enum
  static OTPTypeEnum fromInt(int value) {
    switch (value) {
      case 1:
        return OTPTypeEnum.sms;
      case 2:
        return OTPTypeEnum.whatsapp;
      default:
        throw Exception("Invalid OTPTypeEnum value: $value");
    }
  }
}

extension FamilyFileEnumExtenshion on FamilyFileEnum {
  int get toInt {
    switch (this) {
      case FamilyFileEnum.active:
        return 3;
      case FamilyFileEnum.blocked:
        return 1;
      case FamilyFileEnum.deleted:
        return 0;
      case FamilyFileEnum.pending:
        return 2;
      case FamilyFileEnum.inactive:
        return 6;
      case FamilyFileEnum.rejected:
        return 4;
    }
  }

  String get displayName {
    AppState appState = getIt.get<AppState>();
    bool isArabic = appState.getLanguageID() == 1 ? true : false;
    switch (this) {
      case FamilyFileEnum.active:
        return isArabic ? 'نشط' : 'Active';
      case FamilyFileEnum.inactive:
        return isArabic ? 'غير نشط' : 'Inactive';
      case FamilyFileEnum.blocked:
        return isArabic ? 'محظور' : 'Blocked';
      case FamilyFileEnum.deleted:
        return isArabic ? 'محذوف' : 'Deleted';
      case FamilyFileEnum.pending:
        return isArabic ? 'قيد الانتظار' : 'Pending';
        case FamilyFileEnum.rejected:
        return isArabic ? 'مرفوض' : 'Rejected';
    }
  }

  static FamilyFileEnum? fromValue(int value) {
    switch (value) {
      case 0:
        return FamilyFileEnum.pending;
      case 2:
        return FamilyFileEnum.blocked;
      case 1:
        return FamilyFileEnum.deleted;
      case 3:
        return FamilyFileEnum.active;
      case 4:
        return FamilyFileEnum.inactive;
      default:
        return null;
    }
  }
}

enum ServiceTypeEnum {
  advancePayment, //3
  ancillaryOrder, //3
  appointmentPayment, //2
  covidPayment, //2
  erOnlineCheckIn, //3
  liveCareAppointment //4
}

extension ServiceTypeEnumExt on ServiceTypeEnum {
  String value() {
    switch (this) {
      case ServiceTypeEnum.advancePayment:
        return "Advance Payment";
      case ServiceTypeEnum.ancillaryOrder:
        return "Ancillary Order";
      case ServiceTypeEnum.appointmentPayment:
        return "Appointment Payment";
      case ServiceTypeEnum.covidPayment:
        return "Covid Payment";
      case ServiceTypeEnum.erOnlineCheckIn:
        return "ER Online Check In";
      case ServiceTypeEnum.liveCareAppointment:
        return "LiveCare Appointment";
    }
  }

  int getIdFromServiceEnum() {
    switch (this) {
      case ServiceTypeEnum.advancePayment:
        return 3;
      case ServiceTypeEnum.ancillaryOrder:
        return 3;
      case ServiceTypeEnum.appointmentPayment:
        return 2;
      case ServiceTypeEnum.covidPayment:
        return 2;
      case ServiceTypeEnum.erOnlineCheckIn:
        return 3;
      case ServiceTypeEnum.liveCareAppointment:
        return 4;
    }
  }
}
