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.0.4 to 4.1.0

11

build/components/PhoneInput/PhoneInput.d.ts
import './PhoneInput.style.scss';
import React from 'react';
import { UsePhoneInputConfig } from '../../hooks/usePhoneInput';
import { CountryIso2, ParsedCountry } from '../../types';
import { usePhoneInput, UsePhoneInputConfig } from '../../hooks/usePhoneInput';
import { ParsedCountry } from '../../types';
import { CountrySelectorProps, CountrySelectorStyleProps } from '../CountrySelector/CountrySelector';

@@ -30,2 +30,7 @@ import { DialCodePreviewStyleProps } from '../DialCodePreview/DialCodePreview';

/**
* @description Disable auto focus on input field after country select.
* @default false
*/
disableFocusAfterCountrySelect?: boolean;
/**
* @description Custom flag URLs array

@@ -61,3 +66,3 @@ * @default undefined

export type PhoneInputRefType = null | (HTMLInputElement & {
setCountry: (iso2: CountryIso2) => void;
setCountry: ReturnType<typeof usePhoneInput>['setCountry'];
state: {

@@ -64,0 +69,0 @@ phone: string;

@@ -96,5 +96,7 @@ /// <reference types="react" />

country: ParsedCountry;
setCountry: (countryIso2: CountryIso2) => void;
setCountry: (countryIso2: CountryIso2, options?: {
focusOnInput: boolean;
}) => void;
handlePhoneValueChange: (e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => string;
inputRef: import("react").MutableRefObject<HTMLInputElement | null>;
};

@@ -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 y(e){return t(e)||a(e)||m(e)||u()}function p(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 b=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var w=Object.getPrototypeOf,D=Object.prototype.hasOwnProperty;var P=function(e,r){for(var t in r)b(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&&b(e,a,{get:function(){return r[a]},enumerable:!(n=C(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?b(t,"default",{value:e,enumerable:!0}):t,e)},k=function(e){return S(b({},"__esModule",{value:!0}),e)};var N={};P(N,{CountrySelector:function(){return eh},CountrySelectorDropdown:function(){return em},DialCodePreview:function(){return eC},FlagImage:function(){return ev},PhoneInput:function(){return ew},buildCountryData:function(){return F},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 M="react-international-phone-",O=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 O.apply(void 0,y(r)).split(" ").map(function(e){return"".concat(M).concat(e)}).join(" ")},I=function(e){var r=e.addPrefix,t=e.rawClassNames;return O.apply(void 0,[j.apply(void 0,y(r))].concat(y(t)))};var L=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,y=undefined;try{for(var p=t.split("")[Symbol.iterator](),m;!(f=(m=p.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;y=e}finally{try{if(!f&&p.return!=null){p.return()}}finally{if(v){throw y}}}return d};var _=function(e){return e?/^\d+$/.test(e):!1};var z=function(e){return e.replace(/\D/g,"")};var B=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 F=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=z(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=L({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(_(t[c])){l=c;break}if(l===null){for(var d=0;d<t.length;d+=1)if(_(n[d]))return d;return t.length}var s=0;for(var f=0;f<l;f+=1)_(t[f])&&(s+=1);var v=0,y=0;for(var p=0;p<n.length&&(v+=1,_(n[p])&&(y+=1),!(y>=s+1));p+=1);if(u!=="backward")for(;!_(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(z(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,y,p;var m=r;c&&(m=m.startsWith("".concat(i))?m:"".concat(i).concat(t.dialCode).concat(m));var h;var b=s?ei({phone:m,countries:o,currentCountryIso2:(v=t)===null||v===void 0?void 0:v.iso2}):void 0,C=(h=(y=b)===null||y===void 0?void 0:y.country)!==null&&h!==void 0?h:t,g=G(m,{prefix:i,mask:et({phone:m,country:C,defaultMask:d,disableFormatting:f}),maskChar:X,dialCode:C.dialCode,trimNonDigitsEnd:a,charAfterDialCode:u,forceDialCode:l,insertDialCodeOnEmpty:n,disableDialCodeAndPrefix:c}),w=s&&!((p=b)===null||p===void 0?void 0:p.fullDialCodeMatch)?t:C;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,y,p,m;var h;var b=e.nativeEvent,C=b.inputType,g=W(C),w=!!((v=C)===null||v===void 0?void 0:v.startsWith("insertFrom")),D=C==="insertText",P=((y=b)===null||y===void 0?void 0:y.data)||void 0,S=e.target.value,x=(h=e.target.selectionStart)!==null&&h!==void 0?h:0;if((p=C)===null||p===void 0?void 0:p.includes("history"))return{inputValue:a,phone:q({phone:a,prefix:o}),cursorPosition:a.length,country:t};var k;if(D&&!_(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,M=A.inputValue,O=A.country,j=T({cursorPositionAfterInput:x,phoneBeforeInput:a,phoneAfterInput:S,phoneAfterFormatted:M,leftOffset:u?o.length+t.dialCode.length+i.length:0,deletion:g});return{phone:E,inputValue:M,cursorPosition:j,country:O}};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],p=v((0,H.useState)(0),2),m=p[0],h=p[1],b=$();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=b.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 y(r.slice(0,m)).concat([e])});else{var p=s.length>=n;f(function(r){return y(r.slice(p?1:0,m+1)).concat([e])}),p||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},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,y=f===void 0?ee.charAfterDialCode:f,m=e.historySaveDebounceMS,h=m===void 0?ee.historySaveDebounceMS:m,b=e.disableCountryGuess,C=b===void 0?ee.disableCountryGuess:b,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 M={countries:i,prefix:c,charAfterDialCode:y,forceDialCode:x?!1:P,disableDialCodeAndPrefix:x,defaultMask:s,countryGuessingEnabled:!C,disableFormatting:N},O=(0,V.useRef)(null),j=E||O,I=function(e){Promise.resolve().then(function(){var r,t;(typeof window==="undefined"?"undefined":p(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))})},L=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},M)),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],z=_.phone,B=_.inputValue,F=_.country,R=L[1],G=L[2],T=L[3],q=(0,V.useCallback)(function(e){return eo({value:e,field:"iso2",countries:i})},[i]),W=(0,V.useMemo)(function(){return q(F)},[F,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:B,insertDialCodeOnEmpty:!1},M)),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=eo({value:e,field:"iso2",countries:i});if(!r){console.error('[react-international-phone]: can not find a country with "'.concat(e,'" iso2 code'));return}var t=x?"":"".concat(c).concat(r.dialCode).concat(y);R({inputValue:t,phone:"".concat(c).concat(r.dialCode),country:r.iso2}),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!==z&&((e=A)===null||e===void 0?void 0:e({inputValue:B,phone:z,country:W}));return}if(a===z)return;var r=K(l({value:a,country:W,insertDialCodeOnEmpty:!w},M)),t=r.phone,n=r.inputValue,o=r.country;R({phone:t,inputValue:n,country:o.iso2})},[a]),{phone:z,inputValue:B,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(z(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=z(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 y=v.value;var p=en(y),m=p.dialCode,h=p.areaCodes;if(i.startsWith(m)){var b=u.country?Number(m)>=Number(u.country.dialCode):!0;if(h){var C=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(C.startsWith(x))return{country:p,fullDialCodeMatch:!0}}}catch(e){w=true;D=e}finally{try{if(!g&&P.return!=null){P.return()}}finally{if(w){throw D}}}}(b||m===i||!u.fullDialCodeMatch)&&l({country:p,fullDialCodeMatch:!0})}u.fullDialCodeMatch||i.length<m.length&&m.startsWith(i)&&(!u.country||Number(m)<=Number(u.country.dialCode))&&l({country:p,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 ey=x(require("react"));var ep=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.flags,c=e.onSelect,d=e.onClose,f=s(e,["show","dialCodePrefix","selectedCountry","countries","flags","onSelect","onClose"]);var y=(0,ey.useRef)(null),p=(0,ey.useRef)(),m=(0,ey.useRef)({updatedAt:void 0,value:""}),h=function(e){var r=m.current.updatedAt&&new Date().getTime()-m.current.updatedAt.getTime()>ep;m.current={value:r?e:"".concat(m.current.value).concat(e),updatedAt:new Date};var t=i.findIndex(function(e){return en(e).name.toLowerCase().startsWith(m.current.value)});t!==-1&&w(t)},b=(0,ey.useCallback)(function(e){return i.findIndex(function(r){return en(r).iso2===e})},[i]),C=v((0,ey.useState)(b(a)),2),g=C[0],w=C[1],D=function(){p.current!==a&&w(b(a))},P=(0,ey.useCallback)(function(e){var r;w(b(e.iso2)),(r=c)===null||r===void 0?void 0:r(e)},[c,b]),S=function(e){var r=i.length-1,t=function(t){return e==="prev"?t-1:e==="next"?t+1:e==="last"?r:0};w(function(e){var n=t(e);return n<0?0:n>r?r:n})},x=function(e){if(e.stopPropagation(),e.key==="Enter"){e.preventDefault();var r=en(i[g]);P(r);return}if(e.key==="Escape"){var t;(t=d)===null||t===void 0?void 0:t();return}if(e.key==="ArrowUp"){e.preventDefault(),S("prev");return}if(e.key==="ArrowDown"){e.preventDefault(),S("next");return}if(e.key==="PageUp"){e.preventDefault(),S("first");return}if(e.key==="PageDown"){e.preventDefault(),S("last");return}e.key===" "&&e.preventDefault(),e.key.length===1&&!e.altKey&&!e.ctrlKey&&!e.metaKey&&h(e.key.toLocaleLowerCase())},k=(0,ey.useCallback)(function(){if(!y.current||g===void 0)return;var e=en(i[g]).iso2;if(e===p.current)return;var r=y.current.querySelector('[data-country="'.concat(e,'"]'));r&&(B(y.current,r),p.current=e)},[g,i]);return(0,ey.useEffect)(function(){k()},[g,k]),(0,ey.useEffect)(function(){y.current&&(r?y.current.focus():D())},[r]),(0,ey.useEffect)(function(){D()},[a]),ey.default.createElement("ul",{ref:y,role:"listbox",className:I({addPrefix:["country-selector-dropdown"],rawClassNames:[f.className]}),style:l({display:r?"block":"none"},f.style),onKeyDown:x,onBlur:d,tabIndex:-1,"aria-activedescendant":"react-international-phone__".concat(en(i[g]).iso2,"-option")},i.map(function(e,r){var t,o;var i=en(e),l=i.iso2===a,c=r===g,d=(t=u)===null||t===void 0?void 0:t.find(function(e){return e.iso2===i.iso2});return ey.default.createElement("li",{key:i.iso2,"data-country":i.iso2,role:"option","aria-selected":l,"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",l&&"country-selector-dropdown__list-item--selected",c&&"country-selector-dropdown__list-item--focused"],rawClassNames:[f.listItemClassName]}),onClick:function(){return P(i)},style:f.listItemStyle,title:i.name},ey.default.createElement(ev,{iso2:i.iso2,src:(o=d)===null||o===void 0?void 0:o.src,className:I({addPrefix:["country-selector-dropdown__list-item-flag-emoji"],rawClassNames:[f.listItemFlagClassName]}),style:f.listItemFlagStyle}),ey.default.createElement("span",{className:I({addPrefix:["country-selector-dropdown__list-item-country-name"],rawClassNames:[f.listItemCountryNameClassName]}),style:f.listItemCountryNameStyle},i.name),ey.default.createElement("span",{className:I({addPrefix:["country-selector-dropdown__list-item-dial-code"],rawClassNames:[f.listItemDialCodeClassName]}),style:f.listItemDialCodeStyle},n,i.dialCode))}))};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.flags,c=e.renderButtonWrapper,f=s(e,["selectedCountry","onSelect","disabled","hideDropdown","countries","flags","renderButtonWrapper"]);var y=v((0,A.useState)(!1),2),p=y[0],m=y[1],h=(0,A.useMemo)(function(){if(r)return eo({value:r,field:"iso2",countries:i})},[i,r]),b=(0,A.useRef)(null),C=function(e){e.key&&["ArrowUp","ArrowDown"].includes(e.key)&&(e.preventDefault(),m(!0))},g=function(){var e,t,o;var i={title:(e=h)===null||e===void 0?void 0:e.name,onClick:function(){return m(function(e){return!e})},onMouseDown:function(e){return e.preventDefault()},onKeyDown:C,disabled:a||n,role:"combobox","aria-label":"Country selector","aria-haspopup":"listbox","aria-expanded":p},s=A.default.createElement("div",{className:I({addPrefix:["country-selector-button__button-content"],rawClassNames:[f.buttonContentWrapperClassName]}),style:f.buttonContentWrapperStyle},A.default.createElement(ev,{iso2:r,src:(o=u)===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:[f.flagClassName]}),style:l({visibility:r?"visible":"hidden"},f.flagStyle)}),!a&&A.default.createElement("div",{className:I({addPrefix:["country-selector-button__dropdown-arrow",n&&"country-selector-button__dropdown-arrow--disabled",p&&"country-selector-button__dropdown-arrow--active"],rawClassNames:[f.dropdownArrowClassName]}),style:f.dropdownArrowStyle}));return c?c({children:s,rootProps:i}):A.default.createElement("button",d(l({},i),{type:"button",className:I({addPrefix:["country-selector-button",p&&"country-selector-button--active",n&&"country-selector-button--disabled",a&&"country-selector-button--hide-dropdown"],rawClassNames:[f.buttonClassName]}),"data-country":r,style:f.buttonStyle}),s)};return A.default.createElement("div",{className:I({addPrefix:["country-selector"],rawClassNames:[f.className]}),style:f.style,ref:b},g(),A.default.createElement(em,l({show:p,countries:i,flags:u,onSelect:function(e){var r;m(!1),(r=t)===null||r===void 0?void 0:r(e)},selectedCountry:r,onClose:function(){m(!1)}},f.dropdownStyleProps)))};var eb=x(require("react"));var eC=function(e){var r=e.dialCode,t=e.prefix,n=e.disabled,a=e.style,o=e.className;return eb.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.hideDropdown,u=e.showDisabledDialCodeAndPrefix,c=e.flags,f=e.style,v=e.className,y=e.inputStyle,p=e.inputClassName,m=e.countrySelectorStyleProps,h=e.dialCodePreviewStyleProps,b=e.inputProps,C=e.placeholder,g=e.disabled,w=e.name,D=e.onFocus,P=e.onBlur,S=e.required,x=e.autoFocus,k=s(e,["value","onChange","countries","hideDropdown","showDisabledDialCodeAndPrefix","flags","style","className","inputStyle","inputClassName","countrySelectorStyleProps","dialCodePreviewStyleProps","inputProps","placeholder","disabled","name","onFocus","onBlur","required","autoFocus"]);var N;var A=er(d(l({value:t,countries:o},k),{onChange:function(e){var r;(r=n)===null||r===void 0?void 0:r(e.phone,{country:e.country,inputValue:e.inputValue})}})),M=A.phone,O=A.inputValue,j=A.inputRef,L=A.country,_=A.setCountry,z=A.handlePhoneValueChange,B=k.disableDialCodeAndPrefix&&u&&((N=L)===null||N===void 0?void 0:N.dialCode);var F;return(0,eg.useImperativeHandle)(r,function(){return j.current?Object.assign(j.current,{setCountry:_,state:{phone:M,inputValue:O,country:L}}):null},[j,_,M,O,L]),eg.default.createElement("div",{ref:r,className:I({addPrefix:["input-container"],rawClassNames:[v]}),style:f},eg.default.createElement(eh,l({onSelect:function(e){return _(e.iso2)},flags:c,selectedCountry:L.iso2,countries:o,disabled:g,hideDropdown:i},m)),B&&eg.default.createElement(eC,l({dialCode:L.dialCode,prefix:(F=k.prefix)!==null&&F!==void 0?F:"+",disabled:g},h)),eg.default.createElement("input",l({onChange:z,value:O,type:"tel",ref:j,className:I({addPrefix:["input",g&&"input--disabled"],rawClassNames:[p]}),placeholder:C,disabled:g,style:y,name:w,onFocus:D,onBlur:P,autoFocus:x,required:S},b)))});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 s(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 d(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 b=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var w=Object.getPrototypeOf,D=Object.prototype.hasOwnProperty;var P=function(e,r){for(var t in r)b(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&&b(e,a,{get:function(){return r[a]},enumerable:!(n=C(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?b(t,"default",{value:e,enumerable:!0}):t,e)},k=function(e){return S(b({},"__esModule",{value:!0}),e)};var A={};P(A,{CountrySelector:function(){return eh},CountrySelectorDropdown:function(){return em},DialCodePreview:function(){return eC},FlagImage:function(){return ev},PhoneInput:function(){return ew},buildCountryData:function(){return F},defaultCountries:function(){return O},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(A);var N=x(require("react"));var O=[["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 E="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(E).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 L=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),s=l,d=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(d>=c.length){if(!u&&h!==n){s+=h;continue}break}h===n?(s+=c[d],d+=1):s+=h}}catch(e){v=true;p=e}finally{try{if(!f&&y.return!=null){y.return()}}finally{if(v){throw p}}}return s};var _=function(e){return e?/^\d+$/.test(e):!1};var z=function(e){return e.replace(/\D/g,"")};var B=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 F=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],s=u[l];if(c===void 0&&s!==void 0){var d=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(d))}}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=z(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=L({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(_(t[c])){l=c;break}if(l===null){for(var s=0;s<t.length;s+=1)if(_(n[s]))return s;return t.length}var d=0;for(var f=0;f<l;f+=1)_(t[f])&&(d+=1);var v=0,p=0;for(var y=0;y<n.length&&(v+=1,_(n[y])&&(p+=1),!(p>=d+1));y+=1);if(u!=="backward")for(;!_(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(z(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,s=e.defaultMask,d=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 b=d?ei({phone:m,countries:o,currentCountryIso2:(v=t)===null||v===void 0?void 0:v.iso2}):void 0,C=(h=(p=b)===null||p===void 0?void 0:p.country)!==null&&h!==void 0?h:t,g=G(m,{prefix:i,mask:et({phone:m,country:C,defaultMask:s,disableFormatting:f}),maskChar:X,dialCode:C.dialCode,trimNonDigitsEnd:a,charAfterDialCode:u,forceDialCode:l,insertDialCodeOnEmpty:n,disableDialCodeAndPrefix:c}),w=d&&!((y=b)===null||y===void 0?void 0:y.fullDialCodeMatch)?t:C;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,s=r.defaultMask,d=r.disableFormatting,f=r.countries;var v,p,y,m;var h;var b=e.nativeEvent,C=b.inputType,g=W(C),w=!!((v=C)===null||v===void 0?void 0:v.startsWith("insertFrom")),D=C==="insertText",P=((p=b)===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=C)===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&&!_(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 A=S?a:"".concat(o).concat(t.dialCode).concat(i);return{inputValue:A,phone:q({phone:A,prefix:o}),cursorPosition:o.length+t.dialCode.length+i.length,country:t}}var N=K({value:S,country:t,trimNonDigitsEnd:g==="backward",insertDialCodeOnEmpty:n,countryGuessingEnabled:c,countries:f,prefix:o,charAfterDialCode:i,forceDialCode:u,disableDialCodeAndPrefix:l,disableFormatting:d,defaultMask:s}),O=N.phone,E=N.inputValue,M=N.country,j=T({cursorPositionAfterInput:x,phoneBeforeInput:a,phoneAfterInput:S,phoneAfterFormatted:E,leftOffset:u?o.length+t.dialCode.length+i.length:0,deletion:g});return{phone:O,inputValue:E,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],s=v((0,H.useState)([u]),2),d=s[0],f=s[1],y=v((0,H.useState)(0),2),m=y[0],h=y[1],b=$();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,s=b.check(),v=l&&s!==void 0?s>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=d.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=d[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>=d.length)return{success:!1};var r=d[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:O},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,s=e.defaultMask,d=s===void 0?ee.defaultMask:s,f=e.charAfterDialCode,p=f===void 0?ee.charAfterDialCode:f,m=e.historySaveDebounceMS,h=m===void 0?ee.historySaveDebounceMS:m,b=e.disableCountryGuess,C=b===void 0?ee.disableCountryGuess:b,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,A=k===void 0?ee.disableFormatting:k,N=e.onChange,O=e.inputRef;var E={countries:i,prefix:c,charAfterDialCode:p,forceDialCode:x?!1:P,disableDialCodeAndPrefix:x,defaultMask:d,countryGuessingEnabled:!C,disableFormatting:A},M=(0,V.useRef)(null),j=O||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))})},L=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},E)),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(!N)return;var a=q(n);N({phone:t,inputValue:r,country:a})}}),4),_=L[0],z=_.phone,B=_.inputValue,F=_.country,R=L[1],G=L[2],T=L[3],q=(0,V.useCallback)(function(e){return eo({value:e,field:"iso2",countries:i})},[i]),W=(0,V.useMemo)(function(){return q(F)},[F,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:B,insertDialCodeOnEmpty:!1},E)),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!==z&&((e=N)===null||e===void 0?void 0:e({inputValue:B,phone:z,country:W}));return}if(a===z)return;var r=K(l({value:a,country:W,insertDialCodeOnEmpty:!w},E)),t=r.phone,n=r.inputValue,o=r.country;R({phone:t,inputValue:n,country:o.iso2})},[a]),{phone:z,inputValue:B,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(z(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?O: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?O:t,a=e.currentCountryIso2;var o={country:void 0,fullDialCodeMatch:!1};if(!r)return o;var i=z(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,s=false,d=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 b=u.country?Number(m)>=Number(u.country.dialCode):!0;if(h){var C=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(C.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}}}}(b||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){s=true;d=e}finally{try{if(!c&&f.return!=null){f.return()}}finally{if(s){throw d}}}if(a){var k;var A=eo({value:a,field:"iso2",countries:n});if(!A)return u;var N=A?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)})}(A):!1;!!u&&((k=u.country)===null||k===void 0?void 0:k.dialCode)===A.dialCode&&u.country!==A&&u.fullDialCodeMatch&&(!A.areaCodes||N)&&(u={country:A,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",es="1f1e6",ed=ec.split("").reduce(function(e,r,t){return s(l({},e),n({},r,el(es,t)))},{}),ef=function(e){return[ed[e[0]],ed[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,s=d(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},s));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:""},s))};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?O:o,u=e.flags,c=e.onSelect,s=e.onClose,f=d(e,["show","dialCodePrefix","selectedCountry","countries","flags","onSelect","onClose"]);var p=(0,ep.useRef)(null),y=(0,ep.useRef)(),m=(0,ep.useRef)({updatedAt:void 0,value:""}),h=function(e){var r=m.current.updatedAt&&new Date().getTime()-m.current.updatedAt.getTime()>ey;m.current={value:r?e:"".concat(m.current.value).concat(e),updatedAt:new Date};var t=i.findIndex(function(e){return en(e).name.toLowerCase().startsWith(m.current.value)});t!==-1&&w(t)},b=(0,ep.useCallback)(function(e){return i.findIndex(function(r){return en(r).iso2===e})},[i]),C=v((0,ep.useState)(b(a)),2),g=C[0],w=C[1],D=function(){y.current!==a&&w(b(a))},P=(0,ep.useCallback)(function(e){var r;w(b(e.iso2)),(r=c)===null||r===void 0?void 0:r(e)},[c,b]),S=function(e){var r=i.length-1,t=function(t){return e==="prev"?t-1:e==="next"?t+1:e==="last"?r:0};w(function(e){var n=t(e);return n<0?0:n>r?r:n})},x=function(e){if(e.stopPropagation(),e.key==="Enter"){e.preventDefault();var r=en(i[g]);P(r);return}if(e.key==="Escape"){var t;(t=s)===null||t===void 0?void 0:t();return}if(e.key==="ArrowUp"){e.preventDefault(),S("prev");return}if(e.key==="ArrowDown"){e.preventDefault(),S("next");return}if(e.key==="PageUp"){e.preventDefault(),S("first");return}if(e.key==="PageDown"){e.preventDefault(),S("last");return}e.key===" "&&e.preventDefault(),e.key.length===1&&!e.altKey&&!e.ctrlKey&&!e.metaKey&&h(e.key.toLocaleLowerCase())},k=(0,ep.useCallback)(function(){if(!p.current||g===void 0)return;var e=en(i[g]).iso2;if(e===y.current)return;var r=p.current.querySelector('[data-country="'.concat(e,'"]'));r&&(B(p.current,r),y.current=e)},[g,i]);return(0,ep.useEffect)(function(){k()},[g,k]),(0,ep.useEffect)(function(){p.current&&(r?p.current.focus():D())},[r]),(0,ep.useEffect)(function(){D()},[a]),ep.default.createElement("ul",{ref:p,role:"listbox",className:I({addPrefix:["country-selector-dropdown"],rawClassNames:[f.className]}),style:l({display:r?"block":"none"},f.style),onKeyDown:x,onBlur:s,tabIndex:-1,"aria-activedescendant":"react-international-phone__".concat(en(i[g]).iso2,"-option")},i.map(function(e,r){var t,o;var i=en(e),l=i.iso2===a,c=r===g,s=(t=u)===null||t===void 0?void 0:t.find(function(e){return e.iso2===i.iso2});return ep.default.createElement("li",{key:i.iso2,"data-country":i.iso2,role:"option","aria-selected":l,"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",l&&"country-selector-dropdown__list-item--selected",c&&"country-selector-dropdown__list-item--focused"],rawClassNames:[f.listItemClassName]}),onClick:function(){return P(i)},style:f.listItemStyle,title:i.name},ep.default.createElement(ev,{iso2:i.iso2,src:(o=s)===null||o===void 0?void 0:o.src,className:I({addPrefix:["country-selector-dropdown__list-item-flag-emoji"],rawClassNames:[f.listItemFlagClassName]}),style:f.listItemFlagStyle}),ep.default.createElement("span",{className:I({addPrefix:["country-selector-dropdown__list-item-country-name"],rawClassNames:[f.listItemCountryNameClassName]}),style:f.listItemCountryNameStyle},i.name),ep.default.createElement("span",{className:I({addPrefix:["country-selector-dropdown__list-item-dial-code"],rawClassNames:[f.listItemDialCodeClassName]}),style:f.listItemDialCodeStyle},n,i.dialCode))}))};var eh=function(e){var r=e.selectedCountry,t=e.onSelect,n=e.disabled,a=e.hideDropdown,o=e.countries,i=o===void 0?O:o,u=e.flags,c=e.renderButtonWrapper,f=d(e,["selectedCountry","onSelect","disabled","hideDropdown","countries","flags","renderButtonWrapper"]);var p=v((0,N.useState)(!1),2),y=p[0],m=p[1],h=(0,N.useMemo)(function(){if(r)return eo({value:r,field:"iso2",countries:i})},[i,r]),b=(0,N.useRef)(null),C=function(e){e.key&&["ArrowUp","ArrowDown"].includes(e.key)&&(e.preventDefault(),m(!0))},g=function(){var e,t,o;var i={title:(e=h)===null||e===void 0?void 0:e.name,onClick:function(){return m(function(e){return!e})},onMouseDown:function(e){return e.preventDefault()},onKeyDown:C,disabled:a||n,role:"combobox","aria-label":"Country selector","aria-haspopup":"listbox","aria-expanded":y},d=N.default.createElement("div",{className:I({addPrefix:["country-selector-button__button-content"],rawClassNames:[f.buttonContentWrapperClassName]}),style:f.buttonContentWrapperStyle},N.default.createElement(ev,{iso2:r,src:(o=u)===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:[f.flagClassName]}),style:l({visibility:r?"visible":"hidden"},f.flagStyle)}),!a&&N.default.createElement("div",{className:I({addPrefix:["country-selector-button__dropdown-arrow",n&&"country-selector-button__dropdown-arrow--disabled",y&&"country-selector-button__dropdown-arrow--active"],rawClassNames:[f.dropdownArrowClassName]}),style:f.dropdownArrowStyle}));return c?c({children:d,rootProps:i}):N.default.createElement("button",s(l({},i),{type:"button",className:I({addPrefix:["country-selector-button",y&&"country-selector-button--active",n&&"country-selector-button--disabled",a&&"country-selector-button--hide-dropdown"],rawClassNames:[f.buttonClassName]}),"data-country":r,style:f.buttonStyle}),d)};return N.default.createElement("div",{className:I({addPrefix:["country-selector"],rawClassNames:[f.className]}),style:f.style,ref:b},g(),N.default.createElement(em,l({show:y,countries:i,flags:u,onSelect:function(e){var r;m(!1),(r=t)===null||r===void 0?void 0:r(e)},selectedCountry:r,onClose:function(){m(!1)}},f.dropdownStyleProps)))};var eb=x(require("react"));var eC=function(e){var r=e.dialCode,t=e.prefix,n=e.disabled,a=e.style,o=e.className;return eb.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?O:a,i=e.hideDropdown,u=e.showDisabledDialCodeAndPrefix,c=e.disableFocusAfterCountrySelect,f=e.flags,v=e.style,p=e.className,y=e.inputStyle,m=e.inputClassName,h=e.countrySelectorStyleProps,b=e.dialCodePreviewStyleProps,C=e.inputProps,g=e.placeholder,w=e.disabled,D=e.name,P=e.onFocus,S=e.onBlur,x=e.required,k=e.autoFocus,A=d(e,["value","onChange","countries","hideDropdown","showDisabledDialCodeAndPrefix","disableFocusAfterCountrySelect","flags","style","className","inputStyle","inputClassName","countrySelectorStyleProps","dialCodePreviewStyleProps","inputProps","placeholder","disabled","name","onFocus","onBlur","required","autoFocus"]);var N;var E=er(s(l({value:t,countries:o},A),{onChange:function(e){var r;(r=n)===null||r===void 0?void 0:r(e.phone,{country:e.country,inputValue:e.inputValue})}})),M=E.phone,j=E.inputValue,L=E.inputRef,_=E.country,z=E.setCountry,B=E.handlePhoneValueChange,F=A.disableDialCodeAndPrefix&&u&&((N=_)===null||N===void 0?void 0:N.dialCode);var V;return(0,eg.useImperativeHandle)(r,function(){return L.current?Object.assign(L.current,{setCountry:z,state:{phone:M,inputValue:j,country:_}}):null},[L,z,M,j,_]),eg.default.createElement("div",{ref:r,className:I({addPrefix:["input-container"],rawClassNames:[p]}),style:v},eg.default.createElement(eh,l({onSelect:function(e){return z(e.iso2,{focusOnInput:!c})},flags:f,selectedCountry:_.iso2,countries:o,disabled:w,hideDropdown:i},h)),F&&eg.default.createElement(eC,l({dialCode:_.dialCode,prefix:(V=A.prefix)!==null&&V!==void 0?V:"+",disabled:w},b)),eg.default.createElement("input",l({onChange:B,value:j,type:"tel",ref:L,className:I({addPrefix:["input",w&&"input--disabled"],rawClassNames:[m]}),placeholder:g,disabled:w,style:y,name:D,onFocus:P,onBlur:S,autoFocus:k,required:x},C)))});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.0.4",
"version": "4.1.0",
"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