Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-international-phone

Package Overview
Dependencies
Maintainers
1
Versions
63
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-international-phone - npm Package Compare versions

Comparing version 4.2.6 to 4.2.7

2

dist/index.js

@@ -1,1 +0,1 @@

"use strict";function e(e,r){if(r==null||r>e.length)r=e.length;for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}function r(e){if(Array.isArray(e))return e}function t(r){if(Array.isArray(r))return e(r)}function n(e,r,t){if(r in e){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true})}else{e[r]=t}return e}function a(e){if(typeof Symbol!=="undefined"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function o(e,r){var t=e==null?null:typeof Symbol!=="undefined"&&e[Symbol.iterator]||e["@@iterator"];if(t==null)return;var n=[];var a=true;var o=false;var i,u;try{for(t=t.call(e);!(a=(i=t.next()).done);a=true){n.push(i.value);if(r&&n.length===r)break}}catch(e){o=true;u=e}finally{try{if(!a&&t["return"]!=null)t["return"]()}finally{if(o)throw u}}return n}function i(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function u(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function l(e){for(var r=1;r<arguments.length;r++){var t=arguments[r]!=null?arguments[r]:{};var a=Object.keys(t);if(typeof Object.getOwnPropertySymbols==="function"){a=a.concat(Object.getOwnPropertySymbols(t).filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))}a.forEach(function(r){n(e,r,t[r])})}return e}function c(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);if(r){n=n.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})}t.push.apply(t,n)}return t}function d(e,r){r=r!=null?r:{};if(Object.getOwnPropertyDescriptors){Object.defineProperties(e,Object.getOwnPropertyDescriptors(r))}else{c(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function s(e,r){if(e==null)return{};var t=f(e,r);var n,a;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(a=0;a<o.length;a++){n=o[a];if(r.indexOf(n)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,n))continue;t[n]=e[n]}}return t}function f(e,r){if(e==null)return{};var t={};var n=Object.keys(e);var a,o;for(o=0;o<n.length;o++){a=n[o];if(r.indexOf(a)>=0)continue;t[a]=e[a]}return t}function v(e,t){return r(e)||o(e,t)||m(e,t)||i()}function p(e){return t(e)||a(e)||m(e)||u()}function y(e){"@swc/helpers - typeof";return e&&typeof Symbol!=="undefined"&&e.constructor===Symbol?"symbol":typeof e}function m(r,t){if(!r)return;if(typeof r==="string")return e(r,t);var n=Object.prototype.toString.call(r).slice(8,-1);if(n==="Object"&&r.constructor)n=r.constructor.name;if(n==="Map"||n==="Set")return Array.from(n);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return e(r,t)}var h=Object.create;var C=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var w=Object.getPrototypeOf,D=Object.prototype.hasOwnProperty;var P=function(e,r){for(var t in r)C(e,t,{get:r[t],enumerable:!0})},S=function(e,r,t,n){var a=true,o=false,i=undefined;if(r&&typeof r=="object"||typeof r=="function")try{var u=function(){var a=c.value;!D.call(e,a)&&a!==t&&C(e,a,{get:function(){return r[a]},enumerable:!(n=b(r,a))||n.enumerable})};for(var l=g(r)[Symbol.iterator](),c;!(a=(c=l.next()).done);a=true)u()}catch(e){o=true;i=e}finally{try{if(!a&&l.return!=null){l.return()}}finally{if(o){throw i}}}return e};var x=function(e,r,t){return t=e!=null?h(w(e)):{},S(r||!e||!e.__esModule?C(t,"default",{value:e,enumerable:!0}):t,e)},k=function(e){return S(C({},"__esModule",{value:!0}),e)};var N={};P(N,{CountrySelector:function(){return eh},CountrySelectorDropdown:function(){return em},DialCodePreview:function(){return eb},FlagImage:function(){return ev},PhoneInput:function(){return ew},buildCountryData:function(){return B},defaultCountries:function(){return E},getActiveFormattingMask:function(){return et},getCountry:function(){return eo},guessCountryByPartialPhoneNumber:function(){return ei},parseCountry:function(){return en},removeDialCode:function(){return R},usePhoneInput:function(){return er}});module.exports=k(N);var A=x(require("react"));var E=[["Afghanistan","af","93"],["Albania","al","355"],["Algeria","dz","213"],["Andorra","ad","376"],["Angola","ao","244"],["Antigua and Barbuda","ag","1268"],["Argentina","ar","54","(..) ........",0],["Armenia","am","374",".. ......"],["Aruba","aw","297"],["Australia","au","61",{default:". .... ....","/^4/":"... ... ...","/^5(?!50)/":"... ... ...","/^1(3|8)00/":".... ... ...","/^13/":".. .. ..","/^180/":"... ...."},0,[]],["Austria","at","43"],["Azerbaijan","az","994","(..) ... .. .."],["Bahamas","bs","1242"],["Bahrain","bh","973"],["Bangladesh","bd","880"],["Barbados","bb","1246"],["Belarus","by","375","(..) ... .. .."],["Belgium","be","32","... .. .. .."],["Belize","bz","501"],["Benin","bj","229"],["Bhutan","bt","975"],["Bolivia","bo","591"],["Bosnia and Herzegovina","ba","387"],["Botswana","bw","267"],["Brazil","br","55","(..) ........."],["British Indian Ocean Territory","io","246"],["Brunei","bn","673"],["Bulgaria","bg","359"],["Burkina Faso","bf","226"],["Burundi","bi","257"],["Cambodia","kh","855"],["Cameroon","cm","237"],["Canada","ca","1","(...) ...-....",1,["204","226","236","249","250","289","306","343","365","387","403","416","418","431","437","438","450","506","514","519","548","579","581","587","604","613","639","647","672","705","709","742","778","780","782","807","819","825","867","873","902","905"]],["Cape Verde","cv","238"],["Caribbean Netherlands","bq","599","",1],["Central African Republic","cf","236"],["Chad","td","235"],["Chile","cl","56"],["China","cn","86","... .... ...."],["Colombia","co","57","... ... ...."],["Comoros","km","269"],["Congo","cd","243"],["Congo","cg","242"],["Costa Rica","cr","506","....-...."],["C\xf4te d'Ivoire","ci","225",".. .. .. .. .."],["Croatia","hr","385"],["Cuba","cu","53"],["Cura\xe7ao","cw","599","",0],["Cyprus","cy","357",".. ......"],["Czech Republic","cz","420","... ... ..."],["Denmark","dk","45",".. .. .. .."],["Djibouti","dj","253"],["Dominica","dm","1767"],["Dominican Republic","do","1","",2],["Ecuador","ec","593"],["Egypt","eg","20"],["El Salvador","sv","503","....-...."],["Equatorial Guinea","gq","240"],["Eritrea","er","291"],["Estonia","ee","372",".... ......"],["Ethiopia","et","251"],["Fiji","fj","679"],["Finland","fi","358",".. ... .. .."],["France","fr","33",". .. .. .. .."],["French Guiana","gf","594"],["French Polynesia","pf","689"],["Gabon","ga","241"],["Gambia","gm","220"],["Georgia","ge","995"],["Germany","de","49",".... ........"],["Ghana","gh","233"],["Greece","gr","30"],["Grenada","gd","1473"],["Guadeloupe","gp","590","",0],["Guam","gu","1671"],["Guatemala","gt","502","....-...."],["Guinea","gn","224"],["Guinea-Bissau","gw","245"],["Guyana","gy","592"],["Haiti","ht","509","....-...."],["Honduras","hn","504"],["Hong Kong","hk","852",".... ...."],["Hungary","hu","36"],["Iceland","is","354","... ...."],["India","in","91",".....-....."],["Indonesia","id","62"],["Iran","ir","98","... ... ...."],["Iraq","iq","964"],["Ireland","ie","353",".. ......."],["Israel","il","972","... ... ...."],["Italy","it","39","... .......",0],["Jamaica","jm","1876"],["Japan","jp","81",".. .... ...."],["Jordan","jo","962"],["Kazakhstan","kz","7","... ...-..-..",0],["Kenya","ke","254"],["Kiribati","ki","686"],["Kosovo","xk","383"],["Kuwait","kw","965"],["Kyrgyzstan","kg","996","... ... ..."],["Laos","la","856"],["Latvia","lv","371",".. ... ..."],["Lebanon","lb","961"],["Lesotho","ls","266"],["Liberia","lr","231"],["Libya","ly","218"],["Liechtenstein","li","423"],["Lithuania","lt","370"],["Luxembourg","lu","352"],["Macau","mo","853"],["Macedonia","mk","389"],["Madagascar","mg","261"],["Malawi","mw","265"],["Malaysia","my","60","..-....-...."],["Maldives","mv","960"],["Mali","ml","223"],["Malta","mt","356"],["Marshall Islands","mh","692"],["Martinique","mq","596"],["Mauritania","mr","222"],["Mauritius","mu","230"],["Mexico","mx","52","... ... ....",0],["Micronesia","fm","691"],["Moldova","md","373","(..) ..-..-.."],["Monaco","mc","377"],["Mongolia","mn","976"],["Montenegro","me","382"],["Morocco","ma","212"],["Mozambique","mz","258"],["Myanmar","mm","95"],["Namibia","na","264"],["Nauru","nr","674"],["Nepal","np","977"],["Netherlands","nl","31",".. ........"],["New Caledonia","nc","687"],["New Zealand","nz","64","...-...-...."],["Nicaragua","ni","505"],["Niger","ne","227"],["Nigeria","ng","234"],["North Korea","kp","850"],["Norway","no","47","... .. ..."],["Oman","om","968"],["Pakistan","pk","92","...-......."],["Palau","pw","680"],["Palestine","ps","970"],["Panama","pa","507"],["Papua New Guinea","pg","675"],["Paraguay","py","595"],["Peru","pe","51"],["Philippines","ph","63",".... ......."],["Poland","pl","48","...-...-..."],["Portugal","pt","351"],["Puerto Rico","pr","1","",3,["787","939"]],["Qatar","qa","974"],["R\xe9union","re","262"],["Romania","ro","40"],["Russia","ru","7","(...) ...-..-..",1],["Rwanda","rw","250"],["Saint Kitts and Nevis","kn","1869"],["Saint Lucia","lc","1758"],["Saint Vincent and the Grenadines","vc","1784"],["Samoa","ws","685"],["San Marino","sm","378"],["S\xe3o Tom\xe9 and Pr\xedncipe","st","239"],["Saudi Arabia","sa","966"],["Senegal","sn","221"],["Serbia","rs","381"],["Seychelles","sc","248"],["Sierra Leone","sl","232"],["Singapore","sg","65","....-...."],["Slovakia","sk","421"],["Slovenia","si","386"],["Solomon Islands","sb","677"],["Somalia","so","252"],["South Africa","za","27"],["South Korea","kr","82","... .... ...."],["South Sudan","ss","211"],["Spain","es","34","... ... ..."],["Sri Lanka","lk","94"],["Sudan","sd","249"],["Suriname","sr","597"],["Swaziland","sz","268"],["Sweden","se","46","... ... ..."],["Switzerland","ch","41",".. ... .. .."],["Syria","sy","963"],["Taiwan","tw","886"],["Tajikistan","tj","992"],["Tanzania","tz","255"],["Thailand","th","66"],["Timor-Leste","tl","670"],["Togo","tg","228"],["Tonga","to","676"],["Trinidad and Tobago","tt","1868"],["Tunisia","tn","216"],["Turkey","tr","90","... ... .. .."],["Turkmenistan","tm","993"],["Tuvalu","tv","688"],["Uganda","ug","256"],["Ukraine","ua","380","(..) ... .. .."],["United Arab Emirates","ae","971"],["United Kingdom","gb","44",".... ......"],["United States","us","1","(...) ...-....",0],["Uruguay","uy","598"],["Uzbekistan","uz","998",".. ... .. .."],["Vanuatu","vu","678"],["Vatican City","va","39",".. .... ....",1],["Venezuela","ve","58"],["Vietnam","vn","84"],["Yemen","ye","967"],["Zambia","zm","260"],["Zimbabwe","zw","263"]];var O="react-international-phone-",M=function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return r.filter(function(e){return!!e}).join(" ").trim()},j=function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return M.apply(void 0,p(r)).split(" ").map(function(e){return"".concat(O).concat(e)}).join(" ")},I=function(e){var r=e.addPrefix,t=e.rawClassNames;return M.apply(void 0,[j.apply(void 0,p(r))].concat(p(t)))};var _=function(e){var r=e.value,t=e.mask,n=e.maskSymbol,a=e.offset,o=a===void 0?0:a,i=e.trimNonMaskCharsLeftover,u=i===void 0?!1:i;if(r.length<o)return r;var l=r.slice(0,o),c=r.slice(o),d=l,s=0;var f=true,v=false,p=undefined;try{for(var y=t.split("")[Symbol.iterator](),m;!(f=(m=y.next()).done);f=true){var h=m.value;if(s>=c.length){if(!u&&h!==n){d+=h;continue}break}h===n?(d+=c[s],s+=1):d+=h}}catch(e){v=true;p=e}finally{try{if(!f&&y.return!=null){y.return()}}finally{if(v){throw p}}}return d};var L=function(e){return e?/^\d+$/.test(e):!1};var F=function(e){return e.replace(/\D/g,"")};var z=function(e,r){var t=e.style.display;t!=="block"&&(e.style.display="block");var n=e.getBoundingClientRect(),a=r.getBoundingClientRect(),o=a.top-n.top,i=n.bottom-a.bottom;o>=0&&i>=0||(Math.abs(o)<Math.abs(i)?e.scrollTop+=o:e.scrollTop-=i),e.style.display=t};var B=function(e){var r=e.name,t=e.iso2,n=e.dialCode,a=e.format,o=e.priority,i=e.areaCodes,u=[r,t,n,a,o,i];for(var l=0;l<u.length;l+=1){if(l===0)continue;var c=u[l-1],d=u[l];if(c===void 0&&d!==void 0){var s=JSON.stringify(u,function(e,r){return r===void 0?"__undefined":r}).replace(/"__undefined"/g,"undefined");throw new Error("[react-international-phone] invalid country values passed to buildCountryData. Check ".concat(c," in: ").concat(s))}}return u.filter(function(e){return e!==void 0})};var V=require("react");var R=function(e){var r=e.phone,t=e.dialCode,n=e.prefix,a=n===void 0?"+":n,o=e.charAfterDialCode,i=o===void 0?" ":o;if(!r||!t)return r;var u=r;return u.startsWith(a)&&(u=u.replace(a,"")),u.startsWith(t)?(u=u.replace(t,""),u.startsWith(i)&&(u=u.replace(i,"")),u):r};var G=function(e,r){var t=r.disableDialCodeAndPrefix?!1:r.forceDialCode,n=r.disableDialCodeAndPrefix?!1:r.insertDialCodeOnEmpty,a=e,o=function(e){return r.trimNonDigitsEnd?e.trim():e};if(!a)return n&&!a.length||t?o("".concat(r.prefix).concat(r.dialCode).concat(r.charAfterDialCode)):o(a);if(a=F(a),a===r.dialCode&&!r.disableDialCodeAndPrefix)return o("".concat(r.prefix).concat(r.dialCode).concat(r.charAfterDialCode));if(r.dialCode.startsWith(a)&&!r.disableDialCodeAndPrefix)return o(t?"".concat(r.prefix).concat(r.dialCode).concat(r.charAfterDialCode):"".concat(r.prefix).concat(a));if(!a.startsWith(r.dialCode)&&!r.disableDialCodeAndPrefix){if(t)return o("".concat(r.prefix).concat(r.dialCode).concat(r.charAfterDialCode));if(a.length<r.dialCode.length)return o("".concat(r.prefix).concat(a))}var i=function(){var e=r.dialCode.length,t=a.slice(0,e),n=a.slice(e);return{phoneLeftSide:t,phoneRightSide:n}},u=i(),l=u.phoneLeftSide,c=u.phoneRightSide;return l="".concat(r.prefix).concat(l).concat(r.charAfterDialCode),c=_({value:c,mask:r.mask,maskSymbol:r.maskChar,trimNonMaskCharsLeftover:r.trimNonDigitsEnd||r.disableDialCodeAndPrefix&&c.length===0}),r.disableDialCodeAndPrefix&&(l=""),o("".concat(l).concat(c))};var T=function(e){var r=e.phoneBeforeInput,t=e.phoneAfterInput,n=e.phoneAfterFormatted,a=e.cursorPositionAfterInput,o=e.leftOffset,i=o===void 0?0:o,u=e.deletion;if(a<i)return i;if(!r)return n.length;var l=null;for(var c=a-1;c>=0;c-=1)if(L(t[c])){l=c;break}if(l===null){for(var d=0;d<t.length;d+=1)if(L(n[d]))return d;return t.length}var s=0;for(var f=0;f<l;f+=1)L(t[f])&&(s+=1);var v=0,p=0;for(var y=0;y<n.length&&(v+=1,L(n[y])&&(p+=1),!(p>=s+1));y+=1);if(u!=="backward")for(;!L(n[v])&&v<n.length;)v+=1;return v};var q=function(e){var r=e.phone,t=e.prefix;return r?"".concat(t).concat(F(r)):""};function K(e){var r=e.value,t=e.country,n=e.insertDialCodeOnEmpty,a=e.trimNonDigitsEnd,o=e.countries,i=e.prefix,u=e.charAfterDialCode,l=e.forceDialCode,c=e.disableDialCodeAndPrefix,d=e.defaultMask,s=e.countryGuessingEnabled,f=e.disableFormatting;var v,p,y;var m=r;c&&(m=m.startsWith("".concat(i))?m:"".concat(i).concat(t.dialCode).concat(m));var h;var C=s?ei({phone:m,countries:o,currentCountryIso2:(v=t)===null||v===void 0?void 0:v.iso2}):void 0,b=(h=(p=C)===null||p===void 0?void 0:p.country)!==null&&h!==void 0?h:t,g=G(m,{prefix:i,mask:et({phone:m,country:b,defaultMask:d,disableFormatting:f}),maskChar:X,dialCode:b.dialCode,trimNonDigitsEnd:a,charAfterDialCode:u,forceDialCode:l,insertDialCodeOnEmpty:n,disableDialCodeAndPrefix:c}),w=s&&!((y=C)===null||y===void 0?void 0:y.fullDialCodeMatch)?t:b;return{phone:q({phone:c?"".concat(w.dialCode).concat(g):g,prefix:i}),inputValue:g,country:w}}var W=function(e){var r,t;var n;if((n=(r=e)===null||r===void 0?void 0:r.toLocaleLowerCase().includes("delete"))!==null&&n!==void 0?n:!1)return((t=e)===null||t===void 0?void 0:t.toLocaleLowerCase().includes("forward"))?"forward":"backward"},U=function(e,r){var t=r.country,n=r.insertDialCodeOnEmpty,a=r.phoneBeforeInput,o=r.prefix,i=r.charAfterDialCode,u=r.forceDialCode,l=r.disableDialCodeAndPrefix,c=r.countryGuessingEnabled,d=r.defaultMask,s=r.disableFormatting,f=r.countries;var v,p,y,m;var h;var C=e.nativeEvent,b=C.inputType,g=W(b),w=!!((v=b)===null||v===void 0?void 0:v.startsWith("insertFrom")),D=b==="insertText",P=((p=C)===null||p===void 0?void 0:p.data)||void 0,S=e.target.value,x=(h=e.target.selectionStart)!==null&&h!==void 0?h:0;if((y=b)===null||y===void 0?void 0:y.includes("history"))return{inputValue:a,phone:q({phone:a,prefix:o}),cursorPosition:a.length,country:t};var k;if(D&&!L(P)&&S!==o)return{inputValue:a,phone:q({phone:l?"".concat(t.dialCode).concat(a):a,prefix:o}),cursorPosition:x-((k=(m=P)===null||m===void 0?void 0:m.length)!==null&&k!==void 0?k:0),country:t};if(u&&!S.startsWith("".concat(o).concat(t.dialCode))&&!w){var N=S?a:"".concat(o).concat(t.dialCode).concat(i);return{inputValue:N,phone:q({phone:N,prefix:o}),cursorPosition:o.length+t.dialCode.length+i.length,country:t}}var A=K({value:S,country:t,trimNonDigitsEnd:g==="backward",insertDialCodeOnEmpty:n,countryGuessingEnabled:c,countries:f,prefix:o,charAfterDialCode:i,forceDialCode:u,disableDialCodeAndPrefix:l,disableFormatting:s,defaultMask:d}),E=A.phone,O=A.inputValue,M=A.country,j=T({cursorPositionAfterInput:x,phoneBeforeInput:a,phoneAfterInput:S,phoneAfterFormatted:O,leftOffset:u?o.length+t.dialCode.length+i.length:0,deletion:g});return{phone:E,inputValue:O,cursorPosition:j,country:M}};var H=require("react");var J=function(e,r){var t=Object.keys(e),n=Object.keys(r);if(t.length!==n.length)return!1;var a=true,o=false,i=undefined;try{for(var u=t[Symbol.iterator](),l;!(a=(l=u.next()).done);a=true){var c=l.value;if(e[c]!==r[c])return!1}}catch(e){o=true;i=e}finally{try{if(!a&&u.return!=null){u.return()}}finally{if(o){throw i}}}return!0};var Z=require("react"),$=function(){var e=(0,Z.useRef)(),r=(0,Z.useRef)(Date.now());return{check:function(){var t=Date.now(),n=e.current?t-r.current:void 0;return e.current=r.current,r.current=t,n}}};var Q={size:20,overrideLastItemDebounceMS:-1};function Y(e,r){var t=l({},Q,r),n=t.size,a=t.overrideLastItemDebounceMS,o=t.onChange,i=v((0,H.useState)(e),2),u=i[0],c=i[1],d=v((0,H.useState)([u]),2),s=d[0],f=d[1],y=v((0,H.useState)(0),2),m=y[0],h=y[1],C=$();return[u,function(e,r){var t,i;if(typeof e=="object"&&typeof u=="object"&&J(e,u)||e===u)return;var l=a>0,d=C.check(),v=l&&d!==void 0?d>a:!0;if(((t=r)===null||t===void 0?void 0:t.overrideLastItem)!==void 0?r.overrideLastItem:!v)f(function(r){return p(r.slice(0,m)).concat([e])});else{var y=s.length>=n;f(function(r){return p(r.slice(y?1:0,m+1)).concat([e])}),y||h(function(e){return e+1})}c(e),(i=o)===null||i===void 0?void 0:i(e)},function(){var e;if(m<=0)return{success:!1};var r=s[m-1];return c(r),h(function(e){return e-1}),(e=o)===null||e===void 0?void 0:e(r),{success:!0,value:r}},function(){var e;if(m+1>=s.length)return{success:!1};var r=s[m+1];return c(r),h(function(e){return e+1}),(e=o)===null||e===void 0?void 0:e(r),{success:!0,value:r}}]}var X=".",ee={defaultCountry:"us",value:"",prefix:"+",defaultMask:"............",charAfterDialCode:" ",historySaveDebounceMS:200,disableCountryGuess:!1,disableDialCodePrefill:!1,forceDialCode:!1,disableDialCodeAndPrefix:!1,disableFormatting:!1,countries:E,preferredCountries:[]},er=function(e){var r=e.defaultCountry,t=r===void 0?ee.defaultCountry:r,n=e.value,a=n===void 0?ee.value:n,o=e.countries,i=o===void 0?ee.countries:o,u=e.prefix,c=u===void 0?ee.prefix:u,d=e.defaultMask,s=d===void 0?ee.defaultMask:d,f=e.charAfterDialCode,p=f===void 0?ee.charAfterDialCode:f,m=e.historySaveDebounceMS,h=m===void 0?ee.historySaveDebounceMS:m,C=e.disableCountryGuess,b=C===void 0?ee.disableCountryGuess:C,g=e.disableDialCodePrefill,w=g===void 0?ee.disableDialCodePrefill:g,D=e.forceDialCode,P=D===void 0?ee.forceDialCode:D,S=e.disableDialCodeAndPrefix,x=S===void 0?ee.disableDialCodeAndPrefix:S,k=e.disableFormatting,N=k===void 0?ee.disableFormatting:k,A=e.onChange,E=e.inputRef;var O={countries:i,prefix:c,charAfterDialCode:p,forceDialCode:x?!1:P,disableDialCodeAndPrefix:x,defaultMask:s,countryGuessingEnabled:!b,disableFormatting:N},M=(0,V.useRef)(null),j=E||M,I=function(e){Promise.resolve().then(function(){var r,t;(typeof window==="undefined"?"undefined":y(window))>"u"||j.current!==((r=document)===null||r===void 0?void 0:r.activeElement)||((t=j.current)===null||t===void 0?void 0:t.setSelectionRange(e,e))})},_=v(Y(function(){var e=eo({value:t,field:"iso2",countries:i});e||console.error('[react-international-phone]: can not find a country with "'.concat(t,'" iso2 code'));var r=e||eo({value:"us",field:"iso2",countries:i}),n=K(l({value:a,country:r,insertDialCodeOnEmpty:!w},O)),o=n.phone,u=n.inputValue,c=n.country;return I(u.length),{phone:o,inputValue:u,country:c.iso2}},{overrideLastItemDebounceMS:h,onChange:function(e){var r=e.inputValue,t=e.phone,n=e.country;if(!A)return;var a=q(n);A({phone:t,inputValue:r,country:a})}}),4),L=_[0],F=L.phone,z=L.inputValue,B=L.country,R=_[1],G=_[2],T=_[3],q=(0,V.useCallback)(function(e){return eo({value:e,field:"iso2",countries:i})},[i]),W=(0,V.useMemo)(function(){return q(B)},[B,q]);(0,V.useEffect)(function(){var e=j.current;if(!e)return;var r=function(e){if(!e.key)return;var r=e.ctrlKey,t=e.shiftKey,n=e.key.toLowerCase()==="z";!r||!n||(t?T():G())};return e.addEventListener("keydown",r),function(){e.removeEventListener("keydown",r)}},[j,G,T]);var H=function(e){e.preventDefault();var r=U(e,l({country:W,phoneBeforeInput:z,insertDialCodeOnEmpty:!1},O)),t=r.phone,n=r.inputValue,o=r.country,i=r.cursorPosition;return R({inputValue:n,phone:t,country:o.iso2}),I(i),a},J=function(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{focusOnInput:!1};var t=eo({value:e,field:"iso2",countries:i});if(!t){console.error('[react-international-phone]: can not find a country with "'.concat(e,'" iso2 code'));return}var n=x?"":"".concat(c).concat(t.dialCode).concat(p);R({inputValue:n,phone:"".concat(c).concat(t.dialCode),country:t.iso2}),r.focusOnInput&&Promise.resolve().then(function(){var e;(e=j.current)===null||e===void 0?void 0:e.focus()})},Z=v((0,V.useState)(!1),2),$=Z[0],Q=Z[1];return(0,V.useEffect)(function(){if(!$){var e;Q(!0),a!==F&&((e=A)===null||e===void 0?void 0:e({inputValue:z,phone:F,country:W}));return}if(a===F)return;var r=K(l({value:a,country:W,insertDialCodeOnEmpty:!w},O)),t=r.phone,n=r.inputValue,o=r.country;R({phone:t,inputValue:n,country:o.iso2})},[a]),{phone:F,inputValue:z,country:W,setCountry:J,handlePhoneValueChange:H,inputRef:j}};var et=function(e){var r=e.phone,t=e.country,n=e.defaultMask,a=n===void 0?"............":n,o=e.disableFormatting,i=o===void 0?!1:o;var u=t.format,l=function(e){return i?e.replace(new RegExp("[^".concat(X,"]"),"g"),""):e};if(!u)return l(a);if(typeof u=="string")return l(u);if(!u.default)return console.error("[react-international-phone]: default mask for ".concat(t.iso2," is not provided")),l(a);var c=Object.keys(u).find(function(e){if(e==="default")return!1;if(!(e.charAt(0)==="/"&&e.charAt(e.length-1)==="/"))return console.error('[react-international-phone]: format regex "'.concat(e,'" for ').concat(t.iso2," is not valid")),!1;var n=new RegExp(e.substring(1,e.length-1)),a=r.replace(t.dialCode,"");return n.test(F(a))});return l(c?u[c]:u.default)};var en=function(e){var r=v(e,6),t=r[0],n=r[1],a=r[2],o=r[3],i=r[4],u=r[5];return{name:t,iso2:n,dialCode:a,format:o,priority:i,areaCodes:u}};var ea=function(e){return'Field "'.concat(e,'" is not supported')},eo=function(e){var r=e.field,t=e.value,n=e.countries,a=n===void 0?E:n;if(["priority"].includes(r))throw new Error(ea(r));var o=a.find(function(e){var n=en(e);return t===n[r]});if(o)return en(o)};var ei=function(e){var r=e.phone,t=e.countries,n=t===void 0?E:t,a=e.currentCountryIso2;var o={country:void 0,fullDialCodeMatch:!1};if(!r)return o;var i=F(r);if(!i)return o;var u=o,l=function(e){var r=e.country,t=e.fullDialCodeMatch;var n,a;var o,i;var l=r.dialCode===((n=u.country)===null||n===void 0?void 0:n.dialCode),c=((o=r.priority)!==null&&o!==void 0?o:0)<((i=(a=u.country)===null||a===void 0?void 0:a.priority)!==null&&i!==void 0?i:0);(!l||c)&&(u={country:r,fullDialCodeMatch:t})};var c=true,d=false,s=undefined;try{for(var f=n[Symbol.iterator](),v;!(c=(v=f.next()).done);c=true){var p=v.value;var y=en(p),m=y.dialCode,h=y.areaCodes;if(i.startsWith(m)){var C=u.country?Number(m)>=Number(u.country.dialCode):!0;if(h){var b=i.substring(m.length);var g=true,w=false,D=undefined;try{for(var P=h[Symbol.iterator](),S;!(g=(S=P.next()).done);g=true){var x=S.value;if(b.startsWith(x))return{country:y,fullDialCodeMatch:!0}}}catch(e){w=true;D=e}finally{try{if(!g&&P.return!=null){P.return()}}finally{if(w){throw D}}}}(C||m===i||!u.fullDialCodeMatch)&&l({country:y,fullDialCodeMatch:!0})}u.fullDialCodeMatch||i.length<m.length&&m.startsWith(i)&&(!u.country||Number(m)<=Number(u.country.dialCode))&&l({country:y,fullDialCodeMatch:!1})}}catch(e){d=true;s=e}finally{try{if(!c&&f.return!=null){f.return()}}finally{if(d){throw s}}}if(a){var k;var N=eo({value:a,field:"iso2",countries:n});if(!N)return u;var A=N?function(e){var r;if(!((r=e)===null||r===void 0?void 0:r.areaCodes))return!1;var t=i.substring(e.dialCode.length);return e.areaCodes.some(function(e){return e.startsWith(t)})}(N):!1;!!u&&((k=u.country)===null||k===void 0?void 0:k.dialCode)===N.dialCode&&u.country!==N&&u.fullDialCodeMatch&&(!N.areaCodes||A)&&(u={country:N,fullDialCodeMatch:!0})}return u};var eu=x(require("react"));var el=function(e,r){var t=parseInt(e,16);return Number(t+r).toString(16)},ec="abcdefghijklmnopqrstuvwxyz",ed="1f1e6",es=ec.split("").reduce(function(e,r,t){return d(l({},e),n({},r,el(ed,t)))},{}),ef=function(e){return[es[e[0]],es[e[1]]].join("-")},ev=function(e){var r=e.iso2,t=e.size,n=e.src,a=e.protocol,o=a===void 0?"https":a,i=e.disableLazyLoading,u=e.className,c=e.style,d=s(e,["iso2","size","src","protocol","disableLazyLoading","className","style"]);if(!r)return eu.default.createElement("img",l({className:I({addPrefix:["flag-emoji"],rawClassNames:[u]}),width:t,height:t},d));var f=function(){if(n)return n;var e=ef(r);return"".concat(o,"://cdnjs.cloudflare.com/ajax/libs/twemoji/14.0.2/svg/").concat(e,".svg")};return eu.default.createElement("img",l({className:I({addPrefix:["flag-emoji"],rawClassNames:[u]}),src:f(),width:t,height:t,draggable:!1,"data-country":r,loading:i?void 0:"lazy",style:l({width:t,height:t},c),alt:""},d))};var ep=x(require("react"));var ey=1e3,em=function(e){var r=e.show,t=e.dialCodePrefix,n=t===void 0?"+":t,a=e.selectedCountry,o=e.countries,i=o===void 0?E:o,u=e.preferredCountries,c=u===void 0?[]:u,d=e.flags,f=e.onSelect,y=e.onClose,m=s(e,["show","dialCodePrefix","selectedCountry","countries","preferredCountries","flags","onSelect","onClose"]);var h=(0,ep.useRef)(null),C=(0,ep.useRef)(),b=(0,ep.useMemo)(function(){if(!c||!c.length)return i;var e=[],r=p(i);var t=true,n=false,a=undefined;try{var o=function(){var t=l.value;var n=r.findIndex(function(e){return en(e).iso2===t});if(n!==-1){var a=r.splice(n,1)[0];e.push(a)}};for(var u=c[Symbol.iterator](),l;!(t=(l=u.next()).done);t=true)o()}catch(e){n=true;a=e}finally{try{if(!t&&u.return!=null){u.return()}}finally{if(n){throw a}}}return e.concat(r)},[i,c]),g=(0,ep.useRef)({updatedAt:void 0,value:""}),w=function(e){var r=g.current.updatedAt&&new Date().getTime()-g.current.updatedAt.getTime()>ey;g.current={value:r?e:"".concat(g.current.value).concat(e),updatedAt:new Date};var t=b.findIndex(function(e){return en(e).name.toLowerCase().startsWith(g.current.value)});t!==-1&&x(t)},D=(0,ep.useCallback)(function(e){return b.findIndex(function(r){return en(r).iso2===e})},[b]),P=v((0,ep.useState)(D(a)),2),S=P[0],x=P[1],k=function(){C.current!==a&&x(D(a))},N=(0,ep.useCallback)(function(e){var r;x(D(e.iso2)),(r=f)===null||r===void 0?void 0:r(e)},[f,D]),A=function(e){var r=b.length-1,t=function(t){return e==="prev"?t-1:e==="next"?t+1:e==="last"?r:0};x(function(e){var n=t(e);return n<0?0:n>r?r:n})},O=function(e){if(e.stopPropagation(),e.key==="Enter"){e.preventDefault();var r=en(b[S]);N(r);return}if(e.key==="Escape"){var t;(t=y)===null||t===void 0?void 0:t();return}if(e.key==="ArrowUp"){e.preventDefault(),A("prev");return}if(e.key==="ArrowDown"){e.preventDefault(),A("next");return}if(e.key==="PageUp"){e.preventDefault(),A("first");return}if(e.key==="PageDown"){e.preventDefault(),A("last");return}e.key===" "&&e.preventDefault(),e.key.length===1&&!e.altKey&&!e.ctrlKey&&!e.metaKey&&w(e.key.toLocaleLowerCase())},M=(0,ep.useCallback)(function(){if(!h.current||S===void 0)return;var e=en(b[S]).iso2;if(e===C.current)return;var r=h.current.querySelector('[data-country="'.concat(e,'"]'));r&&(z(h.current,r),C.current=e)},[S,b]);return(0,ep.useEffect)(function(){M()},[S,M]),(0,ep.useEffect)(function(){h.current&&(r?h.current.focus():k())},[r]),(0,ep.useEffect)(function(){k()},[a]),ep.default.createElement("ul",{ref:h,role:"listbox",className:I({addPrefix:["country-selector-dropdown"],rawClassNames:[m.className]}),style:l({display:r?"block":"none"},m.style),onKeyDown:O,onBlur:y,tabIndex:-1,"aria-activedescendant":"react-international-phone__".concat(en(b[S]).iso2,"-option")},b.map(function(e,r){var t,o;var i=en(e),u=i.iso2===a,l=r===S,s=c.includes(i.iso2),f=r===c.length-1,v=(t=d)===null||t===void 0?void 0:t.find(function(e){return e.iso2===i.iso2});return ep.default.createElement(ep.default.Fragment,{key:i.iso2},ep.default.createElement("li",{"data-country":i.iso2,role:"option","aria-selected":u,"aria-label":"".concat(i.name," ").concat(n).concat(i.dialCode),id:"react-international-phone__".concat(i.iso2,"-option"),className:I({addPrefix:["country-selector-dropdown__list-item",s&&"country-selector-dropdown__list-item--preferred",u&&"country-selector-dropdown__list-item--selected",l&&"country-selector-dropdown__list-item--focused"],rawClassNames:[m.listItemClassName]}),onClick:function(){return N(i)},style:m.listItemStyle,title:i.name},ep.default.createElement(ev,{iso2:i.iso2,src:(o=v)===null||o===void 0?void 0:o.src,className:I({addPrefix:["country-selector-dropdown__list-item-flag-emoji"],rawClassNames:[m.listItemFlagClassName]}),style:m.listItemFlagStyle}),ep.default.createElement("span",{className:I({addPrefix:["country-selector-dropdown__list-item-country-name"],rawClassNames:[m.listItemCountryNameClassName]}),style:m.listItemCountryNameStyle},i.name),ep.default.createElement("span",{className:I({addPrefix:["country-selector-dropdown__list-item-dial-code"],rawClassNames:[m.listItemDialCodeClassName]}),style:m.listItemDialCodeStyle},n,i.dialCode)),f?ep.default.createElement("hr",{className:I({addPrefix:["country-selector-dropdown__preferred-list-divider"],rawClassNames:[m.preferredListDividerClassName]}),style:m.preferredListDividerStyle}):null)}))};var eh=function(e){var r=e.selectedCountry,t=e.onSelect,n=e.disabled,a=e.hideDropdown,o=e.countries,i=o===void 0?E:o,u=e.preferredCountries,c=u===void 0?[]:u,f=e.flags,p=e.renderButtonWrapper,y=s(e,["selectedCountry","onSelect","disabled","hideDropdown","countries","preferredCountries","flags","renderButtonWrapper"]);var m=v((0,A.useState)(!1),2),h=m[0],C=m[1],b=(0,A.useMemo)(function(){if(r)return eo({value:r,field:"iso2",countries:i})},[i,r]),g=(0,A.useRef)(null),w=function(e){e.key&&["ArrowUp","ArrowDown"].includes(e.key)&&(e.preventDefault(),C(!0))},D=function(){var e,t,o;var i={title:(e=b)===null||e===void 0?void 0:e.name,onClick:function(){return C(function(e){return!e})},onMouseDown:function(e){return e.preventDefault()},onKeyDown:w,disabled:a||n,role:"combobox","aria-label":"Country selector","aria-haspopup":"listbox","aria-expanded":h},u=A.default.createElement("div",{className:I({addPrefix:["country-selector-button__button-content"],rawClassNames:[y.buttonContentWrapperClassName]}),style:y.buttonContentWrapperStyle},A.default.createElement(ev,{iso2:r,src:(o=f)===null||o===void 0?void 0:(t=o.find(function(e){return e.iso2===r}))===null||t===void 0?void 0:t.src,className:I({addPrefix:["country-selector-button__flag-emoji",n&&"country-selector-button__flag-emoji--disabled"],rawClassNames:[y.flagClassName]}),style:l({visibility:r?"visible":"hidden"},y.flagStyle)}),!a&&A.default.createElement("div",{className:I({addPrefix:["country-selector-button__dropdown-arrow",n&&"country-selector-button__dropdown-arrow--disabled",h&&"country-selector-button__dropdown-arrow--active"],rawClassNames:[y.dropdownArrowClassName]}),style:y.dropdownArrowStyle}));return p?p({children:u,rootProps:i}):A.default.createElement("button",d(l({},i),{type:"button",className:I({addPrefix:["country-selector-button",h&&"country-selector-button--active",n&&"country-selector-button--disabled",a&&"country-selector-button--hide-dropdown"],rawClassNames:[y.buttonClassName]}),"data-country":r,style:y.buttonStyle}),u)};return A.default.createElement("div",{className:I({addPrefix:["country-selector"],rawClassNames:[y.className]}),style:y.style,ref:g},D(),A.default.createElement(em,l({show:h,countries:i,preferredCountries:c,flags:f,onSelect:function(e){var r;C(!1),(r=t)===null||r===void 0?void 0:r(e)},selectedCountry:r,onClose:function(){C(!1)}},y.dropdownStyleProps)))};var eC=x(require("react"));var eb=function(e){var r=e.dialCode,t=e.prefix,n=e.disabled,a=e.style,o=e.className;return eC.default.createElement("div",{className:I({addPrefix:["dial-code-preview",n&&"dial-code-preview--disabled"],rawClassNames:[o]}),style:a},"".concat(t).concat(r))};var eg=x(require("react"));var ew=(0,eg.forwardRef)(function(e,r){var t=e.value,n=e.onChange,a=e.countries,o=a===void 0?E:a,i=e.preferredCountries,u=i===void 0?[]:i,c=e.hideDropdown,f=e.showDisabledDialCodeAndPrefix,v=e.disableFocusAfterCountrySelect,p=e.flags,y=e.style,m=e.className,h=e.inputStyle,C=e.inputClassName,b=e.countrySelectorStyleProps,g=e.dialCodePreviewStyleProps,w=e.inputProps,D=e.placeholder,P=e.disabled,S=e.name,x=e.onFocus,k=e.onBlur,N=e.required,A=e.autoFocus,O=s(e,["value","onChange","countries","preferredCountries","hideDropdown","showDisabledDialCodeAndPrefix","disableFocusAfterCountrySelect","flags","style","className","inputStyle","inputClassName","countrySelectorStyleProps","dialCodePreviewStyleProps","inputProps","placeholder","disabled","name","onFocus","onBlur","required","autoFocus"]);var M;var j=er(d(l({value:t,countries:o},O),{onChange:function(e){var r;(r=n)===null||r===void 0?void 0:r(e.phone,{country:e.country,inputValue:e.inputValue})}})),_=j.phone,L=j.inputValue,F=j.inputRef,z=j.country,B=j.setCountry,V=j.handlePhoneValueChange,R=O.disableDialCodeAndPrefix&&f&&((M=z)===null||M===void 0?void 0:M.dialCode);var G;return(0,eg.useImperativeHandle)(r,function(){return F.current?Object.assign(F.current,{setCountry:B,state:{phone:_,inputValue:L,country:z}}):null},[F,B,_,L,z]),eg.default.createElement("div",{ref:r,className:I({addPrefix:["input-container"],rawClassNames:[m]}),style:y},eg.default.createElement(eh,l({onSelect:function(e){return B(e.iso2,{focusOnInput:!v})},flags:p,selectedCountry:z.iso2,countries:o,preferredCountries:u,disabled:P,hideDropdown:c},b)),R&&eg.default.createElement(eb,l({dialCode:z.dialCode,prefix:(G=O.prefix)!==null&&G!==void 0?G:"+",disabled:P},g)),eg.default.createElement("input",l({onChange:V,value:L,type:"tel",ref:F,className:I({addPrefix:["input",P&&"input--disabled"],rawClassNames:[C]}),placeholder:D,disabled:P,style:h,name:S,onFocus:x,onBlur:k,autoFocus:A,required:N},w)))});0&&(module.exports={CountrySelector:CountrySelector,CountrySelectorDropdown:CountrySelectorDropdown,DialCodePreview:DialCodePreview,FlagImage:FlagImage,PhoneInput:PhoneInput,buildCountryData:buildCountryData,defaultCountries:defaultCountries,getActiveFormattingMask:getActiveFormattingMask,getCountry:getCountry,guessCountryByPartialPhoneNumber:guessCountryByPartialPhoneNumber,parseCountry:parseCountry,removeDialCode:removeDialCode,usePhoneInput:usePhoneInput});
"use strict";function e(e,r){if(r==null||r>e.length)r=e.length;for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}function r(e){if(Array.isArray(e))return e}function t(r){if(Array.isArray(r))return e(r)}function n(e,r,t){if(r in e){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true})}else{e[r]=t}return e}function a(e){if(typeof Symbol!=="undefined"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function o(e,r){var t=e==null?null:typeof Symbol!=="undefined"&&e[Symbol.iterator]||e["@@iterator"];if(t==null)return;var n=[];var a=true;var o=false;var i,u;try{for(t=t.call(e);!(a=(i=t.next()).done);a=true){n.push(i.value);if(r&&n.length===r)break}}catch(e){o=true;u=e}finally{try{if(!a&&t["return"]!=null)t["return"]()}finally{if(o)throw u}}return n}function i(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function u(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function l(e){for(var r=1;r<arguments.length;r++){var t=arguments[r]!=null?arguments[r]:{};var a=Object.keys(t);if(typeof Object.getOwnPropertySymbols==="function"){a=a.concat(Object.getOwnPropertySymbols(t).filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))}a.forEach(function(r){n(e,r,t[r])})}return e}function c(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);if(r){n=n.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})}t.push.apply(t,n)}return t}function d(e,r){r=r!=null?r:{};if(Object.getOwnPropertyDescriptors){Object.defineProperties(e,Object.getOwnPropertyDescriptors(r))}else{c(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function s(e,r){if(e==null)return{};var t=f(e,r);var n,a;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(a=0;a<o.length;a++){n=o[a];if(r.indexOf(n)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,n))continue;t[n]=e[n]}}return t}function f(e,r){if(e==null)return{};var t={};var n=Object.keys(e);var a,o;for(o=0;o<n.length;o++){a=n[o];if(r.indexOf(a)>=0)continue;t[a]=e[a]}return t}function v(e,t){return r(e)||o(e,t)||m(e,t)||i()}function p(e){return t(e)||a(e)||m(e)||u()}function y(e){"@swc/helpers - typeof";return e&&typeof Symbol!=="undefined"&&e.constructor===Symbol?"symbol":typeof e}function m(r,t){if(!r)return;if(typeof r==="string")return e(r,t);var n=Object.prototype.toString.call(r).slice(8,-1);if(n==="Object"&&r.constructor)n=r.constructor.name;if(n==="Map"||n==="Set")return Array.from(n);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return e(r,t)}var h=Object.create;var C=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var w=Object.getPrototypeOf,D=Object.prototype.hasOwnProperty;var P=function(e,r){for(var t in r)C(e,t,{get:r[t],enumerable:!0})},S=function(e,r,t,n){var a=true,o=false,i=undefined;if(r&&typeof r=="object"||typeof r=="function")try{var u=function(){var a=c.value;!D.call(e,a)&&a!==t&&C(e,a,{get:function(){return r[a]},enumerable:!(n=b(r,a))||n.enumerable})};for(var l=g(r)[Symbol.iterator](),c;!(a=(c=l.next()).done);a=true)u()}catch(e){o=true;i=e}finally{try{if(!a&&l.return!=null){l.return()}}finally{if(o){throw i}}}return e};var x=function(e,r,t){return t=e!=null?h(w(e)):{},S(r||!e||!e.__esModule?C(t,"default",{value:e,enumerable:!0}):t,e)},k=function(e){return S(C({},"__esModule",{value:!0}),e)};var N={};P(N,{CountrySelector:function(){return eh},CountrySelectorDropdown:function(){return em},DialCodePreview:function(){return eb},FlagImage:function(){return ev},PhoneInput:function(){return ew},buildCountryData:function(){return B},defaultCountries:function(){return E},getActiveFormattingMask:function(){return et},getCountry:function(){return eo},guessCountryByPartialPhoneNumber:function(){return ei},parseCountry:function(){return en},removeDialCode:function(){return R},usePhoneInput:function(){return er}});module.exports=k(N);var A=x(require("react"));var E=[["Afghanistan","af","93"],["Albania","al","355"],["Algeria","dz","213"],["Andorra","ad","376"],["Angola","ao","244"],["Antigua and Barbuda","ag","1268"],["Argentina","ar","54","(..) ........",0],["Armenia","am","374",".. ......"],["Aruba","aw","297"],["Australia","au","61",{default:". .... ....","/^4/":"... ... ...","/^5(?!50)/":"... ... ...","/^1(3|8)00/":".... ... ...","/^13/":".. .. ..","/^180/":"... ...."},0,[]],["Austria","at","43"],["Azerbaijan","az","994","(..) ... .. .."],["Bahamas","bs","1242"],["Bahrain","bh","973"],["Bangladesh","bd","880"],["Barbados","bb","1246"],["Belarus","by","375","(..) ... .. .."],["Belgium","be","32","... .. .. .."],["Belize","bz","501"],["Benin","bj","229"],["Bhutan","bt","975"],["Bolivia","bo","591"],["Bosnia and Herzegovina","ba","387"],["Botswana","bw","267"],["Brazil","br","55","(..) ........."],["British Indian Ocean Territory","io","246"],["Brunei","bn","673"],["Bulgaria","bg","359"],["Burkina Faso","bf","226"],["Burundi","bi","257"],["Cambodia","kh","855"],["Cameroon","cm","237"],["Canada","ca","1","(...) ...-....",1,["204","226","236","249","250","289","306","343","365","387","403","416","418","431","437","438","450","506","514","519","548","579","581","587","604","613","639","647","672","705","709","742","778","780","782","807","819","825","867","873","902","905"]],["Cape Verde","cv","238"],["Caribbean Netherlands","bq","599","",1],["Central African Republic","cf","236"],["Chad","td","235"],["Chile","cl","56"],["China","cn","86","... .... ...."],["Colombia","co","57","... ... ...."],["Comoros","km","269"],["Congo","cd","243"],["Congo","cg","242"],["Costa Rica","cr","506","....-...."],["C\xf4te d'Ivoire","ci","225",".. .. .. .. .."],["Croatia","hr","385"],["Cuba","cu","53"],["Cura\xe7ao","cw","599","",0],["Cyprus","cy","357",".. ......"],["Czech Republic","cz","420","... ... ..."],["Denmark","dk","45",".. .. .. .."],["Djibouti","dj","253"],["Dominica","dm","1767"],["Dominican Republic","do","1","",2],["Ecuador","ec","593"],["Egypt","eg","20"],["El Salvador","sv","503","....-...."],["Equatorial Guinea","gq","240"],["Eritrea","er","291"],["Estonia","ee","372",".... ......"],["Ethiopia","et","251"],["Fiji","fj","679"],["Finland","fi","358",".. ... .. .."],["France","fr","33",". .. .. .. .."],["French Guiana","gf","594"],["French Polynesia","pf","689"],["Gabon","ga","241"],["Gambia","gm","220"],["Georgia","ge","995"],["Germany","de","49","... ........."],["Ghana","gh","233"],["Greece","gr","30"],["Grenada","gd","1473"],["Guadeloupe","gp","590","",0],["Guam","gu","1671"],["Guatemala","gt","502","....-...."],["Guinea","gn","224"],["Guinea-Bissau","gw","245"],["Guyana","gy","592"],["Haiti","ht","509","....-...."],["Honduras","hn","504"],["Hong Kong","hk","852",".... ...."],["Hungary","hu","36"],["Iceland","is","354","... ...."],["India","in","91",".....-....."],["Indonesia","id","62"],["Iran","ir","98","... ... ...."],["Iraq","iq","964"],["Ireland","ie","353",".. ......."],["Israel","il","972","... ... ...."],["Italy","it","39","... .......",0],["Jamaica","jm","1876"],["Japan","jp","81",".. .... ...."],["Jordan","jo","962"],["Kazakhstan","kz","7","... ...-..-..",0],["Kenya","ke","254"],["Kiribati","ki","686"],["Kosovo","xk","383"],["Kuwait","kw","965"],["Kyrgyzstan","kg","996","... ... ..."],["Laos","la","856"],["Latvia","lv","371",".. ... ..."],["Lebanon","lb","961"],["Lesotho","ls","266"],["Liberia","lr","231"],["Libya","ly","218"],["Liechtenstein","li","423"],["Lithuania","lt","370"],["Luxembourg","lu","352"],["Macau","mo","853"],["Macedonia","mk","389"],["Madagascar","mg","261"],["Malawi","mw","265"],["Malaysia","my","60","..-....-...."],["Maldives","mv","960"],["Mali","ml","223"],["Malta","mt","356"],["Marshall Islands","mh","692"],["Martinique","mq","596"],["Mauritania","mr","222"],["Mauritius","mu","230"],["Mexico","mx","52","... ... ....",0],["Micronesia","fm","691"],["Moldova","md","373","(..) ..-..-.."],["Monaco","mc","377"],["Mongolia","mn","976"],["Montenegro","me","382"],["Morocco","ma","212"],["Mozambique","mz","258"],["Myanmar","mm","95"],["Namibia","na","264"],["Nauru","nr","674"],["Nepal","np","977"],["Netherlands","nl","31",".. ........"],["New Caledonia","nc","687"],["New Zealand","nz","64","...-...-...."],["Nicaragua","ni","505"],["Niger","ne","227"],["Nigeria","ng","234"],["North Korea","kp","850"],["Norway","no","47","... .. ..."],["Oman","om","968"],["Pakistan","pk","92","...-......."],["Palau","pw","680"],["Palestine","ps","970"],["Panama","pa","507"],["Papua New Guinea","pg","675"],["Paraguay","py","595"],["Peru","pe","51"],["Philippines","ph","63",".... ......."],["Poland","pl","48","...-...-..."],["Portugal","pt","351"],["Puerto Rico","pr","1","",3,["787","939"]],["Qatar","qa","974"],["R\xe9union","re","262"],["Romania","ro","40"],["Russia","ru","7","(...) ...-..-..",1],["Rwanda","rw","250"],["Saint Kitts and Nevis","kn","1869"],["Saint Lucia","lc","1758"],["Saint Vincent and the Grenadines","vc","1784"],["Samoa","ws","685"],["San Marino","sm","378"],["S\xe3o Tom\xe9 and Pr\xedncipe","st","239"],["Saudi Arabia","sa","966"],["Senegal","sn","221"],["Serbia","rs","381"],["Seychelles","sc","248"],["Sierra Leone","sl","232"],["Singapore","sg","65","....-...."],["Slovakia","sk","421"],["Slovenia","si","386"],["Solomon Islands","sb","677"],["Somalia","so","252"],["South Africa","za","27"],["South Korea","kr","82","... .... ...."],["South Sudan","ss","211"],["Spain","es","34","... ... ..."],["Sri Lanka","lk","94"],["Sudan","sd","249"],["Suriname","sr","597"],["Swaziland","sz","268"],["Sweden","se","46","... ... ..."],["Switzerland","ch","41",".. ... .. .."],["Syria","sy","963"],["Taiwan","tw","886"],["Tajikistan","tj","992"],["Tanzania","tz","255"],["Thailand","th","66"],["Timor-Leste","tl","670"],["Togo","tg","228"],["Tonga","to","676"],["Trinidad and Tobago","tt","1868"],["Tunisia","tn","216"],["Turkey","tr","90","... ... .. .."],["Turkmenistan","tm","993"],["Tuvalu","tv","688"],["Uganda","ug","256"],["Ukraine","ua","380","(..) ... .. .."],["United Arab Emirates","ae","971"],["United Kingdom","gb","44",".... ......"],["United States","us","1","(...) ...-....",0],["Uruguay","uy","598"],["Uzbekistan","uz","998",".. ... .. .."],["Vanuatu","vu","678"],["Vatican City","va","39",".. .... ....",1],["Venezuela","ve","58"],["Vietnam","vn","84"],["Yemen","ye","967"],["Zambia","zm","260"],["Zimbabwe","zw","263"]];var O="react-international-phone-",M=function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return r.filter(function(e){return!!e}).join(" ").trim()},j=function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return M.apply(void 0,p(r)).split(" ").map(function(e){return"".concat(O).concat(e)}).join(" ")},I=function(e){var r=e.addPrefix,t=e.rawClassNames;return M.apply(void 0,[j.apply(void 0,p(r))].concat(p(t)))};var _=function(e){var r=e.value,t=e.mask,n=e.maskSymbol,a=e.offset,o=a===void 0?0:a,i=e.trimNonMaskCharsLeftover,u=i===void 0?!1:i;if(r.length<o)return r;var l=r.slice(0,o),c=r.slice(o),d=l,s=0;var f=true,v=false,p=undefined;try{for(var y=t.split("")[Symbol.iterator](),m;!(f=(m=y.next()).done);f=true){var h=m.value;if(s>=c.length){if(!u&&h!==n){d+=h;continue}break}h===n?(d+=c[s],s+=1):d+=h}}catch(e){v=true;p=e}finally{try{if(!f&&y.return!=null){y.return()}}finally{if(v){throw p}}}return d};var L=function(e){return e?/^\d+$/.test(e):!1};var F=function(e){return e.replace(/\D/g,"")};var z=function(e,r){var t=e.style.display;t!=="block"&&(e.style.display="block");var n=e.getBoundingClientRect(),a=r.getBoundingClientRect(),o=a.top-n.top,i=n.bottom-a.bottom;o>=0&&i>=0||(Math.abs(o)<Math.abs(i)?e.scrollTop+=o:e.scrollTop-=i),e.style.display=t};var B=function(e){var r=e.name,t=e.iso2,n=e.dialCode,a=e.format,o=e.priority,i=e.areaCodes,u=[r,t,n,a,o,i];for(var l=0;l<u.length;l+=1){if(l===0)continue;var c=u[l-1],d=u[l];if(c===void 0&&d!==void 0){var s=JSON.stringify(u,function(e,r){return r===void 0?"__undefined":r}).replace(/"__undefined"/g,"undefined");throw new Error("[react-international-phone] invalid country values passed to buildCountryData. Check ".concat(c," in: ").concat(s))}}return u.filter(function(e){return e!==void 0})};var V=require("react");var R=function(e){var r=e.phone,t=e.dialCode,n=e.prefix,a=n===void 0?"+":n,o=e.charAfterDialCode,i=o===void 0?" ":o;if(!r||!t)return r;var u=r;return u.startsWith(a)&&(u=u.replace(a,"")),u.startsWith(t)?(u=u.replace(t,""),u.startsWith(i)&&(u=u.replace(i,"")),u):r};var G=function(e,r){var t=r.disableDialCodeAndPrefix?!1:r.forceDialCode,n=r.disableDialCodeAndPrefix?!1:r.insertDialCodeOnEmpty,a=e,o=function(e){return r.trimNonDigitsEnd?e.trim():e};if(!a)return n&&!a.length||t?o("".concat(r.prefix).concat(r.dialCode).concat(r.charAfterDialCode)):o(a);if(a=F(a),a===r.dialCode&&!r.disableDialCodeAndPrefix)return o("".concat(r.prefix).concat(r.dialCode).concat(r.charAfterDialCode));if(r.dialCode.startsWith(a)&&!r.disableDialCodeAndPrefix)return o(t?"".concat(r.prefix).concat(r.dialCode).concat(r.charAfterDialCode):"".concat(r.prefix).concat(a));if(!a.startsWith(r.dialCode)&&!r.disableDialCodeAndPrefix){if(t)return o("".concat(r.prefix).concat(r.dialCode).concat(r.charAfterDialCode));if(a.length<r.dialCode.length)return o("".concat(r.prefix).concat(a))}var i=function(){var e=r.dialCode.length,t=a.slice(0,e),n=a.slice(e);return{phoneLeftSide:t,phoneRightSide:n}},u=i(),l=u.phoneLeftSide,c=u.phoneRightSide;return l="".concat(r.prefix).concat(l).concat(r.charAfterDialCode),c=_({value:c,mask:r.mask,maskSymbol:r.maskChar,trimNonMaskCharsLeftover:r.trimNonDigitsEnd||r.disableDialCodeAndPrefix&&c.length===0}),r.disableDialCodeAndPrefix&&(l=""),o("".concat(l).concat(c))};var T=function(e){var r=e.phoneBeforeInput,t=e.phoneAfterInput,n=e.phoneAfterFormatted,a=e.cursorPositionAfterInput,o=e.leftOffset,i=o===void 0?0:o,u=e.deletion;if(a<i)return i;if(!r)return n.length;var l=null;for(var c=a-1;c>=0;c-=1)if(L(t[c])){l=c;break}if(l===null){for(var d=0;d<t.length;d+=1)if(L(n[d]))return d;return t.length}var s=0;for(var f=0;f<l;f+=1)L(t[f])&&(s+=1);var v=0,p=0;for(var y=0;y<n.length&&(v+=1,L(n[y])&&(p+=1),!(p>=s+1));y+=1);if(u!=="backward")for(;!L(n[v])&&v<n.length;)v+=1;return v};var q=function(e){var r=e.phone,t=e.prefix;return r?"".concat(t).concat(F(r)):""};function K(e){var r=e.value,t=e.country,n=e.insertDialCodeOnEmpty,a=e.trimNonDigitsEnd,o=e.countries,i=e.prefix,u=e.charAfterDialCode,l=e.forceDialCode,c=e.disableDialCodeAndPrefix,d=e.defaultMask,s=e.countryGuessingEnabled,f=e.disableFormatting;var v,p,y;var m=r;c&&(m=m.startsWith("".concat(i))?m:"".concat(i).concat(t.dialCode).concat(m));var h;var C=s?ei({phone:m,countries:o,currentCountryIso2:(v=t)===null||v===void 0?void 0:v.iso2}):void 0,b=(h=(p=C)===null||p===void 0?void 0:p.country)!==null&&h!==void 0?h:t,g=G(m,{prefix:i,mask:et({phone:m,country:b,defaultMask:d,disableFormatting:f}),maskChar:X,dialCode:b.dialCode,trimNonDigitsEnd:a,charAfterDialCode:u,forceDialCode:l,insertDialCodeOnEmpty:n,disableDialCodeAndPrefix:c}),w=s&&!((y=C)===null||y===void 0?void 0:y.fullDialCodeMatch)?t:b;return{phone:q({phone:c?"".concat(w.dialCode).concat(g):g,prefix:i}),inputValue:g,country:w}}var W=function(e){var r,t;var n;if((n=(r=e)===null||r===void 0?void 0:r.toLocaleLowerCase().includes("delete"))!==null&&n!==void 0?n:!1)return((t=e)===null||t===void 0?void 0:t.toLocaleLowerCase().includes("forward"))?"forward":"backward"},U=function(e,r){var t=r.country,n=r.insertDialCodeOnEmpty,a=r.phoneBeforeInput,o=r.prefix,i=r.charAfterDialCode,u=r.forceDialCode,l=r.disableDialCodeAndPrefix,c=r.countryGuessingEnabled,d=r.defaultMask,s=r.disableFormatting,f=r.countries;var v,p,y,m;var h;var C=e.nativeEvent,b=C.inputType,g=W(b),w=!!((v=b)===null||v===void 0?void 0:v.startsWith("insertFrom")),D=b==="insertText",P=((p=C)===null||p===void 0?void 0:p.data)||void 0,S=e.target.value,x=(h=e.target.selectionStart)!==null&&h!==void 0?h:0;if((y=b)===null||y===void 0?void 0:y.includes("history"))return{inputValue:a,phone:q({phone:a,prefix:o}),cursorPosition:a.length,country:t};var k;if(D&&!L(P)&&S!==o)return{inputValue:a,phone:q({phone:l?"".concat(t.dialCode).concat(a):a,prefix:o}),cursorPosition:x-((k=(m=P)===null||m===void 0?void 0:m.length)!==null&&k!==void 0?k:0),country:t};if(u&&!S.startsWith("".concat(o).concat(t.dialCode))&&!w){var N=S?a:"".concat(o).concat(t.dialCode).concat(i);return{inputValue:N,phone:q({phone:N,prefix:o}),cursorPosition:o.length+t.dialCode.length+i.length,country:t}}var A=K({value:S,country:t,trimNonDigitsEnd:g==="backward",insertDialCodeOnEmpty:n,countryGuessingEnabled:c,countries:f,prefix:o,charAfterDialCode:i,forceDialCode:u,disableDialCodeAndPrefix:l,disableFormatting:s,defaultMask:d}),E=A.phone,O=A.inputValue,M=A.country,j=T({cursorPositionAfterInput:x,phoneBeforeInput:a,phoneAfterInput:S,phoneAfterFormatted:O,leftOffset:u?o.length+t.dialCode.length+i.length:0,deletion:g});return{phone:E,inputValue:O,cursorPosition:j,country:M}};var H=require("react");var J=function(e,r){var t=Object.keys(e),n=Object.keys(r);if(t.length!==n.length)return!1;var a=true,o=false,i=undefined;try{for(var u=t[Symbol.iterator](),l;!(a=(l=u.next()).done);a=true){var c=l.value;if(e[c]!==r[c])return!1}}catch(e){o=true;i=e}finally{try{if(!a&&u.return!=null){u.return()}}finally{if(o){throw i}}}return!0};var Z=require("react"),$=function(){var e=(0,Z.useRef)(),r=(0,Z.useRef)(Date.now());return{check:function(){var t=Date.now(),n=e.current?t-r.current:void 0;return e.current=r.current,r.current=t,n}}};var Q={size:20,overrideLastItemDebounceMS:-1};function Y(e,r){var t=l({},Q,r),n=t.size,a=t.overrideLastItemDebounceMS,o=t.onChange,i=v((0,H.useState)(e),2),u=i[0],c=i[1],d=v((0,H.useState)([u]),2),s=d[0],f=d[1],y=v((0,H.useState)(0),2),m=y[0],h=y[1],C=$();return[u,function(e,r){var t,i;if(typeof e=="object"&&typeof u=="object"&&J(e,u)||e===u)return;var l=a>0,d=C.check(),v=l&&d!==void 0?d>a:!0;if(((t=r)===null||t===void 0?void 0:t.overrideLastItem)!==void 0?r.overrideLastItem:!v)f(function(r){return p(r.slice(0,m)).concat([e])});else{var y=s.length>=n;f(function(r){return p(r.slice(y?1:0,m+1)).concat([e])}),y||h(function(e){return e+1})}c(e),(i=o)===null||i===void 0?void 0:i(e)},function(){var e;if(m<=0)return{success:!1};var r=s[m-1];return c(r),h(function(e){return e-1}),(e=o)===null||e===void 0?void 0:e(r),{success:!0,value:r}},function(){var e;if(m+1>=s.length)return{success:!1};var r=s[m+1];return c(r),h(function(e){return e+1}),(e=o)===null||e===void 0?void 0:e(r),{success:!0,value:r}}]}var X=".",ee={defaultCountry:"us",value:"",prefix:"+",defaultMask:"............",charAfterDialCode:" ",historySaveDebounceMS:200,disableCountryGuess:!1,disableDialCodePrefill:!1,forceDialCode:!1,disableDialCodeAndPrefix:!1,disableFormatting:!1,countries:E,preferredCountries:[]},er=function(e){var r=e.defaultCountry,t=r===void 0?ee.defaultCountry:r,n=e.value,a=n===void 0?ee.value:n,o=e.countries,i=o===void 0?ee.countries:o,u=e.prefix,c=u===void 0?ee.prefix:u,d=e.defaultMask,s=d===void 0?ee.defaultMask:d,f=e.charAfterDialCode,p=f===void 0?ee.charAfterDialCode:f,m=e.historySaveDebounceMS,h=m===void 0?ee.historySaveDebounceMS:m,C=e.disableCountryGuess,b=C===void 0?ee.disableCountryGuess:C,g=e.disableDialCodePrefill,w=g===void 0?ee.disableDialCodePrefill:g,D=e.forceDialCode,P=D===void 0?ee.forceDialCode:D,S=e.disableDialCodeAndPrefix,x=S===void 0?ee.disableDialCodeAndPrefix:S,k=e.disableFormatting,N=k===void 0?ee.disableFormatting:k,A=e.onChange,E=e.inputRef;var O={countries:i,prefix:c,charAfterDialCode:p,forceDialCode:x?!1:P,disableDialCodeAndPrefix:x,defaultMask:s,countryGuessingEnabled:!b,disableFormatting:N},M=(0,V.useRef)(null),j=E||M,I=function(e){Promise.resolve().then(function(){var r,t;(typeof window==="undefined"?"undefined":y(window))>"u"||j.current!==((r=document)===null||r===void 0?void 0:r.activeElement)||((t=j.current)===null||t===void 0?void 0:t.setSelectionRange(e,e))})},_=v(Y(function(){var e=eo({value:t,field:"iso2",countries:i});e||console.error('[react-international-phone]: can not find a country with "'.concat(t,'" iso2 code'));var r=e||eo({value:"us",field:"iso2",countries:i}),n=K(l({value:a,country:r,insertDialCodeOnEmpty:!w},O)),o=n.phone,u=n.inputValue,c=n.country;return I(u.length),{phone:o,inputValue:u,country:c.iso2}},{overrideLastItemDebounceMS:h,onChange:function(e){var r=e.inputValue,t=e.phone,n=e.country;if(!A)return;var a=q(n);A({phone:t,inputValue:r,country:a})}}),4),L=_[0],F=L.phone,z=L.inputValue,B=L.country,R=_[1],G=_[2],T=_[3],q=(0,V.useCallback)(function(e){return eo({value:e,field:"iso2",countries:i})},[i]),W=(0,V.useMemo)(function(){return q(B)},[B,q]);(0,V.useEffect)(function(){var e=j.current;if(!e)return;var r=function(e){if(!e.key)return;var r=e.ctrlKey,t=e.shiftKey,n=e.key.toLowerCase()==="z";!r||!n||(t?T():G())};return e.addEventListener("keydown",r),function(){e.removeEventListener("keydown",r)}},[j,G,T]);var H=function(e){e.preventDefault();var r=U(e,l({country:W,phoneBeforeInput:z,insertDialCodeOnEmpty:!1},O)),t=r.phone,n=r.inputValue,o=r.country,i=r.cursorPosition;return R({inputValue:n,phone:t,country:o.iso2}),I(i),a},J=function(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{focusOnInput:!1};var t=eo({value:e,field:"iso2",countries:i});if(!t){console.error('[react-international-phone]: can not find a country with "'.concat(e,'" iso2 code'));return}var n=x?"":"".concat(c).concat(t.dialCode).concat(p);R({inputValue:n,phone:"".concat(c).concat(t.dialCode),country:t.iso2}),r.focusOnInput&&Promise.resolve().then(function(){var e;(e=j.current)===null||e===void 0?void 0:e.focus()})},Z=v((0,V.useState)(!1),2),$=Z[0],Q=Z[1];return(0,V.useEffect)(function(){if(!$){var e;Q(!0),a!==F&&((e=A)===null||e===void 0?void 0:e({inputValue:z,phone:F,country:W}));return}if(a===F)return;var r=K(l({value:a,country:W,insertDialCodeOnEmpty:!w},O)),t=r.phone,n=r.inputValue,o=r.country;R({phone:t,inputValue:n,country:o.iso2})},[a]),{phone:F,inputValue:z,country:W,setCountry:J,handlePhoneValueChange:H,inputRef:j}};var et=function(e){var r=e.phone,t=e.country,n=e.defaultMask,a=n===void 0?"............":n,o=e.disableFormatting,i=o===void 0?!1:o;var u=t.format,l=function(e){return i?e.replace(new RegExp("[^".concat(X,"]"),"g"),""):e};if(!u)return l(a);if(typeof u=="string")return l(u);if(!u.default)return console.error("[react-international-phone]: default mask for ".concat(t.iso2," is not provided")),l(a);var c=Object.keys(u).find(function(e){if(e==="default")return!1;if(!(e.charAt(0)==="/"&&e.charAt(e.length-1)==="/"))return console.error('[react-international-phone]: format regex "'.concat(e,'" for ').concat(t.iso2," is not valid")),!1;var n=new RegExp(e.substring(1,e.length-1)),a=r.replace(t.dialCode,"");return n.test(F(a))});return l(c?u[c]:u.default)};var en=function(e){var r=v(e,6),t=r[0],n=r[1],a=r[2],o=r[3],i=r[4],u=r[5];return{name:t,iso2:n,dialCode:a,format:o,priority:i,areaCodes:u}};var ea=function(e){return'Field "'.concat(e,'" is not supported')},eo=function(e){var r=e.field,t=e.value,n=e.countries,a=n===void 0?E:n;if(["priority"].includes(r))throw new Error(ea(r));var o=a.find(function(e){var n=en(e);return t===n[r]});if(o)return en(o)};var ei=function(e){var r=e.phone,t=e.countries,n=t===void 0?E:t,a=e.currentCountryIso2;var o={country:void 0,fullDialCodeMatch:!1};if(!r)return o;var i=F(r);if(!i)return o;var u=o,l=function(e){var r=e.country,t=e.fullDialCodeMatch;var n,a;var o,i;var l=r.dialCode===((n=u.country)===null||n===void 0?void 0:n.dialCode),c=((o=r.priority)!==null&&o!==void 0?o:0)<((i=(a=u.country)===null||a===void 0?void 0:a.priority)!==null&&i!==void 0?i:0);(!l||c)&&(u={country:r,fullDialCodeMatch:t})};var c=true,d=false,s=undefined;try{for(var f=n[Symbol.iterator](),v;!(c=(v=f.next()).done);c=true){var p=v.value;var y=en(p),m=y.dialCode,h=y.areaCodes;if(i.startsWith(m)){var C=u.country?Number(m)>=Number(u.country.dialCode):!0;if(h){var b=i.substring(m.length);var g=true,w=false,D=undefined;try{for(var P=h[Symbol.iterator](),S;!(g=(S=P.next()).done);g=true){var x=S.value;if(b.startsWith(x))return{country:y,fullDialCodeMatch:!0}}}catch(e){w=true;D=e}finally{try{if(!g&&P.return!=null){P.return()}}finally{if(w){throw D}}}}(C||m===i||!u.fullDialCodeMatch)&&l({country:y,fullDialCodeMatch:!0})}u.fullDialCodeMatch||i.length<m.length&&m.startsWith(i)&&(!u.country||Number(m)<=Number(u.country.dialCode))&&l({country:y,fullDialCodeMatch:!1})}}catch(e){d=true;s=e}finally{try{if(!c&&f.return!=null){f.return()}}finally{if(d){throw s}}}if(a){var k;var N=eo({value:a,field:"iso2",countries:n});if(!N)return u;var A=N?function(e){var r;if(!((r=e)===null||r===void 0?void 0:r.areaCodes))return!1;var t=i.substring(e.dialCode.length);return e.areaCodes.some(function(e){return e.startsWith(t)})}(N):!1;!!u&&((k=u.country)===null||k===void 0?void 0:k.dialCode)===N.dialCode&&u.country!==N&&u.fullDialCodeMatch&&(!N.areaCodes||A)&&(u={country:N,fullDialCodeMatch:!0})}return u};var eu=x(require("react"));var el=function(e,r){var t=parseInt(e,16);return Number(t+r).toString(16)},ec="abcdefghijklmnopqrstuvwxyz",ed="1f1e6",es=ec.split("").reduce(function(e,r,t){return d(l({},e),n({},r,el(ed,t)))},{}),ef=function(e){return[es[e[0]],es[e[1]]].join("-")},ev=function(e){var r=e.iso2,t=e.size,n=e.src,a=e.protocol,o=a===void 0?"https":a,i=e.disableLazyLoading,u=e.className,c=e.style,d=s(e,["iso2","size","src","protocol","disableLazyLoading","className","style"]);if(!r)return eu.default.createElement("img",l({className:I({addPrefix:["flag-emoji"],rawClassNames:[u]}),width:t,height:t},d));var f=function(){if(n)return n;var e=ef(r);return"".concat(o,"://cdnjs.cloudflare.com/ajax/libs/twemoji/14.0.2/svg/").concat(e,".svg")};return eu.default.createElement("img",l({className:I({addPrefix:["flag-emoji"],rawClassNames:[u]}),src:f(),width:t,height:t,draggable:!1,"data-country":r,loading:i?void 0:"lazy",style:l({width:t,height:t},c),alt:""},d))};var ep=x(require("react"));var ey=1e3,em=function(e){var r=e.show,t=e.dialCodePrefix,n=t===void 0?"+":t,a=e.selectedCountry,o=e.countries,i=o===void 0?E:o,u=e.preferredCountries,c=u===void 0?[]:u,d=e.flags,f=e.onSelect,y=e.onClose,m=s(e,["show","dialCodePrefix","selectedCountry","countries","preferredCountries","flags","onSelect","onClose"]);var h=(0,ep.useRef)(null),C=(0,ep.useRef)(),b=(0,ep.useMemo)(function(){if(!c||!c.length)return i;var e=[],r=p(i);var t=true,n=false,a=undefined;try{var o=function(){var t=l.value;var n=r.findIndex(function(e){return en(e).iso2===t});if(n!==-1){var a=r.splice(n,1)[0];e.push(a)}};for(var u=c[Symbol.iterator](),l;!(t=(l=u.next()).done);t=true)o()}catch(e){n=true;a=e}finally{try{if(!t&&u.return!=null){u.return()}}finally{if(n){throw a}}}return e.concat(r)},[i,c]),g=(0,ep.useRef)({updatedAt:void 0,value:""}),w=function(e){var r=g.current.updatedAt&&new Date().getTime()-g.current.updatedAt.getTime()>ey;g.current={value:r?e:"".concat(g.current.value).concat(e),updatedAt:new Date};var t=b.findIndex(function(e){return en(e).name.toLowerCase().startsWith(g.current.value)});t!==-1&&x(t)},D=(0,ep.useCallback)(function(e){return b.findIndex(function(r){return en(r).iso2===e})},[b]),P=v((0,ep.useState)(D(a)),2),S=P[0],x=P[1],k=function(){C.current!==a&&x(D(a))},N=(0,ep.useCallback)(function(e){var r;x(D(e.iso2)),(r=f)===null||r===void 0?void 0:r(e)},[f,D]),A=function(e){var r=b.length-1,t=function(t){return e==="prev"?t-1:e==="next"?t+1:e==="last"?r:0};x(function(e){var n=t(e);return n<0?0:n>r?r:n})},O=function(e){if(e.stopPropagation(),e.key==="Enter"){e.preventDefault();var r=en(b[S]);N(r);return}if(e.key==="Escape"){var t;(t=y)===null||t===void 0?void 0:t();return}if(e.key==="ArrowUp"){e.preventDefault(),A("prev");return}if(e.key==="ArrowDown"){e.preventDefault(),A("next");return}if(e.key==="PageUp"){e.preventDefault(),A("first");return}if(e.key==="PageDown"){e.preventDefault(),A("last");return}e.key===" "&&e.preventDefault(),e.key.length===1&&!e.altKey&&!e.ctrlKey&&!e.metaKey&&w(e.key.toLocaleLowerCase())},M=(0,ep.useCallback)(function(){if(!h.current||S===void 0)return;var e=en(b[S]).iso2;if(e===C.current)return;var r=h.current.querySelector('[data-country="'.concat(e,'"]'));r&&(z(h.current,r),C.current=e)},[S,b]);return(0,ep.useEffect)(function(){M()},[S,M]),(0,ep.useEffect)(function(){h.current&&(r?h.current.focus():k())},[r]),(0,ep.useEffect)(function(){k()},[a]),ep.default.createElement("ul",{ref:h,role:"listbox",className:I({addPrefix:["country-selector-dropdown"],rawClassNames:[m.className]}),style:l({display:r?"block":"none"},m.style),onKeyDown:O,onBlur:y,tabIndex:-1,"aria-activedescendant":"react-international-phone__".concat(en(b[S]).iso2,"-option")},b.map(function(e,r){var t,o;var i=en(e),u=i.iso2===a,l=r===S,s=c.includes(i.iso2),f=r===c.length-1,v=(t=d)===null||t===void 0?void 0:t.find(function(e){return e.iso2===i.iso2});return ep.default.createElement(ep.default.Fragment,{key:i.iso2},ep.default.createElement("li",{"data-country":i.iso2,role:"option","aria-selected":u,"aria-label":"".concat(i.name," ").concat(n).concat(i.dialCode),id:"react-international-phone__".concat(i.iso2,"-option"),className:I({addPrefix:["country-selector-dropdown__list-item",s&&"country-selector-dropdown__list-item--preferred",u&&"country-selector-dropdown__list-item--selected",l&&"country-selector-dropdown__list-item--focused"],rawClassNames:[m.listItemClassName]}),onClick:function(){return N(i)},style:m.listItemStyle,title:i.name},ep.default.createElement(ev,{iso2:i.iso2,src:(o=v)===null||o===void 0?void 0:o.src,className:I({addPrefix:["country-selector-dropdown__list-item-flag-emoji"],rawClassNames:[m.listItemFlagClassName]}),style:m.listItemFlagStyle}),ep.default.createElement("span",{className:I({addPrefix:["country-selector-dropdown__list-item-country-name"],rawClassNames:[m.listItemCountryNameClassName]}),style:m.listItemCountryNameStyle},i.name),ep.default.createElement("span",{className:I({addPrefix:["country-selector-dropdown__list-item-dial-code"],rawClassNames:[m.listItemDialCodeClassName]}),style:m.listItemDialCodeStyle},n,i.dialCode)),f?ep.default.createElement("hr",{className:I({addPrefix:["country-selector-dropdown__preferred-list-divider"],rawClassNames:[m.preferredListDividerClassName]}),style:m.preferredListDividerStyle}):null)}))};var eh=function(e){var r=e.selectedCountry,t=e.onSelect,n=e.disabled,a=e.hideDropdown,o=e.countries,i=o===void 0?E:o,u=e.preferredCountries,c=u===void 0?[]:u,f=e.flags,p=e.renderButtonWrapper,y=s(e,["selectedCountry","onSelect","disabled","hideDropdown","countries","preferredCountries","flags","renderButtonWrapper"]);var m=v((0,A.useState)(!1),2),h=m[0],C=m[1],b=(0,A.useMemo)(function(){if(r)return eo({value:r,field:"iso2",countries:i})},[i,r]),g=(0,A.useRef)(null),w=function(e){e.key&&["ArrowUp","ArrowDown"].includes(e.key)&&(e.preventDefault(),C(!0))},D=function(){var e,t,o;var i={title:(e=b)===null||e===void 0?void 0:e.name,onClick:function(){return C(function(e){return!e})},onMouseDown:function(e){return e.preventDefault()},onKeyDown:w,disabled:a||n,role:"combobox","aria-label":"Country selector","aria-haspopup":"listbox","aria-expanded":h},u=A.default.createElement("div",{className:I({addPrefix:["country-selector-button__button-content"],rawClassNames:[y.buttonContentWrapperClassName]}),style:y.buttonContentWrapperStyle},A.default.createElement(ev,{iso2:r,src:(o=f)===null||o===void 0?void 0:(t=o.find(function(e){return e.iso2===r}))===null||t===void 0?void 0:t.src,className:I({addPrefix:["country-selector-button__flag-emoji",n&&"country-selector-button__flag-emoji--disabled"],rawClassNames:[y.flagClassName]}),style:l({visibility:r?"visible":"hidden"},y.flagStyle)}),!a&&A.default.createElement("div",{className:I({addPrefix:["country-selector-button__dropdown-arrow",n&&"country-selector-button__dropdown-arrow--disabled",h&&"country-selector-button__dropdown-arrow--active"],rawClassNames:[y.dropdownArrowClassName]}),style:y.dropdownArrowStyle}));return p?p({children:u,rootProps:i}):A.default.createElement("button",d(l({},i),{type:"button",className:I({addPrefix:["country-selector-button",h&&"country-selector-button--active",n&&"country-selector-button--disabled",a&&"country-selector-button--hide-dropdown"],rawClassNames:[y.buttonClassName]}),"data-country":r,style:y.buttonStyle}),u)};return A.default.createElement("div",{className:I({addPrefix:["country-selector"],rawClassNames:[y.className]}),style:y.style,ref:g},D(),A.default.createElement(em,l({show:h,countries:i,preferredCountries:c,flags:f,onSelect:function(e){var r;C(!1),(r=t)===null||r===void 0?void 0:r(e)},selectedCountry:r,onClose:function(){C(!1)}},y.dropdownStyleProps)))};var eC=x(require("react"));var eb=function(e){var r=e.dialCode,t=e.prefix,n=e.disabled,a=e.style,o=e.className;return eC.default.createElement("div",{className:I({addPrefix:["dial-code-preview",n&&"dial-code-preview--disabled"],rawClassNames:[o]}),style:a},"".concat(t).concat(r))};var eg=x(require("react"));var ew=(0,eg.forwardRef)(function(e,r){var t=e.value,n=e.onChange,a=e.countries,o=a===void 0?E:a,i=e.preferredCountries,u=i===void 0?[]:i,c=e.hideDropdown,f=e.showDisabledDialCodeAndPrefix,v=e.disableFocusAfterCountrySelect,p=e.flags,y=e.style,m=e.className,h=e.inputStyle,C=e.inputClassName,b=e.countrySelectorStyleProps,g=e.dialCodePreviewStyleProps,w=e.inputProps,D=e.placeholder,P=e.disabled,S=e.name,x=e.onFocus,k=e.onBlur,N=e.required,A=e.autoFocus,O=s(e,["value","onChange","countries","preferredCountries","hideDropdown","showDisabledDialCodeAndPrefix","disableFocusAfterCountrySelect","flags","style","className","inputStyle","inputClassName","countrySelectorStyleProps","dialCodePreviewStyleProps","inputProps","placeholder","disabled","name","onFocus","onBlur","required","autoFocus"]);var M;var j=er(d(l({value:t,countries:o},O),{onChange:function(e){var r;(r=n)===null||r===void 0?void 0:r(e.phone,{country:e.country,inputValue:e.inputValue})}})),_=j.phone,L=j.inputValue,F=j.inputRef,z=j.country,B=j.setCountry,V=j.handlePhoneValueChange,R=O.disableDialCodeAndPrefix&&f&&((M=z)===null||M===void 0?void 0:M.dialCode);var G;return(0,eg.useImperativeHandle)(r,function(){return F.current?Object.assign(F.current,{setCountry:B,state:{phone:_,inputValue:L,country:z}}):null},[F,B,_,L,z]),eg.default.createElement("div",{ref:r,className:I({addPrefix:["input-container"],rawClassNames:[m]}),style:y},eg.default.createElement(eh,l({onSelect:function(e){return B(e.iso2,{focusOnInput:!v})},flags:p,selectedCountry:z.iso2,countries:o,preferredCountries:u,disabled:P,hideDropdown:c},b)),R&&eg.default.createElement(eb,l({dialCode:z.dialCode,prefix:(G=O.prefix)!==null&&G!==void 0?G:"+",disabled:P},g)),eg.default.createElement("input",l({onChange:V,value:L,type:"tel",ref:F,className:I({addPrefix:["input",P&&"input--disabled"],rawClassNames:[C]}),placeholder:D,disabled:P,style:h,name:S,onFocus:x,onBlur:k,autoFocus:A,required:N},w)))});0&&(module.exports={CountrySelector:CountrySelector,CountrySelectorDropdown:CountrySelectorDropdown,DialCodePreview:DialCodePreview,FlagImage:FlagImage,PhoneInput:PhoneInput,buildCountryData:buildCountryData,defaultCountries:defaultCountries,getActiveFormattingMask:getActiveFormattingMask,getCountry:getCountry,guessCountryByPartialPhoneNumber:guessCountryByPartialPhoneNumber,parseCountry:parseCountry,removeDialCode:removeDialCode,usePhoneInput:usePhoneInput});
{
"name": "react-international-phone",
"version": "4.2.6",
"version": "4.2.7",
"description": "☎️ International phone input component for React",

@@ -5,0 +5,0 @@ "keywords": [

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc