<?php
declare(strict_types=1);

namespace Help4BuilderSuite\Modules\Commerce;

if (! defined('ABSPATH')) {
    exit;
}

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

        $filtered = apply_filters('h4bs_commerce_countries', $countries);
        if (! is_array($filtered)) {
            return $countries;
        }

        $normalized = [];
        foreach ($filtered as $code => $label) {
            $code = strtoupper(substr(sanitize_text_field((string) $code), 0, 2));
            $label = sanitize_text_field((string) $label);
            if (strlen($code) === 2 && $label !== '') {
                $normalized[$code] = $label;
            }
        }
        return $normalized;
    }
}
