package challenge

// Generated from IANA tzdb zone1970.tab (public domain). Maps an IANA
// timezone name to the set of ISO-3166 alpha-2 country codes associated
// with it. Regenerate with:
//
//   awk -F'\t' '!/^#/ && NF>=3 { ... }' /usr/share/zoneinfo/zone1970.tab
//
// see the plan / repo docs for the full script.
//
// Historical aliases (Asia/Calcutta, Europe/Kiev, etc.) are in tzAliases
// below so older browsers that still send those names resolve correctly.

var tzCountry = map[string][]string{
	"Europe/Andorra":                 {"AD"},
	"Asia/Dubai":                     {"AE", "OM", "RE", "SC", "TF"},
	"Asia/Kabul":                     {"AF"},
	"Europe/Tirane":                  {"AL"},
	"Asia/Yerevan":                   {"AM"},
	"Antarctica/Casey":                {"AQ"},
	"Antarctica/Davis":                {"AQ"},
	"Antarctica/Mawson":               {"AQ"},
	"Antarctica/Palmer":               {"AQ"},
	"Antarctica/Rothera":              {"AQ"},
	"Antarctica/Troll":                {"AQ"},
	"Antarctica/Vostok":               {"AQ"},
	"America/Argentina/Buenos_Aires":  {"AR"},
	"America/Argentina/Cordoba":       {"AR"},
	"America/Argentina/Salta":         {"AR"},
	"America/Argentina/Jujuy":         {"AR"},
	"America/Argentina/Tucuman":       {"AR"},
	"America/Argentina/Catamarca":     {"AR"},
	"America/Argentina/La_Rioja":      {"AR"},
	"America/Argentina/San_Juan":      {"AR"},
	"America/Argentina/Mendoza":       {"AR"},
	"America/Argentina/San_Luis":      {"AR"},
	"America/Argentina/Rio_Gallegos":  {"AR"},
	"America/Argentina/Ushuaia":       {"AR"},
	"Pacific/Pago_Pago":               {"AS", "UM"},
	"Europe/Vienna":                   {"AT"},
	"Australia/Lord_Howe":             {"AU"},
	"Antarctica/Macquarie":            {"AU"},
	"Australia/Hobart":                {"AU"},
	"Australia/Melbourne":             {"AU"},
	"Australia/Sydney":                {"AU"},
	"Australia/Broken_Hill":           {"AU"},
	"Australia/Brisbane":              {"AU"},
	"Australia/Lindeman":              {"AU"},
	"Australia/Adelaide":              {"AU"},
	"Australia/Darwin":                {"AU"},
	"Australia/Perth":                 {"AU"},
	"Australia/Eucla":                 {"AU"},
	"Asia/Baku":                       {"AZ"},
	"America/Barbados":                {"BB"},
	"Asia/Dhaka":                      {"BD"},
	"Europe/Brussels":                 {"BE", "LU", "NL"},
	"Europe/Sofia":                    {"BG"},
	"Atlantic/Bermuda":                {"BM"},
	"America/La_Paz":                  {"BO"},
	"America/Noronha":                 {"BR"},
	"America/Belem":                   {"BR"},
	"America/Fortaleza":               {"BR"},
	"America/Recife":                  {"BR"},
	"America/Araguaina":               {"BR"},
	"America/Maceio":                  {"BR"},
	"America/Bahia":                   {"BR"},
	"America/Sao_Paulo":               {"BR"},
	"America/Campo_Grande":            {"BR"},
	"America/Cuiaba":                  {"BR"},
	"America/Santarem":                {"BR"},
	"America/Porto_Velho":             {"BR"},
	"America/Boa_Vista":               {"BR"},
	"America/Manaus":                  {"BR"},
	"America/Eirunepe":                {"BR"},
	"America/Rio_Branco":              {"BR"},
	"Asia/Thimphu":                    {"BT"},
	"Europe/Minsk":                    {"BY"},
	"America/Belize":                  {"BZ"},
	"America/St_Johns":                {"CA"},
	"America/Halifax":                 {"CA"},
	"America/Glace_Bay":               {"CA"},
	"America/Moncton":                 {"CA"},
	"America/Goose_Bay":               {"CA"},
	"America/Toronto":                 {"CA", "BS"},
	"America/Iqaluit":                 {"CA"},
	"America/Winnipeg":                {"CA"},
	"America/Resolute":                {"CA"},
	"America/Rankin_Inlet":            {"CA"},
	"America/Regina":                  {"CA"},
	"America/Swift_Current":           {"CA"},
	"America/Edmonton":                {"CA"},
	"America/Cambridge_Bay":           {"CA"},
	"America/Inuvik":                  {"CA"},
	"America/Dawson_Creek":            {"CA"},
	"America/Fort_Nelson":             {"CA"},
	"America/Whitehorse":              {"CA"},
	"America/Dawson":                  {"CA"},
	"America/Vancouver":               {"CA"},
	"Europe/Zurich":                   {"CH", "DE", "LI"},
	"Africa/Abidjan":                  {"CI", "BF", "GH", "GM", "GN", "IS", "ML", "MR", "SH", "SL", "SN", "TG"},
	"Pacific/Rarotonga":               {"CK"},
	"America/Santiago":                {"CL"},
	"America/Coyhaique":               {"CL"},
	"America/Punta_Arenas":            {"CL"},
	"Pacific/Easter":                  {"CL"},
	"Asia/Shanghai":                   {"CN"},
	"Asia/Urumqi":                     {"CN"},
	"America/Bogota":                  {"CO"},
	"America/Costa_Rica":              {"CR"},
	"America/Havana":                  {"CU"},
	"Atlantic/Cape_Verde":             {"CV"},
	"Asia/Nicosia":                    {"CY"},
	"Asia/Famagusta":                  {"CY"},
	"Europe/Prague":                   {"CZ", "SK"},
	"Europe/Berlin":                   {"DE", "DK", "NO", "SE", "SJ"},
	"America/Santo_Domingo":           {"DO"},
	"Africa/Algiers":                  {"DZ"},
	"America/Guayaquil":               {"EC"},
	"Pacific/Galapagos":               {"EC"},
	"Europe/Tallinn":                  {"EE"},
	"Africa/Cairo":                    {"EG"},
	"Africa/El_Aaiun":                 {"EH"},
	"Europe/Madrid":                   {"ES"},
	"Africa/Ceuta":                    {"ES"},
	"Atlantic/Canary":                 {"ES"},
	"Europe/Helsinki":                 {"FI", "AX"},
	"Pacific/Fiji":                    {"FJ"},
	"Atlantic/Stanley":                {"FK"},
	"Pacific/Kosrae":                  {"FM"},
	"Atlantic/Faroe":                  {"FO"},
	"Europe/Paris":                    {"FR", "MC"},
	"Europe/London":                   {"GB", "GG", "IM", "JE"},
	"Asia/Tbilisi":                    {"GE"},
	"America/Cayenne":                 {"GF"},
	"Europe/Gibraltar":                {"GI"},
	"America/Nuuk":                    {"GL"},
	"America/Danmarkshavn":            {"GL"},
	"America/Scoresbysund":            {"GL"},
	"America/Thule":                   {"GL"},
	"Europe/Athens":                   {"GR"},
	"Atlantic/South_Georgia":          {"GS"},
	"America/Guatemala":               {"GT"},
	"Pacific/Guam":                    {"GU", "MP"},
	"Africa/Bissau":                   {"GW"},
	"America/Guyana":                  {"GY"},
	"Asia/Hong_Kong":                  {"HK"},
	"America/Tegucigalpa":             {"HN"},
	"America/Port-au-Prince":          {"HT"},
	"Europe/Budapest":                 {"HU"},
	"Asia/Jakarta":                    {"ID"},
	"Asia/Pontianak":                  {"ID"},
	"Asia/Makassar":                   {"ID"},
	"Asia/Jayapura":                   {"ID"},
	"Europe/Dublin":                   {"IE"},
	"Asia/Jerusalem":                  {"IL"},
	"Asia/Kolkata":                    {"IN"},
	"Indian/Chagos":                   {"IO"},
	"Asia/Baghdad":                    {"IQ"},
	"Asia/Tehran":                     {"IR"},
	"Europe/Rome":                     {"IT", "SM", "VA"},
	"America/Jamaica":                 {"JM"},
	"Asia/Amman":                      {"JO"},
	"Asia/Tokyo":                      {"JP", "AU"},
	"Africa/Nairobi":                  {"KE", "DJ", "ER", "ET", "KM", "MG", "SO", "TZ", "UG", "YT"},
	"Asia/Bishkek":                    {"KG"},
	"Pacific/Tarawa":                  {"KI", "MH", "TV", "UM", "WF"},
	"Pacific/Kanton":                  {"KI"},
	"Pacific/Kiritimati":              {"KI"},
	"Asia/Pyongyang":                  {"KP"},
	"Asia/Seoul":                      {"KR"},
	"Asia/Almaty":                     {"KZ"},
	"Asia/Qyzylorda":                  {"KZ"},
	"Asia/Qostanay":                   {"KZ"},
	"Asia/Aqtobe":                     {"KZ"},
	"Asia/Aqtau":                      {"KZ"},
	"Asia/Atyrau":                     {"KZ"},
	"Asia/Oral":                       {"KZ"},
	"Asia/Beirut":                     {"LB"},
	"Asia/Colombo":                    {"LK"},
	"Africa/Monrovia":                 {"LR"},
	"Europe/Vilnius":                  {"LT"},
	"Europe/Riga":                     {"LV"},
	"Africa/Tripoli":                  {"LY"},
	"Africa/Casablanca":               {"MA"},
	"Europe/Chisinau":                 {"MD"},
	"Pacific/Kwajalein":               {"MH"},
	"Asia/Yangon":                     {"MM", "CC"},
	"Asia/Ulaanbaatar":                {"MN"},
	"Asia/Hovd":                       {"MN"},
	"Asia/Macau":                      {"MO"},
	"America/Martinique":              {"MQ"},
	"Europe/Malta":                    {"MT"},
	"Indian/Mauritius":                {"MU"},
	"Indian/Maldives":                 {"MV", "TF"},
	"America/Mexico_City":             {"MX"},
	"America/Cancun":                  {"MX"},
	"America/Merida":                  {"MX"},
	"America/Monterrey":               {"MX"},
	"America/Matamoros":               {"MX"},
	"America/Chihuahua":               {"MX"},
	"America/Ciudad_Juarez":           {"MX"},
	"America/Ojinaga":                 {"MX"},
	"America/Mazatlan":                {"MX"},
	"America/Bahia_Banderas":          {"MX"},
	"America/Hermosillo":              {"MX"},
	"America/Tijuana":                 {"MX"},
	"Asia/Kuching":                    {"MY", "BN"},
	"Africa/Maputo":                   {"MZ", "BI", "BW", "CD", "MW", "RW", "ZM", "ZW"},
	"Africa/Windhoek":                 {"NA"},
	"Pacific/Noumea":                  {"NC"},
	"Pacific/Norfolk":                 {"NF"},
	"Africa/Lagos":                    {"NG", "AO", "BJ", "CD", "CF", "CG", "CM", "GA", "GQ", "NE"},
	"America/Managua":                 {"NI"},
	"Asia/Kathmandu":                  {"NP"},
	"Pacific/Nauru":                   {"NR"},
	"Pacific/Niue":                    {"NU"},
	"Pacific/Auckland":                {"NZ", "AQ"},
	"Pacific/Chatham":                 {"NZ"},
	"America/Panama":                  {"PA", "CA", "KY"},
	"America/Lima":                    {"PE"},
	"Pacific/Tahiti":                  {"PF"},
	"Pacific/Marquesas":               {"PF"},
	"Pacific/Gambier":                 {"PF"},
	"Pacific/Port_Moresby":            {"PG", "AQ", "FM"},
	"Pacific/Bougainville":            {"PG"},
	"Asia/Manila":                     {"PH"},
	"Asia/Karachi":                    {"PK"},
	"Europe/Warsaw":                   {"PL"},
	"America/Miquelon":                {"PM"},
	"Pacific/Pitcairn":                {"PN"},
	"America/Puerto_Rico":             {"PR", "AG", "CA", "AI", "AW", "BL", "BQ", "CW", "DM", "GD", "GP", "KN", "LC", "MF", "MS", "SX", "TT", "VC", "VG", "VI"},
	"Asia/Gaza":                       {"PS"},
	"Asia/Hebron":                     {"PS"},
	"Europe/Lisbon":                   {"PT"},
	"Atlantic/Madeira":                {"PT"},
	"Atlantic/Azores":                 {"PT"},
	"Pacific/Palau":                   {"PW"},
	"America/Asuncion":                {"PY"},
	"Asia/Qatar":                      {"QA", "BH"},
	"Europe/Bucharest":                {"RO"},
	"Europe/Belgrade":                 {"RS", "BA", "HR", "ME", "MK", "SI"},
	"Europe/Kaliningrad":              {"RU"},
	"Europe/Moscow":                   {"RU"},
	"Europe/Simferopol":               {"RU", "UA"},
	"Europe/Kirov":                    {"RU"},
	"Europe/Volgograd":                {"RU"},
	"Europe/Astrakhan":                {"RU"},
	"Europe/Saratov":                  {"RU"},
	"Europe/Ulyanovsk":                {"RU"},
	"Europe/Samara":                   {"RU"},
	"Asia/Yekaterinburg":              {"RU"},
	"Asia/Omsk":                       {"RU"},
	"Asia/Novosibirsk":                {"RU"},
	"Asia/Barnaul":                    {"RU"},
	"Asia/Tomsk":                      {"RU"},
	"Asia/Novokuznetsk":               {"RU"},
	"Asia/Krasnoyarsk":                {"RU"},
	"Asia/Irkutsk":                    {"RU"},
	"Asia/Chita":                      {"RU"},
	"Asia/Yakutsk":                    {"RU"},
	"Asia/Khandyga":                   {"RU"},
	"Asia/Vladivostok":                {"RU"},
	"Asia/Ust-Nera":                   {"RU"},
	"Asia/Magadan":                    {"RU"},
	"Asia/Sakhalin":                   {"RU"},
	"Asia/Srednekolymsk":              {"RU"},
	"Asia/Kamchatka":                  {"RU"},
	"Asia/Anadyr":                     {"RU"},
	"Asia/Riyadh":                     {"SA", "AQ", "KW", "YE"},
	"Pacific/Guadalcanal":             {"SB", "FM"},
	"Africa/Khartoum":                 {"SD"},
	"Asia/Singapore":                  {"SG", "AQ", "MY"},
	"America/Paramaribo":              {"SR"},
	"Africa/Juba":                     {"SS"},
	"Africa/Sao_Tome":                 {"ST"},
	"America/El_Salvador":             {"SV"},
	"Asia/Damascus":                   {"SY"},
	"America/Grand_Turk":              {"TC"},
	"Africa/Ndjamena":                 {"TD"},
	"Asia/Bangkok":                    {"TH", "CX", "KH", "LA", "VN"},
	"Asia/Dushanbe":                   {"TJ"},
	"Pacific/Fakaofo":                 {"TK"},
	"Asia/Dili":                       {"TL"},
	"Asia/Ashgabat":                   {"TM"},
	"Africa/Tunis":                    {"TN"},
	"Pacific/Tongatapu":               {"TO"},
	"Europe/Istanbul":                 {"TR"},
	"Asia/Taipei":                     {"TW"},
	"Europe/Kyiv":                     {"UA"},
	"America/New_York":                {"US"},
	"America/Detroit":                 {"US"},
	"America/Kentucky/Louisville":     {"US"},
	"America/Kentucky/Monticello":     {"US"},
	"America/Indiana/Indianapolis":    {"US"},
	"America/Indiana/Vincennes":       {"US"},
	"America/Indiana/Winamac":         {"US"},
	"America/Indiana/Marengo":         {"US"},
	"America/Indiana/Petersburg":      {"US"},
	"America/Indiana/Vevay":           {"US"},
	"America/Chicago":                 {"US"},
	"America/Indiana/Tell_City":       {"US"},
	"America/Indiana/Knox":            {"US"},
	"America/Menominee":               {"US"},
	"America/North_Dakota/Center":     {"US"},
	"America/North_Dakota/New_Salem":  {"US"},
	"America/North_Dakota/Beulah":     {"US"},
	"America/Denver":                  {"US"},
	"America/Boise":                   {"US"},
	"America/Phoenix":                 {"US", "CA"},
	"America/Los_Angeles":             {"US"},
	"America/Anchorage":               {"US"},
	"America/Juneau":                  {"US"},
	"America/Sitka":                   {"US"},
	"America/Metlakatla":              {"US"},
	"America/Yakutat":                 {"US"},
	"America/Nome":                    {"US"},
	"America/Adak":                    {"US"},
	"Pacific/Honolulu":                {"US"},
	"America/Montevideo":              {"UY"},
	"Asia/Samarkand":                  {"UZ"},
	"Asia/Tashkent":                   {"UZ"},
	"America/Caracas":                 {"VE"},
	"Asia/Ho_Chi_Minh":                {"VN"},
	"Pacific/Efate":                   {"VU"},
	"Pacific/Apia":                    {"WS"},
	"Africa/Johannesburg":             {"ZA", "LS", "SZ"},
}

// tzAliases maps deprecated / legacy timezone names that older browsers or
// operating systems still emit to their canonical equivalents in tzCountry.
// Keeping the aliases small and explicit rather than generated; pull more in
// as we observe them in production traffic.
var tzAliases = map[string]string{
	"Asia/Calcutta":         "Asia/Kolkata",
	"Asia/Saigon":           "Asia/Ho_Chi_Minh",
	"Asia/Katmandu":         "Asia/Kathmandu",
	"Asia/Istanbul":         "Europe/Istanbul",
	"Europe/Kiev":           "Europe/Kyiv",
	"America/Buenos_Aires":  "America/Argentina/Buenos_Aires",
	"America/Godthab":       "America/Nuuk",
}

// lookupTimezoneCountries returns the ISO country codes associated with an
// IANA timezone, resolving aliases first. Returns nil for unknown zones —
// callers treat nil as "no data" and decline to emit a mismatch signal.
func lookupTimezoneCountries(tz string) []string {
	if tz == "" {
		return nil
	}
	if canonical, ok := tzAliases[tz]; ok {
		tz = canonical
	}
	return tzCountry[tz]
}
