UNPKG

intl-tel-input

Version:

A JavaScript plugin for entering and validating international telephone numbers

39 lines (35 loc) 45 kB
/* * International Telephone Input v26.9.1 * 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 vt=Object.getOwnPropertyDescriptor;var Tt=Object.getOwnPropertyNames;var St=Object.prototype.hasOwnProperty;var Ot=(n,t)=>{for(var e in t)j(n,e,{get:t[e],enumerable:!0})},_t=(n,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Tt(t))!St.call(n,s)&&s!==e&&j(n,s,{get:()=>t[s],enumerable:!(i=vt(t,s))||i.enumerable});return n};var Pt=n=>_t(j({},"__esModule",{value:!0}),n);var jt={};Ot(jt,{Iti:()=>x,default:()=>Yt});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"]],K=[];for(let n of Mt)K.push({name:"",iso2:n[0],dialCode:n[1],priority:n[2]||0,areaCodes:n[3]||null,nodeById:{},nationalPrefix:n[4]||null,normalisedName:"",initials:"",dialCodePlus:""});var Rt=new Set(K.map(n=>n.iso2)),O=n=>Rt.has(n),P=K;var H={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"},C={ARROW_UP:"ArrowUp",ARROW_DOWN:"ArrowDown",SPACE:" ",ENTER:"Enter",ESC:"Escape",TAB:"Tab"},z={PASTE:"insertFromPaste",DELETE_FWD:"deleteContentForward"},A={ALPHA_UNICODE:/\p{L}/u,NON_PLUS_NUMERIC:/[^+0-9]/,NON_PLUS_NUMERIC_GLOBAL:/[^+0-9]/g,HIDDEN_SEARCH_CHAR:/^[a-zA-ZÀ-ÿа-яА-Я ]$/},W={SEARCH_DEBOUNCE_MS:100,HIDDEN_SEARCH_RESET_MS:1e3,NEXT_TICK:0},X={UNKNOWN_NUMBER_TYPE:-99,UNKNOWN_VALIDATION_ERROR:-99},L={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},B={PLUS:"+",NANP:"1"},$={ISO2:"gb",DIAL_CODE:"44",MOBILE_PREFIX:"7",MOBILE_CORE_LENGTH:10},st={ISO2:"us",DIAL_CODE:"1"},M={AGGRESSIVE:"aggressive",POLITE:"polite",OFF:"off"},_={AUTO:"auto"},xt=["FIXED_LINE","MOBILE","FIXED_LINE_OR_MOBILE","TOLL_FREE","PREMIUM_RATE","SHARED_COST","VOIP","PERSONAL_NUMBER","PAGER","UAN","VOICEMAIL","UNKNOWN"],k=new Set(xt),q={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 Ht={selectedCountryAriaLabel:"Change country, selected ${countryName} (${dialCode})",noCountrySelected:"Select country",countryListAriaLabel:"List of countries",searchPlaceholder:"Search",clearSearchAriaLabel:"Clear search",searchEmptyState:"No results found",searchSummaryAria(n){return n===0?"No results found":n===1?"1 result found":`${n} results found`}},nt=Ht;var Q=n=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia(n).matches,at=()=>Q(`(max-width: ${L.NARROW_VIEWPORT_WIDTH}px)`),kt=()=>{if(typeof navigator<"u"&&typeof window<"u"){let n=Q("(max-height: 600px)"),t=Q("(pointer: coarse)");return at()||t&&n}return!1},G={allowDropdown:!0,allowedNumberTypes:["MOBILE","FIXED_LINE"],allowNumberExtensions:!1,allowPhonewords:!1,autoPlaceholder:M.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:kt()},ut=n=>JSON.stringify(n),ot=n=>!!n&&typeof n=="object"&&!Array.isArray(n),Ut=n=>typeof n=="function",Wt=n=>{if(!n||typeof n!="object")return!1;let t=n;return t.nodeType===1&&typeof t.tagName=="string"&&typeof t.appendChild=="function"},lt=new Set(Object.values(M)),F=n=>{console.warn(`[intl-tel-input] ${n}`)},b=(n,t,e)=>{F(`Option '${n}' must be ${t}; got ${ut(e)}. Ignoring.`)},Bt=(n,t)=>Object.prototype.hasOwnProperty.call(n,t),rt=(n,t)=>{let e="an array of ISO2 country code strings";if(!Array.isArray(t))return b(n,e,t),!1;let i=[];for(let s of t){if(typeof s!="string")return b(n,e,t),!1;let o=s.toLowerCase();O(o)?i.push(s):F(`Invalid country code in '${n}': '${s}'. Skipping.`)}return i},ct=n=>{if(n===void 0)return{};if(!ot(n)){let e=`The second argument must be an options object; got ${ut(n)}. Using defaults.`;return F(e),{}}let t={};for(let[e,i]of Object.entries(n)){if(!Bt(G,e)){F(`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 i!="boolean"){b(e,"a boolean",i);break}t[e]=i;break;case"autoPlaceholder":if(typeof i!="string"||!lt.has(i)){let s=Array.from(lt).join(", ");b("autoPlaceholder",`one of ${s}`,i);break}t[e]=i;break;case"containerClass":case"searchInputClass":case"countryNameLocale":if(typeof i!="string"){b(e,"a string",i);break}t[e]=i;break;case"countryOrder":{if(i===null)t[e]=i;else{let s=rt(e,i);s!==!1&&(t[e]=s)}break}case"customPlaceholder":case"geoIpLookup":case"hiddenInput":case"loadUtils":if(i!==null&&!Ut(i)){b(e,"a function or null",i);break}t[e]=i;break;case"dropdownContainer":if(i!==null&&!Wt(i)){b("dropdownContainer","an HTMLElement or null",i);break}t[e]=i;break;case"excludeCountries":case"onlyCountries":{let s=rt(e,i);s!==!1&&(t[e]=s);break}case"i18n":if(i&&!ot(i)){b("i18n","an object",i);break}t[e]=i;break;case"initialCountry":{if(typeof i!="string"){b("initialCountry","a string",i);break}let s=i.toLowerCase();if(s&&s!==_.AUTO&&!O(s)){b("initialCountry","a valid ISO2 country code or 'auto'",i);break}t[e]=i;break}case"placeholderNumberType":if(typeof i!="string"||!k.has(i)){let s=Array.from(k).join(", ");b("placeholderNumberType",`one of ${s}`,i);break}t[e]=i;break;case"allowedNumberTypes":if(i!==null){if(!Array.isArray(i)){b("allowedNumberTypes","an array of number types or null",i);break}let s=!0;for(let o of i)if(typeof o!="string"||!k.has(o)){let l=Array.from(k).join(", ");b("allowedNumberTypes",`an array of valid number types (${l})`,o),s=!1;break}s&&(t[e]=i)}else t[e]=null;break}}return t},dt=n=>{n.initialCountry&&(n.initialCountry=n.initialCountry.toLowerCase()),n.onlyCountries?.length&&(n.onlyCountries=n.onlyCountries.map(t=>t.toLowerCase())),n.excludeCountries?.length&&(n.excludeCountries=n.excludeCountries.map(t=>t.toLowerCase())),n.countryOrder&&(n.countryOrder=n.countryOrder.map(t=>t.toLowerCase()))},ht=n=>{n.dropdownAlwaysOpen&&(n.useFullscreenPopup=!1,n.allowDropdown=!0),n.useFullscreenPopup?n.fixDropdownWidth=!1:at()&&(n.fixDropdownWidth=!0),n.onlyCountries.length===1&&(n.initialCountry=n.onlyCountries[0]),n.separateDialCode&&(n.nationalMode=!1),n.allowDropdown&&!n.showFlags&&!n.separateDialCode&&(n.nationalMode=!1),n.useFullscreenPopup&&!n.dropdownContainer&&(n.dropdownContainer=document.body),n.i18n={...nt,...n.i18n}};var D=n=>n.replace(/\D/g,""),U=(n="")=>n.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase();var pt=()=>typeof navigator<"u"?/Android/i.test(navigator.userAgent):!1;var ft=(n,t)=>{let e=U(t),i=[],s=[],o=[],l=[],r=[],a=[];for(let d of n)d.iso2===e?i.push(d):d.normalisedName.startsWith(e)?s.push(d):d.normalisedName.includes(e)?o.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[...i,...s,...o,...l.sort(c),...r.sort(c),...a]},mt=(n,t)=>{let e=U(t);for(let i of n)if(i.normalisedName.startsWith(e))return i;return null};var V=n=>Object.keys(n).filter(t=>!!n[t]).join(" "),f=(n,t,e)=>{let i=document.createElement(n);return t&&Object.entries(t).forEach(([s,o])=>i.setAttribute(s,o)),e&&e.appendChild(i),i};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=n=>{let t=`iti-${n}-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>`,J=()=>` <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 R=class n{constructor(t,e,i){this.#h=null;this.#I=null;this.#n=null;this.#l=null;this.highlightedItem=null;t.dataset.intlTelInputId=i.toString(),this.telInput=t,this.#t=e,this.#e=i,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;#i;#s;#r;#o;#d;#n;#l;static validateInput(t){let e=t?.tagName;if(!(!!t&&typeof t=="object"&&e==="INPUT"&&typeof t.setAttribute=="function")){let s=Object.prototype.toString.call(t);throw new TypeError(`The first argument must be an HTMLInputElement, not ${s}`)}}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:i,useFullscreenPopup:s}=this.#t,o=V({iti:!0,"iti--allow-dropdown":t,"iti--show-flags":e,"iti--inline-dropdown":!s,[i]:!!i}),l=f("div",{class:o});return this.#m&&l.setAttribute("dir","ltr"),this.telInput.before(l),l}#y(t){let{allowDropdown:e,separateDialCode:i,showFlags:s}=this.#t;if(e||s||i){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 o=f("div",{class:"iti__selected-country-primary"},this.selectedCountry);this.selectedCountryInner=f("div",{class:h.FLAG},o),e&&(this.#i=f("div",{class:"iti__arrow",[p.HIDDEN]:"true"},o)),i&&(this.#b=f("div",{class:"iti__selected-dial-code"},this.selectedCountry)),e&&this.#a()}}#C(){let{fixDropdownWidth:t}=this.#t;if(t&&!this.#s.style.width){let e=this.telInput.offsetWidth;e>0&&(this.#s.style.width=`${e}px`)}}#a(){let{fixDropdownWidth:t,useFullscreenPopup:e,countrySearch:i,i18n:s,dropdownContainer:o,containerClass:l}=this.#t,r=t?"":"iti--flexible-dropdown-width";if(this.#s=f("div",{id:`iti-${this.#e}__dropdown-content`,class:`iti__dropdown-content ${h.HIDE} ${r}`,role:"dialog",[p.MODAL]:"true"}),this.#m&&this.#s.setAttribute("dir","rtl"),i&&this.#p(),this.countryList=f("ul",{class:"iti__country-list",id:`iti-${this.#e}__country-listbox`,role:"listbox",[p.LABEL]:s.countryListAriaLabel},this.#s),this.#H(),i&&this.#D(),e||(this.#C(),this.#I=this.#U(),i&&(this.#s.style.height=`${this.#I}px`)),o){let a=V({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.#s)}else this.countryContainer.appendChild(this.#s)}#p(){let{i18n:t,searchInputClass:e}=this.#t,i=f("div",{class:"iti__search-input-wrapper"},this.#s);this.#r=f("span",{class:"iti__search-icon",[p.HIDDEN]:"true"},i),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"},i),this.searchClearButton=f("button",{type:"button",class:`iti__search-clear ${h.HIDE}`,[p.LABEL]:t.clearSearchAriaLabel,tabindex:"-1"},i),this.searchClearButton.innerHTML=Ct(this.#e),this.#d=f("span",{class:"iti__a11y-text"},this.#s),this.#o=f("div",{class:`iti__no-results ${h.HIDE}`,[p.HIDDEN]:"true"},this.#s),this.#o.textContent=t.searchEmptyState}#R(){this.countryContainer&&(this.#N(),this.countryContainer.classList.remove(h.V_HIDE))}#x(t){let{hiddenInput:e}=this.#t;if(e){let i=this.telInput.getAttribute("name")||"",s=e(i);if(s.phone){let o=this.telInput.form?.querySelector(`input[name="${s.phone}"]`);o?this.hiddenInput=o:(this.hiddenInput=f("input",{type:"hidden",name:s.phone}),t.appendChild(this.hiddenInput))}if(s.country){let o=this.telInput.form?.querySelector(`input[name="${s.country}"]`);o?this.hiddenInputCountry=o:(this.hiddenInputCountry=f("input",{type:"hidden",name:s.country}),t.appendChild(this.hiddenInputCountry))}}}#H(){let t=document.createDocumentFragment();for(let e=0;e<this.#c.length;e++){let i=this.#c[e],s=V({[h.COUNTRY_ITEM]:!0}),o=f("li",{id:`iti-${this.#e}__item-${i.iso2}`,class:s,tabindex:"-1",role:"option",[p.SELECTED]:"false"});o.dataset.dialCode=i.dialCode,o.dataset.countryCode=i.iso2,i.nodeById[this.#e]=o,this.#t.showFlags&&f("div",{class:`${h.FLAG} iti__${i.iso2}`},o);let l=f("span",{class:"iti__country-name"},o);l.textContent=`${i.name} `;let r=f("span",{class:"iti__dial-code"},l);this.#m&&r.setAttribute("dir","ltr"),r.textContent=`(+${i.dialCode})`,t.appendChild(o)}this.countryList.appendChild(t)}#N(){if(this.selectedCountry){let t=this.#t.separateDialCode?L.SANE_SELECTED_WITH_DIAL_WIDTH:L.SANE_SELECTED_NO_DIAL_WIDTH,i=(this.selectedCountry.offsetWidth||this.#k()||t)+L.INPUT_PADDING_EXTRA_LEFT;this.telInput.style.paddingLeft=`${i}px`}}static#A(){let t;try{t=window.top.document.body}catch{t=document.body}return t}#k(){if(this.telInput.parentNode){let t=n.#A(),e=this.telInput.parentNode.cloneNode(!1);e.style.visibility="hidden",t.appendChild(e);let i=this.countryContainer.cloneNode();e.appendChild(i);let s=this.selectedCountry.cloneNode(!0);i.appendChild(s);let o=s.offsetWidth;return t.removeChild(e),o}return 0}#U(){let t=n.#A();this.#s.classList.remove(h.HIDE);let e=f("div",{class:"iti iti--inline-dropdown"});e.appendChild(this.#s),e.style.visibility="hidden",t.appendChild(e);let i=this.#s.offsetHeight;return t.removeChild(e),e.style.visibility="",this.#s.classList.add(h.HIDE),i>0?i:L.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.#W(e)}#v(){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.#v(),this.#h=null},W.SEARCH_DEBOUNCE_MS)}handleSearchClear(){this.searchInput.value="",this.searchInput.focus(),this.#v()}scrollCountryListToItem(t){let e=this.countryList,i=e.getBoundingClientRect(),s=t.getBoundingClientRect(),o=s.top-i.top+e.scrollTop;s.top<i.top?e.scrollTop=o:s.bottom>i.bottom&&(e.scrollTop=o-i.height+s.height)}highlightListItem(t,e){let i=this.highlightedItem;if(i&&i.classList.remove(h.HIGHLIGHT),this.highlightedItem=t,this.highlightedItem){if(this.highlightedItem.classList.add(h.HIGHLIGHT),this.#t.countrySearch){let s=this.highlightedItem.getAttribute("id")||"";this.searchInput.setAttribute(p.ACTIVE_DESCENDANT,s)}e&&this.highlightedItem.focus()}}handleUpDownKey(t){let e=t===C.ARROW_UP?this.highlightedItem?.previousElementSibling:this.highlightedItem?.nextElementSibling;!e&&this.countryList.childElementCount>1&&(e=t===C.ARROW_UP?this.countryList.lastElementChild:this.countryList.firstElementChild),e&&(this.scrollCountryListToItem(e),this.highlightListItem(e,!1))}#T(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 i=f("span",{class:"iti__country-check",[p.HIDDEN]:"true"},e);i.innerHTML=gt(),this.#l=e}}}#W(t){this.countryList.replaceChildren();let e=!0;for(let i of t){let s=i.nodeById[this.#e];s&&(this.countryList.appendChild(s),e&&(this.highlightListItem(s,!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.#i=null,this.#s=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:i}=this.#t;if(this.#C(),i)this.#B();else{let s=this.#S(),o=this.telInput.offsetHeight+L.DROPDOWN_MARGIN;s?this.#s.style.top=`${o}px`:this.#s.style.bottom=`${o}px`}if(this.#s.classList.remove(h.HIDE),this.selectedCountry.setAttribute(p.EXPANDED,"true"),t){let s=this.countryList.firstElementChild;s&&(this.highlightListItem(s,!1),this.countryList.scrollTop=0),e||this.searchInput.focus()}this.#i.classList.add(h.ARROW_UP)}closeDropdown(){let{countrySearch:t,dropdownContainer:e}=this.#t;this.#s.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.#i.classList.remove(h.ARROW_UP),e?(this.#n.remove(),this.#n.style.top="",this.#n.style.bottom="",this.#n.style.paddingLeft="",this.#n.style.paddingRight=""):(this.#s.style.top="",this.#s.style.bottom="")}#S(){if(this.#t.dropdownAlwaysOpen)return!0;let t=this.telInput.getBoundingClientRect(),e=t.top,i=window.innerHeight-t.bottom;return i>=this.#I||i>=e}#B(){let{dropdownContainer:t,useFullscreenPopup:e}=this.#t;if(e){if(window.innerWidth>=L.NARROW_VIEWPORT_WIDTH){let i=this.telInput.getBoundingClientRect();this.#n.style.paddingLeft=`${i.left}px`,this.#n.style.paddingRight=`${window.innerWidth-i.right}px`}}else{let i=this.telInput.getBoundingClientRect();this.#n.style.left=`${i.left}px`,this.#S()?this.#n.style.top=`${i.bottom+L.DROPDOWN_MARGIN}px`:(this.#n.style.top="unset",this.#n.style.bottom=`${window.innerHeight-i.top+L.DROPDOWN_MARGIN}px`)}t.appendChild(this.#n)}isDropdownClosed(){return this.#s.classList.contains(h.HIDE)}setCountry(t){let{allowDropdown:e,showFlags:i,separateDialCode:s,i18n:o}=this.#t,{name:l,dialCode:r,iso2:a=""}=t;if(e&&this.#T(a),this.selectedCountry){let c=a&&i?`${h.FLAG} iti__${a}`:`${h.FLAG} ${h.GLOBE}`,d,m,g;a?(m=l,d=o.selectedCountryAriaLabel.replace("${countryName}",l).replace("${dialCode}",`+${r}`),g=i?"":J()):(m=o.noCountrySelected,d=o.noCountrySelected,g=J()),this.selectedCountryInner.className=c,this.selectedCountry.setAttribute("title",m),this.selectedCountry.setAttribute(p.LABEL,d),this.selectedCountryInner.innerHTML=g}if(s){let c=r?`+${r}`:"";this.#b.textContent=c,this.#N()}}};var It=n=>{let{onlyCountries:t,excludeCountries:e}=n;return t?.length?P.filter(i=>t.includes(i.iso2)):e?.length?P.filter(i=>!e.includes(i.iso2)):P},bt=(n,t)=>{let{countryNameLocale:e,i18n:i}=t,s;try{typeof Intl<"u"&&typeof Intl.DisplayNames=="function"?s=new Intl.DisplayNames(e,{type:"region"}):s=null}catch(o){console.error(o),s=null}for(let o of n)o.name=i[o.iso2]||s?.of(o.iso2.toUpperCase())||""},Et=n=>{let t=new Set,e=0,i={},s=(l,r)=>{if(!l||!r)return;r.length>e&&(e=r.length),i.hasOwnProperty(r)||(i[r]=[]);let a=i[r];a.includes(l)||a.push(l)},o=[...n].sort((l,r)=>l.priority-r.priority);for(let l of o){t.has(l.dialCode)||t.add(l.dialCode);for(let r=1;r<l.dialCode.length;r++){let a=l.dialCode.substring(0,r);s(l.iso2,a)}if(s(l.iso2,l.dialCode),l.areaCodes){let r=i[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;s(r,m),s(l.iso2,m)}s(l.iso2,l.dialCode+a)}}}return{dialCodes:t,dialCodeMaxLen:e,dialCodeToIso2Map:i}},Lt=(n,t)=>{let{countryOrder:e}=t;n.sort((i,s)=>{if(e){let o=e.indexOf(i.iso2),l=e.indexOf(s.iso2),r=o>-1,a=l>-1;if(r||a)return r&&a?o-l:r?-1:1}return i.name.localeCompare(s.name)})},Nt=n=>{for(let t of n)t.normalisedName=U(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"]),Z=n=>{let t=D(n).slice(0,3);return n.startsWith("+")&&$t.has(t)};var tt=(n,t,e,i)=>{let s=n;if(e&&t){let o=`+${i.dialCode}`,l=s[o.length]===" "||s[o.length]==="-"?o.length+1:o.length;s=s.substring(l)}return s},wt=(n,t,e,i,s)=>{let o=e?e.formatNumberAsYouType(n,i.iso2):n,{dialCode:l}=i;return s&&t.charAt(0)!=="+"&&o.includes(`+${l}`)?(o.split(`+${l}`)[1]||"").trim():o};var At=(n,t,e,i)=>{if(e===0&&!i)return 0;let s=0;for(let o=0;o<t.length;o++){if(/[+0-9]/.test(t[o])&&s++,s===n&&!i)return o+1;if(i&&s===n+1)return o}return t.length};var Ft=new Set(["800","822","833","844","855","866","877","880","881","882","883","884","885","886","887","888","889"]),et=n=>{let t=D(n);if(t.startsWith(B.NANP)&&t.length>=4){let e=t.substring(1,4);return Ft.has(e)}return!1};var Y=class{#t;constructor(t){t&&this.#e(t)}#e(t){/[\u0660-\u0669]/.test(t)?this.#t="arabic-indic":/[\u06F0-\u06F9]/.test(t)?this.#t="persian":this.#t="ascii"}denormalise(t){if(!this.#t||this.#t==="ascii")return t;let e=this.#t==="arabic-indic"?1632:1776;return t.replace(/[0-9]/g,i=>String.fromCharCode(e+Number(i)))}normalise(t){if(!t)return"";if(this.#e(t),this.#t==="ascii")return t;let e=this.#t==="arabic-indic"?1632:1776,i=this.#t==="arabic-indic"?/[\u0660-\u0669]/g:/[\u06F0-\u06F9]/g;return t.replace(i,s=>String.fromCharCode(48+(s.charCodeAt(0)-e)))}isAscii(){return!this.#t||this.#t==="ascii"}};var Gt=0,x=class n{#t;#e;#m;#u;#c;#h;#I;#b;#i;#s;#r;#o;#d;#n;#l;#E;#y;#C;constructor(t,e={}){this.id=Gt++,R.validateInput(t);let i=ct(e);this.#e={...G,...i},dt(this.#e),ht(this.#e),this.#t=new R(t,this.#e,this.id),this.#m=pt(),this.#n=new Y(t.value),this.promise=this.#R(this.#e),this.#u=It(this.#e);let{dialCodes:s,dialCodeMaxLen:o,dialCodeToIso2Map:l}=Et(this.#u);this.#I=s,this.#c=o,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){this.#t.telInput.value=this.#n.denormalise(t)}#R(t){let{initialCountry:e,geoIpLookup:i,loadUtils:s}=t,o=e===_.AUTO&&!!i,l=!!s&&!u.utils,r;o?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]).then(()=>{})}#x(){this.#i=null,this.#o=new AbortController,this.#H(),this.#t.generateMarkup(this.#u),this.#N(),this.#A(),this.#D(),this.#e.dropdownAlwaysOpen&&this.#_()}#H(){bt(this.#u,this.#e),Lt(this.#u,this.#e),Nt(this.#u)}#N(t=!1){let e=this.#t.telInput.getAttribute("value"),i=this.#n.normalise(e),s=this.#a(),l=i&&i.startsWith("+")&&(!s||!s.startsWith("+"))?i:s,r=this.#P(l),a=et(l),{initialCountry:c,geoIpLookup:d}=this.#e,g=c===_.AUTO&&d&&!t,N=O(c);r?a?N?this.#g(c):g||this.#g(st.ISO2):this.#$(l):N?this.#g(c):g||this.#g(""),l&&this.#w(l)}#A(){this.#W(),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.#i?.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()},i=this.#t.telInput.closest("label");i&&i.addEventListener("click",e,{signal:t});let s=()=>{this.#t.isDropdownClosed()&&!this.#t.telInput.disabled&&!this.#t.telInput.readOnly&&this.#_()};this.#t.selectedCountry.addEventListener("click",s,{signal:t});let o=l=>{let r=[C.ARROW_UP,C.ARROW_DOWN,C.SPACE,C.ENTER];this.#t.isDropdownClosed()&&r.includes(l.key)&&(l.preventDefault(),l.stopPropagation(),this.#_()),l.key===C.TAB&&this.#L()};this.#t.countryContainer.addEventListener("keydown",o,{signal:t})}#D(){let{loadUtils:t,initialCountry:e,geoIpLookup:i}=this.#e;if(t&&!u.utils){let o=()=>{u.attachUtils(t)?.catch(()=>{})};u.documentReady()?o():window.addEventListener("load",o,{signal:this.#o.signal})}else this.#y();e===_.AUTO&&i&&(this.#i?.iso2?this.#l():this.#v())}#v(){if(u.autoCountry)this.#X();else if(this.#t.selectedCountryInner.classList.add(h.LOADING),!u.startedLoadingAutoCountry&&(u.startedLoadingAutoCountry=!0,typeof this.#e.geoIpLookup=="function")){let t=(i="")=>{this.#t.selectedCountryInner.classList.remove(h.LOADING);let s=i.toLowerCase();O(s)?(u.autoCountry=s,setTimeout(()=>n.forEachInstance("handleAutoCountry"))):n.forEachInstance("handleAutoCountryFailure")},e=()=>{this.#t.selectedCountryInner.classList.remove(h.LOADING),n.forEachInstance("handleAutoCountryFailure")};this.#e.geoIpLookup(t,e)}}#T(){this.#_(),this.#t.searchInput.value="+",this.#t.filterCountriesByQuery("")}#W(){this.#S(),this.#B(),this.#Q()}#S(){let{strictMode:t,formatAsYouType:e,separateDialCode:i,allowDropdown:s,countrySearch:o}=this.#e,l=!1;A.ALPHA_UNICODE.test(this.#a())&&(l=!0);let r=a=>{let c=this.#a();if(this.#m&&a?.data==="+"&&i&&s&&o){let I=this.#t.telInput.selectionStart||0,v=c.substring(0,I-1),w=c.substring(I);this.#p(v+w),this.#T();return}this.#$(c)&&this.#M();let d=a?.data&&A.NON_PLUS_NUMERIC.test(a.data),m=a?.inputType===z.PASTE&&c;d||m&&!t?l=!0:A.NON_PLUS_NUMERIC.test(c)||(l=!1);let g=a?.detail&&a.detail.isSetNumber,N=this.#n.isAscii();if(e&&!l&&!g&&N){let I=this.#t.telInput.selectionStart||0,w=c.substring(0,I).replace(A.NON_PLUS_NUMERIC_GLOBAL,"").length,T=a?.inputType===z.DELETE_FWD,y=this.#f(),S=wt(y,c,u.utils,this.#i??{},i),E=At(w,S,I,T);this.#p(S),this.#t.telInput.setSelectionRange(E,E)}if(i&&c.startsWith("+")&&this.#i?.dialCode){let I=tt(c,!0,i,this.#i??{});this.#p(I)}};this.#t.telInput.addEventListener("input",r,{signal:this.#o.signal})}#B(){let{strictMode:t,separateDialCode:e,allowDropdown:i,countrySearch:s}=this.#e;if(t||e){let o=l=>{if(l.key&&l.key.length===1&&!l.altKey&&!l.ctrlKey&&!l.metaKey){if(e&&i&&s&&l.key==="+"){l.preventDefault(),this.#T();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),g=e?m:c||m,N=this.#t.telInput,I=N.selectionStart,v=N.selectionEnd,w=r.slice(0,I),T=r.slice(v),y=w+l.key+T,S=this.#f(y),E=!1;u.utils&&this.#s&&(E=u.utils.getCoreNumber(S,this.#i?.iso2).length>this.#s);let Dt=this.#G(S)!==null;(!g||E&&!Dt&&!c)&&l.preventDefault()}}};this.#t.telInput.addEventListener("keydown",o,{signal:this.#o.signal})}}#Q(){if(this.#e.strictMode){let t=e=>{e.preventDefault();let i=this.#t.telInput,s=i.selectionStart,o=i.selectionEnd,l=this.#a(),r=l.slice(0,s),a=l.slice(o),c=this.#i?.iso2,d=e.clipboardData.getData("text"),m=this.#n.normalise(d),g=s===0&&o>0,N=!l.startsWith("+")||g,I=m.replace(A.NON_PLUS_NUMERIC_GLOBAL,""),v=I.startsWith("+"),w=I.replace(/\+/g,""),T=v&&N?`+${w}`:w,y=r+T+a;if(y.length>5){let E=u.utils.getCoreNumber(y,c);for(;E.length===0&&y.length>0;)y=y.slice(0,-1),E=u.utils.getCoreNumber(y,c);if(!E)return;if(this.#s&&E.length>this.#s)if(i.selectionEnd===l.length){let it=E.length-this.#s;y=y.slice(0,y.length-it)}else return}this.#p(y);let S=s+T.length;i.setSelectionRange(S,S),i.dispatchEvent(new InputEvent("input",{bubbles:!0}))};this.#t.telInput.addEventListener("paste",t,{signal:this.#o.signal})}}#J(t){let e=Number(this.#t.telInput.getAttribute("maxlength"));return e&&t.length>e?t.substring(0,e):t}#O(t,e={}){let i=new CustomEvent(t,{bubbles:!0,cancelable:!0,detail:e});this.#t.telInput.dispatchEvent(i)}#_(){let{dropdownContainer:t,useFullscreenPopup:e}=this.#e;if(this.#d=new AbortController,this.#t.openDropdown(),!e&&t){let i=()=>this.#L();window.addEventListener("scroll",i,{signal:this.#d.signal})}this.#Z(),this.#O(H.OPEN_COUNTRY_DROPDOWN)}#Z(){let t=this.#d.signal;this.#tt(t),this.#et(t),this.#e.dropdownAlwaysOpen||this.#it(t),this.#st(t),this.#e.countrySearch&&this.#nt(t)}#tt(t){let e=i=>{let s=i.target?.closest(`.${h.COUNTRY_ITEM}`);s&&this.#t.highlightListItem(s,!1)};this.#t.countryList.addEventListener("mouseover",e,{signal:t})}#et(t){let e=i=>{let s=i.target?.closest(`.${h.COUNTRY_ITEM}`);s&&this.#Y(s)};this.#t.countryList.addEventListener("click",e,{signal:t})}#it(t){let e=i=>{!!i.target.closest(`#iti-${this.id}__dropdown-content`)||this.#L()};setTimeout(()=>{document.documentElement.addEventListener("click",e,{signal:t})},0)}#st(t){let e="",i=null,s=o=>{[C.ARROW_UP,C.ARROW_DOWN,C.ENTER,C.ESC].includes(o.key)&&(o.preventDefault(),o.stopPropagation(),o.key===C.ARROW_UP||o.key===C.ARROW_DOWN?this.#t.handleUpDownKey(o.key):o.key===C.ENTER&&!o.isComposing?this.#lt():o.key===C.ESC&&(this.#L(),this.#t.selectedCountry.focus())),!this.#e.countrySearch&&A.HIDDEN_SEARCH_CHAR.test(o.key)&&(o.stopPropagation(),i&&clearTimeout(i),e+=o.key.toLowerCase(),this.#ot(e),i=setTimeout(()=>{e=""},W.HIDDEN_SEARCH_RESET_MS))};document.addEventListener("keydown",s,{signal:t})}#nt(t){this.#t.searchInput.addEventListener("input",()=>this.#t.handleSearchChange(),{signal:t}),this.#t.searchClearButton.addEventListener("click",()=>this.#t.handleSearchClear(),{signal:t})}#ot(t){let e=mt(this.#u,t);if(e){let i=e.nodeById[this.id];this.#t.highlightListItem(i,!1),this.#t.scrollCountryListToItem(i)}}#lt(){this.#t.highlightedItem&&this.#Y(this.#t.highlightedItem)}#w(t){let{formatOnDisplay:e,nationalMode:i,separateDialCode:s}=this.#e,o=t;if(e&&u.utils&&this.#i){let l=Z(t),r=i&&!l||!o.startsWith("+")&&!s,{NATIONAL:a,INTERNATIONAL:c}=u.utils.numberFormat,d=r?a:c;o=u.utils.formatNumber(o,this.#i?.iso2,d)}o=this.#K(o),this.#p(o)}#$(t){let e=this.#G(t);return e!==null?this.#g(e):!1}#rt(t){let e=this.#i?.dialCode,i=this.#i?.nationalPrefix;if(t.startsWith("+")||!e)return t;let l=i&&t.startsWith(i)&&!this.#e.separateDialCode?t.substring(1):t;return`+${e}${l}`}#G(t){let e=t.indexOf("+"),i=e?t.substring(e):t,s=this.#i?.iso2,o=this.#i?.dialCode;i=this.#rt(i);let l=this.#P(i,!0),r=D(i);if(l){let a=D(l),c=this.#h[a];if(c.length===1)return c[0]===s?null:c[0];if(!s&&this.#r&&c.includes(this.#r))return this.#r;if(o===B.NANP&&et(r))return null;let m=this.#i?.areaCodes,g=this.#i?.priority;if(m){let T=m.map(y=>`${o}${y}`);for(let y of T)if(r.startsWith(y))return null}let I=m&&!(g===0)&&r.length>a.length,v=s&&c.includes(s)&&!I,w=s===c[0];if(!v&&!w)return c[0]}else if(i.startsWith("+")&&r.length){let a=this.#i?.dialCode||"";return a&&a.startsWith(r)?null:""}else if((!i||i==="+")&&!s&&this.#r)return this.#r;return null}#g(t){let e=this.#i?.iso2||"";return this.#i=t?this.#b.get(t):null,this.#i?.iso2&&(this.#r=this.#i.iso2),this.#t.setCountry(this.#i??{}),this.#F(),this.#V(),e!==t}#V(){let{strictMode:t,placeholderNumberType:e,allowedNumberTypes:i}=this.#e,s=this.#i?.iso2;if(t&&u.utils)if(s){let o=u.utils.numberType[e],l=u.utils.getExampleNumber(s,!1,o,!0),r=l;for(;u.utils.isPossibleNumber(l,s,i);)r=l,l+="0";let a=u.utils.getCoreNumber(r,s);this.#s=a.length,s==="by"&&(this.#s=a.length+1)}else this.#s=null}#F(){let{autoPlaceholder:t,placeholderNumberType:e,nationalMode:i,customPlaceholder:s}=this.#e,o=t===M.AGGRESSIVE||!this.#t.hadInitialPlaceholder&&t===M.POLITE;if(u.utils&&o){let l=u.utils.numberType[e],r=this.#i?.iso2?u.utils.getExampleNumber(this.#i.iso2,i,l):"";r=this.#K(r),typeof s=="function"&&(r=s(r,this.#i??{})),this.#t.telInput.setAttribute("placeholder",r)}}#Y(t){let e=t.dataset[q.COUNTRY_CODE],i=this.#g(e);this.#L();let s=t.dataset[q.DIAL_CODE];if(this.#j(s),this.#e.formatOnDisplay){let o=this.#a();this.#w(o)}this.#t.telInput.focus(),i&&this.#M()}#L(t){this.#t.isDropdownClosed()||this.#e.dropdownAlwaysOpen&&!t||(this.#t.closeDropdown(),this.#d.abort(),this.#d=null,this.#O(H.CLOSE_COUNTRY_DROPDOWN))}#j(t){let e=this.#a(),i=`+${t}`,s;if(e.startsWith("+")){let o=this.#P(e);o?s=e.replace(o,i):s=i,this.#p(s)}}#P(t,e){let i="";if(t.startsWith("+")){let s="",o=!1;for(let l=0;l<t.length;l++){let r=t.charAt(l);if(/[0-9]/.test(r)){if(s+=r,!!!this.#h[s])break;if(this.#I.has(s)){if(i=t.substring(0,l+1),o=!0,!e)break}else e&&o&&(i=t.substring(0,l+1));if(s.length===this.#c)break}}}return i}#f(t){let e=t?this.#n.normalise(t):this.#a(),i=this.#i?.dialCode,s,o=D(e);return this.#e.separateDialCode&&!e.startsWith("+")&&i&&o?s=`+${i}`:s="",s+e}#K(t){let e=!!this.#P(t),i=tt(t,e,this.#e.separateDialCode,this.#i??{});return this.#J(i)}#z(){let t=this.#i;if(!t)return{};let{iso2:e,dialCode:i,name:s}=t;return{iso2:e,dialCode:i,name:s}}#M(){let t=this.#z();this.#O(H.COUNTRY_CHANGE,t)}#X(){if(!this.#t.telInput){this.#l?.();return}this.#e.initialCountry===_.AUTO&&u.autoCountry&&(this.#r=u.autoCountry,this.#i?.iso2||this.#t.selectedCountryInner.classList.contains(h.GLOBE)||this.setCountry(this.#r),this.#l())}#at(){if(!this.#t.telInput){this.#E?.();return}this.#N(!0),this.#E()}#ut(){if(!this.#t.telInput){this.#y?.();return}if(u.utils){let t=this.#a();t&&this.#w(t),this.#i?.iso2&&(this.#F(),this.#V())}this.#y()}#ct(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(),delete u.instances[this.id])}isActive(){return!!this.#t?.telInput}getExtension(){return u.utils&&this.#t.telInput?u.utils.getExtension(this.#f(),this.#i?.iso2):""}getNumber(t){if(u.utils&&this.#t.telInput){let e=this.#i?.iso2,i=this.#f(),s=u.utils.formatNumber(i,e,t);return this.#n.denormalise(s)}return""}getNumberType(){return u.utils&&this.#t.telInput?u.utils.getNumberType(this.#f(),this.#i?.iso2):X.UNKNOWN_NUMBER_TYPE}getSelectedCountryData(){return this.#z()}getValidationError(){if(u.utils&&this.#t.telInput){let t=this.#i?.iso2;return u.utils.getValidationError(this.#f(),t)}return X.UNKNOWN_VALIDATION_ERROR}isValidNumber(){let t=this.#i?.dialCode,e=this.#i?.iso2;if(u.utils&&this.#t.telInput){let i=this.#f(),s=u.utils.getCoreNumber(i,e);if(s){if(t===$.DIAL_CODE&&s[0]===$.MOBILE_PREFIX&&s.length!==$.MOBILE_CORE_LENGTH)return!1;if(!A.ALPHA_UNICODE.test(i)&&t){let l=i.startsWith("+")?i.slice(1+t.length):i,r=D(l).length;if(s.length>r)return!1}}}return this.#q(!1)}isValidNumberPrecise(){return this.#q(!0)}#dt(t){return u.utils?u.utils.isPossibleNumber(t,this.#i?.iso2,this.#e.allowedNumberTypes):null}#q(t){if(!u.utils||!this.#t.telInput)return null;let{allowNumberExtensions:e,allowPhonewords:i}=this.#e,s=a=>t?this.#ht(a):this.#dt(a),o=this.#f();if(!this.#i?.iso2&&!Z(o)||!s(o))return!1;if(o.search(A.ALPHA_UNICODE)>-1){let a=this.#i?.iso2;return u.utils.getExtension(o,a)?e:i}return!0}#ht(t){return u.utils?u.utils.isValidNumber(t,this.#i?.iso2,this.#e.allowedNumberTypes):null}setCountry(t){if(!this.#t.telInput)return;let e=t?.toLowerCase();if(!O(e))throw new Error(`Invalid country code: '${e}'`);let i=this.#i?.iso2;if(t&&e!==i||!t&&i){if(this.#g(e),this.#j(this.#i?.dialCode||""),this.#e.formatOnDisplay){let o=this.#a();this.#w(o)}this.#M()}}setNumber(t){if(!this.#t.telInput)return;let e=this.#n.normalise(t),i=this.#$(e);this.#w(e),i&&this.#M(),this.#O(H.INPUT,{isSetNumber:!0})}setPlaceholderNumberType(t){this.#t.telInput&&(this.#e.placeholderNumberType=t,this.#F())}setDisabled(t){this.#t.telInput&&(this.#t.telInput.disabled=t,this.#t.selectedCountry&&(t?this.#t.selectedCountry.setAttribute("disabled","true"):this.#t.selectedCountry.removeAttribute("disabled")))}static forEachInstance(t,...e){let i=Object.values(u.instances),s=e[0];i.forEach(o=>{if(o instanceof n)switch(t){case"handleUtils":o.#ut();break;case"handleUtilsFailure":o.#ct(s);break;case"handleAutoCountry":o.#X();break;case"handleAutoCountryFailure":o.#at();break}})}},Vt=n=>{if(!u.utils&&!u.startedLoadingUtilsScript){let t;if(typeof n=="function")try{t=Promise.resolve(n())}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 n}`));return u.startedLoadingUtilsScript=!0,t.then(e=>{let i=e?.default;if(!i||typeof i!="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=i,x.forEachInstance("handleUtils"),!0}).catch(e=>{throw x.forEachInstance("handleUtilsFailure",e),e})}return null},u=Object.assign((n,t)=>{let e=new x(n,t);return u.instances[e.id]=e,n.iti=e,e},{defaults:G,documentReady:()=>document.readyState==="complete",getCountryData:()=>P,getInstance:n=>{let t=n.dataset.intlTelInputId;return t?u.instances[t]:null},instances:{},attachUtils:Vt,startedLoadingUtilsScript:!1,startedLoadingAutoCountry:!1,version:"26.9.1"}),Yt=u;return Pt(jt);})(); // UMD return factoryOutput.default; }));