PageSourceSearch

https://www.beibeihair.com/wp-content/plugins/mystickyelements/int…/build/js/intlTelInput.js?ver=2.2.5

js beibeihair.com collected 2026-10-04 09:26:24 UTC 105,867 bytes, 1,520 lines download raw bytes

1/*
2 * International Telephone Input v17.0.16
3 * https://github.com/jackocnr/intl-tel-input.git
4 * Licensed under the MIT license
5 */
6
7// wrap in UMD
8(function (factory) {
9    if (typeof module === "object" && module.exports) { module.exports = factory(); } else { window.intlTelInput = factory();
10    }
11})(
12    function (undefined) {
13        "use strict";
14        return function () {
15            // Array of country objects for the flag dropdown.
16            // Here is the criteria for the plugin to support a given country/territory
17            // - It has an iso2 code: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
18            // - It has it's own country calling code (it is not a sub-region of another country): https://en.wikipedia.org/wiki/List_of_country_calling_codes
19            // - It has a flag in the region-flags project: https://github.com/behdad/region-flags/tree/gh-pages/png
20            // - It is supported by libphonenumber (it must be listed on this page): https://github.com/googlei18n/libphonenumber/blob/master/resources/ShortNumberMetadata.xml
21            // Each country array has the following information:
22            // [
23            //    Country name,
24            //    iso2 code,
25            //    International dial code,
26            //    Order (if >1 country with same dial code),
27            //    Area codes
28            // ]
29            var allCountries = [ [ "Afghanistan (‫افغانستان‬‎)", "af", "93" ], [ "Albania (Shqipëri)", "al", "355" ], [ "Algeria (‫الجزائر‬‎)", "dz", "213" ], [ "American Samoa", "as", "1", 5, [ "684" ] ], [ "Andorra", "ad", "376" ], [ "Angola", "ao", "244" ], [ "Anguilla", "ai", "1", 6, [ "264" ] ], [ "Antigua and Barbuda", "ag", "1", 7, [ "268" ] ], [ "Argentina", "ar", "54" ], [ "Armenia (Հայաստան)", "am", "374" ], [ "Aruba", "aw", "297" ], [ "Ascension Island", "ac", "247" ], [ "Australia", "au", "61", 0 ], [ "Austria (Österreich)", "at", "43" ], [ "Azerbaijan (Azərbaycan)", "az", "994" ], [ "Bahamas", "bs", "1", 8, [ "242" ] ], [ "Bahrain (‫البحرين‬‎)", "bh", "973" ], [ "Bangladesh (বাংলাদেশ)", "bd", "880" ], [ "Barbados", "bb", "1", 9, [ "246" ] ], [ "Belarus (Беларусь)", "by", "375" ], [ "Belgium (België)", "be", "32" ], [ "Belize", "bz", "501" ], [ "Benin (Bénin)", "bj", "229" ], [ "Bermuda", "bm", "1", 10, [ "441" ] ], [ "Bhutan (འབྲུག)", "bt", "975" ], [ "Bolivia", "bo", "591" ], [ "Bosnia and Herzegovina (Босна и Херцеговина)", "ba", "387" ], [ "Botswana", "bw", "267" ], [ "Brazil (Brasil)", "br", "55" ], [ "British Indian Ocean Territory", "io", "246" ], [ "British Virgin Islands", "vg", "1", 11, [ "284" ] ], [ "Brunei", "bn", "673" ], [ "Bulgaria (България)", "bg", "359" ], [ "Burkina Faso", "bf", "226" ], [ "Burundi (Uburundi)", "bi", "257" ], [ "Cambodia (កម្ពុជា)", "kh", "855" ], [ "Cameroon (Cameroun)", "cm", "237" ], [ "Canada", "ca", "1", 1, [ "204", "226", "236", "249", "250", "289", "306", "343", "365", "387", "403", "416", "418", "431", "437", "438", "450", "506", "514", "519", "548", "579", "581", "587", "604", "613", "639", "647", "672", "705", "709", "742", "778", "780", "782", "807", "819", "825", "867", "873", "902", "905" ] ], [ "Cape Verde (Kabu Verdi)", "cv", "238" ], [ "Caribbean Netherlands", "bq", "599", 1, [ "3", "4", "7" ] ], [ "Cayman Islands", "ky", "1", 12, [ "345" ] ], [ "Central African Republic (République centrafricaine)", "cf", "236" ], [ "Chad (Tchad)", "td", "235" ], [ "Chile", "cl", "56" ], [ "China (中国)", "cn", "86" ], [ "Christmas Island", "cx", "61", 2, [ "89164" ] ], [ "Cocos (Keeling) Islands", "cc", "61", 1, [ "89162" ] ], [ "Colombia", "co", "57" ], [ "Comoros (‫جزر القمر‬‎)", "km", "269" ], [ "Congo (DRC) (Jamhuri ya Kidemokrasia ya Kongo)", "cd", "243" ], [ "Congo (Republic) (Congo-Brazzaville)", "cg", "242" ], [ "Cook Islands", "ck", "682" ], [ "Costa Rica", "cr", "506" ], [ "Côte d’Ivoire", "ci", "225" ], [ "Croatia (Hrvatska)", "hr", "385" ], [ "Cuba", "cu", "53" ], [ "Curaçao", "cw", "599", 0 ], [ "Cyprus (Κύπρος)", "cy", "357" ], [ "Czech Republic (Česká republika)", "cz", "420" ], [ "Denmark (Danmark)", "dk", "45" ], [ "Djibouti", "dj", "253" ], [ "Dominica", "dm", "1", 13, [ "767" ] ], [ "Dominican Republic (República Dominicana)", "do", "1", 2, [ "809", "829", "849" ] ], [ "Ecuador", "ec", "593" ], [ "Egypt (‫مصر‬‎)", "eg", "20" ], [ "El Salvador", "sv", "503" ], [ "Equatorial Guinea (Guinea Ecuatorial)", "gq", "240" ], [ "Eritrea", "er", "291" ], [ "Estonia (Eesti)", "ee", "372" ], [ "Eswatini", "sz", "268" ], [ "Ethiopia", "et", "251" ], [ "Falkland Islands (Islas Malvinas)", "fk", "500" ], [ "Faroe Islands (Føroyar)", "fo", "298" ], [ "Fiji", "fj", "679" ], [ "Finland (Suomi)", "fi", "358", 0 ], [ "France", "fr", "33" ], [ "French Guiana (Guyane française)", "gf", "594" ], [ "French Polynesia (Polynésie française)", "pf", "689" ], [ "Gabon", "ga", "241" ], [ "Gambia", "gm", "220" ], [ "Georgia (საქართველო)", "ge", "995" ], [ "Germany (Deutschland)", "de", "49" ], [ "Ghana (Gaana)", "gh", "233" ], [ "Gibraltar", "gi", "350" ], [ "Greece (Ελλάδα)", "gr", "30" ], [ "Greenland (Kalaallit Nun
29aat)", "gl", "299" ], [ "Grenada", "gd", "1", 14, [ "473" ] ], [ "Guadeloupe", "gp", "590", 0 ], [ "Guam", "gu", "1", 15, [ "671" ] ], [ "Guatemala", "gt", "502" ], [ "Guernsey", "gg", "44", 1, [ "1481", "7781", "7839", "7911" ] ], [ "Guinea (Guinée)", "gn", "224" ], [ "Guinea-Bissau (Guiné Bissau)", "gw", "245" ], [ "Guyana", "gy", "592" ], [ "Haiti", "ht", "509" ], [ "Honduras", "hn", "504" ], [ "Hong Kong (香港)", "hk", "852" ], [ "Hungary (Magyarország)", "hu", "36" ], [ "Iceland (Ísland)", "is", "354" ], [ "India (भारत)", "in", "91" ], [ "Indonesia", "id", "62" ], [ "Iran (‫ایران‬‎)", "ir", "98" ], [ "Iraq (‫العراق‬‎)", "iq", "964" ], [ "Ireland", "ie", "353" ], [ "Isle of Man", "im", "44", 2, [ "1624", "74576", "7524", "7924", "7624" ] ], [ "Israel (‫ישראל‬‎)", "il", "972" ], [ "Italy (Italia)", "it", "39", 0 ], [ "Jamaica", "jm", "1", 4, [ "876", "658" ] ], [ "Japan (日本)", "jp", "81" ], [ "Jersey", "je", "44", 3, [ "1534", "7509", "7700", "7797", "7829", "7937" ] ], [ "Jordan (‫الأردن‬‎)", "jo", "962" ], [ "Kazakhstan (Казахстан)", "kz", "7", 1, [ "33", "7" ] ], [ "Kenya", "ke", "254" ], [ "Kiribati", "ki", "686" ], [ "Kosovo", "xk", "383" ], [ "Kuwait (‫الكويت‬‎)", "kw", "965" ], [ "Kyrgyzstan (Кыргызстан)", "kg", "996" ], [ "Laos (ລາວ)", "la", "856" ], [ "Latvia (Latvija)", "lv", "371" ], [ "Lebanon (‫لبنان‬‎)", "lb", "961" ], [ "Lesotho", "ls", "266" ], [ "Liberia", "lr", "231" ], [ "Libya (‫ليبيا‬‎)", "ly", "218" ], [ "Liechtenstein", "li", "423" ], [ "Lithuania (Lietuva)", "lt", "370" ], [ "Luxembourg", "lu", "352" ], [ "Macau (澳門)", "mo", "853" ], [ "North Macedonia (Македонија)", "mk", "389" ], [ "Madagascar (Madagasikara)", "mg", "261" ], [ "Malawi", "mw", "265" ], [ "Malaysia", "my", "60" ], [ "Maldives", "mv", "960" ], [ "Mali", "ml", "223" ], [ "Malta", "mt", "356" ], [ "Marshall Islands", "mh", "692" ], [ "Martinique", "mq", "596" ], [ "Mauritania (‫موريتانيا‬‎)", "mr", "222" ], [ "Mauritius (Moris)", "mu", "230" ], [ "Mayotte", "yt", "262", 1, [ "269", "639" ] ], [ "Mexico (México)", "mx", "52" ], [ "Micronesia", "fm", "691" ], [ "Moldova (Republica Moldova)", "md", "373" ], [ "Monaco", "mc", "377" ], [ "Mongolia (Монгол)", "mn", "976" ], [ "Montenegro (Crna Gora)", "me", "382" ], [ "Montserrat", "ms", "1", 16, [ "664" ] ], [ "Morocco (‫المغرب‬‎)", "ma", "212", 0 ], [ "Mozambique (Moçambique)", "mz", "258" ], [ "Myanmar (Burma) (မြန်မာ)", "mm", "95" ], [ "Namibia (Namibië)", "na", "264" ], [ "Nauru", "nr", "674" ], [ "Nepal (नेपाल)", "np", "977" ], [ "Netherlands (Nederland)", "nl", "31" ], [ "New Caledonia (Nouvelle-Calédonie)", "nc", "687" ], [ "New Zealand", "nz", "64" ], [ "Nicaragua", "ni", "505" ], [ "Niger (Nijar)", "ne", "227" ], [ "Nigeria", "ng", "234" ], [ "Niue", "nu", "683" ], [ "Norfolk Island", "nf", "672" ], [ "North Korea (조선 민주주의 인민 공화국)", "kp", "850" ], [ "Northern Mariana Islands", "mp", "1", 17, [ "670" ] ], [ "Norway (Norge)", "no", "47", 0 ], [ "Oman (‫عُمان‬‎)", "om", "968" ], [ "Pakistan (‫پاکستان‬‎)", "pk", "92" ], [ "Palau", "pw", "680" ], [ "Palestine (‫فلسطين‬‎)", "ps", "970" ], [ "Panama (Panamá)", "pa", "507" ], [ "Papua New Guinea", "pg", "675" ], [ "Paraguay", "py", "595" ], [ "Peru (Perú)", "pe", "51" ], [ "Philippines", "ph", "63" ], [ "Poland (Polska)", "pl", "48" ], [ "Portugal", "pt", "351" ], [ "Puerto Rico", "pr", "1", 3, [ "787", "939" ] ], [ "Qatar (‫قطر‬‎)", "qa", "974" ], [ "Réunion (La Réunion)", "re", "262", 0 ], [ "Romania (România)", "ro", "40" ], [ "Russia (Россия)", "ru", "7", 0 ], [ "Rwanda", "rw", "250" ], [ "Saint Barthélemy", "bl", "590", 1 ], [ "Saint Helena", "sh", "290" ], [ "Saint Kitts and Nevis", "kn", "1", 18, [ "869" ] ], [ "Saint Lucia", "lc", "1", 19, [ "758" ] ], [ "Saint Martin (Saint-Martin (partie française))", "mf", "590", 2 ], [ "Saint Pierre and Miquelon (Saint-Pierre-et-Miquelon)", "pm", "508" ], [ "Saint Vincent and the Grenadines", "vc", "1", 20, [ "784" ] ], [ "Samoa", "ws", "685" ], [ "San Marino", "sm", "378" ], [ "São Tomé and Príncipe (São Tomé e Príncipe)", "st", "239" ], [ "Saudi Arabia (‫المملكة العربية السعودية‬‎)", "sa", "966" ], [ "Senegal (Sénégal)", "sn", "221" ], [ "Serbia (Србија)", "rs", "381" ], [ "Seychelles", "sc", "248" ], [ "Sierra Leone", "sl", "232" ], [ "Singapore", "sg", "65" ], [ "Sint Maarten", "sx", "1", 21, [ "721" ] ], [ "Slovakia (Slovensko)", "sk", "421" ], [ "Slovenia (Slovenija)", "si", "386" ], [ "Solomon Islands", "sb", "677" ], [ "Somalia (Soomaaliya)", "so", "252" ], [ "South Africa", "za", "27" ], [ "South Korea (대한민국)", "kr", "82" ], [ "South Sudan (‫جنوب السودان‬‎)", "ss", "211" ], [ "Spain (España)", "es", "34" ], [ "Sri Lanka (ශ්‍රී ලංකාව)", "lk", "94" ], [ "Sudan (‫السودان‬‎)", "sd", "249" ], [ "Suriname", "sr", "597" ], [ "Svalbard and Jan Mayen", "sj", "47", 1, [ "79" ] ], [ "Sweden (Sverige)", "se", "46" ], [ "Switzerland (Schweiz)", "ch", "41" ], [ "Syria (‫سوريا‬‎)", "sy", "963" ], [ "Taiwan (台灣)", "tw", "886" ], [ "Tajikistan", "tj", "992" ], [ "Tanzania", "tz", "255" ], [ "Thailand (ไทย)", "th", "66" ], [ "Timor-Leste", "tl", "670" ], [ "Togo", "tg", "228" ], [ "Tokelau", "tk", "690" ], [ "Tonga", "to", "676" ], [ "Trinidad and Tobago", "tt", "1", 22, [ "868" ] ], [ "Tunisia (‫تونس‬‎)", "tn", "216" ], [ "Turkey (Türkiye)", "tr", "90" ], [ "Turkmenistan", "tm", "993" ], [ "Turks and Caicos Islands", "tc", "1", 23, [ "649" ] ], [ "Tuvalu", "tv", "688" ], [ "U.S. Virgin Islands", "vi", "1", 24, [ "340" ] ], [ "Uganda", "ug", "256" ], [ "Ukraine (Україна)", "ua", "380" ], [ "United Arab Emirates (‫الإمارات العربية المتحدة‬‎)", "ae", "971" ], [ "United Kingdom", "gb", "44", 0 ], [ "United States", "us", "1", 0 ], [ "Uruguay", "uy", "598" ], [ "Uzbekistan (Oʻzbekiston)", "uz", "998" ], [ "Vanuatu", "vu", "678" ], [ "Vatican City (Città del Vaticano)", "va", "39", 1, [ "06698" ] ], [ "Venezuela", "ve", "58" ], [ "Vietnam (Việt Nam)", "vn", "84" ], [ "Wallis and Futuna (Wallis-et-Futuna)", "wf", "681" ], [ "Western Sahara (‫الصحراء الغربية‬‎)", "eh", "212", 1, [ "5288", "5289" ] ], [ "Yemen (‫اليمن‬‎)", "ye", "967" ], [ "Zambia", "zm", "260" ], [ "Zimbabwe", "zw", "263" ], [ "Åland Islands", "ax", "358", 1, [ "18" ] ] ];
30            // loop over all of the countries above, restructuring the data to be objects with named keys
31            for (var i = 0; i < allCountries.length; i++) {
32                var c = allCountries[i];
33                allCountries[i] = {
34                    name: c[0],
35                    iso2: c[1],
36                    dialCode: c[2],
37                    priority: c[3] || 0,
38                    areaCodes: c[4] || null
39                };
40            }
41            "use strict";
42            function _classCallCheck(instance, Constructor)
43            {
44                if (!(instance instanceof Constructor)) {
45                    throw new TypeError("Cannot call a class as a function");
46                }
47            }
48            function _defineProperties(target, props)
49            {
50                for (var i = 0; i < props.length; i++) {
51                    var descriptor = props[i];
52                    descriptor.enumerable = descriptor.enumerable || false;
53                    descriptor.configurable = true;
54                    if ("value" in descriptor) { descriptor.writable = true;
55                    }
56                    Object.defineProperty(target, descriptor.key, descriptor);
57                }
58            }
59            function _createClass(Constructor, protoProps, staticProps)
60            {
61                if (protoProps) { _defineProperties(Constructor.prototype, protoProps);
62                }
63                if (staticProps) { _defineProperties(Constructor, staticProps);
64                }
65                return Constructor;
66            }
67            var intlTelInputGlobals = {
68                getInstance: function getInstance(input)
69                {
70                    var id = input.getAttribute("data-intl-tel-input-id");
71                    return window.intlTelInputGlobals.instances[id];
72                },
73                instances: {},
74                // using a global like this allows us to mock it in the tests
75                documentReady: function documentReady()
76                {
77                    return document.readyState === "complete";
78                }
79            };
80            if (typeof window === "object") { window.intlTelInputGlobals = intlTelInputGlobals;
81            }
82            // these vars persist through all instances of the plugin
83            var id = 0;
84            var defaults = {
85                // whether or not to allow the dropdown
86                allowDropdown: true,
87                // if there is just a dial code in the input: remove it on blur
88                autoHideDialCode: true,
89                // add a placeholder in the input with an example number for the selected country
90                autoPlaceholder: "polite",
91                // modify the parentClass
92                customContainer: "",
93                // modify the auto placeholder
94                customPlaceholder: null,
95                // append menu to specified element
96                dropdownContainer: null,
97                // don't display these countries
98                excludeCountries: [],
99                // format the input value during initialisation and on setNumber
100                formatOnDisplay: true,
101                // geoIp lookup function
102                geoIpLookup: null,
103                // inject a hidden input with this name, and on submit, populate it with the result of getNumber
104                hiddenInput: "",
105                // initial country
106                initialCountry: "",
107                // localized country names e.g. { 'de': 'Deutschland' }
108                localizedCountries: null,
109                // don't insert international dial codes
110                nationalMode: true,
111                // display only these countries
112                onlyCountries: [],
113                // number type to use for placeholders
114                placeholderNumberType: "MOBILE",
115                // the countries at the top of the list. defaults to united states and united kingdom
116                preferredCountries: [ "us", "gb" ],
117                // display the country dial code next to the selected flag so it's not part of the typed number
118                separateDialCode: false,
119                // specify the path to the libphonenumber script to enable validation/formatting
120                utilsScript: ""
121            };
122            // https://en.wikipedia.org/wiki/List_of_North_American_Numbering_Plan_area_codes#Non-geographic_area_codes
123            var regionlessNanpNumbers = [ "800", "822", "833", "844", "855", "866", "877", "880", "881", "882", "883", "884", "885", "886", "887", "888", "889" ];
124            // utility function to iterate over an object. can't use Object.entries or native forEac
vendor: 15,086 bytes, lines 124-370
124h because
125            // of IE11
126            var forEachProp = function forEachProp(obj, callback)
127            {
128                var keys = Object.keys(obj);
129                for (var i = 0; i < keys.length; i++) {
130                    callback(keys[i], obj[keys[i]]);
131                }
132            };
133            // run a method on each instance of the plugin
134            var forEachInstance = function forEachInstance(method)
135            {
136                forEachProp(
137                    window.intlTelInputGlobals.instances, function (key) {
138                        window.intlTelInputGlobals.instances[key][method]();
139                    }
140                );
141            };
142            // this is our plugin class that we will create an instance of
143            // eslint-disable-next-line no-unused-vars
144            var Iti = /*#__PURE__*/
145            function () {
146                function Iti(input, options)
147                {
148                    var _this = this;
149                    _classCallCheck(this, Iti);
150                    this.id = id++;
151                    this.telInput = input;
152                    this.activeItem = null;
153                    this.highlightedItem = null;
154                    // process specified options / defaults
155                    // alternative to Object.assign, which isn't supported by IE11
156                    var customOptions = options || {};
157                    this.options = {};
158                    forEachProp(
159                        defaults, function (key, value) {
160                            _this.options[key] = customOptions.hasOwnProperty(key) ? customOptions[key] : value;
161                        }
162                    );
163                    this.hadInitialPlaceholder = Boolean(input.getAttribute("placeholder"));
164                }
165                _createClass(
166                    Iti, [ {
167                        key: "_init",
168                        value: function _init()
169                        {
170                            var _this2 = this;
171                            // if in nationalMode, disable options relating to dial codes
172                            if (this.options.nationalMode) { this.options.autoHideDialCode = false;
173                            }
174                            // if separateDialCode then doesn't make sense to A) insert dial code into input
175                            // (autoHideDialCode), and B) display national numbers (because we're displaying the country
176                            // dial code next to them)
177                            if (this.options.separateDialCode) {
178                                this.options.autoHideDialCode = this.options.nationalMode = false;
179                            }
180                            // we cannot just test screen size as some smartphones/website meta tags will report desktop
181                            // resolutions
182                            // Note: for some reason jasmine breaks if you put this in the main Plugin function with the
183                            // rest of these declarations
184                            // Note: to target Android Mobiles (and not Tablets), we must find 'Android' and 'Mobile'
185                            this.isMobile = /Android.+Mobile|webOS|iPhone|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
186                            if (this.isMobile) {
187                                // trigger the mobile dropdown css
188                                document.body.classList.add("iti-mobile");
189                                // on mobile, we want a full screen dropdown, so we must append it to the body
190                                if (!this.options.dropdownContainer) { this.options.dropdownContainer = document.body;
191                                }
192                            }
193                            // these promises get resolved when their individual requests complete
194                            // this way the dev can do something like iti.promise.then(...) to know when all requests are
195                            // complete
196                            if (typeof Promise !== "undefined") {
197                                var autoCountryPromise = new Promise(
198                                    function (resolve, reject) {
199                                        _this2.resolveAutoCountryPromise = resolve;
200                                        _this2.rejectAutoCountryPromise = reject;
201                                    }
202                                );
203                                var utilsScriptPromise = new Promise(
204                                    function (resolve, reject) {
205                                        _this2.resolveUtilsScriptPromise = resolve;
206                                        _this2.rejectUtilsScriptPromise = reject;
207                                    }
208                                );
209                                this.promise = Promise.all([ autoCountryPromise, utilsScriptPromise ]);
210                            } else {
211                                // prevent errors when Promise doesn't exist
212                                this.resolveAutoCountryPromise = this.rejectAutoCountryPromise = function () {};
213                                this.resolveUtilsScriptPromise = this.rejectUtilsScriptPromise = function () {};
214                            }
215                            // in various situations there could be no country selected initially, but we need to be able
216                            // to assume this variable exists
217                            this.selectedCountryData = {};
218                            // process all the data: onlyCountries, excludeCountries, preferredCountries etc
219                            this._processCountryData();
220                            // generate the markup
221                            this._generateMarkup();
222                            // set the initial state of the input value and the selected flag
223                            this._setInitialState();
224                            // start all of the event listeners: autoHideDialCode, input keydown, selectedFlag click
225                            this._initListeners();
226                            // utils script, and auto country
227                            this._initRequests();
228                        }
229                    }, {
230                        key: "_processCountryData",
231                        value: function _processCountryData()
232                        {
233                            // process onlyCountries or excludeCountries array if present
234                            this._processAllCountries();
235                            // process the countryCodes map
236                            this._processCountryCodes();
237                            // process the preferredCountries
238                            this._processPreferredCountries();
239                            // translate countries according to localizedCountries option
240                            if (this.options.localizedCountries) { this._translateCountriesByLocale();
241                            }
242                            // sort countries by name
243                            if (this.options.onlyCountries.length || this.options.localizedCountries) {
244                                this.countries.sort(this._countryNameSort);
245                            }
246                        }
247                    }, {
248                        key: "_addCountryCode",
249                        value: function _addCountryCode(iso2, countryCode, priority)
250                        {
251                            if (countryCode.length > this.countryCodeMaxLen) {
252                                this.countryCodeMaxLen = countryCode.length;
253                            }
254                            if (!this.countryCodes.hasOwnProperty(countryCode)) {
255                                this.countryCodes[countryCode] = [];
256                            }
257                            // bail if we already have this country for this countryCode
258                            for (var i = 0; i < this.countryCodes[countryCode].length; i++) {
259                                if (this.countryCodes[countryCode][i] === iso2) { return;
260                                }
261                            }
262                            // check for undefined as 0 is falsy
263                            var index = priority !== undefined ? priority : this.countryCodes[countryCode].length;
264                            this.countryCodes[countryCode][index] = iso2;
265                        }
266                    }, {
267                        key: "_processAllCountries",
268                        value: function _processAllCountries()
269                        {
270                            if (this.options.onlyCountries.length) {
271                                var lowerCaseOnlyCountries = this.options.onlyCountries.map(
272                                    function (country) {
273                                        return country.toLowerCase();
274                                    }
275                                );
276                                this.countries = allCountries.filter(
277                                    function (country) {
278                                        return lowerCaseOnlyCountries.indexOf(country.iso2) > -1;
279                                    }
280                                );
281                            } else if (this.options.excludeCountries.length) {
282                                var lowerCaseExcludeCountries = this.options.excludeCountries.map(
283                                    function (country) {
284                                        return country.toLowerCase();
285                                    }
286                                );
287                                this.countries = allCountries.filter(
288                                    function (country) {
289                                        return lowerCaseExcludeCountries.indexOf(country.iso2) === -1;
290                                    }
291                                );
292                            } else {
293                                this.countries = allCountries;
294                            }
295                        }
296                    }, {
297                        key: "_translateCountriesByLocale",
298                        value: function _translateCountriesByLocale()
299                        {
300                            for (var i = 0; i < this.countries.length; i++) {
301                                var iso = this.countries[i].iso2.toLowerCase();
302                                if (this.options.localizedCountries.hasOwnProperty(iso)) {
303                                    this.countries[i].name = this.options.localizedCountries[iso];
304                                }
305                            }
306                        }
307                    }, {
308                        key: "_countryNameSort",
309                        value: function _countryNameSort(a, b)
310                        {
311                            return a.name.localeCompare(b.name);
312                        }
313                    }, {
314                        key: "_processCountryCodes",
315                        value: function _processCountryCodes()
316                        {
317                            this.countryCodeMaxLen = 0;
318                            // here we store just dial codes
319                            this.dialCodes = {};
320                            // here we store "country codes" (both dial codes and their area codes)
321                            this.countryCodes = {};
322                            // first: add dial codes
323                            for (var i = 0; i < this.countries.length; i++) {
324                                var c = this.countries[i];
325                                if (!this.dialCodes[c.dialCode]) { this.dialCodes[c.dialCode] = true;
326                                }
327                                this._addCountryCode(c.iso2, c.dialCode, c.priority);
328                            }
329                            // next: add area codes
330                            // this is a second loop over countries, to make sure we have all of the "root" countries
331                            // already in the map, so that we can access them, as each time we add an area code substring
332                            // to the map, we also need to include the "root" country's code, as that also matches
333                            for (var _i = 0; _i < this.countries.length; _i++) {
334                                var _c = this.countries[_i];
335                                // area codes
336                                if (_c.areaCodes) {
337                                    var rootCountryCode = this.countryCodes[_c.dialCode][0];
338                                    // for each area code
339                                    for (var j = 0; j < _c.areaCodes.length; j++) {
340                                        var areaCode = _c.areaCodes[j];
341                                        // for each digit in the area code to add all partial matches as well
342                                        for (var k = 1; k < areaCode.length; k++) {
343                                            var partialDialCode = _c.dialCode + areaCode.substr(0, k);
344                                            // start with the root country, as that also matches this dial code
345                                            this._addCountryCode(rootCountryCode, partialDialCode);
346                                            this._addCountryCode(_c.iso2, partialDialCode);
347                                        }
348                                        // add the full area code
349                                        this._addCountryCode(_c.iso2, _c.dialCode + areaCode);
350                                    }
351                                }
352                            }
353                        }
354                    }, {
355                        key: "_processPreferredCountries",
356                        value: function _processPreferredCountries()
357                        {
358                            this.preferredCountries = [];
359                            for (var i = 0; i < this.options.preferredCountries.length; i++) {
360                                var countryCode = this.options.preferredCountries[i].toLowerCase();
361                                var countryData = this._getCountryData(countryCode, false, true);
362                                if (countryData) { this.preferredCountries.push(countryData);
363                                }
364                            }
365                        }
366                    }, {
367                        key: "_createEl",
368                        value: function _createEl(name, attrs, container)
369                        {
370                            var el = document.createElement(name);
371                            if (attrs) { forEachProp(
372                                attrs, function (key, value) {
373                                    return el.setAttribute(key, value);
374                                }
375                                );
376                            }
377                            if (container) { container.appendChild(el);
378                            }
379                            return el;
380                        }
381                    }, {
382                        key: "_generateMarkup",
383                        value: function _generateMarkup()
384                        {
385                            // if autocomplete does not exist on the element and its form, then
386                            // prevent autocomplete as there's no safe, cross-browser event we can react to, so it can
387                            // easily put the plugin in an inconsistent state e.g. the wrong flag selected for the
388                            // autocompleted number, which on submit could mean wrong number is saved (esp in nationalMode)
389                            if (!this.telInput.hasAttribute("autocomplete") && !(this.telInput.form && this.telInput.form.hasAttribute("autocomplete"))) {
390                                this.telInput.setAttribute("autocomplete", "off");
391                            }
392                            // containers (mostly for positioning)
393                            var parentClass = "iti";
394                            if (this.options.allowDropdown) { parentClass += " iti--allow-dropdown";
395                            }
396                            if (this.options.separateDialCode) { parentClass += " iti--separate-dial-code";
397                            }
398                            if (this.options.customContainer) {
399                                parentClass += " ";
400                                parentClass += this.options.customContainer;
401                            }
402                            var wrapper = this._createEl(
403                                "div", {
404                                    "class": parentClass
405                                }
406                            );
407                            this.telInput.parentNode.insertBefore(wrapper, this.telInput);
408                            this.flagsContainer = this._createEl(
409                                "div", {
410                                    "class": "iti__flag-container"
411                                }, wrapper
412                            );
413                            wrapper.appendChild(this.telInput);
414                            // selected flag (displayed to left of input)
415                            this.selectedFlag = this._createEl(
416                                "div", {
417                                    "class": "iti__selected-flag",
418                                    role: "combobox",
419                                    "aria-controls": "iti-".concat(this.id, "__country-listbox"),
420                                    "aria-owns": "iti-".concat(this.id, "__country-listbox"),
421                                    "aria-expanded": "false"
422                                }, this.flagsContainer
423                            );
424                            this.selectedFlagInner = this._createEl(
425                                "div", {
426                                    "class": "iti__flag"
427                                }, this.selectedFlag
428                            );
429                            if (this.options.separateDialCode) {
430                                this.selectedDialCode = this._createEl(
431                                    "div", {
432                                        "class": "iti__selected-dial-code"
433                                    }, this.selectedFlag
434                                );
435                            }
436                            if (this.options.allowDropdown) {
437                                // make element focusable and tab navigable
438                                this.selectedFlag.setAttribute("tabindex", "0");
439                                this.dropdownArrow = this._createEl(
440                                    "div", {
441                                        "class": "iti__arrow"
442                                    }, this.selectedFlag
443                                );
444                                // country dropdown: preferred countries, then divider, then all countries
445                                this.countryList = this._createEl(
446                                    "ul", {
447                                        "class": "iti__country-list iti__hide",
448                                        id: "iti-".concat(this.id, "__country-listbox"),
449                                        role: "listbox",
450                                        "aria-label": "List of countries"
451                                    }
452                                );
453                                if (this.preferredCountries.length) {
454                                    this._appendListItems(this.preferredCountries, "iti__preferred", true);
455                                    this._createEl(
456                                        "li", {
457                                            "class": "iti__divider",
458                                            role: "separator",
459                                            "aria-disabled": "true"
460                                        }, this.countryList
461                                    );
462                                }
463                                this._appendListItems(this.countries, "iti__standard");
464                                // create dropdownContainer markup
465                                if (this.options.dropdownContainer) {
466                                    this.dropdown = this._createEl(
467                                        "div", {
468                                            "class": "iti iti--container"
469                                        }
470                                    );
471                                    this.dropdown.appendChild(this.countryList);
472                                } else {
473                                    this.flagsContainer.appendChild(this.countryList);
474                                }
475                            }
476                            if (this.options.hiddenInput) {
477                                var hiddenInputName = this.options.hiddenInput;
478                                var name = this.telInput.getAttribute("name");
479                                if (name) {
480                                    var i = name.lastIndexOf("[");
481                                    // if input name contains square brackets, then give the hidden input the same name,
482                                    // replacing the contents of the last set of brackets with the given hiddenInput name
483                                    if (i !== -1) { hiddenInputName = "".concat(name.substr(0, i), "[").concat(hiddenInputName, "]");
484                                    }
485                                }
486                                this.hiddenInput = this._createEl(
487                                    "input", {
488                                        type: "hidden",
489                                        name: hiddenInputName
490                                    }
491                                );
492                                wrapper.appendChild(this.hiddenInput);
493                            }
494                        }
495                    }, {
496                        key: "_appendListItems",
497                        value: function _appendListItems(countries, className, preferred)
498                        {
499                            // we create so many DOM elements, it is faster to build a temp string
500                            // and then add everything to the DOM in one go at the end
501                            var tmp = "";
502                            // for each country
503                            for (var i = 0; i < countries.length; i++) {
504                                var c = countries[i];
vendor: 45,299 bytes, lines 505-1167
505                                var idSuffix = preferred ? "-preferred" : "";
506                                // open the list item
507                                tmp += "<li class='iti__country ".concat(className, "' tabIndex='-1' id='iti-").concat(this.id, "__item-").concat(c.iso2).concat(idSuffix, "' role='option' data-dial-code='").concat(c.dialCode, "' data-country-code='").concat(c.iso2, "' aria-selected='false'>");
508                                // add the flag
509                                tmp += "<div class='iti__flag-box'><div class='iti__flag iti__".concat(c.iso2, "'></div></div>");
510                                // and the country name and dial code
511                                tmp += "<span class='iti__country-name'>".concat(c.name, "</span>");
512                                tmp += "<span class='iti__dial-code'>+".concat(c.dialCode, "</span>");
513                                // close the list item
514                                tmp += "</li>";
515                            }
516                            this.countryList.insertAdjacentHTML("beforeend", tmp);
517                        }
518                    }, {
519                        key: "_setInitialState",
520                        value: function _setInitialState()
521                        {
522                            // fix firefox bug: when first load page (with input with value set to number with intl dial
523                            // code) and initialising plugin removes the dial code from the input, then refresh page,
524                            // and we try to init plugin again but this time on number without dial code so get grey flag
525                            var attributeValue = this.telInput.getAttribute("value");
526                            var inputValue = this.telInput.value;
527                            var useAttribute = attributeValue && attributeValue.charAt(0) === "+" && (!inputValue || inputValue.charAt(0) !== "+");
528                            var val = useAttribute ? attributeValue : inputValue;
529                            var dialCode = this._getDialCode(val);
530                            var isRegionlessNanp = this._isRegionlessNanp(val);
531                            var _this$options = this.options, initialCountry = _this$options.initialCountry, nationalMode = _this$options.nationalMode, autoHideDialCode = _this$options.autoHideDialCode, separateDialCode = _this$options.separateDialCode;
532                            // if we already have a dial code, and it's not a regionlessNanp, we can go ahead and set the
533                            // flag, else fall back to the default country
534                            if (dialCode && !isRegionlessNanp) {
535                                this._updateFlagFromNumber(val);
536                            } else if (initialCountry !== "auto") {
537                                // see if we should select a flag
538                                if (initialCountry) {
539                                    this._setFlag(initialCountry.toLowerCase());
540                                } else {
541                                    if (dialCode && isRegionlessNanp) {
542                                        // has intl dial code, is regionless nanp, and no initialCountry, so default to US
543                                        this._setFlag("us");
544                                    } else {
545                                        // no dial code and no initialCountry, so default to first in list
546                                        this.defaultCountry = this.preferredCountries.length ? this.preferredCountries[0].iso2 : this.countries[0].iso2;
547                                        if (!val) {
548                                            this._setFlag(this.defaultCountry);
549                                        }
550                                    }
551                                }
552                                // if empty and no nationalMode and no autoHideDialCode then insert the default dial code
553                                if (!val && !nationalMode && !autoHideDialCode && !separateDialCode) {
554                                    this.telInput.value = "+".concat(this.selectedCountryData.dialCode);
555                                }
556                            }
557                            // NOTE: if initialCountry is set to auto, that will be handled separately
558                            // format - note this wont be run after _updateDialCode as that's only called if no val
559                            if (val) { this._updateValFromNumber(val);
560                            }
561                        }
562                    }, {
563                        key: "_initListeners",
564                        value: function _initListeners()
565                        {
566                            this._initKeyListeners();
567                            if (this.options.autoHideDialCode) { this._initBlurListeners();
568                            }
569                            if (this.options.allowDropdown) { this._initDropdownListeners();
570                            }
571                            if (this.hiddenInput) { this._initHiddenInputListener();
572                            }
573                        }
574                    }, {
575                        key: "_initHiddenInputListener",
576                        value: function _initHiddenInputListener()
577                        {
578                            var _this3 = this;
579                            this._handleHiddenInputSubmit = function () {
580                                _this3.hiddenInput.value = _this3.getNumber();
581                            };
582                            if (this.telInput.form) { this.telInput.form.addEventListener("submit", this._handleHiddenInputSubmit);
583                            }
584                        }
585                    }, {
586                        key: "_getClosestLabel",
587                        value: function _getClosestLabel()
588                        {
589                            var el = this.telInput;
590                            while (el && el.tagName !== "LABEL") {
591                                el = el.parentNode;
592                            }
593                            return el;
594                        }
595                    }, {
596                        key: "_initDropdownListeners",
597                        value: function _initDropdownListeners()
598                        {
599                            var _this4 = this;
600                            // hack for input nested inside label (which is valid markup): clicking the selected-flag to
601                            // open the dropdown would then automatically trigger a 2nd click on the input which would
602                            // close it again
603                            this._handleLabelClick = function (e) {
604                                // if the dropdown is closed, then focus the input, else ignore the click
605                                if (_this4.countryList.classList.contains("iti__hide")) { _this4.telInput.focus(); } else { e.preventDefault();
606                                }
607                            };
608                            var label = this._getClosestLabel();
609                            if (label) { label.addEventListener("click", this._handleLabelClick);
610                            }
611                            // toggle country dropdown on click
612                            this._handleClickSelectedFlag = function () {
613                                // only intercept this event if we're opening the dropdown
614                                // else let it bubble up to the top ("click-off-to-close" listener)
615                                // we cannot just stopPropagation as it may be needed to close another instance
616                                if (_this4.countryList.classList.contains("iti__hide") && !_this4.telInput.disabled && !_this4.telInput.readOnly) {
617                                    _this4._showDropdown();
618                                }
619                            };
620                            this.selectedFlag.addEventListener("click", this._handleClickSelectedFlag);
621                            // open dropdown list if currently focused
622                            this._handleFlagsContainerKeydown = function (e) {
623                                var isDropdownHidden = _this4.countryList.classList.contains("iti__hide");
624                                if (isDropdownHidden && [ "ArrowUp", "Up", "ArrowDown", "Down", " ", "Enter" ].indexOf(e.key) !== -1) {
625                                    // prevent form from being submitted if "ENTER" was pressed
626                                    e.preventDefault();
627                                    // prevent event from being handled again by document
628                                    e.stopPropagation();
629                                    _this4._showDropdown();
630                                }
631                                // allow navigation from dropdown to input on TAB
632                                if (e.key === "Tab") { _this4._closeDropdown();
633                                }
634                            };
635                            this.flagsContainer.addEventListener("keydown", this._handleFlagsContainerKeydown);
636                        }
637                    }, {
638                        key: "_initRequests",
639                        value: function _initRequests()
640                        {
641                            var _this5 = this;
642                            // if the user has specified the path to the utils script, fetch it on window.load, else resolve
643                            if (this.options.utilsScript && !window.intlTelInputUtils) {
644                                // if the plugin is being initialised after the window.load event has already been fired
645                                if (window.intlTelInputGlobals.documentReady()) {
646                                    window.intlTelInputGlobals.loadUtils(this.options.utilsScript);
647                                } else {
648                                    // wait until the load event so we don't block any other requests e.g. the flags image
649                                    window.addEventListener(
650                                        "load", function () {
651                                            window.intlTelInputGlobals.loadUtils(_this5.options.utilsScript);
652                                        }
653                                    );
654                                }
655                            } else { this.resolveUtilsScriptPromise();
656                            }
657                            if (this.options.initialCountry === "auto") { this._loadAutoCountry(); } else { this.resolveAutoCountryPromise();
658                            }
659                        }
660                    }, {
661                        key: "_loadAutoCountry",
662                        value: function _loadAutoCountry()
663                        {
664                            // 3 options:
665                            // 1) already loaded (we're done)
666                            // 2) not already started loading (start)
667                            // 3) already started loading (do nothing - just wait for loading callback to fire)
668                            if (window.intlTelInputGlobals.autoCountry) {
669                                this.handleAutoCountry();
670                            } else if (!window.intlTelInputGlobals.startedLoadingAutoCountry) {
671                                // don't do this twice!
672                                window.intlTelInputGlobals.startedLoadingAutoCountry = true;
673                                if (typeof this.options.geoIpLookup === "function") {
674                                    this.options.geoIpLookup(
675                                        function (countryCode) {
676                                            window.intlTelInputGlobals.autoCountry = countryCode.toLowerCase();
677                                            // tell all instances the auto country is ready
678                                            // TODO: this should just be the current instances
679                                            // UPDATE: use setTimeout in case their geoIpLookup function calls this callback straight
680                                            // away (e.g. if they have already done the geo ip lookup somewhere else). Using
681                                            // setTimeout means that the current thread of execution will finish before executing
682                                            // this, which allows the plugin to finish initialising.
683                                            setTimeout(
684                                                function () {
685                                                    return forEachInstance("handleAutoCountry");
686                                                }
687                                            );
688                                        }, function () {
689                                            return forEachInstance("rejectAutoCountryPromise");
690                                        }
691                                    );
692                                }
693                            }
694                        }
695                    }, {
696                        key: "_initKeyListeners",
697                        value: function _initKeyListeners()
698                        {
699                            var _this6 = this;
700                            // update flag on keyup
701                            this._handleKeyupEvent = function () {
702                                if (_this6._updateFlagFromNumber(_this6.telInput.value)) {
703                                    _this6._triggerCountryChange();
704                                }
705                            };
706                            this.telInput.addEventListener("keyup", this._handleKeyupEvent);
707                            // update flag on cut/paste events (now supported in all major browsers)
708                            this._handleClipboardEvent = function () {
709                                // hack because "paste" event is fired before input is updated
710                                setTimeout(_this6._handleKeyupEvent);
711                            };
712                            this.telInput.addEventListener("cut", this._handleClipboardEvent);
713                            this.telInput.addEventListener("paste", this._handleClipboardEvent);
714                        }
715                    }, {
716                        key: "_cap",
717                        value: function _cap(number)
718                        {
719                            var max = this.telInput.getAttribute("maxlength");
720                            return max && number.length > max ? number.substr(0, max) : number;
721                        }
722                    }, {
723                        key: "_initBlurListeners",
724                        value: function _initBlurListeners()
725                        {
726                            var _this7 = this;
727                            // on blur or form submit: if just a dial code then remove it
728                            this._handleSubmitOrBlurEvent = function () {
729                                _this7._removeEmptyDialCode();
730                            };
731                            if (this.telInput.form) { this.telInput.form.addEventListener("submit", this._handleSubmitOrBlurEvent);
732                            }
733                            this.telInput.addEventListener("blur", this._handleSubmitOrBlurEvent);
734                        }
735                    }, {
736                        key: "_removeEmptyDialCode",
737                        value: function _removeEmptyDialCode()
738                        {
739                            if (this.telInput.value.charAt(0) === "+") {
740                                var numeric = this._getNumeric(this.telInput.value);
741                                // if just a plus, or if just a dial code
742                                if (!numeric || this.selectedCountryData.dialCode === numeric) {
743                                    this.telInput.value = "";
744                                }
745                            }
746                        }
747                    }, {
748                        key: "_getNumeric",
749                        value: function _getNumeric(s)
750                        {
751                            return s.replace(/\D/g, "");
752                        }
753                    }, {
754                        key: "_trigger",
755                        value: function _trigger(name)
756                        {
757                            // have to use old school document.createEvent as IE11 doesn't support `new Event()` syntax
758                            var e = document.createEvent("Event");
759                            e.initEvent(name, true, true);
760                            // can bubble, and is cancellable
761                            this.telInput.dispatchEvent(e);
762                        }
763                    }, {
764                        key: "_showDropdown",
765                        value: function _showDropdown()
766                        {
767                            this.countryList.classList.remove("iti__hide");
768                            this.selectedFlag.setAttribute("aria-expanded", "true");
769                            this._setDropdownPosition();
770                            // update highlighting and scroll to active list item
771                            if (this.activeItem) {
772                                this._highlightListItem(this.activeItem, false);
773                                this._scrollTo(this.activeItem, true);
774                            }
775                            // bind all the dropdown-related listeners: mouseover, click, click-off, keydown
776                            this._bindDropdownListeners();
777                            // update the arrow
778                            this.dropdownArrow.classList.add("iti__arrow--up");
779                            this._trigger("open:countrydropdown");
780                        }
781                    }, {
782                        key: "_toggleClass",
783                        value: function _toggleClass(el, className, shouldHaveClass)
784                        {
785                            if (shouldHaveClass && !el.classList.contains(className)) { el.classList.add(className); } else if (!shouldHaveClass && el.classList.contains(className)) { el.classList.remove(className);
786                            }
787                        }
788                    }, {
789                        key: "_setDropdownPosition",
790                        value: function _setDropdownPosition()
791                        {
792                            var _this8 = this;
793                            if (this.options.dropdownContainer) {
794                                this.options.dropdownContainer.appendChild(this.dropdown);
795                            }
796                            if (!this.isMobile) {
797                                var pos = this.telInput.getBoundingClientRect();
798                                // windowTop from https://stackoverflow.com/a/14384091/217866
799                                var windowTop = window.pageYOffset || document.documentElement.scrollTop;
800                                var inputTop = pos.top + windowTop;
801                                var dropdownHeight = this.countryList.offsetHeight;
802                                // dropdownFitsBelow = (dropdownBottom < windowBottom)
803                                var dropdownFitsBelow = inputTop + this.telInput.offsetHeight + dropdownHeight < windowTop + window.innerHeight;
804                                var dropdownFitsAbove = inputTop - dropdownHeight > windowTop;
805                                // by default, the dropdown will be below the input. If we want to position it above the
806                                // input, we add the dropup class.
807                                this._toggleClass(this.countryList, "iti__country-list--dropup", !dropdownFitsBelow && dropdownFitsAbove);
808                                // if dropdownContainer is enabled, calculate postion
809                                if (this.options.dropdownContainer) {
810                                    // by default the dropdown will be directly over the input because it's not in the flow.
811                                    // If we want to position it below, we need to add some extra top value.
812                                    var extraTop = !dropdownFitsBelow && dropdownFitsAbove ? 0 : this.telInput.offsetHeight;
813                                    // calculate placement
814                                    this.dropdown.style.top = "".concat(inputTop + extraTop, "px");
815                                    this.dropdown.style.left = "".concat(pos.left + document.body.scrollLeft, "px");
816                                    // close menu on window scroll
817                                    this._handleWindowScroll = function () {
818                                        return _this8._closeDropdown();
819                                    };
820                                    window.addEventListener("scroll", this._handleWindowScroll);
821                                }
822                            }
823                        }
824                    }, {
825                        key: "_getClosestListItem",
826                        value: function _getClosestListItem(target)
827                        {
828                            var el = target;
829                            while (el && el !== this.countryList && !el.classList.contains("iti__country")) {
830                                el = el.parentNode;
831                            }
832                            // if we reached the countryList element, then return null
833                            return el === this.countryList ? null : el;
834                        }
835                    }, {
836                        key: "_bindDropdownListeners",
837                        value: function _bindDropdownListeners()
838                        {
839                            var _this9 = this;
840                            // when mouse over a list item, just highlight that one
841                            // we add the class "highlight", so if they hit "enter" we know which one to select
842                            this._handleMouseoverCountryList = function (e) {
843                                // handle event delegation, as we're listening for this event on the countryList
844                                var listItem = _this9._getClosestListItem(e.target);
845                                if (listItem) { _this9._highlightListItem(listItem, false);
846                                }
847                            };
848                            this.countryList.addEventListener("mouseover", this._handleMouseoverCountryList);
849                            // listen for country selection
850                            this._handleClickCountryList = function (e) {
851                                var listItem = _this9._getClosestListItem(e.target);
852                                if (listItem) { _this9._selectListItem(listItem);
853                                }
854                            };
855                            this.countryList.addEventListener("click", this._handleClickCountryList);
856                            // click off to close
857                            // (except when this initial opening click is bubbling up)
858                            // we cannot just stopPropagation as it may be needed to close another instance
859                            var isOpening = true;
860                            this._handleClickOffToClose = function () {
861                                if (!isOpening) { _this9._closeDropdown();
862                                }
863                                isOpening = false;
864                            };
865                            document.documentElement.addEventListener("click", this._handleClickOffToClose);
866                            // listen for up/down scrolling, enter to select, or letters to jump to country name.
867                            // use keydown as keypress doesn't fire for non-char keys and we want to catch if they
868                            // just hit down and hold it to scroll down (no keyup event).
869                            // listen on the document because that's where key events are triggered if no input has focus
870                            var query = "";
871                            var queryTimer = null;
872                            this._handleKeydownOnDropdown = function (e) {
873                                // prevent down key from scrolling the whole page,
874                                // and enter key from submitting a form etc
875                                e.preventDefault();
876                                // up and down to navigate
877                                if (e.key === "ArrowUp" || e.key === "Up" || e.key === "ArrowDown" || e.key === "Down") { _this9._handleUpDownKey(e.key); } else if (e.key === "Enter") { _this9._handleEnterKey(); } else if (e.key === "Escape") { _this9._closeDropdown(); } else if (/^[a-zA-ZÀ-ÿа-яА-Я ]$/.test(e.key)) {
878                                    // jump to countries that start with the query string
879                                    if (queryTimer) { clearTimeout(queryTimer);
880                                    }
881                                    query += e.key.toLowerCase();
882                                    _this9._searchForCountry(query);
883                                    // if the timer hits 1 second, reset the query
884                                    queryTimer = setTimeout(
885                                        function () {
886                                            query = "";
887                                        }, 1e3
888                                    );
889                                }
890                            };
891                            document.addEventListener("keydown", this._handleKeydownOnDropdown);
892                        }
893                    }, {
894                        key: "_handleUpDownKey",
895                        value: function _handleUpDownKey(key)
896                        {
897                            var next = key === "ArrowUp" || key === "Up" ? this.highlightedItem.previousElementSibling : this.highlightedItem.nextElementSibling;
898                            if (next) {
899                                // skip the divider
900                                if (next.classList.contains("iti__divider")) {
901                                    next = key === "ArrowUp" || key === "Up" ? next.previousElementSibling : next.nextElementSibling;
902                                }
903                                this._highlightListItem(next, true);
904                            }
905                        }
906                    }, {
907                        key: "_handleEnterKey",
908                        value: function _handleEnterKey()
909                        {
910                            if (this.highlightedItem) { this._selectListItem(this.highlightedItem);
911                            }
912                        }
913                    }, {
914                        key: "_searchForCountry",
915                        value: function _searchForCountry(query)
916                        {
917                            for (var i = 0; i < this.countries.length; i++) {
918                                if (this._startsWith(this.countries[i].name, query)) {
919                                    var listItem = this.countryList.querySelector("#iti-".concat(this.id, "__item-").concat(this.countries[i].iso2));
920                                    // update highlighting and scroll
921                                    this._highlightListItem(listItem, false);
922                                    this._scrollTo(listItem, true);
923                                    break;
924                                }
925                            }
926                        }
927                    }, {
928                        key: "_startsWith",
929                        value: function _startsWith(a, b)
930                        {
931                            return a.substr(0, b.length).toLowerCase() === b;
932                        }
933                    }, {
934                        key: "_updateValFromNumber",
935                        value: function _updateValFromNumber(originalNumber)
936                        {
937                            var number = originalNumber;
938                            if (this.options.formatOnDisplay && window.intlTelInputUtils && this.selectedCountryData) {
939                                var useNational = !this.options.separateDialCode && (this.options.nationalMode || number.charAt(0) !== "+");
940                                var _intlTelInputUtils$nu = intlTelInputUtils.numberFormat, NATIONAL = _intlTelInputUtils$nu.NATIONAL, INTERNATIONAL = _intlTelInputUtils$nu.INTERNATIONAL;
941                                var format = useNational ? NATIONAL : INTERNATIONAL;
942                                number = intlTelInputUtils.formatNumber(number, this.selectedCountryData.iso2, format);
943                            }
944                            number = this._beforeSetNumber(number);
945                            this.telInput.value = number;
946                        }
947                    }, {
948                        key: "_updateFlagFromNumber",
949                        value: function _updateFlagFromNumber(originalNumber)
950                        {
951                            // if we're in nationalMode and we already have US/Canada selected, make sure the number starts
952                            // with a +1 so _getDialCode will be able to extract the area code
953                            // update: if we dont yet have selectedCountryData, but we're here (trying to update the flag
954                            // from the number), that means we're initialising the plugin with a number that already has a
955                            // dial code, so fine to ignore this bit
956                            var number = originalNumber;
957                            var selectedDialCode = this.selectedCountryData.dialCode;
958                            var isNanp = selectedDialCode === "1";
959                            if (number && this.options.nationalMode && isNanp && number.charAt(0) !== "+") {
960                                if (number.charAt(0) !== "1") { number = "1".concat(number);
961                                }
962                                number = "+".concat(number);
963                            }
964                            // update flag if user types area code for another country
965                            if (this.options.separateDialCode && selectedDialCode && number.charAt(0) !== "+") {
966                                number = "+".concat(selectedDialCode).concat(number);
967                            }
968                            // try and extract valid dial code from input
969                            var dialCode = this._getDialCode(number, true);
970                            var numeric = this._getNumeric(number);
971                            var countryCode = null;
972                            if (dialCode) {
973                                var countryCodes = this.countryCodes[this._getNumeric(dialCode)];
974                                // check if the right country is already selected. this should be false if the number is
975                                // longer than the matched dial code because in this case we need to make sure that if
976                                // there are multiple country matches, that the first one is selected (note: we could
977                                // just check that here, but it requires the same loop that we already have later)
978                                var alreadySelected = countryCodes.indexOf(this.selectedCountryData.iso2) !== -1 && numeric.length <= dialCode.length - 1;
979                                var isRegionlessNanpNumber = selectedDialCode === "1" && this._isRegionlessNanp(numeric);
980                                // only update the flag if:
981                                // A) NOT (we currently have a NANP flag selected, and the number is a regionlessNanp)
982                                // AND
983                                // B) the right country is not already selected
984                                if (!isRegionlessNanpNumber && !alreadySelected) {
985                                    // if using onlyCountries option, countryCodes[0] may be empty, so we must find the first
986                                    // non-empty index
987                                    for (var j = 0; j < countryCodes.length; j++) {
988                                        if (countryCodes[j]) {
989                                            countryCode = countryCodes[j];
990                                            break;
991                                        }
992                                    }
993                                }
994                            } else if (number.charAt(0) === "+" && numeric.length) {
995                                // invalid dial code, so empty
996                                // Note: use getNumeric here because the number has not been formatted yet, so could contain
997                                // bad chars
998                                countryCode = "";
999                            } else if (!number || number === "+") {
1000                                // empty, or just a plus, so default
1001                                countryCode = this.defaultCountry;
1002                            }
1003                            if (countryCode !== null) {
1004                                return this._setFlag(countryCode);
1005                            }
1006                            return false;
1007                        }
1008                    }, {
1009                        key: "_isRegionlessNanp",
1010                        value: function _isRegionlessNanp(number)
1011                        {
1012                            var numeric = this._getNumeric(number);
1013                            if (numeric.charAt(0) === "1") {
1014                                var areaCode = numeric.substr(1, 3);
1015                                return regionlessNanpNumbers.indexOf(areaCode) !== -1;
1016                            }
1017                            return false;
1018                        }
1019                    }, {
1020                        key: "_highlightListItem",
1021                        value: function _highlightListItem(listItem, shouldFocus)
1022                        {
1023                            var prevItem = this.highlightedItem;
1024                            if (prevItem) { prevItem.classList.remove("iti__highlight");
1025                            }
1026                            this.highlightedItem = listItem;
1027                            this.highlightedItem.classList.add("iti__highlight");
1028                            if (shouldFocus) { this.highlightedItem.focus();
1029                            }
1030                        }
1031                    }, {
1032                        key: "_getCountryData",
1033                        value: function _getCountryData(countryCode, ignoreOnlyCountriesOption, allowFail)
1034                        {
1035                            var countryList = ignoreOnlyCountriesOption ? allCountries : this.countries;
1036                            for (var i = 0; i < countryList.length; i++) {
1037                                if (countryList[i].iso2 === countryCode) {
1038                                    return countryList[i];
1039                                }
1040                            }
1041                            if (allowFail) {
1042                                return null;
1043                            }
1044                            throw new Error("No country data for '".concat(countryCode, "'"));
1045                        }
1046                    }, {
1047                        key: "_setFlag",
1048                        value: function _setFlag(countryCode)
1049                        {
1050                            var prevCountry = this.selectedCountryData.iso2 ? this.selectedCountryData : {};
1051                            // do this first as it will throw an error and stop if countryCode is invalid
1052                            this.selectedCountryData = countryCode ? this._getCountryData(countryCode, false, false) : {};
1053                            // update the defaultCountry - we only need the iso2 from now on, so just store that
1054                            if (this.selectedCountryData.iso2) {
1055                                this.defaultCountry = this.selectedCountryData.iso2;
1056                            }
1057                            this.selectedFlagInner.setAttribute("class", "iti__flag iti__".concat(countryCode));
1058                            // update the selected country's title attribute
1059                            var title = countryCode ? "".concat(this.selectedCountryData.name, ": +").concat(this.selectedCountryData.dialCode) : "Unknown";
1060                            this.selectedFlag.setAttribute("title", title);
1061                            if (this.options.separateDialCode) {
1062                                var dialCode = this.selectedCountryData.dialCode ? "+".concat(this.selectedCountryData.dialCode) : "";
1063                                this.selectedDialCode.innerHTML = dialCode;
1064                                // offsetWidth is zero if input is in a hidden container during initialisation
1065                                var selectedFlagWidth = this.selectedFlag.offsetWidth || this._getHiddenSelectedFlagWidth();
1066                                // add 6px of padding after the grey selected-dial-code box, as this is what we use in the css
1067                                this.telInput.style.paddingLeft = "".concat(selectedFlagWidth + 6, "px");
1068                            }
1069                            // and the input's placeholder
1070                            this._updatePlaceholder();
1071                            // update the active list item
1072                            if (this.options.allowDropdown) {
1073                                var prevItem = this.activeItem;
1074                                if (prevItem) {
1075                                    prevItem.classList.remove("iti__active");
1076                                    prevItem.setAttribute("aria-selected", "false");
1077                                }
1078                                if (countryCode) {
1079                                    // check if there is a preferred item first, else fall back to standard
1080                                    var nextItem = this.countryList.querySelector("#iti-".concat(this.id, "__item-").concat(countryCode, "-preferred")) || this.countryList.querySelector("#iti-".concat(this.id, "__item-").concat(countryCode));
1081                                    nextItem.setAttribute("aria-selected", "true");
1082                                    nextItem.classList.add("iti__active");
1083                                    this.activeItem = nextItem;
1084                                    this.selectedFlag.setAttribute("aria-activedescendant", nextItem.getAttribute("id"));
1085                                }
1086                            }
1087                            // return if the flag has changed or not
1088                            return prevCountry.iso2 !== countryCode;
1089                        }
1090                    }, {
1091                        key: "_getHiddenSelectedFlagWidth",
1092                        value: function _getHiddenSelectedFlagWidth()
1093                        {
1094                            // to get the right styling to apply, all we need is a shallow clone of the container,
1095                            // and then to inject a deep clone of the selectedFlag element
1096                            var containerClone = this.telInput.parentNode.cloneNode();
1097                            containerClone.style.visibility = "hidden";
1098                            document.body.appendChild(containerClone);
1099                            var flagsContainerClone = this.flagsContainer.cloneNode();
1100                            containerClone.appendChild(flagsContainerClone);
1101                            var selectedFlagClone = this.selectedFlag.cloneNode(true);
1102                            flagsContainerClone.appendChild(selectedFlagClone);
1103                            var width = selectedFlagClone.offsetWidth;
1104                            containerClone.parentNode.removeChild(containerClone);
1105                            return width;
1106                        }
1107                    }, {
1108                        key: "_updatePlaceholder",
1109                        value: function _updatePlaceholder()
1110                        {
1111                            var shouldSetPlaceholder = this.options.autoPlaceholder === "aggressive" || !this.hadInitialPlaceholder && this.options.autoPlaceholder === "polite";
1112                            if (window.intlTelInputUtils && shouldSetPlaceholder) {
1113                                var numberType = intlTelInputUtils.numberType[this.options.placeholderNumberType];
1114                                var placeholder = this.selectedCountryData.iso2 ? intlTelInputUtils.getExampleNumber(this.selectedCountryData.iso2, this.options.nationalMode, numberType) : "";
1115                                placeholder = this._beforeSetNumber(placeholder);
1116                                if (typeof this.options.customPlaceholder === "function") {
1117                                    placeholder = this.options.customPlaceholder(placeholder, this.selectedCountryData);
1118                                }
1119                                this.telInput.setAttribute("placeholder", placeholder);
1120                            }
1121                        }
1122                    }, {
1123                        key: "_selectListItem",
1124                        value: function _selectListItem(listItem)
1125                        {
1126                            // update selected flag and active list item
1127                            var flagChanged = this._setFlag(listItem.getAttribute("data-country-code"));
1128                            this._closeDropdown();
1129                            this._updateDialCode(listItem.getAttribute("data-dial-code"), true);
1130                            // focus the input
1131                            this.telInput.focus();
1132                            // put cursor at end - this fix is required for FF and IE11 (with nationalMode=false i.e. auto
1133                            // inserting dial code), who try to put the cursor at the beginning the first time
1134                            var len = this.telInput.value.length;
1135                            this.telInput.setSelectionRange(len, len);
1136                            if (flagChanged) {
1137                                this._triggerCountryChange();
1138                            }
1139                        }
1140                    }, {
1141                        key: "_closeDropdown",
1142                        value: function _closeDropdown()
1143                        {
1144                            this.countryList.classList.add("iti__hide");
1145                            this.selectedFlag.setAttribute("aria-expanded", "false");
1146                            // update the arrow
1147                            this.dropdownArrow.classList.remove("iti__arrow--up");
1148                            // unbind key events
1149                            document.removeEventListener("keydown", this._handleKeydownOnDropdown);
1150                            document.documentElement.removeEventListener("click", this._handleClickOffToClose);
1151                            this.countryList.removeEventListener("mouseover", this._handleMouseoverCountryList);
1152                            this.countryList.removeEventListener("click", this._handleClickCountryList);
1153                            // remove menu from container
1154                            if (this.options.dropdownContainer) {
1155                                if (!this.isMobile) { window.removeEventListener("scroll", this._handleWindowScroll);
1156                                }
1157                                if (this.dropdown.parentNode) { this.dropdown.parentNode.removeChild(this.dropdown);
1158                                }
1159                            }
1160                            this._trigger("close:countrydropdown");
1161                        }
1162                    }, {
1163                        key: "_scrollTo",
1164                        value: function _scrollTo(element, middle)
1165                        {
1166                            var container = this.countryList;
1167                            // windowTop from https://stackoverflow.com/a/14384091/2
116717866
1168                            var windowTop = window.pageYOffset || document.documentElement.scrollTop;
1169                            var containerHeight = container.offsetHeight;
1170                            var containerTop = container.getBoundingClientRect().top + windowTop;
1171                            var containerBottom = containerTop + containerHeight;
1172                            var elementHeight = element.offsetHeight;
1173                            var elementTop = element.getBoundingClientRect().top + windowTop;
1174                            var elementBottom = elementTop + elementHeight;
1175                            var newScrollTop = elementTop - containerTop + container.scrollTop;
1176                            var middleOffset = containerHeight / 2 - elementHeight / 2;
1177                            if (elementTop < containerTop) {
1178                                // scroll up
1179                                if (middle) { newScrollTop -= middleOffset;
1180                                }
1181                                container.scrollTop = newScrollTop;
1182                            } else if (elementBottom > containerBottom) {
1183                                // scroll down
1184                                if (middle) { newScrollTop += middleOffset;
1185                                }
1186                                var heightDifference = containerHeight - elementHeight;
1187                                container.scrollTop = newScrollTop - heightDifference;
1188                            }
1189                        }
1190                    }, {
1191                        key: "_updateDialCode",
1192                        value: function _updateDialCode(newDialCodeBare, hasSelectedListItem)
1193                        {
1194                            var inputVal = this.telInput.value;
1195                            // save having to pass this every time
1196                            var newDialCode = "+".concat(newDialCodeBare);
1197                            var newNumber;
1198                            if (inputVal.charAt(0) === "+") {
1199                                // there's a plus so we're dealing with a replacement (doesn't matter if nationalMode or not)
1200                                var prevDialCode = this._getDialCode(inputVal);
1201                                if (prevDialCode) {
1202                                    // current number contains a valid dial code, so replace it
1203                                    newNumber = inputVal.replace(prevDialCode, newDialCode);
1204                                } else {
1205                                    // current number contains an invalid dial code, so ditch it
1206                                    // (no way to determine where the invalid dial code ends and the rest of the number begins)
1207                                    newNumber = newDialCode;
1208                                }
1209                            } else if (this.options.nationalMode || this.options.separateDialCode) {
1210                                // don't do anything
1211                                return;
1212                            } else {
1213                                // nationalMode is disabled
1214                                if (inputVal) {
1215                                    // there is an existing value with no dial code: prefix the new dial code
1216                                    newNumber = newDialCode + inputVal;
1217                                } else if (hasSelectedListItem || !this.options.autoHideDialCode) {
1218                                    // no existing value and either they've just selected a list item, or autoHideDialCode is
1219                                    // disabled: insert new dial code
1220                                    newNumber = newDialCode;
1221                                } else {
1222                                    return;
1223                                }
1224                            }
1225                            this.telInput.value = newNumber;
1226                        }
1227                    }, {
1228                        key: "_getDialCode",
1229                        value: function _getDialCode(number, includeAreaCode)
1230                        {
1231                            var dialCode = "";
1232                            // only interested in international numbers (starting with a plus)
1233                            if (number.charAt(0) === "+") {
1234                                var numericChars = "";
1235                                // iterate over chars
1236                                for (var i = 0; i < number.length; i++) {
1237                                    var c = number.charAt(i);
1238                                    // if char is number (https://stackoverflow.com/a/8935649/217866)
1239                                    if (!isNaN(parseInt(c, 10))) {
1240                                        numericChars += c;
vendor: 5,485 bytes, lines 1241-1328
1241                                        // if current numericChars make a valid dial code
1242                                        if (includeAreaCode) {
1243                                            if (this.countryCodes[numericChars]) {
1244                                                // store the actual raw string (useful for matching later)
1245                                                dialCode = number.substr(0, i + 1);
1246                                            }
1247                                        } else {
1248                                            if (this.dialCodes[numericChars]) {
1249                                                dialCode = number.substr(0, i + 1);
1250                                                // if we're just looking for a dial code, we can break as soon as we find one
1251                                                break;
1252                                            }
1253                                        }
1254                                        // stop searching as soon as we can - in this case when we hit max len
1255                                        if (numericChars.length === this.countryCodeMaxLen) {
1256                                            break;
1257                                        }
1258                                    }
1259                                }
1260                            }
1261                            return dialCode;
1262                        }
1263                    }, {
1264                        key: "_getFullNumber",
1265                        value: function _getFullNumber()
1266                        {
1267                            var val = this.telInput.value.trim();
1268                            var dialCode = this.selectedCountryData.dialCode;
1269                            var prefix;
1270                            var numericVal = this._getNumeric(val);
1271                            if (this.options.separateDialCode && val.charAt(0) !== "+" && dialCode && numericVal) {
1272                                // when using separateDialCode, it is visible so is effectively part of the typed number
1273                                prefix = "+".concat(dialCode);
1274                            } else {
1275                                prefix = "";
1276                            }
1277                            return prefix + val;
1278                        }
1279                    }, {
1280                        key: "_beforeSetNumber",
1281                        value: function _beforeSetNumber(originalNumber)
1282                        {
1283                            var number = originalNumber;
1284                            if (this.options.separateDialCode) {
1285                                var dialCode = this._getDialCode(number);
1286                                // if there is a valid dial code
1287                                if (dialCode) {
1288                                    // in case _getDialCode returned an area code as well
1289                                    dialCode = "+".concat(this.selectedCountryData.dialCode);
1290                                    // a lot of numbers will have a space separating the dial code and the main number, and
1291                                    // some NANP numbers will have a hyphen e.g. +1 684-733-1234 - in both cases we want to get
1292                                    // rid of it
1293                                    // NOTE: don't just trim all non-numerics as may want to preserve an open parenthesis etc
1294                                    var start = number[dialCode.length] === " " || number[dialCode.length] === "-" ? dialCode.length + 1 : dialCode.length;
1295                                    number = number.substr(start);
1296                                }
1297                            }
1298                            return this._cap(number);
1299                        }
1300                    }, {
1301                        key: "_triggerCountryChange",
1302                        value: function _triggerCountryChange()
1303                        {
1304                            this._trigger("countrychange");
1305                        }
1306                    }, {
1307                        key: "handleAutoCountry",
1308                        value: function handleAutoCountry()
1309                        {
1310                            if (this.options.initialCountry === "auto") {
1311                                // we must set this even if there is an initial val in the input: in case the initial val is
1312                                // invalid and they delete it - they should see their auto country
1313                                this.defaultCountry = window.intlTelInputGlobals.autoCountry;
1314                                // if there's no initial value in the input, then update the flag
1315                                if (!this.telInput.value) {
1316                                    this.setCountry(this.defaultCountry);
1317                                }
1318                                this.resolveAutoCountryPromise();
1319                            }
1320                        }
1321                    }, {
1322                        key: "handleUtils",
1323                        value: function handleUtils()
1324                        {
1325                            // if the request was successful
1326                            if (window.intlTelInputUtils) {
1327                                // if there's an initial value in the input, then format it
1328                                if (this.telInput.value) {
1329                                    this._updateValFromNumber(this.telInput.value);
1330                                }
1331                                this._updatePlaceholder();
1332                            }
1333                            this.resolveUtilsScriptPromise();
1334                        }
1335                    }, {
1336                        key: "destroy",
1337                        value: function destroy()
1338                        {
1339                            var form = this.telInput.form;
1340                            if (this.options.allowDropdown) {
1341                                // make sure the dropdown is closed (and unbind listeners)
1342                                this._closeDropdown();
1343                                this.selectedFlag.removeEventListener("click", this._handleClickSelectedFlag);
1344                                this.flagsContainer.removeEventListener("keydown", this._handleFlagsContainerKeydown);
1345                                // label click hack
1346                                var label = this._getClosestLabel();
1347                                if (label) { label.removeEventListener("click", this._handleLabelClick);
1348                                }
1349                            }
1350                            // unbind hiddenInput listeners
1351                            if (this.hiddenInput && form) { form.removeEventListener("submit", this._handleHiddenInputSubmit);
1352                            }
1353                            // unbind autoHideDialCode listeners
1354                            if (this.options.autoHideDialCode) {
1355                                if (form) { form.removeEventListener("submit", this._handleSubmitOrBlurEvent);
1356                                }
1357                                this.telInput.removeEventListener("blur", this._handleSubmitOrBlurEvent);
1358                            }
1359                            // unbind key events, and cut/paste events
1360                            this.telInput.removeEventListener("keyup", this._handleKeyupEvent);
1361                            this.telInput.removeEventListener("cut", this._handleClipboardEvent);
1362                            this.telInput.removeEventListener("paste", this._handleClipboardEvent);
1363                            // remove attribute of id instance: data-intl-tel-input-id
1364                            this.telInput.removeAttribute("data-intl-tel-input-id");
1365                            // remove markup (but leave the original input)
1366                            var wrapper = this.telInput.parentNode;
1367                            wrapper.parentNode.insertBefore(this.telInput, wrapper);
1368                            wrapper.parentNode.removeChild(wrapper);
1369                            delete window.intlTelInputGlobals.instances[this.id];
1370                        }
1371                    }, {
1372                        key: "getExtension",
1373                        value: function getExtension()
1374                        {
1375                            if (window.intlTelInputUtils) {
1376                                return intlTelInputUtils.getExtension(this._getFullNumber(), this.selectedCountryData.iso2);
1377                            }
1378                            return "";
1379                        }
1380                    }, {
1381                        key: "getNumber",
1382                        value: function getNumber(format)
1383                        {
1384                            if (window.intlTelInputUtils) {
1385                                var iso2 = this.selectedCountryData.iso2;
1386                                return intlTelInputUtils.formatNumber(this._getFullNumber(), iso2, format);
1387                            }
1388                            return "";
1389                        }
1390                    }, {
1391                        key: "getNumberType",
1392                        value: function getNumberType()
1393                        {
1394                            if (window.intlTelInputUtils) {
1395                                return intlTelInputUtils.getNumberType(this._getFullNumber(), this.selectedCountryData.iso2);
1396                            }
1397                            return -99;
1398                        }
1399                    }, {
1400                        key: "getSelectedCountryData",
1401                        value: function getSelectedCountryData()
1402                        {
1403                            return this.selectedCountryData;
1404                        }
1405                    }, {
1406                        key: "getValidationError",
1407                        value: function getValidationError()
1408                        {
1409                            if (window.intlTelInputUtils) {
1410                                var iso2 = this.selectedCountryData.iso2;
1411                                return intlTelInputUtils.getValidationError(this._getFullNumber(), iso2);
1412                            }
1413                            return -99;
1414                        }
1415                    }, {
1416                        key: "isValidNumber",
1417                        value: function isValidNumber()
1418                        {
1419                            var val = this._getFullNumber().trim();
1420                            var countryCode = this.options.nationalMode ? this.selectedCountryData.iso2 : "";
1421                            return window.intlTelInputUtils ? intlTelInputUtils.isValidNumber(val, countryCode) : null;
1422                        }
1423                    }, {
1424                        key: "setCountry",
1425                        value: function setCountry(originalCountryCode)
1426                        {
1427                            var countryCode = originalCountryCode.toLowerCase();
1428                            // check if already selected
1429                            if (!this.selectedFlagInner.classList.contains("iti__".concat(countryCode))) {
1430                                this._setFlag(countryCode);
1431                                this._updateDialCode(this.selectedCountryData.dialCode, false);
1432                                this._triggerCountryChange();
1433                            }
1434                        }
1435                    }, {
1436                        key: "setNumber",
1437                        value: function setNumber(number)
1438                        {
1439                            // we must update the flag first, which updates this.selectedCountryData, which is used for
1440                            // formatting the number before displaying it
1441                            var flagChanged = this._updateFlagFromNumber(number);
vendor: 3,501 bytes, lines 1442-1520
1442                            this._updateValFromNumber(number);
1443                            if (flagChanged) {
1444                                this._triggerCountryChange();
1445                            }
1446                        }
1447                    }, {
1448                        key: "setPlaceholderNumberType",
1449                        value: function setPlaceholderNumberType(type)
1450                        {
1451                            this.options.placeholderNumberType = type;
1452                            this._updatePlaceholder();
1453                        }
1454                    } ]
1455                );
1456                return Iti;
1457            }();
1458            /********************
1459        *  STATIC METHODS
1460        ********************/
1461            // get the country data object
1462            intlTelInputGlobals.getCountryData = function () {
1463                return allCountries;
1464            };
1465            // inject a <script> element to load utils.js
1466            var injectScript = function injectScript(path, handleSuccess, handleFailure)
1467            {
1468                // inject a new script element into the page
1469                var script = document.createElement("script");
1470                script.onload = function () {
1471                    forEachInstance("handleUtils");
1472                    if (handleSuccess) { handleSuccess();
1473                    }
1474                };
1475                script.onerror = function () {
1476                    forEachInstance("rejectUtilsScriptPromise");
1477                    if (handleFailure) { handleFailure();
1478                    }
1479                };
1480                script.className = "iti-load-utils";
1481                script.async = true;
1482                script.src = path;
1483                document.body.appendChild(script);
1484            };
1485            // load the utils script
1486            intlTelInputGlobals.loadUtils = function (path) {
1487                // 2 options:
1488                // 1) not already started loading (start)
1489                // 2) already started loading (do nothing - just wait for the onload callback to fire, which will
1490                // trigger handleUtils on all instances, invoking their resolveUtilsScriptPromise functions)
1491                if (!window.intlTelInputUtils && !window.intlTelInputGlobals.startedLoadingUtilsScript) {
1492                    // only do this once
1493                    window.intlTelInputGlobals.startedLoadingUtilsScript = true;
1494                    // if we have promises, then return a promise
1495                    if (typeof Promise !== "undefined") {
1496                        return new Promise(
1497                            function (resolve, reject) {
1498                                return injectScript(path, resolve, reject);
1499                            }
1500                        );
1501                    }
1502                    injectScript(path);
1503                }
1504                return null;
1505            };
1506            // default options
1507            intlTelInputGlobals.defaults = defaults;
1508            // version
1509            intlTelInputGlobals.version = "17.0.16";
1510            // convenience wrapper
1511            return function (input, options) {
1512                var iti = new Iti(input, options);
1513                iti._init();
1514                input.setAttribute("data-intl-tel-input-id", iti.id);
1515                window.intlTelInputGlobals.instances[iti.id] = iti;
1516                return iti;
1517            };
1518        }();
1519    }
1520);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.