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

import 'package:easy_localization/easy_localization.dart';
import 'package:hmg_patient_app_new/core/app_state.dart';
import 'package:hmg_patient_app_new/core/dependencies.dart';
import 'package:hmg_patient_app_new/extensions/string_extensions.dart';
import 'package:hmg_patient_app_new/generated/locale_keys.g.dart';

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

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

enum CountryEnum { saudiArabia, unitedArabEmirates, others }

enum CalenderEnum { gregorian, hijri }

enum SelectionTypeEnum { dropdown, calendar, search, time }

enum GenderTypeEnum { male, female }

extension GenderTypeEnumExtension on GenderTypeEnum {
  String get displayName {
    switch (this) {
      case GenderTypeEnum.male:
        return LocaleKeys.malE.tr();
      case GenderTypeEnum.female:
        return LocaleKeys.femaleGender.tr();
    }
  }
}

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 }

enum BodyView { front, back }

enum HealthCalConEnum { calculator, converter }

enum HealthCalculatorEnum { general, women }

enum HealthCalculatorsTypeEnum {
  bmi,
  calories,
  bmr,
  idealBodyWeight,
  bodyFat,
  crabsProteinFat,
  ovulation,
  deliveryDueDate,
  bloodSugar,
  bloodCholesterol,
  triglycerides
}

extension HealthCalculatorExtenshion on HealthCalculatorsTypeEnum {
  String get displayName {
    AppState appState = getIt.get<AppState>();
    bool isArabic = appState.getLanguageID() == 1 ? true : false;
    switch (this) {
      case HealthCalculatorsTypeEnum.bmi:
        return isArabic ? "مؤشر كتلة الجسم" : "BMI Calculator";
      case HealthCalculatorsTypeEnum.calories:
        return isArabic ? "السعرات الحرارية" : "Calories Calculator";
      case HealthCalculatorsTypeEnum.bmr:
        return isArabic ? "معدل الايض" : "BMR Calculator";
      case HealthCalculatorsTypeEnum.idealBodyWeight:
        return isArabic ? "الوزن المثالي" : "Ideal Body Weight Calculator";
      case HealthCalculatorsTypeEnum.bodyFat:
        return isArabic ? "دهون الجسم" : "Body Fat Calculator";
      case HealthCalculatorsTypeEnum.crabsProteinFat:
        return isArabic ? "حاسبة المغذيات" : "Crabs Protein & Fat Calculator";
      case HealthCalculatorsTypeEnum.ovulation:
        return isArabic ? "فترة الإباضة" : "Ovulation Period";
      case HealthCalculatorsTypeEnum.deliveryDueDate:
        return isArabic ? "تاريخ استحقاق التسليم" : "Delivery Due Date";
      case HealthCalculatorsTypeEnum.bloodSugar:
        return isArabic ? "سكر الدم" : "Blood Sugar";
      case HealthCalculatorsTypeEnum.bloodCholesterol:
        return isArabic ? "كوليسترول الدم" : "Blood Cholesterol";
      case HealthCalculatorsTypeEnum.triglycerides:
        return isArabic ? "الدهون الثلاثية في الدم" : "Triglycerides Fat Blood";
    }
    }

    String get title {
      AppState appState = getIt.get<AppState>();
      bool isArabic = appState.getLanguageID() == 1 ? true : false;
      switch (this) {
        case HealthCalculatorsTypeEnum.crabsProteinFat:
          return isArabic ? "نتيجة المغذيات" : "Nutrient Results";
          case HealthCalculatorsTypeEnum.calories:
          return isArabic ? "سعراتك الحرارية" : "Calories";

          case HealthCalculatorsTypeEnum.calories:
          return isArabic ? "مؤشر كتلة الجسم" : "BMI";
        default:
          return "Your ${this.name.toCamelCase}";
      }
  }

  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 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;
    }
  }
}

// SymptomsChecker

enum PossibleConditionsSeverityEnum { seekMedicalAdvice, monitorOnly, emergency }

enum HealthTrackerTypeEnum { bloodSugar, bloodPressure, weightTracker }

// Severity Enum
enum SeverityEnum { mild, moderate, severe }

extension SeverityEnumExtension on SeverityEnum {
  int get toInt {
    switch (this) {
      case SeverityEnum.mild:
        return 0;
      case SeverityEnum.moderate:
        return 1;
      case SeverityEnum.severe:
        return 2;
    }
  }

  String get displayName {
    AppState appState = getIt.get<AppState>();
    bool isArabic = appState.getLanguageID() == 1 ? true : false;
    switch (this) {
      case SeverityEnum.mild:
        return isArabic ? 'خفيف' : 'Mild';
      case SeverityEnum.moderate:
        return isArabic ? 'متوسط' : 'Moderate';
      case SeverityEnum.severe:
        return isArabic ? 'شديد' : 'Severe';
    }
  }

  static SeverityEnum? fromInt(int value) {
    switch (value) {
      case 0:
        return SeverityEnum.mild;
      case 1:
        return SeverityEnum.moderate;
      case 2:
        return SeverityEnum.severe;
      default:
        return null;
    }
  }
}

// Triage Level Enum
enum TriageLevelEnum { emergencyAmbulance, emergency, consultation24, consultation, selfCare }

extension TriageLevelEnumExtension on TriageLevelEnum {
  int get toInt {
    switch (this) {
      case TriageLevelEnum.emergencyAmbulance:
        return 0;
      case TriageLevelEnum.emergency:
        return 1;
      case TriageLevelEnum.consultation24:
        return 2;
      case TriageLevelEnum.consultation:
        return 3;
      case TriageLevelEnum.selfCare:
        return 4;
    }
  }

  String get displayName {
    AppState appState = getIt.get<AppState>();
    bool isArabic = appState.getLanguageID() == 1 ? true : false;
    switch (this) {
      case TriageLevelEnum.emergencyAmbulance:
        return isArabic ? 'طوارئ - إسعاف' : 'Emergency - Ambulance';
      case TriageLevelEnum.emergency:
        return isArabic ? 'طوارئ' : 'Emergency';
      case TriageLevelEnum.consultation24:
        return isArabic ? 'استشارة خلال 24 ساعة' : 'Consultation within 24 hours';
      case TriageLevelEnum.consultation:
        return isArabic ? 'استشارة' : 'Consultation';
      case TriageLevelEnum.selfCare:
        return isArabic ? 'رعاية ذاتية' : 'Self Care';
    }
  }

  static TriageLevelEnum? fromInt(int value) {
    switch (value) {
      case 0:
        return TriageLevelEnum.emergencyAmbulance;
      case 1:
        return TriageLevelEnum.emergency;
      case 2:
        return TriageLevelEnum.consultation24;
      case 3:
        return TriageLevelEnum.consultation;
      case 4:
        return TriageLevelEnum.selfCare;
      default:
        return null;
    }
  }
}

// Question Type Enum
enum QuestionTypeEnum { single, groupSingle, groupMultiple, duration }

extension QuestionTypeEnumExtension on QuestionTypeEnum {
  int get toInt {
    switch (this) {
      case QuestionTypeEnum.single:
        return 0;
      case QuestionTypeEnum.groupSingle:
        return 1;
      case QuestionTypeEnum.groupMultiple:
        return 2;
      case QuestionTypeEnum.duration:
        return 3;
    }
  }

  String get displayName {
    AppState appState = getIt.get<AppState>();
    bool isArabic = appState.getLanguageID() == 1 ? true : false;
    switch (this) {
      case QuestionTypeEnum.single:
        return isArabic ? 'سؤال واحد' : 'Single';
      case QuestionTypeEnum.groupSingle:
        return isArabic ? 'مجموعة - اختيار واحد' : 'Group Single';
      case QuestionTypeEnum.groupMultiple:
        return isArabic ? 'مجموعة - اختيار متعدد' : 'Group Multiple';
      case QuestionTypeEnum.duration:
        return isArabic ? 'المدة' : 'Duration';
    }
  }

  static QuestionTypeEnum? fromInt(int value) {
    switch (value) {
      case 0:
        return QuestionTypeEnum.single;
      case 1:
        return QuestionTypeEnum.groupSingle;
      case 2:
        return QuestionTypeEnum.groupMultiple;
      case 3:
        return QuestionTypeEnum.duration;
      default:
        return null;
    }
  }
}



