UNPKG

material-ui-phone-number-2

Version:

A material-ui react component to format phone numbers. Based on Material UI Phone Number, which ceased to be maintained.

1 lines 38.6 kB
!function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r(require("react"),require("prop-types"),require("country-flag-icons/react/3x2"),require("@mui/material"),require("lodash.debounce"),require("lodash.memoize")):"function"==typeof define&&define.amd?define("MaterialUiPhoneNumber",["react","prop-types","country-flag-icons/react/3x2","@mui/material","lodash.debounce","lodash.memoize"],r):"object"==typeof exports?exports.MaterialUiPhoneNumber=r(require("react"),require("prop-types"),require("country-flag-icons/react/3x2"),require("@mui/material"),require("lodash.debounce"),require("lodash.memoize")):e.MaterialUiPhoneNumber=r(e.react,e["prop-types"],e["country-flag-icons/react/3x2"],e["@mui/material"],e["lodash.debounce"],e["lodash.memoize"])}("undefined"!=typeof self?self:this,((e,r,a,n,t,o)=>(()=>{var i={530:e=>{var r;function a(e,r){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),a.push.apply(a,n)}return a}function n(e){for(var r=1;r<arguments.length;r++){var n=null!=arguments[r]?arguments[r]:{};r%2?a(Object(n),!0).forEach((function(r){t(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):a(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}function t(e,r,a){return r in e?Object.defineProperty(e,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[r]=a,e}function o(e,r){if(e){if("string"==typeof e)return i(e,r);var a=Object.prototype.toString.call(e).slice(8,-1);return"Object"===a&&e.constructor&&(a=e.constructor.name),"Map"===a||"Set"===a?Array.from(e):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?i(e,r):void 0}}function i(e,r){(null==r||r>e.length)&&(r=e.length);for(var a=0,n=new Array(r);a<r;a++)n[a]=e[a];return n}var u={};function c(e,r,a){r in u||(u[r]=[]);var n=a||0;u[r][n]=e}var l,s=(r=[]).concat.apply(r,function(e){if(Array.isArray(e))return i(e)}(l=[["Afghanistan",["asia"],"af","93"],["Albania",["europe"],"al","355"],["Algeria",["africa","north-africa"],"dz","213"],["American Samoa",["oceania"],"as","1684"],["Andorra",["europe"],"ad","376"],["Angola",["africa"],"ao","244"],["Anguilla",["america","carribean"],"ai","1264"],["Antigua and Barbuda",["america","carribean"],"ag","1268"],["Argentina",["america","south-america"],"ar","54","+.. (..) ........"],["Armenia",["asia","ex-ussr"],"am","374"],["Aruba",["america","carribean"],"aw","297"],["Australia",["oceania"],"au","61","+.. ... ... ..."],["Austria",["europe","european-union"],"at","43"],["Azerbaijan",["asia","ex-ussr"],"az","994"],["Bahamas",["america","carribean"],"bs","1242"],["Bahrain",["middle-east"],"bh","973"],["Bangladesh",["asia"],"bd","880"],["Barbados",["america","carribean"],"bb","1246"],["Belarus",["europe","ex-ussr"],"by","375","+... (..) ... .. .."],["Belgium",["europe","european-union"],"be","32","+.. ... .. .. .."],["Belize",["america","central-america"],"bz","501"],["Benin",["africa"],"bj","229","+... .... ...."],["Bermuda",["america","north-america"],"bm","1441"],["Bhutan",["asia"],"bt","975"],["Bolivia",["america","south-america"],"bo","591"],["Bosnia and Herzegovina",["europe"],"ba","387"],["Botswana",["africa"],"bw","267"],["Brazil",["america","south-america"],"br","55","+.. (..) ........."],["British Indian Ocean Territory",["asia"],"io","246"],["British Virgin Islands",["america","carribean"],"vg","1284"],["Brunei",["asia"],"bn","673"],["Bulgaria",["europe","european-union"],"bg","359"],["Burkina Faso",["africa"],"bf","226","+... .. .. .. .."],["Burundi",["africa"],"bi","257","+... .. .. .. .."],["Cambodia",["asia"],"kh","855"],["Cameroon",["africa"],"cm","237"],["Canada",["america","north-america"],"ca","1","+. (...) ...-....",1,["204","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",["africa"],"cv","238","+... ... .. .."],["Caribbean Netherlands",["america","carribean"],"bq","599","",1],["Cayman Islands",["america","carribean"],"ky","1345"],["Central African Republic",["africa"],"cf","236","+... .... ...."],["Chad",["africa"],"td","235","+... .. .. .. .."],["Chile",["america","south-america"],"cl","56"],["China",["asia"],"cn","86","+.. ..-........."],["Colombia",["america","south-america"],"co","57"],["Comoros",["africa"],"km","269","+... ... ...."],["Congo",["africa"],"cd","243"],["Congo",["africa"],"cg","242","+... .. .. ....."],["Cook Islands",["oceania"],"ck","682"],["Costa Rica",["america","central-america"],"cr","506","+... ....-...."],["Côte d’Ivoire",["africa"],"ci","225","+... .. .. .. .."],["Croatia",["europe","european-union"],"hr","385"],["Cuba",["america","carribean"],"cu","53"],["Curaçao",["america","carribean"],"cw","599","",0],["Cyprus",["europe","european-union"],"cy","357","+... .. ......"],["Czech Republic",["europe","european-union"],"cz","420"],["Denmark",["europe","european-union"],"dk","45","+.. .. .. .. .."],["Djibouti",["africa"],"dj","253"],["Dominica",["america","carribean"],"dm","1767"],["Dominican Republic",["america","carribean"],"do","1","",2,["809","829","849"]],["Ecuador",["america","south-america"],"ec","593"],["Egypt",["africa","north-africa"],"eg","20"],["El Salvador",["america","central-america"],"sv","503","+... ....-...."],["Equatorial Guinea",["africa"],"gq","240","+... .. ... ...."],["Eritrea",["africa"],"er","291"],["Estonia",["europe","european-union","ex-ussr"],"ee","372","+... .... ......"],["Ethiopia",["africa"],"et","251"],["Falkland Islands",["america","south-america"],"fk","500"],["Faroe Islands",["europe"],"fo","298"],["Fiji",["oceania"],"fj","679"],["Finland",["europe","european-union"],"fi","358","+... .. ... .. .."],["France",["europe","european-union"],"fr","33","+.. . .. .. .. .."],["French Guiana",["america","south-america"],"gf","594"],["French Polynesia",["oceania"],"pf","689"],["Gabon",["africa"],"ga","241","+... .. .. .. .."],["Gambia",["africa"],"gm","220"],["Georgia",["asia","ex-ussr"],"ge","995"],["Germany",["europe","european-union"],"de","49","+.. .... ........"],["Ghana",["africa"],"gh","233"],["Gibraltar",["europe"],"gi","350"],["Greece",["europe","european-union"],"gr","30"],["Greenland",["america"],"gl","299"],["Grenada",["america","carribean"],"gd","1473"],["Guadeloupe",["america","carribean"],"gp","590","",0],["Guam",["oceania"],"gu","1671"],["Guatemala",["america","central-america"],"gt","502","+... ....-...."],["Guinea",["africa"],"gn","224","+... . ... ...."],["Guinea-Bissau",["africa"],"gw","245"],["Guyana",["america","south-america"],"gy","592"],["Haiti",["america","carribean"],"ht","509","+... ....-...."],["Honduras",["america","central-america"],"hn","504"],["Hong Kong",["asia"],"hk","852","+... .... ...."],["Hungary",["europe","european-union"],"hu","36"],["Iceland",["europe"],"is","354","+... ... ...."],["India",["asia"],"in","91","+.. .....-....."],["Indonesia",["asia"],"id","62"],["Iran",["middle-east"],"ir","98"],["Iraq",["middle-east"],"iq","964"],["Ireland",["europe","european-union"],"ie","353","+... .. ......."],["Israel",["middle-east"],"il","972","+... ... ... ...."],["Italy",["europe","european-union"],"it","39","+.. ... .......",0],["Jamaica",["america","carribean"],"jm","1876"],["Japan",["asia"],"jp","81","+.. .. .... ...."],["Jordan",["middle-east"],"jo","962"],["Kazakhstan",["asia","ex-ussr"],"kz","7","+. ... ...-..-..",1,["313","327","7172","312","73622","321","324","336","318","315","325","311","326","310"]],["Kenya",["africa"],"ke","254"],["Kiribati",["oceania"],"ki","686"],["Kosovo",["europe"],"ks","383"],["Kuwait",["middle-east"],"kw","965"],["Kyrgyzstan",["asia","ex-ussr"],"kg","996"],["Laos",["asia"],"la","856"],["Latvia",["europe","european-union","ex-ussr"],"lv","371"],["Lebanon",["middle-east"],"lb","961"],["Lesotho",["africa"],"ls","266"],["Liberia",["africa"],"lr","231"],["Libya",["africa","north-africa"],"ly","218"],["Liechtenstein",["europe"],"li","423"],["Lithuania",["europe","european-union","ex-ussr"],"lt","370"],["Luxembourg",["europe","european-union"],"lu","352","+.. . ... ... ..."],["Macau",["asia"],"mo","853"],["Macedonia",["europe"],"mk","389"],["Madagascar",["africa"],"mg","261","+... .. . ......"],["Malawi",["africa"],"mw","265"],["Malaysia",["asia"],"my","60","+.. ..-....-...."],["Maldives",["asia"],"mv","960"],["Mali",["africa"],"ml","223","+... .... ...."],["Malta",["europe","european-union"],"mt","356"],["Marshall Islands",["oceania"],"mh","692"],["Martinique",["america","carribean"],"mq","596"],["Mauritania",["africa"],"mr","222","+... .... ...."],["Mauritius",["africa"],"mu","230","+... . ... ...."],["Mexico",["america","central-america"],"mx","52"],["Micronesia",["oceania"],"fm","691"],["Moldova",["europe"],"md","373","+... (..) ..-..-.."],["Monaco",["europe"],"mc","377"],["Mongolia",["asia"],"mn","976"],["Montenegro",["europe"],"me","382"],["Montserrat",["america","carribean"],"ms","1664"],["Morocco",["africa","north-africa"],"ma","212","+212-........."],["Mozambique",["africa"],"mz","258","+... ... ......"],["Myanmar",["asia"],"mm","95"],["Namibia",["africa"],"na","264"],["Nauru",["africa"],"nr","674"],["Nepal",["asia"],"np","977"],["Netherlands",["europe","european-union"],"nl","31","+.. .. ........"],["New Caledonia",["oceania"],"nc","687"],["New Zealand",["oceania"],"nz","64","+.. ...-...-...."],["Nicaragua",["america","central-america"],"ni","505"],["Niger",["africa"],"ne","227","+... .. .. .. .."],["Nigeria",["africa"],"ng","234"],["Niue",["asia"],"nu","683"],["Norfolk Island",["oceania"],"nf","672"],["North Korea",["asia"],"kp","850"],["Northern Mariana Islands",["oceania"],"mp","1670"],["Norway",["europe"],"no","47","+.. ... .. ..."],["Oman",["middle-east"],"om","968"],["Pakistan",["asia"],"pk","92","+.. ...-......."],["Palau",["oceania"],"pw","680"],["Palestine",["middle-east"],"ps","970"],["Panama",["america","central-america"],"pa","507"],["Papua New Guinea",["oceania"],"pg","675"],["Paraguay",["america","south-america"],"py","595"],["Peru",["america","south-america"],"pe","51"],["Philippines",["asia"],"ph","63","+.. .... ......."],["Poland",["europe","european-union"],"pl","48","+.. ...-...-..."],["Portugal",["europe","european-union"],"pt","351"],["Puerto Rico",["america","carribean"],"pr","1","",3,["787","939"]],["Qatar",["middle-east"],"qa","974"],["Réunion",["africa"],"re","262","+.. . .. .. .. .."],["Romania",["europe","european-union"],"ro","40"],["Russia",["europe","asia","ex-ussr"],"ru","7","+. (...) ...-..-..",0],["Rwanda",["africa"],"rw","250","+... ... ... ..."],["Saint Barthélemy",["america","carribean"],"bl","590","",1],["Saint Helena",["africa"],"sh","290"],["Saint Kitts and Nevis",["america","carribean"],"kn","1869"],["Saint Lucia",["america","carribean"],"lc","1758"],["Saint Martin",["america","carribean"],"mf","590","",2],["Saint Pierre and Miquelon",["america","north-america"],"pm","508"],["Saint Vincent and the Grenadines",["america","carribean"],"vc","1784"],["Samoa",["oceania"],"ws","685"],["San Marino",["europe"],"sm","378"],["São Tomé and Príncipe",["africa"],"st","239","+... ... ...."],["Saudi Arabia",["middle-east"],"sa","966"],["Senegal",["africa"],"sn","221","+... .. ... .. .."],["Serbia",["europe"],"rs","381"],["Seychelles",["africa"],"sc","248","+... ... ...."],["Sierra Leone",["africa"],"sl","232"],["Singapore",["asia"],"sg","65","+.. ....-...."],["Sint Maarten",["america","carribean"],"sx","1721"],["Slovakia",["europe","european-union"],"sk","421"],["Slovenia",["europe","european-union"],"si","386"],["Solomon Islands",["oceania"],"sb","677"],["Somalia",["africa"],"so","252"],["South Africa",["africa"],"za","27","+.. .. ... ...."],["South Korea",["asia"],"kr","82","+.. ... .... ...."],["South Sudan",["africa","north-africa"],"ss","211"],["Spain",["europe","european-union"],"es","34","+.. ... ... ..."],["Sri Lanka",["asia"],"lk","94"],["Sudan",["africa"],"sd","249"],["Suriname",["america","south-america"],"sr","597"],["Swaziland",["africa"],"sz","268"],["Sweden",["europe","european-union"],"se","46","+.. (..) ...-..-.."],["Switzerland",["europe"],"ch","41","+.. .. ... .. .."],["Syria",["middle-east"],"sy","963"],["Taiwan",["asia"],"tw","886"],["Tajikistan",["asia","ex-ussr"],"tj","992"],["Tanzania",["africa"],"tz","255"],["Thailand",["asia"],"th","66"],["Timor-Leste",["asia"],"tl","670"],["Togo",["africa"],"tg","228","+... ... ....."],["Tokelau",["oceania"],"tk","690"],["Tonga",["oceania"],"to","676"],["Trinidad and Tobago",["america","carribean"],"tt","1868"],["Tunisia",["africa","north-africa"],"tn","216","+... .. ... ..."],["Turkey",["europe"],"tr","90","+.. ... ... .. .."],["Turkmenistan",["asia","ex-ussr"],"tm","993"],["Turks and Caicos Islands",["america","carribean"],"tc","1649"],["Tuvalu",["asia"],"tv","688"],["U.S. Virgin Islands",["america","carribean"],"vi","1340"],["Uganda",["africa"],"ug","256"],["Ukraine",["europe","ex-ussr"],"ua","380","+... (..) ... .. .."],["United Arab Emirates",["middle-east"],"ae","971"],["United Kingdom",["europe","european-union"],"gb","44","+.. .... ......"],["United States",["america","north-america"],"us","1","+. (...) ...-....",0,["907","205","251","256","334","479","501","870","480","520","602","623","928","209","213","310","323","408","415","510","530","559","562","619","626","650","661","707","714","760","805","818","831","858","909","916","925","949","951","303","719","970","203","860","202","302","239","305","321","352","386","407","561","727","772","813","850","863","904","941","954","229","404","478","706","770","912","808","319","515","563","641","712","208","217","309","312","618","630","708","773","815","847","219","260","317","574","765","812","316","620","785","913","270","502","606","859","225","318","337","504","985","413","508","617","781","978","301","410","207","231","248","269","313","517","586","616","734","810","906","989","218","320","507","612","651","763","952","314","417","573","636","660","816","228","601","662","406","252","336","704","828","910","919","701","308","402","603","201","609","732","856","908","973","505","575","702","775","212","315","516","518","585","607","631","716","718","845","914","216","330","419","440","513","614","740","937","405","580","918","503","541","215","412","570","610","717","724","814","401","803","843","864","605","423","615","731","865","901","931","210","214","254","281","325","361","409","432","512","713","806","817","830","903","915","936","940","956","972","979","435","801","276","434","540","703","757","804","802","206","253","360","425","509","262","414","608","715","920","304","307"]],["Uruguay",["america","south-america"],"uy","598"],["Uzbekistan",["asia","ex-ussr"],"uz","998"],["Vanuatu",["oceania"],"vu","678"],["Vatican City",["europe"],"va","39","+.. .. .... ....",1],["Venezuela",["america","south-america"],"ve","58"],["Vietnam",["asia"],"vn","84"],["Wallis and Futuna",["oceania"],"wf","681"],["Yemen",["middle-east"],"ye","967"],["Zambia",["africa"],"zm","260"],["Zimbabwe",["africa"],"zw","263"]].map((function(e){var r=function(e,r){return function(e){if(Array.isArray(e))return e}(e)||function(e,r){var a=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=a){var n,t,o=[],i=!0,u=!1;try{for(a=a.call(e);!(i=(n=a.next()).done)&&(o.push(n.value),!r||o.length!==r);i=!0);}catch(e){u=!0,t=e}finally{try{i||null==a.return||a.return()}finally{if(u)throw t}}return o}}(e,r)||o(e,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(e,7),a=r[0],t=r[1],i=r[2],u=r[3],l=r[4],s=r[5],d=r[6],f={name:a,regions:t,iso2:i,dialCode:u,priority:s,format:l||void 0,hasAreaCodes:d},p=[];return f.hasAreaCodes&&d.forEach((function(e){var r=n(n({},f),{},{regions:t,dialCode:"".concat(u).concat(e),isAreaCode:!0});p.push(r),c(i,r.dialCode)})),c(f.iso2,f.dialCode,f.hasAreaCodes),p.length>0?[f].concat(p):[f]})))||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(l)||o(l)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}());e.exports={allCountries:s,allCountryCodes:u}},901:e=>{"use strict";e.exports=n},473:e=>{"use strict";e.exports=a},421:e=>{"use strict";e.exports=t},875:e=>{"use strict";e.exports=o},99:e=>{"use strict";e.exports=r},156:r=>{"use strict";r.exports=e}},u={};function c(e){var r=u[e];if(void 0!==r)return r.exports;var a=u[e]={exports:{}};return i[e](a,a.exports,c),a.exports}c.n=e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return c.d(r,{a:r}),r},c.d=(e,r)=>{for(var a in r)c.o(r,a)&&!c.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:r[a]})},c.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),c.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var l={};return(()=>{"use strict";c.r(l),c.d(l,{default:()=>L});var e=c(156),r=c.n(e),a=c(99),n=c.n(a),t=c(473),o=c.n(t),i=c(901),u=c(530),s=c.n(u);function d(e){return d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},d(e)}var f=["name","iso2","dialCode","localization","itemRef","native","className"];function p(){return p=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var a=arguments[r];for(var n in a)Object.prototype.hasOwnProperty.call(a,n)&&(e[n]=a[n])}return e},p.apply(this,arguments)}function m(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}function y(e,r){for(var a=0;a<r.length;a++){var n=r[a];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function b(e,r){return b=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,r){return e.__proto__=r,e},b(e,r)}function h(e,r){if(r&&("object"===d(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function g(e){return g=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},g(e)}var C=function(e){!function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(r&&r.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),r&&b(e,r)}(l,e);var a,n,t,u,c=(t=l,u=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,r=g(t);if(u){var a=g(this).constructor;e=Reflect.construct(r,arguments,a)}else e=r.apply(this,arguments);return h(this,e)});function l(){return m(this,l),c.apply(this,arguments)}return a=l,(n=[{key:"render",value:function(){var e=r().createRef(),a=this.props,n=a.name,t=a.iso2,u=a.dialCode,c=a.localization,l=(a.itemRef,a.native),s=a.className,d=void 0===s?"":s,m=function(e,r){if(null==e)return{};var a,n,t=function(e,r){if(null==e)return{};var a,n,t={},o=Object.keys(e);for(n=0;n<o.length;n++)a=o[n],r.indexOf(a)>=0||(t[a]=e[a]);return t}(e,r);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(n=0;n<o.length;n++)a=o[n],r.indexOf(a)>=0||Object.prototype.propertyIsEnumerable.call(e,a)&&(t[a]=e[a])}return t}(a,f);if(l)return r().createElement("option",p({className:"country","data-dial-code":"1","data-country-code":t,value:t},m),c||n," ","+".concat(u));var y=o()[t.toUpperCase()];return r().createElement(i.MenuItem,p({ref:e,className:"country","data-dial-code":"1","data-country-code":t},m),Boolean(y)&&r().createElement("div",{className:d},r().createElement(y,null)),r().createElement("span",{className:"country-name"},c||n),r().createElement("span",{className:"dial-code"},"+".concat(u)))}}])&&y(a.prototype,n),Object.defineProperty(a,"prototype",{writable:!1}),l}(r().PureComponent);C.propTypes={name:n().string.isRequired,iso2:n().string.isRequired,dialCode:n().string.isRequired,itemRef:n().func.isRequired,localization:n().string,native:n().bool},C.defaultProps={localization:null,native:!1};const v=C;var w=c(421),S=c.n(w),O=c(875),j=c.n(O);function E(e){return E="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},E(e)}var k=["native","defaultCountry","excludeCountries","onlyCountries","preferredCountries","dropdownClass","autoFormat","disableAreaCodes","isValid","disableCountryCode","disableDropdown","enableLongNumbers","countryCodeEditable","onEnterKeyPress","isModernBrowser","keys","localization","placeholder","regions","onChange","value","inputClass","error","InputProps"];function P(){return P=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var a=arguments[r];for(var n in a)Object.prototype.hasOwnProperty.call(a,n)&&(e[n]=a[n])}return e},P.apply(this,arguments)}function x(e,r){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),a.push.apply(a,n)}return a}function I(e){for(var r=1;r<arguments.length;r++){var a=null!=arguments[r]?arguments[r]:{};r%2?x(Object(a),!0).forEach((function(r){z(e,r,a[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):x(Object(a)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(a,r))}))}return e}function T(e,r){(null==r||r>e.length)&&(r=e.length);for(var a=0,n=new Array(r);a<r;a++)n[a]=e[a];return n}function N(e,r){for(var a=0;a<r.length;a++){var n=r[a];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function R(e,r){return R=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,r){return e.__proto__=r,e},R(e,r)}function A(e,r){if(r&&("object"===E(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");return D(e)}function D(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function M(e){return M=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},M(e)}function z(e,r,a){return r in e?Object.defineProperty(e,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[r]=a,e}var B=(0,i.styled)(i.IconButton)({width:"min-content",minWidth:30,padding:0,height:30,"& svg":{width:"auto",height:"1em"}}),_=(0,i.styled)(v)({width:16,marginRight:8}),q=(0,i.styled)(i.NativeSelect)({width:30,height:30,padding:8}),F=function(e){!function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(r&&r.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),r&&R(e,r)}(l,e);var a,n,t,u,c=(t=l,u=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,r=M(t);if(u){var a=M(this).constructor;e=Reflect.construct(r,arguments,a)}else e=r.apply(this,arguments);return A(this,e)});function l(e){var a;!function(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}(this,l),z(D(a=c.call(this,e)),"flags",{}),z(D(a),"guessSelectedCountry",j()((function(e,r,a){var n=r.find((function(e){return e.iso2===a}))||{};if(""===e.trim())return n;var t=r.reduce((function(r,a){if(e.startsWith(a.dialCode)){if(a.dialCode.length>r.dialCode.length)return a;if(a.dialCode.length===r.dialCode.length&&a.priority<r.priority)return a}return r}),{dialCode:"",priority:10001});return t.name?t:n}))),z(D(a),"getProbableCandidate",j()((function(e){return e&&0!==e.length?a.state.onlyCountries.filter((function(r){return r.name.toLowerCase().startsWith(e.toLowerCase())}))[0]:null}))),z(D(a),"getOnlyCountries",(function(e,r){return 0===e.length?r:r.filter((function(r){return e.some((function(e){return e===r.iso2}))}))})),z(D(a),"excludeCountries",(function(e,r){return 0===r.length?e:e.filter((function(e){return!r.includes(e.iso2)}))})),z(D(a),"filterRegions",(function(e,r){if("string"==typeof e){var a=e;return r.filter((function(e){return e.regions.some((function(e){return e===a}))}))}return r.filter((function(r){var a=e.map((function(e){return r.regions.some((function(r){return r===e}))}));return a.some((function(e){return e}))}))})),z(D(a),"deleteAreaCodes",(function(e){return e.filter((function(e){return!0!==e.isAreaCode}))})),z(D(a),"updateDefaultCountry",(function(e){var r=a.state.onlyCountries,n=a.props.disableCountryCode,t=r.find((function(r){return r.iso2===e}));a.setState({defaultCountry:e,selectedCountry:t,formattedNumber:n?"":"+".concat(t.dialCode)})})),z(D(a),"scrollTo",(function(e){if(e){var r=a.dropdownContainerRef;r&&document.body&&(r.scrollTop=e.offsetTop)}})),z(D(a),"formatNumber",(function(e,r){var n,t=a.props,o=t.disableCountryCode,i=t.enableLongNumbers,u=t.autoFormat;if(o&&r?((n=r.split(" ")).shift(),n=n.join(" ")):n=r,!e||0===e.length)return o?"":"+";if(e&&e.length<2||!n||!u)return o?e:"+".concat(e);var c,l=n.split("").reduce((function(e,r){if(0===e.remainingText.length)return e;if("."!==r)return{formattedText:e.formattedText+r,remainingText:e.remainingText};var a,n=function(e){if(Array.isArray(e))return e}(a=e.remainingText)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(a)||function(e,r){if(e){if("string"==typeof e)return T(e,r);var a=Object.prototype.toString.call(e).slice(8,-1);return"Object"===a&&e.constructor&&(a=e.constructor.name),"Map"===a||"Set"===a?Array.from(e):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?T(e,r):void 0}}(a)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),t=n[0],o=n.slice(1);return{formattedText:e.formattedText+t,remainingText:o}}),{formattedText:"",remainingText:e.split("")});return(c=i?l.formattedText+l.remainingText.join(""):l.formattedText).includes("(")&&!c.includes(")")&&(c+=")"),c})),z(D(a),"cursorToEnd",(function(){var e=a.props.isModernBrowser,r=a.inputRef;if(r&&(r.focus(),e)){var n=r.value.length;r.setSelectionRange(n,n)}})),z(D(a),"getElement",(function(e){return a.flags["flag_no_".concat(e)]})),z(D(a),"getCountryData",(function(){var e=a.state.selectedCountry;return e?{name:e.name||"",dialCode:e.dialCode||"",countryCode:e.iso2||""}:{}})),z(D(a),"handleInput",(function(e){var r=a.state,n=r.selectedCountry,t=r.freezeSelection,o=a.state,i=o.selectedCountry,u=o.formattedNumber,c=o.onlyCountries,l=o.defaultCountry,s=a.props,d=s.disableCountryCode,f=s.countryCodeEditable,p=s.isModernBrowser,m=s.onChange,y=d?"":"+";if(!f){var b="+".concat(n.dialCode);if(e.target.value.length<b.length)return}if(!(e.target.value.replace(/\D/g,"").length>15)&&e.target.value!==u){if(e.preventDefault?e.preventDefault():e.returnValue=!1,e.target.value.length>0){var h=e.target.value.replace(/\D/g,"");(!t||i.dialCode.length>h.length)&&(n=a.guessSelectedCountry(h.substring(0,6),c,l),t=!1),y=a.formatNumber(h,a.getInputMask(n))}var g=e.target.selectionStart,C=y.length-u.length;a.setState({formattedNumber:y,freezeSelection:t,selectedCountry:n.dialCode?n:i},(function(){p&&(C>0&&(g-=C),")"===y.charAt(y.length-1)?a.inputRef.setSelectionRange(y.length-1,y.length-1):g>0&&u.length>=y.length&&a.inputRef.setSelectionRange(g,g)),m&&m(y,a.getCountryData())}))}})),z(D(a),"getInputMask",(function(e){return a.props.masks[e.iso2]||e.format})),z(D(a),"handleRefInput",(function(e){var r,n=a.props,t=n.inputRef,o=n.InputProps;a.inputRef=e,t?r=t:o&&o.ref&&(r=o.ref),r&&("function"==typeof r?r(e):r.current=e)})),z(D(a),"handleInputClick",(function(e){var r=a.props.onClick;r&&r(e,a.getCountryData())})),z(D(a),"handleFlagItemClick",(function(e){var r=a.state,n=r.formattedNumber,t=r.selectedCountry,o=r.onlyCountries,i=a.props.onChange,u=t,c="string"==typeof e?o.find((function(r){return r.iso2===e})):o.find((function(r){return r===e})),l=n.replace(" ","").replace("(","").replace(")","").replace("-",""),s=l.length>1?l.replace(u.dialCode,c.dialCode):c.dialCode,d=a.formatNumber(s.replace(/\D/g,""),a.getInputMask(c));a.setState({anchorEl:null,selectedCountry:c,freezeSelection:!0,formattedNumber:d},(function(){a.cursorToEnd(),i&&i(d,a.getCountryData())}))})),z(D(a),"handleInputFocus",(function(e){var r=a.state.selectedCountry,n=a.props,t=n.disableCountryCode,o=n.onFocus;a.inputRef&&"+"===a.inputRef.value&&r&&!t&&a.setState({formattedNumber:"+".concat(r.dialCode)},(function(){return setTimeout(a.cursorToEnd,10)})),a.setState({placeholder:""}),o&&o(e,a.getCountryData()),setTimeout(a.cursorToEnd,10)})),z(D(a),"handleInputBlur",(function(e){var r=a.props,n=r.placeholder,t=r.onBlur;e.target.value||a.setState({placeholder:n}),t&&t(e,a.getCountryData())})),z(D(a),"getHighlightCountryIndex",(function(e){var r=a.state,n=r.highlightCountryIndex,t=r.onlyCountries,o=r.preferredCountries,i=n+e;return i<0||i>=t.length+o.length?i-e:i})),z(D(a),"searchCountry",(function(){var e=a.state,r=e.queryString,n=e.onlyCountries,t=e.preferredCountries,o=a.getProbableCandidate(r)||n[0],i=n.findIndex((function(e){return e===o}))+t.length;a.scrollTo(a.getElement(i),!0),a.setState({queryString:"",highlightCountryIndex:i})})),z(D(a),"handleKeydown",(function(e){var r=a.state,n=r.anchorEl,t=r.highlightCountryIndex,o=r.preferredCountries,i=r.onlyCountries,u=r.queryString,c=r.debouncedQueryStingSearcher,l=a.props,s=l.keys,d=l.disabled;if(n&&!d){e.preventDefault?e.preventDefault():e.returnValue=!1;var f=function(e){a.setState({highlightCountryIndex:a.getHighlightCountryIndex(e)},(function(){a.scrollTo(a.getElement(t+o.length),!0)}))};switch(e.which){case s.DOWN:f(1);break;case s.UP:f(-1);break;case s.ENTER:a.handleFlagItemClick(i[t],e);break;case s.ESC:a.setState({anchorEl:null},a.cursorToEnd);break;default:(e.which>=s.A&&e.which<=s.Z||e.which===s.SPACE)&&a.setState({queryString:u+String.fromCharCode(e.which)},c)}}})),z(D(a),"handleInputKeyDown",(function(e){var r=a.props,n=r.keys,t=r.onEnterKeyPress,o=r.onKeyDown;e.which===n.ENTER&&t&&t(e),o&&o(e)})),z(D(a),"checkIfValid",(function(){var e=a.state.formattedNumber;return(0,a.props.isValid)(e.replace(/\D/g,""))})),z(D(a),"updateFormattedNumber",(function(e){var r,n,t=a.state,o=t.onlyCountries,i=t.defaultCountry,u=a.props.disableCountryCode,c=e;if(c.startsWith("+"))c=c.replace(/\D/g,""),r=a.guessSelectedCountry(c.substring(0,6),o,i),n=a.formatNumber(c,a.getInputMask(r));else{var l=(r=o.find((function(e){return e.iso2===i})))&&!c.replace(/\D/g,"").startsWith(r.dialCode)?r.dialCode:"";n=a.formatNumber((u?"":l)+c.replace(/\D/g,""),r?a.getInputMask(r):void 0)}a.setState({selectedCountry:r,formattedNumber:n})})),z(D(a),"getDropdownProps",(function(){var e=a.state,n=e.selectedCountry,t=e.anchorEl,u=e.preferredCountries,c=e.onlyCountries,l=a.props,s=l.dropdownClass,d=l.localization,f=l.disableDropdown,p=l.native;c.sort((function(e,r){var a=d[e.name]||e.name,n=d[r.name]||r.name;return a.localeCompare(n)}));var m=function(e){return Boolean(n&&n.dialCode===e.dialCode)},y=o()[n.iso2.toUpperCase()];return f?{}:{startAdornment:r().createElement(i.InputAdornment,{sx:{position:"relative"},position:"start"},p?r().createElement(r().Fragment,null,r().createElement(q,{id:"country-menu",open:Boolean(t),onClose:function(){return a.setState({anchorEl:null})},onChange:function(e){return a.handleFlagItemClick(e.target.value)},IconComponent:Boolean(y)&&y,disableUnderline:!0},!!u.length&&u.map((function(e,n){return r().createElement(v,{key:"preferred_".concat(e.iso2,"_").concat(n),itemRef:function(e){a.flags["flag_no_".concat(n)]=e},name:e.name,iso2:e.iso2,dialCode:e.dialCode,localization:d&&d[e.name],native:!0})})),c.map((function(e,n){return r().createElement(v,{key:"preferred_".concat(e.iso2,"_").concat(n),itemRef:function(e){a.flags["flag_no_".concat(n)]=e},name:e.name,iso2:e.iso2,dialCode:e.dialCode,localization:d&&d[e.name],native:!0})})))):r().createElement(r().Fragment,null,r().createElement(B,{"aria-owns":t?"country-menu":null,"aria-label":"Select country",onClick:function(e){return a.setState({anchorEl:e.currentTarget})},"aria-haspopup":!0},Boolean(y)&&r().createElement(y,{className:"margin"})),r().createElement(i.Menu,{className:s,id:"country-menu",anchorEl:t,open:Boolean(t),onClose:function(){return a.setState({anchorEl:null})}},!!u.length&&u.map((function(e,n){return r().createElement(_,{key:"preferred_".concat(e.iso2,"_").concat(n),itemRef:function(e){a.flags["flag_no_".concat(n)]=e},selected:m(e),onClick:function(){return a.handleFlagItemClick(e)},name:e.name,iso2:e.iso2,dialCode:e.dialCode,localization:d&&d[e.name]})})),!!u.length&&r().createElement(i.Divider,null),c.map((function(e,n){return r().createElement(_,{key:"preferred_".concat(e.iso2,"_").concat(n),itemRef:function(e){a.flags["flag_no_".concat(n)]=e},selected:m(e),onClick:function(){return a.handleFlagItemClick(e)},name:e.name,iso2:e.iso2,dialCode:e.dialCode,localization:d&&d[e.name]})})))))}}));var n=s().allCountries;e.disableAreaCodes&&(n=a.deleteAreaCodes(n)),e.regions&&(n=a.filterRegions(e.regions,n));var t,u=a.excludeCountries(a.getOnlyCountries(e.onlyCountries,n),e.excludeCountries),d=n.filter((function(r){return e.preferredCountries.some((function(e){return e===r.iso2}))})),f=e.value||"";t=f.length>1?a.guessSelectedCountry(f.replace(/\D/g,"").substring(0,6),u,e.defaultCountry)||0:e.defaultCountry&&u.find((function(r){return r.iso2===e.defaultCountry}))||0;var p=s().allCountries.findIndex((function(e){return e===t})),m=f.length<2&&t&&!f.replace(/\D/g,"").startsWith(t.dialCode)?t.dialCode:"",y=""===f&&0===t?"":a.formatNumber((e.disableCountryCode?"":m)+f.replace(/\D/g,""),a.getInputMask(t)||(t.name?t.format:void 0));return a.state={formattedNumber:y,placeholder:e.placeholder,onlyCountries:u,preferredCountries:d,defaultCountry:e.defaultCountry,selectedCountry:t,highlightCountryIndex:p,queryString:"",freezeSelection:!1,debouncedQueryStingSearcher:S()(a.searchCountry,100),anchorEl:null},a}return a=l,(n=[{key:"componentDidMount",value:function(){document.addEventListener&&document.addEventListener("keydown",this.handleKeydown)}},{key:"componentDidUpdate",value:function(e){var r=e.value,a=this.state,n=a.defaultCountry,t=a.formattedNumber,o=this.props,i=o.defaultCountry,u=o.value;i&&i!==n&&this.updateDefaultCountry(i),"string"==typeof u&&u!==r&&u!==t&&this.updateFormattedNumber(u)}},{key:"componentWillUnmount",value:function(){document.removeEventListener&&document.removeEventListener("keydown",this.handleKeydown)}},{key:"render",value:function(){var e=this.state,a=e.formattedNumber,n=e.placeholder,t=this.props,o=(t.native,t.defaultCountry,t.excludeCountries,t.onlyCountries,t.preferredCountries,t.dropdownClass,t.autoFormat,t.disableAreaCodes,t.isValid,t.disableCountryCode,t.disableDropdown,t.enableLongNumbers,t.countryCodeEditable,t.onEnterKeyPress,t.isModernBrowser,t.keys,t.localization,t.placeholder,t.regions,t.onChange,t.value,t.inputClass),u=t.error,c=t.InputProps,l=function(e,r){if(null==e)return{};var a,n,t=function(e,r){if(null==e)return{};var a,n,t={},o=Object.keys(e);for(n=0;n<o.length;n++)a=o[n],r.indexOf(a)>=0||(t[a]=e[a]);return t}(e,r);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(n=0;n<o.length;n++)a=o[n],r.indexOf(a)>=0||Object.prototype.propertyIsEnumerable.call(e,a)&&(t[a]=e[a])}return t}(t,k),s=this.getDropdownProps();return r().createElement(i.TextField,P({placeholder:n,value:a,className:o,inputRef:this.handleRefInput,error:u||!this.checkIfValid(),onChange:this.handleInput,onClick:this.handleInputClick,onFocus:this.handleInputFocus,onBlur:this.handleInputBlur,onKeyDown:this.handleInputKeyDown,type:"tel",InputProps:I(I({},s),c)},l))}}])&&N(a.prototype,n),Object.defineProperty(a,"prototype",{writable:!1}),l}(r().Component);F.propTypes={excludeCountries:n().arrayOf(n().string),onlyCountries:n().arrayOf(n().string),preferredCountries:n().arrayOf(n().string),defaultCountry:n().string,masks:n().object,value:n().string,placeholder:n().string,disabled:n().bool,error:n().bool,variant:n().string,native:n().bool,inputClass:n().string,dropdownClass:n().string,InputProps:n().object,inputProps:n().object,inputRef:n().func,autoFormat:n().bool,disableAreaCodes:n().bool,disableCountryCode:n().bool,disableDropdown:n().bool,enableLongNumbers:n().bool,countryCodeEditable:n().bool,regions:n().oneOfType([n().string,n().arrayOf(n().string)]),localization:n().object,onChange:n().func,onFocus:n().func,onBlur:n().func,onClick:n().func,onKeyDown:n().func,isValid:n().func,isModernBrowser:n().func,onEnterKeyPress:n().func,keys:n().object},F.defaultProps={excludeCountries:[],onlyCountries:[],preferredCountries:[],defaultCountry:"",masks:{},placeholder:"+1 (702) 123-4567",disabled:!1,error:!1,variant:"standard",native:!1,inputClass:"",dropdownClass:"",autoFormat:!0,disableAreaCodes:!1,isValid:function(e){return s().allCountries.some((function(r){return e.startsWith(r.dialCode)||r.dialCode.startsWith(e)}))},disableCountryCode:!1,disableDropdown:!1,enableLongNumbers:!1,countryCodeEditable:!0,regions:"",localization:{},onEnterKeyPress:function(){},onChange:function(){},isModernBrowser:function(){return!!document.createElement&&Boolean(document.createElement("input").setSelectionRange)},keys:{UP:38,DOWN:40,RIGHT:39,LEFT:37,ENTER:13,ESC:27,PLUS:43,A:65,Z:90,SPACE:32}},F.displayName="MuiPhoneNumber";const L=F})(),l})()));