intl-tel-input 25.11.0 → 25.11.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/README.md +5 -5
  2. package/angular/README.md +1 -1
  3. package/angular/build/IntlTelInput.js +349 -200
  4. package/angular/build/IntlTelInputWithUtils.js +349 -200
  5. package/angular/build/types/intl-tel-input/data.d.ts +3 -3
  6. package/angular/build/types/intl-tel-input.d.ts +5 -1
  7. package/angular/build/types/modules/constants.d.ts +84 -0
  8. package/angular/build/types/modules/core/countrySearch.d.ts +17 -0
  9. package/angular/build/types/modules/core/icons.d.ts +7 -0
  10. package/angular/build/types/modules/core/options.d.ts +2 -1
  11. package/angular/build/types/modules/data/country-data.d.ts +5 -5
  12. package/angular/build/types/modules/format/caret.d.ts +1 -1
  13. package/angular/build/types/modules/format/formatting.d.ts +2 -2
  14. package/angular/build/types/modules/types/events.d.ts +5 -4
  15. package/build/js/data.js +8 -2
  16. package/build/js/data.min.js +2 -2
  17. package/build/js/intlTelInput.d.ts +137 -17
  18. package/build/js/intlTelInput.js +397 -226
  19. package/build/js/intlTelInput.min.js +13 -13
  20. package/build/js/intlTelInputWithUtils.js +397 -226
  21. package/build/js/intlTelInputWithUtils.min.js +13 -13
  22. package/package.json +2 -1
  23. package/react/README.md +1 -1
  24. package/react/build/IntlTelInput.cjs +396 -225
  25. package/react/build/IntlTelInput.d.ts +137 -17
  26. package/react/build/IntlTelInput.js +396 -225
  27. package/react/build/IntlTelInputWithUtils.cjs +396 -225
  28. package/react/build/IntlTelInputWithUtils.js +396 -225
  29. package/vue/README.md +1 -1
  30. package/vue/build/IntlTelInput.mjs +514 -390
  31. package/vue/build/IntlTelInputWithUtils.mjs +923 -799
@@ -1,5 +1,5 @@
1
- import { mergeModels as P, useModel as B, ref as L, onMounted as F, watch as R, onUnmounted as z, withDirectives as V, createElementBlock as $, openBlock as U, mergeProps as j, vModelText as W } from "vue";
2
- const O = [
1
+ import { mergeModels as U, useModel as K, ref as T, onMounted as Y, watch as q, onUnmounted as X, withDirectives as Q, createElementBlock as J, openBlock as Z, mergeProps as tt, vModelText as et } from "vue";
2
+ const it = [
3
3
  [
4
4
  "af",
5
5
  // Afghanistan
@@ -1676,9 +1676,9 @@ const O = [
1676
1676
  null,
1677
1677
  "0"
1678
1678
  ]
1679
- ], w = [];
1680
- for (const l of O)
1681
- w.push({
1679
+ ], L = [];
1680
+ for (const l of it)
1681
+ L.push({
1682
1682
  name: "",
1683
1683
  // populated in the plugin
1684
1684
  iso2: l[0],
@@ -1687,9 +1687,15 @@ for (const l of O)
1687
1687
  areaCodes: l[3] || null,
1688
1688
  nodeById: {},
1689
1689
  // populated by the plugin
1690
- nationalPrefix: l[4] || null
1690
+ nationalPrefix: l[4] || null,
1691
+ normalisedName: "",
1692
+ // populated in the plugin
1693
+ initials: "",
1694
+ // populated in the plugin
1695
+ dialCodePlus: ""
1696
+ // populated in the plugin
1691
1697
  });
1692
- const x = {
1698
+ const st = {
1693
1699
  ad: "Andorra",
1694
1700
  ae: "United Arab Emirates",
1695
1701
  af: "Afghanistan",
@@ -1932,7 +1938,7 @@ const x = {
1932
1938
  za: "South Africa",
1933
1939
  zm: "Zambia",
1934
1940
  zw: "Zimbabwe"
1935
- }, H = {
1941
+ }, nt = {
1936
1942
  selectedCountryAriaLabel: "Change country, selected ${countryName} (${dialCode})",
1937
1943
  noCountrySelected: "Select country",
1938
1944
  countryListAriaLabel: "List of countries",
@@ -1944,19 +1950,95 @@ const x = {
1944
1950
  // additional countries (not supported by country-list library)
1945
1951
  ac: "Ascension Island",
1946
1952
  xk: "Kosovo"
1947
- }, K = { ...x, ...H }, N = (l) => typeof window < "u" && typeof window.matchMedia == "function" && window.matchMedia(l).matches, G = () => {
1953
+ }, V = { ...st, ...nt }, A = {
1954
+ OPEN_COUNTRY_DROPDOWN: "open:countrydropdown",
1955
+ CLOSE_COUNTRY_DROPDOWN: "close:countrydropdown",
1956
+ COUNTRY_CHANGE: "countrychange",
1957
+ INPUT: "input"
1958
+ // used for synthetic input trigger
1959
+ }, h = {
1960
+ HIDE: "iti__hide",
1961
+ V_HIDE: "iti__v-hide",
1962
+ ARROW_UP: "iti__arrow--up",
1963
+ GLOBE: "iti__globe",
1964
+ FLAG: "iti__flag",
1965
+ COUNTRY_ITEM: "iti__country",
1966
+ HIGHLIGHT: "iti__highlight"
1967
+ }, g = {
1968
+ ARROW_UP: "ArrowUp",
1969
+ ARROW_DOWN: "ArrowDown",
1970
+ SPACE: " ",
1971
+ ENTER: "Enter",
1972
+ ESC: "Escape",
1973
+ TAB: "Tab"
1974
+ }, B = {
1975
+ PASTE: "insertFromPaste",
1976
+ DELETE_FWD: "deleteContentForward"
1977
+ }, D = {
1978
+ ALPHA_UNICODE: new RegExp("\\p{L}", "u"),
1979
+ // any kind of letter from any language
1980
+ NON_PLUS_NUMERIC: /[^+0-9]/,
1981
+ // chars that are NOT + or digit
1982
+ NON_PLUS_NUMERIC_GLOBAL: /[^+0-9]/g,
1983
+ // chars that are NOT + or digit (global)
1984
+ HIDDEN_SEARCH_CHAR: /^[a-zA-ZÀ-ÿа-яА-Я ]$/
1985
+ // single acceptable hidden-search char
1986
+ }, ot = {
1987
+ HIDDEN_SEARCH_RESET_MS: 1e3
1988
+ }, H = {
1989
+ UNKNOWN_NUMBER_TYPE: -99,
1990
+ UNKNOWN_VALIDATION_ERROR: -99
1991
+ }, S = {
1992
+ SANE_SELECTED_WITH_DIAL_WIDTH: 78,
1993
+ // px width fallback when separateDialCode enabled
1994
+ SANE_SELECTED_NO_DIAL_WIDTH: 42,
1995
+ // px width fallback when no separate dial code
1996
+ INPUT_PADDING_EXTRA_LEFT: 6
1997
+ // px gap between selected country container and input text
1998
+ }, $ = {
1999
+ NANP: "1"
2000
+ // North American Numbering Plan
2001
+ }, P = {
2002
+ DIAL_CODE: "44",
2003
+ // +44 United Kingdom
2004
+ MOBILE_PREFIX: "7",
2005
+ // UK mobile numbers start with 7 after national trunk (0) or core section
2006
+ MOBILE_CORE_LENGTH: 10
2007
+ // core number length (excluding dial code / national prefix) for mobiles
2008
+ }, lt = {
2009
+ ISO2: "us"
2010
+ }, rt = {
2011
+ POLITE: "polite"
2012
+ }, O = {
2013
+ AUTO: "auto"
2014
+ }, W = {
2015
+ COUNTRY_CODE: "countryCode",
2016
+ DIAL_CODE: "dialCode"
2017
+ }, C = {
2018
+ EXPANDED: "aria-expanded",
2019
+ LABEL: "aria-label",
2020
+ SELECTED: "aria-selected",
2021
+ ACTIVE_DESCENDANT: "aria-activedescendant",
2022
+ HASPOPUP: "aria-haspopup",
2023
+ CONTROLS: "aria-controls",
2024
+ HIDDEN: "aria-hidden",
2025
+ AUTOCOMPLETE: "aria-autocomplete",
2026
+ MODAL: "aria-modal"
2027
+ }, R = (l) => typeof window < "u" && typeof window.matchMedia == "function" && window.matchMedia(l).matches, at = () => {
1948
2028
  if (typeof navigator < "u" && typeof window < "u") {
1949
- const l = /Android.+Mobile|webOS|iPhone|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent), t = N("(max-width: 500px)"), e = N("(max-height: 600px)"), i = N("(pointer: coarse)");
2029
+ const l = /Android.+Mobile|webOS|iPhone|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
2030
+ navigator.userAgent
2031
+ ), t = R("(max-width: 500px)"), e = R("(max-height: 600px)"), i = R("(pointer: coarse)");
1950
2032
  return l || t || i && e;
1951
2033
  }
1952
2034
  return !1;
1953
- }, T = {
2035
+ }, G = {
1954
2036
  // Allow alphanumeric "phonewords" (e.g. +1 800 FLOWERS) as valid numbers
1955
2037
  allowPhonewords: !1,
1956
2038
  //* Whether or not to allow the dropdown.
1957
2039
  allowDropdown: !0,
1958
2040
  //* Add a placeholder in the input with an example number for the selected country.
1959
- autoPlaceholder: "polite",
2041
+ autoPlaceholder: rt.POLITE,
1960
2042
  //* Modify the parentClass.
1961
2043
  containerClass: "",
1962
2044
  //* The order of the countries in the dropdown. Defaults to alphabetical.
@@ -1998,18 +2080,51 @@ const x = {
1998
2080
  //* Only allow certain chars e.g. a plus followed by numeric digits, and cap at max valid length.
1999
2081
  strictMode: !1,
2000
2082
  //* Use full screen popup instead of dropdown for country list.
2001
- useFullscreenPopup: G(),
2083
+ useFullscreenPopup: at(),
2002
2084
  //* The number type to enforce during validation.
2003
2085
  validationNumberTypes: ["MOBILE"]
2004
- };
2005
- function q(l) {
2006
- l.useFullscreenPopup && (l.fixDropdownWidth = !1), l.onlyCountries.length === 1 && (l.initialCountry = l.onlyCountries[0]), l.separateDialCode && (l.nationalMode = !1), l.allowDropdown && !l.showFlags && !l.separateDialCode && (l.nationalMode = !1), l.useFullscreenPopup && !l.dropdownContainer && (l.dropdownContainer = document.body), l.i18n = { ...K, ...l.i18n };
2007
- }
2008
- const v = (l) => l.replace(/\D/g, ""), M = (l = "") => l.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase(), D = (l) => Object.keys(l).filter((t) => !!l[t]).join(" "), p = (l, t, e) => {
2086
+ }, ut = (l, t) => {
2087
+ l.useFullscreenPopup && (l.fixDropdownWidth = !1), l.onlyCountries.length === 1 && (l.initialCountry = l.onlyCountries[0]), l.separateDialCode && (l.nationalMode = !1), l.allowDropdown && !l.showFlags && !l.separateDialCode && (l.nationalMode = !1), l.useFullscreenPopup && !l.dropdownContainer && (l.dropdownContainer = document.body), l.i18n = { ...t, ...l.i18n };
2088
+ }, v = (l) => l.replace(/\D/g, ""), z = (l = "") => l.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase(), dt = (l, t) => {
2089
+ const e = z(t), i = [], s = [], o = [], n = [], r = [], a = [];
2090
+ for (const c of l)
2091
+ c.iso2 === e ? i.push(c) : c.normalisedName.startsWith(e) ? s.push(c) : c.normalisedName.includes(e) ? o.push(c) : e === c.dialCode || e === c.dialCodePlus ? n.push(c) : c.dialCodePlus.includes(e) ? r.push(c) : c.initials.includes(e) && a.push(c);
2092
+ const d = (c, f) => c.priority - f.priority;
2093
+ return [
2094
+ ...i.sort(d),
2095
+ ...s.sort(d),
2096
+ ...o.sort(d),
2097
+ ...n.sort(d),
2098
+ ...r.sort(d),
2099
+ ...a.sort(d)
2100
+ ];
2101
+ }, ct = (l, t) => {
2102
+ const e = t.toLowerCase();
2103
+ for (const i of l)
2104
+ if (i.name.toLowerCase().startsWith(e))
2105
+ return i;
2106
+ return null;
2107
+ }, k = (l) => Object.keys(l).filter((t) => !!l[t]).join(" "), m = (l, t, e) => {
2009
2108
  const i = document.createElement(l);
2010
- return t && Object.entries(t).forEach(([s, o]) => i.setAttribute(s, o)), e && e.appendChild(i), i;
2109
+ return t && Object.entries(t).forEach(
2110
+ ([s, o]) => i.setAttribute(s, o)
2111
+ ), e && e.appendChild(i), i;
2112
+ }, ht = () => `
2113
+ <svg class="iti__search-icon-svg" width="14" height="14" viewBox="0 0 24 24" focusable="false" ${C.HIDDEN}="true">
2114
+ <circle cx="11" cy="11" r="7" />
2115
+ <line x1="21" y1="21" x2="16.65" y2="16.65" />
2116
+ </svg>`, pt = (l) => {
2117
+ const t = `iti-${l}-clear-mask`;
2118
+ return `
2119
+ <svg class="iti__search-clear-svg" width="12" height="12" viewBox="0 0 16 16" ${C.HIDDEN}="true" focusable="false">
2120
+ <mask id="${t}" maskUnits="userSpaceOnUse">
2121
+ <rect width="16" height="16" fill="white" />
2122
+ <path d="M5.2 5.2 L10.8 10.8 M10.8 5.2 L5.2 10.8" stroke="black" stroke-linecap="round" class="iti__search-clear-x" />
2123
+ </mask>
2124
+ <circle cx="8" cy="8" r="8" class="iti__search-clear-bg" mask="url(#${t})" />
2125
+ </svg>`;
2011
2126
  };
2012
- class Q {
2127
+ class Ct {
2013
2128
  constructor(t, e, i) {
2014
2129
  this.highlightedItem = null, t.dataset.intlTelInputId = i.toString(), this.telInput = t, this.options = e, this.id = i, this.hadInitialPlaceholder = !!t.getAttribute("placeholder"), this.isRTL = !!this.telInput.closest("[dir=rtl]"), this.options.separateDialCode && (this.originalPaddingLeft = this.telInput.style.paddingLeft);
2015
2130
  }
@@ -2024,58 +2139,53 @@ class Q {
2024
2139
  this.telInput.classList.add("iti__tel-input"), !this.telInput.hasAttribute("autocomplete") && !((t = this.telInput.form) != null && t.hasAttribute("autocomplete")) && this.telInput.setAttribute("autocomplete", "off");
2025
2140
  }
2026
2141
  _createWrapperAndInsert() {
2027
- const {
2028
- allowDropdown: t,
2029
- showFlags: e,
2030
- containerClass: i,
2031
- useFullscreenPopup: s
2032
- } = this.options, o = D({
2142
+ const { allowDropdown: t, showFlags: e, containerClass: i, useFullscreenPopup: s } = this.options, o = k({
2033
2143
  iti: !0,
2034
2144
  "iti--allow-dropdown": t,
2035
2145
  "iti--show-flags": e,
2036
2146
  "iti--inline-dropdown": !s,
2037
2147
  [i]: !!i
2038
- }), n = p("div", { class: o });
2148
+ }), n = m("div", { class: o });
2039
2149
  return this.isRTL && n.setAttribute("dir", "ltr"), this.telInput.before(n), n;
2040
2150
  }
2041
2151
  _maybeBuildCountryContainer(t) {
2042
2152
  const { allowDropdown: e, separateDialCode: i, showFlags: s } = this.options;
2043
2153
  if (e || s || i) {
2044
- this.countryContainer = p(
2154
+ this.countryContainer = m(
2045
2155
  "div",
2046
2156
  // visibly hidden until we measure it's width to set the input padding correctly
2047
- { class: "iti__country-container iti__v-hide" },
2157
+ { class: `iti__country-container ${h.V_HIDE}` },
2048
2158
  t
2049
- ), e ? (this.selectedCountry = p(
2159
+ ), e ? (this.selectedCountry = m(
2050
2160
  "button",
2051
2161
  {
2052
2162
  type: "button",
2053
2163
  class: "iti__selected-country",
2054
- "aria-expanded": "false",
2055
- "aria-label": this.options.i18n.noCountrySelected,
2056
- "aria-haspopup": "dialog",
2057
- "aria-controls": `iti-${this.id}__dropdown-content`
2164
+ [C.EXPANDED]: "false",
2165
+ [C.LABEL]: this.options.i18n.noCountrySelected,
2166
+ [C.HASPOPUP]: "dialog",
2167
+ [C.CONTROLS]: `iti-${this.id}__dropdown-content`
2058
2168
  },
2059
2169
  this.countryContainer
2060
- ), this.telInput.disabled && this.selectedCountry.setAttribute("disabled", "true")) : this.selectedCountry = p(
2170
+ ), this.telInput.disabled && this.selectedCountry.setAttribute("disabled", "true")) : this.selectedCountry = m(
2061
2171
  "div",
2062
2172
  { class: "iti__selected-country" },
2063
2173
  this.countryContainer
2064
2174
  );
2065
- const o = p(
2175
+ const o = m(
2066
2176
  "div",
2067
2177
  { class: "iti__selected-country-primary" },
2068
2178
  this.selectedCountry
2069
2179
  );
2070
- this.selectedCountryInner = p(
2180
+ this.selectedCountryInner = m(
2071
2181
  "div",
2072
- { class: "iti__flag" },
2182
+ { class: h.FLAG },
2073
2183
  o
2074
- ), e && (this.dropdownArrow = p(
2184
+ ), e && (this.dropdownArrow = m(
2075
2185
  "div",
2076
- { class: "iti__arrow", "aria-hidden": "true" },
2186
+ { class: "iti__arrow", [C.HIDDEN]: "true" },
2077
2187
  o
2078
- )), i && (this.selectedDialCode = p(
2188
+ )), i && (this.selectedDialCode = m(
2079
2189
  "div",
2080
2190
  { class: "iti__selected-dial-code" },
2081
2191
  this.selectedCountry
@@ -2090,51 +2200,47 @@ class Q {
2090
2200
  i18n: s,
2091
2201
  dropdownContainer: o,
2092
2202
  containerClass: n
2093
- } = this.options, a = t ? "" : "iti--flexible-dropdown-width";
2094
- if (this.dropdownContent = p("div", {
2203
+ } = this.options, r = t ? "" : "iti--flexible-dropdown-width";
2204
+ if (this.dropdownContent = m("div", {
2095
2205
  id: `iti-${this.id}__dropdown-content`,
2096
- class: `iti__dropdown-content iti__hide ${a}`,
2206
+ class: `iti__dropdown-content ${h.HIDE} ${r}`,
2097
2207
  role: "dialog",
2098
- "aria-modal": "true"
2099
- }), this.isRTL && this.dropdownContent.setAttribute("dir", "rtl"), i && this._buildSearchUI(), this.countryList = p(
2208
+ [C.MODAL]: "true"
2209
+ }), this.isRTL && this.dropdownContent.setAttribute("dir", "rtl"), i && this._buildSearchUI(), this.countryList = m(
2100
2210
  "ul",
2101
2211
  {
2102
2212
  class: "iti__country-list",
2103
2213
  id: `iti-${this.id}__country-listbox`,
2104
2214
  role: "listbox",
2105
- "aria-label": s.countryListAriaLabel
2215
+ [C.LABEL]: s.countryListAriaLabel
2106
2216
  },
2107
2217
  this.dropdownContent
2108
- ), this._appendListItems(), this.options.countrySearch && this.updateSearchResultsA11yText(), o) {
2109
- const r = D({
2218
+ ), this._appendListItems(), i && this.updateSearchResultsA11yText(), o) {
2219
+ const a = k({
2110
2220
  iti: !0,
2111
2221
  "iti--container": !0,
2112
2222
  "iti--fullscreen-popup": e,
2113
2223
  "iti--inline-dropdown": !e,
2114
2224
  [n]: !!n
2115
2225
  });
2116
- this.dropdown = p("div", { class: r }), this.dropdown.appendChild(this.dropdownContent);
2226
+ this.dropdown = m("div", { class: a }), this.dropdown.appendChild(this.dropdownContent);
2117
2227
  } else
2118
2228
  this.countryContainer.appendChild(this.dropdownContent);
2119
2229
  }
2120
2230
  _buildSearchUI() {
2121
- const { i18n: t } = this.options, e = p(
2231
+ const { i18n: t } = this.options, e = m(
2122
2232
  "div",
2123
2233
  { class: "iti__search-input-wrapper" },
2124
2234
  this.dropdownContent
2125
2235
  );
2126
- this.searchIcon = p(
2236
+ this.searchIcon = m(
2127
2237
  "span",
2128
2238
  {
2129
2239
  class: "iti__search-icon",
2130
- "aria-hidden": "true"
2240
+ [C.HIDDEN]: "true"
2131
2241
  },
2132
2242
  e
2133
- ), this.searchIcon.innerHTML = `
2134
- <svg class="iti__search-icon-svg" width="14" height="14" viewBox="0 0 24 24" focusable="false" aria-hidden="true">
2135
- <circle cx="11" cy="11" r="7" />
2136
- <line x1="21" y1="21" x2="16.65" y2="16.65" />
2137
- </svg>`, this.searchInput = p(
2243
+ ), this.searchIcon.innerHTML = ht(), this.searchInput = m(
2138
2244
  "input",
2139
2245
  {
2140
2246
  id: `iti-${this.id}__search-input`,
@@ -2144,47 +2250,38 @@ class Q {
2144
2250
  placeholder: t.searchPlaceholder,
2145
2251
  // role=combobox + aria-autocomplete=list + aria-activedescendant allows maintaining focus on the search input while allowing users to navigate search results with up/down keyboard keys
2146
2252
  role: "combobox",
2147
- "aria-expanded": "true",
2148
- "aria-label": t.searchPlaceholder,
2149
- "aria-controls": `iti-${this.id}__country-listbox`,
2150
- "aria-autocomplete": "list",
2253
+ [C.EXPANDED]: "true",
2254
+ [C.LABEL]: t.searchPlaceholder,
2255
+ [C.CONTROLS]: `iti-${this.id}__country-listbox`,
2256
+ [C.AUTOCOMPLETE]: "list",
2151
2257
  autocomplete: "off"
2152
2258
  },
2153
2259
  e
2154
- ), this.searchClearButton = p(
2260
+ ), this.searchClearButton = m(
2155
2261
  "button",
2156
2262
  {
2157
2263
  type: "button",
2158
- class: "iti__search-clear iti__hide",
2159
- "aria-label": t.clearSearchAriaLabel,
2264
+ class: `iti__search-clear ${h.HIDE}`,
2265
+ [C.LABEL]: t.clearSearchAriaLabel,
2160
2266
  tabindex: "-1"
2161
2267
  },
2162
2268
  e
2163
- );
2164
- const i = `iti-${this.id}-clear-mask`;
2165
- this.searchClearButton.innerHTML = `
2166
- <svg class="iti__search-clear-svg" width="12" height="12" viewBox="0 0 16 16" aria-hidden="true" focusable="false">
2167
- <mask id="${i}" maskUnits="userSpaceOnUse">
2168
- <rect width="16" height="16" fill="white" />
2169
- <path d="M5.2 5.2 L10.8 10.8 M10.8 5.2 L5.2 10.8" stroke="black" stroke-linecap="round" class="iti__search-clear-x" />
2170
- </mask>
2171
- <circle cx="8" cy="8" r="8" class="iti__search-clear-bg" mask="url(#${i})" />
2172
- </svg>`, this.searchResultsA11yText = p(
2269
+ ), this.searchClearButton.innerHTML = pt(this.id), this.searchResultsA11yText = m(
2173
2270
  "span",
2174
2271
  { class: "iti__a11y-text" },
2175
2272
  this.dropdownContent
2176
- ), this.searchNoResults = p(
2273
+ ), this.searchNoResults = m(
2177
2274
  "div",
2178
2275
  {
2179
- class: "iti__no-results iti__hide",
2180
- "aria-hidden": "true"
2276
+ class: `iti__no-results ${h.HIDE}`,
2277
+ [C.HIDDEN]: "true"
2181
2278
  // all a11y messaging happens in this.searchResultsA11yText
2182
2279
  },
2183
2280
  this.dropdownContent
2184
2281
  ), this.searchNoResults.textContent = t.zeroSearchResults;
2185
2282
  }
2186
2283
  _maybeUpdateInputPaddingAndReveal() {
2187
- this.countryContainer && (this.updateInputPadding(), this.countryContainer.classList.remove("iti__v-hide"));
2284
+ this.countryContainer && (this.updateInputPadding(), this.countryContainer.classList.remove(h.V_HIDE));
2188
2285
  }
2189
2286
  _maybeBuildHiddenInputs(t) {
2190
2287
  var i, s;
@@ -2192,19 +2289,19 @@ class Q {
2192
2289
  if (e) {
2193
2290
  const o = this.telInput.getAttribute("name") || "", n = e(o);
2194
2291
  if (n.phone) {
2195
- const a = (i = this.telInput.form) == null ? void 0 : i.querySelector(
2292
+ const r = (i = this.telInput.form) == null ? void 0 : i.querySelector(
2196
2293
  `input[name="${n.phone}"]`
2197
2294
  );
2198
- a ? this.hiddenInput = a : (this.hiddenInput = p("input", {
2295
+ r ? this.hiddenInput = r : (this.hiddenInput = m("input", {
2199
2296
  type: "hidden",
2200
2297
  name: n.phone
2201
2298
  }), t.appendChild(this.hiddenInput));
2202
2299
  }
2203
2300
  if (n.country) {
2204
- const a = (s = this.telInput.form) == null ? void 0 : s.querySelector(
2301
+ const r = (s = this.telInput.form) == null ? void 0 : s.querySelector(
2205
2302
  `input[name="${n.country}"]`
2206
2303
  );
2207
- a ? this.hiddenInputCountry = a : (this.hiddenInputCountry = p("input", {
2304
+ r ? this.hiddenInputCountry = r : (this.hiddenInputCountry = m("input", {
2208
2305
  type: "hidden",
2209
2306
  name: n.country
2210
2307
  }), t.appendChild(this.hiddenInputCountry));
@@ -2215,28 +2312,28 @@ class Q {
2215
2312
  _appendListItems() {
2216
2313
  const t = document.createDocumentFragment();
2217
2314
  for (let e = 0; e < this.countries.length; e++) {
2218
- const i = this.countries[e], s = D({
2219
- iti__country: !0,
2220
- iti__highlight: e === 0
2221
- }), o = p("li", {
2315
+ const i = this.countries[e], s = k({
2316
+ [h.COUNTRY_ITEM]: !0,
2317
+ [h.HIGHLIGHT]: e === 0
2318
+ }), o = m("li", {
2222
2319
  id: `iti-${this.id}__item-${i.iso2}`,
2223
2320
  class: s,
2224
2321
  tabindex: "-1",
2225
2322
  role: "option",
2226
- "aria-selected": "false"
2323
+ [C.SELECTED]: "false"
2227
2324
  });
2228
- o.dataset.dialCode = i.dialCode, o.dataset.countryCode = i.iso2, i.nodeById[this.id] = o, this.options.showFlags && p("div", { class: `iti__flag iti__${i.iso2}` }, o);
2229
- const n = p("span", { class: "iti__country-name" }, o);
2325
+ o.dataset.dialCode = i.dialCode, o.dataset.countryCode = i.iso2, i.nodeById[this.id] = o, this.options.showFlags && m("div", { class: `${h.FLAG} iti__${i.iso2}` }, o);
2326
+ const n = m("span", { class: "iti__country-name" }, o);
2230
2327
  n.textContent = i.name;
2231
- const a = p("span", { class: "iti__dial-code" }, o);
2232
- this.isRTL && a.setAttribute("dir", "ltr"), a.textContent = `+${i.dialCode}`, t.appendChild(o);
2328
+ const r = m("span", { class: "iti__dial-code" }, o);
2329
+ this.isRTL && r.setAttribute("dir", "ltr"), r.textContent = `+${i.dialCode}`, t.appendChild(o);
2233
2330
  }
2234
2331
  this.countryList.appendChild(t);
2235
2332
  }
2236
2333
  //* Update the input padding to make space for the selected country/dial code.
2237
2334
  updateInputPadding() {
2238
2335
  if (this.selectedCountry) {
2239
- const t = this.options.separateDialCode ? 78 : 42, i = (this.selectedCountry.offsetWidth || this._getHiddenSelectedCountryWidth() || t) + 6;
2336
+ const t = this.options.separateDialCode ? S.SANE_SELECTED_WITH_DIAL_WIDTH : S.SANE_SELECTED_NO_DIAL_WIDTH, i = (this.selectedCountry.offsetWidth || this._getHiddenSelectedCountryWidth() || t) + S.INPUT_PADDING_EXTRA_LEFT;
2240
2337
  this.telInput.style.paddingLeft = `${i}px`;
2241
2338
  }
2242
2339
  }
@@ -2278,23 +2375,20 @@ class Q {
2278
2375
  }
2279
2376
  //* Check if an element is visible within it's container, else scroll until it is.
2280
2377
  scrollTo(t) {
2281
- const e = this.countryList, i = document.documentElement.scrollTop, s = e.offsetHeight, o = e.getBoundingClientRect().top + i, n = o + s, a = t.offsetHeight, r = t.getBoundingClientRect().top + i, u = r + a, c = r - o + e.scrollTop;
2282
- if (r < o)
2378
+ const e = this.countryList, i = document.documentElement.scrollTop, s = e.offsetHeight, o = e.getBoundingClientRect().top + i, n = o + s, r = t.offsetHeight, a = t.getBoundingClientRect().top + i, d = a + r, c = a - o + e.scrollTop;
2379
+ if (a < o)
2283
2380
  e.scrollTop = c;
2284
- else if (u > n) {
2285
- const C = s - a;
2286
- e.scrollTop = c - C;
2381
+ else if (d > n) {
2382
+ const f = s - r;
2383
+ e.scrollTop = c - f;
2287
2384
  }
2288
2385
  }
2289
2386
  //* Remove highlighting from other list items and highlight the given item.
2290
2387
  highlightListItem(t, e) {
2291
2388
  const i = this.highlightedItem;
2292
- if (i && (i.classList.remove("iti__highlight"), i.setAttribute("aria-selected", "false")), this.highlightedItem = t, this.highlightedItem && (this.highlightedItem.classList.add("iti__highlight"), this.highlightedItem.setAttribute("aria-selected", "true"), this.options.countrySearch)) {
2389
+ if (i && (i.classList.remove(h.HIGHLIGHT), i.setAttribute(C.SELECTED, "false")), this.highlightedItem = t, this.highlightedItem && (this.highlightedItem.classList.add(h.HIGHLIGHT), this.highlightedItem.setAttribute(C.SELECTED, "true"), this.options.countrySearch)) {
2293
2390
  const s = this.highlightedItem.getAttribute("id") || "";
2294
- this.searchInput.setAttribute(
2295
- "aria-activedescendant",
2296
- s
2297
- );
2391
+ this.searchInput.setAttribute(C.ACTIVE_DESCENDANT, s);
2298
2392
  }
2299
2393
  e && this.highlightedItem.focus();
2300
2394
  }
@@ -2306,7 +2400,7 @@ class Q {
2306
2400
  const s = i.nodeById[this.id];
2307
2401
  s && (this.countryList.appendChild(s), e && (this.highlightListItem(s, !1), e = !1));
2308
2402
  }
2309
- e ? (this.highlightListItem(null, !1), this.searchNoResults && this.searchNoResults.classList.remove("iti__hide")) : this.searchNoResults && this.searchNoResults.classList.add("iti__hide"), this.countryList.scrollTop = 0, this.updateSearchResultsA11yText();
2403
+ e ? (this.highlightListItem(null, !1), this.searchNoResults && this.searchNoResults.classList.remove(h.HIDE)) : this.searchNoResults && this.searchNoResults.classList.add(h.HIDE), this.countryList.scrollTop = 0, this.updateSearchResultsA11yText();
2310
2404
  }
2311
2405
  destroy() {
2312
2406
  this.telInput.iti = void 0, delete this.telInput.dataset.intlTelInputId, this.options.separateDialCode && (this.telInput.style.paddingLeft = this.originalPaddingLeft);
@@ -2317,41 +2411,47 @@ class Q {
2317
2411
  this.countries = null;
2318
2412
  }
2319
2413
  }
2320
- function Y(l) {
2414
+ const mt = (l) => {
2321
2415
  const { onlyCountries: t, excludeCountries: e } = l;
2322
2416
  if (t.length) {
2323
- const i = t.map((s) => s.toLowerCase());
2324
- return w.filter((s) => i.includes(s.iso2));
2417
+ const i = t.map(
2418
+ (s) => s.toLowerCase()
2419
+ );
2420
+ return L.filter(
2421
+ (s) => i.includes(s.iso2)
2422
+ );
2325
2423
  } else if (e.length) {
2326
- const i = e.map((s) => s.toLowerCase());
2327
- return w.filter((s) => !i.includes(s.iso2));
2424
+ const i = e.map(
2425
+ (s) => s.toLowerCase()
2426
+ );
2427
+ return L.filter(
2428
+ (s) => !i.includes(s.iso2)
2429
+ );
2328
2430
  }
2329
- return w;
2330
- }
2331
- function J(l, t) {
2431
+ return L;
2432
+ }, ft = (l, t) => {
2332
2433
  for (const e of l) {
2333
2434
  const i = e.iso2.toLowerCase();
2334
2435
  t.i18n[i] && (e.name = t.i18n[i]);
2335
2436
  }
2336
- }
2337
- function Z(l, t) {
2437
+ }, yt = (l, t) => {
2338
2438
  const e = /* @__PURE__ */ new Set();
2339
2439
  let i = 0;
2340
- const s = {}, o = (n, a, r) => {
2341
- if (!n || !a)
2440
+ const s = {}, o = (n, r, a) => {
2441
+ if (!n || !r)
2342
2442
  return;
2343
- a.length > i && (i = a.length), s.hasOwnProperty(a) || (s[a] = []);
2344
- const u = s[a];
2345
- if (u.includes(n))
2443
+ r.length > i && (i = r.length), s.hasOwnProperty(r) || (s[r] = []);
2444
+ const d = s[r];
2445
+ if (d.includes(n))
2346
2446
  return;
2347
- const c = r !== void 0 ? r : u.length;
2348
- u[c] = n;
2447
+ const c = a !== void 0 ? a : d.length;
2448
+ d[c] = n;
2349
2449
  };
2350
2450
  for (const n of l) {
2351
2451
  e.has(n.dialCode) || e.add(n.dialCode);
2352
- for (let a = 1; a < n.dialCode.length; a++) {
2353
- const r = n.dialCode.substring(0, a);
2354
- o(n.iso2, r);
2452
+ for (let r = 1; r < n.dialCode.length; r++) {
2453
+ const a = n.dialCode.substring(0, r);
2454
+ o(n.iso2, a);
2355
2455
  }
2356
2456
  o(n.iso2, n.dialCode, n.priority);
2357
2457
  }
@@ -2360,33 +2460,32 @@ function Z(l, t) {
2360
2460
  });
2361
2461
  for (const n of l)
2362
2462
  if (n.areaCodes) {
2363
- const a = s[n.dialCode][0];
2364
- for (const r of n.areaCodes) {
2365
- for (let u = 1; u < r.length; u++) {
2366
- const c = r.substring(0, u), C = n.dialCode + c;
2367
- o(a, C), o(n.iso2, C);
2463
+ const r = s[n.dialCode][0];
2464
+ for (const a of n.areaCodes) {
2465
+ for (let d = 1; d < a.length; d++) {
2466
+ const c = a.substring(0, d), f = n.dialCode + c;
2467
+ o(r, f), o(n.iso2, f);
2368
2468
  }
2369
- o(n.iso2, n.dialCode + r);
2469
+ o(n.iso2, n.dialCode + a);
2370
2470
  }
2371
2471
  }
2372
2472
  return { dialCodes: e, dialCodeMaxLen: i, dialCodeToIso2Map: s };
2373
- }
2374
- function X(l, t) {
2375
- t.countryOrder && (t.countryOrder = t.countryOrder.map((e) => e.toLowerCase())), l.sort((e, i) => {
2473
+ }, gt = (l, t) => {
2474
+ t.countryOrder && (t.countryOrder = t.countryOrder.map(
2475
+ (e) => e.toLowerCase()
2476
+ )), l.sort((e, i) => {
2376
2477
  const { countryOrder: s } = t;
2377
2478
  if (s) {
2378
- const o = s.indexOf(e.iso2), n = s.indexOf(i.iso2), a = o > -1, r = n > -1;
2379
- if (a || r)
2380
- return a && r ? o - n : a ? -1 : 1;
2479
+ const o = s.indexOf(e.iso2), n = s.indexOf(i.iso2), r = o > -1, a = n > -1;
2480
+ if (r || a)
2481
+ return r && a ? o - n : r ? -1 : 1;
2381
2482
  }
2382
2483
  return e.name.localeCompare(i.name);
2383
2484
  });
2384
- }
2385
- function tt(l) {
2485
+ }, bt = (l) => {
2386
2486
  for (const t of l)
2387
- t.normalisedName = M(t.name), t.initials = t.name.split(/[^a-zA-ZÀ-ÿа-яА-Я]/).map((e) => e[0]).join("").toLowerCase(), t.dialCodePlus = `+${t.dialCode}`;
2388
- }
2389
- function et(l, t, e, i) {
2487
+ t.normalisedName = z(t.name), t.initials = t.normalisedName.split(/[^a-z]/).map((e) => e[0]).join(""), t.dialCodePlus = `+${t.dialCode}`;
2488
+ }, It = (l, t, e, i) => {
2390
2489
  let s = l;
2391
2490
  if (e && t) {
2392
2491
  t = `+${i.dialCode}`;
@@ -2394,12 +2493,10 @@ function et(l, t, e, i) {
2394
2493
  s = s.substring(o);
2395
2494
  }
2396
2495
  return s;
2397
- }
2398
- function it(l, t, e, i, s) {
2496
+ }, _t = (l, t, e, i, s) => {
2399
2497
  const o = e ? e.formatNumberAsYouType(l, i.iso2) : l, { dialCode: n } = i;
2400
2498
  return s && t.charAt(0) !== "+" && o.includes(`+${n}`) ? (o.split(`+${n}`)[1] || "").trim() : o;
2401
- }
2402
- function st(l, t, e, i) {
2499
+ }, wt = (l, t, e, i) => {
2403
2500
  if (e === 0 && !i)
2404
2501
  return 0;
2405
2502
  let s = 0;
@@ -2410,8 +2507,7 @@ function st(l, t, e, i) {
2410
2507
  return o;
2411
2508
  }
2412
2509
  return t.length;
2413
- }
2414
- const nt = [
2510
+ }, Nt = [
2415
2511
  "800",
2416
2512
  "822",
2417
2513
  "833",
@@ -2429,22 +2525,22 @@ const nt = [
2429
2525
  "887",
2430
2526
  "888",
2431
2527
  "889"
2432
- ], k = (l) => {
2528
+ ], F = (l) => {
2433
2529
  const t = v(l);
2434
- if (t.charAt(0) === "1") {
2530
+ if (t.startsWith($.NANP) && t.length >= 4) {
2435
2531
  const e = t.substring(1, 4);
2436
- return nt.includes(e);
2532
+ return Nt.includes(e);
2437
2533
  }
2438
2534
  return !1;
2439
2535
  };
2440
- for (const l of w)
2441
- l.name = x[l.iso2];
2442
- let ot = 0;
2443
- const rt = new Set(w.map((l) => l.iso2)), A = (l) => rt.has(l);
2444
- class S {
2536
+ for (const l of L)
2537
+ l.name = V[l.iso2];
2538
+ let Dt = 0;
2539
+ const Lt = new Set(L.map((l) => l.iso2)), M = (l) => Lt.has(l);
2540
+ class x {
2445
2541
  constructor(t, e = {}) {
2446
- this.id = ot++, this.options = { ...T, ...e }, q(this.options), this.ui = new Q(t, this.options, this.id), this.isAndroid = S._getIsAndroid(), this.promise = this._createInitPromises(), this.countries = Y(this.options);
2447
- const { dialCodes: i, dialCodeMaxLen: s, dialCodeToIso2Map: o } = Z(
2542
+ this.id = Dt++, this.options = { ...G, ...e }, ut(this.options, V), this.ui = new Ct(t, this.options, this.id), this.isAndroid = x._getIsAndroid(), this.promise = this._createInitPromises(), this.countries = mt(this.options);
2543
+ const { dialCodes: i, dialCodeMaxLen: s, dialCodeToIso2Map: o } = yt(
2448
2544
  this.countries,
2449
2545
  this.options
2450
2546
  );
@@ -2470,18 +2566,18 @@ class S {
2470
2566
  //********************
2471
2567
  //* Prepare all of the country data, including onlyCountries, excludeCountries, countryOrder options.
2472
2568
  _processCountryData() {
2473
- J(this.countries, this.options), X(this.countries, this.options), tt(this.countries);
2569
+ ft(this.countries, this.options), gt(this.countries, this.options), bt(this.countries);
2474
2570
  }
2475
2571
  //* Set the initial state of the input value and the selected country by:
2476
2572
  //* 1. Extracting a dial code from the given number
2477
2573
  //* 2. Using explicit initialCountry
2478
2574
  _setInitialState(t = !1) {
2479
- const e = this.ui.telInput.getAttribute("value"), i = this.ui.telInput.value, o = e && e.startsWith("+") && (!i || !i.startsWith("+")) ? e : i, n = this._getDialCode(o), a = k(o), { initialCountry: r, geoIpLookup: u } = this.options, c = r === "auto" && u;
2480
- if (n && !a)
2575
+ const e = this.ui.telInput.getAttribute("value"), i = this.ui.telInput.value, o = e && e.startsWith("+") && (!i || !i.startsWith("+")) ? e : i, n = this._getDialCode(o), r = F(o), { initialCountry: a, geoIpLookup: d } = this.options, c = a === O.AUTO && d;
2576
+ if (n && !r)
2481
2577
  this._updateCountryFromNumber(o);
2482
2578
  else if (!c || t) {
2483
- const C = r ? r.toLowerCase() : "";
2484
- A(C) ? this._setCountry(C) : n && a ? this._setCountry("us") : this._setCountry("");
2579
+ const f = a ? a.toLowerCase() : "";
2580
+ M(f) ? this._setCountry(f) : n && r ? this._setCountry(lt.ISO2) : this._setCountry("");
2485
2581
  }
2486
2582
  o && this._updateValFromNumber(o);
2487
2583
  }
@@ -2502,17 +2598,25 @@ class S {
2502
2598
  //* initialise the dropdown listeners.
2503
2599
  _initDropdownListeners() {
2504
2600
  const t = this.abortController.signal, e = (n) => {
2505
- this.ui.dropdownContent.classList.contains("iti__hide") ? this.ui.telInput.focus() : n.preventDefault();
2601
+ this.ui.dropdownContent.classList.contains(h.HIDE) ? this.ui.telInput.focus() : n.preventDefault();
2506
2602
  }, i = this.ui.telInput.closest("label");
2507
2603
  i && i.addEventListener("click", e, { signal: t });
2508
2604
  const s = () => {
2509
- this.ui.dropdownContent.classList.contains("iti__hide") && !this.ui.telInput.disabled && !this.ui.telInput.readOnly && this._openDropdown();
2605
+ this.ui.dropdownContent.classList.contains(
2606
+ h.HIDE
2607
+ ) && !this.ui.telInput.disabled && !this.ui.telInput.readOnly && this._openDropdown();
2510
2608
  };
2511
- this.ui.selectedCountry.addEventListener("click", s, {
2512
- signal: t
2513
- });
2609
+ this.ui.selectedCountry.addEventListener(
2610
+ "click",
2611
+ s,
2612
+ {
2613
+ signal: t
2614
+ }
2615
+ );
2514
2616
  const o = (n) => {
2515
- this.ui.dropdownContent.classList.contains("iti__hide") && ["ArrowUp", "ArrowDown", " ", "Enter"].includes(n.key) && (n.preventDefault(), n.stopPropagation(), this._openDropdown()), n.key === "Tab" && this._closeDropdown();
2617
+ this.ui.dropdownContent.classList.contains(
2618
+ h.HIDE
2619
+ ) && [g.ARROW_UP, g.ARROW_DOWN, g.SPACE, g.ENTER].includes(n.key) && (n.preventDefault(), n.stopPropagation(), this._openDropdown()), n.key === g.TAB && this._closeDropdown();
2516
2620
  };
2517
2621
  this.ui.countryContainer.addEventListener(
2518
2622
  "keydown",
@@ -2523,13 +2627,13 @@ class S {
2523
2627
  //* Init many requests: utils script / geo ip lookup.
2524
2628
  _initRequests() {
2525
2629
  const { loadUtils: t, initialCountry: e, geoIpLookup: i } = this.options;
2526
- if (t && !d.utils) {
2630
+ if (t && !u.utils) {
2527
2631
  const o = () => {
2528
2632
  var n;
2529
- (n = d.attachUtils(t)) == null || n.catch(() => {
2633
+ (n = u.attachUtils(t)) == null || n.catch(() => {
2530
2634
  });
2531
2635
  };
2532
- if (d.documentReady())
2636
+ if (u.documentReady())
2533
2637
  o();
2534
2638
  else {
2535
2639
  const n = () => {
@@ -2541,17 +2645,17 @@ class S {
2541
2645
  }
2542
2646
  } else
2543
2647
  this.resolveUtilsScriptPromise();
2544
- e === "auto" && i && !this.selectedCountryData.iso2 ? this._loadAutoCountry() : this.resolveAutoCountryPromise();
2648
+ e === O.AUTO && i && !this.selectedCountryData.iso2 ? this._loadAutoCountry() : this.resolveAutoCountryPromise();
2545
2649
  }
2546
2650
  //* Perform the geo ip lookup.
2547
2651
  _loadAutoCountry() {
2548
- d.autoCountry ? this.handleAutoCountry() : d.startedLoadingAutoCountry || (d.startedLoadingAutoCountry = !0, typeof this.options.geoIpLookup == "function" && this.options.geoIpLookup(
2652
+ u.autoCountry ? this.handleAutoCountry() : u.startedLoadingAutoCountry || (u.startedLoadingAutoCountry = !0, typeof this.options.geoIpLookup == "function" && this.options.geoIpLookup(
2549
2653
  (t = "") => {
2550
2654
  const e = t.toLowerCase();
2551
- A(e) ? (d.autoCountry = e, setTimeout(() => I("handleAutoCountry"))) : (this._setInitialState(!0), I("rejectAutoCountryPromise"));
2655
+ M(e) ? (u.autoCountry = e, setTimeout(() => E("handleAutoCountry"))) : (this._setInitialState(!0), E("rejectAutoCountryPromise"));
2552
2656
  },
2553
2657
  () => {
2554
- this._setInitialState(!0), I("rejectAutoCountryPromise");
2658
+ this._setInitialState(!0), E("rejectAutoCountryPromise");
2555
2659
  }
2556
2660
  ));
2557
2661
  }
@@ -2571,45 +2675,49 @@ class S {
2571
2675
  countrySearch: o
2572
2676
  } = this.options;
2573
2677
  let n = !1;
2574
- new RegExp("\\p{L}", "u").test(this.ui.telInput.value) && (n = !0);
2575
- const a = (r) => {
2576
- if (this.isAndroid && (r == null ? void 0 : r.data) === "+" && i && s && o) {
2577
- const m = this.ui.telInput.selectionStart || 0, h = this.ui.telInput.value.substring(
2678
+ D.ALPHA_UNICODE.test(this.ui.telInput.value) && (n = !0);
2679
+ const r = (a) => {
2680
+ if (this.isAndroid && (a == null ? void 0 : a.data) === "+" && i && s && o) {
2681
+ const b = this.ui.telInput.selectionStart || 0, p = this.ui.telInput.value.substring(
2578
2682
  0,
2579
- m - 1
2580
- ), f = this.ui.telInput.value.substring(m);
2581
- this.ui.telInput.value = h + f, this._openDropdownWithPlus();
2683
+ b - 1
2684
+ ), y = this.ui.telInput.value.substring(b);
2685
+ this.ui.telInput.value = p + y, this._openDropdownWithPlus();
2582
2686
  return;
2583
2687
  }
2584
2688
  this._updateCountryFromNumber(this.ui.telInput.value) && this._triggerCountryChange();
2585
- const u = (r == null ? void 0 : r.data) && /[^+0-9]/.test(r.data), c = (r == null ? void 0 : r.inputType) === "insertFromPaste" && this.ui.telInput.value;
2586
- u || c && !t ? n = !0 : /[^+0-9]/.test(this.ui.telInput.value) || (n = !1);
2587
- const C = (r == null ? void 0 : r.detail) && r.detail.isSetNumber;
2588
- if (e && !n && !C) {
2589
- const m = this.ui.telInput.selectionStart || 0, f = this.ui.telInput.value.substring(
2689
+ const d = (a == null ? void 0 : a.data) && D.NON_PLUS_NUMERIC.test(a.data), c = (a == null ? void 0 : a.inputType) === B.PASTE && this.ui.telInput.value;
2690
+ d || c && !t ? n = !0 : D.NON_PLUS_NUMERIC.test(this.ui.telInput.value) || (n = !1);
2691
+ const f = (a == null ? void 0 : a.detail) && a.detail.isSetNumber;
2692
+ if (e && !n && !f) {
2693
+ const b = this.ui.telInput.selectionStart || 0, y = this.ui.telInput.value.substring(
2590
2694
  0,
2591
- m
2695
+ b
2592
2696
  ).replace(
2593
- /[^+0-9]/g,
2697
+ D.NON_PLUS_NUMERIC_GLOBAL,
2594
2698
  ""
2595
- ).length, b = (r == null ? void 0 : r.inputType) === "deleteContentForward", y = this._getFullNumber(), g = it(
2596
- y,
2699
+ ).length, w = (a == null ? void 0 : a.inputType) === B.DELETE_FWD, I = this._getFullNumber(), _ = _t(
2700
+ I,
2597
2701
  this.ui.telInput.value,
2598
- d.utils,
2702
+ u.utils,
2599
2703
  this.selectedCountryData,
2600
2704
  this.options.separateDialCode
2601
- ), _ = st(
2602
- f,
2603
- g,
2604
- m,
2605
- b
2705
+ ), N = wt(
2706
+ y,
2707
+ _,
2708
+ b,
2709
+ w
2606
2710
  );
2607
- this.ui.telInput.value = g, this.ui.telInput.setSelectionRange(_, _);
2711
+ this.ui.telInput.value = _, this.ui.telInput.setSelectionRange(N, N);
2608
2712
  }
2609
2713
  };
2610
- this.ui.telInput.addEventListener("input", a, {
2611
- signal: this.abortController.signal
2612
- });
2714
+ this.ui.telInput.addEventListener(
2715
+ "input",
2716
+ r,
2717
+ {
2718
+ signal: this.abortController.signal
2719
+ }
2720
+ );
2613
2721
  }
2614
2722
  _maybeBindKeydownListener() {
2615
2723
  const { strictMode: t, separateDialCode: e, allowDropdown: i, countrySearch: s } = this.options;
@@ -2621,11 +2729,11 @@ class S {
2621
2729
  return;
2622
2730
  }
2623
2731
  if (t) {
2624
- const a = this.ui.telInput.value, u = !a.startsWith("+") && this.ui.telInput.selectionStart === 0 && n.key === "+", c = /^[0-9]$/.test(n.key), C = e ? c : u || c, m = a.slice(0, this.ui.telInput.selectionStart) + n.key + a.slice(this.ui.telInput.selectionEnd), h = this._getFullNumber(m), f = d.utils.getCoreNumber(
2625
- h,
2732
+ const r = this.ui.telInput.value, d = !r.startsWith("+") && this.ui.telInput.selectionStart === 0 && n.key === "+", c = /^[0-9]$/.test(n.key), f = e ? c : d || c, b = r.slice(0, this.ui.telInput.selectionStart) + n.key + r.slice(this.ui.telInput.selectionEnd), p = this._getFullNumber(b), y = u.utils.getCoreNumber(
2733
+ p,
2626
2734
  this.selectedCountryData.iso2
2627
- ), b = this.maxCoreNumberLength && f.length > this.maxCoreNumberLength, g = this._getNewCountryFromNumber(h) !== null;
2628
- (!C || b && !g && !u) && n.preventDefault();
2735
+ ), w = this.maxCoreNumberLength && y.length > this.maxCoreNumberLength, _ = this._getNewCountryFromNumber(p) !== null;
2736
+ (!f || w && !_ && !d) && n.preventDefault();
2629
2737
  }
2630
2738
  }
2631
2739
  };
@@ -2638,21 +2746,21 @@ class S {
2638
2746
  if (this.options.strictMode) {
2639
2747
  const t = (e) => {
2640
2748
  e.preventDefault();
2641
- const i = this.ui.telInput, s = i.selectionStart, o = i.selectionEnd, n = i.value.slice(0, s), a = i.value.slice(o), r = this.selectedCountryData.iso2, u = e.clipboardData.getData("text"), c = s === 0 && o > 0, C = !i.value.startsWith("+") || c, m = u.replace(/[^0-9+]/g, ""), h = m.startsWith("+"), f = m.replace(/\+/g, ""), b = h && C ? `+${f}` : f;
2642
- let y = n + b + a, g = d.utils.getCoreNumber(y, r);
2643
- for (; g.length === 0 && y.length > 0; )
2644
- y = y.slice(0, -1), g = d.utils.getCoreNumber(y, r);
2645
- if (!g)
2749
+ const i = this.ui.telInput, s = i.selectionStart, o = i.selectionEnd, n = i.value.slice(0, s), r = i.value.slice(o), a = this.selectedCountryData.iso2, d = e.clipboardData.getData("text"), c = s === 0 && o > 0, f = !i.value.startsWith("+") || c, b = d.replace(D.NON_PLUS_NUMERIC_GLOBAL, ""), p = b.startsWith("+"), y = b.replace(/\+/g, ""), w = p && f ? `+${y}` : y;
2750
+ let I = n + w + r, _ = u.utils.getCoreNumber(I, a);
2751
+ for (; _.length === 0 && I.length > 0; )
2752
+ I = I.slice(0, -1), _ = u.utils.getCoreNumber(I, a);
2753
+ if (!_)
2646
2754
  return;
2647
- if (this.maxCoreNumberLength && g.length > this.maxCoreNumberLength)
2755
+ if (this.maxCoreNumberLength && _.length > this.maxCoreNumberLength)
2648
2756
  if (i.selectionEnd === i.value.length) {
2649
- const E = g.length - this.maxCoreNumberLength;
2650
- y = y.slice(0, y.length - E);
2757
+ const j = _.length - this.maxCoreNumberLength;
2758
+ I = I.slice(0, I.length - j);
2651
2759
  } else
2652
2760
  return;
2653
- i.value = y;
2654
- const _ = s + b.length;
2655
- i.setSelectionRange(_, _), i.dispatchEvent(new InputEvent("input", { bubbles: !0 }));
2761
+ i.value = I;
2762
+ const N = s + w.length;
2763
+ i.setSelectionRange(N, N), i.dispatchEvent(new InputEvent("input", { bubbles: !0 }));
2656
2764
  };
2657
2765
  this.ui.telInput.addEventListener("paste", t, {
2658
2766
  signal: this.abortController.signal
@@ -2676,11 +2784,11 @@ class S {
2676
2784
  //* Open the dropdown.
2677
2785
  _openDropdown() {
2678
2786
  const { fixDropdownWidth: t, countrySearch: e } = this.options;
2679
- if (this.dropdownAbortController = new AbortController(), t && (this.ui.dropdownContent.style.width = `${this.ui.telInput.offsetWidth}px`), this.ui.dropdownContent.classList.remove("iti__hide"), this.ui.selectedCountry.setAttribute("aria-expanded", "true"), this._setDropdownPosition(), e) {
2787
+ if (this.dropdownAbortController = new AbortController(), t && (this.ui.dropdownContent.style.width = `${this.ui.telInput.offsetWidth}px`), this.ui.dropdownContent.classList.remove(h.HIDE), this.ui.selectedCountry.setAttribute(C.EXPANDED, "true"), this._setDropdownPosition(), e) {
2680
2788
  const i = this.ui.countryList.firstElementChild;
2681
2789
  i && (this.ui.highlightListItem(i, !1), this.ui.countryList.scrollTop = 0), this.ui.searchInput.focus();
2682
2790
  }
2683
- this._bindDropdownListeners(), this.ui.dropdownArrow.classList.add("iti__arrow--up"), this._trigger("open:countrydropdown");
2791
+ this._bindDropdownListeners(), this.ui.dropdownArrow.classList.add(h.ARROW_UP), this._trigger(A.OPEN_COUNTRY_DROPDOWN);
2684
2792
  }
2685
2793
  //* Set the dropdown position
2686
2794
  _setDropdownPosition() {
@@ -2697,98 +2805,114 @@ class S {
2697
2805
  }
2698
2806
  //* We only bind dropdown listeners when the dropdown is open.
2699
2807
  _bindDropdownListeners() {
2700
- const t = this.dropdownAbortController.signal, e = (r) => {
2701
- var c;
2702
- const u = (c = r.target) == null ? void 0 : c.closest(
2703
- ".iti__country"
2808
+ const t = this.dropdownAbortController.signal;
2809
+ this._bindDropdownMouseoverListener(t), this._bindDropdownCountryClickListener(t), this._bindDropdownClickOffListener(t), this._bindDropdownKeydownListener(t), this.options.countrySearch && this._bindDropdownSearchListeners(t);
2810
+ }
2811
+ //* When mouse over a list item, just highlight that one
2812
+ //* we add the class "highlight", so if they hit "enter" we know which one to select.
2813
+ _bindDropdownMouseoverListener(t) {
2814
+ const e = (i) => {
2815
+ var o;
2816
+ const s = (o = i.target) == null ? void 0 : o.closest(
2817
+ `.${h.COUNTRY_ITEM}`
2704
2818
  );
2705
- u && this.ui.highlightListItem(u, !1);
2819
+ s && this.ui.highlightListItem(s, !1);
2706
2820
  };
2707
- this.ui.countryList.addEventListener("mouseover", e, {
2708
- signal: t
2709
- });
2710
- const i = (r) => {
2711
- var c;
2712
- const u = (c = r.target) == null ? void 0 : c.closest(
2713
- ".iti__country"
2821
+ this.ui.countryList.addEventListener(
2822
+ "mouseover",
2823
+ e,
2824
+ {
2825
+ signal: t
2826
+ }
2827
+ );
2828
+ }
2829
+ //* Listen for country selection.
2830
+ _bindDropdownCountryClickListener(t) {
2831
+ const e = (i) => {
2832
+ var o;
2833
+ const s = (o = i.target) == null ? void 0 : o.closest(
2834
+ `.${h.COUNTRY_ITEM}`
2714
2835
  );
2715
- u && this._selectListItem(u);
2836
+ s && this._selectListItem(s);
2716
2837
  };
2717
- this.ui.countryList.addEventListener("click", i, {
2838
+ this.ui.countryList.addEventListener("click", e, {
2718
2839
  signal: t
2719
2840
  });
2720
- const s = (r) => {
2721
- !!r.target.closest(
2841
+ }
2842
+ //* Click off to close (except when this initial opening click is bubbling up).
2843
+ //* We cannot just stopPropagation as it may be needed to close another instance.
2844
+ _bindDropdownClickOffListener(t) {
2845
+ const e = (i) => {
2846
+ !!i.target.closest(
2722
2847
  `#iti-${this.id}__dropdown-content`
2723
2848
  ) || this._closeDropdown();
2724
2849
  };
2725
2850
  setTimeout(() => {
2726
2851
  document.documentElement.addEventListener(
2727
2852
  "click",
2728
- s,
2853
+ e,
2729
2854
  { signal: t }
2730
2855
  );
2731
2856
  }, 0);
2732
- let o = "", n = null;
2733
- const a = (r) => {
2734
- ["ArrowUp", "ArrowDown", "Enter", "Escape"].includes(r.key) && (r.preventDefault(), r.stopPropagation(), r.key === "ArrowUp" || r.key === "ArrowDown" ? this._handleUpDownKey(r.key) : r.key === "Enter" ? this._handleEnterKey() : r.key === "Escape" && this._closeDropdown()), !this.options.countrySearch && /^[a-zA-ZÀ-ÿа-яА-Я ]$/.test(r.key) && (r.stopPropagation(), n && clearTimeout(n), o += r.key.toLowerCase(), this._searchForCountry(o), n = setTimeout(() => {
2735
- o = "";
2736
- }, 1e3));
2857
+ }
2858
+ //* Listen for up/down scrolling, enter to select, or escape to close.
2859
+ //* Use keydown as keypress doesn't fire for non-char keys and we want to catch if they
2860
+ //* just hit down and hold it to scroll down (no keyup event).
2861
+ //* Listen on the document because that's where key events are triggered if no input has focus.
2862
+ _bindDropdownKeydownListener(t) {
2863
+ let e = "", i = null;
2864
+ const s = (o) => {
2865
+ [
2866
+ g.ARROW_UP,
2867
+ g.ARROW_DOWN,
2868
+ g.ENTER,
2869
+ g.ESC
2870
+ ].includes(o.key) && (o.preventDefault(), o.stopPropagation(), o.key === g.ARROW_UP || o.key === g.ARROW_DOWN ? this._handleUpDownKey(o.key) : o.key === g.ENTER ? this._handleEnterKey() : o.key === g.ESC && this._closeDropdown()), !this.options.countrySearch && D.HIDDEN_SEARCH_CHAR.test(o.key) && (o.stopPropagation(), i && clearTimeout(i), e += o.key.toLowerCase(), this._searchForCountry(e), i = setTimeout(() => {
2871
+ e = "";
2872
+ }, ot.HIDDEN_SEARCH_RESET_MS));
2737
2873
  };
2738
- if (document.addEventListener("keydown", a, { signal: t }), this.options.countrySearch) {
2739
- const r = () => {
2740
- const m = this.ui.searchInput.value.trim();
2741
- this._filterCountriesByQuery(m), this.ui.searchInput.value ? this.ui.searchClearButton.classList.remove("iti__hide") : this.ui.searchClearButton.classList.add("iti__hide");
2742
- };
2743
- let u = null;
2744
- const c = () => {
2745
- u && clearTimeout(u), u = setTimeout(() => {
2746
- r(), u = null;
2747
- }, 100);
2748
- };
2749
- this.ui.searchInput.addEventListener("input", c, {
2750
- signal: t
2751
- });
2752
- const C = () => {
2753
- this.ui.searchInput.value = "", this.ui.searchInput.focus(), r();
2754
- };
2755
- this.ui.searchClearButton.addEventListener("click", C, {
2756
- signal: t
2757
- });
2758
- }
2874
+ document.addEventListener("keydown", s, { signal: t });
2875
+ }
2876
+ //* Search input listeners when countrySearch enabled.
2877
+ _bindDropdownSearchListeners(t) {
2878
+ const e = () => {
2879
+ const n = this.ui.searchInput.value.trim();
2880
+ this._filterCountriesByQuery(n), this.ui.searchInput.value ? this.ui.searchClearButton.classList.remove(h.HIDE) : this.ui.searchClearButton.classList.add(h.HIDE);
2881
+ };
2882
+ let i = null;
2883
+ const s = () => {
2884
+ i && clearTimeout(i), i = setTimeout(() => {
2885
+ e(), i = null;
2886
+ }, 100);
2887
+ };
2888
+ this.ui.searchInput.addEventListener("input", s, {
2889
+ signal: t
2890
+ });
2891
+ const o = () => {
2892
+ this.ui.searchInput.value = "", this.ui.searchInput.focus(), e();
2893
+ };
2894
+ this.ui.searchClearButton.addEventListener("click", o, {
2895
+ signal: t
2896
+ });
2759
2897
  }
2760
2898
  //* Hidden search (countrySearch disabled): Find the first list item whose name starts with the query string.
2761
2899
  _searchForCountry(t) {
2762
- for (const e of this.countries)
2763
- if (e.name.substring(0, t.length).toLowerCase() === t) {
2764
- const s = e.nodeById[this.id];
2765
- this.ui.highlightListItem(s, !1), this.ui.scrollTo(s);
2766
- break;
2767
- }
2900
+ const e = ct(this.countries, t);
2901
+ if (e) {
2902
+ const i = e.nodeById[this.id];
2903
+ this.ui.highlightListItem(i, !1), this.ui.scrollTo(i);
2904
+ }
2768
2905
  }
2769
2906
  //* Country search: Filter the countries according to the search query.
2770
2907
  _filterCountriesByQuery(t) {
2771
2908
  let e;
2772
- t === "" ? e = this.countries : e = this._getMatchedCountries(t), this.ui.filterCountries(e);
2773
- }
2774
- _getMatchedCountries(t) {
2775
- const e = M(t), i = [], s = [], o = [], n = [], a = [], r = [];
2776
- for (const u of this.countries)
2777
- u.iso2 === e ? i.push(u) : u.normalisedName.startsWith(e) ? s.push(u) : u.normalisedName.includes(e) ? o.push(u) : e === u.dialCode || e === u.dialCodePlus ? n.push(u) : u.dialCodePlus.includes(e) ? a.push(u) : u.initials.includes(e) && r.push(u);
2778
- return [
2779
- ...i.sort((u, c) => u.priority - c.priority),
2780
- ...s.sort((u, c) => u.priority - c.priority),
2781
- ...o.sort((u, c) => u.priority - c.priority),
2782
- ...n.sort((u, c) => u.priority - c.priority),
2783
- ...a.sort((u, c) => u.priority - c.priority),
2784
- ...r.sort((u, c) => u.priority - c.priority)
2785
- ];
2909
+ t === "" ? e = this.countries : e = dt(this.countries, t), this.ui.filterCountries(e);
2786
2910
  }
2787
2911
  //* Highlight the next/prev item in the list (and ensure it is visible).
2788
2912
  _handleUpDownKey(t) {
2789
2913
  var i, s;
2790
- let e = t === "ArrowUp" ? (i = this.ui.highlightedItem) == null ? void 0 : i.previousElementSibling : (s = this.ui.highlightedItem) == null ? void 0 : s.nextElementSibling;
2791
- !e && this.ui.countryList.childElementCount > 1 && (e = t === "ArrowUp" ? this.ui.countryList.lastElementChild : this.ui.countryList.firstElementChild), e && (this.ui.scrollTo(e), this.ui.highlightListItem(e, !1));
2914
+ let e = t === g.ARROW_UP ? (i = this.ui.highlightedItem) == null ? void 0 : i.previousElementSibling : (s = this.ui.highlightedItem) == null ? void 0 : s.nextElementSibling;
2915
+ !e && this.ui.countryList.childElementCount > 1 && (e = t === g.ARROW_UP ? this.ui.countryList.lastElementChild : this.ui.countryList.firstElementChild), e && (this.ui.scrollTo(e), this.ui.highlightListItem(e, !1));
2792
2916
  }
2793
2917
  //* Select the currently highlighted item.
2794
2918
  _handleEnterKey() {
@@ -2798,9 +2922,9 @@ class S {
2798
2922
  //* NOTE: this is called from _setInitialState, handleUtils and setNumber.
2799
2923
  _updateValFromNumber(t) {
2800
2924
  let e = t;
2801
- if (this.options.formatOnDisplay && d.utils && this.selectedCountryData) {
2802
- const i = this.options.nationalMode || !e.startsWith("+") && !this.options.separateDialCode, { NATIONAL: s, INTERNATIONAL: o } = d.utils.numberFormat, n = i ? s : o;
2803
- e = d.utils.formatNumber(
2925
+ if (this.options.formatOnDisplay && u.utils && this.selectedCountryData) {
2926
+ const i = this.options.nationalMode || !e.startsWith("+") && !this.options.separateDialCode, { NATIONAL: s, INTERNATIONAL: o } = u.utils.numberFormat, n = i ? s : o;
2927
+ e = u.utils.formatNumber(
2804
2928
  e,
2805
2929
  this.selectedCountryData.iso2,
2806
2930
  n
@@ -2830,29 +2954,29 @@ class S {
2830
2954
  let i = e ? t.substring(e) : t;
2831
2955
  const s = this.selectedCountryData.iso2, o = this.selectedCountryData.dialCode;
2832
2956
  i = this._ensureHasDialCode(i);
2833
- const n = this._getDialCode(i, !0), a = v(i);
2957
+ const n = this._getDialCode(i, !0), r = v(i);
2834
2958
  if (n) {
2835
- const r = v(n), u = this.dialCodeToIso2Map[r];
2836
- if (u.length === 1)
2837
- return u[0] === s ? null : u[0];
2838
- if (!s && this.defaultCountry && u.includes(this.defaultCountry))
2959
+ const a = v(n), d = this.dialCodeToIso2Map[a];
2960
+ if (d.length === 1)
2961
+ return d[0] === s ? null : d[0];
2962
+ if (!s && this.defaultCountry && d.includes(this.defaultCountry))
2839
2963
  return this.defaultCountry;
2840
- if (o === "1" && k(a))
2964
+ if (o === $.NANP && F(r))
2841
2965
  return null;
2842
- const { areaCodes: C, priority: m } = this.selectedCountryData;
2843
- if (C) {
2844
- const g = C.map(
2845
- (_) => `${o}${_}`
2966
+ const { areaCodes: f, priority: b } = this.selectedCountryData;
2967
+ if (f) {
2968
+ const _ = f.map(
2969
+ (N) => `${o}${N}`
2846
2970
  );
2847
- for (const _ of g)
2848
- if (a.startsWith(_))
2971
+ for (const N of _)
2972
+ if (r.startsWith(N))
2849
2973
  return null;
2850
2974
  }
2851
- const f = C && !(m === 0) && a.length > r.length, b = s && u.includes(s) && !f, y = s === u[0];
2852
- if (!b && !y)
2853
- return u[0];
2975
+ const y = f && !(b === 0) && r.length > a.length, w = s && d.includes(s) && !y, I = s === d[0];
2976
+ if (!w && !I)
2977
+ return d[0];
2854
2978
  } else {
2855
- if (i.startsWith("+") && a.length)
2979
+ if (i.startsWith("+") && r.length)
2856
2980
  return "";
2857
2981
  if ((!i || i === "+") && !s)
2858
2982
  return this.defaultCountry;
@@ -2864,14 +2988,14 @@ class S {
2864
2988
  _setCountry(t) {
2865
2989
  const { separateDialCode: e, showFlags: i, i18n: s } = this.options, o = this.selectedCountryData.iso2 || "";
2866
2990
  if (this.selectedCountryData = t ? this.countryByIso2.get(t) : {}, this.selectedCountryData.iso2 && (this.defaultCountry = this.selectedCountryData.iso2), this.ui.selectedCountry) {
2867
- const n = t && i ? `iti__flag iti__${t}` : "iti__flag iti__globe";
2868
- let a, r;
2991
+ const n = t && i ? `${h.FLAG} iti__${t}` : `${h.FLAG} ${h.GLOBE}`;
2992
+ let r, a;
2869
2993
  if (t) {
2870
- const { name: u, dialCode: c } = this.selectedCountryData;
2871
- r = u, a = s.selectedCountryAriaLabel.replace("${countryName}", u).replace("${dialCode}", `+${c}`);
2994
+ const { name: d, dialCode: c } = this.selectedCountryData;
2995
+ a = d, r = s.selectedCountryAriaLabel.replace("${countryName}", d).replace("${dialCode}", `+${c}`);
2872
2996
  } else
2873
- r = s.noCountrySelected, a = s.noCountrySelected;
2874
- this.ui.selectedCountryInner.className = n, this.ui.selectedCountry.setAttribute("title", r), this.ui.selectedCountry.setAttribute("aria-label", a);
2997
+ a = s.noCountrySelected, r = s.noCountrySelected;
2998
+ this.ui.selectedCountryInner.className = n, this.ui.selectedCountry.setAttribute("title", a), this.ui.selectedCountry.setAttribute(C.LABEL, r);
2875
2999
  }
2876
3000
  if (e) {
2877
3001
  const n = this.selectedCountryData.dialCode ? `+${this.selectedCountryData.dialCode}` : "";
@@ -2882,23 +3006,23 @@ class S {
2882
3006
  //* Update the maximum valid number length for the currently selected country.
2883
3007
  _updateMaxLength() {
2884
3008
  const { strictMode: t, placeholderNumberType: e, validationNumberTypes: i } = this.options, { iso2: s } = this.selectedCountryData;
2885
- if (t && d.utils)
3009
+ if (t && u.utils)
2886
3010
  if (s) {
2887
- const o = d.utils.numberType[e];
2888
- let n = d.utils.getExampleNumber(
3011
+ const o = u.utils.numberType[e];
3012
+ let n = u.utils.getExampleNumber(
2889
3013
  s,
2890
3014
  !1,
2891
3015
  o,
2892
3016
  !0
2893
- ), a = n;
2894
- for (; d.utils.isPossibleNumber(
3017
+ ), r = n;
3018
+ for (; u.utils.isPossibleNumber(
2895
3019
  n,
2896
3020
  s,
2897
3021
  i
2898
3022
  ); )
2899
- a = n, n += "0";
2900
- const r = d.utils.getCoreNumber(a, s);
2901
- this.maxCoreNumberLength = r.length, s === "by" && (this.maxCoreNumberLength = r.length + 1);
3023
+ r = n, n += "0";
3024
+ const a = u.utils.getCoreNumber(r, s);
3025
+ this.maxCoreNumberLength = a.length, s === "by" && (this.maxCoreNumberLength = a.length + 1);
2902
3026
  } else
2903
3027
  this.maxCoreNumberLength = null;
2904
3028
  }
@@ -2910,26 +3034,26 @@ class S {
2910
3034
  nationalMode: i,
2911
3035
  customPlaceholder: s
2912
3036
  } = this.options, o = t === "aggressive" || !this.ui.hadInitialPlaceholder && t === "polite";
2913
- if (d.utils && o) {
2914
- const n = d.utils.numberType[e];
2915
- let a = this.selectedCountryData.iso2 ? d.utils.getExampleNumber(
3037
+ if (u.utils && o) {
3038
+ const n = u.utils.numberType[e];
3039
+ let r = this.selectedCountryData.iso2 ? u.utils.getExampleNumber(
2916
3040
  this.selectedCountryData.iso2,
2917
3041
  i,
2918
3042
  n
2919
3043
  ) : "";
2920
- a = this._beforeSetNumber(a), typeof s == "function" && (a = s(a, this.selectedCountryData)), this.ui.telInput.setAttribute("placeholder", a);
3044
+ r = this._beforeSetNumber(r), typeof s == "function" && (r = s(r, this.selectedCountryData)), this.ui.telInput.setAttribute("placeholder", r);
2921
3045
  }
2922
3046
  }
2923
3047
  //* Called when the user selects a list item from the dropdown.
2924
3048
  _selectListItem(t) {
2925
- const e = t.dataset.countryCode, i = this._setCountry(e);
3049
+ const e = t.dataset[W.COUNTRY_CODE], i = this._setCountry(e);
2926
3050
  this._closeDropdown();
2927
- const s = t.dataset.dialCode;
3051
+ const s = t.dataset[W.DIAL_CODE];
2928
3052
  this._updateDialCode(s), this.options.formatOnDisplay && this._updateValFromNumber(this.ui.telInput.value), this.ui.telInput.focus(), i && this._triggerCountryChange();
2929
3053
  }
2930
3054
  //* Close the dropdown and unbind any listeners.
2931
3055
  _closeDropdown() {
2932
- this.ui.dropdownContent.classList.contains("iti__hide") || (this.ui.dropdownContent.classList.add("iti__hide"), this.ui.selectedCountry.setAttribute("aria-expanded", "false"), this.ui.highlightedItem && this.ui.highlightedItem.setAttribute("aria-selected", "false"), this.options.countrySearch && this.ui.searchInput.removeAttribute("aria-activedescendant"), this.ui.dropdownArrow.classList.remove("iti__arrow--up"), this.dropdownAbortController.abort(), this.dropdownAbortController = null, this.options.dropdownContainer && this.ui.dropdown.remove(), this._trigger("close:countrydropdown"));
3056
+ this.ui.dropdownContent.classList.contains(h.HIDE) || (this.ui.dropdownContent.classList.add(h.HIDE), this.ui.selectedCountry.setAttribute(C.EXPANDED, "false"), this.ui.highlightedItem && this.ui.highlightedItem.setAttribute(C.SELECTED, "false"), this.options.countrySearch && this.ui.searchInput.removeAttribute(C.ACTIVE_DESCENDANT), this.ui.dropdownArrow.classList.remove(h.ARROW_UP), this.dropdownAbortController.abort(), this.dropdownAbortController = null, this.options.dropdownContainer && this.ui.dropdown.remove(), this._trigger(A.CLOSE_COUNTRY_DROPDOWN));
2933
3057
  }
2934
3058
  //* Replace any existing dial code with the new one
2935
3059
  //* Note: called from _selectListItem and setCountry
@@ -2974,7 +3098,7 @@ class S {
2974
3098
  }
2975
3099
  //* Remove the dial code if separateDialCode is enabled also cap the length if the input has a maxlength attribute
2976
3100
  _beforeSetNumber(t) {
2977
- const e = this._getDialCode(t), i = et(
3101
+ const e = this._getDialCode(t), i = It(
2978
3102
  t,
2979
3103
  e,
2980
3104
  this.options.separateDialCode,
@@ -2984,38 +3108,38 @@ class S {
2984
3108
  }
2985
3109
  //* Trigger the 'countrychange' event.
2986
3110
  _triggerCountryChange() {
2987
- this._trigger("countrychange");
3111
+ this._trigger(A.COUNTRY_CHANGE);
2988
3112
  }
2989
3113
  //**************************
2990
3114
  //* SECRET PUBLIC METHODS
2991
3115
  //**************************
2992
3116
  //* This is called when the geoip call returns.
2993
3117
  handleAutoCountry() {
2994
- this.options.initialCountry === "auto" && d.autoCountry && (this.defaultCountry = d.autoCountry, this.selectedCountryData.iso2 || this.ui.selectedCountryInner.classList.contains("iti__globe") || this.setCountry(this.defaultCountry), this.resolveAutoCountryPromise());
3118
+ this.options.initialCountry === O.AUTO && u.autoCountry && (this.defaultCountry = u.autoCountry, this.selectedCountryData.iso2 || this.ui.selectedCountryInner.classList.contains(h.GLOBE) || this.setCountry(this.defaultCountry), this.resolveAutoCountryPromise());
2995
3119
  }
2996
3120
  //* This is called when the utils request completes.
2997
3121
  handleUtils() {
2998
- d.utils && (this.ui.telInput.value && this._updateValFromNumber(this.ui.telInput.value), this.selectedCountryData.iso2 && (this._updatePlaceholder(), this._updateMaxLength())), this.resolveUtilsScriptPromise();
3122
+ u.utils && (this.ui.telInput.value && this._updateValFromNumber(this.ui.telInput.value), this.selectedCountryData.iso2 && (this._updatePlaceholder(), this._updateMaxLength())), this.resolveUtilsScriptPromise();
2999
3123
  }
3000
3124
  //********************
3001
3125
  //* PUBLIC METHODS
3002
3126
  //********************
3003
3127
  //* Remove plugin.
3004
3128
  destroy() {
3005
- this.ui.telInput && (this.options.allowDropdown && this._closeDropdown(), this.abortController.abort(), this.abortController = null, this.ui.destroy(), d.instances instanceof Map ? d.instances.delete(this.id) : delete d.instances[this.id]);
3129
+ this.ui.telInput && (this.options.allowDropdown && this._closeDropdown(), this.abortController.abort(), this.abortController = null, this.ui.destroy(), u.instances instanceof Map ? u.instances.delete(this.id) : delete u.instances[this.id]);
3006
3130
  }
3007
3131
  //* Get the extension from the current number.
3008
3132
  getExtension() {
3009
- return d.utils ? d.utils.getExtension(
3133
+ return u.utils ? u.utils.getExtension(
3010
3134
  this._getFullNumber(),
3011
3135
  this.selectedCountryData.iso2
3012
3136
  ) : "";
3013
3137
  }
3014
3138
  //* Format the number to the given format.
3015
3139
  getNumber(t) {
3016
- if (d.utils) {
3140
+ if (u.utils) {
3017
3141
  const { iso2: e } = this.selectedCountryData;
3018
- return d.utils.formatNumber(
3142
+ return u.utils.formatNumber(
3019
3143
  this._getFullNumber(),
3020
3144
  e,
3021
3145
  t
@@ -3025,10 +3149,10 @@ class S {
3025
3149
  }
3026
3150
  //* Get the type of the entered number e.g. landline/mobile.
3027
3151
  getNumberType() {
3028
- return d.utils ? d.utils.getNumberType(
3152
+ return u.utils ? u.utils.getNumberType(
3029
3153
  this._getFullNumber(),
3030
3154
  this.selectedCountryData.iso2
3031
- ) : -99;
3155
+ ) : H.UNKNOWN_NUMBER_TYPE;
3032
3156
  }
3033
3157
  //* Get the country data for the currently selected country.
3034
3158
  getSelectedCountryData() {
@@ -3036,18 +3160,18 @@ class S {
3036
3160
  }
3037
3161
  //* Get the validation error.
3038
3162
  getValidationError() {
3039
- if (d.utils) {
3163
+ if (u.utils) {
3040
3164
  const { iso2: t } = this.selectedCountryData;
3041
- return d.utils.getValidationError(this._getFullNumber(), t);
3165
+ return u.utils.getValidationError(this._getFullNumber(), t);
3042
3166
  }
3043
- return -99;
3167
+ return H.UNKNOWN_VALIDATION_ERROR;
3044
3168
  }
3045
3169
  //* Validate the input val using number length only
3046
3170
  isValidNumber() {
3047
3171
  const { dialCode: t, iso2: e } = this.selectedCountryData;
3048
- if (t === "44" && d.utils) {
3049
- const i = this._getFullNumber(), s = d.utils.getCoreNumber(i, e);
3050
- if (s[0] === "7" && s.length !== 10)
3172
+ if (t === P.DIAL_CODE && u.utils) {
3173
+ const i = this._getFullNumber(), s = u.utils.getCoreNumber(i, e);
3174
+ if (s[0] === P.MOBILE_PREFIX && s.length !== P.MOBILE_CORE_LENGTH)
3051
3175
  return !1;
3052
3176
  }
3053
3177
  return this._validateNumber(!1);
@@ -3057,7 +3181,7 @@ class S {
3057
3181
  return this._validateNumber(!0);
3058
3182
  }
3059
3183
  _utilsIsPossibleNumber(t) {
3060
- return d.utils ? d.utils.isPossibleNumber(
3184
+ return u.utils ? u.utils.isPossibleNumber(
3061
3185
  t,
3062
3186
  this.selectedCountryData.iso2,
3063
3187
  this.options.validationNumberTypes
@@ -3065,19 +3189,19 @@ class S {
3065
3189
  }
3066
3190
  //* Shared internal validation logic to handle alpha character extension rules.
3067
3191
  _validateNumber(t) {
3068
- if (!d.utils)
3192
+ if (!u.utils)
3069
3193
  return null;
3070
3194
  if (!this.selectedCountryData.iso2)
3071
3195
  return !1;
3072
- const e = (n) => t ? this._utilsIsValidNumber(n) : this._utilsIsPossibleNumber(n), i = this._getFullNumber(), s = i.search(new RegExp("\\p{L}", "u"));
3196
+ const e = (n) => t ? this._utilsIsValidNumber(n) : this._utilsIsPossibleNumber(n), i = this._getFullNumber(), s = i.search(D.ALPHA_UNICODE);
3073
3197
  if (s > -1 && !this.options.allowPhonewords) {
3074
- const n = i.substring(0, s), a = e(n), r = e(i);
3075
- return a && r;
3198
+ const n = i.substring(0, s), r = e(n), a = e(i);
3199
+ return r && a;
3076
3200
  }
3077
3201
  return e(i);
3078
3202
  }
3079
3203
  _utilsIsValidNumber(t) {
3080
- return d.utils ? d.utils.isValidNumber(
3204
+ return u.utils ? u.utils.isValidNumber(
3081
3205
  t,
3082
3206
  this.selectedCountryData.iso2,
3083
3207
  this.options.validationNumberTypes
@@ -3086,7 +3210,7 @@ class S {
3086
3210
  //* Update the selected country, and update the input val accordingly.
3087
3211
  setCountry(t) {
3088
3212
  const e = t == null ? void 0 : t.toLowerCase();
3089
- if (!A(e))
3213
+ if (!M(e))
3090
3214
  throw new Error(`Invalid country code: '${e}'`);
3091
3215
  const i = this.selectedCountryData.iso2;
3092
3216
  (t && e !== i || !t && i) && (this._setCountry(e), this._updateDialCode(this.selectedCountryData.dialCode), this.options.formatOnDisplay && this._updateValFromNumber(this.ui.telInput.value), this._triggerCountryChange());
@@ -3094,7 +3218,7 @@ class S {
3094
3218
  //* Set the input value and update the country.
3095
3219
  setNumber(t) {
3096
3220
  const e = this._updateCountryFromNumber(t);
3097
- this._updateValFromNumber(t), e && this._triggerCountryChange(), this._trigger("input", { isSetNumber: !0 });
3221
+ this._updateValFromNumber(t), e && this._triggerCountryChange(), this._trigger(A.INPUT, { isSetNumber: !0 });
3098
3222
  }
3099
3223
  //* Set the placeholder number typ
3100
3224
  setPlaceholderNumberType(t) {
@@ -3104,8 +3228,8 @@ class S {
3104
3228
  this.ui.telInput.disabled = t, t ? this.ui.selectedCountry.setAttribute("disabled", "true") : this.ui.selectedCountry.removeAttribute("disabled");
3105
3229
  }
3106
3230
  }
3107
- const at = (l) => {
3108
- if (!d.utils && !d.startedLoadingUtilsScript) {
3231
+ const Et = (l) => {
3232
+ if (!u.utils && !u.startedLoadingUtilsScript) {
3109
3233
  let t;
3110
3234
  if (typeof l == "function")
3111
3235
  try {
@@ -3119,49 +3243,49 @@ const at = (l) => {
3119
3243
  `The argument passed to attachUtils must be a function that returns a promise for the utilities module, not ${typeof l}`
3120
3244
  )
3121
3245
  );
3122
- return d.startedLoadingUtilsScript = !0, t.then((e) => {
3246
+ return u.startedLoadingUtilsScript = !0, t.then((e) => {
3123
3247
  const i = e == null ? void 0 : e.default;
3124
3248
  if (!i || typeof i != "object")
3125
3249
  throw new TypeError(
3126
3250
  "The loader function passed to attachUtils did not resolve to a module object with utils as its default export."
3127
3251
  );
3128
- return d.utils = i, I("handleUtils"), !0;
3252
+ return u.utils = i, E("handleUtils"), !0;
3129
3253
  }).catch((e) => {
3130
- throw I("rejectUtilsScriptPromise", e), e;
3254
+ throw E("rejectUtilsScriptPromise", e), e;
3131
3255
  });
3132
3256
  }
3133
3257
  return null;
3134
- }, I = (l, ...t) => {
3135
- Object.values(d.instances).forEach((e) => {
3258
+ }, E = (l, ...t) => {
3259
+ Object.values(u.instances).forEach((e) => {
3136
3260
  const i = e[l];
3137
3261
  typeof i == "function" && i.apply(e, t);
3138
3262
  });
3139
- }, d = Object.assign(
3263
+ }, u = Object.assign(
3140
3264
  (l, t) => {
3141
- const e = new S(l, t);
3142
- return d.instances[e.id] = e, l.iti = e, e;
3265
+ const e = new x(l, t);
3266
+ return u.instances[e.id] = e, l.iti = e, e;
3143
3267
  },
3144
3268
  {
3145
- defaults: T,
3269
+ defaults: G,
3146
3270
  //* Using a static var like this allows us to mock it in the tests.
3147
3271
  documentReady: () => document.readyState === "complete",
3148
3272
  //* Get the country data object.
3149
- getCountryData: () => w,
3273
+ getCountryData: () => L,
3150
3274
  //* A getter for the plugin instance.
3151
3275
  getInstance: (l) => {
3152
3276
  const t = l.dataset.intlTelInputId;
3153
- return t ? d.instances[t] : null;
3277
+ return t ? u.instances[t] : null;
3154
3278
  },
3155
3279
  //* A map from instance ID to instance object.
3156
3280
  instances: {},
3157
- attachUtils: at,
3281
+ attachUtils: Et,
3158
3282
  startedLoadingUtilsScript: !1,
3159
3283
  startedLoadingAutoCountry: !1,
3160
- version: "25.11.0"
3284
+ version: "25.11.2"
3161
3285
  }
3162
- ), ut = {
3286
+ ), vt = {
3163
3287
  __name: "IntlTelInput",
3164
- props: /* @__PURE__ */ P({
3288
+ props: /* @__PURE__ */ U({
3165
3289
  disabled: {
3166
3290
  type: Boolean,
3167
3291
  default: !1
@@ -3185,47 +3309,47 @@ const at = (l) => {
3185
3309
  },
3186
3310
  modelModifiers: {}
3187
3311
  }),
3188
- emits: /* @__PURE__ */ P([
3312
+ emits: /* @__PURE__ */ U([
3189
3313
  "changeNumber",
3190
3314
  "changeCountry",
3191
3315
  "changeValidity",
3192
3316
  "changeErrorCode"
3193
3317
  ], ["update:modelValue"]),
3194
3318
  setup(l, { expose: t, emit: e }) {
3195
- const i = B(l, "modelValue"), s = l, o = e, n = L(), a = L(), r = L(!1), u = () => a.value ? s.options.strictMode ? a.value.isValidNumberPrecise() : a.value.isValidNumber() : null, c = () => {
3196
- let h = u();
3197
- r.value !== h && (r.value = h, o("changeValidity", !!h), o(
3319
+ const i = K(l, "modelValue"), s = l, o = e, n = T(), r = T(), a = T(!1), d = () => r.value ? s.options.strictMode ? r.value.isValidNumberPrecise() : r.value.isValidNumber() : null, c = () => {
3320
+ let p = d();
3321
+ a.value !== p && (a.value = p, o("changeValidity", !!p), o(
3198
3322
  "changeErrorCode",
3199
- h ? null : a.value.getValidationError()
3323
+ p ? null : r.value.getValidationError()
3200
3324
  ));
3201
- }, C = () => {
3202
- var h;
3203
- o("changeNumber", ((h = a.value) == null ? void 0 : h.getNumber()) ?? ""), c();
3204
- }, m = () => {
3205
- var h;
3206
- o("changeCountry", ((h = a.value) == null ? void 0 : h.getSelectedCountryData().iso2) ?? ""), C(), c();
3325
+ }, f = () => {
3326
+ var p;
3327
+ o("changeNumber", ((p = r.value) == null ? void 0 : p.getNumber()) ?? ""), c();
3328
+ }, b = () => {
3329
+ var p;
3330
+ o("changeCountry", ((p = r.value) == null ? void 0 : p.getSelectedCountryData().iso2) ?? ""), f(), c();
3207
3331
  };
3208
- return F(() => {
3209
- n.value && (a.value = d(n.value, s.options), s.value && a.value.setNumber(s.value), s.disabled && a.value.setDisabled(s.disabled), r.value = u());
3210
- }), R(
3332
+ return Y(() => {
3333
+ n.value && (r.value = u(n.value, s.options), s.value && r.value.setNumber(s.value), s.disabled && r.value.setDisabled(s.disabled), a.value = d());
3334
+ }), q(
3211
3335
  () => s.disabled,
3212
- (h) => {
3213
- var f;
3214
- return (f = a.value) == null ? void 0 : f.setDisabled(h);
3336
+ (p) => {
3337
+ var y;
3338
+ return (y = r.value) == null ? void 0 : y.setDisabled(p);
3215
3339
  }
3216
- ), z(() => {
3217
- var h;
3218
- return (h = a.value) == null ? void 0 : h.destroy();
3219
- }), t({ instance: a, input: n }), (h, f) => V((U(), $("input", j({
3340
+ ), X(() => {
3341
+ var p;
3342
+ return (p = r.value) == null ? void 0 : p.destroy();
3343
+ }), t({ instance: r, input: n }), (p, y) => Q((Z(), J("input", tt({
3220
3344
  ref_key: "input",
3221
3345
  ref: n,
3222
- "onUpdate:modelValue": f[0] || (f[0] = (b) => i.value = b),
3346
+ "onUpdate:modelValue": y[0] || (y[0] = (w) => i.value = w),
3223
3347
  type: "tel",
3224
- onCountrychange: m,
3225
- onInput: C
3348
+ onCountrychange: b,
3349
+ onInput: f
3226
3350
  }, l.inputProps), null, 16)), [
3227
3351
  [
3228
- W,
3352
+ et,
3229
3353
  i.value,
3230
3354
  void 0,
3231
3355
  { lazy: !0 }
@@ -3234,5 +3358,5 @@ const at = (l) => {
3234
3358
  }
3235
3359
  };
3236
3360
  export {
3237
- ut as default
3361
+ vt as default
3238
3362
  };