@trackunit/custom-field-components 0.0.386 → 0.0.395

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.cjs CHANGED
@@ -8,8 +8,6 @@ var reactComponents = require('@trackunit/react-components');
8
8
  var reactFormComponents = require('@trackunit/react-form-components');
9
9
  var tailwindStyledComponents = require('@trackunit/tailwind-styled-components');
10
10
  var React = require('react');
11
- var uuid = require('uuid');
12
- var libphonenumberJs = require('libphonenumber-js');
13
11
 
14
12
  function _interopNamespace(e) {
15
13
  if (e && e.__esModule) return e;
@@ -58,343 +56,3500 @@ function __rest(s, e) {
58
56
  return t;
59
57
  }
60
58
 
59
+ // Unique ID creation requires a high quality random # generator. In the browser we therefore
60
+ // require the crypto API and do not support built-in fallback to lower quality random number
61
+ // generators (like Math.random()).
62
+ var getRandomValues;
63
+ var rnds8 = new Uint8Array(16);
64
+ function rng() {
65
+ // lazy load so that environments that need to polyfill have a chance to do so
66
+ if (!getRandomValues) {
67
+ // getRandomValues needs to be invoked in a context where "this" is a Crypto implementation. Also,
68
+ // find the complete implementation of crypto (msCrypto) on IE11.
69
+ getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto !== 'undefined' && typeof msCrypto.getRandomValues === 'function' && msCrypto.getRandomValues.bind(msCrypto);
70
+
71
+ if (!getRandomValues) {
72
+ throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
73
+ }
74
+ }
75
+
76
+ return getRandomValues(rnds8);
77
+ }
78
+
79
+ 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;
80
+
81
+ function validate(uuid) {
82
+ return typeof uuid === 'string' && REGEX.test(uuid);
83
+ }
84
+
85
+ /**
86
+ * Convert array of 16 byte values to UUID string format of the form:
87
+ * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
88
+ */
89
+
90
+ var byteToHex = [];
91
+
92
+ for (var i = 0; i < 256; ++i) {
93
+ byteToHex.push((i + 0x100).toString(16).substr(1));
94
+ }
95
+
96
+ function stringify(arr) {
97
+ var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
98
+ // Note: Be careful editing this code! It's been tuned for performance
99
+ // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
100
+ 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
101
+ // of the following:
102
+ // - One or more input array values don't map to a hex octet (leading to
103
+ // "undefined" in the uuid)
104
+ // - Invalid input values for the RFC `version` or `variant` fields
105
+
106
+ if (!validate(uuid)) {
107
+ throw TypeError('Stringified UUID is invalid');
108
+ }
109
+
110
+ return uuid;
111
+ }
112
+
113
+ function v4(options, buf, offset) {
114
+ options = options || {};
115
+ var rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
116
+
117
+ rnds[6] = rnds[6] & 0x0f | 0x40;
118
+ rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
119
+
120
+ if (buf) {
121
+ offset = offset || 0;
122
+
123
+ for (var i = 0; i < 16; ++i) {
124
+ buf[offset + i] = rnds[i];
125
+ }
126
+
127
+ return buf;
128
+ }
129
+
130
+ return stringify(rnds);
131
+ }
132
+
133
+ /**
134
+ * A component that can be used to render a boolean field
135
+ *
136
+ * @param options BooleanCustomFieldProps - options for the component
137
+ * @returns { JSX.Element } JSX.Element - a component that can be used to render a boolean field
138
+ */
139
+ const BooleanCustomField = (_a) => {
140
+ 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"]);
141
+ const initialValue = value !== undefined ? value : defaultValue ? defaultValue : false;
142
+ const renderAsInvalid = isInvalid || Boolean(errorMessage);
143
+ const htmlForId = id ? id : "boolean-custom-field-" + v4();
144
+ const [internalValue, setInternalValue] = React__namespace.useState(initialValue);
145
+ React__namespace.useEffect(() => {
146
+ setInternalValue((value === undefined ? defaultValue : value) || false);
147
+ }, [value, setInternalValue, defaultValue]);
148
+ const onChangeHandler = React__namespace.useCallback((event) => {
149
+ var _a;
150
+ onChange && onChange(event);
151
+ const isChecked = ((_a = event.target) === null || _a === void 0 ? void 0 : _a.checked) || false;
152
+ if (setValue) {
153
+ setValue(id, isChecked);
154
+ }
155
+ setInternalValue(isChecked);
156
+ }, [setInternalValue, onChange, id, setValue]);
157
+ React__namespace.useEffect(() => {
158
+ register && register(id, Object.assign(Object.assign({}, validationRules), { value: internalValue.toString() }));
159
+ // eslint-disable-next-line react-hooks/exhaustive-deps
160
+ }, []); // register only once
161
+ return (jsxRuntime.jsx(reactFormComponents.FormGroup, { htmlFor: htmlForId, label: label, tip: tip, isInvalid: renderAsInvalid, helpText: errorMessage || helpText, helpAddon: helpAddon || null, dataTestId: dataTestId && `${dataTestId}-FormGroup`, children: jsxRuntime.jsx(reactFormComponents.Checkbox, Object.assign({ checked: internalValue, dataTestId: dataTestId, id: htmlForId, disabled: disabled, name: id, onChange: onChangeHandler, isInvalid: renderAsInvalid }, rest)) }));
162
+ };
163
+
164
+ /**
165
+ * A component that can be used to render a date field
166
+ *
167
+ * @param props DateCustomFieldProps - options for the component
168
+ * @returns { JSX.Element } JSX.Element - a component that can be used to render a date field
169
+ */
170
+ const DateCustomField = (props) => {
171
+ const { setValue, defaultValue, register, id, validationRules } = props, rest = __rest(props, ["setValue", "defaultValue", "register", "id", "validationRules"]);
172
+ const onChangeHandler = React.useCallback((e) => {
173
+ var _a, _b, _c, _d;
174
+ if (((_b = (_a = e.target) === null || _a === void 0 ? void 0 : _a.valueAsDate) === null || _b === void 0 ? void 0 : _b.toISOString()) !== undefined) {
175
+ setValue && setValue(id, (_d = (_c = e.target) === null || _c === void 0 ? void 0 : _c.valueAsDate) === null || _d === void 0 ? void 0 : _d.toISOString());
176
+ }
177
+ }, [setValue, id]);
178
+ React.useEffect(() => {
179
+ const value = defaultValue && new Date(defaultValue);
180
+ register && register(id, Object.assign(Object.assign({}, validationRules), { value }));
181
+ }, [register, validationRules, defaultValue, id]);
182
+ return (React.createElement(reactFormComponents.DateField, Object.assign({}, rest, { key: id, id: id, helpAddon: props.helpAddon || null, helpText: props.errorMessage || props.helpText, onChange: onChangeHandler, label: props.title, defaultValue: defaultValue })));
183
+ };
184
+
185
+ const convertToValueFormat = (value) => {
186
+ return { label: value, value };
187
+ };
188
+ /**
189
+ * A custom field that can be used to render a dropdown
190
+ *
191
+ * @param options DropdownCustomFieldProps - an object with all the props
192
+ * @returns {JSX.Element} - a dropdown component
193
+ */
194
+ const DropdownCustomField = ({ defaultValue, dataTestId, onChange, onBlur, id, disabled = false, allValues, multiSelect = false, register, validationRules, setValue, label, tip, errorMessage, helpText, isInvalid, helpAddon, }) => {
195
+ const renderAsInvalid = isInvalid || Boolean(errorMessage);
196
+ const htmlForId = id ? id : "dropdown-custom-field-" + v4();
197
+ const [selectedValue, setSelectedValue] = React__namespace.useState(defaultValue ? defaultValue.map(convertToValueFormat) : []);
198
+ const onChangeHandler = React__namespace.useCallback((selected) => {
199
+ if (selected) {
200
+ const values = Array.isArray(selected) ? selected : [selected];
201
+ setSelectedValue(values);
202
+ setValue && setValue(id, values);
203
+ }
204
+ else {
205
+ setSelectedValue([]);
206
+ setValue && setValue(id, []);
207
+ }
208
+ }, [onChange]);
209
+ const options = React__namespace.useMemo(() => {
210
+ return allValues ? allValues.map(convertToValueFormat) : [];
211
+ }, [allValues]);
212
+ React__namespace.useEffect(() => {
213
+ register && register(id, Object.assign(Object.assign({}, validationRules), { value: selectedValue }));
214
+ }, [register, validationRules, selectedValue, id]);
215
+ return (jsxRuntime.jsx(reactFormComponents.FormGroup, { htmlFor: htmlForId, label: label, tip: tip, isInvalid: renderAsInvalid, helpText: errorMessage || helpText, helpAddon: helpAddon || null, dataTestId: dataTestId && `${dataTestId}-FormGroup`, children: jsxRuntime.jsx(reactFormComponents.Select, { inputId: htmlForId, "aria-labelledby": htmlForId + "-label", disabled: disabled, dataTestId: dataTestId, onChange: onChangeHandler, hasError: renderAsInvalid, options: options, value: selectedValue, isMulti: multiSelect, isClearable: true }) }));
216
+ };
217
+
218
+ // This file is a workaround for a bug in web browsers' "native"
219
+ // ES6 importing system which is uncapable of importing "*.json" files.
220
+ // https://github.com/catamphetamine/libphonenumber-js/issues/239
221
+ 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}"]]]}};
222
+
223
+ // Importing from a ".js" file is a workaround for Node.js "ES Modules"
224
+
225
+ function withMetadataArgument(func, _arguments) {
226
+ var args = Array.prototype.slice.call(_arguments);
227
+ args.push(metadata);
228
+ return func.apply(this, args)
229
+ }
230
+
231
+ 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); }
232
+
233
+ 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); } }
234
+
235
+ 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; }
236
+
237
+ function _classCallCheck$2(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
238
+
239
+ 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); }
240
+
241
+ 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); }; }
242
+
243
+ 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); }
244
+
245
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
246
+
247
+ 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); }
248
+
249
+ 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); }
250
+
251
+ 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; } }
252
+
253
+ function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; }
254
+
255
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
256
+
257
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
258
+
259
+ // https://stackoverflow.com/a/46971044/970769
260
+ // "Breaking changes in Typescript 2.1"
261
+ // "Extending built-ins like Error, Array, and Map may no longer work."
262
+ // "As a recommendation, you can manually adjust the prototype immediately after any super(...) calls."
263
+ // https://github.com/Microsoft/TypeScript-wiki/blob/main/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work
264
+ var ParseError = /*#__PURE__*/function (_Error) {
265
+ _inherits(ParseError, _Error);
266
+
267
+ var _super = _createSuper(ParseError);
268
+
269
+ function ParseError(code) {
270
+ var _this;
271
+
272
+ _classCallCheck$2(this, ParseError);
273
+
274
+ _this = _super.call(this, code); // Set the prototype explicitly.
275
+ // Any subclass of FooError will have to manually set the prototype as well.
276
+
277
+ Object.setPrototypeOf(_assertThisInitialized(_this), ParseError.prototype);
278
+ _this.name = _this.constructor.name;
279
+ return _this;
280
+ }
281
+
282
+ return _createClass$2(ParseError);
283
+ }( /*#__PURE__*/_wrapNativeSuper(Error));
284
+
285
+ // The minimum length of the national significant number.
286
+ var MIN_LENGTH_FOR_NSN = 2; // The ITU says the maximum length should be 15,
287
+ // but one can find longer numbers in Germany.
288
+
289
+ var MAX_LENGTH_FOR_NSN = 17; // The maximum length of the country calling code.
290
+
291
+ var MAX_LENGTH_COUNTRY_CODE = 3; // Digits accepted in phone numbers
292
+ // (ascii, fullwidth, arabic-indic, and eastern arabic digits).
293
+
294
+ var VALID_DIGITS = "0-9\uFF10-\uFF19\u0660-\u0669\u06F0-\u06F9"; // `DASHES` will be right after the opening square bracket of the "character class"
295
+
296
+ var DASHES = "-\u2010-\u2015\u2212\u30FC\uFF0D";
297
+ var SLASHES = "\uFF0F/";
298
+ var DOTS = "\uFF0E.";
299
+ var WHITESPACE = " \xA0\xAD\u200B\u2060\u3000";
300
+ var BRACKETS = "()\uFF08\uFF09\uFF3B\uFF3D\\[\\]"; // export const OPENING_BRACKETS = '(\uFF08\uFF3B\\\['
301
+
302
+ var TILDES = "~\u2053\u223C\uFF5E"; // Regular expression of acceptable punctuation found in phone numbers. This
303
+ // excludes punctuation found as a leading character only. This consists of dash
304
+ // characters, white space characters, full stops, slashes, square brackets,
305
+ // parentheses and tildes. Full-width variants are also present.
306
+
307
+ var VALID_PUNCTUATION = "".concat(DASHES).concat(SLASHES).concat(DOTS).concat(WHITESPACE).concat(BRACKETS).concat(TILDES);
308
+ var PLUS_CHARS = "+\uFF0B"; // const LEADING_PLUS_CHARS_PATTERN = new RegExp('^[' + PLUS_CHARS + ']+')
309
+
310
+ // Copy-pasted from:
311
+ // https://github.com/substack/semver-compare/blob/master/index.js
312
+ //
313
+ // Inlining this function because some users reported issues with
314
+ // importing from `semver-compare` in a browser with ES6 "native" modules.
315
+ //
316
+ // Fixes `semver-compare` not being able to compare versions with alpha/beta/etc "tags".
317
+ // https://github.com/catamphetamine/libphonenumber-js/issues/381
318
+ function compare (a, b) {
319
+ a = a.split('-');
320
+ b = b.split('-');
321
+ var pa = a[0].split('.');
322
+ var pb = b[0].split('.');
323
+
324
+ for (var i = 0; i < 3; i++) {
325
+ var na = Number(pa[i]);
326
+ var nb = Number(pb[i]);
327
+ if (na > nb) return 1;
328
+ if (nb > na) return -1;
329
+ if (!isNaN(na) && isNaN(nb)) return 1;
330
+ if (isNaN(na) && !isNaN(nb)) return -1;
331
+ }
332
+
333
+ if (a[1] && b[1]) {
334
+ return a[1] > b[1] ? 1 : a[1] < b[1] ? -1 : 0;
335
+ }
336
+
337
+ return !a[1] && b[1] ? 1 : a[1] && !b[1] ? -1 : 0;
338
+ }
339
+
340
+ 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); }
341
+
342
+ function _classCallCheck$1(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
343
+
344
+ 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); } }
345
+
346
+ 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; }
347
+
348
+ var V3 = '1.2.0'; // Moved `001` country code to "nonGeographic" section of metadata.
349
+
350
+ var V4 = '1.7.35';
351
+ var DEFAULT_EXT_PREFIX = ' ext. ';
352
+ var CALLING_CODE_REG_EXP = /^\d+$/;
353
+ /**
354
+ * See: https://gitlab.com/catamphetamine/libphonenumber-js/blob/master/METADATA.md
355
+ */
356
+
357
+ var Metadata = /*#__PURE__*/function () {
358
+ function Metadata(metadata) {
359
+ _classCallCheck$1(this, Metadata);
360
+
361
+ validateMetadata(metadata);
362
+ this.metadata = metadata;
363
+ setVersion.call(this, metadata);
364
+ }
365
+
366
+ _createClass$1(Metadata, [{
367
+ key: "getCountries",
368
+ value: function getCountries() {
369
+ return Object.keys(this.metadata.countries).filter(function (_) {
370
+ return _ !== '001';
371
+ });
372
+ }
373
+ }, {
374
+ key: "getCountryMetadata",
375
+ value: function getCountryMetadata(countryCode) {
376
+ return this.metadata.countries[countryCode];
377
+ }
378
+ }, {
379
+ key: "nonGeographic",
380
+ value: function nonGeographic() {
381
+ if (this.v1 || this.v2 || this.v3) return; // `nonGeographical` was a typo.
382
+ // It's present in metadata generated from `1.7.35` to `1.7.37`.
383
+ // The test case could be found by searching for "nonGeographical".
384
+
385
+ return this.metadata.nonGeographic || this.metadata.nonGeographical;
386
+ }
387
+ }, {
388
+ key: "hasCountry",
389
+ value: function hasCountry(country) {
390
+ return this.getCountryMetadata(country) !== undefined;
391
+ }
392
+ }, {
393
+ key: "hasCallingCode",
394
+ value: function hasCallingCode(callingCode) {
395
+ if (this.getCountryCodesForCallingCode(callingCode)) {
396
+ return true;
397
+ }
398
+
399
+ if (this.nonGeographic()) {
400
+ if (this.nonGeographic()[callingCode]) {
401
+ return true;
402
+ }
403
+ } else {
404
+ // A hacky workaround for old custom metadata (generated before V4).
405
+ var countryCodes = this.countryCallingCodes()[callingCode];
406
+
407
+ if (countryCodes && countryCodes.length === 1 && countryCodes[0] === '001') {
408
+ return true;
409
+ }
410
+ }
411
+ }
412
+ }, {
413
+ key: "isNonGeographicCallingCode",
414
+ value: function isNonGeographicCallingCode(callingCode) {
415
+ if (this.nonGeographic()) {
416
+ return this.nonGeographic()[callingCode] ? true : false;
417
+ } else {
418
+ return this.getCountryCodesForCallingCode(callingCode) ? false : true;
419
+ }
420
+ } // Deprecated.
421
+
422
+ }, {
423
+ key: "country",
424
+ value: function country(countryCode) {
425
+ return this.selectNumberingPlan(countryCode);
426
+ }
427
+ }, {
428
+ key: "selectNumberingPlan",
429
+ value: function selectNumberingPlan(countryCode, callingCode) {
430
+ // Supports just passing `callingCode` as the first argument.
431
+ if (countryCode && CALLING_CODE_REG_EXP.test(countryCode)) {
432
+ callingCode = countryCode;
433
+ countryCode = null;
434
+ }
435
+
436
+ if (countryCode && countryCode !== '001') {
437
+ if (!this.hasCountry(countryCode)) {
438
+ throw new Error("Unknown country: ".concat(countryCode));
439
+ }
440
+
441
+ this.numberingPlan = new NumberingPlan(this.getCountryMetadata(countryCode), this);
442
+ } else if (callingCode) {
443
+ if (!this.hasCallingCode(callingCode)) {
444
+ throw new Error("Unknown calling code: ".concat(callingCode));
445
+ }
446
+
447
+ this.numberingPlan = new NumberingPlan(this.getNumberingPlanMetadata(callingCode), this);
448
+ } else {
449
+ this.numberingPlan = undefined;
450
+ }
451
+
452
+ return this;
453
+ }
454
+ }, {
455
+ key: "getCountryCodesForCallingCode",
456
+ value: function getCountryCodesForCallingCode(callingCode) {
457
+ var countryCodes = this.countryCallingCodes()[callingCode];
458
+
459
+ if (countryCodes) {
460
+ // Metadata before V4 included "non-geographic entity" calling codes
461
+ // inside `country_calling_codes` (for example, `"881":["001"]`).
462
+ // Now the semantics of `country_calling_codes` has changed:
463
+ // it's specifically for "countries" now.
464
+ // Older versions of custom metadata will simply skip parsing
465
+ // "non-geographic entity" phone numbers with new versions
466
+ // of this library: it's not considered a bug,
467
+ // because such numbers are extremely rare,
468
+ // and developers extremely rarely use custom metadata.
469
+ if (countryCodes.length === 1 && countryCodes[0].length === 3) {
470
+ return;
471
+ }
472
+
473
+ return countryCodes;
474
+ }
475
+ }
476
+ }, {
477
+ key: "getCountryCodeForCallingCode",
478
+ value: function getCountryCodeForCallingCode(callingCode) {
479
+ var countryCodes = this.getCountryCodesForCallingCode(callingCode);
480
+
481
+ if (countryCodes) {
482
+ return countryCodes[0];
483
+ }
484
+ }
485
+ }, {
486
+ key: "getNumberingPlanMetadata",
487
+ value: function getNumberingPlanMetadata(callingCode) {
488
+ var countryCode = this.getCountryCodeForCallingCode(callingCode);
489
+
490
+ if (countryCode) {
491
+ return this.getCountryMetadata(countryCode);
492
+ }
493
+
494
+ if (this.nonGeographic()) {
495
+ var metadata = this.nonGeographic()[callingCode];
496
+
497
+ if (metadata) {
498
+ return metadata;
499
+ }
500
+ } else {
501
+ // A hacky workaround for old custom metadata (generated before V4).
502
+ // In that metadata, there was no concept of "non-geographic" metadata
503
+ // so metadata for `001` country code was stored along with other countries.
504
+ // The test case can be found by searching for:
505
+ // "should work around `nonGeographic` metadata not existing".
506
+ var countryCodes = this.countryCallingCodes()[callingCode];
507
+
508
+ if (countryCodes && countryCodes.length === 1 && countryCodes[0] === '001') {
509
+ return this.metadata.countries['001'];
510
+ }
511
+ }
512
+ } // Deprecated.
513
+
514
+ }, {
515
+ key: "countryCallingCode",
516
+ value: function countryCallingCode() {
517
+ return this.numberingPlan.callingCode();
518
+ } // Deprecated.
519
+
520
+ }, {
521
+ key: "IDDPrefix",
522
+ value: function IDDPrefix() {
523
+ return this.numberingPlan.IDDPrefix();
524
+ } // Deprecated.
525
+
526
+ }, {
527
+ key: "defaultIDDPrefix",
528
+ value: function defaultIDDPrefix() {
529
+ return this.numberingPlan.defaultIDDPrefix();
530
+ } // Deprecated.
531
+
532
+ }, {
533
+ key: "nationalNumberPattern",
534
+ value: function nationalNumberPattern() {
535
+ return this.numberingPlan.nationalNumberPattern();
536
+ } // Deprecated.
537
+
538
+ }, {
539
+ key: "possibleLengths",
540
+ value: function possibleLengths() {
541
+ return this.numberingPlan.possibleLengths();
542
+ } // Deprecated.
543
+
544
+ }, {
545
+ key: "formats",
546
+ value: function formats() {
547
+ return this.numberingPlan.formats();
548
+ } // Deprecated.
549
+
550
+ }, {
551
+ key: "nationalPrefixForParsing",
552
+ value: function nationalPrefixForParsing() {
553
+ return this.numberingPlan.nationalPrefixForParsing();
554
+ } // Deprecated.
555
+
556
+ }, {
557
+ key: "nationalPrefixTransformRule",
558
+ value: function nationalPrefixTransformRule() {
559
+ return this.numberingPlan.nationalPrefixTransformRule();
560
+ } // Deprecated.
561
+
562
+ }, {
563
+ key: "leadingDigits",
564
+ value: function leadingDigits() {
565
+ return this.numberingPlan.leadingDigits();
566
+ } // Deprecated.
567
+
568
+ }, {
569
+ key: "hasTypes",
570
+ value: function hasTypes() {
571
+ return this.numberingPlan.hasTypes();
572
+ } // Deprecated.
573
+
574
+ }, {
575
+ key: "type",
576
+ value: function type(_type) {
577
+ return this.numberingPlan.type(_type);
578
+ } // Deprecated.
579
+
580
+ }, {
581
+ key: "ext",
582
+ value: function ext() {
583
+ return this.numberingPlan.ext();
584
+ }
585
+ }, {
586
+ key: "countryCallingCodes",
587
+ value: function countryCallingCodes() {
588
+ if (this.v1) return this.metadata.country_phone_code_to_countries;
589
+ return this.metadata.country_calling_codes;
590
+ } // Deprecated.
591
+
592
+ }, {
593
+ key: "chooseCountryByCountryCallingCode",
594
+ value: function chooseCountryByCountryCallingCode(callingCode) {
595
+ return this.selectNumberingPlan(callingCode);
596
+ }
597
+ }, {
598
+ key: "hasSelectedNumberingPlan",
599
+ value: function hasSelectedNumberingPlan() {
600
+ return this.numberingPlan !== undefined;
601
+ }
602
+ }]);
603
+
604
+ return Metadata;
605
+ }();
606
+
607
+ var NumberingPlan = /*#__PURE__*/function () {
608
+ function NumberingPlan(metadata, globalMetadataObject) {
609
+ _classCallCheck$1(this, NumberingPlan);
610
+
611
+ this.globalMetadataObject = globalMetadataObject;
612
+ this.metadata = metadata;
613
+ setVersion.call(this, globalMetadataObject.metadata);
614
+ }
615
+
616
+ _createClass$1(NumberingPlan, [{
617
+ key: "callingCode",
618
+ value: function callingCode() {
619
+ return this.metadata[0];
620
+ } // Formatting information for regions which share
621
+ // a country calling code is contained by only one region
622
+ // for performance reasons. For example, for NANPA region
623
+ // ("North American Numbering Plan Administration",
624
+ // which includes USA, Canada, Cayman Islands, Bahamas, etc)
625
+ // it will be contained in the metadata for `US`.
626
+
627
+ }, {
628
+ key: "getDefaultCountryMetadataForRegion",
629
+ value: function getDefaultCountryMetadataForRegion() {
630
+ return this.globalMetadataObject.getNumberingPlanMetadata(this.callingCode());
631
+ } // Is always present.
632
+
633
+ }, {
634
+ key: "IDDPrefix",
635
+ value: function IDDPrefix() {
636
+ if (this.v1 || this.v2) return;
637
+ return this.metadata[1];
638
+ } // Is only present when a country supports multiple IDD prefixes.
639
+
640
+ }, {
641
+ key: "defaultIDDPrefix",
642
+ value: function defaultIDDPrefix() {
643
+ if (this.v1 || this.v2) return;
644
+ return this.metadata[12];
645
+ }
646
+ }, {
647
+ key: "nationalNumberPattern",
648
+ value: function nationalNumberPattern() {
649
+ if (this.v1 || this.v2) return this.metadata[1];
650
+ return this.metadata[2];
651
+ } // "possible length" data is always present in Google's metadata.
652
+
653
+ }, {
654
+ key: "possibleLengths",
655
+ value: function possibleLengths() {
656
+ if (this.v1) return;
657
+ return this.metadata[this.v2 ? 2 : 3];
658
+ }
659
+ }, {
660
+ key: "_getFormats",
661
+ value: function _getFormats(metadata) {
662
+ return metadata[this.v1 ? 2 : this.v2 ? 3 : 4];
663
+ } // For countries of the same region (e.g. NANPA)
664
+ // formats are all stored in the "main" country for that region.
665
+ // E.g. "RU" and "KZ", "US" and "CA".
666
+
667
+ }, {
668
+ key: "formats",
669
+ value: function formats() {
670
+ var _this = this;
671
+
672
+ var formats = this._getFormats(this.metadata) || this._getFormats(this.getDefaultCountryMetadataForRegion()) || [];
673
+ return formats.map(function (_) {
674
+ return new Format(_, _this);
675
+ });
676
+ }
677
+ }, {
678
+ key: "nationalPrefix",
679
+ value: function nationalPrefix() {
680
+ return this.metadata[this.v1 ? 3 : this.v2 ? 4 : 5];
681
+ }
682
+ }, {
683
+ key: "_getNationalPrefixFormattingRule",
684
+ value: function _getNationalPrefixFormattingRule(metadata) {
685
+ return metadata[this.v1 ? 4 : this.v2 ? 5 : 6];
686
+ } // For countries of the same region (e.g. NANPA)
687
+ // national prefix formatting rule is stored in the "main" country for that region.
688
+ // E.g. "RU" and "KZ", "US" and "CA".
689
+
690
+ }, {
691
+ key: "nationalPrefixFormattingRule",
692
+ value: function nationalPrefixFormattingRule() {
693
+ return this._getNationalPrefixFormattingRule(this.metadata) || this._getNationalPrefixFormattingRule(this.getDefaultCountryMetadataForRegion());
694
+ }
695
+ }, {
696
+ key: "_nationalPrefixForParsing",
697
+ value: function _nationalPrefixForParsing() {
698
+ return this.metadata[this.v1 ? 5 : this.v2 ? 6 : 7];
699
+ }
700
+ }, {
701
+ key: "nationalPrefixForParsing",
702
+ value: function nationalPrefixForParsing() {
703
+ // If `national_prefix_for_parsing` is not set explicitly,
704
+ // then infer it from `national_prefix` (if any)
705
+ return this._nationalPrefixForParsing() || this.nationalPrefix();
706
+ }
707
+ }, {
708
+ key: "nationalPrefixTransformRule",
709
+ value: function nationalPrefixTransformRule() {
710
+ return this.metadata[this.v1 ? 6 : this.v2 ? 7 : 8];
711
+ }
712
+ }, {
713
+ key: "_getNationalPrefixIsOptionalWhenFormatting",
714
+ value: function _getNationalPrefixIsOptionalWhenFormatting() {
715
+ return !!this.metadata[this.v1 ? 7 : this.v2 ? 8 : 9];
716
+ } // For countries of the same region (e.g. NANPA)
717
+ // "national prefix is optional when formatting" flag is
718
+ // stored in the "main" country for that region.
719
+ // E.g. "RU" and "KZ", "US" and "CA".
720
+
721
+ }, {
722
+ key: "nationalPrefixIsOptionalWhenFormattingInNationalFormat",
723
+ value: function nationalPrefixIsOptionalWhenFormattingInNationalFormat() {
724
+ return this._getNationalPrefixIsOptionalWhenFormatting(this.metadata) || this._getNationalPrefixIsOptionalWhenFormatting(this.getDefaultCountryMetadataForRegion());
725
+ }
726
+ }, {
727
+ key: "leadingDigits",
728
+ value: function leadingDigits() {
729
+ return this.metadata[this.v1 ? 8 : this.v2 ? 9 : 10];
730
+ }
731
+ }, {
732
+ key: "types",
733
+ value: function types() {
734
+ return this.metadata[this.v1 ? 9 : this.v2 ? 10 : 11];
735
+ }
736
+ }, {
737
+ key: "hasTypes",
738
+ value: function hasTypes() {
739
+ // Versions 1.2.0 - 1.2.4: can be `[]`.
740
+
741
+ /* istanbul ignore next */
742
+ if (this.types() && this.types().length === 0) {
743
+ return false;
744
+ } // Versions <= 1.2.4: can be `undefined`.
745
+ // Version >= 1.2.5: can be `0`.
746
+
747
+
748
+ return !!this.types();
749
+ }
750
+ }, {
751
+ key: "type",
752
+ value: function type(_type2) {
753
+ if (this.hasTypes() && getType(this.types(), _type2)) {
754
+ return new Type(getType(this.types(), _type2), this);
755
+ }
756
+ }
757
+ }, {
758
+ key: "ext",
759
+ value: function ext() {
760
+ if (this.v1 || this.v2) return DEFAULT_EXT_PREFIX;
761
+ return this.metadata[13] || DEFAULT_EXT_PREFIX;
762
+ }
763
+ }]);
764
+
765
+ return NumberingPlan;
766
+ }();
767
+
768
+ var Format = /*#__PURE__*/function () {
769
+ function Format(format, metadata) {
770
+ _classCallCheck$1(this, Format);
771
+
772
+ this._format = format;
773
+ this.metadata = metadata;
774
+ }
775
+
776
+ _createClass$1(Format, [{
777
+ key: "pattern",
778
+ value: function pattern() {
779
+ return this._format[0];
780
+ }
781
+ }, {
782
+ key: "format",
783
+ value: function format() {
784
+ return this._format[1];
785
+ }
786
+ }, {
787
+ key: "leadingDigitsPatterns",
788
+ value: function leadingDigitsPatterns() {
789
+ return this._format[2] || [];
790
+ }
791
+ }, {
792
+ key: "nationalPrefixFormattingRule",
793
+ value: function nationalPrefixFormattingRule() {
794
+ return this._format[3] || this.metadata.nationalPrefixFormattingRule();
795
+ }
796
+ }, {
797
+ key: "nationalPrefixIsOptionalWhenFormattingInNationalFormat",
798
+ value: function nationalPrefixIsOptionalWhenFormattingInNationalFormat() {
799
+ return !!this._format[4] || this.metadata.nationalPrefixIsOptionalWhenFormattingInNationalFormat();
800
+ }
801
+ }, {
802
+ key: "nationalPrefixIsMandatoryWhenFormattingInNationalFormat",
803
+ value: function nationalPrefixIsMandatoryWhenFormattingInNationalFormat() {
804
+ // National prefix is omitted if there's no national prefix formatting rule
805
+ // set for this country, or when the national prefix formatting rule
806
+ // contains no national prefix itself, or when this rule is set but
807
+ // national prefix is optional for this phone number format
808
+ // (and it is not enforced explicitly)
809
+ return this.usesNationalPrefix() && !this.nationalPrefixIsOptionalWhenFormattingInNationalFormat();
810
+ } // Checks whether national prefix formatting rule contains national prefix.
811
+
812
+ }, {
813
+ key: "usesNationalPrefix",
814
+ value: function usesNationalPrefix() {
815
+ return this.nationalPrefixFormattingRule() && // Check that national prefix formatting rule is not a "dummy" one.
816
+ !FIRST_GROUP_ONLY_PREFIX_PATTERN.test(this.nationalPrefixFormattingRule()) // In compressed metadata, `this.nationalPrefixFormattingRule()` is `0`
817
+ // when `national_prefix_formatting_rule` is not present.
818
+ // So, `true` or `false` are returned explicitly here, so that
819
+ // `0` number isn't returned.
820
+ ? true : false;
821
+ }
822
+ }, {
823
+ key: "internationalFormat",
824
+ value: function internationalFormat() {
825
+ return this._format[5] || this.format();
826
+ }
827
+ }]);
828
+
829
+ return Format;
830
+ }();
831
+ /**
832
+ * A pattern that is used to determine if the national prefix formatting rule
833
+ * has the first group only, i.e., does not start with the national prefix.
834
+ * Note that the pattern explicitly allows for unbalanced parentheses.
835
+ */
836
+
837
+
838
+ var FIRST_GROUP_ONLY_PREFIX_PATTERN = /^\(?\$1\)?$/;
839
+
840
+ var Type = /*#__PURE__*/function () {
841
+ function Type(type, metadata) {
842
+ _classCallCheck$1(this, Type);
843
+
844
+ this.type = type;
845
+ this.metadata = metadata;
846
+ }
847
+
848
+ _createClass$1(Type, [{
849
+ key: "pattern",
850
+ value: function pattern() {
851
+ if (this.metadata.v1) return this.type;
852
+ return this.type[0];
853
+ }
854
+ }, {
855
+ key: "possibleLengths",
856
+ value: function possibleLengths() {
857
+ if (this.metadata.v1) return;
858
+ return this.type[1] || this.metadata.possibleLengths();
859
+ }
860
+ }]);
861
+
862
+ return Type;
863
+ }();
864
+
865
+ function getType(types, type) {
866
+ switch (type) {
867
+ case 'FIXED_LINE':
868
+ return types[0];
869
+
870
+ case 'MOBILE':
871
+ return types[1];
872
+
873
+ case 'TOLL_FREE':
874
+ return types[2];
875
+
876
+ case 'PREMIUM_RATE':
877
+ return types[3];
878
+
879
+ case 'PERSONAL_NUMBER':
880
+ return types[4];
881
+
882
+ case 'VOICEMAIL':
883
+ return types[5];
884
+
885
+ case 'UAN':
886
+ return types[6];
887
+
888
+ case 'PAGER':
889
+ return types[7];
890
+
891
+ case 'VOIP':
892
+ return types[8];
893
+
894
+ case 'SHARED_COST':
895
+ return types[9];
896
+ }
897
+ }
898
+
899
+ function validateMetadata(metadata) {
900
+ if (!metadata) {
901
+ throw new Error('[libphonenumber-js] `metadata` argument not passed. Check your arguments.');
902
+ } // `country_phone_code_to_countries` was renamed to
903
+ // `country_calling_codes` in `1.0.18`.
904
+
905
+
906
+ if (!is_object(metadata) || !is_object(metadata.countries)) {
907
+ 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, "."));
908
+ }
909
+ } // Babel transforms `typeof` into some "branches"
910
+ // so istanbul will show this as "branch not covered".
911
+
912
+ /* istanbul ignore next */
913
+
914
+ var is_object = function is_object(_) {
915
+ return _typeof$1(_) === 'object';
916
+ }; // Babel transforms `typeof` into some "branches"
917
+ // so istanbul will show this as "branch not covered".
918
+
919
+ /* istanbul ignore next */
920
+
921
+
922
+ var type_of = function type_of(_) {
923
+ return _typeof$1(_);
924
+ };
925
+ /**
926
+ * Returns "country calling code" for a country.
927
+ * Throws an error if the country doesn't exist or isn't supported by this library.
928
+ * @param {string} country
929
+ * @param {object} metadata
930
+ * @return {string}
931
+ * @example
932
+ * // Returns "44"
933
+ * getCountryCallingCode("GB")
934
+ */
935
+
936
+ function getCountryCallingCode(country, metadata) {
937
+ metadata = new Metadata(metadata);
938
+
939
+ if (metadata.hasCountry(country)) {
940
+ return metadata.country(country).countryCallingCode();
941
+ }
942
+
943
+ throw new Error("Unknown country: ".concat(country));
944
+ }
945
+ function isSupportedCountry(country, metadata) {
946
+ // metadata = new Metadata(metadata)
947
+ // return metadata.hasCountry(country)
948
+ return metadata.countries[country] !== undefined;
949
+ }
950
+
951
+ function setVersion(metadata) {
952
+ var version = metadata.version;
953
+
954
+ if (typeof version === 'number') {
955
+ this.v1 = version === 1;
956
+ this.v2 = version === 2;
957
+ this.v3 = version === 3;
958
+ this.v4 = version === 4;
959
+ } else {
960
+ if (!version) {
961
+ this.v1 = true;
962
+ } else if (compare(version, V3) === -1) {
963
+ this.v2 = true;
964
+ } else if (compare(version, V4) === -1) {
965
+ this.v3 = true;
966
+ } else {
967
+ this.v4 = true;
968
+ }
969
+ }
970
+ } // const ISO_COUNTRY_CODE = /^[A-Z]{2}$/
971
+ // function isCountryCode(countryCode) {
972
+ // return ISO_COUNTRY_CODE.test(countryCodeOrCountryCallingCode)
973
+ // }
974
+
975
+ var RFC3966_EXTN_PREFIX = ';ext=';
976
+ /**
977
+ * Helper method for constructing regular expressions for parsing. Creates
978
+ * an expression that captures up to max_length digits.
979
+ * @return {string} RegEx pattern to capture extension digits.
980
+ */
981
+
982
+ var getExtensionDigitsPattern = function getExtensionDigitsPattern(maxLength) {
983
+ return "([".concat(VALID_DIGITS, "]{1,").concat(maxLength, "})");
984
+ };
985
+ /**
986
+ * Helper initialiser method to create the regular-expression pattern to match
987
+ * extensions.
988
+ * Copy-pasted from Google's `libphonenumber`:
989
+ * https://github.com/google/libphonenumber/blob/55b2646ec9393f4d3d6661b9c82ef9e258e8b829/javascript/i18n/phonenumbers/phonenumberutil.js#L759-L766
990
+ * @return {string} RegEx pattern to capture extensions.
991
+ */
992
+
993
+
994
+ function createExtensionPattern(purpose) {
995
+ // We cap the maximum length of an extension based on the ambiguity of the way
996
+ // the extension is prefixed. As per ITU, the officially allowed length for
997
+ // extensions is actually 40, but we don't support this since we haven't seen real
998
+ // examples and this introduces many false interpretations as the extension labels
999
+ // are not standardized.
1000
+
1001
+ /** @type {string} */
1002
+ var extLimitAfterExplicitLabel = '20';
1003
+ /** @type {string} */
1004
+
1005
+ var extLimitAfterLikelyLabel = '15';
1006
+ /** @type {string} */
1007
+
1008
+ var extLimitAfterAmbiguousChar = '9';
1009
+ /** @type {string} */
1010
+
1011
+ var extLimitWhenNotSure = '6';
1012
+ /** @type {string} */
1013
+
1014
+ var possibleSeparatorsBetweenNumberAndExtLabel = "[ \xA0\\t,]*"; // Optional full stop (.) or colon, followed by zero or more spaces/tabs/commas.
1015
+
1016
+ /** @type {string} */
1017
+
1018
+ var possibleCharsAfterExtLabel = "[:\\.\uFF0E]?[ \xA0\\t,-]*";
1019
+ /** @type {string} */
1020
+
1021
+ var optionalExtnSuffix = "#?"; // Here the extension is called out in more explicit way, i.e mentioning it obvious
1022
+ // patterns like "ext.".
1023
+
1024
+ /** @type {string} */
1025
+
1026
+ 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
1027
+ // commonly used or more ambiguous extension labels.
1028
+
1029
+ /** @type {string} */
1030
+
1031
+ var ambiguousExtLabels = "(?:[x\uFF58#\uFF03~\uFF5E]|int|\uFF49\uFF4E\uFF54)"; // When extension is not separated clearly.
1032
+
1033
+ /** @type {string} */
1034
+
1035
+ var ambiguousSeparator = "[- ]+"; // This is the same as possibleSeparatorsBetweenNumberAndExtLabel, but not matching
1036
+ // comma as extension label may have it.
1037
+
1038
+ /** @type {string} */
1039
+
1040
+ var possibleSeparatorsNumberExtLabelNoComma = "[ \xA0\\t]*"; // ",," is commonly used for auto dialling the extension when connected. First
1041
+ // comma is matched through possibleSeparatorsBetweenNumberAndExtLabel, so we do
1042
+ // not repeat it here. Semi-colon works in Iphone and Android also to pop up a
1043
+ // button with the extension number following.
1044
+
1045
+ /** @type {string} */
1046
+
1047
+ var autoDiallingAndExtLabelsFound = "(?:,{2}|;)";
1048
+ /** @type {string} */
1049
+
1050
+ var rfcExtn = RFC3966_EXTN_PREFIX + getExtensionDigitsPattern(extLimitAfterExplicitLabel);
1051
+ /** @type {string} */
1052
+
1053
+ var explicitExtn = possibleSeparatorsBetweenNumberAndExtLabel + explicitExtLabels + possibleCharsAfterExtLabel + getExtensionDigitsPattern(extLimitAfterExplicitLabel) + optionalExtnSuffix;
1054
+ /** @type {string} */
1055
+
1056
+ var ambiguousExtn = possibleSeparatorsBetweenNumberAndExtLabel + ambiguousExtLabels + possibleCharsAfterExtLabel + getExtensionDigitsPattern(extLimitAfterAmbiguousChar) + optionalExtnSuffix;
1057
+ /** @type {string} */
1058
+
1059
+ var americanStyleExtnWithSuffix = ambiguousSeparator + getExtensionDigitsPattern(extLimitWhenNotSure) + "#";
1060
+ /** @type {string} */
1061
+
1062
+ var autoDiallingExtn = possibleSeparatorsNumberExtLabelNoComma + autoDiallingAndExtLabelsFound + possibleCharsAfterExtLabel + getExtensionDigitsPattern(extLimitAfterLikelyLabel) + optionalExtnSuffix;
1063
+ /** @type {string} */
1064
+
1065
+ var onlyCommasExtn = possibleSeparatorsNumberExtLabelNoComma + "(?:,)+" + possibleCharsAfterExtLabel + getExtensionDigitsPattern(extLimitAfterAmbiguousChar) + optionalExtnSuffix; // The first regular expression covers RFC 3966 format, where the extension is added
1066
+ // using ";ext=". The second more generic where extension is mentioned with explicit
1067
+ // labels like "ext:". In both the above cases we allow more numbers in extension than
1068
+ // any other extension labels. The third one captures when single character extension
1069
+ // labels or less commonly used labels are used. In such cases we capture fewer
1070
+ // extension digits in order to reduce the chance of falsely interpreting two
1071
+ // numbers beside each other as a number + extension. The fourth one covers the
1072
+ // special case of American numbers where the extension is written with a hash
1073
+ // at the end, such as "- 503#". The fifth one is exclusively for extension
1074
+ // autodialling formats which are used when dialling and in this case we accept longer
1075
+ // extensions. The last one is more liberal on the number of commas that acts as
1076
+ // extension labels, so we have a strict cap on the number of digits in such extensions.
1077
+
1078
+ return rfcExtn + "|" + explicitExtn + "|" + ambiguousExtn + "|" + americanStyleExtnWithSuffix + "|" + autoDiallingExtn + "|" + onlyCommasExtn;
1079
+ }
1080
+
1081
+ // Checks we have at least three leading digits, and only valid punctuation,
1082
+ // alpha characters and digits in the phone number. Does not include extension
1083
+ // data. The symbol 'x' is allowed here as valid punctuation since it is often
1084
+ // used as a placeholder for carrier codes, for example in Brazilian phone
1085
+ // numbers. We also allow multiple '+' characters at the start.
1086
+ //
1087
+ // Corresponds to the following:
1088
+ // [digits]{minLengthNsn}|
1089
+ // plus_sign*
1090
+ // (([punctuation]|[star])*[digits]){3,}([punctuation]|[star]|[digits]|[alpha])*
1091
+ //
1092
+ // The first reg-ex is to allow short numbers (two digits long) to be parsed if
1093
+ // they are entered as "15" etc, but only if there is no punctuation in them.
1094
+ // The second expression restricts the number of digits to three or more, but
1095
+ // then allows them to be in international form, and to have alpha-characters
1096
+ // and punctuation. We split up the two reg-exes here and combine them when
1097
+ // creating the reg-ex VALID_PHONE_NUMBER_PATTERN itself so we can prefix it
1098
+ // with ^ and append $ to each branch.
1099
+ //
1100
+ // "Note VALID_PUNCTUATION starts with a -,
1101
+ // so must be the first in the range" (c) Google devs.
1102
+ // (wtf did they mean by saying that; probably nothing)
1103
+ //
1104
+
1105
+ var MIN_LENGTH_PHONE_NUMBER_PATTERN = '[' + VALID_DIGITS + ']{' + MIN_LENGTH_FOR_NSN + '}'; //
1106
+ // And this is the second reg-exp:
1107
+ // (see MIN_LENGTH_PHONE_NUMBER_PATTERN for a full description of this reg-exp)
1108
+ //
1109
+
1110
+ 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`
1111
+ // and is only used to determine whether the phone number being input
1112
+ // is too short for it to even consider it a "valid" number.
1113
+ // This is just a way to differentiate between a really invalid phone
1114
+ // number like "abcde" and a valid phone number that a user has just
1115
+ // started inputting, like "+1" or "1": both these cases would be
1116
+ // considered `NOT_A_NUMBER` by Google's `libphonenumber`, but this
1117
+ // library can provide a more detailed error message — whether it's
1118
+ // really "not a number", or is it just a start of a valid phone number.
1119
+
1120
+ var VALID_PHONE_NUMBER_START_REG_EXP = new RegExp('^' + '[' + PLUS_CHARS + ']{0,1}' + '(?:' + '[' + VALID_PUNCTUATION + ']*' + '[' + VALID_DIGITS + ']' + '){1,2}' + '$', 'i');
1121
+ var VALID_PHONE_NUMBER_WITH_EXTENSION = VALID_PHONE_NUMBER + // Phone number extensions
1122
+ '(?:' + createExtensionPattern() + ')?'; // The combined regular expression for valid phone numbers:
1123
+ //
1124
+
1125
+ var VALID_PHONE_NUMBER_PATTERN = new RegExp( // Either a short two-digit-only phone number
1126
+ '^' + MIN_LENGTH_PHONE_NUMBER_PATTERN + '$' + '|' + // Or a longer fully parsed phone number (min 3 characters)
1127
+ '^' + VALID_PHONE_NUMBER_WITH_EXTENSION + '$', 'i'); // Checks to see if the string of characters could possibly be a phone number at
1128
+ // all. At the moment, checks to see that the string begins with at least 2
1129
+ // digits, ignoring any punctuation commonly found in phone numbers. This method
1130
+ // does not require the number to be normalized in advance - but does assume
1131
+ // that leading non-number symbols have been removed, such as by the method
1132
+ // `extract_possible_number`.
1133
+ //
1134
+
1135
+ function isViablePhoneNumber(number) {
1136
+ return number.length >= MIN_LENGTH_FOR_NSN && VALID_PHONE_NUMBER_PATTERN.test(number);
1137
+ } // This is just a way to differentiate between a really invalid phone
1138
+ // number like "abcde" and a valid phone number that a user has just
1139
+ // started inputting, like "+1" or "1": both these cases would be
1140
+ // considered `NOT_A_NUMBER` by Google's `libphonenumber`, but this
1141
+ // library can provide a more detailed error message — whether it's
1142
+ // really "not a number", or is it just a start of a valid phone number.
1143
+
1144
+ function isViablePhoneNumberStart(number) {
1145
+ return VALID_PHONE_NUMBER_START_REG_EXP.test(number);
1146
+ }
1147
+
1148
+ // 1 or more valid digits, for use when parsing.
1149
+
1150
+ var EXTN_PATTERN = new RegExp('(?:' + createExtensionPattern() + ')$', 'i'); // Strips any extension (as in, the part of the number dialled after the call is
1151
+ // connected, usually indicated with extn, ext, x or similar) from the end of
1152
+ // the number, and returns it.
1153
+
1154
+ function extractExtension(number) {
1155
+ var start = number.search(EXTN_PATTERN);
1156
+
1157
+ if (start < 0) {
1158
+ return {};
1159
+ } // If we find a potential extension, and the number preceding this is a viable
1160
+ // number, we assume it is an extension.
1161
+
1162
+
1163
+ var numberWithoutExtension = number.slice(0, start);
1164
+ var matches = number.match(EXTN_PATTERN);
1165
+ var i = 1;
1166
+
1167
+ while (i < matches.length) {
1168
+ if (matches[i]) {
1169
+ return {
1170
+ number: numberWithoutExtension,
1171
+ ext: matches[i]
1172
+ };
1173
+ }
1174
+
1175
+ i++;
1176
+ }
1177
+ }
1178
+
1179
+ // These mappings map a character (key) to a specific digit that should
1180
+ // replace it for normalization purposes. Non-European digits that
1181
+ // may be used in phone numbers are mapped to a European equivalent.
1182
+ //
1183
+ // E.g. in Iraq they don't write `+442323234` but rather `+٤٤٢٣٢٣٢٣٤`.
1184
+ //
1185
+ var DIGITS = {
1186
+ '0': '0',
1187
+ '1': '1',
1188
+ '2': '2',
1189
+ '3': '3',
1190
+ '4': '4',
1191
+ '5': '5',
1192
+ '6': '6',
1193
+ '7': '7',
1194
+ '8': '8',
1195
+ '9': '9',
1196
+ "\uFF10": '0',
1197
+ // Fullwidth digit 0
1198
+ "\uFF11": '1',
1199
+ // Fullwidth digit 1
1200
+ "\uFF12": '2',
1201
+ // Fullwidth digit 2
1202
+ "\uFF13": '3',
1203
+ // Fullwidth digit 3
1204
+ "\uFF14": '4',
1205
+ // Fullwidth digit 4
1206
+ "\uFF15": '5',
1207
+ // Fullwidth digit 5
1208
+ "\uFF16": '6',
1209
+ // Fullwidth digit 6
1210
+ "\uFF17": '7',
1211
+ // Fullwidth digit 7
1212
+ "\uFF18": '8',
1213
+ // Fullwidth digit 8
1214
+ "\uFF19": '9',
1215
+ // Fullwidth digit 9
1216
+ "\u0660": '0',
1217
+ // Arabic-indic digit 0
1218
+ "\u0661": '1',
1219
+ // Arabic-indic digit 1
1220
+ "\u0662": '2',
1221
+ // Arabic-indic digit 2
1222
+ "\u0663": '3',
1223
+ // Arabic-indic digit 3
1224
+ "\u0664": '4',
1225
+ // Arabic-indic digit 4
1226
+ "\u0665": '5',
1227
+ // Arabic-indic digit 5
1228
+ "\u0666": '6',
1229
+ // Arabic-indic digit 6
1230
+ "\u0667": '7',
1231
+ // Arabic-indic digit 7
1232
+ "\u0668": '8',
1233
+ // Arabic-indic digit 8
1234
+ "\u0669": '9',
1235
+ // Arabic-indic digit 9
1236
+ "\u06F0": '0',
1237
+ // Eastern-Arabic digit 0
1238
+ "\u06F1": '1',
1239
+ // Eastern-Arabic digit 1
1240
+ "\u06F2": '2',
1241
+ // Eastern-Arabic digit 2
1242
+ "\u06F3": '3',
1243
+ // Eastern-Arabic digit 3
1244
+ "\u06F4": '4',
1245
+ // Eastern-Arabic digit 4
1246
+ "\u06F5": '5',
1247
+ // Eastern-Arabic digit 5
1248
+ "\u06F6": '6',
1249
+ // Eastern-Arabic digit 6
1250
+ "\u06F7": '7',
1251
+ // Eastern-Arabic digit 7
1252
+ "\u06F8": '8',
1253
+ // Eastern-Arabic digit 8
1254
+ "\u06F9": '9' // Eastern-Arabic digit 9
1255
+
1256
+ };
1257
+ function parseDigit(character) {
1258
+ return DIGITS[character];
1259
+ }
1260
+
1261
+ 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."); }
1262
+
1263
+ 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); }
1264
+
1265
+ 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; }
1266
+ /**
1267
+ * Parses phone number characters from a string.
1268
+ * Drops all punctuation leaving only digits and the leading `+` sign (if any).
1269
+ * Also converts wide-ascii and arabic-indic numerals to conventional numerals.
1270
+ * E.g. in Iraq they don't write `+442323234` but rather `+٤٤٢٣٢٣٢٣٤`.
1271
+ * @param {string} string
1272
+ * @return {string}
1273
+ * @example
1274
+ * ```js
1275
+ * // Outputs '8800555'.
1276
+ * parseIncompletePhoneNumber('8 (800) 555')
1277
+ * // Outputs '+7800555'.
1278
+ * parseIncompletePhoneNumber('+7 800 555')
1279
+ * ```
1280
+ */
1281
+
1282
+ function parseIncompletePhoneNumber(string) {
1283
+ var result = ''; // Using `.split('')` here instead of normal `for ... of`
1284
+ // because the importing application doesn't neccessarily include an ES6 polyfill.
1285
+ // The `.split('')` approach discards "exotic" UTF-8 characters
1286
+ // (the ones consisting of four bytes) but digits
1287
+ // (including non-European ones) don't fall into that range
1288
+ // so such "exotic" characters would be discarded anyway.
1289
+
1290
+ for (var _iterator = _createForOfIteratorHelperLoose$4(string.split('')), _step; !(_step = _iterator()).done;) {
1291
+ var character = _step.value;
1292
+ result += parsePhoneNumberCharacter(character, result) || '';
1293
+ }
1294
+
1295
+ return result;
1296
+ }
1297
+ /**
1298
+ * Parses next character while parsing phone number digits (including a `+`)
1299
+ * from text: discards everything except `+` and digits, and `+` is only allowed
1300
+ * at the start of a phone number.
1301
+ * For example, is used in `react-phone-number-input` where it uses
1302
+ * [`input-format`](https://gitlab.com/catamphetamine/input-format).
1303
+ * @param {string} character - Yet another character from raw input string.
1304
+ * @param {string?} prevParsedCharacters - Previous parsed characters.
1305
+ * @param {object} meta - Optional custom use-case-specific metadata.
1306
+ * @return {string?} The parsed character.
1307
+ */
1308
+
1309
+ function parsePhoneNumberCharacter(character, prevParsedCharacters) {
1310
+ // Only allow a leading `+`.
1311
+ if (character === '+') {
1312
+ // If this `+` is not the first parsed character
1313
+ // then discard it.
1314
+ if (prevParsedCharacters) {
1315
+ return;
1316
+ }
1317
+
1318
+ return '+';
1319
+ } // Allow digits.
1320
+
1321
+
1322
+ return parseDigit(character);
1323
+ }
1324
+
1325
+ 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."); }
1326
+
1327
+ 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); }
1328
+
1329
+ 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; }
1330
+
1331
+ /**
1332
+ * Merges two arrays.
1333
+ * @param {*} a
1334
+ * @param {*} b
1335
+ * @return {*}
1336
+ */
1337
+ function mergeArrays(a, b) {
1338
+ var merged = a.slice();
1339
+
1340
+ for (var _iterator = _createForOfIteratorHelperLoose$3(b), _step; !(_step = _iterator()).done;) {
1341
+ var element = _step.value;
1342
+
1343
+ if (a.indexOf(element) < 0) {
1344
+ merged.push(element);
1345
+ }
1346
+ }
1347
+
1348
+ return merged.sort(function (a, b) {
1349
+ return a - b;
1350
+ }); // ES6 version, requires Set polyfill.
1351
+ // let merged = new Set(a)
1352
+ // for (const element of b) {
1353
+ // merged.add(i)
1354
+ // }
1355
+ // return Array.from(merged).sort((a, b) => a - b)
1356
+ }
1357
+
1358
+ function checkNumberLength(nationalNumber, metadata) {
1359
+ return checkNumberLengthForType(nationalNumber, undefined, metadata);
1360
+ } // Checks whether a number is possible for the country based on its length.
1361
+ // Should only be called for the "new" metadata which has "possible lengths".
1362
+
1363
+ function checkNumberLengthForType(nationalNumber, type, metadata) {
1364
+ var type_info = metadata.type(type); // There should always be "<possiblePengths/>" set for every type element.
1365
+ // This is declared in the XML schema.
1366
+ // For size efficiency, where a sub-description (e.g. fixed-line)
1367
+ // has the same "<possiblePengths/>" as the "general description", this is missing,
1368
+ // so we fall back to the "general description". Where no numbers of the type
1369
+ // exist at all, there is one possible length (-1) which is guaranteed
1370
+ // not to match the length of any real phone number.
1371
+
1372
+ var possible_lengths = type_info && type_info.possibleLengths() || metadata.possibleLengths(); // let local_lengths = type_info && type.possibleLengthsLocal() || metadata.possibleLengthsLocal()
1373
+ // Metadata before version `1.0.18` didn't contain `possible_lengths`.
1374
+
1375
+ if (!possible_lengths) {
1376
+ return 'IS_POSSIBLE';
1377
+ }
1378
+
1379
+ if (type === 'FIXED_LINE_OR_MOBILE') {
1380
+ // No such country in metadata.
1381
+
1382
+ /* istanbul ignore next */
1383
+ if (!metadata.type('FIXED_LINE')) {
1384
+ // The rare case has been encountered where no fixedLine data is available
1385
+ // (true for some non-geographic entities), so we just check mobile.
1386
+ return checkNumberLengthForType(nationalNumber, 'MOBILE', metadata);
1387
+ }
1388
+
1389
+ var mobile_type = metadata.type('MOBILE');
1390
+
1391
+ if (mobile_type) {
1392
+ // Merge the mobile data in if there was any. "Concat" creates a new
1393
+ // array, it doesn't edit possible_lengths in place, so we don't need a copy.
1394
+ // Note that when adding the possible lengths from mobile, we have
1395
+ // to again check they aren't empty since if they are this indicates
1396
+ // they are the same as the general desc and should be obtained from there.
1397
+ possible_lengths = mergeArrays(possible_lengths, mobile_type.possibleLengths()); // The current list is sorted; we need to merge in the new list and
1398
+ // re-sort (duplicates are okay). Sorting isn't so expensive because
1399
+ // the lists are very small.
1400
+ // if (local_lengths) {
1401
+ // local_lengths = mergeArrays(local_lengths, mobile_type.possibleLengthsLocal())
1402
+ // } else {
1403
+ // local_lengths = mobile_type.possibleLengthsLocal()
1404
+ // }
1405
+ }
1406
+ } // If the type doesn't exist then return 'INVALID_LENGTH'.
1407
+ else if (type && !type_info) {
1408
+ return 'INVALID_LENGTH';
1409
+ }
1410
+
1411
+ var actual_length = nationalNumber.length; // In `libphonenumber-js` all "local-only" formats are dropped for simplicity.
1412
+ // // This is safe because there is never an overlap beween the possible lengths
1413
+ // // and the local-only lengths; this is checked at build time.
1414
+ // if (local_lengths && local_lengths.indexOf(nationalNumber.length) >= 0)
1415
+ // {
1416
+ // return 'IS_POSSIBLE_LOCAL_ONLY'
1417
+ // }
1418
+
1419
+ var minimum_length = possible_lengths[0];
1420
+
1421
+ if (minimum_length === actual_length) {
1422
+ return 'IS_POSSIBLE';
1423
+ }
1424
+
1425
+ if (minimum_length > actual_length) {
1426
+ return 'TOO_SHORT';
1427
+ }
1428
+
1429
+ if (possible_lengths[possible_lengths.length - 1] < actual_length) {
1430
+ return 'TOO_LONG';
1431
+ } // We skip the first element since we've already checked it.
1432
+
1433
+
1434
+ return possible_lengths.indexOf(actual_length, 1) >= 0 ? 'IS_POSSIBLE' : 'INVALID_LENGTH';
1435
+ }
1436
+
1437
+ /**
1438
+ * Checks if a phone number is "possible" (basically just checks its length).
1439
+ *
1440
+ * isPossible(phoneNumberInstance, { ..., v2: true }, metadata)
1441
+ *
1442
+ * isPossible({ phone: '8005553535', country: 'RU' }, { ... }, metadata)
1443
+ * isPossible({ phone: '8005553535', country: 'RU' }, undefined, metadata)
1444
+ *
1445
+ * @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: '...' }`.
1446
+ * @param {object} [options]
1447
+ * @param {object} metadata
1448
+ * @return {string}
1449
+ */
1450
+
1451
+ function isPossiblePhoneNumber(input, options, metadata) {
1452
+ /* istanbul ignore if */
1453
+ if (options === undefined) {
1454
+ options = {};
1455
+ }
1456
+
1457
+ metadata = new Metadata(metadata);
1458
+
1459
+ if (options.v2) {
1460
+ if (!input.countryCallingCode) {
1461
+ throw new Error('Invalid phone number object passed');
1462
+ }
1463
+
1464
+ metadata.selectNumberingPlan(input.countryCallingCode);
1465
+ } else {
1466
+ if (!input.phone) {
1467
+ return false;
1468
+ }
1469
+
1470
+ if (input.country) {
1471
+ if (!metadata.hasCountry(input.country)) {
1472
+ throw new Error("Unknown country: ".concat(input.country));
1473
+ }
1474
+
1475
+ metadata.country(input.country);
1476
+ } else {
1477
+ if (!input.countryCallingCode) {
1478
+ throw new Error('Invalid phone number object passed');
1479
+ }
1480
+
1481
+ metadata.selectNumberingPlan(input.countryCallingCode);
1482
+ }
1483
+ } // Old metadata (< 1.0.18) had no "possible length" data.
1484
+
1485
+
1486
+ if (metadata.possibleLengths()) {
1487
+ return isPossibleNumber(input.phone || input.nationalNumber, metadata);
1488
+ } else {
1489
+ // There was a bug between `1.7.35` and `1.7.37` where "possible_lengths"
1490
+ // were missing for "non-geographical" numbering plans.
1491
+ // Just assume the number is possible in such cases:
1492
+ // it's unlikely that anyone generated their custom metadata
1493
+ // in that short period of time (one day).
1494
+ // This code can be removed in some future major version update.
1495
+ if (input.countryCallingCode && metadata.isNonGeographicCallingCode(input.countryCallingCode)) {
1496
+ // "Non-geographic entities" did't have `possibleLengths`
1497
+ // due to a bug in metadata generation process.
1498
+ return true;
1499
+ } else {
1500
+ throw new Error('Missing "possibleLengths" in metadata. Perhaps the metadata has been generated before v1.0.18.');
1501
+ }
1502
+ }
1503
+ }
1504
+ function isPossibleNumber(nationalNumber, metadata) {
1505
+ //, isInternational) {
1506
+ switch (checkNumberLength(nationalNumber, metadata)) {
1507
+ case 'IS_POSSIBLE':
1508
+ return true;
1509
+ // This library ignores "local-only" phone numbers (for simplicity).
1510
+ // See the readme for more info on what are "local-only" phone numbers.
1511
+ // case 'IS_POSSIBLE_LOCAL_ONLY':
1512
+ // return !isInternational
1513
+
1514
+ default:
1515
+ return false;
1516
+ }
1517
+ }
1518
+
1519
+ /**
1520
+ * Checks whether the entire input sequence can be matched
1521
+ * against the regular expression.
1522
+ * @return {boolean}
1523
+ */
1524
+ function matchesEntirely(text, regular_expression) {
1525
+ // If assigning the `''` default value is moved to the arguments above,
1526
+ // code coverage would decrease for some weird reason.
1527
+ text = text || '';
1528
+ return new RegExp('^(?:' + regular_expression + ')$').test(text);
1529
+ }
1530
+
1531
+ 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."); }
1532
+
1533
+ 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); }
1534
+
1535
+ 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; }
1536
+ 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)
1537
+
1538
+ function getNumberType(input, options, metadata) {
1539
+ // If assigning the `{}` default value is moved to the arguments above,
1540
+ // code coverage would decrease for some weird reason.
1541
+ options = options || {}; // When `parse()` returned `{}`
1542
+ // meaning that the phone number is not a valid one.
1543
+
1544
+ if (!input.country) {
1545
+ return;
1546
+ }
1547
+
1548
+ metadata = new Metadata(metadata);
1549
+ metadata.selectNumberingPlan(input.country, input.countryCallingCode);
1550
+ var nationalNumber = options.v2 ? input.nationalNumber : input.phone; // The following is copy-pasted from the original function:
1551
+ // https://github.com/googlei18n/libphonenumber/blob/3ea547d4fbaa2d0b67588904dfa5d3f2557c27ff/javascript/i18n/phonenumbers/phonenumberutil.js#L2835
1552
+ // Is this national number even valid for this country
1553
+
1554
+ if (!matchesEntirely(nationalNumber, metadata.nationalNumberPattern())) {
1555
+ return;
1556
+ } // Is it fixed line number
1557
+
1558
+
1559
+ if (isNumberTypeEqualTo(nationalNumber, 'FIXED_LINE', metadata)) {
1560
+ // Because duplicate regular expressions are removed
1561
+ // to reduce metadata size, if "mobile" pattern is ""
1562
+ // then it means it was removed due to being a duplicate of the fixed-line pattern.
1563
+ //
1564
+ if (metadata.type('MOBILE') && metadata.type('MOBILE').pattern() === '') {
1565
+ return 'FIXED_LINE_OR_MOBILE';
1566
+ } // `MOBILE` type pattern isn't included if it matched `FIXED_LINE` one.
1567
+ // For example, for "US" country.
1568
+ // Old metadata (< `1.0.18`) had a specific "types" data structure
1569
+ // that happened to be `undefined` for `MOBILE` in that case.
1570
+ // Newer metadata (>= `1.0.18`) has another data structure that is
1571
+ // not `undefined` for `MOBILE` in that case (it's just an empty array).
1572
+ // So this `if` is just for backwards compatibility with old metadata.
1573
+
1574
+
1575
+ if (!metadata.type('MOBILE')) {
1576
+ return 'FIXED_LINE_OR_MOBILE';
1577
+ } // Check if the number happens to qualify as both fixed line and mobile.
1578
+ // (no such country in the minimal metadata set)
1579
+
1580
+ /* istanbul ignore if */
1581
+
1582
+
1583
+ if (isNumberTypeEqualTo(nationalNumber, 'MOBILE', metadata)) {
1584
+ return 'FIXED_LINE_OR_MOBILE';
1585
+ }
1586
+
1587
+ return 'FIXED_LINE';
1588
+ }
1589
+
1590
+ for (var _iterator = _createForOfIteratorHelperLoose$2(NON_FIXED_LINE_PHONE_TYPES), _step; !(_step = _iterator()).done;) {
1591
+ var type = _step.value;
1592
+
1593
+ if (isNumberTypeEqualTo(nationalNumber, type, metadata)) {
1594
+ return type;
1595
+ }
1596
+ }
1597
+ }
1598
+ function isNumberTypeEqualTo(nationalNumber, type, metadata) {
1599
+ type = metadata.type(type);
1600
+
1601
+ if (!type || !type.pattern()) {
1602
+ return false;
1603
+ } // Check if any possible number lengths are present;
1604
+ // if so, we use them to avoid checking
1605
+ // the validation pattern if they don't match.
1606
+ // If they are absent, this means they match
1607
+ // the general description, which we have
1608
+ // already checked before a specific number type.
1609
+
1610
+
1611
+ if (type.possibleLengths() && type.possibleLengths().indexOf(nationalNumber.length) < 0) {
1612
+ return false;
1613
+ }
1614
+
1615
+ return matchesEntirely(nationalNumber, type.pattern());
1616
+ }
1617
+
1618
+ /**
1619
+ * Checks if a given phone number is valid.
1620
+ *
1621
+ * isValid(phoneNumberInstance, { ..., v2: true }, metadata)
1622
+ *
1623
+ * isPossible({ phone: '8005553535', country: 'RU' }, { ... }, metadata)
1624
+ * isPossible({ phone: '8005553535', country: 'RU' }, undefined, metadata)
1625
+ *
1626
+ * If the `number` is a string, it will be parsed to an object,
1627
+ * but only if it contains only valid phone number characters (including punctuation).
1628
+ * If the `number` is an object, it is used as is.
1629
+ *
1630
+ * The optional `defaultCountry` argument is the default country.
1631
+ * I.e. it does not restrict to just that country,
1632
+ * e.g. in those cases where several countries share
1633
+ * the same phone numbering rules (NANPA, Britain, etc).
1634
+ * For example, even though the number `07624 369230`
1635
+ * belongs to the Isle of Man ("IM" country code)
1636
+ * calling `isValidNumber('07624369230', 'GB', metadata)`
1637
+ * still returns `true` because the country is not restricted to `GB`,
1638
+ * it's just that `GB` is the default one for the phone numbering rules.
1639
+ * For restricting the country see `isValidNumberForRegion()`
1640
+ * though restricting a country might not be a good idea.
1641
+ * https://github.com/googlei18n/libphonenumber/blob/master/FAQ.md#when-should-i-use-isvalidnumberforregion
1642
+ *
1643
+ * Examples:
1644
+ *
1645
+ * ```js
1646
+ * isValidNumber('+78005553535', metadata)
1647
+ * isValidNumber('8005553535', 'RU', metadata)
1648
+ * isValidNumber('88005553535', 'RU', metadata)
1649
+ * isValidNumber({ phone: '8005553535', country: 'RU' }, metadata)
1650
+ * ```
1651
+ */
1652
+
1653
+ function isValidNumber(input, options, metadata) {
1654
+ // If assigning the `{}` default value is moved to the arguments above,
1655
+ // code coverage would decrease for some weird reason.
1656
+ options = options || {};
1657
+ metadata = new Metadata(metadata);
1658
+ /**
1659
+ * Checks if a phone number is "possible" (basically just checks its length).
1660
+ *
1661
+ * @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: '...' }`.
1662
+ * @param {object} [options]
1663
+ * @param {object} metadata
1664
+ * @return {string}
1665
+ */
1666
+
1667
+ metadata.selectNumberingPlan(input.country, input.countryCallingCode); // By default, countries only have type regexps when it's required for
1668
+ // distinguishing different countries having the same `countryCallingCode`.
1669
+
1670
+ if (metadata.hasTypes()) {
1671
+ return getNumberType(input, options, metadata.metadata) !== undefined;
1672
+ } // If there are no type regexps for this country in metadata then use
1673
+ // `nationalNumberPattern` as a "better than nothing" replacement.
1674
+
1675
+
1676
+ var nationalNumber = options.v2 ? input.nationalNumber : input.phone;
1677
+ return matchesEntirely(nationalNumber, metadata.nationalNumberPattern());
1678
+ }
1679
+
1680
+ /**
1681
+ * Returns a list of countries that the phone number could potentially belong to.
1682
+ * @param {string} callingCode — Calling code.
1683
+ * @param {string} nationalNumber — National (significant) number.
1684
+ * @param {object} metadata — Metadata.
1685
+ * @return {string[]} A list of possible countries.
1686
+ */
1687
+
1688
+ function getPossibleCountriesForNumber(callingCode, nationalNumber, metadata) {
1689
+ var _metadata = new Metadata(metadata);
1690
+
1691
+ var possibleCountries = _metadata.getCountryCodesForCallingCode(callingCode);
1692
+
1693
+ if (!possibleCountries) {
1694
+ return [];
1695
+ }
1696
+
1697
+ return possibleCountries.filter(function (country) {
1698
+ return couldNationalNumberBelongToCountry(nationalNumber, country, metadata);
1699
+ });
1700
+ }
1701
+
1702
+ function couldNationalNumberBelongToCountry(nationalNumber, country, metadata) {
1703
+ var _metadata = new Metadata(metadata);
1704
+
1705
+ _metadata.selectNumberingPlan(country);
1706
+
1707
+ if (_metadata.numberingPlan.possibleLengths().indexOf(nationalNumber.length) >= 0) {
1708
+ return true;
1709
+ }
1710
+
1711
+ return false;
1712
+ }
1713
+
1714
+ //
1715
+ // E.g. "(999) 111-22-33" -> "999 111 22 33"
1716
+ //
1717
+ // For some reason Google's metadata contains `<intlFormat/>`s with brackets and dashes.
1718
+ // Meanwhile, there's no single opinion about using punctuation in international phone numbers.
1719
+ //
1720
+ // For example, Google's `<intlFormat/>` for USA is `+1 213-373-4253`.
1721
+ // And here's a quote from WikiPedia's "North American Numbering Plan" page:
1722
+ // https://en.wikipedia.org/wiki/North_American_Numbering_Plan
1723
+ //
1724
+ // "The country calling code for all countries participating in the NANP is 1.
1725
+ // In international format, an NANP number should be listed as +1 301 555 01 00,
1726
+ // where 301 is an area code (Maryland)."
1727
+ //
1728
+ // I personally prefer the international format without any punctuation.
1729
+ // For example, brackets are remnants of the old age, meaning that the
1730
+ // phone number part in brackets (so called "area code") can be omitted
1731
+ // if dialing within the same "area".
1732
+ // And hyphens were clearly introduced for splitting local numbers into memorizable groups.
1733
+ // For example, remembering "5553535" is difficult but "555-35-35" is much simpler.
1734
+ // Imagine a man taking a bus from home to work and seeing an ad with a phone number.
1735
+ // He has a couple of seconds to memorize that number until it passes by.
1736
+ // If it were spaces instead of hyphens the man wouldn't necessarily get it,
1737
+ // but with hyphens instead of spaces the grouping is more explicit.
1738
+ // I personally think that hyphens introduce visual clutter,
1739
+ // so I prefer replacing them with spaces in international numbers.
1740
+ // In the modern age all output is done on displays where spaces are clearly distinguishable
1741
+ // so hyphens can be safely replaced with spaces without losing any legibility.
1742
+ //
1743
+
1744
+ function applyInternationalSeparatorStyle(formattedNumber) {
1745
+ return formattedNumber.replace(new RegExp("[".concat(VALID_PUNCTUATION, "]+"), 'g'), ' ').trim();
1746
+ }
1747
+
1748
+ // first group is not used in the national pattern (e.g. Argentina) so the $1
1749
+ // group does not match correctly. Therefore, we use `\d`, so that the first
1750
+ // group actually used in the pattern will be matched.
1751
+
1752
+ var FIRST_GROUP_PATTERN = /(\$\d)/;
1753
+ function formatNationalNumberUsingFormat(number, format, _ref) {
1754
+ var useInternationalFormat = _ref.useInternationalFormat,
1755
+ withNationalPrefix = _ref.withNationalPrefix;
1756
+ _ref.carrierCode;
1757
+ _ref.metadata;
1758
+ var formattedNumber = number.replace(new RegExp(format.pattern()), useInternationalFormat ? format.internationalFormat() : // This library doesn't use `domestic_carrier_code_formatting_rule`,
1759
+ // because that one is only used when formatting phone numbers
1760
+ // for dialing from a mobile phone, and this is not a dialing library.
1761
+ // carrierCode && format.domesticCarrierCodeFormattingRule()
1762
+ // // First, replace the $CC in the formatting rule with the desired carrier code.
1763
+ // // Then, replace the $FG in the formatting rule with the first group
1764
+ // // and the carrier code combined in the appropriate way.
1765
+ // ? format.format().replace(FIRST_GROUP_PATTERN, format.domesticCarrierCodeFormattingRule().replace('$CC', carrierCode))
1766
+ // : (
1767
+ // withNationalPrefix && format.nationalPrefixFormattingRule()
1768
+ // ? format.format().replace(FIRST_GROUP_PATTERN, format.nationalPrefixFormattingRule())
1769
+ // : format.format()
1770
+ // )
1771
+ withNationalPrefix && format.nationalPrefixFormattingRule() ? format.format().replace(FIRST_GROUP_PATTERN, format.nationalPrefixFormattingRule()) : format.format());
1772
+
1773
+ if (useInternationalFormat) {
1774
+ return applyInternationalSeparatorStyle(formattedNumber);
1775
+ }
1776
+
1777
+ return formattedNumber;
1778
+ }
1779
+
1780
+ /**
1781
+ * Pattern that makes it easy to distinguish whether a region has a single
1782
+ * international dialing prefix or not. If a region has a single international
1783
+ * prefix (e.g. 011 in USA), it will be represented as a string that contains
1784
+ * a sequence of ASCII digits, and possibly a tilde, which signals waiting for
1785
+ * the tone. If there are multiple available international prefixes in a
1786
+ * region, they will be represented as a regex string that always contains one
1787
+ * or more characters that are not ASCII digits or a tilde.
1788
+ */
1789
+
1790
+ var SINGLE_IDD_PREFIX_REG_EXP = /^[\d]+(?:[~\u2053\u223C\uFF5E][\d]+)?$/; // For regions that have multiple IDD prefixes
1791
+ // a preferred IDD prefix is returned.
1792
+
1793
+ function getIddPrefix(country, callingCode, metadata) {
1794
+ var countryMetadata = new Metadata(metadata);
1795
+ countryMetadata.selectNumberingPlan(country, callingCode);
1796
+
1797
+ if (countryMetadata.defaultIDDPrefix()) {
1798
+ return countryMetadata.defaultIDDPrefix();
1799
+ }
1800
+
1801
+ if (SINGLE_IDD_PREFIX_REG_EXP.test(countryMetadata.IDDPrefix())) {
1802
+ return countryMetadata.IDDPrefix();
1803
+ }
1804
+ }
1805
+
1806
+ /**
1807
+ * @param {object} - `{ ?number, ?extension }`.
1808
+ * @return {string} Phone URI (RFC 3966).
1809
+ */
1810
+
1811
+ function formatRFC3966(_ref) {
1812
+ var number = _ref.number,
1813
+ ext = _ref.ext;
1814
+
1815
+ if (!number) {
1816
+ return '';
1817
+ }
1818
+
1819
+ if (number[0] !== '+') {
1820
+ throw new Error("\"formatRFC3966()\" expects \"number\" to be in E.164 format.");
1821
+ }
1822
+
1823
+ return "tel:".concat(number).concat(ext ? ';ext=' + ext : '');
1824
+ }
1825
+
1826
+ 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."); }
1827
+
1828
+ 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); }
1829
+
1830
+ 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; }
1831
+
1832
+ 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; }
1833
+
1834
+ 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; }
1835
+
1836
+ 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; }
1837
+ var DEFAULT_OPTIONS = {
1838
+ formatExtension: function formatExtension(formattedNumber, extension, metadata) {
1839
+ return "".concat(formattedNumber).concat(metadata.ext()).concat(extension);
1840
+ }
1841
+ };
1842
+ /**
1843
+ * Formats a phone number.
1844
+ *
1845
+ * format(phoneNumberInstance, 'INTERNATIONAL', { ..., v2: true }, metadata)
1846
+ * format(phoneNumberInstance, 'NATIONAL', { ..., v2: true }, metadata)
1847
+ *
1848
+ * format({ phone: '8005553535', country: 'RU' }, 'INTERNATIONAL', { ... }, metadata)
1849
+ * format({ phone: '8005553535', country: 'RU' }, 'NATIONAL', undefined, metadata)
1850
+ *
1851
+ * @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: '...' }`.
1852
+ * @param {string} format
1853
+ * @param {object} [options]
1854
+ * @param {object} metadata
1855
+ * @return {string}
1856
+ */
1857
+
1858
+ function formatNumber(input, format, options, metadata) {
1859
+ // Apply default options.
1860
+ if (options) {
1861
+ options = _objectSpread$5(_objectSpread$5({}, DEFAULT_OPTIONS), options);
1862
+ } else {
1863
+ options = DEFAULT_OPTIONS;
1864
+ }
1865
+
1866
+ metadata = new Metadata(metadata);
1867
+
1868
+ if (input.country && input.country !== '001') {
1869
+ // Validate `input.country`.
1870
+ if (!metadata.hasCountry(input.country)) {
1871
+ throw new Error("Unknown country: ".concat(input.country));
1872
+ }
1873
+
1874
+ metadata.country(input.country);
1875
+ } else if (input.countryCallingCode) {
1876
+ metadata.selectNumberingPlan(input.countryCallingCode);
1877
+ } else return input.phone || '';
1878
+
1879
+ var countryCallingCode = metadata.countryCallingCode();
1880
+ var nationalNumber = options.v2 ? input.nationalNumber : input.phone; // This variable should have been declared inside `case`s
1881
+ // but Babel has a bug and it says "duplicate variable declaration".
1882
+
1883
+ var number;
1884
+
1885
+ switch (format) {
1886
+ case 'NATIONAL':
1887
+ // Legacy argument support.
1888
+ // (`{ country: ..., phone: '' }`)
1889
+ if (!nationalNumber) {
1890
+ return '';
1891
+ }
1892
+
1893
+ number = formatNationalNumber(nationalNumber, input.carrierCode, 'NATIONAL', metadata, options);
1894
+ return addExtension(number, input.ext, metadata, options.formatExtension);
1895
+
1896
+ case 'INTERNATIONAL':
1897
+ // Legacy argument support.
1898
+ // (`{ country: ..., phone: '' }`)
1899
+ if (!nationalNumber) {
1900
+ return "+".concat(countryCallingCode);
1901
+ }
1902
+
1903
+ number = formatNationalNumber(nationalNumber, null, 'INTERNATIONAL', metadata, options);
1904
+ number = "+".concat(countryCallingCode, " ").concat(number);
1905
+ return addExtension(number, input.ext, metadata, options.formatExtension);
1906
+
1907
+ case 'E.164':
1908
+ // `E.164` doesn't define "phone number extensions".
1909
+ return "+".concat(countryCallingCode).concat(nationalNumber);
1910
+
1911
+ case 'RFC3966':
1912
+ return formatRFC3966({
1913
+ number: "+".concat(countryCallingCode).concat(nationalNumber),
1914
+ ext: input.ext
1915
+ });
1916
+ // For reference, here's Google's IDD formatter:
1917
+ // https://github.com/google/libphonenumber/blob/32719cf74e68796788d1ca45abc85dcdc63ba5b9/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java#L1546
1918
+ // Not saying that this IDD formatter replicates it 1:1, but it seems to work.
1919
+ // Who would even need to format phone numbers in IDD format anyway?
1920
+
1921
+ case 'IDD':
1922
+ if (!options.fromCountry) {
1923
+ return; // throw new Error('`fromCountry` option not passed for IDD-prefixed formatting.')
1924
+ }
1925
+
1926
+ var formattedNumber = formatIDD(nationalNumber, input.carrierCode, countryCallingCode, options.fromCountry, metadata);
1927
+ return addExtension(formattedNumber, input.ext, metadata, options.formatExtension);
1928
+
1929
+ default:
1930
+ throw new Error("Unknown \"format\" argument passed to \"formatNumber()\": \"".concat(format, "\""));
1931
+ }
1932
+ }
1933
+
1934
+ function formatNationalNumber(number, carrierCode, formatAs, metadata, options) {
1935
+ var format = chooseFormatForNumber(metadata.formats(), number);
1936
+
1937
+ if (!format) {
1938
+ return number;
1939
+ }
1940
+
1941
+ return formatNationalNumberUsingFormat(number, format, {
1942
+ useInternationalFormat: formatAs === 'INTERNATIONAL',
1943
+ withNationalPrefix: format.nationalPrefixIsOptionalWhenFormattingInNationalFormat() && options && options.nationalPrefix === false ? false : true,
1944
+ carrierCode: carrierCode,
1945
+ metadata: metadata
1946
+ });
1947
+ }
1948
+
1949
+ function chooseFormatForNumber(availableFormats, nationalNnumber) {
1950
+ for (var _iterator = _createForOfIteratorHelperLoose$1(availableFormats), _step; !(_step = _iterator()).done;) {
1951
+ var format = _step.value;
1952
+
1953
+ // Validate leading digits.
1954
+ // The test case for "else path" could be found by searching for
1955
+ // "format.leadingDigitsPatterns().length === 0".
1956
+ if (format.leadingDigitsPatterns().length > 0) {
1957
+ // The last leading_digits_pattern is used here, as it is the most detailed
1958
+ var lastLeadingDigitsPattern = format.leadingDigitsPatterns()[format.leadingDigitsPatterns().length - 1]; // If leading digits don't match then move on to the next phone number format
1959
+
1960
+ if (nationalNnumber.search(lastLeadingDigitsPattern) !== 0) {
1961
+ continue;
1962
+ }
1963
+ } // Check that the national number matches the phone number format regular expression
1964
+
1965
+
1966
+ if (matchesEntirely(nationalNnumber, format.pattern())) {
1967
+ return format;
1968
+ }
1969
+ }
1970
+ }
1971
+
1972
+ function addExtension(formattedNumber, ext, metadata, formatExtension) {
1973
+ return ext ? formatExtension(formattedNumber, ext, metadata) : formattedNumber;
1974
+ }
1975
+
1976
+ function formatIDD(nationalNumber, carrierCode, countryCallingCode, fromCountry, metadata) {
1977
+ var fromCountryCallingCode = getCountryCallingCode(fromCountry, metadata.metadata); // When calling within the same country calling code.
1978
+
1979
+ if (fromCountryCallingCode === countryCallingCode) {
1980
+ var formattedNumber = formatNationalNumber(nationalNumber, carrierCode, 'NATIONAL', metadata); // For NANPA regions, return the national format for these regions
1981
+ // but prefix it with the country calling code.
1982
+
1983
+ if (countryCallingCode === '1') {
1984
+ return countryCallingCode + ' ' + formattedNumber;
1985
+ } // If regions share a country calling code, the country calling code need
1986
+ // not be dialled. This also applies when dialling within a region, so this
1987
+ // if clause covers both these cases. Technically this is the case for
1988
+ // dialling from La Reunion to other overseas departments of France (French
1989
+ // Guiana, Martinique, Guadeloupe), but not vice versa - so we don't cover
1990
+ // this edge case for now and for those cases return the version including
1991
+ // country calling code. Details here:
1992
+ // http://www.petitfute.com/voyage/225-info-pratiques-reunion
1993
+ //
1994
+
1995
+
1996
+ return formattedNumber;
1997
+ }
1998
+
1999
+ var iddPrefix = getIddPrefix(fromCountry, undefined, metadata.metadata);
2000
+
2001
+ if (iddPrefix) {
2002
+ return "".concat(iddPrefix, " ").concat(countryCallingCode, " ").concat(formatNationalNumber(nationalNumber, null, 'INTERNATIONAL', metadata));
2003
+ }
2004
+ }
2005
+
2006
+ 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; }
2007
+
2008
+ 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; }
2009
+
2010
+ 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; }
2011
+
2012
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
2013
+
2014
+ 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); } }
2015
+
2016
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
2017
+
2018
+ var PhoneNumber = /*#__PURE__*/function () {
2019
+ /**
2020
+ * @param {string} countryOrCountryCallingCode
2021
+ * @param {string} nationalNumber
2022
+ * @param {object} metadata — Metadata JSON
2023
+ * @return {PhoneNumber}
2024
+ */
2025
+ function PhoneNumber(countryOrCountryCallingCode, nationalNumber, metadata) {
2026
+ _classCallCheck(this, PhoneNumber);
2027
+
2028
+ if (!countryOrCountryCallingCode) {
2029
+ throw new TypeError('`country` or `countryCallingCode` not passed');
2030
+ }
2031
+
2032
+ if (!nationalNumber) {
2033
+ throw new TypeError('`nationalNumber` not passed');
2034
+ }
2035
+
2036
+ if (!metadata) {
2037
+ throw new TypeError('`metadata` not passed');
2038
+ }
2039
+
2040
+ var _getCountryAndCountry = getCountryAndCountryCallingCode(countryOrCountryCallingCode, metadata),
2041
+ country = _getCountryAndCountry.country,
2042
+ countryCallingCode = _getCountryAndCountry.countryCallingCode;
2043
+
2044
+ this.country = country;
2045
+ this.countryCallingCode = countryCallingCode;
2046
+ this.nationalNumber = nationalNumber;
2047
+ this.number = '+' + this.countryCallingCode + this.nationalNumber; // Exclude `metadata` property output from `PhoneNumber.toString()`
2048
+ // so that it doesn't clutter the console output of Node.js.
2049
+ // Previously, when Node.js did `console.log(new PhoneNumber(...))`,
2050
+ // it would output the whole internal structure of the `metadata` object.
2051
+
2052
+ this.getMetadata = function () {
2053
+ return metadata;
2054
+ };
2055
+ }
2056
+
2057
+ _createClass(PhoneNumber, [{
2058
+ key: "setExt",
2059
+ value: function setExt(ext) {
2060
+ this.ext = ext;
2061
+ }
2062
+ }, {
2063
+ key: "getPossibleCountries",
2064
+ value: function getPossibleCountries() {
2065
+ if (this.country) {
2066
+ return [this.country];
2067
+ }
2068
+
2069
+ return getPossibleCountriesForNumber(this.countryCallingCode, this.nationalNumber, this.getMetadata());
2070
+ }
2071
+ }, {
2072
+ key: "isPossible",
2073
+ value: function isPossible() {
2074
+ return isPossiblePhoneNumber(this, {
2075
+ v2: true
2076
+ }, this.getMetadata());
2077
+ }
2078
+ }, {
2079
+ key: "isValid",
2080
+ value: function isValid() {
2081
+ return isValidNumber(this, {
2082
+ v2: true
2083
+ }, this.getMetadata());
2084
+ }
2085
+ }, {
2086
+ key: "isNonGeographic",
2087
+ value: function isNonGeographic() {
2088
+ var metadata = new Metadata(this.getMetadata());
2089
+ return metadata.isNonGeographicCallingCode(this.countryCallingCode);
2090
+ }
2091
+ }, {
2092
+ key: "isEqual",
2093
+ value: function isEqual(phoneNumber) {
2094
+ return this.number === phoneNumber.number && this.ext === phoneNumber.ext;
2095
+ } // This function was originally meant to be an equivalent for `validatePhoneNumberLength()`,
2096
+ // but later it was found out that it doesn't include the possible `TOO_SHORT` result
2097
+ // returned from `parsePhoneNumberWithError()` in the original `validatePhoneNumberLength()`,
2098
+ // so eventually I simply commented out this method from the `PhoneNumber` class
2099
+ // and just left the `validatePhoneNumberLength()` function, even though that one would require
2100
+ // and additional step to also validate the actual country / calling code of the phone number.
2101
+ // validateLength() {
2102
+ // const metadata = new Metadata(this.getMetadata())
2103
+ // metadata.selectNumberingPlan(this.countryCallingCode)
2104
+ // const result = checkNumberLength(this.nationalNumber, metadata)
2105
+ // if (result !== 'IS_POSSIBLE') {
2106
+ // return result
2107
+ // }
2108
+ // }
2109
+
2110
+ }, {
2111
+ key: "getType",
2112
+ value: function getType() {
2113
+ return getNumberType(this, {
2114
+ v2: true
2115
+ }, this.getMetadata());
2116
+ }
2117
+ }, {
2118
+ key: "format",
2119
+ value: function format(_format, options) {
2120
+ return formatNumber(this, _format, options ? _objectSpread$4(_objectSpread$4({}, options), {}, {
2121
+ v2: true
2122
+ }) : {
2123
+ v2: true
2124
+ }, this.getMetadata());
2125
+ }
2126
+ }, {
2127
+ key: "formatNational",
2128
+ value: function formatNational(options) {
2129
+ return this.format('NATIONAL', options);
2130
+ }
2131
+ }, {
2132
+ key: "formatInternational",
2133
+ value: function formatInternational(options) {
2134
+ return this.format('INTERNATIONAL', options);
2135
+ }
2136
+ }, {
2137
+ key: "getURI",
2138
+ value: function getURI(options) {
2139
+ return this.format('RFC3966', options);
2140
+ }
2141
+ }]);
2142
+
2143
+ return PhoneNumber;
2144
+ }();
2145
+
2146
+ var isCountryCode = function isCountryCode(value) {
2147
+ return /^[A-Z]{2}$/.test(value);
2148
+ };
2149
+
2150
+ function getCountryAndCountryCallingCode(countryOrCountryCallingCode, metadataJson) {
2151
+ var country;
2152
+ var countryCallingCode;
2153
+ var metadata = new Metadata(metadataJson); // If country code is passed then derive `countryCallingCode` from it.
2154
+ // Also store the country code as `.country`.
2155
+
2156
+ if (isCountryCode(countryOrCountryCallingCode)) {
2157
+ country = countryOrCountryCallingCode;
2158
+ metadata.selectNumberingPlan(country);
2159
+ countryCallingCode = metadata.countryCallingCode();
2160
+ } else {
2161
+ countryCallingCode = countryOrCountryCallingCode;
2162
+ }
2163
+
2164
+ return {
2165
+ country: country,
2166
+ countryCallingCode: countryCallingCode
2167
+ };
2168
+ }
2169
+
2170
+ var CAPTURING_DIGIT_PATTERN = new RegExp('([' + VALID_DIGITS + '])');
2171
+ function stripIddPrefix(number, country, callingCode, metadata) {
2172
+ if (!country) {
2173
+ return;
2174
+ } // Check if the number is IDD-prefixed.
2175
+
2176
+
2177
+ var countryMetadata = new Metadata(metadata);
2178
+ countryMetadata.selectNumberingPlan(country, callingCode);
2179
+ var IDDPrefixPattern = new RegExp(countryMetadata.IDDPrefix());
2180
+
2181
+ if (number.search(IDDPrefixPattern) !== 0) {
2182
+ return;
2183
+ } // Strip IDD prefix.
2184
+
2185
+
2186
+ number = number.slice(number.match(IDDPrefixPattern)[0].length); // If there're any digits after an IDD prefix,
2187
+ // then those digits are a country calling code.
2188
+ // Since no country code starts with a `0`,
2189
+ // the code below validates that the next digit (if present) is not `0`.
2190
+
2191
+ var matchedGroups = number.match(CAPTURING_DIGIT_PATTERN);
2192
+
2193
+ if (matchedGroups && matchedGroups[1] != null && matchedGroups[1].length > 0) {
2194
+ if (matchedGroups[1] === '0') {
2195
+ return;
2196
+ }
2197
+ }
2198
+
2199
+ return number;
2200
+ }
2201
+
2202
+ /**
2203
+ * Strips any national prefix (such as 0, 1) present in a
2204
+ * (possibly incomplete) number provided.
2205
+ * "Carrier codes" are only used in Colombia and Brazil,
2206
+ * and only when dialing within those countries from a mobile phone to a fixed line number.
2207
+ * Sometimes it won't actually strip national prefix
2208
+ * and will instead prepend some digits to the `number`:
2209
+ * for example, when number `2345678` is passed with `VI` country selected,
2210
+ * it will return `{ number: "3402345678" }`, because `340` area code is prepended.
2211
+ * @param {string} number — National number digits.
2212
+ * @param {object} metadata — Metadata with country selected.
2213
+ * @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.
2214
+ */
2215
+ function extractNationalNumberFromPossiblyIncompleteNumber(number, metadata) {
2216
+ if (number && metadata.numberingPlan.nationalPrefixForParsing()) {
2217
+ // See METADATA.md for the description of
2218
+ // `national_prefix_for_parsing` and `national_prefix_transform_rule`.
2219
+ // Attempt to parse the first digits as a national prefix.
2220
+ var prefixPattern = new RegExp('^(?:' + metadata.numberingPlan.nationalPrefixForParsing() + ')');
2221
+ var prefixMatch = prefixPattern.exec(number);
2222
+
2223
+ if (prefixMatch) {
2224
+ var nationalNumber;
2225
+ var carrierCode; // https://gitlab.com/catamphetamine/libphonenumber-js/-/blob/master/METADATA.md#national_prefix_for_parsing--national_prefix_transform_rule
2226
+ // If a `national_prefix_for_parsing` has any "capturing groups"
2227
+ // then it means that the national (significant) number is equal to
2228
+ // those "capturing groups" transformed via `national_prefix_transform_rule`,
2229
+ // and nothing could be said about the actual national prefix:
2230
+ // what is it and was it even there.
2231
+ // If a `national_prefix_for_parsing` doesn't have any "capturing groups",
2232
+ // then everything it matches is a national prefix.
2233
+ // To determine whether `national_prefix_for_parsing` matched any
2234
+ // "capturing groups", the value of the result of calling `.exec()`
2235
+ // is looked at, and if it has non-undefined values where there're
2236
+ // "capturing groups" in the regular expression, then it means
2237
+ // that "capturing groups" have been matched.
2238
+ // It's not possible to tell whether there'll be any "capturing gropus"
2239
+ // before the matching process, because a `national_prefix_for_parsing`
2240
+ // could exhibit both behaviors.
2241
+
2242
+ var capturedGroupsCount = prefixMatch.length - 1;
2243
+ var hasCapturedGroups = capturedGroupsCount > 0 && prefixMatch[capturedGroupsCount];
2244
+
2245
+ if (metadata.nationalPrefixTransformRule() && hasCapturedGroups) {
2246
+ nationalNumber = number.replace(prefixPattern, metadata.nationalPrefixTransformRule()); // If there's more than one captured group,
2247
+ // then carrier code is the second one.
2248
+
2249
+ if (capturedGroupsCount > 1) {
2250
+ carrierCode = prefixMatch[1];
2251
+ }
2252
+ } // If there're no "capturing groups",
2253
+ // or if there're "capturing groups" but no
2254
+ // `national_prefix_transform_rule`,
2255
+ // then just strip the national prefix from the number,
2256
+ // and possibly a carrier code.
2257
+ // Seems like there could be more.
2258
+ else {
2259
+ // `prefixBeforeNationalNumber` is the whole substring matched by
2260
+ // the `national_prefix_for_parsing` regular expression.
2261
+ // There seem to be no guarantees that it's just a national prefix.
2262
+ // For example, if there's a carrier code, it's gonna be a
2263
+ // part of `prefixBeforeNationalNumber` too.
2264
+ var prefixBeforeNationalNumber = prefixMatch[0];
2265
+ nationalNumber = number.slice(prefixBeforeNationalNumber.length); // If there's at least one captured group,
2266
+ // then carrier code is the first one.
2267
+
2268
+ if (hasCapturedGroups) {
2269
+ carrierCode = prefixMatch[1];
2270
+ }
2271
+ } // Tries to guess whether a national prefix was present in the input.
2272
+ // This is not something copy-pasted from Google's library:
2273
+ // they don't seem to have an equivalent for that.
2274
+ // So this isn't an "officially approved" way of doing something like that.
2275
+ // But since there seems no other existing method, this library uses it.
2276
+
2277
+
2278
+ var nationalPrefix;
2279
+
2280
+ if (hasCapturedGroups) {
2281
+ var possiblePositionOfTheFirstCapturedGroup = number.indexOf(prefixMatch[1]);
2282
+ var possibleNationalPrefix = number.slice(0, possiblePositionOfTheFirstCapturedGroup); // Example: an Argentinian (AR) phone number `0111523456789`.
2283
+ // `prefixMatch[0]` is `01115`, and `$1` is `11`,
2284
+ // and the rest of the phone number is `23456789`.
2285
+ // The national number is transformed via `9$1` to `91123456789`.
2286
+ // National prefix `0` is detected being present at the start.
2287
+ // if (possibleNationalPrefix.indexOf(metadata.numberingPlan.nationalPrefix()) === 0) {
2288
+
2289
+ if (possibleNationalPrefix === metadata.numberingPlan.nationalPrefix()) {
2290
+ nationalPrefix = metadata.numberingPlan.nationalPrefix();
2291
+ }
2292
+ } else {
2293
+ nationalPrefix = prefixMatch[0];
2294
+ }
2295
+
2296
+ return {
2297
+ nationalNumber: nationalNumber,
2298
+ nationalPrefix: nationalPrefix,
2299
+ carrierCode: carrierCode
2300
+ };
2301
+ }
2302
+ }
2303
+
2304
+ return {
2305
+ nationalNumber: number
2306
+ };
2307
+ }
2308
+
2309
+ /**
2310
+ * Strips national prefix and carrier code from a complete phone number.
2311
+ * The difference from the non-"FromCompleteNumber" function is that
2312
+ * it won't extract national prefix if the resultant number is too short
2313
+ * to be a complete number for the selected phone numbering plan.
2314
+ * @param {string} number — Complete phone number digits.
2315
+ * @param {Metadata} metadata — Metadata with a phone numbering plan selected.
2316
+ * @return {object} `{ nationalNumber: string, carrierCode: string? }`.
2317
+ */
2318
+
2319
+ function extractNationalNumber(number, metadata) {
2320
+ // Parsing national prefixes and carrier codes
2321
+ // is only required for local phone numbers
2322
+ // but some people don't understand that
2323
+ // and sometimes write international phone numbers
2324
+ // with national prefixes (or maybe even carrier codes).
2325
+ // http://ucken.blogspot.ru/2016/03/trunk-prefixes-in-skype4b.html
2326
+ // Google's original library forgives such mistakes
2327
+ // and so does this library, because it has been requested:
2328
+ // https://github.com/catamphetamine/libphonenumber-js/issues/127
2329
+ var _extractNationalNumbe = extractNationalNumberFromPossiblyIncompleteNumber(number, metadata),
2330
+ carrierCode = _extractNationalNumbe.carrierCode,
2331
+ nationalNumber = _extractNationalNumbe.nationalNumber;
2332
+
2333
+ if (nationalNumber !== number) {
2334
+ if (!shouldHaveExtractedNationalPrefix(number, nationalNumber, metadata)) {
2335
+ // Don't strip the national prefix.
2336
+ return {
2337
+ nationalNumber: number
2338
+ };
2339
+ } // Check the national (significant) number length after extracting national prefix and carrier code.
2340
+ // Legacy generated metadata (before `1.0.18`) didn't support the "possible lengths" feature.
2341
+
2342
+
2343
+ if (metadata.possibleLengths()) {
2344
+ // The number remaining after stripping the national prefix and carrier code
2345
+ // should be long enough to have a possible length for the country.
2346
+ // Otherwise, don't strip the national prefix and carrier code,
2347
+ // since the original number could be a valid number.
2348
+ // This check has been copy-pasted "as is" from Google's original library:
2349
+ // https://github.com/google/libphonenumber/blob/876268eb1ad6cdc1b7b5bef17fc5e43052702d57/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java#L3236-L3250
2350
+ // It doesn't check for the "possibility" of the original `number`.
2351
+ // I guess it's fine not checking that one. It works as is anyway.
2352
+ if (!isPossibleIncompleteNationalNumber(nationalNumber, metadata)) {
2353
+ // Don't strip the national prefix.
2354
+ return {
2355
+ nationalNumber: number
2356
+ };
2357
+ }
2358
+ }
2359
+ }
2360
+
2361
+ return {
2362
+ nationalNumber: nationalNumber,
2363
+ carrierCode: carrierCode
2364
+ };
2365
+ } // In some countries, the same digit could be a national prefix
2366
+ // or a leading digit of a valid phone number.
2367
+ // For example, in Russia, national prefix is `8`,
2368
+ // and also `800 555 35 35` is a valid number
2369
+ // in which `8` is not a national prefix, but the first digit
2370
+ // of a national (significant) number.
2371
+ // Same's with Belarus:
2372
+ // `82004910060` is a valid national (significant) number,
2373
+ // but `2004910060` is not.
2374
+ // To support such cases (to prevent the code from always stripping
2375
+ // national prefix), a condition is imposed: a national prefix
2376
+ // is not extracted when the original number is "viable" and the
2377
+ // resultant number is not, a "viable" national number being the one
2378
+ // that matches `national_number_pattern`.
2379
+
2380
+ function shouldHaveExtractedNationalPrefix(nationalNumberBefore, nationalNumberAfter, metadata) {
2381
+ // The equivalent in Google's code is:
2382
+ // https://github.com/google/libphonenumber/blob/e326fa1fc4283bb05eb35cb3c15c18f98a31af33/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java#L2969-L3004
2383
+ if (matchesEntirely(nationalNumberBefore, metadata.nationalNumberPattern()) && !matchesEntirely(nationalNumberAfter, metadata.nationalNumberPattern())) {
2384
+ return false;
2385
+ } // This "is possible" national number (length) check has been commented out
2386
+ // because it's superceded by the (effectively) same check done in the
2387
+ // `extractNationalNumber()` function after it calls `shouldHaveExtractedNationalPrefix()`.
2388
+ // In other words, why run the same check twice if it could only be run once.
2389
+ // // Check the national (significant) number length after extracting national prefix and carrier code.
2390
+ // // Fixes a minor "weird behavior" bug: https://gitlab.com/catamphetamine/libphonenumber-js/-/issues/57
2391
+ // // (Legacy generated metadata (before `1.0.18`) didn't support the "possible lengths" feature).
2392
+ // if (metadata.possibleLengths()) {
2393
+ // if (isPossibleIncompleteNationalNumber(nationalNumberBefore, metadata) &&
2394
+ // !isPossibleIncompleteNationalNumber(nationalNumberAfter, metadata)) {
2395
+ // return false
2396
+ // }
2397
+ // }
2398
+
2399
+
2400
+ return true;
2401
+ }
2402
+
2403
+ function isPossibleIncompleteNationalNumber(nationalNumber, metadata) {
2404
+ switch (checkNumberLength(nationalNumber, metadata)) {
2405
+ case 'TOO_SHORT':
2406
+ case 'INVALID_LENGTH':
2407
+ // This library ignores "local-only" phone numbers (for simplicity).
2408
+ // See the readme for more info on what are "local-only" phone numbers.
2409
+ // case 'IS_POSSIBLE_LOCAL_ONLY':
2410
+ return false;
2411
+
2412
+ default:
2413
+ return true;
2414
+ }
2415
+ }
2416
+
61
2417
  /**
62
- * A component that can be used to render a boolean field
63
- *
64
- * @param options BooleanCustomFieldProps - options for the component
65
- * @returns { JSX.Element } JSX.Element - a component that can be used to render a boolean field
66
- */
67
- const BooleanCustomField = (_a) => {
68
- 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"]);
69
- const initialValue = value !== undefined ? value : defaultValue ? defaultValue : false;
70
- const renderAsInvalid = isInvalid || Boolean(errorMessage);
71
- const htmlForId = id ? id : "boolean-custom-field-" + uuid.v4();
72
- const [internalValue, setInternalValue] = React__namespace.useState(initialValue);
73
- React__namespace.useEffect(() => {
74
- setInternalValue((value === undefined ? defaultValue : value) || false);
75
- }, [value, setInternalValue, defaultValue]);
76
- const onChangeHandler = React__namespace.useCallback((event) => {
77
- var _a;
78
- onChange && onChange(event);
79
- const isChecked = ((_a = event.target) === null || _a === void 0 ? void 0 : _a.checked) || false;
80
- if (setValue) {
81
- setValue(id, isChecked);
82
- }
83
- setInternalValue(isChecked);
84
- }, [setInternalValue, onChange, id, setValue]);
85
- React__namespace.useEffect(() => {
86
- register && register(id, Object.assign(Object.assign({}, validationRules), { value: internalValue.toString() }));
87
- // eslint-disable-next-line react-hooks/exhaustive-deps
88
- }, []); // register only once
89
- return (jsxRuntime.jsx(reactFormComponents.FormGroup, Object.assign({ htmlFor: htmlForId, label: label, tip: tip, isInvalid: renderAsInvalid, helpText: errorMessage || helpText, helpAddon: helpAddon || null, dataTestId: dataTestId && `${dataTestId}-FormGroup` }, { children: jsxRuntime.jsx(reactFormComponents.Checkbox, Object.assign({ checked: internalValue, dataTestId: dataTestId, id: htmlForId, disabled: disabled, name: id, onChange: onChangeHandler, isInvalid: renderAsInvalid }, rest)) })));
90
- };
2418
+ * Sometimes some people incorrectly input international phone numbers
2419
+ * without the leading `+`. This function corrects such input.
2420
+ * @param {string} number Phone number digits.
2421
+ * @param {string?} country
2422
+ * @param {string?} callingCode
2423
+ * @param {object} metadata
2424
+ * @return {object} `{ countryCallingCode: string?, number: string }`.
2425
+ */
2426
+
2427
+ function extractCountryCallingCodeFromInternationalNumberWithoutPlusSign(number, country, callingCode, metadata) {
2428
+ var countryCallingCode = country ? getCountryCallingCode(country, metadata) : callingCode;
2429
+
2430
+ if (number.indexOf(countryCallingCode) === 0) {
2431
+ metadata = new Metadata(metadata);
2432
+ metadata.selectNumberingPlan(country, callingCode);
2433
+ var possibleShorterNumber = number.slice(countryCallingCode.length);
2434
+
2435
+ var _extractNationalNumbe = extractNationalNumber(possibleShorterNumber, metadata),
2436
+ possibleShorterNationalNumber = _extractNationalNumbe.nationalNumber;
2437
+
2438
+ var _extractNationalNumbe2 = extractNationalNumber(number, metadata),
2439
+ nationalNumber = _extractNationalNumbe2.nationalNumber; // If the number was not valid before but is valid now,
2440
+ // or if it was too long before, we consider the number
2441
+ // with the country calling code stripped to be a better result
2442
+ // and keep that instead.
2443
+ // For example, in Germany (+49), `49` is a valid area code,
2444
+ // so if a number starts with `49`, it could be both a valid
2445
+ // national German number or an international number without
2446
+ // a leading `+`.
2447
+
2448
+
2449
+ if (!matchesEntirely(nationalNumber, metadata.nationalNumberPattern()) && matchesEntirely(possibleShorterNationalNumber, metadata.nationalNumberPattern()) || checkNumberLength(nationalNumber, metadata) === 'TOO_LONG') {
2450
+ return {
2451
+ countryCallingCode: countryCallingCode,
2452
+ number: possibleShorterNumber
2453
+ };
2454
+ }
2455
+ }
2456
+
2457
+ return {
2458
+ number: number
2459
+ };
2460
+ }
91
2461
 
92
2462
  /**
93
- * A component that can be used to render a date field
94
- *
95
- * @param props DateCustomFieldProps - options for the component
96
- * @returns { JSX.Element } JSX.Element - a component that can be used to render a date field
97
- */
98
- const DateCustomField = (props) => {
99
- const { setValue, defaultValue, register, id, validationRules } = props, rest = __rest(props, ["setValue", "defaultValue", "register", "id", "validationRules"]);
100
- const onChangeHandler = React.useCallback((e) => {
101
- var _a, _b, _c, _d;
102
- if (((_b = (_a = e.target) === null || _a === void 0 ? void 0 : _a.valueAsDate) === null || _b === void 0 ? void 0 : _b.toISOString()) !== undefined) {
103
- setValue && setValue(id, (_d = (_c = e.target) === null || _c === void 0 ? void 0 : _c.valueAsDate) === null || _d === void 0 ? void 0 : _d.toISOString());
104
- }
105
- }, [setValue, id]);
106
- React.useEffect(() => {
107
- const value = defaultValue && new Date(defaultValue);
108
- register && register(id, Object.assign(Object.assign({}, validationRules), { value }));
109
- }, [register, validationRules, defaultValue, id]);
110
- return (React.createElement(reactFormComponents.DateField, Object.assign({}, rest, { key: id, id: id, helpAddon: props.helpAddon || null, helpText: props.errorMessage || props.helpText, onChange: onChangeHandler, label: props.title, defaultValue: defaultValue })));
111
- };
2463
+ * Converts a phone number digits (possibly with a `+`)
2464
+ * into a calling code and the rest phone number digits.
2465
+ * The "rest phone number digits" could include
2466
+ * a national prefix, carrier code, and national
2467
+ * (significant) number.
2468
+ * @param {string} number — Phone number digits (possibly with a `+`).
2469
+ * @param {string} [country] — Default country.
2470
+ * @param {string} [callingCode] — Default calling code (some phone numbering plans are non-geographic).
2471
+ * @param {object} metadata
2472
+ * @return {object} `{ countryCallingCodeSource: string?, countryCallingCode: string?, number: string }`
2473
+ * @example
2474
+ * // Returns `{ countryCallingCode: "1", number: "2133734253" }`.
2475
+ * extractCountryCallingCode('2133734253', 'US', null, metadata)
2476
+ * extractCountryCallingCode('2133734253', null, '1', metadata)
2477
+ * extractCountryCallingCode('+12133734253', null, null, metadata)
2478
+ * extractCountryCallingCode('+12133734253', 'RU', null, metadata)
2479
+ */
2480
+
2481
+ function extractCountryCallingCode(number, country, callingCode, metadata) {
2482
+ if (!number) {
2483
+ return {};
2484
+ }
2485
+
2486
+ var isNumberWithIddPrefix; // If this is not an international phone number,
2487
+ // then either extract an "IDD" prefix, or extract a
2488
+ // country calling code from a number by autocorrecting it
2489
+ // by prepending a leading `+` in cases when it starts
2490
+ // with the country calling code.
2491
+ // https://wikitravel.org/en/International_dialling_prefix
2492
+ // https://github.com/catamphetamine/libphonenumber-js/issues/376
2493
+
2494
+ if (number[0] !== '+') {
2495
+ // Convert an "out-of-country" dialing phone number
2496
+ // to a proper international phone number.
2497
+ var numberWithoutIDD = stripIddPrefix(number, country, callingCode, metadata); // If an IDD prefix was stripped then
2498
+ // convert the number to international one
2499
+ // for subsequent parsing.
2500
+
2501
+ if (numberWithoutIDD && numberWithoutIDD !== number) {
2502
+ isNumberWithIddPrefix = true;
2503
+ number = '+' + numberWithoutIDD;
2504
+ } else {
2505
+ // Check to see if the number starts with the country calling code
2506
+ // for the default country. If so, we remove the country calling code,
2507
+ // and do some checks on the validity of the number before and after.
2508
+ // https://github.com/catamphetamine/libphonenumber-js/issues/376
2509
+ if (country || callingCode) {
2510
+ var _extractCountryCallin = extractCountryCallingCodeFromInternationalNumberWithoutPlusSign(number, country, callingCode, metadata),
2511
+ countryCallingCode = _extractCountryCallin.countryCallingCode,
2512
+ shorterNumber = _extractCountryCallin.number;
2513
+
2514
+ if (countryCallingCode) {
2515
+ return {
2516
+ countryCallingCodeSource: 'FROM_NUMBER_WITHOUT_PLUS_SIGN',
2517
+ countryCallingCode: countryCallingCode,
2518
+ number: shorterNumber
2519
+ };
2520
+ }
2521
+ }
2522
+
2523
+ return {
2524
+ // No need to set it to `UNSPECIFIED`. It can be just `undefined`.
2525
+ // countryCallingCodeSource: 'UNSPECIFIED',
2526
+ number: number
2527
+ };
2528
+ }
2529
+ } // Fast abortion: country codes do not begin with a '0'
2530
+
2531
+
2532
+ if (number[1] === '0') {
2533
+ return {};
2534
+ }
2535
+
2536
+ metadata = new Metadata(metadata); // The thing with country phone codes
2537
+ // is that they are orthogonal to each other
2538
+ // i.e. there's no such country phone code A
2539
+ // for which country phone code B exists
2540
+ // where B starts with A.
2541
+ // Therefore, while scanning digits,
2542
+ // if a valid country code is found,
2543
+ // that means that it is the country code.
2544
+ //
2545
+
2546
+ var i = 2;
2547
+
2548
+ while (i - 1 <= MAX_LENGTH_COUNTRY_CODE && i <= number.length) {
2549
+ var _countryCallingCode = number.slice(1, i);
112
2550
 
113
- const convertToValueFormat = (value) => {
114
- return { label: value, value };
115
- };
2551
+ if (metadata.hasCallingCode(_countryCallingCode)) {
2552
+ metadata.selectNumberingPlan(_countryCallingCode);
2553
+ return {
2554
+ countryCallingCodeSource: isNumberWithIddPrefix ? 'FROM_NUMBER_WITH_IDD' : 'FROM_NUMBER_WITH_PLUS_SIGN',
2555
+ countryCallingCode: _countryCallingCode,
2556
+ number: number.slice(i)
2557
+ };
2558
+ }
2559
+
2560
+ i++;
2561
+ }
2562
+
2563
+ return {};
2564
+ } // The possible values for the returned `countryCallingCodeSource` are:
2565
+ //
2566
+ // Copy-pasted from:
2567
+ // https://github.com/google/libphonenumber/blob/master/resources/phonenumber.proto
2568
+ //
2569
+ // // The source from which the country_code is derived. This is not set in the
2570
+ // // general parsing method, but in the method that parses and keeps raw_input.
2571
+ // // New fields could be added upon request.
2572
+ // enum CountryCodeSource {
2573
+ // // Default value returned if this is not set, because the phone number was
2574
+ // // created using parse, not parseAndKeepRawInput. hasCountryCodeSource will
2575
+ // // return false if this is the case.
2576
+ // UNSPECIFIED = 0;
2577
+ //
2578
+ // // The country_code is derived based on a phone number with a leading "+",
2579
+ // // e.g. the French number "+33 1 42 68 53 00".
2580
+ // FROM_NUMBER_WITH_PLUS_SIGN = 1;
2581
+ //
2582
+ // // The country_code is derived based on a phone number with a leading IDD,
2583
+ // // e.g. the French number "011 33 1 42 68 53 00", as it is dialled from US.
2584
+ // FROM_NUMBER_WITH_IDD = 5;
2585
+ //
2586
+ // // The country_code is derived based on a phone number without a leading
2587
+ // // "+", e.g. the French number "33 1 42 68 53 00" when defaultCountry is
2588
+ // // supplied as France.
2589
+ // FROM_NUMBER_WITHOUT_PLUS_SIGN = 10;
2590
+ //
2591
+ // // The country_code is derived NOT based on the phone number itself, but
2592
+ // // from the defaultCountry parameter provided in the parsing function by the
2593
+ // // clients. This happens mostly for numbers written in the national format
2594
+ // // (without country code). For example, this would be set when parsing the
2595
+ // // French number "01 42 68 53 00", when defaultCountry is supplied as
2596
+ // // France.
2597
+ // FROM_DEFAULT_COUNTRY = 20;
2598
+ // }
2599
+
2600
+ 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."); }
2601
+
2602
+ 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); }
2603
+
2604
+ 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; }
2605
+ function getCountryByNationalNumber(nationalPhoneNumber, _ref) {
2606
+ var countries = _ref.countries,
2607
+ defaultCountry = _ref.defaultCountry,
2608
+ metadata = _ref.metadata;
2609
+ // Re-create `metadata` because it will be selecting a `country`.
2610
+ metadata = new Metadata(metadata);
2611
+ var matchingCountries = [];
2612
+
2613
+ for (var _iterator = _createForOfIteratorHelperLoose(countries), _step; !(_step = _iterator()).done;) {
2614
+ var country = _step.value;
2615
+ metadata.country(country); // "Leading digits" patterns are only defined for about 20% of all countries.
2616
+ // By definition, matching "leading digits" is a sufficient but not a necessary
2617
+ // condition for a phone number to belong to a country.
2618
+ // The point of "leading digits" check is that it's the fastest one to get a match.
2619
+ // https://gitlab.com/catamphetamine/libphonenumber-js/blob/master/METADATA.md#leading_digits
2620
+ // I'd suppose that "leading digits" patterns are mutually exclusive for different countries
2621
+ // because of the intended use of that feature.
2622
+
2623
+ if (metadata.leadingDigits()) {
2624
+ if (nationalPhoneNumber && nationalPhoneNumber.search(metadata.leadingDigits()) === 0) {
2625
+ return country;
2626
+ }
2627
+ } // Else perform full validation with all of those
2628
+ // fixed-line/mobile/etc regular expressions.
2629
+ else if (getNumberType({
2630
+ phone: nationalPhoneNumber,
2631
+ country: country
2632
+ }, undefined, metadata.metadata)) {
2633
+ // If the `defaultCountry` is among the `matchingCountries` then return it.
2634
+ if (defaultCountry) {
2635
+ if (country === defaultCountry) {
2636
+ return country;
2637
+ }
2638
+
2639
+ matchingCountries.push(country);
2640
+ } else {
2641
+ return country;
2642
+ }
2643
+ }
2644
+ } // Return the first ("main") one of the `matchingCountries`.
2645
+
2646
+
2647
+ if (matchingCountries.length > 0) {
2648
+ return matchingCountries[0];
2649
+ }
2650
+ }
2651
+
2652
+ var USE_NON_GEOGRAPHIC_COUNTRY_CODE = false;
2653
+ function getCountryByCallingCode(callingCode, _ref) {
2654
+ var nationalPhoneNumber = _ref.nationalNumber,
2655
+ defaultCountry = _ref.defaultCountry,
2656
+ metadata = _ref.metadata;
2657
+
2658
+ /* istanbul ignore if */
2659
+ if (USE_NON_GEOGRAPHIC_COUNTRY_CODE) {
2660
+ if (metadata.isNonGeographicCallingCode(callingCode)) {
2661
+ return '001';
2662
+ }
2663
+ }
2664
+
2665
+ var possibleCountries = metadata.getCountryCodesForCallingCode(callingCode);
2666
+
2667
+ if (!possibleCountries) {
2668
+ return;
2669
+ } // If there's just one country corresponding to the country code,
2670
+ // then just return it, without further phone number digits validation.
2671
+
2672
+
2673
+ if (possibleCountries.length === 1) {
2674
+ return possibleCountries[0];
2675
+ }
2676
+
2677
+ return getCountryByNationalNumber(nationalPhoneNumber, {
2678
+ countries: possibleCountries,
2679
+ defaultCountry: defaultCountry,
2680
+ metadata: metadata.metadata
2681
+ });
2682
+ }
2683
+
2684
+ // When phone numbers are written in `RFC3966` format — `"tel:+12133734253"` —
2685
+ var PLUS_SIGN = '+';
2686
+ var RFC3966_VISUAL_SEPARATOR_ = '[\\-\\.\\(\\)]?';
2687
+ var RFC3966_PHONE_DIGIT_ = '(' + '[' + VALID_DIGITS + ']' + '|' + RFC3966_VISUAL_SEPARATOR_ + ')';
2688
+ var RFC3966_GLOBAL_NUMBER_DIGITS_ = '^' + '\\' + PLUS_SIGN + RFC3966_PHONE_DIGIT_ + '*' + '[' + VALID_DIGITS + ']' + RFC3966_PHONE_DIGIT_ + '*' + '$';
116
2689
  /**
117
- * A custom field that can be used to render a dropdown
118
- *
119
- * @param options DropdownCustomFieldProps - an object with all the props
120
- * @returns {JSX.Element} - a dropdown component
121
- */
122
- const DropdownCustomField = ({ defaultValue, dataTestId, onChange, onBlur, id, disabled = false, allValues, multiSelect = false, register, validationRules, setValue, label, tip, errorMessage, helpText, isInvalid, helpAddon, }) => {
123
- const renderAsInvalid = isInvalid || Boolean(errorMessage);
124
- const htmlForId = id ? id : "dropdown-custom-field-" + uuid.v4();
125
- const [selectedValue, setSelectedValue] = React__namespace.useState(defaultValue ? defaultValue.map(convertToValueFormat) : []);
126
- const onChangeHandler = React__namespace.useCallback((selected) => {
127
- if (selected) {
128
- const values = Array.isArray(selected) ? selected : [selected];
129
- setSelectedValue(values);
130
- setValue && setValue(id, values);
131
- }
132
- else {
133
- setSelectedValue([]);
134
- setValue && setValue(id, []);
135
- }
136
- }, [onChange]);
137
- const options = React__namespace.useMemo(() => {
138
- return allValues ? allValues.map(convertToValueFormat) : [];
139
- }, [allValues]);
140
- React__namespace.useEffect(() => {
141
- register && register(id, Object.assign(Object.assign({}, validationRules), { value: selectedValue }));
142
- }, [register, validationRules, selectedValue, id]);
143
- return (jsxRuntime.jsx(reactFormComponents.FormGroup, Object.assign({ htmlFor: htmlForId, label: label, tip: tip, isInvalid: renderAsInvalid, helpText: errorMessage || helpText, helpAddon: helpAddon || null, dataTestId: dataTestId && `${dataTestId}-FormGroup` }, { children: jsxRuntime.jsx(reactFormComponents.Select, { inputId: htmlForId, "aria-labelledby": htmlForId + "-label", disabled: disabled, dataTestId: dataTestId, onChange: onChangeHandler, hasError: renderAsInvalid, options: options, value: selectedValue, isMulti: multiSelect, isClearable: true }) })));
144
- };
2690
+ * Regular expression of valid global-number-digits for the phone-context
2691
+ * parameter, following the syntax defined in RFC3966.
2692
+ */
2693
+
2694
+ 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.
2695
+ // const ALPHANUM_ = VALID_ALPHA_ + VALID_DIGITS
145
2696
 
2697
+ var ALPHANUM_ = VALID_DIGITS;
2698
+ var RFC3966_DOMAINLABEL_ = '[' + ALPHANUM_ + ']+((\\-)*[' + ALPHANUM_ + '])*';
2699
+ var VALID_ALPHA_ = 'a-zA-Z';
2700
+ var RFC3966_TOPLABEL_ = '[' + VALID_ALPHA_ + ']+((\\-)*[' + ALPHANUM_ + '])*';
2701
+ var RFC3966_DOMAINNAME_ = '^(' + RFC3966_DOMAINLABEL_ + '\\.)*' + RFC3966_TOPLABEL_ + '\\.?$';
146
2702
  /**
147
- * Get validation rules for a field
148
- *
149
- * @param { WebAddressFieldDefinition } definition the field definition
150
- * @returns { ValidationRules} the validation rules
151
- */
152
- const getWebAddressValidationRules = (definition) => {
153
- const defaultRules = {};
154
- const pattern = {
155
- pattern: {
156
- value: RegExp("^(((https?|ftps?)://)(%[0-9A-Fa-f]{2}|[-()_.!~*';/?:@&=+$,A-Za-z0-9])+)([).!';/?:,][[:blank:|:blank:]])?$"),
157
- message: `Must match url pattern`,
158
- },
159
- };
160
- return definition.uiEditable
161
- ? Object.assign(Object.assign({}, pattern), defaultRules) : defaultRules;
162
- };
2703
+ * Regular expression of valid domainname for the phone-context parameter,
2704
+ * following the syntax defined in RFC3966.
2705
+ */
2706
+
2707
+ var RFC3966_DOMAINNAME_PATTERN_ = new RegExp(RFC3966_DOMAINNAME_, 'g');
2708
+ var RFC3966_PREFIX_ = 'tel:';
2709
+ var RFC3966_PHONE_CONTEXT_ = ';phone-context=';
2710
+ var RFC3966_ISDN_SUBADDRESS_ = ';isub=';
163
2711
  /**
164
- * Get validation rules for a field.
2712
+ * Extracts the value of the phone-context parameter of `numberToExtractFrom`,
2713
+ * following the syntax defined in RFC3966.
165
2714
  *
166
- * @param { NumberFieldDefinition } definition the field definition
167
- * @returns { ValidationRules} the validation rules
168
- */
169
- const getNumberValidationRules = (definition) => {
170
- const defaultRules = { valueAsNumber: true };
171
- const minimum = definition.minimumNumber && {
172
- min: {
173
- value: definition.minimumNumber,
174
- message: `minimum value is ${definition.minimumNumber}`,
175
- },
176
- };
177
- const maximum = definition.maximumNumber && {
178
- max: {
179
- value: definition.maximumNumber,
180
- message: `maximum value is ${definition.maximumNumber}`,
181
- },
182
- };
183
- // TODO: Validate if integer if definition requires integer
184
- return definition.uiEditable
185
- ? Object.assign(Object.assign(Object.assign({}, maximum), minimum), defaultRules) : defaultRules;
186
- };
2715
+ * @param {string} numberToExtractFrom
2716
+ * @return {string|null} the extracted string (possibly empty), or `null` if no phone-context parameter is found.
2717
+ */
2718
+
2719
+ function extractPhoneContext(numberToExtractFrom) {
2720
+ var indexOfPhoneContext = numberToExtractFrom.indexOf(RFC3966_PHONE_CONTEXT_); // If no phone-context parameter is present
2721
+
2722
+ if (indexOfPhoneContext < 0) {
2723
+ return null;
2724
+ }
2725
+
2726
+ var phoneContextStart = indexOfPhoneContext + RFC3966_PHONE_CONTEXT_.length; // If phone-context parameter is empty
2727
+
2728
+ if (phoneContextStart >= numberToExtractFrom.length) {
2729
+ return '';
2730
+ }
2731
+
2732
+ var phoneContextEnd = numberToExtractFrom.indexOf(';', phoneContextStart); // If phone-context is not the last parameter
2733
+
2734
+ if (phoneContextEnd >= 0) {
2735
+ return numberToExtractFrom.substring(phoneContextStart, phoneContextEnd);
2736
+ } else {
2737
+ return numberToExtractFrom.substring(phoneContextStart);
2738
+ }
2739
+ }
187
2740
  /**
188
- * Get validation rules for a string field.
2741
+ * Returns whether the value of phoneContext follows the syntax defined in RFC3966.
189
2742
  *
190
- * @param { StringFieldDefinition } definition the field definition
191
- * @returns { ValidationRules} the validation rules
192
- */
193
- const getStringValidationRules = (definition) => {
194
- const defaultRules = {};
195
- const minLength = definition.minimumLength
196
- ? {
197
- minLength: {
198
- value: definition.minimumLength,
199
- message: `minimum length is ${definition.minimumLength}`,
200
- },
201
- required: {
202
- value: true,
203
- message: `minimum length is ${definition.minimumLength}`,
204
- },
205
- }
206
- : undefined;
207
- const maxLength = definition.maximumLength
208
- ? {
209
- maxLength: {
210
- value: definition.maximumLength,
211
- message: `maximum length is ${definition.maximumLength}`,
212
- },
213
- }
214
- : undefined;
215
- const pattern = definition.pattern
216
- ? {
217
- pattern: {
218
- value: RegExp(definition.pattern),
219
- message: `Must match pattern: ${definition.pattern}`,
220
- },
221
- }
222
- : undefined;
223
- return definition.uiEditable
224
- ? Object.assign(Object.assign(Object.assign(Object.assign({}, maxLength), minLength), pattern), defaultRules) : defaultRules;
225
- };
2743
+ * @param {string|null} phoneContext
2744
+ * @return {boolean}
2745
+ */
2746
+
2747
+ function isPhoneContextValid(phoneContext) {
2748
+ if (phoneContext === null) {
2749
+ return true;
2750
+ }
2751
+
2752
+ if (phoneContext.length === 0) {
2753
+ return false;
2754
+ } // Does phone-context value match pattern of global-number-digits or domainname.
2755
+
2756
+
2757
+ return RFC3966_GLOBAL_NUMBER_DIGITS_PATTERN_.test(phoneContext) || RFC3966_DOMAINNAME_PATTERN_.test(phoneContext);
2758
+ }
2759
+
226
2760
  /**
227
- * Get validation rules for a boolean field.
228
- *
229
- * @param { BooleanFieldDefinition } definition the field definition
230
- * @returns { ValidationRules} the validation rules
231
- */
232
- const getBooleanValidationRules = (definition) => {
233
- const defaultRules = {};
234
- return defaultRules;
235
- };
2761
+ * @param {string} numberToParse
2762
+ * @param {string} nationalNumber
2763
+ * @return {}
2764
+ */
2765
+
2766
+ function extractFormattedPhoneNumberFromPossibleRfc3966NumberUri(numberToParse, _ref) {
2767
+ var extractFormattedPhoneNumber = _ref.extractFormattedPhoneNumber;
2768
+ var phoneContext = extractPhoneContext(numberToParse);
2769
+
2770
+ if (!isPhoneContextValid(phoneContext)) {
2771
+ throw new ParseError('NOT_A_NUMBER');
2772
+ }
2773
+
2774
+ var phoneNumberString;
2775
+
2776
+ if (phoneContext === null) {
2777
+ // Extract a possible number from the string passed in.
2778
+ // (this strips leading characters that could not be the start of a phone number)
2779
+ phoneNumberString = extractFormattedPhoneNumber(numberToParse) || '';
2780
+ } else {
2781
+ phoneNumberString = ''; // If the phone context contains a phone number prefix, we need to capture
2782
+ // it, whereas domains will be ignored.
2783
+
2784
+ if (phoneContext.charAt(0) === PLUS_SIGN) {
2785
+ phoneNumberString += phoneContext;
2786
+ } // Now append everything between the "tel:" prefix and the phone-context.
2787
+ // This should include the national number, an optional extension or
2788
+ // isdn-subaddress component. Note we also handle the case when "tel:" is
2789
+ // missing, as we have seen in some of the phone number inputs.
2790
+ // In that case, we append everything from the beginning.
2791
+
2792
+
2793
+ var indexOfRfc3966Prefix = numberToParse.indexOf(RFC3966_PREFIX_);
2794
+ var indexOfNationalNumber; // RFC 3966 "tel:" prefix is preset at this stage because
2795
+ // `isPhoneContextValid()` requires it to be present.
2796
+
2797
+ /* istanbul ignore else */
2798
+
2799
+ if (indexOfRfc3966Prefix >= 0) {
2800
+ indexOfNationalNumber = indexOfRfc3966Prefix + RFC3966_PREFIX_.length;
2801
+ } else {
2802
+ indexOfNationalNumber = 0;
2803
+ }
2804
+
2805
+ var indexOfPhoneContext = numberToParse.indexOf(RFC3966_PHONE_CONTEXT_);
2806
+ phoneNumberString += numberToParse.substring(indexOfNationalNumber, indexOfPhoneContext);
2807
+ } // Delete the isdn-subaddress and everything after it if it is present.
2808
+ // Note extension won't appear at the same time with isdn-subaddress
2809
+ // according to paragraph 5.3 of the RFC3966 spec.
2810
+
2811
+
2812
+ var indexOfIsdn = phoneNumberString.indexOf(RFC3966_ISDN_SUBADDRESS_);
2813
+
2814
+ if (indexOfIsdn > 0) {
2815
+ phoneNumberString = phoneNumberString.substring(0, indexOfIsdn);
2816
+ } // If both phone context and isdn-subaddress are absent but other
2817
+ // parameters are present, the parameters are left in nationalNumber.
2818
+ // This is because we are concerned about deleting content from a potential
2819
+ // number string when there is no strong evidence that the number is
2820
+ // actually written in RFC3966.
2821
+
2822
+
2823
+ if (phoneNumberString !== '') {
2824
+ return phoneNumberString;
2825
+ }
2826
+ }
2827
+
2828
+ // This is a port of Google Android `libphonenumber`'s
2829
+ // This prevents malicious input from consuming CPU.
2830
+
2831
+ var MAX_INPUT_STRING_LENGTH = 250; // This consists of the plus symbol, digits, and arabic-indic digits.
2832
+
2833
+ var PHONE_NUMBER_START_PATTERN = new RegExp('[' + PLUS_CHARS + VALID_DIGITS + ']'); // Regular expression of trailing characters that we want to remove.
2834
+ // A trailing `#` is sometimes used when writing phone numbers with extensions in US.
2835
+ // Example: "+1 (645) 123 1234-910#" number has extension "910".
2836
+
2837
+ var AFTER_PHONE_NUMBER_END_PATTERN = new RegExp('[^' + VALID_DIGITS + '#' + ']+$');
2838
+ //
2839
+ // ```js
2840
+ // parse('8 (800) 555-35-35', 'RU')
2841
+ // parse('8 (800) 555-35-35', 'RU', metadata)
2842
+ // parse('8 (800) 555-35-35', { country: { default: 'RU' } })
2843
+ // parse('8 (800) 555-35-35', { country: { default: 'RU' } }, metadata)
2844
+ // parse('+7 800 555 35 35')
2845
+ // parse('+7 800 555 35 35', metadata)
2846
+ // ```
2847
+ //
2848
+
236
2849
  /**
237
- * Get validation rules for a dropdown field.
2850
+ * Parses a phone number.
238
2851
  *
239
- * @param { DropDownFieldDefinition } definition the field definition
240
- * @returns { ValidationRules} the validation rules
241
- */
242
- const getDropdownValidationRules = (definition) => {
243
- const defaultRules = {};
244
- return defaultRules;
245
- };
246
- /**
247
- * Get validation rules for a date field.
2852
+ * parse('123456789', { defaultCountry: 'RU', v2: true }, metadata)
2853
+ * parse('123456789', { defaultCountry: 'RU' }, metadata)
2854
+ * parse('123456789', undefined, metadata)
248
2855
  *
249
- * @param { DateFieldDefinition } definition the field definition
250
- * @returns { ValidationRules} the validation rules
251
- */
252
- const getDateValidationRules = (definition) => {
253
- const defaultRules = {};
254
- return defaultRules;
255
- };
2856
+ * @param {string} input
2857
+ * @param {object} [options]
2858
+ * @param {object} metadata
2859
+ * @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).
2860
+ */
2861
+
2862
+ function parse(text, options, metadata) {
2863
+ // If assigning the `{}` default value is moved to the arguments above,
2864
+ // code coverage would decrease for some weird reason.
2865
+ options = options || {};
2866
+ metadata = new Metadata(metadata); // Validate `defaultCountry`.
2867
+
2868
+ if (options.defaultCountry && !metadata.hasCountry(options.defaultCountry)) {
2869
+ if (options.v2) {
2870
+ throw new ParseError('INVALID_COUNTRY');
2871
+ }
2872
+
2873
+ throw new Error("Unknown country: ".concat(options.defaultCountry));
2874
+ } // Parse the phone number.
2875
+
2876
+
2877
+ var _parseInput = parseInput(text, options.v2, options.extract),
2878
+ formattedPhoneNumber = _parseInput.number,
2879
+ ext = _parseInput.ext,
2880
+ error = _parseInput.error; // If the phone number is not viable then return nothing.
2881
+
2882
+
2883
+ if (!formattedPhoneNumber) {
2884
+ if (options.v2) {
2885
+ if (error === 'TOO_SHORT') {
2886
+ throw new ParseError('TOO_SHORT');
2887
+ }
2888
+
2889
+ throw new ParseError('NOT_A_NUMBER');
2890
+ }
2891
+
2892
+ return {};
2893
+ }
2894
+
2895
+ var _parsePhoneNumber = parsePhoneNumber$1(formattedPhoneNumber, options.defaultCountry, options.defaultCallingCode, metadata),
2896
+ country = _parsePhoneNumber.country,
2897
+ nationalNumber = _parsePhoneNumber.nationalNumber,
2898
+ countryCallingCode = _parsePhoneNumber.countryCallingCode,
2899
+ countryCallingCodeSource = _parsePhoneNumber.countryCallingCodeSource,
2900
+ carrierCode = _parsePhoneNumber.carrierCode;
2901
+
2902
+ if (!metadata.hasSelectedNumberingPlan()) {
2903
+ if (options.v2) {
2904
+ throw new ParseError('INVALID_COUNTRY');
2905
+ }
2906
+
2907
+ return {};
2908
+ } // Validate national (significant) number length.
2909
+
2910
+
2911
+ if (!nationalNumber || nationalNumber.length < MIN_LENGTH_FOR_NSN) {
2912
+ // Won't throw here because the regexp already demands length > 1.
2913
+
2914
+ /* istanbul ignore if */
2915
+ if (options.v2) {
2916
+ throw new ParseError('TOO_SHORT');
2917
+ } // Google's demo just throws an error in this case.
2918
+
2919
+
2920
+ return {};
2921
+ } // Validate national (significant) number length.
2922
+ //
2923
+ // A sidenote:
2924
+ //
2925
+ // They say that sometimes national (significant) numbers
2926
+ // can be longer than `MAX_LENGTH_FOR_NSN` (e.g. in Germany).
2927
+ // https://github.com/googlei18n/libphonenumber/blob/7e1748645552da39c4e1ba731e47969d97bdb539/resources/phonenumber.proto#L36
2928
+ // Such numbers will just be discarded.
2929
+ //
2930
+
2931
+
2932
+ if (nationalNumber.length > MAX_LENGTH_FOR_NSN) {
2933
+ if (options.v2) {
2934
+ throw new ParseError('TOO_LONG');
2935
+ } // Google's demo just throws an error in this case.
2936
+
2937
+
2938
+ return {};
2939
+ }
2940
+
2941
+ if (options.v2) {
2942
+ var phoneNumber = new PhoneNumber(countryCallingCode, nationalNumber, metadata.metadata);
2943
+
2944
+ if (country) {
2945
+ phoneNumber.country = country;
2946
+ }
2947
+
2948
+ if (carrierCode) {
2949
+ phoneNumber.carrierCode = carrierCode;
2950
+ }
2951
+
2952
+ if (ext) {
2953
+ phoneNumber.ext = ext;
2954
+ }
2955
+
2956
+ phoneNumber.__countryCallingCodeSource = countryCallingCodeSource;
2957
+ return phoneNumber;
2958
+ } // Check if national phone number pattern matches the number.
2959
+ // National number pattern is different for each country,
2960
+ // even for those ones which are part of the "NANPA" group.
2961
+
2962
+
2963
+ var valid = (options.extended ? metadata.hasSelectedNumberingPlan() : country) ? matchesEntirely(nationalNumber, metadata.nationalNumberPattern()) : false;
2964
+
2965
+ if (!options.extended) {
2966
+ return valid ? result(country, nationalNumber, ext) : {};
2967
+ } // isInternational: countryCallingCode !== undefined
2968
+
2969
+
2970
+ return {
2971
+ country: country,
2972
+ countryCallingCode: countryCallingCode,
2973
+ carrierCode: carrierCode,
2974
+ valid: valid,
2975
+ possible: valid ? true : options.extended === true && metadata.possibleLengths() && isPossibleNumber(nationalNumber, metadata) ? true : false,
2976
+ phone: nationalNumber,
2977
+ ext: ext
2978
+ };
2979
+ }
256
2980
  /**
257
- * Get validation rules for an email field.
258
- *
259
- * @param { EmailFieldDefinition } definition the field definition
260
- * @returns { ValidationRules} the validation rules
261
- */
262
- const getEmailValidationRules = (definition) => {
263
- const defaultRules = {};
264
- const pattern = {
265
- pattern: {
266
- value: RegExp("^[a-zA-Z0-9_+&*-]+(?:.[a-zA-Z0-9_+&*-]+)*@(?:[a-zA-Z0-9-]+.)+[a-zA-Z]{2,7}$"),
267
- message: `Must match email pattern`,
268
- },
269
- };
270
- return definition.uiEditable
271
- ? Object.assign(Object.assign({}, pattern), defaultRules) : defaultRules;
272
- };
2981
+ * Extracts a formatted phone number from text.
2982
+ * Doesn't guarantee that the extracted phone number
2983
+ * is a valid phone number (for example, doesn't validate its length).
2984
+ * @param {string} text
2985
+ * @param {boolean} [extract] — If `false`, then will parse the entire `text` as a phone number.
2986
+ * @param {boolean} [throwOnError] By default, it won't throw if the text is too long.
2987
+ * @return {string}
2988
+ * @example
2989
+ * // Returns "(213) 373-4253".
2990
+ * extractFormattedPhoneNumber("Call (213) 373-4253 for assistance.")
2991
+ */
2992
+
2993
+ function _extractFormattedPhoneNumber(text, extract, throwOnError) {
2994
+ if (!text) {
2995
+ return;
2996
+ }
2997
+
2998
+ if (text.length > MAX_INPUT_STRING_LENGTH) {
2999
+ if (throwOnError) {
3000
+ throw new ParseError('TOO_LONG');
3001
+ }
3002
+
3003
+ return;
3004
+ }
3005
+
3006
+ if (extract === false) {
3007
+ return text;
3008
+ } // Attempt to extract a possible number from the string passed in
3009
+
3010
+
3011
+ var startsAt = text.search(PHONE_NUMBER_START_PATTERN);
3012
+
3013
+ if (startsAt < 0) {
3014
+ return;
3015
+ }
3016
+
3017
+ return text // Trim everything to the left of the phone number
3018
+ .slice(startsAt) // Remove trailing non-numerical characters
3019
+ .replace(AFTER_PHONE_NUMBER_END_PATTERN, '');
3020
+ }
273
3021
  /**
274
- * Get validation rules for a phonenumber field.
275
- *
276
- * @param { PhoneNumberFieldDefinition } definition the field definition
277
- * @returns { ValidationRules} the validation rules
278
- */
279
- const getPhoneNumberValidationRules = (definition) => {
280
- const defaultRules = {};
281
- const pattern = {
282
- validate: value => libphonenumberJs.isValidPhoneNumber(value) || value === "",
283
- };
284
- return definition.uiEditable
285
- ? Object.assign(Object.assign({}, pattern), defaultRules) : defaultRules;
286
- };
3022
+ * @param {string} text - Input.
3023
+ * @param {boolean} v2 - Legacy API functions don't pass `v2: true` flag.
3024
+ * @param {boolean} [extract] - Whether to extract a phone number from `text`, or attempt to parse the entire text as a phone number.
3025
+ * @return {object} `{ ?number, ?ext }`.
3026
+ */
3027
+
3028
+
3029
+ function parseInput(text, v2, extract) {
3030
+ // // Parse RFC 3966 phone number URI.
3031
+ // if (text && text.indexOf('tel:') === 0) {
3032
+ // return parseRFC3966(text)
3033
+ // }
3034
+ // let number = extractFormattedPhoneNumber(text, extract, v2)
3035
+ var number = extractFormattedPhoneNumberFromPossibleRfc3966NumberUri(text, {
3036
+ extractFormattedPhoneNumber: function extractFormattedPhoneNumber(text) {
3037
+ return _extractFormattedPhoneNumber(text, extract, v2);
3038
+ }
3039
+ }); // If the phone number is not viable, then abort.
3040
+
3041
+ if (!number) {
3042
+ return {};
3043
+ }
3044
+
3045
+ if (!isViablePhoneNumber(number)) {
3046
+ if (isViablePhoneNumberStart(number)) {
3047
+ return {
3048
+ error: 'TOO_SHORT'
3049
+ };
3050
+ }
3051
+
3052
+ return {};
3053
+ } // Attempt to parse extension first, since it doesn't require region-specific
3054
+ // data and we want to have the non-normalised number here.
287
3055
 
3056
+
3057
+ var withExtensionStripped = extractExtension(number);
3058
+
3059
+ if (withExtensionStripped.ext) {
3060
+ return withExtensionStripped;
3061
+ }
3062
+
3063
+ return {
3064
+ number: number
3065
+ };
3066
+ }
288
3067
  /**
289
- * A component that renders a custom field based on the field definition
290
- *
291
- * @param field A field definition and value
292
- * @param validation A validation object that contains the register, setValue and formState
293
- * @param unitPreference A unit preference that can be used to override the default unit preference
294
- * @param fieldId An optional Id to override the definition.key
295
- * @returns { JSX.Element } A JSX.Element or null if the field definition is undefined
296
- */
297
- const useCustomFieldResolver = (field, validation, unitPreference = "SI", fieldId) => {
298
- 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;
299
- const [isEditing, setIsEditing] = React.useState(false);
300
- const [numberValue, setNumberValue] = React.useState(() => {
301
- var _a;
302
- if ((field === null || field === void 0 ? void 0 : field.definition) && field.definition.type === irisAppRuntimeCoreApi.CustomFieldType.NUMBER) {
303
- const typedValue = field.value;
304
- return (_a = typedValue.numberValue) !== null && _a !== void 0 ? _a : field.definition.defaultNumberValue;
305
- }
306
- else {
307
- return "";
308
- }
309
- });
310
- 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) {
311
- return null;
312
- }
313
- const key = (_b = fieldId !== null && fieldId !== void 0 ? fieldId : field.definition.key) !== null && _b !== void 0 ? _b : "";
314
- const fieldError = key ? validation.formState.errors[key] : undefined;
315
- const errorMessage = fieldError ? fieldError.message + "" : undefined;
316
- const { type, description, title } = field.definition;
317
- switch (type) {
318
- case irisAppRuntimeCoreApi.CustomFieldType.WEB_ADDRESS: {
319
- const typedDefinition = field.definition;
320
- const typedValue = field.value;
321
- const rules = getWebAddressValidationRules(typedDefinition);
322
- return (jsxRuntime.jsx(reactFormComponents.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 &&
323
- (typedValue.stringValue || typedDefinition.defaultStringValue) && (jsxRuntime.jsx(reactFormComponents.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))));
324
- }
325
- case irisAppRuntimeCoreApi.CustomFieldType.EMAIL: {
326
- const typedDefinition = field.definition;
327
- const typedValue = field.value;
328
- const rules = getEmailValidationRules(typedDefinition);
329
- return (jsxRuntime.jsx(reactFormComponents.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 &&
330
- (typedValue.stringValue || typedDefinition.defaultStringValue) && (jsxRuntime.jsx(reactFormComponents.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))));
331
- }
332
- case irisAppRuntimeCoreApi.CustomFieldType.PHONE_NUMBER: {
333
- const typedDefinition = field.definition;
334
- const typedValue = field.value;
335
- const rules = getPhoneNumberValidationRules(typedDefinition);
336
- return (jsxRuntime.jsx(reactFormComponents.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 &&
337
- (typedValue.stringValue || typedDefinition.defaultStringValue) && (jsxRuntime.jsx(reactFormComponents.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))));
338
- }
339
- case irisAppRuntimeCoreApi.CustomFieldType.STRING: {
340
- const typedDefinition = field.definition;
341
- const typedValue = field.value;
342
- const rules = getStringValidationRules(typedDefinition);
343
- return (jsxRuntime.jsx(reactFormComponents.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))));
344
- }
345
- case irisAppRuntimeCoreApi.CustomFieldType.NUMBER: {
346
- const typedDefinition = field.definition;
347
- const typedValue = field.value;
348
- const rules = getNumberValidationRules(typedDefinition);
349
- const unit = unitPreference === "US_CUSTOMARY" ? typedDefinition.unitUs : typedDefinition.unitSi;
350
- const numberProps = {
351
- placeholder: (_t = typedDefinition.title) !== null && _t !== void 0 ? _t : "",
352
- addonAfter: unit,
353
- };
354
- return (jsxRuntime.jsx(reactFormComponents.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 ? (jsxRuntime.jsx(reactFormComponents.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 => {
355
- setNumberValue(e.target.value);
356
- validation.register(key, rules).onChange(e);
357
- } }, numberProps))) : (jsxRuntime.jsx(reactFormComponents.BaseInput, Object.assign({ type: "text", id: `${key}-number-field`, dataTestId: `${typedDefinition.key}`, defaultValue: parseFloat(Number(numberValue).toPrecision(4)), readOnly: true, actions: jsxRuntime.jsx(ActionContainer, { children: jsxRuntime.jsx(StyledIconButton, { dataTestId: `${typedDefinition.key}-editIconButtonId`, size: "small", color: "tertiary", icon: jsxRuntime.jsx(reactComponents.Icon, { size: "small", name: "PencilIcon" }), onClick: () => setIsEditing(!isEditing) }) }) }, numberProps))) })));
358
- }
359
- case irisAppRuntimeCoreApi.CustomFieldType.BOOLEAN: {
360
- const typedDefinition = field.definition;
361
- const typedValue = field.value;
362
- const rules = getBooleanValidationRules();
363
- return (jsxRuntime.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));
364
- }
365
- case irisAppRuntimeCoreApi.CustomFieldType.DROPDOWN: {
366
- const typedDefinition = field.definition;
367
- const typedValue = field.value;
368
- const rules = getDropdownValidationRules();
369
- return (jsxRuntime.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));
370
- }
371
- case irisAppRuntimeCoreApi.CustomFieldType.DATE: {
372
- const typedDefinition = field.definition;
373
- const typedValue = field.value;
374
- const rules = getDateValidationRules();
375
- let defaultValue;
376
- if (typedValue.dateValue !== undefined && typedValue.dateValue !== null) {
377
- defaultValue = new Date(typedValue.dateValue);
378
- }
379
- else if (typedDefinition.defaultDateValue !== undefined && typedDefinition.defaultDateValue !== null) {
380
- defaultValue = new Date(typedDefinition.defaultDateValue);
381
- }
382
- return (jsxRuntime.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));
383
- }
384
- default:
385
- throw new Error(`Type not supported: ${type}`);
386
- }
387
- };
3068
+ * Creates `parse()` result object.
3069
+ */
3070
+
3071
+
3072
+ function result(country, nationalNumber, ext) {
3073
+ var result = {
3074
+ country: country,
3075
+ phone: nationalNumber
3076
+ };
3077
+
3078
+ if (ext) {
3079
+ result.ext = ext;
3080
+ }
3081
+
3082
+ return result;
3083
+ }
388
3084
  /**
389
- *
390
- */
391
- const CustomField = ({ field, register, formState, setValue, unitPreference, fieldId }) => {
392
- const fieldComponent = useCustomFieldResolver(field, { register, setValue, formState }, unitPreference, fieldId);
393
- return fieldComponent;
394
- };
3085
+ * Parses a viable phone number.
3086
+ * @param {string} formattedPhoneNumber — Example: "(213) 373-4253".
3087
+ * @param {string} [defaultCountry]
3088
+ * @param {string} [defaultCallingCode]
3089
+ * @param {Metadata} metadata
3090
+ * @return {object} Returns `{ country: string?, countryCallingCode: string?, nationalNumber: string? }`.
3091
+ */
3092
+
3093
+
3094
+ function parsePhoneNumber$1(formattedPhoneNumber, defaultCountry, defaultCallingCode, metadata) {
3095
+ // Extract calling code from phone number.
3096
+ var _extractCountryCallin = extractCountryCallingCode(parseIncompletePhoneNumber(formattedPhoneNumber), defaultCountry, defaultCallingCode, metadata.metadata),
3097
+ countryCallingCodeSource = _extractCountryCallin.countryCallingCodeSource,
3098
+ countryCallingCode = _extractCountryCallin.countryCallingCode,
3099
+ number = _extractCountryCallin.number; // Choose a country by `countryCallingCode`.
3100
+
3101
+
3102
+ var country;
3103
+
3104
+ if (countryCallingCode) {
3105
+ metadata.selectNumberingPlan(countryCallingCode);
3106
+ } // If `formattedPhoneNumber` is passed in "national" format
3107
+ // then `number` is defined and `countryCallingCode` is `undefined`.
3108
+ else if (number && (defaultCountry || defaultCallingCode)) {
3109
+ metadata.selectNumberingPlan(defaultCountry, defaultCallingCode);
3110
+
3111
+ if (defaultCountry) {
3112
+ country = defaultCountry;
3113
+ }
3114
+
3115
+ countryCallingCode = defaultCallingCode || getCountryCallingCode(defaultCountry, metadata.metadata);
3116
+ } else return {};
3117
+
3118
+ if (!number) {
3119
+ return {
3120
+ countryCallingCodeSource: countryCallingCodeSource,
3121
+ countryCallingCode: countryCallingCode
3122
+ };
3123
+ }
3124
+
3125
+ var _extractNationalNumbe = extractNationalNumber(parseIncompletePhoneNumber(number), metadata),
3126
+ nationalNumber = _extractNationalNumbe.nationalNumber,
3127
+ carrierCode = _extractNationalNumbe.carrierCode; // Sometimes there are several countries
3128
+ // corresponding to the same country phone code
3129
+ // (e.g. NANPA countries all having `1` country phone code).
3130
+ // Therefore, to reliably determine the exact country,
3131
+ // national (significant) number should have been parsed first.
3132
+ //
3133
+ // When `metadata.json` is generated, all "ambiguous" country phone codes
3134
+ // get their countries populated with the full set of
3135
+ // "phone number type" regular expressions.
3136
+ //
3137
+
3138
+
3139
+ var exactCountry = getCountryByCallingCode(countryCallingCode, {
3140
+ nationalNumber: nationalNumber,
3141
+ defaultCountry: defaultCountry,
3142
+ metadata: metadata
3143
+ });
3144
+
3145
+ if (exactCountry) {
3146
+ country = exactCountry;
3147
+ /* istanbul ignore if */
3148
+
3149
+ if (exactCountry === '001') ; else {
3150
+ metadata.country(country);
3151
+ }
3152
+ }
3153
+
3154
+ return {
3155
+ country: country,
3156
+ countryCallingCode: countryCallingCode,
3157
+ countryCallingCodeSource: countryCallingCodeSource,
3158
+ nationalNumber: nationalNumber,
3159
+ carrierCode: carrierCode
3160
+ };
3161
+ }
3162
+
3163
+ 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; }
3164
+
3165
+ 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; }
3166
+
3167
+ 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; }
3168
+ function parsePhoneNumberWithError(text, options, metadata) {
3169
+ return parse(text, _objectSpread$3(_objectSpread$3({}, options), {}, {
3170
+ v2: true
3171
+ }), metadata);
3172
+ }
3173
+
3174
+ 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); }
3175
+
3176
+ 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; }
3177
+
3178
+ 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; }
3179
+
3180
+ 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; }
3181
+
3182
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
3183
+
3184
+ 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."); }
3185
+
3186
+ 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); }
3187
+
3188
+ 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; }
3189
+
3190
+ 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; }
3191
+
3192
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
3193
+
3194
+ // Extracts the following properties from function arguments:
3195
+ // * input `text`
3196
+ // * `options` object
3197
+ // * `metadata` JSON
3198
+ function normalizeArguments(args) {
3199
+ var _Array$prototype$slic = Array.prototype.slice.call(args),
3200
+ _Array$prototype$slic2 = _slicedToArray(_Array$prototype$slic, 4),
3201
+ arg_1 = _Array$prototype$slic2[0],
3202
+ arg_2 = _Array$prototype$slic2[1],
3203
+ arg_3 = _Array$prototype$slic2[2],
3204
+ arg_4 = _Array$prototype$slic2[3];
3205
+
3206
+ var text;
3207
+ var options;
3208
+ var metadata; // If the phone number is passed as a string.
3209
+ // `parsePhoneNumber('88005553535', ...)`.
3210
+
3211
+ if (typeof arg_1 === 'string') {
3212
+ text = arg_1;
3213
+ } else throw new TypeError('A text for parsing must be a string.'); // If "default country" argument is being passed then move it to `options`.
3214
+ // `parsePhoneNumber('88005553535', 'RU', [options], metadata)`.
3215
+
3216
+
3217
+ if (!arg_2 || typeof arg_2 === 'string') {
3218
+ if (arg_4) {
3219
+ options = arg_3;
3220
+ metadata = arg_4;
3221
+ } else {
3222
+ options = undefined;
3223
+ metadata = arg_3;
3224
+ }
3225
+
3226
+ if (arg_2) {
3227
+ options = _objectSpread$2({
3228
+ defaultCountry: arg_2
3229
+ }, options);
3230
+ }
3231
+ } // `defaultCountry` is not passed.
3232
+ // Example: `parsePhoneNumber('+78005553535', [options], metadata)`.
3233
+ else if (isObject(arg_2)) {
3234
+ if (arg_3) {
3235
+ options = arg_2;
3236
+ metadata = arg_3;
3237
+ } else {
3238
+ metadata = arg_2;
3239
+ }
3240
+ } else throw new Error("Invalid second argument: ".concat(arg_2));
3241
+
3242
+ return {
3243
+ text: text,
3244
+ options: options,
3245
+ metadata: metadata
3246
+ };
3247
+ } // Otherwise istanbul would show this as "branch not covered".
3248
+
3249
+ /* istanbul ignore next */
3250
+
3251
+ var isObject = function isObject(_) {
3252
+ return _typeof(_) === 'object';
3253
+ };
3254
+
3255
+ 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; }
3256
+
3257
+ 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; }
3258
+
3259
+ 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; }
3260
+ function parsePhoneNumber(text, options, metadata) {
3261
+ // Validate `defaultCountry`.
3262
+ if (options && options.defaultCountry && !isSupportedCountry(options.defaultCountry, metadata)) {
3263
+ options = _objectSpread$1(_objectSpread$1({}, options), {}, {
3264
+ defaultCountry: undefined
3265
+ });
3266
+ } // Parse phone number.
3267
+
3268
+
3269
+ try {
3270
+ return parsePhoneNumberWithError(text, options, metadata);
3271
+ } catch (error) {
3272
+ /* istanbul ignore else */
3273
+ if (error instanceof ParseError) ; else {
3274
+ throw error;
3275
+ }
3276
+ }
3277
+ }
3278
+
3279
+ 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; }
3280
+
3281
+ 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; }
3282
+
3283
+ 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; }
3284
+ function isValidPhoneNumber$1() {
3285
+ var _normalizeArguments = normalizeArguments(arguments),
3286
+ text = _normalizeArguments.text,
3287
+ options = _normalizeArguments.options,
3288
+ metadata = _normalizeArguments.metadata;
3289
+
3290
+ options = _objectSpread(_objectSpread({}, options), {}, {
3291
+ extract: false
3292
+ });
3293
+ var phoneNumber = parsePhoneNumber(text, options, metadata);
3294
+ return phoneNumber && phoneNumber.isValid() || false;
3295
+ }
3296
+
3297
+ function isValidPhoneNumber() {
3298
+ return withMetadataArgument(isValidPhoneNumber$1, arguments)
3299
+ }
3300
+
3301
+ /**
3302
+ * Get validation rules for a field
3303
+ *
3304
+ * @param { WebAddressFieldDefinition } definition the field definition
3305
+ * @returns { ValidationRules} the validation rules
3306
+ */
3307
+ const getWebAddressValidationRules = (definition) => {
3308
+ const defaultRules = {};
3309
+ const pattern = {
3310
+ pattern: {
3311
+ value: RegExp("^(((https?|ftps?)://)(%[0-9A-Fa-f]{2}|[-()_.!~*';/?:@&=+$,A-Za-z0-9])+)([).!';/?:,][[:blank:|:blank:]])?$"),
3312
+ message: `Must match url pattern`,
3313
+ },
3314
+ };
3315
+ return definition.uiEditable
3316
+ ? Object.assign(Object.assign({}, pattern), defaultRules) : defaultRules;
3317
+ };
3318
+ /**
3319
+ * Get validation rules for a field.
3320
+ *
3321
+ * @param { NumberFieldDefinition } definition the field definition
3322
+ * @returns { ValidationRules} the validation rules
3323
+ */
3324
+ const getNumberValidationRules = (definition) => {
3325
+ const defaultRules = { valueAsNumber: true };
3326
+ const minimum = definition.minimumNumber && {
3327
+ min: {
3328
+ value: definition.minimumNumber,
3329
+ message: `minimum value is ${definition.minimumNumber}`,
3330
+ },
3331
+ };
3332
+ const maximum = definition.maximumNumber && {
3333
+ max: {
3334
+ value: definition.maximumNumber,
3335
+ message: `maximum value is ${definition.maximumNumber}`,
3336
+ },
3337
+ };
3338
+ // TODO: Validate if integer if definition requires integer
3339
+ return definition.uiEditable
3340
+ ? Object.assign(Object.assign(Object.assign({}, maximum), minimum), defaultRules) : defaultRules;
3341
+ };
3342
+ /**
3343
+ * Get validation rules for a string field.
3344
+ *
3345
+ * @param { StringFieldDefinition } definition the field definition
3346
+ * @returns { ValidationRules} the validation rules
3347
+ */
3348
+ const getStringValidationRules = (definition) => {
3349
+ const defaultRules = {};
3350
+ const minLength = definition.minimumLength
3351
+ ? {
3352
+ minLength: {
3353
+ value: definition.minimumLength,
3354
+ message: `minimum length is ${definition.minimumLength}`,
3355
+ },
3356
+ required: {
3357
+ value: true,
3358
+ message: `minimum length is ${definition.minimumLength}`,
3359
+ },
3360
+ }
3361
+ : undefined;
3362
+ const maxLength = definition.maximumLength
3363
+ ? {
3364
+ maxLength: {
3365
+ value: definition.maximumLength,
3366
+ message: `maximum length is ${definition.maximumLength}`,
3367
+ },
3368
+ }
3369
+ : undefined;
3370
+ const pattern = definition.pattern
3371
+ ? {
3372
+ pattern: {
3373
+ value: RegExp(definition.pattern),
3374
+ message: `Must match pattern: ${definition.pattern}`,
3375
+ },
3376
+ }
3377
+ : undefined;
3378
+ return definition.uiEditable
3379
+ ? Object.assign(Object.assign(Object.assign(Object.assign({}, maxLength), minLength), pattern), defaultRules) : defaultRules;
3380
+ };
3381
+ /**
3382
+ * Get validation rules for a boolean field.
3383
+ *
3384
+ * @param { BooleanFieldDefinition } definition the field definition
3385
+ * @returns { ValidationRules} the validation rules
3386
+ */
3387
+ const getBooleanValidationRules = (definition) => {
3388
+ const defaultRules = {};
3389
+ return defaultRules;
3390
+ };
3391
+ /**
3392
+ * Get validation rules for a dropdown field.
3393
+ *
3394
+ * @param { DropDownFieldDefinition } definition the field definition
3395
+ * @returns { ValidationRules} the validation rules
3396
+ */
3397
+ const getDropdownValidationRules = (definition) => {
3398
+ const defaultRules = {};
3399
+ return defaultRules;
3400
+ };
3401
+ /**
3402
+ * Get validation rules for a date field.
3403
+ *
3404
+ * @param { DateFieldDefinition } definition the field definition
3405
+ * @returns { ValidationRules} the validation rules
3406
+ */
3407
+ const getDateValidationRules = (definition) => {
3408
+ const defaultRules = {};
3409
+ return defaultRules;
3410
+ };
3411
+ /**
3412
+ * Get validation rules for an email field.
3413
+ *
3414
+ * @param { EmailFieldDefinition } definition the field definition
3415
+ * @returns { ValidationRules} the validation rules
3416
+ */
3417
+ const getEmailValidationRules = (definition) => {
3418
+ const defaultRules = {};
3419
+ const pattern = {
3420
+ pattern: {
3421
+ value: RegExp("^[a-zA-Z0-9_+&*-]+(?:.[a-zA-Z0-9_+&*-]+)*@(?:[a-zA-Z0-9-]+.)+[a-zA-Z]{2,7}$"),
3422
+ message: `Must match email pattern`,
3423
+ },
3424
+ };
3425
+ return definition.uiEditable
3426
+ ? Object.assign(Object.assign({}, pattern), defaultRules) : defaultRules;
3427
+ };
3428
+ /**
3429
+ * Get validation rules for a phonenumber field.
3430
+ *
3431
+ * @param { PhoneNumberFieldDefinition } definition the field definition
3432
+ * @returns { ValidationRules} the validation rules
3433
+ */
3434
+ const getPhoneNumberValidationRules = (definition) => {
3435
+ const defaultRules = {};
3436
+ const pattern = {
3437
+ validate: value => isValidPhoneNumber(value) || value === "",
3438
+ };
3439
+ return definition.uiEditable
3440
+ ? Object.assign(Object.assign({}, pattern), defaultRules) : defaultRules;
3441
+ };
3442
+
3443
+ /**
3444
+ * A component that renders a custom field based on the field definition
3445
+ *
3446
+ * @param field A field definition and value
3447
+ * @param validation A validation object that contains the register, setValue and formState
3448
+ * @param unitPreference A unit preference that can be used to override the default unit preference
3449
+ * @param fieldId An optional Id to override the definition.key
3450
+ * @returns { JSX.Element } A JSX.Element or null if the field definition is undefined
3451
+ */
3452
+ const useCustomFieldResolver = (field, validation, unitPreference = "SI", fieldId) => {
3453
+ 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;
3454
+ const [isEditing, setIsEditing] = React.useState(false);
3455
+ const [numberValue, setNumberValue] = React.useState(() => {
3456
+ var _a;
3457
+ if ((field === null || field === void 0 ? void 0 : field.definition) && field.definition.type === irisAppRuntimeCoreApi.CustomFieldType.NUMBER) {
3458
+ const typedValue = field.value;
3459
+ return (_a = typedValue.numberValue) !== null && _a !== void 0 ? _a : field.definition.defaultNumberValue;
3460
+ }
3461
+ else {
3462
+ return "";
3463
+ }
3464
+ });
3465
+ 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) {
3466
+ return null;
3467
+ }
3468
+ const key = (_b = fieldId !== null && fieldId !== void 0 ? fieldId : field.definition.key) !== null && _b !== void 0 ? _b : "";
3469
+ const fieldError = key ? validation.formState.errors[key] : undefined;
3470
+ const errorMessage = fieldError ? fieldError.message + "" : undefined;
3471
+ const { type, description, title } = field.definition;
3472
+ switch (type) {
3473
+ case irisAppRuntimeCoreApi.CustomFieldType.WEB_ADDRESS: {
3474
+ const typedDefinition = field.definition;
3475
+ const typedValue = field.value;
3476
+ const rules = getWebAddressValidationRules(typedDefinition);
3477
+ return (jsxRuntime.jsx(reactFormComponents.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 &&
3478
+ (typedValue.stringValue || typedDefinition.defaultStringValue) && (jsxRuntime.jsx(reactFormComponents.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))));
3479
+ }
3480
+ case irisAppRuntimeCoreApi.CustomFieldType.EMAIL: {
3481
+ const typedDefinition = field.definition;
3482
+ const typedValue = field.value;
3483
+ const rules = getEmailValidationRules(typedDefinition);
3484
+ return (jsxRuntime.jsx(reactFormComponents.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 &&
3485
+ (typedValue.stringValue || typedDefinition.defaultStringValue) && (jsxRuntime.jsx(reactFormComponents.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))));
3486
+ }
3487
+ case irisAppRuntimeCoreApi.CustomFieldType.PHONE_NUMBER: {
3488
+ const typedDefinition = field.definition;
3489
+ const typedValue = field.value;
3490
+ const rules = getPhoneNumberValidationRules(typedDefinition);
3491
+ return (jsxRuntime.jsx(reactFormComponents.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 &&
3492
+ (typedValue.stringValue || typedDefinition.defaultStringValue) && (jsxRuntime.jsx(reactFormComponents.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))));
3493
+ }
3494
+ case irisAppRuntimeCoreApi.CustomFieldType.STRING: {
3495
+ const typedDefinition = field.definition;
3496
+ const typedValue = field.value;
3497
+ const rules = getStringValidationRules(typedDefinition);
3498
+ return (jsxRuntime.jsx(reactFormComponents.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))));
3499
+ }
3500
+ case irisAppRuntimeCoreApi.CustomFieldType.NUMBER: {
3501
+ const typedDefinition = field.definition;
3502
+ const typedValue = field.value;
3503
+ const rules = getNumberValidationRules(typedDefinition);
3504
+ const unit = unitPreference === "US_CUSTOMARY" ? typedDefinition.unitUs : typedDefinition.unitSi;
3505
+ const numberProps = {
3506
+ placeholder: (_t = typedDefinition.title) !== null && _t !== void 0 ? _t : "",
3507
+ addonAfter: unit,
3508
+ };
3509
+ return (jsxRuntime.jsx(reactFormComponents.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 ? (jsxRuntime.jsx(reactFormComponents.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 => {
3510
+ setNumberValue(e.target.value);
3511
+ validation.register(key, rules).onChange(e);
3512
+ } }, numberProps))) : (jsxRuntime.jsx(reactFormComponents.BaseInput, Object.assign({ type: "text", id: `${key}-number-field`, dataTestId: `${typedDefinition.key}`, defaultValue: parseFloat(Number(numberValue).toPrecision(4)), readOnly: true, actions: jsxRuntime.jsx(ActionContainer, { children: jsxRuntime.jsx(StyledIconButton, { dataTestId: `${typedDefinition.key}-editIconButtonId`, size: "small", color: "tertiary", icon: jsxRuntime.jsx(reactComponents.Icon, { size: "small", name: "PencilIcon" }), onClick: () => setIsEditing(!isEditing) }) }) }, numberProps))) }));
3513
+ }
3514
+ case irisAppRuntimeCoreApi.CustomFieldType.BOOLEAN: {
3515
+ const typedDefinition = field.definition;
3516
+ const typedValue = field.value;
3517
+ const rules = getBooleanValidationRules();
3518
+ return (jsxRuntime.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));
3519
+ }
3520
+ case irisAppRuntimeCoreApi.CustomFieldType.DROPDOWN: {
3521
+ const typedDefinition = field.definition;
3522
+ const typedValue = field.value;
3523
+ const rules = getDropdownValidationRules();
3524
+ return (jsxRuntime.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));
3525
+ }
3526
+ case irisAppRuntimeCoreApi.CustomFieldType.DATE: {
3527
+ const typedDefinition = field.definition;
3528
+ const typedValue = field.value;
3529
+ const rules = getDateValidationRules();
3530
+ let defaultValue;
3531
+ if (typedValue.dateValue !== undefined && typedValue.dateValue !== null) {
3532
+ defaultValue = new Date(typedValue.dateValue);
3533
+ }
3534
+ else if (typedDefinition.defaultDateValue !== undefined && typedDefinition.defaultDateValue !== null) {
3535
+ defaultValue = new Date(typedDefinition.defaultDateValue);
3536
+ }
3537
+ return (jsxRuntime.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));
3538
+ }
3539
+ default:
3540
+ throw new Error(`Type not supported: ${type}`);
3541
+ }
3542
+ };
3543
+ /**
3544
+ *
3545
+ */
3546
+ const CustomField = ({ field, register, formState, setValue, unitPreference, fieldId }) => {
3547
+ const fieldComponent = useCustomFieldResolver(field, { register, setValue, formState }, unitPreference, fieldId);
3548
+ return fieldComponent;
3549
+ };
395
3550
  const ActionContainer = tailwindStyledComponents.tw.div `
396
3551
  tu-action-container
397
- `;
3552
+ `;
398
3553
  const StyledIconButton = tailwindStyledComponents.twx(reactComponents.IconButton) `
399
3554
  tu-action-button
400
3555
  `;