export type CountryCallingCode = {
  name: string;
  iso2: string;
  dialCode: string;
};

export const COUNTRY_CALLING_CODES: CountryCallingCode[] = [
  { name: "China", iso2: "CN", dialCode: "+86" },
  { name: "Hong Kong", iso2: "HK", dialCode: "+852" },
  { name: "Macao", iso2: "MO", dialCode: "+853" },
  { name: "Taiwan", iso2: "TW", dialCode: "+886" },
  { name: "Thailand", iso2: "TH", dialCode: "+66" },
  { name: "Singapore", iso2: "SG", dialCode: "+65" },
  { name: "Malaysia", iso2: "MY", dialCode: "+60" },
  { name: "Indonesia", iso2: "ID", dialCode: "+62" },
  { name: "Vietnam", iso2: "VN", dialCode: "+84" },
  { name: "Philippines", iso2: "PH", dialCode: "+63" },
  { name: "Japan", iso2: "JP", dialCode: "+81" },
  { name: "Korea, Republic of", iso2: "KR", dialCode: "+82" },
  { name: "India", iso2: "IN", dialCode: "+91" },
  { name: "Pakistan", iso2: "PK", dialCode: "+92" },
  { name: "Bangladesh", iso2: "BD", dialCode: "+880" },
  { name: "Sri Lanka", iso2: "LK", dialCode: "+94" },
  { name: "Cambodia", iso2: "KH", dialCode: "+855" },
  { name: "Laos", iso2: "LA", dialCode: "+856" },
  { name: "Myanmar", iso2: "MM", dialCode: "+95" },
  { name: "Australia", iso2: "AU", dialCode: "+61" },
  { name: "New Zealand", iso2: "NZ", dialCode: "+64" },
  { name: "United States", iso2: "US", dialCode: "+1" },
  { name: "Canada", iso2: "CA", dialCode: "+1" },
  { name: "Mexico", iso2: "MX", dialCode: "+52" },
  { name: "Brazil", iso2: "BR", dialCode: "+55" },
  { name: "Argentina", iso2: "AR", dialCode: "+54" },
  { name: "Chile", iso2: "CL", dialCode: "+56" },
  { name: "Colombia", iso2: "CO", dialCode: "+57" },
  { name: "Peru", iso2: "PE", dialCode: "+51" },
  { name: "Ecuador", iso2: "EC", dialCode: "+593" },
  { name: "Bolivia", iso2: "BO", dialCode: "+591" },
  { name: "Venezuela", iso2: "VE", dialCode: "+58" },
  { name: "Uruguay", iso2: "UY", dialCode: "+598" },
  { name: "Paraguay", iso2: "PY", dialCode: "+595" },
  { name: "United Kingdom", iso2: "GB", dialCode: "+44" },
  { name: "Ireland", iso2: "IE", dialCode: "+353" },
  { name: "France", iso2: "FR", dialCode: "+33" },
  { name: "Germany", iso2: "DE", dialCode: "+49" },
  { name: "Italy", iso2: "IT", dialCode: "+39" },
  { name: "Spain", iso2: "ES", dialCode: "+34" },
  { name: "Portugal", iso2: "PT", dialCode: "+351" },
  { name: "Netherlands", iso2: "NL", dialCode: "+31" },
  { name: "Belgium", iso2: "BE", dialCode: "+32" },
  { name: "Switzerland", iso2: "CH", dialCode: "+41" },
  { name: "Austria", iso2: "AT", dialCode: "+43" },
  { name: "Sweden", iso2: "SE", dialCode: "+46" },
  { name: "Norway", iso2: "NO", dialCode: "+47" },
  { name: "Denmark", iso2: "DK", dialCode: "+45" },
  { name: "Finland", iso2: "FI", dialCode: "+358" },
  { name: "Poland", iso2: "PL", dialCode: "+48" },
  { name: "Czech Republic", iso2: "CZ", dialCode: "+420" },
  { name: "Hungary", iso2: "HU", dialCode: "+36" },
  { name: "Greece", iso2: "GR", dialCode: "+30" },
  { name: "Romania", iso2: "RO", dialCode: "+40" },
  { name: "Bulgaria", iso2: "BG", dialCode: "+359" },
  { name: "Russia", iso2: "RU", dialCode: "+7" },
  { name: "Ukraine", iso2: "UA", dialCode: "+380" },
  { name: "Turkey", iso2: "TR", dialCode: "+90" },
  { name: "Israel", iso2: "IL", dialCode: "+972" },
  { name: "Saudi Arabia", iso2: "SA", dialCode: "+966" },
  { name: "United Arab Emirates", iso2: "AE", dialCode: "+971" },
  { name: "Qatar", iso2: "QA", dialCode: "+974" },
  { name: "Kuwait", iso2: "KW", dialCode: "+965" },
  { name: "Bahrain", iso2: "BH", dialCode: "+973" },
  { name: "Oman", iso2: "OM", dialCode: "+968" },
  { name: "Jordan", iso2: "JO", dialCode: "+962" },
  { name: "Lebanon", iso2: "LB", dialCode: "+961" },
  { name: "Iraq", iso2: "IQ", dialCode: "+964" },
  { name: "Iran", iso2: "IR", dialCode: "+98" },
  { name: "Egypt", iso2: "EG", dialCode: "+20" },
  { name: "Morocco", iso2: "MA", dialCode: "+212" },
  { name: "Algeria", iso2: "DZ", dialCode: "+213" },
  { name: "Tunisia", iso2: "TN", dialCode: "+216" },
  { name: "South Africa", iso2: "ZA", dialCode: "+27" },
  { name: "Nigeria", iso2: "NG", dialCode: "+234" },
  { name: "Kenya", iso2: "KE", dialCode: "+254" },
  { name: "Ghana", iso2: "GH", dialCode: "+233" },
  { name: "Ethiopia", iso2: "ET", dialCode: "+251" },
  { name: "Tanzania", iso2: "TZ", dialCode: "+255" },
];

export function findCountryCallingCode(iso2: string): CountryCallingCode | null {
  const normalized = iso2.trim().toUpperCase();
  return COUNTRY_CALLING_CODES.find((item) => item.iso2 === normalized) ?? null;
}

