import { Enum, Id, Optional, text } from '@thisisagile/easy'; export class Country extends Enum { static readonly AF = new Country('Afghanistan', 'AF'); static readonly AX = new Country('Åland Islands', 'AX'); static readonly AL = new Country('Albania', 'AL'); static readonly DZ = new Country('Algeria', 'DZ'); static readonly AS = new Country('American Samoa', 'AS'); static readonly AD = new Country('Andorra', 'AD'); static readonly AO = new Country('Angola', 'AO'); static readonly AI = new Country('Anguilla', 'AI'); static readonly AQ = new Country('Antarctica', 'AQ'); static readonly AG = new Country('Antigua & Barbuda', 'AG'); static readonly AR = new Country('Argentina', 'AR'); static readonly AM = new Country('Armenia', 'AM'); static readonly AW = new Country('Aruba', 'AW'); static readonly AU = new Country('Australia', 'AU'); static readonly AT = new Country('Austria', 'AT'); static readonly AZ = new Country('Azerbaijan', 'AZ'); static readonly BS = new Country('Bahamas', 'BS'); static readonly BH = new Country('Bahrain', 'BH'); static readonly BD = new Country('Bangladesh', 'BD'); static readonly BB = new Country('Barbados', 'BB'); static readonly BY = new Country('Belarus', 'BY'); static readonly BE = new Country('Belgium', 'BE'); static readonly BZ = new Country('Belize', 'BZ'); static readonly BJ = new Country('Benin', 'BJ'); static readonly BM = new Country('Bermuda', 'BM'); static readonly BT = new Country('Bhutan', 'BT'); static readonly BO = new Country('Bolivia', 'BO'); static readonly BA = new Country('Bosnia & Herzegovina', 'BA'); static readonly BW = new Country('Botswana', 'BW'); static readonly BV = new Country('Bouvet Island', 'BV'); static readonly BR = new Country('Brazil', 'BR'); static readonly IO = new Country('British Indian Ocean Territory', 'IO'); static readonly VG = new Country('British Virgin Islands', 'VG'); static readonly BN = new Country('Brunei', 'BN'); static readonly BG = new Country('Bulgaria', 'BG'); static readonly BF = new Country('Burkina Faso', 'BF'); static readonly BI = new Country('Burundi', 'BI'); static readonly KH = new Country('Cambodia', 'KH'); static readonly CM = new Country('Cameroon', 'CM'); static readonly CA = new Country('Canada', 'CA'); static readonly CV = new Country('Cape Verde', 'CV'); static readonly BQ = new Country('Caribbean Netherlands', 'BQ'); static readonly KY = new Country('Cayman Islands', 'KY'); static readonly CF = new Country('Central African Republic', 'CF'); static readonly TD = new Country('Chad', 'TD'); static readonly CL = new Country('Chile', 'CL'); static readonly CN = new Country('China', 'CN'); static readonly CX = new Country('Christmas Island', 'CX'); static readonly CC = new Country('Cocos (Keeling) Islands', 'CC'); static readonly CO = new Country('Colombia', 'CO'); static readonly KM = new Country('Comoros', 'KM'); static readonly CG = new Country('Congo - Brazzaville', 'CG'); static readonly CD = new Country('Congo - Kinshasa', 'CD'); static readonly CK = new Country('Cook Islands', 'CK'); static readonly CR = new Country('Costa Rica', 'CR'); static readonly CI = new Country('Côte d’Ivoire', 'CI'); static readonly HR = new Country('Croatia', 'HR'); static readonly CU = new Country('Cuba', 'CU'); static readonly CW = new Country('Curaçao', 'CW'); static readonly CY = new Country('Cyprus', 'CY'); static readonly CZ = new Country('Czechia', 'CZ'); static readonly DK = new Country('Denmark', 'DK'); static readonly DJ = new Country('Djibouti', 'DJ'); static readonly DM = new Country('Dominica', 'DM'); static readonly DO = new Country('Dominican Republic', 'DO'); static readonly EC = new Country('Ecuador', 'EC'); static readonly EG = new Country('Egypt', 'EG'); static readonly SV = new Country('El Salvador', 'SV'); static readonly GQ = new Country('Equatorial Guinea', 'GQ'); static readonly ER = new Country('Eritrea', 'ER'); static readonly EE = new Country('Estonia', 'EE'); static readonly SZ = new Country('Eswatini', 'SZ'); static readonly ET = new Country('Ethiopia', 'ET'); static readonly FK = new Country('Falkland Islands', 'FK'); static readonly FO = new Country('Faroe Islands', 'FO'); static readonly FJ = new Country('Fiji', 'FJ'); static readonly FI = new Country('Finland', 'FI'); static readonly FR = new Country('France', 'FR'); static readonly GF = new Country('French Guiana', 'GF'); static readonly PF = new Country('French Polynesia', 'PF'); static readonly TF = new Country('French Southern Territories', 'TF'); static readonly GA = new Country('Gabon', 'GA'); static readonly GM = new Country('Gambia', 'GM'); static readonly GE = new Country('Georgia', 'GE'); static readonly DE = new Country('Germany', 'DE'); static readonly GH = new Country('Ghana', 'GH'); static readonly GI = new Country('Gibraltar', 'GI'); static readonly GR = new Country('Greece', 'GR'); static readonly GL = new Country('Greenland', 'GL'); static readonly GD = new Country('Grenada', 'GD'); static readonly GP = new Country('Guadeloupe', 'GP'); static readonly GU = new Country('Guam', 'GU'); static readonly GT = new Country('Guatemala', 'GT'); static readonly GG = new Country('Guernsey', 'GG'); static readonly GN = new Country('Guinea', 'GN'); static readonly GW = new Country('Guinea-Bissau', 'GW'); static readonly GY = new Country('Guyana', 'GY'); static readonly HT = new Country('Haiti', 'HT'); static readonly HM = new Country('Heard & McDonald Islands', 'HM'); static readonly HN = new Country('Honduras', 'HN'); static readonly HK = new Country('Hong Kong SAR China', 'HK'); static readonly HU = new Country('Hungary', 'HU'); static readonly IS = new Country('Iceland', 'IS'); static readonly IN = new Country('India', 'IN'); static readonly ID = new Country('Indonesia', 'ID'); static readonly IR = new Country('Iran', 'IR'); static readonly IQ = new Country('Iraq', 'IQ'); static readonly IE = new Country('Ireland', 'IE'); static readonly IM = new Country('Isle of Man', 'IM'); static readonly IL = new Country('Israel', 'IL'); static readonly IT = new Country('Italy', 'IT'); static readonly JM = new Country('Jamaica', 'JM'); static readonly JP = new Country('Japan', 'JP'); static readonly JE = new Country('Jersey', 'JE'); static readonly JO = new Country('Jordan', 'JO'); static readonly KZ = new Country('Kazakhstan', 'KZ'); static readonly KE = new Country('Kenya', 'KE'); static readonly KI = new Country('Kiribati', 'KI'); static readonly KW = new Country('Kuwait', 'KW'); static readonly KG = new Country('Kyrgyzstan', 'KG'); static readonly LA = new Country('Laos', 'LA'); static readonly LV = new Country('Latvia', 'LV'); static readonly LB = new Country('Lebanon', 'LB'); static readonly LS = new Country('Lesotho', 'LS'); static readonly LR = new Country('Liberia', 'LR'); static readonly LY = new Country('Libya', 'LY'); static readonly LI = new Country('Liechtenstein', 'LI'); static readonly LT = new Country('Lithuania', 'LT'); static readonly LU = new Country('Luxembourg', 'LU'); static readonly MO = new Country('Macao SAR China', 'MO'); static readonly MG = new Country('Madagascar', 'MG'); static readonly MW = new Country('Malawi', 'MW'); static readonly MY = new Country('Malaysia', 'MY'); static readonly MV = new Country('Maldives', 'MV'); static readonly ML = new Country('Mali', 'ML'); static readonly MT = new Country('Malta', 'MT'); static readonly MH = new Country('Marshall Islands', 'MH'); static readonly MQ = new Country('Martinique', 'MQ'); static readonly MR = new Country('Mauritania', 'MR'); static readonly MU = new Country('Mauritius', 'MU'); static readonly YT = new Country('Mayotte', 'YT'); static readonly MX = new Country('Mexico', 'MX'); static readonly FM = new Country('Micronesia', 'FM'); static readonly MD = new Country('Moldova', 'MD'); static readonly MC = new Country('Monaco', 'MC'); static readonly MN = new Country('Mongolia', 'MN'); static readonly ME = new Country('Montenegro', 'ME'); static readonly MS = new Country('Montserrat', 'MS'); static readonly MA = new Country('Morocco', 'MA'); static readonly MZ = new Country('Mozambique', 'MZ'); static readonly MM = new Country('Myanmar (Burma)', 'MM'); static readonly NA = new Country('Namibia', 'NA'); static readonly NR = new Country('Nauru', 'NR'); static readonly NP = new Country('Nepal', 'NP'); static readonly NL = new Country('Netherlands', 'NL'); static readonly NC = new Country('New Caledonia', 'NC'); static readonly NZ = new Country('New Zealand', 'NZ'); static readonly NI = new Country('Nicaragua', 'NI'); static readonly NE = new Country('Niger', 'NE'); static readonly NG = new Country('Nigeria', 'NG'); static readonly NU = new Country('Niue', 'NU'); static readonly NF = new Country('Norfolk Island', 'NF'); static readonly KP = new Country('North Korea', 'KP'); static readonly MK = new Country('North Macedonia', 'MK'); static readonly MP = new Country('Northern Mariana Islands', 'MP'); static readonly NO = new Country('Norway', 'NO'); static readonly OM = new Country('Oman', 'OM'); static readonly PK = new Country('Pakistan', 'PK'); static readonly PW = new Country('Palau', 'PW'); static readonly PS = new Country('Palestinian Territories', 'PS'); static readonly PA = new Country('Panama', 'PA'); static readonly PG = new Country('Papua New Guinea', 'PG'); static readonly PY = new Country('Paraguay', 'PY'); static readonly PE = new Country('Peru', 'PE'); static readonly PH = new Country('Philippines', 'PH'); static readonly PN = new Country('Pitcairn Islands', 'PN'); static readonly PL = new Country('Poland', 'PL'); static readonly PT = new Country('Portugal', 'PT'); static readonly PR = new Country('Puerto Rico', 'PR'); static readonly QA = new Country('Qatar', 'QA'); static readonly RE = new Country('Réunion', 'RE'); static readonly RO = new Country('Romania', 'RO'); static readonly RU = new Country('Russia', 'RU'); static readonly RW = new Country('Rwanda', 'RW'); static readonly WS = new Country('Samoa', 'WS'); static readonly SM = new Country('San Marino', 'SM'); static readonly ST = new Country('São Tomé & Príncipe', 'ST'); static readonly SA = new Country('Saudi Arabia', 'SA'); static readonly SN = new Country('Senegal', 'SN'); static readonly RS = new Country('Serbia', 'RS'); static readonly SC = new Country('Seychelles', 'SC'); static readonly SL = new Country('Sierra Leone', 'SL'); static readonly SG = new Country('Singapore', 'SG'); static readonly SX = new Country('Sint Maarten', 'SX'); static readonly SK = new Country('Slovakia', 'SK'); static readonly SI = new Country('Slovenia', 'SI'); static readonly SB = new Country('Solomon Islands', 'SB'); static readonly SO = new Country('Somalia', 'SO'); static readonly ZA = new Country('South Africa', 'ZA'); static readonly GS = new Country('South Georgia & South Sandwich Islands', 'GS'); static readonly KR = new Country('South Korea', 'KR'); static readonly SS = new Country('South Sudan', 'SS'); static readonly ES = new Country('Spain', 'ES'); static readonly LK = new Country('Sri Lanka', 'LK'); static readonly BL = new Country('St. Barthélemy', 'BL'); static readonly SH = new Country('St. Helena', 'SH'); static readonly KN = new Country('St. Kitts & Nevis', 'KN'); static readonly LC = new Country('St. Lucia', 'LC'); static readonly MF = new Country('St. Martin', 'MF'); static readonly PM = new Country('St. Pierre & Miquelon', 'PM'); static readonly VC = new Country('St. Vincent & Grenadines', 'VC'); static readonly SD = new Country('Sudan', 'SD'); static readonly SR = new Country('Suriname', 'SR'); static readonly SJ = new Country('Svalbard & Jan Mayen', 'SJ'); static readonly SE = new Country('Sweden', 'SE'); static readonly CH = new Country('Switzerland', 'CH'); static readonly SY = new Country('Syria', 'SY'); static readonly TW = new Country('Taiwan', 'TW'); static readonly TJ = new Country('Tajikistan', 'TJ'); static readonly TZ = new Country('Tanzania', 'TZ'); static readonly TH = new Country('Thailand', 'TH'); static readonly TL = new Country('Timor-Leste', 'TL'); static readonly TG = new Country('Togo', 'TG'); static readonly TK = new Country('Tokelau', 'TK'); static readonly TO = new Country('Tonga', 'TO'); static readonly TT = new Country('Trinidad & Tobago', 'TT'); static readonly TN = new Country('Tunisia', 'TN'); static readonly TR = new Country('Turkey', 'TR'); static readonly TM = new Country('Turkmenistan', 'TM'); static readonly TC = new Country('Turks & Caicos Islands', 'TC'); static readonly TV = new Country('Tuvalu', 'TV'); static readonly UM = new Country('U.S. Outlying Islands', 'UM'); static readonly VI = new Country('U.S. Virgin Islands', 'VI'); static readonly UG = new Country('Uganda', 'UG'); static readonly UA = new Country('Ukraine', 'UA'); static readonly AE = new Country('United Arab Emirates', 'AE'); static readonly GB = new Country('United Kingdom', 'GB'); static readonly US = new Country('United States', 'US'); static readonly UY = new Country('Uruguay', 'UY'); static readonly UZ = new Country('Uzbekistan', 'UZ'); static readonly VU = new Country('Vanuatu', 'VU'); static readonly VA = new Country('Vatican City', 'VA'); static readonly VE = new Country('Venezuela', 'VE'); static readonly VN = new Country('Vietnam', 'VN'); static readonly WF = new Country('Wallis & Futuna', 'WF'); static readonly EH = new Country('Western Sahara', 'EH'); static readonly YE = new Country('Yemen', 'YE'); static readonly ZM = new Country('Zambia', 'ZM'); static readonly ZW = new Country('Zimbabwe', 'ZW'); constructor( name: string, id: string, private readonly lower = text(id).lower.trim.toString() ) { super(name, id); } static lookup(other: string): Optional { return this.all().first(l => l.equals(other)); } equals(other: E | Id): other is E { return text(other).lower.trim.equals(this.lower); } } export const inEurope = (c: Country | string): boolean => { const country = c instanceof Country ? c : Country.lookup(c); if (!country) { return false; } const euCountries = [ Country.AT, Country.BE, Country.BG, Country.HR, Country.CY, Country.CZ, Country.DK, Country.EE, Country.FI, Country.FR, Country.DE, Country.GR, Country.HU, Country.IE, Country.IT, Country.LV, Country.LT, Country.LU, Country.MT, Country.NL, Country.PL, Country.PT, Country.RO, Country.SK, Country.SI, Country.ES, Country.SE ]; return euCountries.some(euCountry => euCountry.equals(country)); };