intl-tel-input 26.9.2 → 27.0.1

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 (254) hide show
  1. package/CHANGELOG.md +2 -1
  2. package/angular/README.md +1 -1
  3. package/angular/dist/IntlTelInput.d.ts +97 -0
  4. package/angular/dist/IntlTelInput.js +4929 -0
  5. package/angular/dist/IntlTelInputWithUtils.d.ts +3 -0
  6. package/angular/{build → dist}/IntlTelInputWithUtils.js +2510 -2147
  7. package/{build → dist}/css/demo.css +1 -1
  8. package/dist/css/intlTelInput-no-assets.css +1 -0
  9. package/dist/css/intlTelInput-no-assets.min.css +1 -0
  10. package/dist/css/intlTelInput.css +1 -0
  11. package/dist/css/intlTelInput.min.css +1 -0
  12. package/dist/img/flags.png +0 -0
  13. package/dist/img/flags.webp +0 -0
  14. package/dist/img/flags@2x.png +0 -0
  15. package/dist/img/flags@2x.webp +0 -0
  16. package/dist/js/data.d.ts +1616 -0
  17. package/{build → dist}/js/data.js +62 -18
  18. package/dist/js/data.min.js +7 -0
  19. package/dist/js/data.mjs +1764 -0
  20. package/{build/js/i18n/ar/index.js → dist/js/i18n/ar.js} +1 -0
  21. package/{build/js/i18n/bg/index.js → dist/js/i18n/bg.js} +1 -0
  22. package/{build/js/i18n/bn/index.js → dist/js/i18n/bn.js} +1 -0
  23. package/{build/js/i18n/bs/index.js → dist/js/i18n/bs.js} +1 -0
  24. package/{build/js/i18n/ca/index.js → dist/js/i18n/ca.js} +1 -0
  25. package/{build/js/i18n/cs/index.js → dist/js/i18n/cs.js} +1 -0
  26. package/{build/js/i18n/da/index.js → dist/js/i18n/da.js} +1 -0
  27. package/{build/js/i18n/de/index.js → dist/js/i18n/de.js} +1 -0
  28. package/{build/js/i18n/el/index.js → dist/js/i18n/el.js} +1 -0
  29. package/{build/js/i18n/en/index.js → dist/js/i18n/en.js} +3 -2
  30. package/{build/js/i18n/es/index.js → dist/js/i18n/es.js} +1 -0
  31. package/{build/js/i18n/et/index.js → dist/js/i18n/et.js} +1 -0
  32. package/{build/js/i18n/fa/index.js → dist/js/i18n/fa.js} +1 -0
  33. package/{build/js/i18n/fi/index.js → dist/js/i18n/fi.js} +1 -0
  34. package/{build/js/i18n/fr/index.js → dist/js/i18n/fr.js} +1 -0
  35. package/{build/js/i18n/hi/index.js → dist/js/i18n/hi.js} +1 -0
  36. package/{build/js/i18n/hr/index.js → dist/js/i18n/hr.js} +1 -0
  37. package/{build/js/i18n/hu/index.js → dist/js/i18n/hu.js} +1 -0
  38. package/{build/js/i18n/id/index.js → dist/js/i18n/id.js} +1 -0
  39. package/{build → dist}/js/i18n/index.js +1 -0
  40. package/{build/js/i18n/it/index.js → dist/js/i18n/it.js} +1 -0
  41. package/{build/js/i18n/ja/index.js → dist/js/i18n/ja.js} +1 -0
  42. package/{build/js/i18n/kn/index.js → dist/js/i18n/kn.js} +1 -0
  43. package/{build/js/i18n/ko/index.js → dist/js/i18n/ko.js} +1 -0
  44. package/{build/js/i18n/lt/index.js → dist/js/i18n/lt.js} +1 -0
  45. package/{build/js/i18n/mr/index.js → dist/js/i18n/mr.js} +1 -0
  46. package/{build/js/i18n/nl/index.js → dist/js/i18n/nl.js} +1 -0
  47. package/{build/js/i18n/no/index.js → dist/js/i18n/no.js} +1 -0
  48. package/{build/js/i18n/pl/index.js → dist/js/i18n/pl.js} +1 -0
  49. package/{build/js/i18n/pt/index.js → dist/js/i18n/pt.js} +1 -0
  50. package/{build/js/i18n/ro/index.js → dist/js/i18n/ro.js} +1 -0
  51. package/{build/js/i18n/ru/index.js → dist/js/i18n/ru.js} +1 -0
  52. package/{build/js/i18n/sk/index.js → dist/js/i18n/sk.js} +1 -0
  53. package/{build/js/i18n/sl/index.js → dist/js/i18n/sl.js} +1 -0
  54. package/{build/js/i18n/sq/index.js → dist/js/i18n/sq.js} +1 -0
  55. package/{build/js/i18n/sr/index.js → dist/js/i18n/sr.js} +1 -0
  56. package/{build/js/i18n/sv/index.js → dist/js/i18n/sv.js} +1 -0
  57. package/{build/js/i18n/te/index.js → dist/js/i18n/te.js} +1 -0
  58. package/{build/js/i18n/th/index.js → dist/js/i18n/th.js} +1 -0
  59. package/{build/js/i18n/tr/index.js → dist/js/i18n/tr.js} +1 -0
  60. package/dist/js/i18n/types.js +1 -0
  61. package/{build/js/i18n/uk/index.js → dist/js/i18n/uk.js} +1 -0
  62. package/{build/js/i18n/ur/index.js → dist/js/i18n/ur.js} +1 -0
  63. package/{build/js/i18n/uz/index.js → dist/js/i18n/uz.js} +1 -0
  64. package/{build/js/i18n/vi/index.js → dist/js/i18n/vi.js} +1 -0
  65. package/{build/js/i18n/zh-hk/index.js → dist/js/i18n/zh-hk.js} +1 -0
  66. package/{build/js/i18n/zh/index.js → dist/js/i18n/zh.js} +1 -0
  67. package/dist/js/i18n.d.ts +1697 -0
  68. package/dist/js/intlTelInput.d.ts +1773 -0
  69. package/{build → dist}/js/intlTelInput.js +690 -560
  70. package/dist/js/intlTelInput.min.js +25 -0
  71. package/{react/build/IntlTelInput.cjs → dist/js/intlTelInput.mjs} +692 -685
  72. package/{build → dist}/js/intlTelInputWithUtils.js +993 -843
  73. package/dist/js/intlTelInputWithUtils.min.js +25 -0
  74. package/{react/build/IntlTelInputWithUtils.js → dist/js/intlTelInputWithUtils.mjs} +989 -937
  75. package/{build → dist}/js/utils.js +46 -47
  76. package/package.json +122 -122
  77. package/react/README.md +1 -1
  78. package/react/dist/IntlTelInput.d.ts +20 -0
  79. package/react/{build → dist}/IntlTelInput.js +736 -600
  80. package/react/dist/IntlTelInputWithUtils.d.ts +4 -0
  81. package/react/{build/IntlTelInputWithUtils.cjs → dist/IntlTelInputWithUtils.js} +1061 -932
  82. package/svelte/README.md +1 -1
  83. package/svelte/src/IntlTelInput.svelte +199 -0
  84. package/svelte/src/IntlTelInputWithUtils.svelte +15 -0
  85. package/svelte/src/shims.d.ts +4 -0
  86. package/vue/README.md +1 -1
  87. package/vue/dist/IntlTelInput-C4kh0zfZ.js +2580 -0
  88. package/vue/dist/IntlTelInput.js +5 -0
  89. package/vue/dist/IntlTelInputWithUtils.js +49385 -0
  90. package/vue/dist/src/IntlTelInput.vue.d.ts +35 -0
  91. package/vue/dist/src/index.d.ts +4 -0
  92. package/vue/dist/src/indexWithUtils.d.ts +3 -0
  93. package/angular/build/IntlTelInput.js +0 -4501
  94. package/angular/build/types/intl-tel-input/angular.d.ts +0 -65
  95. package/angular/build/types/intl-tel-input/angularWithUtils.d.ts +0 -65
  96. package/angular/build/types/intl-tel-input/data.d.ts +0 -20
  97. package/angular/build/types/intl-tel-input/i18n/ar/index.d.ts +0 -3
  98. package/angular/build/types/intl-tel-input/i18n/bg/index.d.ts +0 -3
  99. package/angular/build/types/intl-tel-input/i18n/bn/index.d.ts +0 -3
  100. package/angular/build/types/intl-tel-input/i18n/bs/index.d.ts +0 -3
  101. package/angular/build/types/intl-tel-input/i18n/ca/index.d.ts +0 -3
  102. package/angular/build/types/intl-tel-input/i18n/cs/index.d.ts +0 -3
  103. package/angular/build/types/intl-tel-input/i18n/da/index.d.ts +0 -3
  104. package/angular/build/types/intl-tel-input/i18n/de/index.d.ts +0 -3
  105. package/angular/build/types/intl-tel-input/i18n/el/index.d.ts +0 -3
  106. package/angular/build/types/intl-tel-input/i18n/en/index.d.ts +0 -3
  107. package/angular/build/types/intl-tel-input/i18n/es/index.d.ts +0 -3
  108. package/angular/build/types/intl-tel-input/i18n/et/index.d.ts +0 -3
  109. package/angular/build/types/intl-tel-input/i18n/fa/index.d.ts +0 -3
  110. package/angular/build/types/intl-tel-input/i18n/fi/index.d.ts +0 -3
  111. package/angular/build/types/intl-tel-input/i18n/fr/index.d.ts +0 -3
  112. package/angular/build/types/intl-tel-input/i18n/hi/index.d.ts +0 -3
  113. package/angular/build/types/intl-tel-input/i18n/hr/index.d.ts +0 -3
  114. package/angular/build/types/intl-tel-input/i18n/hu/index.d.ts +0 -3
  115. package/angular/build/types/intl-tel-input/i18n/id/index.d.ts +0 -3
  116. package/angular/build/types/intl-tel-input/i18n/index.d.ts +0 -45
  117. package/angular/build/types/intl-tel-input/i18n/it/index.d.ts +0 -3
  118. package/angular/build/types/intl-tel-input/i18n/ja/index.d.ts +0 -3
  119. package/angular/build/types/intl-tel-input/i18n/kn/index.d.ts +0 -3
  120. package/angular/build/types/intl-tel-input/i18n/ko/index.d.ts +0 -3
  121. package/angular/build/types/intl-tel-input/i18n/lt/index.d.ts +0 -3
  122. package/angular/build/types/intl-tel-input/i18n/mr/index.d.ts +0 -3
  123. package/angular/build/types/intl-tel-input/i18n/nl/index.d.ts +0 -3
  124. package/angular/build/types/intl-tel-input/i18n/no/index.d.ts +0 -3
  125. package/angular/build/types/intl-tel-input/i18n/pl/index.d.ts +0 -3
  126. package/angular/build/types/intl-tel-input/i18n/pt/index.d.ts +0 -3
  127. package/angular/build/types/intl-tel-input/i18n/ro/index.d.ts +0 -3
  128. package/angular/build/types/intl-tel-input/i18n/ru/index.d.ts +0 -3
  129. package/angular/build/types/intl-tel-input/i18n/sk/index.d.ts +0 -3
  130. package/angular/build/types/intl-tel-input/i18n/sl/index.d.ts +0 -3
  131. package/angular/build/types/intl-tel-input/i18n/sq/index.d.ts +0 -3
  132. package/angular/build/types/intl-tel-input/i18n/sr/index.d.ts +0 -3
  133. package/angular/build/types/intl-tel-input/i18n/sv/index.d.ts +0 -3
  134. package/angular/build/types/intl-tel-input/i18n/te/index.d.ts +0 -3
  135. package/angular/build/types/intl-tel-input/i18n/th/index.d.ts +0 -3
  136. package/angular/build/types/intl-tel-input/i18n/tr/index.d.ts +0 -3
  137. package/angular/build/types/intl-tel-input/i18n/types.d.ts +0 -10
  138. package/angular/build/types/intl-tel-input/i18n/uk/index.d.ts +0 -3
  139. package/angular/build/types/intl-tel-input/i18n/ur/index.d.ts +0 -3
  140. package/angular/build/types/intl-tel-input/i18n/uz/index.d.ts +0 -3
  141. package/angular/build/types/intl-tel-input/i18n/vi/index.d.ts +0 -3
  142. package/angular/build/types/intl-tel-input/i18n/zh/index.d.ts +0 -3
  143. package/angular/build/types/intl-tel-input/i18n/zh-hk/index.d.ts +0 -3
  144. package/angular/build/types/intl-tel-input/intlTelInputWithUtils.d.ts +0 -2
  145. package/angular/build/types/intl-tel-input/utils.d.ts +0 -2
  146. package/angular/build/types/intl-tel-input.d.ts +0 -46
  147. package/angular/build/types/modules/constants.d.ts +0 -94
  148. package/angular/build/types/modules/core/countrySearch.d.ts +0 -17
  149. package/angular/build/types/modules/core/icons.d.ts +0 -11
  150. package/angular/build/types/modules/core/numerals.d.ts +0 -7
  151. package/angular/build/types/modules/core/options.d.ts +0 -8
  152. package/angular/build/types/modules/core/ui.d.ts +0 -30
  153. package/angular/build/types/modules/data/country-data.d.ts +0 -12
  154. package/angular/build/types/modules/data/intl-regionless.d.ts +0 -2
  155. package/angular/build/types/modules/data/nanp-regionless.d.ts +0 -2
  156. package/angular/build/types/modules/format/caret.d.ts +0 -1
  157. package/angular/build/types/modules/format/formatting.d.ts +0 -3
  158. package/angular/build/types/modules/types/events.d.ts +0 -10
  159. package/angular/build/types/modules/types/forEachInstanceArgsMap.d.ts +0 -6
  160. package/angular/build/types/modules/types/public-api.d.ts +0 -65
  161. package/angular/build/types/modules/utils/dom.d.ts +0 -6
  162. package/angular/build/types/modules/utils/isAndroid.d.ts +0 -1
  163. package/angular/build/types/modules/utils/string.d.ts +0 -2
  164. package/build/css/intlTelInput-no-assets.css +0 -1323
  165. package/build/css/intlTelInput-no-assets.min.css +0 -1
  166. package/build/css/intlTelInput.css +0 -1327
  167. package/build/css/intlTelInput.min.css +0 -1
  168. package/build/img/flags.png +0 -0
  169. package/build/img/flags.webp +0 -0
  170. package/build/img/flags@2x.png +0 -0
  171. package/build/img/flags@2x.webp +0 -0
  172. package/build/js/data.min.js +0 -20
  173. package/build/js/i18n/types.js +0 -0
  174. package/build/js/intlTelInput.d.ts +0 -671
  175. package/build/js/intlTelInput.min.js +0 -38
  176. package/build/js/intlTelInputWithUtils.min.js +0 -38
  177. package/index.js +0 -1
  178. package/react/build/IntlTelInput.d.ts +0 -721
  179. package/svelte/build/IntlTelInput.mjs +0 -5294
  180. package/svelte/build/IntlTelInputWithUtils.mjs +0 -11381
  181. package/vue/build/IntlTelInput.vue.d.ts +0 -34
  182. package/vue/build/IntlTelInputWithUtils.vue.d.ts +0 -34
  183. package/vue/build/exports/IntlTelInput.d.ts +0 -3
  184. package/vue/build/exports/IntlTelInput.mjs +0 -86
  185. package/vue/build/exports/IntlTelInputWithUtils.d.ts +0 -3
  186. package/vue/build/exports/IntlTelInputWithUtils.mjs +0 -6173
  187. package/vue/build/intl-tel-input/data.d.ts +0 -20
  188. package/vue/build/intl-tel-input/i18n/ar/index.d.ts +0 -3
  189. package/vue/build/intl-tel-input/i18n/bg/index.d.ts +0 -3
  190. package/vue/build/intl-tel-input/i18n/bn/index.d.ts +0 -3
  191. package/vue/build/intl-tel-input/i18n/bs/index.d.ts +0 -3
  192. package/vue/build/intl-tel-input/i18n/ca/index.d.ts +0 -3
  193. package/vue/build/intl-tel-input/i18n/cs/index.d.ts +0 -3
  194. package/vue/build/intl-tel-input/i18n/da/index.d.ts +0 -3
  195. package/vue/build/intl-tel-input/i18n/de/index.d.ts +0 -3
  196. package/vue/build/intl-tel-input/i18n/el/index.d.ts +0 -3
  197. package/vue/build/intl-tel-input/i18n/en/index.d.ts +0 -3
  198. package/vue/build/intl-tel-input/i18n/es/index.d.ts +0 -3
  199. package/vue/build/intl-tel-input/i18n/et/index.d.ts +0 -3
  200. package/vue/build/intl-tel-input/i18n/fa/index.d.ts +0 -3
  201. package/vue/build/intl-tel-input/i18n/fi/index.d.ts +0 -3
  202. package/vue/build/intl-tel-input/i18n/fr/index.d.ts +0 -3
  203. package/vue/build/intl-tel-input/i18n/hi/index.d.ts +0 -3
  204. package/vue/build/intl-tel-input/i18n/hr/index.d.ts +0 -3
  205. package/vue/build/intl-tel-input/i18n/hu/index.d.ts +0 -3
  206. package/vue/build/intl-tel-input/i18n/id/index.d.ts +0 -3
  207. package/vue/build/intl-tel-input/i18n/index.d.ts +0 -45
  208. package/vue/build/intl-tel-input/i18n/it/index.d.ts +0 -3
  209. package/vue/build/intl-tel-input/i18n/ja/index.d.ts +0 -3
  210. package/vue/build/intl-tel-input/i18n/kn/index.d.ts +0 -3
  211. package/vue/build/intl-tel-input/i18n/ko/index.d.ts +0 -3
  212. package/vue/build/intl-tel-input/i18n/lt/index.d.ts +0 -3
  213. package/vue/build/intl-tel-input/i18n/mr/index.d.ts +0 -3
  214. package/vue/build/intl-tel-input/i18n/nl/index.d.ts +0 -3
  215. package/vue/build/intl-tel-input/i18n/no/index.d.ts +0 -3
  216. package/vue/build/intl-tel-input/i18n/pl/index.d.ts +0 -3
  217. package/vue/build/intl-tel-input/i18n/pt/index.d.ts +0 -3
  218. package/vue/build/intl-tel-input/i18n/ro/index.d.ts +0 -3
  219. package/vue/build/intl-tel-input/i18n/ru/index.d.ts +0 -3
  220. package/vue/build/intl-tel-input/i18n/sk/index.d.ts +0 -3
  221. package/vue/build/intl-tel-input/i18n/sl/index.d.ts +0 -3
  222. package/vue/build/intl-tel-input/i18n/sq/index.d.ts +0 -3
  223. package/vue/build/intl-tel-input/i18n/sr/index.d.ts +0 -3
  224. package/vue/build/intl-tel-input/i18n/sv/index.d.ts +0 -3
  225. package/vue/build/intl-tel-input/i18n/te/index.d.ts +0 -3
  226. package/vue/build/intl-tel-input/i18n/th/index.d.ts +0 -3
  227. package/vue/build/intl-tel-input/i18n/tr/index.d.ts +0 -3
  228. package/vue/build/intl-tel-input/i18n/types.d.ts +0 -10
  229. package/vue/build/intl-tel-input/i18n/uk/index.d.ts +0 -3
  230. package/vue/build/intl-tel-input/i18n/ur/index.d.ts +0 -3
  231. package/vue/build/intl-tel-input/i18n/uz/index.d.ts +0 -3
  232. package/vue/build/intl-tel-input/i18n/vi/index.d.ts +0 -3
  233. package/vue/build/intl-tel-input/i18n/zh/index.d.ts +0 -3
  234. package/vue/build/intl-tel-input/i18n/zh-hk/index.d.ts +0 -3
  235. package/vue/build/intl-tel-input/intlTelInputWithUtils.d.ts +0 -2
  236. package/vue/build/intl-tel-input-MeSkUgHd.mjs +0 -3438
  237. package/vue/build/intl-tel-input.d.ts +0 -46
  238. package/vue/build/modules/constants.d.ts +0 -94
  239. package/vue/build/modules/core/countrySearch.d.ts +0 -17
  240. package/vue/build/modules/core/icons.d.ts +0 -11
  241. package/vue/build/modules/core/numerals.d.ts +0 -7
  242. package/vue/build/modules/core/options.d.ts +0 -8
  243. package/vue/build/modules/core/ui.d.ts +0 -30
  244. package/vue/build/modules/data/country-data.d.ts +0 -12
  245. package/vue/build/modules/data/intl-regionless.d.ts +0 -2
  246. package/vue/build/modules/data/nanp-regionless.d.ts +0 -2
  247. package/vue/build/modules/format/caret.d.ts +0 -1
  248. package/vue/build/modules/format/formatting.d.ts +0 -3
  249. package/vue/build/modules/types/events.d.ts +0 -10
  250. package/vue/build/modules/types/forEachInstanceArgsMap.d.ts +0 -6
  251. package/vue/build/modules/types/public-api.d.ts +0 -65
  252. package/vue/build/modules/utils/dom.d.ts +0 -6
  253. package/vue/build/modules/utils/isAndroid.d.ts +0 -1
  254. package/vue/build/modules/utils/string.d.ts +0 -2
@@ -0,0 +1,4929 @@
1
+ // dist/js/intlTelInput.mjs
2
+ var rawCountryData = [
3
+ [
4
+ "af",
5
+ // Afghanistan
6
+ "93",
7
+ 0,
8
+ null,
9
+ "0"
10
+ ],
11
+ [
12
+ "ax",
13
+ // Åland Islands
14
+ "358",
15
+ 1,
16
+ ["18", "4"],
17
+ // (4 is a mobile range shared with FI)
18
+ "0"
19
+ ],
20
+ [
21
+ "al",
22
+ // Albania
23
+ "355",
24
+ 0,
25
+ null,
26
+ "0"
27
+ ],
28
+ [
29
+ "dz",
30
+ // Algeria
31
+ "213",
32
+ 0,
33
+ null,
34
+ "0"
35
+ ],
36
+ [
37
+ "as",
38
+ // American Samoa
39
+ "1",
40
+ 5,
41
+ ["684"],
42
+ "1"
43
+ ],
44
+ [
45
+ "ad",
46
+ // Andorra
47
+ "376"
48
+ ],
49
+ [
50
+ "ao",
51
+ // Angola
52
+ "244"
53
+ ],
54
+ [
55
+ "ai",
56
+ // Anguilla
57
+ "1",
58
+ 6,
59
+ ["264"],
60
+ "1"
61
+ ],
62
+ [
63
+ "ag",
64
+ // Antigua and Barbuda
65
+ "1",
66
+ 7,
67
+ ["268"],
68
+ "1"
69
+ ],
70
+ [
71
+ "ar",
72
+ // Argentina
73
+ "54",
74
+ 0,
75
+ null,
76
+ "0"
77
+ ],
78
+ [
79
+ "am",
80
+ // Armenia
81
+ "374",
82
+ 0,
83
+ null,
84
+ "0"
85
+ ],
86
+ [
87
+ "aw",
88
+ // Aruba
89
+ "297"
90
+ ],
91
+ [
92
+ "ac",
93
+ // Ascension Island
94
+ "247"
95
+ ],
96
+ [
97
+ "au",
98
+ // Australia
99
+ "61",
100
+ 0,
101
+ ["4"],
102
+ // (mobile range shared with CX and CC)
103
+ "0"
104
+ ],
105
+ [
106
+ "at",
107
+ // Austria
108
+ "43",
109
+ 0,
110
+ null,
111
+ "0"
112
+ ],
113
+ [
114
+ "az",
115
+ // Azerbaijan
116
+ "994",
117
+ 0,
118
+ null,
119
+ "0"
120
+ ],
121
+ [
122
+ "bs",
123
+ // Bahamas
124
+ "1",
125
+ 8,
126
+ ["242"],
127
+ "1"
128
+ ],
129
+ [
130
+ "bh",
131
+ // Bahrain
132
+ "973"
133
+ ],
134
+ [
135
+ "bd",
136
+ // Bangladesh
137
+ "880",
138
+ 0,
139
+ null,
140
+ "0"
141
+ ],
142
+ [
143
+ "bb",
144
+ // Barbados
145
+ "1",
146
+ 9,
147
+ ["246"],
148
+ "1"
149
+ ],
150
+ [
151
+ "by",
152
+ // Belarus
153
+ "375",
154
+ 0,
155
+ null,
156
+ "8"
157
+ ],
158
+ [
159
+ "be",
160
+ // Belgium
161
+ "32",
162
+ 0,
163
+ null,
164
+ "0"
165
+ ],
166
+ [
167
+ "bz",
168
+ // Belize
169
+ "501"
170
+ ],
171
+ [
172
+ "bj",
173
+ // Benin
174
+ "229"
175
+ ],
176
+ [
177
+ "bm",
178
+ // Bermuda
179
+ "1",
180
+ 10,
181
+ ["441"],
182
+ "1"
183
+ ],
184
+ [
185
+ "bt",
186
+ // Bhutan
187
+ "975"
188
+ ],
189
+ [
190
+ "bo",
191
+ // Bolivia
192
+ "591",
193
+ 0,
194
+ null,
195
+ "0"
196
+ ],
197
+ [
198
+ "ba",
199
+ // Bosnia and Herzegovina
200
+ "387",
201
+ 0,
202
+ null,
203
+ "0"
204
+ ],
205
+ [
206
+ "bw",
207
+ // Botswana
208
+ "267"
209
+ ],
210
+ [
211
+ "br",
212
+ // Brazil
213
+ "55",
214
+ 0,
215
+ null,
216
+ "0"
217
+ ],
218
+ [
219
+ "io",
220
+ // British Indian Ocean Territory
221
+ "246"
222
+ ],
223
+ [
224
+ "vg",
225
+ // British Virgin Islands
226
+ "1",
227
+ 11,
228
+ ["284"],
229
+ "1"
230
+ ],
231
+ [
232
+ "bn",
233
+ // Brunei
234
+ "673"
235
+ ],
236
+ [
237
+ "bg",
238
+ // Bulgaria
239
+ "359",
240
+ 0,
241
+ null,
242
+ "0"
243
+ ],
244
+ [
245
+ "bf",
246
+ // Burkina Faso
247
+ "226"
248
+ ],
249
+ [
250
+ "bi",
251
+ // Burundi
252
+ "257"
253
+ ],
254
+ [
255
+ "kh",
256
+ // Cambodia
257
+ "855",
258
+ 0,
259
+ null,
260
+ "0"
261
+ ],
262
+ [
263
+ "cm",
264
+ // Cameroon
265
+ "237"
266
+ ],
267
+ [
268
+ "ca",
269
+ // Canada
270
+ "1",
271
+ 1,
272
+ [
273
+ "204",
274
+ "226",
275
+ "236",
276
+ "249",
277
+ "250",
278
+ "257",
279
+ "263",
280
+ "289",
281
+ "306",
282
+ "343",
283
+ "354",
284
+ "365",
285
+ "367",
286
+ "368",
287
+ "382",
288
+ "403",
289
+ "416",
290
+ "418",
291
+ "428",
292
+ "431",
293
+ "437",
294
+ "438",
295
+ "450",
296
+ "468",
297
+ "474",
298
+ "506",
299
+ "514",
300
+ "519",
301
+ "548",
302
+ "579",
303
+ "581",
304
+ "584",
305
+ "587",
306
+ "604",
307
+ "613",
308
+ "639",
309
+ "647",
310
+ "672",
311
+ "683",
312
+ "705",
313
+ "709",
314
+ "742",
315
+ "753",
316
+ "778",
317
+ "780",
318
+ "782",
319
+ "807",
320
+ "819",
321
+ "825",
322
+ "867",
323
+ "873",
324
+ "879",
325
+ "902",
326
+ "905",
327
+ "942"
328
+ ],
329
+ "1"
330
+ ],
331
+ [
332
+ "cv",
333
+ // Cape Verde
334
+ "238"
335
+ ],
336
+ [
337
+ "bq",
338
+ // Caribbean Netherlands
339
+ "599",
340
+ 1,
341
+ ["3", "4", "7"]
342
+ ],
343
+ [
344
+ "ky",
345
+ // Cayman Islands
346
+ "1",
347
+ 12,
348
+ ["345"],
349
+ "1"
350
+ ],
351
+ [
352
+ "cf",
353
+ // Central African Republic
354
+ "236"
355
+ ],
356
+ [
357
+ "td",
358
+ // Chad
359
+ "235"
360
+ ],
361
+ [
362
+ "cl",
363
+ // Chile
364
+ "56"
365
+ ],
366
+ [
367
+ "cn",
368
+ // China
369
+ "86",
370
+ 0,
371
+ null,
372
+ "0"
373
+ ],
374
+ [
375
+ "cx",
376
+ // Christmas Island
377
+ "61",
378
+ 2,
379
+ ["4", "89164"],
380
+ // (4 is a mobile range shared with AU and CC)
381
+ "0"
382
+ ],
383
+ [
384
+ "cc",
385
+ // Cocos (Keeling) Islands
386
+ "61",
387
+ 1,
388
+ ["4", "89162"],
389
+ // (4 is a mobile range shared with AU and CX)
390
+ "0"
391
+ ],
392
+ [
393
+ "co",
394
+ // Colombia
395
+ "57",
396
+ 0,
397
+ null,
398
+ "0"
399
+ ],
400
+ [
401
+ "km",
402
+ // Comoros
403
+ "269"
404
+ ],
405
+ [
406
+ "cg",
407
+ // Congo (Brazzaville)
408
+ "242"
409
+ ],
410
+ [
411
+ "cd",
412
+ // Congo (Kinshasa)
413
+ "243",
414
+ 0,
415
+ null,
416
+ "0"
417
+ ],
418
+ [
419
+ "ck",
420
+ // Cook Islands
421
+ "682"
422
+ ],
423
+ [
424
+ "cr",
425
+ // Costa Rica
426
+ "506"
427
+ ],
428
+ [
429
+ "ci",
430
+ // Côte d'Ivoire
431
+ "225"
432
+ ],
433
+ [
434
+ "hr",
435
+ // Croatia
436
+ "385",
437
+ 0,
438
+ null,
439
+ "0"
440
+ ],
441
+ [
442
+ "cu",
443
+ // Cuba
444
+ "53",
445
+ 0,
446
+ null,
447
+ "0"
448
+ ],
449
+ [
450
+ "cw",
451
+ // Curaçao
452
+ "599",
453
+ 0
454
+ ],
455
+ [
456
+ "cy",
457
+ // Cyprus
458
+ "357"
459
+ ],
460
+ [
461
+ "cz",
462
+ // Czech Republic
463
+ "420"
464
+ ],
465
+ [
466
+ "dk",
467
+ // Denmark
468
+ "45"
469
+ ],
470
+ [
471
+ "dj",
472
+ // Djibouti
473
+ "253"
474
+ ],
475
+ [
476
+ "dm",
477
+ // Dominica
478
+ "1",
479
+ 13,
480
+ ["767"],
481
+ "1"
482
+ ],
483
+ [
484
+ "do",
485
+ // Dominican Republic
486
+ "1",
487
+ 2,
488
+ ["809", "829", "849"],
489
+ "1"
490
+ ],
491
+ [
492
+ "ec",
493
+ // Ecuador
494
+ "593",
495
+ 0,
496
+ null,
497
+ "0"
498
+ ],
499
+ [
500
+ "eg",
501
+ // Egypt
502
+ "20",
503
+ 0,
504
+ null,
505
+ "0"
506
+ ],
507
+ [
508
+ "sv",
509
+ // El Salvador
510
+ "503"
511
+ ],
512
+ [
513
+ "gq",
514
+ // Equatorial Guinea
515
+ "240"
516
+ ],
517
+ [
518
+ "er",
519
+ // Eritrea
520
+ "291",
521
+ 0,
522
+ null,
523
+ "0"
524
+ ],
525
+ [
526
+ "ee",
527
+ // Estonia
528
+ "372"
529
+ ],
530
+ [
531
+ "sz",
532
+ // Eswatini
533
+ "268"
534
+ ],
535
+ [
536
+ "et",
537
+ // Ethiopia
538
+ "251",
539
+ 0,
540
+ null,
541
+ "0"
542
+ ],
543
+ [
544
+ "fk",
545
+ // Falkland Islands (Malvinas)
546
+ "500"
547
+ ],
548
+ [
549
+ "fo",
550
+ // Faroe Islands
551
+ "298"
552
+ ],
553
+ [
554
+ "fj",
555
+ // Fiji
556
+ "679"
557
+ ],
558
+ [
559
+ "fi",
560
+ // Finland
561
+ "358",
562
+ 0,
563
+ ["4"],
564
+ // (mobile range shared with AX)
565
+ "0"
566
+ ],
567
+ [
568
+ "fr",
569
+ // France
570
+ "33",
571
+ 0,
572
+ null,
573
+ "0"
574
+ ],
575
+ [
576
+ "gf",
577
+ // French Guiana
578
+ "594",
579
+ 0,
580
+ null,
581
+ "0"
582
+ ],
583
+ [
584
+ "pf",
585
+ // French Polynesia
586
+ "689"
587
+ ],
588
+ [
589
+ "ga",
590
+ // Gabon
591
+ "241"
592
+ ],
593
+ [
594
+ "gm",
595
+ // Gambia
596
+ "220"
597
+ ],
598
+ [
599
+ "ge",
600
+ // Georgia
601
+ "995",
602
+ 0,
603
+ null,
604
+ "0"
605
+ ],
606
+ [
607
+ "de",
608
+ // Germany
609
+ "49",
610
+ 0,
611
+ null,
612
+ "0"
613
+ ],
614
+ [
615
+ "gh",
616
+ // Ghana
617
+ "233",
618
+ 0,
619
+ null,
620
+ "0"
621
+ ],
622
+ [
623
+ "gi",
624
+ // Gibraltar
625
+ "350"
626
+ ],
627
+ [
628
+ "gr",
629
+ // Greece
630
+ "30"
631
+ ],
632
+ [
633
+ "gl",
634
+ // Greenland
635
+ "299"
636
+ ],
637
+ [
638
+ "gd",
639
+ // Grenada
640
+ "1",
641
+ 14,
642
+ ["473"],
643
+ "1"
644
+ ],
645
+ [
646
+ "gp",
647
+ // Guadeloupe
648
+ "590",
649
+ 0,
650
+ null,
651
+ "0"
652
+ ],
653
+ [
654
+ "gu",
655
+ // Guam
656
+ "1",
657
+ 15,
658
+ ["671"],
659
+ "1"
660
+ ],
661
+ [
662
+ "gt",
663
+ // Guatemala
664
+ "502"
665
+ ],
666
+ [
667
+ "gg",
668
+ // Guernsey
669
+ "44",
670
+ 1,
671
+ ["1481", "7781", "7839", "7911"],
672
+ "0"
673
+ ],
674
+ [
675
+ "gn",
676
+ // Guinea
677
+ "224"
678
+ ],
679
+ [
680
+ "gw",
681
+ // Guinea-Bissau
682
+ "245"
683
+ ],
684
+ [
685
+ "gy",
686
+ // Guyana
687
+ "592"
688
+ ],
689
+ [
690
+ "ht",
691
+ // Haiti
692
+ "509"
693
+ ],
694
+ [
695
+ "hn",
696
+ // Honduras
697
+ "504"
698
+ ],
699
+ [
700
+ "hk",
701
+ // Hong Kong SAR China
702
+ "852"
703
+ ],
704
+ [
705
+ "hu",
706
+ // Hungary
707
+ "36",
708
+ 0,
709
+ null,
710
+ "06"
711
+ ],
712
+ [
713
+ "is",
714
+ // Iceland
715
+ "354"
716
+ ],
717
+ [
718
+ "in",
719
+ // India
720
+ "91",
721
+ 0,
722
+ null,
723
+ "0"
724
+ ],
725
+ [
726
+ "id",
727
+ // Indonesia
728
+ "62",
729
+ 0,
730
+ null,
731
+ "0"
732
+ ],
733
+ [
734
+ "ir",
735
+ // Iran
736
+ "98",
737
+ 0,
738
+ null,
739
+ "0"
740
+ ],
741
+ [
742
+ "iq",
743
+ // Iraq
744
+ "964",
745
+ 0,
746
+ null,
747
+ "0"
748
+ ],
749
+ [
750
+ "ie",
751
+ // Ireland
752
+ "353",
753
+ 0,
754
+ null,
755
+ "0"
756
+ ],
757
+ [
758
+ "im",
759
+ // Isle of Man
760
+ "44",
761
+ 2,
762
+ ["1624", "74576", "7524", "7624", "7924"],
763
+ "0"
764
+ ],
765
+ [
766
+ "il",
767
+ // Israel
768
+ "972",
769
+ 0,
770
+ null,
771
+ "0"
772
+ ],
773
+ [
774
+ "it",
775
+ // Italy
776
+ "39",
777
+ 0,
778
+ ["3"]
779
+ // (mobile range shared with VA)
780
+ ],
781
+ [
782
+ "jm",
783
+ // Jamaica
784
+ "1",
785
+ 4,
786
+ ["658", "876"],
787
+ "1"
788
+ ],
789
+ [
790
+ "jp",
791
+ // Japan
792
+ "81",
793
+ 0,
794
+ null,
795
+ "0"
796
+ ],
797
+ [
798
+ "je",
799
+ // Jersey
800
+ "44",
801
+ 3,
802
+ ["1534", "7509", "7700", "7797", "7829", "7937"],
803
+ "0"
804
+ ],
805
+ [
806
+ "jo",
807
+ // Jordan
808
+ "962",
809
+ 0,
810
+ null,
811
+ "0"
812
+ ],
813
+ [
814
+ "kz",
815
+ // Kazakhstan
816
+ "7",
817
+ 1,
818
+ ["33", "7"],
819
+ // (33 is shared with RU)
820
+ "8"
821
+ ],
822
+ [
823
+ "ke",
824
+ // Kenya
825
+ "254",
826
+ 0,
827
+ null,
828
+ "0"
829
+ ],
830
+ [
831
+ "ki",
832
+ // Kiribati
833
+ "686",
834
+ 0,
835
+ null,
836
+ "0"
837
+ ],
838
+ [
839
+ "xk",
840
+ // Kosovo
841
+ "383",
842
+ 0,
843
+ null,
844
+ "0"
845
+ ],
846
+ [
847
+ "kw",
848
+ // Kuwait
849
+ "965"
850
+ ],
851
+ [
852
+ "kg",
853
+ // Kyrgyzstan
854
+ "996",
855
+ 0,
856
+ null,
857
+ "0"
858
+ ],
859
+ [
860
+ "la",
861
+ // Laos
862
+ "856",
863
+ 0,
864
+ null,
865
+ "0"
866
+ ],
867
+ [
868
+ "lv",
869
+ // Latvia
870
+ "371"
871
+ ],
872
+ [
873
+ "lb",
874
+ // Lebanon
875
+ "961",
876
+ 0,
877
+ null,
878
+ "0"
879
+ ],
880
+ [
881
+ "ls",
882
+ // Lesotho
883
+ "266"
884
+ ],
885
+ [
886
+ "lr",
887
+ // Liberia
888
+ "231",
889
+ 0,
890
+ null,
891
+ "0"
892
+ ],
893
+ [
894
+ "ly",
895
+ // Libya
896
+ "218",
897
+ 0,
898
+ null,
899
+ "0"
900
+ ],
901
+ [
902
+ "li",
903
+ // Liechtenstein
904
+ "423",
905
+ 0,
906
+ null,
907
+ "0"
908
+ ],
909
+ [
910
+ "lt",
911
+ // Lithuania
912
+ "370",
913
+ 0,
914
+ null,
915
+ "0"
916
+ ],
917
+ [
918
+ "lu",
919
+ // Luxembourg
920
+ "352"
921
+ ],
922
+ [
923
+ "mo",
924
+ // Macao SAR China
925
+ "853"
926
+ ],
927
+ [
928
+ "mg",
929
+ // Madagascar
930
+ "261",
931
+ 0,
932
+ null,
933
+ "0"
934
+ ],
935
+ [
936
+ "mw",
937
+ // Malawi
938
+ "265",
939
+ 0,
940
+ null,
941
+ "0"
942
+ ],
943
+ [
944
+ "my",
945
+ // Malaysia
946
+ "60",
947
+ 0,
948
+ null,
949
+ "0"
950
+ ],
951
+ [
952
+ "mv",
953
+ // Maldives
954
+ "960"
955
+ ],
956
+ [
957
+ "ml",
958
+ // Mali
959
+ "223"
960
+ ],
961
+ [
962
+ "mt",
963
+ // Malta
964
+ "356"
965
+ ],
966
+ [
967
+ "mh",
968
+ // Marshall Islands
969
+ "692",
970
+ 0,
971
+ null,
972
+ "1"
973
+ ],
974
+ [
975
+ "mq",
976
+ // Martinique
977
+ "596",
978
+ 0,
979
+ null,
980
+ "0"
981
+ ],
982
+ [
983
+ "mr",
984
+ // Mauritania
985
+ "222"
986
+ ],
987
+ [
988
+ "mu",
989
+ // Mauritius
990
+ "230"
991
+ ],
992
+ [
993
+ "yt",
994
+ // Mayotte
995
+ "262",
996
+ 1,
997
+ ["269", "639"],
998
+ "0"
999
+ ],
1000
+ [
1001
+ "mx",
1002
+ // Mexico
1003
+ "52"
1004
+ ],
1005
+ [
1006
+ "fm",
1007
+ // Micronesia
1008
+ "691"
1009
+ ],
1010
+ [
1011
+ "md",
1012
+ // Moldova
1013
+ "373",
1014
+ 0,
1015
+ null,
1016
+ "0"
1017
+ ],
1018
+ [
1019
+ "mc",
1020
+ // Monaco
1021
+ "377",
1022
+ 0,
1023
+ null,
1024
+ "0"
1025
+ ],
1026
+ [
1027
+ "mn",
1028
+ // Mongolia
1029
+ "976",
1030
+ 0,
1031
+ null,
1032
+ "0"
1033
+ ],
1034
+ [
1035
+ "me",
1036
+ // Montenegro
1037
+ "382",
1038
+ 0,
1039
+ null,
1040
+ "0"
1041
+ ],
1042
+ [
1043
+ "ms",
1044
+ // Montserrat
1045
+ "1",
1046
+ 16,
1047
+ ["664"],
1048
+ "1"
1049
+ ],
1050
+ [
1051
+ "ma",
1052
+ // Morocco
1053
+ "212",
1054
+ 0,
1055
+ ["6", "7"],
1056
+ // (mobile ranges shared with EH)
1057
+ "0"
1058
+ ],
1059
+ [
1060
+ "mz",
1061
+ // Mozambique
1062
+ "258"
1063
+ ],
1064
+ [
1065
+ "mm",
1066
+ // Myanmar (Burma)
1067
+ "95",
1068
+ 0,
1069
+ null,
1070
+ "0"
1071
+ ],
1072
+ [
1073
+ "na",
1074
+ // Namibia
1075
+ "264",
1076
+ 0,
1077
+ null,
1078
+ "0"
1079
+ ],
1080
+ [
1081
+ "nr",
1082
+ // Nauru
1083
+ "674"
1084
+ ],
1085
+ [
1086
+ "np",
1087
+ // Nepal
1088
+ "977",
1089
+ 0,
1090
+ null,
1091
+ "0"
1092
+ ],
1093
+ [
1094
+ "nl",
1095
+ // Netherlands
1096
+ "31",
1097
+ 0,
1098
+ null,
1099
+ "0"
1100
+ ],
1101
+ [
1102
+ "nc",
1103
+ // New Caledonia
1104
+ "687"
1105
+ ],
1106
+ [
1107
+ "nz",
1108
+ // New Zealand
1109
+ "64",
1110
+ 0,
1111
+ null,
1112
+ "0"
1113
+ ],
1114
+ [
1115
+ "ni",
1116
+ // Nicaragua
1117
+ "505"
1118
+ ],
1119
+ [
1120
+ "ne",
1121
+ // Niger
1122
+ "227"
1123
+ ],
1124
+ [
1125
+ "ng",
1126
+ // Nigeria
1127
+ "234",
1128
+ 0,
1129
+ null,
1130
+ "0"
1131
+ ],
1132
+ [
1133
+ "nu",
1134
+ // Niue
1135
+ "683"
1136
+ ],
1137
+ [
1138
+ "nf",
1139
+ // Norfolk Island
1140
+ "672"
1141
+ ],
1142
+ [
1143
+ "kp",
1144
+ // North Korea
1145
+ "850",
1146
+ 0,
1147
+ null,
1148
+ "0"
1149
+ ],
1150
+ [
1151
+ "mk",
1152
+ // North Macedonia
1153
+ "389",
1154
+ 0,
1155
+ null,
1156
+ "0"
1157
+ ],
1158
+ [
1159
+ "mp",
1160
+ // Northern Mariana Islands
1161
+ "1",
1162
+ 17,
1163
+ ["670"],
1164
+ "1"
1165
+ ],
1166
+ [
1167
+ "no",
1168
+ // Norway
1169
+ "47",
1170
+ 0,
1171
+ ["4", "9"]
1172
+ // (mobile ranges shared with SJ)
1173
+ ],
1174
+ [
1175
+ "om",
1176
+ // Oman
1177
+ "968"
1178
+ ],
1179
+ [
1180
+ "pk",
1181
+ // Pakistan
1182
+ "92",
1183
+ 0,
1184
+ null,
1185
+ "0"
1186
+ ],
1187
+ [
1188
+ "pw",
1189
+ // Palau
1190
+ "680"
1191
+ ],
1192
+ [
1193
+ "ps",
1194
+ // Palestinian Territories
1195
+ "970",
1196
+ 0,
1197
+ null,
1198
+ "0"
1199
+ ],
1200
+ [
1201
+ "pa",
1202
+ // Panama
1203
+ "507"
1204
+ ],
1205
+ [
1206
+ "pg",
1207
+ // Papua New Guinea
1208
+ "675"
1209
+ ],
1210
+ [
1211
+ "py",
1212
+ // Paraguay
1213
+ "595",
1214
+ 0,
1215
+ null,
1216
+ "0"
1217
+ ],
1218
+ [
1219
+ "pe",
1220
+ // Peru
1221
+ "51",
1222
+ 0,
1223
+ null,
1224
+ "0"
1225
+ ],
1226
+ [
1227
+ "ph",
1228
+ // Philippines
1229
+ "63",
1230
+ 0,
1231
+ null,
1232
+ "0"
1233
+ ],
1234
+ [
1235
+ "pl",
1236
+ // Poland
1237
+ "48"
1238
+ ],
1239
+ [
1240
+ "pt",
1241
+ // Portugal
1242
+ "351"
1243
+ ],
1244
+ [
1245
+ "pr",
1246
+ // Puerto Rico
1247
+ "1",
1248
+ 3,
1249
+ ["787", "939"],
1250
+ "1"
1251
+ ],
1252
+ [
1253
+ "qa",
1254
+ // Qatar
1255
+ "974"
1256
+ ],
1257
+ [
1258
+ "re",
1259
+ // Réunion
1260
+ "262",
1261
+ 0,
1262
+ null,
1263
+ "0"
1264
+ ],
1265
+ [
1266
+ "ro",
1267
+ // Romania
1268
+ "40",
1269
+ 0,
1270
+ null,
1271
+ "0"
1272
+ ],
1273
+ [
1274
+ "ru",
1275
+ // Russia
1276
+ "7",
1277
+ 0,
1278
+ ["33"],
1279
+ // (shared with KZ)
1280
+ "8"
1281
+ ],
1282
+ [
1283
+ "rw",
1284
+ // Rwanda
1285
+ "250",
1286
+ 0,
1287
+ null,
1288
+ "0"
1289
+ ],
1290
+ [
1291
+ "ws",
1292
+ // Samoa
1293
+ "685"
1294
+ ],
1295
+ [
1296
+ "sm",
1297
+ // San Marino
1298
+ "378"
1299
+ ],
1300
+ [
1301
+ "st",
1302
+ // São Tomé & Príncipe
1303
+ "239"
1304
+ ],
1305
+ [
1306
+ "sa",
1307
+ // Saudi Arabia
1308
+ "966",
1309
+ 0,
1310
+ null,
1311
+ "0"
1312
+ ],
1313
+ [
1314
+ "sn",
1315
+ // Senegal
1316
+ "221"
1317
+ ],
1318
+ [
1319
+ "rs",
1320
+ // Serbia
1321
+ "381",
1322
+ 0,
1323
+ null,
1324
+ "0"
1325
+ ],
1326
+ [
1327
+ "sc",
1328
+ // Seychelles
1329
+ "248"
1330
+ ],
1331
+ [
1332
+ "sl",
1333
+ // Sierra Leone
1334
+ "232",
1335
+ 0,
1336
+ null,
1337
+ "0"
1338
+ ],
1339
+ [
1340
+ "sg",
1341
+ // Singapore
1342
+ "65"
1343
+ ],
1344
+ [
1345
+ "sx",
1346
+ // Sint Maarten
1347
+ "1",
1348
+ 21,
1349
+ ["721"],
1350
+ "1"
1351
+ ],
1352
+ [
1353
+ "sk",
1354
+ // Slovakia
1355
+ "421",
1356
+ 0,
1357
+ null,
1358
+ "0"
1359
+ ],
1360
+ [
1361
+ "si",
1362
+ // Slovenia
1363
+ "386",
1364
+ 0,
1365
+ null,
1366
+ "0"
1367
+ ],
1368
+ [
1369
+ "sb",
1370
+ // Solomon Islands
1371
+ "677"
1372
+ ],
1373
+ [
1374
+ "so",
1375
+ // Somalia
1376
+ "252",
1377
+ 0,
1378
+ null,
1379
+ "0"
1380
+ ],
1381
+ [
1382
+ "za",
1383
+ // South Africa
1384
+ "27",
1385
+ 0,
1386
+ null,
1387
+ "0"
1388
+ ],
1389
+ [
1390
+ "kr",
1391
+ // South Korea
1392
+ "82",
1393
+ 0,
1394
+ null,
1395
+ "0"
1396
+ ],
1397
+ [
1398
+ "ss",
1399
+ // South Sudan
1400
+ "211",
1401
+ 0,
1402
+ null,
1403
+ "0"
1404
+ ],
1405
+ [
1406
+ "es",
1407
+ // Spain
1408
+ "34"
1409
+ ],
1410
+ [
1411
+ "lk",
1412
+ // Sri Lanka
1413
+ "94",
1414
+ 0,
1415
+ null,
1416
+ "0"
1417
+ ],
1418
+ [
1419
+ "bl",
1420
+ // St. Barthélemy
1421
+ "590",
1422
+ 1,
1423
+ null,
1424
+ "0"
1425
+ ],
1426
+ [
1427
+ "sh",
1428
+ // St. Helena
1429
+ "290"
1430
+ ],
1431
+ [
1432
+ "kn",
1433
+ // St. Kitts & Nevis
1434
+ "1",
1435
+ 18,
1436
+ ["869"],
1437
+ "1"
1438
+ ],
1439
+ [
1440
+ "lc",
1441
+ // St. Lucia
1442
+ "1",
1443
+ 19,
1444
+ ["758"],
1445
+ "1"
1446
+ ],
1447
+ [
1448
+ "mf",
1449
+ // St. Martin
1450
+ "590",
1451
+ 2,
1452
+ null,
1453
+ "0"
1454
+ ],
1455
+ [
1456
+ "pm",
1457
+ // St. Pierre & Miquelon
1458
+ "508",
1459
+ 0,
1460
+ null,
1461
+ "0"
1462
+ ],
1463
+ [
1464
+ "vc",
1465
+ // St. Vincent & Grenadines
1466
+ "1",
1467
+ 20,
1468
+ ["784"],
1469
+ "1"
1470
+ ],
1471
+ [
1472
+ "sd",
1473
+ // Sudan
1474
+ "249",
1475
+ 0,
1476
+ null,
1477
+ "0"
1478
+ ],
1479
+ [
1480
+ "sr",
1481
+ // Suriname
1482
+ "597"
1483
+ ],
1484
+ [
1485
+ "sj",
1486
+ // Svalbard & Jan Mayen
1487
+ "47",
1488
+ 1,
1489
+ ["4", "79", "9"]
1490
+ // (4 and 9 are mobile ranges shared with NO)
1491
+ ],
1492
+ [
1493
+ "se",
1494
+ // Sweden
1495
+ "46",
1496
+ 0,
1497
+ null,
1498
+ "0"
1499
+ ],
1500
+ [
1501
+ "ch",
1502
+ // Switzerland
1503
+ "41",
1504
+ 0,
1505
+ null,
1506
+ "0"
1507
+ ],
1508
+ [
1509
+ "sy",
1510
+ // Syria
1511
+ "963",
1512
+ 0,
1513
+ null,
1514
+ "0"
1515
+ ],
1516
+ [
1517
+ "tw",
1518
+ // Taiwan
1519
+ "886",
1520
+ 0,
1521
+ null,
1522
+ "0"
1523
+ ],
1524
+ [
1525
+ "tj",
1526
+ // Tajikistan
1527
+ "992"
1528
+ ],
1529
+ [
1530
+ "tz",
1531
+ // Tanzania
1532
+ "255",
1533
+ 0,
1534
+ null,
1535
+ "0"
1536
+ ],
1537
+ [
1538
+ "th",
1539
+ // Thailand
1540
+ "66",
1541
+ 0,
1542
+ null,
1543
+ "0"
1544
+ ],
1545
+ [
1546
+ "tl",
1547
+ // Timor-Leste
1548
+ "670"
1549
+ ],
1550
+ [
1551
+ "tg",
1552
+ // Togo
1553
+ "228"
1554
+ ],
1555
+ [
1556
+ "tk",
1557
+ // Tokelau
1558
+ "690"
1559
+ ],
1560
+ [
1561
+ "to",
1562
+ // Tonga
1563
+ "676"
1564
+ ],
1565
+ [
1566
+ "tt",
1567
+ // Trinidad & Tobago
1568
+ "1",
1569
+ 22,
1570
+ ["868"],
1571
+ "1"
1572
+ ],
1573
+ [
1574
+ "tn",
1575
+ // Tunisia
1576
+ "216"
1577
+ ],
1578
+ [
1579
+ "tr",
1580
+ // Turkey
1581
+ "90",
1582
+ 0,
1583
+ null,
1584
+ "0"
1585
+ ],
1586
+ [
1587
+ "tm",
1588
+ // Turkmenistan
1589
+ "993",
1590
+ 0,
1591
+ null,
1592
+ "8"
1593
+ ],
1594
+ [
1595
+ "tc",
1596
+ // Turks & Caicos Islands
1597
+ "1",
1598
+ 23,
1599
+ ["649"],
1600
+ "1"
1601
+ ],
1602
+ [
1603
+ "tv",
1604
+ // Tuvalu
1605
+ "688"
1606
+ ],
1607
+ [
1608
+ "vi",
1609
+ // U.S. Virgin Islands
1610
+ "1",
1611
+ 24,
1612
+ ["340"],
1613
+ "1"
1614
+ ],
1615
+ [
1616
+ "ug",
1617
+ // Uganda
1618
+ "256",
1619
+ 0,
1620
+ null,
1621
+ "0"
1622
+ ],
1623
+ [
1624
+ "ua",
1625
+ // Ukraine
1626
+ "380",
1627
+ 0,
1628
+ null,
1629
+ "0"
1630
+ ],
1631
+ [
1632
+ "ae",
1633
+ // United Arab Emirates
1634
+ "971",
1635
+ 0,
1636
+ null,
1637
+ "0"
1638
+ ],
1639
+ [
1640
+ "gb",
1641
+ // United Kingdom
1642
+ "44",
1643
+ 0,
1644
+ null,
1645
+ "0"
1646
+ ],
1647
+ [
1648
+ "us",
1649
+ // United States
1650
+ "1",
1651
+ 0,
1652
+ null,
1653
+ "1"
1654
+ ],
1655
+ [
1656
+ "uy",
1657
+ // Uruguay
1658
+ "598",
1659
+ 0,
1660
+ null,
1661
+ "0"
1662
+ ],
1663
+ [
1664
+ "uz",
1665
+ // Uzbekistan
1666
+ "998"
1667
+ ],
1668
+ [
1669
+ "vu",
1670
+ // Vanuatu
1671
+ "678"
1672
+ ],
1673
+ [
1674
+ "va",
1675
+ // Vatican City
1676
+ "39",
1677
+ 1,
1678
+ ["06698", "3"]
1679
+ // (3 is a mobile range shared with IT)
1680
+ ],
1681
+ [
1682
+ "ve",
1683
+ // Venezuela
1684
+ "58",
1685
+ 0,
1686
+ null,
1687
+ "0"
1688
+ ],
1689
+ [
1690
+ "vn",
1691
+ // Vietnam
1692
+ "84",
1693
+ 0,
1694
+ null,
1695
+ "0"
1696
+ ],
1697
+ [
1698
+ "wf",
1699
+ // Wallis & Futuna
1700
+ "681"
1701
+ ],
1702
+ [
1703
+ "eh",
1704
+ // Western Sahara
1705
+ "212",
1706
+ 1,
1707
+ ["5288", "5289", "6", "7"],
1708
+ // (6 and 7 are mobile ranges shared with MA)
1709
+ "0"
1710
+ ],
1711
+ [
1712
+ "ye",
1713
+ // Yemen
1714
+ "967",
1715
+ 0,
1716
+ null,
1717
+ "0"
1718
+ ],
1719
+ [
1720
+ "zm",
1721
+ // Zambia
1722
+ "260",
1723
+ 0,
1724
+ null,
1725
+ "0"
1726
+ ],
1727
+ [
1728
+ "zw",
1729
+ // Zimbabwe
1730
+ "263",
1731
+ 0,
1732
+ null,
1733
+ "0"
1734
+ ]
1735
+ ];
1736
+ var allCountries = [];
1737
+ for (const c of rawCountryData) {
1738
+ allCountries.push({
1739
+ name: "",
1740
+ // populated in the plugin
1741
+ iso2: c[0],
1742
+ dialCode: c[1],
1743
+ priority: c[2] || 0,
1744
+ areaCodes: c[3] || null,
1745
+ nodeById: {},
1746
+ // populated by the plugin
1747
+ nationalPrefix: c[4] || null,
1748
+ normalisedName: "",
1749
+ // populated in the plugin
1750
+ initials: "",
1751
+ // populated in the plugin
1752
+ dialCodePlus: ""
1753
+ // populated in the plugin
1754
+ });
1755
+ }
1756
+ var iso2Set = new Set(allCountries.map((c) => c.iso2));
1757
+ var isIso2 = (val) => iso2Set.has(val);
1758
+ var data_default = allCountries;
1759
+ var EVENTS = {
1760
+ OPEN_COUNTRY_DROPDOWN: "open:countrydropdown",
1761
+ CLOSE_COUNTRY_DROPDOWN: "close:countrydropdown",
1762
+ COUNTRY_CHANGE: "countrychange",
1763
+ INPUT: "input"
1764
+ // used for synthetic input trigger
1765
+ };
1766
+ var CLASSES = {
1767
+ HIDE: "iti__hide",
1768
+ V_HIDE: "iti__v-hide",
1769
+ ARROW_UP: "iti__arrow--up",
1770
+ GLOBE: "iti__globe",
1771
+ FLAG: "iti__flag",
1772
+ LOADING: "iti__loading",
1773
+ COUNTRY_ITEM: "iti__country",
1774
+ HIGHLIGHT: "iti__highlight"
1775
+ };
1776
+ var KEYS = {
1777
+ ARROW_UP: "ArrowUp",
1778
+ ARROW_DOWN: "ArrowDown",
1779
+ SPACE: " ",
1780
+ ENTER: "Enter",
1781
+ ESC: "Escape",
1782
+ TAB: "Tab"
1783
+ };
1784
+ var INPUT_TYPES = {
1785
+ PASTE: "insertFromPaste",
1786
+ DELETE_FWD: "deleteContentForward"
1787
+ };
1788
+ var REGEX = {
1789
+ ALPHA_UNICODE: /\p{L}/u,
1790
+ // any kind of letter from any language
1791
+ NON_PLUS_NUMERIC: /[^+0-9]/,
1792
+ // chars that are NOT + or digit
1793
+ NON_PLUS_NUMERIC_GLOBAL: /[^+0-9]/g,
1794
+ // chars that are NOT + or digit (global)
1795
+ HIDDEN_SEARCH_CHAR: /^[a-zA-ZÀ-ÿа-яА-Я ]$/
1796
+ // single acceptable hidden-search char
1797
+ };
1798
+ var TIMINGS = {
1799
+ SEARCH_DEBOUNCE_MS: 100,
1800
+ HIDDEN_SEARCH_RESET_MS: 1e3,
1801
+ NEXT_TICK: 0
1802
+ };
1803
+ var SENTINELS = {
1804
+ UNKNOWN_NUMBER_TYPE: -99,
1805
+ UNKNOWN_VALIDATION_ERROR: -99
1806
+ };
1807
+ var LAYOUT = {
1808
+ NARROW_VIEWPORT_WIDTH: 500,
1809
+ // keep in sync with .iti__country-list CSS media query
1810
+ SANE_SELECTED_WITH_DIAL_WIDTH: 78,
1811
+ // px width fallback when separateDialCode enabled
1812
+ SANE_SELECTED_NO_DIAL_WIDTH: 42,
1813
+ // px width fallback when no separate dial code
1814
+ INPUT_PADDING_EXTRA_LEFT: 6,
1815
+ // px gap between selected country container and input text
1816
+ DROPDOWN_MARGIN: 3,
1817
+ // px margin between dropdown and tel input
1818
+ SANE_DROPDOWN_HEIGHT: 200
1819
+ // px height fallback for dropdown
1820
+ };
1821
+ var DIAL = {
1822
+ PLUS: "+",
1823
+ NANP: "1"
1824
+ // North American Numbering Plan
1825
+ };
1826
+ var UK = {
1827
+ ISO2: "gb",
1828
+ DIAL_CODE: "44",
1829
+ // +44 United Kingdom
1830
+ MOBILE_PREFIX: "7",
1831
+ // UK mobile numbers start with 7 after national trunk (0) or core section
1832
+ MOBILE_CORE_LENGTH: 10
1833
+ // core number length (excluding dial code / national prefix) for mobiles
1834
+ };
1835
+ var US = {
1836
+ ISO2: "us",
1837
+ DIAL_CODE: "1"
1838
+ // +1 United States
1839
+ };
1840
+ var PLACEHOLDER_MODES = {
1841
+ AGGRESSIVE: "aggressive",
1842
+ POLITE: "polite",
1843
+ OFF: "off"
1844
+ };
1845
+ var INITIAL_COUNTRY = {
1846
+ AUTO: "auto"
1847
+ };
1848
+ var NUMBER_TYPES = [
1849
+ "FIXED_LINE",
1850
+ "MOBILE",
1851
+ "FIXED_LINE_OR_MOBILE",
1852
+ "TOLL_FREE",
1853
+ "PREMIUM_RATE",
1854
+ "SHARED_COST",
1855
+ "VOIP",
1856
+ "PERSONAL_NUMBER",
1857
+ "PAGER",
1858
+ "UAN",
1859
+ "VOICEMAIL",
1860
+ "UNKNOWN"
1861
+ ];
1862
+ var NUMBER_TYPE_SET = new Set(NUMBER_TYPES);
1863
+ var DATA_KEYS = {
1864
+ COUNTRY_CODE: "countryCode",
1865
+ DIAL_CODE: "dialCode"
1866
+ };
1867
+ var ARIA = {
1868
+ EXPANDED: "aria-expanded",
1869
+ LABEL: "aria-label",
1870
+ SELECTED: "aria-selected",
1871
+ ACTIVE_DESCENDANT: "aria-activedescendant",
1872
+ HASPOPUP: "aria-haspopup",
1873
+ CONTROLS: "aria-controls",
1874
+ HIDDEN: "aria-hidden",
1875
+ AUTOCOMPLETE: "aria-autocomplete",
1876
+ MODAL: "aria-modal"
1877
+ };
1878
+ var interfaceTranslations = {
1879
+ selectedCountryAriaLabel: "Change country for phone number, currently selected ${countryName} (${dialCode})",
1880
+ noCountrySelected: "Select country for phone number",
1881
+ countryListAriaLabel: "List of countries",
1882
+ searchPlaceholder: "Search",
1883
+ clearSearchAriaLabel: "Clear search",
1884
+ searchEmptyState: "No results found",
1885
+ searchSummaryAria(count) {
1886
+ if (count === 0) {
1887
+ return "No results found";
1888
+ }
1889
+ if (count === 1) {
1890
+ return "1 result found";
1891
+ }
1892
+ return `${count} results found`;
1893
+ }
1894
+ };
1895
+ var en_default = interfaceTranslations;
1896
+ var mq = (q) => typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia(q).matches;
1897
+ var isNarrowViewport = () => mq(`(max-width: ${LAYOUT.NARROW_VIEWPORT_WIDTH}px)`);
1898
+ var computeDefaultUseFullscreenPopup = () => {
1899
+ if (typeof navigator !== "undefined" && typeof window !== "undefined") {
1900
+ const isShortViewport = mq("(max-height: 600px)");
1901
+ const isCoarsePointer = mq("(pointer: coarse)");
1902
+ return isNarrowViewport() || isCoarsePointer && isShortViewport;
1903
+ }
1904
+ return false;
1905
+ };
1906
+ var defaults = {
1907
+ //* Whether or not to allow the dropdown.
1908
+ allowDropdown: true,
1909
+ //* The number type to enforce during validation.
1910
+ allowedNumberTypes: ["MOBILE", "FIXED_LINE"],
1911
+ //* Whether or not to allow extensions after the main number.
1912
+ allowNumberExtensions: false,
1913
+ // Allow alphanumeric "phonewords" (e.g. +1 800 FLOWERS) as valid numbers
1914
+ allowPhonewords: false,
1915
+ //* Add a placeholder in the input with an example number for the selected country.
1916
+ autoPlaceholder: PLACEHOLDER_MODES.POLITE,
1917
+ //* Add a custom class to the (injected) container element.
1918
+ containerClass: "",
1919
+ //* Locale for localising country names via Intl.DisplayNames.
1920
+ countryNameLocale: "en",
1921
+ //* The order of the countries in the dropdown. Defaults to alphabetical.
1922
+ countryOrder: null,
1923
+ //* Add a country search input at the top of the dropdown.
1924
+ countrySearch: true,
1925
+ //* Modify the auto placeholder.
1926
+ customPlaceholder: null,
1927
+ //* Always show the dropdown
1928
+ dropdownAlwaysOpen: false,
1929
+ //* Append menu to specified element.
1930
+ dropdownContainer: null,
1931
+ //* Don't display these countries.
1932
+ excludeCountries: null,
1933
+ //* Fix the dropdown width to the input width (rather than being as wide as the longest country name).
1934
+ fixDropdownWidth: true,
1935
+ //* Format the number as the user types
1936
+ formatAsYouType: true,
1937
+ //* Format the input value during initialisation and on setNumber.
1938
+ formatOnDisplay: true,
1939
+ //* geoIp lookup function.
1940
+ geoIpLookup: null,
1941
+ //* Inject a hidden input with the name returned from this function, and on submit, populate it with the result of getNumber.
1942
+ hiddenInput: null,
1943
+ //* Internationalise the plugin text e.g. search input placeholder, country names.
1944
+ i18n: {},
1945
+ //* Initial country.
1946
+ initialCountry: "",
1947
+ //* A function to load the utils script.
1948
+ loadUtils: null,
1949
+ //* National vs international formatting for numbers e.g. placeholders and displaying existing numbers.
1950
+ nationalMode: true,
1951
+ //* Display only these countries.
1952
+ onlyCountries: null,
1953
+ //* Number type to use for placeholders.
1954
+ placeholderNumberType: "MOBILE",
1955
+ //* Add custom classes to the search input element.
1956
+ searchInputClass: "",
1957
+ //* Display the international dial code next to the selected flag.
1958
+ separateDialCode: false,
1959
+ //* Show flags - for both the selected country, and in the country dropdown
1960
+ showFlags: true,
1961
+ //* Only allow certain chars e.g. a plus followed by numeric digits, and cap at max valid length.
1962
+ strictMode: false,
1963
+ //* Use full screen popup instead of dropdown for country list.
1964
+ useFullscreenPopup: computeDefaultUseFullscreenPopup()
1965
+ };
1966
+ var toString = (val) => JSON.stringify(val);
1967
+ var isPlainObject = (val) => Boolean(val) && typeof val === "object" && !Array.isArray(val);
1968
+ var isFn = (val) => typeof val === "function";
1969
+ var isElLike = (val) => {
1970
+ if (!val || typeof val !== "object") {
1971
+ return false;
1972
+ }
1973
+ const v = val;
1974
+ return v.nodeType === 1 && typeof v.tagName === "string" && typeof v.appendChild === "function";
1975
+ };
1976
+ var placeholderModeSet = new Set(Object.values(PLACEHOLDER_MODES));
1977
+ var warn = (message) => {
1978
+ console.warn(`[intl-tel-input] ${message}`);
1979
+ };
1980
+ var warnOption = (optionName, expectedType, actualValue) => {
1981
+ warn(
1982
+ `Option '${optionName}' must be ${expectedType}; got ${toString(actualValue)}. Ignoring.`
1983
+ );
1984
+ };
1985
+ var validateIso2Array = (key, value) => {
1986
+ const expectedType = "an array of ISO2 country code strings";
1987
+ if (!Array.isArray(value)) {
1988
+ warnOption(key, expectedType, value);
1989
+ return false;
1990
+ }
1991
+ const valid = [];
1992
+ for (const v of value) {
1993
+ if (typeof v !== "string") {
1994
+ warnOption(key, expectedType, value);
1995
+ return false;
1996
+ }
1997
+ const lower = v.toLowerCase();
1998
+ if (!isIso2(lower)) {
1999
+ warn(`Invalid country code in '${key}': '${v}'. Skipping.`);
2000
+ } else {
2001
+ valid.push(v);
2002
+ }
2003
+ }
2004
+ return valid;
2005
+ };
2006
+ var validateOptions = (customOptions) => {
2007
+ if (customOptions === void 0) {
2008
+ return {};
2009
+ }
2010
+ if (!isPlainObject(customOptions)) {
2011
+ const error = `The second argument must be an options object; got ${toString(customOptions)}. Using defaults.`;
2012
+ warn(error);
2013
+ return {};
2014
+ }
2015
+ const validatedOptions = {};
2016
+ for (const [key, value] of Object.entries(customOptions)) {
2017
+ if (!Object.hasOwn(defaults, key)) {
2018
+ warn(`Unknown option '${key}'. Ignoring.`);
2019
+ continue;
2020
+ }
2021
+ switch (key) {
2022
+ case "allowDropdown":
2023
+ case "allowNumberExtensions":
2024
+ case "allowPhonewords":
2025
+ case "countrySearch":
2026
+ case "dropdownAlwaysOpen":
2027
+ case "fixDropdownWidth":
2028
+ case "formatAsYouType":
2029
+ case "formatOnDisplay":
2030
+ case "nationalMode":
2031
+ case "showFlags":
2032
+ case "separateDialCode":
2033
+ case "strictMode":
2034
+ case "useFullscreenPopup":
2035
+ if (typeof value !== "boolean") {
2036
+ warnOption(key, "a boolean", value);
2037
+ break;
2038
+ }
2039
+ validatedOptions[key] = value;
2040
+ break;
2041
+ case "autoPlaceholder":
2042
+ if (typeof value !== "string" || !placeholderModeSet.has(value)) {
2043
+ const validModes = Array.from(placeholderModeSet).join(", ");
2044
+ warnOption("autoPlaceholder", `one of ${validModes}`, value);
2045
+ break;
2046
+ }
2047
+ validatedOptions[key] = value;
2048
+ break;
2049
+ case "containerClass":
2050
+ case "searchInputClass":
2051
+ case "countryNameLocale":
2052
+ if (typeof value !== "string") {
2053
+ warnOption(key, "a string", value);
2054
+ break;
2055
+ }
2056
+ validatedOptions[key] = value;
2057
+ break;
2058
+ case "countryOrder": {
2059
+ if (value === null) {
2060
+ validatedOptions[key] = value;
2061
+ } else {
2062
+ const filtered = validateIso2Array(key, value);
2063
+ if (filtered !== false) {
2064
+ validatedOptions[key] = filtered;
2065
+ }
2066
+ }
2067
+ break;
2068
+ }
2069
+ case "customPlaceholder":
2070
+ case "geoIpLookup":
2071
+ case "hiddenInput":
2072
+ case "loadUtils":
2073
+ if (value !== null && !isFn(value)) {
2074
+ warnOption(key, "a function or null", value);
2075
+ break;
2076
+ }
2077
+ validatedOptions[key] = value;
2078
+ break;
2079
+ case "dropdownContainer":
2080
+ if (value !== null && !isElLike(value)) {
2081
+ warnOption("dropdownContainer", "an HTMLElement or null", value);
2082
+ break;
2083
+ }
2084
+ validatedOptions[key] = value;
2085
+ break;
2086
+ case "excludeCountries":
2087
+ case "onlyCountries": {
2088
+ if (value === null) {
2089
+ validatedOptions[key] = value;
2090
+ } else {
2091
+ const filtered = validateIso2Array(key, value);
2092
+ if (filtered !== false) {
2093
+ validatedOptions[key] = filtered;
2094
+ }
2095
+ }
2096
+ break;
2097
+ }
2098
+ case "i18n":
2099
+ if (value && !isPlainObject(value)) {
2100
+ warnOption("i18n", "an object", value);
2101
+ break;
2102
+ }
2103
+ validatedOptions[key] = value;
2104
+ break;
2105
+ case "initialCountry": {
2106
+ if (typeof value !== "string") {
2107
+ warnOption("initialCountry", "a string", value);
2108
+ break;
2109
+ }
2110
+ const lower = value.toLowerCase();
2111
+ if (lower && lower !== INITIAL_COUNTRY.AUTO && !isIso2(lower)) {
2112
+ warnOption(
2113
+ "initialCountry",
2114
+ "a valid ISO2 country code or 'auto'",
2115
+ value
2116
+ );
2117
+ break;
2118
+ }
2119
+ validatedOptions[key] = value;
2120
+ break;
2121
+ }
2122
+ case "placeholderNumberType":
2123
+ if (typeof value !== "string" || !NUMBER_TYPE_SET.has(value)) {
2124
+ const validTypes = Array.from(NUMBER_TYPE_SET).join(", ");
2125
+ warnOption("placeholderNumberType", `one of ${validTypes}`, value);
2126
+ break;
2127
+ }
2128
+ validatedOptions[key] = value;
2129
+ break;
2130
+ case "allowedNumberTypes":
2131
+ if (value !== null) {
2132
+ if (!Array.isArray(value)) {
2133
+ warnOption(
2134
+ "allowedNumberTypes",
2135
+ "an array of number types or null",
2136
+ value
2137
+ );
2138
+ break;
2139
+ }
2140
+ let allValid = true;
2141
+ for (const v of value) {
2142
+ if (typeof v !== "string" || !NUMBER_TYPE_SET.has(v)) {
2143
+ const validTypes = Array.from(NUMBER_TYPE_SET).join(", ");
2144
+ warnOption(
2145
+ "allowedNumberTypes",
2146
+ `an array of valid number types (${validTypes})`,
2147
+ v
2148
+ );
2149
+ allValid = false;
2150
+ break;
2151
+ }
2152
+ }
2153
+ if (allValid) {
2154
+ validatedOptions[key] = value;
2155
+ }
2156
+ } else {
2157
+ validatedOptions[key] = null;
2158
+ }
2159
+ break;
2160
+ }
2161
+ }
2162
+ return validatedOptions;
2163
+ };
2164
+ var normaliseOptions = (o) => {
2165
+ if (o.initialCountry) {
2166
+ o.initialCountry = o.initialCountry.toLowerCase();
2167
+ }
2168
+ if (o.onlyCountries?.length) {
2169
+ o.onlyCountries = o.onlyCountries.map((c) => c.toLowerCase());
2170
+ }
2171
+ if (o.excludeCountries?.length) {
2172
+ o.excludeCountries = o.excludeCountries.map((c) => c.toLowerCase());
2173
+ }
2174
+ if (o.countryOrder) {
2175
+ o.countryOrder = o.countryOrder.map((c) => c.toLowerCase());
2176
+ }
2177
+ };
2178
+ var applyOptionSideEffects = (o) => {
2179
+ if (o.dropdownAlwaysOpen) {
2180
+ o.useFullscreenPopup = false;
2181
+ o.allowDropdown = true;
2182
+ }
2183
+ if (o.useFullscreenPopup) {
2184
+ o.fixDropdownWidth = false;
2185
+ } else {
2186
+ if (isNarrowViewport()) {
2187
+ o.fixDropdownWidth = true;
2188
+ }
2189
+ }
2190
+ if (o.onlyCountries?.length === 1) {
2191
+ o.initialCountry = o.onlyCountries[0];
2192
+ }
2193
+ if (o.separateDialCode) {
2194
+ o.nationalMode = false;
2195
+ }
2196
+ if (o.allowDropdown && !o.showFlags && !o.separateDialCode) {
2197
+ o.nationalMode = false;
2198
+ }
2199
+ if (o.useFullscreenPopup && !o.dropdownContainer) {
2200
+ o.dropdownContainer = document.body;
2201
+ }
2202
+ o.i18n = { ...en_default, ...o.i18n };
2203
+ };
2204
+ var getNumeric = (s) => s.replace(/\D/g, "");
2205
+ var normaliseString = (s = "") => s.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase();
2206
+ var getIsAndroid = () => typeof navigator !== "undefined" ? /Android/i.test(navigator.userAgent) : false;
2207
+ var getMatchedCountries = (countries, query) => {
2208
+ const normalisedQuery = normaliseString(query);
2209
+ const iso2Matches = [];
2210
+ const nameStartWith = [];
2211
+ const nameContains = [];
2212
+ const dialCodeMatches = [];
2213
+ const dialCodeContains = [];
2214
+ const initialsMatches = [];
2215
+ for (const c of countries) {
2216
+ if (c.iso2 === normalisedQuery) {
2217
+ iso2Matches.push(c);
2218
+ } else if (c.normalisedName.startsWith(normalisedQuery)) {
2219
+ nameStartWith.push(c);
2220
+ } else if (c.normalisedName.includes(normalisedQuery)) {
2221
+ nameContains.push(c);
2222
+ } else if (normalisedQuery === c.dialCode || normalisedQuery === c.dialCodePlus) {
2223
+ dialCodeMatches.push(c);
2224
+ } else if (c.dialCodePlus.includes(normalisedQuery)) {
2225
+ dialCodeContains.push(c);
2226
+ } else if (c.initials.includes(normalisedQuery)) {
2227
+ initialsMatches.push(c);
2228
+ }
2229
+ }
2230
+ const sortByPriority = (a, b) => a.priority - b.priority;
2231
+ return [
2232
+ ...iso2Matches,
2233
+ ...nameStartWith,
2234
+ ...nameContains,
2235
+ // priority sort is only relevant when showing multiple countries with the same dial code (that's what the priority field is used to distinguish between)
2236
+ ...dialCodeMatches.sort(sortByPriority),
2237
+ ...dialCodeContains.sort(sortByPriority),
2238
+ ...initialsMatches
2239
+ ];
2240
+ };
2241
+ var findFirstCountryStartingWith = (countries, query) => {
2242
+ const normalisedQuery = normaliseString(query);
2243
+ for (const c of countries) {
2244
+ if (c.normalisedName.startsWith(normalisedQuery)) {
2245
+ return c;
2246
+ }
2247
+ }
2248
+ return null;
2249
+ };
2250
+ var buildClassNames = (flags) => Object.keys(flags).filter((k) => Boolean(flags[k])).join(" ");
2251
+ var createEl = (tagName, attrs, container) => {
2252
+ const el = document.createElement(tagName);
2253
+ if (attrs) {
2254
+ Object.entries(attrs).forEach(
2255
+ ([key, value]) => el.setAttribute(key, value)
2256
+ );
2257
+ }
2258
+ if (container) {
2259
+ container.appendChild(el);
2260
+ }
2261
+ return el;
2262
+ };
2263
+ var buildSearchIcon = () => `
2264
+ <svg class="iti__search-icon-svg" width="14" height="14" viewBox="0 0 24 24" focusable="false" ${ARIA.HIDDEN}="true">
2265
+ <circle cx="11" cy="11" r="7" />
2266
+ <line x1="21" y1="21" x2="16.65" y2="16.65" />
2267
+ </svg>`;
2268
+ var buildClearIcon = (id2) => {
2269
+ const maskId = `iti-${id2}-clear-mask`;
2270
+ return `
2271
+ <svg class="iti__search-clear-svg" width="12" height="12" viewBox="0 0 16 16" ${ARIA.HIDDEN}="true" focusable="false">
2272
+ <mask id="${maskId}" maskUnits="userSpaceOnUse">
2273
+ <rect width="16" height="16" fill="white" />
2274
+ <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" />
2275
+ </mask>
2276
+ <circle cx="8" cy="8" r="8" class="iti__search-clear-bg" mask="url(#${maskId})" />
2277
+ </svg>`;
2278
+ };
2279
+ var buildCheckIcon = () => `
2280
+ <svg class="iti__country-check-svg" width="14" height="14" viewBox="0 0 16 16" fill="currentColor" focusable="false" ${ARIA.HIDDEN}="true">
2281
+ <path d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0m-3.97-3.03a.75.75 0 0 0-1.08.022L7.477 9.417 5.384 7.323a.75.75 0 0 0-1.06 1.06L6.97 11.03a.75.75 0 0 0 1.079-.02l3.992-4.99a.75.75 0 0 0-.01-1.05z"/>
2282
+ </svg>`;
2283
+ var buildGlobeIcon = () => `
2284
+ <svg width="256" height="256" viewBox="0 0 512 512" class="iti__globe-svg">
2285
+ <path d="M508 213a240 240 0 0 0-449-87l-2 5-2 5c-8 14-13 30-17 46a65 65 0 0 1 56 4c16-10 35-19 56-27l9-3c-6 23-10 48-10 74h-16l4 6c3 4 5 8 6 13h6c0 22 3 44 8 65l2 10-25-10-4 5 12 18 9 3 6 2 8 3 9 26 1 2 16-7h1l-5-13-1-2c24 6 49 9 75 10v26l11 10 7 7v-30l1-13c22 0 44-3 65-8l10-2-21 48-1 1a317 317 0 0 1-14 23l-21 5h-2c6 16 7 33 1 50a240 240 0 0 0 211-265m-401-56-11 6c19-44 54-79 98-98-11 20-21 44-29 69-21 6-40 15-58 23m154 182v4c-29-1-57-6-81-13-7-25-12-52-13-81h94zm0-109h-94c1-29 6-56 13-81 24-7 52-12 81-13zm0-112c-22 1-44 4-65 8l-10 2 12-30 9-17 1-2a332 332 0 0 1 13-23c13-4 26-6 40-7zm187 69 6 4c4 12 6 25 6 38v1h-68c-1-26-4-51-10-74l48 20 1 1 14 8zm-14-44 10 20c-20-11-43-21-68-29-8-25-18-49-29-69 37 16 67 44 87 78M279 49h1c13 1 27 3 39 7l14 23 1 2a343 343 0 0 1 12 26l2 5 6 16c-23-6-48-9-74-10h-1zm0 87h1c29 1 56 6 81 13 7 24 12 51 12 80v1h-94zm2 207h-2v-94h95c-1 29-6 56-13 81-24 7-51 12-80 13m86 60-20 10c11-20 21-43 29-68 25-8 48-18 68-29-16 37-43 67-77 87m87-115-7 5-16 9-2 1a337 337 0 0 1-47 21c6-24 9-49 10-75h68c0 13-2 27-6 39"/>
2286
+ <path d="m261 428-2-2-22-21a40 40 0 0 0-32-11h-1a37 37 0 0 0-18 8l-1 1-4 2-2 2-5 4c-9-3-36-31-47-44s-32-45-34-55l3-2a151 151 0 0 0 11-9v-1a39 39 0 0 0 5-48l-3-3-11-19-3-4-5-7h-1l-3-3-4-3-5-2a35 35 0 0 0-16-3h-5c-4 1-14 5-24 11l-4 2-4 3-4 2c-9 8-17 17-18 27a380 380 0 0 0 212 259h3c12 0 25-10 36-21l10-12 6-11a39 39 0 0 0-8-40"/>
2287
+ </svg>`;
2288
+ var UI = class _UI {
2289
+ // private
2290
+ #options;
2291
+ #id;
2292
+ #isRTL;
2293
+ #originalPaddingLeft = "";
2294
+ #countries;
2295
+ #searchKeyupTimer = null;
2296
+ #inlineDropdownHeight;
2297
+ #selectedDialCode;
2298
+ #dropdownArrow;
2299
+ #dropdownContent;
2300
+ #searchIcon;
2301
+ #searchNoResults;
2302
+ #searchResultsA11yText;
2303
+ #dropdownForContainer;
2304
+ #selectedItem = null;
2305
+ #viewportHandler = null;
2306
+ // public
2307
+ telInput;
2308
+ countryContainer;
2309
+ selectedCountry;
2310
+ selectedCountryInner;
2311
+ searchInput;
2312
+ searchClearButton;
2313
+ countryList;
2314
+ hiddenInputPhone;
2315
+ hiddenInputCountry;
2316
+ highlightedItem = null;
2317
+ hadInitialPlaceholder;
2318
+ constructor(input, options, id2) {
2319
+ input.dataset.intlTelInputId = id2.toString();
2320
+ this.telInput = input;
2321
+ this.#options = options;
2322
+ this.#id = id2;
2323
+ this.hadInitialPlaceholder = Boolean(input.getAttribute("placeholder"));
2324
+ this.#isRTL = !!this.telInput.closest("[dir=rtl]");
2325
+ if (this.#options.separateDialCode) {
2326
+ this.#originalPaddingLeft = this.telInput.style.paddingLeft;
2327
+ }
2328
+ }
2329
+ // Validate that the provided element is an HTMLInputElement.
2330
+ static validateInput(input) {
2331
+ const tagName = input?.tagName;
2332
+ const isInputEl = Boolean(input) && typeof input === "object" && tagName === "INPUT" && typeof input.setAttribute === "function";
2333
+ if (!isInputEl) {
2334
+ const type = Object.prototype.toString.call(input);
2335
+ throw new TypeError(
2336
+ `The first argument must be an HTMLInputElement, not ${type}`
2337
+ );
2338
+ }
2339
+ }
2340
+ //* Generate all of the markup for the plugin: the selected country overlay, and the dropdown.
2341
+ generateMarkup(countries) {
2342
+ this.#countries = countries;
2343
+ this.telInput.classList.add("iti__tel-input");
2344
+ if (!this.telInput.hasAttribute("type")) {
2345
+ this.telInput.setAttribute("type", "tel");
2346
+ }
2347
+ if (!this.telInput.hasAttribute("autocomplete")) {
2348
+ this.telInput.setAttribute("autocomplete", "tel");
2349
+ }
2350
+ if (!this.telInput.hasAttribute("inputmode")) {
2351
+ this.telInput.setAttribute("inputmode", "tel");
2352
+ }
2353
+ const wrapper = this.#createWrapperAndInsert();
2354
+ this.#maybeBuildCountryContainer(wrapper);
2355
+ wrapper.appendChild(this.telInput);
2356
+ this.#maybeEnsureDropdownWidthSet();
2357
+ this.#maybeUpdateInputPaddingAndReveal();
2358
+ this.#maybeBuildHiddenInputs(wrapper);
2359
+ }
2360
+ #createWrapperAndInsert() {
2361
+ const { allowDropdown, showFlags, containerClass, useFullscreenPopup } = this.#options;
2362
+ const parentClasses = buildClassNames({
2363
+ iti: true,
2364
+ "iti--allow-dropdown": allowDropdown,
2365
+ "iti--show-flags": showFlags,
2366
+ "iti--inline-dropdown": !useFullscreenPopup,
2367
+ [containerClass]: Boolean(containerClass)
2368
+ });
2369
+ const wrapper = createEl("div", { class: parentClasses });
2370
+ if (this.#isRTL) {
2371
+ wrapper.setAttribute("dir", "ltr");
2372
+ }
2373
+ this.telInput.before(wrapper);
2374
+ return wrapper;
2375
+ }
2376
+ #maybeBuildCountryContainer(wrapper) {
2377
+ const { allowDropdown, separateDialCode, showFlags } = this.#options;
2378
+ if (!allowDropdown && !showFlags && !separateDialCode) {
2379
+ return;
2380
+ }
2381
+ this.countryContainer = createEl(
2382
+ "div",
2383
+ // visibly hidden until we measure its width to set the input padding correctly
2384
+ { class: `iti__country-container ${CLASSES.V_HIDE}` },
2385
+ wrapper
2386
+ );
2387
+ if (allowDropdown) {
2388
+ this.selectedCountry = createEl(
2389
+ "button",
2390
+ {
2391
+ type: "button",
2392
+ class: "iti__selected-country",
2393
+ [ARIA.EXPANDED]: "false",
2394
+ [ARIA.LABEL]: this.#options.i18n.noCountrySelected,
2395
+ [ARIA.HASPOPUP]: "dialog",
2396
+ [ARIA.CONTROLS]: `iti-${this.#id}__dropdown-content`
2397
+ },
2398
+ this.countryContainer
2399
+ );
2400
+ if (this.telInput.disabled) {
2401
+ this.selectedCountry.setAttribute("disabled", "true");
2402
+ }
2403
+ } else {
2404
+ this.selectedCountry = createEl(
2405
+ "div",
2406
+ { class: "iti__selected-country" },
2407
+ this.countryContainer
2408
+ );
2409
+ }
2410
+ const selectedCountryPrimary = createEl(
2411
+ "div",
2412
+ { class: "iti__selected-country-primary" },
2413
+ this.selectedCountry
2414
+ );
2415
+ this.selectedCountryInner = createEl(
2416
+ "div",
2417
+ { class: CLASSES.FLAG },
2418
+ selectedCountryPrimary
2419
+ );
2420
+ if (allowDropdown) {
2421
+ this.#dropdownArrow = createEl(
2422
+ "div",
2423
+ { class: "iti__arrow", [ARIA.HIDDEN]: "true" },
2424
+ selectedCountryPrimary
2425
+ );
2426
+ }
2427
+ if (separateDialCode) {
2428
+ this.#selectedDialCode = createEl(
2429
+ "div",
2430
+ { class: "iti__selected-dial-code" },
2431
+ this.selectedCountry
2432
+ );
2433
+ }
2434
+ if (allowDropdown) {
2435
+ this.#buildDropdownContent();
2436
+ }
2437
+ }
2438
+ #maybeEnsureDropdownWidthSet() {
2439
+ const { fixDropdownWidth, allowDropdown } = this.#options;
2440
+ if (!allowDropdown || !fixDropdownWidth || this.#dropdownContent.style.width) {
2441
+ return;
2442
+ }
2443
+ const inputWidth = this.telInput.offsetWidth;
2444
+ if (inputWidth > 0) {
2445
+ this.#dropdownContent.style.width = `${inputWidth}px`;
2446
+ }
2447
+ }
2448
+ #buildDropdownContent() {
2449
+ const {
2450
+ fixDropdownWidth,
2451
+ useFullscreenPopup,
2452
+ countrySearch,
2453
+ i18n,
2454
+ dropdownContainer,
2455
+ containerClass
2456
+ } = this.#options;
2457
+ const extraClasses = fixDropdownWidth ? "" : "iti--flexible-dropdown-width";
2458
+ this.#dropdownContent = createEl("div", {
2459
+ id: `iti-${this.#id}__dropdown-content`,
2460
+ class: `iti__dropdown-content ${CLASSES.HIDE} ${extraClasses}`,
2461
+ role: "dialog",
2462
+ [ARIA.MODAL]: "true"
2463
+ });
2464
+ if (this.#isRTL) {
2465
+ this.#dropdownContent.setAttribute("dir", "rtl");
2466
+ }
2467
+ if (countrySearch) {
2468
+ this.#buildSearchUI();
2469
+ }
2470
+ this.countryList = createEl(
2471
+ "ul",
2472
+ {
2473
+ class: "iti__country-list",
2474
+ id: `iti-${this.#id}__country-listbox`,
2475
+ role: "listbox",
2476
+ [ARIA.LABEL]: i18n.countryListAriaLabel
2477
+ },
2478
+ this.#dropdownContent
2479
+ );
2480
+ this.#appendListItems();
2481
+ if (countrySearch) {
2482
+ this.#updateSearchResultsA11yText();
2483
+ }
2484
+ if (!useFullscreenPopup) {
2485
+ this.#inlineDropdownHeight = this.#getHiddenInlineDropdownHeight();
2486
+ if (countrySearch) {
2487
+ this.#dropdownContent.style.height = `${this.#inlineDropdownHeight}px`;
2488
+ }
2489
+ }
2490
+ if (dropdownContainer) {
2491
+ const dropdownClasses = buildClassNames({
2492
+ iti: true,
2493
+ "iti--container": true,
2494
+ "iti--fullscreen-popup": useFullscreenPopup,
2495
+ "iti--inline-dropdown": !useFullscreenPopup,
2496
+ [containerClass]: Boolean(containerClass)
2497
+ });
2498
+ this.#dropdownForContainer = createEl("div", { class: dropdownClasses });
2499
+ this.#dropdownForContainer.appendChild(this.#dropdownContent);
2500
+ } else {
2501
+ this.countryContainer.appendChild(this.#dropdownContent);
2502
+ }
2503
+ }
2504
+ #buildSearchUI() {
2505
+ const { i18n, searchInputClass } = this.#options;
2506
+ const searchWrapper = createEl(
2507
+ "div",
2508
+ { class: "iti__search-input-wrapper" },
2509
+ this.#dropdownContent
2510
+ );
2511
+ this.#searchIcon = createEl(
2512
+ "span",
2513
+ {
2514
+ class: "iti__search-icon",
2515
+ [ARIA.HIDDEN]: "true"
2516
+ },
2517
+ searchWrapper
2518
+ );
2519
+ this.#searchIcon.innerHTML = buildSearchIcon();
2520
+ this.searchInput = createEl(
2521
+ "input",
2522
+ {
2523
+ id: `iti-${this.#id}__search-input`,
2524
+ // Chrome says inputs need either a name or an id
2525
+ type: "search",
2526
+ class: `iti__search-input ${searchInputClass}`,
2527
+ placeholder: i18n.searchPlaceholder,
2528
+ // 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
2529
+ role: "combobox",
2530
+ [ARIA.EXPANDED]: "true",
2531
+ [ARIA.LABEL]: i18n.searchPlaceholder,
2532
+ [ARIA.CONTROLS]: `iti-${this.#id}__country-listbox`,
2533
+ [ARIA.AUTOCOMPLETE]: "list",
2534
+ autocomplete: "off"
2535
+ },
2536
+ searchWrapper
2537
+ );
2538
+ this.searchClearButton = createEl(
2539
+ "button",
2540
+ {
2541
+ type: "button",
2542
+ class: `iti__search-clear ${CLASSES.HIDE}`,
2543
+ [ARIA.LABEL]: i18n.clearSearchAriaLabel,
2544
+ tabindex: "-1"
2545
+ },
2546
+ searchWrapper
2547
+ );
2548
+ this.searchClearButton.innerHTML = buildClearIcon(this.#id);
2549
+ this.#searchResultsA11yText = createEl(
2550
+ "span",
2551
+ { class: "iti__a11y-text" },
2552
+ this.#dropdownContent
2553
+ );
2554
+ this.#searchNoResults = createEl(
2555
+ "div",
2556
+ {
2557
+ class: `iti__no-results ${CLASSES.HIDE}`,
2558
+ [ARIA.HIDDEN]: "true"
2559
+ // all a11y messaging happens in this.#searchResultsA11yText
2560
+ },
2561
+ this.#dropdownContent
2562
+ );
2563
+ this.#searchNoResults.textContent = i18n.searchEmptyState ?? null;
2564
+ }
2565
+ #maybeUpdateInputPaddingAndReveal() {
2566
+ if (!this.countryContainer) {
2567
+ return;
2568
+ }
2569
+ this.#updateInputPadding();
2570
+ this.countryContainer.classList.remove(CLASSES.V_HIDE);
2571
+ }
2572
+ #maybeBuildHiddenInputs(wrapper) {
2573
+ const { hiddenInput } = this.#options;
2574
+ if (!hiddenInput) {
2575
+ return;
2576
+ }
2577
+ const telInputName = this.telInput.getAttribute("name") || "";
2578
+ const names = hiddenInput(telInputName);
2579
+ if (names.phone) {
2580
+ const existingInput = this.telInput.form?.querySelector(
2581
+ `input[name="${names.phone}"]`
2582
+ );
2583
+ if (existingInput) {
2584
+ this.hiddenInputPhone = existingInput;
2585
+ } else {
2586
+ this.hiddenInputPhone = createEl("input", {
2587
+ type: "hidden",
2588
+ name: names.phone
2589
+ });
2590
+ wrapper.appendChild(this.hiddenInputPhone);
2591
+ }
2592
+ }
2593
+ if (names.country) {
2594
+ const existingInput = this.telInput.form?.querySelector(
2595
+ `input[name="${names.country}"]`
2596
+ );
2597
+ if (existingInput) {
2598
+ this.hiddenInputCountry = existingInput;
2599
+ } else {
2600
+ this.hiddenInputCountry = createEl("input", {
2601
+ type: "hidden",
2602
+ name: names.country
2603
+ });
2604
+ wrapper.appendChild(this.hiddenInputCountry);
2605
+ }
2606
+ }
2607
+ }
2608
+ //* For each country: add a country list item <li> to the countryList <ul> container.
2609
+ #appendListItems() {
2610
+ const frag = document.createDocumentFragment();
2611
+ for (let i = 0; i < this.#countries.length; i++) {
2612
+ const c = this.#countries[i];
2613
+ const liClass = buildClassNames({
2614
+ [CLASSES.COUNTRY_ITEM]: true
2615
+ });
2616
+ const listItem = createEl("li", {
2617
+ id: `iti-${this.#id}__item-${c.iso2}`,
2618
+ class: liClass,
2619
+ tabindex: "-1",
2620
+ role: "option",
2621
+ [ARIA.SELECTED]: "false"
2622
+ });
2623
+ listItem.dataset.dialCode = c.dialCode;
2624
+ listItem.dataset.countryCode = c.iso2;
2625
+ c.nodeById[this.#id] = listItem;
2626
+ if (this.#options.showFlags) {
2627
+ createEl("div", { class: `${CLASSES.FLAG} iti__${c.iso2}` }, listItem);
2628
+ }
2629
+ const nameEl = createEl("span", { class: "iti__country-name" }, listItem);
2630
+ nameEl.textContent = `${c.name} `;
2631
+ const dialEl = createEl("span", { class: "iti__dial-code" }, nameEl);
2632
+ if (this.#isRTL) {
2633
+ dialEl.setAttribute("dir", "ltr");
2634
+ }
2635
+ dialEl.textContent = `(+${c.dialCode})`;
2636
+ frag.appendChild(listItem);
2637
+ }
2638
+ this.countryList.appendChild(frag);
2639
+ }
2640
+ //* Update the input padding to make space for the selected country/dial code.
2641
+ #updateInputPadding() {
2642
+ if (this.selectedCountry) {
2643
+ const fallbackWidth = this.#options.separateDialCode ? LAYOUT.SANE_SELECTED_WITH_DIAL_WIDTH : LAYOUT.SANE_SELECTED_NO_DIAL_WIDTH;
2644
+ const selectedCountryWidth = this.selectedCountry.offsetWidth || this.#getHiddenSelectedCountryWidth() || fallbackWidth;
2645
+ const inputPadding = selectedCountryWidth + LAYOUT.INPUT_PADDING_EXTRA_LEFT;
2646
+ this.telInput.style.paddingLeft = `${inputPadding}px`;
2647
+ }
2648
+ }
2649
+ static #getBody() {
2650
+ let body;
2651
+ try {
2652
+ body = window.top.document.body;
2653
+ } catch (e) {
2654
+ body = document.body;
2655
+ }
2656
+ return body;
2657
+ }
2658
+ //* When input is in a hidden container during init, we cannot calculate the selected country width.
2659
+ //* Fix: clone the markup, make it invisible, add it to the end of the DOM, and then measure it's width.
2660
+ //* To get the right styling to apply, all we need is a shallow clone of the container,
2661
+ //* and then to inject a deep clone of the selectedCountry element.
2662
+ #getHiddenSelectedCountryWidth() {
2663
+ if (!this.telInput.parentNode) {
2664
+ return 0;
2665
+ }
2666
+ const body = _UI.#getBody();
2667
+ const containerClone = this.telInput.parentNode.cloneNode(
2668
+ false
2669
+ );
2670
+ containerClone.style.visibility = "hidden";
2671
+ body.appendChild(containerClone);
2672
+ const countryContainerClone = this.countryContainer.cloneNode();
2673
+ containerClone.appendChild(countryContainerClone);
2674
+ const selectedCountryClone = this.selectedCountry.cloneNode(
2675
+ true
2676
+ );
2677
+ countryContainerClone.appendChild(selectedCountryClone);
2678
+ const width = selectedCountryClone.offsetWidth;
2679
+ body.removeChild(containerClone);
2680
+ return width;
2681
+ }
2682
+ // Get the dropdown height (before it is added to the DOM)
2683
+ #getHiddenInlineDropdownHeight() {
2684
+ const body = _UI.#getBody();
2685
+ this.#dropdownContent.classList.remove(CLASSES.HIDE);
2686
+ const tempContainer = createEl("div", {
2687
+ class: "iti iti--inline-dropdown"
2688
+ });
2689
+ tempContainer.appendChild(this.#dropdownContent);
2690
+ tempContainer.style.visibility = "hidden";
2691
+ body.appendChild(tempContainer);
2692
+ const height = this.#dropdownContent.offsetHeight;
2693
+ body.removeChild(tempContainer);
2694
+ tempContainer.style.visibility = "";
2695
+ this.#dropdownContent.classList.add(CLASSES.HIDE);
2696
+ return height > 0 ? height : LAYOUT.SANE_DROPDOWN_HEIGHT;
2697
+ }
2698
+ //* Update search results text (for a11y).
2699
+ #updateSearchResultsA11yText() {
2700
+ const { i18n } = this.#options;
2701
+ const count = this.countryList.childElementCount;
2702
+ this.#searchResultsA11yText.textContent = i18n.searchSummaryAria(count);
2703
+ }
2704
+ //* Country search: Filter the countries according to the search query.
2705
+ filterCountriesByQuery(query) {
2706
+ let matchedCountries;
2707
+ if (query === "") {
2708
+ matchedCountries = this.#countries;
2709
+ } else {
2710
+ matchedCountries = getMatchedCountries(this.#countries, query);
2711
+ }
2712
+ this.#filterCountries(matchedCountries);
2713
+ }
2714
+ // Search input handlers
2715
+ #doFilter() {
2716
+ const inputQuery = this.searchInput.value.trim();
2717
+ this.filterCountriesByQuery(inputQuery);
2718
+ if (this.searchInput.value) {
2719
+ this.searchClearButton.classList.remove(CLASSES.HIDE);
2720
+ } else {
2721
+ this.searchClearButton.classList.add(CLASSES.HIDE);
2722
+ }
2723
+ }
2724
+ handleSearchChange() {
2725
+ if (this.#searchKeyupTimer) {
2726
+ clearTimeout(this.#searchKeyupTimer);
2727
+ }
2728
+ this.#searchKeyupTimer = setTimeout(() => {
2729
+ this.#doFilter();
2730
+ this.#searchKeyupTimer = null;
2731
+ }, TIMINGS.SEARCH_DEBOUNCE_MS);
2732
+ }
2733
+ handleSearchClear() {
2734
+ this.searchInput.value = "";
2735
+ this.searchInput.focus();
2736
+ this.#doFilter();
2737
+ }
2738
+ //* Check if a country list item element is visible within it's container (the country list), else scroll until it is.
2739
+ scrollCountryListToItem(element) {
2740
+ const container = this.countryList;
2741
+ const containerRect = container.getBoundingClientRect();
2742
+ const elementRect = element.getBoundingClientRect();
2743
+ const offsetTop = elementRect.top - containerRect.top + container.scrollTop;
2744
+ if (elementRect.top < containerRect.top) {
2745
+ container.scrollTop = offsetTop;
2746
+ } else if (elementRect.bottom > containerRect.bottom) {
2747
+ container.scrollTop = offsetTop - containerRect.height + elementRect.height;
2748
+ }
2749
+ }
2750
+ //* Remove highlighting from the previous list item and highlight the new one.
2751
+ highlightListItem(listItem, shouldFocus) {
2752
+ const prevItem = this.highlightedItem;
2753
+ if (prevItem) {
2754
+ prevItem.classList.remove(CLASSES.HIGHLIGHT);
2755
+ }
2756
+ this.highlightedItem = listItem;
2757
+ if (this.highlightedItem) {
2758
+ this.highlightedItem.classList.add(CLASSES.HIGHLIGHT);
2759
+ if (this.#options.countrySearch) {
2760
+ const activeDescendant = this.highlightedItem.getAttribute("id") || "";
2761
+ this.searchInput.setAttribute(
2762
+ ARIA.ACTIVE_DESCENDANT,
2763
+ activeDescendant
2764
+ );
2765
+ }
2766
+ if (shouldFocus) {
2767
+ this.highlightedItem.focus();
2768
+ }
2769
+ }
2770
+ }
2771
+ //* Highlight the next/prev item in the list (and ensure it is visible).
2772
+ handleUpDownKey(key) {
2773
+ let next = key === KEYS.ARROW_UP ? this.highlightedItem?.previousElementSibling : this.highlightedItem?.nextElementSibling;
2774
+ if (!next && this.countryList.childElementCount > 1) {
2775
+ next = key === KEYS.ARROW_UP ? this.countryList.lastElementChild : this.countryList.firstElementChild;
2776
+ }
2777
+ if (next) {
2778
+ this.scrollCountryListToItem(next);
2779
+ this.highlightListItem(next, false);
2780
+ }
2781
+ }
2782
+ // Update the selected list item in the dropdown
2783
+ #updateSelectedItem(iso2) {
2784
+ if (this.#selectedItem && this.#selectedItem.dataset.countryCode !== iso2) {
2785
+ this.#selectedItem.setAttribute(ARIA.SELECTED, "false");
2786
+ this.#selectedItem.querySelector(".iti__country-check")?.remove();
2787
+ this.#selectedItem = null;
2788
+ }
2789
+ if (iso2 && !this.#selectedItem) {
2790
+ const newListItem = this.countryList.querySelector(
2791
+ `[data-country-code="${iso2}"]`
2792
+ );
2793
+ if (newListItem) {
2794
+ newListItem.setAttribute(ARIA.SELECTED, "true");
2795
+ const checkIcon = createEl(
2796
+ "span",
2797
+ { class: "iti__country-check", [ARIA.HIDDEN]: "true" },
2798
+ newListItem
2799
+ );
2800
+ checkIcon.innerHTML = buildCheckIcon();
2801
+ this.#selectedItem = newListItem;
2802
+ }
2803
+ }
2804
+ }
2805
+ //* Country search: Filter the country list to the given array of countries.
2806
+ #filterCountries(matchedCountries) {
2807
+ this.countryList.replaceChildren();
2808
+ let noCountriesAddedYet = true;
2809
+ for (const c of matchedCountries) {
2810
+ const listItem = c.nodeById[this.#id];
2811
+ if (listItem) {
2812
+ this.countryList.appendChild(listItem);
2813
+ if (noCountriesAddedYet) {
2814
+ this.highlightListItem(listItem, false);
2815
+ noCountriesAddedYet = false;
2816
+ }
2817
+ }
2818
+ }
2819
+ if (noCountriesAddedYet) {
2820
+ this.highlightListItem(null, false);
2821
+ if (this.#searchNoResults) {
2822
+ this.#searchNoResults.classList.remove(CLASSES.HIDE);
2823
+ }
2824
+ } else if (this.#searchNoResults) {
2825
+ this.#searchNoResults.classList.add(CLASSES.HIDE);
2826
+ }
2827
+ this.countryList.scrollTop = 0;
2828
+ this.#updateSearchResultsA11yText();
2829
+ }
2830
+ destroy() {
2831
+ this.telInput.iti = void 0;
2832
+ delete this.telInput.dataset.intlTelInputId;
2833
+ if (this.#options.separateDialCode) {
2834
+ this.telInput.style.paddingLeft = this.#originalPaddingLeft;
2835
+ }
2836
+ const wrapper = this.telInput.parentNode;
2837
+ wrapper.before(this.telInput);
2838
+ wrapper.remove();
2839
+ for (const c of this.#countries) {
2840
+ delete c.nodeById[this.#id];
2841
+ }
2842
+ }
2843
+ // UI: Open the dropdown (DOM only).
2844
+ openDropdown() {
2845
+ const { countrySearch, dropdownAlwaysOpen, dropdownContainer } = this.#options;
2846
+ this.#maybeEnsureDropdownWidthSet();
2847
+ if (dropdownContainer) {
2848
+ this.#handleDropdownContainer();
2849
+ } else {
2850
+ const positionBelow = this.#shouldPositionInlineDropdownBelowInput();
2851
+ const distance = this.telInput.offsetHeight + LAYOUT.DROPDOWN_MARGIN;
2852
+ if (positionBelow) {
2853
+ this.#dropdownContent.style.top = `${distance}px`;
2854
+ } else {
2855
+ this.#dropdownContent.style.bottom = `${distance}px`;
2856
+ }
2857
+ }
2858
+ this.#dropdownContent.classList.remove(CLASSES.HIDE);
2859
+ this.selectedCountry.setAttribute(ARIA.EXPANDED, "true");
2860
+ const itemToHighlight = this.#selectedItem ?? this.countryList.firstElementChild;
2861
+ if (itemToHighlight) {
2862
+ this.highlightListItem(itemToHighlight, false);
2863
+ this.scrollCountryListToItem(itemToHighlight);
2864
+ }
2865
+ if (countrySearch && !dropdownAlwaysOpen) {
2866
+ this.searchInput.focus();
2867
+ }
2868
+ if (this.#options.useFullscreenPopup && this.#dropdownForContainer && window.visualViewport) {
2869
+ this.#viewportHandler = () => {
2870
+ this.#adjustFullscreenPopupToViewport();
2871
+ if (this.highlightedItem) {
2872
+ this.scrollCountryListToItem(this.highlightedItem);
2873
+ }
2874
+ };
2875
+ window.visualViewport.addEventListener("resize", this.#viewportHandler);
2876
+ }
2877
+ this.#dropdownArrow.classList.add(CLASSES.ARROW_UP);
2878
+ }
2879
+ // UI: Close the dropdown (DOM only).
2880
+ closeDropdown() {
2881
+ const { countrySearch, dropdownContainer } = this.#options;
2882
+ this.#dropdownContent.classList.add(CLASSES.HIDE);
2883
+ this.selectedCountry.setAttribute(ARIA.EXPANDED, "false");
2884
+ if (countrySearch) {
2885
+ this.searchInput.removeAttribute(ARIA.ACTIVE_DESCENDANT);
2886
+ this.searchInput.value = "";
2887
+ this.#doFilter();
2888
+ if (this.highlightedItem) {
2889
+ this.highlightedItem.classList.remove(CLASSES.HIGHLIGHT);
2890
+ this.highlightedItem = null;
2891
+ }
2892
+ }
2893
+ this.#dropdownArrow.classList.remove(CLASSES.ARROW_UP);
2894
+ if (this.#viewportHandler && window.visualViewport) {
2895
+ window.visualViewport.removeEventListener(
2896
+ "resize",
2897
+ this.#viewportHandler
2898
+ );
2899
+ this.#viewportHandler = null;
2900
+ }
2901
+ if (dropdownContainer) {
2902
+ this.#dropdownForContainer.remove();
2903
+ this.#dropdownForContainer.style.top = "";
2904
+ this.#dropdownForContainer.style.bottom = "";
2905
+ this.#dropdownForContainer.style.paddingLeft = "";
2906
+ this.#dropdownForContainer.style.paddingRight = "";
2907
+ } else {
2908
+ this.#dropdownContent.style.top = "";
2909
+ this.#dropdownContent.style.bottom = "";
2910
+ }
2911
+ }
2912
+ #shouldPositionInlineDropdownBelowInput() {
2913
+ if (this.#options.dropdownAlwaysOpen) {
2914
+ return true;
2915
+ }
2916
+ const inputPos = this.telInput.getBoundingClientRect();
2917
+ const spaceAbove = inputPos.top;
2918
+ const spaceBelow = window.innerHeight - inputPos.bottom;
2919
+ return spaceBelow >= this.#inlineDropdownHeight || spaceBelow >= spaceAbove;
2920
+ }
2921
+ // inject dropdown into container and apply positioning styles
2922
+ #handleDropdownContainer() {
2923
+ const { dropdownContainer, useFullscreenPopup } = this.#options;
2924
+ if (useFullscreenPopup) {
2925
+ if (window.innerWidth >= LAYOUT.NARROW_VIEWPORT_WIDTH) {
2926
+ const inputPos = this.telInput.getBoundingClientRect();
2927
+ this.#dropdownForContainer.style.paddingLeft = `${inputPos.left}px`;
2928
+ this.#dropdownForContainer.style.paddingRight = `${window.innerWidth - inputPos.right}px`;
2929
+ }
2930
+ } else {
2931
+ const inputPos = this.telInput.getBoundingClientRect();
2932
+ this.#dropdownForContainer.style.left = `${inputPos.left}px`;
2933
+ const positionBelow = this.#shouldPositionInlineDropdownBelowInput();
2934
+ if (positionBelow) {
2935
+ this.#dropdownForContainer.style.top = `${inputPos.bottom + LAYOUT.DROPDOWN_MARGIN}px`;
2936
+ } else {
2937
+ this.#dropdownForContainer.style.top = "unset";
2938
+ this.#dropdownForContainer.style.bottom = `${window.innerHeight - inputPos.top + LAYOUT.DROPDOWN_MARGIN}px`;
2939
+ }
2940
+ }
2941
+ dropdownContainer.appendChild(this.#dropdownForContainer);
2942
+ }
2943
+ // Adjust the fullscreen popup dimensions to match the visual viewport,
2944
+ // so it stays above the virtual keyboard on mobile devices.
2945
+ #adjustFullscreenPopupToViewport() {
2946
+ const vv = window.visualViewport;
2947
+ if (!vv || !this.#dropdownForContainer) {
2948
+ return;
2949
+ }
2950
+ const virtualKeyboardHeight = window.innerHeight - vv.height;
2951
+ this.#dropdownForContainer.style.bottom = `${virtualKeyboardHeight}px`;
2952
+ }
2953
+ // UI: Whether the dropdown is currently closed (hidden).
2954
+ isDropdownClosed() {
2955
+ return this.#dropdownContent.classList.contains(CLASSES.HIDE);
2956
+ }
2957
+ setCountry(selectedCountryData) {
2958
+ const { allowDropdown, showFlags, separateDialCode, i18n } = this.#options;
2959
+ const name = selectedCountryData?.name;
2960
+ const dialCode = selectedCountryData?.dialCode;
2961
+ const iso2 = selectedCountryData?.iso2 ?? "";
2962
+ if (allowDropdown) {
2963
+ this.#updateSelectedItem(iso2);
2964
+ }
2965
+ if (this.selectedCountry) {
2966
+ const flagClass = iso2 && showFlags ? `${CLASSES.FLAG} iti__${iso2}` : `${CLASSES.FLAG} ${CLASSES.GLOBE}`;
2967
+ let ariaLabel, title, selectedCountryInner;
2968
+ if (iso2) {
2969
+ title = name;
2970
+ ariaLabel = i18n.selectedCountryAriaLabel.replace("${countryName}", name).replace("${dialCode}", `+${dialCode}`);
2971
+ selectedCountryInner = showFlags ? "" : buildGlobeIcon();
2972
+ } else {
2973
+ title = i18n.noCountrySelected;
2974
+ ariaLabel = i18n.noCountrySelected;
2975
+ selectedCountryInner = buildGlobeIcon();
2976
+ }
2977
+ this.selectedCountryInner.className = flagClass;
2978
+ this.selectedCountry.setAttribute("title", title);
2979
+ this.selectedCountry.setAttribute(ARIA.LABEL, ariaLabel);
2980
+ this.selectedCountryInner.innerHTML = selectedCountryInner;
2981
+ }
2982
+ if (separateDialCode) {
2983
+ const fullDialCode = dialCode ? `+${dialCode}` : "";
2984
+ this.#selectedDialCode.textContent = fullDialCode;
2985
+ this.#updateInputPadding();
2986
+ }
2987
+ }
2988
+ };
2989
+ var processAllCountries = (options) => {
2990
+ const { onlyCountries, excludeCountries } = options;
2991
+ if (onlyCountries?.length) {
2992
+ return data_default.filter(
2993
+ (country) => onlyCountries.includes(country.iso2)
2994
+ );
2995
+ } else if (excludeCountries?.length) {
2996
+ return data_default.filter(
2997
+ (country) => !excludeCountries.includes(country.iso2)
2998
+ );
2999
+ }
3000
+ return [...data_default];
3001
+ };
3002
+ var generateCountryNames = (countries, options) => {
3003
+ const { countryNameLocale, i18n } = options;
3004
+ let displayNames;
3005
+ try {
3006
+ const hasDisplayNames = typeof Intl !== "undefined" && typeof Intl.DisplayNames === "function";
3007
+ if (hasDisplayNames) {
3008
+ displayNames = new Intl.DisplayNames(countryNameLocale, {
3009
+ type: "region"
3010
+ });
3011
+ } else {
3012
+ displayNames = null;
3013
+ }
3014
+ } catch (e) {
3015
+ console.error(e);
3016
+ displayNames = null;
3017
+ }
3018
+ for (const c of countries) {
3019
+ c.name = i18n[c.iso2] || displayNames?.of(c.iso2.toUpperCase()) || "";
3020
+ }
3021
+ };
3022
+ var processDialCodes = (countries) => {
3023
+ const dialCodes = /* @__PURE__ */ new Set();
3024
+ let dialCodeMaxLen = 0;
3025
+ const dialCodeToIso2Map = {};
3026
+ const addToDialCodeMap = (iso2, dialCode) => {
3027
+ if (!iso2 || !dialCode) {
3028
+ return;
3029
+ }
3030
+ if (dialCode.length > dialCodeMaxLen) {
3031
+ dialCodeMaxLen = dialCode.length;
3032
+ }
3033
+ if (!Object.hasOwn(dialCodeToIso2Map, dialCode)) {
3034
+ dialCodeToIso2Map[dialCode] = [];
3035
+ }
3036
+ const iso2List = dialCodeToIso2Map[dialCode];
3037
+ if (iso2List.includes(iso2)) {
3038
+ return;
3039
+ }
3040
+ iso2List.push(iso2);
3041
+ };
3042
+ const countriesSortedByPriority = [...countries].sort(
3043
+ (a, b) => a.priority - b.priority
3044
+ );
3045
+ for (const c of countriesSortedByPriority) {
3046
+ if (!dialCodes.has(c.dialCode)) {
3047
+ dialCodes.add(c.dialCode);
3048
+ }
3049
+ for (let k = 1; k < c.dialCode.length; k++) {
3050
+ const partialDialCode = c.dialCode.substring(0, k);
3051
+ addToDialCodeMap(c.iso2, partialDialCode);
3052
+ }
3053
+ addToDialCodeMap(c.iso2, c.dialCode);
3054
+ if (c.areaCodes) {
3055
+ const rootIso2Code = dialCodeToIso2Map[c.dialCode][0];
3056
+ for (const areaCode of c.areaCodes) {
3057
+ for (let k = 1; k < areaCode.length; k++) {
3058
+ const partialAreaCode = areaCode.substring(0, k);
3059
+ const partialDialCode = c.dialCode + partialAreaCode;
3060
+ addToDialCodeMap(rootIso2Code, partialDialCode);
3061
+ addToDialCodeMap(c.iso2, partialDialCode);
3062
+ }
3063
+ addToDialCodeMap(c.iso2, c.dialCode + areaCode);
3064
+ }
3065
+ }
3066
+ }
3067
+ return { dialCodes, dialCodeMaxLen, dialCodeToIso2Map };
3068
+ };
3069
+ var sortCountries = (countries, options) => {
3070
+ const { countryOrder } = options;
3071
+ countries.sort((a, b) => {
3072
+ if (countryOrder) {
3073
+ const aIndex = countryOrder.indexOf(a.iso2);
3074
+ const bIndex = countryOrder.indexOf(b.iso2);
3075
+ const aIndexExists = aIndex > -1;
3076
+ const bIndexExists = bIndex > -1;
3077
+ if (aIndexExists || bIndexExists) {
3078
+ if (aIndexExists && bIndexExists) {
3079
+ return aIndex - bIndex;
3080
+ }
3081
+ return aIndexExists ? -1 : 1;
3082
+ }
3083
+ }
3084
+ return a.name.localeCompare(b.name);
3085
+ });
3086
+ };
3087
+ var cacheSearchTokens = (countries) => {
3088
+ for (const c of countries) {
3089
+ c.normalisedName = normaliseString(c.name);
3090
+ c.initials = c.normalisedName.split(/[^a-z]/).map((word) => word[0]).join("");
3091
+ c.dialCodePlus = `+${c.dialCode}`;
3092
+ }
3093
+ };
3094
+ var REGIONLESS_DIAL_CODES = /* @__PURE__ */ new Set([
3095
+ "800",
3096
+ "808",
3097
+ "870",
3098
+ "881",
3099
+ "882",
3100
+ "883",
3101
+ "888",
3102
+ "979"
3103
+ ]);
3104
+ var hasRegionlessDialCode = (number) => {
3105
+ const dialCode = getNumeric(number).slice(0, 3);
3106
+ return number.startsWith("+") && REGIONLESS_DIAL_CODES.has(dialCode);
3107
+ };
3108
+ var beforeSetNumber = (fullNumber, hasValidDialCode, separateDialCode, selectedCountryData) => {
3109
+ if (!separateDialCode || !hasValidDialCode) {
3110
+ return fullNumber;
3111
+ }
3112
+ const dialCode = `+${selectedCountryData.dialCode}`;
3113
+ const start = fullNumber[dialCode.length] === " " || fullNumber[dialCode.length] === "-" ? dialCode.length + 1 : dialCode.length;
3114
+ return fullNumber.substring(start);
3115
+ };
3116
+ var formatNumberAsYouType = (fullNumber, telInputValue, utils, selectedCountryData, separateDialCode) => {
3117
+ const result = utils ? utils.formatNumberAsYouType(fullNumber, selectedCountryData?.iso2) : fullNumber;
3118
+ const dialCode = selectedCountryData?.dialCode;
3119
+ if (separateDialCode && telInputValue.charAt(0) !== "+" && result.includes(`+${dialCode}`)) {
3120
+ const afterDialCode = result.split(`+${dialCode}`)[1] || "";
3121
+ return afterDialCode.trim();
3122
+ }
3123
+ return result;
3124
+ };
3125
+ var translateCursorPosition = (relevantChars, formattedValue, prevCaretPos, isDeleteForwards) => {
3126
+ if (prevCaretPos === 0 && !isDeleteForwards) {
3127
+ return 0;
3128
+ }
3129
+ let relevantCharCount = 0;
3130
+ for (let i = 0; i < formattedValue.length; i++) {
3131
+ if (/[+0-9]/.test(formattedValue[i])) {
3132
+ relevantCharCount++;
3133
+ }
3134
+ if (relevantCharCount === relevantChars && !isDeleteForwards) {
3135
+ return i + 1;
3136
+ }
3137
+ if (isDeleteForwards && relevantCharCount === relevantChars + 1) {
3138
+ return i;
3139
+ }
3140
+ }
3141
+ return formattedValue.length;
3142
+ };
3143
+ var regionlessNanpNumbers = /* @__PURE__ */ new Set([
3144
+ "800",
3145
+ "822",
3146
+ "833",
3147
+ "844",
3148
+ "855",
3149
+ "866",
3150
+ "877",
3151
+ "880",
3152
+ "881",
3153
+ "882",
3154
+ "883",
3155
+ "884",
3156
+ "885",
3157
+ "886",
3158
+ "887",
3159
+ "888",
3160
+ "889"
3161
+ ]);
3162
+ var isRegionlessNanp = (number) => {
3163
+ const numeric = getNumeric(number);
3164
+ if (numeric.startsWith(DIAL.NANP) && numeric.length >= 4) {
3165
+ const areaCode = numeric.substring(1, 4);
3166
+ return regionlessNanpNumbers.has(areaCode);
3167
+ }
3168
+ return false;
3169
+ };
3170
+ var Numerals = class {
3171
+ #userNumeralSet;
3172
+ constructor(initialValue) {
3173
+ if (initialValue) {
3174
+ this.#updateNumeralSet(initialValue);
3175
+ }
3176
+ }
3177
+ // If any Arabic-Indic digits, then label it as that set. Same for Persian. Otherwise assume ASCII.
3178
+ #updateNumeralSet(str) {
3179
+ if (/[\u0660-\u0669]/.test(str)) {
3180
+ this.#userNumeralSet = "arabic-indic";
3181
+ } else if (/[\u06F0-\u06F9]/.test(str)) {
3182
+ this.#userNumeralSet = "persian";
3183
+ } else {
3184
+ this.#userNumeralSet = "ascii";
3185
+ }
3186
+ }
3187
+ // Denormalise ASCII 0-9 to the user's numeral set. If not yet known, return as-is.
3188
+ // NOTE: normalise is always called before this, so it should be impossible for the numeral set to be unknown at this point.
3189
+ denormalise(str) {
3190
+ if (!this.#userNumeralSet || this.#userNumeralSet === "ascii") {
3191
+ return str;
3192
+ }
3193
+ const base = this.#userNumeralSet === "arabic-indic" ? 1632 : 1776;
3194
+ return str.replace(/[0-9]/g, (d) => String.fromCharCode(base + Number(d)));
3195
+ }
3196
+ // Normalize Eastern Arabic (U+0660-0669) and Persian/Extended Arabic-Indic (U+06F0-06F9) numerals to ASCII 0-9
3197
+ normalise(str) {
3198
+ if (!str) {
3199
+ return "";
3200
+ }
3201
+ this.#updateNumeralSet(str);
3202
+ if (this.#userNumeralSet === "ascii") {
3203
+ return str;
3204
+ }
3205
+ const base = this.#userNumeralSet === "arabic-indic" ? 1632 : 1776;
3206
+ const regex = this.#userNumeralSet === "arabic-indic" ? /[\u0660-\u0669]/g : /[\u06F0-\u06F9]/g;
3207
+ return str.replace(
3208
+ regex,
3209
+ (ch) => String.fromCharCode(48 + (ch.charCodeAt(0) - base))
3210
+ );
3211
+ }
3212
+ isAscii() {
3213
+ return !this.#userNumeralSet || this.#userNumeralSet === "ascii";
3214
+ }
3215
+ };
3216
+ var id = 0;
3217
+ var ensureUtils = (methodName) => {
3218
+ if (!intlTelInput.utils) {
3219
+ throw new Error(
3220
+ `intlTelInput.utils is required for ${methodName}(). See: https://intl-tel-input.com/docs/utils`
3221
+ );
3222
+ }
3223
+ };
3224
+ var createDeferred = () => {
3225
+ let resolve;
3226
+ let reject;
3227
+ const promise = new Promise((res, rej) => {
3228
+ resolve = res;
3229
+ reject = rej;
3230
+ });
3231
+ return { promise, resolve, reject };
3232
+ };
3233
+ var Iti = class _Iti {
3234
+ //* PUBLIC FIELDS - READONLY
3235
+ //* Can't be private as it's called from intlTelInput convenience wrapper.
3236
+ id;
3237
+ // accessed externally via iti.promise.then(...)
3238
+ promise;
3239
+ //* PRIVATE FIELDS
3240
+ #ui;
3241
+ #options;
3242
+ #isAndroid;
3243
+ // country data
3244
+ #countries;
3245
+ #dialCodeMaxLen;
3246
+ #dialCodeToIso2Map;
3247
+ #dialCodes;
3248
+ #countryByIso2;
3249
+ #selectedCountryData = null;
3250
+ #maxCoreNumberLength = null;
3251
+ #defaultCountry;
3252
+ #destroyed = false;
3253
+ #abortController;
3254
+ #dropdownAbortController = null;
3255
+ #numerals;
3256
+ #autoCountryDeferred;
3257
+ #utilsScriptDeferred;
3258
+ constructor(input, customOptions = {}) {
3259
+ this.id = id++;
3260
+ UI.validateInput(input);
3261
+ const validatedOptions = validateOptions(customOptions);
3262
+ this.#options = { ...defaults, ...validatedOptions };
3263
+ normaliseOptions(this.#options);
3264
+ applyOptionSideEffects(this.#options);
3265
+ this.#ui = new UI(input, this.#options, this.id);
3266
+ this.#isAndroid = getIsAndroid();
3267
+ this.#numerals = new Numerals(input.value);
3268
+ this.promise = this.#createInitPromises(this.#options);
3269
+ this.#countries = processAllCountries(this.#options);
3270
+ const { dialCodes, dialCodeMaxLen, dialCodeToIso2Map } = processDialCodes(
3271
+ this.#countries
3272
+ );
3273
+ this.#dialCodes = dialCodes;
3274
+ this.#dialCodeMaxLen = dialCodeMaxLen;
3275
+ this.#dialCodeToIso2Map = dialCodeToIso2Map;
3276
+ this.#countryByIso2 = new Map(this.#countries.map((c) => [c.iso2, c]));
3277
+ this.#init();
3278
+ }
3279
+ #getTelInputValue() {
3280
+ const inputValue = this.#ui.telInput.value.trim();
3281
+ return this.#numerals.normalise(inputValue);
3282
+ }
3283
+ #setTelInputValue(asciiValue) {
3284
+ this.#ui.telInput.value = this.#numerals.denormalise(asciiValue);
3285
+ }
3286
+ #createInitPromises(options) {
3287
+ const { initialCountry, geoIpLookup, loadUtils } = options;
3288
+ const needsAutoCountryPromise = initialCountry === INITIAL_COUNTRY.AUTO && Boolean(geoIpLookup);
3289
+ const needsUtilsScriptPromise = Boolean(loadUtils) && !intlTelInput.utils;
3290
+ if (needsAutoCountryPromise) {
3291
+ this.#autoCountryDeferred = createDeferred();
3292
+ }
3293
+ if (needsUtilsScriptPromise) {
3294
+ this.#utilsScriptDeferred = createDeferred();
3295
+ }
3296
+ return Promise.all([
3297
+ this.#autoCountryDeferred?.promise,
3298
+ this.#utilsScriptDeferred?.promise
3299
+ ]).then(() => {
3300
+ });
3301
+ }
3302
+ #init() {
3303
+ this.#abortController = new AbortController();
3304
+ this.#processCountryData();
3305
+ this.#ui.generateMarkup(this.#countries);
3306
+ this.#setInitialState();
3307
+ this.#initListeners();
3308
+ this.#initRequests();
3309
+ if (this.#options.dropdownAlwaysOpen) {
3310
+ this.#openDropdown();
3311
+ }
3312
+ }
3313
+ //********************
3314
+ //* PRIVATE METHODS
3315
+ //********************
3316
+ //* Prepare all of the country data, including onlyCountries, excludeCountries, countryOrder options.
3317
+ #processCountryData() {
3318
+ generateCountryNames(this.#countries, this.#options);
3319
+ sortCountries(this.#countries, this.#options);
3320
+ cacheSearchTokens(this.#countries);
3321
+ }
3322
+ //* Set the initial state of the input value and the selected country by:
3323
+ //* 1. Extracting a dial code from the given number
3324
+ //* 2. Using explicit initialCountry
3325
+ #setInitialState(overrideAutoCountry = false) {
3326
+ const attributeValueRaw = this.#ui.telInput.getAttribute("value");
3327
+ const attributeValue = this.#numerals.normalise(attributeValueRaw ?? "");
3328
+ const inputValue = this.#getTelInputValue();
3329
+ const useAttribute = attributeValue && attributeValue.startsWith("+") && (!inputValue || !inputValue.startsWith("+"));
3330
+ const val = useAttribute ? attributeValue : inputValue;
3331
+ const dialCode = this.#getDialCode(val);
3332
+ const isRegionlessNanpNumber = isRegionlessNanp(val);
3333
+ const { initialCountry, geoIpLookup } = this.#options;
3334
+ const isAutoCountry = initialCountry === INITIAL_COUNTRY.AUTO && geoIpLookup;
3335
+ const doingAutoCountryLookup = isAutoCountry && !overrideAutoCountry;
3336
+ const isValidInitialCountry = isIso2(initialCountry);
3337
+ if (dialCode) {
3338
+ if (isRegionlessNanpNumber) {
3339
+ if (isValidInitialCountry) {
3340
+ this.#setCountry(initialCountry);
3341
+ } else if (!doingAutoCountryLookup) {
3342
+ this.#setCountry(US.ISO2);
3343
+ }
3344
+ } else {
3345
+ this.#updateCountryFromNumber(val);
3346
+ }
3347
+ } else if (isValidInitialCountry) {
3348
+ this.#setCountry(initialCountry);
3349
+ } else if (!doingAutoCountryLookup) {
3350
+ this.#setCountry("");
3351
+ }
3352
+ if (val) {
3353
+ this.#updateValFromNumber(val);
3354
+ }
3355
+ }
3356
+ //* Initialise the main event listeners: input keyup, and click selected country.
3357
+ #initListeners() {
3358
+ this.#initTelInputListeners();
3359
+ if (this.#options.allowDropdown) {
3360
+ this.#initDropdownListeners();
3361
+ }
3362
+ if ((this.#ui.hiddenInputPhone || this.#ui.hiddenInputCountry) && this.#ui.telInput.form) {
3363
+ this.#initHiddenInputListener();
3364
+ }
3365
+ }
3366
+ //* Update hidden input on form submit.
3367
+ #initHiddenInputListener() {
3368
+ const handleHiddenInputSubmit = () => {
3369
+ if (this.#ui.hiddenInputPhone) {
3370
+ this.#ui.hiddenInputPhone.value = this.getNumber();
3371
+ }
3372
+ if (this.#ui.hiddenInputCountry) {
3373
+ this.#ui.hiddenInputCountry.value = this.#selectedCountryData?.iso2 || "";
3374
+ }
3375
+ };
3376
+ this.#ui.telInput.form?.addEventListener(
3377
+ "submit",
3378
+ handleHiddenInputSubmit,
3379
+ {
3380
+ signal: this.#abortController.signal
3381
+ }
3382
+ );
3383
+ }
3384
+ //* initialise the dropdown listeners.
3385
+ #initDropdownListeners() {
3386
+ const signal = this.#abortController.signal;
3387
+ const handleLabelClick = (e) => {
3388
+ if (this.#ui.isDropdownClosed()) {
3389
+ this.#ui.telInput.focus();
3390
+ } else {
3391
+ e.preventDefault();
3392
+ }
3393
+ };
3394
+ const label = this.#ui.telInput.closest("label");
3395
+ if (label) {
3396
+ label.addEventListener("click", handleLabelClick, { signal });
3397
+ }
3398
+ const handleClickSelectedCountry = () => {
3399
+ if (this.#ui.isDropdownClosed() && !this.#ui.telInput.disabled && !this.#ui.telInput.readOnly) {
3400
+ this.#openDropdown();
3401
+ }
3402
+ };
3403
+ this.#ui.selectedCountry.addEventListener(
3404
+ "click",
3405
+ handleClickSelectedCountry,
3406
+ {
3407
+ signal
3408
+ }
3409
+ );
3410
+ const handleCountryContainerKeydown = (e) => {
3411
+ const allowedKeys = [
3412
+ KEYS.ARROW_UP,
3413
+ KEYS.ARROW_DOWN,
3414
+ KEYS.SPACE,
3415
+ KEYS.ENTER
3416
+ ];
3417
+ if (this.#ui.isDropdownClosed() && allowedKeys.includes(e.key)) {
3418
+ e.preventDefault();
3419
+ e.stopPropagation();
3420
+ this.#openDropdown();
3421
+ }
3422
+ if (e.key === KEYS.TAB) {
3423
+ this.#closeDropdown();
3424
+ }
3425
+ };
3426
+ this.#ui.countryContainer.addEventListener(
3427
+ "keydown",
3428
+ handleCountryContainerKeydown,
3429
+ { signal }
3430
+ );
3431
+ }
3432
+ //* Init requests: utils script / geo ip lookup.
3433
+ #initRequests() {
3434
+ if (this.#utilsScriptDeferred) {
3435
+ const { loadUtils } = this.#options;
3436
+ const doAttachUtils = () => {
3437
+ intlTelInput.attachUtils(loadUtils)?.catch(() => {
3438
+ });
3439
+ };
3440
+ if (intlTelInput.documentReady()) {
3441
+ doAttachUtils();
3442
+ } else {
3443
+ window.addEventListener("load", doAttachUtils, {
3444
+ signal: this.#abortController.signal
3445
+ });
3446
+ }
3447
+ }
3448
+ if (this.#autoCountryDeferred) {
3449
+ if (this.#selectedCountryData) {
3450
+ this.#autoCountryDeferred.resolve();
3451
+ } else {
3452
+ this.#loadAutoCountry();
3453
+ }
3454
+ }
3455
+ }
3456
+ //* Perform the geo ip lookup.
3457
+ #loadAutoCountry() {
3458
+ if (intlTelInput.autoCountry) {
3459
+ this.#handleAutoCountry();
3460
+ return;
3461
+ }
3462
+ this.#ui.selectedCountryInner.classList.add(CLASSES.LOADING);
3463
+ if (intlTelInput.startedLoadingAutoCountry) {
3464
+ return;
3465
+ }
3466
+ intlTelInput.startedLoadingAutoCountry = true;
3467
+ if (typeof this.#options.geoIpLookup === "function") {
3468
+ const successCallback = (iso2 = "") => {
3469
+ this.#ui.selectedCountryInner.classList.remove(CLASSES.LOADING);
3470
+ const iso2Lower = iso2.toLowerCase();
3471
+ if (isIso2(iso2Lower)) {
3472
+ intlTelInput.autoCountry = iso2Lower;
3473
+ setTimeout(() => _Iti.forEachInstance("handleAutoCountry"));
3474
+ } else {
3475
+ _Iti.forEachInstance("handleAutoCountryFailure");
3476
+ }
3477
+ };
3478
+ const failureCallback = () => {
3479
+ this.#ui.selectedCountryInner.classList.remove(CLASSES.LOADING);
3480
+ _Iti.forEachInstance("handleAutoCountryFailure");
3481
+ };
3482
+ this.#options.geoIpLookup(successCallback, failureCallback);
3483
+ }
3484
+ }
3485
+ #openDropdownWithPlus() {
3486
+ this.#openDropdown();
3487
+ this.#ui.searchInput.value = "+";
3488
+ this.#ui.filterCountriesByQuery("");
3489
+ }
3490
+ //* Initialize the tel input listeners.
3491
+ #initTelInputListeners() {
3492
+ this.#bindInputListener();
3493
+ this.#maybeBindKeydownListener();
3494
+ this.#maybeBindPasteListener();
3495
+ }
3496
+ #bindInputListener() {
3497
+ const {
3498
+ strictMode,
3499
+ formatAsYouType,
3500
+ separateDialCode,
3501
+ allowDropdown,
3502
+ countrySearch
3503
+ } = this.#options;
3504
+ let userOverrideFormatting = false;
3505
+ if (REGEX.ALPHA_UNICODE.test(this.#getTelInputValue())) {
3506
+ userOverrideFormatting = true;
3507
+ }
3508
+ const handleInputEvent = (e) => {
3509
+ const inputValue = this.#getTelInputValue();
3510
+ if (this.#isAndroid && e?.data === "+" && separateDialCode && allowDropdown && countrySearch) {
3511
+ const currentCaretPos = this.#ui.telInput.selectionStart || 0;
3512
+ const valueBeforeCaret = inputValue.substring(0, currentCaretPos - 1);
3513
+ const valueAfterCaret = inputValue.substring(currentCaretPos);
3514
+ this.#setTelInputValue(valueBeforeCaret + valueAfterCaret);
3515
+ this.#openDropdownWithPlus();
3516
+ return;
3517
+ }
3518
+ if (this.#updateCountryFromNumber(inputValue)) {
3519
+ this.#triggerCountryChange();
3520
+ }
3521
+ const isFormattingChar = e?.data && REGEX.NON_PLUS_NUMERIC.test(e.data);
3522
+ const isPaste = e?.inputType === INPUT_TYPES.PASTE && inputValue;
3523
+ if (isFormattingChar || isPaste && !strictMode) {
3524
+ userOverrideFormatting = true;
3525
+ } else if (!REGEX.NON_PLUS_NUMERIC.test(inputValue)) {
3526
+ userOverrideFormatting = false;
3527
+ }
3528
+ const isSetNumber = e?.detail && e.detail["isSetNumber"];
3529
+ const isAscii = this.#numerals.isAscii();
3530
+ if (formatAsYouType && !userOverrideFormatting && !isSetNumber && isAscii) {
3531
+ const currentCaretPos = this.#ui.telInput.selectionStart || 0;
3532
+ const valueBeforeCaret = inputValue.substring(0, currentCaretPos);
3533
+ const relevantCharsBeforeCaret = valueBeforeCaret.replace(
3534
+ REGEX.NON_PLUS_NUMERIC_GLOBAL,
3535
+ ""
3536
+ ).length;
3537
+ const isDeleteForwards = e?.inputType === INPUT_TYPES.DELETE_FWD;
3538
+ const fullNumber = this.#getFullNumber();
3539
+ const formattedValue = formatNumberAsYouType(
3540
+ fullNumber,
3541
+ inputValue,
3542
+ intlTelInput.utils,
3543
+ this.#selectedCountryData,
3544
+ separateDialCode
3545
+ );
3546
+ const newCaretPos = translateCursorPosition(
3547
+ relevantCharsBeforeCaret,
3548
+ formattedValue,
3549
+ currentCaretPos,
3550
+ isDeleteForwards
3551
+ );
3552
+ this.#setTelInputValue(formattedValue);
3553
+ this.#ui.telInput.setSelectionRange(newCaretPos, newCaretPos);
3554
+ }
3555
+ if (separateDialCode && inputValue.startsWith("+") && this.#selectedCountryData?.dialCode) {
3556
+ const cleanNumber = beforeSetNumber(
3557
+ inputValue,
3558
+ true,
3559
+ separateDialCode,
3560
+ this.#selectedCountryData
3561
+ );
3562
+ this.#setTelInputValue(cleanNumber);
3563
+ }
3564
+ };
3565
+ this.#ui.telInput.addEventListener(
3566
+ "input",
3567
+ handleInputEvent,
3568
+ {
3569
+ signal: this.#abortController.signal
3570
+ }
3571
+ );
3572
+ }
3573
+ #maybeBindKeydownListener() {
3574
+ const { strictMode, separateDialCode, allowDropdown, countrySearch } = this.#options;
3575
+ if (!strictMode && !separateDialCode) {
3576
+ return;
3577
+ }
3578
+ const handleKeydownEvent = (e) => {
3579
+ if (!e.key || e.key.length !== 1 || e.altKey || e.ctrlKey || e.metaKey) {
3580
+ return;
3581
+ }
3582
+ if (separateDialCode && allowDropdown && countrySearch && e.key === "+") {
3583
+ e.preventDefault();
3584
+ this.#openDropdownWithPlus();
3585
+ return;
3586
+ }
3587
+ if (!strictMode) {
3588
+ return;
3589
+ }
3590
+ const inputValue = this.#getTelInputValue();
3591
+ const alreadyHasPlus = inputValue.startsWith("+");
3592
+ const isInitialPlus = !alreadyHasPlus && this.#ui.telInput.selectionStart === 0 && e.key === "+";
3593
+ const normalisedKey = this.#numerals.normalise(e.key);
3594
+ const isNumeric = /^[0-9]$/.test(normalisedKey);
3595
+ const isAllowedChar = separateDialCode ? isNumeric : isInitialPlus || isNumeric;
3596
+ const input = this.#ui.telInput;
3597
+ const selStart = input.selectionStart;
3598
+ const selEnd = input.selectionEnd;
3599
+ const before = inputValue.slice(0, selStart ?? void 0);
3600
+ const after = inputValue.slice(selEnd ?? void 0);
3601
+ const newValue = before + e.key + after;
3602
+ const newFullNumber = this.#getFullNumber(newValue);
3603
+ let hasExceededMaxLength = false;
3604
+ if (intlTelInput.utils && this.#maxCoreNumberLength) {
3605
+ const coreNumber = intlTelInput.utils.getCoreNumber(
3606
+ newFullNumber,
3607
+ this.#selectedCountryData?.iso2
3608
+ );
3609
+ hasExceededMaxLength = coreNumber.length > this.#maxCoreNumberLength;
3610
+ }
3611
+ const newCountry = this.#getNewCountryFromNumber(newFullNumber);
3612
+ const isChangingDialCode = newCountry !== null;
3613
+ if (!isAllowedChar || hasExceededMaxLength && !isChangingDialCode && !isInitialPlus) {
3614
+ e.preventDefault();
3615
+ }
3616
+ };
3617
+ this.#ui.telInput.addEventListener("keydown", handleKeydownEvent, {
3618
+ signal: this.#abortController.signal
3619
+ });
3620
+ }
3621
+ #maybeBindPasteListener() {
3622
+ if (!this.#options.strictMode) {
3623
+ return;
3624
+ }
3625
+ const handlePasteEvent = (e) => {
3626
+ e.preventDefault();
3627
+ const input = this.#ui.telInput;
3628
+ const selStart = input.selectionStart;
3629
+ const selEnd = input.selectionEnd;
3630
+ const inputValue = this.#getTelInputValue();
3631
+ const before = inputValue.slice(0, selStart ?? void 0);
3632
+ const after = inputValue.slice(selEnd ?? void 0);
3633
+ const iso2 = this.#selectedCountryData?.iso2;
3634
+ const pastedRaw = e.clipboardData.getData("text");
3635
+ const pasted = this.#numerals.normalise(pastedRaw);
3636
+ const initialCharSelected = selStart === 0 && selEnd > 0;
3637
+ const allowLeadingPlus = !inputValue.startsWith("+") || initialCharSelected;
3638
+ const allowedChars = pasted.replace(REGEX.NON_PLUS_NUMERIC_GLOBAL, "");
3639
+ const hasLeadingPlus = allowedChars.startsWith("+");
3640
+ const numerics = allowedChars.replace(/\+/g, "");
3641
+ const sanitised = hasLeadingPlus && allowLeadingPlus ? `+${numerics}` : numerics;
3642
+ let newVal = before + sanitised + after;
3643
+ if (newVal.length > 5 && intlTelInput.utils) {
3644
+ let coreNumber = intlTelInput.utils.getCoreNumber(newVal, iso2);
3645
+ while (coreNumber.length === 0 && newVal.length > 0) {
3646
+ newVal = newVal.slice(0, -1);
3647
+ coreNumber = intlTelInput.utils.getCoreNumber(newVal, iso2);
3648
+ }
3649
+ if (!coreNumber) {
3650
+ return;
3651
+ }
3652
+ if (this.#maxCoreNumberLength && coreNumber.length > this.#maxCoreNumberLength) {
3653
+ if (input.selectionEnd === inputValue.length) {
3654
+ const trimLength = coreNumber.length - this.#maxCoreNumberLength;
3655
+ newVal = newVal.slice(0, newVal.length - trimLength);
3656
+ } else {
3657
+ return;
3658
+ }
3659
+ }
3660
+ }
3661
+ this.#setTelInputValue(newVal);
3662
+ const caretPos = selStart + sanitised.length;
3663
+ input.setSelectionRange(caretPos, caretPos);
3664
+ input.dispatchEvent(new InputEvent("input", { bubbles: true }));
3665
+ };
3666
+ this.#ui.telInput.addEventListener("paste", handlePasteEvent, {
3667
+ signal: this.#abortController.signal
3668
+ });
3669
+ }
3670
+ //* Adhere to the input's maxlength attr.
3671
+ #cap(number) {
3672
+ const max = Number(this.#ui.telInput.getAttribute("maxlength"));
3673
+ return max && number.length > max ? number.substring(0, max) : number;
3674
+ }
3675
+ //* Trigger a custom event on the input (typed via ItiEventMap).
3676
+ #trigger(name, detailProps = {}) {
3677
+ const e = new CustomEvent(name, {
3678
+ bubbles: true,
3679
+ cancelable: true,
3680
+ detail: detailProps
3681
+ });
3682
+ this.#ui.telInput.dispatchEvent(e);
3683
+ }
3684
+ //* Open the dropdown.
3685
+ #openDropdown() {
3686
+ const { dropdownContainer, useFullscreenPopup } = this.#options;
3687
+ this.#dropdownAbortController = new AbortController();
3688
+ this.#ui.openDropdown();
3689
+ if (!useFullscreenPopup && dropdownContainer) {
3690
+ const handleWindowScroll = () => this.#closeDropdown();
3691
+ window.addEventListener("scroll", handleWindowScroll, {
3692
+ signal: this.#dropdownAbortController.signal
3693
+ });
3694
+ }
3695
+ this.#bindDropdownListeners();
3696
+ this.#trigger(EVENTS.OPEN_COUNTRY_DROPDOWN);
3697
+ }
3698
+ //* We only bind dropdown listeners when the dropdown is open.
3699
+ #bindDropdownListeners() {
3700
+ const signal = this.#dropdownAbortController.signal;
3701
+ this.#bindDropdownMouseoverListener(signal);
3702
+ this.#bindDropdownCountryClickListener(signal);
3703
+ if (!this.#options.dropdownAlwaysOpen) {
3704
+ this.#bindDropdownClickOffListener(signal);
3705
+ }
3706
+ this.#bindDropdownKeydownListener(signal);
3707
+ if (this.#options.countrySearch) {
3708
+ this.#bindDropdownSearchListeners(signal);
3709
+ }
3710
+ }
3711
+ //* When mouse over a list item, just highlight that one
3712
+ //* we add the class "highlight", so if they hit "enter" we know which one to select.
3713
+ #bindDropdownMouseoverListener(signal) {
3714
+ const handleMouseoverCountryList = (e) => {
3715
+ const listItem = e.target?.closest(
3716
+ `.${CLASSES.COUNTRY_ITEM}`
3717
+ );
3718
+ if (listItem) {
3719
+ this.#ui.highlightListItem(listItem, false);
3720
+ }
3721
+ };
3722
+ this.#ui.countryList.addEventListener(
3723
+ "mouseover",
3724
+ handleMouseoverCountryList,
3725
+ {
3726
+ signal
3727
+ }
3728
+ );
3729
+ }
3730
+ //* Listen for country selection.
3731
+ #bindDropdownCountryClickListener(signal) {
3732
+ const handleClickCountryList = (e) => {
3733
+ const listItem = e.target?.closest(
3734
+ `.${CLASSES.COUNTRY_ITEM}`
3735
+ );
3736
+ if (listItem) {
3737
+ this.#selectListItem(listItem);
3738
+ }
3739
+ };
3740
+ this.#ui.countryList.addEventListener("click", handleClickCountryList, {
3741
+ signal
3742
+ });
3743
+ }
3744
+ //* Click off to close (except when this initial opening click is bubbling up).
3745
+ //* We cannot just stopPropagation as it may be needed to close another instance.
3746
+ #bindDropdownClickOffListener(signal) {
3747
+ const handleClickOffToClose = (e) => {
3748
+ const target = e.target;
3749
+ const clickedInsideDropdown = !!target.closest(
3750
+ `#iti-${this.id}__dropdown-content`
3751
+ );
3752
+ if (!clickedInsideDropdown) {
3753
+ this.#closeDropdown();
3754
+ }
3755
+ };
3756
+ setTimeout(() => {
3757
+ document.documentElement.addEventListener(
3758
+ "click",
3759
+ handleClickOffToClose,
3760
+ { signal }
3761
+ );
3762
+ }, 0);
3763
+ }
3764
+ //* Listen for up/down scrolling, enter to select, or escape to close.
3765
+ //* Use keydown as keypress doesn't fire for non-char keys and we want to catch if they
3766
+ //* just hit down and hold it to scroll down (no keyup event).
3767
+ //* Listen on the document because that's where key events are triggered if no input has focus.
3768
+ #bindDropdownKeydownListener(signal) {
3769
+ let query = "";
3770
+ let queryTimer = null;
3771
+ const handleKeydownOnDropdown = (e) => {
3772
+ const allowedKeys = [
3773
+ KEYS.ARROW_UP,
3774
+ KEYS.ARROW_DOWN,
3775
+ KEYS.ENTER,
3776
+ KEYS.ESC
3777
+ ];
3778
+ if (allowedKeys.includes(e.key)) {
3779
+ e.preventDefault();
3780
+ e.stopPropagation();
3781
+ if (e.key === KEYS.ARROW_UP || e.key === KEYS.ARROW_DOWN) {
3782
+ this.#ui.handleUpDownKey(e.key);
3783
+ } else if (e.key === KEYS.ENTER && !e.isComposing) {
3784
+ this.#handleEnterKey();
3785
+ } else if (e.key === KEYS.ESC) {
3786
+ this.#closeDropdown();
3787
+ this.#ui.selectedCountry.focus();
3788
+ }
3789
+ }
3790
+ if (!this.#options.countrySearch && REGEX.HIDDEN_SEARCH_CHAR.test(e.key)) {
3791
+ e.stopPropagation();
3792
+ if (queryTimer) {
3793
+ clearTimeout(queryTimer);
3794
+ }
3795
+ query += e.key.toLowerCase();
3796
+ this.#searchForCountry(query);
3797
+ queryTimer = setTimeout(() => {
3798
+ query = "";
3799
+ }, TIMINGS.HIDDEN_SEARCH_RESET_MS);
3800
+ }
3801
+ };
3802
+ document.addEventListener("keydown", handleKeydownOnDropdown, { signal });
3803
+ }
3804
+ //* Search input listeners when countrySearch enabled.
3805
+ #bindDropdownSearchListeners(signal) {
3806
+ this.#ui.searchInput.addEventListener(
3807
+ "input",
3808
+ () => this.#ui.handleSearchChange(),
3809
+ { signal }
3810
+ );
3811
+ this.#ui.searchClearButton.addEventListener(
3812
+ "click",
3813
+ () => this.#ui.handleSearchClear(),
3814
+ { signal }
3815
+ );
3816
+ }
3817
+ //* Hidden search (countrySearch disabled): Find the first list item whose name starts with the query string.
3818
+ #searchForCountry(query) {
3819
+ const match = findFirstCountryStartingWith(this.#countries, query);
3820
+ if (match) {
3821
+ const listItem = match.nodeById[this.id];
3822
+ this.#ui.highlightListItem(listItem, false);
3823
+ this.#ui.scrollCountryListToItem(listItem);
3824
+ }
3825
+ }
3826
+ //* Select the currently highlighted item.
3827
+ #handleEnterKey() {
3828
+ if (this.#ui.highlightedItem) {
3829
+ this.#selectListItem(this.#ui.highlightedItem);
3830
+ }
3831
+ }
3832
+ //* Update the input's value to the given val (format first if possible)
3833
+ //* NOTE: this is called from _setInitialState, handleUtils and setNumber.
3834
+ #updateValFromNumber(fullNumber) {
3835
+ const { formatOnDisplay, nationalMode, separateDialCode } = this.#options;
3836
+ let number = fullNumber;
3837
+ if (formatOnDisplay && intlTelInput.utils && this.#selectedCountryData) {
3838
+ const isRegionless = hasRegionlessDialCode(fullNumber);
3839
+ const useNational = nationalMode && !isRegionless || !number.startsWith("+") && !separateDialCode;
3840
+ const { NATIONAL, INTERNATIONAL } = intlTelInput.utils.numberFormat;
3841
+ const format = useNational ? NATIONAL : INTERNATIONAL;
3842
+ number = intlTelInput.utils.formatNumber(
3843
+ number,
3844
+ this.#selectedCountryData?.iso2,
3845
+ format
3846
+ );
3847
+ }
3848
+ number = this.#beforeSetNumber(number);
3849
+ this.#setTelInputValue(number);
3850
+ }
3851
+ //* Check if need to select a new country based on the given number
3852
+ //* Note: called from _setInitialState, keyup handler, setNumber.
3853
+ #updateCountryFromNumber(fullNumber) {
3854
+ const iso2 = this.#getNewCountryFromNumber(fullNumber);
3855
+ if (iso2 !== null) {
3856
+ return this.#setCountry(iso2);
3857
+ }
3858
+ return false;
3859
+ }
3860
+ // if there is a selected country, and the number doesn't start with a dial code, then add it
3861
+ #ensureHasDialCode(number) {
3862
+ const dialCode = this.#selectedCountryData?.dialCode;
3863
+ const nationalPrefix = this.#selectedCountryData?.nationalPrefix;
3864
+ const alreadyHasPlus = number.startsWith("+");
3865
+ if (alreadyHasPlus || !dialCode) {
3866
+ return number;
3867
+ }
3868
+ const hasPrefix = nationalPrefix && number.startsWith(nationalPrefix) && !this.#options.separateDialCode;
3869
+ const cleanNumber = hasPrefix ? number.substring(1) : number;
3870
+ return `+${dialCode}${cleanNumber}`;
3871
+ }
3872
+ //* Get the new country based on the input number, or return null if no change, or empty string if should be empty (e.g. if they type an invalid dial code).
3873
+ #getNewCountryFromNumber(fullNumber) {
3874
+ const plusIndex = fullNumber.indexOf("+");
3875
+ let number = plusIndex > 0 ? fullNumber.substring(plusIndex) : fullNumber;
3876
+ const selectedIso2 = this.#selectedCountryData?.iso2;
3877
+ const selectedDialCode = this.#selectedCountryData?.dialCode;
3878
+ number = this.#ensureHasDialCode(number);
3879
+ const dialCodeMatch = this.#getDialCode(number, true);
3880
+ const numeric = getNumeric(number);
3881
+ if (dialCodeMatch) {
3882
+ const dialCodeMatchNumeric = getNumeric(dialCodeMatch);
3883
+ const iso2Codes = this.#dialCodeToIso2Map[dialCodeMatchNumeric];
3884
+ if (iso2Codes.length === 1) {
3885
+ if (iso2Codes[0] === selectedIso2) {
3886
+ return null;
3887
+ }
3888
+ return iso2Codes[0];
3889
+ }
3890
+ if (!selectedIso2 && this.#defaultCountry && iso2Codes.includes(this.#defaultCountry)) {
3891
+ return this.#defaultCountry;
3892
+ }
3893
+ const isRegionlessNanpNumber = selectedDialCode === DIAL.NANP && isRegionlessNanp(numeric);
3894
+ if (isRegionlessNanpNumber) {
3895
+ return null;
3896
+ }
3897
+ const areaCodes = this.#selectedCountryData?.areaCodes;
3898
+ const priority = this.#selectedCountryData?.priority;
3899
+ if (areaCodes) {
3900
+ const dialCodeAreaCodes = areaCodes.map(
3901
+ (areaCode) => `${selectedDialCode}${areaCode}`
3902
+ );
3903
+ for (const dialCodeAreaCode of dialCodeAreaCodes) {
3904
+ if (numeric.startsWith(dialCodeAreaCode)) {
3905
+ return null;
3906
+ }
3907
+ }
3908
+ }
3909
+ const isMainCountry = priority === 0;
3910
+ const hasAreaCodesButNoneMatched = areaCodes && !isMainCountry && numeric.length > dialCodeMatchNumeric.length;
3911
+ const isValidSelection = selectedIso2 && iso2Codes.includes(selectedIso2) && !hasAreaCodesButNoneMatched;
3912
+ const alreadySelected = selectedIso2 === iso2Codes[0];
3913
+ if (!isValidSelection && !alreadySelected) {
3914
+ return iso2Codes[0];
3915
+ }
3916
+ } else if (number.startsWith("+") && numeric.length) {
3917
+ const currentDial = this.#selectedCountryData?.dialCode || "";
3918
+ if (currentDial && currentDial.startsWith(numeric)) {
3919
+ return null;
3920
+ }
3921
+ return "";
3922
+ } else if ((!number || number === "+") && !selectedIso2 && this.#defaultCountry) {
3923
+ return this.#defaultCountry;
3924
+ }
3925
+ return null;
3926
+ }
3927
+ //* Update the selected country, dial code (if separateDialCode), placeholder, title, and selected list item.
3928
+ //* Note: called from _setInitialState, _updateCountryFromNumber, _selectListItem, setCountry.
3929
+ #setCountry(iso2) {
3930
+ const prevIso2 = this.#selectedCountryData?.iso2 || "";
3931
+ this.#selectedCountryData = iso2 ? this.#countryByIso2.get(iso2) : null;
3932
+ if (this.#selectedCountryData) {
3933
+ this.#defaultCountry = this.#selectedCountryData.iso2;
3934
+ }
3935
+ this.#ui.setCountry(this.#selectedCountryData);
3936
+ this.#updatePlaceholder();
3937
+ this.#updateMaxLength();
3938
+ return prevIso2 !== iso2;
3939
+ }
3940
+ //* Update the maximum valid number length for the currently selected country.
3941
+ #updateMaxLength() {
3942
+ const { strictMode, placeholderNumberType, allowedNumberTypes } = this.#options;
3943
+ if (!strictMode || !intlTelInput.utils) {
3944
+ return;
3945
+ }
3946
+ const iso2 = this.#selectedCountryData?.iso2;
3947
+ if (!iso2) {
3948
+ this.#maxCoreNumberLength = null;
3949
+ return;
3950
+ }
3951
+ const numberType = intlTelInput.utils.numberType[placeholderNumberType];
3952
+ let exampleNumber = intlTelInput.utils.getExampleNumber(
3953
+ iso2,
3954
+ false,
3955
+ numberType,
3956
+ true
3957
+ );
3958
+ let validNumber = exampleNumber;
3959
+ while (intlTelInput.utils.isPossibleNumber(
3960
+ exampleNumber,
3961
+ iso2,
3962
+ allowedNumberTypes
3963
+ )) {
3964
+ validNumber = exampleNumber;
3965
+ exampleNumber += "0";
3966
+ }
3967
+ const coreNumber = intlTelInput.utils.getCoreNumber(validNumber, iso2);
3968
+ this.#maxCoreNumberLength = coreNumber.length;
3969
+ if (iso2 === "by") {
3970
+ this.#maxCoreNumberLength = coreNumber.length + 1;
3971
+ }
3972
+ }
3973
+ //* Update the input placeholder to an example number from the currently selected country.
3974
+ #updatePlaceholder() {
3975
+ const {
3976
+ autoPlaceholder,
3977
+ placeholderNumberType,
3978
+ nationalMode,
3979
+ customPlaceholder
3980
+ } = this.#options;
3981
+ const shouldSetPlaceholder = autoPlaceholder === PLACEHOLDER_MODES.AGGRESSIVE || !this.#ui.hadInitialPlaceholder && autoPlaceholder === PLACEHOLDER_MODES.POLITE;
3982
+ if (!intlTelInput.utils || !shouldSetPlaceholder) {
3983
+ return;
3984
+ }
3985
+ const numberType = intlTelInput.utils.numberType[placeholderNumberType];
3986
+ let placeholder = this.#selectedCountryData ? intlTelInput.utils.getExampleNumber(
3987
+ this.#selectedCountryData.iso2,
3988
+ nationalMode,
3989
+ numberType
3990
+ ) : "";
3991
+ placeholder = this.#beforeSetNumber(placeholder);
3992
+ if (typeof customPlaceholder === "function") {
3993
+ placeholder = customPlaceholder(placeholder, this.#selectedCountryData);
3994
+ }
3995
+ this.#ui.telInput.setAttribute("placeholder", placeholder);
3996
+ }
3997
+ //* Called when the user selects a list item from the dropdown.
3998
+ #selectListItem(listItem) {
3999
+ const iso2 = listItem.dataset[DATA_KEYS.COUNTRY_CODE];
4000
+ const countryChanged = this.#setCountry(iso2);
4001
+ this.#closeDropdown();
4002
+ const dialCode = listItem.dataset[DATA_KEYS.DIAL_CODE];
4003
+ this.#updateDialCode(dialCode);
4004
+ if (this.#options.formatOnDisplay) {
4005
+ const inputValue = this.#getTelInputValue();
4006
+ this.#updateValFromNumber(inputValue);
4007
+ }
4008
+ this.#ui.telInput.focus();
4009
+ if (countryChanged) {
4010
+ this.#triggerCountryChange();
4011
+ }
4012
+ }
4013
+ //* Close the dropdown and unbind any listeners.
4014
+ #closeDropdown(isDestroy) {
4015
+ if (this.#ui.isDropdownClosed() || this.#options.dropdownAlwaysOpen && !isDestroy) {
4016
+ return;
4017
+ }
4018
+ this.#ui.closeDropdown();
4019
+ this.#dropdownAbortController.abort();
4020
+ this.#dropdownAbortController = null;
4021
+ this.#trigger(EVENTS.CLOSE_COUNTRY_DROPDOWN);
4022
+ }
4023
+ //* Replace any existing dial code with the new one
4024
+ //* Note: called from _selectListItem and setCountry
4025
+ #updateDialCode(newDialCodeBare) {
4026
+ const inputVal = this.#getTelInputValue();
4027
+ if (!inputVal.startsWith("+")) {
4028
+ return;
4029
+ }
4030
+ const newDialCode = `+${newDialCodeBare}`;
4031
+ const prevDialCode = this.#getDialCode(inputVal);
4032
+ let newNumber;
4033
+ if (prevDialCode) {
4034
+ newNumber = inputVal.replace(prevDialCode, newDialCode);
4035
+ } else {
4036
+ newNumber = newDialCode;
4037
+ }
4038
+ this.#setTelInputValue(newNumber);
4039
+ }
4040
+ //* Try and extract a valid international dial code from a full telephone number.
4041
+ //* Note: returns the raw string inc plus character and any whitespace/dots etc.
4042
+ #getDialCode(number, includeAreaCode) {
4043
+ if (!number.startsWith("+")) {
4044
+ return "";
4045
+ }
4046
+ let dialCode = "";
4047
+ let numericChars = "";
4048
+ let foundBaseDialCode = false;
4049
+ for (let i = 0; i < number.length; i++) {
4050
+ const c = number.charAt(i);
4051
+ if (!/[0-9]/.test(c)) {
4052
+ continue;
4053
+ }
4054
+ numericChars += c;
4055
+ const hasMapEntry = Boolean(this.#dialCodeToIso2Map[numericChars]);
4056
+ if (!hasMapEntry) {
4057
+ break;
4058
+ }
4059
+ if (this.#dialCodes.has(numericChars)) {
4060
+ dialCode = number.substring(0, i + 1);
4061
+ foundBaseDialCode = true;
4062
+ if (!includeAreaCode) {
4063
+ break;
4064
+ }
4065
+ } else if (includeAreaCode && foundBaseDialCode) {
4066
+ dialCode = number.substring(0, i + 1);
4067
+ }
4068
+ if (numericChars.length === this.#dialCodeMaxLen) {
4069
+ break;
4070
+ }
4071
+ }
4072
+ return dialCode;
4073
+ }
4074
+ //* Get the input val, adding the dial code if separateDialCode is enabled.
4075
+ #getFullNumber(overrideVal) {
4076
+ const val = overrideVal ? this.#numerals.normalise(overrideVal) : this.#getTelInputValue();
4077
+ const dialCode = this.#selectedCountryData?.dialCode;
4078
+ let prefix;
4079
+ const numericVal = getNumeric(val);
4080
+ if (this.#options.separateDialCode && !val.startsWith("+") && dialCode && numericVal) {
4081
+ prefix = `+${dialCode}`;
4082
+ } else {
4083
+ prefix = "";
4084
+ }
4085
+ return prefix + val;
4086
+ }
4087
+ //* Remove the dial code if separateDialCode is enabled also cap the length if the input has a maxlength attribute
4088
+ #beforeSetNumber(fullNumber) {
4089
+ const hasValidDialCode = Boolean(this.#getDialCode(fullNumber));
4090
+ const number = beforeSetNumber(
4091
+ fullNumber,
4092
+ hasValidDialCode,
4093
+ this.#options.separateDialCode,
4094
+ this.#selectedCountryData
4095
+ );
4096
+ return this.#cap(number);
4097
+ }
4098
+ //* Return only the public-facing subset of the selected country data.
4099
+ #getPublicCountryData() {
4100
+ const d = this.#selectedCountryData;
4101
+ if (!d) {
4102
+ return null;
4103
+ }
4104
+ const { iso2, dialCode, name } = d;
4105
+ return { iso2, dialCode, name };
4106
+ }
4107
+ //* Trigger the 'countrychange' event.
4108
+ #triggerCountryChange() {
4109
+ const countryData = this.#getPublicCountryData();
4110
+ this.#trigger(EVENTS.COUNTRY_CHANGE, countryData);
4111
+ }
4112
+ //**************************
4113
+ //* INTERNAL METHODS
4114
+ //**************************
4115
+ //* Called when the geoip call returns.
4116
+ #handleAutoCountry() {
4117
+ if (!this.#autoCountryDeferred || !intlTelInput.autoCountry) {
4118
+ return;
4119
+ }
4120
+ if (this.#destroyed) {
4121
+ this.#autoCountryDeferred.resolve();
4122
+ return;
4123
+ }
4124
+ this.#defaultCountry = intlTelInput.autoCountry;
4125
+ const hasSelectedCountryOrGlobe = this.#selectedCountryData || this.#ui.selectedCountryInner.classList.contains(CLASSES.GLOBE);
4126
+ if (!hasSelectedCountryOrGlobe) {
4127
+ this.setCountry(this.#defaultCountry);
4128
+ }
4129
+ this.#autoCountryDeferred.resolve();
4130
+ }
4131
+ //* Called when the geoip call fails or times out.
4132
+ #handleAutoCountryFailure() {
4133
+ if (this.#destroyed) {
4134
+ this.#autoCountryDeferred?.reject();
4135
+ return;
4136
+ }
4137
+ this.#setInitialState(true);
4138
+ this.#autoCountryDeferred?.reject();
4139
+ }
4140
+ //* Called when the utils request completes.
4141
+ #handleUtils() {
4142
+ if (this.#destroyed) {
4143
+ this.#utilsScriptDeferred?.resolve();
4144
+ return;
4145
+ }
4146
+ if (!intlTelInput.utils) {
4147
+ this.#utilsScriptDeferred?.resolve();
4148
+ return;
4149
+ }
4150
+ const inputValue = this.#getTelInputValue();
4151
+ if (inputValue) {
4152
+ this.#updateValFromNumber(inputValue);
4153
+ }
4154
+ if (this.#selectedCountryData) {
4155
+ this.#updatePlaceholder();
4156
+ this.#updateMaxLength();
4157
+ }
4158
+ this.#utilsScriptDeferred?.resolve();
4159
+ }
4160
+ //* Called when the utils request fails or times out.
4161
+ #handleUtilsFailure(error) {
4162
+ if (this.#destroyed) {
4163
+ this.#utilsScriptDeferred?.reject(error);
4164
+ return;
4165
+ }
4166
+ this.#utilsScriptDeferred?.reject(error);
4167
+ }
4168
+ //********************
4169
+ //* PUBLIC METHODS
4170
+ //********************
4171
+ //* Remove plugin.
4172
+ destroy() {
4173
+ if (this.#destroyed) {
4174
+ return;
4175
+ }
4176
+ this.#destroyed = true;
4177
+ if (this.#options.allowDropdown) {
4178
+ this.#closeDropdown(true);
4179
+ }
4180
+ this.#abortController.abort();
4181
+ this.#ui.destroy();
4182
+ intlTelInput.instances.delete(String(this.id));
4183
+ }
4184
+ // check if the instance is still valid (not destroyed)
4185
+ isActive() {
4186
+ return !this.#destroyed;
4187
+ }
4188
+ //* Get the extension from the current number.
4189
+ getExtension() {
4190
+ if (this.#destroyed) {
4191
+ return "";
4192
+ }
4193
+ ensureUtils("getExtension");
4194
+ return intlTelInput.utils.getExtension(
4195
+ this.#getFullNumber(),
4196
+ this.#selectedCountryData?.iso2
4197
+ );
4198
+ }
4199
+ //* Format the number to the given format.
4200
+ getNumber(format) {
4201
+ if (this.#destroyed) {
4202
+ return "";
4203
+ }
4204
+ ensureUtils("getNumber");
4205
+ const iso2 = this.#selectedCountryData?.iso2;
4206
+ const fullNumber = this.#getFullNumber();
4207
+ const formattedNumber = intlTelInput.utils.formatNumber(
4208
+ fullNumber,
4209
+ iso2,
4210
+ format
4211
+ );
4212
+ return this.#numerals.denormalise(formattedNumber);
4213
+ }
4214
+ //* Get the type of the entered number e.g. landline/mobile.
4215
+ getNumberType() {
4216
+ if (this.#destroyed) {
4217
+ return SENTINELS.UNKNOWN_NUMBER_TYPE;
4218
+ }
4219
+ ensureUtils("getNumberType");
4220
+ return intlTelInput.utils.getNumberType(
4221
+ this.#getFullNumber(),
4222
+ this.#selectedCountryData?.iso2
4223
+ );
4224
+ }
4225
+ //* Get the country data for the currently selected country.
4226
+ getSelectedCountryData() {
4227
+ return this.#getPublicCountryData();
4228
+ }
4229
+ //* Get the validation error.
4230
+ getValidationError() {
4231
+ if (this.#destroyed) {
4232
+ return SENTINELS.UNKNOWN_VALIDATION_ERROR;
4233
+ }
4234
+ ensureUtils("getValidationError");
4235
+ const iso2 = this.#selectedCountryData?.iso2;
4236
+ return intlTelInput.utils.getValidationError(this.#getFullNumber(), iso2);
4237
+ }
4238
+ //* Validate the input val using number length only
4239
+ isValidNumber() {
4240
+ if (this.#destroyed) {
4241
+ return null;
4242
+ }
4243
+ ensureUtils("isValidNumber");
4244
+ const dialCode = this.#selectedCountryData?.dialCode;
4245
+ const iso2 = this.#selectedCountryData?.iso2;
4246
+ const number = this.#getFullNumber();
4247
+ const coreNumber = intlTelInput.utils.getCoreNumber(number, iso2);
4248
+ if (coreNumber) {
4249
+ if (dialCode === UK.DIAL_CODE) {
4250
+ if (coreNumber[0] === UK.MOBILE_PREFIX && coreNumber.length !== UK.MOBILE_CORE_LENGTH) {
4251
+ return false;
4252
+ }
4253
+ }
4254
+ const hasAlphaChar = REGEX.ALPHA_UNICODE.test(number);
4255
+ if (!hasAlphaChar && dialCode) {
4256
+ const nationalPortion = number.startsWith("+") ? number.slice(1 + dialCode.length) : number;
4257
+ const nationalDigitCount = getNumeric(nationalPortion).length;
4258
+ if (coreNumber.length > nationalDigitCount) {
4259
+ return false;
4260
+ }
4261
+ }
4262
+ }
4263
+ return this.#validateNumber(false);
4264
+ }
4265
+ //* Validate the input val with precise validation
4266
+ isValidNumberPrecise() {
4267
+ if (this.#destroyed) {
4268
+ return null;
4269
+ }
4270
+ ensureUtils("isValidNumberPrecise");
4271
+ return this.#validateNumber(true);
4272
+ }
4273
+ #utilsIsPossibleNumber(val) {
4274
+ return intlTelInput.utils ? intlTelInput.utils.isPossibleNumber(
4275
+ val,
4276
+ this.#selectedCountryData?.iso2,
4277
+ this.#options.allowedNumberTypes
4278
+ ) : null;
4279
+ }
4280
+ //* Shared internal validation logic to handle alpha character extension rules.
4281
+ #validateNumber(precise) {
4282
+ const { allowNumberExtensions, allowPhonewords } = this.#options;
4283
+ const testValidity = (s) => precise ? this.#utilsIsValidNumber(s) : this.#utilsIsPossibleNumber(s);
4284
+ const val = this.#getFullNumber();
4285
+ if (!this.#selectedCountryData) {
4286
+ const isRegionlessDialCode = hasRegionlessDialCode(val);
4287
+ if (!isRegionlessDialCode) {
4288
+ return false;
4289
+ }
4290
+ }
4291
+ if (!testValidity(val)) {
4292
+ return false;
4293
+ }
4294
+ const alphaCharPosition = val.search(REGEX.ALPHA_UNICODE);
4295
+ const hasAlphaChar = alphaCharPosition > -1;
4296
+ if (hasAlphaChar) {
4297
+ const selectedIso2 = this.#selectedCountryData?.iso2;
4298
+ const hasExtension = Boolean(
4299
+ intlTelInput.utils.getExtension(val, selectedIso2)
4300
+ );
4301
+ if (hasExtension) {
4302
+ return allowNumberExtensions;
4303
+ }
4304
+ return allowPhonewords;
4305
+ }
4306
+ return true;
4307
+ }
4308
+ #utilsIsValidNumber(val) {
4309
+ return intlTelInput.utils ? intlTelInput.utils.isValidNumber(
4310
+ val,
4311
+ this.#selectedCountryData?.iso2,
4312
+ this.#options.allowedNumberTypes
4313
+ ) : null;
4314
+ }
4315
+ //* Update the selected country, and update the input val accordingly.
4316
+ setCountry(iso2) {
4317
+ if (this.#destroyed) {
4318
+ return;
4319
+ }
4320
+ const iso2Lower = iso2?.toLowerCase();
4321
+ if (!isIso2(iso2Lower)) {
4322
+ throw new Error(`Invalid country code: '${iso2Lower}'`);
4323
+ }
4324
+ const currentCountry = this.#selectedCountryData?.iso2;
4325
+ const isCountryChange = iso2 && iso2Lower !== currentCountry || !iso2 && currentCountry;
4326
+ if (!isCountryChange) {
4327
+ return;
4328
+ }
4329
+ this.#setCountry(iso2Lower);
4330
+ this.#updateDialCode(this.#selectedCountryData?.dialCode || "");
4331
+ if (this.#options.formatOnDisplay) {
4332
+ const inputValue = this.#getTelInputValue();
4333
+ this.#updateValFromNumber(inputValue);
4334
+ }
4335
+ this.#triggerCountryChange();
4336
+ }
4337
+ //* Set the input value and update the country.
4338
+ setNumber(number) {
4339
+ if (this.#destroyed) {
4340
+ return;
4341
+ }
4342
+ const normalisedNumber = this.#numerals.normalise(number);
4343
+ const countryChanged = this.#updateCountryFromNumber(normalisedNumber);
4344
+ this.#updateValFromNumber(normalisedNumber);
4345
+ if (countryChanged) {
4346
+ this.#triggerCountryChange();
4347
+ }
4348
+ this.#trigger(EVENTS.INPUT, { isSetNumber: true });
4349
+ }
4350
+ //* Set the placeholder number type
4351
+ setPlaceholderNumberType(type) {
4352
+ if (this.#destroyed) {
4353
+ return;
4354
+ }
4355
+ this.#options.placeholderNumberType = type;
4356
+ this.#updatePlaceholder();
4357
+ }
4358
+ // Set the disabled state of the input and dropdown.
4359
+ setDisabled(disabled) {
4360
+ if (this.#destroyed) {
4361
+ return;
4362
+ }
4363
+ this.#ui.telInput.disabled = disabled;
4364
+ if (this.#ui.selectedCountry) {
4365
+ if (disabled) {
4366
+ this.#ui.selectedCountry.setAttribute("disabled", "true");
4367
+ } else {
4368
+ this.#ui.selectedCountry.removeAttribute("disabled");
4369
+ }
4370
+ }
4371
+ }
4372
+ // Set the readonly state of the input and dropdown.
4373
+ setReadonly(readonly) {
4374
+ if (!this.#ui.telInput) {
4375
+ return;
4376
+ }
4377
+ this.#ui.telInput.readOnly = readonly;
4378
+ if (this.#ui.selectedCountry) {
4379
+ if (readonly) {
4380
+ this.#ui.selectedCountry.setAttribute("disabled", "true");
4381
+ } else {
4382
+ this.#ui.selectedCountry.removeAttribute("disabled");
4383
+ }
4384
+ }
4385
+ }
4386
+ //********************
4387
+ //* STATIC METHODS
4388
+ //********************
4389
+ // Internal instance notification used by utils/geoip loaders.
4390
+ // Kept public so module-level helpers (e.g. attachUtils) can call it, while still allowing
4391
+ // access to private instance methods.
4392
+ static forEachInstance(method, ...args) {
4393
+ const values = [...intlTelInput.instances.values()];
4394
+ const arg = args[0];
4395
+ values.forEach((instance) => {
4396
+ if (!(instance instanceof _Iti)) {
4397
+ return;
4398
+ }
4399
+ switch (method) {
4400
+ case "handleUtils":
4401
+ instance.#handleUtils();
4402
+ break;
4403
+ case "handleUtilsFailure":
4404
+ instance.#handleUtilsFailure(arg);
4405
+ break;
4406
+ case "handleAutoCountry":
4407
+ instance.#handleAutoCountry();
4408
+ break;
4409
+ case "handleAutoCountryFailure":
4410
+ instance.#handleAutoCountryFailure();
4411
+ break;
4412
+ }
4413
+ });
4414
+ }
4415
+ };
4416
+ var attachUtils = (source) => {
4417
+ if (!intlTelInput.utils && !intlTelInput.startedLoadingUtilsScript) {
4418
+ let loadCall;
4419
+ if (typeof source === "function") {
4420
+ try {
4421
+ loadCall = Promise.resolve(source());
4422
+ } catch (error) {
4423
+ return Promise.reject(error);
4424
+ }
4425
+ } else {
4426
+ return Promise.reject(
4427
+ new TypeError(
4428
+ `The argument passed to attachUtils must be a function that returns a promise for the utilities module, not ${typeof source}`
4429
+ )
4430
+ );
4431
+ }
4432
+ intlTelInput.startedLoadingUtilsScript = true;
4433
+ return loadCall.then((module) => {
4434
+ const utils = module?.default;
4435
+ if (!utils || typeof utils !== "object") {
4436
+ throw new TypeError(
4437
+ "The loader function passed to attachUtils did not resolve to a module object with utils as its default export."
4438
+ );
4439
+ }
4440
+ intlTelInput.utils = utils;
4441
+ Iti.forEachInstance("handleUtils");
4442
+ return true;
4443
+ }).catch((error) => {
4444
+ Iti.forEachInstance("handleUtilsFailure", error);
4445
+ throw error;
4446
+ });
4447
+ }
4448
+ return null;
4449
+ };
4450
+ var intlTelInput = Object.assign(
4451
+ (input, options) => {
4452
+ const iti = new Iti(input, options);
4453
+ intlTelInput.instances.set(String(iti.id), iti);
4454
+ input.iti = iti;
4455
+ return iti;
4456
+ },
4457
+ {
4458
+ defaults,
4459
+ //* Using a static var like this allows us to mock it in the tests.
4460
+ documentReady: () => document.readyState === "complete",
4461
+ //* Get the country data object.
4462
+ getCountryData: () => data_default,
4463
+ //* A getter for the plugin instance.
4464
+ getInstance: (input) => {
4465
+ const id2 = input.dataset.intlTelInputId;
4466
+ return id2 ? intlTelInput.instances.get(id2) ?? null : null;
4467
+ },
4468
+ //* A map from instance ID to instance object.
4469
+ instances: /* @__PURE__ */ new Map(),
4470
+ attachUtils,
4471
+ startedLoadingUtilsScript: false,
4472
+ startedLoadingAutoCountry: false,
4473
+ version: "27.0.1"
4474
+ }
4475
+ );
4476
+ var intl_tel_input_default = intlTelInput;
4477
+
4478
+ // angular/dist/temp/IntlTelInput.js
4479
+ import { Component, Input, ViewChild, ElementRef, Output, EventEmitter, forwardRef } from "@angular/core";
4480
+ import { NG_VALUE_ACCESSOR, NG_VALIDATORS } from "@angular/forms";
4481
+ import * as i0 from "@angular/core";
4482
+ var _c0 = ["inputRef"];
4483
+ var warnInputAttr = (prop) => {
4484
+ console.warn(`intl-tel-input: ignoring inputAttributes.${prop} - see docs for more info.`);
4485
+ };
4486
+ var IntlTelInput = class _IntlTelInput {
4487
+ inputRef;
4488
+ /** initialValue is only used during initialization — changes after init are ignored. */
4489
+ initialValue;
4490
+ usePreciseValidation = false;
4491
+ inputAttributes = {};
4492
+ disabled = false;
4493
+ readonly = false;
4494
+ // Plugin initialisation options (one @Input per option)
4495
+ allowDropdown;
4496
+ allowedNumberTypes;
4497
+ allowNumberExtensions;
4498
+ allowPhonewords;
4499
+ autoPlaceholder;
4500
+ containerClass;
4501
+ countryNameLocale;
4502
+ countryOrder;
4503
+ countrySearch;
4504
+ customPlaceholder;
4505
+ dropdownAlwaysOpen;
4506
+ dropdownContainer;
4507
+ excludeCountries;
4508
+ fixDropdownWidth;
4509
+ formatAsYouType;
4510
+ formatOnDisplay;
4511
+ geoIpLookup;
4512
+ hiddenInput;
4513
+ i18n;
4514
+ initialCountry;
4515
+ loadUtils;
4516
+ nationalMode;
4517
+ onlyCountries;
4518
+ placeholderNumberType;
4519
+ searchInputClass;
4520
+ separateDialCode;
4521
+ showFlags;
4522
+ strictMode;
4523
+ useFullscreenPopup;
4524
+ numberChange = new EventEmitter();
4525
+ countryChange = new EventEmitter();
4526
+ validityChange = new EventEmitter();
4527
+ errorCodeChange = new EventEmitter();
4528
+ blur = new EventEmitter();
4529
+ focus = new EventEmitter();
4530
+ keydown = new EventEmitter();
4531
+ keyup = new EventEmitter();
4532
+ paste = new EventEmitter();
4533
+ click = new EventEmitter();
4534
+ iti;
4535
+ appliedInputAttrKeys = /* @__PURE__ */ new Set();
4536
+ lastEmittedNumber;
4537
+ lastEmittedCountry;
4538
+ lastEmittedValidity;
4539
+ lastEmittedErrorCode;
4540
+ // writeValue may be called by Angular forms before utils has loaded; queue it until then
4541
+ pendingWriteValue;
4542
+ countryChangeHandler = () => this.handleInput();
4543
+ // eslint-disable-next-line class-methods-use-this
4544
+ onChange = () => {
4545
+ };
4546
+ // eslint-disable-next-line class-methods-use-this
4547
+ onTouched = () => {
4548
+ };
4549
+ // eslint-disable-next-line class-methods-use-this
4550
+ onValidatorChange = () => {
4551
+ };
4552
+ ngAfterViewInit() {
4553
+ this.iti = intl_tel_input_default(this.inputRef.nativeElement, this.buildInitOptions());
4554
+ this.inputRef.nativeElement.addEventListener("countrychange", this.countryChangeHandler);
4555
+ this.applyInputAttrs();
4556
+ if (this.disabled) {
4557
+ this.iti.setDisabled(this.disabled);
4558
+ }
4559
+ if (this.readonly) {
4560
+ this.iti.setReadonly(this.readonly);
4561
+ }
4562
+ this.iti.promise.then(() => {
4563
+ if (!this.iti?.isActive()) {
4564
+ return;
4565
+ }
4566
+ if (this.pendingWriteValue !== void 0) {
4567
+ this.iti.setNumber(this.pendingWriteValue);
4568
+ this.pendingWriteValue = void 0;
4569
+ } else if (this.initialValue) {
4570
+ this.iti.setNumber(this.initialValue);
4571
+ }
4572
+ });
4573
+ }
4574
+ buildInitOptions() {
4575
+ const options = {
4576
+ allowDropdown: this.allowDropdown,
4577
+ allowedNumberTypes: this.allowedNumberTypes,
4578
+ allowNumberExtensions: this.allowNumberExtensions,
4579
+ allowPhonewords: this.allowPhonewords,
4580
+ autoPlaceholder: this.autoPlaceholder,
4581
+ containerClass: this.containerClass,
4582
+ countryNameLocale: this.countryNameLocale,
4583
+ countryOrder: this.countryOrder,
4584
+ countrySearch: this.countrySearch,
4585
+ customPlaceholder: this.customPlaceholder,
4586
+ dropdownAlwaysOpen: this.dropdownAlwaysOpen,
4587
+ dropdownContainer: this.dropdownContainer,
4588
+ excludeCountries: this.excludeCountries,
4589
+ fixDropdownWidth: this.fixDropdownWidth,
4590
+ formatAsYouType: this.formatAsYouType,
4591
+ formatOnDisplay: this.formatOnDisplay,
4592
+ geoIpLookup: this.geoIpLookup,
4593
+ hiddenInput: this.hiddenInput,
4594
+ i18n: this.i18n,
4595
+ initialCountry: this.initialCountry,
4596
+ loadUtils: this.loadUtils,
4597
+ nationalMode: this.nationalMode,
4598
+ onlyCountries: this.onlyCountries,
4599
+ placeholderNumberType: this.placeholderNumberType,
4600
+ searchInputClass: this.searchInputClass,
4601
+ separateDialCode: this.separateDialCode,
4602
+ showFlags: this.showFlags,
4603
+ strictMode: this.strictMode,
4604
+ useFullscreenPopup: this.useFullscreenPopup
4605
+ };
4606
+ return Object.fromEntries(Object.entries(options).filter(([, value]) => value !== void 0));
4607
+ }
4608
+ ngOnChanges(changes) {
4609
+ if (changes["disabled"]) {
4610
+ this.iti?.setDisabled(this.disabled);
4611
+ }
4612
+ if (changes["readonly"]) {
4613
+ this.iti?.setReadonly(this.readonly);
4614
+ }
4615
+ if (changes["inputAttributes"]) {
4616
+ this.applyInputAttrs();
4617
+ }
4618
+ }
4619
+ handleInput() {
4620
+ if (!this.iti) {
4621
+ return;
4622
+ }
4623
+ const num = this.iti.getNumber() ?? "";
4624
+ const countryIso = this.iti.getSelectedCountryData()?.iso2 ?? "";
4625
+ let hasChanged = false;
4626
+ if (num !== this.lastEmittedNumber) {
4627
+ this.lastEmittedNumber = num;
4628
+ this.numberChange.emit(num);
4629
+ this.onChange(num);
4630
+ hasChanged = true;
4631
+ }
4632
+ if (countryIso !== this.lastEmittedCountry) {
4633
+ this.lastEmittedCountry = countryIso;
4634
+ this.countryChange.emit(countryIso);
4635
+ hasChanged = true;
4636
+ }
4637
+ const isValid = (this.usePreciseValidation ? this.iti.isValidNumberPrecise() : this.iti.isValidNumber()) ?? false;
4638
+ const errorCode = isValid ? null : this.iti.getValidationError();
4639
+ if (isValid !== this.lastEmittedValidity) {
4640
+ this.lastEmittedValidity = isValid;
4641
+ this.validityChange.emit(isValid);
4642
+ hasChanged = true;
4643
+ }
4644
+ if (errorCode !== this.lastEmittedErrorCode) {
4645
+ this.lastEmittedErrorCode = errorCode;
4646
+ this.errorCodeChange.emit(errorCode);
4647
+ hasChanged = true;
4648
+ }
4649
+ if (hasChanged) {
4650
+ this.onValidatorChange();
4651
+ }
4652
+ }
4653
+ handleBlur(event) {
4654
+ this.onTouched();
4655
+ this.blur.emit(event);
4656
+ }
4657
+ handleFocus(event) {
4658
+ this.focus.emit(event);
4659
+ }
4660
+ handleKeyDown(event) {
4661
+ this.keydown.emit(event);
4662
+ }
4663
+ handleKeyUp(event) {
4664
+ this.keyup.emit(event);
4665
+ }
4666
+ handlePaste(event) {
4667
+ this.paste.emit(event);
4668
+ }
4669
+ handleClick(event) {
4670
+ this.click.emit(event);
4671
+ }
4672
+ /**
4673
+ * This method must be called in `ngAfterViewInit` or later lifecycle hooks,
4674
+ * not in `ngOnInit` or the `constructor`, as the component needs to be fully initialized.
4675
+ */
4676
+ getInstance() {
4677
+ return this.iti;
4678
+ }
4679
+ /**
4680
+ * This method must be called in `ngAfterViewInit` or later lifecycle hooks,
4681
+ * not in `ngOnInit` or the `constructor`, as the component needs to be fully initialized.
4682
+ */
4683
+ getInput() {
4684
+ return this.inputRef.nativeElement;
4685
+ }
4686
+ ngOnDestroy() {
4687
+ this.iti?.destroy();
4688
+ this.inputRef.nativeElement.removeEventListener("countrychange", this.countryChangeHandler);
4689
+ }
4690
+ ignoredInputAttrs = /* @__PURE__ */ new Set([
4691
+ "type",
4692
+ "value",
4693
+ "disabled",
4694
+ "readonly"
4695
+ ]);
4696
+ applyInputAttrs() {
4697
+ const currentKeys = /* @__PURE__ */ new Set();
4698
+ Object.entries(this.inputAttributes).forEach(([key, value]) => {
4699
+ if (this.ignoredInputAttrs.has(key)) {
4700
+ warnInputAttr(key);
4701
+ } else {
4702
+ currentKeys.add(key);
4703
+ this.inputRef.nativeElement.setAttribute(key, value);
4704
+ }
4705
+ });
4706
+ this.appliedInputAttrKeys.forEach((key) => {
4707
+ if (!currentKeys.has(key)) {
4708
+ this.inputRef.nativeElement.removeAttribute(key);
4709
+ }
4710
+ });
4711
+ this.appliedInputAttrKeys = currentKeys;
4712
+ }
4713
+ // ============ ControlValueAccessor Implementation ============
4714
+ writeValue(value) {
4715
+ const next = value || "";
4716
+ if (this.iti) {
4717
+ this.iti.promise.then(() => {
4718
+ if (this.iti?.isActive()) {
4719
+ this.iti.setNumber(next);
4720
+ }
4721
+ });
4722
+ } else {
4723
+ this.pendingWriteValue = next;
4724
+ }
4725
+ }
4726
+ registerOnChange(fn) {
4727
+ this.onChange = fn;
4728
+ }
4729
+ registerOnTouched(fn) {
4730
+ this.onTouched = fn;
4731
+ }
4732
+ setDisabledState(isDisabled) {
4733
+ this.disabled = isDisabled;
4734
+ this.iti?.setDisabled(isDisabled);
4735
+ }
4736
+ // ============ Validator Implementation ============
4737
+ validate(_control) {
4738
+ if (!this.iti || !this.iti.getNumber()) {
4739
+ return null;
4740
+ }
4741
+ const isValid = this.usePreciseValidation ? this.iti.isValidNumberPrecise() : this.iti.isValidNumber();
4742
+ if (isValid) {
4743
+ return null;
4744
+ }
4745
+ const errorCode = this.iti.getValidationError();
4746
+ return {
4747
+ invalidPhone: errorCode
4748
+ };
4749
+ }
4750
+ registerOnValidatorChange(fn) {
4751
+ this.onValidatorChange = fn;
4752
+ }
4753
+ static \u0275fac = function IntlTelInput_Factory(__ngFactoryType__) {
4754
+ return new (__ngFactoryType__ || _IntlTelInput)();
4755
+ };
4756
+ static \u0275cmp = /* @__PURE__ */ i0.\u0275\u0275defineComponent({ type: _IntlTelInput, selectors: [["intl-tel-input"]], viewQuery: function IntlTelInput_Query(rf, ctx) {
4757
+ if (rf & 1) {
4758
+ i0.\u0275\u0275viewQuery(_c0, 7);
4759
+ }
4760
+ if (rf & 2) {
4761
+ let _t;
4762
+ i0.\u0275\u0275queryRefresh(_t = i0.\u0275\u0275loadQuery()) && (ctx.inputRef = _t.first);
4763
+ }
4764
+ }, inputs: { initialValue: "initialValue", usePreciseValidation: "usePreciseValidation", inputAttributes: "inputAttributes", disabled: "disabled", readonly: "readonly", allowDropdown: "allowDropdown", allowedNumberTypes: "allowedNumberTypes", allowNumberExtensions: "allowNumberExtensions", allowPhonewords: "allowPhonewords", autoPlaceholder: "autoPlaceholder", containerClass: "containerClass", countryNameLocale: "countryNameLocale", countryOrder: "countryOrder", countrySearch: "countrySearch", customPlaceholder: "customPlaceholder", dropdownAlwaysOpen: "dropdownAlwaysOpen", dropdownContainer: "dropdownContainer", excludeCountries: "excludeCountries", fixDropdownWidth: "fixDropdownWidth", formatAsYouType: "formatAsYouType", formatOnDisplay: "formatOnDisplay", geoIpLookup: "geoIpLookup", hiddenInput: "hiddenInput", i18n: "i18n", initialCountry: "initialCountry", loadUtils: "loadUtils", nationalMode: "nationalMode", onlyCountries: "onlyCountries", placeholderNumberType: "placeholderNumberType", searchInputClass: "searchInputClass", separateDialCode: "separateDialCode", showFlags: "showFlags", strictMode: "strictMode", useFullscreenPopup: "useFullscreenPopup" }, outputs: { numberChange: "numberChange", countryChange: "countryChange", validityChange: "validityChange", errorCodeChange: "errorCodeChange", blur: "blur", focus: "focus", keydown: "keydown", keyup: "keyup", paste: "paste", click: "click" }, features: [i0.\u0275\u0275ProvidersFeature([
4765
+ {
4766
+ provide: NG_VALUE_ACCESSOR,
4767
+ useExisting: forwardRef(() => _IntlTelInput),
4768
+ multi: true
4769
+ },
4770
+ {
4771
+ provide: NG_VALIDATORS,
4772
+ useExisting: forwardRef(() => _IntlTelInput),
4773
+ multi: true
4774
+ }
4775
+ ]), i0.\u0275\u0275NgOnChangesFeature], decls: 2, vars: 0, consts: [["inputRef", ""], ["type", "tel", 3, "input", "blur", "focus", "keydown", "keyup", "paste", "click"]], template: function IntlTelInput_Template(rf, ctx) {
4776
+ if (rf & 1) {
4777
+ i0.\u0275\u0275domElementStart(0, "input", 1, 0);
4778
+ i0.\u0275\u0275domListener("input", function IntlTelInput_Template_input_input_0_listener() {
4779
+ return ctx.handleInput();
4780
+ })("blur", function IntlTelInput_Template_input_blur_0_listener($event) {
4781
+ return ctx.handleBlur($event);
4782
+ })("focus", function IntlTelInput_Template_input_focus_0_listener($event) {
4783
+ return ctx.handleFocus($event);
4784
+ })("keydown", function IntlTelInput_Template_input_keydown_0_listener($event) {
4785
+ return ctx.handleKeyDown($event);
4786
+ })("keyup", function IntlTelInput_Template_input_keyup_0_listener($event) {
4787
+ return ctx.handleKeyUp($event);
4788
+ })("paste", function IntlTelInput_Template_input_paste_0_listener($event) {
4789
+ return ctx.handlePaste($event);
4790
+ })("click", function IntlTelInput_Template_input_click_0_listener($event) {
4791
+ return ctx.handleClick($event);
4792
+ });
4793
+ i0.\u0275\u0275domElementEnd();
4794
+ }
4795
+ }, encapsulation: 2 });
4796
+ };
4797
+ (() => {
4798
+ (typeof ngDevMode === "undefined" || ngDevMode) && i0.\u0275setClassMetadata(IntlTelInput, [{
4799
+ type: Component,
4800
+ args: [{
4801
+ selector: "intl-tel-input",
4802
+ standalone: true,
4803
+ template: `
4804
+ <input
4805
+ type="tel"
4806
+ #inputRef
4807
+ (input)="handleInput()"
4808
+ (blur)="handleBlur($event)"
4809
+ (focus)="handleFocus($event)"
4810
+ (keydown)="handleKeyDown($event)"
4811
+ (keyup)="handleKeyUp($event)"
4812
+ (paste)="handlePaste($event)"
4813
+ (click)="handleClick($event)"
4814
+ />
4815
+ `,
4816
+ providers: [
4817
+ {
4818
+ provide: NG_VALUE_ACCESSOR,
4819
+ useExisting: forwardRef(() => IntlTelInput),
4820
+ multi: true
4821
+ },
4822
+ {
4823
+ provide: NG_VALIDATORS,
4824
+ useExisting: forwardRef(() => IntlTelInput),
4825
+ multi: true
4826
+ }
4827
+ ]
4828
+ }]
4829
+ }], null, { inputRef: [{
4830
+ type: ViewChild,
4831
+ args: ["inputRef", { static: true }]
4832
+ }], initialValue: [{
4833
+ type: Input
4834
+ }], usePreciseValidation: [{
4835
+ type: Input
4836
+ }], inputAttributes: [{
4837
+ type: Input
4838
+ }], disabled: [{
4839
+ type: Input
4840
+ }], readonly: [{
4841
+ type: Input
4842
+ }], allowDropdown: [{
4843
+ type: Input
4844
+ }], allowedNumberTypes: [{
4845
+ type: Input
4846
+ }], allowNumberExtensions: [{
4847
+ type: Input
4848
+ }], allowPhonewords: [{
4849
+ type: Input
4850
+ }], autoPlaceholder: [{
4851
+ type: Input
4852
+ }], containerClass: [{
4853
+ type: Input
4854
+ }], countryNameLocale: [{
4855
+ type: Input
4856
+ }], countryOrder: [{
4857
+ type: Input
4858
+ }], countrySearch: [{
4859
+ type: Input
4860
+ }], customPlaceholder: [{
4861
+ type: Input
4862
+ }], dropdownAlwaysOpen: [{
4863
+ type: Input
4864
+ }], dropdownContainer: [{
4865
+ type: Input
4866
+ }], excludeCountries: [{
4867
+ type: Input
4868
+ }], fixDropdownWidth: [{
4869
+ type: Input
4870
+ }], formatAsYouType: [{
4871
+ type: Input
4872
+ }], formatOnDisplay: [{
4873
+ type: Input
4874
+ }], geoIpLookup: [{
4875
+ type: Input
4876
+ }], hiddenInput: [{
4877
+ type: Input
4878
+ }], i18n: [{
4879
+ type: Input
4880
+ }], initialCountry: [{
4881
+ type: Input
4882
+ }], loadUtils: [{
4883
+ type: Input
4884
+ }], nationalMode: [{
4885
+ type: Input
4886
+ }], onlyCountries: [{
4887
+ type: Input
4888
+ }], placeholderNumberType: [{
4889
+ type: Input
4890
+ }], searchInputClass: [{
4891
+ type: Input
4892
+ }], separateDialCode: [{
4893
+ type: Input
4894
+ }], showFlags: [{
4895
+ type: Input
4896
+ }], strictMode: [{
4897
+ type: Input
4898
+ }], useFullscreenPopup: [{
4899
+ type: Input
4900
+ }], numberChange: [{
4901
+ type: Output
4902
+ }], countryChange: [{
4903
+ type: Output
4904
+ }], validityChange: [{
4905
+ type: Output
4906
+ }], errorCodeChange: [{
4907
+ type: Output
4908
+ }], blur: [{
4909
+ type: Output
4910
+ }], focus: [{
4911
+ type: Output
4912
+ }], keydown: [{
4913
+ type: Output
4914
+ }], keyup: [{
4915
+ type: Output
4916
+ }], paste: [{
4917
+ type: Output
4918
+ }], click: [{
4919
+ type: Output
4920
+ }] });
4921
+ })();
4922
+ (() => {
4923
+ (typeof ngDevMode === "undefined" || ngDevMode) && i0.\u0275setClassDebugInfo(IntlTelInput, { className: "IntlTelInput", filePath: "intltelinput.ts", lineNumber: 62 });
4924
+ })();
4925
+ var IntlTelInput_default = IntlTelInput;
4926
+ export {
4927
+ IntlTelInput_default as default,
4928
+ intl_tel_input_default as intlTelInput
4929
+ };