PageSourceSearch

https://aadme.co/wp-content/plugins/telephone-field-for-elementor-…/lib/js/intlTelInput-jquery.js?ver=7.1.3

js aadme.co collected 2026-10-07 15:28:38 UTC 121,065 bytes, 1,815 lines download raw bytes

1/*
2 * International Telephone Input v20.0.4
3 * https://github.com/jackocnr/intl-tel-input.git
4 * Licensed under the MIT license
5 */
6// wrap in UMD
7(function(factory) {
8    if (typeof module === "object" && module.exports) {
9        module.exports = factory(require("jquery"));
10    } else if (typeof define === "function" && define.amd) {
11        define([ "jquery" ], function($) {
12            factory($);
13        });
14    } else factory(jQuery);
15})(function($, undefined) {
16    "use strict";
17    // Array of country objects for the flag dropdown.
18    // Here is the criteria for the plugin to support a given country/territory
19    // - It has an iso2 code: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
20    // - 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
21    // - It has a flag in the region-flags project: https://github.com/behdad/region-flags/tree/gh-pages/png
22    // - It is supported by libphonenumber (it must be listed on this page): https://github.com/googlei18n/libphonenumber/blob/master/resources/ShortNumberMetadata.xml
23    // Each country array has the following information:
24    // [
25    //    Country name,
26    //    iso2 code,
27    //    International dial code,
28    //    Order (if >1 country with same dial code),
29    //    Area codes
30    // ]
31    var allCountries = [ [ "Afghanistan", "af", "93" ], [ "Albania", "al", "355" ], [ "Algeria", "dz", "213" ], [ "American Samoa", "as", "1", 5, [ "684" ] ], [ "Andorra", "ad", "376" ], [ "Angola", "ao", "244" ], [ "Anguilla", "ai", "1", 6, [ "264" ] ], [ "Antigua & Barbuda", "ag", "1", 7, [ "268" ] ], [ "Argentina", "ar", "54" ], [ "Armenia", "am", "374" ], [ "Aruba", "aw", "297" ], [ "Ascension Island", "ac", "247" ], [ "Australia", "au", "61", 0 ], [ "Austria", "at", "43" ], [ "Azerbaijan", "az", "994" ], [ "Bahamas", "bs", "1", 8, [ "242" ] ], [ "Bahrain", "bh", "973" ], [ "Bangladesh", "bd", "880" ], [ "Barbados", "bb", "1", 9, [ "246" ] ], [ "Belarus", "by", "375" ], [ "Belgium", "be", "32" ], [ "Belize", "bz", "501" ], [ "Benin", "bj", "229" ], [ "Bermuda", "bm", "1", 10, [ "441" ] ], [ "Bhutan", "bt", "975" ], [ "Bolivia", "bo", "591" ], [ "Bosnia & Herzegovina", "ba", "387" ], [ "Botswana", "bw", "267" ], [ "Brazil", "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", "bi", "257" ], [ "Cambodia", "kh", "855" ], [ "Cameroon", "cm", "237" ], [ "Canada", "ca", "1", 1, [ "204", "226", "236", "249", "250", "263", "289", "306", "343", "354", "365", "367", "368", "382", "387", "403", "416", "418", "428", "431", "437", "438", "450", "584", "468", "474", "506", "514", "519", "548", "579", "581", "584", "587", "604", "613", "639", "647", "672", "683", "705", "709", "742", "753", "778", "780", "782", "807", "819", "825", "867", "873", "902", "905" ] ], [ "Cape Verde", "cv", "238" ], [ "Caribbean Netherlands", "bq", "599", 1, [ "3", "4", "7" ] ], [ "Cayman Islands", "ky", "1", 12, [ "345" ] ], [ "Central African Republic", "cf", "236" ], [ "Chad", "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 - Brazzaville", "cg", "242" ], [ "Congo - Kinshasa", "cd", "243" ], [ "Cook Islands", "ck", "682" ], [ "Costa Rica", "cr", "506" ], [ "Côte d’Ivoire", "ci", "225" ], [ "Croatia", "hr", "385" ], [ "Cuba", "cu", "53" ], [ "Curaçao", "cw", "599", 0 ], [ "Cyprus", "cy", "357" ], [ "Czech Republic", "cz", "420" ], [ "Denmark", "dk", "45" ], [ "Djibouti", "dj", "253" ], [ "Dominica", "dm", "1", 13, [ "767" ] ], [ "Dominican Republic", "do", "1", 2, [ "809", "829", "849" ] ], [ "Ecuador", "ec", "593" ], [ "Egypt", "eg", "20" ], [ "El Salvador", "sv", "503" ], [ "Equatorial Guinea", "gq", "240" ], [ "Eritrea", "er", "291" ], [ "Estonia", "ee", "372" ], [ "Eswatini", "sz", "268" ], [ "Ethiopia", "et", "251" ], [ "Falkland Islands", "fk", "500" ], [ "Faroe Islands", "fo", "298" ], [ "Fiji", "fj", "679" ], [ "Finland", "fi", "358", 0 ], [ "France", "fr", "33" ], [ "French Guiana", "gf", "594" ], [ "French Polynesia", "pf", "689" ], [ "Gabon", "ga", "241" ], [ "Gambia", "gm", "220" ], [ "Georgia", "ge", "995" ], [ "Germany", "de", "49" ], [ "Ghana", "gh", "233" ], [ "Gibraltar", "gi", "350" ], [ "Greece", "gr", "30" ], [ "Greenland", "gl", "299" ], [ "Grenada", "gd", "1", 14, [ "473" ] ], [ "Guadeloupe", "gp", "590", 0 ], [ "Guam", "gu", "1", 15, [ "671" ] ], [ "Guatemala", "gt", "502" ], [ "Guer
31nsey", "gg", "44", 1, [ "1481", "7781", "7839", "7911" ] ], [ "Guinea", "gn", "224" ], [ "Guinea-Bissau", "gw", "245" ], [ "Guyana", "gy", "592" ], [ "Haiti", "ht", "509" ], [ "Honduras", "hn", "504" ], [ "Hong Kong", "hk", "852" ], [ "Hungary", "hu", "36" ], [ "Iceland", "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", "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", "lv", "371" ], [ "Lebanon", "lb", "961" ], [ "Lesotho", "ls", "266" ], [ "Liberia", "lr", "231" ], [ "Libya", "ly", "218" ], [ "Liechtenstein", "li", "423" ], [ "Lithuania", "lt", "370" ], [ "Luxembourg", "lu", "352" ], [ "Macau", "mo", "853" ], [ "Madagascar", "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", "mu", "230" ], [ "Mayotte", "yt", "262", 1, [ "269", "639" ] ], [ "Mexico", "mx", "52" ], [ "Micronesia", "fm", "691" ], [ "Moldova", "md", "373" ], [ "Monaco", "mc", "377" ], [ "Mongolia", "mn", "976" ], [ "Montenegro", "me", "382" ], [ "Montserrat", "ms", "1", 16, [ "664" ] ], [ "Morocco", "ma", "212", 0 ], [ "Mozambique", "mz", "258" ], [ "Myanmar (Burma)", "mm", "95" ], [ "Namibia", "na", "264" ], [ "Nauru", "nr", "674" ], [ "Nepal", "np", "977" ], [ "Netherlands", "nl", "31" ], [ "New Caledonia", "nc", "687" ], [ "New Zealand", "nz", "64" ], [ "Nicaragua", "ni", "505" ], [ "Niger", "ne", "227" ], [ "Nigeria", "ng", "234" ], [ "Niue", "nu", "683" ], [ "Norfolk Island", "nf", "672" ], [ "North Korea", "kp", "850" ], [ "North Macedonia", "mk", "389" ], [ "Northern Mariana Islands", "mp", "1", 17, [ "670" ] ], [ "Norway", "no", "47", 0 ], [ "Oman", "om", "968" ], [ "Pakistan", "pk", "92" ], [ "Palau", "pw", "680" ], [ "Palestine", "ps", "970" ], [ "Panama", "pa", "507" ], [ "Papua New Guinea", "pg", "675" ], [ "Paraguay", "py", "595" ], [ "Peru", "pe", "51" ], [ "Philippines", "ph", "63" ], [ "Poland", "pl", "48" ], [ "Portugal", "pt", "351" ], [ "Puerto Rico", "pr", "1", 3, [ "787", "939" ] ], [ "Qatar", "qa", "974" ], [ "Réunion", "re", "262", 0 ], [ "Romania", "ro", "40" ], [ "Russia", "ru", "7", 0 ], [ "Rwanda", "rw", "250" ], [ "Samoa", "ws", "685" ], [ "San Marino", "sm", "378" ], [ "São Tomé & Príncipe", "st", "239" ], [ "Saudi Arabia", "sa", "966" ], [ "Senegal", "sn", "221" ], [ "Serbia", "rs", "381" ], [ "Seychelles", "sc", "248" ], [ "Sierra Leone", "sl", "232" ], [ "Singapore", "sg", "65" ], [ "Sint Maarten", "sx", "1", 21, [ "721" ] ], [ "Slovakia", "sk", "421" ], [ "Slovenia", "si", "386" ], [ "Solomon Islands", "sb", "677" ], [ "Somalia", "so", "252" ], [ "South Africa", "za", "27" ], [ "South Korea", "kr", "82" ], [ "South Sudan", "ss", "211" ], [ "Spain", "es", "34" ], [ "Sri Lanka", "lk", "94" ], [ "St Barthélemy", "bl", "590", 1 ], [ "St Helena", "sh", "290" ], [ "St Kitts & Nevis", "kn", "1", 18, [ "869" ] ], [ "St Lucia", "lc", "1", 19, [ "758" ] ], [ "St Martin", "mf", "590", 2 ], [ "St Pierre & Miquelon", "pm", "508" ], [ "St Vincent & Grenadines", "vc", "1", 20, [ "784" ] ], [ "Sudan", "sd", "249" ], [ "Suriname", "sr", "597" ], [ "Svalbard & Jan Mayen", "sj", "47", 1, [ "79" ] ], [ "Sweden", "se", "46" ], [ "Switzerland", "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 & Tobago", "tt", "1", 22, [ "868" ] ], [ "Tunisia", "tn", "216" ], [ "Turkey", "tr", "90" ], [ "Turkmenistan", "tm", "993" ], [ "Turks & Caicos Islands", "tc", "1", 23, [ "649" ] ], [ "Tuvalu", "tv", "688" ], [ "Uganda", "ug", "256" ], [ "Ukraine", "ua", "380" ], [ "United Arab Emirates", "ae", "971" ], [ "United Kingdom", "gb", "44", 0 ], [ "United States", "us", "1", 0 ], [ "Uruguay", "uy", "598" ], [ "US Virgin Islands", "vi", "1", 24, [ "340" ] ], [ "Uzbekistan", "uz", "998" ], [ "Vanuatu", "vu", "678" ], [ "Vatican City", "va", "39", 1, [ "06698" ] ], [ "Venezuela", "ve", "58" ], [ "Vietnam", "vn", "84" ], [ "Wallis & 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" ] ] ];
32    // loop over all of the countries above, restructuring the data to be objects with named keys
33    for (var i = 0; i < allCountries.length; i++) {
34        var c = allCountries[i];
35        allCountries[i] = {
36            name: c[0],
37            iso2: c[1],
38            dialCode: c[2],
39            priority: c[3] || 0,
40            areaCodes: c[4] || null,
41            nodeById: {}
42        };
43    }
44    "use strict";
45    function ownKeys(object, enumerableOnly) {
46        var keys = Object.keys(object);
47        if (Object.getOwnPropertySymbols) {
48            var symbols = Object.getOwnPropertySymbols(object);
49            enumerableOnly && (symbols = symbols.filter(function(sym) {
50                return Object.getOwnPropertyDescriptor(object, sym).enumerable;
51            })), keys.push.apply(keys, symbols);
52        }
53        return keys;
54    }
55    function _objectSpread(target) {
56        for (var i = 1; i < arguments.length; i++) {
57            var source = null != arguments[i] ? arguments[i] : {};
58            i % 2 ? ownKeys(Object(source), !0).forEach(function(key) {
59                _defineProperty(target, key, source[key]);
60            }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function(key) {
61                Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
62            });
63        }
64        return target;
65    }
66    function _defineProperty(obj, key, value) {
67        key = _toPropertyKey(key);
68        if (key in obj) {
69            Object.defineProperty(obj, key, {
70                value: value,
71                enumerable: true,
72                configurable: true,
73                writable: true
74            });
75        } else {
76            obj[key] = value;
77        }
78        return obj;
79    }
80    function _slicedToArray(arr, i) {
81        return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
82    }
83    function _nonIterableRest() {
84        throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
85    }
86    function _unsupportedIterableToArray(o, minLen) {
87        if (!o) return;
88        if (typeof o === "string") return _arrayLikeToArray(o, minLen);
89        var n = Object.prototype.toString.call(o).slice(8, -1);
90        if (n === "Object" && o.constructor) n = o.constructor.name;
91        if (n === "Map" || n === "Set") return Array.from(o);
92        if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
93    }
94    function _arrayLikeToArray(arr, len) {
95        if (len == null || len > arr.length) len = arr.length;
96        for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
97        return arr2;
98    }
99    function _iterableToArrayLimit(arr, i) {
100        var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"];
101        if (null != _i) {
102            var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1;
103            try {
104                if (_x = (_i = _i.call(arr)).next, 0 === i) {
105                    if (Object(_i) !== _i) return;
106                    _n = !1;
107                } else for (;!(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0) ;
108            } catch (err) {
109                _d = !0, _e = err;
110            } finally {
111                try {
112                    if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return;
113                } finally {
114                    if (_d) throw _e;
115                }
116            }
117            return _arr;
118        }
119    }
120    function _arrayWithHoles(arr) {
121        if (Array.isArray(arr)) return arr;
122    }
123    function _classCallCheck(instance, Constructor) {
124        if (!(instance instanceof Constructor)) {
125            throw new TypeError("Cannot call a class as a function");
126        }
127    }
128    function _defineProperties(target, props) {
129        for (var i = 0; i < props.length; i++) {
130            var descriptor = props[i];
131            descriptor.enumerable = descriptor.enumerable || false;
132            descriptor.configurable = true;
133            if ("value" in descriptor) descriptor.writable = true;
134            Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
135        }
136    }
137    function _createClass(Constructor, protoProps, staticProps) {
138        if (protoProps) _defineProperties(Constructor.prototype, protoProps);
139        if (staticProps) _defineProperties(Constructor, staticProps);
140        Object.defineProperty(Constructor, "prototype", {
141            writable: false
142        });
143        return Constructor;
144    }
145    function _toPropertyKey(arg) {
146        var key = _toPrimitive(arg, "string");
147        return typeof key === "symbol" ? key : String(key);
148    }
149    function _toPrimitive(input, hint) {
150        if (typeof input !== "object" || input === null) return input;
151        var prim = input[Symbol.toPrimitive];
152        if (prim !== undefined) {
153            var res = prim.call(input, hint || "default");
154            if (typeof res !== "object") return res;
155            throw new TypeError("@@toPrimitive must return a primitive value.");
156        }
157        return (hint === "string" ? String : Number)(input);
158    }
159    var intlTelInputGlobals = {
160        getInstance: function getInstance(input) {
161            var id = input.getAttribute("data-intl-tel-input-id");
162            return window.intlTelInputGlobals.instances[id];
163        },
164        instances: {},
165        // using a global like this allows us to mock it in the tests
166        documentReady: function documentReady() {
167            return document.readyState === "complete";
168        }
169    };
170    if (typeof window === "object") {
171        window.intlTelInputGlobals = intlTelInputGlobals;
172    }
173    // these vars persist through all instances of the plugin
174    var id = 0;
175    var defaults = {
176        // whether or not to allow the dropdown
177        allowDropdown: true,
178        // add a placeholder in the input with an example number for the selected country
179        autoPlaceholder: "polite",
180        // add a country search input at the top of the dropdown
181        countrySearch: true,
182        // modify the parentClass
183        containerClass: "",
184        // modify the auto placeholder
185        customPlaceholder: null,
186        // append menu to specified element
187        dropdownContainer: null,
188        // don't display these countries
189        excludeCountries: [],
190        // fix the dropdown width to the input width (rather than being as wide as the longest country name)
191        fixDropdownWidth: true,
192        // format the number as the user types
193        formatAsYouType: true,
194        // format the input value during initialisation and on setNumber
195        formatOnDisplay: true,
196        // geoIp lookup function
197        geoIpLookup: null,
198        // inject a hidden input with the name returned from this function, and on submit, populate it with the result of getNumber
199        hiddenInput: null,
200        // internationalise the plugin text e.g. search input placeholder, country names
201        i18n: {},
202        // initial country
203        initialCountry: "",
204        // national vs international formatting for numbers e.g. placeholders and displaying existing numbers
205        nationalMode: true,
206        // display only these countries
207        onlyCountries: [],
208        // number type to use for placeholders
209        placeholderNumberType: "MOBILE",
210        // the countries at the top of the list
211        preferredCountries: [],
212        // option to hide the flags - must be used with showSelectedDialCode, or allowDropdown=false
213        showFlags: true,
214        // display the international dial code next to the selected flag
215        showSelectedDialCode: false,
vendor: 11,927 bytes, lines 216-441
216        // use full screen popup instead of dropdown for country list
217        useFullscreenPopup: typeof navigator !== "undefined" && typeof window !== "undefined" ? // we cannot just test screen size as some smartphones/website meta tags will report desktop
218        // resolutions
219        // Note: to target Android Mobiles (and not Tablets), we must find 'Android' and 'Mobile'
220        /Android.+Mobile|webOS|iPhone|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) || window.innerWidth <= 500 : false,
221        // specify the path to the libphonenumber script to enable validation/formatting
222        utilsScript: ""
223    };
224    // https://en.wikipedia.org/wiki/List_of_North_American_Numbering_Plan_area_codes#Non-geographic_area_codes
225    var regionlessNanpNumbers = [ "800", "822", "833", "844", "855", "866", "877", "880", "881", "882", "883", "884", "885", "886", "887", "888", "889" ];
226    // run a method on each instance of the plugin
227    var forEachInstance = function forEachInstance(method) {
228        var instances = window.intlTelInputGlobals.instances;
229        Object.values(instances).forEach(function(instance) {
230            return instance[method]();
231        });
232    };
233    // this is our plugin class that we will create an instance of
234    // eslint-disable-next-line no-unused-vars
235    var Iti = /*#__PURE__*/ function() {
236        function Iti(input) {
237            var customOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
238            _classCallCheck(this, Iti);
239            this.id = id++;
240            this.telInput = input;
241            this.activeItem = null;
242            this.highlightedItem = null;
243            // process specified options / defaults
244            this.options = Object.assign({}, defaults, customOptions);
245            this.hadInitialPlaceholder = Boolean(input.getAttribute("placeholder"));
246        }
247        _createClass(Iti, [ {
248            key: "_init",
249            value: function _init() {
250                var _this = this;
251                // if showing fullscreen popup, do not fix the width
252                if (this.options.useFullscreenPopup) {
253                    this.options.fixDropdownWidth = false;
254                }
255                // when search enabled, we must fix the width else it would change with different results
256                if (this.options.countrySearch && !this.options.useFullscreenPopup) {
257                    this.options.fixDropdownWidth = true;
258                }
259                // force showFlags=true if there's a dropdown and we're not displaying the dial code,
260                // as otherwise you just have a down arrow on it's own which doesn't make sense
261                var forceShowFlags = this.options.allowDropdown && !this.options.showSelectedDialCode;
262                if (!this.options.showFlags && forceShowFlags) {
263                    this.options.showFlags = true;
264                }
265                // on mobile, we want a full screen dropdown, so we must append it to the body
266                if (this.options.useFullscreenPopup && !this.options.dropdownContainer) {
267                    this.options.dropdownContainer = document.body;
268                }
269                // check if input has one parent with RTL
270                this.isRTL = !!this.telInput.closest("[dir=rtl]");
271                // these promises get resolved when their individual requests complete
272                // this way the dev can do something like iti.promise.then(...) to know when all requests are
273                // complete
274                var autoCountryPromise = new Promise(function(resolve, reject) {
275                    _this.resolveAutoCountryPromise = resolve;
276                    _this.rejectAutoCountryPromise = reject;
277                });
278                var utilsScriptPromise = new Promise(function(resolve, reject) {
279                    _this.resolveUtilsScriptPromise = resolve;
280                    _this.rejectUtilsScriptPromise = reject;
281                });
282                this.promise = Promise.all([ autoCountryPromise, utilsScriptPromise ]);
283                // in various situations there could be no country selected initially, but we need to be able
284                // to assume this variable exists
285                this.selectedCountryData = {};
286                // process all the data: onlyCountries, excludeCountries, preferredCountries etc
287                this._processCountryData();
288                // generate the markup
289                this._generateMarkup();
290                // set the initial state of the input value and the selected flag
291                this._setInitialState();
292                // start all of the event listeners: input keydown, selectedFlag click
293                this._initListeners();
294                // utils script, and auto country
295                this._initRequests();
296            }
297        }, {
298            key: "_processCountryData",
299            value: function _processCountryData() {
300                // process onlyCountries or excludeCountries array if present
301                this._processAllCountries();
302                // generate this.dialCodes and this.dialCodeToIso2Map
303                this._processDialCodes();
304                // process the preferredCountries
305                this._processPreferredCountries();
306                // translate country names according to i18n option
307                this._translateCountryNames();
308                // sort countries by name
309                if (this.options.onlyCountries.length || this.options.i18n) {
310                    this.countries.sort(this._countryNameSort);
311                }
312            }
313        }, {
314            key: "_addToDialCodeMap",
315            value: function _addToDialCodeMap(iso2, dialCode, priority) {
316                if (dialCode.length > this.dialCodeMaxLen) {
317                    this.dialCodeMaxLen = dialCode.length;
318                }
319                if (!this.dialCodeToIso2Map.hasOwnProperty(dialCode)) {
320                    this.dialCodeToIso2Map[dialCode] = [];
321                }
322                // bail if we already have this country for this dialCode
323                for (var i = 0; i < this.dialCodeToIso2Map[dialCode].length; i++) {
324                    if (this.dialCodeToIso2Map[dialCode][i] === iso2) {
325                        return;
326                    }
327                }
328                // check for undefined as 0 is falsy
329                var index = priority !== undefined ? priority : this.dialCodeToIso2Map[dialCode].length;
330                this.dialCodeToIso2Map[dialCode][index] = iso2;
331            }
332        }, {
333            key: "_processAllCountries",
334            value: function _processAllCountries() {
335                if (this.options.onlyCountries.length) {
336                    var lowerCaseOnlyCountries = this.options.onlyCountries.map(function(country) {
337                        return country.toLowerCase();
338                    });
339                    this.countries = allCountries.filter(function(country) {
340                        return lowerCaseOnlyCountries.indexOf(country.iso2) > -1;
341                    });
342                } else if (this.options.excludeCountries.length) {
343                    var lowerCaseExcludeCountries = this.options.excludeCountries.map(function(country) {
344                        return country.toLowerCase();
345                    });
346                    this.countries = allCountries.filter(function(country) {
347                        return lowerCaseExcludeCountries.indexOf(country.iso2) === -1;
348                    });
349                } else {
350                    this.countries = allCountries;
351                }
352            }
353        }, {
354            key: "_translateCountryNames",
355            value: function _translateCountryNames() {
356                for (var i = 0; i < this.countries.length; i++) {
357                    var iso2 = this.countries[i].iso2.toLowerCase();
358                    if (this.options.i18n.hasOwnProperty(iso2)) {
359                        this.countries[i].name = this.options.i18n[iso2];
360                    }
361                }
362            }
363        }, {
364            key: "_countryNameSort",
365            value: function _countryNameSort(a, b) {
366                if (a.name < b.name) {
367                    return -1;
368                }
369                if (a.name > b.name) {
370                    return 1;
371                }
372                return 0;
373            }
374        }, {
375            key: "_processDialCodes",
376            value: function _processDialCodes() {
377                // here we store just dial codes, where the key is the dial code, and the value is true
378                // e.g. { 1: true, 7: true, 20: true, ... }
379                this.dialCodes = {};
380                this.dialCodeMaxLen = 0;
381                // here we map dialCodes (inc both dialCode and dialCode+areaCode) to iso2 codes
382                /* e.g.
383       * {
384       *   1: [ 'us', 'ca', ... ],    # all NANP countries
385       *   12: [ 'us', 'ca', ... ],   # subset of NANP countries
386       *   120: [ 'us', 'ca' ],       # just US and Canada
387       *   1204: [ 'ca' ],            # only Canada
388       *   ...
389       *  }
390       */
391                this.dialCodeToIso2Map = {};
392                // first: add dial codes
393                for (var i = 0; i < this.countries.length; i++) {
394                    var c = this.countries[i];
395                    if (!this.dialCodes[c.dialCode]) {
396                        this.dialCodes[c.dialCode] = true;
397                    }
398                    this._addToDialCodeMap(c.iso2, c.dialCode, c.priority);
399                }
400                // next: add area codes
401                // this is a second loop over countries, to make sure we have all of the "root" countries
402                // already in the map, so that we can access them, as each time we add an area code substring
403                // to the map, we also need to include the "root" country's code, as that also matches
404                for (var _i = 0; _i < this.countries.length; _i++) {
405                    var _c = this.countries[_i];
406                    // area codes
407                    if (_c.areaCodes) {
408                        var rootIso2Code = this.dialCodeToIso2Map[_c.dialCode][0];
409                        // for each area code
410                        for (var j = 0; j < _c.areaCodes.length; j++) {
411                            var areaCode = _c.areaCodes[j];
412                            // for each digit in the area code to add all partial matches as well
413                            for (var k = 1; k < areaCode.length; k++) {
414                                var partialDialCode = _c.dialCode + areaCode.substr(0, k);
415                                // start with the root country, as that also matches this dial code
416                                this._addToDialCodeMap(rootIso2Code, partialDialCode);
417                                this._addToDialCodeMap(_c.iso2, partialDialCode);
418                            }
419                            // add the full area code
420                            this._addToDialCodeMap(_c.iso2, _c.dialCode + areaCode);
421                        }
422                    }
423                }
424            }
425        }, {
426            key: "_processPreferredCountries",
427            value: function _processPreferredCountries() {
428                this.preferredCountries = [];
429                for (var i = 0; i < this.options.preferredCountries.length; i++) {
430                    var iso2 = this.options.preferredCountries[i].toLowerCase();
431                    var countryData = this._getCountryData(iso2, true);
432                    if (countryData) {
433                        this.preferredCountries.push(countryData);
434                    }
435                }
436            }
437        }, {
438            key: "_createEl",
439            value: function _createEl(name, attrs, container) {
440                var el = document.createElement(name);
441                if (attrs) {
442                    Object.entries(attrs).forEach(function(_ref) {
443                        var _ref2 = _slicedToArray(_ref, 2), key = _ref2[0], value = _ref2[1];
444                        return el.setAttribute(key, value);
445                    });
446                }
447                if (container) {
448                    container.appendChild(el);
449                }
450                return el;
451            }
452        }, {
453            key: "_generateMarkup",
454            value: function _generateMarkup() {
455                this.telInput.classList.add("iti__tel-input");
456                // if autocomplete does not exist on the element and its form, then
457                // prevent autocomplete as there's no safe, cross-browser event we can react to, so it can
458                // easily put the plugin in an inconsistent state e.g. the wrong flag selected for the
459                // autocompleted number, which on submit could mean wrong number is saved
460                if (!this.telInput.hasAttribute("autocomplete") && !(this.telInput.form && this.telInput.form.hasAttribute("autocomplete"))) {
461                    this.telInput.setAttribute("autocomplete", "off");
462                }
463                var _this$options = this.options, allowDropdown = _this$options.allowDropdown, showSelectedDialCode = _this$options.showSelectedDialCode, showFlags = _this$options.showFlags, containerClass = _this$options.containerClass, hiddenInput = _this$options.hiddenInput, dropdownContainer = _this$options.dropdownContainer, fixDropdownWidth = _this$options.fixDropdownWidth, useFullscreenPopup = _this$options.useFullscreenPopup, countrySearch = _this$options.countrySearch, i18n = _this$options.i18n;
464                // containers (mostly for positioning)
465                var parentClass = "iti";
466                if (allowDropdown) {
467                    parentClass += " iti--allow-dropdown";
468                }
469                if (showSelectedDialCode) {
470                    parentClass += " iti--show-selected-dial-code";
471                }
472                if (showFlags) {
473                    parentClass += " iti--show-flags";
474                }
475                if (containerClass) {
476                    parentClass += " ".concat(containerClass);
477                }
478                if (!useFullscreenPopup) {
479                    parentClass += " iti--inline-dropdown";
480                }
481                var wrapper = this._createEl("div", {
482                    "class": parentClass
483                });
484                this.telInput.parentNode.insertBefore(wrapper, this.telInput);
485                // if we're showing flags or dial codes, we need the flags container etc
486                if (showFlags || showSelectedDialCode) {
487                    this.flagsContainer = this._createEl("div", {
488                        "class": "iti__flag-container"
489                    }, wrapper);
490                    // selected flag (displayed on left of input while allowDropdown is enabled, otherwise to right)
491                    // when countrySearch disabled: using Aria tags for "Select-Only Combobox Example"
492                    // https://www.w3.org/WAI/ARIA/apg/patterns/combobox/examples/combobox-select-only/
493                    this.selectedFlag = this._createEl("div", _objectSpread({
494                        "class": "iti__selected-flag"
495                    }, allowDropdown && _objectSpread({
496                        "aria-expanded": "false",
497                        "aria-label": this.options.i18n.selectedCountryAriaLabel || "Selected country",
498                        "aria-haspopup": countrySearch ? "true" : "listbox",
499                        "aria-controls": countrySearch ? "iti-".concat(this.id, "__dropdown-content") : "iti-".concat(this.id, "__country-listbox")
500                    }, countrySearch || {
501                        role: "combobox"
502                    })), this.flagsContainer);
503                    // we now include the selected flag element even when showFlags is disabled,
504                    // as need to show globe icon for showSelectedDialCode empty state
505                    this.selectedFlagInner = this._createEl("div", null, this.selectedFlag);
506                    this.selectedFlagA11yText = this._createEl("span", {
507                        "class": "iti__a11y-text"
508                    }, this.selectedFlagInner);
509                }
510                wrapper.appendChild(this.telInput);
511                if (this.selectedFlag && this.telInput.disabled) {
512                    this.selectedFlag.setAttribute("aria-disabled", "true");
513                }
514                if (showSelectedDialCode) {
515                    this.selectedDialCode = this._createEl("div", {
516                        "class": "iti__selected-dial-code"
517                    }, this.selectedFlag);
518                }
519                if (allowDropdown) {
520                    if (!this.telInput.disabled) {
521                        // make element focusable and tab navigable
522                        this.selectedFlag.setAttribute("tabindex", "0");
523                    }
524                    this.dropdownArrow = this._createEl("div", {
525                        "class": "iti__arrow",
526                        "aria-hidden": "true"
527                    }, this.selectedFlag);
528                    var extraClasses = fixDropdownWidth ? "" : "iti--flexible-dropdown-width";
529                    this.dropdownContent = this._createEl("div", {
530                        id: "iti-".concat(this.id, "__dropdown-content"),
531                        "class": "iti__dropdown-content iti__hide ".concat(extraClasses)
532                    });
533                    if (countrySearch) {
534                        this.searchInput = this._createEl("input", {
535                            type: "text",
536                            "class": "iti__search-input",
537                            placeholder: i18n.searchPlaceholder || "Search",
538                            role: "combobox",
539                            "aria-expanded": "true",
540                            "aria-label": i18n.searchPlaceholder || "Search",
541                            "aria-controls": "iti-".concat(this.id, "__country-listbox"),
542                            "aria-autocomplete": "list",
543                            autocomplete: "off"
544                        }, this.dropdownContent);
545                        this.searchResultsA11yText = this._createEl("span", {
546                            "class": "iti__a11y-text"
547                        }, this.dropdownContent);
548                    }
549                    // country list: preferred countries, then divider, then all countries
550                    this.countryList = this._createEl("ul", {
551                        "class": "iti__country-list",
552                        id: "iti-".concat(this.id, "__country-listbox"),
553                        role: "listbox",
554                        "aria-label": i18n.countryListAriaLabel || "List of countries"
555                    }, this.dropdownContent);
556                    if (this.preferredCountries.length && !countrySearch) {
557                        this._appendListItems(this.preferredCountries, "iti__preferred", true);
558                        this._createEl("li", {
559                            "class": "iti__divider",
560                            "aria-hidden": "true"
561                        }, this.countryList);
562                    }
563                    this._appendListItems(this.countries, "iti__standard");
564                    if (countrySearch) {
565                        this._updateSearchResultsText();
566                    }
567                    // create dropdownContainer markup
568                    if (dropdownContainer) {
569                        var dropdownClasses = "iti iti--container";
570                        if (useFullscreenPopup) {
571                            dropdownClasses += " iti--fullscreen-popup";
572                        } else {
573                            dropdownClasses += " iti--inline-dropdown";
574                        }
575                        if (countrySearch) {
576                            dropdownClasses += " iti--country-search";
577                        }
578                        this.dropdown = this._createEl("div", {
579                            "class": dropdownClasses
580                        });
581                        this.dropdown.appendChild(this.dropdownContent);
582                    } else {
583                        this.flagsContainer.appendChild(this.dropdownContent);
584                    }
585                }
586                if (hiddenInput) {
587                    var telInputName = this.telInput.getAttribute("name");
588                    var names = hiddenInput(telInputName);
589                    if (names.phone) {
590                        // Create hidden input for the full international number
591                        this.hiddenInput = this._createEl("input", {
592                            type: "hidden",
593                            name: names.phone
594                        });
595                        wrapper.appendChild(this.hiddenInput);
596                    }
597                    if (names.country) {
598                        // Create hidden input for the selected country iso2 code
599                        this.hiddenInputCountry = this._createEl("input", {
600                            type: "hidden",
601                            name: names.country
602                        });
603                        wrapper.appendChild(this.hiddenInputCountry);
604                    }
605                }
606            }
607        }, {
608            key: "_appendListItems",
609            value: function _appendListItems(countries, className, preferred) {
610                for (var i = 0; i < countries.length; i++) {
611                    var c = countries[i];
612                    var idSuffix = preferred ? "-preferred" : "";
613                    var listItem = this._createEl("li", {
614                        id: "iti-".concat(this.id, "__item-").concat(c.iso2).concat(idSuffix),
615                        "class": "iti__country ".concat(className),
616                        tabindex: "-1",
617                        role: "option",
618                        "data-dial-code": c.dialCode,
619                        "data-country-code": c.iso2,
620                        "aria-selected": "false"
621                    }, this.countryList);
622                    // store this for later use e.g. country search f
622iltering
623                    c.nodeById[this.id] = listItem;
624                    var content = "";
625                    // add the flag
626                    if (this.options.showFlags) {
627                        content += "<div class='iti__flag-box'><div class='iti__flag iti__".concat(c.iso2, "'></div></div>");
628                    }
629                    // and the country name and dial code
630                    content += "<span class='iti__country-name'>".concat(c.name, "</span>");
631                    content += "<span class='iti__dial-code'>+".concat(c.dialCode, "</span>");
632                    listItem.insertAdjacentHTML("beforeend", content);
633                }
634            }
635        }, {
636            key: "_setInitialState",
637            value: function _setInitialState() {
638                var overrideAutoCountry = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
639                // fix firefox bug: when first load page (with input with value set to number with intl dial
640                // code) and initialising plugin removes the dial code from the input, then refresh page,
641                // and we try to init plugin again but this time on number without dial code so get grey flag
642                var attributeValue = this.telInput.getAttribute("value");
643                var inputValue = this.telInput.value;
644                var useAttribute = attributeValue && attributeValue.charAt(0) === "+" && (!inputValue || inputValue.charAt(0) !== "+");
645                var val = useAttribute ? attributeValue : inputValue;
646                var dialCode = this._getDialCode(val);
647                var isRegionlessNanp = this._isRegionlessNanp(val);
648                var initialCountry = this.options.initialCountry;
649                // if we already have a dial code, and it's not a regionlessNanp, we can go ahead and set the
650                // flag, else fall back to the default country
651                if (dialCode && !isRegionlessNanp) {
652                    this._updateFlagFromNumber(val);
653                } else if (initialCountry !== "auto" || overrideAutoCountry) {
654                    var lowerInitialCountry = initialCountry ? initialCountry.toLowerCase() : "";
655                    var isValidInitialCountry = lowerInitialCountry && this._getCountryData(lowerInitialCountry, true);
656                    // see if we should select a flag
657                    if (isValidInitialCountry) {
658                        this._setCountry(lowerInitialCountry);
659                    } else {
660                        if (dialCode && isRegionlessNanp) {
661                            // has intl dial code, is regionless nanp, and no initialCountry, so default to US
662                            this._setCountry("us");
663                        } else {
664                            // display the empty state (globe icon)
665                            this._setCountry();
666                        }
667                    }
668                }
669                // NOTE: if initialCountry is set to auto, that will be handled separately
670                // format - note this wont be run after _updateDialCode as that's only called 
670if no val
671                if (val) {
672                    this._updateValFromNumber(val);
673                }
674            }
675        }, {
676            key: "_initListeners",
677            value: function _initListeners() {
678                this._initKeyListeners();
679                if (this.options.allowDropdown) {
680                    this._initDropdownListeners();
681                }
682                if ((this.hiddenInput || this.hiddenInputCountry) && this.telInput.form) {
683                    this._initHiddenInputListener();
684                }
685            }
686        }, {
687            key: "_initHiddenInputListener",
688            value: function _initHiddenInputListener() {
689                var _this2 = this;
690                this._handleHiddenInputSubmit = function() {
691                    if (_this2.hiddenInput) {
692                        _this2.hiddenInput.value = _this2.getNumber();
693                    }
694                    if (_this2.hiddenInputCountry) {
695                        _this2.hiddenInputCountry.value = _this2.getSelectedCountryData().iso2;
696                    }
697                };
698                this.telInput.form.addEventListener("submit", this._handleHiddenInputSubmit);
699            }
700        }, {
701            key: "_initDropdownListeners",
702            value: function _initDropdownListeners() {
703                var _this3 = this;
704                // hack for input nested inside label (which is valid markup): clicking the selected-flag to
705                // open the dropdown would then automatically trigger a 2nd click on the input which would
706                // close it again
707                this._handleLabelClick = function(e) {
708                    // if the dropdown is closed, then focus the input, else ignore the click
709                    if (_this3.dropdownContent.classList.contains("iti__hide")) {
710                        _this3.telInput.focus();
711                    } else {
712                        e.preventDefault();
713                    }
714                };
715                var label = this.telInput.closest("label");
716                if (label) {
717                    label.addEventListener("click", this._handleLabelClick);
718                }
719                // toggle country dropdown on click
720                this._handleClickSelectedFlag = function() {
721                    // only intercept this event if we're opening the dropdown
722                    // else let it bubble up to the top ("click-off-to-close" listener)
723                    // we cannot just stopPropagation as it may be needed to close another instance
724                    if (_this3.dropdownContent.classList.contains("iti__hide") && !_this3.telInput.disabled && !_this3.telInput.readOnly) {
725                        _this3._openDropdown();
726                    }
727                };
728                this.selectedFlag.addEventListener("click", this._handleClickSelectedFlag);
729                // open dropdown if selected flag is focused and they press up/down/space/enter
730                this._handleFlagsContainerKeydown = function(e) {
731                    var isDropdownHidden = _this3.dropdownContent.classList.contains("iti__hide");
732                    if (isDropdownHidden && [ "ArrowUp", "ArrowDown", " ", "Enter" ].includes(e.key)) {
733                        // prevent form from being submitted if "ENTER" was pressed
734                        e.preventDefault();
735                        // prevent event from being handled again by document
736                        e.stopPropagation();
737                        _this3._openDropdown();
738                    }
739                    // allow navigation from dropdown to input on TAB
740                    if (e.key === "Tab") {
741                        _this3._closeDropdown();
742                    }
743                };
744                this.flagsContainer.addEventListener("keydown", this._handleFlagsContainerKeydown);
745            }
746        }, {
747            key: "_initRequests",
748            value: function _initRequests() {
749                var _this4 = this;
750                // if the user has specified the path to the utils script, fetch it on window.load, else resolve
751                if (this.options.utilsScript && !window.intlTelInputUtils) {
752                    // if the plugin is being initialised after the window.load event has already been fired
753                    if (window.intlTelInputGlobals.documentReady()) {
754                        window.intlTelInputGlobals.loadUtils(this.options.utilsScript);
755                    } else {
756                        // wait until the load event so we don't block any other requests e.g. the flags image
757                        window.addEventListener("load", function() {
758                            window.intlTelInputGlobals.loadUtils(_this4.options.utilsScript);
759                        });
760                    }
761                } else {
762                    this.resolveUtilsScriptPromise();
763                }
764                // dont bother with IP lookup if we already have a selected country
765                if (this.options.initialCountry === "auto" && !this.selectedCountryData.iso2) {
766                    this._loadAutoCountry();
767                } else {
768                    this.resolveAutoCountryPromise();
769                }
770            }
771        }, {
772            key: "_loadAutoCountry",
773            value: function _loadAutoCountry() {
774                var _this5 = this;
775                // 3 options:
776                // 1) already loaded (we're done)
777                // 2) not already started loading (start)
778                // 3) already started loading (do nothing - just wait for loading callback to fire)
779                if (window.intlTelInputGlobals.autoCountry) {
780                    this.handleAutoCountry();
781                } else if (!window.intlTelInputGlobals.startedLoadingAutoCountry) {
782                    // don't do this twice!
783                    window.intlTelInputGlobals.startedLoadingAutoCountry = true;
784                    if (typeof this.options.geoIpLookup === "function") {
785                        this.options.geoIpLookup(function() {
786                            var iso2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
787                            var iso2Lower = iso2.toLowerCase();
788                            var isValidIso2 = iso2Lower && _this5._getCountryData(iso2Lower, true);
789                            if (isValidIso2) {
790                                window.intlTelInputGlobals.autoCountry = iso2Lower;
791                                // tell all instances the auto country is ready
792                                // TODO: this should just be the current instances
793                                // UPDATE: use setTimeout in case their geoIpLookup function calls this callback straight
794                                // away (e.g. if they have already done the geo ip lookup somewhere else). Using
795                                // setTimeout means that the current thread of execution will finish before executing
796                                // this, which allows the plugin to finish initialising.
797                                setTimeout(function() {
798                                    return forEachInstance("handleAutoCountry");
799                                });
800                            } else {
801                                _this5._setInitialState(true);
802                                forEachInstance("rejectAutoCountryPromise");
803                            }
804                        }, function() {
805                            return forEachInstance("rejectAutoCountryPromise");
806                        });
807                    }
808                }
809            }
810        }, {
811            key: "_initKeyListeners",
812            value: function _initKeyListeners() {
813                var _this6 = this;
814                var userOverrideFormatting = false;
815                // update flag on input event
816                this._handleKeyEvent = function(e) {
817                    if (_this6._updateFlagFromNumber(_this6.telInput.value)) {
818                        _this6._triggerCountryChange();
819                    }
820                    // if user types their own formatting char (not a plus or a numeric), then set the override
821                    var isFormattingChar = e && e.data && /[^+0-9]/.test(e.data);
822                    var isPaste = e && e.inputType === "insertFromPaste" && _this6.telInput.value;
823                    if (isFormattingChar || isPaste) {
824                        userOverrideFormatting = true;
825                    } else if (!/[^+0-9]/.test(_this6.telInput.value)) {
826                        userOverrideFormatting = false;
827                    }
828                    // handle FAYT, unless userOverrideFormatting or it's a paste event
829                    if (_this6.options.formatAsYouType && !userOverrideFormatting && !isPaste) {
830                        // maintain caret position after reformatting
831                        var currentCaretPos = _this6.telInput.selectionStart;
832                        var valueBeforeCaret = _this6.telInput.value.substring(0, currentCaretPos);
833                        var relevantCharsBeforeCaret = valueBeforeCaret.replace(/[^+0-9]/g, "").length;
834                        var isDeleteForwards = e && e.inputType === "deleteContentForward";
835                        var formattedValue = _this6._formatNumberAsYouType();
836                        var newCaretPos = _this6._translateCursorPosition(relevantCharsBeforeCaret, formattedValue, currentCaretPos, isDeleteForwards);
837                        _this6.telInput.value = formattedValue;
838                        _this6.telInput.setSelectionRange(newCaretPos, newCaretPos);
839                    }
840                };
841                // this handles individual key presses as well as cut/paste events
842                // the advantage of the "input" event over "keyup" etc is that "input" only fires when the value changes,
843                // whereas "keyup" fires even for arrow key presses etc
844                this.telInput.addEventListener("input", this._handleKeyEvent);
845            }
846        }, {
847            key: "_translateCursorPosition",
848            value: function _translateCursorPosition(relevantChars, formattedValue, prevCaretPos, isDeleteForwards) {
849                // if the first char is a formatting char, and they backspace delete it:
850                // cursor should stay at the start (pos 0), rather than stick to the first digit (pos 1)
851                if (prevCaretPos === 0 && !isDeleteForwards) {
852                    return 0;
853                }
854                var count = 0;
855                for (var i = 0; i < formattedValue.length; i++) {
856                    if (/[+0-9]/.test(formattedValue[i])) {
857                        count++;
858                    }
859                    // normal case: stop when you hit the right number of relevant chars
860                    // (cursor will be just after the final relevant char)
861                    if (count === relevantChars && !isDeleteForwards) {
862                        return i + 1;
863                    }
864                    // spacial case: delete forwards (fn + delete on a mac):
865                    // wait until hit one extra relevant char, and put the cursor just before it (after any formatting chars)
866                    if (isDeleteForwards && count === relevantChars + 1) {
867                        return i;
868                    }
869                }
870                return formattedValue.length;
871            }
872        }, {
873            key: "_cap",
874            value: function _cap(number) {
875                var max = this.telInput.getAttribute("maxlength");
876                return max && number.length > max ? number.substr(0, max) : number;
877            }
878        }, {
879            key: "_removeEmptyDialCode",
880            value: function _removeEmptyDialCode() {
881                if (this.telInput.value.charAt(0) === "+") {
882                    var numeric = this._getNumeric(this.telInput.value);
883                    // if just a plus, or if just a dial code
884                    if (!numeric || this.selectedCountryData.dialCode === numeric) {
885                        this.telInput.value = "";
886                    }
887                }
888            }
889        }, {
890            key: "_getNumeric",
891            value: function _getNumeric(s) {
892                return s.replace(/\D/g, "");
893            }
894        }, {
895            key: "_trigger",
896            value: function _trigger(name) {
897                var e = new Event(name, {
898                    bubbles: true,
899                    cancelable: true
900                });
901                this.telInput.dispatchEvent(e);
902            }
903        }, {
904            key: "_openDropdown",
905            value: function _openDropdown() {
906                var _this$options2 = this.options, fixDropdownWidth = _this$options2.fixDropdownWidth, countrySearch = _this$options2.countrySearch;
907                if (fixDropdownWidth) {
908                    this.dropdownContent.style.width = "".concat(this.telInput.offsetWidth, "px");
909                }
910                this.dropdownContent.classList.remove("iti__hide");
911                this.selectedFlag.setAttribute("aria-expanded", "true");
912                this._setDropdownPosition();
913                // if we have previously selected a country (and countrySearch is disabled), then highlight that item and scroll to it
914                // else highlight the first item and scroll to top (even if countrySearch is disabled e.g. on init, showing globe icon)
915                if (this.activeItem && !countrySearch) {
916                    // update highlighting and scroll to active list item
917                    this._highlightListItem(this.activeItem, false);
918                    this._scrollTo(this.activeItem, true);
919                } else {
920                    // start by highlighting the first item in the list
921                    var firstElementChild = this.countryList.firstElementChild;
922                    if (firstElementChild) {
923                        this._highlightListItem(firstElementChild, false);
924                        this.countryList.scrollTop = 0;
925                    }
926                    if (countrySearch) {
927                        this.searchInput.focus();
928                    }
929                }
930                // bind all the dropdown-related listeners: mouseover, click, click-off, keydown
931                this._bindDropdownListeners();
932                // update the arrow
933                this.dropdownArrow.classList.add("iti__arrow--up");
934                this._trigger("open:countrydropdown");
935            }
936        }, {
937            key: "_toggleClass",
938            value: function _toggleClass(el, className, shouldHaveClass) {
939                if (shouldHaveClass && !el.classList.contains(className)) {
940                    el.classList.add(className);
941                } else if (!shouldHaveClass && el.classList.contains(className)) {
942                    el.classList.remove(className);
943                }
944            }
945        }, {
946            key: "_setDropdownPosition",
947            value: function _setDropdownPosition() {
948                var _this7 = this;
949                if (this.options.dropdownContainer) {
950                    this.options.dropdownContainer.appendChild(this.dropdown);
951                }
952                if (!this.options.useFullscreenPopup) {
953                    var pos = this.telInput.getBoundingClientRect();
954                    // windowTop from https://stackoverflow.com/a/14384091/2
95417866
955                    var windowTop = document.documentElement.scrollTop;
956                    var inputTop = pos.top + windowTop;
957                    var dropdownHeight = this.dropdownContent.offsetHeight;
958                    // dropdownFitsBelow = (dropdownBottom < windowBottom)
959                    var dropdownFitsBelow = inputTop + this.telInput.offsetHeight + dropdownHeight < windowTop + window.innerHeight;
960                    var dropdownFitsAbove = inputTop - dropdownHeight > windowTop;
961                    // dont allow positioning above when country search enabled as the search box jumps around as you filter countries
962                    var positionDropdownAboveInput = !this.options.countrySearch && !dropdownFitsBelow && dropdownFitsAbove;
963                    // by default, the dropdown will be below the input. If we want to position it above the
964                    // input, we add the dropup class.
965                    this._toggleClass(this.dropdownContent, "iti__dropdown-content--dropup", positionDropdownAboveInput);
966                    // if dropdownContainer is enabled, calculate postion
967                    if (this.options.dropdownContainer) {
968                        // if we want to position the dropdown below the input, we need to add the input height to the top value
969                        var extraTop = positionDropdownAboveInput ? 0 : this.telInput.offsetHeight;
970                        // calculate placement
971                        this.dropdown.style.top = "".concat(inputTop + extraTop, "px");
972                        this.dropdown.style.left = "".concat(pos.left + document.body.scrollLeft, "px");
973                        // close menu on window scroll
974                        this._handleWindowScroll = function() {
975                            return _this7._closeDropdown();
976                        };
977                        window.addEventListener("scroll", this._handleWindowScroll);
978                    }
979                }
980            }
981        }, {
982            key: "_bindDropdownListeners",
983            value: function _bindDropdownListeners() {
984                var _this8 = this;
985                // when mouse over a list item, just highlight that one
986                // we add the class "highlight", so if they hit "enter" we know which one to select
987                this._handleMouseoverCountryList = function(e) {
988                    // handle event delegation, as we're listening for this event on the countryList
989                    var listItem = e.target.closest(".iti__country");
990                    if (listItem) {
991                        _this8._highlightListItem(listItem, false);
992                    }
993                };
994                this.countryList.addEventListener("mouseover", this._handleMouseoverCountryList);
995                // listen for country selection
996                this._handleClickCountryList = function(e) {
997                    var listItem = e.target.closest(".iti__country");
998                    if (listItem) {
999                        _this8._selectListItem(listItem);
1000                    }
1001                };
1002                this.countryList.addEventListener("click", this._handleClickCountryList);
1003                // click off to close
1004                // (except when this initial opening click is bubbling up)
1005                // we cannot just stopPropagation as it may be needed to close another instance
1006                var isOpening = true;
1007                this._handleClickOffToClose = function() {
1008                    if (!isOpening) {
1009                        _this8._closeDropdown();
1010                    }
1011                    isOpening = false;
1012                };
1013                document.documentElement.addEventListener("click", this._handleClickOffToClose);
1014                // listen for up/down scrolling, enter to select, or escape to close
1015                // use keydown as keypress doesn't fire for non-char keys and we want to catch if they
1016                // just hit down and hold it to scroll down (no keyup event).
1017                // listen on the document because that's where key events are triggered if no input has focus
1018                var query = "";
1019                var queryTimer = null;
1020                this._handleKeydownOnDropdown = function(e) {
1021                    // prevent down key from scrolling the whole page,
1022                    // and enter key from submitting a form etc
1023                    if ([ "ArrowUp", "ArrowDown", "Enter", "Escape" ].includes(e.ke
1023y)) {
1024                        e.preventDefault();
1025                        e.stopPropagation();
1026                        // up and down to navigate
1027                        if (e.key === "ArrowUp" || e.key === "ArrowDown") {
1028                            _this8._handleUpDownKey(e.key);
1029                        } else if (e.key === "Enter") {
1030                            _this8._handleEnterKey();
1031                        } else if (e.key === "Escape") {
1032                            _this8._closeDropdown();
1033                        }
1034                    }
1035                    // alpha chars to perform search
1036                    // regex allows one latin alpha char or space, based on https://stackoverflow.com/a/26900132/217866)
1037                    if (!_this8.options.countrySearch && /^[a-zA-ZÀ-ÿа-яА-Я ]$/.test(e.key)) {
1038                        e.stopPropagation();
1039                        // jump to countries that start with the query string
1040                        if (queryTimer) {
1041                            clearTimeout(queryTimer);
1042                        }
1043                        query += e.key.toLowerCase();
1044                        _this8._searchForCountry(query);
1045                        // if the timer hits 1 second, reset the query
1046                        queryTimer = setTimeout(function() {
1047                            query = "";
1048                        }, 1e3);
1049                    }
1050                };
1051                document.addEventListener("keydown", this._handleKeydownOnDropdown);
1052                if (this.options.countrySearch) {
1053                    var doFilter = function doFilter() {
1054                        var inputQuery = _this8.searchInput.value.trim();
1055                        if (inputQuery) {
1056                            _this8._filterCountries(inputQuery);
1057                        } else {
1058                            _this8._filterCountries("", true);
1059                        }
1060                    };
1061                    var keyupTimer = null;
1062                    this._handleSearchChange = function() {
1063                        // filtering country nodes is expensive (lots of DOM manipulation), so rate limit it
1064                        if (keyupTimer) {
1065                            clearTimeout(keyupTimer);
1066                        }
1067                        keyupTimer = setTimeout(function() {
1068                            doFilter();
1069                            keyupTimer = null;
1070                        }, 100);
1071                    };
1072                    this.searchInput.addEventListener("input", this._handleSearchChange);
1073                    // stop propagation on search input click, so doesn't trigger click-off-to-close listener
1074                    this.searchInput.addEventListener("click", function(e) {
1075                        return e.stopPropagation();
1076                    });
1077                }
1078            }
1079        }, {
1080            key: "_normaliseString",
1081            value: function _normaliseString() {
1082                var s = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
1083                return s.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase();
1084            }
1085        }, {
1086            key: "_filterCountries",
1087            value: function _filterCountries(query) {
1088                var isReset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
1089                var isFirst = true;
1090                this.countryList.innerHTML = "";
1091                var normalisedQuery = this._normaliseString(query);
1092                for (var i = 0; i < this.countries.length; i++) {
1093                    var c = this.countries[i];
1094                    var normalisedCountryName = this._normaliseString(c.name);
1095                    var fullDialCode = "+".concat(c.dialCode);
1096                    if (isReset || normalisedCountryName.includes(normalisedQuery) || fullDialCode.includes(normalisedQuery) || c.iso2.includes(normalisedQuery)) {
1097                        this.countryList.appendChild(c.nodeById[this.id]);
1098                        // highlight the first item
1099                        if (isFirst) {
1100                            this._highlightListItem(c.nodeById[this.id], false);
1101                            isFirst = false;
1102                        }
1103                    }
1104                }
1105                // scroll to top (useful if user had previously scrolled down)
1106                this.countryList.scrollTop = 0;
1107                this._updateSearchResultsText();
1108            }
1109        }, {
1110            key: "_updateSearchResultsText",
1111            value: function _updateSearchResultsText() {
1112                var i18n = this.options.i18n;
1113                var count = this.countryList.childElementCount;
1114                var searchText;
1115                if (count === 0) {
1116                    searchText = i18n.zeroSearchResults || "No results found";
1117                } else if (count === 1) {
1118                    searchText = i18n.oneSearchResult || "1 result found";
1119                } else {
1120                    // eslint-disable-next-line no-template-curly-in-string
1121                    searchText = i18n.multipleSearchResults ? i18n.multipleSearchResults.replace("${count}", count) : "".concat(count, " results found");
1122                }
1123                this.searchResultsA11yText.textContent = searchText;
1124            }
1125        }, {
1126            key: "_handleUpDownKey",
1127            value: function _handleUpDownKey(key) {
1128                var next = key === "ArrowUp" ? this.highlightedItem.previousElementSibling : this.highlightedItem.nextElementSibling;
1129                if (next) {
1130                    // skip the divider
1131                    if (next.classList.contains("iti__divider")) {
1132                        next = key === "ArrowUp" ? next.previousElementSibling : next.nextElementSibling;
1133                    }
1134                } else if (this.countryList.childElementCount > 1) {
1135                    // otherwise, we must be at the end, so loop round again
1136                    next = key === "ArrowUp" ? this.countryList.lastElementChild : this.countryList.firstElementChild;
1137                }
1138                if (next) {
1139                    // make sure the next item is visible
1140                    // (before calling focus(), which can cause the next item to scroll to the middle of the dropdown, which is jarring)
1141                    this._scrollTo(next, false);
1142                    // if country search enabled, dont lose focus from the search input on up/down
1143                    var doFocus = !this.options.countrySearch;
1144                    this._highlightListItem(next, doFocus);
1145                }
1146            }
1147        }, {
1148            key: "_handleEnterKey",
1149            value: function _handleEnterKey() {
1150                if (this.highlightedItem) {
1151                    this._selectListItem(this.highlightedItem);
1152                }
1153            }
1154        }, {
1155            key: "_searchForCountry",
1156            value: function _searchForCountry(query) {
1157                for (var i = 0; i < this.countries.length; i++) {
1158                    if (this._startsWith(this.countries[i].name, query)) {
1159                        var listItem = this.countries[i].nodeById[this.id];
1160                        // update highlighting and scroll
1161                        this._highlightListItem(listItem, false);
1162                        this._scrollTo(listItem, true);
1163                        break;
1164                    }
1165                }
1166            }
1167        }, {
1168            key: "_startsWith",
1169            value: function _startsWith(a, b) {
1170                return a.substr(0, b.length).toLowerCase() === b;
1171            }
1172        }, {
1173            key: "_updateValFromNumber",
1174            value: function _updateValFromNumber(fullNumber) {
1175                var number = fullNumber;
1176                if (this.options.formatOnDisplay && window.intlTelInputUtils && this.selectedCountryData) {
1177                    var useNational = this.options.nationalMode || number.charAt(0) !== "+" && !this.options.showSelectedDialCode;
1178                    var _intlTelInputUtils$nu = intlTelInputUtils.numberFormat, NATIONAL = _intlTelInputUtils$nu.NATIONAL, INTERNATIONAL = _intlTelInputUtils$nu.INTERNATIONAL;
1179                    var format = useNational ? NATIONAL : INTERNATIONAL;
1180                    number = intlTelInputUtils.formatNumber(number, this.selectedCountryData.iso2, format);
1181                }
1182                number = this._beforeSetNumber(number);
1183                this.telInput.value = number;
1184            }
1185        }, {
1186            key: "_updateFlagFromNumber",
1187            value: function _updateFlagFromNumber(fullNumber) {
1188                var plusIndex = fullNumber.indexOf("+");
1189                // if it contains a plus, discard any chars before it e.g. accidental space char.
1190                // this keeps the selected country auto-updating correctly, which we want as
1191                // libphonenumber's validation/getNumber methods will ignore these chars anyway
1192                var number = plusIndex ? fullNumber.substring(plusIndex) : fullNumber;
vendor: 5,051 bytes, lines 1193-1280
1193                // if we already have US/Canada selected, make sure the number starts
1194                // with a +1 so _getDialCode will be able to extract the area code
1195                // update: if we dont yet have selectedCountryData, but we're here (trying to update the flag
1196                // from the number), that means we're initialising the plugin with a number that already has a
1197                // dial code, so fine to ignore this bit
1198                var selectedDialCode = this.selectedCountryData.dialCode;
1199                var isNanp = selectedDialCode === "1";
1200                if (number && isNanp && number.charAt(0) !== "+") {
1201                    if (number.charAt(0) !== "1") {
1202                        number = "1".concat(number);
1203                    }
1204                    number = "+".concat(number);
1205                }
1206                // if showSelectedDialCode enabled, then consider the selected dial code to be part of the number
1207                if (this.options.showSelectedDialCode && selectedDialCode && number.charAt(0) !== "+") {
1208                    number = "+".concat(selectedDialCode).concat(number);
1209                }
1210                // try and extract valid dial code from input
1211                var dialCode = this._getDialCode(number, true);
1212                var numeric = this._getNumeric(number);
1213                var iso2 = null;
1214                if (dialCode) {
1215                    var iso2Codes = this.dialCodeToIso2Map[this._getNumeric(dialCode)];
1216                    // check if the right country is already selected. this should be false if the number is
1217                    // longer than the matched dial code because in this case we need to make sure that if
1218                    // there are multiple country matches, that the first one is selected (note: we could
1219                    // just check that here, but it requires the same loop that we already have later)
1220                    var alreadySelected = iso2Codes.indexOf(this.selectedCountryData.iso2) !== -1 && numeric.length <= dialCode.length - 1;
1221                    var isRegionlessNanpNumber = selectedDialCode === "1" && this._isRegionlessNanp(numeric);
1222                    // only update the flag if:
1223                    // A) NOT (we currently have a NANP flag selected, and the number is a regionlessNanp)
1224                    // AND
1225                    // B) the right country is not already selected
1226                    if (!isRegionlessNanpNumber && !alreadySelected) {
1227                        // if using onlyCountries option, iso2Codes[0] may be empty, so we must find the first
1228                        // non-empty index
1229                        for (var j = 0; j < iso2Codes.length; j++) {
1230                            if (iso2Codes[j]) {
1231                                iso2 = iso2Codes[j];
1232                                break;
1233                            }
1234                        }
1235                    }
1236                } else if (number.charAt(0) === "+" && numeric.length) {
1237                    // invalid dial code, so empty
1238                    // Note: use getNumeric here because the number has not been formatted yet, so could contain
1239                    // bad chars
1240                    iso2 = "";
1241                } else if ((!number || number === "+") && !this.selectedCountryData.iso2) {
1242                    // if no selected flag, and user either clears the input, or just types a plus, then show default
1243                    iso2 = this.defaultCountry;
1244                }
1245                if (iso2 !== null) {
1246                    return this._setCountry(iso2);
1247                }
1248                return false;
1249            }
1250        }, {
1251            key: "_isRegionlessNanp",
1252            value: function _isRegionlessNanp(number) {
1253                var numeric = this._getNumeric(number);
1254                if (numeric.charAt(0) === "1") {
1255                    var areaCode = numeric.substr(1, 3);
1256                    return regionlessNanpNumbers.indexOf(areaCode) !== -1;
1257                }
1258                return false;
1259            }
1260        }, {
1261            key: "_highlightListItem",
1262            value: function _highlightListItem(listItem, shouldFocus) {
1263                var prevItem = this.highlightedItem;
1264                if (prevItem) {
1265                    prevItem.classList.remove("iti__highlight");
1266                    prevItem.setAttribute("aria-selected", "false");
1267                }
1268                this.highlightedItem = listItem;
1269                this.highlightedItem.classList.add("iti__highlight");
1270                this.highlightedItem.setAttribute("aria-selected", "true");
1271                this.selectedFlag.setAttribute("aria-activedescendant", listItem.getAttribute("id"));
1272                if (this.options.countrySearch) {
1273                    this.searchInput.setAttribute("aria-activedescendant", listItem.getAttribute("id"));
1274                }
1275                if (shouldFocus) {
1276                    this.highlightedItem.focus();
1277                }
1278            }
1279        }, {
1280            key: "_getCountryData",
1281            value: function _getCountryData(iso2, allowFail) {
1282                for (var i = 0; i < this.countries.length; i++) {
1283                    if (this.countries[i].iso2 === iso2) {
1284                        return this.countries[i];
1285                    }
1286                }
1287                if (allowFail) {
1288                    return null;
1289                }
1290                throw new Error("No country data for '".concat(iso2, "'"));
1291            }
1292        }, {
1293            key: "_setCountry",
1294            value: function _setCountry(iso2) {
1295                var _this$options3 = this.options, allowDropdown = _this$options3.allowDropdown, showSelectedDialCode = _this$options3.showSelectedDialCode, showFlags = _this$options3.showFlags, countrySearch = _this$options3.countrySearch, i18n = _this$options3.i18n;
1296                var prevCountry = this.selectedCountryData.iso2 ? this.selectedCountryData : {};
1297                // do this first as it will throw an error and stop if iso2 is invalid
1298                this.selectedCountryData = iso2 ? this._getCountryData(iso2, false) : {};
1299                // update the defaultCountry - we only need the iso2 from now on, so just store that
1300                if (this.selectedCountryData.iso2) {
1301                    this.defaultCountry = this.selectedCountryData.iso2;
1302                }
1303                // update the flag class and the a11y text
1304                if (this.selectedFlagInner) {
1305                    var flagClass = "";
1306                    var a11yText = "";
1307                    if (iso2) {
1308                        if (showFlags) {
1309                            flagClass = "iti__flag iti__".concat(iso2);
1310                            a11yText = "".concat(this.selectedCountryData.name, " +").concat(this.selectedCountryData.dialCode);
1311                        }
1312                    } else {
1313                        flagClass = "iti__flag iti__globe";
1314                        a11yText = i18n.noCountrySelected || "No country selected";
1315                    }
1316                    this.selectedFlagInner.className = flagClass;
1317                    this.selectedFlagA11yText.textContent = a11yText;
1318                }
1319                this._setSelectedCountryFlagTitleAttribute(iso2, showSelectedDialCode);
1320                // update the selected dial code
1321                if (showSelectedDialCode) {
1322                    var dialCode = this.selectedCountryData.dialCode ? "+".concat(this.selectedCountryData.dialCode) : "";
1323                    this.selectedDialCode.innerHTML = dialCode;
1324                    // offsetWidth is zero if input is in a hidden container during initialisation
1325                    var selectedFlagWidth = this.selectedFlag.offsetWidth || this._getHiddenSelectedFlagWidth();
1326                    // add 6px of padding after the grey selected-dial-code box, as this is what we use in the css
1327                    if (this.isRTL) {
1328                        this.telInput.style.paddingRight = "".concat(selectedFlagWidth + 6, "px");
1329                    } else {
1330                        this.telInput.style.paddingLeft = "".concat(selectedFlagWidth + 6, "px");
1331                    }
1332                }
1333                // and the input's placeholder
1334                this._updatePlaceholder();
1335                // update the active list item (only if country search disabled, as country search doesn't store the active item)
1336                if (allowDropdown && !countrySearch) {
1337                    var prevItem = this.activeItem;
1338                    if (prevItem) {
1339                        prevItem.classList.remove("iti__active");
1340                        prevItem.setAttribute("aria-selected", "false");
1341                    }
1342                    if (iso2) {
1343                        // check if there is a preferred item first, else fall back to standard
1344                        var nextItem = this.countryList.querySelector("#iti-".concat(this.id, "__item-").concat(iso2, "-preferred")) || this.countryList.querySelector("#iti-".concat(this.id, "__item-").concat(iso2));
1345                        nextItem.setAttribute("aria-selected", "true");
1346                        nextItem.classList.add("iti__active");
1347                        this.activeItem = nextItem;
1348                    }
1349                }
1350                // return if the flag has changed or not
1351                return prevCountry.iso2 !== iso2;
1352            }
1353        }, {
1354            key: "_setSelectedCountryFlagTitleAttribute",
1355            value: function _setSelectedCountryFlagTitleAttribute(iso2, showSelectedDialCode) {
1356                if (!this.selectedFlag) {
1357                    return;
1358                }
1359                var title;
1360                if (iso2 && !showSelectedDialCode) {
1361                    title = "".concat(this.selectedCountryData.name, ": +").concat(this.selectedCountryData.dialCode);
1362                } else if (iso2) {
1363                    // For screen reader output, we don't want to include the dial code in the reader output twice
1364                    // so just use the selected country name here:
1365                    title = this.selectedCountryData.name;
1366                } else {
1367                    title = "Unknown";
1368                }
1369                this.selectedFlag.setAttribute("title", title);
1370            }
1371        }, {
1372            key: "_getHiddenSelectedFlagWidth",
1373            value: function _getHiddenSelectedFlagWidth() {
1374                // to get the right styling to apply, all we need is a shallow clone of the container,
1375                // and then to inject a deep clone of the selectedFlag element
1376                var containerClone = this.telInput.parentNode.cloneNode();
1377                containerClone.style.visibility = "hidden";
1378                document.body.appendChild(containerClone);
1379                var flagsContainerClone = this.flagsContainer.cloneNode();
1380                containerClone.appendChild(flagsContainerClone);
1381                var selectedFlagClone = this.selectedFlag.cloneNode(true);
1382                flagsContainerClone.appendChild(selectedFlagClone);
1383                var width = selectedFlagClone.offsetWidth;
1384                containerClone.parentNode.removeChild(containerClone);
1385                return width;
1386            }
1387        }, {
1388            key: "_updatePlaceholder",
1389            value: function _updatePlaceholder() {
1390                var _this$options4 = this.options, autoPlaceholder = _this$options4.autoPlaceholder, placeholderNumberType = _this$options4.placeholderNumberType, nationalMode = _this$options4.nationalMode, customPlaceholder = _this$options4.customPlaceholder;
1391                var shouldSetPlaceholder = autoPlaceholder === "aggressive" || !this.hadInitialPlaceholder && autoPlaceholder === "polite";
1392                if (window.intlTelInputUtils && shouldSetPlaceholder) {
1393                    var numberType = intlTelInputUtils.numberType[placeholderNumberType];
1394                    var placeholder = this.selectedCountryData.iso2 ? intlTelInputUtils.getExampleNumber(this.selectedCountryData.iso2, nationalMode, numberType) : "";
1395                    placeholder = this._beforeSetNumber(placeholder);
1396                    if (typeof customPlaceholder === "function") {
1397                        placeholder = customPlaceholder(placeholder, this.selectedCountryData);
1398                    }
1399                    this.telInput.setAttribute("placeholder", placeholder);
1400                }
1401            }
1402        }, {
1403            key: "_selectListItem",
1404            value: function _selectListItem(listItem) {
1405                // update selected flag and active list item
1406                var flagChanged = this._setCountry(listItem.getAttribute("data-country-code"));
1407                this._closeDropdown();
1408                this._updateDialCode(listItem.getAttribute("data-dial-code"));
1409                // focus the input
1410                this.telInput.focus();
1411                if (flagChanged) {
1412                    this._triggerCountryChange();
1413                }
1414            }
1415        }, {
1416            key: "_closeDropdown",
1417            value: function _closeDropdown() {
1418                this.dropdownContent.classList.add("iti__hide");
1419                this.selectedFlag.setAttribute("aria-expanded", "false");
1420                this.selectedFlag.removeAttribute("aria-activedescendant");
1421                if (this.highlightedItem) {
1422                    this.highlightedItem.setAttribute("aria-selected", "false");
1423                }
1424                if (this.options.countrySearch) {
1425                    this.searchInput.removeAttribute("aria-activedescendant");
1426                }
1427                // update the arrow
1428                this.dropdownArrow.classList.remove("iti__arrow--up");
1429                // unbind key events
1430                document.removeEventListener("keydown", this._handleKeydownOnDropdown);
1431                if (this.options.countrySearch) {
1432                    this.searchInput.removeEventListener("input", this._handleSearchChange);
1433                }
1434                document.documentElement.removeEventListener("click", this._handleClickOffToClose);
1435                this.countryList.removeEventListener("mouseover", this._handleMouseoverCountryList);
1436                this.countryList.removeEventListener("click", this._handleClickCountryList);
1437                // remove menu from container
1438                if (this.options.dropdownContainer) {
1439                    if (!this.options.useFullscreenPopup) {
1440                        window.removeEventListener("scroll", this._handleWindowScroll);
1441                    }
1442                    if (this.dropdown.parentNode) {
1443                        this.dropdown.parentNode.removeChild(this.dropdown);
1444                    }
1445                }
1446                this._trigger("close:countrydropdown");
1447            }
1448        }, {
1449            key: "_scrollTo",
1450            value: function _scrollTo(element, middle) {
1451                var container = this.countryList;
1452                // windowTop from https://stackoverflow.com/a/14384091/2
vendor: 8,239 bytes, lines 1452-1606
145217866
1453                var windowTop = document.documentElement.scrollTop;
1454                var containerHeight = container.offsetHeight;
1455                var containerTop = container.getBoundingClientRect().top + windowTop;
1456                var containerBottom = containerTop + containerHeight;
1457                var elementHeight = element.offsetHeight;
1458                var elementTop = element.getBoundingClientRect().top + windowTop;
1459                var elementBottom = elementTop + elementHeight;
1460                var newScrollTop = elementTop - containerTop + container.scrollTop;
1461                var middleOffset = containerHeight / 2 - elementHeight / 2;
1462                if (elementTop < containerTop) {
1463                    // scroll up
1464                    if (middle) {
1465                        newScrollTop -= middleOffset;
1466                    }
1467                    container.scrollTop = newScrollTop;
1468                } else if (elementBottom > containerBottom) {
1469                    // scroll down
1470                    if (middle) {
1471                        newScrollTop += middleOffset;
1472                    }
1473                    var heightDifference = containerHeight - elementHeight;
1474                    container.scrollTop = newScrollTop - heightDifference;
1475                }
1476            }
1477        }, {
1478            key: "_updateDialCode",
1479            value: function _updateDialCode(newDialCodeBare) {
1480                var inputVal = this.telInput.value;
1481                // save having to pass this every time
1482                var newDialCode = "+".concat(newDialCodeBare);
1483                var newNumber;
1484                if (inputVal.charAt(0) === "+") {
1485                    // there's a plus so we're dealing with a replacement
1486                    var prevDialCode = this._getDialCode(inputVal);
1487                    if (prevDialCode) {
1488                        // current number contains a valid dial code, so replace it
1489                        newNumber = inputVal.replace(prevDialCode, newDialCode);
1490                    } else {
1491                        // current number contains an invalid dial code, so ditch it
1492                        // (no way to determine where the invalid dial code ends and the rest of the number begins)
1493                        newNumber = newDialCode;
1494                    }
1495                    this.telInput.value = newNumber;
1496                }
1497            }
1498        }, {
1499            key: "_getDialCode",
1500            value: function _getDialCode(number, includeAreaCode) {
1501                var dialCode = "";
1502                // only interested in international numbers (starting with a plus)
1503                if (number.charAt(0) === "+") {
1504                    var numericChars = "";
1505                    // iterate over chars
1506                    for (var i = 0; i < number.length; i++) {
1507                        var c = number.charAt(i);
1508                        // if char is number (https://stackoverflow.com/a/8935649/217866)
1509                        if (!isNaN(parseInt(c, 10))) {
1510                            numericChars += c;
1511                            // if current numericChars make a valid dial code
1512                            if (includeAreaCode) {
1513                                if (this.dialCodeToIso2Map[numericChars]) {
1514                                    // store the actual raw string (useful for matching later)
1515                                    dialCode = number.substr(0, i + 1);
1516                                }
1517                            } else {
1518                                if (this.dialCodes[numericChars]) {
1519                                    dialCode = number.substr(0, i + 1);
1520                                    // if we're just looking for a dial code, we can break as soon as we find one
1521                                    break;
1522                                }
1523                            }
1524                            // stop searching as soon as we can - in this case when we hit max len
1525                            if (numericChars.length === this.dialCodeMaxLen) {
1526                                break;
1527                            }
1528                        }
1529                    }
1530                }
1531                return dialCode;
1532            }
1533        }, {
1534            key: "_getFullNumber",
1535            value: function _getFullNumber() {
1536                var val = this.telInput.value.trim();
1537                var dialCode = this.selectedCountryData.dialCode;
1538                var prefix;
1539                var numericVal = this._getNumeric(val);
1540                if (this.options.showSelectedDialCode && !this.options.nationalMode && val.charAt(0) !== "+" && dialCode && numericVal) {
1541                    // when using showSelectedDialCode, it is visible so is effectively part of the typed number
1542                    prefix = "+".concat(dialCode);
1543                } else {
1544                    prefix = "";
1545                }
1546                return prefix + val;
1547            }
1548        }, {
1549            key: "_beforeSetNumber",
1550            value: function _beforeSetNumber(fullNumber) {
1551                var number = fullNumber;
1552                if (this.options.showSelectedDialCode) {
1553                    var dialCode = this._getDialCode(number);
1554                    // if there is a valid dial code
1555                    if (dialCode) {
1556                        // in case _getDialCode returned an area code as well
1557                        dialCode = "+".concat(this.selectedCountryData.dialCode);
1558                        // a lot of numbers will have a space separating the dial code and the main number, and
1559                        // some NANP numbers will have a hyphen e.g. +1 684-733-1234 - in both cases we want to get
1560                        // rid of it
1561                        // NOTE: don't just trim all non-numerics as may want to preserve an open parenthesis etc
1562                        var start = number[dialCode.length] === " " || number[dialCode.length] === "-" ? dialCode.length + 1 : dialCode.length;
1563                        number = number.substr(start);
1564                    }
1565                }
1566                return this._cap(number);
1567            }
1568        }, {
1569            key: "_triggerCountryChange",
1570            value: function _triggerCountryChange() {
1571                this._trigger("countrychange");
1572            }
1573        }, {
1574            key: "_formatNumberAsYouType",
1575            value: function _formatNumberAsYouType() {
1576                var val = this._getFullNumber();
1577                var result = window.intlTelInputUtils ? intlTelInputUtils.formatNumberAsYouType(val, this.selectedCountryData.iso2) : val;
1578                // if showSelectedDialCode and they haven't (re)typed the dial code in the input as well, then remove the dial code
1579                var dialCode = this.selectedCountryData.dialCode;
1580                if (this.options.showSelectedDialCode && !this.options.nationalMode && this.telInput.value.charAt(0) !== "+" && result.includes("+".concat(dialCode))) {
1581                    var afterDialCode = result.split("+".concat(dialCode))[1] || "";
1582                    return afterDialCode.trim();
1583                }
1584                return result;
1585            }
1586        }, {
1587            key: "handleAutoCountry",
1588            value: function handleAutoCountry() {
1589                if (this.options.initialCountry === "auto") {
1590                    // we must set this even if there is an initial val in the input: in case the initial val is
1591                    // invalid and they delete it - they should see their auto country
1592                    this.defaultCountry = window.intlTelInputGlobals.autoCountry;
1593                    // if there's no initial value in the input, then update the flag
1594                    if (!this.telInput.value) {
1595                        this.setCountry(this.defaultCountry);
1596                    }
1597                    this.resolveAutoCountryPromise();
1598                }
1599            }
1600        }, {
1601            key: "handleUtils",
1602            value: function handleUtils() {
1603                // if the request was successful
1604                if (window.intlTelInputUtils) {
1605                    // if there's an initial value in the input, then format it
1606                    if (this.telInput.value) {
1607                        this._updateValFromNumber(this.telInput.value);
1608                    }
1609                    if (this.selectedCountryData.iso2) {
1610                        this._updatePlaceholder();
1611                    }
1612                }
1613                this.resolveUtilsScriptPromise();
1614            }
1615        }, {
1616            key: "destroy",
1617            value: function destroy() {
1618                if (this.options.allowDropdown) {
1619                    // make sure the dropdown is closed (and unbind listeners)
1620                    this._closeDropdown();
1621                    this.selectedFlag.removeEventListener("click", this._handleClickSelectedFlag);
1622                    this.flagsContainer.removeEventListener("keydown", this._handleFlagsContainerKeydown);
1623                    // label click hack
1624                    var label = this.telInput.closest("label");
1625                    if (label) {
1626                        label.removeEventListener("click", this._handleLabelClick);
1627                    }
1628                }
1629                // unbind hiddenInput listeners
1630                var form = this.telInput.form;
1631                if (this._handleHiddenInputSubmit && form) {
1632                    form.removeEventListener("submit", this._handleHiddenInputSubmit);
1633                }
1634                // unbind key events, and cut/paste events
1635                this.telInput.removeEventListener("input", this._handleKeyEvent);
1636                // remove attribute of id instance: data-intl-tel-input-id
1637                this.telInput.removeAttribute("data-intl-tel-input-id");
1638                // remove markup (but leave the original input)
1639                var wrapper = this.telInput.parentNode;
1640                wrapper.parentNode.insertBefore(this.telInput, wrapper);
1641                wrapper.parentNode.removeChild(wrapper);
1642                delete window.intlTelInputGlobals.instances[this.id];
1643            }
1644        }, {
1645            key: "getExtension",
1646            value: function getExtension() {
1647                if (window.intlTelInputUtils) {
1648                    return intlTelInputUtils.getExtension(this._getFullNumber(), this.selectedCountryData.iso2);
1649                }
1650                return "";
1651            }
1652        }, {
1653            key: "getNumber",
1654            value: function getNumber(format) {
1655                if (window.intlTelInputUtils) {
1656                    var iso2 = this.selectedCountryData.iso2;
1657                    return intlTelInputUtils.formatNumber(this._getFullNumber(), iso2, format);
1658                }
1659                return "";
1660            }
1661        }, {
1662            key: "getNumberType",
1663            value: function getNumberType() {
1664                if (window.intlTelInputUtils) {
1665                    return intlTelInputUtils.getNumberType(this._getFullNumber(), this.selectedCountryData.iso2);
1666                }
1667                return -99;
1668            }
1669        }, {
1670            key: "getSelectedCountryData",
1671            value: function getSelectedCountryData() {
1672                return this.selectedCountryData;
1673            }
1674        }, {
1675            key: "getValidationError",
1676            value: function getValidationError() {
1677                if (window.intlTelInputUtils) {
1678                    var iso2 = this.selectedCountryData.iso2;
1679                    return intlTelInputUtils.getValidationError(this._getFullNumber(), iso2);
1680                }
1681                return -99;
1682            }
1683        }, {
1684            key: "isValidNumber",
1685            value: function isValidNumber() {
1686                var mobileOnly = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
1687                var val = this._getFullNumber();
1688                // return false for any alpha chars
1689                if (/(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088E\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u
16890EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7CA\uA7D0\uA7D1\uA7D3\uA7D5-\uA7D9\uA7F2-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDD70-\uDD7A\uDD7C-\uDD8A\uDD8C-\uDD92\uDD94\uDD95\uDD97-\uDDA1\uDDA3-\uDDB1\uDDB3-\uDDB9\uDDBB\uDDBC\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67\uDF80-\uDF85\uDF87-\uDFB0\uDFB2-\uDFBA]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDF70-\uDF81\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC71\uDC72\uDC75\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE3F\uDE40\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A\uDF40-\uDF46]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEB0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDF02\uDF04-\uDF10\uDF12-\uDF33\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD887][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2F\uDC41-\uDC46]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE70-\uDEBE\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD32\uDD50-\uDD52\uDD55\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD837[\uDF00-\uDF1E\uDF25-\uDF2A]|\uD838[\uDC30-\uDC6D\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDE90-\uDEAD\uDEC0-\uDEEB]|\uD839[\uDCD0-\uDCEB\uDFE0-\uDFE6\uDFE8-\uDFEB\uDFED\uDFEE\uDFF0-\uDFFE]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF39\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD888[\uDC00-\uDFAF])/.test(val)) {
1690                    return false;
1691                }
1692                return window.intlTelInputUtils ? intlTelInputUtils.isPossibleNumber(val, this.selectedCountryData.iso2, mobileOnly) : null;
1693            }
1694        }, {
1695            key: "isValidNumberPrecise",
1696            value: function isValidNumberPrecise() {
1697                var val = this._getFullNumber();
1698                // return false for any alpha chars
1699                if (/(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088E\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7CA\uA7D0\uA7D1\uA7D3\uA7D5-\uA7D9\uA7F2-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFB
1699D3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDD70-\uDD7A\uDD7C-\uDD8A\uDD8C-\uDD92\uDD94\uDD95\uDD97-\uDDA1\uDDA3-\uDDB1\uDDB3-\uDDB9\uDDBB\uDDBC\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67\uDF80-\uDF85\uDF87-\uDFB0\uDFB2-\uDFBA]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDF70-\uDF81\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC71\uDC72\uDC75\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE3F\uDE40\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A\uDF40-\uDF46]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEB0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDF02\uDF04-\uDF10\uDF12-\uDF33\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD887][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2F\uDC41-\uDC46]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE70-\uDEBE\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD32\uDD50-\uDD52\uDD55\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD837[\uDF00-\uDF1E\uDF25-\uDF2A]|\uD838[\uDC30-\uDC6D\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDE90-\uDEAD\uDEC0-\uDEEB]|\uD839[\uDCD0-\uDCEB\uDFE0-\uDFE6\uDFE8-\uDFEB\uDFED\uDFEE\uDFF0-\uDFFE]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF39\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD888[\uDC00-\uDFAF])/.test(val)) {
1700                    return false;
1701                }
1702                return window.intlTelInputUtils ? intlTelInputUtils.isValidNumber(val, this.selectedCountryData.iso2) : null;
1703            }
1704        }, {
1705            key: "setCountry",
1706            value: function setCountry(iso2) {
1707                var iso2Lower = iso2.toLowerCase();
1708                // check if already selected
1709                if (this.selectedCountryData.iso2 !== iso2Lower) {
1710                    this._setCountry(iso2Lower);
1711                    this._updateDialCode(this.selectedCountryData.dialCode);
1712                    this._triggerCountryChange();
1713                }
1714            }
1715        }, {
1716            key: "setNumber",
1717            value: function setNumber(number) {
1718                // we must update the flag first, which updates this.selectedCountryData, which is used for
1719                // formatting the number before displaying it
1720                var flagChanged = this._updateFlagFromNumber(number);
1721                this._updateValFromNumber(number);
1722                if (flagChanged) {
1723                    this._triggerCountryChange();
1724                }
1725            }
1726        }, {
1727            key: "setPlaceholderNumberType",
1728            value: function setPlaceholderNumberType(type) {
1729                this.options.placeholderNumberType = type;
1730                this._updatePlaceholder();
1731            }
1732        } ]);
1733        return Iti;
1734    }();
1735    /********************
1736 *  STATIC METHODS
1737 ********************/
1738    // get the country data object
1739    intlTelInputGlobals.getCountryData = function() {
1740        return allCountries;
1741    };
1742    // inject a <script> element to load utils.js
1743    var injectScript = function injectScript(path, handleSuccess, handleFailure) {
1744        // inject a new script element into the page
1745        var script = document.createElement("script");
1746        script.onload = function() {
1747            forEachInstance("handleUtils");
1748            if (handleSuccess) {
1749                handleSuccess();
1750            }
1751        };
1752        script.onerror = function() {
1753            forEachInstance("rejectUtilsScriptPromise");
1754            if (handleFailure) {
1755                handleFailure();
1756            }
1757        };
1758        script.className = "iti-load-utils";
1759        script.async = true;
1760        script.src = path;
1761        document.body.appendChild(script);
1762    };
1763    // load the utils script
1764    intlTelInputGlobals.loadUtils = function(path) {
1765        // 2 options:
1766        // 1) not already started loading (start)
1767        // 2) already started loading (do nothing - just wait for the onload callback to fire, which will
1768        // trigger handleUtils on all instances, invoking their resolveUtilsScriptPromise functions)
1769        if (!window.intlTelInputUtils && !window.intlTelInputGlobals.startedLoadingUtilsScript) {
1770            // only do this once
1771            window.intlTelInputGlobals.startedLoadingUtilsScript = true;
1772            return new Promise(function(resolve, reject) {
1773                return injectScript(path, resolve, reject);
1774            });
1775        }
1776        return null;
1777    };
1778    // default options
1779    intlTelInputGlobals.defaults = defaults;
1780    // version
1781    intlTelInputGlobals.version = "20.0.4";
1782    var pluginName = "intlTelInput";
1783    // A really lightweight plugin wrapper around the constructor,
1784    // preventing against multiple instantiations
1785    $.fn[pluginName] = function(options) {
1786        var args = arguments;
1787        // Is the first parameter an object (options), or was omitted, instantiate a new instance of the plugin.
1788        if (options === undefined || typeof options === "object") {
1789            return this.each(function() {
1790                if (!$.data(this, "plugin_" + pluginName)) {
1791                    var iti = new Iti(this, options);
1792                    iti._init();
1793                    window.intlTelInputGlobals.instances[iti.id] = iti;
1794                    $.data(this, "plugin_" + pluginName, iti);
1795                }
1796            });
1797        } else if (typeof options === "string" && options[0] !== "_") {
1798            // If the first parameter is a string and it doesn't start with an underscore treat this as a call to a public method.
1799            // Cache the method call to make it possible to return a value
1800            var returns;
1801            this.each(function() {
1802                var instance = $.data(this, "plugin_" + pluginName);
1803                // Tests that there's already a plugin-instance and checks that the requested public method exists
1804                if (instance instanceof Iti && typeof instance[options] === "function") {
1805                    // Call the method of our plugin instance, and pass it the supplied arguments.
1806                    returns = instance[options].apply(instance, Array.prototype.slice.call(args, 1));
1807                }
1808                // Allow instances to be destroyed via the 'destroy' method
1809                if (options === "destroy") $.data(this, "plugin_" + pluginName, null);
1810            });
1811            // If the earlier cached method gives a value back return the value, otherwise return this to preserve chainability.
1812            return returns !== undefined ? returns : this;
1813        }
1814    };
1815});

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.