intl-tel-input
Version:
A JavaScript plugin for entering and validating international telephone numbers
39 lines (35 loc) • 44.5 kB
JavaScript
/*
* International Telephone Input v26.8.0
* https://github.com/jackocnr/intl-tel-input.git
* Licensed under the MIT license
*/
// UMD
(function(factory) {
if (typeof module === 'object' && module.exports) {
module.exports = factory();
} else {
window.intlTelInput = factory();
}
}(() => {
var factoryOutput=(()=>{var j=Object.defineProperty;var Tt=Object.getOwnPropertyDescriptor;var vt=Object.getOwnPropertyNames;var St=Object.prototype.hasOwnProperty;var _t=(o,t)=>{for(var e in t)j(o,e,{get:t[e],enumerable:!0})},Ot=(o,t,e,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of vt(t))!St.call(o,i)&&i!==e&&j(o,i,{get:()=>t[i],enumerable:!(s=Tt(t,i))||s.enumerable});return o};var Pt=o=>Ot(j({},"__esModule",{value:!0}),o);var Kt={};_t(Kt,{Iti:()=>R,default:()=>jt});var Mt=[["af","93",0,null,"0"],["ax","358",1,["18","4"],"0"],["al","355",0,null,"0"],["dz","213",0,null,"0"],["as","1",5,["684"],"1"],["ad","376"],["ao","244"],["ai","1",6,["264"],"1"],["ag","1",7,["268"],"1"],["ar","54",0,null,"0"],["am","374",0,null,"0"],["aw","297"],["ac","247"],["au","61",0,["4"],"0"],["at","43",0,null,"0"],["az","994",0,null,"0"],["bs","1",8,["242"],"1"],["bh","973"],["bd","880",0,null,"0"],["bb","1",9,["246"],"1"],["by","375",0,null,"8"],["be","32",0,null,"0"],["bz","501"],["bj","229"],["bm","1",10,["441"],"1"],["bt","975"],["bo","591",0,null,"0"],["ba","387",0,null,"0"],["bw","267"],["br","55",0,null,"0"],["io","246"],["vg","1",11,["284"],"1"],["bn","673"],["bg","359",0,null,"0"],["bf","226"],["bi","257"],["kh","855",0,null,"0"],["cm","237"],["ca","1",1,["204","226","236","249","250","257","263","289","306","343","354","365","367","368","382","403","416","418","428","431","437","438","450","468","474","506","514","519","548","579","581","584","587","604","613","639","647","672","683","705","709","742","753","778","780","782","807","819","825","867","873","879","902","905","942"],"1"],["cv","238"],["bq","599",1,["3","4","7"]],["ky","1",12,["345"],"1"],["cf","236"],["td","235"],["cl","56"],["cn","86",0,null,"0"],["cx","61",2,["4","89164"],"0"],["cc","61",1,["4","89162"],"0"],["co","57",0,null,"0"],["km","269"],["cg","242"],["cd","243",0,null,"0"],["ck","682"],["cr","506"],["ci","225"],["hr","385",0,null,"0"],["cu","53",0,null,"0"],["cw","599",0],["cy","357"],["cz","420"],["dk","45"],["dj","253"],["dm","1",13,["767"],"1"],["do","1",2,["809","829","849"],"1"],["ec","593",0,null,"0"],["eg","20",0,null,"0"],["sv","503"],["gq","240"],["er","291",0,null,"0"],["ee","372"],["sz","268"],["et","251",0,null,"0"],["fk","500"],["fo","298"],["fj","679"],["fi","358",0,["4"],"0"],["fr","33",0,null,"0"],["gf","594",0,null,"0"],["pf","689"],["ga","241"],["gm","220"],["ge","995",0,null,"0"],["de","49",0,null,"0"],["gh","233",0,null,"0"],["gi","350"],["gr","30"],["gl","299"],["gd","1",14,["473"],"1"],["gp","590",0,null,"0"],["gu","1",15,["671"],"1"],["gt","502"],["gg","44",1,["1481","7781","7839","7911"],"0"],["gn","224"],["gw","245"],["gy","592"],["ht","509"],["hn","504"],["hk","852"],["hu","36",0,null,"06"],["is","354"],["in","91",0,null,"0"],["id","62",0,null,"0"],["ir","98",0,null,"0"],["iq","964",0,null,"0"],["ie","353",0,null,"0"],["im","44",2,["1624","74576","7524","7624","7924"],"0"],["il","972",0,null,"0"],["it","39",0,["3"]],["jm","1",4,["658","876"],"1"],["jp","81",0,null,"0"],["je","44",3,["1534","7509","7700","7797","7829","7937"],"0"],["jo","962",0,null,"0"],["kz","7",1,["33","7"],"8"],["ke","254",0,null,"0"],["ki","686",0,null,"0"],["xk","383",0,null,"0"],["kw","965"],["kg","996",0,null,"0"],["la","856",0,null,"0"],["lv","371"],["lb","961",0,null,"0"],["ls","266"],["lr","231",0,null,"0"],["ly","218",0,null,"0"],["li","423",0,null,"0"],["lt","370",0,null,"0"],["lu","352"],["mo","853"],["mg","261",0,null,"0"],["mw","265",0,null,"0"],["my","60",0,null,"0"],["mv","960"],["ml","223"],["mt","356"],["mh","692",0,null,"1"],["mq","596",0,null,"0"],["mr","222"],["mu","230"],["yt","262",1,["269","639"],"0"],["mx","52"],["fm","691"],["md","373",0,null,"0"],["mc","377",0,null,"0"],["mn","976",0,null,"0"],["me","382",0,null,"0"],["ms","1",16,["664"],"1"],["ma","212",0,["6","7"],"0"],["mz","258"],["mm","95",0,null,"0"],["na","264",0,null,"0"],["nr","674"],["np","977",0,null,"0"],["nl","31",0,null,"0"],["nc","687"],["nz","64",0,null,"0"],["ni","505"],["ne","227"],["ng","234",0,null,"0"],["nu","683"],["nf","672"],["kp","850",0,null,"0"],["mk","389",0,null,"0"],["mp","1",17,["670"],"1"],["no","47",0,["4","9"]],["om","968"],["pk","92",0,null,"0"],["pw","680"],["ps","970",0,null,"0"],["pa","507"],["pg","675"],["py","595",0,null,"0"],["pe","51",0,null,"0"],["ph","63",0,null,"0"],["pl","48"],["pt","351"],["pr","1",3,["787","939"],"1"],["qa","974"],["re","262",0,null,"0"],["ro","40",0,null,"0"],["ru","7",0,["33"],"8"],["rw","250",0,null,"0"],["ws","685"],["sm","378"],["st","239"],["sa","966",0,null,"0"],["sn","221"],["rs","381",0,null,"0"],["sc","248"],["sl","232",0,null,"0"],["sg","65"],["sx","1",21,["721"],"1"],["sk","421",0,null,"0"],["si","386",0,null,"0"],["sb","677"],["so","252",0,null,"0"],["za","27",0,null,"0"],["kr","82",0,null,"0"],["ss","211",0,null,"0"],["es","34"],["lk","94",0,null,"0"],["bl","590",1,null,"0"],["sh","290"],["kn","1",18,["869"],"1"],["lc","1",19,["758"],"1"],["mf","590",2,null,"0"],["pm","508",0,null,"0"],["vc","1",20,["784"],"1"],["sd","249",0,null,"0"],["sr","597"],["sj","47",1,["4","79","9"]],["se","46",0,null,"0"],["ch","41",0,null,"0"],["sy","963",0,null,"0"],["tw","886",0,null,"0"],["tj","992"],["tz","255",0,null,"0"],["th","66",0,null,"0"],["tl","670"],["tg","228"],["tk","690"],["to","676"],["tt","1",22,["868"],"1"],["tn","216"],["tr","90",0,null,"0"],["tm","993",0,null,"8"],["tc","1",23,["649"],"1"],["tv","688"],["vi","1",24,["340"],"1"],["ug","256",0,null,"0"],["ua","380",0,null,"0"],["ae","971",0,null,"0"],["gb","44",0,null,"0"],["us","1",0,null,"1"],["uy","598",0,null,"0"],["uz","998"],["vu","678"],["va","39",1,["06698","3"]],["ve","58",0,null,"0"],["vn","84",0,null,"0"],["wf","681"],["eh","212",1,["5288","5289","6","7"],"0"],["ye","967",0,null,"0"],["zm","260",0,null,"0"],["zw","263",0,null,"0"]],st=[];for(let o of Mt)st.push({name:"",iso2:o[0],dialCode:o[1],priority:o[2]||0,areaCodes:o[3]||null,nodeById:{},nationalPrefix:o[4]||null,normalisedName:"",initials:"",dialCodePlus:""});var A=st;var x={OPEN_COUNTRY_DROPDOWN:"open:countrydropdown",CLOSE_COUNTRY_DROPDOWN:"close:countrydropdown",COUNTRY_CHANGE:"countrychange",INPUT:"input"},h={HIDE:"iti__hide",V_HIDE:"iti__v-hide",ARROW_UP:"iti__arrow--up",GLOBE:"iti__globe",FLAG:"iti__flag",LOADING:"iti__loading",COUNTRY_ITEM:"iti__country",HIGHLIGHT:"iti__highlight"},g={ARROW_UP:"ArrowUp",ARROW_DOWN:"ArrowDown",SPACE:" ",ENTER:"Enter",ESC:"Escape",TAB:"Tab"},K={PASTE:"insertFromPaste",DELETE_FWD:"deleteContentForward"},D={ALPHA_UNICODE:/\p{L}/u,NON_PLUS_NUMERIC:/[^+0-9]/,NON_PLUS_NUMERIC_GLOBAL:/[^+0-9]/g,HIDDEN_SEARCH_CHAR:/^[a-zA-ZÀ-ÿа-яА-Я ]$/},k={SEARCH_DEBOUNCE_MS:100,HIDDEN_SEARCH_RESET_MS:1e3,NEXT_TICK:0},z={UNKNOWN_NUMBER_TYPE:-99,UNKNOWN_VALIDATION_ERROR:-99},N={NARROW_VIEWPORT_WIDTH:500,SANE_SELECTED_WITH_DIAL_WIDTH:78,SANE_SELECTED_NO_DIAL_WIDTH:42,INPUT_PADDING_EXTRA_LEFT:6,DROPDOWN_MARGIN:3,SANE_DROPDOWN_HEIGHT:200},U={PLUS:"+",NANP:"1"},B={ISO2:"gb",DIAL_CODE:"44",MOBILE_PREFIX:"7",MOBILE_CORE_LENGTH:10},it={ISO2:"us",DIAL_CODE:"1"},P={AGGRESSIVE:"aggressive",POLITE:"polite",OFF:"off"},O={AUTO:"auto"},Rt=["FIXED_LINE","MOBILE","FIXED_LINE_OR_MOBILE","TOLL_FREE","PREMIUM_RATE","SHARED_COST","VOIP","PERSONAL_NUMBER","PAGER","UAN","VOICEMAIL","UNKNOWN"],H=new Set(Rt),X={COUNTRY_CODE:"countryCode",DIAL_CODE:"dialCode"},p={EXPANDED:"aria-expanded",LABEL:"aria-label",SELECTED:"aria-selected",ACTIVE_DESCENDANT:"aria-activedescendant",HASPOPUP:"aria-haspopup",CONTROLS:"aria-controls",HIDDEN:"aria-hidden",AUTOCOMPLETE:"aria-autocomplete",MODAL:"aria-modal"};var xt={selectedCountryAriaLabel:"Change country, selected ${countryName} (${dialCode})",noCountrySelected:"Select country",countryListAriaLabel:"List of countries",searchPlaceholder:"Search",clearSearchAriaLabel:"Clear search",searchEmptyState:"No results found",searchSummaryAria(o){return o===0?"No results found":o===1?"1 result found":`${o} results found`}},nt=xt;var q=o=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia(o).matches,at=()=>q(`(max-width: ${N.NARROW_VIEWPORT_WIDTH}px)`),Ht=()=>{if(typeof navigator<"u"&&typeof window<"u"){let o=q("(max-height: 600px)"),t=q("(pointer: coarse)");return at()||t&&o}return!1},$={allowDropdown:!0,allowedNumberTypes:["MOBILE","FIXED_LINE"],allowNumberExtensions:!1,allowPhonewords:!1,autoPlaceholder:P.POLITE,containerClass:"",countryNameLocale:"en",countryOrder:null,countrySearch:!0,customPlaceholder:null,dropdownAlwaysOpen:!1,dropdownContainer:null,excludeCountries:[],fixDropdownWidth:!0,formatAsYouType:!0,formatOnDisplay:!0,geoIpLookup:null,hiddenInput:null,i18n:{},initialCountry:"",loadUtils:null,nationalMode:!0,onlyCountries:[],placeholderNumberType:"MOBILE",searchInputClass:"",separateDialCode:!1,showFlags:!0,strictMode:!1,useFullscreenPopup:Ht()},ut=o=>JSON.stringify(o),ot=o=>!!o&&typeof o=="object"&&!Array.isArray(o),kt=o=>typeof o=="function",Ut=o=>{if(!o||typeof o!="object")return!1;let t=o;return t.nodeType===1&&typeof t.tagName=="string"&&typeof t.appendChild=="function"},Bt=new Set(A.map(o=>o.iso2)),ct=o=>Bt.has(o),lt=new Set(Object.values(P)),W=o=>{console.warn(`[intl-tel-input] ${o}`)},b=(o,t,e)=>{W(`Option '${o}' must be ${t}; got ${ut(e)}. Ignoring.`)},Wt=(o,t)=>Object.prototype.hasOwnProperty.call(o,t),rt=(o,t)=>{let e="an array of ISO2 country code strings";if(!Array.isArray(t))return b(o,e,t),!1;for(let s of t){if(typeof s!="string")return b(o,e,t),!1;let i=s.toLowerCase();if(!ct(i))return W(`Invalid country code in '${o}': '${s}'. Ignoring.`),!1}return!0},dt=o=>{if(o===void 0)return{};if(!ot(o)){let e=`The second argument must be an options object; got ${ut(o)}. Using defaults.`;return W(e),{}}let t={};for(let[e,s]of Object.entries(o)){if(!Wt($,e)){W(`Unknown option '${e}'. Ignoring.`);continue}switch(e){case"allowDropdown":case"allowNumberExtensions":case"allowPhonewords":case"countrySearch":case"dropdownAlwaysOpen":case"fixDropdownWidth":case"formatAsYouType":case"formatOnDisplay":case"nationalMode":case"showFlags":case"separateDialCode":case"strictMode":case"useFullscreenPopup":if(typeof s!="boolean"){b(e,"a boolean",s);break}t[e]=s;break;case"autoPlaceholder":if(typeof s!="string"||!lt.has(s)){let i=Array.from(lt).join(", ");b("autoPlaceholder",`one of ${i}`,s);break}t[e]=s;break;case"containerClass":case"searchInputClass":case"countryNameLocale":if(typeof s!="string"){b(e,"a string",s);break}t[e]=s;break;case"countryOrder":(s===null||rt(e,s))&&(t[e]=s);break;case"customPlaceholder":case"geoIpLookup":case"hiddenInput":case"loadUtils":if(s!==null&&!kt(s)){b(e,"a function or null",s);break}t[e]=s;break;case"dropdownContainer":if(s!==null&&!Ut(s)){b("dropdownContainer","an HTMLElement or null",s);break}t[e]=s;break;case"excludeCountries":case"onlyCountries":rt(e,s)&&(t[e]=s);break;case"i18n":if(s&&!ot(s)){b("i18n","an object",s);break}t[e]=s;break;case"initialCountry":{if(typeof s!="string"){b("initialCountry","a string",s);break}let i=s.toLowerCase();if(i&&i!==O.AUTO&&!ct(i)){b("initialCountry","a valid ISO2 country code or 'auto'",s);break}t[e]=s;break}case"placeholderNumberType":if(typeof s!="string"||!H.has(s)){let i=Array.from(H).join(", ");b("placeholderNumberType",`one of ${i}`,s);break}t[e]=s;break;case"allowedNumberTypes":if(s!==null){if(!Array.isArray(s)){b("allowedNumberTypes","an array of number types or null",s);break}let i=!0;for(let n of s)if(typeof n!="string"||!H.has(n)){let l=Array.from(H).join(", ");b("allowedNumberTypes",`an array of valid number types (${l})`,n),i=!1;break}i&&(t[e]=s)}else t[e]=null;break}}return t},ht=o=>{o.dropdownAlwaysOpen&&(o.useFullscreenPopup=!1,o.allowDropdown=!0),o.useFullscreenPopup?o.fixDropdownWidth=!1:at()&&(o.fixDropdownWidth=!0),o.onlyCountries.length===1&&(o.initialCountry=o.onlyCountries[0]),o.separateDialCode&&(o.nationalMode=!1),o.allowDropdown&&!o.showFlags&&!o.separateDialCode&&(o.nationalMode=!1),o.useFullscreenPopup&&!o.dropdownContainer&&(o.dropdownContainer=document.body),o.i18n={...nt,...o.i18n}};var T=o=>o.replace(/\D/g,""),F=(o="")=>o.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase();var pt=()=>typeof navigator<"u"?/Android/i.test(navigator.userAgent):!1;var ft=(o,t)=>{let e=F(t),s=[],i=[],n=[],l=[],r=[],a=[];for(let d of o)d.iso2===e?s.push(d):d.normalisedName.startsWith(e)?i.push(d):d.normalisedName.includes(e)?n.push(d):e===d.dialCode||e===d.dialCodePlus?l.push(d):d.dialCodePlus.includes(e)?r.push(d):d.initials.includes(e)&&a.push(d);let c=(d,m)=>d.priority-m.priority;return[...s.sort(c),...i.sort(c),...n.sort(c),...l.sort(c),...r.sort(c),...a.sort(c)]},mt=(o,t)=>{let e=t.toLowerCase();for(let s of o)if(s.name.toLowerCase().startsWith(e))return s;return null};var G=o=>Object.keys(o).filter(t=>!!o[t]).join(" "),f=(o,t,e)=>{let s=document.createElement(o);return t&&Object.entries(t).forEach(([i,n])=>s.setAttribute(i,n)),e&&e.appendChild(s),s};var yt=()=>`
<svg class="iti__search-icon-svg" width="14" height="14" viewBox="0 0 24 24" focusable="false" ${p.HIDDEN}="true">
<circle cx="11" cy="11" r="7" />
<line x1="21" y1="21" x2="16.65" y2="16.65" />
</svg>`,Ct=o=>{let t=`iti-${o}-clear-mask`;return`
<svg class="iti__search-clear-svg" width="12" height="12" viewBox="0 0 16 16" ${p.HIDDEN}="true" focusable="false">
<mask id="${t}" maskUnits="userSpaceOnUse">
<rect width="16" height="16" fill="white" />
<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" />
</mask>
<circle cx="8" cy="8" r="8" class="iti__search-clear-bg" mask="url(#${t})" />
</svg>`},gt=()=>`
<svg class="iti__country-check-svg" width="14" height="14" viewBox="0 0 16 16" fill="currentColor" focusable="false" ${p.HIDDEN}="true">
<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"/>
</svg>`,Q=()=>`
<svg width="256" height="256" viewBox="0 0 512 512" class="iti__globe-svg">
<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"/>
<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"/>
</svg>`;var M=class o{constructor(t,e,s){this.#h=null;this.#I=null;this.#n=null;this.#l=null;this.highlightedItem=null;t.dataset.intlTelInputId=s.toString(),this.telInput=t,this.#t=e,this.#e=s,this.hadInitialPlaceholder=!!t.getAttribute("placeholder"),this.#m=!!this.telInput.closest("[dir=rtl]"),this.#t.separateDialCode&&(this.#u=this.telInput.style.paddingLeft)}#t;#e;#m;#u;#c;#h;#I;#b;#s;#i;#r;#o;#d;#n;#l;static validateInput(t){let e=t?.tagName;if(!(!!t&&typeof t=="object"&&e==="INPUT"&&typeof t.setAttribute=="function")){let i=Object.prototype.toString.call(t);throw new TypeError(`The first argument must be an HTMLInputElement, not ${i}`)}}generateMarkup(t){this.#c=t,this.telInput.classList.add("iti__tel-input"),this.telInput.hasAttribute("autocomplete")||this.telInput.setAttribute("autocomplete","tel"),this.telInput.hasAttribute("inputmode")||this.telInput.setAttribute("inputmode","tel");let e=this.#E();this.#y(e),e.appendChild(this.telInput),this.#R(),this.#x(e)}#E(){let{allowDropdown:t,showFlags:e,containerClass:s,useFullscreenPopup:i}=this.#t,n=G({iti:!0,"iti--allow-dropdown":t,"iti--show-flags":e,"iti--inline-dropdown":!i,[s]:!!s}),l=f("div",{class:n});return this.#m&&l.setAttribute("dir","ltr"),this.telInput.before(l),l}#y(t){let{allowDropdown:e,separateDialCode:s,showFlags:i}=this.#t;if(e||i||s){this.countryContainer=f("div",{class:`iti__country-container ${h.V_HIDE}`},t),e?(this.selectedCountry=f("button",{type:"button",class:"iti__selected-country",[p.EXPANDED]:"false",[p.LABEL]:this.#t.i18n.noCountrySelected,[p.HASPOPUP]:"dialog",[p.CONTROLS]:`iti-${this.#e}__dropdown-content`},this.countryContainer),this.telInput.disabled&&this.selectedCountry.setAttribute("disabled","true")):this.selectedCountry=f("div",{class:"iti__selected-country"},this.countryContainer);let n=f("div",{class:"iti__selected-country-primary"},this.selectedCountry);this.selectedCountryInner=f("div",{class:h.FLAG},n),e&&(this.#s=f("div",{class:"iti__arrow",[p.HIDDEN]:"true"},n)),s&&(this.#b=f("div",{class:"iti__selected-dial-code"},this.selectedCountry)),e&&this.#a()}}#C(){let{fixDropdownWidth:t}=this.#t;if(t&&!this.#i.style.width){let e=this.telInput.offsetWidth;e>0&&(this.#i.style.width=`${e}px`)}}#a(){let{fixDropdownWidth:t,useFullscreenPopup:e,countrySearch:s,i18n:i,dropdownContainer:n,containerClass:l}=this.#t,r=t?"":"iti--flexible-dropdown-width";if(this.#i=f("div",{id:`iti-${this.#e}__dropdown-content`,class:`iti__dropdown-content ${h.HIDE} ${r}`,role:"dialog",[p.MODAL]:"true"}),this.#m&&this.#i.setAttribute("dir","rtl"),s&&this.#p(),this.countryList=f("ul",{class:"iti__country-list",id:`iti-${this.#e}__country-listbox`,role:"listbox",[p.LABEL]:i.countryListAriaLabel},this.#i),this.#H(),s&&this.#D(),e||(this.#C(),this.#I=this.#U(),s&&(this.#i.style.height=`${this.#I}px`)),n){let a=G({iti:!0,"iti--container":!0,"iti--fullscreen-popup":e,"iti--inline-dropdown":!e,[l]:!!l});this.#n=f("div",{class:a}),this.#n.appendChild(this.#i)}else this.countryContainer.appendChild(this.#i)}#p(){let{i18n:t,searchInputClass:e}=this.#t,s=f("div",{class:"iti__search-input-wrapper"},this.#i);this.#r=f("span",{class:"iti__search-icon",[p.HIDDEN]:"true"},s),this.#r.innerHTML=yt(),this.searchInput=f("input",{id:`iti-${this.#e}__search-input`,type:"search",class:`iti__search-input ${e}`,placeholder:t.searchPlaceholder,role:"combobox",[p.EXPANDED]:"true",[p.LABEL]:t.searchPlaceholder,[p.CONTROLS]:`iti-${this.#e}__country-listbox`,[p.AUTOCOMPLETE]:"list",autocomplete:"off"},s),this.searchClearButton=f("button",{type:"button",class:`iti__search-clear ${h.HIDE}`,[p.LABEL]:t.clearSearchAriaLabel,tabindex:"-1"},s),this.searchClearButton.innerHTML=Ct(this.#e),this.#d=f("span",{class:"iti__a11y-text"},this.#i),this.#o=f("div",{class:`iti__no-results ${h.HIDE}`,[p.HIDDEN]:"true"},this.#i),this.#o.textContent=t.searchEmptyState}#R(){this.countryContainer&&(this.#w(),this.countryContainer.classList.remove(h.V_HIDE))}#x(t){let{hiddenInput:e}=this.#t;if(e){let s=this.telInput.getAttribute("name")||"",i=e(s);if(i.phone){let n=this.telInput.form?.querySelector(`input[name="${i.phone}"]`);n?this.hiddenInput=n:(this.hiddenInput=f("input",{type:"hidden",name:i.phone}),t.appendChild(this.hiddenInput))}if(i.country){let n=this.telInput.form?.querySelector(`input[name="${i.country}"]`);n?this.hiddenInputCountry=n:(this.hiddenInputCountry=f("input",{type:"hidden",name:i.country}),t.appendChild(this.hiddenInputCountry))}}}#H(){let t=document.createDocumentFragment();for(let e=0;e<this.#c.length;e++){let s=this.#c[e],i=G({[h.COUNTRY_ITEM]:!0}),n=f("li",{id:`iti-${this.#e}__item-${s.iso2}`,class:i,tabindex:"-1",role:"option",[p.SELECTED]:"false"});n.dataset.dialCode=s.dialCode,n.dataset.countryCode=s.iso2,s.nodeById[this.#e]=n,this.#t.showFlags&&f("div",{class:`${h.FLAG} iti__${s.iso2}`},n);let l=f("span",{class:"iti__country-name"},n);l.textContent=`${s.name} `;let r=f("span",{class:"iti__dial-code"},l);this.#m&&r.setAttribute("dir","ltr"),r.textContent=`(+${s.dialCode})`,t.appendChild(n)}this.countryList.appendChild(t)}#w(){if(this.selectedCountry){let t=this.#t.separateDialCode?N.SANE_SELECTED_WITH_DIAL_WIDTH:N.SANE_SELECTED_NO_DIAL_WIDTH,s=(this.selectedCountry.offsetWidth||this.#k()||t)+N.INPUT_PADDING_EXTRA_LEFT;this.telInput.style.paddingLeft=`${s}px`}}static#A(){let t;try{t=window.top.document.body}catch{t=document.body}return t}#k(){if(this.telInput.parentNode){let t=o.#A(),e=this.telInput.parentNode.cloneNode(!1);e.style.visibility="hidden",t.appendChild(e);let s=this.countryContainer.cloneNode();e.appendChild(s);let i=this.selectedCountry.cloneNode(!0);s.appendChild(i);let n=i.offsetWidth;return t.removeChild(e),n}return 0}#U(){let t=o.#A();this.#i.classList.remove(h.HIDE);let e=f("div",{class:"iti iti--inline-dropdown"});e.appendChild(this.#i),e.style.visibility="hidden",t.appendChild(e);let s=this.#i.offsetHeight;return t.removeChild(e),e.style.visibility="",this.#i.classList.add(h.HIDE),s>0?s:N.SANE_DROPDOWN_HEIGHT}#D(){let{i18n:t}=this.#t,e=this.countryList.childElementCount;this.#d.textContent=t.searchSummaryAria(e)}filterCountriesByQuery(t){let e;t===""?e=this.#c:e=ft(this.#c,t),this.#B(e)}#T(){let t=this.searchInput.value.trim();this.filterCountriesByQuery(t),this.searchInput.value?this.searchClearButton.classList.remove(h.HIDE):this.searchClearButton.classList.add(h.HIDE)}handleSearchChange(){this.#h&&clearTimeout(this.#h),this.#h=setTimeout(()=>{this.#T(),this.#h=null},k.SEARCH_DEBOUNCE_MS)}handleSearchClear(){this.searchInput.value="",this.searchInput.focus(),this.#T()}scrollTo(t){let e=this.countryList,s=document.documentElement.scrollTop,i=e.offsetHeight,n=e.getBoundingClientRect().top+s,l=n+i,r=t.offsetHeight,a=t.getBoundingClientRect().top+s,c=a+r,d=a-n+e.scrollTop;if(a<n)e.scrollTop=d;else if(c>l){let m=i-r;e.scrollTop=d-m}}highlightListItem(t,e){let s=this.highlightedItem;if(s&&s.classList.remove(h.HIGHLIGHT),this.highlightedItem=t,this.highlightedItem&&(this.highlightedItem.classList.add(h.HIGHLIGHT),this.#t.countrySearch)){let i=this.highlightedItem.getAttribute("id")||"";this.searchInput.setAttribute(p.ACTIVE_DESCENDANT,i)}e&&this.highlightedItem.focus()}handleUpDownKey(t){let e=t===g.ARROW_UP?this.highlightedItem?.previousElementSibling:this.highlightedItem?.nextElementSibling;!e&&this.countryList.childElementCount>1&&(e=t===g.ARROW_UP?this.countryList.lastElementChild:this.countryList.firstElementChild),e&&(this.scrollTo(e),this.highlightListItem(e,!1))}#v(t){if(this.#l&&this.#l.dataset.countryCode!==t&&(this.#l.setAttribute(p.SELECTED,"false"),this.#l.querySelector(".iti__country-check")?.remove(),this.#l=null),t&&!this.#l){let e=this.countryList.querySelector(`[data-country-code="${t}"]`);if(e){e.setAttribute(p.SELECTED,"true");let s=f("span",{class:"iti__country-check",[p.HIDDEN]:"true"},e);s.innerHTML=gt(),this.#l=e}}}#B(t){this.countryList.innerHTML="";let e=!0;for(let s of t){let i=s.nodeById[this.#e];i&&(this.countryList.appendChild(i),e&&(this.highlightListItem(i,!1),e=!1))}e?(this.highlightListItem(null,!1),this.#o&&this.#o.classList.remove(h.HIDE)):this.#o&&this.#o.classList.add(h.HIDE),this.countryList.scrollTop=0,this.#D()}destroy(){this.telInput.iti=void 0,delete this.telInput.dataset.intlTelInputId,this.#t.separateDialCode&&(this.telInput.style.paddingLeft=this.#u);let t=this.telInput.parentNode;t.before(this.telInput),t.remove(),this.telInput=null,this.countryContainer=null,this.selectedCountry=null,this.selectedCountryInner=null,this.searchInput=null,this.searchClearButton=null,this.countryList=null,this.hiddenInput=null,this.hiddenInputCountry=null,this.highlightedItem=null,this.#b=null,this.#s=null,this.#i=null,this.#r=null,this.#o=null,this.#d=null,this.#n=null,this.#l=null;for(let e of this.#c)delete e.nodeById[this.#e];this.#c=null}openDropdown(){let{countrySearch:t,dropdownAlwaysOpen:e,dropdownContainer:s}=this.#t;if(this.#C(),s)this.#W();else{let i=this.#S(),n=this.telInput.offsetHeight+N.DROPDOWN_MARGIN;i?this.#i.style.top=`${n}px`:this.#i.style.bottom=`${n}px`}if(this.#i.classList.remove(h.HIDE),this.selectedCountry.setAttribute(p.EXPANDED,"true"),t){let i=this.countryList.firstElementChild;i&&(this.highlightListItem(i,!1),this.countryList.scrollTop=0),e||this.searchInput.focus()}this.#s.classList.add(h.ARROW_UP)}closeDropdown(){let{countrySearch:t,dropdownContainer:e}=this.#t;this.#i.classList.add(h.HIDE),this.selectedCountry.setAttribute(p.EXPANDED,"false"),t&&(this.searchInput.removeAttribute(p.ACTIVE_DESCENDANT),this.highlightedItem&&(this.highlightedItem.classList.remove(h.HIGHLIGHT),this.highlightedItem=null)),this.#s.classList.remove(h.ARROW_UP),e?(this.#n.remove(),this.#n.style.top="",this.#n.style.bottom=""):(this.#i.style.top="",this.#i.style.bottom="")}#S(){if(this.#t.dropdownAlwaysOpen)return!0;let t=this.telInput.getBoundingClientRect(),e=t.top,s=window.innerHeight-t.bottom;return s>=this.#I||s>=e}#W(){let{dropdownContainer:t,useFullscreenPopup:e}=this.#t;if(t){if(!e){let s=this.telInput.getBoundingClientRect();this.#n.style.left=`${s.left}px`,this.#S()?this.#n.style.top=`${s.bottom+N.DROPDOWN_MARGIN}px`:(this.#n.style.top="unset",this.#n.style.bottom=`${window.innerHeight-s.top+N.DROPDOWN_MARGIN}px`)}t.appendChild(this.#n)}}isDropdownClosed(){return this.#i.classList.contains(h.HIDE)}setCountry(t){let{allowDropdown:e,showFlags:s,separateDialCode:i,i18n:n}=this.#t,{name:l,dialCode:r,iso2:a=""}=t;if(e&&this.#v(a),this.selectedCountry){let c=a&&s?`${h.FLAG} iti__${a}`:`${h.FLAG} ${h.GLOBE}`,d,m,I;a?(m=l,d=n.selectedCountryAriaLabel.replace("${countryName}",l).replace("${dialCode}",`+${r}`),I=s?"":Q()):(m=n.noCountrySelected,d=n.noCountrySelected,I=Q()),this.selectedCountryInner.className=c,this.selectedCountry.setAttribute("title",m),this.selectedCountry.setAttribute(p.LABEL,d),this.selectedCountryInner.innerHTML=I}if(i){let c=r?`+${r}`:"";this.#b.textContent=c,this.#w()}}};var It=o=>{let{onlyCountries:t,excludeCountries:e}=o;if(t?.length){let s=t.map(i=>i.toLowerCase());return A.filter(i=>s.includes(i.iso2))}else if(e?.length){let s=e.map(i=>i.toLowerCase());return A.filter(i=>!s.includes(i.iso2))}return A},bt=(o,t)=>{let{countryNameLocale:e,i18n:s}=t,i;try{typeof Intl<"u"&&typeof Intl.DisplayNames=="function"?i=new Intl.DisplayNames(e,{type:"region"}):i=null}catch(n){console.error(n),i=null}for(let n of o)n.name=s[n.iso2]||i?.of(n.iso2.toUpperCase())||""},Et=o=>{let t=new Set,e=0,s={},i=(l,r)=>{if(!l||!r)return;r.length>e&&(e=r.length),s.hasOwnProperty(r)||(s[r]=[]);let a=s[r];a.includes(l)||a.push(l)},n=[...o].sort((l,r)=>l.priority-r.priority);for(let l of n){t.has(l.dialCode)||t.add(l.dialCode);for(let r=1;r<l.dialCode.length;r++){let a=l.dialCode.substring(0,r);i(l.iso2,a)}if(i(l.iso2,l.dialCode),l.areaCodes){let r=s[l.dialCode][0];for(let a of l.areaCodes){for(let c=1;c<a.length;c++){let d=a.substring(0,c),m=l.dialCode+d;i(r,m),i(l.iso2,m)}i(l.iso2,l.dialCode+a)}}}return{dialCodes:t,dialCodeMaxLen:e,dialCodeToIso2Map:s}},Lt=(o,t)=>{t.countryOrder&&(t.countryOrder=t.countryOrder.map(e=>e.toLowerCase())),o.sort((e,s)=>{let{countryOrder:i}=t;if(i){let n=i.indexOf(e.iso2),l=i.indexOf(s.iso2),r=n>-1,a=l>-1;if(r||a)return r&&a?n-l:r?-1:1}return e.name.localeCompare(s.name)})},wt=o=>{for(let t of o)t.normalisedName=F(t.name),t.initials=t.normalisedName.split(/[^a-z]/).map(e=>e[0]).join(""),t.dialCodePlus=`+${t.dialCode}`};var $t=new Set(["800","808","870","881","882","883","888","979"]),J=o=>{let t=T(o).slice(0,3);return o.startsWith("+")&&$t.has(t)};var Z=(o,t,e,s)=>{let i=o;if(e&&t){let n=`+${s.dialCode}`,l=i[n.length]===" "||i[n.length]==="-"?n.length+1:n.length;i=i.substring(l)}return i},Nt=(o,t,e,s,i)=>{let n=e?e.formatNumberAsYouType(o,s.iso2):o,{dialCode:l}=s;return i&&t.charAt(0)!=="+"&&n.includes(`+${l}`)?(n.split(`+${l}`)[1]||"").trim():n};var At=(o,t,e,s)=>{if(e===0&&!s)return 0;let i=0;for(let n=0;n<t.length;n++){if(/[+0-9]/.test(t[n])&&i++,i===o&&!s)return n+1;if(s&&i===o+1)return n}return t.length};var Ft=["800","822","833","844","855","866","877","880","881","882","883","884","885","886","887","888","889"],tt=o=>{let t=T(o);if(t.startsWith(U.NANP)&&t.length>=4){let e=t.substring(1,4);return Ft.includes(e)}return!1};var V=class{#t;constructor(){}#e(t){/[\u0660-\u0669]/.test(t)?this.#t="arabic-indic":/[\u06F0-\u06F9]/.test(t)?this.#t="persian":this.#t="ascii"}denormalise(t,e){if(this.#t||this.#e(e),this.#t==="ascii")return t;let s=this.#t==="arabic-indic"?1632:1776;return t.replace(/[0-9]/g,i=>String.fromCharCode(s+Number(i)))}normalise(t){if(!t)return"";if(this.#e(t),this.#t==="ascii")return t;let e=this.#t==="arabic-indic"?1632:1776,s=this.#t==="arabic-indic"?/[\u0660-\u0669]/g:/[\u06F0-\u06F9]/g;return t.replace(s,i=>String.fromCharCode(48+(i.charCodeAt(0)-e)))}isAscii(){return this.#t==="ascii"}};var Gt=0,Vt=new Set(A.map(o=>o.iso2)),et=o=>Vt.has(o),R=class o{#t;#e;#m;#u;#c;#h;#I;#b;#s;#i;#r;#o;#d;#n;#l;#E;#y;#C;constructor(t,e={}){this.id=Gt++,M.validateInput(t);let s=dt(e);this.#e={...$,...s},ht(this.#e),this.#t=new M(t,this.#e,this.id),this.#m=pt(),this.#n=new V,this.promise=this.#R(this.#e),this.#u=It(this.#e);let{dialCodes:i,dialCodeMaxLen:n,dialCodeToIso2Map:l}=Et(this.#u);this.#I=i,this.#c=n,this.#h=l,this.#b=new Map(this.#u.map(r=>[r.iso2,r])),this.#x()}#a(){let t=this.#t.telInput.value.trim();return this.#n.normalise(t)}#p(t){let e=this.#t.telInput.value;this.#t.telInput.value=this.#n.denormalise(t,e)}#R(t){let{initialCountry:e,geoIpLookup:s,loadUtils:i}=t,n=e===O.AUTO&&!!s,l=!!i&&!u.utils,r;n?r=new Promise((c,d)=>{this.#l=c,this.#E=d}):(r=Promise.resolve(void 0),this.#l=()=>{},this.#E=()=>{});let a;return l?a=new Promise((c,d)=>{this.#y=c,this.#C=d}):(a=Promise.resolve(void 0),this.#y=()=>{},this.#C=()=>{}),Promise.all([r,a])}#x(){this.#s={},this.#o=new AbortController,this.#H(),this.#t.generateMarkup(this.#u),this.#w(),this.#A(),this.#D(),this.#e.dropdownAlwaysOpen&&this.#O()}#H(){bt(this.#u,this.#e),Lt(this.#u,this.#e),wt(this.#u)}#w(t=!1){let e=this.#t.telInput.getAttribute("value"),s=this.#n.normalise(e),i=this.#a(),l=s&&s.startsWith("+")&&(!i||!i.startsWith("+"))?s:i,r=this.#P(l),a=tt(l),{initialCountry:c,geoIpLookup:d}=this.#e,I=c===O.AUTO&&d&&!t,E=c.toLowerCase(),C=et(E);r?a?C?this.#g(E):I||this.#g(it.ISO2):this.#$(l):C?this.#g(E):I||this.#g(""),l&&this.#N(l)}#A(){this.#B(),this.#e.allowDropdown&&this.#U(),(this.#t.hiddenInput||this.#t.hiddenInputCountry)&&this.#t.telInput.form&&this.#k()}#k(){let t=()=>{this.#t.hiddenInput&&(this.#t.hiddenInput.value=this.getNumber()),this.#t.hiddenInputCountry&&(this.#t.hiddenInputCountry.value=this.#s.iso2||"")};this.#t.telInput.form?.addEventListener("submit",t,{signal:this.#o.signal})}#U(){let t=this.#o.signal,e=l=>{this.#t.isDropdownClosed()?this.#t.telInput.focus():l.preventDefault()},s=this.#t.telInput.closest("label");s&&s.addEventListener("click",e,{signal:t});let i=()=>{this.#t.isDropdownClosed()&&!this.#t.telInput.disabled&&!this.#t.telInput.readOnly&&this.#O()};this.#t.selectedCountry.addEventListener("click",i,{signal:t});let n=l=>{let r=[g.ARROW_UP,g.ARROW_DOWN,g.SPACE,g.ENTER];this.#t.isDropdownClosed()&&r.includes(l.key)&&(l.preventDefault(),l.stopPropagation(),this.#O()),l.key===g.TAB&&this.#L()};this.#t.countryContainer.addEventListener("keydown",n,{signal:t})}#D(){let{loadUtils:t,initialCountry:e,geoIpLookup:s}=this.#e;if(t&&!u.utils){let n=()=>{u.attachUtils(t)?.catch(()=>{})};if(u.documentReady())n();else{let l=()=>{n()};window.addEventListener("load",l,{signal:this.#o.signal})}}else this.#y();e===O.AUTO&&s&&(this.#s.iso2?this.#l():this.#T())}#T(){if(u.autoCountry)this.#z();else if(this.#t.selectedCountryInner.classList.add(h.LOADING),!u.startedLoadingAutoCountry&&(u.startedLoadingAutoCountry=!0,typeof this.#e.geoIpLookup=="function")){let t=(s="")=>{this.#t.selectedCountryInner.classList.remove(h.LOADING);let i=s.toLowerCase();et(i)?(u.autoCountry=i,setTimeout(()=>o.forEachInstance("handleAutoCountry"))):o.forEachInstance("handleAutoCountryFailure")},e=()=>{this.#t.selectedCountryInner.classList.remove(h.LOADING),o.forEachInstance("handleAutoCountryFailure")};this.#e.geoIpLookup(t,e)}}#v(){this.#O(),this.#t.searchInput.value="+",this.#t.filterCountriesByQuery("")}#B(){this.#S(),this.#W(),this.#q()}#S(){let{strictMode:t,formatAsYouType:e,separateDialCode:s,allowDropdown:i,countrySearch:n}=this.#e,l=!1;D.ALPHA_UNICODE.test(this.#a())&&(l=!0);let r=a=>{let c=this.#a();if(this.#m&&a?.data==="+"&&s&&i&&n){let C=this.#t.telInput.selectionStart||0,v=c.substring(0,C-1),L=c.substring(C);this.#p(v+L),this.#v();return}this.#$(c)&&this.#M();let d=a?.data&&D.NON_PLUS_NUMERIC.test(a.data),m=a?.inputType===K.PASTE&&c;d||m&&!t?l=!0:D.NON_PLUS_NUMERIC.test(c)||(l=!1);let I=a?.detail&&a.detail.isSetNumber,E=this.#n.isAscii();if(e&&!l&&!I&&E){let C=this.#t.telInput.selectionStart||0,L=c.substring(0,C).replace(D.NON_PLUS_NUMERIC_GLOBAL,"").length,S=a?.inputType===K.DELETE_FWD,y=this.#f(),_=Nt(y,c,u.utils,this.#s,s),w=At(L,_,C,S);this.#p(_),this.#t.telInput.setSelectionRange(w,w)}if(s&&c.startsWith("+")&&this.#s.dialCode){let C=Z(c,!0,s,this.#s);this.#p(C)}};this.#t.telInput.addEventListener("input",r,{signal:this.#o.signal})}#W(){let{strictMode:t,separateDialCode:e,allowDropdown:s,countrySearch:i}=this.#e;if(t||e){let n=l=>{if(l.key&&l.key.length===1&&!l.altKey&&!l.ctrlKey&&!l.metaKey){if(e&&s&&i&&l.key==="+"){l.preventDefault(),this.#v();return}if(t){let r=this.#a(),c=!r.startsWith("+")&&this.#t.telInput.selectionStart===0&&l.key==="+",d=this.#n.normalise(l.key),m=/^[0-9]$/.test(d),I=e?m:c||m,E=this.#t.telInput,C=E.selectionStart,v=E.selectionEnd,L=r.slice(0,C),S=r.slice(v),y=L+l.key+S,_=this.#f(y),w=u.utils.getCoreNumber(_,this.#s.iso2),Y=this.#i&&w.length>this.#i,Dt=this.#G(_)!==null;(!I||Y&&!Dt&&!c)&&l.preventDefault()}}};this.#t.telInput.addEventListener("keydown",n,{signal:this.#o.signal})}}#q(){if(this.#e.strictMode){let t=e=>{e.preventDefault();let s=this.#t.telInput,i=s.selectionStart,n=s.selectionEnd,l=this.#a(),r=l.slice(0,i),a=l.slice(n),c=this.#s.iso2,d=e.clipboardData.getData("text"),m=this.#n.normalise(d),I=i===0&&n>0,E=!l.startsWith("+")||I,C=m.replace(D.NON_PLUS_NUMERIC_GLOBAL,""),v=C.startsWith("+"),L=C.replace(/\+/g,""),S=v&&E?`+${L}`:L,y=r+S+a;if(y.length>5){let w=u.utils.getCoreNumber(y,c);for(;w.length===0&&y.length>0;)y=y.slice(0,-1),w=u.utils.getCoreNumber(y,c);if(!w)return;if(this.#i&&w.length>this.#i)if(s.selectionEnd===l.length){let Y=w.length-this.#i;y=y.slice(0,y.length-Y)}else return}this.#p(y);let _=i+S.length;s.setSelectionRange(_,_),s.dispatchEvent(new InputEvent("input",{bubbles:!0}))};this.#t.telInput.addEventListener("paste",t,{signal:this.#o.signal})}}#Q(t){let e=Number(this.#t.telInput.getAttribute("maxlength"));return e&&t.length>e?t.substring(0,e):t}#_(t,e={}){let s=new CustomEvent(t,{bubbles:!0,cancelable:!0,detail:e});this.#t.telInput.dispatchEvent(s)}#O(){let{dropdownContainer:t,useFullscreenPopup:e}=this.#e;if(this.#d=new AbortController,this.#t.openDropdown(),!e&&t){let s=()=>this.#L();window.addEventListener("scroll",s,{signal:this.#d.signal})}this.#J(),this.#_(x.OPEN_COUNTRY_DROPDOWN)}#J(){let t=this.#d.signal;this.#Z(t),this.#tt(t),this.#e.dropdownAlwaysOpen||this.#et(t),this.#st(t),this.#e.countrySearch&&this.#it(t)}#Z(t){let e=s=>{let i=s.target?.closest(`.${h.COUNTRY_ITEM}`);i&&this.#t.highlightListItem(i,!1)};this.#t.countryList.addEventListener("mouseover",e,{signal:t})}#tt(t){let e=s=>{let i=s.target?.closest(`.${h.COUNTRY_ITEM}`);i&&this.#Y(i)};this.#t.countryList.addEventListener("click",e,{signal:t})}#et(t){let e=s=>{!!s.target.closest(`#iti-${this.id}__dropdown-content`)||this.#L()};setTimeout(()=>{document.documentElement.addEventListener("click",e,{signal:t})},0)}#st(t){let e="",s=null,i=n=>{[g.ARROW_UP,g.ARROW_DOWN,g.ENTER,g.ESC].includes(n.key)&&(n.preventDefault(),n.stopPropagation(),n.key===g.ARROW_UP||n.key===g.ARROW_DOWN?this.#t.handleUpDownKey(n.key):n.key===g.ENTER?this.#ot():n.key===g.ESC&&(this.#L(),this.#t.selectedCountry.focus())),!this.#e.countrySearch&&D.HIDDEN_SEARCH_CHAR.test(n.key)&&(n.stopPropagation(),s&&clearTimeout(s),e+=n.key.toLowerCase(),this.#nt(e),s=setTimeout(()=>{e=""},k.HIDDEN_SEARCH_RESET_MS))};document.addEventListener("keydown",i,{signal:t})}#it(t){this.#t.searchInput.addEventListener("input",()=>this.#t.handleSearchChange(),{signal:t}),this.#t.searchClearButton.addEventListener("click",()=>this.#t.handleSearchClear(),{signal:t})}#nt(t){let e=mt(this.#u,t);if(e){let s=e.nodeById[this.id];this.#t.highlightListItem(s,!1),this.#t.scrollTo(s)}}#ot(){this.#t.highlightedItem&&this.#Y(this.#t.highlightedItem)}#N(t){let{formatOnDisplay:e,nationalMode:s,separateDialCode:i}=this.#e,n=t;if(e&&u.utils&&this.#s){let l=J(t),r=s&&!l||!n.startsWith("+")&&!i,{NATIONAL:a,INTERNATIONAL:c}=u.utils.numberFormat,d=r?a:c;n=u.utils.formatNumber(n,this.#s.iso2,d)}n=this.#K(n),this.#p(n)}#$(t){let e=this.#G(t);return e!==null?this.#g(e):!1}#lt(t){let{dialCode:e,nationalPrefix:s}=this.#s;if(t.startsWith("+")||!e)return t;let l=s&&t.startsWith(s)&&!this.#e.separateDialCode?t.substring(1):t;return`+${e}${l}`}#G(t){let e=t.indexOf("+"),s=e?t.substring(e):t,i=this.#s.iso2,n=this.#s.dialCode;s=this.#lt(s);let l=this.#P(s,!0),r=T(s);if(l){let a=T(l),c=this.#h[a];if(c.length===1)return c[0]===i?null:c[0];if(!i&&this.#r&&c.includes(this.#r))return this.#r;if(n===U.NANP&&tt(r))return null;let{areaCodes:m,priority:I}=this.#s;if(m){let S=m.map(y=>`${n}${y}`);for(let y of S)if(r.startsWith(y))return null}let C=m&&!(I===0)&&r.length>a.length,v=i&&c.includes(i)&&!C,L=i===c[0];if(!v&&!L)return c[0]}else if(s.startsWith("+")&&r.length){let a=this.#s.dialCode||"";return a&&a.startsWith(r)?null:""}else if((!s||s==="+")&&!i&&this.#r)return this.#r;return null}#g(t){let e=this.#s.iso2||"";return this.#s=t?this.#b.get(t):{},this.#s.iso2&&(this.#r=this.#s.iso2),this.#t.setCountry(this.#s),this.#F(),this.#V(),e!==t}#V(){let{strictMode:t,placeholderNumberType:e,allowedNumberTypes:s}=this.#e,{iso2:i}=this.#s;if(t&&u.utils)if(i){let n=u.utils.numberType[e],l=u.utils.getExampleNumber(i,!1,n,!0),r=l;for(;u.utils.isPossibleNumber(l,i,s);)r=l,l+="0";let a=u.utils.getCoreNumber(r,i);this.#i=a.length,i==="by"&&(this.#i=a.length+1)}else this.#i=null}#F(){let{autoPlaceholder:t,placeholderNumberType:e,nationalMode:s,customPlaceholder:i}=this.#e,n=t===P.AGGRESSIVE||!this.#t.hadInitialPlaceholder&&t===P.POLITE;if(u.utils&&n){let l=u.utils.numberType[e],r=this.#s.iso2?u.utils.getExampleNumber(this.#s.iso2,s,l):"";r=this.#K(r),typeof i=="function"&&(r=i(r,this.#s)),this.#t.telInput.setAttribute("placeholder",r)}}#Y(t){let e=t.dataset[X.COUNTRY_CODE],s=this.#g(e);this.#L();let i=t.dataset[X.DIAL_CODE];if(this.#j(i),this.#e.formatOnDisplay){let n=this.#a();this.#N(n)}this.#t.telInput.focus(),s&&this.#M()}#L(t){this.#t.isDropdownClosed()||this.#e.dropdownAlwaysOpen&&!t||(this.#t.closeDropdown(),this.#d.abort(),this.#d=null,this.#_(x.CLOSE_COUNTRY_DROPDOWN))}#j(t){let e=this.#a(),s=`+${t}`,i;if(e.startsWith("+")){let n=this.#P(e);n?i=e.replace(n,s):i=s,this.#p(i)}}#P(t,e){let s="";if(t.startsWith("+")){let i="",n=!1;for(let l=0;l<t.length;l++){let r=t.charAt(l);if(/[0-9]/.test(r)){if(i+=r,!!!this.#h[i])break;if(this.#I.has(i)){if(s=t.substring(0,l+1),n=!0,!e)break}else e&&n&&(s=t.substring(0,l+1));if(i.length===this.#c)break}}}return s}#f(t){let e=t?this.#n.normalise(t):this.#a(),{dialCode:s}=this.#s,i,n=T(e);return this.#e.separateDialCode&&!e.startsWith("+")&&s&&n?i=`+${s}`:i="",i+e}#K(t){let e=!!this.#P(t),s=Z(t,e,this.#e.separateDialCode,this.#s);return this.#Q(s)}#M(){this.#_(x.COUNTRY_CHANGE)}#z(){if(!this.#t.telInput){this.#l?.();return}this.#e.initialCountry===O.AUTO&&u.autoCountry&&(this.#r=u.autoCountry,this.#s.iso2||this.#t.selectedCountryInner.classList.contains(h.GLOBE)||this.setCountry(this.#r),this.#l())}#rt(){if(!this.#t.telInput){this.#E?.();return}this.#w(!0),this.#E()}#at(){if(!this.#t.telInput){this.#y?.();return}if(u.utils){let t=this.#a();t&&this.#N(t),this.#s.iso2&&(this.#F(),this.#V())}this.#y()}#ut(t){if(!this.#t.telInput){this.#C?.(t);return}this.#C(t)}destroy(){this.#t.telInput&&(this.#e.allowDropdown&&this.#L(!0),this.#o.abort(),this.#o=null,this.#t.destroy(),u.instances instanceof Map?u.instances.delete(this.id):delete u.instances[this.id])}isActive(){return!!this.#t?.telInput}getExtension(){return u.utils&&this.#t.telInput?u.utils.getExtension(this.#f(),this.#s.iso2):""}getNumber(t){if(u.utils&&this.#t.telInput){let{iso2:e}=this.#s,s=this.#f(),i=u.utils.formatNumber(s,e,t),n=this.#t.telInput.value;return this.#n.denormalise(i,n)}return""}getNumberType(){return u.utils&&this.#t.telInput?u.utils.getNumberType(this.#f(),this.#s.iso2):z.UNKNOWN_NUMBER_TYPE}getSelectedCountryData(){return this.#s}getValidationError(){if(u.utils&&this.#t.telInput){let{iso2:t}=this.#s;return u.utils.getValidationError(this.#f(),t)}return z.UNKNOWN_VALIDATION_ERROR}isValidNumber(){let{dialCode:t,iso2:e}=this.#s;if(u.utils&&this.#t.telInput){let s=this.#f(),i=u.utils.getCoreNumber(s,e);if(i){if(t===B.DIAL_CODE&&i[0]===B.MOBILE_PREFIX&&i.length!==B.MOBILE_CORE_LENGTH)return!1;if(!D.ALPHA_UNICODE.test(s)&&t){let l=s.startsWith("+")?s.slice(1+t.length):s,r=T(l).length;if(i.length>r)return!1}}}return this.#X(!1)}isValidNumberPrecise(){return this.#X(!0)}#ct(t){return u.utils?u.utils.isPossibleNumber(t,this.#s.iso2,this.#e.allowedNumberTypes):null}#X(t){if(!u.utils||!this.#t.telInput)return null;let{allowNumberExtensions:e,allowPhonewords:s}=this.#e,i=a=>t?this.#dt(a):this.#ct(a),n=this.#f();if(!this.#s.iso2&&!J(n)||!i(n))return!1;if(n.search(D.ALPHA_UNICODE)>-1){let a=this.#s.iso2;return u.utils.getExtension(n,a)?e:s}return!0}#dt(t){return u.utils?u.utils.isValidNumber(t,this.#s.iso2,this.#e.allowedNumberTypes):null}setCountry(t){if(!this.#t.telInput)return;let e=t?.toLowerCase();if(!et(e))throw new Error(`Invalid country code: '${e}'`);let s=this.#s.iso2;if(t&&e!==s||!t&&s){if(this.#g(e),this.#j(this.#s.dialCode),this.#e.formatOnDisplay){let n=this.#a();this.#N(n)}this.#M()}}setNumber(t){if(!this.#t.telInput)return;let e=this.#n.normalise(t),s=this.#$(e);this.#N(e),s&&this.#M(),this.#_(x.INPUT,{isSetNumber:!0})}setPlaceholderNumberType(t){this.#t.telInput&&(this.#e.placeholderNumberType=t,this.#F())}setDisabled(t){this.#t.telInput&&(this.#t.telInput.disabled=t,t?this.#t.selectedCountry.setAttribute("disabled","true"):this.#t.selectedCountry.removeAttribute("disabled"))}static forEachInstance(t,...e){let s=u.instances,i=s instanceof Map?Array.from(s.values()):Object.values(s),n=e[0];i.forEach(l=>{if(l instanceof o)switch(t){case"handleUtils":l.#at();break;case"handleUtilsFailure":l.#ut(n);break;case"handleAutoCountry":l.#z();break;case"handleAutoCountryFailure":l.#rt();break}})}},Yt=o=>{if(!u.utils&&!u.startedLoadingUtilsScript){let t;if(typeof o=="function")try{t=Promise.resolve(o())}catch(e){return Promise.reject(e)}else return Promise.reject(new TypeError(`The argument passed to attachUtils must be a function that returns a promise for the utilities module, not ${typeof o}`));return u.startedLoadingUtilsScript=!0,t.then(e=>{let s=e?.default;if(!s||typeof s!="object")throw new TypeError("The loader function passed to attachUtils did not resolve to a module object with utils as its default export.");return u.utils=s,R.forEachInstance("handleUtils"),!0}).catch(e=>{throw R.forEachInstance("handleUtilsFailure",e),e})}return null},u=Object.assign((o,t)=>{let e=new R(o,t);return u.instances[e.id]=e,o.iti=e,e},{defaults:$,documentReady:()=>document.readyState==="complete",getCountryData:()=>A,getInstance:o=>{let t=o.dataset.intlTelInputId;return t?u.instances[t]:null},instances:{},attachUtils:Yt,startedLoadingUtilsScript:!1,startedLoadingAutoCountry:!1,version:"26.8.0"}),jt=u;return Pt(Kt);})();
// UMD
return factoryOutput.default;
}));