@trackunit/custom-field-components 0.0.386 → 0.0.389

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -5,8 +5,6 @@ import { FormGroup, Checkbox, DateField, Select, NumberInput, BaseInput, TextFie
5
5
  import { tw, twx } from '@trackunit/tailwind-styled-components';
6
6
  import * as React from 'react';
7
7
  import { useCallback, useEffect, createElement, useState } from 'react';
8
- import { v4 } from 'uuid';
9
- import { isValidPhoneNumber } from 'libphonenumber-js';
10
8
 
11
9
  /******************************************************************************
12
10
  Copyright (c) Microsoft Corporation.
@@ -35,343 +33,3500 @@ function __rest(s, e) {
35
33
  return t;
36
34
  }
37
35
 
36
+ // Unique ID creation requires a high quality random # generator. In the browser we therefore
37
+ // require the crypto API and do not support built-in fallback to lower quality random number
38
+ // generators (like Math.random()).
39
+ var getRandomValues;
40
+ var rnds8 = new Uint8Array(16);
41
+ function rng() {
42
+ // lazy load so that environments that need to polyfill have a chance to do so
43
+ if (!getRandomValues) {
44
+ // getRandomValues needs to be invoked in a context where "this" is a Crypto implementation. Also,
45
+ // find the complete implementation of crypto (msCrypto) on IE11.
46
+ getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto !== 'undefined' && typeof msCrypto.getRandomValues === 'function' && msCrypto.getRandomValues.bind(msCrypto);
47
+
48
+ if (!getRandomValues) {
49
+ throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
50
+ }
51
+ }
52
+
53
+ return getRandomValues(rnds8);
54
+ }
55
+
56
+ var REGEX = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;
57
+
58
+ function validate(uuid) {
59
+ return typeof uuid === 'string' && REGEX.test(uuid);
60
+ }
61
+
62
+ /**
63
+ * Convert array of 16 byte values to UUID string format of the form:
64
+ * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
65
+ */
66
+
67
+ var byteToHex = [];
68
+
69
+ for (var i = 0; i < 256; ++i) {
70
+ byteToHex.push((i + 0x100).toString(16).substr(1));
71
+ }
72
+
73
+ function stringify(arr) {
74
+ var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
75
+ // Note: Be careful editing this code! It's been tuned for performance
76
+ // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
77
+ var uuid = (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase(); // Consistency check for valid UUID. If this throws, it's likely due to one
78
+ // of the following:
79
+ // - One or more input array values don't map to a hex octet (leading to
80
+ // "undefined" in the uuid)
81
+ // - Invalid input values for the RFC `version` or `variant` fields
82
+
83
+ if (!validate(uuid)) {
84
+ throw TypeError('Stringified UUID is invalid');
85
+ }
86
+
87
+ return uuid;
88
+ }
89
+
90
+ function v4(options, buf, offset) {
91
+ options = options || {};
92
+ var rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
93
+
94
+ rnds[6] = rnds[6] & 0x0f | 0x40;
95
+ rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
96
+
97
+ if (buf) {
98
+ offset = offset || 0;
99
+
100
+ for (var i = 0; i < 16; ++i) {
101
+ buf[offset + i] = rnds[i];
102
+ }
103
+
104
+ return buf;
105
+ }
106
+
107
+ return stringify(rnds);
108
+ }
109
+
110
+ /**
111
+ * A component that can be used to render a boolean field
112
+ *
113
+ * @param options BooleanCustomFieldProps - options for the component
114
+ * @returns { JSX.Element } JSX.Element - a component that can be used to render a boolean field
115
+ */
116
+ const BooleanCustomField = (_a) => {
117
+ var { defaultValue, dataTestId = "booleanField", onChange, value, id, setValue, register, validationRules, disabled = false, label, tip, isInvalid, errorMessage, helpAddon, maxLength, helpText } = _a, rest = __rest(_a, ["defaultValue", "dataTestId", "onChange", "value", "id", "setValue", "register", "validationRules", "disabled", "label", "tip", "isInvalid", "errorMessage", "helpAddon", "maxLength", "helpText"]);
118
+ const initialValue = value !== undefined ? value : defaultValue ? defaultValue : false;
119
+ const renderAsInvalid = isInvalid || Boolean(errorMessage);
120
+ const htmlForId = id ? id : "boolean-custom-field-" + v4();
121
+ const [internalValue, setInternalValue] = React.useState(initialValue);
122
+ React.useEffect(() => {
123
+ setInternalValue((value === undefined ? defaultValue : value) || false);
124
+ }, [value, setInternalValue, defaultValue]);
125
+ const onChangeHandler = React.useCallback((event) => {
126
+ var _a;
127
+ onChange && onChange(event);
128
+ const isChecked = ((_a = event.target) === null || _a === void 0 ? void 0 : _a.checked) || false;
129
+ if (setValue) {
130
+ setValue(id, isChecked);
131
+ }
132
+ setInternalValue(isChecked);
133
+ }, [setInternalValue, onChange, id, setValue]);
134
+ React.useEffect(() => {
135
+ register && register(id, Object.assign(Object.assign({}, validationRules), { value: internalValue.toString() }));
136
+ // eslint-disable-next-line react-hooks/exhaustive-deps
137
+ }, []); // register only once
138
+ return (jsx(FormGroup, { htmlFor: htmlForId, label: label, tip: tip, isInvalid: renderAsInvalid, helpText: errorMessage || helpText, helpAddon: helpAddon || null, dataTestId: dataTestId && `${dataTestId}-FormGroup`, children: jsx(Checkbox, Object.assign({ checked: internalValue, dataTestId: dataTestId, id: htmlForId, disabled: disabled, name: id, onChange: onChangeHandler, isInvalid: renderAsInvalid }, rest)) }));
139
+ };
140
+
141
+ /**
142
+ * A component that can be used to render a date field
143
+ *
144
+ * @param props DateCustomFieldProps - options for the component
145
+ * @returns { JSX.Element } JSX.Element - a component that can be used to render a date field
146
+ */
147
+ const DateCustomField = (props) => {
148
+ const { setValue, defaultValue, register, id, validationRules } = props, rest = __rest(props, ["setValue", "defaultValue", "register", "id", "validationRules"]);
149
+ const onChangeHandler = useCallback((e) => {
150
+ var _a, _b, _c, _d;
151
+ if (((_b = (_a = e.target) === null || _a === void 0 ? void 0 : _a.valueAsDate) === null || _b === void 0 ? void 0 : _b.toISOString()) !== undefined) {
152
+ setValue && setValue(id, (_d = (_c = e.target) === null || _c === void 0 ? void 0 : _c.valueAsDate) === null || _d === void 0 ? void 0 : _d.toISOString());
153
+ }
154
+ }, [setValue, id]);
155
+ useEffect(() => {
156
+ const value = defaultValue && new Date(defaultValue);
157
+ register && register(id, Object.assign(Object.assign({}, validationRules), { value }));
158
+ }, [register, validationRules, defaultValue, id]);
159
+ return (createElement(DateField, Object.assign({}, rest, { key: id, id: id, helpAddon: props.helpAddon || null, helpText: props.errorMessage || props.helpText, onChange: onChangeHandler, label: props.title, defaultValue: defaultValue })));
160
+ };
161
+
162
+ const convertToValueFormat = (value) => {
163
+ return { label: value, value };
164
+ };
165
+ /**
166
+ * A custom field that can be used to render a dropdown
167
+ *
168
+ * @param options DropdownCustomFieldProps - an object with all the props
169
+ * @returns {JSX.Element} - a dropdown component
170
+ */
171
+ const DropdownCustomField = ({ defaultValue, dataTestId, onChange, onBlur, id, disabled = false, allValues, multiSelect = false, register, validationRules, setValue, label, tip, errorMessage, helpText, isInvalid, helpAddon, }) => {
172
+ const renderAsInvalid = isInvalid || Boolean(errorMessage);
173
+ const htmlForId = id ? id : "dropdown-custom-field-" + v4();
174
+ const [selectedValue, setSelectedValue] = React.useState(defaultValue ? defaultValue.map(convertToValueFormat) : []);
175
+ const onChangeHandler = React.useCallback((selected) => {
176
+ if (selected) {
177
+ const values = Array.isArray(selected) ? selected : [selected];
178
+ setSelectedValue(values);
179
+ setValue && setValue(id, values);
180
+ }
181
+ else {
182
+ setSelectedValue([]);
183
+ setValue && setValue(id, []);
184
+ }
185
+ }, [onChange]);
186
+ const options = React.useMemo(() => {
187
+ return allValues ? allValues.map(convertToValueFormat) : [];
188
+ }, [allValues]);
189
+ React.useEffect(() => {
190
+ register && register(id, Object.assign(Object.assign({}, validationRules), { value: selectedValue }));
191
+ }, [register, validationRules, selectedValue, id]);
192
+ return (jsx(FormGroup, { htmlFor: htmlForId, label: label, tip: tip, isInvalid: renderAsInvalid, helpText: errorMessage || helpText, helpAddon: helpAddon || null, dataTestId: dataTestId && `${dataTestId}-FormGroup`, children: jsx(Select, { inputId: htmlForId, "aria-labelledby": htmlForId + "-label", disabled: disabled, dataTestId: dataTestId, onChange: onChangeHandler, hasError: renderAsInvalid, options: options, value: selectedValue, isMulti: multiSelect, isClearable: true }) }));
193
+ };
194
+
195
+ // This file is a workaround for a bug in web browsers' "native"
196
+ // ES6 importing system which is uncapable of importing "*.json" files.
197
+ // https://github.com/catamphetamine/libphonenumber-js/issues/239
198
+ var metadata = {"version":4,"country_calling_codes":{"1":["US","AG","AI","AS","BB","BM","BS","CA","DM","DO","GD","GU","JM","KN","KY","LC","MP","MS","PR","SX","TC","TT","VC","VG","VI"],"7":["RU","KZ"],"20":["EG"],"27":["ZA"],"30":["GR"],"31":["NL"],"32":["BE"],"33":["FR"],"34":["ES"],"36":["HU"],"39":["IT","VA"],"40":["RO"],"41":["CH"],"43":["AT"],"44":["GB","GG","IM","JE"],"45":["DK"],"46":["SE"],"47":["NO","SJ"],"48":["PL"],"49":["DE"],"51":["PE"],"52":["MX"],"53":["CU"],"54":["AR"],"55":["BR"],"56":["CL"],"57":["CO"],"58":["VE"],"60":["MY"],"61":["AU","CC","CX"],"62":["ID"],"63":["PH"],"64":["NZ"],"65":["SG"],"66":["TH"],"81":["JP"],"82":["KR"],"84":["VN"],"86":["CN"],"90":["TR"],"91":["IN"],"92":["PK"],"93":["AF"],"94":["LK"],"95":["MM"],"98":["IR"],"211":["SS"],"212":["MA","EH"],"213":["DZ"],"216":["TN"],"218":["LY"],"220":["GM"],"221":["SN"],"222":["MR"],"223":["ML"],"224":["GN"],"225":["CI"],"226":["BF"],"227":["NE"],"228":["TG"],"229":["BJ"],"230":["MU"],"231":["LR"],"232":["SL"],"233":["GH"],"234":["NG"],"235":["TD"],"236":["CF"],"237":["CM"],"238":["CV"],"239":["ST"],"240":["GQ"],"241":["GA"],"242":["CG"],"243":["CD"],"244":["AO"],"245":["GW"],"246":["IO"],"247":["AC"],"248":["SC"],"249":["SD"],"250":["RW"],"251":["ET"],"252":["SO"],"253":["DJ"],"254":["KE"],"255":["TZ"],"256":["UG"],"257":["BI"],"258":["MZ"],"260":["ZM"],"261":["MG"],"262":["RE","YT"],"263":["ZW"],"264":["NA"],"265":["MW"],"266":["LS"],"267":["BW"],"268":["SZ"],"269":["KM"],"290":["SH","TA"],"291":["ER"],"297":["AW"],"298":["FO"],"299":["GL"],"350":["GI"],"351":["PT"],"352":["LU"],"353":["IE"],"354":["IS"],"355":["AL"],"356":["MT"],"357":["CY"],"358":["FI","AX"],"359":["BG"],"370":["LT"],"371":["LV"],"372":["EE"],"373":["MD"],"374":["AM"],"375":["BY"],"376":["AD"],"377":["MC"],"378":["SM"],"380":["UA"],"381":["RS"],"382":["ME"],"383":["XK"],"385":["HR"],"386":["SI"],"387":["BA"],"389":["MK"],"420":["CZ"],"421":["SK"],"423":["LI"],"500":["FK"],"501":["BZ"],"502":["GT"],"503":["SV"],"504":["HN"],"505":["NI"],"506":["CR"],"507":["PA"],"508":["PM"],"509":["HT"],"590":["GP","BL","MF"],"591":["BO"],"592":["GY"],"593":["EC"],"594":["GF"],"595":["PY"],"596":["MQ"],"597":["SR"],"598":["UY"],"599":["CW","BQ"],"670":["TL"],"672":["NF"],"673":["BN"],"674":["NR"],"675":["PG"],"676":["TO"],"677":["SB"],"678":["VU"],"679":["FJ"],"680":["PW"],"681":["WF"],"682":["CK"],"683":["NU"],"685":["WS"],"686":["KI"],"687":["NC"],"688":["TV"],"689":["PF"],"690":["TK"],"691":["FM"],"692":["MH"],"850":["KP"],"852":["HK"],"853":["MO"],"855":["KH"],"856":["LA"],"880":["BD"],"886":["TW"],"960":["MV"],"961":["LB"],"962":["JO"],"963":["SY"],"964":["IQ"],"965":["KW"],"966":["SA"],"967":["YE"],"968":["OM"],"970":["PS"],"971":["AE"],"972":["IL"],"973":["BH"],"974":["QA"],"975":["BT"],"976":["MN"],"977":["NP"],"992":["TJ"],"993":["TM"],"994":["AZ"],"995":["GE"],"996":["KG"],"998":["UZ"]},"countries":{"AC":["247","00","(?:[01589]\\d|[46])\\d{4}",[5,6]],"AD":["376","00","(?:1|6\\d)\\d{7}|[135-9]\\d{5}",[6,8,9],[["(\\d{3})(\\d{3})","$1 $2",["[135-9]"]],["(\\d{4})(\\d{4})","$1 $2",["1"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["6"]]]],"AE":["971","00","(?:[4-7]\\d|9[0-689])\\d{7}|800\\d{2,9}|[2-4679]\\d{7}",[5,6,7,8,9,10,11,12],[["(\\d{3})(\\d{2,9})","$1 $2",["60|8"]],["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["[236]|[479][2-8]"],"0$1"],["(\\d{3})(\\d)(\\d{5})","$1 $2 $3",["[479]"]],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["5"],"0$1"]],"0"],"AF":["93","00","[2-7]\\d{8}",[9],[["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[2-7]"],"0$1"]],"0"],"AG":["1","011","(?:268|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([457]\\d{6})$|1","268$1",0,"268"],"AI":["1","011","(?:264|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([2457]\\d{6})$|1","264$1",0,"264"],"AL":["355","00","(?:700\\d\\d|900)\\d{3}|8\\d{5,7}|(?:[2-5]|6\\d)\\d{7}",[6,7,8,9],[["(\\d{3})(\\d{3,4})","$1 $2",["80|9"],"0$1"],["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["4[2-6]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[2358][2-5]|4"],"0$1"],["(\\d{3})(\\d{5})","$1 $2",["[23578]"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["6"],"0$1"]],"0"],"AM":["374","00","(?:[1-489]\\d|55|60|77)\\d{6}",[8],[["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["[89]0"],"0 $1"],["(\\d{3})(\\d{5})","$1 $2",["2|3[12]"],"(0$1)"],["(\\d{2})(\\d{6})","$1 $2",["1|47"],"(0$1)"],["(\\d{2})(\\d{6})","$1 $2",["[3-9]"],"0$1"]],"0"],"AO":["244","00","[29]\\d{8}",[9],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[29]"]]]],"AR":["54","00","(?:11|[89]\\d\\d)\\d{8}|[2368]\\d{9}",[10,11],[["(\\d{4})(\\d{2})(\\d{4})","$1 $2-$3",["2(?:2[024-9]|3[0-59]|47|6[245]|9[02-8])|3(?:3[28]|4[03-9]|5[2-46-8]|7[1-578]|8[2-9])","2(?:[23]02|6(?:[25]|4[6-8])|9(?:[02356]|4[02568]|72|8[23]))|3(?:3[28]|4(?:[04679]|3[5-8]|5[4-68]|8[2379])|5(?:[2467]|3[237]|8[2-5])|7[1-578]|8(?:[2469]|3[2578]|5[4-8]|7[36-8]|8[5-8]))|2(?:2[24-9]|3[1-59]|47)","2(?:[23]02|6(?:[25]|4(?:64|[78]))|9(?:[02356]|4(?:[0268]|5[2-6])|72|8[23]))|3(?:3[28]|4(?:[04679]|3[78]|5(?:4[46]|8)|8[2379])|5(?:[2467]|3[237]|8[23])|7[1-578]|8(?:[2469]|3[278]|5[56][46]|86[3-6]))|2(?:2[24-9]|3[1-59]|47)|38(?:[58][78]|7[378])|3(?:4[35][56]|58[45]|8(?:[38]5|54|76))[4-6]","2(?:[23]02|6(?:[25]|4(?:64|[78]))|9(?:[02356]|4(?:[0268]|5[2-6])|72|8[23]))|3(?:3[28]|4(?:[04679]|3(?:5(?:4[0-25689]|[56])|[78])|58|8[2379])|5(?:[2467]|3[237]|8(?:[23]|4(?:[45]|60)|5(?:4[0-39]|5|64)))|7[1-578]|8(?:[2469]|3[278]|54(?:4|5[13-7]|6[89])|86[3-6]))|2(?:2[24-9]|3[1-59]|47)|38(?:[58][78]|7[378])|3(?:454|85[56])[46]|3(?:4(?:36|5[56])|8(?:[38]5|76))[4-6]"],"0$1",1],["(\\d{2})(\\d{4})(\\d{4})","$1 $2-$3",["1"],"0$1",1],["(\\d{3})(\\d{3})(\\d{4})","$1-$2-$3",["[68]"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2-$3",["[23]"],"0$1",1],["(\\d)(\\d{4})(\\d{2})(\\d{4})","$2 15-$3-$4",["9(?:2[2-469]|3[3-578])","9(?:2(?:2[024-9]|3[0-59]|47|6[245]|9[02-8])|3(?:3[28]|4[03-9]|5[2-46-8]|7[1-578]|8[2-9]))","9(?:2(?:[23]02|6(?:[25]|4[6-8])|9(?:[02356]|4[02568]|72|8[23]))|3(?:3[28]|4(?:[04679]|3[5-8]|5[4-68]|8[2379])|5(?:[2467]|3[237]|8[2-5])|7[1-578]|8(?:[2469]|3[2578]|5[4-8]|7[36-8]|8[5-8])))|92(?:2[24-9]|3[1-59]|47)","9(?:2(?:[23]02|6(?:[25]|4(?:64|[78]))|9(?:[02356]|4(?:[0268]|5[2-6])|72|8[23]))|3(?:3[28]|4(?:[04679]|3[78]|5(?:4[46]|8)|8[2379])|5(?:[2467]|3[237]|8[23])|7[1-578]|8(?:[2469]|3[278]|5(?:[56][46]|[78])|7[378]|8(?:6[3-6]|[78]))))|92(?:2[24-9]|3[1-59]|47)|93(?:4[35][56]|58[45]|8(?:[38]5|54|76))[4-6]","9(?:2(?:[23]02|6(?:[25]|4(?:64|[78]))|9(?:[02356]|4(?:[0268]|5[2-6])|72|8[23]))|3(?:3[28]|4(?:[04679]|3(?:5(?:4[0-25689]|[56])|[78])|5(?:4[46]|8)|8[2379])|5(?:[2467]|3[237]|8(?:[23]|4(?:[45]|60)|5(?:4[0-39]|5|64)))|7[1-578]|8(?:[2469]|3[278]|5(?:4(?:4|5[13-7]|6[89])|[56][46]|[78])|7[378]|8(?:6[3-6]|[78]))))|92(?:2[24-9]|3[1-59]|47)|93(?:4(?:36|5[56])|8(?:[38]5|76))[4-6]"],"0$1",0,"$1 $2 $3-$4"],["(\\d)(\\d{2})(\\d{4})(\\d{4})","$2 15-$3-$4",["91"],"0$1",0,"$1 $2 $3-$4"],["(\\d{3})(\\d{3})(\\d{5})","$1-$2-$3",["8"],"0$1"],["(\\d)(\\d{3})(\\d{3})(\\d{4})","$2 15-$3-$4",["9"],"0$1",0,"$1 $2 $3-$4"]],"0",0,"0?(?:(11|2(?:2(?:02?|[13]|2[13-79]|4[1-6]|5[2457]|6[124-8]|7[1-4]|8[13-6]|9[1267])|3(?:02?|1[467]|2[03-6]|3[13-8]|[49][2-6]|5[2-8]|[67])|4(?:7[3-578]|9)|6(?:[0136]|2[24-6]|4[6-8]?|5[15-8])|80|9(?:0[1-3]|[19]|2\\d|3[1-6]|4[02568]?|5[2-4]|6[2-46]|72?|8[23]?))|3(?:3(?:2[79]|6|8[2578])|4(?:0[0-24-9]|[12]|3[5-8]?|4[24-7]|5[4-68]?|6[02-9]|7[126]|8[2379]?|9[1-36-8])|5(?:1|2[1245]|3[237]?|4[1-46-9]|6[2-4]|7[1-6]|8[2-5]?)|6[24]|7(?:[069]|1[1568]|2[15]|3[145]|4[13]|5[14-8]|7[2-57]|8[126])|8(?:[01]|2[15-7]|3[2578]?|4[13-6]|5[4-8]?|6[1-357-9]|7[36-8]?|8[5-8]?|9[124])))15)?","9$1"],"AS":["1","011","(?:[58]\\d\\d|684|900)\\d{7}",[10],0,"1",0,"([267]\\d{6})$|1","684$1",0,"684"],"AT":["43","00","1\\d{3,12}|2\\d{6,12}|43(?:(?:0\\d|5[02-9])\\d{3,9}|2\\d{4,5}|[3467]\\d{4}|8\\d{4,6}|9\\d{4,7})|5\\d{4,12}|8\\d{7,12}|9\\d{8,12}|(?:[367]\\d|4[0-24-9])\\d{4,11}",[4,5,6,7,8,9,10,11,12,13],[["(\\d)(\\d{3,12})","$1 $2",["1(?:11|[2-9])"],"0$1"],["(\\d{3})(\\d{2})","$1 $2",["517"],"0$1"],["(\\d{2})(\\d{3,5})","$1 $2",["5[079]"],"0$1"],["(\\d{3})(\\d{3,10})","$1 $2",["(?:31|4)6|51|6(?:5[0-3579]|[6-9])|7(?:20|32|8)|[89]"],"0$1"],["(\\d{4})(\\d{3,9})","$1 $2",["[2-467]|5[2-6]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["5"],"0$1"],["(\\d{2})(\\d{4})(\\d{4,7})","$1 $2 $3",["5"],"0$1"]],"0"],"AU":["61","001[14-689]|14(?:1[14]|34|4[17]|[56]6|7[47]|88)0011","1(?:[0-79]\\d{7}(?:\\d(?:\\d{2})?)?|8[0-24-9]\\d{7})|[2-478]\\d{8}|1\\d{4,7}",[5,6,7,8,9,10,12],[["(\\d{2})(\\d{3,4})","$1 $2",["16"],"0$1"],["(\\d{2})(\\d{3})(\\d{2,4})","$1 $2 $3",["16"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["14|4"],"0$1"],["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["[2378]"],"(0$1)"],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["1(?:30|[89])"]]],"0",0,"(183[12])|0",0,0,0,[["(?:(?:2(?:[0-26-9]\\d|3[0-8]|4[02-9]|5[0135-9])|3(?:[0-3589]\\d|4[0-578]|6[1-9]|7[0-35-9])|7(?:[013-57-9]\\d|2[0-8]))\\d{3}|8(?:51(?:0(?:0[03-9]|[12479]\\d|3[2-9]|5[0-8]|6[1-9]|8[0-7])|1(?:[0235689]\\d|1[0-69]|4[0-589]|7[0-47-9])|2(?:0[0-79]|[18][13579]|2[14-9]|3[0-46-9]|[4-6]\\d|7[89]|9[0-4]))|(?:6[0-8]|[78]\\d)\\d{3}|9(?:[02-9]\\d{3}|1(?:(?:[0-58]\\d|6[0135-9])\\d|7(?:0[0-24-9]|[1-9]\\d)|9(?:[0-46-9]\\d|5[0-79])))))\\d{3}",[9]],["4(?:(?:79|94)[01]|83[0-389])\\d{5}|4(?:[0-3]\\d|4[047-9]|5[0-25-9]|6[016-9]|7[02-8]|8[0-24-9]|9[0-37-9])\\d{6}",[9]],["180(?:0\\d{3}|2)\\d{3}",[7,10]],["190[0-26]\\d{6}",[10]],0,0,0,["163\\d{2,6}",[5,6,7,8,9]],["14(?:5(?:1[0458]|[23][458])|71\\d)\\d{4}",[9]],["13(?:00\\d{6}(?:\\d{2})?|45[0-4]\\d{3})|13\\d{4}",[6,8,10,12]]],"0011"],"AW":["297","00","(?:[25-79]\\d\\d|800)\\d{4}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[25-9]"]]]],"AX":["358","00|99(?:[01469]|5(?:[14]1|3[23]|5[59]|77|88|9[09]))","2\\d{4,9}|35\\d{4,5}|(?:60\\d\\d|800)\\d{4,6}|7\\d{5,11}|(?:[14]\\d|3[0-46-9]|50)\\d{4,8}",[5,6,7,8,9,10,11,12],0,"0",0,0,0,0,"18",0,"00"],"AZ":["994","00","365\\d{6}|(?:[124579]\\d|60|88)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["90"],"0$1"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["1[28]|2|365|46","1[28]|2|365[45]|46","1[28]|2|365(?:4|5[02])|46"],"(0$1)"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[13-9]"],"0$1"]],"0"],"BA":["387","00","6\\d{8}|(?:[35689]\\d|49|70)\\d{6}",[8,9],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["6[1-3]|[7-9]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2-$3",["[3-5]|6[56]"],"0$1"],["(\\d{2})(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3 $4",["6"],"0$1"]],"0"],"BB":["1","011","(?:246|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([2-9]\\d{6})$|1","246$1",0,"246"],"BD":["880","00","[1-469]\\d{9}|8[0-79]\\d{7,8}|[2-79]\\d{8}|[2-9]\\d{7}|[3-9]\\d{6}|[57-9]\\d{5}",[6,7,8,9,10],[["(\\d{2})(\\d{4,6})","$1-$2",["31[5-8]|[459]1"],"0$1"],["(\\d{3})(\\d{3,7})","$1-$2",["3(?:[67]|8[013-9])|4(?:6[168]|7|[89][18])|5(?:6[128]|9)|6(?:[15]|28|4[14])|7[2-589]|8(?:0[014-9]|[12])|9[358]|(?:3[2-5]|4[235]|5[2-578]|6[0389]|76|8[3-7]|9[24])1|(?:44|66)[01346-9]"],"0$1"],["(\\d{4})(\\d{3,6})","$1-$2",["[13-9]|22"],"0$1"],["(\\d)(\\d{7,8})","$1-$2",["2"],"0$1"]],"0"],"BE":["32","00","4\\d{8}|[1-9]\\d{7}",[8,9],[["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["(?:80|9)0"],"0$1"],["(\\d)(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[239]|4[23]"],"0$1"],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[15-8]"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["4"],"0$1"]],"0"],"BF":["226","00","[025-7]\\d{7}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[025-7]"]]]],"BG":["359","00","00800\\d{7}|[2-7]\\d{6,7}|[89]\\d{6,8}|2\\d{5}",[6,7,8,9,12],[["(\\d)(\\d)(\\d{2})(\\d{2})","$1 $2 $3 $4",["2"],"0$1"],["(\\d{3})(\\d{4})","$1 $2",["43[1-6]|70[1-9]"],"0$1"],["(\\d)(\\d{3})(\\d{3,4})","$1 $2 $3",["2"],"0$1"],["(\\d{2})(\\d{3})(\\d{2,3})","$1 $2 $3",["[356]|4[124-7]|7[1-9]|8[1-6]|9[1-7]"],"0$1"],["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["(?:70|8)0"],"0$1"],["(\\d{3})(\\d{3})(\\d{2})","$1 $2 $3",["43[1-7]|7"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[48]|9[08]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["9"],"0$1"]],"0"],"BH":["973","00","[136-9]\\d{7}",[8],[["(\\d{4})(\\d{4})","$1 $2",["[13679]|8[047]"]]]],"BI":["257","00","(?:[267]\\d|31)\\d{6}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[2367]"]]]],"BJ":["229","00","[24-689]\\d{7}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[24-689]"]]]],"BL":["590","00","590\\d{6}|(?:69|80|9\\d)\\d{7}",[9],0,"0",0,0,0,0,0,[["590(?:2[7-9]|5[12]|87)\\d{4}"],["69(?:0\\d\\d|1(?:2[2-9]|3[0-5]))\\d{4}"],["80[0-5]\\d{6}"],0,0,0,0,0,["9(?:(?:395|76[018])\\d|475[0-2])\\d{4}"]]],"BM":["1","011","(?:441|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([2-9]\\d{6})$|1","441$1",0,"441"],"BN":["673","00","[2-578]\\d{6}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[2-578]"]]]],"BO":["591","00(?:1\\d)?","(?:[2-467]\\d\\d|8001)\\d{5}",[8,9],[["(\\d)(\\d{7})","$1 $2",["[23]|4[46]"]],["(\\d{8})","$1",["[67]"]],["(\\d{3})(\\d{2})(\\d{4})","$1 $2 $3",["8"]]],"0",0,"0(1\\d)?"],"BQ":["599","00","(?:[34]1|7\\d)\\d{5}",[7],0,0,0,0,0,0,"[347]"],"BR":["55","00(?:1[245]|2[1-35]|31|4[13]|[56]5|99)","(?:[1-46-9]\\d\\d|5(?:[0-46-9]\\d|5[0-46-9]))\\d{8}|[1-9]\\d{9}|[3589]\\d{8}|[34]\\d{7}",[8,9,10,11],[["(\\d{4})(\\d{4})","$1-$2",["300|4(?:0[02]|37)","4(?:02|37)0|[34]00"]],["(\\d{3})(\\d{2,3})(\\d{4})","$1 $2 $3",["(?:[358]|90)0"],"0$1"],["(\\d{2})(\\d{4})(\\d{4})","$1 $2-$3",["(?:[14689][1-9]|2[12478]|3[1-578]|5[13-5]|7[13-579])[2-57]"],"($1)"],["(\\d{2})(\\d{5})(\\d{4})","$1 $2-$3",["[16][1-9]|[2-57-9]"],"($1)"]],"0",0,"(?:0|90)(?:(1[245]|2[1-35]|31|4[13]|[56]5|99)(\\d{10,11}))?","$2"],"BS":["1","011","(?:242|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([3-8]\\d{6})$|1","242$1",0,"242"],"BT":["975","00","[17]\\d{7}|[2-8]\\d{6}",[7,8],[["(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["[2-68]|7[246]"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["1[67]|7"]]]],"BW":["267","00","(?:0800|(?:[37]|800)\\d)\\d{6}|(?:[2-6]\\d|90)\\d{5}",[7,8,10],[["(\\d{2})(\\d{5})","$1 $2",["90"]],["(\\d{3})(\\d{4})","$1 $2",["[24-6]|3[15-79]"]],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[37]"]],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["0"]],["(\\d{3})(\\d{4})(\\d{3})","$1 $2 $3",["8"]]]],"BY":["375","810","(?:[12]\\d|33|44|902)\\d{7}|8(?:0[0-79]\\d{5,7}|[1-7]\\d{9})|8(?:1[0-489]|[5-79]\\d)\\d{7}|8[1-79]\\d{6,7}|8[0-79]\\d{5}|8\\d{5}",[6,7,8,9,10,11],[["(\\d{3})(\\d{3})","$1 $2",["800"],"8 $1"],["(\\d{3})(\\d{2})(\\d{2,4})","$1 $2 $3",["800"],"8 $1"],["(\\d{4})(\\d{2})(\\d{3})","$1 $2-$3",["1(?:5[169]|6[3-5]|7[179])|2(?:1[35]|2[34]|3[3-5])","1(?:5[169]|6(?:3[1-3]|4|5[125])|7(?:1[3-9]|7[0-24-6]|9[2-7]))|2(?:1[35]|2[34]|3[3-5])"],"8 0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2-$3-$4",["1(?:[56]|7[467])|2[1-3]"],"8 0$1"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2-$3-$4",["[1-4]"],"8 0$1"],["(\\d{3})(\\d{3,4})(\\d{4})","$1 $2 $3",["[89]"],"8 $1"]],"8",0,"0|80?",0,0,0,0,"8~10"],"BZ":["501","00","(?:0800\\d|[2-8])\\d{6}",[7,11],[["(\\d{3})(\\d{4})","$1-$2",["[2-8]"]],["(\\d)(\\d{3})(\\d{4})(\\d{3})","$1-$2-$3-$4",["0"]]]],"CA":["1","011","(?:[2-8]\\d|90)\\d{8}|3\\d{6}",[7,10],0,"1",0,0,0,0,0,[["(?:2(?:04|[23]6|[48]9|50|63)|3(?:06|43|54|6[578]|82)|4(?:03|1[68]|[26]8|3[178]|50|74)|5(?:06|1[49]|48|79|8[147])|6(?:04|[18]3|39|47|72)|7(?:0[59]|42|53|78|8[02])|8(?:[06]7|19|25|73)|90[25])[2-9]\\d{6}",[10]],["",[10]],["8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",[10]],["900[2-9]\\d{6}",[10]],["52(?:3(?:[2-46-9][02-9]\\d|5(?:[02-46-9]\\d|5[0-46-9]))|4(?:[2-478][02-9]\\d|5(?:[034]\\d|2[024-9]|5[0-46-9])|6(?:0[1-9]|[2-9]\\d)|9(?:[05-9]\\d|2[0-5]|49)))\\d{4}|52[34][2-9]1[02-9]\\d{4}|(?:5(?:00|2[125-9]|33|44|66|77|88)|622)[2-9]\\d{6}",[10]],0,["310\\d{4}",[7]],0,["600[2-9]\\d{6}",[10]]]],"CC":["61","001[14-689]|14(?:1[14]|34|4[17]|[56]6|7[47]|88)0011","1(?:[0-79]\\d{8}(?:\\d{2})?|8[0-24-9]\\d{7})|[148]\\d{8}|1\\d{5,7}",[6,7,8,9,10,12],0,"0",0,"([59]\\d{7})$|0","8$1",0,0,[["8(?:51(?:0(?:02|31|60|89)|1(?:18|76)|223)|91(?:0(?:1[0-2]|29)|1(?:[28]2|50|79)|2(?:10|64)|3(?:[06]8|22)|4[29]8|62\\d|70[23]|959))\\d{3}",[9]],["4(?:(?:79|94)[01]|83[0-389])\\d{5}|4(?:[0-3]\\d|4[047-9]|5[0-25-9]|6[016-9]|7[02-8]|8[0-24-9]|9[0-37-9])\\d{6}",[9]],["180(?:0\\d{3}|2)\\d{3}",[7,10]],["190[0-26]\\d{6}",[10]],0,0,0,0,["14(?:5(?:1[0458]|[23][458])|71\\d)\\d{4}",[9]],["13(?:00\\d{6}(?:\\d{2})?|45[0-4]\\d{3})|13\\d{4}",[6,8,10,12]]],"0011"],"CD":["243","00","[189]\\d{8}|[1-68]\\d{6}",[7,9],[["(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3",["88"],"0$1"],["(\\d{2})(\\d{5})","$1 $2",["[1-6]"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["1"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[89]"],"0$1"]],"0"],"CF":["236","00","(?:[27]\\d{3}|8776)\\d{4}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[278]"]]]],"CG":["242","00","222\\d{6}|(?:0\\d|80)\\d{7}",[9],[["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["8"]],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[02]"]]]],"CH":["41","00","8\\d{11}|[2-9]\\d{8}",[9],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["8[047]|90"],"0$1"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[2-79]|81"],"0$1"],["(\\d{3})(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4 $5",["8"],"0$1"]],"0"],"CI":["225","00","[02]\\d{9}",[10],[["(\\d{2})(\\d{2})(\\d)(\\d{5})","$1 $2 $3 $4",["2"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{4})","$1 $2 $3 $4",["0"]]]],"CK":["682","00","[2-578]\\d{4}",[5],[["(\\d{2})(\\d{3})","$1 $2",["[2-578]"]]]],"CL":["56","(?:0|1(?:1[0-69]|2[02-5]|5[13-58]|69|7[0167]|8[018]))0","12300\\d{6}|6\\d{9,10}|[2-9]\\d{8}",[9,10,11],[["(\\d{5})(\\d{4})","$1 $2",["219","2196"],"($1)"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["44"]],["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["2[1-36]"],"($1)"],["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["9[2-9]"]],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["3[2-5]|[47]|5[1-3578]|6[13-57]|8(?:0[1-9]|[1-9])"],"($1)"],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["60|8"]],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["1"]],["(\\d{3})(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3 $4",["60"]]]],"CM":["237","00","[26]\\d{8}|88\\d{6,7}",[8,9],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["88"]],["(\\d)(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4 $5",["[26]|88"]]]],"CN":["86","00|1(?:[12]\\d|79)\\d\\d00","1[127]\\d{8,9}|2\\d{9}(?:\\d{2})?|[12]\\d{6,7}|86\\d{6}|(?:1[03-689]\\d|6)\\d{7,9}|(?:[3-579]\\d|8[0-57-9])\\d{6,9}",[7,8,9,10,11,12],[["(\\d{2})(\\d{5,6})","$1 $2",["(?:10|2[0-57-9])[19]","(?:10|2[0-57-9])(?:10|9[56])","10(?:10|9[56])|2[0-57-9](?:100|9[56])"],"0$1"],["(\\d{3})(\\d{5,6})","$1 $2",["3(?:[157]|35|49|9[1-68])|4(?:[17]|2[179]|6[47-9]|8[23])|5(?:[1357]|2[37]|4[36]|6[1-46]|80)|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|[379]|4[13]|5[1-5])|(?:4[35]|59|85)[1-9]","(?:3(?:[157]\\d|35|49|9[1-68])|4(?:[17]\\d|2[179]|[35][1-9]|6[47-9]|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]\\d|5[1-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|[379]\\d|4[13]|5[1-5]))[19]","85[23](?:10|95)|(?:3(?:[157]\\d|35|49|9[1-68])|4(?:[17]\\d|2[179]|[35][1-9]|6[47-9]|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]\\d|5[14-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|[379]\\d|4[13]|5[1-5]))(?:10|9[56])","85[23](?:100|95)|(?:3(?:[157]\\d|35|49|9[1-68])|4(?:[17]\\d|2[179]|[35][1-9]|6[47-9]|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]\\d|5[14-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|[379]\\d|4[13]|5[1-5]))(?:100|9[56])"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["(?:4|80)0"]],["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["10|2(?:[02-57-9]|1[1-9])","10|2(?:[02-57-9]|1[1-9])","10[0-79]|2(?:[02-57-9]|1[1-79])|(?:10|21)8(?:0[1-9]|[1-9])"],"0$1",1],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["3(?:[3-59]|7[02-68])|4(?:[26-8]|3[3-9]|5[2-9])|5(?:3[03-9]|[468]|7[028]|9[2-46-9])|6|7(?:[0-247]|3[04-9]|5[0-4689]|6[2368])|8(?:[1-358]|9[1-7])|9(?:[013479]|5[1-5])|(?:[34]1|55|79|87)[02-9]"],"0$1",1],["(\\d{3})(\\d{7,8})","$1 $2",["9"]],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["80"],"0$1",1],["(\\d{3})(\\d{4})(\\d{4})","$1 $2 $3",["[3-578]"],"0$1",1],["(\\d{3})(\\d{4})(\\d{4})","$1 $2 $3",["1[3-9]"]],["(\\d{2})(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3 $4",["[12]"],"0$1",1]],"0",0,"(1(?:[12]\\d|79)\\d\\d)|0",0,0,0,0,"00"],"CO":["57","00(?:4(?:[14]4|56)|[579])","(?:60\\d\\d|9101)\\d{6}|(?:1\\d|3)\\d{9}",[10,11],[["(\\d{3})(\\d{7})","$1 $2",["6"],"($1)"],["(\\d{3})(\\d{7})","$1 $2",["3[0-357]|91"]],["(\\d)(\\d{3})(\\d{7})","$1-$2-$3",["1"],"0$1",0,"$1 $2 $3"]],"0",0,"0(4(?:[14]4|56)|[579])?"],"CR":["506","00","(?:8\\d|90)\\d{8}|(?:[24-8]\\d{3}|3005)\\d{4}",[8,10],[["(\\d{4})(\\d{4})","$1 $2",["[2-7]|8[3-9]"]],["(\\d{3})(\\d{3})(\\d{4})","$1-$2-$3",["[89]"]]],0,0,"(19(?:0[0-2468]|1[09]|20|66|77|99))"],"CU":["53","119","[27]\\d{6,7}|[34]\\d{5,7}|(?:5|8\\d\\d)\\d{7}",[6,7,8,10],[["(\\d{2})(\\d{4,6})","$1 $2",["2[1-4]|[34]"],"(0$1)"],["(\\d)(\\d{6,7})","$1 $2",["7"],"(0$1)"],["(\\d)(\\d{7})","$1 $2",["5"],"0$1"],["(\\d{3})(\\d{7})","$1 $2",["8"],"0$1"]],"0"],"CV":["238","0","(?:[2-59]\\d\\d|800)\\d{4}",[7],[["(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3",["[2-589]"]]]],"CW":["599","00","(?:[34]1|60|(?:7|9\\d)\\d)\\d{5}",[7,8],[["(\\d{3})(\\d{4})","$1 $2",["[3467]"]],["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["9[4-8]"]]],0,0,0,0,0,"[69]"],"CX":["61","001[14-689]|14(?:1[14]|34|4[17]|[56]6|7[47]|88)0011","1(?:[0-79]\\d{8}(?:\\d{2})?|8[0-24-9]\\d{7})|[148]\\d{8}|1\\d{5,7}",[6,7,8,9,10,12],0,"0",0,"([59]\\d{7})$|0","8$1",0,0,[["8(?:51(?:0(?:01|30|59|88)|1(?:17|46|75)|2(?:22|35))|91(?:00[6-9]|1(?:[28]1|49|78)|2(?:09|63)|3(?:12|26|75)|4(?:56|97)|64\\d|7(?:0[01]|1[0-2])|958))\\d{3}",[9]],["4(?:(?:79|94)[01]|83[0-389])\\d{5}|4(?:[0-3]\\d|4[047-9]|5[0-25-9]|6[016-9]|7[02-8]|8[0-24-9]|9[0-37-9])\\d{6}",[9]],["180(?:0\\d{3}|2)\\d{3}",[7,10]],["190[0-26]\\d{6}",[10]],0,0,0,0,["14(?:5(?:1[0458]|[23][458])|71\\d)\\d{4}",[9]],["13(?:00\\d{6}(?:\\d{2})?|45[0-4]\\d{3})|13\\d{4}",[6,8,10,12]]],"0011"],"CY":["357","00","(?:[279]\\d|[58]0)\\d{6}",[8],[["(\\d{2})(\\d{6})","$1 $2",["[257-9]"]]]],"CZ":["420","00","(?:[2-578]\\d|60)\\d{7}|9\\d{8,11}",[9],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[2-8]|9[015-7]"]],["(\\d{2})(\\d{3})(\\d{3})(\\d{2})","$1 $2 $3 $4",["96"]],["(\\d{2})(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["9"]],["(\\d{3})(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["9"]]]],"DE":["49","00","[2579]\\d{5,14}|49(?:[34]0|69|8\\d)\\d\\d?|49(?:37|49|60|7[089]|9\\d)\\d{1,3}|49(?:2[024-9]|3[2-689]|7[1-7])\\d{1,8}|(?:1|[368]\\d|4[0-8])\\d{3,13}|49(?:[015]\\d|2[13]|31|[46][1-8])\\d{1,9}",[4,5,6,7,8,9,10,11,12,13,14,15],[["(\\d{2})(\\d{3,13})","$1 $2",["3[02]|40|[68]9"],"0$1"],["(\\d{3})(\\d{3,12})","$1 $2",["2(?:0[1-389]|1[124]|2[18]|3[14])|3(?:[35-9][15]|4[015])|906|(?:2[4-9]|4[2-9]|[579][1-9]|[68][1-8])1","2(?:0[1-389]|12[0-8])|3(?:[35-9][15]|4[015])|906|2(?:[13][14]|2[18])|(?:2[4-9]|4[2-9]|[579][1-9]|[68][1-8])1"],"0$1"],["(\\d{4})(\\d{2,11})","$1 $2",["[24-6]|3(?:[3569][02-46-9]|4[2-4679]|7[2-467]|8[2-46-8])|70[2-8]|8(?:0[2-9]|[1-8])|90[7-9]|[79][1-9]","[24-6]|3(?:3(?:0[1-467]|2[127-9]|3[124578]|7[1257-9]|8[1256]|9[145])|4(?:2[135]|4[13578]|9[1346])|5(?:0[14]|2[1-3589]|6[1-4]|7[13468]|8[13568])|6(?:2[1-489]|3[124-6]|6[13]|7[12579]|8[1-356]|9[135])|7(?:2[1-7]|4[145]|6[1-5]|7[1-4])|8(?:21|3[1468]|6|7[1467]|8[136])|9(?:0[12479]|2[1358]|4[134679]|6[1-9]|7[136]|8[147]|9[1468]))|70[2-8]|8(?:0[2-9]|[1-8])|90[7-9]|[79][1-9]|3[68]4[1347]|3(?:47|60)[1356]|3(?:3[46]|46|5[49])[1246]|3[4579]3[1357]"],"0$1"],["(\\d{3})(\\d{4})","$1 $2",["138"],"0$1"],["(\\d{5})(\\d{2,10})","$1 $2",["3"],"0$1"],["(\\d{3})(\\d{5,11})","$1 $2",["181"],"0$1"],["(\\d{3})(\\d)(\\d{4,10})","$1 $2 $3",["1(?:3|80)|9"],"0$1"],["(\\d{3})(\\d{7,8})","$1 $2",["1[67]"],"0$1"],["(\\d{3})(\\d{7,12})","$1 $2",["8"],"0$1"],["(\\d{5})(\\d{6})","$1 $2",["185","1850","18500"],"0$1"],["(\\d{3})(\\d{4})(\\d{4})","$1 $2 $3",["7"],"0$1"],["(\\d{4})(\\d{7})","$1 $2",["18[68]"],"0$1"],["(\\d{5})(\\d{6})","$1 $2",["15[0568]"],"0$1"],["(\\d{4})(\\d{7})","$1 $2",["15[1279]"],"0$1"],["(\\d{3})(\\d{8})","$1 $2",["18"],"0$1"],["(\\d{3})(\\d{2})(\\d{7,8})","$1 $2 $3",["1(?:6[023]|7)"],"0$1"],["(\\d{4})(\\d{2})(\\d{7})","$1 $2 $3",["15[279]"],"0$1"],["(\\d{3})(\\d{2})(\\d{8})","$1 $2 $3",["15"],"0$1"]],"0"],"DJ":["253","00","(?:2\\d|77)\\d{6}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[27]"]]]],"DK":["45","00","[2-9]\\d{7}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[2-9]"]]]],"DM":["1","011","(?:[58]\\d\\d|767|900)\\d{7}",[10],0,"1",0,"([2-7]\\d{6})$|1","767$1",0,"767"],"DO":["1","011","(?:[58]\\d\\d|900)\\d{7}",[10],0,"1",0,0,0,0,"8001|8[024]9"],"DZ":["213","00","(?:[1-4]|[5-79]\\d|80)\\d{7}",[8,9],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[1-4]"],"0$1"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["9"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[5-8]"],"0$1"]],"0"],"EC":["593","00","1\\d{9,10}|(?:[2-7]|9\\d)\\d{7}",[8,9,10,11],[["(\\d)(\\d{3})(\\d{4})","$1 $2-$3",["[2-7]"],"(0$1)",0,"$1-$2-$3"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["9"],"0$1"],["(\\d{4})(\\d{3})(\\d{3,4})","$1 $2 $3",["1"]]],"0"],"EE":["372","00","8\\d{9}|[4578]\\d{7}|(?:[3-8]\\d|90)\\d{5}",[7,8,10],[["(\\d{3})(\\d{4})","$1 $2",["[369]|4[3-8]|5(?:[0-2]|5[0-478]|6[45])|7[1-9]|88","[369]|4[3-8]|5(?:[02]|1(?:[0-8]|95)|5[0-478]|6(?:4[0-4]|5[1-589]))|7[1-9]|88"]],["(\\d{4})(\\d{3,4})","$1 $2",["[45]|8(?:00|[1-49])","[45]|8(?:00[1-9]|[1-49])"]],["(\\d{2})(\\d{2})(\\d{4})","$1 $2 $3",["7"]],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["8"]]]],"EG":["20","00","[189]\\d{8,9}|[24-6]\\d{8}|[135]\\d{7}",[8,9,10],[["(\\d)(\\d{7,8})","$1 $2",["[23]"],"0$1"],["(\\d{2})(\\d{6,7})","$1 $2",["1[35]|[4-6]|8[2468]|9[235-7]"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["[189]"],"0$1"]],"0"],"EH":["212","00","[5-8]\\d{8}",[9],0,"0",0,0,0,0,"528[89]"],"ER":["291","00","[178]\\d{6}",[7],[["(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["[178]"],"0$1"]],"0"],"ES":["34","00","[5-9]\\d{8}",[9],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[89]00"]],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[5-9]"]]]],"ET":["251","00","(?:11|[2-579]\\d)\\d{7}",[9],[["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[1-579]"],"0$1"]],"0"],"FI":["358","00|99(?:[01469]|5(?:[14]1|3[23]|5[59]|77|88|9[09]))","[1-35689]\\d{4}|7\\d{10,11}|(?:[124-7]\\d|3[0-46-9])\\d{8}|[1-9]\\d{5,8}",[5,6,7,8,9,10,11,12],[["(\\d)(\\d{4,9})","$1 $2",["[2568][1-8]|3(?:0[1-9]|[1-9])|9"],"0$1"],["(\\d{3})(\\d{3,7})","$1 $2",["[12]00|[368]|70[07-9]"],"0$1"],["(\\d{2})(\\d{4,8})","$1 $2",["[1245]|7[135]"],"0$1"],["(\\d{2})(\\d{6,10})","$1 $2",["7"],"0$1"]],"0",0,0,0,0,"1[03-79]|[2-9]",0,"00"],"FJ":["679","0(?:0|52)","45\\d{5}|(?:0800\\d|[235-9])\\d{6}",[7,11],[["(\\d{3})(\\d{4})","$1 $2",["[235-9]|45"]],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["0"]]],0,0,0,0,0,0,0,"00"],"FK":["500","00","[2-7]\\d{4}",[5]],"FM":["691","00","(?:[39]\\d\\d|820)\\d{4}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[389]"]]]],"FO":["298","00","[2-9]\\d{5}",[6],[["(\\d{6})","$1",["[2-9]"]]],0,0,"(10(?:01|[12]0|88))"],"FR":["33","00","[1-9]\\d{8}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"],"0 $1"],["(\\d)(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4 $5",["[1-79]"],"0$1"]],"0"],"GA":["241","00","(?:[067]\\d|11)\\d{6}|[2-7]\\d{6}",[7,8],[["(\\d)(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[2-7]"],"0$1"],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["0"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["11|[67]"],"0$1"]],0,0,"0(11\\d{6}|60\\d{6}|61\\d{6}|6[256]\\d{6}|7[467]\\d{6})","$1"],"GB":["44","00","[1-357-9]\\d{9}|[18]\\d{8}|8\\d{6}",[7,9,10],[["(\\d{3})(\\d{4})","$1 $2",["800","8001","80011","800111","8001111"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3",["845","8454","84546","845464"],"0$1"],["(\\d{3})(\\d{6})","$1 $2",["800"],"0$1"],["(\\d{5})(\\d{4,5})","$1 $2",["1(?:38|5[23]|69|76|94)","1(?:(?:38|69)7|5(?:24|39)|768|946)","1(?:3873|5(?:242|39[4-6])|(?:697|768)[347]|9467)"],"0$1"],["(\\d{4})(\\d{5,6})","$1 $2",["1(?:[2-69][02-9]|[78])"],"0$1"],["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["[25]|7(?:0|6[02-9])","[25]|7(?:0|6(?:[03-9]|2[356]))"],"0$1"],["(\\d{4})(\\d{6})","$1 $2",["7"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["[1389]"],"0$1"]],"0",0,0,0,0,0,[["(?:1(?:1(?:3(?:[0-58]\\d\\d|73[0235])|4(?:[0-5]\\d\\d|69[7-9]|70[0-579])|(?:(?:5[0-26-9]|[78][0-49])\\d|6(?:[0-4]\\d|50))\\d)|(?:2(?:(?:0[024-9]|2[3-9]|3[3-79]|4[1-689]|[58][02-9]|6[0-47-9]|7[013-9]|9\\d)\\d|1(?:[0-7]\\d|8[0-2]))|(?:3(?:0\\d|1[0-8]|[25][02-9]|3[02-579]|[468][0-46-9]|7[1-35-79]|9[2-578])|4(?:0[03-9]|[137]\\d|[28][02-57-9]|4[02-69]|5[0-8]|[69][0-79])|5(?:0[1-35-9]|[16]\\d|2[024-9]|3[015689]|4[02-9]|5[03-9]|7[0-35-9]|8[0-468]|9[0-57-9])|6(?:0[034689]|1\\d|2[0-35689]|[38][013-9]|4[1-467]|5[0-69]|6[13-9]|7[0-8]|9[0-24578])|7(?:0[0246-9]|2\\d|3[0236-8]|4[03-9]|5[0-46-9]|6[013-9]|7[0-35-9]|8[024-9]|9[02-9])|8(?:0[35-9]|2[1-57-9]|3[02-578]|4[0-578]|5[124-9]|6[2-69]|7\\d|8[02-9]|9[02569])|9(?:0[02-589]|[18]\\d|2[02-689]|3[1-57-9]|4[2-9]|5[0-579]|6[2-47-9]|7[0-24578]|9[2-57]))\\d)\\d)|2(?:0[013478]|3[0189]|4[017]|8[0-46-9]|9[0-2])\\d{3})\\d{4}|1(?:2(?:0(?:46[1-4]|87[2-9])|545[1-79]|76(?:2\\d|3[1-8]|6[1-6])|9(?:7(?:2[0-4]|3[2-5])|8(?:2[2-8]|7[0-47-9]|8[3-5])))|3(?:6(?:38[2-5]|47[23])|8(?:47[04-9]|64[0157-9]))|4(?:044[1-7]|20(?:2[23]|8\\d)|6(?:0(?:30|5[2-57]|6[1-8]|7[2-8])|140)|8(?:052|87[1-3]))|5(?:2(?:4(?:3[2-79]|6\\d)|76\\d)|6(?:26[06-9]|686))|6(?:06(?:4\\d|7[4-79])|295[5-7]|35[34]\\d|47(?:24|61)|59(?:5[08]|6[67]|74)|9(?:55[0-4]|77[23]))|7(?:26(?:6[13-9]|7[0-7])|(?:442|688)\\d|50(?:2[0-3]|[3-68]2|76))|8(?:27[56]\\d|37(?:5[2-5]|8[239])|843[2-58])|9(?:0(?:0(?:6[1-8]|85)|52\\d)|3583|4(?:66[1-8]|9(?:2[01]|81))|63(?:23|3[1-4])|9561))\\d{3}",[9,10]],["7(?:457[0-57-9]|700[01]|911[028])\\d{5}|7(?:[1-3]\\d\\d|4(?:[0-46-9]\\d|5[0-689])|5(?:0[0-8]|[13-9]\\d|2[0-35-9])|7(?:0[1-9]|[1-7]\\d|8[02-9]|9[0-689])|8(?:[014-9]\\d|[23][0-8])|9(?:[024-9]\\d|1[02-9]|3[0-689]))\\d{6}",[10]],["80[08]\\d{7}|800\\d{6}|8001111"],["(?:8(?:4[2-5]|7[0-3])|9(?:[01]\\d|8[2-49]))\\d{7}|845464\\d",[7,10]],["70\\d{8}",[10]],0,["(?:3[0347]|55)\\d{8}",[10]],["76(?:464|652)\\d{5}|76(?:0[0-28]|2[356]|34|4[01347]|5[49]|6[0-369]|77|8[14]|9[139])\\d{6}",[10]],["56\\d{8}",[10]]],0," x"],"GD":["1","011","(?:473|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([2-9]\\d{6})$|1","473$1",0,"473"],"GE":["995","00","(?:[3-57]\\d\\d|800)\\d{6}",[9],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["70"],"0$1"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["32"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[57]"]],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[348]"],"0$1"]],"0"],"GF":["594","00","[56]94\\d{6}|(?:80|9\\d)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[56]|9[47]"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[89]"],"0$1"]],"0"],"GG":["44","00","(?:1481|[357-9]\\d{3})\\d{6}|8\\d{6}(?:\\d{2})?",[7,9,10],0,"0",0,"([25-9]\\d{5})$|0","1481$1",0,0,[["1481[25-9]\\d{5}",[10]],["7(?:(?:781|839)\\d|911[17])\\d{5}",[10]],["80[08]\\d{7}|800\\d{6}|8001111"],["(?:8(?:4[2-5]|7[0-3])|9(?:[01]\\d|8[0-3]))\\d{7}|845464\\d",[7,10]],["70\\d{8}",[10]],0,["(?:3[0347]|55)\\d{8}",[10]],["76(?:464|652)\\d{5}|76(?:0[0-28]|2[356]|34|4[01347]|5[49]|6[0-369]|77|8[14]|9[139])\\d{6}",[10]],["56\\d{8}",[10]]]],"GH":["233","00","(?:[235]\\d{3}|800)\\d{5}",[8,9],[["(\\d{3})(\\d{5})","$1 $2",["8"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[235]"],"0$1"]],"0"],"GI":["350","00","(?:[25]\\d|60)\\d{6}",[8],[["(\\d{3})(\\d{5})","$1 $2",["2"]]]],"GL":["299","00","(?:19|[2-689]\\d|70)\\d{4}",[6],[["(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3",["19|[2-9]"]]]],"GM":["220","00","[2-9]\\d{6}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[2-9]"]]]],"GN":["224","00","722\\d{6}|(?:3|6\\d)\\d{7}",[8,9],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["3"]],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[67]"]]]],"GP":["590","00","590\\d{6}|(?:69|80|9\\d)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[569]"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"],"0$1"]],"0",0,0,0,0,0,[["590(?:0[1-68]|[14][0-24-9]|2[0-68]|3[1289]|5[3-579]|[68][0-689]|7[08]|9\\d)\\d{4}"],["69(?:0\\d\\d|1(?:2[2-9]|3[0-5]))\\d{4}"],["80[0-5]\\d{6}"],0,0,0,0,0,["9(?:(?:395|76[018])\\d|475[0-2])\\d{4}"]]],"GQ":["240","00","222\\d{6}|(?:3\\d|55|[89]0)\\d{7}",[9],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[235]"]],["(\\d{3})(\\d{6})","$1 $2",["[89]"]]]],"GR":["30","00","5005000\\d{3}|8\\d{9,11}|(?:[269]\\d|70)\\d{8}",[10,11,12],[["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["21|7"]],["(\\d{4})(\\d{6})","$1 $2",["2(?:2|3[2-57-9]|4[2-469]|5[2-59]|6[2-9]|7[2-69]|8[2-49])|5"]],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["[2689]"]],["(\\d{3})(\\d{3,4})(\\d{5})","$1 $2 $3",["8"]]]],"GT":["502","00","(?:1\\d{3}|[2-7])\\d{7}",[8,11],[["(\\d{4})(\\d{4})","$1 $2",["[2-7]"]],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["1"]]]],"GU":["1","011","(?:[58]\\d\\d|671|900)\\d{7}",[10],0,"1",0,"([3-9]\\d{6})$|1","671$1",0,"671"],"GW":["245","00","[49]\\d{8}|4\\d{6}",[7,9],[["(\\d{3})(\\d{4})","$1 $2",["40"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[49]"]]]],"GY":["592","001","9008\\d{3}|(?:[2-467]\\d\\d|862)\\d{4}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[2-46-9]"]]]],"HK":["852","00(?:30|5[09]|[126-9]?)","8[0-46-9]\\d{6,7}|9\\d{4,7}|(?:[2-7]|9\\d{3})\\d{7}",[5,6,7,8,9,11],[["(\\d{3})(\\d{2,5})","$1 $2",["900","9003"]],["(\\d{4})(\\d{4})","$1 $2",["[2-7]|8[1-4]|9(?:0[1-9]|[1-8])"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["8"]],["(\\d{3})(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3 $4",["9"]]],0,0,0,0,0,0,0,"00"],"HN":["504","00","8\\d{10}|[237-9]\\d{7}",[8,11],[["(\\d{4})(\\d{4})","$1-$2",["[237-9]"]]]],"HR":["385","00","(?:[24-69]\\d|3[0-79])\\d{7}|80\\d{5,7}|[1-79]\\d{7}|6\\d{5,6}",[6,7,8,9],[["(\\d{2})(\\d{2})(\\d{2,3})","$1 $2 $3",["6[01]"],"0$1"],["(\\d{3})(\\d{2})(\\d{2,3})","$1 $2 $3",["8"],"0$1"],["(\\d)(\\d{4})(\\d{3})","$1 $2 $3",["1"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[67]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["9"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[2-5]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["8"],"0$1"]],"0"],"HT":["509","00","(?:[2-489]\\d|55)\\d{6}",[8],[["(\\d{2})(\\d{2})(\\d{4})","$1 $2 $3",["[2-589]"]]]],"HU":["36","00","[235-7]\\d{8}|[1-9]\\d{7}",[8,9],[["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["1"],"(06 $1)"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[27][2-9]|3[2-7]|4[24-9]|5[2-79]|6|8[2-57-9]|9[2-69]"],"(06 $1)"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[2-9]"],"06 $1"]],"06"],"ID":["62","00[89]","(?:(?:00[1-9]|8\\d)\\d{4}|[1-36])\\d{6}|00\\d{10}|[1-9]\\d{8,10}|[2-9]\\d{7}",[7,8,9,10,11,12,13],[["(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["15"]],["(\\d{2})(\\d{5,9})","$1 $2",["2[124]|[36]1"],"(0$1)"],["(\\d{3})(\\d{5,7})","$1 $2",["800"],"0$1"],["(\\d{3})(\\d{5,8})","$1 $2",["[2-79]"],"(0$1)"],["(\\d{3})(\\d{3,4})(\\d{3})","$1-$2-$3",["8[1-35-9]"],"0$1"],["(\\d{3})(\\d{6,8})","$1 $2",["1"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["804"],"0$1"],["(\\d{3})(\\d)(\\d{3})(\\d{3})","$1 $2 $3 $4",["80"],"0$1"],["(\\d{3})(\\d{4})(\\d{4,5})","$1-$2-$3",["8"],"0$1"]],"0"],"IE":["353","00","(?:1\\d|[2569])\\d{6,8}|4\\d{6,9}|7\\d{8}|8\\d{8,9}",[7,8,9,10],[["(\\d{2})(\\d{5})","$1 $2",["2[24-9]|47|58|6[237-9]|9[35-9]"],"(0$1)"],["(\\d{3})(\\d{5})","$1 $2",["[45]0"],"(0$1)"],["(\\d)(\\d{3,4})(\\d{4})","$1 $2 $3",["1"],"(0$1)"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[2569]|4[1-69]|7[14]"],"(0$1)"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["70"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["81"],"(0$1)"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[78]"],"0$1"],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["1"]],["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["4"],"(0$1)"],["(\\d{2})(\\d)(\\d{3})(\\d{4})","$1 $2 $3 $4",["8"],"0$1"]],"0"],"IL":["972","0(?:0|1[2-9])","1\\d{6}(?:\\d{3,5})?|[57]\\d{8}|[1-489]\\d{7}",[7,8,9,10,11,12],[["(\\d{4})(\\d{3})","$1-$2",["125"]],["(\\d{4})(\\d{2})(\\d{2})","$1-$2-$3",["121"]],["(\\d)(\\d{3})(\\d{4})","$1-$2-$3",["[2-489]"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1-$2-$3",["[57]"],"0$1"],["(\\d{4})(\\d{3})(\\d{3})","$1-$2-$3",["12"]],["(\\d{4})(\\d{6})","$1-$2",["159"]],["(\\d)(\\d{3})(\\d{3})(\\d{3})","$1-$2-$3-$4",["1[7-9]"]],["(\\d{3})(\\d{1,2})(\\d{3})(\\d{4})","$1-$2 $3-$4",["15"]]],"0"],"IM":["44","00","1624\\d{6}|(?:[3578]\\d|90)\\d{8}",[10],0,"0",0,"([25-8]\\d{5})$|0","1624$1",0,"74576|(?:16|7[56])24"],"IN":["91","00","(?:000800|[2-9]\\d\\d)\\d{7}|1\\d{7,12}",[8,9,10,11,12,13],[["(\\d{8})","$1",["5(?:0|2[23]|3[03]|[67]1|88)","5(?:0|2(?:21|3)|3(?:0|3[23])|616|717|888)","5(?:0|2(?:21|3)|3(?:0|3[23])|616|717|8888)"],0,1],["(\\d{4})(\\d{4,5})","$1 $2",["180","1800"],0,1],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["140"],0,1],["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["11|2[02]|33|4[04]|79[1-7]|80[2-46]","11|2[02]|33|4[04]|79(?:[1-6]|7[19])|80(?:[2-4]|6[0-589])","11|2[02]|33|4[04]|79(?:[124-6]|3(?:[02-9]|1[0-24-9])|7(?:1|9[1-6]))|80(?:[2-4]|6[0-589])"],"0$1",1],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["1(?:2[0-249]|3[0-25]|4[145]|[68]|7[1257])|2(?:1[257]|3[013]|4[01]|5[0137]|6[0158]|78|8[1568])|3(?:26|4[1-3]|5[34]|6[01489]|7[02-46]|8[159])|4(?:1[36]|2[1-47]|5[12]|6[0-26-9]|7[0-24-9]|8[013-57]|9[014-7])|5(?:1[025]|22|[36][25]|4[28]|5[12]|[78]1)|6(?:12|[2-4]1|5[17]|6[13]|80)|7(?:12|3[134]|4[47]|61|88)|8(?:16|2[014]|3[126]|6[136]|7[078]|8[34]|91)|(?:43|59|75)[15]|(?:1[59]|29|67|72)[14]","1(?:2[0-24]|3[0-25]|4[145]|[59][14]|6[1-9]|7[1257]|8[1-57-9])|2(?:1[257]|3[013]|4[01]|5[0137]|6[058]|78|8[1568]|9[14])|3(?:26|4[1-3]|5[34]|6[01489]|7[02-46]|8[159])|4(?:1[36]|2[1-47]|3[15]|5[12]|6[0-26-9]|7[0-24-9]|8[013-57]|9[014-7])|5(?:1[025]|22|[36][25]|4[28]|[578]1|9[15])|674|7(?:(?:2[14]|3[34]|5[15])[2-6]|61[346]|88[0-8])|8(?:70[2-6]|84[235-7]|91[3-7])|(?:1(?:29|60|8[06])|261|552|6(?:12|[2-47]1|5[17]|6[13]|80)|7(?:12|31|4[47])|8(?:16|2[014]|3[126]|6[136]|7[78]|83))[2-7]","1(?:2[0-24]|3[0-25]|4[145]|[59][14]|6[1-9]|7[1257]|8[1-57-9])|2(?:1[257]|3[013]|4[01]|5[0137]|6[058]|78|8[1568]|9[14])|3(?:26|4[1-3]|5[34]|6[01489]|7[02-46]|8[159])|4(?:1[36]|2[1-47]|3[15]|5[12]|6[0-26-9]|7[0-24-9]|8[013-57]|9[014-7])|5(?:1[025]|22|[36][25]|4[28]|[578]1|9[15])|6(?:12(?:[2-6]|7[0-8])|74[2-7])|7(?:(?:2[14]|5[15])[2-6]|3171|61[346]|88(?:[2-7]|82))|8(?:70[2-6]|84(?:[2356]|7[19])|91(?:[3-6]|7[19]))|73[134][2-6]|(?:74[47]|8(?:16|2[014]|3[126]|6[136]|7[78]|83))(?:[2-6]|7[19])|(?:1(?:29|60|8[06])|261|552|6(?:[2-4]1|5[17]|6[13]|7(?:1|4[0189])|80)|7(?:12|88[01]))[2-7]"],"0$1",1],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["1(?:[2-479]|5[0235-9])|[2-5]|6(?:1[1358]|2[2457-9]|3[2-5]|4[235-7]|5[2-689]|6[24578]|7[235689]|8[1-6])|7(?:1[013-9]|28|3[129]|4[1-35689]|5[29]|6[02-5]|70)|807","1(?:[2-479]|5[0235-9])|[2-5]|6(?:1[1358]|2(?:[2457]|84|95)|3(?:[2-4]|55)|4[235-7]|5[2-689]|6[24578]|7[235689]|8[1-6])|7(?:1(?:[013-8]|9[6-9])|28[6-8]|3(?:17|2[0-49]|9[2-57])|4(?:1[2-4]|[29][0-7]|3[0-8]|[56]|8[0-24-7])|5(?:2[1-3]|9[0-6])|6(?:0[5689]|2[5-9]|3[02-8]|4|5[0-367])|70[13-7])|807[19]","1(?:[2-479]|5(?:[0236-9]|5[013-9]))|[2-5]|6(?:2(?:84|95)|355|83)|73179|807(?:1|9[1-3])|(?:1552|6(?:1[1358]|2[2457]|3[2-4]|4[235-7]|5[2-689]|6[24578]|7[235689]|8[124-6])\\d|7(?:1(?:[013-8]\\d|9[6-9])|28[6-8]|3(?:2[0-49]|9[2-57])|4(?:1[2-4]|[29][0-7]|3[0-8]|[56]\\d|8[0-24-7])|5(?:2[1-3]|9[0-6])|6(?:0[5689]|2[5-9]|3[02-8]|4\\d|5[0-367])|70[13-7]))[2-7]"],"0$1",1],["(\\d{5})(\\d{5})","$1 $2",["[6-9]"],"0$1",1],["(\\d{4})(\\d{2,4})(\\d{4})","$1 $2 $3",["1(?:6|8[06])","1(?:6|8[06]0)"],0,1],["(\\d{4})(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["18"],0,1]],"0"],"IO":["246","00","3\\d{6}",[7],[["(\\d{3})(\\d{4})","$1 $2",["3"]]]],"IQ":["964","00","(?:1|7\\d\\d)\\d{7}|[2-6]\\d{7,8}",[8,9,10],[["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["1"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[2-6]"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["7"],"0$1"]],"0"],"IR":["98","00","[1-9]\\d{9}|(?:[1-8]\\d\\d|9)\\d{3,4}",[4,5,6,7,10],[["(\\d{4,5})","$1",["96"],"0$1"],["(\\d{2})(\\d{4,5})","$1 $2",["(?:1[137]|2[13-68]|3[1458]|4[145]|5[1468]|6[16]|7[1467]|8[13467])[12689]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["9"],"0$1"],["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["[1-8]"],"0$1"]],"0"],"IS":["354","00|1(?:0(?:01|[12]0)|100)","(?:38\\d|[4-9])\\d{6}",[7,9],[["(\\d{3})(\\d{4})","$1 $2",["[4-9]"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["3"]]],0,0,0,0,0,0,0,"00"],"IT":["39","00","0\\d{5,10}|1\\d{8,10}|3(?:[0-8]\\d{7,10}|9\\d{7,8})|(?:55|70)\\d{8}|8\\d{5}(?:\\d{2,4})?",[6,7,8,9,10,11],[["(\\d{2})(\\d{4,6})","$1 $2",["0[26]"]],["(\\d{3})(\\d{3,6})","$1 $2",["0[13-57-9][0159]|8(?:03|4[17]|9[2-5])","0[13-57-9][0159]|8(?:03|4[17]|9(?:2|3[04]|[45][0-4]))"]],["(\\d{4})(\\d{2,6})","$1 $2",["0(?:[13-579][2-46-8]|8[236-8])"]],["(\\d{4})(\\d{4})","$1 $2",["894"]],["(\\d{2})(\\d{3,4})(\\d{4})","$1 $2 $3",["0[26]|5"]],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["1(?:44|[679])|[378]"]],["(\\d{3})(\\d{3,4})(\\d{4})","$1 $2 $3",["0[13-57-9][0159]|14"]],["(\\d{2})(\\d{4})(\\d{5})","$1 $2 $3",["0[26]"]],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["0"]],["(\\d{3})(\\d{4})(\\d{4,5})","$1 $2 $3",["3"]]],0,0,0,0,0,0,[["0669[0-79]\\d{1,6}|0(?:1(?:[0159]\\d|[27][1-5]|31|4[1-4]|6[1356]|8[2-57])|2\\d\\d|3(?:[0159]\\d|2[1-4]|3[12]|[48][1-6]|6[2-59]|7[1-7])|4(?:[0159]\\d|[23][1-9]|4[245]|6[1-5]|7[1-4]|81)|5(?:[0159]\\d|2[1-5]|3[2-6]|4[1-79]|6[4-6]|7[1-578]|8[3-8])|6(?:[0-57-9]\\d|6[0-8])|7(?:[0159]\\d|2[12]|3[1-7]|4[2-46]|6[13569]|7[13-6]|8[1-59])|8(?:[0159]\\d|2[3-578]|3[1-356]|[6-8][1-5])|9(?:[0159]\\d|[238][1-5]|4[12]|6[1-8]|7[1-6]))\\d{2,7}"],["3[1-9]\\d{8}|3[2-9]\\d{7}",[9,10]],["80(?:0\\d{3}|3)\\d{3}",[6,9]],["(?:0878\\d{3}|89(?:2\\d|3[04]|4(?:[0-4]|[5-9]\\d\\d)|5[0-4]))\\d\\d|(?:1(?:44|6[346])|89(?:38|5[5-9]|9))\\d{6}",[6,8,9,10]],["1(?:78\\d|99)\\d{6}",[9,10]],0,0,0,["55\\d{8}",[10]],["84(?:[08]\\d{3}|[17])\\d{3}",[6,9]]]],"JE":["44","00","1534\\d{6}|(?:[3578]\\d|90)\\d{8}",[10],0,"0",0,"([0-24-8]\\d{5})$|0","1534$1",0,0,[["1534[0-24-8]\\d{5}"],["7(?:(?:(?:50|82)9|937)\\d|7(?:00[378]|97[7-9]))\\d{5}"],["80(?:07(?:35|81)|8901)\\d{4}"],["(?:8(?:4(?:4(?:4(?:05|42|69)|703)|5(?:041|800))|7(?:0002|1206))|90(?:066[59]|1810|71(?:07|55)))\\d{4}"],["701511\\d{4}"],0,["(?:3(?:0(?:07(?:35|81)|8901)|3\\d{4}|4(?:4(?:4(?:05|42|69)|703)|5(?:041|800))|7(?:0002|1206))|55\\d{4})\\d{4}"],["76(?:464|652)\\d{5}|76(?:0[0-28]|2[356]|34|4[01347]|5[49]|6[0-369]|77|8[14]|9[139])\\d{6}"],["56\\d{8}"]]],"JM":["1","011","(?:[58]\\d\\d|658|900)\\d{7}",[10],0,"1",0,0,0,0,"658|876"],"JO":["962","00","(?:(?:[2689]|7\\d)\\d|32|53)\\d{6}",[8,9],[["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["[2356]|87"],"(0$1)"],["(\\d{3})(\\d{5,6})","$1 $2",["[89]"],"0$1"],["(\\d{2})(\\d{7})","$1 $2",["70"],"0$1"],["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["7"],"0$1"]],"0"],"JP":["81","010","00[1-9]\\d{6,14}|[257-9]\\d{9}|(?:00|[1-9]\\d\\d)\\d{6}",[8,9,10,11,12,13,14,15,16,17],[["(\\d{3})(\\d{3})(\\d{3})","$1-$2-$3",["(?:12|57|99)0"],"0$1"],["(\\d{4})(\\d)(\\d{4})","$1-$2-$3",["1(?:26|3[79]|4[56]|5[4-68]|6[3-5])|499|5(?:76|97)|746|8(?:3[89]|47|51|63)|9(?:80|9[16])","1(?:267|3(?:7[247]|9[278])|466|5(?:47|58|64)|6(?:3[245]|48|5[4-68]))|499[2468]|5(?:76|97)9|7468|8(?:3(?:8[7-9]|96)|477|51[2-9]|636)|9(?:802|9(?:1[23]|69))|1(?:45|58)[67]","1(?:267|3(?:7[247]|9[278])|466|5(?:47|58|64)|6(?:3[245]|48|5[4-68]))|499[2468]|5(?:769|979[2-69])|7468|8(?:3(?:8[7-9]|96[2457-9])|477|51[2-9]|636[457-9])|9(?:802|9(?:1[23]|69))|1(?:45|58)[67]"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1-$2-$3",["60"],"0$1"],["(\\d)(\\d{4})(\\d{4})","$1-$2-$3",["[36]|4(?:2[09]|7[01])","[36]|4(?:2(?:0|9[02-69])|7(?:0[019]|1))"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1-$2-$3",["1(?:1|5[45]|77|88|9[69])|2(?:2[1-37]|3[0-269]|4[59]|5|6[24]|7[1-358]|8[1369]|9[0-38])|4(?:[28][1-9]|3[0-57]|[45]|6[248]|7[2-579]|9[29])|5(?:2|3[045]|4[0-369]|5[29]|8[02389]|9[0-389])|7(?:2[02-46-9]|34|[58]|6[0249]|7[57]|9[2-6])|8(?:2[124589]|3[27-9]|49|51|6|7[0-468]|8[68]|9[019])|9(?:[23][1-9]|4[15]|5[138]|6[1-3]|7[156]|8[189]|9[1-489])","1(?:1|5(?:4[018]|5[017])|77|88|9[69])|2(?:2(?:[127]|3[014-9])|3[0-269]|4[59]|5(?:[1-3]|5[0-69]|9[19])|62|7(?:[1-35]|8[0189])|8(?:[16]|3[0134]|9[0-5])|9(?:[028]|17))|4(?:2(?:[13-79]|8[014-6])|3[0-57]|[45]|6[248]|7[2-47]|8[1-9])|5(?:2|3[045]|4[0-369]|8[02389]|9[0-3])|7(?:2[02-46-9]|34|[58]|6[0249]|7[57]|9(?:[23]|4[0-59]|5[01569]|6[0167]))|8(?:2(?:[1258]|4[0-39]|9[0-2469])|49|51|6(?:[0-24]|36|5[0-3589]|72|9[01459])|7[0-468]|8[68])|9(?:[23][1-9]|4[15]|5[138]|6[1-3]|7[156]|8[189]|9(?:[1289]|3[34]|4[0178]))|(?:49|55|83)[29]|(?:264|837)[016-9]|2(?:57|93)[015-9]|(?:25[0468]|422|838)[01]|(?:47[59]|59[89]|8(?:6[68]|9))[019]","1(?:1|5(?:4[018]|5[017])|77|88|9[69])|2(?:2[127]|3[0-269]|4[59]|5(?:[1-3]|5[0-69]|9(?:17|99))|6(?:2|4[016-9])|7(?:[1-35]|8[0189])|8(?:[16]|3[0134]|9[0-5])|9(?:[028]|17))|4(?:2(?:[13-79]|8[014-6])|3[0-57]|[45]|6[248]|7[2-47]|9[29])|5(?:2|3[045]|4[0-369]|5[29]|8[02389]|9[0-3])|7(?:2[02-46-9]|34|[58]|6[0249]|7[57]|9(?:[23]|4[0-59]|5[01569]|6[0167]))|8(?:2(?:[1258]|4[0-39]|9[0169])|3(?:[29]|7(?:[017-9]|6[6-8]))|49|51|6(?:[0-24]|36[23]|5(?:[0-389]|5[23])|6(?:[01]|9[178])|72|9[0145])|7[0-468]|8[68])|9(?:4[15]|5[138]|7[156]|8[189]|9(?:[1289]|3(?:31|4[357])|4[0178]))|(?:8294|96)[1-3]|2(?:57|93)[015-9]|(?:223|8699)[014-9]|(?:25[0468]|422|838)[01]|(?:48|8292|9[23])[1-9]|(?:47[59]|59[89]|8(?:68|9))[019]","1(?:1|5(?:4[018]|5[017])|77|88|9[69])|2(?:2[127]|3[0-269]|4[59]|5(?:[1-3]|5[0-69]|7[015-9]|9(?:17|99))|6(?:2|4[016-9])|7(?:[1-35]|8[0189])|8(?:[16]|3[0134]|9[0-5])|9(?:[028]|17|3[015-9]))|4(?:2(?:[13-79]|8[014-6])|3[0-57]|[45]|6[248]|7[2-47]|9[29])|5(?:2|3[045]|4[0-369]|5[29]|8[02389]|9[0-3])|7(?:2[02-46-9]|34|[58]|6[0249]|7[57]|9(?:[23]|4[0-59]|5[01569]|6[0167]))|8(?:2(?:[1258]|4[0-39]|9(?:[019]|4[1-3]|6(?:[0-47-9]|5[01346-9])))|3(?:[29]|7(?:[017-9]|6[6-8]))|49|51|6(?:[0-24]|36[23]|5(?:[0-389]|5[23])|6(?:[01]|9[178])|72|9[0145])|7[0-468]|8[68])|9(?:4[15]|5[138]|6[1-3]|7[156]|8[189]|9(?:[1289]|3(?:31|4[357])|4[0178]))|(?:223|8699)[014-9]|(?:25[0468]|422|838)[01]|(?:48|829(?:2|66)|9[23])[1-9]|(?:47[59]|59[89]|8(?:68|9))[019]"],"0$1"],["(\\d{3})(\\d{2})(\\d{4})","$1-$2-$3",["[14]|[289][2-9]|5[3-9]|7[2-4679]"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1-$2-$3",["800"],"0$1"],["(\\d{2})(\\d{4})(\\d{4})","$1-$2-$3",["[257-9]"],"0$1"]],"0"],"KE":["254","000","(?:[17]\\d\\d|900)\\d{6}|(?:2|80)0\\d{6,7}|[4-6]\\d{6,8}",[7,8,9,10],[["(\\d{2})(\\d{5,7})","$1 $2",["[24-6]"],"0$1"],["(\\d{3})(\\d{6})","$1 $2",["[17]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["[89]"],"0$1"]],"0"],"KG":["996","00","8\\d{9}|(?:[235-8]\\d|99)\\d{7}",[9,10],[["(\\d{4})(\\d{5})","$1 $2",["3(?:1[346]|[24-79])"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[235-79]|88"],"0$1"],["(\\d{3})(\\d{3})(\\d)(\\d{2,3})","$1 $2 $3 $4",["8"],"0$1"]],"0"],"KH":["855","00[14-9]","1\\d{9}|[1-9]\\d{7,8}",[8,9,10],[["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[1-9]"],"0$1"],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["1"]]],"0"],"KI":["686","00","(?:[37]\\d|6[0-79])\\d{6}|(?:[2-48]\\d|50)\\d{3}",[5,8],0,"0"],"KM":["269","00","[3478]\\d{6}",[7],[["(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3",["[3478]"]]]],"KN":["1","011","(?:[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([2-7]\\d{6})$|1","869$1",0,"869"],"KP":["850","00|99","85\\d{6}|(?:19\\d|[2-7])\\d{7}",[8,10],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["8"],"0$1"],["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["[2-7]"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["1"],"0$1"]],"0"],"KR":["82","00(?:[125689]|3(?:[46]5|91)|7(?:00|27|3|55|6[126]))","00[1-9]\\d{8,11}|(?:[12]|5\\d{3})\\d{7}|[13-6]\\d{9}|(?:[1-6]\\d|80)\\d{7}|[3-6]\\d{4,5}|(?:00|7)0\\d{8}",[5,6,8,9,10,11,12,13,14],[["(\\d{2})(\\d{3,4})","$1-$2",["(?:3[1-3]|[46][1-4]|5[1-5])1"],"0$1"],["(\\d{4})(\\d{4})","$1-$2",["1"]],["(\\d)(\\d{3,4})(\\d{4})","$1-$2-$3",["2"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1-$2-$3",["60|8"],"0$1"],["(\\d{2})(\\d{3,4})(\\d{4})","$1-$2-$3",["[1346]|5[1-5]"],"0$1"],["(\\d{2})(\\d{4})(\\d{4})","$1-$2-$3",["[57]"],"0$1"],["(\\d{2})(\\d{5})(\\d{4})","$1-$2-$3",["5"],"0$1"]],"0",0,"0(8(?:[1-46-8]|5\\d\\d))?"],"KW":["965","00","18\\d{5}|(?:[2569]\\d|41)\\d{6}",[7,8],[["(\\d{4})(\\d{3,4})","$1 $2",["[169]|2(?:[235]|4[1-35-9])|52"]],["(\\d{3})(\\d{5})","$1 $2",["[245]"]]]],"KY":["1","011","(?:345|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([2-9]\\d{6})$|1","345$1",0,"345"],"KZ":["7","810","(?:33622|8\\d{8})\\d{5}|[78]\\d{9}",[10,14],0,"8",0,0,0,0,"33|7",0,"8~10"],"LA":["856","00","[23]\\d{9}|3\\d{8}|(?:[235-8]\\d|41)\\d{6}",[8,9,10],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["2[13]|3[14]|[4-8]"],"0$1"],["(\\d{2})(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3 $4",["30[013-9]"],"0$1"],["(\\d{2})(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3 $4",["[23]"],"0$1"]],"0"],"LB":["961","00","[27-9]\\d{7}|[13-9]\\d{6}",[7,8],[["(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["[13-69]|7(?:[2-57]|62|8[0-7]|9[04-9])|8[02-9]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[27-9]"]]],"0"],"LC":["1","011","(?:[58]\\d\\d|758|900)\\d{7}",[10],0,"1",0,"([2-8]\\d{6})$|1","758$1",0,"758"],"LI":["423","00","[68]\\d{8}|(?:[2378]\\d|90)\\d{5}",[7,9],[["(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3",["[2379]|8(?:0[09]|7)","[2379]|8(?:0(?:02|9)|7)"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["8"]],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["69"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["6"]]],"0",0,"(1001)|0"],"LK":["94","00","[1-9]\\d{8}",[9],[["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["7"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[1-689]"],"0$1"]],"0"],"LR":["231","00","(?:[25]\\d|33|77|88)\\d{7}|(?:2\\d|[4-6])\\d{6}",[7,8,9],[["(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["[4-6]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["2"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[23578]"],"0$1"]],"0"],"LS":["266","00","(?:[256]\\d\\d|800)\\d{5}",[8],[["(\\d{4})(\\d{4})","$1 $2",["[2568]"]]]],"LT":["370","00","(?:[3469]\\d|52|[78]0)\\d{6}",[8],[["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["52[0-7]"],"(8-$1)",1],["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["[7-9]"],"8 $1",1],["(\\d{2})(\\d{6})","$1 $2",["37|4(?:[15]|6[1-8])"],"(8-$1)",1],["(\\d{3})(\\d{5})","$1 $2",["[3-6]"],"(8-$1)",1]],"8",0,"[08]"],"LU":["352","00","35[013-9]\\d{4,8}|6\\d{8}|35\\d{2,4}|(?:[2457-9]\\d|3[0-46-9])\\d{2,9}",[4,5,6,7,8,9,10,11],[["(\\d{2})(\\d{3})","$1 $2",["2(?:0[2-689]|[2-9])|[3-57]|8(?:0[2-9]|[13-9])|9(?:0[89]|[2-579])"]],["(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3",["2(?:0[2-689]|[2-9])|[3-57]|8(?:0[2-9]|[13-9])|9(?:0[89]|[2-579])"]],["(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3",["20[2-689]"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{1,2})","$1 $2 $3 $4",["2(?:[0367]|4[3-8])"]],["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["80[01]|90[015]"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3 $4",["20"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["6"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})(\\d{1,2})","$1 $2 $3 $4 $5",["2(?:[0367]|4[3-8])"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{1,5})","$1 $2 $3 $4",["[3-57]|8[13-9]|9(?:0[89]|[2-579])|(?:2|80)[2-9]"]]],0,0,"(15(?:0[06]|1[12]|[35]5|4[04]|6[26]|77|88|99)\\d)"],"LV":["371","00","(?:[268]\\d|90)\\d{6}",[8],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[269]|8[01]"]]]],"LY":["218","00","[2-9]\\d{8}",[9],[["(\\d{2})(\\d{7})","$1-$2",["[2-9]"],"0$1"]],"0"],"MA":["212","00","[5-8]\\d{8}",[9],[["(\\d{5})(\\d{4})","$1-$2",["5(?:29|38)","5(?:29[1289]|389)","529(?:1[1-46-9]|2[013-8]|90)|5(?:298|389)[0-46-9]"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["5[45]"],"0$1"],["(\\d{4})(\\d{5})","$1-$2",["5(?:2[2-489]|3[5-9]|9)|892","5(?:2(?:[2-49]|8[235-9])|3[5-9]|9)|892"],"0$1"],["(\\d{2})(\\d{7})","$1-$2",["8"],"0$1"],["(\\d{3})(\\d{6})","$1-$2",["[5-7]"],"0$1"]],"0",0,0,0,0,0,[["5293[01]\\d{4}|5(?:2(?:[0-25-7]\\d|3[1-578]|4[02-46-8]|8[0235-7]|9[0-289])|3(?:[0-47]\\d|5[02-9]|6[02-8]|8[0189]|9[3-9])|(?:4[067]|5[03])\\d)\\d{5}"],["(?:6(?:[0-79]\\d|8[0-247-9])|7(?:[017]\\d|2[0-2]|6[0-8]|8[0-3]))\\d{6}"],["80\\d{7}"],["89\\d{7}"],0,0,0,0,["592(?:4[0-2]|93)\\d{4}"]]],"MC":["377","00","(?:[3489]|6\\d)\\d{7}",[8,9],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["4"],"0$1"],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[389]"]],["(\\d)(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4 $5",["6"],"0$1"]],"0"],"MD":["373","00","(?:[235-7]\\d|[89]0)\\d{6}",[8],[["(\\d{3})(\\d{5})","$1 $2",["[89]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["22|3"],"0$1"],["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["[25-7]"],"0$1"]],"0"],"ME":["382","00","(?:20|[3-79]\\d)\\d{6}|80\\d{6,7}",[8,9],[["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[2-9]"],"0$1"]],"0"],"MF":["590","00","590\\d{6}|(?:69|80|9\\d)\\d{7}",[9],0,"0",0,0,0,0,0,[["590(?:0[079]|[14]3|[27][79]|30|5[0-268]|87)\\d{4}"],["69(?:0\\d\\d|1(?:2[2-9]|3[0-5]))\\d{4}"],["80[0-5]\\d{6}"],0,0,0,0,0,["9(?:(?:395|76[018])\\d|475[0-2])\\d{4}"]]],"MG":["261","00","[23]\\d{8}",[9],[["(\\d{2})(\\d{2})(\\d{3})(\\d{2})","$1 $2 $3 $4",["[23]"],"0$1"]],"0",0,"([24-9]\\d{6})$|0","20$1"],"MH":["692","011","329\\d{4}|(?:[256]\\d|45)\\d{5}",[7],[["(\\d{3})(\\d{4})","$1-$2",["[2-6]"]]],"1"],"MK":["389","00","[2-578]\\d{7}",[8],[["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["2|34[47]|4(?:[37]7|5[47]|64)"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[347]"],"0$1"],["(\\d{3})(\\d)(\\d{2})(\\d{2})","$1 $2 $3 $4",["[58]"],"0$1"]],"0"],"ML":["223","00","[24-9]\\d{7}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[24-9]"]]]],"MM":["95","00","1\\d{5,7}|95\\d{6}|(?:[4-7]|9[0-46-9])\\d{6,8}|(?:2|8\\d)\\d{5,8}",[6,7,8,9,10],[["(\\d)(\\d{2})(\\d{3})","$1 $2 $3",["16|2"],"0$1"],["(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3",["[45]|6(?:0[23]|[1-689]|7[235-7])|7(?:[0-4]|5[2-7])|8[1-6]"],"0$1"],["(\\d)(\\d{3})(\\d{3,4})","$1 $2 $3",["[12]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[4-7]|8[1-35]"],"0$1"],["(\\d)(\\d{3})(\\d{4,6})","$1 $2 $3",["9(?:2[0-4]|[35-9]|4[137-9])"],"0$1"],["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["2"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["8"],"0$1"],["(\\d)(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["92"],"0$1"],["(\\d)(\\d{5})(\\d{4})","$1 $2 $3",["9"],"0$1"]],"0"],"MN":["976","001","[12]\\d{7,9}|[5-9]\\d{7}",[8,9,10],[["(\\d{2})(\\d{2})(\\d{4})","$1 $2 $3",["[12]1"],"0$1"],["(\\d{4})(\\d{4})","$1 $2",["[5-9]"]],["(\\d{3})(\\d{5,6})","$1 $2",["[12]2[1-3]"],"0$1"],["(\\d{4})(\\d{5,6})","$1 $2",["[12](?:27|3[2-8]|4[2-68]|5[1-4689])","[12](?:27|3[2-8]|4[2-68]|5[1-4689])[0-3]"],"0$1"],["(\\d{5})(\\d{4,5})","$1 $2",["[12]"],"0$1"]],"0"],"MO":["853","00","0800\\d{3}|(?:28|[68]\\d)\\d{6}",[7,8],[["(\\d{4})(\\d{3})","$1 $2",["0"]],["(\\d{4})(\\d{4})","$1 $2",["[268]"]]]],"MP":["1","011","[58]\\d{9}|(?:67|90)0\\d{7}",[10],0,"1",0,"([2-9]\\d{6})$|1","670$1",0,"670"],"MQ":["596","00","596\\d{6}|(?:69|80|9\\d)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[569]"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"],"0$1"]],"0"],"MR":["222","00","(?:[2-4]\\d\\d|800)\\d{5}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[2-48]"]]]],"MS":["1","011","(?:[58]\\d\\d|664|900)\\d{7}",[10],0,"1",0,"([34]\\d{6})$|1","664$1",0,"664"],"MT":["356","00","3550\\d{4}|(?:[2579]\\d\\d|800)\\d{5}",[8],[["(\\d{4})(\\d{4})","$1 $2",["[2357-9]"]]]],"MU":["230","0(?:0|[24-7]0|3[03])","(?:[57]|8\\d\\d)\\d{7}|[2-468]\\d{6}",[7,8,10],[["(\\d{3})(\\d{4})","$1 $2",["[2-46]|8[013]"]],["(\\d{4})(\\d{4})","$1 $2",["[57]"]],["(\\d{5})(\\d{5})","$1 $2",["8"]]],0,0,0,0,0,0,0,"020"],"MV":["960","0(?:0|19)","(?:800|9[0-57-9]\\d)\\d{7}|[34679]\\d{6}",[7,10],[["(\\d{3})(\\d{4})","$1-$2",["[34679]"]],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["[89]"]]],0,0,0,0,0,0,0,"00"],"MW":["265","00","(?:[1289]\\d|31|77)\\d{7}|1\\d{6}",[7,9],[["(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["1[2-9]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["2"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[137-9]"],"0$1"]],"0"],"MX":["52","0[09]","1(?:(?:[27]2|44|99)[1-9]|65[0-689])\\d{7}|(?:1(?:[01]\\d|2[13-9]|[35][1-9]|4[0-35-9]|6[0-46-9]|7[013-9]|8[1-79]|9[1-8])|[2-9]\\d)\\d{8}",[10,11],[["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["33|5[56]|81"],0,1],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["[2-9]"],0,1],["(\\d)(\\d{2})(\\d{4})(\\d{4})","$2 $3 $4",["1(?:33|5[56]|81)"],0,1],["(\\d)(\\d{3})(\\d{3})(\\d{4})","$2 $3 $4",["1"],0,1]],"01",0,"0(?:[12]|4[45])|1",0,0,0,0,"00"],"MY":["60","00","1\\d{8,9}|(?:3\\d|[4-9])\\d{7}",[8,9,10],[["(\\d)(\\d{3})(\\d{4})","$1-$2 $3",["[4-79]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1-$2 $3",["1(?:[02469]|[378][1-9]|53)|8","1(?:[02469]|[37][1-9]|53|8(?:[1-46-9]|5[7-9]))|8"],"0$1"],["(\\d)(\\d{4})(\\d{4})","$1-$2 $3",["3"],"0$1"],["(\\d)(\\d{3})(\\d{2})(\\d{4})","$1-$2-$3-$4",["1(?:[367]|80)"]],["(\\d{3})(\\d{3})(\\d{4})","$1-$2 $3",["15"],"0$1"],["(\\d{2})(\\d{4})(\\d{4})","$1-$2 $3",["1"],"0$1"]],"0"],"MZ":["258","00","(?:2|8\\d)\\d{7}",[8,9],[["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["2|8[2-79]"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["8"]]]],"NA":["264","00","[68]\\d{7,8}",[8,9],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["88"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["6"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["87"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["8"],"0$1"]],"0"],"NC":["687","00","(?:050|[2-57-9]\\d\\d)\\d{3}",[6],[["(\\d{2})(\\d{2})(\\d{2})","$1.$2.$3",["[02-57-9]"]]]],"NE":["227","00","[027-9]\\d{7}",[8],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["08"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[089]|2[013]|7[04]"]]]],"NF":["672","00","[13]\\d{5}",[6],[["(\\d{2})(\\d{4})","$1 $2",["1[0-3]"]],["(\\d)(\\d{5})","$1 $2",["[13]"]]],0,0,"([0-258]\\d{4})$","3$1"],"NG":["234","009","(?:[124-7]|9\\d{3})\\d{6}|[1-9]\\d{7}|[78]\\d{9,13}",[7,8,10,11,12,13,14],[["(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3",["78"],"0$1"],["(\\d)(\\d{3})(\\d{3,4})","$1 $2 $3",["[12]|9(?:0[3-9]|[1-9])"],"0$1"],["(\\d{2})(\\d{3})(\\d{2,3})","$1 $2 $3",["[3-7]|8[2-9]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["[7-9]"],"0$1"],["(\\d{3})(\\d{4})(\\d{4,5})","$1 $2 $3",["[78]"],"0$1"],["(\\d{3})(\\d{5})(\\d{5,6})","$1 $2 $3",["[78]"],"0$1"]],"0"],"NI":["505","00","(?:1800|[25-8]\\d{3})\\d{4}",[8],[["(\\d{4})(\\d{4})","$1 $2",["[125-8]"]]]],"NL":["31","00","(?:[124-7]\\d\\d|3(?:[02-9]\\d|1[0-8]))\\d{6}|8\\d{6,9}|9\\d{6,10}|1\\d{4,5}",[5,6,7,8,9,10,11],[["(\\d{3})(\\d{4,7})","$1 $2",["[89]0"],"0$1"],["(\\d{2})(\\d{7})","$1 $2",["66"],"0$1"],["(\\d)(\\d{8})","$1 $2",["6"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["1[16-8]|2[259]|3[124]|4[17-9]|5[124679]"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[1-578]|91"],"0$1"],["(\\d{3})(\\d{3})(\\d{5})","$1 $2 $3",["9"],"0$1"]],"0"],"NO":["47","00","(?:0|[2-9]\\d{3})\\d{4}",[5,8],[["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["8"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[2-79]"]]],0,0,0,0,0,"[02-689]|7[0-8]"],"NP":["977","00","(?:1\\d|9)\\d{9}|[1-9]\\d{7}",[8,10,11],[["(\\d)(\\d{7})","$1-$2",["1[2-6]"],"0$1"],["(\\d{2})(\\d{6})","$1-$2",["1[01]|[2-8]|9(?:[1-59]|[67][2-6])"],"0$1"],["(\\d{3})(\\d{7})","$1-$2",["9"]]],"0"],"NR":["674","00","(?:444|(?:55|8\\d)\\d|666)\\d{4}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[4-68]"]]]],"NU":["683","00","(?:[47]|888\\d)\\d{3}",[4,7],[["(\\d{3})(\\d{4})","$1 $2",["8"]]]],"NZ":["64","0(?:0|161)","[29]\\d{7,9}|50\\d{5}(?:\\d{2,3})?|6[0-35-9]\\d{6}|7\\d{7,8}|8\\d{4,9}|(?:11\\d|[34])\\d{7}",[5,6,7,8,9,10],[["(\\d{2})(\\d{3,8})","$1 $2",["8[1-579]"],"0$1"],["(\\d{3})(\\d{2})(\\d{2,3})","$1 $2 $3",["50[036-8]|[89]0","50(?:[0367]|88)|[89]0"],"0$1"],["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["24|[346]|7[2-57-9]|9[2-9]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["2(?:10|74)|[59]|80"],"0$1"],["(\\d{2})(\\d{3,4})(\\d{4})","$1 $2 $3",["1|2[028]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,5})","$1 $2 $3",["2(?:[169]|7[0-35-9])|7|86"],"0$1"]],"0",0,0,0,0,0,0,"00"],"OM":["968","00","(?:1505|[279]\\d{3}|500)\\d{4}|800\\d{5,6}",[7,8,9],[["(\\d{3})(\\d{4,6})","$1 $2",["[58]"]],["(\\d{2})(\\d{6})","$1 $2",["2"]],["(\\d{4})(\\d{4})","$1 $2",["[179]"]]]],"PA":["507","00","(?:00800|8\\d{3})\\d{6}|[68]\\d{7}|[1-57-9]\\d{6}",[7,8,10,11],[["(\\d{3})(\\d{4})","$1-$2",["[1-57-9]"]],["(\\d{4})(\\d{4})","$1-$2",["[68]"]],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["8"]]]],"PE":["51","00|19(?:1[124]|77|90)00","(?:[14-8]|9\\d)\\d{7}",[8,9],[["(\\d{3})(\\d{5})","$1 $2",["80"],"(0$1)"],["(\\d)(\\d{7})","$1 $2",["1"],"(0$1)"],["(\\d{2})(\\d{6})","$1 $2",["[4-8]"],"(0$1)"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["9"]]],"0",0,0,0,0,0,0,"00"," Anexo "],"PF":["689","00","4\\d{5}(?:\\d{2})?|8\\d{7,8}",[6,8,9],[["(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3",["44"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["4|8[7-9]"]],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"]]]],"PG":["675","00|140[1-3]","(?:180|[78]\\d{3})\\d{4}|(?:[2-589]\\d|64)\\d{5}",[7,8],[["(\\d{3})(\\d{4})","$1 $2",["18|[2-69]|85"]],["(\\d{4})(\\d{4})","$1 $2",["[78]"]]],0,0,0,0,0,0,0,"00"],"PH":["63","00","(?:[2-7]|9\\d)\\d{8}|2\\d{5}|(?:1800|8)\\d{7,9}",[6,8,9,10,11,12,13],[["(\\d)(\\d{5})","$1 $2",["2"],"(0$1)"],["(\\d{4})(\\d{4,6})","$1 $2",["3(?:23|39|46)|4(?:2[3-6]|[35]9|4[26]|76)|544|88[245]|(?:52|64|86)2","3(?:230|397|461)|4(?:2(?:35|[46]4|51)|396|4(?:22|63)|59[347]|76[15])|5(?:221|446)|642[23]|8(?:622|8(?:[24]2|5[13]))"],"(0$1)"],["(\\d{5})(\\d{4})","$1 $2",["346|4(?:27|9[35])|883","3469|4(?:279|9(?:30|56))|8834"],"(0$1)"],["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["2"],"(0$1)"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[3-7]|8[2-8]"],"(0$1)"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["[89]"],"0$1"],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["1"]],["(\\d{4})(\\d{1,2})(\\d{3})(\\d{4})","$1 $2 $3 $4",["1"]]],"0"],"PK":["92","00","122\\d{6}|[24-8]\\d{10,11}|9(?:[013-9]\\d{8,10}|2(?:[01]\\d\\d|2(?:[06-8]\\d|1[01]))\\d{7})|(?:[2-8]\\d{3}|92(?:[0-7]\\d|8[1-9]))\\d{6}|[24-9]\\d{8}|[89]\\d{7}",[8,9,10,11,12],[["(\\d{3})(\\d{3})(\\d{2,7})","$1 $2 $3",["[89]0"],"0$1"],["(\\d{4})(\\d{5})","$1 $2",["1"]],["(\\d{3})(\\d{6,7})","$1 $2",["2(?:3[2358]|4[2-4]|9[2-8])|45[3479]|54[2-467]|60[468]|72[236]|8(?:2[2-689]|3[23578]|4[3478]|5[2356])|9(?:2[2-8]|3[27-9]|4[2-6]|6[3569]|9[25-8])","9(?:2[3-8]|98)|(?:2(?:3[2358]|4[2-4]|9[2-8])|45[3479]|54[2-467]|60[468]|72[236]|8(?:2[2-689]|3[23578]|4[3478]|5[2356])|9(?:22|3[27-9]|4[2-6]|6[3569]|9[25-7]))[2-9]"],"(0$1)"],["(\\d{2})(\\d{7,8})","$1 $2",["(?:2[125]|4[0-246-9]|5[1-35-7]|6[1-8]|7[14]|8[16]|91)[2-9]"],"(0$1)"],["(\\d{5})(\\d{5})","$1 $2",["58"],"(0$1)"],["(\\d{3})(\\d{7})","$1 $2",["3"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["2[125]|4[0-246-9]|5[1-35-7]|6[1-8]|7[14]|8[16]|91"],"(0$1)"],["(\\d{3})(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["[24-9]"],"(0$1)"]],"0"],"PL":["48","00","(?:6|8\\d\\d)\\d{7}|[1-9]\\d{6}(?:\\d{2})?|[26]\\d{5}",[6,7,8,9,10],[["(\\d{5})","$1",["19"]],["(\\d{3})(\\d{3})","$1 $2",["11|20|64"]],["(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3",["(?:1[2-8]|2[2-69]|3[2-4]|4[1-468]|5[24-689]|6[1-3578]|7[14-7]|8[1-79]|9[145])1","(?:1[2-8]|2[2-69]|3[2-4]|4[1-468]|5[24-689]|6[1-3578]|7[14-7]|8[1-79]|9[145])19"]],["(\\d{3})(\\d{2})(\\d{2,3})","$1 $2 $3",["64"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["21|39|45|5[0137]|6[0469]|7[02389]|8(?:0[14]|8)"]],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["1[2-8]|[2-7]|8[1-79]|9[145]"]],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["8"]]]],"PM":["508","00","[45]\\d{5}|(?:708|80\\d)\\d{6}",[6,9],[["(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3",["[45]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["7"]],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"],"0$1"]],"0"],"PR":["1","011","(?:[589]\\d\\d|787)\\d{7}",[10],0,"1",0,0,0,0,"787|939"],"PS":["970","00","[2489]2\\d{6}|(?:1\\d|5)\\d{8}",[8,9,10],[["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["[2489]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["5"],"0$1"],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["1"]]],"0"],"PT":["351","00","1693\\d{5}|(?:[26-9]\\d|30)\\d{7}",[9],[["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["2[12]"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["16|[236-9]"]]]],"PW":["680","01[12]","(?:[24-8]\\d\\d|345|900)\\d{4}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[2-9]"]]]],"PY":["595","00","59\\d{4,6}|9\\d{5,10}|(?:[2-46-8]\\d|5[0-8])\\d{4,7}",[6,7,8,9,10,11],[["(\\d{3})(\\d{3,6})","$1 $2",["[2-9]0"],"0$1"],["(\\d{2})(\\d{5})","$1 $2",["[26]1|3[289]|4[1246-8]|7[1-3]|8[1-36]"],"(0$1)"],["(\\d{3})(\\d{4,5})","$1 $2",["2[279]|3[13-5]|4[359]|5|6(?:[34]|7[1-46-8])|7[46-8]|85"],"(0$1)"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["2[14-68]|3[26-9]|4[1246-8]|6(?:1|75)|7[1-35]|8[1-36]"],"(0$1)"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["87"]],["(\\d{3})(\\d{6})","$1 $2",["9(?:[5-79]|8[1-6])"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[2-8]"],"0$1"],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["9"]]],"0"],"QA":["974","00","800\\d{4}|(?:2|800)\\d{6}|(?:0080|[3-7])\\d{7}",[7,8,9,11],[["(\\d{3})(\\d{4})","$1 $2",["2[16]|8"]],["(\\d{4})(\\d{4})","$1 $2",["[3-7]"]]]],"RE":["262","00","(?:26|[689]\\d)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[2689]"],"0$1"]],"0",0,0,0,0,0,[["26(?:2\\d\\d|3(?:0\\d|1[0-3]))\\d{4}"],["(?:69(?:2\\d\\d|3(?:0[0-46]|1[013]|2[0-2]|3[0-39]|4\\d|5[0-5]|6[0-6]|7[0-27]|8[0-8]|9[0-479]))|9(?:399[0-3]|479[0-2]|76(?:2[27]|3[0-37]|9\\d)))\\d{4}"],["80\\d{7}"],["89[1-37-9]\\d{6}"],0,0,0,0,0,["8(?:1[019]|2[0156]|84|90)\\d{6}"]]],"RO":["40","00","(?:[2378]\\d|90)\\d{7}|[23]\\d{5}",[6,9],[["(\\d{3})(\\d{3})","$1 $2",["2[3-6]","2[3-6]\\d9"],"0$1"],["(\\d{2})(\\d{4})","$1 $2",["219|31"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[23]1"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[237-9]"],"0$1"]],"0",0,0,0,0,0,0,0," int "],"RS":["381","00","38[02-9]\\d{6,9}|6\\d{7,9}|90\\d{4,8}|38\\d{5,6}|(?:7\\d\\d|800)\\d{3,9}|(?:[12]\\d|3[0-79])\\d{5,10}",[6,7,8,9,10,11,12],[["(\\d{3})(\\d{3,9})","$1 $2",["(?:2[389]|39)0|[7-9]"],"0$1"],["(\\d{2})(\\d{5,10})","$1 $2",["[1-36]"],"0$1"]],"0"],"RU":["7","810","8\\d{13}|[347-9]\\d{9}",[10,14],[["(\\d{4})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["7(?:1[0-8]|2[1-9])","7(?:1(?:[0-356]2|4[29]|7|8[27])|2(?:1[23]|[2-9]2))","7(?:1(?:[0-356]2|4[29]|7|8[27])|2(?:13[03-69]|62[013-9]))|72[1-57-9]2"],"8 ($1)",1],["(\\d{5})(\\d)(\\d{2})(\\d{2})","$1 $2 $3 $4",["7(?:1[0-68]|2[1-9])","7(?:1(?:[06][3-6]|[18]|2[35]|[3-5][3-5])|2(?:[13][3-5]|[24-689]|7[457]))","7(?:1(?:0(?:[356]|4[023])|[18]|2(?:3[013-9]|5)|3[45]|43[013-79]|5(?:3[1-8]|4[1-7]|5)|6(?:3[0-35-9]|[4-6]))|2(?:1(?:3[178]|[45])|[24-689]|3[35]|7[457]))|7(?:14|23)4[0-8]|71(?:33|45)[1-79]"],"8 ($1)",1],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["7"],"8 ($1)",1],["(\\d{3})(\\d{3})(\\d{2})(\\d{2})","$1 $2-$3-$4",["[349]|8(?:[02-7]|1[1-8])"],"8 ($1)",1],["(\\d{4})(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3 $4",["8"],"8 ($1)"]],"8",0,0,0,0,"3[04-689]|[489]",0,"8~10"],"RW":["250","00","(?:06|[27]\\d\\d|[89]00)\\d{6}",[8,9],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["0"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[7-9]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["2"]]],"0"],"SA":["966","00","92\\d{7}|(?:[15]|8\\d)\\d{8}",[9,10],[["(\\d{4})(\\d{5})","$1 $2",["9"]],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["1"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["5"],"0$1"],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["81"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["8"]]],"0"],"SB":["677","0[01]","(?:[1-6]|[7-9]\\d\\d)\\d{4}",[5,7],[["(\\d{2})(\\d{5})","$1 $2",["7|8[4-9]|9(?:[1-8]|9[0-8])"]]]],"SC":["248","010|0[0-2]","800\\d{4}|(?:[249]\\d|64)\\d{5}",[7],[["(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["[246]|9[57]"]]],0,0,0,0,0,0,0,"00"],"SD":["249","00","[19]\\d{8}",[9],[["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[19]"],"0$1"]],"0"],"SE":["46","00","(?:[26]\\d\\d|9)\\d{9}|[1-9]\\d{8}|[1-689]\\d{7}|[1-4689]\\d{6}|2\\d{5}",[6,7,8,9,10],[["(\\d{2})(\\d{2,3})(\\d{2})","$1-$2 $3",["20"],"0$1",0,"$1 $2 $3"],["(\\d{3})(\\d{4})","$1-$2",["9(?:00|39|44|9)"],"0$1",0,"$1 $2"],["(\\d{2})(\\d{3})(\\d{2})","$1-$2 $3",["[12][136]|3[356]|4[0246]|6[03]|90[1-9]"],"0$1",0,"$1 $2 $3"],["(\\d)(\\d{2,3})(\\d{2})(\\d{2})","$1-$2 $3 $4",["8"],"0$1",0,"$1 $2 $3 $4"],["(\\d{3})(\\d{2,3})(\\d{2})","$1-$2 $3",["1[2457]|2(?:[247-9]|5[0138])|3[0247-9]|4[1357-9]|5[0-35-9]|6(?:[125689]|4[02-57]|7[0-2])|9(?:[125-8]|3[02-5]|4[0-3])"],"0$1",0,"$1 $2 $3"],["(\\d{3})(\\d{2,3})(\\d{3})","$1-$2 $3",["9(?:00|39|44)"],"0$1",0,"$1 $2 $3"],["(\\d{2})(\\d{2,3})(\\d{2})(\\d{2})","$1-$2 $3 $4",["1[13689]|2[0136]|3[1356]|4[0246]|54|6[03]|90[1-9]"],"0$1",0,"$1 $2 $3 $4"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1-$2 $3 $4",["10|7"],"0$1",0,"$1 $2 $3 $4"],["(\\d)(\\d{3})(\\d{3})(\\d{2})","$1-$2 $3 $4",["8"],"0$1",0,"$1 $2 $3 $4"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1-$2 $3 $4",["[13-5]|2(?:[247-9]|5[0138])|6(?:[124-689]|7[0-2])|9(?:[125-8]|3[02-5]|4[0-3])"],"0$1",0,"$1 $2 $3 $4"],["(\\d{3})(\\d{2})(\\d{2})(\\d{3})","$1-$2 $3 $4",["9"],"0$1",0,"$1 $2 $3 $4"],["(\\d{3})(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1-$2 $3 $4 $5",["[26]"],"0$1",0,"$1 $2 $3 $4 $5"]],"0"],"SG":["65","0[0-3]\\d","(?:(?:1\\d|8)\\d\\d|7000)\\d{7}|[3689]\\d{7}",[8,10,11],[["(\\d{4})(\\d{4})","$1 $2",["[369]|8(?:0[1-6]|[1-9])"]],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["8"]],["(\\d{4})(\\d{4})(\\d{3})","$1 $2 $3",["7"]],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["1"]]]],"SH":["290","00","(?:[256]\\d|8)\\d{3}",[4,5],0,0,0,0,0,0,"[256]"],"SI":["386","00|10(?:22|66|88|99)","[1-7]\\d{7}|8\\d{4,7}|90\\d{4,6}",[5,6,7,8],[["(\\d{2})(\\d{3,6})","$1 $2",["8[09]|9"],"0$1"],["(\\d{3})(\\d{5})","$1 $2",["59|8"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[37][01]|4[0139]|51|6"],"0$1"],["(\\d)(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[1-57]"],"(0$1)"]],"0",0,0,0,0,0,0,"00"],"SJ":["47","00","0\\d{4}|(?:[489]\\d|[57]9)\\d{6}",[5,8],0,0,0,0,0,0,"79"],"SK":["421","00","[2-689]\\d{8}|[2-59]\\d{6}|[2-5]\\d{5}",[6,7,9],[["(\\d)(\\d{2})(\\d{3,4})","$1 $2 $3",["21"],"0$1"],["(\\d{2})(\\d{2})(\\d{2,3})","$1 $2 $3",["[3-5][1-8]1","[3-5][1-8]1[67]"],"0$1"],["(\\d)(\\d{3})(\\d{3})(\\d{2})","$1/$2 $3 $4",["2"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[689]"],"0$1"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1/$2 $3 $4",["[3-5]"],"0$1"]],"0"],"SL":["232","00","(?:[237-9]\\d|66)\\d{6}",[8],[["(\\d{2})(\\d{6})","$1 $2",["[236-9]"],"(0$1)"]],"0"],"SM":["378","00","(?:0549|[5-7]\\d)\\d{6}",[8,10],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[5-7]"]],["(\\d{4})(\\d{6})","$1 $2",["0"]]],0,0,"([89]\\d{5})$","0549$1"],"SN":["221","00","(?:[378]\\d|93)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"]],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[379]"]]]],"SO":["252","00","[346-9]\\d{8}|[12679]\\d{7}|[1-5]\\d{6}|[1348]\\d{5}",[6,7,8,9],[["(\\d{2})(\\d{4})","$1 $2",["8[125]"]],["(\\d{6})","$1",["[134]"]],["(\\d)(\\d{6})","$1 $2",["[15]|2[0-79]|3[0-46-8]|4[0-7]"]],["(\\d)(\\d{7})","$1 $2",["(?:2|90)4|[67]"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[3478]|64|90"]],["(\\d{2})(\\d{5,7})","$1 $2",["1|28|6(?:0[5-7]|[1-35-9])|9[2-9]"]]],"0"],"SR":["597","00","(?:[2-5]|68|[78]\\d)\\d{5}",[6,7],[["(\\d{2})(\\d{2})(\\d{2})","$1-$2-$3",["56"]],["(\\d{3})(\\d{3})","$1-$2",["[2-5]"]],["(\\d{3})(\\d{4})","$1-$2",["[6-8]"]]]],"SS":["211","00","[19]\\d{8}",[9],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[19]"],"0$1"]],"0"],"ST":["239","00","(?:22|9\\d)\\d{5}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[29]"]]]],"SV":["503","00","[267]\\d{7}|[89]00\\d{4}(?:\\d{4})?",[7,8,11],[["(\\d{3})(\\d{4})","$1 $2",["[89]"]],["(\\d{4})(\\d{4})","$1 $2",["[267]"]],["(\\d{3})(\\d{4})(\\d{4})","$1 $2 $3",["[89]"]]]],"SX":["1","011","7215\\d{6}|(?:[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"(5\\d{6})$|1","721$1",0,"721"],"SY":["963","00","[1-39]\\d{8}|[1-5]\\d{7}",[8,9],[["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[1-5]"],"0$1",1],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["9"],"0$1",1]],"0"],"SZ":["268","00","0800\\d{4}|(?:[237]\\d|900)\\d{6}",[8,9],[["(\\d{4})(\\d{4})","$1 $2",["[0237]"]],["(\\d{5})(\\d{4})","$1 $2",["9"]]]],"TA":["290","00","8\\d{3}",[4],0,0,0,0,0,0,"8"],"TC":["1","011","(?:[58]\\d\\d|649|900)\\d{7}",[10],0,"1",0,"([2-479]\\d{6})$|1","649$1",0,"649"],"TD":["235","00|16","(?:22|[69]\\d|77)\\d{6}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[2679]"]]],0,0,0,0,0,0,0,"00"],"TG":["228","00","[279]\\d{7}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[279]"]]]],"TH":["66","00[1-9]","(?:001800|[2-57]|[689]\\d)\\d{7}|1\\d{7,9}",[8,9,10,13],[["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["2"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[13-9]"],"0$1"],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["1"]]],"0"],"TJ":["992","810","[0-57-9]\\d{8}",[9],[["(\\d{6})(\\d)(\\d{2})","$1 $2 $3",["331","3317"]],["(\\d{3})(\\d{2})(\\d{4})","$1 $2 $3",["[34]7|91[78]"]],["(\\d{4})(\\d)(\\d{4})","$1 $2 $3",["3[1-5]"]],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[0-57-9]"]]],0,0,0,0,0,0,0,"8~10"],"TK":["690","00","[2-47]\\d{3,6}",[4,5,6,7]],"TL":["670","00","7\\d{7}|(?:[2-47]\\d|[89]0)\\d{5}",[7,8],[["(\\d{3})(\\d{4})","$1 $2",["[2-489]|70"]],["(\\d{4})(\\d{4})","$1 $2",["7"]]]],"TM":["993","810","[1-6]\\d{7}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2-$3-$4",["12"],"(8 $1)"],["(\\d{3})(\\d)(\\d{2})(\\d{2})","$1 $2-$3-$4",["[1-5]"],"(8 $1)"],["(\\d{2})(\\d{6})","$1 $2",["6"],"8 $1"]],"8",0,0,0,0,0,0,"8~10"],"TN":["216","00","[2-57-9]\\d{7}",[8],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[2-57-9]"]]]],"TO":["676","00","(?:0800|(?:[5-8]\\d\\d|999)\\d)\\d{3}|[2-8]\\d{4}",[5,7],[["(\\d{2})(\\d{3})","$1-$2",["[2-4]|50|6[09]|7[0-24-69]|8[05]"]],["(\\d{4})(\\d{3})","$1 $2",["0"]],["(\\d{3})(\\d{4})","$1 $2",["[5-9]"]]]],"TR":["90","00","4\\d{6}|8\\d{11,12}|(?:[2-58]\\d\\d|900)\\d{7}",[7,10,12,13],[["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["512|8[01589]|90"],"0$1",1],["(\\d{3})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["5(?:[0-59]|61)","5(?:[0-59]|616)","5(?:[0-59]|6161)"],"0$1",1],["(\\d{3})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[24][1-8]|3[1-9]"],"(0$1)",1],["(\\d{3})(\\d{3})(\\d{6,7})","$1 $2 $3",["80"],"0$1",1]],"0"],"TT":["1","011","(?:[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([2-46-8]\\d{6})$|1","868$1",0,"868"],"TV":["688","00","(?:2|7\\d\\d|90)\\d{4}",[5,6,7],[["(\\d{2})(\\d{3})","$1 $2",["2"]],["(\\d{2})(\\d{4})","$1 $2",["90"]],["(\\d{2})(\\d{5})","$1 $2",["7"]]]],"TW":["886","0(?:0[25-79]|19)","[2-689]\\d{8}|7\\d{9,10}|[2-8]\\d{7}|2\\d{6}",[7,8,9,10,11],[["(\\d{2})(\\d)(\\d{4})","$1 $2 $3",["202"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[258]0"],"0$1"],["(\\d)(\\d{3,4})(\\d{4})","$1 $2 $3",["[23568]|4(?:0[02-48]|[1-47-9])|7[1-9]","[23568]|4(?:0[2-48]|[1-47-9])|(?:400|7)[1-9]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[49]"],"0$1"],["(\\d{2})(\\d{4})(\\d{4,5})","$1 $2 $3",["7"],"0$1"]],"0",0,0,0,0,0,0,0,"#"],"TZ":["255","00[056]","(?:[25-8]\\d|41|90)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{4})","$1 $2 $3",["[89]"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[24]"],"0$1"],["(\\d{2})(\\d{7})","$1 $2",["5"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[67]"],"0$1"]],"0"],"UA":["380","00","[89]\\d{9}|[3-9]\\d{8}",[9,10],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["6[12][29]|(?:3[1-8]|4[136-8]|5[12457]|6[49])2|(?:56|65)[24]","6[12][29]|(?:35|4[1378]|5[12457]|6[49])2|(?:56|65)[24]|(?:3[1-46-8]|46)2[013-9]"],"0$1"],["(\\d{4})(\\d{5})","$1 $2",["3[1-8]|4(?:[1367]|[45][6-9]|8[4-6])|5(?:[1-5]|6[0135689]|7[4-6])|6(?:[12][3-7]|[459])","3[1-8]|4(?:[1367]|[45][6-9]|8[4-6])|5(?:[1-5]|6(?:[015689]|3[02389])|7[4-6])|6(?:[12][3-7]|[459])"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[3-7]|89|9[1-9]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["[89]"],"0$1"]],"0",0,0,0,0,0,0,"0~0"],"UG":["256","00[057]","800\\d{6}|(?:[29]0|[347]\\d)\\d{7}",[9],[["(\\d{4})(\\d{5})","$1 $2",["202","2024"],"0$1"],["(\\d{3})(\\d{6})","$1 $2",["[27-9]|4(?:6[45]|[7-9])"],"0$1"],["(\\d{2})(\\d{7})","$1 $2",["[34]"],"0$1"]],"0"],"US":["1","011","[2-9]\\d{9}|3\\d{6}",[10],[["(\\d{3})(\\d{4})","$1-$2",["310"],0,1],["(\\d{3})(\\d{3})(\\d{4})","($1) $2-$3",["[2-9]"],0,1,"$1-$2-$3"]],"1",0,0,0,0,0,[["5056(?:[0-35-9]\\d|4[46])\\d{4}|(?:4722|505[2-57-9])\\d{6}|(?:2(?:0[1-35-9]|1[02-9]|2[03-589]|3[149]|4[08]|5[1-46]|6[0279]|7[0269]|8[13])|3(?:0[1-57-9]|1[02-9]|2[01356]|3[0-24679]|4[167]|5[0-2]|6[014]|8[056])|4(?:0[124-9]|1[02-579]|2[3-5]|3[0245]|4[023578]|58|6[349]|7[0589]|8[04])|5(?:0[1-47-9]|1[0235-8]|20|3[0149]|4[01]|5[179]|6[1-47]|7[0-5]|8[0256])|6(?:0[1-35-9]|1[024-9]|2[03689]|[34][016]|5[01679]|6[0-279]|78|8[0-29])|7(?:0[1-46-8]|1[2-9]|2[04-7]|3[1247]|4[037]|5[47]|6[02359]|7[0-59]|8[156])|8(?:0[1-68]|1[02-8]|2[068]|3[0-2589]|4[03578]|5[046-9]|6[02-5]|7[028])|9(?:0[1346-9]|1[02-9]|2[0589]|3[0146-8]|4[01357-9]|5[12469]|7[0-389]|8[04-69]))[2-9]\\d{6}"],[""],["8(?:00|33|44|55|66|77|88)[2-9]\\d{6}"],["900[2-9]\\d{6}"],["52(?:3(?:[2-46-9][02-9]\\d|5(?:[02-46-9]\\d|5[0-46-9]))|4(?:[2-478][02-9]\\d|5(?:[034]\\d|2[024-9]|5[0-46-9])|6(?:0[1-9]|[2-9]\\d)|9(?:[05-9]\\d|2[0-5]|49)))\\d{4}|52[34][2-9]1[02-9]\\d{4}|5(?:00|2[125-9]|33|44|66|77|88)[2-9]\\d{6}"]]],"UY":["598","0(?:0|1[3-9]\\d)","(?:0004|4)\\d{9}|[1249]\\d{7}|(?:[49]\\d|80)\\d{5}",[7,8,10,13],[["(\\d{3})(\\d{4})","$1 $2",["405|8|90"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["9"],"0$1"],["(\\d{4})(\\d{4})","$1 $2",["[124]"]],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["4"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3 $4",["0"]]],"0",0,0,0,0,0,0,"00"," int. "],"UZ":["998","810","(?:33|[5-79]\\d|88)\\d{7}",[9],[["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[35-9]"],"8 $1"]],"8",0,0,0,0,0,0,"8~10"],"VA":["39","00","0\\d{5,10}|3[0-8]\\d{7,10}|55\\d{8}|8\\d{5}(?:\\d{2,4})?|(?:1\\d|39)\\d{7,8}",[6,7,8,9,10,11],0,0,0,0,0,0,"06698"],"VC":["1","011","(?:[58]\\d\\d|784|900)\\d{7}",[10],0,"1",0,"([2-7]\\d{6})$|1","784$1",0,"784"],"VE":["58","00","[68]00\\d{7}|(?:[24]\\d|[59]0)\\d{8}",[10],[["(\\d{3})(\\d{7})","$1-$2",["[24-689]"],"0$1"]],"0"],"VG":["1","011","(?:284|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([2-578]\\d{6})$|1","284$1",0,"284"],"VI":["1","011","[58]\\d{9}|(?:34|90)0\\d{7}",[10],0,"1",0,"([2-9]\\d{6})$|1","340$1",0,"340"],"VN":["84","00","[12]\\d{9}|[135-9]\\d{8}|[16]\\d{7}|[16-8]\\d{6}",[7,8,9,10],[["(\\d{2})(\\d{5})","$1 $2",["80"],"0$1",1],["(\\d{4})(\\d{4,6})","$1 $2",["1"],0,1],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[69]"],"0$1",1],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[3578]"],"0$1",1],["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["2[48]"],"0$1",1],["(\\d{3})(\\d{4})(\\d{3})","$1 $2 $3",["2"],"0$1",1]],"0"],"VU":["678","00","[57-9]\\d{6}|(?:[238]\\d|48)\\d{3}",[5,7],[["(\\d{3})(\\d{4})","$1 $2",["[57-9]"]]]],"WF":["681","00","(?:40|72)\\d{4}|8\\d{5}(?:\\d{3})?",[6,9],[["(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3",["[478]"]],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"]]]],"WS":["685","0","(?:[2-6]|8\\d{5})\\d{4}|[78]\\d{6}|[68]\\d{5}",[5,6,7,10],[["(\\d{5})","$1",["[2-5]|6[1-9]"]],["(\\d{3})(\\d{3,7})","$1 $2",["[68]"]],["(\\d{2})(\\d{5})","$1 $2",["7"]]]],"XK":["383","00","[23]\\d{7,8}|(?:4\\d\\d|[89]00)\\d{5}",[8,9],[["(\\d{3})(\\d{5})","$1 $2",["[89]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[2-4]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[23]"],"0$1"]],"0"],"YE":["967","00","(?:1|7\\d)\\d{7}|[1-7]\\d{6}",[7,8,9],[["(\\d)(\\d{3})(\\d{3,4})","$1 $2 $3",["[1-6]|7(?:[24-6]|8[0-7])"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["7"],"0$1"]],"0"],"YT":["262","00","(?:(?:(?:26|63)9|80\\d)\\d|9398)\\d{5}",[9],0,"0",0,0,0,0,"269|63|9398"],"ZA":["27","00","[1-79]\\d{8}|8\\d{4,9}",[5,6,7,8,9,10],[["(\\d{2})(\\d{3,4})","$1 $2",["8[1-4]"],"0$1"],["(\\d{2})(\\d{3})(\\d{2,3})","$1 $2 $3",["8[1-4]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["860"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[1-9]"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["8"],"0$1"]],"0"],"ZM":["260","00","800\\d{6}|(?:21|63|[79]\\d)\\d{7}",[9],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[28]"],"0$1"],["(\\d{2})(\\d{7})","$1 $2",["[79]"],"0$1"]],"0"],"ZW":["263","00","2(?:[0-57-9]\\d{6,8}|6[0-24-9]\\d{6,7})|[38]\\d{9}|[35-8]\\d{8}|[3-6]\\d{7}|[1-689]\\d{6}|[1-3569]\\d{5}|[1356]\\d{4}",[5,6,7,8,9,10],[["(\\d{3})(\\d{3,5})","$1 $2",["2(?:0[45]|2[278]|[49]8)|3(?:[09]8|17)|6(?:[29]8|37|75)|[23][78]|(?:33|5[15]|6[68])[78]"],"0$1"],["(\\d)(\\d{3})(\\d{2,4})","$1 $2 $3",["[49]"],"0$1"],["(\\d{3})(\\d{4})","$1 $2",["80"],"0$1"],["(\\d{2})(\\d{7})","$1 $2",["24|8[13-59]|(?:2[05-79]|39|5[45]|6[15-8])2","2(?:02[014]|4|[56]20|[79]2)|392|5(?:42|525)|6(?:[16-8]21|52[013])|8[13-59]"],"(0$1)"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["7"],"0$1"],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["2(?:1[39]|2[0157]|[378]|[56][14])|3(?:12|29)","2(?:1[39]|2[0157]|[378]|[56][14])|3(?:123|29)"],"0$1"],["(\\d{4})(\\d{6})","$1 $2",["8"],"0$1"],["(\\d{2})(\\d{3,5})","$1 $2",["1|2(?:0[0-36-9]|12|29|[56])|3(?:1[0-689]|[24-6])|5(?:[0236-9]|1[2-4])|6(?:[013-59]|7[0-46-9])|(?:33|55|6[68])[0-69]|(?:29|3[09]|62)[0-79]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["29[013-9]|39|54"],"0$1"],["(\\d{4})(\\d{3,5})","$1 $2",["(?:25|54)8","258|5483"],"0$1"]],"0"]},"nonGeographic":{"800":["800",0,"(?:00|[1-9]\\d)\\d{6}",[8],[["(\\d{4})(\\d{4})","$1 $2",["\\d"]]],0,0,0,0,0,0,[0,0,["(?:00|[1-9]\\d)\\d{6}"]]],"808":["808",0,"[1-9]\\d{7}",[8],[["(\\d{4})(\\d{4})","$1 $2",["[1-9]"]]],0,0,0,0,0,0,[0,0,0,0,0,0,0,0,0,["[1-9]\\d{7}"]]],"870":["870",0,"7\\d{11}|[35-7]\\d{8}",[9,12],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[35-7]"]]],0,0,0,0,0,0,[0,["(?:[356]|774[45])\\d{8}|7[6-8]\\d{7}"]]],"878":["878",0,"10\\d{10}",[12],[["(\\d{2})(\\d{5})(\\d{5})","$1 $2 $3",["1"]]],0,0,0,0,0,0,[0,0,0,0,0,0,0,0,["10\\d{10}"]]],"881":["881",0,"[0-36-9]\\d{8}",[9],[["(\\d)(\\d{3})(\\d{5})","$1 $2 $3",["[0-36-9]"]]],0,0,0,0,0,0,[0,["[0-36-9]\\d{8}"]]],"882":["882",0,"[13]\\d{6}(?:\\d{2,5})?|[19]\\d{7}|(?:[25]\\d\\d|4)\\d{7}(?:\\d{2})?",[7,8,9,10,11,12],[["(\\d{2})(\\d{5})","$1 $2",["16|342"]],["(\\d{2})(\\d{6})","$1 $2",["49"]],["(\\d{2})(\\d{2})(\\d{4})","$1 $2 $3",["1[36]|9"]],["(\\d{2})(\\d{4})(\\d{3})","$1 $2 $3",["3[23]"]],["(\\d{2})(\\d{3,4})(\\d{4})","$1 $2 $3",["16"]],["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["10|23|3(?:[15]|4[57])|4|51"]],["(\\d{3})(\\d{4})(\\d{4})","$1 $2 $3",["34"]],["(\\d{2})(\\d{4,5})(\\d{5})","$1 $2 $3",["[1-35]"]]],0,0,0,0,0,0,[0,["342\\d{4}|(?:337|49)\\d{6}|(?:3(?:2|47|7\\d{3})|50\\d{3})\\d{7}",[7,8,9,10,12]],0,0,0,0,0,0,["1(?:3(?:0[0347]|[13][0139]|2[035]|4[013568]|6[0459]|7[06]|8[15-8]|9[0689])\\d{4}|6\\d{5,10})|(?:345\\d|9[89])\\d{6}|(?:10|2(?:3|85\\d)|3(?:[15]|[69]\\d\\d)|4[15-8]|51)\\d{8}"]]],"883":["883",0,"(?:[1-4]\\d|51)\\d{6,10}",[8,9,10,11,12],[["(\\d{3})(\\d{3})(\\d{2,8})","$1 $2 $3",["[14]|2[24-689]|3[02-689]|51[24-9]"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["510"]],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["21"]],["(\\d{4})(\\d{4})(\\d{4})","$1 $2 $3",["51[13]"]],["(\\d{3})(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["[235]"]]],0,0,0,0,0,0,[0,0,0,0,0,0,0,0,["(?:2(?:00\\d\\d|10)|(?:370[1-9]|51\\d0)\\d)\\d{7}|51(?:00\\d{5}|[24-9]0\\d{4,7})|(?:1[013-79]|2[24-689]|3[02-689]|4[0-4])0\\d{5,9}"]]],"888":["888",0,"\\d{11}",[11],[["(\\d{3})(\\d{3})(\\d{5})","$1 $2 $3"]],0,0,0,0,0,0,[0,0,0,0,0,0,["\\d{11}"]]],"979":["979",0,"[1359]\\d{8}",[9],[["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["[1359]"]]],0,0,0,0,0,0,[0,0,0,["[1359]\\d{8}"]]]}};
199
+
200
+ // Importing from a ".js" file is a workaround for Node.js "ES Modules"
201
+
202
+ function withMetadataArgument(func, _arguments) {
203
+ var args = Array.prototype.slice.call(_arguments);
204
+ args.push(metadata);
205
+ return func.apply(this, args)
206
+ }
207
+
208
+ function _typeof$2(obj) { "@babel/helpers - typeof"; return _typeof$2 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof$2(obj); }
209
+
210
+ function _defineProperties$2(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
211
+
212
+ function _createClass$2(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$2(Constructor.prototype, protoProps); if (staticProps) _defineProperties$2(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
213
+
214
+ function _classCallCheck$2(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
215
+
216
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
217
+
218
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
219
+
220
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof$2(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
221
+
222
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
223
+
224
+ function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }
225
+
226
+ function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
227
+
228
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
229
+
230
+ function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; }
231
+
232
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
233
+
234
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
235
+
236
+ // https://stackoverflow.com/a/46971044/970769
237
+ // "Breaking changes in Typescript 2.1"
238
+ // "Extending built-ins like Error, Array, and Map may no longer work."
239
+ // "As a recommendation, you can manually adjust the prototype immediately after any super(...) calls."
240
+ // https://github.com/Microsoft/TypeScript-wiki/blob/main/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work
241
+ var ParseError = /*#__PURE__*/function (_Error) {
242
+ _inherits(ParseError, _Error);
243
+
244
+ var _super = _createSuper(ParseError);
245
+
246
+ function ParseError(code) {
247
+ var _this;
248
+
249
+ _classCallCheck$2(this, ParseError);
250
+
251
+ _this = _super.call(this, code); // Set the prototype explicitly.
252
+ // Any subclass of FooError will have to manually set the prototype as well.
253
+
254
+ Object.setPrototypeOf(_assertThisInitialized(_this), ParseError.prototype);
255
+ _this.name = _this.constructor.name;
256
+ return _this;
257
+ }
258
+
259
+ return _createClass$2(ParseError);
260
+ }( /*#__PURE__*/_wrapNativeSuper(Error));
261
+
262
+ // The minimum length of the national significant number.
263
+ var MIN_LENGTH_FOR_NSN = 2; // The ITU says the maximum length should be 15,
264
+ // but one can find longer numbers in Germany.
265
+
266
+ var MAX_LENGTH_FOR_NSN = 17; // The maximum length of the country calling code.
267
+
268
+ var MAX_LENGTH_COUNTRY_CODE = 3; // Digits accepted in phone numbers
269
+ // (ascii, fullwidth, arabic-indic, and eastern arabic digits).
270
+
271
+ var VALID_DIGITS = "0-9\uFF10-\uFF19\u0660-\u0669\u06F0-\u06F9"; // `DASHES` will be right after the opening square bracket of the "character class"
272
+
273
+ var DASHES = "-\u2010-\u2015\u2212\u30FC\uFF0D";
274
+ var SLASHES = "\uFF0F/";
275
+ var DOTS = "\uFF0E.";
276
+ var WHITESPACE = " \xA0\xAD\u200B\u2060\u3000";
277
+ var BRACKETS = "()\uFF08\uFF09\uFF3B\uFF3D\\[\\]"; // export const OPENING_BRACKETS = '(\uFF08\uFF3B\\\['
278
+
279
+ var TILDES = "~\u2053\u223C\uFF5E"; // Regular expression of acceptable punctuation found in phone numbers. This
280
+ // excludes punctuation found as a leading character only. This consists of dash
281
+ // characters, white space characters, full stops, slashes, square brackets,
282
+ // parentheses and tildes. Full-width variants are also present.
283
+
284
+ var VALID_PUNCTUATION = "".concat(DASHES).concat(SLASHES).concat(DOTS).concat(WHITESPACE).concat(BRACKETS).concat(TILDES);
285
+ var PLUS_CHARS = "+\uFF0B"; // const LEADING_PLUS_CHARS_PATTERN = new RegExp('^[' + PLUS_CHARS + ']+')
286
+
287
+ // Copy-pasted from:
288
+ // https://github.com/substack/semver-compare/blob/master/index.js
289
+ //
290
+ // Inlining this function because some users reported issues with
291
+ // importing from `semver-compare` in a browser with ES6 "native" modules.
292
+ //
293
+ // Fixes `semver-compare` not being able to compare versions with alpha/beta/etc "tags".
294
+ // https://github.com/catamphetamine/libphonenumber-js/issues/381
295
+ function compare (a, b) {
296
+ a = a.split('-');
297
+ b = b.split('-');
298
+ var pa = a[0].split('.');
299
+ var pb = b[0].split('.');
300
+
301
+ for (var i = 0; i < 3; i++) {
302
+ var na = Number(pa[i]);
303
+ var nb = Number(pb[i]);
304
+ if (na > nb) return 1;
305
+ if (nb > na) return -1;
306
+ if (!isNaN(na) && isNaN(nb)) return 1;
307
+ if (isNaN(na) && !isNaN(nb)) return -1;
308
+ }
309
+
310
+ if (a[1] && b[1]) {
311
+ return a[1] > b[1] ? 1 : a[1] < b[1] ? -1 : 0;
312
+ }
313
+
314
+ return !a[1] && b[1] ? 1 : a[1] && !b[1] ? -1 : 0;
315
+ }
316
+
317
+ function _typeof$1(obj) { "@babel/helpers - typeof"; return _typeof$1 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof$1(obj); }
318
+
319
+ function _classCallCheck$1(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
320
+
321
+ function _defineProperties$1(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
322
+
323
+ function _createClass$1(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$1(Constructor.prototype, protoProps); if (staticProps) _defineProperties$1(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
324
+
325
+ var V3 = '1.2.0'; // Moved `001` country code to "nonGeographic" section of metadata.
326
+
327
+ var V4 = '1.7.35';
328
+ var DEFAULT_EXT_PREFIX = ' ext. ';
329
+ var CALLING_CODE_REG_EXP = /^\d+$/;
330
+ /**
331
+ * See: https://gitlab.com/catamphetamine/libphonenumber-js/blob/master/METADATA.md
332
+ */
333
+
334
+ var Metadata = /*#__PURE__*/function () {
335
+ function Metadata(metadata) {
336
+ _classCallCheck$1(this, Metadata);
337
+
338
+ validateMetadata(metadata);
339
+ this.metadata = metadata;
340
+ setVersion.call(this, metadata);
341
+ }
342
+
343
+ _createClass$1(Metadata, [{
344
+ key: "getCountries",
345
+ value: function getCountries() {
346
+ return Object.keys(this.metadata.countries).filter(function (_) {
347
+ return _ !== '001';
348
+ });
349
+ }
350
+ }, {
351
+ key: "getCountryMetadata",
352
+ value: function getCountryMetadata(countryCode) {
353
+ return this.metadata.countries[countryCode];
354
+ }
355
+ }, {
356
+ key: "nonGeographic",
357
+ value: function nonGeographic() {
358
+ if (this.v1 || this.v2 || this.v3) return; // `nonGeographical` was a typo.
359
+ // It's present in metadata generated from `1.7.35` to `1.7.37`.
360
+ // The test case could be found by searching for "nonGeographical".
361
+
362
+ return this.metadata.nonGeographic || this.metadata.nonGeographical;
363
+ }
364
+ }, {
365
+ key: "hasCountry",
366
+ value: function hasCountry(country) {
367
+ return this.getCountryMetadata(country) !== undefined;
368
+ }
369
+ }, {
370
+ key: "hasCallingCode",
371
+ value: function hasCallingCode(callingCode) {
372
+ if (this.getCountryCodesForCallingCode(callingCode)) {
373
+ return true;
374
+ }
375
+
376
+ if (this.nonGeographic()) {
377
+ if (this.nonGeographic()[callingCode]) {
378
+ return true;
379
+ }
380
+ } else {
381
+ // A hacky workaround for old custom metadata (generated before V4).
382
+ var countryCodes = this.countryCallingCodes()[callingCode];
383
+
384
+ if (countryCodes && countryCodes.length === 1 && countryCodes[0] === '001') {
385
+ return true;
386
+ }
387
+ }
388
+ }
389
+ }, {
390
+ key: "isNonGeographicCallingCode",
391
+ value: function isNonGeographicCallingCode(callingCode) {
392
+ if (this.nonGeographic()) {
393
+ return this.nonGeographic()[callingCode] ? true : false;
394
+ } else {
395
+ return this.getCountryCodesForCallingCode(callingCode) ? false : true;
396
+ }
397
+ } // Deprecated.
398
+
399
+ }, {
400
+ key: "country",
401
+ value: function country(countryCode) {
402
+ return this.selectNumberingPlan(countryCode);
403
+ }
404
+ }, {
405
+ key: "selectNumberingPlan",
406
+ value: function selectNumberingPlan(countryCode, callingCode) {
407
+ // Supports just passing `callingCode` as the first argument.
408
+ if (countryCode && CALLING_CODE_REG_EXP.test(countryCode)) {
409
+ callingCode = countryCode;
410
+ countryCode = null;
411
+ }
412
+
413
+ if (countryCode && countryCode !== '001') {
414
+ if (!this.hasCountry(countryCode)) {
415
+ throw new Error("Unknown country: ".concat(countryCode));
416
+ }
417
+
418
+ this.numberingPlan = new NumberingPlan(this.getCountryMetadata(countryCode), this);
419
+ } else if (callingCode) {
420
+ if (!this.hasCallingCode(callingCode)) {
421
+ throw new Error("Unknown calling code: ".concat(callingCode));
422
+ }
423
+
424
+ this.numberingPlan = new NumberingPlan(this.getNumberingPlanMetadata(callingCode), this);
425
+ } else {
426
+ this.numberingPlan = undefined;
427
+ }
428
+
429
+ return this;
430
+ }
431
+ }, {
432
+ key: "getCountryCodesForCallingCode",
433
+ value: function getCountryCodesForCallingCode(callingCode) {
434
+ var countryCodes = this.countryCallingCodes()[callingCode];
435
+
436
+ if (countryCodes) {
437
+ // Metadata before V4 included "non-geographic entity" calling codes
438
+ // inside `country_calling_codes` (for example, `"881":["001"]`).
439
+ // Now the semantics of `country_calling_codes` has changed:
440
+ // it's specifically for "countries" now.
441
+ // Older versions of custom metadata will simply skip parsing
442
+ // "non-geographic entity" phone numbers with new versions
443
+ // of this library: it's not considered a bug,
444
+ // because such numbers are extremely rare,
445
+ // and developers extremely rarely use custom metadata.
446
+ if (countryCodes.length === 1 && countryCodes[0].length === 3) {
447
+ return;
448
+ }
449
+
450
+ return countryCodes;
451
+ }
452
+ }
453
+ }, {
454
+ key: "getCountryCodeForCallingCode",
455
+ value: function getCountryCodeForCallingCode(callingCode) {
456
+ var countryCodes = this.getCountryCodesForCallingCode(callingCode);
457
+
458
+ if (countryCodes) {
459
+ return countryCodes[0];
460
+ }
461
+ }
462
+ }, {
463
+ key: "getNumberingPlanMetadata",
464
+ value: function getNumberingPlanMetadata(callingCode) {
465
+ var countryCode = this.getCountryCodeForCallingCode(callingCode);
466
+
467
+ if (countryCode) {
468
+ return this.getCountryMetadata(countryCode);
469
+ }
470
+
471
+ if (this.nonGeographic()) {
472
+ var metadata = this.nonGeographic()[callingCode];
473
+
474
+ if (metadata) {
475
+ return metadata;
476
+ }
477
+ } else {
478
+ // A hacky workaround for old custom metadata (generated before V4).
479
+ // In that metadata, there was no concept of "non-geographic" metadata
480
+ // so metadata for `001` country code was stored along with other countries.
481
+ // The test case can be found by searching for:
482
+ // "should work around `nonGeographic` metadata not existing".
483
+ var countryCodes = this.countryCallingCodes()[callingCode];
484
+
485
+ if (countryCodes && countryCodes.length === 1 && countryCodes[0] === '001') {
486
+ return this.metadata.countries['001'];
487
+ }
488
+ }
489
+ } // Deprecated.
490
+
491
+ }, {
492
+ key: "countryCallingCode",
493
+ value: function countryCallingCode() {
494
+ return this.numberingPlan.callingCode();
495
+ } // Deprecated.
496
+
497
+ }, {
498
+ key: "IDDPrefix",
499
+ value: function IDDPrefix() {
500
+ return this.numberingPlan.IDDPrefix();
501
+ } // Deprecated.
502
+
503
+ }, {
504
+ key: "defaultIDDPrefix",
505
+ value: function defaultIDDPrefix() {
506
+ return this.numberingPlan.defaultIDDPrefix();
507
+ } // Deprecated.
508
+
509
+ }, {
510
+ key: "nationalNumberPattern",
511
+ value: function nationalNumberPattern() {
512
+ return this.numberingPlan.nationalNumberPattern();
513
+ } // Deprecated.
514
+
515
+ }, {
516
+ key: "possibleLengths",
517
+ value: function possibleLengths() {
518
+ return this.numberingPlan.possibleLengths();
519
+ } // Deprecated.
520
+
521
+ }, {
522
+ key: "formats",
523
+ value: function formats() {
524
+ return this.numberingPlan.formats();
525
+ } // Deprecated.
526
+
527
+ }, {
528
+ key: "nationalPrefixForParsing",
529
+ value: function nationalPrefixForParsing() {
530
+ return this.numberingPlan.nationalPrefixForParsing();
531
+ } // Deprecated.
532
+
533
+ }, {
534
+ key: "nationalPrefixTransformRule",
535
+ value: function nationalPrefixTransformRule() {
536
+ return this.numberingPlan.nationalPrefixTransformRule();
537
+ } // Deprecated.
538
+
539
+ }, {
540
+ key: "leadingDigits",
541
+ value: function leadingDigits() {
542
+ return this.numberingPlan.leadingDigits();
543
+ } // Deprecated.
544
+
545
+ }, {
546
+ key: "hasTypes",
547
+ value: function hasTypes() {
548
+ return this.numberingPlan.hasTypes();
549
+ } // Deprecated.
550
+
551
+ }, {
552
+ key: "type",
553
+ value: function type(_type) {
554
+ return this.numberingPlan.type(_type);
555
+ } // Deprecated.
556
+
557
+ }, {
558
+ key: "ext",
559
+ value: function ext() {
560
+ return this.numberingPlan.ext();
561
+ }
562
+ }, {
563
+ key: "countryCallingCodes",
564
+ value: function countryCallingCodes() {
565
+ if (this.v1) return this.metadata.country_phone_code_to_countries;
566
+ return this.metadata.country_calling_codes;
567
+ } // Deprecated.
568
+
569
+ }, {
570
+ key: "chooseCountryByCountryCallingCode",
571
+ value: function chooseCountryByCountryCallingCode(callingCode) {
572
+ return this.selectNumberingPlan(callingCode);
573
+ }
574
+ }, {
575
+ key: "hasSelectedNumberingPlan",
576
+ value: function hasSelectedNumberingPlan() {
577
+ return this.numberingPlan !== undefined;
578
+ }
579
+ }]);
580
+
581
+ return Metadata;
582
+ }();
583
+
584
+ var NumberingPlan = /*#__PURE__*/function () {
585
+ function NumberingPlan(metadata, globalMetadataObject) {
586
+ _classCallCheck$1(this, NumberingPlan);
587
+
588
+ this.globalMetadataObject = globalMetadataObject;
589
+ this.metadata = metadata;
590
+ setVersion.call(this, globalMetadataObject.metadata);
591
+ }
592
+
593
+ _createClass$1(NumberingPlan, [{
594
+ key: "callingCode",
595
+ value: function callingCode() {
596
+ return this.metadata[0];
597
+ } // Formatting information for regions which share
598
+ // a country calling code is contained by only one region
599
+ // for performance reasons. For example, for NANPA region
600
+ // ("North American Numbering Plan Administration",
601
+ // which includes USA, Canada, Cayman Islands, Bahamas, etc)
602
+ // it will be contained in the metadata for `US`.
603
+
604
+ }, {
605
+ key: "getDefaultCountryMetadataForRegion",
606
+ value: function getDefaultCountryMetadataForRegion() {
607
+ return this.globalMetadataObject.getNumberingPlanMetadata(this.callingCode());
608
+ } // Is always present.
609
+
610
+ }, {
611
+ key: "IDDPrefix",
612
+ value: function IDDPrefix() {
613
+ if (this.v1 || this.v2) return;
614
+ return this.metadata[1];
615
+ } // Is only present when a country supports multiple IDD prefixes.
616
+
617
+ }, {
618
+ key: "defaultIDDPrefix",
619
+ value: function defaultIDDPrefix() {
620
+ if (this.v1 || this.v2) return;
621
+ return this.metadata[12];
622
+ }
623
+ }, {
624
+ key: "nationalNumberPattern",
625
+ value: function nationalNumberPattern() {
626
+ if (this.v1 || this.v2) return this.metadata[1];
627
+ return this.metadata[2];
628
+ } // "possible length" data is always present in Google's metadata.
629
+
630
+ }, {
631
+ key: "possibleLengths",
632
+ value: function possibleLengths() {
633
+ if (this.v1) return;
634
+ return this.metadata[this.v2 ? 2 : 3];
635
+ }
636
+ }, {
637
+ key: "_getFormats",
638
+ value: function _getFormats(metadata) {
639
+ return metadata[this.v1 ? 2 : this.v2 ? 3 : 4];
640
+ } // For countries of the same region (e.g. NANPA)
641
+ // formats are all stored in the "main" country for that region.
642
+ // E.g. "RU" and "KZ", "US" and "CA".
643
+
644
+ }, {
645
+ key: "formats",
646
+ value: function formats() {
647
+ var _this = this;
648
+
649
+ var formats = this._getFormats(this.metadata) || this._getFormats(this.getDefaultCountryMetadataForRegion()) || [];
650
+ return formats.map(function (_) {
651
+ return new Format(_, _this);
652
+ });
653
+ }
654
+ }, {
655
+ key: "nationalPrefix",
656
+ value: function nationalPrefix() {
657
+ return this.metadata[this.v1 ? 3 : this.v2 ? 4 : 5];
658
+ }
659
+ }, {
660
+ key: "_getNationalPrefixFormattingRule",
661
+ value: function _getNationalPrefixFormattingRule(metadata) {
662
+ return metadata[this.v1 ? 4 : this.v2 ? 5 : 6];
663
+ } // For countries of the same region (e.g. NANPA)
664
+ // national prefix formatting rule is stored in the "main" country for that region.
665
+ // E.g. "RU" and "KZ", "US" and "CA".
666
+
667
+ }, {
668
+ key: "nationalPrefixFormattingRule",
669
+ value: function nationalPrefixFormattingRule() {
670
+ return this._getNationalPrefixFormattingRule(this.metadata) || this._getNationalPrefixFormattingRule(this.getDefaultCountryMetadataForRegion());
671
+ }
672
+ }, {
673
+ key: "_nationalPrefixForParsing",
674
+ value: function _nationalPrefixForParsing() {
675
+ return this.metadata[this.v1 ? 5 : this.v2 ? 6 : 7];
676
+ }
677
+ }, {
678
+ key: "nationalPrefixForParsing",
679
+ value: function nationalPrefixForParsing() {
680
+ // If `national_prefix_for_parsing` is not set explicitly,
681
+ // then infer it from `national_prefix` (if any)
682
+ return this._nationalPrefixForParsing() || this.nationalPrefix();
683
+ }
684
+ }, {
685
+ key: "nationalPrefixTransformRule",
686
+ value: function nationalPrefixTransformRule() {
687
+ return this.metadata[this.v1 ? 6 : this.v2 ? 7 : 8];
688
+ }
689
+ }, {
690
+ key: "_getNationalPrefixIsOptionalWhenFormatting",
691
+ value: function _getNationalPrefixIsOptionalWhenFormatting() {
692
+ return !!this.metadata[this.v1 ? 7 : this.v2 ? 8 : 9];
693
+ } // For countries of the same region (e.g. NANPA)
694
+ // "national prefix is optional when formatting" flag is
695
+ // stored in the "main" country for that region.
696
+ // E.g. "RU" and "KZ", "US" and "CA".
697
+
698
+ }, {
699
+ key: "nationalPrefixIsOptionalWhenFormattingInNationalFormat",
700
+ value: function nationalPrefixIsOptionalWhenFormattingInNationalFormat() {
701
+ return this._getNationalPrefixIsOptionalWhenFormatting(this.metadata) || this._getNationalPrefixIsOptionalWhenFormatting(this.getDefaultCountryMetadataForRegion());
702
+ }
703
+ }, {
704
+ key: "leadingDigits",
705
+ value: function leadingDigits() {
706
+ return this.metadata[this.v1 ? 8 : this.v2 ? 9 : 10];
707
+ }
708
+ }, {
709
+ key: "types",
710
+ value: function types() {
711
+ return this.metadata[this.v1 ? 9 : this.v2 ? 10 : 11];
712
+ }
713
+ }, {
714
+ key: "hasTypes",
715
+ value: function hasTypes() {
716
+ // Versions 1.2.0 - 1.2.4: can be `[]`.
717
+
718
+ /* istanbul ignore next */
719
+ if (this.types() && this.types().length === 0) {
720
+ return false;
721
+ } // Versions <= 1.2.4: can be `undefined`.
722
+ // Version >= 1.2.5: can be `0`.
723
+
724
+
725
+ return !!this.types();
726
+ }
727
+ }, {
728
+ key: "type",
729
+ value: function type(_type2) {
730
+ if (this.hasTypes() && getType(this.types(), _type2)) {
731
+ return new Type(getType(this.types(), _type2), this);
732
+ }
733
+ }
734
+ }, {
735
+ key: "ext",
736
+ value: function ext() {
737
+ if (this.v1 || this.v2) return DEFAULT_EXT_PREFIX;
738
+ return this.metadata[13] || DEFAULT_EXT_PREFIX;
739
+ }
740
+ }]);
741
+
742
+ return NumberingPlan;
743
+ }();
744
+
745
+ var Format = /*#__PURE__*/function () {
746
+ function Format(format, metadata) {
747
+ _classCallCheck$1(this, Format);
748
+
749
+ this._format = format;
750
+ this.metadata = metadata;
751
+ }
752
+
753
+ _createClass$1(Format, [{
754
+ key: "pattern",
755
+ value: function pattern() {
756
+ return this._format[0];
757
+ }
758
+ }, {
759
+ key: "format",
760
+ value: function format() {
761
+ return this._format[1];
762
+ }
763
+ }, {
764
+ key: "leadingDigitsPatterns",
765
+ value: function leadingDigitsPatterns() {
766
+ return this._format[2] || [];
767
+ }
768
+ }, {
769
+ key: "nationalPrefixFormattingRule",
770
+ value: function nationalPrefixFormattingRule() {
771
+ return this._format[3] || this.metadata.nationalPrefixFormattingRule();
772
+ }
773
+ }, {
774
+ key: "nationalPrefixIsOptionalWhenFormattingInNationalFormat",
775
+ value: function nationalPrefixIsOptionalWhenFormattingInNationalFormat() {
776
+ return !!this._format[4] || this.metadata.nationalPrefixIsOptionalWhenFormattingInNationalFormat();
777
+ }
778
+ }, {
779
+ key: "nationalPrefixIsMandatoryWhenFormattingInNationalFormat",
780
+ value: function nationalPrefixIsMandatoryWhenFormattingInNationalFormat() {
781
+ // National prefix is omitted if there's no national prefix formatting rule
782
+ // set for this country, or when the national prefix formatting rule
783
+ // contains no national prefix itself, or when this rule is set but
784
+ // national prefix is optional for this phone number format
785
+ // (and it is not enforced explicitly)
786
+ return this.usesNationalPrefix() && !this.nationalPrefixIsOptionalWhenFormattingInNationalFormat();
787
+ } // Checks whether national prefix formatting rule contains national prefix.
788
+
789
+ }, {
790
+ key: "usesNationalPrefix",
791
+ value: function usesNationalPrefix() {
792
+ return this.nationalPrefixFormattingRule() && // Check that national prefix formatting rule is not a "dummy" one.
793
+ !FIRST_GROUP_ONLY_PREFIX_PATTERN.test(this.nationalPrefixFormattingRule()) // In compressed metadata, `this.nationalPrefixFormattingRule()` is `0`
794
+ // when `national_prefix_formatting_rule` is not present.
795
+ // So, `true` or `false` are returned explicitly here, so that
796
+ // `0` number isn't returned.
797
+ ? true : false;
798
+ }
799
+ }, {
800
+ key: "internationalFormat",
801
+ value: function internationalFormat() {
802
+ return this._format[5] || this.format();
803
+ }
804
+ }]);
805
+
806
+ return Format;
807
+ }();
808
+ /**
809
+ * A pattern that is used to determine if the national prefix formatting rule
810
+ * has the first group only, i.e., does not start with the national prefix.
811
+ * Note that the pattern explicitly allows for unbalanced parentheses.
812
+ */
813
+
814
+
815
+ var FIRST_GROUP_ONLY_PREFIX_PATTERN = /^\(?\$1\)?$/;
816
+
817
+ var Type = /*#__PURE__*/function () {
818
+ function Type(type, metadata) {
819
+ _classCallCheck$1(this, Type);
820
+
821
+ this.type = type;
822
+ this.metadata = metadata;
823
+ }
824
+
825
+ _createClass$1(Type, [{
826
+ key: "pattern",
827
+ value: function pattern() {
828
+ if (this.metadata.v1) return this.type;
829
+ return this.type[0];
830
+ }
831
+ }, {
832
+ key: "possibleLengths",
833
+ value: function possibleLengths() {
834
+ if (this.metadata.v1) return;
835
+ return this.type[1] || this.metadata.possibleLengths();
836
+ }
837
+ }]);
838
+
839
+ return Type;
840
+ }();
841
+
842
+ function getType(types, type) {
843
+ switch (type) {
844
+ case 'FIXED_LINE':
845
+ return types[0];
846
+
847
+ case 'MOBILE':
848
+ return types[1];
849
+
850
+ case 'TOLL_FREE':
851
+ return types[2];
852
+
853
+ case 'PREMIUM_RATE':
854
+ return types[3];
855
+
856
+ case 'PERSONAL_NUMBER':
857
+ return types[4];
858
+
859
+ case 'VOICEMAIL':
860
+ return types[5];
861
+
862
+ case 'UAN':
863
+ return types[6];
864
+
865
+ case 'PAGER':
866
+ return types[7];
867
+
868
+ case 'VOIP':
869
+ return types[8];
870
+
871
+ case 'SHARED_COST':
872
+ return types[9];
873
+ }
874
+ }
875
+
876
+ function validateMetadata(metadata) {
877
+ if (!metadata) {
878
+ throw new Error('[libphonenumber-js] `metadata` argument not passed. Check your arguments.');
879
+ } // `country_phone_code_to_countries` was renamed to
880
+ // `country_calling_codes` in `1.0.18`.
881
+
882
+
883
+ if (!is_object(metadata) || !is_object(metadata.countries)) {
884
+ throw new Error("[libphonenumber-js] `metadata` argument was passed but it's not a valid metadata. Must be an object having `.countries` child object property. Got ".concat(is_object(metadata) ? 'an object of shape: { ' + Object.keys(metadata).join(', ') + ' }' : 'a ' + type_of(metadata) + ': ' + metadata, "."));
885
+ }
886
+ } // Babel transforms `typeof` into some "branches"
887
+ // so istanbul will show this as "branch not covered".
888
+
889
+ /* istanbul ignore next */
890
+
891
+ var is_object = function is_object(_) {
892
+ return _typeof$1(_) === 'object';
893
+ }; // Babel transforms `typeof` into some "branches"
894
+ // so istanbul will show this as "branch not covered".
895
+
896
+ /* istanbul ignore next */
897
+
898
+
899
+ var type_of = function type_of(_) {
900
+ return _typeof$1(_);
901
+ };
902
+ /**
903
+ * Returns "country calling code" for a country.
904
+ * Throws an error if the country doesn't exist or isn't supported by this library.
905
+ * @param {string} country
906
+ * @param {object} metadata
907
+ * @return {string}
908
+ * @example
909
+ * // Returns "44"
910
+ * getCountryCallingCode("GB")
911
+ */
912
+
913
+ function getCountryCallingCode(country, metadata) {
914
+ metadata = new Metadata(metadata);
915
+
916
+ if (metadata.hasCountry(country)) {
917
+ return metadata.country(country).countryCallingCode();
918
+ }
919
+
920
+ throw new Error("Unknown country: ".concat(country));
921
+ }
922
+ function isSupportedCountry(country, metadata) {
923
+ // metadata = new Metadata(metadata)
924
+ // return metadata.hasCountry(country)
925
+ return metadata.countries[country] !== undefined;
926
+ }
927
+
928
+ function setVersion(metadata) {
929
+ var version = metadata.version;
930
+
931
+ if (typeof version === 'number') {
932
+ this.v1 = version === 1;
933
+ this.v2 = version === 2;
934
+ this.v3 = version === 3;
935
+ this.v4 = version === 4;
936
+ } else {
937
+ if (!version) {
938
+ this.v1 = true;
939
+ } else if (compare(version, V3) === -1) {
940
+ this.v2 = true;
941
+ } else if (compare(version, V4) === -1) {
942
+ this.v3 = true;
943
+ } else {
944
+ this.v4 = true;
945
+ }
946
+ }
947
+ } // const ISO_COUNTRY_CODE = /^[A-Z]{2}$/
948
+ // function isCountryCode(countryCode) {
949
+ // return ISO_COUNTRY_CODE.test(countryCodeOrCountryCallingCode)
950
+ // }
951
+
952
+ var RFC3966_EXTN_PREFIX = ';ext=';
953
+ /**
954
+ * Helper method for constructing regular expressions for parsing. Creates
955
+ * an expression that captures up to max_length digits.
956
+ * @return {string} RegEx pattern to capture extension digits.
957
+ */
958
+
959
+ var getExtensionDigitsPattern = function getExtensionDigitsPattern(maxLength) {
960
+ return "([".concat(VALID_DIGITS, "]{1,").concat(maxLength, "})");
961
+ };
962
+ /**
963
+ * Helper initialiser method to create the regular-expression pattern to match
964
+ * extensions.
965
+ * Copy-pasted from Google's `libphonenumber`:
966
+ * https://github.com/google/libphonenumber/blob/55b2646ec9393f4d3d6661b9c82ef9e258e8b829/javascript/i18n/phonenumbers/phonenumberutil.js#L759-L766
967
+ * @return {string} RegEx pattern to capture extensions.
968
+ */
969
+
970
+
971
+ function createExtensionPattern(purpose) {
972
+ // We cap the maximum length of an extension based on the ambiguity of the way
973
+ // the extension is prefixed. As per ITU, the officially allowed length for
974
+ // extensions is actually 40, but we don't support this since we haven't seen real
975
+ // examples and this introduces many false interpretations as the extension labels
976
+ // are not standardized.
977
+
978
+ /** @type {string} */
979
+ var extLimitAfterExplicitLabel = '20';
980
+ /** @type {string} */
981
+
982
+ var extLimitAfterLikelyLabel = '15';
983
+ /** @type {string} */
984
+
985
+ var extLimitAfterAmbiguousChar = '9';
986
+ /** @type {string} */
987
+
988
+ var extLimitWhenNotSure = '6';
989
+ /** @type {string} */
990
+
991
+ var possibleSeparatorsBetweenNumberAndExtLabel = "[ \xA0\\t,]*"; // Optional full stop (.) or colon, followed by zero or more spaces/tabs/commas.
992
+
993
+ /** @type {string} */
994
+
995
+ var possibleCharsAfterExtLabel = "[:\\.\uFF0E]?[ \xA0\\t,-]*";
996
+ /** @type {string} */
997
+
998
+ var optionalExtnSuffix = "#?"; // Here the extension is called out in more explicit way, i.e mentioning it obvious
999
+ // patterns like "ext.".
1000
+
1001
+ /** @type {string} */
1002
+
1003
+ var explicitExtLabels = "(?:e?xt(?:ensi(?:o\u0301?|\xF3))?n?|\uFF45?\uFF58\uFF54\uFF4E?|\u0434\u043E\u0431|anexo)"; // One-character symbols that can be used to indicate an extension, and less
1004
+ // commonly used or more ambiguous extension labels.
1005
+
1006
+ /** @type {string} */
1007
+
1008
+ var ambiguousExtLabels = "(?:[x\uFF58#\uFF03~\uFF5E]|int|\uFF49\uFF4E\uFF54)"; // When extension is not separated clearly.
1009
+
1010
+ /** @type {string} */
1011
+
1012
+ var ambiguousSeparator = "[- ]+"; // This is the same as possibleSeparatorsBetweenNumberAndExtLabel, but not matching
1013
+ // comma as extension label may have it.
1014
+
1015
+ /** @type {string} */
1016
+
1017
+ var possibleSeparatorsNumberExtLabelNoComma = "[ \xA0\\t]*"; // ",," is commonly used for auto dialling the extension when connected. First
1018
+ // comma is matched through possibleSeparatorsBetweenNumberAndExtLabel, so we do
1019
+ // not repeat it here. Semi-colon works in Iphone and Android also to pop up a
1020
+ // button with the extension number following.
1021
+
1022
+ /** @type {string} */
1023
+
1024
+ var autoDiallingAndExtLabelsFound = "(?:,{2}|;)";
1025
+ /** @type {string} */
1026
+
1027
+ var rfcExtn = RFC3966_EXTN_PREFIX + getExtensionDigitsPattern(extLimitAfterExplicitLabel);
1028
+ /** @type {string} */
1029
+
1030
+ var explicitExtn = possibleSeparatorsBetweenNumberAndExtLabel + explicitExtLabels + possibleCharsAfterExtLabel + getExtensionDigitsPattern(extLimitAfterExplicitLabel) + optionalExtnSuffix;
1031
+ /** @type {string} */
1032
+
1033
+ var ambiguousExtn = possibleSeparatorsBetweenNumberAndExtLabel + ambiguousExtLabels + possibleCharsAfterExtLabel + getExtensionDigitsPattern(extLimitAfterAmbiguousChar) + optionalExtnSuffix;
1034
+ /** @type {string} */
1035
+
1036
+ var americanStyleExtnWithSuffix = ambiguousSeparator + getExtensionDigitsPattern(extLimitWhenNotSure) + "#";
1037
+ /** @type {string} */
1038
+
1039
+ var autoDiallingExtn = possibleSeparatorsNumberExtLabelNoComma + autoDiallingAndExtLabelsFound + possibleCharsAfterExtLabel + getExtensionDigitsPattern(extLimitAfterLikelyLabel) + optionalExtnSuffix;
1040
+ /** @type {string} */
1041
+
1042
+ var onlyCommasExtn = possibleSeparatorsNumberExtLabelNoComma + "(?:,)+" + possibleCharsAfterExtLabel + getExtensionDigitsPattern(extLimitAfterAmbiguousChar) + optionalExtnSuffix; // The first regular expression covers RFC 3966 format, where the extension is added
1043
+ // using ";ext=". The second more generic where extension is mentioned with explicit
1044
+ // labels like "ext:". In both the above cases we allow more numbers in extension than
1045
+ // any other extension labels. The third one captures when single character extension
1046
+ // labels or less commonly used labels are used. In such cases we capture fewer
1047
+ // extension digits in order to reduce the chance of falsely interpreting two
1048
+ // numbers beside each other as a number + extension. The fourth one covers the
1049
+ // special case of American numbers where the extension is written with a hash
1050
+ // at the end, such as "- 503#". The fifth one is exclusively for extension
1051
+ // autodialling formats which are used when dialling and in this case we accept longer
1052
+ // extensions. The last one is more liberal on the number of commas that acts as
1053
+ // extension labels, so we have a strict cap on the number of digits in such extensions.
1054
+
1055
+ return rfcExtn + "|" + explicitExtn + "|" + ambiguousExtn + "|" + americanStyleExtnWithSuffix + "|" + autoDiallingExtn + "|" + onlyCommasExtn;
1056
+ }
1057
+
1058
+ // Checks we have at least three leading digits, and only valid punctuation,
1059
+ // alpha characters and digits in the phone number. Does not include extension
1060
+ // data. The symbol 'x' is allowed here as valid punctuation since it is often
1061
+ // used as a placeholder for carrier codes, for example in Brazilian phone
1062
+ // numbers. We also allow multiple '+' characters at the start.
1063
+ //
1064
+ // Corresponds to the following:
1065
+ // [digits]{minLengthNsn}|
1066
+ // plus_sign*
1067
+ // (([punctuation]|[star])*[digits]){3,}([punctuation]|[star]|[digits]|[alpha])*
1068
+ //
1069
+ // The first reg-ex is to allow short numbers (two digits long) to be parsed if
1070
+ // they are entered as "15" etc, but only if there is no punctuation in them.
1071
+ // The second expression restricts the number of digits to three or more, but
1072
+ // then allows them to be in international form, and to have alpha-characters
1073
+ // and punctuation. We split up the two reg-exes here and combine them when
1074
+ // creating the reg-ex VALID_PHONE_NUMBER_PATTERN itself so we can prefix it
1075
+ // with ^ and append $ to each branch.
1076
+ //
1077
+ // "Note VALID_PUNCTUATION starts with a -,
1078
+ // so must be the first in the range" (c) Google devs.
1079
+ // (wtf did they mean by saying that; probably nothing)
1080
+ //
1081
+
1082
+ var MIN_LENGTH_PHONE_NUMBER_PATTERN = '[' + VALID_DIGITS + ']{' + MIN_LENGTH_FOR_NSN + '}'; //
1083
+ // And this is the second reg-exp:
1084
+ // (see MIN_LENGTH_PHONE_NUMBER_PATTERN for a full description of this reg-exp)
1085
+ //
1086
+
1087
+ var VALID_PHONE_NUMBER = '[' + PLUS_CHARS + ']{0,1}' + '(?:' + '[' + VALID_PUNCTUATION + ']*' + '[' + VALID_DIGITS + ']' + '){3,}' + '[' + VALID_PUNCTUATION + VALID_DIGITS + ']*'; // This regular expression isn't present in Google's `libphonenumber`
1088
+ // and is only used to determine whether the phone number being input
1089
+ // is too short for it to even consider it a "valid" number.
1090
+ // This is just a way to differentiate between a really invalid phone
1091
+ // number like "abcde" and a valid phone number that a user has just
1092
+ // started inputting, like "+1" or "1": both these cases would be
1093
+ // considered `NOT_A_NUMBER` by Google's `libphonenumber`, but this
1094
+ // library can provide a more detailed error message — whether it's
1095
+ // really "not a number", or is it just a start of a valid phone number.
1096
+
1097
+ var VALID_PHONE_NUMBER_START_REG_EXP = new RegExp('^' + '[' + PLUS_CHARS + ']{0,1}' + '(?:' + '[' + VALID_PUNCTUATION + ']*' + '[' + VALID_DIGITS + ']' + '){1,2}' + '$', 'i');
1098
+ var VALID_PHONE_NUMBER_WITH_EXTENSION = VALID_PHONE_NUMBER + // Phone number extensions
1099
+ '(?:' + createExtensionPattern() + ')?'; // The combined regular expression for valid phone numbers:
1100
+ //
1101
+
1102
+ var VALID_PHONE_NUMBER_PATTERN = new RegExp( // Either a short two-digit-only phone number
1103
+ '^' + MIN_LENGTH_PHONE_NUMBER_PATTERN + '$' + '|' + // Or a longer fully parsed phone number (min 3 characters)
1104
+ '^' + VALID_PHONE_NUMBER_WITH_EXTENSION + '$', 'i'); // Checks to see if the string of characters could possibly be a phone number at
1105
+ // all. At the moment, checks to see that the string begins with at least 2
1106
+ // digits, ignoring any punctuation commonly found in phone numbers. This method
1107
+ // does not require the number to be normalized in advance - but does assume
1108
+ // that leading non-number symbols have been removed, such as by the method
1109
+ // `extract_possible_number`.
1110
+ //
1111
+
1112
+ function isViablePhoneNumber(number) {
1113
+ return number.length >= MIN_LENGTH_FOR_NSN && VALID_PHONE_NUMBER_PATTERN.test(number);
1114
+ } // This is just a way to differentiate between a really invalid phone
1115
+ // number like "abcde" and a valid phone number that a user has just
1116
+ // started inputting, like "+1" or "1": both these cases would be
1117
+ // considered `NOT_A_NUMBER` by Google's `libphonenumber`, but this
1118
+ // library can provide a more detailed error message — whether it's
1119
+ // really "not a number", or is it just a start of a valid phone number.
1120
+
1121
+ function isViablePhoneNumberStart(number) {
1122
+ return VALID_PHONE_NUMBER_START_REG_EXP.test(number);
1123
+ }
1124
+
1125
+ // 1 or more valid digits, for use when parsing.
1126
+
1127
+ var EXTN_PATTERN = new RegExp('(?:' + createExtensionPattern() + ')$', 'i'); // Strips any extension (as in, the part of the number dialled after the call is
1128
+ // connected, usually indicated with extn, ext, x or similar) from the end of
1129
+ // the number, and returns it.
1130
+
1131
+ function extractExtension(number) {
1132
+ var start = number.search(EXTN_PATTERN);
1133
+
1134
+ if (start < 0) {
1135
+ return {};
1136
+ } // If we find a potential extension, and the number preceding this is a viable
1137
+ // number, we assume it is an extension.
1138
+
1139
+
1140
+ var numberWithoutExtension = number.slice(0, start);
1141
+ var matches = number.match(EXTN_PATTERN);
1142
+ var i = 1;
1143
+
1144
+ while (i < matches.length) {
1145
+ if (matches[i]) {
1146
+ return {
1147
+ number: numberWithoutExtension,
1148
+ ext: matches[i]
1149
+ };
1150
+ }
1151
+
1152
+ i++;
1153
+ }
1154
+ }
1155
+
1156
+ // These mappings map a character (key) to a specific digit that should
1157
+ // replace it for normalization purposes. Non-European digits that
1158
+ // may be used in phone numbers are mapped to a European equivalent.
1159
+ //
1160
+ // E.g. in Iraq they don't write `+442323234` but rather `+٤٤٢٣٢٣٢٣٤`.
1161
+ //
1162
+ var DIGITS = {
1163
+ '0': '0',
1164
+ '1': '1',
1165
+ '2': '2',
1166
+ '3': '3',
1167
+ '4': '4',
1168
+ '5': '5',
1169
+ '6': '6',
1170
+ '7': '7',
1171
+ '8': '8',
1172
+ '9': '9',
1173
+ "\uFF10": '0',
1174
+ // Fullwidth digit 0
1175
+ "\uFF11": '1',
1176
+ // Fullwidth digit 1
1177
+ "\uFF12": '2',
1178
+ // Fullwidth digit 2
1179
+ "\uFF13": '3',
1180
+ // Fullwidth digit 3
1181
+ "\uFF14": '4',
1182
+ // Fullwidth digit 4
1183
+ "\uFF15": '5',
1184
+ // Fullwidth digit 5
1185
+ "\uFF16": '6',
1186
+ // Fullwidth digit 6
1187
+ "\uFF17": '7',
1188
+ // Fullwidth digit 7
1189
+ "\uFF18": '8',
1190
+ // Fullwidth digit 8
1191
+ "\uFF19": '9',
1192
+ // Fullwidth digit 9
1193
+ "\u0660": '0',
1194
+ // Arabic-indic digit 0
1195
+ "\u0661": '1',
1196
+ // Arabic-indic digit 1
1197
+ "\u0662": '2',
1198
+ // Arabic-indic digit 2
1199
+ "\u0663": '3',
1200
+ // Arabic-indic digit 3
1201
+ "\u0664": '4',
1202
+ // Arabic-indic digit 4
1203
+ "\u0665": '5',
1204
+ // Arabic-indic digit 5
1205
+ "\u0666": '6',
1206
+ // Arabic-indic digit 6
1207
+ "\u0667": '7',
1208
+ // Arabic-indic digit 7
1209
+ "\u0668": '8',
1210
+ // Arabic-indic digit 8
1211
+ "\u0669": '9',
1212
+ // Arabic-indic digit 9
1213
+ "\u06F0": '0',
1214
+ // Eastern-Arabic digit 0
1215
+ "\u06F1": '1',
1216
+ // Eastern-Arabic digit 1
1217
+ "\u06F2": '2',
1218
+ // Eastern-Arabic digit 2
1219
+ "\u06F3": '3',
1220
+ // Eastern-Arabic digit 3
1221
+ "\u06F4": '4',
1222
+ // Eastern-Arabic digit 4
1223
+ "\u06F5": '5',
1224
+ // Eastern-Arabic digit 5
1225
+ "\u06F6": '6',
1226
+ // Eastern-Arabic digit 6
1227
+ "\u06F7": '7',
1228
+ // Eastern-Arabic digit 7
1229
+ "\u06F8": '8',
1230
+ // Eastern-Arabic digit 8
1231
+ "\u06F9": '9' // Eastern-Arabic digit 9
1232
+
1233
+ };
1234
+ function parseDigit(character) {
1235
+ return DIGITS[character];
1236
+ }
1237
+
1238
+ function _createForOfIteratorHelperLoose$4(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray$5(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
1239
+
1240
+ function _unsupportedIterableToArray$5(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$5(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$5(o, minLen); }
1241
+
1242
+ function _arrayLikeToArray$5(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
1243
+ /**
1244
+ * Parses phone number characters from a string.
1245
+ * Drops all punctuation leaving only digits and the leading `+` sign (if any).
1246
+ * Also converts wide-ascii and arabic-indic numerals to conventional numerals.
1247
+ * E.g. in Iraq they don't write `+442323234` but rather `+٤٤٢٣٢٣٢٣٤`.
1248
+ * @param {string} string
1249
+ * @return {string}
1250
+ * @example
1251
+ * ```js
1252
+ * // Outputs '8800555'.
1253
+ * parseIncompletePhoneNumber('8 (800) 555')
1254
+ * // Outputs '+7800555'.
1255
+ * parseIncompletePhoneNumber('+7 800 555')
1256
+ * ```
1257
+ */
1258
+
1259
+ function parseIncompletePhoneNumber(string) {
1260
+ var result = ''; // Using `.split('')` here instead of normal `for ... of`
1261
+ // because the importing application doesn't neccessarily include an ES6 polyfill.
1262
+ // The `.split('')` approach discards "exotic" UTF-8 characters
1263
+ // (the ones consisting of four bytes) but digits
1264
+ // (including non-European ones) don't fall into that range
1265
+ // so such "exotic" characters would be discarded anyway.
1266
+
1267
+ for (var _iterator = _createForOfIteratorHelperLoose$4(string.split('')), _step; !(_step = _iterator()).done;) {
1268
+ var character = _step.value;
1269
+ result += parsePhoneNumberCharacter(character, result) || '';
1270
+ }
1271
+
1272
+ return result;
1273
+ }
1274
+ /**
1275
+ * Parses next character while parsing phone number digits (including a `+`)
1276
+ * from text: discards everything except `+` and digits, and `+` is only allowed
1277
+ * at the start of a phone number.
1278
+ * For example, is used in `react-phone-number-input` where it uses
1279
+ * [`input-format`](https://gitlab.com/catamphetamine/input-format).
1280
+ * @param {string} character - Yet another character from raw input string.
1281
+ * @param {string?} prevParsedCharacters - Previous parsed characters.
1282
+ * @param {object} meta - Optional custom use-case-specific metadata.
1283
+ * @return {string?} The parsed character.
1284
+ */
1285
+
1286
+ function parsePhoneNumberCharacter(character, prevParsedCharacters) {
1287
+ // Only allow a leading `+`.
1288
+ if (character === '+') {
1289
+ // If this `+` is not the first parsed character
1290
+ // then discard it.
1291
+ if (prevParsedCharacters) {
1292
+ return;
1293
+ }
1294
+
1295
+ return '+';
1296
+ } // Allow digits.
1297
+
1298
+
1299
+ return parseDigit(character);
1300
+ }
1301
+
1302
+ function _createForOfIteratorHelperLoose$3(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray$4(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
1303
+
1304
+ function _unsupportedIterableToArray$4(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$4(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$4(o, minLen); }
1305
+
1306
+ function _arrayLikeToArray$4(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
1307
+
1308
+ /**
1309
+ * Merges two arrays.
1310
+ * @param {*} a
1311
+ * @param {*} b
1312
+ * @return {*}
1313
+ */
1314
+ function mergeArrays(a, b) {
1315
+ var merged = a.slice();
1316
+
1317
+ for (var _iterator = _createForOfIteratorHelperLoose$3(b), _step; !(_step = _iterator()).done;) {
1318
+ var element = _step.value;
1319
+
1320
+ if (a.indexOf(element) < 0) {
1321
+ merged.push(element);
1322
+ }
1323
+ }
1324
+
1325
+ return merged.sort(function (a, b) {
1326
+ return a - b;
1327
+ }); // ES6 version, requires Set polyfill.
1328
+ // let merged = new Set(a)
1329
+ // for (const element of b) {
1330
+ // merged.add(i)
1331
+ // }
1332
+ // return Array.from(merged).sort((a, b) => a - b)
1333
+ }
1334
+
1335
+ function checkNumberLength(nationalNumber, metadata) {
1336
+ return checkNumberLengthForType(nationalNumber, undefined, metadata);
1337
+ } // Checks whether a number is possible for the country based on its length.
1338
+ // Should only be called for the "new" metadata which has "possible lengths".
1339
+
1340
+ function checkNumberLengthForType(nationalNumber, type, metadata) {
1341
+ var type_info = metadata.type(type); // There should always be "<possiblePengths/>" set for every type element.
1342
+ // This is declared in the XML schema.
1343
+ // For size efficiency, where a sub-description (e.g. fixed-line)
1344
+ // has the same "<possiblePengths/>" as the "general description", this is missing,
1345
+ // so we fall back to the "general description". Where no numbers of the type
1346
+ // exist at all, there is one possible length (-1) which is guaranteed
1347
+ // not to match the length of any real phone number.
1348
+
1349
+ var possible_lengths = type_info && type_info.possibleLengths() || metadata.possibleLengths(); // let local_lengths = type_info && type.possibleLengthsLocal() || metadata.possibleLengthsLocal()
1350
+ // Metadata before version `1.0.18` didn't contain `possible_lengths`.
1351
+
1352
+ if (!possible_lengths) {
1353
+ return 'IS_POSSIBLE';
1354
+ }
1355
+
1356
+ if (type === 'FIXED_LINE_OR_MOBILE') {
1357
+ // No such country in metadata.
1358
+
1359
+ /* istanbul ignore next */
1360
+ if (!metadata.type('FIXED_LINE')) {
1361
+ // The rare case has been encountered where no fixedLine data is available
1362
+ // (true for some non-geographic entities), so we just check mobile.
1363
+ return checkNumberLengthForType(nationalNumber, 'MOBILE', metadata);
1364
+ }
1365
+
1366
+ var mobile_type = metadata.type('MOBILE');
1367
+
1368
+ if (mobile_type) {
1369
+ // Merge the mobile data in if there was any. "Concat" creates a new
1370
+ // array, it doesn't edit possible_lengths in place, so we don't need a copy.
1371
+ // Note that when adding the possible lengths from mobile, we have
1372
+ // to again check they aren't empty since if they are this indicates
1373
+ // they are the same as the general desc and should be obtained from there.
1374
+ possible_lengths = mergeArrays(possible_lengths, mobile_type.possibleLengths()); // The current list is sorted; we need to merge in the new list and
1375
+ // re-sort (duplicates are okay). Sorting isn't so expensive because
1376
+ // the lists are very small.
1377
+ // if (local_lengths) {
1378
+ // local_lengths = mergeArrays(local_lengths, mobile_type.possibleLengthsLocal())
1379
+ // } else {
1380
+ // local_lengths = mobile_type.possibleLengthsLocal()
1381
+ // }
1382
+ }
1383
+ } // If the type doesn't exist then return 'INVALID_LENGTH'.
1384
+ else if (type && !type_info) {
1385
+ return 'INVALID_LENGTH';
1386
+ }
1387
+
1388
+ var actual_length = nationalNumber.length; // In `libphonenumber-js` all "local-only" formats are dropped for simplicity.
1389
+ // // This is safe because there is never an overlap beween the possible lengths
1390
+ // // and the local-only lengths; this is checked at build time.
1391
+ // if (local_lengths && local_lengths.indexOf(nationalNumber.length) >= 0)
1392
+ // {
1393
+ // return 'IS_POSSIBLE_LOCAL_ONLY'
1394
+ // }
1395
+
1396
+ var minimum_length = possible_lengths[0];
1397
+
1398
+ if (minimum_length === actual_length) {
1399
+ return 'IS_POSSIBLE';
1400
+ }
1401
+
1402
+ if (minimum_length > actual_length) {
1403
+ return 'TOO_SHORT';
1404
+ }
1405
+
1406
+ if (possible_lengths[possible_lengths.length - 1] < actual_length) {
1407
+ return 'TOO_LONG';
1408
+ } // We skip the first element since we've already checked it.
1409
+
1410
+
1411
+ return possible_lengths.indexOf(actual_length, 1) >= 0 ? 'IS_POSSIBLE' : 'INVALID_LENGTH';
1412
+ }
1413
+
1414
+ /**
1415
+ * Checks if a phone number is "possible" (basically just checks its length).
1416
+ *
1417
+ * isPossible(phoneNumberInstance, { ..., v2: true }, metadata)
1418
+ *
1419
+ * isPossible({ phone: '8005553535', country: 'RU' }, { ... }, metadata)
1420
+ * isPossible({ phone: '8005553535', country: 'RU' }, undefined, metadata)
1421
+ *
1422
+ * @param {object|PhoneNumber} input — If `options.v2: true` flag is passed, the `input` should be a `PhoneNumber` instance. Otherwise, it should be an object of shape `{ phone: '...', country: '...' }`.
1423
+ * @param {object} [options]
1424
+ * @param {object} metadata
1425
+ * @return {string}
1426
+ */
1427
+
1428
+ function isPossiblePhoneNumber(input, options, metadata) {
1429
+ /* istanbul ignore if */
1430
+ if (options === undefined) {
1431
+ options = {};
1432
+ }
1433
+
1434
+ metadata = new Metadata(metadata);
1435
+
1436
+ if (options.v2) {
1437
+ if (!input.countryCallingCode) {
1438
+ throw new Error('Invalid phone number object passed');
1439
+ }
1440
+
1441
+ metadata.selectNumberingPlan(input.countryCallingCode);
1442
+ } else {
1443
+ if (!input.phone) {
1444
+ return false;
1445
+ }
1446
+
1447
+ if (input.country) {
1448
+ if (!metadata.hasCountry(input.country)) {
1449
+ throw new Error("Unknown country: ".concat(input.country));
1450
+ }
1451
+
1452
+ metadata.country(input.country);
1453
+ } else {
1454
+ if (!input.countryCallingCode) {
1455
+ throw new Error('Invalid phone number object passed');
1456
+ }
1457
+
1458
+ metadata.selectNumberingPlan(input.countryCallingCode);
1459
+ }
1460
+ } // Old metadata (< 1.0.18) had no "possible length" data.
1461
+
1462
+
1463
+ if (metadata.possibleLengths()) {
1464
+ return isPossibleNumber(input.phone || input.nationalNumber, metadata);
1465
+ } else {
1466
+ // There was a bug between `1.7.35` and `1.7.37` where "possible_lengths"
1467
+ // were missing for "non-geographical" numbering plans.
1468
+ // Just assume the number is possible in such cases:
1469
+ // it's unlikely that anyone generated their custom metadata
1470
+ // in that short period of time (one day).
1471
+ // This code can be removed in some future major version update.
1472
+ if (input.countryCallingCode && metadata.isNonGeographicCallingCode(input.countryCallingCode)) {
1473
+ // "Non-geographic entities" did't have `possibleLengths`
1474
+ // due to a bug in metadata generation process.
1475
+ return true;
1476
+ } else {
1477
+ throw new Error('Missing "possibleLengths" in metadata. Perhaps the metadata has been generated before v1.0.18.');
1478
+ }
1479
+ }
1480
+ }
1481
+ function isPossibleNumber(nationalNumber, metadata) {
1482
+ //, isInternational) {
1483
+ switch (checkNumberLength(nationalNumber, metadata)) {
1484
+ case 'IS_POSSIBLE':
1485
+ return true;
1486
+ // This library ignores "local-only" phone numbers (for simplicity).
1487
+ // See the readme for more info on what are "local-only" phone numbers.
1488
+ // case 'IS_POSSIBLE_LOCAL_ONLY':
1489
+ // return !isInternational
1490
+
1491
+ default:
1492
+ return false;
1493
+ }
1494
+ }
1495
+
1496
+ /**
1497
+ * Checks whether the entire input sequence can be matched
1498
+ * against the regular expression.
1499
+ * @return {boolean}
1500
+ */
1501
+ function matchesEntirely(text, regular_expression) {
1502
+ // If assigning the `''` default value is moved to the arguments above,
1503
+ // code coverage would decrease for some weird reason.
1504
+ text = text || '';
1505
+ return new RegExp('^(?:' + regular_expression + ')$').test(text);
1506
+ }
1507
+
1508
+ function _createForOfIteratorHelperLoose$2(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray$3(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
1509
+
1510
+ function _unsupportedIterableToArray$3(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$3(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$3(o, minLen); }
1511
+
1512
+ function _arrayLikeToArray$3(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
1513
+ var NON_FIXED_LINE_PHONE_TYPES = ['MOBILE', 'PREMIUM_RATE', 'TOLL_FREE', 'SHARED_COST', 'VOIP', 'PERSONAL_NUMBER', 'PAGER', 'UAN', 'VOICEMAIL']; // Finds out national phone number type (fixed line, mobile, etc)
1514
+
1515
+ function getNumberType(input, options, metadata) {
1516
+ // If assigning the `{}` default value is moved to the arguments above,
1517
+ // code coverage would decrease for some weird reason.
1518
+ options = options || {}; // When `parse()` returned `{}`
1519
+ // meaning that the phone number is not a valid one.
1520
+
1521
+ if (!input.country) {
1522
+ return;
1523
+ }
1524
+
1525
+ metadata = new Metadata(metadata);
1526
+ metadata.selectNumberingPlan(input.country, input.countryCallingCode);
1527
+ var nationalNumber = options.v2 ? input.nationalNumber : input.phone; // The following is copy-pasted from the original function:
1528
+ // https://github.com/googlei18n/libphonenumber/blob/3ea547d4fbaa2d0b67588904dfa5d3f2557c27ff/javascript/i18n/phonenumbers/phonenumberutil.js#L2835
1529
+ // Is this national number even valid for this country
1530
+
1531
+ if (!matchesEntirely(nationalNumber, metadata.nationalNumberPattern())) {
1532
+ return;
1533
+ } // Is it fixed line number
1534
+
1535
+
1536
+ if (isNumberTypeEqualTo(nationalNumber, 'FIXED_LINE', metadata)) {
1537
+ // Because duplicate regular expressions are removed
1538
+ // to reduce metadata size, if "mobile" pattern is ""
1539
+ // then it means it was removed due to being a duplicate of the fixed-line pattern.
1540
+ //
1541
+ if (metadata.type('MOBILE') && metadata.type('MOBILE').pattern() === '') {
1542
+ return 'FIXED_LINE_OR_MOBILE';
1543
+ } // `MOBILE` type pattern isn't included if it matched `FIXED_LINE` one.
1544
+ // For example, for "US" country.
1545
+ // Old metadata (< `1.0.18`) had a specific "types" data structure
1546
+ // that happened to be `undefined` for `MOBILE` in that case.
1547
+ // Newer metadata (>= `1.0.18`) has another data structure that is
1548
+ // not `undefined` for `MOBILE` in that case (it's just an empty array).
1549
+ // So this `if` is just for backwards compatibility with old metadata.
1550
+
1551
+
1552
+ if (!metadata.type('MOBILE')) {
1553
+ return 'FIXED_LINE_OR_MOBILE';
1554
+ } // Check if the number happens to qualify as both fixed line and mobile.
1555
+ // (no such country in the minimal metadata set)
1556
+
1557
+ /* istanbul ignore if */
1558
+
1559
+
1560
+ if (isNumberTypeEqualTo(nationalNumber, 'MOBILE', metadata)) {
1561
+ return 'FIXED_LINE_OR_MOBILE';
1562
+ }
1563
+
1564
+ return 'FIXED_LINE';
1565
+ }
1566
+
1567
+ for (var _iterator = _createForOfIteratorHelperLoose$2(NON_FIXED_LINE_PHONE_TYPES), _step; !(_step = _iterator()).done;) {
1568
+ var type = _step.value;
1569
+
1570
+ if (isNumberTypeEqualTo(nationalNumber, type, metadata)) {
1571
+ return type;
1572
+ }
1573
+ }
1574
+ }
1575
+ function isNumberTypeEqualTo(nationalNumber, type, metadata) {
1576
+ type = metadata.type(type);
1577
+
1578
+ if (!type || !type.pattern()) {
1579
+ return false;
1580
+ } // Check if any possible number lengths are present;
1581
+ // if so, we use them to avoid checking
1582
+ // the validation pattern if they don't match.
1583
+ // If they are absent, this means they match
1584
+ // the general description, which we have
1585
+ // already checked before a specific number type.
1586
+
1587
+
1588
+ if (type.possibleLengths() && type.possibleLengths().indexOf(nationalNumber.length) < 0) {
1589
+ return false;
1590
+ }
1591
+
1592
+ return matchesEntirely(nationalNumber, type.pattern());
1593
+ }
1594
+
1595
+ /**
1596
+ * Checks if a given phone number is valid.
1597
+ *
1598
+ * isValid(phoneNumberInstance, { ..., v2: true }, metadata)
1599
+ *
1600
+ * isPossible({ phone: '8005553535', country: 'RU' }, { ... }, metadata)
1601
+ * isPossible({ phone: '8005553535', country: 'RU' }, undefined, metadata)
1602
+ *
1603
+ * If the `number` is a string, it will be parsed to an object,
1604
+ * but only if it contains only valid phone number characters (including punctuation).
1605
+ * If the `number` is an object, it is used as is.
1606
+ *
1607
+ * The optional `defaultCountry` argument is the default country.
1608
+ * I.e. it does not restrict to just that country,
1609
+ * e.g. in those cases where several countries share
1610
+ * the same phone numbering rules (NANPA, Britain, etc).
1611
+ * For example, even though the number `07624 369230`
1612
+ * belongs to the Isle of Man ("IM" country code)
1613
+ * calling `isValidNumber('07624369230', 'GB', metadata)`
1614
+ * still returns `true` because the country is not restricted to `GB`,
1615
+ * it's just that `GB` is the default one for the phone numbering rules.
1616
+ * For restricting the country see `isValidNumberForRegion()`
1617
+ * though restricting a country might not be a good idea.
1618
+ * https://github.com/googlei18n/libphonenumber/blob/master/FAQ.md#when-should-i-use-isvalidnumberforregion
1619
+ *
1620
+ * Examples:
1621
+ *
1622
+ * ```js
1623
+ * isValidNumber('+78005553535', metadata)
1624
+ * isValidNumber('8005553535', 'RU', metadata)
1625
+ * isValidNumber('88005553535', 'RU', metadata)
1626
+ * isValidNumber({ phone: '8005553535', country: 'RU' }, metadata)
1627
+ * ```
1628
+ */
1629
+
1630
+ function isValidNumber(input, options, metadata) {
1631
+ // If assigning the `{}` default value is moved to the arguments above,
1632
+ // code coverage would decrease for some weird reason.
1633
+ options = options || {};
1634
+ metadata = new Metadata(metadata);
1635
+ /**
1636
+ * Checks if a phone number is "possible" (basically just checks its length).
1637
+ *
1638
+ * @param {object|PhoneNumber} input — If `options.v2: true` flag is passed, the `input` should be a `PhoneNumber` instance. Otherwise, it should be an object of shape `{ phone: '...', country: '...' }`.
1639
+ * @param {object} [options]
1640
+ * @param {object} metadata
1641
+ * @return {string}
1642
+ */
1643
+
1644
+ metadata.selectNumberingPlan(input.country, input.countryCallingCode); // By default, countries only have type regexps when it's required for
1645
+ // distinguishing different countries having the same `countryCallingCode`.
1646
+
1647
+ if (metadata.hasTypes()) {
1648
+ return getNumberType(input, options, metadata.metadata) !== undefined;
1649
+ } // If there are no type regexps for this country in metadata then use
1650
+ // `nationalNumberPattern` as a "better than nothing" replacement.
1651
+
1652
+
1653
+ var nationalNumber = options.v2 ? input.nationalNumber : input.phone;
1654
+ return matchesEntirely(nationalNumber, metadata.nationalNumberPattern());
1655
+ }
1656
+
1657
+ /**
1658
+ * Returns a list of countries that the phone number could potentially belong to.
1659
+ * @param {string} callingCode — Calling code.
1660
+ * @param {string} nationalNumber — National (significant) number.
1661
+ * @param {object} metadata — Metadata.
1662
+ * @return {string[]} A list of possible countries.
1663
+ */
1664
+
1665
+ function getPossibleCountriesForNumber(callingCode, nationalNumber, metadata) {
1666
+ var _metadata = new Metadata(metadata);
1667
+
1668
+ var possibleCountries = _metadata.getCountryCodesForCallingCode(callingCode);
1669
+
1670
+ if (!possibleCountries) {
1671
+ return [];
1672
+ }
1673
+
1674
+ return possibleCountries.filter(function (country) {
1675
+ return couldNationalNumberBelongToCountry(nationalNumber, country, metadata);
1676
+ });
1677
+ }
1678
+
1679
+ function couldNationalNumberBelongToCountry(nationalNumber, country, metadata) {
1680
+ var _metadata = new Metadata(metadata);
1681
+
1682
+ _metadata.selectNumberingPlan(country);
1683
+
1684
+ if (_metadata.numberingPlan.possibleLengths().indexOf(nationalNumber.length) >= 0) {
1685
+ return true;
1686
+ }
1687
+
1688
+ return false;
1689
+ }
1690
+
1691
+ //
1692
+ // E.g. "(999) 111-22-33" -> "999 111 22 33"
1693
+ //
1694
+ // For some reason Google's metadata contains `<intlFormat/>`s with brackets and dashes.
1695
+ // Meanwhile, there's no single opinion about using punctuation in international phone numbers.
1696
+ //
1697
+ // For example, Google's `<intlFormat/>` for USA is `+1 213-373-4253`.
1698
+ // And here's a quote from WikiPedia's "North American Numbering Plan" page:
1699
+ // https://en.wikipedia.org/wiki/North_American_Numbering_Plan
1700
+ //
1701
+ // "The country calling code for all countries participating in the NANP is 1.
1702
+ // In international format, an NANP number should be listed as +1 301 555 01 00,
1703
+ // where 301 is an area code (Maryland)."
1704
+ //
1705
+ // I personally prefer the international format without any punctuation.
1706
+ // For example, brackets are remnants of the old age, meaning that the
1707
+ // phone number part in brackets (so called "area code") can be omitted
1708
+ // if dialing within the same "area".
1709
+ // And hyphens were clearly introduced for splitting local numbers into memorizable groups.
1710
+ // For example, remembering "5553535" is difficult but "555-35-35" is much simpler.
1711
+ // Imagine a man taking a bus from home to work and seeing an ad with a phone number.
1712
+ // He has a couple of seconds to memorize that number until it passes by.
1713
+ // If it were spaces instead of hyphens the man wouldn't necessarily get it,
1714
+ // but with hyphens instead of spaces the grouping is more explicit.
1715
+ // I personally think that hyphens introduce visual clutter,
1716
+ // so I prefer replacing them with spaces in international numbers.
1717
+ // In the modern age all output is done on displays where spaces are clearly distinguishable
1718
+ // so hyphens can be safely replaced with spaces without losing any legibility.
1719
+ //
1720
+
1721
+ function applyInternationalSeparatorStyle(formattedNumber) {
1722
+ return formattedNumber.replace(new RegExp("[".concat(VALID_PUNCTUATION, "]+"), 'g'), ' ').trim();
1723
+ }
1724
+
1725
+ // first group is not used in the national pattern (e.g. Argentina) so the $1
1726
+ // group does not match correctly. Therefore, we use `\d`, so that the first
1727
+ // group actually used in the pattern will be matched.
1728
+
1729
+ var FIRST_GROUP_PATTERN = /(\$\d)/;
1730
+ function formatNationalNumberUsingFormat(number, format, _ref) {
1731
+ var useInternationalFormat = _ref.useInternationalFormat,
1732
+ withNationalPrefix = _ref.withNationalPrefix;
1733
+ _ref.carrierCode;
1734
+ _ref.metadata;
1735
+ var formattedNumber = number.replace(new RegExp(format.pattern()), useInternationalFormat ? format.internationalFormat() : // This library doesn't use `domestic_carrier_code_formatting_rule`,
1736
+ // because that one is only used when formatting phone numbers
1737
+ // for dialing from a mobile phone, and this is not a dialing library.
1738
+ // carrierCode && format.domesticCarrierCodeFormattingRule()
1739
+ // // First, replace the $CC in the formatting rule with the desired carrier code.
1740
+ // // Then, replace the $FG in the formatting rule with the first group
1741
+ // // and the carrier code combined in the appropriate way.
1742
+ // ? format.format().replace(FIRST_GROUP_PATTERN, format.domesticCarrierCodeFormattingRule().replace('$CC', carrierCode))
1743
+ // : (
1744
+ // withNationalPrefix && format.nationalPrefixFormattingRule()
1745
+ // ? format.format().replace(FIRST_GROUP_PATTERN, format.nationalPrefixFormattingRule())
1746
+ // : format.format()
1747
+ // )
1748
+ withNationalPrefix && format.nationalPrefixFormattingRule() ? format.format().replace(FIRST_GROUP_PATTERN, format.nationalPrefixFormattingRule()) : format.format());
1749
+
1750
+ if (useInternationalFormat) {
1751
+ return applyInternationalSeparatorStyle(formattedNumber);
1752
+ }
1753
+
1754
+ return formattedNumber;
1755
+ }
1756
+
1757
+ /**
1758
+ * Pattern that makes it easy to distinguish whether a region has a single
1759
+ * international dialing prefix or not. If a region has a single international
1760
+ * prefix (e.g. 011 in USA), it will be represented as a string that contains
1761
+ * a sequence of ASCII digits, and possibly a tilde, which signals waiting for
1762
+ * the tone. If there are multiple available international prefixes in a
1763
+ * region, they will be represented as a regex string that always contains one
1764
+ * or more characters that are not ASCII digits or a tilde.
1765
+ */
1766
+
1767
+ var SINGLE_IDD_PREFIX_REG_EXP = /^[\d]+(?:[~\u2053\u223C\uFF5E][\d]+)?$/; // For regions that have multiple IDD prefixes
1768
+ // a preferred IDD prefix is returned.
1769
+
1770
+ function getIddPrefix(country, callingCode, metadata) {
1771
+ var countryMetadata = new Metadata(metadata);
1772
+ countryMetadata.selectNumberingPlan(country, callingCode);
1773
+
1774
+ if (countryMetadata.defaultIDDPrefix()) {
1775
+ return countryMetadata.defaultIDDPrefix();
1776
+ }
1777
+
1778
+ if (SINGLE_IDD_PREFIX_REG_EXP.test(countryMetadata.IDDPrefix())) {
1779
+ return countryMetadata.IDDPrefix();
1780
+ }
1781
+ }
1782
+
1783
+ /**
1784
+ * @param {object} - `{ ?number, ?extension }`.
1785
+ * @return {string} Phone URI (RFC 3966).
1786
+ */
1787
+
1788
+ function formatRFC3966(_ref) {
1789
+ var number = _ref.number,
1790
+ ext = _ref.ext;
1791
+
1792
+ if (!number) {
1793
+ return '';
1794
+ }
1795
+
1796
+ if (number[0] !== '+') {
1797
+ throw new Error("\"formatRFC3966()\" expects \"number\" to be in E.164 format.");
1798
+ }
1799
+
1800
+ return "tel:".concat(number).concat(ext ? ';ext=' + ext : '');
1801
+ }
1802
+
1803
+ function _createForOfIteratorHelperLoose$1(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray$2(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
1804
+
1805
+ function _unsupportedIterableToArray$2(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$2(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$2(o, minLen); }
1806
+
1807
+ function _arrayLikeToArray$2(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
1808
+
1809
+ function ownKeys$5(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
1810
+
1811
+ function _objectSpread$5(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$5(Object(source), !0).forEach(function (key) { _defineProperty$5(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$5(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
1812
+
1813
+ function _defineProperty$5(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
1814
+ var DEFAULT_OPTIONS = {
1815
+ formatExtension: function formatExtension(formattedNumber, extension, metadata) {
1816
+ return "".concat(formattedNumber).concat(metadata.ext()).concat(extension);
1817
+ }
1818
+ };
1819
+ /**
1820
+ * Formats a phone number.
1821
+ *
1822
+ * format(phoneNumberInstance, 'INTERNATIONAL', { ..., v2: true }, metadata)
1823
+ * format(phoneNumberInstance, 'NATIONAL', { ..., v2: true }, metadata)
1824
+ *
1825
+ * format({ phone: '8005553535', country: 'RU' }, 'INTERNATIONAL', { ... }, metadata)
1826
+ * format({ phone: '8005553535', country: 'RU' }, 'NATIONAL', undefined, metadata)
1827
+ *
1828
+ * @param {object|PhoneNumber} input — If `options.v2: true` flag is passed, the `input` should be a `PhoneNumber` instance. Otherwise, it should be an object of shape `{ phone: '...', country: '...' }`.
1829
+ * @param {string} format
1830
+ * @param {object} [options]
1831
+ * @param {object} metadata
1832
+ * @return {string}
1833
+ */
1834
+
1835
+ function formatNumber(input, format, options, metadata) {
1836
+ // Apply default options.
1837
+ if (options) {
1838
+ options = _objectSpread$5(_objectSpread$5({}, DEFAULT_OPTIONS), options);
1839
+ } else {
1840
+ options = DEFAULT_OPTIONS;
1841
+ }
1842
+
1843
+ metadata = new Metadata(metadata);
1844
+
1845
+ if (input.country && input.country !== '001') {
1846
+ // Validate `input.country`.
1847
+ if (!metadata.hasCountry(input.country)) {
1848
+ throw new Error("Unknown country: ".concat(input.country));
1849
+ }
1850
+
1851
+ metadata.country(input.country);
1852
+ } else if (input.countryCallingCode) {
1853
+ metadata.selectNumberingPlan(input.countryCallingCode);
1854
+ } else return input.phone || '';
1855
+
1856
+ var countryCallingCode = metadata.countryCallingCode();
1857
+ var nationalNumber = options.v2 ? input.nationalNumber : input.phone; // This variable should have been declared inside `case`s
1858
+ // but Babel has a bug and it says "duplicate variable declaration".
1859
+
1860
+ var number;
1861
+
1862
+ switch (format) {
1863
+ case 'NATIONAL':
1864
+ // Legacy argument support.
1865
+ // (`{ country: ..., phone: '' }`)
1866
+ if (!nationalNumber) {
1867
+ return '';
1868
+ }
1869
+
1870
+ number = formatNationalNumber(nationalNumber, input.carrierCode, 'NATIONAL', metadata, options);
1871
+ return addExtension(number, input.ext, metadata, options.formatExtension);
1872
+
1873
+ case 'INTERNATIONAL':
1874
+ // Legacy argument support.
1875
+ // (`{ country: ..., phone: '' }`)
1876
+ if (!nationalNumber) {
1877
+ return "+".concat(countryCallingCode);
1878
+ }
1879
+
1880
+ number = formatNationalNumber(nationalNumber, null, 'INTERNATIONAL', metadata, options);
1881
+ number = "+".concat(countryCallingCode, " ").concat(number);
1882
+ return addExtension(number, input.ext, metadata, options.formatExtension);
1883
+
1884
+ case 'E.164':
1885
+ // `E.164` doesn't define "phone number extensions".
1886
+ return "+".concat(countryCallingCode).concat(nationalNumber);
1887
+
1888
+ case 'RFC3966':
1889
+ return formatRFC3966({
1890
+ number: "+".concat(countryCallingCode).concat(nationalNumber),
1891
+ ext: input.ext
1892
+ });
1893
+ // For reference, here's Google's IDD formatter:
1894
+ // https://github.com/google/libphonenumber/blob/32719cf74e68796788d1ca45abc85dcdc63ba5b9/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java#L1546
1895
+ // Not saying that this IDD formatter replicates it 1:1, but it seems to work.
1896
+ // Who would even need to format phone numbers in IDD format anyway?
1897
+
1898
+ case 'IDD':
1899
+ if (!options.fromCountry) {
1900
+ return; // throw new Error('`fromCountry` option not passed for IDD-prefixed formatting.')
1901
+ }
1902
+
1903
+ var formattedNumber = formatIDD(nationalNumber, input.carrierCode, countryCallingCode, options.fromCountry, metadata);
1904
+ return addExtension(formattedNumber, input.ext, metadata, options.formatExtension);
1905
+
1906
+ default:
1907
+ throw new Error("Unknown \"format\" argument passed to \"formatNumber()\": \"".concat(format, "\""));
1908
+ }
1909
+ }
1910
+
1911
+ function formatNationalNumber(number, carrierCode, formatAs, metadata, options) {
1912
+ var format = chooseFormatForNumber(metadata.formats(), number);
1913
+
1914
+ if (!format) {
1915
+ return number;
1916
+ }
1917
+
1918
+ return formatNationalNumberUsingFormat(number, format, {
1919
+ useInternationalFormat: formatAs === 'INTERNATIONAL',
1920
+ withNationalPrefix: format.nationalPrefixIsOptionalWhenFormattingInNationalFormat() && options && options.nationalPrefix === false ? false : true,
1921
+ carrierCode: carrierCode,
1922
+ metadata: metadata
1923
+ });
1924
+ }
1925
+
1926
+ function chooseFormatForNumber(availableFormats, nationalNnumber) {
1927
+ for (var _iterator = _createForOfIteratorHelperLoose$1(availableFormats), _step; !(_step = _iterator()).done;) {
1928
+ var format = _step.value;
1929
+
1930
+ // Validate leading digits.
1931
+ // The test case for "else path" could be found by searching for
1932
+ // "format.leadingDigitsPatterns().length === 0".
1933
+ if (format.leadingDigitsPatterns().length > 0) {
1934
+ // The last leading_digits_pattern is used here, as it is the most detailed
1935
+ var lastLeadingDigitsPattern = format.leadingDigitsPatterns()[format.leadingDigitsPatterns().length - 1]; // If leading digits don't match then move on to the next phone number format
1936
+
1937
+ if (nationalNnumber.search(lastLeadingDigitsPattern) !== 0) {
1938
+ continue;
1939
+ }
1940
+ } // Check that the national number matches the phone number format regular expression
1941
+
1942
+
1943
+ if (matchesEntirely(nationalNnumber, format.pattern())) {
1944
+ return format;
1945
+ }
1946
+ }
1947
+ }
1948
+
1949
+ function addExtension(formattedNumber, ext, metadata, formatExtension) {
1950
+ return ext ? formatExtension(formattedNumber, ext, metadata) : formattedNumber;
1951
+ }
1952
+
1953
+ function formatIDD(nationalNumber, carrierCode, countryCallingCode, fromCountry, metadata) {
1954
+ var fromCountryCallingCode = getCountryCallingCode(fromCountry, metadata.metadata); // When calling within the same country calling code.
1955
+
1956
+ if (fromCountryCallingCode === countryCallingCode) {
1957
+ var formattedNumber = formatNationalNumber(nationalNumber, carrierCode, 'NATIONAL', metadata); // For NANPA regions, return the national format for these regions
1958
+ // but prefix it with the country calling code.
1959
+
1960
+ if (countryCallingCode === '1') {
1961
+ return countryCallingCode + ' ' + formattedNumber;
1962
+ } // If regions share a country calling code, the country calling code need
1963
+ // not be dialled. This also applies when dialling within a region, so this
1964
+ // if clause covers both these cases. Technically this is the case for
1965
+ // dialling from La Reunion to other overseas departments of France (French
1966
+ // Guiana, Martinique, Guadeloupe), but not vice versa - so we don't cover
1967
+ // this edge case for now and for those cases return the version including
1968
+ // country calling code. Details here:
1969
+ // http://www.petitfute.com/voyage/225-info-pratiques-reunion
1970
+ //
1971
+
1972
+
1973
+ return formattedNumber;
1974
+ }
1975
+
1976
+ var iddPrefix = getIddPrefix(fromCountry, undefined, metadata.metadata);
1977
+
1978
+ if (iddPrefix) {
1979
+ return "".concat(iddPrefix, " ").concat(countryCallingCode, " ").concat(formatNationalNumber(nationalNumber, null, 'INTERNATIONAL', metadata));
1980
+ }
1981
+ }
1982
+
1983
+ function ownKeys$4(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
1984
+
1985
+ function _objectSpread$4(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$4(Object(source), !0).forEach(function (key) { _defineProperty$4(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$4(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
1986
+
1987
+ function _defineProperty$4(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
1988
+
1989
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
1990
+
1991
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
1992
+
1993
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
1994
+
1995
+ var PhoneNumber = /*#__PURE__*/function () {
1996
+ /**
1997
+ * @param {string} countryOrCountryCallingCode
1998
+ * @param {string} nationalNumber
1999
+ * @param {object} metadata — Metadata JSON
2000
+ * @return {PhoneNumber}
2001
+ */
2002
+ function PhoneNumber(countryOrCountryCallingCode, nationalNumber, metadata) {
2003
+ _classCallCheck(this, PhoneNumber);
2004
+
2005
+ if (!countryOrCountryCallingCode) {
2006
+ throw new TypeError('`country` or `countryCallingCode` not passed');
2007
+ }
2008
+
2009
+ if (!nationalNumber) {
2010
+ throw new TypeError('`nationalNumber` not passed');
2011
+ }
2012
+
2013
+ if (!metadata) {
2014
+ throw new TypeError('`metadata` not passed');
2015
+ }
2016
+
2017
+ var _getCountryAndCountry = getCountryAndCountryCallingCode(countryOrCountryCallingCode, metadata),
2018
+ country = _getCountryAndCountry.country,
2019
+ countryCallingCode = _getCountryAndCountry.countryCallingCode;
2020
+
2021
+ this.country = country;
2022
+ this.countryCallingCode = countryCallingCode;
2023
+ this.nationalNumber = nationalNumber;
2024
+ this.number = '+' + this.countryCallingCode + this.nationalNumber; // Exclude `metadata` property output from `PhoneNumber.toString()`
2025
+ // so that it doesn't clutter the console output of Node.js.
2026
+ // Previously, when Node.js did `console.log(new PhoneNumber(...))`,
2027
+ // it would output the whole internal structure of the `metadata` object.
2028
+
2029
+ this.getMetadata = function () {
2030
+ return metadata;
2031
+ };
2032
+ }
2033
+
2034
+ _createClass(PhoneNumber, [{
2035
+ key: "setExt",
2036
+ value: function setExt(ext) {
2037
+ this.ext = ext;
2038
+ }
2039
+ }, {
2040
+ key: "getPossibleCountries",
2041
+ value: function getPossibleCountries() {
2042
+ if (this.country) {
2043
+ return [this.country];
2044
+ }
2045
+
2046
+ return getPossibleCountriesForNumber(this.countryCallingCode, this.nationalNumber, this.getMetadata());
2047
+ }
2048
+ }, {
2049
+ key: "isPossible",
2050
+ value: function isPossible() {
2051
+ return isPossiblePhoneNumber(this, {
2052
+ v2: true
2053
+ }, this.getMetadata());
2054
+ }
2055
+ }, {
2056
+ key: "isValid",
2057
+ value: function isValid() {
2058
+ return isValidNumber(this, {
2059
+ v2: true
2060
+ }, this.getMetadata());
2061
+ }
2062
+ }, {
2063
+ key: "isNonGeographic",
2064
+ value: function isNonGeographic() {
2065
+ var metadata = new Metadata(this.getMetadata());
2066
+ return metadata.isNonGeographicCallingCode(this.countryCallingCode);
2067
+ }
2068
+ }, {
2069
+ key: "isEqual",
2070
+ value: function isEqual(phoneNumber) {
2071
+ return this.number === phoneNumber.number && this.ext === phoneNumber.ext;
2072
+ } // This function was originally meant to be an equivalent for `validatePhoneNumberLength()`,
2073
+ // but later it was found out that it doesn't include the possible `TOO_SHORT` result
2074
+ // returned from `parsePhoneNumberWithError()` in the original `validatePhoneNumberLength()`,
2075
+ // so eventually I simply commented out this method from the `PhoneNumber` class
2076
+ // and just left the `validatePhoneNumberLength()` function, even though that one would require
2077
+ // and additional step to also validate the actual country / calling code of the phone number.
2078
+ // validateLength() {
2079
+ // const metadata = new Metadata(this.getMetadata())
2080
+ // metadata.selectNumberingPlan(this.countryCallingCode)
2081
+ // const result = checkNumberLength(this.nationalNumber, metadata)
2082
+ // if (result !== 'IS_POSSIBLE') {
2083
+ // return result
2084
+ // }
2085
+ // }
2086
+
2087
+ }, {
2088
+ key: "getType",
2089
+ value: function getType() {
2090
+ return getNumberType(this, {
2091
+ v2: true
2092
+ }, this.getMetadata());
2093
+ }
2094
+ }, {
2095
+ key: "format",
2096
+ value: function format(_format, options) {
2097
+ return formatNumber(this, _format, options ? _objectSpread$4(_objectSpread$4({}, options), {}, {
2098
+ v2: true
2099
+ }) : {
2100
+ v2: true
2101
+ }, this.getMetadata());
2102
+ }
2103
+ }, {
2104
+ key: "formatNational",
2105
+ value: function formatNational(options) {
2106
+ return this.format('NATIONAL', options);
2107
+ }
2108
+ }, {
2109
+ key: "formatInternational",
2110
+ value: function formatInternational(options) {
2111
+ return this.format('INTERNATIONAL', options);
2112
+ }
2113
+ }, {
2114
+ key: "getURI",
2115
+ value: function getURI(options) {
2116
+ return this.format('RFC3966', options);
2117
+ }
2118
+ }]);
2119
+
2120
+ return PhoneNumber;
2121
+ }();
2122
+
2123
+ var isCountryCode = function isCountryCode(value) {
2124
+ return /^[A-Z]{2}$/.test(value);
2125
+ };
2126
+
2127
+ function getCountryAndCountryCallingCode(countryOrCountryCallingCode, metadataJson) {
2128
+ var country;
2129
+ var countryCallingCode;
2130
+ var metadata = new Metadata(metadataJson); // If country code is passed then derive `countryCallingCode` from it.
2131
+ // Also store the country code as `.country`.
2132
+
2133
+ if (isCountryCode(countryOrCountryCallingCode)) {
2134
+ country = countryOrCountryCallingCode;
2135
+ metadata.selectNumberingPlan(country);
2136
+ countryCallingCode = metadata.countryCallingCode();
2137
+ } else {
2138
+ countryCallingCode = countryOrCountryCallingCode;
2139
+ }
2140
+
2141
+ return {
2142
+ country: country,
2143
+ countryCallingCode: countryCallingCode
2144
+ };
2145
+ }
2146
+
2147
+ var CAPTURING_DIGIT_PATTERN = new RegExp('([' + VALID_DIGITS + '])');
2148
+ function stripIddPrefix(number, country, callingCode, metadata) {
2149
+ if (!country) {
2150
+ return;
2151
+ } // Check if the number is IDD-prefixed.
2152
+
2153
+
2154
+ var countryMetadata = new Metadata(metadata);
2155
+ countryMetadata.selectNumberingPlan(country, callingCode);
2156
+ var IDDPrefixPattern = new RegExp(countryMetadata.IDDPrefix());
2157
+
2158
+ if (number.search(IDDPrefixPattern) !== 0) {
2159
+ return;
2160
+ } // Strip IDD prefix.
2161
+
2162
+
2163
+ number = number.slice(number.match(IDDPrefixPattern)[0].length); // If there're any digits after an IDD prefix,
2164
+ // then those digits are a country calling code.
2165
+ // Since no country code starts with a `0`,
2166
+ // the code below validates that the next digit (if present) is not `0`.
2167
+
2168
+ var matchedGroups = number.match(CAPTURING_DIGIT_PATTERN);
2169
+
2170
+ if (matchedGroups && matchedGroups[1] != null && matchedGroups[1].length > 0) {
2171
+ if (matchedGroups[1] === '0') {
2172
+ return;
2173
+ }
2174
+ }
2175
+
2176
+ return number;
2177
+ }
2178
+
38
2179
  /**
39
- * A component that can be used to render a boolean field
40
- *
41
- * @param options BooleanCustomFieldProps - options for the component
42
- * @returns { JSX.Element } JSX.Element - a component that can be used to render a boolean field
43
- */
44
- const BooleanCustomField = (_a) => {
45
- var { defaultValue, dataTestId = "booleanField", onChange, value, id, setValue, register, validationRules, disabled = false, label, tip, isInvalid, errorMessage, helpAddon, maxLength, helpText } = _a, rest = __rest(_a, ["defaultValue", "dataTestId", "onChange", "value", "id", "setValue", "register", "validationRules", "disabled", "label", "tip", "isInvalid", "errorMessage", "helpAddon", "maxLength", "helpText"]);
46
- const initialValue = value !== undefined ? value : defaultValue ? defaultValue : false;
47
- const renderAsInvalid = isInvalid || Boolean(errorMessage);
48
- const htmlForId = id ? id : "boolean-custom-field-" + v4();
49
- const [internalValue, setInternalValue] = React.useState(initialValue);
50
- React.useEffect(() => {
51
- setInternalValue((value === undefined ? defaultValue : value) || false);
52
- }, [value, setInternalValue, defaultValue]);
53
- const onChangeHandler = React.useCallback((event) => {
54
- var _a;
55
- onChange && onChange(event);
56
- const isChecked = ((_a = event.target) === null || _a === void 0 ? void 0 : _a.checked) || false;
57
- if (setValue) {
58
- setValue(id, isChecked);
59
- }
60
- setInternalValue(isChecked);
61
- }, [setInternalValue, onChange, id, setValue]);
62
- React.useEffect(() => {
63
- register && register(id, Object.assign(Object.assign({}, validationRules), { value: internalValue.toString() }));
64
- // eslint-disable-next-line react-hooks/exhaustive-deps
65
- }, []); // register only once
66
- return (jsx(FormGroup, Object.assign({ htmlFor: htmlForId, label: label, tip: tip, isInvalid: renderAsInvalid, helpText: errorMessage || helpText, helpAddon: helpAddon || null, dataTestId: dataTestId && `${dataTestId}-FormGroup` }, { children: jsx(Checkbox, Object.assign({ checked: internalValue, dataTestId: dataTestId, id: htmlForId, disabled: disabled, name: id, onChange: onChangeHandler, isInvalid: renderAsInvalid }, rest)) })));
67
- };
2180
+ * Strips any national prefix (such as 0, 1) present in a
2181
+ * (possibly incomplete) number provided.
2182
+ * "Carrier codes" are only used in Colombia and Brazil,
2183
+ * and only when dialing within those countries from a mobile phone to a fixed line number.
2184
+ * Sometimes it won't actually strip national prefix
2185
+ * and will instead prepend some digits to the `number`:
2186
+ * for example, when number `2345678` is passed with `VI` country selected,
2187
+ * it will return `{ number: "3402345678" }`, because `340` area code is prepended.
2188
+ * @param {string} number — National number digits.
2189
+ * @param {object} metadata Metadata with country selected.
2190
+ * @return {object} `{ nationalNumber: string, nationalPrefix: string? carrierCode: string? }`. Even if a national prefix was extracted, it's not necessarily present in the returned object, so don't rely on its presence in the returned object in order to find out whether a national prefix has been extracted or not.
2191
+ */
2192
+ function extractNationalNumberFromPossiblyIncompleteNumber(number, metadata) {
2193
+ if (number && metadata.numberingPlan.nationalPrefixForParsing()) {
2194
+ // See METADATA.md for the description of
2195
+ // `national_prefix_for_parsing` and `national_prefix_transform_rule`.
2196
+ // Attempt to parse the first digits as a national prefix.
2197
+ var prefixPattern = new RegExp('^(?:' + metadata.numberingPlan.nationalPrefixForParsing() + ')');
2198
+ var prefixMatch = prefixPattern.exec(number);
2199
+
2200
+ if (prefixMatch) {
2201
+ var nationalNumber;
2202
+ var carrierCode; // https://gitlab.com/catamphetamine/libphonenumber-js/-/blob/master/METADATA.md#national_prefix_for_parsing--national_prefix_transform_rule
2203
+ // If a `national_prefix_for_parsing` has any "capturing groups"
2204
+ // then it means that the national (significant) number is equal to
2205
+ // those "capturing groups" transformed via `national_prefix_transform_rule`,
2206
+ // and nothing could be said about the actual national prefix:
2207
+ // what is it and was it even there.
2208
+ // If a `national_prefix_for_parsing` doesn't have any "capturing groups",
2209
+ // then everything it matches is a national prefix.
2210
+ // To determine whether `national_prefix_for_parsing` matched any
2211
+ // "capturing groups", the value of the result of calling `.exec()`
2212
+ // is looked at, and if it has non-undefined values where there're
2213
+ // "capturing groups" in the regular expression, then it means
2214
+ // that "capturing groups" have been matched.
2215
+ // It's not possible to tell whether there'll be any "capturing gropus"
2216
+ // before the matching process, because a `national_prefix_for_parsing`
2217
+ // could exhibit both behaviors.
2218
+
2219
+ var capturedGroupsCount = prefixMatch.length - 1;
2220
+ var hasCapturedGroups = capturedGroupsCount > 0 && prefixMatch[capturedGroupsCount];
2221
+
2222
+ if (metadata.nationalPrefixTransformRule() && hasCapturedGroups) {
2223
+ nationalNumber = number.replace(prefixPattern, metadata.nationalPrefixTransformRule()); // If there's more than one captured group,
2224
+ // then carrier code is the second one.
2225
+
2226
+ if (capturedGroupsCount > 1) {
2227
+ carrierCode = prefixMatch[1];
2228
+ }
2229
+ } // If there're no "capturing groups",
2230
+ // or if there're "capturing groups" but no
2231
+ // `national_prefix_transform_rule`,
2232
+ // then just strip the national prefix from the number,
2233
+ // and possibly a carrier code.
2234
+ // Seems like there could be more.
2235
+ else {
2236
+ // `prefixBeforeNationalNumber` is the whole substring matched by
2237
+ // the `national_prefix_for_parsing` regular expression.
2238
+ // There seem to be no guarantees that it's just a national prefix.
2239
+ // For example, if there's a carrier code, it's gonna be a
2240
+ // part of `prefixBeforeNationalNumber` too.
2241
+ var prefixBeforeNationalNumber = prefixMatch[0];
2242
+ nationalNumber = number.slice(prefixBeforeNationalNumber.length); // If there's at least one captured group,
2243
+ // then carrier code is the first one.
2244
+
2245
+ if (hasCapturedGroups) {
2246
+ carrierCode = prefixMatch[1];
2247
+ }
2248
+ } // Tries to guess whether a national prefix was present in the input.
2249
+ // This is not something copy-pasted from Google's library:
2250
+ // they don't seem to have an equivalent for that.
2251
+ // So this isn't an "officially approved" way of doing something like that.
2252
+ // But since there seems no other existing method, this library uses it.
2253
+
2254
+
2255
+ var nationalPrefix;
2256
+
2257
+ if (hasCapturedGroups) {
2258
+ var possiblePositionOfTheFirstCapturedGroup = number.indexOf(prefixMatch[1]);
2259
+ var possibleNationalPrefix = number.slice(0, possiblePositionOfTheFirstCapturedGroup); // Example: an Argentinian (AR) phone number `0111523456789`.
2260
+ // `prefixMatch[0]` is `01115`, and `$1` is `11`,
2261
+ // and the rest of the phone number is `23456789`.
2262
+ // The national number is transformed via `9$1` to `91123456789`.
2263
+ // National prefix `0` is detected being present at the start.
2264
+ // if (possibleNationalPrefix.indexOf(metadata.numberingPlan.nationalPrefix()) === 0) {
2265
+
2266
+ if (possibleNationalPrefix === metadata.numberingPlan.nationalPrefix()) {
2267
+ nationalPrefix = metadata.numberingPlan.nationalPrefix();
2268
+ }
2269
+ } else {
2270
+ nationalPrefix = prefixMatch[0];
2271
+ }
2272
+
2273
+ return {
2274
+ nationalNumber: nationalNumber,
2275
+ nationalPrefix: nationalPrefix,
2276
+ carrierCode: carrierCode
2277
+ };
2278
+ }
2279
+ }
2280
+
2281
+ return {
2282
+ nationalNumber: number
2283
+ };
2284
+ }
68
2285
 
69
2286
  /**
70
- * A component that can be used to render a date field
71
- *
72
- * @param props DateCustomFieldProps - options for the component
73
- * @returns { JSX.Element } JSX.Element - a component that can be used to render a date field
74
- */
75
- const DateCustomField = (props) => {
76
- const { setValue, defaultValue, register, id, validationRules } = props, rest = __rest(props, ["setValue", "defaultValue", "register", "id", "validationRules"]);
77
- const onChangeHandler = useCallback((e) => {
78
- var _a, _b, _c, _d;
79
- if (((_b = (_a = e.target) === null || _a === void 0 ? void 0 : _a.valueAsDate) === null || _b === void 0 ? void 0 : _b.toISOString()) !== undefined) {
80
- setValue && setValue(id, (_d = (_c = e.target) === null || _c === void 0 ? void 0 : _c.valueAsDate) === null || _d === void 0 ? void 0 : _d.toISOString());
81
- }
82
- }, [setValue, id]);
83
- useEffect(() => {
84
- const value = defaultValue && new Date(defaultValue);
85
- register && register(id, Object.assign(Object.assign({}, validationRules), { value }));
86
- }, [register, validationRules, defaultValue, id]);
87
- return (createElement(DateField, Object.assign({}, rest, { key: id, id: id, helpAddon: props.helpAddon || null, helpText: props.errorMessage || props.helpText, onChange: onChangeHandler, label: props.title, defaultValue: defaultValue })));
88
- };
2287
+ * Strips national prefix and carrier code from a complete phone number.
2288
+ * The difference from the non-"FromCompleteNumber" function is that
2289
+ * it won't extract national prefix if the resultant number is too short
2290
+ * to be a complete number for the selected phone numbering plan.
2291
+ * @param {string} number — Complete phone number digits.
2292
+ * @param {Metadata} metadata Metadata with a phone numbering plan selected.
2293
+ * @return {object} `{ nationalNumber: string, carrierCode: string? }`.
2294
+ */
2295
+
2296
+ function extractNationalNumber(number, metadata) {
2297
+ // Parsing national prefixes and carrier codes
2298
+ // is only required for local phone numbers
2299
+ // but some people don't understand that
2300
+ // and sometimes write international phone numbers
2301
+ // with national prefixes (or maybe even carrier codes).
2302
+ // http://ucken.blogspot.ru/2016/03/trunk-prefixes-in-skype4b.html
2303
+ // Google's original library forgives such mistakes
2304
+ // and so does this library, because it has been requested:
2305
+ // https://github.com/catamphetamine/libphonenumber-js/issues/127
2306
+ var _extractNationalNumbe = extractNationalNumberFromPossiblyIncompleteNumber(number, metadata),
2307
+ carrierCode = _extractNationalNumbe.carrierCode,
2308
+ nationalNumber = _extractNationalNumbe.nationalNumber;
2309
+
2310
+ if (nationalNumber !== number) {
2311
+ if (!shouldHaveExtractedNationalPrefix(number, nationalNumber, metadata)) {
2312
+ // Don't strip the national prefix.
2313
+ return {
2314
+ nationalNumber: number
2315
+ };
2316
+ } // Check the national (significant) number length after extracting national prefix and carrier code.
2317
+ // Legacy generated metadata (before `1.0.18`) didn't support the "possible lengths" feature.
2318
+
2319
+
2320
+ if (metadata.possibleLengths()) {
2321
+ // The number remaining after stripping the national prefix and carrier code
2322
+ // should be long enough to have a possible length for the country.
2323
+ // Otherwise, don't strip the national prefix and carrier code,
2324
+ // since the original number could be a valid number.
2325
+ // This check has been copy-pasted "as is" from Google's original library:
2326
+ // https://github.com/google/libphonenumber/blob/876268eb1ad6cdc1b7b5bef17fc5e43052702d57/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java#L3236-L3250
2327
+ // It doesn't check for the "possibility" of the original `number`.
2328
+ // I guess it's fine not checking that one. It works as is anyway.
2329
+ if (!isPossibleIncompleteNationalNumber(nationalNumber, metadata)) {
2330
+ // Don't strip the national prefix.
2331
+ return {
2332
+ nationalNumber: number
2333
+ };
2334
+ }
2335
+ }
2336
+ }
2337
+
2338
+ return {
2339
+ nationalNumber: nationalNumber,
2340
+ carrierCode: carrierCode
2341
+ };
2342
+ } // In some countries, the same digit could be a national prefix
2343
+ // or a leading digit of a valid phone number.
2344
+ // For example, in Russia, national prefix is `8`,
2345
+ // and also `800 555 35 35` is a valid number
2346
+ // in which `8` is not a national prefix, but the first digit
2347
+ // of a national (significant) number.
2348
+ // Same's with Belarus:
2349
+ // `82004910060` is a valid national (significant) number,
2350
+ // but `2004910060` is not.
2351
+ // To support such cases (to prevent the code from always stripping
2352
+ // national prefix), a condition is imposed: a national prefix
2353
+ // is not extracted when the original number is "viable" and the
2354
+ // resultant number is not, a "viable" national number being the one
2355
+ // that matches `national_number_pattern`.
2356
+
2357
+ function shouldHaveExtractedNationalPrefix(nationalNumberBefore, nationalNumberAfter, metadata) {
2358
+ // The equivalent in Google's code is:
2359
+ // https://github.com/google/libphonenumber/blob/e326fa1fc4283bb05eb35cb3c15c18f98a31af33/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java#L2969-L3004
2360
+ if (matchesEntirely(nationalNumberBefore, metadata.nationalNumberPattern()) && !matchesEntirely(nationalNumberAfter, metadata.nationalNumberPattern())) {
2361
+ return false;
2362
+ } // This "is possible" national number (length) check has been commented out
2363
+ // because it's superceded by the (effectively) same check done in the
2364
+ // `extractNationalNumber()` function after it calls `shouldHaveExtractedNationalPrefix()`.
2365
+ // In other words, why run the same check twice if it could only be run once.
2366
+ // // Check the national (significant) number length after extracting national prefix and carrier code.
2367
+ // // Fixes a minor "weird behavior" bug: https://gitlab.com/catamphetamine/libphonenumber-js/-/issues/57
2368
+ // // (Legacy generated metadata (before `1.0.18`) didn't support the "possible lengths" feature).
2369
+ // if (metadata.possibleLengths()) {
2370
+ // if (isPossibleIncompleteNationalNumber(nationalNumberBefore, metadata) &&
2371
+ // !isPossibleIncompleteNationalNumber(nationalNumberAfter, metadata)) {
2372
+ // return false
2373
+ // }
2374
+ // }
2375
+
2376
+
2377
+ return true;
2378
+ }
2379
+
2380
+ function isPossibleIncompleteNationalNumber(nationalNumber, metadata) {
2381
+ switch (checkNumberLength(nationalNumber, metadata)) {
2382
+ case 'TOO_SHORT':
2383
+ case 'INVALID_LENGTH':
2384
+ // This library ignores "local-only" phone numbers (for simplicity).
2385
+ // See the readme for more info on what are "local-only" phone numbers.
2386
+ // case 'IS_POSSIBLE_LOCAL_ONLY':
2387
+ return false;
2388
+
2389
+ default:
2390
+ return true;
2391
+ }
2392
+ }
89
2393
 
90
- const convertToValueFormat = (value) => {
91
- return { label: value, value };
92
- };
93
2394
  /**
94
- * A custom field that can be used to render a dropdown
95
- *
96
- * @param options DropdownCustomFieldProps - an object with all the props
97
- * @returns {JSX.Element} - a dropdown component
98
- */
99
- const DropdownCustomField = ({ defaultValue, dataTestId, onChange, onBlur, id, disabled = false, allValues, multiSelect = false, register, validationRules, setValue, label, tip, errorMessage, helpText, isInvalid, helpAddon, }) => {
100
- const renderAsInvalid = isInvalid || Boolean(errorMessage);
101
- const htmlForId = id ? id : "dropdown-custom-field-" + v4();
102
- const [selectedValue, setSelectedValue] = React.useState(defaultValue ? defaultValue.map(convertToValueFormat) : []);
103
- const onChangeHandler = React.useCallback((selected) => {
104
- if (selected) {
105
- const values = Array.isArray(selected) ? selected : [selected];
106
- setSelectedValue(values);
107
- setValue && setValue(id, values);
108
- }
109
- else {
110
- setSelectedValue([]);
111
- setValue && setValue(id, []);
112
- }
113
- }, [onChange]);
114
- const options = React.useMemo(() => {
115
- return allValues ? allValues.map(convertToValueFormat) : [];
116
- }, [allValues]);
117
- React.useEffect(() => {
118
- register && register(id, Object.assign(Object.assign({}, validationRules), { value: selectedValue }));
119
- }, [register, validationRules, selectedValue, id]);
120
- return (jsx(FormGroup, Object.assign({ htmlFor: htmlForId, label: label, tip: tip, isInvalid: renderAsInvalid, helpText: errorMessage || helpText, helpAddon: helpAddon || null, dataTestId: dataTestId && `${dataTestId}-FormGroup` }, { children: jsx(Select, { inputId: htmlForId, "aria-labelledby": htmlForId + "-label", disabled: disabled, dataTestId: dataTestId, onChange: onChangeHandler, hasError: renderAsInvalid, options: options, value: selectedValue, isMulti: multiSelect, isClearable: true }) })));
121
- };
2395
+ * Sometimes some people incorrectly input international phone numbers
2396
+ * without the leading `+`. This function corrects such input.
2397
+ * @param {string} number Phone number digits.
2398
+ * @param {string?} country
2399
+ * @param {string?} callingCode
2400
+ * @param {object} metadata
2401
+ * @return {object} `{ countryCallingCode: string?, number: string }`.
2402
+ */
2403
+
2404
+ function extractCountryCallingCodeFromInternationalNumberWithoutPlusSign(number, country, callingCode, metadata) {
2405
+ var countryCallingCode = country ? getCountryCallingCode(country, metadata) : callingCode;
2406
+
2407
+ if (number.indexOf(countryCallingCode) === 0) {
2408
+ metadata = new Metadata(metadata);
2409
+ metadata.selectNumberingPlan(country, callingCode);
2410
+ var possibleShorterNumber = number.slice(countryCallingCode.length);
2411
+
2412
+ var _extractNationalNumbe = extractNationalNumber(possibleShorterNumber, metadata),
2413
+ possibleShorterNationalNumber = _extractNationalNumbe.nationalNumber;
2414
+
2415
+ var _extractNationalNumbe2 = extractNationalNumber(number, metadata),
2416
+ nationalNumber = _extractNationalNumbe2.nationalNumber; // If the number was not valid before but is valid now,
2417
+ // or if it was too long before, we consider the number
2418
+ // with the country calling code stripped to be a better result
2419
+ // and keep that instead.
2420
+ // For example, in Germany (+49), `49` is a valid area code,
2421
+ // so if a number starts with `49`, it could be both a valid
2422
+ // national German number or an international number without
2423
+ // a leading `+`.
2424
+
2425
+
2426
+ if (!matchesEntirely(nationalNumber, metadata.nationalNumberPattern()) && matchesEntirely(possibleShorterNationalNumber, metadata.nationalNumberPattern()) || checkNumberLength(nationalNumber, metadata) === 'TOO_LONG') {
2427
+ return {
2428
+ countryCallingCode: countryCallingCode,
2429
+ number: possibleShorterNumber
2430
+ };
2431
+ }
2432
+ }
2433
+
2434
+ return {
2435
+ number: number
2436
+ };
2437
+ }
122
2438
 
123
2439
  /**
124
- * Get validation rules for a field
125
- *
126
- * @param { WebAddressFieldDefinition } definition the field definition
127
- * @returns { ValidationRules} the validation rules
128
- */
129
- const getWebAddressValidationRules = (definition) => {
130
- const defaultRules = {};
131
- const pattern = {
132
- pattern: {
133
- value: RegExp("^(((https?|ftps?)://)(%[0-9A-Fa-f]{2}|[-()_.!~*';/?:@&=+$,A-Za-z0-9])+)([).!';/?:,][[:blank:|:blank:]])?$"),
134
- message: `Must match url pattern`,
135
- },
136
- };
137
- return definition.uiEditable
138
- ? Object.assign(Object.assign({}, pattern), defaultRules) : defaultRules;
139
- };
2440
+ * Converts a phone number digits (possibly with a `+`)
2441
+ * into a calling code and the rest phone number digits.
2442
+ * The "rest phone number digits" could include
2443
+ * a national prefix, carrier code, and national
2444
+ * (significant) number.
2445
+ * @param {string} number — Phone number digits (possibly with a `+`).
2446
+ * @param {string} [country] — Default country.
2447
+ * @param {string} [callingCode] — Default calling code (some phone numbering plans are non-geographic).
2448
+ * @param {object} metadata
2449
+ * @return {object} `{ countryCallingCodeSource: string?, countryCallingCode: string?, number: string }`
2450
+ * @example
2451
+ * // Returns `{ countryCallingCode: "1", number: "2133734253" }`.
2452
+ * extractCountryCallingCode('2133734253', 'US', null, metadata)
2453
+ * extractCountryCallingCode('2133734253', null, '1', metadata)
2454
+ * extractCountryCallingCode('+12133734253', null, null, metadata)
2455
+ * extractCountryCallingCode('+12133734253', 'RU', null, metadata)
2456
+ */
2457
+
2458
+ function extractCountryCallingCode(number, country, callingCode, metadata) {
2459
+ if (!number) {
2460
+ return {};
2461
+ }
2462
+
2463
+ var isNumberWithIddPrefix; // If this is not an international phone number,
2464
+ // then either extract an "IDD" prefix, or extract a
2465
+ // country calling code from a number by autocorrecting it
2466
+ // by prepending a leading `+` in cases when it starts
2467
+ // with the country calling code.
2468
+ // https://wikitravel.org/en/International_dialling_prefix
2469
+ // https://github.com/catamphetamine/libphonenumber-js/issues/376
2470
+
2471
+ if (number[0] !== '+') {
2472
+ // Convert an "out-of-country" dialing phone number
2473
+ // to a proper international phone number.
2474
+ var numberWithoutIDD = stripIddPrefix(number, country, callingCode, metadata); // If an IDD prefix was stripped then
2475
+ // convert the number to international one
2476
+ // for subsequent parsing.
2477
+
2478
+ if (numberWithoutIDD && numberWithoutIDD !== number) {
2479
+ isNumberWithIddPrefix = true;
2480
+ number = '+' + numberWithoutIDD;
2481
+ } else {
2482
+ // Check to see if the number starts with the country calling code
2483
+ // for the default country. If so, we remove the country calling code,
2484
+ // and do some checks on the validity of the number before and after.
2485
+ // https://github.com/catamphetamine/libphonenumber-js/issues/376
2486
+ if (country || callingCode) {
2487
+ var _extractCountryCallin = extractCountryCallingCodeFromInternationalNumberWithoutPlusSign(number, country, callingCode, metadata),
2488
+ countryCallingCode = _extractCountryCallin.countryCallingCode,
2489
+ shorterNumber = _extractCountryCallin.number;
2490
+
2491
+ if (countryCallingCode) {
2492
+ return {
2493
+ countryCallingCodeSource: 'FROM_NUMBER_WITHOUT_PLUS_SIGN',
2494
+ countryCallingCode: countryCallingCode,
2495
+ number: shorterNumber
2496
+ };
2497
+ }
2498
+ }
2499
+
2500
+ return {
2501
+ // No need to set it to `UNSPECIFIED`. It can be just `undefined`.
2502
+ // countryCallingCodeSource: 'UNSPECIFIED',
2503
+ number: number
2504
+ };
2505
+ }
2506
+ } // Fast abortion: country codes do not begin with a '0'
2507
+
2508
+
2509
+ if (number[1] === '0') {
2510
+ return {};
2511
+ }
2512
+
2513
+ metadata = new Metadata(metadata); // The thing with country phone codes
2514
+ // is that they are orthogonal to each other
2515
+ // i.e. there's no such country phone code A
2516
+ // for which country phone code B exists
2517
+ // where B starts with A.
2518
+ // Therefore, while scanning digits,
2519
+ // if a valid country code is found,
2520
+ // that means that it is the country code.
2521
+ //
2522
+
2523
+ var i = 2;
2524
+
2525
+ while (i - 1 <= MAX_LENGTH_COUNTRY_CODE && i <= number.length) {
2526
+ var _countryCallingCode = number.slice(1, i);
2527
+
2528
+ if (metadata.hasCallingCode(_countryCallingCode)) {
2529
+ metadata.selectNumberingPlan(_countryCallingCode);
2530
+ return {
2531
+ countryCallingCodeSource: isNumberWithIddPrefix ? 'FROM_NUMBER_WITH_IDD' : 'FROM_NUMBER_WITH_PLUS_SIGN',
2532
+ countryCallingCode: _countryCallingCode,
2533
+ number: number.slice(i)
2534
+ };
2535
+ }
2536
+
2537
+ i++;
2538
+ }
2539
+
2540
+ return {};
2541
+ } // The possible values for the returned `countryCallingCodeSource` are:
2542
+ //
2543
+ // Copy-pasted from:
2544
+ // https://github.com/google/libphonenumber/blob/master/resources/phonenumber.proto
2545
+ //
2546
+ // // The source from which the country_code is derived. This is not set in the
2547
+ // // general parsing method, but in the method that parses and keeps raw_input.
2548
+ // // New fields could be added upon request.
2549
+ // enum CountryCodeSource {
2550
+ // // Default value returned if this is not set, because the phone number was
2551
+ // // created using parse, not parseAndKeepRawInput. hasCountryCodeSource will
2552
+ // // return false if this is the case.
2553
+ // UNSPECIFIED = 0;
2554
+ //
2555
+ // // The country_code is derived based on a phone number with a leading "+",
2556
+ // // e.g. the French number "+33 1 42 68 53 00".
2557
+ // FROM_NUMBER_WITH_PLUS_SIGN = 1;
2558
+ //
2559
+ // // The country_code is derived based on a phone number with a leading IDD,
2560
+ // // e.g. the French number "011 33 1 42 68 53 00", as it is dialled from US.
2561
+ // FROM_NUMBER_WITH_IDD = 5;
2562
+ //
2563
+ // // The country_code is derived based on a phone number without a leading
2564
+ // // "+", e.g. the French number "33 1 42 68 53 00" when defaultCountry is
2565
+ // // supplied as France.
2566
+ // FROM_NUMBER_WITHOUT_PLUS_SIGN = 10;
2567
+ //
2568
+ // // The country_code is derived NOT based on the phone number itself, but
2569
+ // // from the defaultCountry parameter provided in the parsing function by the
2570
+ // // clients. This happens mostly for numbers written in the national format
2571
+ // // (without country code). For example, this would be set when parsing the
2572
+ // // French number "01 42 68 53 00", when defaultCountry is supplied as
2573
+ // // France.
2574
+ // FROM_DEFAULT_COUNTRY = 20;
2575
+ // }
2576
+
2577
+ function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray$1(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
2578
+
2579
+ function _unsupportedIterableToArray$1(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$1(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$1(o, minLen); }
2580
+
2581
+ function _arrayLikeToArray$1(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
2582
+ function getCountryByNationalNumber(nationalPhoneNumber, _ref) {
2583
+ var countries = _ref.countries,
2584
+ defaultCountry = _ref.defaultCountry,
2585
+ metadata = _ref.metadata;
2586
+ // Re-create `metadata` because it will be selecting a `country`.
2587
+ metadata = new Metadata(metadata);
2588
+ var matchingCountries = [];
2589
+
2590
+ for (var _iterator = _createForOfIteratorHelperLoose(countries), _step; !(_step = _iterator()).done;) {
2591
+ var country = _step.value;
2592
+ metadata.country(country); // "Leading digits" patterns are only defined for about 20% of all countries.
2593
+ // By definition, matching "leading digits" is a sufficient but not a necessary
2594
+ // condition for a phone number to belong to a country.
2595
+ // The point of "leading digits" check is that it's the fastest one to get a match.
2596
+ // https://gitlab.com/catamphetamine/libphonenumber-js/blob/master/METADATA.md#leading_digits
2597
+ // I'd suppose that "leading digits" patterns are mutually exclusive for different countries
2598
+ // because of the intended use of that feature.
2599
+
2600
+ if (metadata.leadingDigits()) {
2601
+ if (nationalPhoneNumber && nationalPhoneNumber.search(metadata.leadingDigits()) === 0) {
2602
+ return country;
2603
+ }
2604
+ } // Else perform full validation with all of those
2605
+ // fixed-line/mobile/etc regular expressions.
2606
+ else if (getNumberType({
2607
+ phone: nationalPhoneNumber,
2608
+ country: country
2609
+ }, undefined, metadata.metadata)) {
2610
+ // If the `defaultCountry` is among the `matchingCountries` then return it.
2611
+ if (defaultCountry) {
2612
+ if (country === defaultCountry) {
2613
+ return country;
2614
+ }
2615
+
2616
+ matchingCountries.push(country);
2617
+ } else {
2618
+ return country;
2619
+ }
2620
+ }
2621
+ } // Return the first ("main") one of the `matchingCountries`.
2622
+
2623
+
2624
+ if (matchingCountries.length > 0) {
2625
+ return matchingCountries[0];
2626
+ }
2627
+ }
2628
+
2629
+ var USE_NON_GEOGRAPHIC_COUNTRY_CODE = false;
2630
+ function getCountryByCallingCode(callingCode, _ref) {
2631
+ var nationalPhoneNumber = _ref.nationalNumber,
2632
+ defaultCountry = _ref.defaultCountry,
2633
+ metadata = _ref.metadata;
2634
+
2635
+ /* istanbul ignore if */
2636
+ if (USE_NON_GEOGRAPHIC_COUNTRY_CODE) {
2637
+ if (metadata.isNonGeographicCallingCode(callingCode)) {
2638
+ return '001';
2639
+ }
2640
+ }
2641
+
2642
+ var possibleCountries = metadata.getCountryCodesForCallingCode(callingCode);
2643
+
2644
+ if (!possibleCountries) {
2645
+ return;
2646
+ } // If there's just one country corresponding to the country code,
2647
+ // then just return it, without further phone number digits validation.
2648
+
2649
+
2650
+ if (possibleCountries.length === 1) {
2651
+ return possibleCountries[0];
2652
+ }
2653
+
2654
+ return getCountryByNationalNumber(nationalPhoneNumber, {
2655
+ countries: possibleCountries,
2656
+ defaultCountry: defaultCountry,
2657
+ metadata: metadata.metadata
2658
+ });
2659
+ }
2660
+
2661
+ // When phone numbers are written in `RFC3966` format — `"tel:+12133734253"` —
2662
+ var PLUS_SIGN = '+';
2663
+ var RFC3966_VISUAL_SEPARATOR_ = '[\\-\\.\\(\\)]?';
2664
+ var RFC3966_PHONE_DIGIT_ = '(' + '[' + VALID_DIGITS + ']' + '|' + RFC3966_VISUAL_SEPARATOR_ + ')';
2665
+ var RFC3966_GLOBAL_NUMBER_DIGITS_ = '^' + '\\' + PLUS_SIGN + RFC3966_PHONE_DIGIT_ + '*' + '[' + VALID_DIGITS + ']' + RFC3966_PHONE_DIGIT_ + '*' + '$';
140
2666
  /**
141
- * Get validation rules for a field.
142
- *
143
- * @param { NumberFieldDefinition } definition the field definition
144
- * @returns { ValidationRules} the validation rules
145
- */
146
- const getNumberValidationRules = (definition) => {
147
- const defaultRules = { valueAsNumber: true };
148
- const minimum = definition.minimumNumber && {
149
- min: {
150
- value: definition.minimumNumber,
151
- message: `minimum value is ${definition.minimumNumber}`,
152
- },
153
- };
154
- const maximum = definition.maximumNumber && {
155
- max: {
156
- value: definition.maximumNumber,
157
- message: `maximum value is ${definition.maximumNumber}`,
158
- },
159
- };
160
- // TODO: Validate if integer if definition requires integer
161
- return definition.uiEditable
162
- ? Object.assign(Object.assign(Object.assign({}, maximum), minimum), defaultRules) : defaultRules;
163
- };
2667
+ * Regular expression of valid global-number-digits for the phone-context
2668
+ * parameter, following the syntax defined in RFC3966.
2669
+ */
2670
+
2671
+ var RFC3966_GLOBAL_NUMBER_DIGITS_PATTERN_ = new RegExp(RFC3966_GLOBAL_NUMBER_DIGITS_, 'g'); // In this port of Google's library, we don't accept alpha characters in phone numbers.
2672
+ // const ALPHANUM_ = VALID_ALPHA_ + VALID_DIGITS
2673
+
2674
+ var ALPHANUM_ = VALID_DIGITS;
2675
+ var RFC3966_DOMAINLABEL_ = '[' + ALPHANUM_ + ']+((\\-)*[' + ALPHANUM_ + '])*';
2676
+ var VALID_ALPHA_ = 'a-zA-Z';
2677
+ var RFC3966_TOPLABEL_ = '[' + VALID_ALPHA_ + ']+((\\-)*[' + ALPHANUM_ + '])*';
2678
+ var RFC3966_DOMAINNAME_ = '^(' + RFC3966_DOMAINLABEL_ + '\\.)*' + RFC3966_TOPLABEL_ + '\\.?$';
164
2679
  /**
165
- * Get validation rules for a string field.
166
- *
167
- * @param { StringFieldDefinition } definition the field definition
168
- * @returns { ValidationRules} the validation rules
169
- */
170
- const getStringValidationRules = (definition) => {
171
- const defaultRules = {};
172
- const minLength = definition.minimumLength
173
- ? {
174
- minLength: {
175
- value: definition.minimumLength,
176
- message: `minimum length is ${definition.minimumLength}`,
177
- },
178
- required: {
179
- value: true,
180
- message: `minimum length is ${definition.minimumLength}`,
181
- },
182
- }
183
- : undefined;
184
- const maxLength = definition.maximumLength
185
- ? {
186
- maxLength: {
187
- value: definition.maximumLength,
188
- message: `maximum length is ${definition.maximumLength}`,
189
- },
190
- }
191
- : undefined;
192
- const pattern = definition.pattern
193
- ? {
194
- pattern: {
195
- value: RegExp(definition.pattern),
196
- message: `Must match pattern: ${definition.pattern}`,
197
- },
198
- }
199
- : undefined;
200
- return definition.uiEditable
201
- ? Object.assign(Object.assign(Object.assign(Object.assign({}, maxLength), minLength), pattern), defaultRules) : defaultRules;
202
- };
2680
+ * Regular expression of valid domainname for the phone-context parameter,
2681
+ * following the syntax defined in RFC3966.
2682
+ */
2683
+
2684
+ var RFC3966_DOMAINNAME_PATTERN_ = new RegExp(RFC3966_DOMAINNAME_, 'g');
2685
+ var RFC3966_PREFIX_ = 'tel:';
2686
+ var RFC3966_PHONE_CONTEXT_ = ';phone-context=';
2687
+ var RFC3966_ISDN_SUBADDRESS_ = ';isub=';
203
2688
  /**
204
- * Get validation rules for a boolean field.
2689
+ * Extracts the value of the phone-context parameter of `numberToExtractFrom`,
2690
+ * following the syntax defined in RFC3966.
205
2691
  *
206
- * @param { BooleanFieldDefinition } definition the field definition
207
- * @returns { ValidationRules} the validation rules
208
- */
209
- const getBooleanValidationRules = (definition) => {
210
- const defaultRules = {};
211
- return defaultRules;
212
- };
2692
+ * @param {string} numberToExtractFrom
2693
+ * @return {string|null} the extracted string (possibly empty), or `null` if no phone-context parameter is found.
2694
+ */
2695
+
2696
+ function extractPhoneContext(numberToExtractFrom) {
2697
+ var indexOfPhoneContext = numberToExtractFrom.indexOf(RFC3966_PHONE_CONTEXT_); // If no phone-context parameter is present
2698
+
2699
+ if (indexOfPhoneContext < 0) {
2700
+ return null;
2701
+ }
2702
+
2703
+ var phoneContextStart = indexOfPhoneContext + RFC3966_PHONE_CONTEXT_.length; // If phone-context parameter is empty
2704
+
2705
+ if (phoneContextStart >= numberToExtractFrom.length) {
2706
+ return '';
2707
+ }
2708
+
2709
+ var phoneContextEnd = numberToExtractFrom.indexOf(';', phoneContextStart); // If phone-context is not the last parameter
2710
+
2711
+ if (phoneContextEnd >= 0) {
2712
+ return numberToExtractFrom.substring(phoneContextStart, phoneContextEnd);
2713
+ } else {
2714
+ return numberToExtractFrom.substring(phoneContextStart);
2715
+ }
2716
+ }
213
2717
  /**
214
- * Get validation rules for a dropdown field.
2718
+ * Returns whether the value of phoneContext follows the syntax defined in RFC3966.
215
2719
  *
216
- * @param { DropDownFieldDefinition } definition the field definition
217
- * @returns { ValidationRules} the validation rules
218
- */
219
- const getDropdownValidationRules = (definition) => {
220
- const defaultRules = {};
221
- return defaultRules;
222
- };
2720
+ * @param {string|null} phoneContext
2721
+ * @return {boolean}
2722
+ */
2723
+
2724
+ function isPhoneContextValid(phoneContext) {
2725
+ if (phoneContext === null) {
2726
+ return true;
2727
+ }
2728
+
2729
+ if (phoneContext.length === 0) {
2730
+ return false;
2731
+ } // Does phone-context value match pattern of global-number-digits or domainname.
2732
+
2733
+
2734
+ return RFC3966_GLOBAL_NUMBER_DIGITS_PATTERN_.test(phoneContext) || RFC3966_DOMAINNAME_PATTERN_.test(phoneContext);
2735
+ }
2736
+
223
2737
  /**
224
- * Get validation rules for a date field.
225
- *
226
- * @param { DateFieldDefinition } definition the field definition
227
- * @returns { ValidationRules} the validation rules
228
- */
229
- const getDateValidationRules = (definition) => {
230
- const defaultRules = {};
231
- return defaultRules;
232
- };
2738
+ * @param {string} numberToParse
2739
+ * @param {string} nationalNumber
2740
+ * @return {}
2741
+ */
2742
+
2743
+ function extractFormattedPhoneNumberFromPossibleRfc3966NumberUri(numberToParse, _ref) {
2744
+ var extractFormattedPhoneNumber = _ref.extractFormattedPhoneNumber;
2745
+ var phoneContext = extractPhoneContext(numberToParse);
2746
+
2747
+ if (!isPhoneContextValid(phoneContext)) {
2748
+ throw new ParseError('NOT_A_NUMBER');
2749
+ }
2750
+
2751
+ var phoneNumberString;
2752
+
2753
+ if (phoneContext === null) {
2754
+ // Extract a possible number from the string passed in.
2755
+ // (this strips leading characters that could not be the start of a phone number)
2756
+ phoneNumberString = extractFormattedPhoneNumber(numberToParse) || '';
2757
+ } else {
2758
+ phoneNumberString = ''; // If the phone context contains a phone number prefix, we need to capture
2759
+ // it, whereas domains will be ignored.
2760
+
2761
+ if (phoneContext.charAt(0) === PLUS_SIGN) {
2762
+ phoneNumberString += phoneContext;
2763
+ } // Now append everything between the "tel:" prefix and the phone-context.
2764
+ // This should include the national number, an optional extension or
2765
+ // isdn-subaddress component. Note we also handle the case when "tel:" is
2766
+ // missing, as we have seen in some of the phone number inputs.
2767
+ // In that case, we append everything from the beginning.
2768
+
2769
+
2770
+ var indexOfRfc3966Prefix = numberToParse.indexOf(RFC3966_PREFIX_);
2771
+ var indexOfNationalNumber; // RFC 3966 "tel:" prefix is preset at this stage because
2772
+ // `isPhoneContextValid()` requires it to be present.
2773
+
2774
+ /* istanbul ignore else */
2775
+
2776
+ if (indexOfRfc3966Prefix >= 0) {
2777
+ indexOfNationalNumber = indexOfRfc3966Prefix + RFC3966_PREFIX_.length;
2778
+ } else {
2779
+ indexOfNationalNumber = 0;
2780
+ }
2781
+
2782
+ var indexOfPhoneContext = numberToParse.indexOf(RFC3966_PHONE_CONTEXT_);
2783
+ phoneNumberString += numberToParse.substring(indexOfNationalNumber, indexOfPhoneContext);
2784
+ } // Delete the isdn-subaddress and everything after it if it is present.
2785
+ // Note extension won't appear at the same time with isdn-subaddress
2786
+ // according to paragraph 5.3 of the RFC3966 spec.
2787
+
2788
+
2789
+ var indexOfIsdn = phoneNumberString.indexOf(RFC3966_ISDN_SUBADDRESS_);
2790
+
2791
+ if (indexOfIsdn > 0) {
2792
+ phoneNumberString = phoneNumberString.substring(0, indexOfIsdn);
2793
+ } // If both phone context and isdn-subaddress are absent but other
2794
+ // parameters are present, the parameters are left in nationalNumber.
2795
+ // This is because we are concerned about deleting content from a potential
2796
+ // number string when there is no strong evidence that the number is
2797
+ // actually written in RFC3966.
2798
+
2799
+
2800
+ if (phoneNumberString !== '') {
2801
+ return phoneNumberString;
2802
+ }
2803
+ }
2804
+
2805
+ // This is a port of Google Android `libphonenumber`'s
2806
+ // This prevents malicious input from consuming CPU.
2807
+
2808
+ var MAX_INPUT_STRING_LENGTH = 250; // This consists of the plus symbol, digits, and arabic-indic digits.
2809
+
2810
+ var PHONE_NUMBER_START_PATTERN = new RegExp('[' + PLUS_CHARS + VALID_DIGITS + ']'); // Regular expression of trailing characters that we want to remove.
2811
+ // A trailing `#` is sometimes used when writing phone numbers with extensions in US.
2812
+ // Example: "+1 (645) 123 1234-910#" number has extension "910".
2813
+
2814
+ var AFTER_PHONE_NUMBER_END_PATTERN = new RegExp('[^' + VALID_DIGITS + '#' + ']+$');
2815
+ //
2816
+ // ```js
2817
+ // parse('8 (800) 555-35-35', 'RU')
2818
+ // parse('8 (800) 555-35-35', 'RU', metadata)
2819
+ // parse('8 (800) 555-35-35', { country: { default: 'RU' } })
2820
+ // parse('8 (800) 555-35-35', { country: { default: 'RU' } }, metadata)
2821
+ // parse('+7 800 555 35 35')
2822
+ // parse('+7 800 555 35 35', metadata)
2823
+ // ```
2824
+ //
2825
+
233
2826
  /**
234
- * Get validation rules for an email field.
2827
+ * Parses a phone number.
235
2828
  *
236
- * @param { EmailFieldDefinition } definition the field definition
237
- * @returns { ValidationRules} the validation rules
238
- */
239
- const getEmailValidationRules = (definition) => {
240
- const defaultRules = {};
241
- const pattern = {
242
- pattern: {
243
- value: RegExp("^[a-zA-Z0-9_+&*-]+(?:.[a-zA-Z0-9_+&*-]+)*@(?:[a-zA-Z0-9-]+.)+[a-zA-Z]{2,7}$"),
244
- message: `Must match email pattern`,
245
- },
246
- };
247
- return definition.uiEditable
248
- ? Object.assign(Object.assign({}, pattern), defaultRules) : defaultRules;
249
- };
250
- /**
251
- * Get validation rules for a phonenumber field.
2829
+ * parse('123456789', { defaultCountry: 'RU', v2: true }, metadata)
2830
+ * parse('123456789', { defaultCountry: 'RU' }, metadata)
2831
+ * parse('123456789', undefined, metadata)
252
2832
  *
253
- * @param { PhoneNumberFieldDefinition } definition the field definition
254
- * @returns { ValidationRules} the validation rules
255
- */
256
- const getPhoneNumberValidationRules = (definition) => {
257
- const defaultRules = {};
258
- const pattern = {
259
- validate: value => isValidPhoneNumber(value) || value === "",
260
- };
261
- return definition.uiEditable
262
- ? Object.assign(Object.assign({}, pattern), defaultRules) : defaultRules;
263
- };
2833
+ * @param {string} input
2834
+ * @param {object} [options]
2835
+ * @param {object} metadata
2836
+ * @return {object|PhoneNumber?} If `options.v2: true` flag is passed, it returns a `PhoneNumber?` instance. Otherwise, returns an object of shape `{ phone: '...', country: '...' }` (or just `{}` if no phone number was parsed).
2837
+ */
2838
+
2839
+ function parse(text, options, metadata) {
2840
+ // If assigning the `{}` default value is moved to the arguments above,
2841
+ // code coverage would decrease for some weird reason.
2842
+ options = options || {};
2843
+ metadata = new Metadata(metadata); // Validate `defaultCountry`.
2844
+
2845
+ if (options.defaultCountry && !metadata.hasCountry(options.defaultCountry)) {
2846
+ if (options.v2) {
2847
+ throw new ParseError('INVALID_COUNTRY');
2848
+ }
2849
+
2850
+ throw new Error("Unknown country: ".concat(options.defaultCountry));
2851
+ } // Parse the phone number.
2852
+
2853
+
2854
+ var _parseInput = parseInput(text, options.v2, options.extract),
2855
+ formattedPhoneNumber = _parseInput.number,
2856
+ ext = _parseInput.ext,
2857
+ error = _parseInput.error; // If the phone number is not viable then return nothing.
2858
+
264
2859
 
2860
+ if (!formattedPhoneNumber) {
2861
+ if (options.v2) {
2862
+ if (error === 'TOO_SHORT') {
2863
+ throw new ParseError('TOO_SHORT');
2864
+ }
2865
+
2866
+ throw new ParseError('NOT_A_NUMBER');
2867
+ }
2868
+
2869
+ return {};
2870
+ }
2871
+
2872
+ var _parsePhoneNumber = parsePhoneNumber$1(formattedPhoneNumber, options.defaultCountry, options.defaultCallingCode, metadata),
2873
+ country = _parsePhoneNumber.country,
2874
+ nationalNumber = _parsePhoneNumber.nationalNumber,
2875
+ countryCallingCode = _parsePhoneNumber.countryCallingCode,
2876
+ countryCallingCodeSource = _parsePhoneNumber.countryCallingCodeSource,
2877
+ carrierCode = _parsePhoneNumber.carrierCode;
2878
+
2879
+ if (!metadata.hasSelectedNumberingPlan()) {
2880
+ if (options.v2) {
2881
+ throw new ParseError('INVALID_COUNTRY');
2882
+ }
2883
+
2884
+ return {};
2885
+ } // Validate national (significant) number length.
2886
+
2887
+
2888
+ if (!nationalNumber || nationalNumber.length < MIN_LENGTH_FOR_NSN) {
2889
+ // Won't throw here because the regexp already demands length > 1.
2890
+
2891
+ /* istanbul ignore if */
2892
+ if (options.v2) {
2893
+ throw new ParseError('TOO_SHORT');
2894
+ } // Google's demo just throws an error in this case.
2895
+
2896
+
2897
+ return {};
2898
+ } // Validate national (significant) number length.
2899
+ //
2900
+ // A sidenote:
2901
+ //
2902
+ // They say that sometimes national (significant) numbers
2903
+ // can be longer than `MAX_LENGTH_FOR_NSN` (e.g. in Germany).
2904
+ // https://github.com/googlei18n/libphonenumber/blob/7e1748645552da39c4e1ba731e47969d97bdb539/resources/phonenumber.proto#L36
2905
+ // Such numbers will just be discarded.
2906
+ //
2907
+
2908
+
2909
+ if (nationalNumber.length > MAX_LENGTH_FOR_NSN) {
2910
+ if (options.v2) {
2911
+ throw new ParseError('TOO_LONG');
2912
+ } // Google's demo just throws an error in this case.
2913
+
2914
+
2915
+ return {};
2916
+ }
2917
+
2918
+ if (options.v2) {
2919
+ var phoneNumber = new PhoneNumber(countryCallingCode, nationalNumber, metadata.metadata);
2920
+
2921
+ if (country) {
2922
+ phoneNumber.country = country;
2923
+ }
2924
+
2925
+ if (carrierCode) {
2926
+ phoneNumber.carrierCode = carrierCode;
2927
+ }
2928
+
2929
+ if (ext) {
2930
+ phoneNumber.ext = ext;
2931
+ }
2932
+
2933
+ phoneNumber.__countryCallingCodeSource = countryCallingCodeSource;
2934
+ return phoneNumber;
2935
+ } // Check if national phone number pattern matches the number.
2936
+ // National number pattern is different for each country,
2937
+ // even for those ones which are part of the "NANPA" group.
2938
+
2939
+
2940
+ var valid = (options.extended ? metadata.hasSelectedNumberingPlan() : country) ? matchesEntirely(nationalNumber, metadata.nationalNumberPattern()) : false;
2941
+
2942
+ if (!options.extended) {
2943
+ return valid ? result(country, nationalNumber, ext) : {};
2944
+ } // isInternational: countryCallingCode !== undefined
2945
+
2946
+
2947
+ return {
2948
+ country: country,
2949
+ countryCallingCode: countryCallingCode,
2950
+ carrierCode: carrierCode,
2951
+ valid: valid,
2952
+ possible: valid ? true : options.extended === true && metadata.possibleLengths() && isPossibleNumber(nationalNumber, metadata) ? true : false,
2953
+ phone: nationalNumber,
2954
+ ext: ext
2955
+ };
2956
+ }
265
2957
  /**
266
- * A component that renders a custom field based on the field definition
267
- *
268
- * @param field A field definition and value
269
- * @param validation A validation object that contains the register, setValue and formState
270
- * @param unitPreference A unit preference that can be used to override the default unit preference
271
- * @param fieldId An optional Id to override the definition.key
272
- * @returns { JSX.Element } A JSX.Element or null if the field definition is undefined
273
- */
274
- const useCustomFieldResolver = (field, validation, unitPreference = "SI", fieldId) => {
275
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4;
276
- const [isEditing, setIsEditing] = useState(false);
277
- const [numberValue, setNumberValue] = useState(() => {
278
- var _a;
279
- if ((field === null || field === void 0 ? void 0 : field.definition) && field.definition.type === CustomFieldType.NUMBER) {
280
- const typedValue = field.value;
281
- return (_a = typedValue.numberValue) !== null && _a !== void 0 ? _a : field.definition.defaultNumberValue;
282
- }
283
- else {
284
- return "";
285
- }
286
- });
287
- if ((field === null || field === void 0 ? void 0 : field.definition) === undefined || ((_a = field === null || field === void 0 ? void 0 : field.definition) === null || _a === void 0 ? void 0 : _a.type) === undefined) {
288
- return null;
289
- }
290
- const key = (_b = fieldId !== null && fieldId !== void 0 ? fieldId : field.definition.key) !== null && _b !== void 0 ? _b : "";
291
- const fieldError = key ? validation.formState.errors[key] : undefined;
292
- const errorMessage = fieldError ? fieldError.message + "" : undefined;
293
- const { type, description, title } = field.definition;
294
- switch (type) {
295
- case CustomFieldType.WEB_ADDRESS: {
296
- const typedDefinition = field.definition;
297
- const typedValue = field.value;
298
- const rules = getWebAddressValidationRules(typedDefinition);
299
- return (jsx(TextField, Object.assign({ id: key, label: title, placeholder: (_c = typedDefinition.title) !== null && _c !== void 0 ? _c : "", defaultValue: (_e = (_d = typedValue.stringValue) !== null && _d !== void 0 ? _d : typedDefinition.defaultStringValue) !== null && _e !== void 0 ? _e : "", dataTestId: `${typedDefinition.key}`, actions: !typedDefinition.uiEditable &&
300
- (typedValue.stringValue || typedDefinition.defaultStringValue) && (jsx(ActionButton, { value: (_f = typedValue.stringValue) !== null && _f !== void 0 ? _f : typedDefinition.defaultStringValue, type: "WEB_ADDRESS" })), readOnly: !typedDefinition.uiEditable, helpText: description, errorMessage: errorMessage }, validation.register(key, rules))));
301
- }
302
- case CustomFieldType.EMAIL: {
303
- const typedDefinition = field.definition;
304
- const typedValue = field.value;
305
- const rules = getEmailValidationRules(typedDefinition);
306
- return (jsx(TextField, Object.assign({ id: key, label: title, placeholder: (_g = typedDefinition.title) !== null && _g !== void 0 ? _g : "", defaultValue: (_j = (_h = typedValue.stringValue) !== null && _h !== void 0 ? _h : typedDefinition.defaultStringValue) !== null && _j !== void 0 ? _j : "", dataTestId: `${typedDefinition.key}`, actions: !typedDefinition.uiEditable &&
307
- (typedValue.stringValue || typedDefinition.defaultStringValue) && (jsx(ActionButton, { value: (_k = typedValue.stringValue) !== null && _k !== void 0 ? _k : typedDefinition.defaultStringValue, type: "EMAIL" })), readOnly: !typedDefinition.uiEditable, helpText: description, errorMessage: errorMessage }, validation.register(key, rules))));
308
- }
309
- case CustomFieldType.PHONE_NUMBER: {
310
- const typedDefinition = field.definition;
311
- const typedValue = field.value;
312
- const rules = getPhoneNumberValidationRules(typedDefinition);
313
- return (jsx(TextField, Object.assign({ label: title, id: key, placeholder: (_l = typedDefinition.title) !== null && _l !== void 0 ? _l : "", defaultValue: (_o = (_m = typedValue.stringValue) !== null && _m !== void 0 ? _m : typedDefinition.defaultStringValue) !== null && _o !== void 0 ? _o : "", dataTestId: `${typedDefinition.key}`, actions: !typedDefinition.uiEditable &&
314
- (typedValue.stringValue || typedDefinition.defaultStringValue) && (jsx(ActionButton, { value: (_p = typedValue.stringValue) !== null && _p !== void 0 ? _p : typedDefinition.defaultStringValue, type: "PHONE_NUMBER" })), readOnly: !typedDefinition.uiEditable, helpText: description, errorMessage: errorMessage === "" ? "Must be a phone number" : undefined }, validation.register(key, rules))));
315
- }
316
- case CustomFieldType.STRING: {
317
- const typedDefinition = field.definition;
318
- const typedValue = field.value;
319
- const rules = getStringValidationRules(typedDefinition);
320
- return (jsx(TextField, Object.assign({ label: title, id: key || "string-field", placeholder: (_q = typedDefinition.title) !== null && _q !== void 0 ? _q : "", defaultValue: (_s = (_r = typedValue.stringValue) !== null && _r !== void 0 ? _r : typedDefinition.defaultStringValue) !== null && _s !== void 0 ? _s : "", readOnly: !typedDefinition.uiEditable, helpText: description, errorMessage: errorMessage, dataTestId: `${typedDefinition.key}` }, validation.register(key, rules))));
321
- }
322
- case CustomFieldType.NUMBER: {
323
- const typedDefinition = field.definition;
324
- const typedValue = field.value;
325
- const rules = getNumberValidationRules(typedDefinition);
326
- const unit = unitPreference === "US_CUSTOMARY" ? typedDefinition.unitUs : typedDefinition.unitSi;
327
- const numberProps = {
328
- placeholder: (_t = typedDefinition.title) !== null && _t !== void 0 ? _t : "",
329
- addonAfter: unit,
330
- };
331
- return (jsx(FormGroup, Object.assign({ htmlFor: isEditing ? key || "number-field" : `${key}-number-field`, label: title, isInvalid: errorMessage ? true : false, helpText: errorMessage || description, dataTestId: `${typedDefinition.key}-FormGroup`, disabled: !typedDefinition.uiEditable }, { children: isEditing ? (jsx(NumberInput, Object.assign({ id: key || "number-field", dataTestId: typedDefinition.key ? typedDefinition.key : `numberField`, defaultValue: (_v = (_u = typedValue.numberValue) !== null && _u !== void 0 ? _u : typedDefinition.defaultNumberValue) !== null && _v !== void 0 ? _v : "", readOnly: !typedDefinition.uiEditable, step: typedDefinition.isInteger ? 1 : "any", min: (_w = typedDefinition.minimumNumber) !== null && _w !== void 0 ? _w : undefined, max: (_x = typedDefinition.maximumNumber) !== null && _x !== void 0 ? _x : undefined }, validation.register(key, rules), { onBlur: () => setIsEditing(!isEditing), onChange: e => {
332
- setNumberValue(e.target.value);
333
- validation.register(key, rules).onChange(e);
334
- } }, numberProps))) : (jsx(BaseInput, Object.assign({ type: "text", id: `${key}-number-field`, dataTestId: `${typedDefinition.key}`, defaultValue: parseFloat(Number(numberValue).toPrecision(4)), readOnly: true, actions: jsx(ActionContainer, { children: jsx(StyledIconButton, { dataTestId: `${typedDefinition.key}-editIconButtonId`, size: "small", color: "tertiary", icon: jsx(Icon, { size: "small", name: "PencilIcon" }), onClick: () => setIsEditing(!isEditing) }) }) }, numberProps))) })));
335
- }
336
- case CustomFieldType.BOOLEAN: {
337
- const typedDefinition = field.definition;
338
- const typedValue = field.value;
339
- const rules = getBooleanValidationRules();
340
- return (jsx(BooleanCustomField, { label: (_y = typedDefinition.title) !== null && _y !== void 0 ? _y : "", id: key || "boolean-field", defaultValue: (_0 = (_z = typedValue.booleanValue) !== null && _z !== void 0 ? _z : typedDefinition.defaultBooleanValue) !== null && _0 !== void 0 ? _0 : undefined, readOnly: !typedDefinition.uiEditable, register: validation.register, validationRules: rules, helpText: description, setValue: validation.setValue, errorMessage: errorMessage, dataTestId: `${typedDefinition.key}` }, key));
341
- }
342
- case CustomFieldType.DROPDOWN: {
343
- const typedDefinition = field.definition;
344
- const typedValue = field.value;
345
- const rules = getDropdownValidationRules();
346
- return (jsx(DropdownCustomField, { label: typedDefinition.title || "", id: key || "dropdown-field", defaultValue: (_2 = (_1 = typedValue.stringArrayValue) !== null && _1 !== void 0 ? _1 : typedDefinition.defaultStringArrayValue) !== null && _2 !== void 0 ? _2 : undefined, disabled: !typedDefinition.uiEditable, allValues: (_3 = typedDefinition.allValues) !== null && _3 !== void 0 ? _3 : undefined, multiSelect: (_4 = typedDefinition.multiSelect) !== null && _4 !== void 0 ? _4 : false, register: validation.register, validationRules: rules, helpText: description, setValue: validation.setValue, errorMessage: errorMessage, dataTestId: `${typedDefinition.key}` }, key));
347
- }
348
- case CustomFieldType.DATE: {
349
- const typedDefinition = field.definition;
350
- const typedValue = field.value;
351
- const rules = getDateValidationRules();
352
- let defaultValue;
353
- if (typedValue.dateValue !== undefined && typedValue.dateValue !== null) {
354
- defaultValue = new Date(typedValue.dateValue);
355
- }
356
- else if (typedDefinition.defaultDateValue !== undefined && typedDefinition.defaultDateValue !== null) {
357
- defaultValue = new Date(typedDefinition.defaultDateValue);
358
- }
359
- return (jsx(DateCustomField, { dataTestId: `${typedDefinition.key}`, id: key || "date-field", defaultValue: defaultValue, readOnly: !typedDefinition.uiEditable, register: validation.register, label: typedDefinition.title || "", validationRules: rules, helpText: description, errorMessage: errorMessage, setValue: validation.setValue, title: field.definition.title || "" }, key));
360
- }
361
- default:
362
- throw new Error(`Type not supported: ${type}`);
363
- }
364
- };
2958
+ * Extracts a formatted phone number from text.
2959
+ * Doesn't guarantee that the extracted phone number
2960
+ * is a valid phone number (for example, doesn't validate its length).
2961
+ * @param {string} text
2962
+ * @param {boolean} [extract] If `false`, then will parse the entire `text` as a phone number.
2963
+ * @param {boolean} [throwOnError] By default, it won't throw if the text is too long.
2964
+ * @return {string}
2965
+ * @example
2966
+ * // Returns "(213) 373-4253".
2967
+ * extractFormattedPhoneNumber("Call (213) 373-4253 for assistance.")
2968
+ */
2969
+
2970
+ function _extractFormattedPhoneNumber(text, extract, throwOnError) {
2971
+ if (!text) {
2972
+ return;
2973
+ }
2974
+
2975
+ if (text.length > MAX_INPUT_STRING_LENGTH) {
2976
+ if (throwOnError) {
2977
+ throw new ParseError('TOO_LONG');
2978
+ }
2979
+
2980
+ return;
2981
+ }
2982
+
2983
+ if (extract === false) {
2984
+ return text;
2985
+ } // Attempt to extract a possible number from the string passed in
2986
+
2987
+
2988
+ var startsAt = text.search(PHONE_NUMBER_START_PATTERN);
2989
+
2990
+ if (startsAt < 0) {
2991
+ return;
2992
+ }
2993
+
2994
+ return text // Trim everything to the left of the phone number
2995
+ .slice(startsAt) // Remove trailing non-numerical characters
2996
+ .replace(AFTER_PHONE_NUMBER_END_PATTERN, '');
2997
+ }
365
2998
  /**
366
- *
367
- */
368
- const CustomField = ({ field, register, formState, setValue, unitPreference, fieldId }) => {
369
- const fieldComponent = useCustomFieldResolver(field, { register, setValue, formState }, unitPreference, fieldId);
370
- return fieldComponent;
371
- };
2999
+ * @param {string} text - Input.
3000
+ * @param {boolean} v2 - Legacy API functions don't pass `v2: true` flag.
3001
+ * @param {boolean} [extract] - Whether to extract a phone number from `text`, or attempt to parse the entire text as a phone number.
3002
+ * @return {object} `{ ?number, ?ext }`.
3003
+ */
3004
+
3005
+
3006
+ function parseInput(text, v2, extract) {
3007
+ // // Parse RFC 3966 phone number URI.
3008
+ // if (text && text.indexOf('tel:') === 0) {
3009
+ // return parseRFC3966(text)
3010
+ // }
3011
+ // let number = extractFormattedPhoneNumber(text, extract, v2)
3012
+ var number = extractFormattedPhoneNumberFromPossibleRfc3966NumberUri(text, {
3013
+ extractFormattedPhoneNumber: function extractFormattedPhoneNumber(text) {
3014
+ return _extractFormattedPhoneNumber(text, extract, v2);
3015
+ }
3016
+ }); // If the phone number is not viable, then abort.
3017
+
3018
+ if (!number) {
3019
+ return {};
3020
+ }
3021
+
3022
+ if (!isViablePhoneNumber(number)) {
3023
+ if (isViablePhoneNumberStart(number)) {
3024
+ return {
3025
+ error: 'TOO_SHORT'
3026
+ };
3027
+ }
3028
+
3029
+ return {};
3030
+ } // Attempt to parse extension first, since it doesn't require region-specific
3031
+ // data and we want to have the non-normalised number here.
3032
+
3033
+
3034
+ var withExtensionStripped = extractExtension(number);
3035
+
3036
+ if (withExtensionStripped.ext) {
3037
+ return withExtensionStripped;
3038
+ }
3039
+
3040
+ return {
3041
+ number: number
3042
+ };
3043
+ }
3044
+ /**
3045
+ * Creates `parse()` result object.
3046
+ */
3047
+
3048
+
3049
+ function result(country, nationalNumber, ext) {
3050
+ var result = {
3051
+ country: country,
3052
+ phone: nationalNumber
3053
+ };
3054
+
3055
+ if (ext) {
3056
+ result.ext = ext;
3057
+ }
3058
+
3059
+ return result;
3060
+ }
3061
+ /**
3062
+ * Parses a viable phone number.
3063
+ * @param {string} formattedPhoneNumber — Example: "(213) 373-4253".
3064
+ * @param {string} [defaultCountry]
3065
+ * @param {string} [defaultCallingCode]
3066
+ * @param {Metadata} metadata
3067
+ * @return {object} Returns `{ country: string?, countryCallingCode: string?, nationalNumber: string? }`.
3068
+ */
3069
+
3070
+
3071
+ function parsePhoneNumber$1(formattedPhoneNumber, defaultCountry, defaultCallingCode, metadata) {
3072
+ // Extract calling code from phone number.
3073
+ var _extractCountryCallin = extractCountryCallingCode(parseIncompletePhoneNumber(formattedPhoneNumber), defaultCountry, defaultCallingCode, metadata.metadata),
3074
+ countryCallingCodeSource = _extractCountryCallin.countryCallingCodeSource,
3075
+ countryCallingCode = _extractCountryCallin.countryCallingCode,
3076
+ number = _extractCountryCallin.number; // Choose a country by `countryCallingCode`.
3077
+
3078
+
3079
+ var country;
3080
+
3081
+ if (countryCallingCode) {
3082
+ metadata.selectNumberingPlan(countryCallingCode);
3083
+ } // If `formattedPhoneNumber` is passed in "national" format
3084
+ // then `number` is defined and `countryCallingCode` is `undefined`.
3085
+ else if (number && (defaultCountry || defaultCallingCode)) {
3086
+ metadata.selectNumberingPlan(defaultCountry, defaultCallingCode);
3087
+
3088
+ if (defaultCountry) {
3089
+ country = defaultCountry;
3090
+ }
3091
+
3092
+ countryCallingCode = defaultCallingCode || getCountryCallingCode(defaultCountry, metadata.metadata);
3093
+ } else return {};
3094
+
3095
+ if (!number) {
3096
+ return {
3097
+ countryCallingCodeSource: countryCallingCodeSource,
3098
+ countryCallingCode: countryCallingCode
3099
+ };
3100
+ }
3101
+
3102
+ var _extractNationalNumbe = extractNationalNumber(parseIncompletePhoneNumber(number), metadata),
3103
+ nationalNumber = _extractNationalNumbe.nationalNumber,
3104
+ carrierCode = _extractNationalNumbe.carrierCode; // Sometimes there are several countries
3105
+ // corresponding to the same country phone code
3106
+ // (e.g. NANPA countries all having `1` country phone code).
3107
+ // Therefore, to reliably determine the exact country,
3108
+ // national (significant) number should have been parsed first.
3109
+ //
3110
+ // When `metadata.json` is generated, all "ambiguous" country phone codes
3111
+ // get their countries populated with the full set of
3112
+ // "phone number type" regular expressions.
3113
+ //
3114
+
3115
+
3116
+ var exactCountry = getCountryByCallingCode(countryCallingCode, {
3117
+ nationalNumber: nationalNumber,
3118
+ defaultCountry: defaultCountry,
3119
+ metadata: metadata
3120
+ });
3121
+
3122
+ if (exactCountry) {
3123
+ country = exactCountry;
3124
+ /* istanbul ignore if */
3125
+
3126
+ if (exactCountry === '001') ; else {
3127
+ metadata.country(country);
3128
+ }
3129
+ }
3130
+
3131
+ return {
3132
+ country: country,
3133
+ countryCallingCode: countryCallingCode,
3134
+ countryCallingCodeSource: countryCallingCodeSource,
3135
+ nationalNumber: nationalNumber,
3136
+ carrierCode: carrierCode
3137
+ };
3138
+ }
3139
+
3140
+ function ownKeys$3(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
3141
+
3142
+ function _objectSpread$3(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$3(Object(source), !0).forEach(function (key) { _defineProperty$3(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$3(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
3143
+
3144
+ function _defineProperty$3(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
3145
+ function parsePhoneNumberWithError(text, options, metadata) {
3146
+ return parse(text, _objectSpread$3(_objectSpread$3({}, options), {}, {
3147
+ v2: true
3148
+ }), metadata);
3149
+ }
3150
+
3151
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
3152
+
3153
+ function ownKeys$2(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
3154
+
3155
+ function _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$2(Object(source), !0).forEach(function (key) { _defineProperty$2(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$2(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
3156
+
3157
+ function _defineProperty$2(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
3158
+
3159
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
3160
+
3161
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3162
+
3163
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
3164
+
3165
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
3166
+
3167
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
3168
+
3169
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
3170
+
3171
+ // Extracts the following properties from function arguments:
3172
+ // * input `text`
3173
+ // * `options` object
3174
+ // * `metadata` JSON
3175
+ function normalizeArguments(args) {
3176
+ var _Array$prototype$slic = Array.prototype.slice.call(args),
3177
+ _Array$prototype$slic2 = _slicedToArray(_Array$prototype$slic, 4),
3178
+ arg_1 = _Array$prototype$slic2[0],
3179
+ arg_2 = _Array$prototype$slic2[1],
3180
+ arg_3 = _Array$prototype$slic2[2],
3181
+ arg_4 = _Array$prototype$slic2[3];
3182
+
3183
+ var text;
3184
+ var options;
3185
+ var metadata; // If the phone number is passed as a string.
3186
+ // `parsePhoneNumber('88005553535', ...)`.
3187
+
3188
+ if (typeof arg_1 === 'string') {
3189
+ text = arg_1;
3190
+ } else throw new TypeError('A text for parsing must be a string.'); // If "default country" argument is being passed then move it to `options`.
3191
+ // `parsePhoneNumber('88005553535', 'RU', [options], metadata)`.
3192
+
3193
+
3194
+ if (!arg_2 || typeof arg_2 === 'string') {
3195
+ if (arg_4) {
3196
+ options = arg_3;
3197
+ metadata = arg_4;
3198
+ } else {
3199
+ options = undefined;
3200
+ metadata = arg_3;
3201
+ }
3202
+
3203
+ if (arg_2) {
3204
+ options = _objectSpread$2({
3205
+ defaultCountry: arg_2
3206
+ }, options);
3207
+ }
3208
+ } // `defaultCountry` is not passed.
3209
+ // Example: `parsePhoneNumber('+78005553535', [options], metadata)`.
3210
+ else if (isObject(arg_2)) {
3211
+ if (arg_3) {
3212
+ options = arg_2;
3213
+ metadata = arg_3;
3214
+ } else {
3215
+ metadata = arg_2;
3216
+ }
3217
+ } else throw new Error("Invalid second argument: ".concat(arg_2));
3218
+
3219
+ return {
3220
+ text: text,
3221
+ options: options,
3222
+ metadata: metadata
3223
+ };
3224
+ } // Otherwise istanbul would show this as "branch not covered".
3225
+
3226
+ /* istanbul ignore next */
3227
+
3228
+ var isObject = function isObject(_) {
3229
+ return _typeof(_) === 'object';
3230
+ };
3231
+
3232
+ function ownKeys$1(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
3233
+
3234
+ function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$1(Object(source), !0).forEach(function (key) { _defineProperty$1(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$1(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
3235
+
3236
+ function _defineProperty$1(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
3237
+ function parsePhoneNumber(text, options, metadata) {
3238
+ // Validate `defaultCountry`.
3239
+ if (options && options.defaultCountry && !isSupportedCountry(options.defaultCountry, metadata)) {
3240
+ options = _objectSpread$1(_objectSpread$1({}, options), {}, {
3241
+ defaultCountry: undefined
3242
+ });
3243
+ } // Parse phone number.
3244
+
3245
+
3246
+ try {
3247
+ return parsePhoneNumberWithError(text, options, metadata);
3248
+ } catch (error) {
3249
+ /* istanbul ignore else */
3250
+ if (error instanceof ParseError) ; else {
3251
+ throw error;
3252
+ }
3253
+ }
3254
+ }
3255
+
3256
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
3257
+
3258
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
3259
+
3260
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
3261
+ function isValidPhoneNumber$1() {
3262
+ var _normalizeArguments = normalizeArguments(arguments),
3263
+ text = _normalizeArguments.text,
3264
+ options = _normalizeArguments.options,
3265
+ metadata = _normalizeArguments.metadata;
3266
+
3267
+ options = _objectSpread(_objectSpread({}, options), {}, {
3268
+ extract: false
3269
+ });
3270
+ var phoneNumber = parsePhoneNumber(text, options, metadata);
3271
+ return phoneNumber && phoneNumber.isValid() || false;
3272
+ }
3273
+
3274
+ function isValidPhoneNumber() {
3275
+ return withMetadataArgument(isValidPhoneNumber$1, arguments)
3276
+ }
3277
+
3278
+ /**
3279
+ * Get validation rules for a field
3280
+ *
3281
+ * @param { WebAddressFieldDefinition } definition the field definition
3282
+ * @returns { ValidationRules} the validation rules
3283
+ */
3284
+ const getWebAddressValidationRules = (definition) => {
3285
+ const defaultRules = {};
3286
+ const pattern = {
3287
+ pattern: {
3288
+ value: RegExp("^(((https?|ftps?)://)(%[0-9A-Fa-f]{2}|[-()_.!~*';/?:@&=+$,A-Za-z0-9])+)([).!';/?:,][[:blank:|:blank:]])?$"),
3289
+ message: `Must match url pattern`,
3290
+ },
3291
+ };
3292
+ return definition.uiEditable
3293
+ ? Object.assign(Object.assign({}, pattern), defaultRules) : defaultRules;
3294
+ };
3295
+ /**
3296
+ * Get validation rules for a field.
3297
+ *
3298
+ * @param { NumberFieldDefinition } definition the field definition
3299
+ * @returns { ValidationRules} the validation rules
3300
+ */
3301
+ const getNumberValidationRules = (definition) => {
3302
+ const defaultRules = { valueAsNumber: true };
3303
+ const minimum = definition.minimumNumber && {
3304
+ min: {
3305
+ value: definition.minimumNumber,
3306
+ message: `minimum value is ${definition.minimumNumber}`,
3307
+ },
3308
+ };
3309
+ const maximum = definition.maximumNumber && {
3310
+ max: {
3311
+ value: definition.maximumNumber,
3312
+ message: `maximum value is ${definition.maximumNumber}`,
3313
+ },
3314
+ };
3315
+ // TODO: Validate if integer if definition requires integer
3316
+ return definition.uiEditable
3317
+ ? Object.assign(Object.assign(Object.assign({}, maximum), minimum), defaultRules) : defaultRules;
3318
+ };
3319
+ /**
3320
+ * Get validation rules for a string field.
3321
+ *
3322
+ * @param { StringFieldDefinition } definition the field definition
3323
+ * @returns { ValidationRules} the validation rules
3324
+ */
3325
+ const getStringValidationRules = (definition) => {
3326
+ const defaultRules = {};
3327
+ const minLength = definition.minimumLength
3328
+ ? {
3329
+ minLength: {
3330
+ value: definition.minimumLength,
3331
+ message: `minimum length is ${definition.minimumLength}`,
3332
+ },
3333
+ required: {
3334
+ value: true,
3335
+ message: `minimum length is ${definition.minimumLength}`,
3336
+ },
3337
+ }
3338
+ : undefined;
3339
+ const maxLength = definition.maximumLength
3340
+ ? {
3341
+ maxLength: {
3342
+ value: definition.maximumLength,
3343
+ message: `maximum length is ${definition.maximumLength}`,
3344
+ },
3345
+ }
3346
+ : undefined;
3347
+ const pattern = definition.pattern
3348
+ ? {
3349
+ pattern: {
3350
+ value: RegExp(definition.pattern),
3351
+ message: `Must match pattern: ${definition.pattern}`,
3352
+ },
3353
+ }
3354
+ : undefined;
3355
+ return definition.uiEditable
3356
+ ? Object.assign(Object.assign(Object.assign(Object.assign({}, maxLength), minLength), pattern), defaultRules) : defaultRules;
3357
+ };
3358
+ /**
3359
+ * Get validation rules for a boolean field.
3360
+ *
3361
+ * @param { BooleanFieldDefinition } definition the field definition
3362
+ * @returns { ValidationRules} the validation rules
3363
+ */
3364
+ const getBooleanValidationRules = (definition) => {
3365
+ const defaultRules = {};
3366
+ return defaultRules;
3367
+ };
3368
+ /**
3369
+ * Get validation rules for a dropdown field.
3370
+ *
3371
+ * @param { DropDownFieldDefinition } definition the field definition
3372
+ * @returns { ValidationRules} the validation rules
3373
+ */
3374
+ const getDropdownValidationRules = (definition) => {
3375
+ const defaultRules = {};
3376
+ return defaultRules;
3377
+ };
3378
+ /**
3379
+ * Get validation rules for a date field.
3380
+ *
3381
+ * @param { DateFieldDefinition } definition the field definition
3382
+ * @returns { ValidationRules} the validation rules
3383
+ */
3384
+ const getDateValidationRules = (definition) => {
3385
+ const defaultRules = {};
3386
+ return defaultRules;
3387
+ };
3388
+ /**
3389
+ * Get validation rules for an email field.
3390
+ *
3391
+ * @param { EmailFieldDefinition } definition the field definition
3392
+ * @returns { ValidationRules} the validation rules
3393
+ */
3394
+ const getEmailValidationRules = (definition) => {
3395
+ const defaultRules = {};
3396
+ const pattern = {
3397
+ pattern: {
3398
+ value: RegExp("^[a-zA-Z0-9_+&*-]+(?:.[a-zA-Z0-9_+&*-]+)*@(?:[a-zA-Z0-9-]+.)+[a-zA-Z]{2,7}$"),
3399
+ message: `Must match email pattern`,
3400
+ },
3401
+ };
3402
+ return definition.uiEditable
3403
+ ? Object.assign(Object.assign({}, pattern), defaultRules) : defaultRules;
3404
+ };
3405
+ /**
3406
+ * Get validation rules for a phonenumber field.
3407
+ *
3408
+ * @param { PhoneNumberFieldDefinition } definition the field definition
3409
+ * @returns { ValidationRules} the validation rules
3410
+ */
3411
+ const getPhoneNumberValidationRules = (definition) => {
3412
+ const defaultRules = {};
3413
+ const pattern = {
3414
+ validate: value => isValidPhoneNumber(value) || value === "",
3415
+ };
3416
+ return definition.uiEditable
3417
+ ? Object.assign(Object.assign({}, pattern), defaultRules) : defaultRules;
3418
+ };
3419
+
3420
+ /**
3421
+ * A component that renders a custom field based on the field definition
3422
+ *
3423
+ * @param field A field definition and value
3424
+ * @param validation A validation object that contains the register, setValue and formState
3425
+ * @param unitPreference A unit preference that can be used to override the default unit preference
3426
+ * @param fieldId An optional Id to override the definition.key
3427
+ * @returns { JSX.Element } A JSX.Element or null if the field definition is undefined
3428
+ */
3429
+ const useCustomFieldResolver = (field, validation, unitPreference = "SI", fieldId) => {
3430
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4;
3431
+ const [isEditing, setIsEditing] = useState(false);
3432
+ const [numberValue, setNumberValue] = useState(() => {
3433
+ var _a;
3434
+ if ((field === null || field === void 0 ? void 0 : field.definition) && field.definition.type === CustomFieldType.NUMBER) {
3435
+ const typedValue = field.value;
3436
+ return (_a = typedValue.numberValue) !== null && _a !== void 0 ? _a : field.definition.defaultNumberValue;
3437
+ }
3438
+ else {
3439
+ return "";
3440
+ }
3441
+ });
3442
+ if ((field === null || field === void 0 ? void 0 : field.definition) === undefined || ((_a = field === null || field === void 0 ? void 0 : field.definition) === null || _a === void 0 ? void 0 : _a.type) === undefined) {
3443
+ return null;
3444
+ }
3445
+ const key = (_b = fieldId !== null && fieldId !== void 0 ? fieldId : field.definition.key) !== null && _b !== void 0 ? _b : "";
3446
+ const fieldError = key ? validation.formState.errors[key] : undefined;
3447
+ const errorMessage = fieldError ? fieldError.message + "" : undefined;
3448
+ const { type, description, title } = field.definition;
3449
+ switch (type) {
3450
+ case CustomFieldType.WEB_ADDRESS: {
3451
+ const typedDefinition = field.definition;
3452
+ const typedValue = field.value;
3453
+ const rules = getWebAddressValidationRules(typedDefinition);
3454
+ return (jsx(TextField, Object.assign({ id: key, label: title, placeholder: (_c = typedDefinition.title) !== null && _c !== void 0 ? _c : "", defaultValue: (_e = (_d = typedValue.stringValue) !== null && _d !== void 0 ? _d : typedDefinition.defaultStringValue) !== null && _e !== void 0 ? _e : "", dataTestId: `${typedDefinition.key}`, actions: !typedDefinition.uiEditable &&
3455
+ (typedValue.stringValue || typedDefinition.defaultStringValue) && (jsx(ActionButton, { value: (_f = typedValue.stringValue) !== null && _f !== void 0 ? _f : typedDefinition.defaultStringValue, type: "WEB_ADDRESS" })), readOnly: !typedDefinition.uiEditable, helpText: description, errorMessage: errorMessage }, validation.register(key, rules))));
3456
+ }
3457
+ case CustomFieldType.EMAIL: {
3458
+ const typedDefinition = field.definition;
3459
+ const typedValue = field.value;
3460
+ const rules = getEmailValidationRules(typedDefinition);
3461
+ return (jsx(TextField, Object.assign({ id: key, label: title, placeholder: (_g = typedDefinition.title) !== null && _g !== void 0 ? _g : "", defaultValue: (_j = (_h = typedValue.stringValue) !== null && _h !== void 0 ? _h : typedDefinition.defaultStringValue) !== null && _j !== void 0 ? _j : "", dataTestId: `${typedDefinition.key}`, actions: !typedDefinition.uiEditable &&
3462
+ (typedValue.stringValue || typedDefinition.defaultStringValue) && (jsx(ActionButton, { value: (_k = typedValue.stringValue) !== null && _k !== void 0 ? _k : typedDefinition.defaultStringValue, type: "EMAIL" })), readOnly: !typedDefinition.uiEditable, helpText: description, errorMessage: errorMessage }, validation.register(key, rules))));
3463
+ }
3464
+ case CustomFieldType.PHONE_NUMBER: {
3465
+ const typedDefinition = field.definition;
3466
+ const typedValue = field.value;
3467
+ const rules = getPhoneNumberValidationRules(typedDefinition);
3468
+ return (jsx(TextField, Object.assign({ label: title, id: key, placeholder: (_l = typedDefinition.title) !== null && _l !== void 0 ? _l : "", defaultValue: (_o = (_m = typedValue.stringValue) !== null && _m !== void 0 ? _m : typedDefinition.defaultStringValue) !== null && _o !== void 0 ? _o : "", dataTestId: `${typedDefinition.key}`, actions: !typedDefinition.uiEditable &&
3469
+ (typedValue.stringValue || typedDefinition.defaultStringValue) && (jsx(ActionButton, { value: (_p = typedValue.stringValue) !== null && _p !== void 0 ? _p : typedDefinition.defaultStringValue, type: "PHONE_NUMBER" })), readOnly: !typedDefinition.uiEditable, helpText: description, errorMessage: errorMessage === "" ? "Must be a phone number" : undefined }, validation.register(key, rules))));
3470
+ }
3471
+ case CustomFieldType.STRING: {
3472
+ const typedDefinition = field.definition;
3473
+ const typedValue = field.value;
3474
+ const rules = getStringValidationRules(typedDefinition);
3475
+ return (jsx(TextField, Object.assign({ label: title, id: key || "string-field", placeholder: (_q = typedDefinition.title) !== null && _q !== void 0 ? _q : "", defaultValue: (_s = (_r = typedValue.stringValue) !== null && _r !== void 0 ? _r : typedDefinition.defaultStringValue) !== null && _s !== void 0 ? _s : "", readOnly: !typedDefinition.uiEditable, helpText: description, errorMessage: errorMessage, dataTestId: `${typedDefinition.key}` }, validation.register(key, rules))));
3476
+ }
3477
+ case CustomFieldType.NUMBER: {
3478
+ const typedDefinition = field.definition;
3479
+ const typedValue = field.value;
3480
+ const rules = getNumberValidationRules(typedDefinition);
3481
+ const unit = unitPreference === "US_CUSTOMARY" ? typedDefinition.unitUs : typedDefinition.unitSi;
3482
+ const numberProps = {
3483
+ placeholder: (_t = typedDefinition.title) !== null && _t !== void 0 ? _t : "",
3484
+ addonAfter: unit,
3485
+ };
3486
+ return (jsx(FormGroup, { htmlFor: isEditing ? key || "number-field" : `${key}-number-field`, label: title, isInvalid: errorMessage ? true : false, helpText: errorMessage || description, dataTestId: `${typedDefinition.key}-FormGroup`, disabled: !typedDefinition.uiEditable, children: isEditing ? (jsx(NumberInput, Object.assign({ id: key || "number-field", dataTestId: typedDefinition.key ? typedDefinition.key : `numberField`, defaultValue: (_v = (_u = typedValue.numberValue) !== null && _u !== void 0 ? _u : typedDefinition.defaultNumberValue) !== null && _v !== void 0 ? _v : "", readOnly: !typedDefinition.uiEditable, step: typedDefinition.isInteger ? 1 : "any", min: (_w = typedDefinition.minimumNumber) !== null && _w !== void 0 ? _w : undefined, max: (_x = typedDefinition.maximumNumber) !== null && _x !== void 0 ? _x : undefined }, validation.register(key, rules), { onBlur: () => setIsEditing(!isEditing), onChange: e => {
3487
+ setNumberValue(e.target.value);
3488
+ validation.register(key, rules).onChange(e);
3489
+ } }, numberProps))) : (jsx(BaseInput, Object.assign({ type: "text", id: `${key}-number-field`, dataTestId: `${typedDefinition.key}`, defaultValue: parseFloat(Number(numberValue).toPrecision(4)), readOnly: true, actions: jsx(ActionContainer, { children: jsx(StyledIconButton, { dataTestId: `${typedDefinition.key}-editIconButtonId`, size: "small", color: "tertiary", icon: jsx(Icon, { size: "small", name: "PencilIcon" }), onClick: () => setIsEditing(!isEditing) }) }) }, numberProps))) }));
3490
+ }
3491
+ case CustomFieldType.BOOLEAN: {
3492
+ const typedDefinition = field.definition;
3493
+ const typedValue = field.value;
3494
+ const rules = getBooleanValidationRules();
3495
+ return (jsx(BooleanCustomField, { label: (_y = typedDefinition.title) !== null && _y !== void 0 ? _y : "", id: key || "boolean-field", defaultValue: (_0 = (_z = typedValue.booleanValue) !== null && _z !== void 0 ? _z : typedDefinition.defaultBooleanValue) !== null && _0 !== void 0 ? _0 : undefined, readOnly: !typedDefinition.uiEditable, register: validation.register, validationRules: rules, helpText: description, setValue: validation.setValue, errorMessage: errorMessage, dataTestId: `${typedDefinition.key}` }, key));
3496
+ }
3497
+ case CustomFieldType.DROPDOWN: {
3498
+ const typedDefinition = field.definition;
3499
+ const typedValue = field.value;
3500
+ const rules = getDropdownValidationRules();
3501
+ return (jsx(DropdownCustomField, { label: typedDefinition.title || "", id: key || "dropdown-field", defaultValue: (_2 = (_1 = typedValue.stringArrayValue) !== null && _1 !== void 0 ? _1 : typedDefinition.defaultStringArrayValue) !== null && _2 !== void 0 ? _2 : undefined, disabled: !typedDefinition.uiEditable, allValues: (_3 = typedDefinition.allValues) !== null && _3 !== void 0 ? _3 : undefined, multiSelect: (_4 = typedDefinition.multiSelect) !== null && _4 !== void 0 ? _4 : false, register: validation.register, validationRules: rules, helpText: description, setValue: validation.setValue, errorMessage: errorMessage, dataTestId: `${typedDefinition.key}` }, key));
3502
+ }
3503
+ case CustomFieldType.DATE: {
3504
+ const typedDefinition = field.definition;
3505
+ const typedValue = field.value;
3506
+ const rules = getDateValidationRules();
3507
+ let defaultValue;
3508
+ if (typedValue.dateValue !== undefined && typedValue.dateValue !== null) {
3509
+ defaultValue = new Date(typedValue.dateValue);
3510
+ }
3511
+ else if (typedDefinition.defaultDateValue !== undefined && typedDefinition.defaultDateValue !== null) {
3512
+ defaultValue = new Date(typedDefinition.defaultDateValue);
3513
+ }
3514
+ return (jsx(DateCustomField, { dataTestId: `${typedDefinition.key}`, id: key || "date-field", defaultValue: defaultValue, readOnly: !typedDefinition.uiEditable, register: validation.register, label: typedDefinition.title || "", validationRules: rules, helpText: description, errorMessage: errorMessage, setValue: validation.setValue, title: field.definition.title || "" }, key));
3515
+ }
3516
+ default:
3517
+ throw new Error(`Type not supported: ${type}`);
3518
+ }
3519
+ };
3520
+ /**
3521
+ *
3522
+ */
3523
+ const CustomField = ({ field, register, formState, setValue, unitPreference, fieldId }) => {
3524
+ const fieldComponent = useCustomFieldResolver(field, { register, setValue, formState }, unitPreference, fieldId);
3525
+ return fieldComponent;
3526
+ };
372
3527
  const ActionContainer = tw.div `
373
3528
  tu-action-container
374
- `;
3529
+ `;
375
3530
  const StyledIconButton = twx(IconButton) `
376
3531
  tu-action-button
377
3532
  `;