use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

#[cfg(feature = "jsbindings")]
use wasm_bindgen::prelude::*;

#[cfg(feature = "jsbindings")]
use strum::IntoEnumIterator;

#[cfg(feature = "jsbindings")]
use strum_macros::EnumIter;

#[cfg(feature = "pybindings")]
use pyo3::prelude::*;

#[cfg(feature = "jsbindings")]
use tsify_next::Tsify;

#[derive(Deserialize, Serialize, JsonSchema, Default, Clone, PartialEq)]
#[serde(rename_all = "lowercase")]
#[cfg_attr(
    feature = "jsbindings",
    derive(Tsify, EnumIter),
    tsify(into_wasm_abi, from_wasm_abi)
)]
#[cfg_attr(feature = "pybindings", pyclass(eq, eq_int))]
pub enum Country {
    #[default]
    UNKNOWN,
    AFG,
    ALA,
    ALB,
    DZA,
    ASM,
    AND,
    AGO,
    AIA,
    ATA,
    ATG,
    ARG,
    ARM,
    ABW,
    AUS,
    AUT,
    AZE,
    BHS,
    BHR,
    BGD,
    BRB,
    BLR,
    BEL,
    BLZ,
    BEN,
    BMU,
    BTN,
    BOL,
    BES,
    BIH,
    BWA,
    BVT,
    BRA,
    IOT,
    BRN,
    BGR,
    BFA,
    BDI,
    CPV,
    KHM,
    CMR,
    CAN,
    CYM,
    CAF,
    TCD,
    CHL,
    CHN,
    CXR,
    CCK,
    COL,
    COM,
    COG,
    COD,
    COK,
    CRI,
    CIV,
    HRV,
    CUB,
    CUW,
    CYP,
    CZE,
    DNK,
    DJI,
    DMA,
    DOM,
    ECU,
    EGY,
    SLV,
    GNQ,
    ERI,
    EST,
    SWZ,
    ETH,
    FLK,
    FRO,
    FJI,
    FIN,
    FRA,
    GUF,
    PYF,
    ATF,
    GAB,
    GMB,
    GEO,
    DEU,
    GHA,
    GIB,
    GRC,
    GRL,
    GRD,
    GLP,
    GUM,
    GTM,
    GGY,
    GIN,
    GNB,
    GUY,
    HTI,
    HMD,
    VAT,
    HND,
    HKG,
    HUN,
    ISL,
    IND,
    IDN,
    IRN,
    IRQ,
    IRL,
    IMN,
    ISR,
    ITA,
    JAM,
    JPN,
    JEY,
    JOR,
    KAZ,
    KEN,
    KIR,
    PRK,
    KOR,
    KWT,
    KGZ,
    LAO,
    LVA,
    LBN,
    LSO,
    LBR,
    LBY,
    LIE,
    LTU,
    LUX,
    MAC,
    MDG,
    MWI,
    MYS,
    MDV,
    MLI,
    MLT,
    MHL,
    MTQ,
    MRT,
    MUS,
    MYT,
    MEX,
    FSM,
    MDA,
    MCO,
    MNG,
    MNE,
    MSR,
    MAR,
    MOZ,
    MMR,
    NAM,
    NRU,
    NPL,
    NLD,
    NCL,
    NZL,
    NIC,
    NER,
    NGA,
    NIU,
    NFK,
    MKD,
    MNP,
    NOR,
    OMN,
    PAK,
    PLW,
    PSE,
    PAN,
    PNG,
    PRY,
    PER,
    PHL,
    PCN,
    POL,
    PRT,
    PRI,
    QAT,
    REU,
    ROU,
    RUS,
    RWA,
    BLM,
    SHN,
    KNA,
    LCA,
    MAF,
    SPM,
    VCT,
    WSM,
    SMR,
    STP,
    SAU,
    SEN,
    SRB,
    SYC,
    SLE,
    SGP,
    SXM,
    SVK,
    SVN,
    SLB,
    SOM,
    ZAF,
    SGS,
    SSD,
    ESP,
    LKA,
    SDN,
    SUR,
    SJM,
    SWE,
    CHE,
    SYR,
    TWN,
    TJK,
    TZA,
    THA,
    TLS,
    TGO,
    TKL,
    TON,
    TTO,
    TUN,
    TUR,
    TKM,
    TCA,
    TUV,
    UGA,
    UKR,
    ARE,
    GBR,
    USA,
    UMI,
    URY,
    UZB,
    VUT,
    VEN,
    VNM,
    VGB,
    VIR,
    WLF,
    ESH,
    YEM,
    ZMB,
    ZWE,
}

impl From<&str> for Country {
    fn from(value: &str) -> Self {
        match value.len() {
            2 => Country::_from_alpha2(value),
            3 => Country::_from_alpha3(value),
            _ => Country::UNKNOWN,
        }
    }
}

#[cfg(feature = "pybindings")]
#[pymethods]
impl Country {
    #[staticmethod]
    pub fn from_string(value: &str) -> Self {
        Country::from(value)
    }
    #[pyo3(name = "name")]
    pub fn name_py(&self) -> String {
        self.get_name()
    }
}

impl Country {
    fn _from_alpha2(value: &str) -> Self {
        match value.to_uppercase().as_str() {
            "AF" => Country::AFG,
            "AX" => Country::ALA,
            "AL" => Country::ALB,
            "DZ" => Country::DZA,
            "AS" => Country::ASM,
            "AD" => Country::AND,
            "AO" => Country::AGO,
            "AI" => Country::AIA,
            "AQ" => Country::ATA,
            "AG" => Country::ATG,
            "AR" => Country::ARG,
            "AM" => Country::ARM,
            "AW" => Country::ABW,
            "AU" => Country::AUS,
            "AT" => Country::AUT,
            "AZ" => Country::AZE,
            "BS" => Country::BHS,
            "BH" => Country::BHR,
            "BD" => Country::BGD,
            "BB" => Country::BRB,
            "BY" => Country::BLR,
            "BE" => Country::BEL,
            "BZ" => Country::BLZ,
            "BJ" => Country::BEN,
            "BM" => Country::BMU,
            "BT" => Country::BTN,
            "BO" => Country::BOL,
            "BQ" => Country::BES,
            "BA" => Country::BIH,
            "BW" => Country::BWA,
            "BV" => Country::BVT,
            "BR" => Country::BRA,
            "IO" => Country::IOT,
            "BN" => Country::BRN,
            "BG" => Country::BGR,
            "BF" => Country::BFA,
            "BI" => Country::BDI,
            "CV" => Country::CPV,
            "KH" => Country::KHM,
            "CM" => Country::CMR,
            "CA" => Country::CAN,
            "KY" => Country::CYM,
            "CF" => Country::CAF,
            "TD" => Country::TCD,
            "CL" => Country::CHL,
            "CN" => Country::CHN,
            "CX" => Country::CXR,
            "CC" => Country::CCK,
            "CO" => Country::COL,
            "KM" => Country::COM,
            "CG" => Country::COG,
            "CD" => Country::COD,
            "CK" => Country::COK,
            "CR" => Country::CRI,
            "CI" => Country::CIV,
            "HR" => Country::HRV,
            "CU" => Country::CUB,
            "CW" => Country::CUW,
            "CY" => Country::CYP,
            "CZ" => Country::CZE,
            "DK" => Country::DNK,
            "DJ" => Country::DJI,
            "DM" => Country::DMA,
            "DO" => Country::DOM,
            "EC" => Country::ECU,
            "EG" => Country::EGY,
            "SV" => Country::SLV,
            "GQ" => Country::GNQ,
            "ER" => Country::ERI,
            "EE" => Country::EST,
            "SZ" => Country::SWZ,
            "ET" => Country::ETH,
            "FK" => Country::FLK,
            "FO" => Country::FRO,
            "FJ" => Country::FJI,
            "FI" => Country::FIN,
            "FR" => Country::FRA,
            "GF" => Country::GUF,
            "PF" => Country::PYF,
            "TF" => Country::ATF,
            "GA" => Country::GAB,
            "GM" => Country::GMB,
            "GE" => Country::GEO,
            "DE" => Country::DEU,
            "GH" => Country::GHA,
            "GI" => Country::GIB,
            "GR" => Country::GRC,
            "GL" => Country::GRL,
            "GD" => Country::GRD,
            "GP" => Country::GLP,
            "GU" => Country::GUM,
            "GT" => Country::GTM,
            "GG" => Country::GGY,
            "GN" => Country::GIN,
            "GW" => Country::GNB,
            "GY" => Country::GUY,
            "HT" => Country::HTI,
            "HM" => Country::HMD,
            "VA" => Country::VAT,
            "HN" => Country::HND,
            "HK" => Country::HKG,
            "HU" => Country::HUN,
            "IS" => Country::ISL,
            "IN" => Country::IND,
            "ID" => Country::IDN,
            "IR" => Country::IRN,
            "IQ" => Country::IRQ,
            "IE" => Country::IRL,
            "IM" => Country::IMN,
            "IL" => Country::ISR,
            "IT" => Country::ITA,
            "JM" => Country::JAM,
            "JP" => Country::JPN,
            "JE" => Country::JEY,
            "JO" => Country::JOR,
            "KZ" => Country::KAZ,
            "KE" => Country::KEN,
            "KI" => Country::KIR,
            "KP" => Country::PRK,
            "KR" => Country::KOR,
            "KW" => Country::KWT,
            "KG" => Country::KGZ,
            "LA" => Country::LAO,
            "LV" => Country::LVA,
            "LB" => Country::LBN,
            "LS" => Country::LSO,
            "LR" => Country::LBR,
            "LY" => Country::LBY,
            "LI" => Country::LIE,
            "LT" => Country::LTU,
            "LU" => Country::LUX,
            "MO" => Country::MAC,
            "MG" => Country::MDG,
            "MW" => Country::MWI,
            "MY" => Country::MYS,
            "MV" => Country::MDV,
            "ML" => Country::MLI,
            "MT" => Country::MLT,
            "MH" => Country::MHL,
            "MQ" => Country::MTQ,
            "MR" => Country::MRT,
            "MU" => Country::MUS,
            "YT" => Country::MYT,
            "MX" => Country::MEX,
            "FM" => Country::FSM,
            "MD" => Country::MDA,
            "MC" => Country::MCO,
            "MN" => Country::MNG,
            "ME" => Country::MNE,
            "MS" => Country::MSR,
            "MA" => Country::MAR,
            "MZ" => Country::MOZ,
            "MM" => Country::MMR,
            "NA" => Country::NAM,
            "NR" => Country::NRU,
            "NP" => Country::NPL,
            "NL" => Country::NLD,
            "NC" => Country::NCL,
            "NZ" => Country::NZL,
            "NI" => Country::NIC,
            "NE" => Country::NER,
            "NG" => Country::NGA,
            "NU" => Country::NIU,
            "NF" => Country::NFK,
            "MK" => Country::MKD,
            "MP" => Country::MNP,
            "NO" => Country::NOR,
            "OM" => Country::OMN,
            "PK" => Country::PAK,
            "PW" => Country::PLW,
            "PS" => Country::PSE,
            "PA" => Country::PAN,
            "PG" => Country::PNG,
            "PY" => Country::PRY,
            "PE" => Country::PER,
            "PH" => Country::PHL,
            "PN" => Country::PCN,
            "PL" => Country::POL,
            "PT" => Country::PRT,
            "PR" => Country::PRI,
            "QT" => Country::QAT,
            "RE" => Country::REU,
            "RO" => Country::ROU,
            "RU" => Country::RUS,
            "RW" => Country::RWA,
            "BL" => Country::BLM,
            "SH" => Country::SHN,
            "KN" => Country::KNA,
            "LC" => Country::LCA,
            "MF" => Country::MAF,
            "PM" => Country::SPM,
            "VT" => Country::VCT,
            "WS" => Country::WSM,
            "SM" => Country::SMR,
            "ST" => Country::STP,
            "SA" => Country::SAU,
            "SN" => Country::SEN,
            "RS" => Country::SRB,
            "SC" => Country::SYC,
            "SL" => Country::SLE,
            "SG" => Country::SGP,
            "SX" => Country::SXM,
            "SK" => Country::SVK,
            "SI" => Country::SVN,
            "SB" => Country::SLB,
            "SO" => Country::SOM,
            "ZA" => Country::ZAF,
            "GS" => Country::SGS,
            "SS" => Country::SSD,
            "ES" => Country::ESP,
            "LK" => Country::LKA,
            "SD" => Country::SDN,
            "SR" => Country::SUR,
            "SJ" => Country::SJM,
            "SE" => Country::SWE,
            "CH" => Country::CHE,
            "SY" => Country::SYR,
            "TW" => Country::TWN,
            "TJ" => Country::TJK,
            "TZ" => Country::TZA,
            "TH" => Country::THA,
            "TL" => Country::TLS,
            "TG" => Country::TGO,
            "TK" => Country::TKL,
            "TO" => Country::TON,
            "TT" => Country::TTO,
            "TN" => Country::TUN,
            "TR" => Country::TUR,
            "TM" => Country::TKM,
            "TC" => Country::TCA,
            "TV" => Country::TUV,
            "UG" => Country::UGA,
            "UA" => Country::UKR,
            "AE" => Country::ARE,
            "GB" => Country::GBR,
            "US" => Country::USA,
            "UM" => Country::UMI,
            "UY" => Country::URY,
            "UZ" => Country::UZB,
            "VU" => Country::VUT,
            "VE" => Country::VEN,
            "VN" => Country::VNM,
            "VB" => Country::VGB,
            "VI" => Country::VIR,
            "WF" => Country::WLF,
            "EH" => Country::ESH,
            "YE" => Country::YEM,
            "ZM" => Country::ZMB,
            "ZW" => Country::ZWE,
            _ => Country::UNKNOWN,
        }
    }
    fn _from_alpha3(value: &str) -> Self {
        match value.to_uppercase().as_str() {
            "AFG" => Country::AFG,
            "ALA" => Country::ALA,
            "ALB" => Country::ALB,
            "DZA" => Country::DZA,
            "ASM" => Country::ASM,
            "AND" => Country::AND,
            "AGO" => Country::AGO,
            "AIA" => Country::AIA,
            "ATA" => Country::ATA,
            "ATG" => Country::ATG,
            "ARG" => Country::ARG,
            "ARM" => Country::ARM,
            "ABW" => Country::ABW,
            "AUS" => Country::AUS,
            "AUT" => Country::AUT,
            "AZE" => Country::AZE,
            "BHS" => Country::BHS,
            "BHR" => Country::BHR,
            "BGD" => Country::BGD,
            "BRB" => Country::BRB,
            "BLR" => Country::BLR,
            "BEL" => Country::BEL,
            "BLZ" => Country::BLZ,
            "BEN" => Country::BEN,
            "BMU" => Country::BMU,
            "BTN" => Country::BTN,
            "BOL" => Country::BOL,
            "BES" => Country::BES,
            "BIH" => Country::BIH,
            "BWA" => Country::BWA,
            "BVT" => Country::BVT,
            "BRA" => Country::BRA,
            "IOT" => Country::IOT,
            "BRN" => Country::BRN,
            "BGR" => Country::BGR,
            "BFA" => Country::BFA,
            "BDI" => Country::BDI,
            "CPV" => Country::CPV,
            "KHM" => Country::KHM,
            "CMR" => Country::CMR,
            "CAN" => Country::CAN,
            "CYM" => Country::CYM,
            "CAF" => Country::CAF,
            "TCD" => Country::TCD,
            "CHL" => Country::CHL,
            "CHN" => Country::CHN,
            "CXR" => Country::CXR,
            "CCK" => Country::CCK,
            "COL" => Country::COL,
            "COM" => Country::COM,
            "COG" => Country::COG,
            "COD" => Country::COD,
            "COK" => Country::COK,
            "CRI" => Country::CRI,
            "CIV" => Country::CIV,
            "HRV" => Country::HRV,
            "CUB" => Country::CUB,
            "CUW" => Country::CUW,
            "CYP" => Country::CYP,
            "CZE" => Country::CZE,
            "DNK" => Country::DNK,
            "DJI" => Country::DJI,
            "DMA" => Country::DMA,
            "DOM" => Country::DOM,
            "ECU" => Country::ECU,
            "EGY" => Country::EGY,
            "SLV" => Country::SLV,
            "GNQ" => Country::GNQ,
            "ERI" => Country::ERI,
            "EST" => Country::EST,
            "SWZ" => Country::SWZ,
            "ETH" => Country::ETH,
            "FLK" => Country::FLK,
            "FRO" => Country::FRO,
            "FJI" => Country::FJI,
            "FIN" => Country::FIN,
            "FRA" => Country::FRA,
            "GUF" => Country::GUF,
            "PYF" => Country::PYF,
            "ATF" => Country::ATF,
            "GAB" => Country::GAB,
            "GMB" => Country::GMB,
            "GEO" => Country::GEO,
            "DEU" => Country::DEU,
            "GHA" => Country::GHA,
            "GIB" => Country::GIB,
            "GRC" => Country::GRC,
            "GRL" => Country::GRL,
            "GRD" => Country::GRD,
            "GLP" => Country::GLP,
            "GUM" => Country::GUM,
            "GTM" => Country::GTM,
            "GGY" => Country::GGY,
            "GIN" => Country::GIN,
            "GNB" => Country::GNB,
            "GUY" => Country::GUY,
            "HTI" => Country::HTI,
            "HMD" => Country::HMD,
            "VAT" => Country::VAT,
            "HND" => Country::HND,
            "HKG" => Country::HKG,
            "HUN" => Country::HUN,
            "ISL" => Country::ISL,
            "IND" => Country::IND,
            "IDN" => Country::IDN,
            "IRN" => Country::IRN,
            "IRQ" => Country::IRQ,
            "IRL" => Country::IRL,
            "IMN" => Country::IMN,
            "ISR" => Country::ISR,
            "ITA" => Country::ITA,
            "JAM" => Country::JAM,
            "JPN" => Country::JPN,
            "JEY" => Country::JEY,
            "JOR" => Country::JOR,
            "KAZ" => Country::KAZ,
            "KEN" => Country::KEN,
            "KIR" => Country::KIR,
            "PRK" => Country::PRK,
            "KOR" => Country::KOR,
            "KWT" => Country::KWT,
            "KGZ" => Country::KGZ,
            "LAO" => Country::LAO,
            "LVA" => Country::LVA,
            "LBN" => Country::LBN,
            "LSO" => Country::LSO,
            "LBR" => Country::LBR,
            "LBY" => Country::LBY,
            "LIE" => Country::LIE,
            "LTU" => Country::LTU,
            "LUX" => Country::LUX,
            "MAC" => Country::MAC,
            "MDG" => Country::MDG,
            "MWI" => Country::MWI,
            "MYS" => Country::MYS,
            "MDV" => Country::MDV,
            "MLI" => Country::MLI,
            "MLT" => Country::MLT,
            "MHL" => Country::MHL,
            "MTQ" => Country::MTQ,
            "MRT" => Country::MRT,
            "MUS" => Country::MUS,
            "MYT" => Country::MYT,
            "MEX" => Country::MEX,
            "FSM" => Country::FSM,
            "MDA" => Country::MDA,
            "MCO" => Country::MCO,
            "MNG" => Country::MNG,
            "MNE" => Country::MNE,
            "MSR" => Country::MSR,
            "MAR" => Country::MAR,
            "MOZ" => Country::MOZ,
            "MMR" => Country::MMR,
            "NAM" => Country::NAM,
            "NRU" => Country::NRU,
            "NPL" => Country::NPL,
            "NLD" => Country::NLD,
            "NCL" => Country::NCL,
            "NZL" => Country::NZL,
            "NIC" => Country::NIC,
            "NER" => Country::NER,
            "NGA" => Country::NGA,
            "NIU" => Country::NIU,
            "NFK" => Country::NFK,
            "MKD" => Country::MKD,
            "MNP" => Country::MNP,
            "NOR" => Country::NOR,
            "OMN" => Country::OMN,
            "PAK" => Country::PAK,
            "PLW" => Country::PLW,
            "PSE" => Country::PSE,
            "PAN" => Country::PAN,
            "PNG" => Country::PNG,
            "PRY" => Country::PRY,
            "PER" => Country::PER,
            "PHL" => Country::PHL,
            "PCN" => Country::PCN,
            "POL" => Country::POL,
            "PRT" => Country::PRT,
            "PRI" => Country::PRI,
            "QAT" => Country::QAT,
            "REU" => Country::REU,
            "ROU" => Country::ROU,
            "RUS" => Country::RUS,
            "RWA" => Country::RWA,
            "BLM" => Country::BLM,
            "SHN" => Country::SHN,
            "KNA" => Country::KNA,
            "LCA" => Country::LCA,
            "MAF" => Country::MAF,
            "SPM" => Country::SPM,
            "VCT" => Country::VCT,
            "WSM" => Country::WSM,
            "SMR" => Country::SMR,
            "STP" => Country::STP,
            "SAU" => Country::SAU,
            "SEN" => Country::SEN,
            "SRB" => Country::SRB,
            "SYC" => Country::SYC,
            "SLE" => Country::SLE,
            "SGP" => Country::SGP,
            "SXM" => Country::SXM,
            "SVK" => Country::SVK,
            "SVN" => Country::SVN,
            "SLB" => Country::SLB,
            "SOM" => Country::SOM,
            "ZAF" => Country::ZAF,
            "SGS" => Country::SGS,
            "SSD" => Country::SSD,
            "ESP" => Country::ESP,
            "LKA" => Country::LKA,
            "SDN" => Country::SDN,
            "SUR" => Country::SUR,
            "SJM" => Country::SJM,
            "SWE" => Country::SWE,
            "CHE" => Country::CHE,
            "SYR" => Country::SYR,
            "TWN" => Country::TWN,
            "TJK" => Country::TJK,
            "TZA" => Country::TZA,
            "THA" => Country::THA,
            "TLS" => Country::TLS,
            "TGO" => Country::TGO,
            "TKL" => Country::TKL,
            "TON" => Country::TON,
            "TTO" => Country::TTO,
            "TUN" => Country::TUN,
            "TUR" => Country::TUR,
            "TKM" => Country::TKM,
            "TCA" => Country::TCA,
            "TUV" => Country::TUV,
            "UGA" => Country::UGA,
            "UKR" => Country::UKR,
            "ARE" => Country::ARE,
            "GBR" => Country::GBR,
            "USA" => Country::USA,
            "UMI" => Country::UMI,
            "URY" => Country::URY,
            "UZB" => Country::UZB,
            "VUT" => Country::VUT,
            "VEN" => Country::VEN,
            "VNM" => Country::VNM,
            "VGB" => Country::VGB,
            "VIR" => Country::VIR,
            "WLF" => Country::WLF,
            "ESH" => Country::ESH,
            "YEM" => Country::YEM,
            "ZMB" => Country::ZMB,
            "ZWE" => Country::ZWE,
            _ => Country::UNKNOWN,
        }
    }
    #[allow(dead_code)]
    fn get_name(&self) -> String {
        match self {
            Country::UNKNOWN => "Unknown",
            Country::AFG => "Afghanistan",
            Country::ALA => "Åland Islands",
            Country::ALB => "Albania",
            Country::DZA => "Algeria",
            Country::ASM => "American Samoa",
            Country::AND => "Andorra",
            Country::AGO => "Angola",
            Country::AIA => "Anguilla",
            Country::ATA => "Antarctica",
            Country::ATG => "Antigua and Barbuda",
            Country::ARG => "Argentina",
            Country::ARM => "Armenia",
            Country::ABW => "Aruba",
            Country::AUS => "Australia",
            Country::AUT => "Austria",
            Country::AZE => "Azerbaijan",
            Country::BHS => "Bahamas",
            Country::BHR => "Bahrain",
            Country::BGD => "Bangladesh",
            Country::BRB => "Barbados",
            Country::BLR => "Belarus",
            Country::BEL => "Belgium",
            Country::BLZ => "Belize",
            Country::BEN => "Benin",
            Country::BMU => "Bermuda",
            Country::BTN => "Bhutan",
            Country::BOL => "Bolivia, Plurinational State of",
            Country::BES => "Bonaire, Sint Eustatius and Saba",
            Country::BIH => "Bosnia and Herzegovina",
            Country::BWA => "Botswana",
            Country::BVT => "Bouvet Island",
            Country::BRA => "Brazil",
            Country::IOT => "British Indian Ocean Territory",
            Country::BRN => "Brunei Darussalam",
            Country::BGR => "Bulgaria",
            Country::BFA => "Burkina Faso",
            Country::BDI => "Burundi",
            Country::CPV => "Cabo Verde",
            Country::KHM => "Cambodia",
            Country::CMR => "Cameroon",
            Country::CAN => "Canada",
            Country::CYM => "Cayman Islands",
            Country::CAF => "Central African Republic",
            Country::TCD => "Chad",
            Country::CHL => "Chile",
            Country::CHN => "China",
            Country::CXR => "Christmas Island",
            Country::CCK => "Cocos (Keeling) Islands",
            Country::COL => "Colombia",
            Country::COM => "Comoros",
            Country::COG => "Congo",
            Country::COD => "Congo, The Democratic Republic of the",
            Country::COK => "Cook Islands",
            Country::CRI => "Costa Rica",
            Country::CIV => "Côte d'Ivoire",
            Country::HRV => "Croatia",
            Country::CUB => "Cuba",
            Country::CUW => "Curaçao",
            Country::CYP => "Cyprus",
            Country::CZE => "Czechia",
            Country::DNK => "Denmark",
            Country::DJI => "Djibouti",
            Country::DMA => "Dominica",
            Country::DOM => "Dominican Republic",
            Country::ECU => "Ecuador",
            Country::EGY => "Egypt",
            Country::SLV => "El Salvador",
            Country::GNQ => "Equatorial Guinea",
            Country::ERI => "Eritrea",
            Country::EST => "Estonia",
            Country::SWZ => "Eswatini",
            Country::ETH => "Ethiopia",
            Country::FLK => "Falkland Islands (Malvinas)",
            Country::FRO => "Faroe Islands",
            Country::FJI => "Fiji",
            Country::FIN => "Finland",
            Country::FRA => "France",
            Country::GUF => "French Guiana",
            Country::PYF => "French Polynesia",
            Country::ATF => "French Southern Territories",
            Country::GAB => "Gabon",
            Country::GMB => "Gambia",
            Country::GEO => "Georgia",
            Country::DEU => "Germany",
            Country::GHA => "Ghana",
            Country::GIB => "Gibraltar",
            Country::GRC => "Greece",
            Country::GRL => "Greenland",
            Country::GRD => "Grenada",
            Country::GLP => "Guadeloupe",
            Country::GUM => "Guam",
            Country::GTM => "Guatemala",
            Country::GGY => "Guernsey",
            Country::GIN => "Guinea",
            Country::GNB => "Guinea-Bissau",
            Country::GUY => "Guyana",
            Country::HTI => "Haiti",
            Country::HMD => "Heard Island and McDonald Islands",
            Country::VAT => "Holy See",
            Country::HND => "Honduras",
            Country::HKG => "Hong Kong",
            Country::HUN => "Hungary",
            Country::ISL => "Iceland",
            Country::IND => "India",
            Country::IDN => "Indonesia",
            Country::IRN => "Iran, Islamic Republic of",
            Country::IRQ => "Iraq",
            Country::IRL => "Ireland",
            Country::IMN => "Isle of Man",
            Country::ISR => "Israel",
            Country::ITA => "Italy",
            Country::JAM => "Jamaica",
            Country::JPN => "Japan",
            Country::JEY => "Jersey",
            Country::JOR => "Jordan",
            Country::KAZ => "Kazakhstan",
            Country::KEN => "Kenya",
            Country::KIR => "Kiribati",
            Country::PRK => "Korea, Democratic People's Republic of",
            Country::KOR => "Korea, Republic of",
            Country::KWT => "Kuwait",
            Country::KGZ => "Kyrgyzstan",
            Country::LAO => "Lao People's Democratic Republic",
            Country::LVA => "Latvia",
            Country::LBN => "Lebanon",
            Country::LSO => "Lesotho",
            Country::LBR => "Liberia",
            Country::LBY => "Libya",
            Country::LIE => "Liechtenstein",
            Country::LTU => "Lithuania",
            Country::LUX => "Luxembourg",
            Country::MAC => "Macao",
            Country::MDG => "Madagascar",
            Country::MWI => "Malawi",
            Country::MYS => "Malaysia",
            Country::MDV => "Maldives",
            Country::MLI => "Mali",
            Country::MLT => "Malta",
            Country::MHL => "Marshall Islands",
            Country::MTQ => "Martinique",
            Country::MRT => "Mauritania",
            Country::MUS => "Mauritius",
            Country::MYT => "Mayotte",
            Country::MEX => "Mexico",
            Country::FSM => "Micronesia, Federated States of",
            Country::MDA => "Moldova, Republic of",
            Country::MCO => "Monaco",
            Country::MNG => "Mongolia",
            Country::MNE => "Montenegro",
            Country::MSR => "Montserrat",
            Country::MAR => "Morocco",
            Country::MOZ => "Mozambique",
            Country::MMR => "Myanmar",
            Country::NAM => "Namibia",
            Country::NRU => "Nauru",
            Country::NPL => "Nepal",
            Country::NLD => "Netherlands",
            Country::NCL => "New Caledonia",
            Country::NZL => "New Zealand",
            Country::NIC => "Nicaragua",
            Country::NER => "Niger",
            Country::NGA => "Nigeria",
            Country::NIU => "Niue",
            Country::NFK => "Norfolk Island",
            Country::MKD => "North Macedonia",
            Country::MNP => "Northern Mariana Islands",
            Country::NOR => "Norway",
            Country::OMN => "Oman",
            Country::PAK => "Pakistan",
            Country::PLW => "Palau",
            Country::PSE => "Palestine, State of",
            Country::PAN => "Panama",
            Country::PNG => "Papua New Guinea",
            Country::PRY => "Paraguay",
            Country::PER => "Peru",
            Country::PHL => "Philippines",
            Country::PCN => "Pitcairn",
            Country::POL => "Poland",
            Country::PRT => "Portugal",
            Country::PRI => "Puerto Rico",
            Country::QAT => "Qatar",
            Country::REU => "Réunion",
            Country::ROU => "Romania",
            Country::RUS => "Russian Federation",
            Country::RWA => "Rwanda",
            Country::BLM => "Saint Barthélemy",
            Country::SHN => "Saint Helena, Ascension and Tristan da Cunha",
            Country::KNA => "Saint Kitts and Nevis",
            Country::LCA => "Saint Lucia",
            Country::MAF => "Saint Martin (French part)",
            Country::SPM => "Saint Pierre and Miquelon",
            Country::VCT => "Saint Vincent and the Grenadines",
            Country::WSM => "Samoa",
            Country::SMR => "San Marino",
            Country::STP => "Sao Tome and Principe",
            Country::SAU => "Saudi Arabia",
            Country::SEN => "Senegal",
            Country::SRB => "Serbia",
            Country::SYC => "Seychelles",
            Country::SLE => "Sierra Leone",
            Country::SGP => "Singapore",
            Country::SXM => "Sint Maarten (Dutch part)",
            Country::SVK => "Slovakia",
            Country::SVN => "Slovenia",
            Country::SLB => "Solomon Islands",
            Country::SOM => "Somalia",
            Country::ZAF => "South Africa",
            Country::SGS => "South Georgia and the South Sandwich Islands",
            Country::SSD => "South Sudan",
            Country::ESP => "Spain",
            Country::LKA => "Sri Lanka",
            Country::SDN => "Sudan",
            Country::SUR => "Suriname",
            Country::SJM => "Svalbard and Jan Mayen",
            Country::SWE => "Sweden",
            Country::CHE => "Switzerland",
            Country::SYR => "Syrian Arab Republic",
            Country::TWN => "Taiwan, Province of China",
            Country::TJK => "Tajikistan",
            Country::TZA => "Tanzania, United Republic of",
            Country::THA => "Thailand",
            Country::TLS => "Timor-Leste",
            Country::TGO => "Togo",
            Country::TKL => "Tokelau",
            Country::TON => "Tonga",
            Country::TTO => "Trinidad and Tobago",
            Country::TUN => "Tunisia",
            Country::TUR => "Türkiye",
            Country::TKM => "Turkmenistan",
            Country::TCA => "Turks and Caicos Islands",
            Country::TUV => "Tuvalu",
            Country::UGA => "Uganda",
            Country::UKR => "Ukraine",
            Country::ARE => "United Arab Emirates",
            Country::GBR => "United Kingdom",
            Country::USA => "United States of America",
            Country::UMI => "United States Minor Outlying Islands",
            Country::URY => "Uruguay",
            Country::UZB => "Uzbekistan",
            Country::VUT => "Vanuatu",
            Country::VEN => "Venezuela, Bolivarian Republic of",
            Country::VNM => "Viet Nam",
            Country::VGB => "Virgin Islands, British",
            Country::VIR => "Virgin Islands, U.S.",
            Country::WLF => "Wallis and Futuna",
            Country::ESH => "Western Sahara",
            Country::YEM => "Yemen",
            Country::ZMB => "Zambia",
            Country::ZWE => "Zimbabwe",
        }
        .to_string()
    }
}

#[cfg(feature = "jsbindings")]
#[wasm_bindgen]
pub fn countries() -> Vec<Country> {
    Country::iter().collect()
}

#[cfg(feature = "jsbindings")]
#[wasm_bindgen(js_name = getCountryName)]
pub fn get_country_name(value: &str) -> String {
    let country = Country::from(value);
    country.get_name()
}
