UNPKG

498 kBJavaScriptView Raw
1import { createContextId, componentQrl, inlinedQrl, _restProps, useSignal, useTaskQrl, useLexicalScope, useVisibleTaskQrl, useContextProvider, _jsxS, _jsxC, Slot, useId, useContext, _fnSignal, useStylesScopedQrl, _jsxQ, useStore, useOnWindow, noSerialize, useOnDocument, useComputedQrl, _wrapSignal, _jsxBranch, component$, _IMMUTABLE, useStylesQrl, useOn } from '@builder.io/qwik';
2import { jsx, Fragment } from '@builder.io/qwik/jsx-runtime';
3import { isBrowser, isServer } from '@builder.io/qwik/build';
4
5const accordionRootContextId = createContextId("accordion-root");
6const accordionItemContextId = createContextId("accordion-item");
7
8const AccordionRoot = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
9 const props1 = _restProps(props, [
10 "collapsible",
11 "behavior",
12 "animated",
13 "onSelectedIndexChange$",
14 "onFocusIndexChange$"
15 ]);
16 const rootRef = useSignal();
17 const currFocusedTriggerIndexSig = useSignal(-1);
18 const currSelectedTriggerIndexSig = useSignal(-1);
19 const selectedTriggerIdSig = useSignal("");
20 const triggerElementsSig = useSignal([]);
21 useTaskQrl(/* @__PURE__ */ inlinedQrl(({ track }) => {
22 const [currSelectedTriggerIndexSig2, props2] = useLexicalScope();
23 track(() => currSelectedTriggerIndexSig2.value);
24 if (props2.onSelectedIndexChange$)
25 props2.onSelectedIndexChange$(currSelectedTriggerIndexSig2.value);
26 }, "AccordionRoot_component_useTask_Qwqwbzx0Lr8", [
27 currSelectedTriggerIndexSig,
28 props
29 ]));
30 useTaskQrl(/* @__PURE__ */ inlinedQrl(({ track }) => {
31 const [currFocusedTriggerIndexSig2, props2] = useLexicalScope();
32 track(() => currFocusedTriggerIndexSig2.value);
33 if (props2.onFocusIndexChange$)
34 props2.onFocusIndexChange$(currFocusedTriggerIndexSig2.value);
35 }, "AccordionRoot_component_useTask_1_eCYTRyvWCIU", [
36 currFocusedTriggerIndexSig,
37 props
38 ]));
39 const updateTriggers$ = /* @__PURE__ */ inlinedQrl(() => {
40 const [rootRef2, triggerElementsSig2] = useLexicalScope();
41 if (!rootRef2.value)
42 return;
43 const getLatestTriggers = Array.from(rootRef2.value.querySelectorAll("[data-trigger-id]"));
44 triggerElementsSig2.value = getLatestTriggers.filter((element) => {
45 if (element.getAttribute("aria-disabled") === "true")
46 return false;
47 return true;
48 });
49 }, "AccordionRoot_component_updateTriggers_IvCdCytWFQ0", [
50 rootRef,
51 triggerElementsSig
52 ]);
53 const focusPreviousTrigger$ = /* @__PURE__ */ inlinedQrl(() => {
54 const [currFocusedTriggerIndexSig2, triggerElementsSig2] = useLexicalScope();
55 if (currFocusedTriggerIndexSig2.value === 0) {
56 currFocusedTriggerIndexSig2.value = triggerElementsSig2.value.length - 1;
57 return triggerElementsSig2.value[triggerElementsSig2.value.length - 1].focus();
58 }
59 currFocusedTriggerIndexSig2.value--;
60 return triggerElementsSig2.value[currFocusedTriggerIndexSig2.value].focus();
61 }, "AccordionRoot_component_focusPreviousTrigger_ImTP7x2Qm0M", [
62 currFocusedTriggerIndexSig,
63 triggerElementsSig
64 ]);
65 const focusNextTrigger$ = /* @__PURE__ */ inlinedQrl(() => {
66 const [currFocusedTriggerIndexSig2, triggerElementsSig2] = useLexicalScope();
67 if (currFocusedTriggerIndexSig2.value === triggerElementsSig2.value.length - 1) {
68 currFocusedTriggerIndexSig2.value = 0;
69 return triggerElementsSig2.value[0].focus();
70 }
71 currFocusedTriggerIndexSig2.value++;
72 return triggerElementsSig2.value[currFocusedTriggerIndexSig2.value].focus();
73 }, "AccordionRoot_component_focusNextTrigger_9te8634Gk34", [
74 currFocusedTriggerIndexSig,
75 triggerElementsSig
76 ]);
77 const focusFirstTrigger$ = /* @__PURE__ */ inlinedQrl(() => {
78 const [triggerElementsSig2] = useLexicalScope();
79 return triggerElementsSig2.value[0].focus();
80 }, "AccordionRoot_component_focusFirstTrigger_68n0b3BkBYI", [
81 triggerElementsSig
82 ]);
83 const focusLastTrigger$ = /* @__PURE__ */ inlinedQrl(() => {
84 const [triggerElementsSig2] = useLexicalScope();
85 return triggerElementsSig2.value[triggerElementsSig2.value.length - 1].focus();
86 }, "AccordionRoot_component_focusLastTrigger_i9ed6fSgwd0", [
87 triggerElementsSig
88 ]);
89 useVisibleTaskQrl(/* @__PURE__ */ inlinedQrl(function reIndexTriggers() {
90 const [updateTriggers$2] = useLexicalScope();
91 updateTriggers$2();
92 }, "AccordionRoot_component_useVisibleTask_c7PiYJ1s0GU", [
93 updateTriggers$
94 ]));
95 const contextService = {
96 updateTriggers$,
97 focusFirstTrigger$,
98 focusPreviousTrigger$,
99 focusNextTrigger$,
100 focusLastTrigger$,
101 currFocusedTriggerIndexSig,
102 currSelectedTriggerIndexSig,
103 selectedTriggerIdSig,
104 triggerElementsSig,
105 collapsible: props.collapsible ?? true,
106 behavior: props.behavior ?? "single",
107 animated: props.animated ?? false
108 };
109 useContextProvider(accordionRootContextId, contextService);
110 return /* @__PURE__ */ _jsxS("div", {
111 ...props1,
112 ref: rootRef,
113 children: /* @__PURE__ */ _jsxC(Slot, null, 3, "jW_0")
114 }, null, 0, "jW_1");
115}, "AccordionRoot_component_dyqeXuV0Jjc"));
116
117const AccordionItem = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
118 const props1 = _restProps(props, [
119 "defaultValue",
120 "id"
121 ]);
122 const localId = useId();
123 const itemId = props.id || localId;
124 const isTriggerExpandedSig = useSignal(props.defaultValue ?? false);
125 const itemContext = {
126 itemId,
127 isTriggerExpandedSig,
128 defaultValue: props.defaultValue ?? false
129 };
130 useContextProvider(accordionItemContextId, itemContext);
131 return /* @__PURE__ */ _jsxS("div", {
132 id: itemId,
133 "data-item-id": itemId,
134 ...props1,
135 children: /* @__PURE__ */ _jsxC(Slot, null, 3, "qs_0")
136 }, {
137 "data-type": "item"
138 }, 0, "qs_1");
139}, "AccordionItem_component_YgHXnQO1y0I"));
140
141const AccordionHeader = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
142 const props1 = _restProps(props, [
143 "as"
144 ]);
145 const itemContext = useContext(accordionItemContextId);
146 const headerId = `${itemContext.itemId}-header`;
147 return /* @__PURE__ */ _jsxC(props.as ?? "h3", {
148 id: headerId,
149 ...props1,
150 children: /* @__PURE__ */ _jsxC(Slot, null, 3, "X8_0")
151 }, 0, "X8_1");
152}, "AccordionHeader_component_bB5ZxNj2LlA"));
153
154let KeyCode;
155(function(KeyCode2) {
156 KeyCode2["ArrowLeft"] = "ArrowLeft";
157 KeyCode2["ArrowRight"] = "ArrowRight";
158 KeyCode2["ArrowUp"] = "ArrowUp";
159 KeyCode2["ArrowDown"] = "ArrowDown";
160 KeyCode2["Home"] = "Home";
161 KeyCode2["End"] = "End";
162 KeyCode2["PageUp"] = "PageUp";
163 KeyCode2["PageDown"] = "PageDown";
164 KeyCode2["Enter"] = "Enter";
165})(KeyCode || (KeyCode = {}));
166
167const accordionPreventedKeys = [
168 KeyCode.Home,
169 KeyCode.End,
170 KeyCode.PageDown,
171 KeyCode.PageUp,
172 KeyCode.ArrowDown,
173 KeyCode.ArrowUp
174];
175const AccordionTrigger = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
176 const props1 = _restProps(props, [
177 "disabled"
178 ]);
179 const contextService = useContext(accordionRootContextId);
180 const itemContext = useContext(accordionItemContextId);
181 const ref = useSignal();
182 const triggerId = `${itemContext.itemId}-trigger`;
183 const contentId = `${itemContext.itemId}-content`;
184 const setSelectedTriggerIndexSig$ = /* @__PURE__ */ inlinedQrl(() => {
185 const [contextService2, ref2] = useLexicalScope();
186 if (contextService2.behavior === "single" && ref2.value)
187 contextService2.currSelectedTriggerIndexSig.value = contextService2.triggerElementsSig.value.indexOf(ref2.value);
188 }, "AccordionTrigger_component_setSelectedTriggerIndexSig_OPIX0WmIn3U", [
189 contextService,
190 ref
191 ]);
192 const setCurrFocusedIndexSig$ = /* @__PURE__ */ inlinedQrl(() => {
193 const [contextService2, ref2] = useLexicalScope();
194 if (!ref2.value)
195 return;
196 contextService2.currFocusedTriggerIndexSig.value = contextService2.triggerElementsSig.value.indexOf(ref2.value);
197 }, "AccordionTrigger_component_setCurrFocusedIndexSig_aUMl0Mknykg", [
198 contextService,
199 ref
200 ]);
201 useTaskQrl(/* @__PURE__ */ inlinedQrl(function resetTriggersTask({ track }) {
202 const [contextService2, itemContext2, triggerId2] = useLexicalScope();
203 track(() => contextService2.selectedTriggerIdSig.value);
204 if (contextService2.behavior === "single" && triggerId2 !== contextService2.selectedTriggerIdSig.value)
205 itemContext2.isTriggerExpandedSig.value = false;
206 }, "AccordionTrigger_component_useTask_moIlZJ0XpGY", [
207 contextService,
208 itemContext,
209 triggerId
210 ]));
211 useTaskQrl(/* @__PURE__ */ inlinedQrl(function openDefaultValueTask() {
212 const [itemContext2] = useLexicalScope();
213 if (itemContext2.defaultValue)
214 itemContext2.isTriggerExpandedSig.value = true;
215 }, "AccordionTrigger_component_useTask_1_ClIa90D1LOw", [
216 itemContext
217 ]));
218 useVisibleTaskQrl(/* @__PURE__ */ inlinedQrl(function navigateTriggerVisibleTask({ cleanup }) {
219 const [contextService2, props2, ref2] = useLexicalScope();
220 if (!ref2.value)
221 return;
222 if (!props2.disabled)
223 contextService2.updateTriggers$();
224 function keyHandler(e) {
225 if (accordionPreventedKeys.includes(e.key))
226 e.preventDefault();
227 }
228 ref2.value.addEventListener("keydown", keyHandler);
229 cleanup(() => {
230 ref2.value?.removeEventListener("keydown", keyHandler);
231 });
232 }, "AccordionTrigger_component_useVisibleTask_py4L6HieTpw", [
233 contextService,
234 props,
235 ref
236 ]));
237 useVisibleTaskQrl(/* @__PURE__ */ inlinedQrl(function cleanupTriggersTask({ cleanup }) {
238 const [contextService2] = useLexicalScope();
239 cleanup(() => {
240 contextService2.updateTriggers$();
241 });
242 }, "AccordionTrigger_component_useVisibleTask_1_ZlkQX0dQ4iE", [
243 contextService
244 ]), {
245 strategy: "document-ready"
246 });
247 return /* @__PURE__ */ _jsxS("button", {
248 ref,
249 id: triggerId,
250 "data-trigger-id": triggerId,
251 "aria-controls": contentId,
252 ...props1,
253 children: /* @__PURE__ */ _jsxC(Slot, null, 3, "RH_0"),
254 onClick$: [
255 /* @__PURE__ */ inlinedQrl(() => {
256 const [contextService2, itemContext2, setSelectedTriggerIndexSig$2, triggerId2] = useLexicalScope();
257 contextService2.selectedTriggerIdSig.value = triggerId2;
258 setSelectedTriggerIndexSig$2();
259 contextService2.collapsible ? itemContext2.isTriggerExpandedSig.value = !itemContext2.isTriggerExpandedSig.value : itemContext2.isTriggerExpandedSig.value = true;
260 }, "AccordionTrigger_component_button_onClick_vCRJEICs24o", [
261 contextService,
262 itemContext,
263 setSelectedTriggerIndexSig$,
264 triggerId
265 ]),
266 props1.onClick$
267 ],
268 onKeyDown$: [
269 /* @__PURE__ */ inlinedQrl(async (e) => {
270 const [contextService2] = useLexicalScope();
271 if (e.key === "ArrowUp")
272 await contextService2.focusPreviousTrigger$();
273 if (e.key === "ArrowDown")
274 await contextService2.focusNextTrigger$();
275 if (e.key === "Home")
276 await contextService2.focusFirstTrigger$();
277 if (e.key === "End")
278 await contextService2.focusLastTrigger$();
279 }, "AccordionTrigger_component_button_onKeyDown_zRbRiLzl1zc", [
280 contextService
281 ]),
282 props1.onKeyDown$
283 ],
284 onFocus$: [
285 setCurrFocusedIndexSig$,
286 props1.onFocus$
287 ]
288 }, {
289 disabled: _fnSignal((p0) => p0.disabled, [
290 props
291 ], "p0.disabled"),
292 "aria-disabled": _fnSignal((p0) => p0.disabled, [
293 props
294 ], "p0.disabled"),
295 "data-state": _fnSignal((p0) => p0.isTriggerExpandedSig.value ? "open" : "closed", [
296 itemContext
297 ], 'p0.isTriggerExpandedSig.value?"open":"closed"'),
298 "aria-expanded": _fnSignal((p0) => p0.isTriggerExpandedSig.value, [
299 itemContext
300 ], "p0.isTriggerExpandedSig.value")
301 }, 0, "RH_1");
302}, "AccordionTrigger_component_HLYQug4XlU4"));
303
304const AccordionContent = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl(({ ...props }) => {
305 const contextService = useContext(accordionRootContextId);
306 const itemContext = useContext(accordionItemContextId);
307 const ref = useSignal();
308 const contentId = `${itemContext.itemId}-content`;
309 const totalHeightSig = useSignal(0);
310 const isContentHiddenSig = useSignal(!itemContext.defaultValue);
311 const hideContent$ = /* @__PURE__ */ inlinedQrl(() => {
312 const [isContentHiddenSig2, itemContext2] = useLexicalScope();
313 if (!itemContext2.isTriggerExpandedSig.value)
314 isContentHiddenSig2.value = true;
315 }, "AccordionContent_component_hideContent_dGXzdRcdkdY", [
316 isContentHiddenSig,
317 itemContext
318 ]);
319 useStylesScopedQrl(/* @__PURE__ */ inlinedQrl(`
320 /* check global.css utilites layer for animation */
321 @keyframes accordion-open {
322 0% {
323 height: 0;
324 }
325 100% {
326 height: var(--qwikui-accordion-content-height);
327 }
328 }
329
330 @keyframes accordion-close {
331 0% {
332 height: var(--qwikui-accordion-content-height);
333 }
334 100% {
335 height: 0;
336 }
337 }
338 `, "AccordionContent_component_useStylesScoped_jkiDTw0Rxa4"));
339 useTaskQrl(/* @__PURE__ */ inlinedQrl(function animateContentTask({ track }) {
340 const [contextService2, isContentHiddenSig2, itemContext2] = useLexicalScope();
341 if (!contextService2.animated)
342 return;
343 track(() => itemContext2.isTriggerExpandedSig.value);
344 if (itemContext2.isTriggerExpandedSig.value)
345 isContentHiddenSig2.value = false;
346 }, "AccordionContent_component_useTask_yqEZj1cracY", [
347 contextService,
348 isContentHiddenSig,
349 itemContext
350 ]));
351 useVisibleTaskQrl(/* @__PURE__ */ inlinedQrl(function calculateHeightVisibleTask({ track }) {
352 const [contextService2, isContentHiddenSig2, ref2, totalHeightSig2] = useLexicalScope();
353 if (contextService2.animated === false)
354 return;
355 track(() => isContentHiddenSig2.value);
356 if (totalHeightSig2.value === 0)
357 getCalculatedHeight();
358 function getCalculatedHeight() {
359 if (!ref2.value)
360 return;
361 const contentChildren = Array.from(ref2.value.children);
362 contentChildren.forEach((element, index) => {
363 totalHeightSig2.value += element.offsetHeight;
364 if (index === contentChildren.length - 1)
365 ref2.value.style.setProperty("--qwikui-accordion-content-height", `${totalHeightSig2.value}px`);
366 });
367 }
368 }, "AccordionContent_component_useVisibleTask_M0tH5WLqYIQ", [
369 contextService,
370 isContentHiddenSig,
371 ref,
372 totalHeightSig
373 ]));
374 return /* @__PURE__ */ _jsxS("div", {
375 ref,
376 id: contentId,
377 "data-content-id": contentId,
378 ...props,
379 children: /* @__PURE__ */ _jsxC(Slot, null, 3, "0S_0"),
380 onAnimationEnd$: [
381 hideContent$,
382 props.onAnimationEnd$
383 ],
384 onTransitionEnd$: [
385 hideContent$,
386 props.onTransitionEnd$
387 ]
388 }, {
389 role: "region",
390 "data-state": _fnSignal((p0) => p0.isTriggerExpandedSig.value ? "open" : "closed", [
391 itemContext
392 ], 'p0.isTriggerExpandedSig.value?"open":"closed"'),
393 hidden: _fnSignal((p0, p1, p2) => p0.animated ? p1.value : !p2.isTriggerExpandedSig.value, [
394 contextService,
395 isContentHiddenSig,
396 itemContext
397 ], "p0.animated?p1.value:!p2.isTriggerExpandedSig.value"),
398 style: {
399 ["--qwikui-collapsible-content-height"]: "var(--qwikui-accordion-content-height)",
400 ["--qwikui-collapsible-content-width"]: "var(--qwikui-accordion-content-width)"
401 }
402 }, 0, "0S_1");
403}, "AccordionContent_component_FpJ0F5de3jc"));
404
405const Badge = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
406 return /* @__PURE__ */ _jsxS("div", {
407 ...props,
408 children: /* @__PURE__ */ _jsxC(Slot, null, 3, "vp_0")
409 }, null, 0, "vp_1");
410}, "Badge_component_PfxP6eiunY8"));
411
412const ButtonGroup = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
413 return /* @__PURE__ */ _jsxS("span", {
414 ...props,
415 children: /* @__PURE__ */ _jsxC(Slot, null, 3, "DH_0")
416 }, null, 0, "DH_1");
417}, "ButtonGroup_component_FjcIrKyQZyc"));
418
419const Card = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
420 return /* @__PURE__ */ _jsxS("div", {
421 ...props,
422 children: /* @__PURE__ */ _jsxC(Slot, null, 3, "Bp_0")
423 }, null, 0, "Bp_1");
424}, "Card_component_Z0hZmbFoO7c"));
425
426const CardTitle = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
427 return /* @__PURE__ */ _jsxS("h2", {
428 ...props,
429 children: /* @__PURE__ */ _jsxC(Slot, null, 3, "Tz_0")
430 }, null, 0, "Tz_1");
431}, "CardTitle_component_fWJvio7d2Xo"));
432
433const CardBody = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
434 return /* @__PURE__ */ _jsxS("div", {
435 ...props,
436 children: /* @__PURE__ */ _jsxC(Slot, null, 3, "Xo_0")
437 }, null, 0, "Xo_1");
438}, "CardBody_component_Gqb0aH11nwU"));
439
440const CardActions = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
441 return /* @__PURE__ */ _jsxS("div", {
442 ...props,
443 children: /* @__PURE__ */ _jsxC(Slot, null, 3, "Sq_0")
444 }, null, 0, "Sq_1");
445}, "CardActions_component_uRwvuYGjzoI"));
446
447const CardImage = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
448 return /* @__PURE__ */ _jsxQ("figure", null, null, /* @__PURE__ */ _jsxS("img", {
449 ...props
450 }, null, 0, null), 1, "Ws_0");
451}, "CardImage_component_4fckO3L00vk"));
452
453function t(t){return t.split("-")[1]}function e(t){return "y"===t?"height":"width"}function n$1(t){return t.split("-")[0]}function o$1(t){return ["top","bottom"].includes(n$1(t))?"x":"y"}function r$1(r,i,a){let{reference:l,floating:s}=r;const c=l.x+l.width/2-s.width/2,f=l.y+l.height/2-s.height/2,u=o$1(i),m=e(u),g=l[m]/2-s[m]/2,d="x"===u;let p;switch(n$1(i)){case"top":p={x:c,y:l.y-s.height};break;case"bottom":p={x:c,y:l.y+l.height};break;case"right":p={x:l.x+l.width,y:f};break;case"left":p={x:l.x-s.width,y:f};break;default:p={x:l.x,y:l.y};}switch(t(i)){case"start":p[u]-=g*(a&&d?-1:1);break;case"end":p[u]+=g*(a&&d?-1:1);}return p}const i$1=async(t,e,n)=>{const{placement:o="bottom",strategy:i="absolute",middleware:a=[],platform:l}=n,s=a.filter(Boolean),c=await(null==l.isRTL?void 0:l.isRTL(e));let f=await l.getElementRects({reference:t,floating:e,strategy:i}),{x:u,y:m}=r$1(f,o,c),g=o,d={},p=0;for(let n=0;n<s.length;n++){const{name:a,fn:h}=s[n],{x:y,y:x,data:w,reset:v}=await h({x:u,y:m,initialPlacement:o,placement:g,strategy:i,middlewareData:d,rects:f,platform:l,elements:{reference:t,floating:e}});u=null!=y?y:u,m=null!=x?x:m,d={...d,[a]:{...d[a],...w}},v&&p<=50&&(p++,"object"==typeof v&&(v.placement&&(g=v.placement),v.rects&&(f=!0===v.rects?await l.getElementRects({reference:t,floating:e,strategy:i}):v.rects),({x:u,y:m}=r$1(f,g,c))),n=-1);}return {x:u,y:m,placement:g,strategy:i,middlewareData:d}};function a$1(t){return "number"!=typeof t?function(t){return {top:0,right:0,bottom:0,left:0,...t}}(t):{top:t,right:t,bottom:t,left:t}}function l$1(t){return {...t,top:t.y,left:t.x,right:t.x+t.width,bottom:t.y+t.height}}async function s$1(t,e){var n;void 0===e&&(e={});const{x:o,y:r,platform:i,rects:s,elements:c,strategy:f}=t,{boundary:u="clippingAncestors",rootBoundary:m="viewport",elementContext:g="floating",altBoundary:d=!1,padding:p=0}=e,h=a$1(p),y=c[d?"floating"===g?"reference":"floating":g],x=l$1(await i.getClippingRect({element:null==(n=await(null==i.isElement?void 0:i.isElement(y)))||n?y:y.contextElement||await(null==i.getDocumentElement?void 0:i.getDocumentElement(c.floating)),boundary:u,rootBoundary:m,strategy:f})),w="floating"===g?{...s.floating,x:o,y:r}:s.reference,v=await(null==i.getOffsetParent?void 0:i.getOffsetParent(c.floating)),b=await(null==i.isElement?void 0:i.isElement(v))&&await(null==i.getScale?void 0:i.getScale(v))||{x:1,y:1},R=l$1(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({rect:w,offsetParent:v,strategy:f}):w);return {top:(x.top-R.top+h.top)/b.y,bottom:(R.bottom-x.bottom+h.bottom)/b.y,left:(x.left-R.left+h.left)/b.x,right:(R.right-x.right+h.right)/b.x}}const c$1=Math.min,f$1=Math.max;function u$1(t,e,n){return f$1(t,c$1(e,n))}const g$1=["top","right","bottom","left"];g$1.reduce(((t,e)=>t.concat(e,e+"-start",e+"-end")),[]);const p$1={left:"right",right:"left",bottom:"top",top:"bottom"};function h$1(t){return t.replace(/left|right|bottom|top/g,(t=>p$1[t]))}function y$1(n,r,i){void 0===i&&(i=!1);const a=t(n),l=o$1(n),s=e(l);let c="x"===l?a===(i?"end":"start")?"right":"left":"start"===a?"bottom":"top";return r.reference[s]>r.floating[s]&&(c=h$1(c)),{main:c,cross:h$1(c)}}const x$1={start:"end",end:"start"};function w$1(t){return t.replace(/start|end/g,(t=>x$1[t]))}const b$1=function(e){return void 0===e&&(e={}),{name:"flip",options:e,async fn(o){var r;const{placement:i,middlewareData:a,rects:l,initialPlacement:c,platform:f,elements:u}=o,{mainAxis:m=!0,crossAxis:g=!0,fallbackPlacements:d,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:x="none",flipAlignment:v=!0,...b}=e,R=n$1(i),A=n$1(c)===c,P=await(null==f.isRTL?void 0:f.isRTL(u.floating)),T=d||(A||!v?[h$1(c)]:function(t){const e=h$1(t);return [w$1(t),e,w$1(e)]}(c));d||"none"===x||T.push(...function(e,o,r,i){const a=t(e);let l=function(t,e,n){const o=["left","right"],r=["right","left"],i=["top","bottom"],a=["bottom","top"];switch(t){case"top":case"bottom":return n?e?r:o:e?o:r;case"left":case"right":return e?i:a;default:return []}}(n$1(e),"start"===r,i);return a&&(l=l.map((t=>t+"-"+a)),o&&(l=l.concat(l.map(w$1)))),l}(c,v,x,P));const O=[c,...T],D=await s$1(o,b),E=[];let L=(null==(r=a.flip)?void 0:r.overflows)||[];if(m&&E.push(D[R]),g){const{main:t,cross:e}=y$1(i,l,P);E.push(D[t],D[e]);}if(L=[...L,{placement:i,overflows:E}],!E.every((t=>t<=0))){var k,B;const t=((null==(k=a.flip)?void 0:k.index)||0)+1,e=O[t];if(e)return {data:{index:t,overflows:L},reset:{placement:e}};let n=null==(B=L.filter((t=>t.overflows[0]<=0)).sort(((t,e)=>t.overflows[1]-e.overflows[1]))[0])?void 0:B.placement;if(!n)switch(p){case"bestFit":{var C;const t=null==(C=L.map((t=>[t.placement,t.overflows.filter((t=>t>0)).reduce(((t,e)=>t+e),0)])).sort(((t,e)=>t[1]-e[1]))[0])?void 0:C[0];t&&(n=t);break}case"initialPlacement":n=c;}if(i!==n)return {reset:{placement:n}}}return {}}}};const O$1=function(e){return void 0===e&&(e=0),{name:"offset",options:e,async fn(r){const{x:i,y:a}=r,l=await async function(e,r){const{placement:i,platform:a,elements:l}=e,s=await(null==a.isRTL?void 0:a.isRTL(l.floating)),c=n$1(i),f=t(i),u="x"===o$1(i),m=["left","top"].includes(c)?-1:1,g=s&&u?-1:1,d="function"==typeof r?r(e):r;let{mainAxis:p,crossAxis:h,alignmentAxis:y}="number"==typeof d?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:0,crossAxis:0,alignmentAxis:null,...d};return f&&"number"==typeof y&&(h="end"===f?-1*y:y),u?{x:h*g,y:p*m}:{x:p*m,y:h*g}}(r,e);return {x:i+l.x,y:a+l.y,data:l}}}};function D$1(t){return "x"===t?"y":"x"}const E$1=function(t){return void 0===t&&(t={}),{name:"shift",options:t,async fn(e){const{x:r,y:i,placement:a}=e,{mainAxis:l=!0,crossAxis:c=!1,limiter:f={fn:t=>{let{x:e,y:n}=t;return {x:e,y:n}}},...m}=t,g={x:r,y:i},d=await s$1(e,m),p=o$1(n$1(a)),h=D$1(p);let y=g[p],x=g[h];if(l){const t="y"===p?"bottom":"right";y=u$1(y+d["y"===p?"top":"left"],y,y-d[t]);}if(c){const t="y"===h?"bottom":"right";x=u$1(x+d["y"===h?"top":"left"],x,x-d[t]);}const w=f.fn({...e,[p]:y,[h]:x});return {...w,data:{x:w.x-r,y:w.y-i}}}}};
454
455function n(t){var e;return (null==(e=t.ownerDocument)?void 0:e.defaultView)||window}function o(t){return n(t).getComputedStyle(t)}function i(t){return f(t)?(t.nodeName||"").toLowerCase():""}let r;function l(){if(r)return r;const t=navigator.userAgentData;return t&&Array.isArray(t.brands)?(r=t.brands.map((t=>t.brand+"/"+t.version)).join(" "),r):navigator.userAgent}function c(t){return t instanceof n(t).HTMLElement}function s(t){return t instanceof n(t).Element}function f(t){return t instanceof n(t).Node}function u(t){if("undefined"==typeof ShadowRoot)return !1;return t instanceof n(t).ShadowRoot||t instanceof ShadowRoot}function a(t){const{overflow:e,overflowX:n,overflowY:i,display:r}=o(t);return /auto|scroll|overlay|hidden/.test(e+i+n)&&!["inline","contents"].includes(r)}function d(t){return ["table","td","th"].includes(i(t))}function h(t){const e=/firefox/i.test(l()),n=o(t),i=n.backdropFilter||n.WebkitBackdropFilter;return "none"!==n.transform||"none"!==n.perspective||!!i&&"none"!==i||e&&"filter"===n.willChange||e&&!!n.filter&&"none"!==n.filter||["transform","perspective"].some((t=>n.willChange.includes(t)))||["paint","layout","strict","content"].some((t=>{const e=n.contain;return null!=e&&e.includes(t)}))}function g(){return !/^((?!chrome|android).)*safari/i.test(l())}function m(t){return ["html","body","#document"].includes(i(t))}const p={x:1,y:1};function y(t){const e=!s(t)&&t.contextElement?t.contextElement:s(t)?t:null;if(!e)return p;const n=e.getBoundingClientRect(),i=o(e);let r=n.width/parseFloat(i.width),l=n.height/parseFloat(i.height);return r&&Number.isFinite(r)||(r=1),l&&Number.isFinite(l)||(l=1),{x:r,y:l}}function w(t,e,o,i){var r,l,c,f;void 0===e&&(e=!1),void 0===o&&(o=!1);const u=t.getBoundingClientRect();let a=p;e&&(i?s(i)&&(a=y(i)):a=y(t));const d=s(t)?n(t):window,h=!g()&&o,m=(u.left+(h&&null!=(r=null==(l=d.visualViewport)?void 0:l.offsetLeft)?r:0))/a.x,w=(u.top+(h&&null!=(c=null==(f=d.visualViewport)?void 0:f.offsetTop)?c:0))/a.y,x=u.width/a.x,v=u.height/a.y;return {width:x,height:v,top:w,right:m+x,bottom:w+v,left:m,x:m,y:w}}function x(t){return ((f(t)?t.ownerDocument:t.document)||window.document).documentElement}function v(t){return s(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.pageXOffset,scrollTop:t.pageYOffset}}function b(t){return w(x(t)).left+v(t).scrollLeft}function L(t,e,n){const o=c(e),r=x(e),l=w(t,!0,"fixed"===n,e);let s={scrollLeft:0,scrollTop:0};const f={x:0,y:0};if(o||!o&&"fixed"!==n)if(("body"!==i(e)||a(r))&&(s=v(e)),c(e)){const t=w(e,!0);f.x=t.x+e.clientLeft,f.y=t.y+e.clientTop;}else r&&(f.x=b(r));return {x:l.left+s.scrollLeft-f.x,y:l.top+s.scrollTop-f.y,width:l.width,height:l.height}}function E(t){if("html"===i(t))return t;const e=t.assignedSlot||t.parentNode||(u(t)?t.host:null)||x(t);return u(e)?e.host:e}function R(t){return c(t)&&"fixed"!==o(t).position?t.offsetParent:null}function T(t){const e=n(t);let r=R(t);for(;r&&d(r)&&"static"===o(r).position;)r=R(r);return r&&("html"===i(r)||"body"===i(r)&&"static"===o(r).position&&!h(r))?e:r||function(t){let e=E(t);for(;c(e)&&!m(e);){if(h(e))return e;e=E(e);}return null}(t)||e}const W=Math.min,C=Math.max;function D(t){const e=E(t);return m(e)?t.ownerDocument.body:c(e)&&a(e)?e:D(e)}function F(t,e){var o;void 0===e&&(e=[]);const i=D(t),r=i===(null==(o=t.ownerDocument)?void 0:o.body),l=n(i);return r?e.concat(l,l.visualViewport||[],a(i)?i:[]):e.concat(i,F(i))}function A(e,i,r){return "viewport"===i?l$1(function(t,e){const o=n(t),i=x(t),r=o.visualViewport;let l=i.clientWidth,c=i.clientHeight,s=0,f=0;if(r){l=r.width,c=r.height;const t=g();(t||!t&&"fixed"===e)&&(s=r.offsetLeft,f=r.offsetTop);}return {width:l,height:c,x:s,y:f}}(e,r)):s(i)?function(t,e){const n=w(t,!0,"fixed"===e),o=n.top+t.clientTop,i=n.left+t.clientLeft,r=c(t)?y(t):{x:1,y:1},l=t.clientWidth*r.x,s=t.clientHeight*r.y,f=i*r.x,u=o*r.y;return {top:u,left:f,right:f+l,bottom:u+s,x:f,y:u,width:l,height:s}}(i,r):l$1(function(t){var e;const n=x(t),i=v(t),r=null==(e=t.ownerDocument)?void 0:e.body,l=C(n.scrollWidth,n.clientWidth,r?r.scrollWidth:0,r?r.clientWidth:0),c=C(n.scrollHeight,n.clientHeight,r?r.scrollHeight:0,r?r.clientHeight:0);let s=-i.scrollLeft+b(t);const f=-i.scrollTop;return "rtl"===o(r||n).direction&&(s+=C(n.clientWidth,r?r.clientWidth:0)-l),{width:l,height:c,x:s,y:f}}(x(e)))}const H={getClippingRect:function(t){let{element:e,boundary:n,rootBoundary:r,strategy:l}=t;const c="clippingAncestors"===n?function(t,e){const n=e.get(t);if(n)return n;let r=F(t).filter((t=>s(t)&&"body"!==i(t))),l=null;const c="fixed"===o(t).position;let f=c?E(t):t;for(;s(f)&&!m(f);){const t=o(f),e=h(f);(c?e||l:e||"static"!==t.position||!l||!["absolute","fixed"].includes(l.position))?l=t:r=r.filter((t=>t!==f)),f=E(f);}return e.set(t,r),r}(e,this._c):[].concat(n),f=[...c,r],u=f[0],a=f.reduce(((t,n)=>{const o=A(e,n,l);return t.top=C(o.top,t.top),t.right=W(o.right,t.right),t.bottom=W(o.bottom,t.bottom),t.left=C(o.left,t.left),t}),A(e,u,l));return {width:a.right-a.left,height:a.bottom-a.top,x:a.left,y:a.top}},convertOffsetParentRelativeRectToViewportRelativeRect:function(t){let{rect:e,offsetParent:n,strategy:o}=t;const r=c(n),l=x(n);if(n===l)return e;let s={scrollLeft:0,scrollTop:0},f={x:1,y:1};const u={x:0,y:0};if((r||!r&&"fixed"!==o)&&(("body"!==i(n)||a(l))&&(s=v(n)),c(n))){const t=w(n);f=y(n),u.x=t.x+n.clientLeft,u.y=t.y+n.clientTop;}return {width:e.width*f.x,height:e.height*f.y,x:e.x*f.x-s.scrollLeft*f.x+u.x,y:e.y*f.y-s.scrollTop*f.y+u.y}},isElement:s,getDimensions:function(t){if(c(t))return {width:t.offsetWidth,height:t.offsetHeight};const e=w(t);return {width:e.width,height:e.height}},getOffsetParent:T,getDocumentElement:x,getScale:y,async getElementRects(t){let{reference:e,floating:n,strategy:o}=t;const i=this.getOffsetParent||T,r=this.getDimensions;return {reference:L(e,await i(n),o),floating:{x:0,y:0,...await r(n)}}},getClientRects:t=>Array.from(t.getClientRects()),isRTL:t=>"rtl"===o(t).direction};function S(t,e,n,o){void 0===o&&(o={});const{ancestorScroll:i=!0,ancestorResize:r=!0,elementResize:l=!0,animationFrame:c=!1}=o,f=i&&!c,u=f||r?[...s(t)?F(t):t.contextElement?F(t.contextElement):[],...F(e)]:[];u.forEach((t=>{f&&t.addEventListener("scroll",n,{passive:!0}),r&&t.addEventListener("resize",n);}));let a,d=null;if(l){let o=!0;d=new ResizeObserver((()=>{o||n(),o=!1;})),s(t)&&!c&&d.observe(t),s(t)||!t.contextElement||c||d.observe(t.contextElement),d.observe(e);}let h=c?w(t):null;return c&&function e(){const o=w(t);!h||o.x===h.x&&o.y===h.y&&o.width===h.width&&o.height===h.height||n();h=o,a=requestAnimationFrame(e);}(),n(),()=>{var t;u.forEach((t=>{f&&t.removeEventListener("scroll",n),r&&t.removeEventListener("resize",n);})),null==(t=d)||t.disconnect(),d=null,c&&cancelAnimationFrame(a);}}const O=(t,n,o)=>{const i=new Map,r={platform:H,...o},l={...r.platform,_c:i};return i$1(t,n,{...r,platform:l})};
456
457const AutocompleteContextId = createContextId("autocomplete-root");
458
459const AutocompleteRoot = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
460 const props1 = _restProps(props, [
461 "defaultValue"
462 ]);
463 const options = useStore([]);
464 const filteredOptions = useStore([]);
465 const selectedOption = useSignal(props.defaultValue ? props.defaultValue : "");
466 const isExpanded = useSignal(false);
467 const triggerRef = useSignal();
468 const listBoxRef = useSignal();
469 const rootRef = useSignal();
470 const labelRef = useSignal();
471 const inputValue = useSignal(props.defaultValue ? props.defaultValue : "");
472 const listBoxId = useId();
473 const inputId = useId();
474 const triggerId = useId();
475 const activeOptionId = useSignal(null);
476 const focusInput$ = /* @__PURE__ */ inlinedQrl((inputId2) => {
477 const [rootRef2] = useLexicalScope();
478 rootRef2.value?.querySelector(`[data-autocomplete-input-id="${inputId2}"]`)?.focus();
479 }, "AutocompleteRoot_component_focusInput_ympUatoO4zs", [
480 rootRef
481 ]);
482 const contextService = {
483 options,
484 filteredOptions,
485 selectedOption,
486 isExpanded,
487 triggerRef,
488 listBoxRef,
489 labelRef,
490 inputValue,
491 listBoxId,
492 inputId,
493 triggerId,
494 activeOptionId,
495 focusInput$
496 };
497 useContextProvider(AutocompleteContextId, contextService);
498 const updatePosition = /* @__PURE__ */ inlinedQrl((referenceEl, floatingEl) => {
499 O(referenceEl, floatingEl, {
500 placement: "bottom",
501 middleware: [
502 b$1()
503 ]
504 }).then(({ x, y }) => {
505 Object.assign(floatingEl.style, {
506 left: `${x}px`,
507 top: `${y}px`
508 });
509 });
510 }, "AutocompleteRoot_component_updatePosition_C1fynSf09uw");
511 useVisibleTaskQrl(/* @__PURE__ */ inlinedQrl(async ({ track }) => {
512 const [contextService2, isExpanded2, updatePosition2] = useLexicalScope();
513 const trigger = track(() => contextService2.triggerRef.value);
514 const listBox = track(() => contextService2.listBoxRef.value);
515 const expanded = track(() => isExpanded2.value);
516 if (!trigger || !listBox)
517 return;
518 if (expanded === true) {
519 listBox.style.visibility = "hidden";
520 await updatePosition2(trigger, listBox);
521 listBox.style.visibility = "visible";
522 listBox?.focus();
523 }
524 if (expanded === false)
525 trigger?.focus();
526 }, "AutocompleteRoot_component_useVisibleTask_YM0YQy6ylMI", [
527 contextService,
528 isExpanded,
529 updatePosition
530 ]));
531 useOnWindow("click", /* @__PURE__ */ inlinedQrl((e) => {
532 const [contextService2] = useLexicalScope();
533 const target = e.target;
534 if (contextService2.isExpanded.value === true && !contextService2.listBoxRef.value?.contains(target) && !contextService2.triggerRef.value?.contains(target))
535 contextService2.isExpanded.value = false;
536 }, "AutocompleteRoot_component_useOnWindow_nlwR8BFcQiY", [
537 contextService
538 ]));
539 return /* @__PURE__ */ _jsxS("div", {
540 ...props1,
541 ref: rootRef,
542 children: /* @__PURE__ */ _jsxC(Slot, null, 3, "XJ_0"),
543 onKeyDown$: [
544 /* @__PURE__ */ inlinedQrl((e) => {
545 const [contextService2] = useLexicalScope();
546 if (e.key === "Escape") {
547 contextService2.isExpanded.value = false;
548 const inputElement = contextService2.triggerRef.value?.firstElementChild;
549 inputElement?.focus();
550 }
551 }, "AutocompleteRoot_component_div_onKeyDown_sTRTEBYUlQc", [
552 contextService
553 ]),
554 props1.onKeyDown$
555 ]
556 }, null, 0, "XJ_1");
557}, "AutocompleteRoot_component_vXjTqQMRfek"));
558
559const AutocompleteLabel = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
560 const ref = useSignal();
561 const contextService = useContext(AutocompleteContextId);
562 contextService.labelRef = ref;
563 return /* @__PURE__ */ _jsxS("label", {
564 ...props,
565 children: /* @__PURE__ */ _jsxC(Slot, null, 3, "vq_0")
566 }, {
567 for: _fnSignal((p0) => p0.inputId, [
568 contextService
569 ], "p0.inputId")
570 }, 0, "vq_1");
571}, "AutocompleteLabel_component_Leh0ZNkltzc"));
572
573const AutocompleteControl = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
574 const ref = useSignal();
575 const contextService = useContext(AutocompleteContextId);
576 contextService.triggerRef = ref;
577 return /* @__PURE__ */ _jsxS("div", {
578 ref,
579 ...props,
580 children: /* @__PURE__ */ _jsxC(Slot, null, 3, "9e_0")
581 }, null, 0, "9e_1");
582}, "AutocompleteControl_component_HoXuGbctnX8"));
583
584const autocompletePreventedKeys = [
585 KeyCode.Home,
586 KeyCode.End,
587 KeyCode.PageDown,
588 KeyCode.PageUp,
589 KeyCode.ArrowDown,
590 KeyCode.ArrowUp
591];
592const AutocompleteInput = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
593 const ref = useSignal();
594 const contextService = useContext(AutocompleteContextId);
595 useVisibleTaskQrl(/* @__PURE__ */ inlinedQrl(function preventDefaultTask({ cleanup }) {
596 const [ref2] = useLexicalScope();
597 function keyHandler(e) {
598 if (autocompletePreventedKeys.includes(e.key))
599 e.preventDefault();
600 }
601 ref2.value?.addEventListener("keydown", keyHandler);
602 cleanup(() => {
603 ref2.value?.removeEventListener("keydown", keyHandler);
604 });
605 }, "AutocompleteInput_component_useVisibleTask_thYHaSqtZmg", [
606 ref
607 ]));
608 useVisibleTaskQrl(/* @__PURE__ */ inlinedQrl(async ({ track }) => {
609 const [contextService2, ref2] = useLexicalScope();
610 track(() => contextService2.inputValue.value);
611 contextService2.filteredOptions = contextService2.options.filter((option) => {
612 const optionValue = option.value.getAttribute("optionValue");
613 const inputValue = contextService2.inputValue.value;
614 const defaultFilter = new RegExp(inputValue, "i");
615 if (contextService2.inputValue.value.length >= 0 && document.activeElement === ref2.value) {
616 if (optionValue === inputValue)
617 contextService2.isExpanded.value = false;
618 else if (optionValue.match(defaultFilter))
619 contextService2.isExpanded.value = true;
620 } else
621 contextService2.isExpanded.value = false;
622 return optionValue.match(defaultFilter);
623 });
624 contextService2.options.map((option) => {
625 if (!option.value.getAttribute("optionValue").match(new RegExp(contextService2.inputValue.value, "i")))
626 option.value.style.display = "none";
627 else
628 option.value.style.display = "";
629 });
630 }, "AutocompleteInput_component_useVisibleTask_1_VyuLbo0324M", [
631 contextService,
632 ref
633 ]));
634 return /* @__PURE__ */ _jsxS("input", {
635 ref,
636 ...props,
637 "onInput$": /* @__PURE__ */ inlinedQrl((_, elm) => {
638 const [contextService2] = useLexicalScope();
639 return contextService2.inputValue.value = elm.value;
640 }, "AutocompleteInput_component_input_bind_value_t722JOYUiD0", [
641 contextService
642 ]),
643 onKeyDown$: [
644 /* @__PURE__ */ inlinedQrl((e) => {
645 const [contextService2] = useLexicalScope();
646 if (e.key === "ArrowDown") {
647 contextService2.isExpanded.value = true;
648 contextService2.filteredOptions[0]?.value?.focus();
649 }
650 }, "AutocompleteInput_component_input_onKeyDown_EuX8MfHcVXc", [
651 contextService
652 ]),
653 props.onKeyDown$
654 ]
655 }, {
656 "data-autocomplete-input-id": _fnSignal((p0) => p0.inputId, [
657 contextService
658 ], "p0.inputId"),
659 role: "combobox",
660 "aria-invalid": _fnSignal((p0) => p0["aria-invalid"] || false, [
661 props
662 ], 'p0["aria-invalid"]||false'),
663 id: _fnSignal((p0) => p0.inputId, [
664 contextService
665 ], "p0.inputId"),
666 "aria-autocomplete": "list",
667 "aria-haspopup": "listbox",
668 "aria-controls": _fnSignal((p0) => p0.listBoxId, [
669 contextService
670 ], "p0.listBoxId"),
671 "aria-expanded": _fnSignal((p0) => p0.isExpanded.value, [
672 contextService
673 ], "p0.isExpanded.value"),
674 "aria-disabled": _fnSignal((p0) => p0["aria-disabled"] || false, [
675 props
676 ], 'p0["aria-disabled"]||false'),
677 "aria-label": _fnSignal((p0) => p0.labelRef.value ? void 0 : p0.inputValue.value, [
678 contextService
679 ], "p0.labelRef.value?undefined:p0.inputValue.value"),
680 "aria-required": _fnSignal((p0) => p0["aria-required"] || false, [
681 props
682 ], 'p0["aria-required"]||false'),
683 "value": contextService.inputValue
684 }, 0, "uX_0");
685}, "AutocompleteInput_component_0lwjKc4pIhE"));
686
687const AutocompleteTrigger = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl(({ ...props }) => {
688 const contextService = useContext(AutocompleteContextId);
689 return /* @__PURE__ */ _jsxS("button", {
690 ...props,
691 children: /* @__PURE__ */ _jsxC(Slot, null, 3, "h3_0"),
692 // add their own custom onClick with our onClick functionality
693 onClick$: [
694 /* @__PURE__ */ inlinedQrl(() => {
695 const [contextService2] = useLexicalScope();
696 return contextService2.isExpanded.value = !contextService2.isExpanded.value;
697 }, "AutocompleteTrigger_component_button_onClick_Z5Ur56odKNw", [
698 contextService
699 ]),
700 props.onClick$
701 ]
702 }, {
703 id: _fnSignal((p0) => p0.triggerId, [
704 contextService
705 ], "p0.triggerId"),
706 "aria-expanded": _fnSignal((p0) => p0.isExpanded.value, [
707 contextService
708 ], "p0.isExpanded.value"),
709 "aria-label": "listbox toggle trigger",
710 "aria-haspopup": "listbox",
711 "aria-controls": _fnSignal((p0) => p0.listBoxId, [
712 contextService
713 ], "p0.listBoxId"),
714 tabIndex: -1
715 }, 0, "h3_1");
716}, "AutocompleteTrigger_component_X4cPs5Kv8iA"));
717
718const preventedKeys$1 = [
719 KeyCode.Home,
720 KeyCode.End,
721 KeyCode.PageDown,
722 KeyCode.PageUp,
723 KeyCode.ArrowDown,
724 KeyCode.ArrowUp
725];
726const AutocompleteListbox = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
727 const ref = useSignal();
728 const contextService = useContext(AutocompleteContextId);
729 useVisibleTaskQrl(/* @__PURE__ */ inlinedQrl(function preventDefaultTask({ cleanup }) {
730 const [ref2] = useLexicalScope();
731 function keyHandler(e) {
732 if (preventedKeys$1.includes(e.key))
733 e.preventDefault();
734 }
735 ref2.value?.addEventListener("keydown", keyHandler);
736 cleanup(() => {
737 ref2.value?.removeEventListener("keydown", keyHandler);
738 });
739 }, "AutocompleteListbox_component_useVisibleTask_Ezcf8dU18EU", [
740 ref
741 ]));
742 return /* @__PURE__ */ _jsxS("ul", {
743 ref,
744 ...props,
745 children: /* @__PURE__ */ _jsxC(Slot, null, 3, "D6_0"),
746 // aria-label={!contextService.labelRef.value ? contextService.inputValue.value : undefined}
747 onKeyDown$: [
748 /* @__PURE__ */ inlinedQrl((e) => {
749 const [contextService2] = useLexicalScope();
750 const availableOptions = contextService2.filteredOptions.map((option) => option.value);
751 const target = e.target;
752 const currentIndex = availableOptions.indexOf(target);
753 if (e.key === "ArrowDown") {
754 if (currentIndex === availableOptions.length - 1)
755 availableOptions[0]?.focus();
756 else
757 availableOptions[currentIndex + 1]?.focus();
758 }
759 if (e.key === "ArrowUp") {
760 if (currentIndex <= 0)
761 availableOptions[availableOptions.length - 1]?.focus();
762 else
763 availableOptions[currentIndex - 1]?.focus();
764 }
765 if (e.key === "Home")
766 availableOptions[0]?.focus();
767 if (e.key === "End")
768 availableOptions[availableOptions.length - 1]?.focus();
769 }, "AutocompleteListbox_component_ul_onKeyDown_IqVk5yUZAFQ", [
770 contextService
771 ]),
772 props.onKeyDown$
773 ]
774 }, {
775 id: _fnSignal((p0) => p0.listBoxId, [
776 contextService
777 ], "p0.listBoxId"),
778 style: _fnSignal((p0, p1) => `
779 display: ${p0.isExpanded.value ? "block" : "none"}; position: absolute; z-index: 1; ${p1.style}
780 `, [
781 contextService,
782 props
783 ], '`\n display: ${p0.isExpanded.value?"block":"none"}; position: absolute; z-index: 1; ${p1.style}\n `'),
784 role: "listbox"
785 }, 0, "D6_1");
786}, "AutocompleteListbox_component_GKhRxpVEBKY"));
787
788const AutocompleteOption = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
789 const ref = useSignal();
790 const contextService = useContext(AutocompleteContextId);
791 contextService.options = [
792 ...contextService.options,
793 ref
794 ];
795 return /* @__PURE__ */ _jsxS("li", {
796 ref,
797 ...props,
798 children: /* @__PURE__ */ _jsxC(Slot, null, 3, "RK_0"),
799 onClick$: [
800 /* @__PURE__ */ inlinedQrl(() => {
801 const [contextService2, props2] = useLexicalScope();
802 if (!props2.disabled) {
803 contextService2.inputValue.value = props2.optionValue;
804 contextService2.isExpanded.value = false;
805 }
806 }, "AutocompleteOption_component_li_onClick_0srwbu5LfRI", [
807 contextService,
808 props
809 ]),
810 props.onClick$
811 ],
812 onKeyDown$: [
813 /* @__PURE__ */ inlinedQrl((e) => {
814 const [contextService2, props2] = useLexicalScope();
815 if ((e.key === "Enter" || e.key === " ") && !props2.disabled) {
816 contextService2.inputValue.value = props2.optionValue;
817 contextService2.isExpanded.value = false;
818 contextService2.focusInput$(contextService2.inputId);
819 }
820 }, "AutocompleteOption_component_li_onKeyDown_NW1K4SApSwk", [
821 contextService,
822 props
823 ]),
824 props.onKeyDown$
825 ]
826 }, {
827 role: "option",
828 tabIndex: _fnSignal((p0) => p0.disabled ? -1 : 0, [
829 props
830 ], "p0.disabled?-1:0"),
831 "aria-disabled": _fnSignal((p0) => p0.disabled, [
832 props
833 ], "p0.disabled")
834 }, 0, "RK_1");
835}, "AutocompleteOption_component_ArnQlArjEIU"));
836
837function toVal(mix) {
838 let str = "";
839 if (typeof mix === "string" || typeof mix === "number") {
840 str += mix;
841 } else if (typeof mix === "object") {
842 if (Array.isArray(mix)) {
843 for (let k = 0; k < mix.length; k++) {
844 if (mix[k]) {
845 const y = toVal(mix[k]);
846 if (y) {
847 str && (str += " ");
848 str += y;
849 }
850 }
851 }
852 } else {
853 for (const k in mix) {
854 if (mix[k]) {
855 str && (str += " ");
856 str += k;
857 }
858 }
859 }
860 }
861 return str;
862}
863function clsq(...inputs) {
864 let i = 0;
865 let tmp;
866 let str = "";
867 while (i < inputs.length) {
868 tmp = inputs[i++];
869 if (tmp) {
870 const x = toVal(tmp);
871 if (x) {
872 str && (str += " ");
873 str += x;
874 }
875 }
876 }
877 return str;
878}
879
880const useOrdinal = () => {
881 return noSerialize((n) => {
882 const pr = new Intl.PluralRules("en-GB", { type: "ordinal" });
883 const suffixes = /* @__PURE__ */ new Map([
884 ["one", "st"],
885 ["two", "nd"],
886 ["few", "rd"],
887 ["other", "th"]
888 ]);
889 return `${n}${suffixes.get(pr.select(n))}`;
890 });
891};
892
893const stylesButtons = ":where(button:focus) {\n z-index: 1;\n}\n";
894
895const stylesControl = ":where(input[type='radio']) {\n appearance: none;\n}\n\n:where(div:focus-within) {\n outline: -webkit-focus-ring-color auto 1px;\n z-index: 1;\n}\n";
896
897const stylesItem = ":where(li) {\n /**\n * CAUTION need at least 1px height to scroll to \n * the active item on initial render (startAt)\n */\n min-height: 1px;\n /* */\n scroll-snap-align: start;\n flex-shrink: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n width: auto;\n max-width: 100%;\n height: 100%;\n}\n\n:where(input[type='radio']) {\n appearance: none;\n}\n\n:where(li[aria-current='true']) {\n outline: 0.15em solid;\n outline-offset: 2px;\n border-radius: 1px;\n z-index: 1;\n}\n";
898
899const stylesItems = ":where([attr-data-qui='carousel-wapper']) {\n display: grid;\n}\n\n:where([attr-data-qui='carousel']) {\n /**\n give some room for showing the outline on focus.\n Better solution would prevent from hidding the outline\n behind the overflow – stacking issue.\n **/\n padding: 0.3em;\n height: 100%;\n position: relative;\n display: flex;\n align-items: center;\n overflow-x: auto;\n scroll-snap-type: x mandatory;\n overscroll-behavior-x: contain;\n}\n";
900
901const getCount = (ref) => {
902 return getContainer(ref)?.childElementCount || 0;
903};
904const getContainer = (ref) => {
905 return ref.value?.querySelector('[attr-data-qui="carousel"]');
906};
907const getElements = (ref) => {
908 return Array.from(getContainer(ref)?.children || []);
909};
910const getElement = (ref, index) => {
911 return getElements(ref).at(index);
912};
913
914const useVisible = (ref) => {
915 const first = useSignal(0);
916 const last = useSignal(0);
917 const trackVisible = /* @__PURE__ */ inlinedQrl(async (map) => {
918 const items = Array.from(map);
919 let start = 0;
920 let end = 0;
921 items.forEach(([, visible], i) => {
922 if (i === 0 && visible)
923 start = 0;
924 const next = items.at(i + 1)?.[1];
925 if (!visible && next)
926 start = i + 1;
927 if (visible && !next)
928 end = i;
929 });
930 return {
931 start,
932 end
933 };
934 }, "useVisible_trackVisible_ASQcAhU0NT4");
935 useVisibleTaskQrl(/* @__PURE__ */ inlinedQrl(async function trackActiveItems() {
936 const [first2, last2, ref2, trackVisible2] = useLexicalScope();
937 const map = /* @__PURE__ */ new Map();
938 getElements(ref2).forEach((element) => map.set(element, void 0));
939 const observer = new IntersectionObserver((nodes) => {
940 nodes.forEach(async (item) => {
941 map.set(item.target, item.isIntersecting);
942 const { start, end } = await trackVisible2(map);
943 first2.value = start;
944 last2.value = end;
945 });
946 }, {
947 root: getContainer(ref2)
948 });
949 getElements(ref2).forEach((item) => observer.observe(item));
950 }, "useVisible_useVisibleTask_0nEd0KoWmT8", [
951 first,
952 last,
953 ref,
954 trackVisible
955 ]));
956 return {
957 first,
958 last
959 };
960};
961
962const useItems = (ref, params) => {
963 const visible = useVisible(ref);
964 const loop = params?.loop ?? true;
965 const transition = params?.transition || 350;
966 const isFirst = params?.startAt && params?.startAt === 0 || false;
967 const isLast = params?.startAt && params?.startAt + 1 === getCount(ref) || false;
968 const index = params?.startAt || 0;
969 const total = useSignal(0);
970 const active = useStore({
971 isFirst: useSignal(isFirst),
972 isLast: useSignal(isLast),
973 current: useSignal(index)
974 });
975 const scrollAt = /* @__PURE__ */ inlinedQrl((index2) => {
976 const [active2, ref2, transition2] = useLexicalScope();
977 const count = getCount(ref2);
978 const element = getElement(ref2, index2);
979 if (!ref2?.value || !count) {
980 console.warn(`Can't jump to ${index2} because the carousel elements is empty.`);
981 return;
982 }
983 if (!element) {
984 console.warn(`Can't jump to ${index2} because the element index ${index2} doesn't exist.`);
985 return;
986 }
987 setTimeout(() => element.scrollIntoView({
988 behavior: "smooth",
989 block: "nearest",
990 inline: "center"
991 }), transition2);
992 active2.current.value = index2;
993 }, "useItems_scrollAt_w0rF5B4LQ7s", [
994 active,
995 ref,
996 transition
997 ]);
998 const previous = /* @__PURE__ */ inlinedQrl(() => {
999 const [active2, loop2, ref2, scrollAt2] = useLexicalScope();
1000 if (!loop2 && active2.isFirst.value)
1001 return;
1002 const index2 = active2.isFirst.value ? getCount(ref2) - 1 : active2.current.value - 1;
1003 scrollAt2(index2);
1004 }, "useItems_previous_4tOoNm3D6To", [
1005 active,
1006 loop,
1007 ref,
1008 scrollAt
1009 ]);
1010 const next = /* @__PURE__ */ inlinedQrl(() => {
1011 const [active2, loop2, ref2, scrollAt2] = useLexicalScope();
1012 const max = getCount(ref2) - 1;
1013 if (!loop2 && active2.current.value === max)
1014 return;
1015 const index2 = active2.current.value === max ? 0 : active2.current.value + 1;
1016 scrollAt2(index2);
1017 }, "useItems_next_Aw4EtPIWJ2M", [
1018 active,
1019 loop,
1020 ref,
1021 scrollAt
1022 ]);
1023 useOnDocument("focus", /* @__PURE__ */ inlinedQrl(() => {
1024 const [active2, ref2] = useLexicalScope();
1025 getElements(ref2).forEach((element, index2) => {
1026 if (!element.contains(document.activeElement))
1027 return;
1028 active2.current.value = index2;
1029 });
1030 }, "useItems_useOnDocument_o3Qy4RtDcX4", [
1031 active,
1032 ref
1033 ]));
1034 useTaskQrl(/* @__PURE__ */ inlinedQrl(({ track }) => {
1035 const [active2, ref2] = useLexicalScope();
1036 const index2 = track(() => active2.current.value);
1037 active2.isFirst.value = index2 === 0;
1038 active2.isLast.value = index2 + 1 === getCount(ref2);
1039 }, "useItems_useTask_koFKDjM01VA", [
1040 active,
1041 ref
1042 ]));
1043 useVisibleTaskQrl(/* @__PURE__ */ inlinedQrl(() => {
1044 const [active2, ref2, scrollAt2, total2] = useLexicalScope();
1045 total2.value = getCount(ref2);
1046 scrollAt2(active2.current.value);
1047 }, "useItems_useVisibleTask_FPaY6NnxHbA", [
1048 active,
1049 ref,
1050 scrollAt,
1051 total
1052 ]));
1053 return {
1054 active,
1055 visible,
1056 total,
1057 next,
1058 previous,
1059 scrollAt
1060 };
1061};
1062
1063const usePages = (ref, params) => {
1064 const transition = params.transition || 350;
1065 const loop = params.loop ?? true;
1066 const ranges = useSignal([]);
1067 const total = useComputedQrl(/* @__PURE__ */ inlinedQrl(() => {
1068 const [ranges2] = useLexicalScope();
1069 return ranges2.value.length;
1070 }, "usePages_total_useComputed_Tk6xK4k2yQo", [
1071 ranges
1072 ]));
1073 const current = useComputedQrl(/* @__PURE__ */ inlinedQrl(() => {
1074 const [params2, ranges2] = useLexicalScope();
1075 return getPageFromActiveItem(params2.items.active.current.value, ranges2.value);
1076 }, "usePages_current_useComputed_x0idL0BpEos", [
1077 params,
1078 ranges
1079 ]));
1080 const active = params.items.active;
1081 const computePages = /* @__PURE__ */ inlinedQrl(() => {
1082 const [ranges2, ref2] = useLexicalScope();
1083 let acc = 0;
1084 const element = ref2.value?.querySelector('[attr-data-qui="carousel"]');
1085 const widthMax = ref2.value?.getClientRects()[0].width || 1;
1086 const output = [
1087 []
1088 ];
1089 Array.from(element?.children || []).forEach((child, i) => {
1090 const width = child.getClientRects()[0].width;
1091 const next2 = element?.children[i + 1]?.getClientRects()[0].x;
1092 const gap = !next2 ? 0 : width + child.getClientRects()[0].x - next2;
1093 acc += width + Math.abs(gap);
1094 if (!output[Math.ceil(acc / widthMax) - 1])
1095 output.push([]);
1096 output[Math.ceil(acc / widthMax) - 1].push(i);
1097 });
1098 ranges2.value = output;
1099 }, "usePages_computePages_l5SxS96OnmE", [
1100 ranges,
1101 ref
1102 ]);
1103 const scrollAt = /* @__PURE__ */ inlinedQrl((index) => {
1104 const [active2, ref2, transition2] = useLexicalScope();
1105 const count = getCount(ref2);
1106 const element = getElement(ref2, index);
1107 if (!ref2?.value || !count) {
1108 console.warn(`Can't jump to ${index} because the carousel elements is empty.`);
1109 return;
1110 }
1111 if (!element) {
1112 console.warn(`Can't jump to ${index} because the element index ${index} doesn't exist.`);
1113 return;
1114 }
1115 setTimeout(() => element.scrollIntoView({
1116 behavior: "smooth",
1117 block: "nearest",
1118 inline: "center"
1119 }), transition2);
1120 active2.current.value = index;
1121 }, "usePages_scrollAt_0UAHSrJNsa0", [
1122 active,
1123 ref,
1124 transition
1125 ]);
1126 const previous = /* @__PURE__ */ inlinedQrl(() => {
1127 const [current2, loop2, params2, ranges2, scrollAt2] = useLexicalScope();
1128 if (!loop2 && params2.items.active.current.value === 0)
1129 return;
1130 if (params2.items.active.current.value === 0) {
1131 scrollAt2(ranges2.value.at(current2.value - 1)?.[0] || 0);
1132 return;
1133 }
1134 if (current2.value === 0) {
1135 scrollAt2(0);
1136 return;
1137 }
1138 scrollAt2(ranges2.value.at(current2.value - 1)?.[0] || 0);
1139 }, "usePages_previous_c8kpC9y5s5o", [
1140 current,
1141 loop,
1142 params,
1143 ranges,
1144 scrollAt
1145 ]);
1146 const next = /* @__PURE__ */ inlinedQrl(() => {
1147 const [current2, loop2, ranges2, scrollAt2, total2] = useLexicalScope();
1148 if (!loop2 && current2.value + 1 === total2.value)
1149 return;
1150 scrollAt2(ranges2.value.at(current2.value + 1)?.[0] || 0);
1151 }, "usePages_next_04wvMUX0XqE", [
1152 current,
1153 loop,
1154 ranges,
1155 scrollAt,
1156 total
1157 ]);
1158 useVisibleTaskQrl(/* @__PURE__ */ inlinedQrl(() => {
1159 const [computePages2] = useLexicalScope();
1160 return computePages2();
1161 }, "usePages_useVisibleTask_1yNtW2XyCAI", [
1162 computePages
1163 ]));
1164 useOnWindow("resize", computePages);
1165 return {
1166 total,
1167 ranges,
1168 current,
1169 next,
1170 previous,
1171 scrollAt
1172 };
1173};
1174const getPageFromActiveItem = (index, ranges) => {
1175 if (index === 0)
1176 return 0;
1177 return ranges.findIndex((range) => range.find((value) => value === index));
1178};
1179
1180const useCarousel = (params) => {
1181 const generatedId = useId();
1182 const newRef = useSignal(void 0);
1183 const defaultParams = {
1184 id: params?.id || generatedId,
1185 ref: params?.ref || newRef,
1186 startAt: params?.startAt ?? 0,
1187 loop: params?.loop ?? true,
1188 transition: params?.transition ?? 350
1189 };
1190 const items = useItems(defaultParams.ref, {
1191 startAt: defaultParams.startAt,
1192 transition: defaultParams.transition
1193 });
1194 const pages = usePages(defaultParams.ref, {
1195 items,
1196 loop: defaultParams.loop,
1197 transition: defaultParams.transition
1198 });
1199 return {
1200 ...defaultParams,
1201 items,
1202 pages
1203 };
1204};
1205
1206const useScroll = (ref, { items, loop = true, transition = 350 }) => {
1207 const to = /* @__PURE__ */ inlinedQrl((index) => {
1208 const [items2, ref2, transition2] = useLexicalScope();
1209 const count = getCount(ref2);
1210 const element = getElement(ref2, index);
1211 if (!ref2?.value || !count) {
1212 console.warn(`Can't jump to ${index} because the carousel elements is empty.`);
1213 return;
1214 }
1215 if (!element) {
1216 console.warn(`Can't jump to ${index} because the element index ${index} doesn't exist.`);
1217 return;
1218 }
1219 setTimeout(() => element.scrollIntoView({
1220 behavior: "smooth",
1221 block: "nearest",
1222 inline: "center"
1223 }), transition2);
1224 items2.active.current.value = index;
1225 }, "useScroll_to_WrZidvDKeoY", [
1226 items,
1227 ref,
1228 transition
1229 ]);
1230 const previous = /* @__PURE__ */ inlinedQrl(() => {
1231 const [items2, loop2, ref2, to2] = useLexicalScope();
1232 if (!loop2 && items2.active.isFirst.value)
1233 return;
1234 const index = items2.active.isFirst.value ? getCount(ref2) - 1 : items2.active.current.value - 1;
1235 to2(index);
1236 }, "useScroll_previous_rvN0clYB7Bc", [
1237 items,
1238 loop,
1239 ref,
1240 to
1241 ]);
1242 const next = /* @__PURE__ */ inlinedQrl(() => {
1243 const [items2, loop2, ref2, to2] = useLexicalScope();
1244 const max = getCount(ref2) - 1;
1245 if (!loop2 && items2.active.current.value === max)
1246 return;
1247 const index = items2.active.current.value === max ? 0 : items2.active.current.value + 1;
1248 to2(index);
1249 }, "useScroll_next_CXf0hNVuUhM", [
1250 items,
1251 loop,
1252 ref,
1253 to
1254 ]);
1255 useVisibleTaskQrl(/* @__PURE__ */ inlinedQrl(() => {
1256 const [items2, to2] = useLexicalScope();
1257 to2(items2.active.current.value);
1258 }, "useScroll_useVisibleTask_vbzitETuPSM", [
1259 items,
1260 to
1261 ]));
1262 return {
1263 to,
1264 previous,
1265 next
1266 };
1267};
1268
1269const useCarouselProvider = (state) => {
1270 useContextProvider(carouselContext, state);
1271};
1272const carouselContext = createContextId("carousel-root");
1273const Root$2 = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
1274 const props1 = _restProps(props, [
1275 "use"
1276 ]);
1277 const carouselState = useCarousel();
1278 const provider = props.use || carouselState;
1279 useCarouselProvider(provider);
1280 return /* @__PURE__ */ _jsxS("div", {
1281 id: _wrapSignal(provider, "id"),
1282 ref: provider.ref,
1283 ...props1,
1284 children: /* @__PURE__ */ _jsxC(Slot, null, 3, "d4_0")
1285 }, {
1286 role: "presentation"
1287 }, 0, "d4_1");
1288}, "Root_component_NRAWrRuxVfc"));
1289const ButtonNext = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
1290 const props1 = _restProps(props, [
1291 "onClick$",
1292 "label"
1293 ]);
1294 useStylesScopedQrl(/* @__PURE__ */ inlinedQrl(stylesButtons, "ButtonNext_component_useStylesScoped_vMMW4PxXQ8w"));
1295 const context = useContext(carouselContext);
1296 return /* @__PURE__ */ _jsxS("button", {
1297 ...props1,
1298 children: /* @__PURE__ */ _jsxC(Slot, null, 3, "d4_2"),
1299 onClick$: [
1300 /* @__PURE__ */ inlinedQrl(() => {
1301 const [context2] = useLexicalScope();
1302 return context2.items.next();
1303 }, "ButtonNext_component_button_onClick_Qc9xlwbsj0Q", [
1304 context
1305 ]),
1306 props.onClick$
1307 ]
1308 }, {
1309 "aria-label": _fnSignal((p0) => p0.label ?? "Go to the next item", [
1310 props
1311 ], 'p0.label??"Go to the next item"'),
1312 disabled: _fnSignal((p0) => !p0.loop ? p0.items.active.isLast.value : false, [
1313 context
1314 ], "!p0.loop?p0.items.active.isLast.value:false")
1315 }, 0, "d4_3");
1316}, "ButtonNext_component_mi0CimL0jFI"));
1317const ButtonPrevious = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
1318 const props1 = _restProps(props, [
1319 "onClick$",
1320 "label"
1321 ]);
1322 useStylesScopedQrl(/* @__PURE__ */ inlinedQrl(stylesButtons, "ButtonPrevious_component_useStylesScoped_fOvx4pn1zRQ"));
1323 const context = useContext(carouselContext);
1324 return /* @__PURE__ */ _jsxS("button", {
1325 ...props1,
1326 children: /* @__PURE__ */ _jsxC(Slot, null, 3, "d4_4"),
1327 onClick$: [
1328 /* @__PURE__ */ inlinedQrl(() => {
1329 const [context2] = useLexicalScope();
1330 return context2.items.previous();
1331 }, "ButtonPrevious_component_button_onClick_m4xC2sNSg0k", [
1332 context
1333 ]),
1334 props.onClick$
1335 ]
1336 }, {
1337 "aria-label": _fnSignal((p0) => p0.label ?? "Go to the previous item", [
1338 props
1339 ], 'p0.label??"Go to the previous item"'),
1340 disabled: _fnSignal((p0) => !p0.loop ? p0.items.active.isFirst.value : false, [
1341 context
1342 ], "!p0.loop?p0.items.active.isFirst.value:false")
1343 }, 0, "d4_5");
1344}, "ButtonPrevious_component_f2CDkWxKAsM"));
1345const Items = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
1346 useStylesScopedQrl(/* @__PURE__ */ inlinedQrl(stylesItems, "Items_component_useStylesScoped_GpZR1tw0n0Q"));
1347 return /* @__PURE__ */ _jsxQ("div", null, {
1348 "attr-data-qui": "carousel-wapper"
1349 }, /* @__PURE__ */ _jsxS("ul", {
1350 ...props,
1351 children: /* @__PURE__ */ _jsxC(Slot, null, 3, "d4_6")
1352 }, {
1353 "attr-data-qui": "carousel"
1354 }, 0, null), 1, "d4_7");
1355}, "Items_component_IQtmkwvbnI0"));
1356const Item = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
1357 const props1 = _restProps(props, [
1358 "index",
1359 "label"
1360 ]);
1361 useStylesScopedQrl(/* @__PURE__ */ inlinedQrl(stylesItem, "Item_component_useStylesScoped_lzrIZT9GSBU"));
1362 const context = useContext(carouselContext);
1363 return /* @__PURE__ */ _jsxS("li", {
1364 ...props1,
1365 children: [
1366 /* @__PURE__ */ _jsxQ("input", null, {
1367 "aria-label": _fnSignal((p0) => p0.label, [
1368 props
1369 ], "p0.label"),
1370 type: "radio",
1371 checked: _fnSignal((p0, p1) => p0.items.active.current.value === p1.index, [
1372 context,
1373 props
1374 ], "p0.items.active.current.value===p1.index"),
1375 name: _fnSignal((p0) => `item-${p0.id}`, [
1376 context
1377 ], "`item-${p0.id}`"),
1378 onChange$: /* @__PURE__ */ inlinedQrl(() => {
1379 const [context2, props2] = useLexicalScope();
1380 return context2.items.scrollAt(props2.index);
1381 }, "Item_component_li_input_onChange_s56tIypzlRA", [
1382 context,
1383 props
1384 ])
1385 }, null, 3, null),
1386 /* @__PURE__ */ _jsxC(Slot, null, 3, "d4_8")
1387 ]
1388 }, {
1389 "aria-current": _fnSignal((p0, p1) => p0.items.active.current.value === p1.index, [
1390 context,
1391 props
1392 ], "p0.items.active.current.value===p1.index")
1393 }, 0, "d4_9");
1394}, "Item_component_OYfNf5CqpyM"));
1395const controlContext = createContextId("carousel-control-root");
1396const Controls = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
1397 _jsxBranch();
1398 const uniqueId = useId();
1399 const controlService = {
1400 id: props.id || uniqueId
1401 };
1402 const context = useContext(carouselContext);
1403 useContextProvider(controlContext, controlService);
1404 return /* @__PURE__ */ _jsxS("nav", {
1405 ...props,
1406 children: context.pages.ranges.value && /* @__PURE__ */ _jsxC(Slot, null, 3, "d4_10")
1407 }, null, 0, "d4_11");
1408}, "Controls_component_tsn2aW4QuKA"));
1409const Control = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
1410 const props1 = _restProps(props, [
1411 "index",
1412 "onClick$",
1413 "label"
1414 ]);
1415 useStylesScopedQrl(/* @__PURE__ */ inlinedQrl(stylesControl, "Control_component_useStylesScoped_L2t1ZYaMmtQ"));
1416 const ordinal = useOrdinal();
1417 const context = useContext(carouselContext);
1418 const context1 = useContext(controlContext);
1419 return /* @__PURE__ */ _jsxS("div", {
1420 ...props1,
1421 children: [
1422 /* @__PURE__ */ _jsxQ("input", null, {
1423 "aria-label": _fnSignal((p0, p1) => p1.label || `Go to the ${p0?.(p1.index + 1)} item`, [
1424 ordinal,
1425 props
1426 ], "p1.label||`Go to the ${p0?.(p1.index+1)} item`"),
1427 type: "radio",
1428 checked: _fnSignal((p0, p1) => p0.items.active.current.value === p1.index, [
1429 context,
1430 props
1431 ], "p0.items.active.current.value===p1.index"),
1432 name: _fnSignal((p0) => `control-${p0.id}`, [
1433 context1
1434 ], "`control-${p0.id}`"),
1435 onChange$: /* @__PURE__ */ inlinedQrl(() => {
1436 const [context2, props2] = useLexicalScope();
1437 return context2.items.scrollAt(props2.index);
1438 }, "Control_component_div_input_onChange_KMuD8ad6BIY", [
1439 context,
1440 props
1441 ])
1442 }, null, 3, null),
1443 /* @__PURE__ */ _jsxC(Slot, null, 3, "d4_12")
1444 ],
1445 onClick$: [
1446 /* @__PURE__ */ inlinedQrl(() => {
1447 const [context2, props2] = useLexicalScope();
1448 return context2.items.scrollAt(props2.index);
1449 }, "Control_component_div_onClick_046SLdYoam0", [
1450 context,
1451 props
1452 ]),
1453 props.onClick$
1454 ]
1455 }, {
1456 "aria-current": _fnSignal((p0, p1) => p0.items.active.current.value === p1.index, [
1457 context,
1458 props
1459 ], "p0.items.active.current.value===p1.index")
1460 }, 0, "d4_13");
1461}, "Control_component_KjEWhtG7Dp4"));
1462const IconPrevious = () => /* @__PURE__ */ _jsxQ("svg", null, {
1463 xmlns: "http://www.w3.org/2000/svg",
1464 width: "24",
1465 height: "24",
1466 viewBox: "0 0 24 24",
1467 fill: "none",
1468 stroke: "currentColor",
1469 "stroke-width": "2",
1470 "stroke-linecap": "round",
1471 "stroke-linejoin": "round"
1472}, /* @__PURE__ */ _jsxQ("polyline", null, {
1473 points: "15 18 9 12 15 6"
1474}, null, 3, null), 3, "d4_14");
1475const IconNext = () => /* @__PURE__ */ _jsxQ("svg", null, {
1476 xmlns: "http://www.w3.org/2000/svg",
1477 width: "24",
1478 height: "24",
1479 viewBox: "0 0 24 24",
1480 fill: "none",
1481 stroke: "currentColor",
1482 "stroke-width": "2",
1483 "stroke-linecap": "round",
1484 "stroke-linejoin": "round"
1485}, /* @__PURE__ */ _jsxQ("polyline", null, {
1486 points: "9 18 15 12 9 6"
1487}, null, 3, null), 3, "d4_15");
1488const IconChevronLeft = () => /* @__PURE__ */ _jsxQ("svg", null, {
1489 xmlns: "http://www.w3.org/2000/svg",
1490 width: "24",
1491 height: "24",
1492 viewBox: "0 0 24 24",
1493 fill: "none",
1494 stroke: "currentColor",
1495 "stroke-width": "2",
1496 "stroke-linecap": "round",
1497 "stroke-linejoin": "round",
1498 class: "lucide lucide-chevrons-left"
1499}, [
1500 /* @__PURE__ */ _jsxQ("polyline", null, {
1501 points: "11 17 6 12 11 7"
1502 }, null, 3, null),
1503 /* @__PURE__ */ _jsxQ("polyline", null, {
1504 points: "18 17 13 12 18 7"
1505 }, null, 3, null)
1506], 3, "d4_16");
1507const IconChevronRight = () => /* @__PURE__ */ _jsxQ("svg", null, {
1508 xmlns: "http://www.w3.org/2000/svg",
1509 width: "24",
1510 height: "24",
1511 viewBox: "0 0 24 24",
1512 fill: "none",
1513 stroke: "currentColor",
1514 "stroke-width": "2",
1515 "stroke-linecap": "round",
1516 "stroke-linejoin": "round",
1517 class: "lucide lucide-chevrons-right"
1518}, [
1519 /* @__PURE__ */ _jsxQ("polyline", null, {
1520 points: "13 17 18 12 13 7"
1521 }, null, 3, null),
1522 /* @__PURE__ */ _jsxQ("polyline", null, {
1523 points: "6 17 11 12 6 7"
1524 }, null, 3, null)
1525], 3, "d4_17");
1526
1527const carousel = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
1528 __proto__: null,
1529 ButtonNext,
1530 ButtonPrevious,
1531 Control,
1532 Controls,
1533 IconChevronLeft,
1534 IconChevronRight,
1535 IconNext,
1536 IconPrevious,
1537 Item,
1538 Items,
1539 Root: Root$2,
1540 carouselContext,
1541 controlContext,
1542 useCarouselProvider
1543}, Symbol.toStringTag, { value: 'Module' }));
1544
1545const Button = ({ children, ...props }) => {
1546 return /* @__PURE__ */ jsx("button", { ...props, children });
1547};
1548
1549component$((props) => {
1550 const {
1551 pressed: pressedProp,
1552 defaultPressed = false,
1553 onClick$,
1554 disabled,
1555 ...toggleProps
1556 } = props;
1557 const pressedState = useSignal(pressedProp || defaultPressed);
1558 return /* @__PURE__ */ jsx(
1559 "input",
1560 {
1561 type: "checkbox",
1562 role: "switch",
1563 "aria-pressed": pressedState.value,
1564 "data-state": pressedState.value ? "on" : "off",
1565 "data-disabled": disabled ? "" : void 0,
1566 checked: pressedState.value,
1567 onClick$: (event) => {
1568 if (!disabled) {
1569 pressedState.value = !pressedState.value;
1570 if (onClick$) {
1571 onClick$(event);
1572 }
1573 }
1574 },
1575 ...toggleProps
1576 }
1577 );
1578});
1579
1580const range = (start, end) => {
1581 const length = end - start + 1;
1582 return Array.from({
1583 length
1584 }, (_, i) => start + i);
1585};
1586const getPaginationButtons = (page, count, labels, { boundaryCount = 1, siblingCount = 1, hidePrevButton, hideNextButton, showFirstButton, showLastButton }) => {
1587 const startPages = range(1, Math.min(boundaryCount, count));
1588 const endPages = range(Math.max(count - boundaryCount + 1, boundaryCount + 1), count);
1589 const siblingsStart = Math.max(
1590 Math.min(
1591 page - siblingCount,
1592 count - boundaryCount - siblingCount * 2 - 1
1593 // Lower boundary when page is high
1594 ),
1595 boundaryCount + 2
1596 // Greater than startPages
1597 );
1598 const siblingsEnd = Math.min(
1599 Math.max(
1600 page + siblingCount,
1601 boundaryCount + siblingCount * 2 + 2
1602 // Upper boundary when page is low
1603 ),
1604 endPages.length > 0 ? endPages[0] - 2 : count - 1
1605 // Less than endPages
1606 );
1607 const items = [
1608 ...showFirstButton ? [
1609 "first"
1610 ] : [],
1611 ...hidePrevButton ? [] : [
1612 "prev"
1613 ],
1614 ...startPages,
1615 ...siblingsStart > boundaryCount + 2 ? [
1616 "divider"
1617 ] : boundaryCount + 1 < count - boundaryCount ? [
1618 boundaryCount + 1
1619 ] : [],
1620 ...range(siblingsStart, siblingsEnd),
1621 ...siblingsEnd < count - boundaryCount - 1 ? [
1622 "divider"
1623 ] : count - boundaryCount > boundaryCount ? [
1624 count - boundaryCount
1625 ] : [],
1626 ...endPages,
1627 ...hideNextButton ? [] : [
1628 "next"
1629 ],
1630 ...showLastButton ? [
1631 "last"
1632 ] : []
1633 ];
1634 return items;
1635};
1636const PaginationButton = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl(({ "aria-label": ariaLabel, disabled, onClick$, key, value }) => {
1637 return /* @__PURE__ */ _jsxC(Button, {
1638 onClick$,
1639 "aria-label": ariaLabel,
1640 disabled,
1641 children: value
1642 }, 0, key);
1643}, "PaginationButton_component_jbwPgRg00Pk"));
1644const PaginationDivider = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl(() => {
1645 return /* @__PURE__ */ _jsxQ("span", null, null, "...", 3, "f1_0");
1646}, "PaginationDivider_component_wW5KtiyjHRk"));
1647const Pagination = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
1648 const rest = _restProps(props, [
1649 "RenderItem",
1650 "RenderDivider",
1651 "onPaging$",
1652 "page",
1653 "pages",
1654 "activeClass",
1655 "defaultClass",
1656 "labels"
1657 ]);
1658 const _onPaging$ = /* @__PURE__ */ inlinedQrl((page) => {
1659 const [props2] = useLexicalScope();
1660 if (page < 1 || page > props2.pages)
1661 return;
1662 props2.onPaging$(page);
1663 }, "Pagination_component__onPaging_ddNDknazsIA", [
1664 props
1665 ]);
1666 const itemClickHandler = /* @__PURE__ */ inlinedQrl((item) => {
1667 const [_onPaging$2, props2] = useLexicalScope();
1668 return _onPaging$2((() => {
1669 switch (item) {
1670 case "first":
1671 return 1;
1672 case "prev":
1673 return props2.page - 1;
1674 case "next":
1675 return props2.page + 1;
1676 case "last":
1677 return props2.pages;
1678 default:
1679 if (typeof item === "number")
1680 return item;
1681 return props2.page;
1682 }
1683 })());
1684 }, "Pagination_component_itemClickHandler_rfL9vVzPwYw", [
1685 _onPaging$,
1686 props
1687 ]);
1688 const items = getPaginationButtons(props.page, props.pages, props.labels, rest);
1689 return /* @__PURE__ */ _jsxC(Fragment, {
1690 children: items.map((item, i) => {
1691 return /* @__PURE__ */ _jsxC(Fragment, {
1692 children: item === "divider" ? /* @__PURE__ */ _jsxC(props.RenderDivider ?? PaginationDivider, null, 3, i) : /* @__PURE__ */ _jsxC(props.RenderItem ?? PaginationButton, {
1693 get activeClass() {
1694 return props.activeClass;
1695 },
1696 get defaultClass() {
1697 return props.defaultClass;
1698 },
1699 get labels() {
1700 return props.labels;
1701 },
1702 onClick$: /* @__PURE__ */ inlinedQrl(() => {
1703 const [item2, itemClickHandler2] = useLexicalScope();
1704 return itemClickHandler2(item2);
1705 }, "Pagination_component__Fragment__Fragment_onClick_u7xsZhx3bhM", [
1706 item,
1707 itemClickHandler
1708 ]),
1709 disabled: [
1710 "prev",
1711 "first"
1712 ].includes(item.toString()) && props.page === 1 || [
1713 "next",
1714 "last"
1715 ].includes(item.toString()) && props.page === props.pages,
1716 "aria-label": `Page ${item}`,
1717 "aria-current": item === props.page,
1718 value: item,
1719 [_IMMUTABLE]: {
1720 activeClass: _fnSignal((p0) => p0.activeClass, [
1721 props
1722 ], "p0.activeClass"),
1723 defaultClass: _fnSignal((p0) => p0.defaultClass, [
1724 props
1725 ], "p0.defaultClass"),
1726 labels: _fnSignal((p0) => p0.labels, [
1727 props
1728 ], "p0.labels")
1729 }
1730 }, 3, i)
1731 }, 1, "f1_1");
1732 })
1733 }, 1, "f1_2");
1734}, "Pagination_component_W5aD6KjRTnY"));
1735
1736const Collapse = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
1737 const random = Math.random() * 1e3;
1738 const state = useSignal("closed");
1739 return /* @__PURE__ */ _jsxQ("div", null, {
1740 "data-state": _fnSignal((p0) => p0.value, [
1741 state
1742 ], "p0.value"),
1743 class: _fnSignal((p0) => p0.class, [
1744 props
1745 ], "p0.class")
1746 }, [
1747 /* @__PURE__ */ _jsxQ("style", null, {
1748 dangerouslySetInnerHTML: `
1749 @keyframes DummyIn {
1750 to: { opacity(1); }
1751 }
1752 @keyframes DummyOut {
1753 to: { opacity(0); }
1754 }
1755 [data-state='closing'] > div {
1756 animation: DummyOut 1ms linear forwards;
1757 }
1758 [data-state='open'] > div {
1759 animation: DummyIn 1ms linear forwards;
1760 }
1761 [data-state='closed'] > div {
1762 display: none;
1763 }
1764 `
1765 }, null, 3, null),
1766 /* @__PURE__ */ _jsxQ("button", {
1767 "aria-controls": random.toString()
1768 }, {
1769 "aria-expanded": _fnSignal((p0) => p0.value === "open", [
1770 state
1771 ], 'p0.value==="open"'),
1772 onClick$: /* @__PURE__ */ inlinedQrl(() => {
1773 const [state2] = useLexicalScope();
1774 return state2.value === "open" ? state2.value = "closing" : state2.value = "open";
1775 }, "Collapse_component_div_button_onClick_E5blXWvrWRA", [
1776 state
1777 ])
1778 }, /* @__PURE__ */ _jsxC(Slot, {
1779 name: "label",
1780 [_IMMUTABLE]: {
1781 name: _IMMUTABLE
1782 }
1783 }, 3, "Ji_0"), 1, null),
1784 /* @__PURE__ */ _jsxQ("div", {
1785 id: random.toString()
1786 }, {
1787 onAnimationEnd$: /* @__PURE__ */ inlinedQrl(() => {
1788 const [state2] = useLexicalScope();
1789 state2.value === "closing" ? state2.value = "closed" : state2.value;
1790 }, "Collapse_component_div_div_onAnimationEnd_hh05FvQ4qm8", [
1791 state
1792 ])
1793 }, /* @__PURE__ */ _jsxC(Slot, {
1794 name: "content",
1795 [_IMMUTABLE]: {
1796 name: _IMMUTABLE
1797 }
1798 }, 3, "Ji_1"), 1, null)
1799 ], 1, "Ji_2");
1800}, "Collapse_component_YdCJfq0QZV8"));
1801
1802const drawerContext = createContextId("DrawerContext");
1803const Drawer = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
1804 const randomId = (Math.random() * 1e3).toString();
1805 const drawerState = useSignal("closed");
1806 useContextProvider(drawerContext, {
1807 randomId,
1808 drawerState
1809 });
1810 return /* @__PURE__ */ _jsxQ("div", null, {
1811 class: _fnSignal((p0) => p0.class ? p0.class : "", [
1812 props
1813 ], 'p0.class?p0.class:""')
1814 }, /* @__PURE__ */ _jsxC(Slot, null, 3, "yt_0"), 1, "yt_1");
1815}, "Drawer_component_cnMP0d9Lrd8"));
1816
1817const DrawerContent = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
1818 return /* @__PURE__ */ _jsxQ("div", null, {
1819 class: _fnSignal((p0) => p0.class ? p0.class : "", [
1820 props
1821 ], 'p0.class?p0.class:""')
1822 }, /* @__PURE__ */ _jsxC(Slot, null, 3, "id_0"), 1, "id_1");
1823}, "DrawerContent_component_S4XvLy9gxbk"));
1824
1825const DrawerTrigger = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl(() => /* @__PURE__ */ _jsxC(Slot, null, 3, "qO_0"), "DrawerTrigger_component_0zndoeUc9CM"));
1826
1827// This file is a workaround for a bug in web browsers' "native"
1828// ES6 importing system which is uncapable of importing "*.json" files.
1829// https://github.com/catamphetamine/libphonenumber-js/issues/239
1830const 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[01]|83[0-389]|93[0-6])\\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-27-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(?:28|4[14]|5)|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{5}"]]],"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]|3[178]|50|68|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[01]|83[0-389]|93[0-6])\\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-27-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[01]|83[0-389]|93[0-6])\\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-27-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\\d|1(?:[0-7]\\d\\d|8(?:[02]\\d|1[0-246-9])))|(?: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]|97"],"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\\d|606)\\d{5}",[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]|6[0-489]|7[08]|8[0-689]|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{5}"]]],"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{5}"]]],"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",["[489]|59"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[235-7]"]]],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-2]|4790|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","(?:00|[1-57-9]\\d)\\d{7}",[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,[["(?:47220[01]|5(?:05(?:[2-57-9]\\d\\d|6(?:[0-35-9]\\d|4[46]))|57200))\\d{4}|(?: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[19]|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\\d|93980)\\d{4}",[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}"]]]}};
1831
1832// Importing from a ".js" file is a workaround for Node.js "ES Modules"
1833// importing system which is even uncapable of importing "*.json" files.
1834
1835function withMetadataArgument(func, _arguments) {
1836 var args = Array.prototype.slice.call(_arguments);
1837 args.push(metadata);
1838 return func.apply(this, args)
1839}
1840
1841function _typeof$3(obj) { "@babel/helpers - typeof"; return _typeof$3 = "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$3(obj); }
1842
1843function _defineProperties$8(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); } }
1844
1845function _createClass$8(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$8(Constructor.prototype, protoProps); if (staticProps) _defineProperties$8(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
1846
1847function _classCallCheck$8(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
1848
1849function _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); }
1850
1851function _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); }; }
1852
1853function _possibleConstructorReturn(self, call) { if (call && (_typeof$3(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); }
1854
1855function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
1856
1857function _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); }
1858
1859function _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); }
1860
1861function _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; } }
1862
1863function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; }
1864
1865function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
1866
1867function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
1868
1869// https://stackoverflow.com/a/46971044/970769
1870// "Breaking changes in Typescript 2.1"
1871// "Extending built-ins like Error, Array, and Map may no longer work."
1872// "As a recommendation, you can manually adjust the prototype immediately after any super(...) calls."
1873// https://github.com/Microsoft/TypeScript-wiki/blob/main/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work
1874var ParseError = /*#__PURE__*/function (_Error) {
1875 _inherits(ParseError, _Error);
1876
1877 var _super = _createSuper(ParseError);
1878
1879 function ParseError(code) {
1880 var _this;
1881
1882 _classCallCheck$8(this, ParseError);
1883
1884 _this = _super.call(this, code); // Set the prototype explicitly.
1885 // Any subclass of FooError will have to manually set the prototype as well.
1886
1887 Object.setPrototypeOf(_assertThisInitialized(_this), ParseError.prototype);
1888 _this.name = _this.constructor.name;
1889 return _this;
1890 }
1891
1892 return _createClass$8(ParseError);
1893}( /*#__PURE__*/_wrapNativeSuper(Error));
1894
1895// The minimum length of the national significant number.
1896var MIN_LENGTH_FOR_NSN = 2; // The ITU says the maximum length should be 15,
1897// but one can find longer numbers in Germany.
1898
1899var MAX_LENGTH_FOR_NSN = 17; // The maximum length of the country calling code.
1900
1901var MAX_LENGTH_COUNTRY_CODE = 3; // Digits accepted in phone numbers
1902// (ascii, fullwidth, arabic-indic, and eastern arabic digits).
1903
1904var VALID_DIGITS = "0-9\uFF10-\uFF19\u0660-\u0669\u06F0-\u06F9"; // `DASHES` will be right after the opening square bracket of the "character class"
1905
1906var DASHES = "-\u2010-\u2015\u2212\u30FC\uFF0D";
1907var SLASHES = "\uFF0F/";
1908var DOTS = "\uFF0E.";
1909var WHITESPACE = " \xA0\xAD\u200B\u2060\u3000";
1910var BRACKETS = "()\uFF08\uFF09\uFF3B\uFF3D\\[\\]"; // export const OPENING_BRACKETS = '(\uFF08\uFF3B\\\['
1911
1912var TILDES = "~\u2053\u223C\uFF5E"; // Regular expression of acceptable punctuation found in phone numbers. This
1913// excludes punctuation found as a leading character only. This consists of dash
1914// characters, white space characters, full stops, slashes, square brackets,
1915// parentheses and tildes. Full-width variants are also present.
1916
1917var VALID_PUNCTUATION = "".concat(DASHES).concat(SLASHES).concat(DOTS).concat(WHITESPACE).concat(BRACKETS).concat(TILDES);
1918var PLUS_CHARS = "+\uFF0B"; // const LEADING_PLUS_CHARS_PATTERN = new RegExp('^[' + PLUS_CHARS + ']+')
1919
1920// Copy-pasted from:
1921// https://github.com/substack/semver-compare/blob/master/index.js
1922//
1923// Inlining this function because some users reported issues with
1924// importing from `semver-compare` in a browser with ES6 "native" modules.
1925//
1926// Fixes `semver-compare` not being able to compare versions with alpha/beta/etc "tags".
1927// https://github.com/catamphetamine/libphonenumber-js/issues/381
1928function compare (a, b) {
1929 a = a.split('-');
1930 b = b.split('-');
1931 var pa = a[0].split('.');
1932 var pb = b[0].split('.');
1933
1934 for (var i = 0; i < 3; i++) {
1935 var na = Number(pa[i]);
1936 var nb = Number(pb[i]);
1937 if (na > nb) return 1;
1938 if (nb > na) return -1;
1939 if (!isNaN(na) && isNaN(nb)) return 1;
1940 if (isNaN(na) && !isNaN(nb)) return -1;
1941 }
1942
1943 if (a[1] && b[1]) {
1944 return a[1] > b[1] ? 1 : a[1] < b[1] ? -1 : 0;
1945 }
1946
1947 return !a[1] && b[1] ? 1 : a[1] && !b[1] ? -1 : 0;
1948}
1949
1950function _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); }
1951
1952function _classCallCheck$7(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
1953
1954function _defineProperties$7(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); } }
1955
1956function _createClass$7(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$7(Constructor.prototype, protoProps); if (staticProps) _defineProperties$7(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
1957
1958var V3 = '1.2.0'; // Moved `001` country code to "nonGeographic" section of metadata.
1959
1960var V4 = '1.7.35';
1961var DEFAULT_EXT_PREFIX = ' ext. ';
1962var CALLING_CODE_REG_EXP = /^\d+$/;
1963/**
1964 * See: https://gitlab.com/catamphetamine/libphonenumber-js/blob/master/METADATA.md
1965 */
1966
1967var Metadata = /*#__PURE__*/function () {
1968 function Metadata(metadata) {
1969 _classCallCheck$7(this, Metadata);
1970
1971 validateMetadata(metadata);
1972 this.metadata = metadata;
1973 setVersion.call(this, metadata);
1974 }
1975
1976 _createClass$7(Metadata, [{
1977 key: "getCountries",
1978 value: function getCountries() {
1979 return Object.keys(this.metadata.countries).filter(function (_) {
1980 return _ !== '001';
1981 });
1982 }
1983 }, {
1984 key: "getCountryMetadata",
1985 value: function getCountryMetadata(countryCode) {
1986 return this.metadata.countries[countryCode];
1987 }
1988 }, {
1989 key: "nonGeographic",
1990 value: function nonGeographic() {
1991 if (this.v1 || this.v2 || this.v3) return; // `nonGeographical` was a typo.
1992 // It's present in metadata generated from `1.7.35` to `1.7.37`.
1993 // The test case could be found by searching for "nonGeographical".
1994
1995 return this.metadata.nonGeographic || this.metadata.nonGeographical;
1996 }
1997 }, {
1998 key: "hasCountry",
1999 value: function hasCountry(country) {
2000 return this.getCountryMetadata(country) !== undefined;
2001 }
2002 }, {
2003 key: "hasCallingCode",
2004 value: function hasCallingCode(callingCode) {
2005 if (this.getCountryCodesForCallingCode(callingCode)) {
2006 return true;
2007 }
2008
2009 if (this.nonGeographic()) {
2010 if (this.nonGeographic()[callingCode]) {
2011 return true;
2012 }
2013 } else {
2014 // A hacky workaround for old custom metadata (generated before V4).
2015 var countryCodes = this.countryCallingCodes()[callingCode];
2016
2017 if (countryCodes && countryCodes.length === 1 && countryCodes[0] === '001') {
2018 return true;
2019 }
2020 }
2021 }
2022 }, {
2023 key: "isNonGeographicCallingCode",
2024 value: function isNonGeographicCallingCode(callingCode) {
2025 if (this.nonGeographic()) {
2026 return this.nonGeographic()[callingCode] ? true : false;
2027 } else {
2028 return this.getCountryCodesForCallingCode(callingCode) ? false : true;
2029 }
2030 } // Deprecated.
2031
2032 }, {
2033 key: "country",
2034 value: function country(countryCode) {
2035 return this.selectNumberingPlan(countryCode);
2036 }
2037 }, {
2038 key: "selectNumberingPlan",
2039 value: function selectNumberingPlan(countryCode, callingCode) {
2040 // Supports just passing `callingCode` as the first argument.
2041 if (countryCode && CALLING_CODE_REG_EXP.test(countryCode)) {
2042 callingCode = countryCode;
2043 countryCode = null;
2044 }
2045
2046 if (countryCode && countryCode !== '001') {
2047 if (!this.hasCountry(countryCode)) {
2048 throw new Error("Unknown country: ".concat(countryCode));
2049 }
2050
2051 this.numberingPlan = new NumberingPlan(this.getCountryMetadata(countryCode), this);
2052 } else if (callingCode) {
2053 if (!this.hasCallingCode(callingCode)) {
2054 throw new Error("Unknown calling code: ".concat(callingCode));
2055 }
2056
2057 this.numberingPlan = new NumberingPlan(this.getNumberingPlanMetadata(callingCode), this);
2058 } else {
2059 this.numberingPlan = undefined;
2060 }
2061
2062 return this;
2063 }
2064 }, {
2065 key: "getCountryCodesForCallingCode",
2066 value: function getCountryCodesForCallingCode(callingCode) {
2067 var countryCodes = this.countryCallingCodes()[callingCode];
2068
2069 if (countryCodes) {
2070 // Metadata before V4 included "non-geographic entity" calling codes
2071 // inside `country_calling_codes` (for example, `"881":["001"]`).
2072 // Now the semantics of `country_calling_codes` has changed:
2073 // it's specifically for "countries" now.
2074 // Older versions of custom metadata will simply skip parsing
2075 // "non-geographic entity" phone numbers with new versions
2076 // of this library: it's not considered a bug,
2077 // because such numbers are extremely rare,
2078 // and developers extremely rarely use custom metadata.
2079 if (countryCodes.length === 1 && countryCodes[0].length === 3) {
2080 return;
2081 }
2082
2083 return countryCodes;
2084 }
2085 }
2086 }, {
2087 key: "getCountryCodeForCallingCode",
2088 value: function getCountryCodeForCallingCode(callingCode) {
2089 var countryCodes = this.getCountryCodesForCallingCode(callingCode);
2090
2091 if (countryCodes) {
2092 return countryCodes[0];
2093 }
2094 }
2095 }, {
2096 key: "getNumberingPlanMetadata",
2097 value: function getNumberingPlanMetadata(callingCode) {
2098 var countryCode = this.getCountryCodeForCallingCode(callingCode);
2099
2100 if (countryCode) {
2101 return this.getCountryMetadata(countryCode);
2102 }
2103
2104 if (this.nonGeographic()) {
2105 var metadata = this.nonGeographic()[callingCode];
2106
2107 if (metadata) {
2108 return metadata;
2109 }
2110 } else {
2111 // A hacky workaround for old custom metadata (generated before V4).
2112 // In that metadata, there was no concept of "non-geographic" metadata
2113 // so metadata for `001` country code was stored along with other countries.
2114 // The test case can be found by searching for:
2115 // "should work around `nonGeographic` metadata not existing".
2116 var countryCodes = this.countryCallingCodes()[callingCode];
2117
2118 if (countryCodes && countryCodes.length === 1 && countryCodes[0] === '001') {
2119 return this.metadata.countries['001'];
2120 }
2121 }
2122 } // Deprecated.
2123
2124 }, {
2125 key: "countryCallingCode",
2126 value: function countryCallingCode() {
2127 return this.numberingPlan.callingCode();
2128 } // Deprecated.
2129
2130 }, {
2131 key: "IDDPrefix",
2132 value: function IDDPrefix() {
2133 return this.numberingPlan.IDDPrefix();
2134 } // Deprecated.
2135
2136 }, {
2137 key: "defaultIDDPrefix",
2138 value: function defaultIDDPrefix() {
2139 return this.numberingPlan.defaultIDDPrefix();
2140 } // Deprecated.
2141
2142 }, {
2143 key: "nationalNumberPattern",
2144 value: function nationalNumberPattern() {
2145 return this.numberingPlan.nationalNumberPattern();
2146 } // Deprecated.
2147
2148 }, {
2149 key: "possibleLengths",
2150 value: function possibleLengths() {
2151 return this.numberingPlan.possibleLengths();
2152 } // Deprecated.
2153
2154 }, {
2155 key: "formats",
2156 value: function formats() {
2157 return this.numberingPlan.formats();
2158 } // Deprecated.
2159
2160 }, {
2161 key: "nationalPrefixForParsing",
2162 value: function nationalPrefixForParsing() {
2163 return this.numberingPlan.nationalPrefixForParsing();
2164 } // Deprecated.
2165
2166 }, {
2167 key: "nationalPrefixTransformRule",
2168 value: function nationalPrefixTransformRule() {
2169 return this.numberingPlan.nationalPrefixTransformRule();
2170 } // Deprecated.
2171
2172 }, {
2173 key: "leadingDigits",
2174 value: function leadingDigits() {
2175 return this.numberingPlan.leadingDigits();
2176 } // Deprecated.
2177
2178 }, {
2179 key: "hasTypes",
2180 value: function hasTypes() {
2181 return this.numberingPlan.hasTypes();
2182 } // Deprecated.
2183
2184 }, {
2185 key: "type",
2186 value: function type(_type) {
2187 return this.numberingPlan.type(_type);
2188 } // Deprecated.
2189
2190 }, {
2191 key: "ext",
2192 value: function ext() {
2193 return this.numberingPlan.ext();
2194 }
2195 }, {
2196 key: "countryCallingCodes",
2197 value: function countryCallingCodes() {
2198 if (this.v1) return this.metadata.country_phone_code_to_countries;
2199 return this.metadata.country_calling_codes;
2200 } // Deprecated.
2201
2202 }, {
2203 key: "chooseCountryByCountryCallingCode",
2204 value: function chooseCountryByCountryCallingCode(callingCode) {
2205 return this.selectNumberingPlan(callingCode);
2206 }
2207 }, {
2208 key: "hasSelectedNumberingPlan",
2209 value: function hasSelectedNumberingPlan() {
2210 return this.numberingPlan !== undefined;
2211 }
2212 }]);
2213
2214 return Metadata;
2215}();
2216
2217var NumberingPlan = /*#__PURE__*/function () {
2218 function NumberingPlan(metadata, globalMetadataObject) {
2219 _classCallCheck$7(this, NumberingPlan);
2220
2221 this.globalMetadataObject = globalMetadataObject;
2222 this.metadata = metadata;
2223 setVersion.call(this, globalMetadataObject.metadata);
2224 }
2225
2226 _createClass$7(NumberingPlan, [{
2227 key: "callingCode",
2228 value: function callingCode() {
2229 return this.metadata[0];
2230 } // Formatting information for regions which share
2231 // a country calling code is contained by only one region
2232 // for performance reasons. For example, for NANPA region
2233 // ("North American Numbering Plan Administration",
2234 // which includes USA, Canada, Cayman Islands, Bahamas, etc)
2235 // it will be contained in the metadata for `US`.
2236
2237 }, {
2238 key: "getDefaultCountryMetadataForRegion",
2239 value: function getDefaultCountryMetadataForRegion() {
2240 return this.globalMetadataObject.getNumberingPlanMetadata(this.callingCode());
2241 } // Is always present.
2242
2243 }, {
2244 key: "IDDPrefix",
2245 value: function IDDPrefix() {
2246 if (this.v1 || this.v2) return;
2247 return this.metadata[1];
2248 } // Is only present when a country supports multiple IDD prefixes.
2249
2250 }, {
2251 key: "defaultIDDPrefix",
2252 value: function defaultIDDPrefix() {
2253 if (this.v1 || this.v2) return;
2254 return this.metadata[12];
2255 }
2256 }, {
2257 key: "nationalNumberPattern",
2258 value: function nationalNumberPattern() {
2259 if (this.v1 || this.v2) return this.metadata[1];
2260 return this.metadata[2];
2261 } // "possible length" data is always present in Google's metadata.
2262
2263 }, {
2264 key: "possibleLengths",
2265 value: function possibleLengths() {
2266 if (this.v1) return;
2267 return this.metadata[this.v2 ? 2 : 3];
2268 }
2269 }, {
2270 key: "_getFormats",
2271 value: function _getFormats(metadata) {
2272 return metadata[this.v1 ? 2 : this.v2 ? 3 : 4];
2273 } // For countries of the same region (e.g. NANPA)
2274 // formats are all stored in the "main" country for that region.
2275 // E.g. "RU" and "KZ", "US" and "CA".
2276
2277 }, {
2278 key: "formats",
2279 value: function formats() {
2280 var _this = this;
2281
2282 var formats = this._getFormats(this.metadata) || this._getFormats(this.getDefaultCountryMetadataForRegion()) || [];
2283 return formats.map(function (_) {
2284 return new Format(_, _this);
2285 });
2286 }
2287 }, {
2288 key: "nationalPrefix",
2289 value: function nationalPrefix() {
2290 return this.metadata[this.v1 ? 3 : this.v2 ? 4 : 5];
2291 }
2292 }, {
2293 key: "_getNationalPrefixFormattingRule",
2294 value: function _getNationalPrefixFormattingRule(metadata) {
2295 return metadata[this.v1 ? 4 : this.v2 ? 5 : 6];
2296 } // For countries of the same region (e.g. NANPA)
2297 // national prefix formatting rule is stored in the "main" country for that region.
2298 // E.g. "RU" and "KZ", "US" and "CA".
2299
2300 }, {
2301 key: "nationalPrefixFormattingRule",
2302 value: function nationalPrefixFormattingRule() {
2303 return this._getNationalPrefixFormattingRule(this.metadata) || this._getNationalPrefixFormattingRule(this.getDefaultCountryMetadataForRegion());
2304 }
2305 }, {
2306 key: "_nationalPrefixForParsing",
2307 value: function _nationalPrefixForParsing() {
2308 return this.metadata[this.v1 ? 5 : this.v2 ? 6 : 7];
2309 }
2310 }, {
2311 key: "nationalPrefixForParsing",
2312 value: function nationalPrefixForParsing() {
2313 // If `national_prefix_for_parsing` is not set explicitly,
2314 // then infer it from `national_prefix` (if any)
2315 return this._nationalPrefixForParsing() || this.nationalPrefix();
2316 }
2317 }, {
2318 key: "nationalPrefixTransformRule",
2319 value: function nationalPrefixTransformRule() {
2320 return this.metadata[this.v1 ? 6 : this.v2 ? 7 : 8];
2321 }
2322 }, {
2323 key: "_getNationalPrefixIsOptionalWhenFormatting",
2324 value: function _getNationalPrefixIsOptionalWhenFormatting() {
2325 return !!this.metadata[this.v1 ? 7 : this.v2 ? 8 : 9];
2326 } // For countries of the same region (e.g. NANPA)
2327 // "national prefix is optional when formatting" flag is
2328 // stored in the "main" country for that region.
2329 // E.g. "RU" and "KZ", "US" and "CA".
2330
2331 }, {
2332 key: "nationalPrefixIsOptionalWhenFormattingInNationalFormat",
2333 value: function nationalPrefixIsOptionalWhenFormattingInNationalFormat() {
2334 return this._getNationalPrefixIsOptionalWhenFormatting(this.metadata) || this._getNationalPrefixIsOptionalWhenFormatting(this.getDefaultCountryMetadataForRegion());
2335 }
2336 }, {
2337 key: "leadingDigits",
2338 value: function leadingDigits() {
2339 return this.metadata[this.v1 ? 8 : this.v2 ? 9 : 10];
2340 }
2341 }, {
2342 key: "types",
2343 value: function types() {
2344 return this.metadata[this.v1 ? 9 : this.v2 ? 10 : 11];
2345 }
2346 }, {
2347 key: "hasTypes",
2348 value: function hasTypes() {
2349 // Versions 1.2.0 - 1.2.4: can be `[]`.
2350
2351 /* istanbul ignore next */
2352 if (this.types() && this.types().length === 0) {
2353 return false;
2354 } // Versions <= 1.2.4: can be `undefined`.
2355 // Version >= 1.2.5: can be `0`.
2356
2357
2358 return !!this.types();
2359 }
2360 }, {
2361 key: "type",
2362 value: function type(_type2) {
2363 if (this.hasTypes() && getType(this.types(), _type2)) {
2364 return new Type(getType(this.types(), _type2), this);
2365 }
2366 }
2367 }, {
2368 key: "ext",
2369 value: function ext() {
2370 if (this.v1 || this.v2) return DEFAULT_EXT_PREFIX;
2371 return this.metadata[13] || DEFAULT_EXT_PREFIX;
2372 }
2373 }]);
2374
2375 return NumberingPlan;
2376}();
2377
2378var Format = /*#__PURE__*/function () {
2379 function Format(format, metadata) {
2380 _classCallCheck$7(this, Format);
2381
2382 this._format = format;
2383 this.metadata = metadata;
2384 }
2385
2386 _createClass$7(Format, [{
2387 key: "pattern",
2388 value: function pattern() {
2389 return this._format[0];
2390 }
2391 }, {
2392 key: "format",
2393 value: function format() {
2394 return this._format[1];
2395 }
2396 }, {
2397 key: "leadingDigitsPatterns",
2398 value: function leadingDigitsPatterns() {
2399 return this._format[2] || [];
2400 }
2401 }, {
2402 key: "nationalPrefixFormattingRule",
2403 value: function nationalPrefixFormattingRule() {
2404 return this._format[3] || this.metadata.nationalPrefixFormattingRule();
2405 }
2406 }, {
2407 key: "nationalPrefixIsOptionalWhenFormattingInNationalFormat",
2408 value: function nationalPrefixIsOptionalWhenFormattingInNationalFormat() {
2409 return !!this._format[4] || this.metadata.nationalPrefixIsOptionalWhenFormattingInNationalFormat();
2410 }
2411 }, {
2412 key: "nationalPrefixIsMandatoryWhenFormattingInNationalFormat",
2413 value: function nationalPrefixIsMandatoryWhenFormattingInNationalFormat() {
2414 // National prefix is omitted if there's no national prefix formatting rule
2415 // set for this country, or when the national prefix formatting rule
2416 // contains no national prefix itself, or when this rule is set but
2417 // national prefix is optional for this phone number format
2418 // (and it is not enforced explicitly)
2419 return this.usesNationalPrefix() && !this.nationalPrefixIsOptionalWhenFormattingInNationalFormat();
2420 } // Checks whether national prefix formatting rule contains national prefix.
2421
2422 }, {
2423 key: "usesNationalPrefix",
2424 value: function usesNationalPrefix() {
2425 return this.nationalPrefixFormattingRule() && // Check that national prefix formatting rule is not a "dummy" one.
2426 !FIRST_GROUP_ONLY_PREFIX_PATTERN.test(this.nationalPrefixFormattingRule()) // In compressed metadata, `this.nationalPrefixFormattingRule()` is `0`
2427 // when `national_prefix_formatting_rule` is not present.
2428 // So, `true` or `false` are returned explicitly here, so that
2429 // `0` number isn't returned.
2430 ? true : false;
2431 }
2432 }, {
2433 key: "internationalFormat",
2434 value: function internationalFormat() {
2435 return this._format[5] || this.format();
2436 }
2437 }]);
2438
2439 return Format;
2440}();
2441/**
2442 * A pattern that is used to determine if the national prefix formatting rule
2443 * has the first group only, i.e., does not start with the national prefix.
2444 * Note that the pattern explicitly allows for unbalanced parentheses.
2445 */
2446
2447
2448var FIRST_GROUP_ONLY_PREFIX_PATTERN = /^\(?\$1\)?$/;
2449
2450var Type = /*#__PURE__*/function () {
2451 function Type(type, metadata) {
2452 _classCallCheck$7(this, Type);
2453
2454 this.type = type;
2455 this.metadata = metadata;
2456 }
2457
2458 _createClass$7(Type, [{
2459 key: "pattern",
2460 value: function pattern() {
2461 if (this.metadata.v1) return this.type;
2462 return this.type[0];
2463 }
2464 }, {
2465 key: "possibleLengths",
2466 value: function possibleLengths() {
2467 if (this.metadata.v1) return;
2468 return this.type[1] || this.metadata.possibleLengths();
2469 }
2470 }]);
2471
2472 return Type;
2473}();
2474
2475function getType(types, type) {
2476 switch (type) {
2477 case 'FIXED_LINE':
2478 return types[0];
2479
2480 case 'MOBILE':
2481 return types[1];
2482
2483 case 'TOLL_FREE':
2484 return types[2];
2485
2486 case 'PREMIUM_RATE':
2487 return types[3];
2488
2489 case 'PERSONAL_NUMBER':
2490 return types[4];
2491
2492 case 'VOICEMAIL':
2493 return types[5];
2494
2495 case 'UAN':
2496 return types[6];
2497
2498 case 'PAGER':
2499 return types[7];
2500
2501 case 'VOIP':
2502 return types[8];
2503
2504 case 'SHARED_COST':
2505 return types[9];
2506 }
2507}
2508
2509function validateMetadata(metadata) {
2510 if (!metadata) {
2511 throw new Error('[libphonenumber-js] `metadata` argument not passed. Check your arguments.');
2512 } // `country_phone_code_to_countries` was renamed to
2513 // `country_calling_codes` in `1.0.18`.
2514
2515
2516 if (!is_object(metadata) || !is_object(metadata.countries)) {
2517 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, "."));
2518 }
2519} // Babel transforms `typeof` into some "branches"
2520// so istanbul will show this as "branch not covered".
2521
2522/* istanbul ignore next */
2523
2524var is_object = function is_object(_) {
2525 return _typeof$2(_) === 'object';
2526}; // Babel transforms `typeof` into some "branches"
2527// so istanbul will show this as "branch not covered".
2528
2529/* istanbul ignore next */
2530
2531
2532var type_of = function type_of(_) {
2533 return _typeof$2(_);
2534};
2535/**
2536 * Returns "country calling code" for a country.
2537 * Throws an error if the country doesn't exist or isn't supported by this library.
2538 * @param {string} country
2539 * @param {object} metadata
2540 * @return {string}
2541 * @example
2542 * // Returns "44"
2543 * getCountryCallingCode("GB")
2544 */
2545
2546function getCountryCallingCode(country, metadata) {
2547 metadata = new Metadata(metadata);
2548
2549 if (metadata.hasCountry(country)) {
2550 return metadata.country(country).countryCallingCode();
2551 }
2552
2553 throw new Error("Unknown country: ".concat(country));
2554}
2555function isSupportedCountry(country, metadata) {
2556 // metadata = new Metadata(metadata)
2557 // return metadata.hasCountry(country)
2558 return metadata.countries[country] !== undefined;
2559}
2560
2561function setVersion(metadata) {
2562 var version = metadata.version;
2563
2564 if (typeof version === 'number') {
2565 this.v1 = version === 1;
2566 this.v2 = version === 2;
2567 this.v3 = version === 3;
2568 this.v4 = version === 4;
2569 } else {
2570 if (!version) {
2571 this.v1 = true;
2572 } else if (compare(version, V3) === -1) {
2573 this.v2 = true;
2574 } else if (compare(version, V4) === -1) {
2575 this.v3 = true;
2576 } else {
2577 this.v4 = true;
2578 }
2579 }
2580} // const ISO_COUNTRY_CODE = /^[A-Z]{2}$/
2581// function isCountryCode(countryCode) {
2582// return ISO_COUNTRY_CODE.test(countryCodeOrCountryCallingCode)
2583// }
2584
2585var RFC3966_EXTN_PREFIX = ';ext=';
2586/**
2587 * Helper method for constructing regular expressions for parsing. Creates
2588 * an expression that captures up to max_length digits.
2589 * @return {string} RegEx pattern to capture extension digits.
2590 */
2591
2592var getExtensionDigitsPattern = function getExtensionDigitsPattern(maxLength) {
2593 return "([".concat(VALID_DIGITS, "]{1,").concat(maxLength, "})");
2594};
2595/**
2596 * Helper initialiser method to create the regular-expression pattern to match
2597 * extensions.
2598 * Copy-pasted from Google's `libphonenumber`:
2599 * https://github.com/google/libphonenumber/blob/55b2646ec9393f4d3d6661b9c82ef9e258e8b829/javascript/i18n/phonenumbers/phonenumberutil.js#L759-L766
2600 * @return {string} RegEx pattern to capture extensions.
2601 */
2602
2603
2604function createExtensionPattern(purpose) {
2605 // We cap the maximum length of an extension based on the ambiguity of the way
2606 // the extension is prefixed. As per ITU, the officially allowed length for
2607 // extensions is actually 40, but we don't support this since we haven't seen real
2608 // examples and this introduces many false interpretations as the extension labels
2609 // are not standardized.
2610
2611 /** @type {string} */
2612 var extLimitAfterExplicitLabel = '20';
2613 /** @type {string} */
2614
2615 var extLimitAfterLikelyLabel = '15';
2616 /** @type {string} */
2617
2618 var extLimitAfterAmbiguousChar = '9';
2619 /** @type {string} */
2620
2621 var extLimitWhenNotSure = '6';
2622 /** @type {string} */
2623
2624 var possibleSeparatorsBetweenNumberAndExtLabel = "[ \xA0\\t,]*"; // Optional full stop (.) or colon, followed by zero or more spaces/tabs/commas.
2625
2626 /** @type {string} */
2627
2628 var possibleCharsAfterExtLabel = "[:\\.\uFF0E]?[ \xA0\\t,-]*";
2629 /** @type {string} */
2630
2631 var optionalExtnSuffix = "#?"; // Here the extension is called out in more explicit way, i.e mentioning it obvious
2632 // patterns like "ext.".
2633
2634 /** @type {string} */
2635
2636 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
2637 // commonly used or more ambiguous extension labels.
2638
2639 /** @type {string} */
2640
2641 var ambiguousExtLabels = "(?:[x\uFF58#\uFF03~\uFF5E]|int|\uFF49\uFF4E\uFF54)"; // When extension is not separated clearly.
2642
2643 /** @type {string} */
2644
2645 var ambiguousSeparator = "[- ]+"; // This is the same as possibleSeparatorsBetweenNumberAndExtLabel, but not matching
2646 // comma as extension label may have it.
2647
2648 /** @type {string} */
2649
2650 var possibleSeparatorsNumberExtLabelNoComma = "[ \xA0\\t]*"; // ",," is commonly used for auto dialling the extension when connected. First
2651 // comma is matched through possibleSeparatorsBetweenNumberAndExtLabel, so we do
2652 // not repeat it here. Semi-colon works in Iphone and Android also to pop up a
2653 // button with the extension number following.
2654
2655 /** @type {string} */
2656
2657 var autoDiallingAndExtLabelsFound = "(?:,{2}|;)";
2658 /** @type {string} */
2659
2660 var rfcExtn = RFC3966_EXTN_PREFIX + getExtensionDigitsPattern(extLimitAfterExplicitLabel);
2661 /** @type {string} */
2662
2663 var explicitExtn = possibleSeparatorsBetweenNumberAndExtLabel + explicitExtLabels + possibleCharsAfterExtLabel + getExtensionDigitsPattern(extLimitAfterExplicitLabel) + optionalExtnSuffix;
2664 /** @type {string} */
2665
2666 var ambiguousExtn = possibleSeparatorsBetweenNumberAndExtLabel + ambiguousExtLabels + possibleCharsAfterExtLabel + getExtensionDigitsPattern(extLimitAfterAmbiguousChar) + optionalExtnSuffix;
2667 /** @type {string} */
2668
2669 var americanStyleExtnWithSuffix = ambiguousSeparator + getExtensionDigitsPattern(extLimitWhenNotSure) + "#";
2670 /** @type {string} */
2671
2672 var autoDiallingExtn = possibleSeparatorsNumberExtLabelNoComma + autoDiallingAndExtLabelsFound + possibleCharsAfterExtLabel + getExtensionDigitsPattern(extLimitAfterLikelyLabel) + optionalExtnSuffix;
2673 /** @type {string} */
2674
2675 var onlyCommasExtn = possibleSeparatorsNumberExtLabelNoComma + "(?:,)+" + possibleCharsAfterExtLabel + getExtensionDigitsPattern(extLimitAfterAmbiguousChar) + optionalExtnSuffix; // The first regular expression covers RFC 3966 format, where the extension is added
2676 // using ";ext=". The second more generic where extension is mentioned with explicit
2677 // labels like "ext:". In both the above cases we allow more numbers in extension than
2678 // any other extension labels. The third one captures when single character extension
2679 // labels or less commonly used labels are used. In such cases we capture fewer
2680 // extension digits in order to reduce the chance of falsely interpreting two
2681 // numbers beside each other as a number + extension. The fourth one covers the
2682 // special case of American numbers where the extension is written with a hash
2683 // at the end, such as "- 503#". The fifth one is exclusively for extension
2684 // autodialling formats which are used when dialling and in this case we accept longer
2685 // extensions. The last one is more liberal on the number of commas that acts as
2686 // extension labels, so we have a strict cap on the number of digits in such extensions.
2687
2688 return rfcExtn + "|" + explicitExtn + "|" + ambiguousExtn + "|" + americanStyleExtnWithSuffix + "|" + autoDiallingExtn + "|" + onlyCommasExtn;
2689}
2690
2691// Checks we have at least three leading digits, and only valid punctuation,
2692// alpha characters and digits in the phone number. Does not include extension
2693// data. The symbol 'x' is allowed here as valid punctuation since it is often
2694// used as a placeholder for carrier codes, for example in Brazilian phone
2695// numbers. We also allow multiple '+' characters at the start.
2696//
2697// Corresponds to the following:
2698// [digits]{minLengthNsn}|
2699// plus_sign*
2700// (([punctuation]|[star])*[digits]){3,}([punctuation]|[star]|[digits]|[alpha])*
2701//
2702// The first reg-ex is to allow short numbers (two digits long) to be parsed if
2703// they are entered as "15" etc, but only if there is no punctuation in them.
2704// The second expression restricts the number of digits to three or more, but
2705// then allows them to be in international form, and to have alpha-characters
2706// and punctuation. We split up the two reg-exes here and combine them when
2707// creating the reg-ex VALID_PHONE_NUMBER_PATTERN itself so we can prefix it
2708// with ^ and append $ to each branch.
2709//
2710// "Note VALID_PUNCTUATION starts with a -,
2711// so must be the first in the range" (c) Google devs.
2712// (wtf did they mean by saying that; probably nothing)
2713//
2714
2715var MIN_LENGTH_PHONE_NUMBER_PATTERN = '[' + VALID_DIGITS + ']{' + MIN_LENGTH_FOR_NSN + '}'; //
2716// And this is the second reg-exp:
2717// (see MIN_LENGTH_PHONE_NUMBER_PATTERN for a full description of this reg-exp)
2718//
2719
2720var 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`
2721// and is only used to determine whether the phone number being input
2722// is too short for it to even consider it a "valid" number.
2723// This is just a way to differentiate between a really invalid phone
2724// number like "abcde" and a valid phone number that a user has just
2725// started inputting, like "+1" or "1": both these cases would be
2726// considered `NOT_A_NUMBER` by Google's `libphonenumber`, but this
2727// library can provide a more detailed error message — whether it's
2728// really "not a number", or is it just a start of a valid phone number.
2729
2730var VALID_PHONE_NUMBER_START_REG_EXP = new RegExp('^' + '[' + PLUS_CHARS + ']{0,1}' + '(?:' + '[' + VALID_PUNCTUATION + ']*' + '[' + VALID_DIGITS + ']' + '){1,2}' + '$', 'i');
2731var VALID_PHONE_NUMBER_WITH_EXTENSION = VALID_PHONE_NUMBER + // Phone number extensions
2732'(?:' + createExtensionPattern() + ')?'; // The combined regular expression for valid phone numbers:
2733//
2734
2735var VALID_PHONE_NUMBER_PATTERN = new RegExp( // Either a short two-digit-only phone number
2736'^' + MIN_LENGTH_PHONE_NUMBER_PATTERN + '$' + '|' + // Or a longer fully parsed phone number (min 3 characters)
2737'^' + VALID_PHONE_NUMBER_WITH_EXTENSION + '$', 'i'); // Checks to see if the string of characters could possibly be a phone number at
2738// all. At the moment, checks to see that the string begins with at least 2
2739// digits, ignoring any punctuation commonly found in phone numbers. This method
2740// does not require the number to be normalized in advance - but does assume
2741// that leading non-number symbols have been removed, such as by the method
2742// `extract_possible_number`.
2743//
2744
2745function isViablePhoneNumber(number) {
2746 return number.length >= MIN_LENGTH_FOR_NSN && VALID_PHONE_NUMBER_PATTERN.test(number);
2747} // This is just a way to differentiate between a really invalid phone
2748// number like "abcde" and a valid phone number that a user has just
2749// started inputting, like "+1" or "1": both these cases would be
2750// considered `NOT_A_NUMBER` by Google's `libphonenumber`, but this
2751// library can provide a more detailed error message — whether it's
2752// really "not a number", or is it just a start of a valid phone number.
2753
2754function isViablePhoneNumberStart(number) {
2755 return VALID_PHONE_NUMBER_START_REG_EXP.test(number);
2756}
2757
2758// 1 or more valid digits, for use when parsing.
2759
2760var EXTN_PATTERN = new RegExp('(?:' + createExtensionPattern() + ')$', 'i'); // Strips any extension (as in, the part of the number dialled after the call is
2761// connected, usually indicated with extn, ext, x or similar) from the end of
2762// the number, and returns it.
2763
2764function extractExtension(number) {
2765 var start = number.search(EXTN_PATTERN);
2766
2767 if (start < 0) {
2768 return {};
2769 } // If we find a potential extension, and the number preceding this is a viable
2770 // number, we assume it is an extension.
2771
2772
2773 var numberWithoutExtension = number.slice(0, start);
2774 var matches = number.match(EXTN_PATTERN);
2775 var i = 1;
2776
2777 while (i < matches.length) {
2778 if (matches[i]) {
2779 return {
2780 number: numberWithoutExtension,
2781 ext: matches[i]
2782 };
2783 }
2784
2785 i++;
2786 }
2787}
2788
2789function _createForOfIteratorHelperLoose$9(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$c(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."); }
2790
2791function _unsupportedIterableToArray$c(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$c(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$c(o, minLen); }
2792
2793function _arrayLikeToArray$c(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; }
2794
2795// These mappings map a character (key) to a specific digit that should
2796// replace it for normalization purposes. Non-European digits that
2797// may be used in phone numbers are mapped to a European equivalent.
2798//
2799// E.g. in Iraq they don't write `+442323234` but rather `+٤٤٢٣٢٣٢٣٤`.
2800//
2801var DIGITS = {
2802 '0': '0',
2803 '1': '1',
2804 '2': '2',
2805 '3': '3',
2806 '4': '4',
2807 '5': '5',
2808 '6': '6',
2809 '7': '7',
2810 '8': '8',
2811 '9': '9',
2812 "\uFF10": '0',
2813 // Fullwidth digit 0
2814 "\uFF11": '1',
2815 // Fullwidth digit 1
2816 "\uFF12": '2',
2817 // Fullwidth digit 2
2818 "\uFF13": '3',
2819 // Fullwidth digit 3
2820 "\uFF14": '4',
2821 // Fullwidth digit 4
2822 "\uFF15": '5',
2823 // Fullwidth digit 5
2824 "\uFF16": '6',
2825 // Fullwidth digit 6
2826 "\uFF17": '7',
2827 // Fullwidth digit 7
2828 "\uFF18": '8',
2829 // Fullwidth digit 8
2830 "\uFF19": '9',
2831 // Fullwidth digit 9
2832 "\u0660": '0',
2833 // Arabic-indic digit 0
2834 "\u0661": '1',
2835 // Arabic-indic digit 1
2836 "\u0662": '2',
2837 // Arabic-indic digit 2
2838 "\u0663": '3',
2839 // Arabic-indic digit 3
2840 "\u0664": '4',
2841 // Arabic-indic digit 4
2842 "\u0665": '5',
2843 // Arabic-indic digit 5
2844 "\u0666": '6',
2845 // Arabic-indic digit 6
2846 "\u0667": '7',
2847 // Arabic-indic digit 7
2848 "\u0668": '8',
2849 // Arabic-indic digit 8
2850 "\u0669": '9',
2851 // Arabic-indic digit 9
2852 "\u06F0": '0',
2853 // Eastern-Arabic digit 0
2854 "\u06F1": '1',
2855 // Eastern-Arabic digit 1
2856 "\u06F2": '2',
2857 // Eastern-Arabic digit 2
2858 "\u06F3": '3',
2859 // Eastern-Arabic digit 3
2860 "\u06F4": '4',
2861 // Eastern-Arabic digit 4
2862 "\u06F5": '5',
2863 // Eastern-Arabic digit 5
2864 "\u06F6": '6',
2865 // Eastern-Arabic digit 6
2866 "\u06F7": '7',
2867 // Eastern-Arabic digit 7
2868 "\u06F8": '8',
2869 // Eastern-Arabic digit 8
2870 "\u06F9": '9' // Eastern-Arabic digit 9
2871
2872};
2873function parseDigit(character) {
2874 return DIGITS[character];
2875}
2876/**
2877 * Parses phone number digits from a string.
2878 * Drops all punctuation leaving only digits.
2879 * Also converts wide-ascii and arabic-indic numerals to conventional numerals.
2880 * E.g. in Iraq they don't write `+442323234` but rather `+٤٤٢٣٢٣٢٣٤`.
2881 * @param {string} string
2882 * @return {string}
2883 * @example
2884 * ```js
2885 * parseDigits('8 (800) 555')
2886 * // Outputs '8800555'.
2887 * ```
2888 */
2889
2890function parseDigits(string) {
2891 var result = ''; // Using `.split('')` here instead of normal `for ... of`
2892 // because the importing application doesn't neccessarily include an ES6 polyfill.
2893 // The `.split('')` approach discards "exotic" UTF-8 characters
2894 // (the ones consisting of four bytes) but digits
2895 // (including non-European ones) don't fall into that range
2896 // so such "exotic" characters would be discarded anyway.
2897
2898 for (var _iterator = _createForOfIteratorHelperLoose$9(string.split('')), _step; !(_step = _iterator()).done;) {
2899 var character = _step.value;
2900 var digit = parseDigit(character);
2901
2902 if (digit) {
2903 result += digit;
2904 }
2905 }
2906
2907 return result;
2908}
2909
2910function _createForOfIteratorHelperLoose$8(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$b(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."); }
2911
2912function _unsupportedIterableToArray$b(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$b(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$b(o, minLen); }
2913
2914function _arrayLikeToArray$b(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; }
2915/**
2916 * Parses phone number characters from a string.
2917 * Drops all punctuation leaving only digits and the leading `+` sign (if any).
2918 * Also converts wide-ascii and arabic-indic numerals to conventional numerals.
2919 * E.g. in Iraq they don't write `+442323234` but rather `+٤٤٢٣٢٣٢٣٤`.
2920 * @param {string} string
2921 * @return {string}
2922 * @example
2923 * ```js
2924 * // Outputs '8800555'.
2925 * parseIncompletePhoneNumber('8 (800) 555')
2926 * // Outputs '+7800555'.
2927 * parseIncompletePhoneNumber('+7 800 555')
2928 * ```
2929 */
2930
2931function parseIncompletePhoneNumber(string) {
2932 var result = ''; // Using `.split('')` here instead of normal `for ... of`
2933 // because the importing application doesn't neccessarily include an ES6 polyfill.
2934 // The `.split('')` approach discards "exotic" UTF-8 characters
2935 // (the ones consisting of four bytes) but digits
2936 // (including non-European ones) don't fall into that range
2937 // so such "exotic" characters would be discarded anyway.
2938
2939 for (var _iterator = _createForOfIteratorHelperLoose$8(string.split('')), _step; !(_step = _iterator()).done;) {
2940 var character = _step.value;
2941 result += parsePhoneNumberCharacter(character, result) || '';
2942 }
2943
2944 return result;
2945}
2946/**
2947 * Parses next character while parsing phone number digits (including a `+`)
2948 * from text: discards everything except `+` and digits, and `+` is only allowed
2949 * at the start of a phone number.
2950 * For example, is used in `react-phone-number-input` where it uses
2951 * [`input-format`](https://gitlab.com/catamphetamine/input-format).
2952 * @param {string} character - Yet another character from raw input string.
2953 * @param {string?} prevParsedCharacters - Previous parsed characters.
2954 * @param {object} meta - Optional custom use-case-specific metadata.
2955 * @return {string?} The parsed character.
2956 */
2957
2958function parsePhoneNumberCharacter(character, prevParsedCharacters) {
2959 // Only allow a leading `+`.
2960 if (character === '+') {
2961 // If this `+` is not the first parsed character
2962 // then discard it.
2963 if (prevParsedCharacters) {
2964 return;
2965 }
2966
2967 return '+';
2968 } // Allow digits.
2969
2970
2971 return parseDigit(character);
2972}
2973
2974function _createForOfIteratorHelperLoose$7(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$a(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."); }
2975
2976function _unsupportedIterableToArray$a(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$a(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$a(o, minLen); }
2977
2978function _arrayLikeToArray$a(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; }
2979
2980/**
2981 * Merges two arrays.
2982 * @param {*} a
2983 * @param {*} b
2984 * @return {*}
2985 */
2986function mergeArrays(a, b) {
2987 var merged = a.slice();
2988
2989 for (var _iterator = _createForOfIteratorHelperLoose$7(b), _step; !(_step = _iterator()).done;) {
2990 var element = _step.value;
2991
2992 if (a.indexOf(element) < 0) {
2993 merged.push(element);
2994 }
2995 }
2996
2997 return merged.sort(function (a, b) {
2998 return a - b;
2999 }); // ES6 version, requires Set polyfill.
3000 // let merged = new Set(a)
3001 // for (const element of b) {
3002 // merged.add(i)
3003 // }
3004 // return Array.from(merged).sort((a, b) => a - b)
3005}
3006
3007function checkNumberLength(nationalNumber, metadata) {
3008 return checkNumberLengthForType(nationalNumber, undefined, metadata);
3009} // Checks whether a number is possible for the country based on its length.
3010// Should only be called for the "new" metadata which has "possible lengths".
3011
3012function checkNumberLengthForType(nationalNumber, type, metadata) {
3013 var type_info = metadata.type(type); // There should always be "<possiblePengths/>" set for every type element.
3014 // This is declared in the XML schema.
3015 // For size efficiency, where a sub-description (e.g. fixed-line)
3016 // has the same "<possiblePengths/>" as the "general description", this is missing,
3017 // so we fall back to the "general description". Where no numbers of the type
3018 // exist at all, there is one possible length (-1) which is guaranteed
3019 // not to match the length of any real phone number.
3020
3021 var possible_lengths = type_info && type_info.possibleLengths() || metadata.possibleLengths(); // let local_lengths = type_info && type.possibleLengthsLocal() || metadata.possibleLengthsLocal()
3022 // Metadata before version `1.0.18` didn't contain `possible_lengths`.
3023
3024 if (!possible_lengths) {
3025 return 'IS_POSSIBLE';
3026 }
3027
3028 if (type === 'FIXED_LINE_OR_MOBILE') {
3029 // No such country in metadata.
3030
3031 /* istanbul ignore next */
3032 if (!metadata.type('FIXED_LINE')) {
3033 // The rare case has been encountered where no fixedLine data is available
3034 // (true for some non-geographic entities), so we just check mobile.
3035 return checkNumberLengthForType(nationalNumber, 'MOBILE', metadata);
3036 }
3037
3038 var mobile_type = metadata.type('MOBILE');
3039
3040 if (mobile_type) {
3041 // Merge the mobile data in if there was any. "Concat" creates a new
3042 // array, it doesn't edit possible_lengths in place, so we don't need a copy.
3043 // Note that when adding the possible lengths from mobile, we have
3044 // to again check they aren't empty since if they are this indicates
3045 // they are the same as the general desc and should be obtained from there.
3046 possible_lengths = mergeArrays(possible_lengths, mobile_type.possibleLengths()); // The current list is sorted; we need to merge in the new list and
3047 // re-sort (duplicates are okay). Sorting isn't so expensive because
3048 // the lists are very small.
3049 // if (local_lengths) {
3050 // local_lengths = mergeArrays(local_lengths, mobile_type.possibleLengthsLocal())
3051 // } else {
3052 // local_lengths = mobile_type.possibleLengthsLocal()
3053 // }
3054 }
3055 } // If the type doesn't exist then return 'INVALID_LENGTH'.
3056 else if (type && !type_info) {
3057 return 'INVALID_LENGTH';
3058 }
3059
3060 var actual_length = nationalNumber.length; // In `libphonenumber-js` all "local-only" formats are dropped for simplicity.
3061 // // This is safe because there is never an overlap beween the possible lengths
3062 // // and the local-only lengths; this is checked at build time.
3063 // if (local_lengths && local_lengths.indexOf(nationalNumber.length) >= 0)
3064 // {
3065 // return 'IS_POSSIBLE_LOCAL_ONLY'
3066 // }
3067
3068 var minimum_length = possible_lengths[0];
3069
3070 if (minimum_length === actual_length) {
3071 return 'IS_POSSIBLE';
3072 }
3073
3074 if (minimum_length > actual_length) {
3075 return 'TOO_SHORT';
3076 }
3077
3078 if (possible_lengths[possible_lengths.length - 1] < actual_length) {
3079 return 'TOO_LONG';
3080 } // We skip the first element since we've already checked it.
3081
3082
3083 return possible_lengths.indexOf(actual_length, 1) >= 0 ? 'IS_POSSIBLE' : 'INVALID_LENGTH';
3084}
3085
3086/**
3087 * Checks if a phone number is "possible" (basically just checks its length).
3088 *
3089 * isPossible(phoneNumberInstance, { ..., v2: true }, metadata)
3090 *
3091 * isPossible({ phone: '8005553535', country: 'RU' }, { ... }, metadata)
3092 * isPossible({ phone: '8005553535', country: 'RU' }, undefined, metadata)
3093 *
3094 * @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: '...' }`.
3095 * @param {object} [options]
3096 * @param {object} metadata
3097 * @return {string}
3098 */
3099
3100function isPossiblePhoneNumber$2(input, options, metadata) {
3101 /* istanbul ignore if */
3102 if (options === undefined) {
3103 options = {};
3104 }
3105
3106 metadata = new Metadata(metadata);
3107
3108 if (options.v2) {
3109 if (!input.countryCallingCode) {
3110 throw new Error('Invalid phone number object passed');
3111 }
3112
3113 metadata.selectNumberingPlan(input.countryCallingCode);
3114 } else {
3115 if (!input.phone) {
3116 return false;
3117 }
3118
3119 if (input.country) {
3120 if (!metadata.hasCountry(input.country)) {
3121 throw new Error("Unknown country: ".concat(input.country));
3122 }
3123
3124 metadata.country(input.country);
3125 } else {
3126 if (!input.countryCallingCode) {
3127 throw new Error('Invalid phone number object passed');
3128 }
3129
3130 metadata.selectNumberingPlan(input.countryCallingCode);
3131 }
3132 } // Old metadata (< 1.0.18) had no "possible length" data.
3133
3134
3135 if (metadata.possibleLengths()) {
3136 return isPossibleNumber(input.phone || input.nationalNumber, metadata);
3137 } else {
3138 // There was a bug between `1.7.35` and `1.7.37` where "possible_lengths"
3139 // were missing for "non-geographical" numbering plans.
3140 // Just assume the number is possible in such cases:
3141 // it's unlikely that anyone generated their custom metadata
3142 // in that short period of time (one day).
3143 // This code can be removed in some future major version update.
3144 if (input.countryCallingCode && metadata.isNonGeographicCallingCode(input.countryCallingCode)) {
3145 // "Non-geographic entities" did't have `possibleLengths`
3146 // due to a bug in metadata generation process.
3147 return true;
3148 } else {
3149 throw new Error('Missing "possibleLengths" in metadata. Perhaps the metadata has been generated before v1.0.18.');
3150 }
3151 }
3152}
3153function isPossibleNumber(nationalNumber, metadata) {
3154 //, isInternational) {
3155 switch (checkNumberLength(nationalNumber, metadata)) {
3156 case 'IS_POSSIBLE':
3157 return true;
3158 // This library ignores "local-only" phone numbers (for simplicity).
3159 // See the readme for more info on what are "local-only" phone numbers.
3160 // case 'IS_POSSIBLE_LOCAL_ONLY':
3161 // return !isInternational
3162
3163 default:
3164 return false;
3165 }
3166}
3167
3168function _slicedToArray$3(arr, i) { return _arrayWithHoles$3(arr) || _iterableToArrayLimit$3(arr, i) || _unsupportedIterableToArray$9(arr, i) || _nonIterableRest$3(); }
3169
3170function _nonIterableRest$3() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3171
3172function _iterableToArrayLimit$3(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; }
3173
3174function _arrayWithHoles$3(arr) { if (Array.isArray(arr)) return arr; }
3175
3176function _createForOfIteratorHelperLoose$6(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$9(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."); }
3177
3178function _unsupportedIterableToArray$9(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$9(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$9(o, minLen); }
3179
3180function _arrayLikeToArray$9(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; }
3181
3182/**
3183 * @param {string} text - Phone URI (RFC 3966).
3184 * @return {object} `{ ?number, ?ext }`.
3185 */
3186
3187function parseRFC3966(text) {
3188 var number;
3189 var ext; // Replace "tel:" with "tel=" for parsing convenience.
3190
3191 text = text.replace(/^tel:/, 'tel=');
3192
3193 for (var _iterator = _createForOfIteratorHelperLoose$6(text.split(';')), _step; !(_step = _iterator()).done;) {
3194 var part = _step.value;
3195
3196 var _part$split = part.split('='),
3197 _part$split2 = _slicedToArray$3(_part$split, 2),
3198 name = _part$split2[0],
3199 value = _part$split2[1];
3200
3201 switch (name) {
3202 case 'tel':
3203 number = value;
3204 break;
3205
3206 case 'ext':
3207 ext = value;
3208 break;
3209
3210 case 'phone-context':
3211 // Only "country contexts" are supported.
3212 // "Domain contexts" are ignored.
3213 if (value[0] === '+') {
3214 number = value + number;
3215 }
3216
3217 break;
3218 }
3219 } // If the phone number is not viable, then abort.
3220
3221
3222 if (!isViablePhoneNumber(number)) {
3223 return {};
3224 }
3225
3226 var result = {
3227 number: number
3228 };
3229
3230 if (ext) {
3231 result.ext = ext;
3232 }
3233
3234 return result;
3235}
3236/**
3237 * @param {object} - `{ ?number, ?extension }`.
3238 * @return {string} Phone URI (RFC 3966).
3239 */
3240
3241function formatRFC3966(_ref) {
3242 var number = _ref.number,
3243 ext = _ref.ext;
3244
3245 if (!number) {
3246 return '';
3247 }
3248
3249 if (number[0] !== '+') {
3250 throw new Error("\"formatRFC3966()\" expects \"number\" to be in E.164 format.");
3251 }
3252
3253 return "tel:".concat(number).concat(ext ? ';ext=' + ext : '');
3254}
3255
3256/**
3257 * Checks whether the entire input sequence can be matched
3258 * against the regular expression.
3259 * @return {boolean}
3260 */
3261function matchesEntirely(text, regular_expression) {
3262 // If assigning the `''` default value is moved to the arguments above,
3263 // code coverage would decrease for some weird reason.
3264 text = text || '';
3265 return new RegExp('^(?:' + regular_expression + ')$').test(text);
3266}
3267
3268function _createForOfIteratorHelperLoose$5(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$8(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."); }
3269
3270function _unsupportedIterableToArray$8(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$8(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$8(o, minLen); }
3271
3272function _arrayLikeToArray$8(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; }
3273var 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)
3274
3275function getNumberType(input, options, metadata) {
3276 // If assigning the `{}` default value is moved to the arguments above,
3277 // code coverage would decrease for some weird reason.
3278 options = options || {}; // When `parse()` returned `{}`
3279 // meaning that the phone number is not a valid one.
3280
3281 if (!input.country) {
3282 return;
3283 }
3284
3285 metadata = new Metadata(metadata);
3286 metadata.selectNumberingPlan(input.country, input.countryCallingCode);
3287 var nationalNumber = options.v2 ? input.nationalNumber : input.phone; // The following is copy-pasted from the original function:
3288 // https://github.com/googlei18n/libphonenumber/blob/3ea547d4fbaa2d0b67588904dfa5d3f2557c27ff/javascript/i18n/phonenumbers/phonenumberutil.js#L2835
3289 // Is this national number even valid for this country
3290
3291 if (!matchesEntirely(nationalNumber, metadata.nationalNumberPattern())) {
3292 return;
3293 } // Is it fixed line number
3294
3295
3296 if (isNumberTypeEqualTo(nationalNumber, 'FIXED_LINE', metadata)) {
3297 // Because duplicate regular expressions are removed
3298 // to reduce metadata size, if "mobile" pattern is ""
3299 // then it means it was removed due to being a duplicate of the fixed-line pattern.
3300 //
3301 if (metadata.type('MOBILE') && metadata.type('MOBILE').pattern() === '') {
3302 return 'FIXED_LINE_OR_MOBILE';
3303 } // `MOBILE` type pattern isn't included if it matched `FIXED_LINE` one.
3304 // For example, for "US" country.
3305 // Old metadata (< `1.0.18`) had a specific "types" data structure
3306 // that happened to be `undefined` for `MOBILE` in that case.
3307 // Newer metadata (>= `1.0.18`) has another data structure that is
3308 // not `undefined` for `MOBILE` in that case (it's just an empty array).
3309 // So this `if` is just for backwards compatibility with old metadata.
3310
3311
3312 if (!metadata.type('MOBILE')) {
3313 return 'FIXED_LINE_OR_MOBILE';
3314 } // Check if the number happens to qualify as both fixed line and mobile.
3315 // (no such country in the minimal metadata set)
3316
3317 /* istanbul ignore if */
3318
3319
3320 if (isNumberTypeEqualTo(nationalNumber, 'MOBILE', metadata)) {
3321 return 'FIXED_LINE_OR_MOBILE';
3322 }
3323
3324 return 'FIXED_LINE';
3325 }
3326
3327 for (var _iterator = _createForOfIteratorHelperLoose$5(NON_FIXED_LINE_PHONE_TYPES), _step; !(_step = _iterator()).done;) {
3328 var type = _step.value;
3329
3330 if (isNumberTypeEqualTo(nationalNumber, type, metadata)) {
3331 return type;
3332 }
3333 }
3334}
3335function isNumberTypeEqualTo(nationalNumber, type, metadata) {
3336 type = metadata.type(type);
3337
3338 if (!type || !type.pattern()) {
3339 return false;
3340 } // Check if any possible number lengths are present;
3341 // if so, we use them to avoid checking
3342 // the validation pattern if they don't match.
3343 // If they are absent, this means they match
3344 // the general description, which we have
3345 // already checked before a specific number type.
3346
3347
3348 if (type.possibleLengths() && type.possibleLengths().indexOf(nationalNumber.length) < 0) {
3349 return false;
3350 }
3351
3352 return matchesEntirely(nationalNumber, type.pattern());
3353}
3354
3355/**
3356 * Checks if a given phone number is valid.
3357 *
3358 * isValid(phoneNumberInstance, { ..., v2: true }, metadata)
3359 *
3360 * isPossible({ phone: '8005553535', country: 'RU' }, { ... }, metadata)
3361 * isPossible({ phone: '8005553535', country: 'RU' }, undefined, metadata)
3362 *
3363 * If the `number` is a string, it will be parsed to an object,
3364 * but only if it contains only valid phone number characters (including punctuation).
3365 * If the `number` is an object, it is used as is.
3366 *
3367 * The optional `defaultCountry` argument is the default country.
3368 * I.e. it does not restrict to just that country,
3369 * e.g. in those cases where several countries share
3370 * the same phone numbering rules (NANPA, Britain, etc).
3371 * For example, even though the number `07624 369230`
3372 * belongs to the Isle of Man ("IM" country code)
3373 * calling `isValidNumber('07624369230', 'GB', metadata)`
3374 * still returns `true` because the country is not restricted to `GB`,
3375 * it's just that `GB` is the default one for the phone numbering rules.
3376 * For restricting the country see `isValidNumberForRegion()`
3377 * though restricting a country might not be a good idea.
3378 * https://github.com/googlei18n/libphonenumber/blob/master/FAQ.md#when-should-i-use-isvalidnumberforregion
3379 *
3380 * Examples:
3381 *
3382 * ```js
3383 * isValidNumber('+78005553535', metadata)
3384 * isValidNumber('8005553535', 'RU', metadata)
3385 * isValidNumber('88005553535', 'RU', metadata)
3386 * isValidNumber({ phone: '8005553535', country: 'RU' }, metadata)
3387 * ```
3388 */
3389
3390function isValidNumber(input, options, metadata) {
3391 // If assigning the `{}` default value is moved to the arguments above,
3392 // code coverage would decrease for some weird reason.
3393 options = options || {};
3394 metadata = new Metadata(metadata);
3395 /**
3396 * Checks if a phone number is "possible" (basically just checks its length).
3397 *
3398 * @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: '...' }`.
3399 * @param {object} [options]
3400 * @param {object} metadata
3401 * @return {string}
3402 */
3403
3404 metadata.selectNumberingPlan(input.country, input.countryCallingCode); // By default, countries only have type regexps when it's required for
3405 // distinguishing different countries having the same `countryCallingCode`.
3406
3407 if (metadata.hasTypes()) {
3408 return getNumberType(input, options, metadata.metadata) !== undefined;
3409 } // If there are no type regexps for this country in metadata then use
3410 // `nationalNumberPattern` as a "better than nothing" replacement.
3411
3412
3413 var nationalNumber = options.v2 ? input.nationalNumber : input.phone;
3414 return matchesEntirely(nationalNumber, metadata.nationalNumberPattern());
3415}
3416
3417/**
3418 * Returns a list of countries that the phone number could potentially belong to.
3419 * @param {string} callingCode — Calling code.
3420 * @param {string} nationalNumber — National (significant) number.
3421 * @param {object} metadata — Metadata.
3422 * @return {string[]} A list of possible countries.
3423 */
3424
3425function getPossibleCountriesForNumber(callingCode, nationalNumber, metadata) {
3426 var _metadata = new Metadata(metadata);
3427
3428 var possibleCountries = _metadata.getCountryCodesForCallingCode(callingCode);
3429
3430 if (!possibleCountries) {
3431 return [];
3432 }
3433
3434 return possibleCountries.filter(function (country) {
3435 return couldNationalNumberBelongToCountry(nationalNumber, country, metadata);
3436 });
3437}
3438
3439function couldNationalNumberBelongToCountry(nationalNumber, country, metadata) {
3440 var _metadata = new Metadata(metadata);
3441
3442 _metadata.selectNumberingPlan(country);
3443
3444 if (_metadata.numberingPlan.possibleLengths().indexOf(nationalNumber.length) >= 0) {
3445 return true;
3446 }
3447
3448 return false;
3449}
3450
3451//
3452// E.g. "(999) 111-22-33" -> "999 111 22 33"
3453//
3454// For some reason Google's metadata contains `<intlFormat/>`s with brackets and dashes.
3455// Meanwhile, there's no single opinion about using punctuation in international phone numbers.
3456//
3457// For example, Google's `<intlFormat/>` for USA is `+1 213-373-4253`.
3458// And here's a quote from WikiPedia's "North American Numbering Plan" page:
3459// https://en.wikipedia.org/wiki/North_American_Numbering_Plan
3460//
3461// "The country calling code for all countries participating in the NANP is 1.
3462// In international format, an NANP number should be listed as +1 301 555 01 00,
3463// where 301 is an area code (Maryland)."
3464//
3465// I personally prefer the international format without any punctuation.
3466// For example, brackets are remnants of the old age, meaning that the
3467// phone number part in brackets (so called "area code") can be omitted
3468// if dialing within the same "area".
3469// And hyphens were clearly introduced for splitting local numbers into memorizable groups.
3470// For example, remembering "5553535" is difficult but "555-35-35" is much simpler.
3471// Imagine a man taking a bus from home to work and seeing an ad with a phone number.
3472// He has a couple of seconds to memorize that number until it passes by.
3473// If it were spaces instead of hyphens the man wouldn't necessarily get it,
3474// but with hyphens instead of spaces the grouping is more explicit.
3475// I personally think that hyphens introduce visual clutter,
3476// so I prefer replacing them with spaces in international numbers.
3477// In the modern age all output is done on displays where spaces are clearly distinguishable
3478// so hyphens can be safely replaced with spaces without losing any legibility.
3479//
3480
3481function applyInternationalSeparatorStyle(formattedNumber) {
3482 return formattedNumber.replace(new RegExp("[".concat(VALID_PUNCTUATION, "]+"), 'g'), ' ').trim();
3483}
3484
3485// first group is not used in the national pattern (e.g. Argentina) so the $1
3486// group does not match correctly. Therefore, we use `\d`, so that the first
3487// group actually used in the pattern will be matched.
3488
3489var FIRST_GROUP_PATTERN = /(\$\d)/;
3490function formatNationalNumberUsingFormat(number, format, _ref) {
3491 var useInternationalFormat = _ref.useInternationalFormat,
3492 withNationalPrefix = _ref.withNationalPrefix;
3493 _ref.carrierCode;
3494 _ref.metadata;
3495 var formattedNumber = number.replace(new RegExp(format.pattern()), useInternationalFormat ? format.internationalFormat() : // This library doesn't use `domestic_carrier_code_formatting_rule`,
3496 // because that one is only used when formatting phone numbers
3497 // for dialing from a mobile phone, and this is not a dialing library.
3498 // carrierCode && format.domesticCarrierCodeFormattingRule()
3499 // // First, replace the $CC in the formatting rule with the desired carrier code.
3500 // // Then, replace the $FG in the formatting rule with the first group
3501 // // and the carrier code combined in the appropriate way.
3502 // ? format.format().replace(FIRST_GROUP_PATTERN, format.domesticCarrierCodeFormattingRule().replace('$CC', carrierCode))
3503 // : (
3504 // withNationalPrefix && format.nationalPrefixFormattingRule()
3505 // ? format.format().replace(FIRST_GROUP_PATTERN, format.nationalPrefixFormattingRule())
3506 // : format.format()
3507 // )
3508 withNationalPrefix && format.nationalPrefixFormattingRule() ? format.format().replace(FIRST_GROUP_PATTERN, format.nationalPrefixFormattingRule()) : format.format());
3509
3510 if (useInternationalFormat) {
3511 return applyInternationalSeparatorStyle(formattedNumber);
3512 }
3513
3514 return formattedNumber;
3515}
3516
3517/**
3518 * Pattern that makes it easy to distinguish whether a region has a single
3519 * international dialing prefix or not. If a region has a single international
3520 * prefix (e.g. 011 in USA), it will be represented as a string that contains
3521 * a sequence of ASCII digits, and possibly a tilde, which signals waiting for
3522 * the tone. If there are multiple available international prefixes in a
3523 * region, they will be represented as a regex string that always contains one
3524 * or more characters that are not ASCII digits or a tilde.
3525 */
3526
3527var SINGLE_IDD_PREFIX_REG_EXP = /^[\d]+(?:[~\u2053\u223C\uFF5E][\d]+)?$/; // For regions that have multiple IDD prefixes
3528// a preferred IDD prefix is returned.
3529
3530function getIddPrefix(country, callingCode, metadata) {
3531 var countryMetadata = new Metadata(metadata);
3532 countryMetadata.selectNumberingPlan(country, callingCode);
3533
3534 if (countryMetadata.defaultIDDPrefix()) {
3535 return countryMetadata.defaultIDDPrefix();
3536 }
3537
3538 if (SINGLE_IDD_PREFIX_REG_EXP.test(countryMetadata.IDDPrefix())) {
3539 return countryMetadata.IDDPrefix();
3540 }
3541}
3542
3543function _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$7(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."); }
3544
3545function _unsupportedIterableToArray$7(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$7(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$7(o, minLen); }
3546
3547function _arrayLikeToArray$7(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; }
3548
3549function ownKeys$6(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; }
3550
3551function _objectSpread$6(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$6(Object(source), !0).forEach(function (key) { _defineProperty$6(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$6(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
3552
3553function _defineProperty$6(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; }
3554var DEFAULT_OPTIONS = {
3555 formatExtension: function formatExtension(formattedNumber, extension, metadata) {
3556 return "".concat(formattedNumber).concat(metadata.ext()).concat(extension);
3557 }
3558};
3559/**
3560 * Formats a phone number.
3561 *
3562 * format(phoneNumberInstance, 'INTERNATIONAL', { ..., v2: true }, metadata)
3563 * format(phoneNumberInstance, 'NATIONAL', { ..., v2: true }, metadata)
3564 *
3565 * format({ phone: '8005553535', country: 'RU' }, 'INTERNATIONAL', { ... }, metadata)
3566 * format({ phone: '8005553535', country: 'RU' }, 'NATIONAL', undefined, metadata)
3567 *
3568 * @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: '...' }`.
3569 * @param {string} format
3570 * @param {object} [options]
3571 * @param {object} metadata
3572 * @return {string}
3573 */
3574
3575function formatNumber(input, format, options, metadata) {
3576 // Apply default options.
3577 if (options) {
3578 options = _objectSpread$6(_objectSpread$6({}, DEFAULT_OPTIONS), options);
3579 } else {
3580 options = DEFAULT_OPTIONS;
3581 }
3582
3583 metadata = new Metadata(metadata);
3584
3585 if (input.country && input.country !== '001') {
3586 // Validate `input.country`.
3587 if (!metadata.hasCountry(input.country)) {
3588 throw new Error("Unknown country: ".concat(input.country));
3589 }
3590
3591 metadata.country(input.country);
3592 } else if (input.countryCallingCode) {
3593 metadata.selectNumberingPlan(input.countryCallingCode);
3594 } else return input.phone || '';
3595
3596 var countryCallingCode = metadata.countryCallingCode();
3597 var nationalNumber = options.v2 ? input.nationalNumber : input.phone; // This variable should have been declared inside `case`s
3598 // but Babel has a bug and it says "duplicate variable declaration".
3599
3600 var number;
3601
3602 switch (format) {
3603 case 'NATIONAL':
3604 // Legacy argument support.
3605 // (`{ country: ..., phone: '' }`)
3606 if (!nationalNumber) {
3607 return '';
3608 }
3609
3610 number = formatNationalNumber$1(nationalNumber, input.carrierCode, 'NATIONAL', metadata, options);
3611 return addExtension(number, input.ext, metadata, options.formatExtension);
3612
3613 case 'INTERNATIONAL':
3614 // Legacy argument support.
3615 // (`{ country: ..., phone: '' }`)
3616 if (!nationalNumber) {
3617 return "+".concat(countryCallingCode);
3618 }
3619
3620 number = formatNationalNumber$1(nationalNumber, null, 'INTERNATIONAL', metadata, options);
3621 number = "+".concat(countryCallingCode, " ").concat(number);
3622 return addExtension(number, input.ext, metadata, options.formatExtension);
3623
3624 case 'E.164':
3625 // `E.164` doesn't define "phone number extensions".
3626 return "+".concat(countryCallingCode).concat(nationalNumber);
3627
3628 case 'RFC3966':
3629 return formatRFC3966({
3630 number: "+".concat(countryCallingCode).concat(nationalNumber),
3631 ext: input.ext
3632 });
3633 // For reference, here's Google's IDD formatter:
3634 // https://github.com/google/libphonenumber/blob/32719cf74e68796788d1ca45abc85dcdc63ba5b9/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java#L1546
3635 // Not saying that this IDD formatter replicates it 1:1, but it seems to work.
3636 // Who would even need to format phone numbers in IDD format anyway?
3637
3638 case 'IDD':
3639 if (!options.fromCountry) {
3640 return; // throw new Error('`fromCountry` option not passed for IDD-prefixed formatting.')
3641 }
3642
3643 var formattedNumber = formatIDD(nationalNumber, input.carrierCode, countryCallingCode, options.fromCountry, metadata);
3644 return addExtension(formattedNumber, input.ext, metadata, options.formatExtension);
3645
3646 default:
3647 throw new Error("Unknown \"format\" argument passed to \"formatNumber()\": \"".concat(format, "\""));
3648 }
3649}
3650
3651function formatNationalNumber$1(number, carrierCode, formatAs, metadata, options) {
3652 var format = chooseFormatForNumber(metadata.formats(), number);
3653
3654 if (!format) {
3655 return number;
3656 }
3657
3658 return formatNationalNumberUsingFormat(number, format, {
3659 useInternationalFormat: formatAs === 'INTERNATIONAL',
3660 withNationalPrefix: format.nationalPrefixIsOptionalWhenFormattingInNationalFormat() && options && options.nationalPrefix === false ? false : true,
3661 carrierCode: carrierCode,
3662 metadata: metadata
3663 });
3664}
3665
3666function chooseFormatForNumber(availableFormats, nationalNnumber) {
3667 for (var _iterator = _createForOfIteratorHelperLoose$4(availableFormats), _step; !(_step = _iterator()).done;) {
3668 var format = _step.value;
3669
3670 // Validate leading digits.
3671 // The test case for "else path" could be found by searching for
3672 // "format.leadingDigitsPatterns().length === 0".
3673 if (format.leadingDigitsPatterns().length > 0) {
3674 // The last leading_digits_pattern is used here, as it is the most detailed
3675 var lastLeadingDigitsPattern = format.leadingDigitsPatterns()[format.leadingDigitsPatterns().length - 1]; // If leading digits don't match then move on to the next phone number format
3676
3677 if (nationalNnumber.search(lastLeadingDigitsPattern) !== 0) {
3678 continue;
3679 }
3680 } // Check that the national number matches the phone number format regular expression
3681
3682
3683 if (matchesEntirely(nationalNnumber, format.pattern())) {
3684 return format;
3685 }
3686 }
3687}
3688
3689function addExtension(formattedNumber, ext, metadata, formatExtension) {
3690 return ext ? formatExtension(formattedNumber, ext, metadata) : formattedNumber;
3691}
3692
3693function formatIDD(nationalNumber, carrierCode, countryCallingCode, fromCountry, metadata) {
3694 var fromCountryCallingCode = getCountryCallingCode(fromCountry, metadata.metadata); // When calling within the same country calling code.
3695
3696 if (fromCountryCallingCode === countryCallingCode) {
3697 var formattedNumber = formatNationalNumber$1(nationalNumber, carrierCode, 'NATIONAL', metadata); // For NANPA regions, return the national format for these regions
3698 // but prefix it with the country calling code.
3699
3700 if (countryCallingCode === '1') {
3701 return countryCallingCode + ' ' + formattedNumber;
3702 } // If regions share a country calling code, the country calling code need
3703 // not be dialled. This also applies when dialling within a region, so this
3704 // if clause covers both these cases. Technically this is the case for
3705 // dialling from La Reunion to other overseas departments of France (French
3706 // Guiana, Martinique, Guadeloupe), but not vice versa - so we don't cover
3707 // this edge case for now and for those cases return the version including
3708 // country calling code. Details here:
3709 // http://www.petitfute.com/voyage/225-info-pratiques-reunion
3710 //
3711
3712
3713 return formattedNumber;
3714 }
3715
3716 var iddPrefix = getIddPrefix(fromCountry, undefined, metadata.metadata);
3717
3718 if (iddPrefix) {
3719 return "".concat(iddPrefix, " ").concat(countryCallingCode, " ").concat(formatNationalNumber$1(nationalNumber, null, 'INTERNATIONAL', metadata));
3720 }
3721}
3722
3723function 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; }
3724
3725function _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; }
3726
3727function _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; }
3728
3729function _classCallCheck$6(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
3730
3731function _defineProperties$6(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); } }
3732
3733function _createClass$6(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$6(Constructor.prototype, protoProps); if (staticProps) _defineProperties$6(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
3734
3735var PhoneNumber = /*#__PURE__*/function () {
3736 function PhoneNumber(countryOrCountryCallingCode, nationalNumber, metadata) {
3737 _classCallCheck$6(this, PhoneNumber);
3738
3739 if (!countryOrCountryCallingCode) {
3740 throw new TypeError('`country` or `countryCallingCode` not passed');
3741 }
3742
3743 if (!nationalNumber) {
3744 throw new TypeError('`nationalNumber` not passed');
3745 }
3746
3747 if (!metadata) {
3748 throw new TypeError('`metadata` not passed');
3749 }
3750
3751 var _getCountryAndCountry = getCountryAndCountryCallingCode(countryOrCountryCallingCode, metadata),
3752 country = _getCountryAndCountry.country,
3753 countryCallingCode = _getCountryAndCountry.countryCallingCode;
3754
3755 this.country = country;
3756 this.countryCallingCode = countryCallingCode;
3757 this.nationalNumber = nationalNumber;
3758 this.number = '+' + this.countryCallingCode + this.nationalNumber;
3759 this.metadata = metadata;
3760 }
3761
3762 _createClass$6(PhoneNumber, [{
3763 key: "setExt",
3764 value: function setExt(ext) {
3765 this.ext = ext;
3766 }
3767 }, {
3768 key: "getPossibleCountries",
3769 value: function getPossibleCountries() {
3770 if (this.country) {
3771 return [this.country];
3772 }
3773
3774 return getPossibleCountriesForNumber(this.countryCallingCode, this.nationalNumber, this.metadata);
3775 }
3776 }, {
3777 key: "isPossible",
3778 value: function isPossible() {
3779 return isPossiblePhoneNumber$2(this, {
3780 v2: true
3781 }, this.metadata);
3782 }
3783 }, {
3784 key: "isValid",
3785 value: function isValid() {
3786 return isValidNumber(this, {
3787 v2: true
3788 }, this.metadata);
3789 }
3790 }, {
3791 key: "isNonGeographic",
3792 value: function isNonGeographic() {
3793 var metadata = new Metadata(this.metadata);
3794 return metadata.isNonGeographicCallingCode(this.countryCallingCode);
3795 }
3796 }, {
3797 key: "isEqual",
3798 value: function isEqual(phoneNumber) {
3799 return this.number === phoneNumber.number && this.ext === phoneNumber.ext;
3800 } // This function was originally meant to be an equivalent for `validatePhoneNumberLength()`,
3801 // but later it was found out that it doesn't include the possible `TOO_SHORT` result
3802 // returned from `parsePhoneNumberWithError()` in the original `validatePhoneNumberLength()`,
3803 // so eventually I simply commented out this method from the `PhoneNumber` class
3804 // and just left the `validatePhoneNumberLength()` function, even though that one would require
3805 // and additional step to also validate the actual country / calling code of the phone number.
3806 // validateLength() {
3807 // const metadata = new Metadata(this.metadata)
3808 // metadata.selectNumberingPlan(this.countryCallingCode)
3809 // const result = checkNumberLength(this.nationalNumber, metadata)
3810 // if (result !== 'IS_POSSIBLE') {
3811 // return result
3812 // }
3813 // }
3814
3815 }, {
3816 key: "getType",
3817 value: function getType() {
3818 return getNumberType(this, {
3819 v2: true
3820 }, this.metadata);
3821 }
3822 }, {
3823 key: "format",
3824 value: function format(_format, options) {
3825 return formatNumber(this, _format, options ? _objectSpread$5(_objectSpread$5({}, options), {}, {
3826 v2: true
3827 }) : {
3828 v2: true
3829 }, this.metadata);
3830 }
3831 }, {
3832 key: "formatNational",
3833 value: function formatNational(options) {
3834 return this.format('NATIONAL', options);
3835 }
3836 }, {
3837 key: "formatInternational",
3838 value: function formatInternational(options) {
3839 return this.format('INTERNATIONAL', options);
3840 }
3841 }, {
3842 key: "getURI",
3843 value: function getURI(options) {
3844 return this.format('RFC3966', options);
3845 }
3846 }]);
3847
3848 return PhoneNumber;
3849}();
3850
3851var isCountryCode = function isCountryCode(value) {
3852 return /^[A-Z]{2}$/.test(value);
3853};
3854
3855function getCountryAndCountryCallingCode(countryOrCountryCallingCode, metadataJson) {
3856 var country;
3857 var countryCallingCode;
3858 var metadata = new Metadata(metadataJson); // If country code is passed then derive `countryCallingCode` from it.
3859 // Also store the country code as `.country`.
3860
3861 if (isCountryCode(countryOrCountryCallingCode)) {
3862 country = countryOrCountryCallingCode;
3863 metadata.selectNumberingPlan(country);
3864 countryCallingCode = metadata.countryCallingCode();
3865 } else {
3866 countryCallingCode = countryOrCountryCallingCode;
3867 }
3868
3869 return {
3870 country: country,
3871 countryCallingCode: countryCallingCode
3872 };
3873}
3874
3875var CAPTURING_DIGIT_PATTERN = new RegExp('([' + VALID_DIGITS + '])');
3876function stripIddPrefix(number, country, callingCode, metadata) {
3877 if (!country) {
3878 return;
3879 } // Check if the number is IDD-prefixed.
3880
3881
3882 var countryMetadata = new Metadata(metadata);
3883 countryMetadata.selectNumberingPlan(country, callingCode);
3884 var IDDPrefixPattern = new RegExp(countryMetadata.IDDPrefix());
3885
3886 if (number.search(IDDPrefixPattern) !== 0) {
3887 return;
3888 } // Strip IDD prefix.
3889
3890
3891 number = number.slice(number.match(IDDPrefixPattern)[0].length); // If there're any digits after an IDD prefix,
3892 // then those digits are a country calling code.
3893 // Since no country code starts with a `0`,
3894 // the code below validates that the next digit (if present) is not `0`.
3895
3896 var matchedGroups = number.match(CAPTURING_DIGIT_PATTERN);
3897
3898 if (matchedGroups && matchedGroups[1] != null && matchedGroups[1].length > 0) {
3899 if (matchedGroups[1] === '0') {
3900 return;
3901 }
3902 }
3903
3904 return number;
3905}
3906
3907/**
3908 * Strips any national prefix (such as 0, 1) present in a
3909 * (possibly incomplete) number provided.
3910 * "Carrier codes" are only used in Colombia and Brazil,
3911 * and only when dialing within those countries from a mobile phone to a fixed line number.
3912 * Sometimes it won't actually strip national prefix
3913 * and will instead prepend some digits to the `number`:
3914 * for example, when number `2345678` is passed with `VI` country selected,
3915 * it will return `{ number: "3402345678" }`, because `340` area code is prepended.
3916 * @param {string} number — National number digits.
3917 * @param {object} metadata — Metadata with country selected.
3918 * @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.
3919 */
3920function extractNationalNumberFromPossiblyIncompleteNumber(number, metadata) {
3921 if (number && metadata.numberingPlan.nationalPrefixForParsing()) {
3922 // See METADATA.md for the description of
3923 // `national_prefix_for_parsing` and `national_prefix_transform_rule`.
3924 // Attempt to parse the first digits as a national prefix.
3925 var prefixPattern = new RegExp('^(?:' + metadata.numberingPlan.nationalPrefixForParsing() + ')');
3926 var prefixMatch = prefixPattern.exec(number);
3927
3928 if (prefixMatch) {
3929 var nationalNumber;
3930 var carrierCode; // https://gitlab.com/catamphetamine/libphonenumber-js/-/blob/master/METADATA.md#national_prefix_for_parsing--national_prefix_transform_rule
3931 // If a `national_prefix_for_parsing` has any "capturing groups"
3932 // then it means that the national (significant) number is equal to
3933 // those "capturing groups" transformed via `national_prefix_transform_rule`,
3934 // and nothing could be said about the actual national prefix:
3935 // what is it and was it even there.
3936 // If a `national_prefix_for_parsing` doesn't have any "capturing groups",
3937 // then everything it matches is a national prefix.
3938 // To determine whether `national_prefix_for_parsing` matched any
3939 // "capturing groups", the value of the result of calling `.exec()`
3940 // is looked at, and if it has non-undefined values where there're
3941 // "capturing groups" in the regular expression, then it means
3942 // that "capturing groups" have been matched.
3943 // It's not possible to tell whether there'll be any "capturing gropus"
3944 // before the matching process, because a `national_prefix_for_parsing`
3945 // could exhibit both behaviors.
3946
3947 var capturedGroupsCount = prefixMatch.length - 1;
3948 var hasCapturedGroups = capturedGroupsCount > 0 && prefixMatch[capturedGroupsCount];
3949
3950 if (metadata.nationalPrefixTransformRule() && hasCapturedGroups) {
3951 nationalNumber = number.replace(prefixPattern, metadata.nationalPrefixTransformRule()); // If there's more than one captured group,
3952 // then carrier code is the second one.
3953
3954 if (capturedGroupsCount > 1) {
3955 carrierCode = prefixMatch[1];
3956 }
3957 } // If there're no "capturing groups",
3958 // or if there're "capturing groups" but no
3959 // `national_prefix_transform_rule`,
3960 // then just strip the national prefix from the number,
3961 // and possibly a carrier code.
3962 // Seems like there could be more.
3963 else {
3964 // `prefixBeforeNationalNumber` is the whole substring matched by
3965 // the `national_prefix_for_parsing` regular expression.
3966 // There seem to be no guarantees that it's just a national prefix.
3967 // For example, if there's a carrier code, it's gonna be a
3968 // part of `prefixBeforeNationalNumber` too.
3969 var prefixBeforeNationalNumber = prefixMatch[0];
3970 nationalNumber = number.slice(prefixBeforeNationalNumber.length); // If there's at least one captured group,
3971 // then carrier code is the first one.
3972
3973 if (hasCapturedGroups) {
3974 carrierCode = prefixMatch[1];
3975 }
3976 } // Tries to guess whether a national prefix was present in the input.
3977 // This is not something copy-pasted from Google's library:
3978 // they don't seem to have an equivalent for that.
3979 // So this isn't an "officially approved" way of doing something like that.
3980 // But since there seems no other existing method, this library uses it.
3981
3982
3983 var nationalPrefix;
3984
3985 if (hasCapturedGroups) {
3986 var possiblePositionOfTheFirstCapturedGroup = number.indexOf(prefixMatch[1]);
3987 var possibleNationalPrefix = number.slice(0, possiblePositionOfTheFirstCapturedGroup); // Example: an Argentinian (AR) phone number `0111523456789`.
3988 // `prefixMatch[0]` is `01115`, and `$1` is `11`,
3989 // and the rest of the phone number is `23456789`.
3990 // The national number is transformed via `9$1` to `91123456789`.
3991 // National prefix `0` is detected being present at the start.
3992 // if (possibleNationalPrefix.indexOf(metadata.numberingPlan.nationalPrefix()) === 0) {
3993
3994 if (possibleNationalPrefix === metadata.numberingPlan.nationalPrefix()) {
3995 nationalPrefix = metadata.numberingPlan.nationalPrefix();
3996 }
3997 } else {
3998 nationalPrefix = prefixMatch[0];
3999 }
4000
4001 return {
4002 nationalNumber: nationalNumber,
4003 nationalPrefix: nationalPrefix,
4004 carrierCode: carrierCode
4005 };
4006 }
4007 }
4008
4009 return {
4010 nationalNumber: number
4011 };
4012}
4013
4014/**
4015 * Strips national prefix and carrier code from a complete phone number.
4016 * The difference from the non-"FromCompleteNumber" function is that
4017 * it won't extract national prefix if the resultant number is too short
4018 * to be a complete number for the selected phone numbering plan.
4019 * @param {string} number — Complete phone number digits.
4020 * @param {Metadata} metadata — Metadata with a phone numbering plan selected.
4021 * @return {object} `{ nationalNumber: string, carrierCode: string? }`.
4022 */
4023
4024function extractNationalNumber(number, metadata) {
4025 // Parsing national prefixes and carrier codes
4026 // is only required for local phone numbers
4027 // but some people don't understand that
4028 // and sometimes write international phone numbers
4029 // with national prefixes (or maybe even carrier codes).
4030 // http://ucken.blogspot.ru/2016/03/trunk-prefixes-in-skype4b.html
4031 // Google's original library forgives such mistakes
4032 // and so does this library, because it has been requested:
4033 // https://github.com/catamphetamine/libphonenumber-js/issues/127
4034 var _extractNationalNumbe = extractNationalNumberFromPossiblyIncompleteNumber(number, metadata),
4035 carrierCode = _extractNationalNumbe.carrierCode,
4036 nationalNumber = _extractNationalNumbe.nationalNumber;
4037
4038 if (nationalNumber !== number) {
4039 if (!shouldHaveExtractedNationalPrefix(number, nationalNumber, metadata)) {
4040 // Don't strip the national prefix.
4041 return {
4042 nationalNumber: number
4043 };
4044 } // Check the national (significant) number length after extracting national prefix and carrier code.
4045 // Legacy generated metadata (before `1.0.18`) didn't support the "possible lengths" feature.
4046
4047
4048 if (metadata.possibleLengths()) {
4049 // The number remaining after stripping the national prefix and carrier code
4050 // should be long enough to have a possible length for the country.
4051 // Otherwise, don't strip the national prefix and carrier code,
4052 // since the original number could be a valid number.
4053 // This check has been copy-pasted "as is" from Google's original library:
4054 // https://github.com/google/libphonenumber/blob/876268eb1ad6cdc1b7b5bef17fc5e43052702d57/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java#L3236-L3250
4055 // It doesn't check for the "possibility" of the original `number`.
4056 // I guess it's fine not checking that one. It works as is anyway.
4057 if (!isPossibleIncompleteNationalNumber(nationalNumber, metadata)) {
4058 // Don't strip the national prefix.
4059 return {
4060 nationalNumber: number
4061 };
4062 }
4063 }
4064 }
4065
4066 return {
4067 nationalNumber: nationalNumber,
4068 carrierCode: carrierCode
4069 };
4070} // In some countries, the same digit could be a national prefix
4071// or a leading digit of a valid phone number.
4072// For example, in Russia, national prefix is `8`,
4073// and also `800 555 35 35` is a valid number
4074// in which `8` is not a national prefix, but the first digit
4075// of a national (significant) number.
4076// Same's with Belarus:
4077// `82004910060` is a valid national (significant) number,
4078// but `2004910060` is not.
4079// To support such cases (to prevent the code from always stripping
4080// national prefix), a condition is imposed: a national prefix
4081// is not extracted when the original number is "viable" and the
4082// resultant number is not, a "viable" national number being the one
4083// that matches `national_number_pattern`.
4084
4085function shouldHaveExtractedNationalPrefix(nationalNumberBefore, nationalNumberAfter, metadata) {
4086 // The equivalent in Google's code is:
4087 // https://github.com/google/libphonenumber/blob/e326fa1fc4283bb05eb35cb3c15c18f98a31af33/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java#L2969-L3004
4088 if (matchesEntirely(nationalNumberBefore, metadata.nationalNumberPattern()) && !matchesEntirely(nationalNumberAfter, metadata.nationalNumberPattern())) {
4089 return false;
4090 } // This "is possible" national number (length) check has been commented out
4091 // because it's superceded by the (effectively) same check done in the
4092 // `extractNationalNumber()` function after it calls `shouldHaveExtractedNationalPrefix()`.
4093 // In other words, why run the same check twice if it could only be run once.
4094 // // Check the national (significant) number length after extracting national prefix and carrier code.
4095 // // Fixes a minor "weird behavior" bug: https://gitlab.com/catamphetamine/libphonenumber-js/-/issues/57
4096 // // (Legacy generated metadata (before `1.0.18`) didn't support the "possible lengths" feature).
4097 // if (metadata.possibleLengths()) {
4098 // if (isPossibleIncompleteNationalNumber(nationalNumberBefore, metadata) &&
4099 // !isPossibleIncompleteNationalNumber(nationalNumberAfter, metadata)) {
4100 // return false
4101 // }
4102 // }
4103
4104
4105 return true;
4106}
4107
4108function isPossibleIncompleteNationalNumber(nationalNumber, metadata) {
4109 switch (checkNumberLength(nationalNumber, metadata)) {
4110 case 'TOO_SHORT':
4111 case 'INVALID_LENGTH':
4112 // This library ignores "local-only" phone numbers (for simplicity).
4113 // See the readme for more info on what are "local-only" phone numbers.
4114 // case 'IS_POSSIBLE_LOCAL_ONLY':
4115 return false;
4116
4117 default:
4118 return true;
4119 }
4120}
4121
4122/**
4123 * Sometimes some people incorrectly input international phone numbers
4124 * without the leading `+`. This function corrects such input.
4125 * @param {string} number — Phone number digits.
4126 * @param {string?} country
4127 * @param {string?} callingCode
4128 * @param {object} metadata
4129 * @return {object} `{ countryCallingCode: string?, number: string }`.
4130 */
4131
4132function extractCountryCallingCodeFromInternationalNumberWithoutPlusSign(number, country, callingCode, metadata) {
4133 var countryCallingCode = country ? getCountryCallingCode(country, metadata) : callingCode;
4134
4135 if (number.indexOf(countryCallingCode) === 0) {
4136 metadata = new Metadata(metadata);
4137 metadata.selectNumberingPlan(country, callingCode);
4138 var possibleShorterNumber = number.slice(countryCallingCode.length);
4139
4140 var _extractNationalNumbe = extractNationalNumber(possibleShorterNumber, metadata),
4141 possibleShorterNationalNumber = _extractNationalNumbe.nationalNumber;
4142
4143 var _extractNationalNumbe2 = extractNationalNumber(number, metadata),
4144 nationalNumber = _extractNationalNumbe2.nationalNumber; // If the number was not valid before but is valid now,
4145 // or if it was too long before, we consider the number
4146 // with the country calling code stripped to be a better result
4147 // and keep that instead.
4148 // For example, in Germany (+49), `49` is a valid area code,
4149 // so if a number starts with `49`, it could be both a valid
4150 // national German number or an international number without
4151 // a leading `+`.
4152
4153
4154 if (!matchesEntirely(nationalNumber, metadata.nationalNumberPattern()) && matchesEntirely(possibleShorterNationalNumber, metadata.nationalNumberPattern()) || checkNumberLength(nationalNumber, metadata) === 'TOO_LONG') {
4155 return {
4156 countryCallingCode: countryCallingCode,
4157 number: possibleShorterNumber
4158 };
4159 }
4160 }
4161
4162 return {
4163 number: number
4164 };
4165}
4166
4167/**
4168 * Converts a phone number digits (possibly with a `+`)
4169 * into a calling code and the rest phone number digits.
4170 * The "rest phone number digits" could include
4171 * a national prefix, carrier code, and national
4172 * (significant) number.
4173 * @param {string} number — Phone number digits (possibly with a `+`).
4174 * @param {string} [country] — Default country.
4175 * @param {string} [callingCode] — Default calling code (some phone numbering plans are non-geographic).
4176 * @param {object} metadata
4177 * @return {object} `{ countryCallingCode: string?, number: string }`
4178 * @example
4179 * // Returns `{ countryCallingCode: "1", number: "2133734253" }`.
4180 * extractCountryCallingCode('2133734253', 'US', null, metadata)
4181 * extractCountryCallingCode('2133734253', null, '1', metadata)
4182 * extractCountryCallingCode('+12133734253', null, null, metadata)
4183 * extractCountryCallingCode('+12133734253', 'RU', null, metadata)
4184 */
4185
4186function extractCountryCallingCode(number, country, callingCode, metadata) {
4187 if (!number) {
4188 return {};
4189 } // If this is not an international phone number,
4190 // then either extract an "IDD" prefix, or extract a
4191 // country calling code from a number by autocorrecting it
4192 // by prepending a leading `+` in cases when it starts
4193 // with the country calling code.
4194 // https://wikitravel.org/en/International_dialling_prefix
4195 // https://github.com/catamphetamine/libphonenumber-js/issues/376
4196
4197
4198 if (number[0] !== '+') {
4199 // Convert an "out-of-country" dialing phone number
4200 // to a proper international phone number.
4201 var numberWithoutIDD = stripIddPrefix(number, country, callingCode, metadata); // If an IDD prefix was stripped then
4202 // convert the number to international one
4203 // for subsequent parsing.
4204
4205 if (numberWithoutIDD && numberWithoutIDD !== number) {
4206 number = '+' + numberWithoutIDD;
4207 } else {
4208 // Check to see if the number starts with the country calling code
4209 // for the default country. If so, we remove the country calling code,
4210 // and do some checks on the validity of the number before and after.
4211 // https://github.com/catamphetamine/libphonenumber-js/issues/376
4212 if (country || callingCode) {
4213 var _extractCountryCallin = extractCountryCallingCodeFromInternationalNumberWithoutPlusSign(number, country, callingCode, metadata),
4214 countryCallingCode = _extractCountryCallin.countryCallingCode,
4215 shorterNumber = _extractCountryCallin.number;
4216
4217 if (countryCallingCode) {
4218 return {
4219 countryCallingCode: countryCallingCode,
4220 number: shorterNumber
4221 };
4222 }
4223 }
4224
4225 return {
4226 number: number
4227 };
4228 }
4229 } // Fast abortion: country codes do not begin with a '0'
4230
4231
4232 if (number[1] === '0') {
4233 return {};
4234 }
4235
4236 metadata = new Metadata(metadata); // The thing with country phone codes
4237 // is that they are orthogonal to each other
4238 // i.e. there's no such country phone code A
4239 // for which country phone code B exists
4240 // where B starts with A.
4241 // Therefore, while scanning digits,
4242 // if a valid country code is found,
4243 // that means that it is the country code.
4244 //
4245
4246 var i = 2;
4247
4248 while (i - 1 <= MAX_LENGTH_COUNTRY_CODE && i <= number.length) {
4249 var _countryCallingCode = number.slice(1, i);
4250
4251 if (metadata.hasCallingCode(_countryCallingCode)) {
4252 metadata.selectNumberingPlan(_countryCallingCode);
4253 return {
4254 countryCallingCode: _countryCallingCode,
4255 number: number.slice(i)
4256 };
4257 }
4258
4259 i++;
4260 }
4261
4262 return {};
4263}
4264
4265function _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$6(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."); }
4266
4267function _unsupportedIterableToArray$6(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$6(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$6(o, minLen); }
4268
4269function _arrayLikeToArray$6(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; }
4270function getCountryByNationalNumber(possibleCountries, nationalPhoneNumber, metadata) {
4271 // Re-create `metadata` because it will be selecting a `country`.
4272 metadata = new Metadata(metadata);
4273
4274 for (var _iterator = _createForOfIteratorHelperLoose$3(possibleCountries), _step; !(_step = _iterator()).done;) {
4275 var country = _step.value;
4276 metadata.country(country); // "Leading digits" patterns are only defined for about 20% of all countries.
4277 // By definition, matching "leading digits" is a sufficient but not a necessary
4278 // condition for a phone number to belong to a country.
4279 // The point of "leading digits" check is that it's the fastest one to get a match.
4280 // https://gitlab.com/catamphetamine/libphonenumber-js/blob/master/METADATA.md#leading_digits
4281
4282 if (metadata.leadingDigits()) {
4283 if (nationalPhoneNumber && nationalPhoneNumber.search(metadata.leadingDigits()) === 0) {
4284 return country;
4285 }
4286 } // Else perform full validation with all of those
4287 // fixed-line/mobile/etc regular expressions.
4288 else if (getNumberType({
4289 phone: nationalPhoneNumber,
4290 country: country
4291 }, undefined, metadata.metadata)) {
4292 return country;
4293 }
4294 }
4295}
4296
4297var USE_NON_GEOGRAPHIC_COUNTRY_CODE = false;
4298function getCountryByCallingCode(callingCode, nationalPhoneNumber, metadata) {
4299 /* istanbul ignore if */
4300 if (USE_NON_GEOGRAPHIC_COUNTRY_CODE) {
4301 if (metadata.isNonGeographicCallingCode(callingCode)) {
4302 return '001';
4303 }
4304 }
4305
4306 var possibleCountries = metadata.getCountryCodesForCallingCode(callingCode);
4307
4308 if (!possibleCountries) {
4309 return;
4310 } // If there's just one country corresponding to the country code,
4311 // then just return it, without further phone number digits validation.
4312
4313
4314 if (possibleCountries.length === 1) {
4315 return possibleCountries[0];
4316 }
4317
4318 return getCountryByNationalNumber(possibleCountries, nationalPhoneNumber, metadata.metadata);
4319}
4320
4321// This is a port of Google Android `libphonenumber`'s
4322// `phonenumberutil.js` of December 31th, 2018.
4323//
4324// https://github.com/googlei18n/libphonenumber/commits/master/javascript/i18n/phonenumbers/phonenumberutil.js
4325// This prevents malicious input from consuming CPU.
4326
4327var MAX_INPUT_STRING_LENGTH = 250; // This consists of the plus symbol, digits, and arabic-indic digits.
4328
4329var PHONE_NUMBER_START_PATTERN = new RegExp('[' + PLUS_CHARS + VALID_DIGITS + ']'); // Regular expression of trailing characters that we want to remove.
4330// A trailing `#` is sometimes used when writing phone numbers with extensions in US.
4331// Example: "+1 (645) 123 1234-910#" number has extension "910".
4332
4333var AFTER_PHONE_NUMBER_END_PATTERN = new RegExp('[^' + VALID_DIGITS + '#' + ']+$');
4334//
4335// ```js
4336// parse('8 (800) 555-35-35', 'RU')
4337// parse('8 (800) 555-35-35', 'RU', metadata)
4338// parse('8 (800) 555-35-35', { country: { default: 'RU' } })
4339// parse('8 (800) 555-35-35', { country: { default: 'RU' } }, metadata)
4340// parse('+7 800 555 35 35')
4341// parse('+7 800 555 35 35', metadata)
4342// ```
4343//
4344
4345/**
4346 * Parses a phone number.
4347 *
4348 * parse('123456789', { defaultCountry: 'RU', v2: true }, metadata)
4349 * parse('123456789', { defaultCountry: 'RU' }, metadata)
4350 * parse('123456789', undefined, metadata)
4351 *
4352 * @param {string} input
4353 * @param {object} [options]
4354 * @param {object} metadata
4355 * @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).
4356 */
4357
4358function parse(text, options, metadata) {
4359 // If assigning the `{}` default value is moved to the arguments above,
4360 // code coverage would decrease for some weird reason.
4361 options = options || {};
4362 metadata = new Metadata(metadata); // Validate `defaultCountry`.
4363
4364 if (options.defaultCountry && !metadata.hasCountry(options.defaultCountry)) {
4365 if (options.v2) {
4366 throw new ParseError('INVALID_COUNTRY');
4367 }
4368
4369 throw new Error("Unknown country: ".concat(options.defaultCountry));
4370 } // Parse the phone number.
4371
4372
4373 var _parseInput = parseInput(text, options.v2, options.extract),
4374 formattedPhoneNumber = _parseInput.number,
4375 ext = _parseInput.ext,
4376 error = _parseInput.error; // If the phone number is not viable then return nothing.
4377
4378
4379 if (!formattedPhoneNumber) {
4380 if (options.v2) {
4381 if (error === 'TOO_SHORT') {
4382 throw new ParseError('TOO_SHORT');
4383 }
4384
4385 throw new ParseError('NOT_A_NUMBER');
4386 }
4387
4388 return {};
4389 }
4390
4391 var _parsePhoneNumber = parsePhoneNumber$1(formattedPhoneNumber, options.defaultCountry, options.defaultCallingCode, metadata),
4392 country = _parsePhoneNumber.country,
4393 nationalNumber = _parsePhoneNumber.nationalNumber,
4394 countryCallingCode = _parsePhoneNumber.countryCallingCode,
4395 carrierCode = _parsePhoneNumber.carrierCode;
4396
4397 if (!metadata.hasSelectedNumberingPlan()) {
4398 if (options.v2) {
4399 throw new ParseError('INVALID_COUNTRY');
4400 }
4401
4402 return {};
4403 } // Validate national (significant) number length.
4404
4405
4406 if (!nationalNumber || nationalNumber.length < MIN_LENGTH_FOR_NSN) {
4407 // Won't throw here because the regexp already demands length > 1.
4408
4409 /* istanbul ignore if */
4410 if (options.v2) {
4411 throw new ParseError('TOO_SHORT');
4412 } // Google's demo just throws an error in this case.
4413
4414
4415 return {};
4416 } // Validate national (significant) number length.
4417 //
4418 // A sidenote:
4419 //
4420 // They say that sometimes national (significant) numbers
4421 // can be longer than `MAX_LENGTH_FOR_NSN` (e.g. in Germany).
4422 // https://github.com/googlei18n/libphonenumber/blob/7e1748645552da39c4e1ba731e47969d97bdb539/resources/phonenumber.proto#L36
4423 // Such numbers will just be discarded.
4424 //
4425
4426
4427 if (nationalNumber.length > MAX_LENGTH_FOR_NSN) {
4428 if (options.v2) {
4429 throw new ParseError('TOO_LONG');
4430 } // Google's demo just throws an error in this case.
4431
4432
4433 return {};
4434 }
4435
4436 if (options.v2) {
4437 var phoneNumber = new PhoneNumber(countryCallingCode, nationalNumber, metadata.metadata);
4438
4439 if (country) {
4440 phoneNumber.country = country;
4441 }
4442
4443 if (carrierCode) {
4444 phoneNumber.carrierCode = carrierCode;
4445 }
4446
4447 if (ext) {
4448 phoneNumber.ext = ext;
4449 }
4450
4451 return phoneNumber;
4452 } // Check if national phone number pattern matches the number.
4453 // National number pattern is different for each country,
4454 // even for those ones which are part of the "NANPA" group.
4455
4456
4457 var valid = (options.extended ? metadata.hasSelectedNumberingPlan() : country) ? matchesEntirely(nationalNumber, metadata.nationalNumberPattern()) : false;
4458
4459 if (!options.extended) {
4460 return valid ? result(country, nationalNumber, ext) : {};
4461 } // isInternational: countryCallingCode !== undefined
4462
4463
4464 return {
4465 country: country,
4466 countryCallingCode: countryCallingCode,
4467 carrierCode: carrierCode,
4468 valid: valid,
4469 possible: valid ? true : options.extended === true && metadata.possibleLengths() && isPossibleNumber(nationalNumber, metadata) ? true : false,
4470 phone: nationalNumber,
4471 ext: ext
4472 };
4473}
4474/**
4475 * Extracts a formatted phone number from text.
4476 * Doesn't guarantee that the extracted phone number
4477 * is a valid phone number (for example, doesn't validate its length).
4478 * @param {string} text
4479 * @param {boolean} [extract] — If `false`, then will parse the entire `text` as a phone number.
4480 * @param {boolean} [throwOnError] — By default, it won't throw if the text is too long.
4481 * @return {string}
4482 * @example
4483 * // Returns "(213) 373-4253".
4484 * extractFormattedPhoneNumber("Call (213) 373-4253 for assistance.")
4485 */
4486
4487function extractFormattedPhoneNumber$1(text, extract, throwOnError) {
4488 if (!text) {
4489 return;
4490 }
4491
4492 if (text.length > MAX_INPUT_STRING_LENGTH) {
4493 if (throwOnError) {
4494 throw new ParseError('TOO_LONG');
4495 }
4496
4497 return;
4498 }
4499
4500 if (extract === false) {
4501 return text;
4502 } // Attempt to extract a possible number from the string passed in
4503
4504
4505 var startsAt = text.search(PHONE_NUMBER_START_PATTERN);
4506
4507 if (startsAt < 0) {
4508 return;
4509 }
4510
4511 return text // Trim everything to the left of the phone number
4512 .slice(startsAt) // Remove trailing non-numerical characters
4513 .replace(AFTER_PHONE_NUMBER_END_PATTERN, '');
4514}
4515/**
4516 * @param {string} text - Input.
4517 * @param {boolean} v2 - Legacy API functions don't pass `v2: true` flag.
4518 * @param {boolean} [extract] - Whether to extract a phone number from `text`, or attempt to parse the entire text as a phone number.
4519 * @return {object} `{ ?number, ?ext }`.
4520 */
4521
4522
4523function parseInput(text, v2, extract) {
4524 // Parse RFC 3966 phone number URI.
4525 if (text && text.indexOf('tel:') === 0) {
4526 return parseRFC3966(text);
4527 }
4528
4529 var number = extractFormattedPhoneNumber$1(text, extract, v2); // If the phone number is not viable, then abort.
4530
4531 if (!number) {
4532 return {};
4533 }
4534
4535 if (!isViablePhoneNumber(number)) {
4536 if (isViablePhoneNumberStart(number)) {
4537 return {
4538 error: 'TOO_SHORT'
4539 };
4540 }
4541
4542 return {};
4543 } // Attempt to parse extension first, since it doesn't require region-specific
4544 // data and we want to have the non-normalised number here.
4545
4546
4547 var withExtensionStripped = extractExtension(number);
4548
4549 if (withExtensionStripped.ext) {
4550 return withExtensionStripped;
4551 }
4552
4553 return {
4554 number: number
4555 };
4556}
4557/**
4558 * Creates `parse()` result object.
4559 */
4560
4561
4562function result(country, nationalNumber, ext) {
4563 var result = {
4564 country: country,
4565 phone: nationalNumber
4566 };
4567
4568 if (ext) {
4569 result.ext = ext;
4570 }
4571
4572 return result;
4573}
4574/**
4575 * Parses a viable phone number.
4576 * @param {string} formattedPhoneNumber — Example: "(213) 373-4253".
4577 * @param {string} [defaultCountry]
4578 * @param {string} [defaultCallingCode]
4579 * @param {Metadata} metadata
4580 * @return {object} Returns `{ country: string?, countryCallingCode: string?, nationalNumber: string? }`.
4581 */
4582
4583
4584function parsePhoneNumber$1(formattedPhoneNumber, defaultCountry, defaultCallingCode, metadata) {
4585 // Extract calling code from phone number.
4586 var _extractCountryCallin = extractCountryCallingCode(parseIncompletePhoneNumber(formattedPhoneNumber), defaultCountry, defaultCallingCode, metadata.metadata),
4587 countryCallingCode = _extractCountryCallin.countryCallingCode,
4588 number = _extractCountryCallin.number; // Choose a country by `countryCallingCode`.
4589
4590
4591 var country;
4592
4593 if (countryCallingCode) {
4594 metadata.selectNumberingPlan(countryCallingCode);
4595 } // If `formattedPhoneNumber` is passed in "national" format
4596 // then `number` is defined and `countryCallingCode` is `undefined`.
4597 else if (number && (defaultCountry || defaultCallingCode)) {
4598 metadata.selectNumberingPlan(defaultCountry, defaultCallingCode);
4599
4600 if (defaultCountry) {
4601 country = defaultCountry;
4602 }
4603
4604 countryCallingCode = defaultCallingCode || getCountryCallingCode(defaultCountry, metadata.metadata);
4605 } else return {};
4606
4607 if (!number) {
4608 return {
4609 countryCallingCode: countryCallingCode
4610 };
4611 }
4612
4613 var _extractNationalNumbe = extractNationalNumber(parseIncompletePhoneNumber(number), metadata),
4614 nationalNumber = _extractNationalNumbe.nationalNumber,
4615 carrierCode = _extractNationalNumbe.carrierCode; // Sometimes there are several countries
4616 // corresponding to the same country phone code
4617 // (e.g. NANPA countries all having `1` country phone code).
4618 // Therefore, to reliably determine the exact country,
4619 // national (significant) number should have been parsed first.
4620 //
4621 // When `metadata.json` is generated, all "ambiguous" country phone codes
4622 // get their countries populated with the full set of
4623 // "phone number type" regular expressions.
4624 //
4625
4626
4627 var exactCountry = getCountryByCallingCode(countryCallingCode, nationalNumber, metadata);
4628
4629 if (exactCountry) {
4630 country = exactCountry;
4631 /* istanbul ignore if */
4632
4633 if (exactCountry === '001') ; else {
4634 metadata.country(country);
4635 }
4636 }
4637
4638 return {
4639 country: country,
4640 countryCallingCode: countryCallingCode,
4641 nationalNumber: nationalNumber,
4642 carrierCode: carrierCode
4643 };
4644}
4645
4646function 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; }
4647
4648function _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; }
4649
4650function _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; }
4651function parsePhoneNumberWithError$2(text, options, metadata) {
4652 return parse(text, _objectSpread$4(_objectSpread$4({}, options), {}, {
4653 v2: true
4654 }), metadata);
4655}
4656
4657function _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); }
4658
4659function 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; }
4660
4661function _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; }
4662
4663function _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; }
4664
4665function _slicedToArray$2(arr, i) { return _arrayWithHoles$2(arr) || _iterableToArrayLimit$2(arr, i) || _unsupportedIterableToArray$5(arr, i) || _nonIterableRest$2(); }
4666
4667function _nonIterableRest$2() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4668
4669function _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); }
4670
4671function _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; }
4672
4673function _iterableToArrayLimit$2(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; }
4674
4675function _arrayWithHoles$2(arr) { if (Array.isArray(arr)) return arr; }
4676
4677// Extracts the following properties from function arguments:
4678// * input `text`
4679// * `options` object
4680// * `metadata` JSON
4681function normalizeArguments(args) {
4682 var _Array$prototype$slic = Array.prototype.slice.call(args),
4683 _Array$prototype$slic2 = _slicedToArray$2(_Array$prototype$slic, 4),
4684 arg_1 = _Array$prototype$slic2[0],
4685 arg_2 = _Array$prototype$slic2[1],
4686 arg_3 = _Array$prototype$slic2[2],
4687 arg_4 = _Array$prototype$slic2[3];
4688
4689 var text;
4690 var options;
4691 var metadata; // If the phone number is passed as a string.
4692 // `parsePhoneNumber('88005553535', ...)`.
4693
4694 if (typeof arg_1 === 'string') {
4695 text = arg_1;
4696 } else throw new TypeError('A text for parsing must be a string.'); // If "default country" argument is being passed then move it to `options`.
4697 // `parsePhoneNumber('88005553535', 'RU', [options], metadata)`.
4698
4699
4700 if (!arg_2 || typeof arg_2 === 'string') {
4701 if (arg_4) {
4702 options = arg_3;
4703 metadata = arg_4;
4704 } else {
4705 options = undefined;
4706 metadata = arg_3;
4707 }
4708
4709 if (arg_2) {
4710 options = _objectSpread$3({
4711 defaultCountry: arg_2
4712 }, options);
4713 }
4714 } // `defaultCountry` is not passed.
4715 // Example: `parsePhoneNumber('+78005553535', [options], metadata)`.
4716 else if (isObject(arg_2)) {
4717 if (arg_3) {
4718 options = arg_2;
4719 metadata = arg_3;
4720 } else {
4721 metadata = arg_2;
4722 }
4723 } else throw new Error("Invalid second argument: ".concat(arg_2));
4724
4725 return {
4726 text: text,
4727 options: options,
4728 metadata: metadata
4729 };
4730} // Otherwise istanbul would show this as "branch not covered".
4731
4732/* istanbul ignore next */
4733
4734var isObject = function isObject(_) {
4735 return _typeof$1(_) === 'object';
4736};
4737
4738function parsePhoneNumberWithError$1() {
4739 var _normalizeArguments = normalizeArguments(arguments),
4740 text = _normalizeArguments.text,
4741 options = _normalizeArguments.options,
4742 metadata = _normalizeArguments.metadata;
4743
4744 return parsePhoneNumberWithError$2(text, options, metadata);
4745}
4746
4747function 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; }
4748
4749function _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; }
4750
4751function _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; }
4752function parsePhoneNumber(text, options, metadata) {
4753 // Validate `defaultCountry`.
4754 if (options && options.defaultCountry && !isSupportedCountry(options.defaultCountry, metadata)) {
4755 options = _objectSpread$2(_objectSpread$2({}, options), {}, {
4756 defaultCountry: undefined
4757 });
4758 } // Parse phone number.
4759
4760
4761 try {
4762 return parsePhoneNumberWithError$2(text, options, metadata);
4763 } catch (error) {
4764 /* istanbul ignore else */
4765 if (error instanceof ParseError) ; else {
4766 throw error;
4767 }
4768 }
4769}
4770
4771function 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; }
4772
4773function _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; }
4774
4775function _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; }
4776function isValidPhoneNumber$1() {
4777 var _normalizeArguments = normalizeArguments(arguments),
4778 text = _normalizeArguments.text,
4779 options = _normalizeArguments.options,
4780 metadata = _normalizeArguments.metadata;
4781
4782 options = _objectSpread$1(_objectSpread$1({}, options), {}, {
4783 extract: false
4784 });
4785 var phoneNumber = parsePhoneNumber(text, options, metadata);
4786 return phoneNumber && phoneNumber.isValid() || false;
4787}
4788
4789function 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; }
4790
4791function _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; }
4792
4793function _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; }
4794function isPossiblePhoneNumber$1() {
4795 var _normalizeArguments = normalizeArguments(arguments),
4796 text = _normalizeArguments.text,
4797 options = _normalizeArguments.options,
4798 metadata = _normalizeArguments.metadata;
4799
4800 options = _objectSpread(_objectSpread({}, options), {}, {
4801 extract: false
4802 });
4803 var phoneNumber = parsePhoneNumber(text, options, metadata);
4804 return phoneNumber && phoneNumber.isPossible() || false;
4805}
4806
4807function _classCallCheck$5(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
4808
4809function _defineProperties$5(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); } }
4810
4811function _createClass$5(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$5(Constructor.prototype, protoProps); if (staticProps) _defineProperties$5(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
4812
4813var AsYouTypeState = /*#__PURE__*/function () {
4814 function AsYouTypeState(_ref) {
4815 var onCountryChange = _ref.onCountryChange,
4816 onCallingCodeChange = _ref.onCallingCodeChange;
4817
4818 _classCallCheck$5(this, AsYouTypeState);
4819
4820 this.onCountryChange = onCountryChange;
4821 this.onCallingCodeChange = onCallingCodeChange;
4822 }
4823
4824 _createClass$5(AsYouTypeState, [{
4825 key: "reset",
4826 value: function reset(_ref2) {
4827 var country = _ref2.country,
4828 callingCode = _ref2.callingCode;
4829 this.international = false;
4830 this.IDDPrefix = undefined;
4831 this.missingPlus = undefined;
4832 this.callingCode = undefined;
4833 this.digits = '';
4834 this.resetNationalSignificantNumber();
4835 this.initCountryAndCallingCode(country, callingCode);
4836 }
4837 }, {
4838 key: "resetNationalSignificantNumber",
4839 value: function resetNationalSignificantNumber() {
4840 this.nationalSignificantNumber = this.getNationalDigits();
4841 this.nationalSignificantNumberMatchesInput = true;
4842 this.nationalPrefix = undefined;
4843 this.carrierCode = undefined;
4844 this.complexPrefixBeforeNationalSignificantNumber = undefined;
4845 }
4846 }, {
4847 key: "update",
4848 value: function update(properties) {
4849 for (var _i = 0, _Object$keys = Object.keys(properties); _i < _Object$keys.length; _i++) {
4850 var key = _Object$keys[_i];
4851 this[key] = properties[key];
4852 }
4853 }
4854 }, {
4855 key: "initCountryAndCallingCode",
4856 value: function initCountryAndCallingCode(country, callingCode) {
4857 this.setCountry(country);
4858 this.setCallingCode(callingCode);
4859 }
4860 }, {
4861 key: "setCountry",
4862 value: function setCountry(country) {
4863 this.country = country;
4864 this.onCountryChange(country);
4865 }
4866 }, {
4867 key: "setCallingCode",
4868 value: function setCallingCode(callingCode) {
4869 this.callingCode = callingCode;
4870 this.onCallingCodeChange(callingCode, this.country);
4871 }
4872 }, {
4873 key: "startInternationalNumber",
4874 value: function startInternationalNumber(country, callingCode) {
4875 // Prepend the `+` to parsed input.
4876 this.international = true; // If a default country was set then reset it
4877 // because an explicitly international phone
4878 // number is being entered.
4879
4880 this.initCountryAndCallingCode(country, callingCode);
4881 }
4882 }, {
4883 key: "appendDigits",
4884 value: function appendDigits(nextDigits) {
4885 this.digits += nextDigits;
4886 }
4887 }, {
4888 key: "appendNationalSignificantNumberDigits",
4889 value: function appendNationalSignificantNumberDigits(nextDigits) {
4890 this.nationalSignificantNumber += nextDigits;
4891 }
4892 /**
4893 * Returns the part of `this.digits` that corresponds to the national number.
4894 * Basically, all digits that have been input by the user, except for the
4895 * international prefix and the country calling code part
4896 * (if the number is an international one).
4897 * @return {string}
4898 */
4899
4900 }, {
4901 key: "getNationalDigits",
4902 value: function getNationalDigits() {
4903 if (this.international) {
4904 return this.digits.slice((this.IDDPrefix ? this.IDDPrefix.length : 0) + (this.callingCode ? this.callingCode.length : 0));
4905 }
4906
4907 return this.digits;
4908 }
4909 }, {
4910 key: "getDigitsWithoutInternationalPrefix",
4911 value: function getDigitsWithoutInternationalPrefix() {
4912 if (this.international) {
4913 if (this.IDDPrefix) {
4914 return this.digits.slice(this.IDDPrefix.length);
4915 }
4916 }
4917
4918 return this.digits;
4919 }
4920 }]);
4921
4922 return AsYouTypeState;
4923}();
4924
4925function _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$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."); }
4926
4927function _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); }
4928
4929function _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; }
4930
4931// Should be the same as `DIGIT_PLACEHOLDER` in `libphonenumber-metadata-generator`.
4932var DIGIT_PLACEHOLDER = 'x'; // '\u2008' (punctuation space)
4933
4934var DIGIT_PLACEHOLDER_MATCHER = new RegExp(DIGIT_PLACEHOLDER); // Counts all occurences of a symbol in a string.
4935// http://stackoverflow.com/questions/202605/repeat-string-javascript
4936
4937function repeat(string, times) {
4938 if (times < 1) {
4939 return '';
4940 }
4941
4942 var result = '';
4943
4944 while (times > 1) {
4945 if (times & 1) {
4946 result += string;
4947 }
4948
4949 times >>= 1;
4950 string += string;
4951 }
4952
4953 return result + string;
4954}
4955function cutAndStripNonPairedParens(string, cutBeforeIndex) {
4956 if (string[cutBeforeIndex] === ')') {
4957 cutBeforeIndex++;
4958 }
4959
4960 return stripNonPairedParens(string.slice(0, cutBeforeIndex));
4961}
4962function stripNonPairedParens(string) {
4963 var dangling_braces = [];
4964 var i = 0;
4965
4966 while (i < string.length) {
4967 if (string[i] === '(') {
4968 dangling_braces.push(i);
4969 } else if (string[i] === ')') {
4970 dangling_braces.pop();
4971 }
4972
4973 i++;
4974 }
4975
4976 var start = 0;
4977 var cleared_string = '';
4978 dangling_braces.push(string.length);
4979
4980 for (var _i = 0, _dangling_braces = dangling_braces; _i < _dangling_braces.length; _i++) {
4981 var index = _dangling_braces[_i];
4982 cleared_string += string.slice(start, index);
4983 start = index + 1;
4984 }
4985
4986 return cleared_string;
4987}
4988function populateTemplateWithDigits(template, position, digits) {
4989 // Using `.split('')` to iterate through a string here
4990 // to avoid requiring `Symbol.iterator` polyfill.
4991 // `.split('')` is generally not safe for Unicode,
4992 // but in this particular case for `digits` it is safe.
4993 // for (const digit of digits)
4994 for (var _iterator2 = _createForOfIteratorHelperLoose$2(digits.split('')), _step2; !(_step2 = _iterator2()).done;) {
4995 var digit = _step2.value;
4996
4997 // If there is room for more digits in current `template`,
4998 // then set the next digit in the `template`,
4999 // and return the formatted digits so far.
5000 // If more digits are entered than the current format could handle.
5001 if (template.slice(position + 1).search(DIGIT_PLACEHOLDER_MATCHER) < 0) {
5002 return;
5003 }
5004
5005 position = template.search(DIGIT_PLACEHOLDER_MATCHER);
5006 template = template.replace(DIGIT_PLACEHOLDER_MATCHER, digit);
5007 }
5008
5009 return [template, position];
5010}
5011
5012function formatCompleteNumber(state, format, _ref) {
5013 var metadata = _ref.metadata,
5014 shouldTryNationalPrefixFormattingRule = _ref.shouldTryNationalPrefixFormattingRule,
5015 getSeparatorAfterNationalPrefix = _ref.getSeparatorAfterNationalPrefix;
5016 var matcher = new RegExp("^(?:".concat(format.pattern(), ")$"));
5017
5018 if (matcher.test(state.nationalSignificantNumber)) {
5019 return formatNationalNumberWithAndWithoutNationalPrefixFormattingRule(state, format, {
5020 metadata: metadata,
5021 shouldTryNationalPrefixFormattingRule: shouldTryNationalPrefixFormattingRule,
5022 getSeparatorAfterNationalPrefix: getSeparatorAfterNationalPrefix
5023 });
5024 }
5025}
5026function canFormatCompleteNumber(nationalSignificantNumber, metadata) {
5027 return checkNumberLength(nationalSignificantNumber, metadata) === 'IS_POSSIBLE';
5028}
5029
5030function formatNationalNumberWithAndWithoutNationalPrefixFormattingRule(state, format, _ref2) {
5031 var metadata = _ref2.metadata,
5032 shouldTryNationalPrefixFormattingRule = _ref2.shouldTryNationalPrefixFormattingRule,
5033 getSeparatorAfterNationalPrefix = _ref2.getSeparatorAfterNationalPrefix;
5034 // `format` has already been checked for `nationalPrefix` requirement.
5035 state.nationalSignificantNumber;
5036 state.international;
5037 state.nationalPrefix;
5038 state.carrierCode; // Format the number with using `national_prefix_formatting_rule`.
5039 // If the resulting formatted number is a valid formatted number, then return it.
5040 //
5041 // Google's AsYouType formatter is different in a way that it doesn't try
5042 // to format using the "national prefix formatting rule", and instead it
5043 // simply prepends a national prefix followed by a " " character.
5044 // This code does that too, but as a fallback.
5045 // The reason is that "national prefix formatting rule" may use parentheses,
5046 // which wouldn't be included has it used the simpler Google's way.
5047 //
5048
5049 if (shouldTryNationalPrefixFormattingRule(format)) {
5050 var formattedNumber = formatNationalNumber(state, format, {
5051 useNationalPrefixFormattingRule: true,
5052 getSeparatorAfterNationalPrefix: getSeparatorAfterNationalPrefix,
5053 metadata: metadata
5054 });
5055
5056 if (formattedNumber) {
5057 return formattedNumber;
5058 }
5059 } // Format the number without using `national_prefix_formatting_rule`.
5060
5061
5062 return formatNationalNumber(state, format, {
5063 useNationalPrefixFormattingRule: false,
5064 getSeparatorAfterNationalPrefix: getSeparatorAfterNationalPrefix,
5065 metadata: metadata
5066 });
5067}
5068
5069function formatNationalNumber(state, format, _ref3) {
5070 var metadata = _ref3.metadata,
5071 useNationalPrefixFormattingRule = _ref3.useNationalPrefixFormattingRule,
5072 getSeparatorAfterNationalPrefix = _ref3.getSeparatorAfterNationalPrefix;
5073 var formattedNationalNumber = formatNationalNumberUsingFormat(state.nationalSignificantNumber, format, {
5074 carrierCode: state.carrierCode,
5075 useInternationalFormat: state.international,
5076 withNationalPrefix: useNationalPrefixFormattingRule,
5077 metadata: metadata
5078 });
5079
5080 if (!useNationalPrefixFormattingRule) {
5081 if (state.nationalPrefix) {
5082 // If a national prefix was extracted, then just prepend it,
5083 // followed by a " " character.
5084 formattedNationalNumber = state.nationalPrefix + getSeparatorAfterNationalPrefix(format) + formattedNationalNumber;
5085 } else if (state.complexPrefixBeforeNationalSignificantNumber) {
5086 formattedNationalNumber = state.complexPrefixBeforeNationalSignificantNumber + ' ' + formattedNationalNumber;
5087 }
5088 }
5089
5090 if (isValidFormattedNationalNumber(formattedNationalNumber, state)) {
5091 return formattedNationalNumber;
5092 }
5093} // Check that the formatted phone number contains exactly
5094// the same digits that have been input by the user.
5095// For example, when "0111523456789" is input for `AR` country,
5096// the extracted `this.nationalSignificantNumber` is "91123456789",
5097// which means that the national part of `this.digits` isn't simply equal to
5098// `this.nationalPrefix` + `this.nationalSignificantNumber`.
5099//
5100// Also, a `format` can add extra digits to the `this.nationalSignificantNumber`
5101// being formatted via `metadata[country].national_prefix_transform_rule`.
5102// For example, for `VI` country, it prepends `340` to the national number,
5103// and if this check hasn't been implemented, then there would be a bug
5104// when `340` "area coude" is "duplicated" during input for `VI` country:
5105// https://github.com/catamphetamine/libphonenumber-js/issues/318
5106//
5107// So, all these "gotchas" are filtered out.
5108//
5109// In the original Google's code, the comments say:
5110// "Check that we didn't remove nor add any extra digits when we matched
5111// this formatting pattern. This usually happens after we entered the last
5112// digit during AYTF. Eg: In case of MX, we swallow mobile token (1) when
5113// formatted but AYTF should retain all the number entered and not change
5114// in order to match a format (of same leading digits and length) display
5115// in that way."
5116// "If it's the same (i.e entered number and format is same), then it's
5117// safe to return this in formatted number as nothing is lost / added."
5118// Otherwise, don't use this format.
5119// https://github.com/google/libphonenumber/commit/3e7c1f04f5e7200f87fb131e6f85c6e99d60f510#diff-9149457fa9f5d608a11bb975c6ef4bc5
5120// https://github.com/google/libphonenumber/commit/3ac88c7106e7dcb553bcc794b15f19185928a1c6#diff-2dcb77e833422ee304da348b905cde0b
5121//
5122
5123
5124function isValidFormattedNationalNumber(formattedNationalNumber, state) {
5125 return parseDigits(formattedNationalNumber) === state.getNationalDigits();
5126}
5127
5128function _classCallCheck$4(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
5129
5130function _defineProperties$4(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); } }
5131
5132function _createClass$4(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$4(Constructor.prototype, protoProps); if (staticProps) _defineProperties$4(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
5133
5134var PatternParser = /*#__PURE__*/function () {
5135 function PatternParser() {
5136 _classCallCheck$4(this, PatternParser);
5137 }
5138
5139 _createClass$4(PatternParser, [{
5140 key: "parse",
5141 value: function parse(pattern) {
5142 this.context = [{
5143 or: true,
5144 instructions: []
5145 }];
5146 this.parsePattern(pattern);
5147
5148 if (this.context.length !== 1) {
5149 throw new Error('Non-finalized contexts left when pattern parse ended');
5150 }
5151
5152 var _this$context$ = this.context[0],
5153 branches = _this$context$.branches,
5154 instructions = _this$context$.instructions;
5155
5156 if (branches) {
5157 return {
5158 op: '|',
5159 args: branches.concat([expandSingleElementArray(instructions)])
5160 };
5161 }
5162 /* istanbul ignore if */
5163
5164
5165 if (instructions.length === 0) {
5166 throw new Error('Pattern is required');
5167 }
5168
5169 if (instructions.length === 1) {
5170 return instructions[0];
5171 }
5172
5173 return instructions;
5174 }
5175 }, {
5176 key: "startContext",
5177 value: function startContext(context) {
5178 this.context.push(context);
5179 }
5180 }, {
5181 key: "endContext",
5182 value: function endContext() {
5183 this.context.pop();
5184 }
5185 }, {
5186 key: "getContext",
5187 value: function getContext() {
5188 return this.context[this.context.length - 1];
5189 }
5190 }, {
5191 key: "parsePattern",
5192 value: function parsePattern(pattern) {
5193 if (!pattern) {
5194 throw new Error('Pattern is required');
5195 }
5196
5197 var match = pattern.match(OPERATOR);
5198
5199 if (!match) {
5200 if (ILLEGAL_CHARACTER_REGEXP.test(pattern)) {
5201 throw new Error("Illegal characters found in a pattern: ".concat(pattern));
5202 }
5203
5204 this.getContext().instructions = this.getContext().instructions.concat(pattern.split(''));
5205 return;
5206 }
5207
5208 var operator = match[1];
5209 var before = pattern.slice(0, match.index);
5210 var rightPart = pattern.slice(match.index + operator.length);
5211
5212 switch (operator) {
5213 case '(?:':
5214 if (before) {
5215 this.parsePattern(before);
5216 }
5217
5218 this.startContext({
5219 or: true,
5220 instructions: [],
5221 branches: []
5222 });
5223 break;
5224
5225 case ')':
5226 if (!this.getContext().or) {
5227 throw new Error('")" operator must be preceded by "(?:" operator');
5228 }
5229
5230 if (before) {
5231 this.parsePattern(before);
5232 }
5233
5234 if (this.getContext().instructions.length === 0) {
5235 throw new Error('No instructions found after "|" operator in an "or" group');
5236 }
5237
5238 var _this$getContext = this.getContext(),
5239 branches = _this$getContext.branches;
5240
5241 branches.push(expandSingleElementArray(this.getContext().instructions));
5242 this.endContext();
5243 this.getContext().instructions.push({
5244 op: '|',
5245 args: branches
5246 });
5247 break;
5248
5249 case '|':
5250 if (!this.getContext().or) {
5251 throw new Error('"|" operator can only be used inside "or" groups');
5252 }
5253
5254 if (before) {
5255 this.parsePattern(before);
5256 } // The top-level is an implicit "or" group, if required.
5257
5258
5259 if (!this.getContext().branches) {
5260 // `branches` are not defined only for the root implicit "or" operator.
5261
5262 /* istanbul ignore else */
5263 if (this.context.length === 1) {
5264 this.getContext().branches = [];
5265 } else {
5266 throw new Error('"branches" not found in an "or" group context');
5267 }
5268 }
5269
5270 this.getContext().branches.push(expandSingleElementArray(this.getContext().instructions));
5271 this.getContext().instructions = [];
5272 break;
5273
5274 case '[':
5275 if (before) {
5276 this.parsePattern(before);
5277 }
5278
5279 this.startContext({
5280 oneOfSet: true
5281 });
5282 break;
5283
5284 case ']':
5285 if (!this.getContext().oneOfSet) {
5286 throw new Error('"]" operator must be preceded by "[" operator');
5287 }
5288
5289 this.endContext();
5290 this.getContext().instructions.push({
5291 op: '[]',
5292 args: parseOneOfSet(before)
5293 });
5294 break;
5295
5296 /* istanbul ignore next */
5297
5298 default:
5299 throw new Error("Unknown operator: ".concat(operator));
5300 }
5301
5302 if (rightPart) {
5303 this.parsePattern(rightPart);
5304 }
5305 }
5306 }]);
5307
5308 return PatternParser;
5309}();
5310
5311function parseOneOfSet(pattern) {
5312 var values = [];
5313 var i = 0;
5314
5315 while (i < pattern.length) {
5316 if (pattern[i] === '-') {
5317 if (i === 0 || i === pattern.length - 1) {
5318 throw new Error("Couldn't parse a one-of set pattern: ".concat(pattern));
5319 }
5320
5321 var prevValue = pattern[i - 1].charCodeAt(0) + 1;
5322 var nextValue = pattern[i + 1].charCodeAt(0) - 1;
5323 var value = prevValue;
5324
5325 while (value <= nextValue) {
5326 values.push(String.fromCharCode(value));
5327 value++;
5328 }
5329 } else {
5330 values.push(pattern[i]);
5331 }
5332
5333 i++;
5334 }
5335
5336 return values;
5337}
5338
5339var ILLEGAL_CHARACTER_REGEXP = /[\(\)\[\]\?\:\|]/;
5340var OPERATOR = new RegExp( // any of:
5341'(' + // or operator
5342'\\|' + // or
5343'|' + // or group start
5344'\\(\\?\\:' + // or
5345'|' + // or group end
5346'\\)' + // or
5347'|' + // one-of set start
5348'\\[' + // or
5349'|' + // one-of set end
5350'\\]' + ')');
5351
5352function expandSingleElementArray(array) {
5353 if (array.length === 1) {
5354 return array[0];
5355 }
5356
5357 return array;
5358}
5359
5360function _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$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."); }
5361
5362function _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); }
5363
5364function _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; }
5365
5366function _classCallCheck$3(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
5367
5368function _defineProperties$3(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); } }
5369
5370function _createClass$3(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$3(Constructor.prototype, protoProps); if (staticProps) _defineProperties$3(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
5371
5372var PatternMatcher = /*#__PURE__*/function () {
5373 function PatternMatcher(pattern) {
5374 _classCallCheck$3(this, PatternMatcher);
5375
5376 this.matchTree = new PatternParser().parse(pattern);
5377 }
5378
5379 _createClass$3(PatternMatcher, [{
5380 key: "match",
5381 value: function match(string) {
5382 var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
5383 allowOverflow = _ref.allowOverflow;
5384
5385 if (!string) {
5386 throw new Error('String is required');
5387 }
5388
5389 var result = _match(string.split(''), this.matchTree, true);
5390
5391 if (result && result.match) {
5392 delete result.matchedChars;
5393 }
5394
5395 if (result && result.overflow) {
5396 if (!allowOverflow) {
5397 return;
5398 }
5399 }
5400
5401 return result;
5402 }
5403 }]);
5404
5405 return PatternMatcher;
5406}();
5407
5408function _match(characters, tree, last) {
5409 // If `tree` is a string, then `tree` is a single character.
5410 // That's because when a pattern is parsed, multi-character-string parts
5411 // of a pattern are compiled into arrays of single characters.
5412 // I still wrote this piece of code for a "general" hypothetical case
5413 // when `tree` could be a string of several characters, even though
5414 // such case is not possible with the current implementation.
5415 if (typeof tree === 'string') {
5416 var characterString = characters.join('');
5417
5418 if (tree.indexOf(characterString) === 0) {
5419 // `tree` is always a single character.
5420 // If `tree.indexOf(characterString) === 0`
5421 // then `characters.length === tree.length`.
5422
5423 /* istanbul ignore else */
5424 if (characters.length === tree.length) {
5425 return {
5426 match: true,
5427 matchedChars: characters
5428 };
5429 } // `tree` is always a single character.
5430 // If `tree.indexOf(characterString) === 0`
5431 // then `characters.length === tree.length`.
5432
5433 /* istanbul ignore next */
5434
5435
5436 return {
5437 partialMatch: true // matchedChars: characters
5438
5439 };
5440 }
5441
5442 if (characterString.indexOf(tree) === 0) {
5443 if (last) {
5444 // The `else` path is not possible because `tree` is always a single character.
5445 // The `else` case for `characters.length > tree.length` would be
5446 // `characters.length <= tree.length` which means `characters.length <= 1`.
5447 // `characters` array can't be empty, so that means `characters === [tree]`,
5448 // which would also mean `tree.indexOf(characterString) === 0` and that'd mean
5449 // that the `if (tree.indexOf(characterString) === 0)` condition before this
5450 // `if` condition would be entered, and returned from there, not reaching this code.
5451
5452 /* istanbul ignore else */
5453 if (characters.length > tree.length) {
5454 return {
5455 overflow: true
5456 };
5457 }
5458 }
5459
5460 return {
5461 match: true,
5462 matchedChars: characters.slice(0, tree.length)
5463 };
5464 }
5465
5466 return;
5467 }
5468
5469 if (Array.isArray(tree)) {
5470 var restCharacters = characters.slice();
5471 var i = 0;
5472
5473 while (i < tree.length) {
5474 var subtree = tree[i];
5475
5476 var result = _match(restCharacters, subtree, last && i === tree.length - 1);
5477
5478 if (!result) {
5479 return;
5480 } else if (result.overflow) {
5481 return result;
5482 } else if (result.match) {
5483 // Continue with the next subtree with the rest of the characters.
5484 restCharacters = restCharacters.slice(result.matchedChars.length);
5485
5486 if (restCharacters.length === 0) {
5487 if (i === tree.length - 1) {
5488 return {
5489 match: true,
5490 matchedChars: characters
5491 };
5492 } else {
5493 return {
5494 partialMatch: true // matchedChars: characters
5495
5496 };
5497 }
5498 }
5499 } else {
5500 /* istanbul ignore else */
5501 if (result.partialMatch) {
5502 return {
5503 partialMatch: true // matchedChars: characters
5504
5505 };
5506 } else {
5507 throw new Error("Unsupported match result:\n".concat(JSON.stringify(result, null, 2)));
5508 }
5509 }
5510
5511 i++;
5512 } // If `last` then overflow has already been checked
5513 // by the last element of the `tree` array.
5514
5515 /* istanbul ignore if */
5516
5517
5518 if (last) {
5519 return {
5520 overflow: true
5521 };
5522 }
5523
5524 return {
5525 match: true,
5526 matchedChars: characters.slice(0, characters.length - restCharacters.length)
5527 };
5528 }
5529
5530 switch (tree.op) {
5531 case '|':
5532 var partialMatch;
5533
5534 for (var _iterator = _createForOfIteratorHelperLoose$1(tree.args), _step; !(_step = _iterator()).done;) {
5535 var branch = _step.value;
5536
5537 var _result = _match(characters, branch, last);
5538
5539 if (_result) {
5540 if (_result.overflow) {
5541 return _result;
5542 } else if (_result.match) {
5543 return {
5544 match: true,
5545 matchedChars: _result.matchedChars
5546 };
5547 } else {
5548 /* istanbul ignore else */
5549 if (_result.partialMatch) {
5550 partialMatch = true;
5551 } else {
5552 throw new Error("Unsupported match result:\n".concat(JSON.stringify(_result, null, 2)));
5553 }
5554 }
5555 }
5556 }
5557
5558 if (partialMatch) {
5559 return {
5560 partialMatch: true // matchedChars: ...
5561
5562 };
5563 } // Not even a partial match.
5564
5565
5566 return;
5567
5568 case '[]':
5569 for (var _iterator2 = _createForOfIteratorHelperLoose$1(tree.args), _step2; !(_step2 = _iterator2()).done;) {
5570 var _char = _step2.value;
5571
5572 if (characters[0] === _char) {
5573 if (characters.length === 1) {
5574 return {
5575 match: true,
5576 matchedChars: characters
5577 };
5578 }
5579
5580 if (last) {
5581 return {
5582 overflow: true
5583 };
5584 }
5585
5586 return {
5587 match: true,
5588 matchedChars: [_char]
5589 };
5590 }
5591 } // No character matches.
5592
5593
5594 return;
5595
5596 /* istanbul ignore next */
5597
5598 default:
5599 throw new Error("Unsupported instruction tree: ".concat(tree));
5600 }
5601}
5602
5603function _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$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."); }
5604
5605function _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); }
5606
5607function _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; }
5608
5609function _classCallCheck$2(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
5610
5611function _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); } }
5612
5613function _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; }
5614// Could be any digit, I guess.
5615
5616var DUMMY_DIGIT = '9'; // I don't know why is it exactly `15`
5617
5618var LONGEST_NATIONAL_PHONE_NUMBER_LENGTH = 15; // Create a phone number consisting only of the digit 9 that matches the
5619// `number_pattern` by applying the pattern to the "longest phone number" string.
5620
5621var LONGEST_DUMMY_PHONE_NUMBER = repeat(DUMMY_DIGIT, LONGEST_NATIONAL_PHONE_NUMBER_LENGTH); // A set of characters that, if found in a national prefix formatting rules, are an indicator to
5622// us that we should separate the national prefix from the number when formatting.
5623
5624var NATIONAL_PREFIX_SEPARATORS_PATTERN = /[- ]/; // Deprecated: Google has removed some formatting pattern related code from their repo.
5625// An example of a character class is "[1-4]".
5626
5627var CREATE_CHARACTER_CLASS_PATTERN = function () {
5628 return /\[([^\[\]])*\]/g;
5629}; // Any digit in a regular expression that actually denotes a digit. For
5630// example, in the regular expression "80[0-2]\d{6,10}", the first 2 digits
5631// (8 and 0) are standalone digits, but the rest are not.
5632// Two look-aheads are needed because the number following \\d could be a
5633// two-digit number, since the phone number can be as long as 15 digits.
5634
5635
5636var CREATE_STANDALONE_DIGIT_PATTERN = function () {
5637 return /\d(?=[^,}][^,}])/g;
5638}; // A regular expression that is used to determine if a `format` is
5639// suitable to be used in the "as you type formatter".
5640// A `format` is suitable when the resulting formatted number has
5641// the same digits as the user has entered.
5642//
5643// In the simplest case, that would mean that the format
5644// doesn't add any additional digits when formatting a number.
5645// Google says that it also shouldn't add "star" (`*`) characters,
5646// like it does in some Israeli formats.
5647// Such basic format would only contain "valid punctuation"
5648// and "captured group" identifiers ($1, $2, etc).
5649//
5650// An example of a format that adds additional digits:
5651//
5652// Country: `AR` (Argentina).
5653// Format:
5654// {
5655// "pattern": "(\\d)(\\d{2})(\\d{4})(\\d{4})",
5656// "leading_digits_patterns": ["91"],
5657// "national_prefix_formatting_rule": "0$1",
5658// "format": "$2 15-$3-$4",
5659// "international_format": "$1 $2 $3-$4"
5660// }
5661//
5662// In the format above, the `format` adds `15` to the digits when formatting a number.
5663// A sidenote: this format actually is suitable because `national_prefix_for_parsing`
5664// has previously removed `15` from a national number, so re-adding `15` in `format`
5665// doesn't actually result in any extra digits added to user's input.
5666// But verifying that would be a complex procedure, so the code chooses a simpler path:
5667// it simply filters out all `format`s that contain anything but "captured group" ids.
5668//
5669// This regular expression is called `ELIGIBLE_FORMAT_PATTERN` in Google's
5670// `libphonenumber` code.
5671//
5672
5673
5674var NON_ALTERING_FORMAT_REG_EXP = new RegExp('[' + VALID_PUNCTUATION + ']*' + // Google developers say:
5675// "We require that the first matching group is present in the
5676// output pattern to ensure no data is lost while formatting."
5677'\\$1' + '[' + VALID_PUNCTUATION + ']*' + '(\\$\\d[' + VALID_PUNCTUATION + ']*)*' + '$'); // This is the minimum length of the leading digits of a phone number
5678// to guarantee the first "leading digits pattern" for a phone number format
5679// to be preemptive.
5680
5681var MIN_LEADING_DIGITS_LENGTH = 3;
5682
5683var AsYouTypeFormatter = /*#__PURE__*/function () {
5684 function AsYouTypeFormatter(_ref) {
5685 _ref.state;
5686 var metadata = _ref.metadata;
5687
5688 _classCallCheck$2(this, AsYouTypeFormatter);
5689
5690 this.metadata = metadata;
5691 this.resetFormat();
5692 }
5693
5694 _createClass$2(AsYouTypeFormatter, [{
5695 key: "resetFormat",
5696 value: function resetFormat() {
5697 this.chosenFormat = undefined;
5698 this.template = undefined;
5699 this.nationalNumberTemplate = undefined;
5700 this.populatedNationalNumberTemplate = undefined;
5701 this.populatedNationalNumberTemplatePosition = -1;
5702 }
5703 }, {
5704 key: "reset",
5705 value: function reset(numberingPlan, state) {
5706 this.resetFormat();
5707
5708 if (numberingPlan) {
5709 this.isNANP = numberingPlan.callingCode() === '1';
5710 this.matchingFormats = numberingPlan.formats();
5711
5712 if (state.nationalSignificantNumber) {
5713 this.narrowDownMatchingFormats(state);
5714 }
5715 } else {
5716 this.isNANP = undefined;
5717 this.matchingFormats = [];
5718 }
5719 }
5720 /**
5721 * Formats an updated phone number.
5722 * @param {string} nextDigits — Additional phone number digits.
5723 * @param {object} state — `AsYouType` state.
5724 * @return {[string]} Returns undefined if the updated phone number can't be formatted using any of the available formats.
5725 */
5726
5727 }, {
5728 key: "format",
5729 value: function format(nextDigits, state) {
5730 var _this = this;
5731
5732 // See if the phone number digits can be formatted as a complete phone number.
5733 // If not, use the results from `formatNationalNumberWithNextDigits()`,
5734 // which formats based on the chosen formatting pattern.
5735 //
5736 // Attempting to format complete phone number first is how it's done
5737 // in Google's `libphonenumber`, so this library just follows it.
5738 // Google's `libphonenumber` code doesn't explain in detail why does it
5739 // attempt to format digits as a complete phone number
5740 // instead of just going with a previoulsy (or newly) chosen `format`:
5741 //
5742 // "Checks to see if there is an exact pattern match for these digits.
5743 // If so, we should use this instead of any other formatting template
5744 // whose leadingDigitsPattern also matches the input."
5745 //
5746 if (canFormatCompleteNumber(state.nationalSignificantNumber, this.metadata)) {
5747 for (var _iterator = _createForOfIteratorHelperLoose(this.matchingFormats), _step; !(_step = _iterator()).done;) {
5748 var format = _step.value;
5749 var formattedCompleteNumber = formatCompleteNumber(state, format, {
5750 metadata: this.metadata,
5751 shouldTryNationalPrefixFormattingRule: function shouldTryNationalPrefixFormattingRule(format) {
5752 return _this.shouldTryNationalPrefixFormattingRule(format, {
5753 international: state.international,
5754 nationalPrefix: state.nationalPrefix
5755 });
5756 },
5757 getSeparatorAfterNationalPrefix: function getSeparatorAfterNationalPrefix(format) {
5758 return _this.getSeparatorAfterNationalPrefix(format);
5759 }
5760 });
5761
5762 if (formattedCompleteNumber) {
5763 this.resetFormat();
5764 this.chosenFormat = format;
5765 this.setNationalNumberTemplate(formattedCompleteNumber.replace(/\d/g, DIGIT_PLACEHOLDER), state);
5766 this.populatedNationalNumberTemplate = formattedCompleteNumber; // With a new formatting template, the matched position
5767 // using the old template needs to be reset.
5768
5769 this.populatedNationalNumberTemplatePosition = this.template.lastIndexOf(DIGIT_PLACEHOLDER);
5770 return formattedCompleteNumber;
5771 }
5772 }
5773 } // Format the digits as a partial (incomplete) phone number
5774 // using the previously chosen formatting pattern (or a newly chosen one).
5775
5776
5777 return this.formatNationalNumberWithNextDigits(nextDigits, state);
5778 } // Formats the next phone number digits.
5779
5780 }, {
5781 key: "formatNationalNumberWithNextDigits",
5782 value: function formatNationalNumberWithNextDigits(nextDigits, state) {
5783 var previouslyChosenFormat = this.chosenFormat; // Choose a format from the list of matching ones.
5784
5785 var newlyChosenFormat = this.chooseFormat(state);
5786
5787 if (newlyChosenFormat) {
5788 if (newlyChosenFormat === previouslyChosenFormat) {
5789 // If it can format the next (current) digits
5790 // using the previously chosen phone number format
5791 // then return the updated formatted number.
5792 return this.formatNextNationalNumberDigits(nextDigits);
5793 } else {
5794 // If a more appropriate phone number format
5795 // has been chosen for these "leading digits",
5796 // then re-format the national phone number part
5797 // using the newly selected format.
5798 return this.formatNextNationalNumberDigits(state.getNationalDigits());
5799 }
5800 }
5801 }
5802 }, {
5803 key: "narrowDownMatchingFormats",
5804 value: function narrowDownMatchingFormats(_ref2) {
5805 var _this2 = this;
5806
5807 var nationalSignificantNumber = _ref2.nationalSignificantNumber,
5808 nationalPrefix = _ref2.nationalPrefix,
5809 international = _ref2.international;
5810 var leadingDigits = nationalSignificantNumber; // "leading digits" pattern list starts with a
5811 // "leading digits" pattern fitting a maximum of 3 leading digits.
5812 // So, after a user inputs 3 digits of a national (significant) phone number
5813 // this national (significant) number can already be formatted.
5814 // The next "leading digits" pattern is for 4 leading digits max,
5815 // and the "leading digits" pattern after it is for 5 leading digits max, etc.
5816 // This implementation is different from Google's
5817 // in that it searches for a fitting format
5818 // even if the user has entered less than
5819 // `MIN_LEADING_DIGITS_LENGTH` digits of a national number.
5820 // Because some leading digit patterns already match for a single first digit.
5821
5822 var leadingDigitsPatternIndex = leadingDigits.length - MIN_LEADING_DIGITS_LENGTH;
5823
5824 if (leadingDigitsPatternIndex < 0) {
5825 leadingDigitsPatternIndex = 0;
5826 }
5827
5828 this.matchingFormats = this.matchingFormats.filter(function (format) {
5829 return _this2.formatSuits(format, international, nationalPrefix) && _this2.formatMatches(format, leadingDigits, leadingDigitsPatternIndex);
5830 }); // If there was a phone number format chosen
5831 // and it no longer holds given the new leading digits then reset it.
5832 // The test for this `if` condition is marked as:
5833 // "Reset a chosen format when it no longer holds given the new leading digits".
5834 // To construct a valid test case for this one can find a country
5835 // in `PhoneNumberMetadata.xml` yielding one format for 3 `<leadingDigits>`
5836 // and yielding another format for 4 `<leadingDigits>` (Australia in this case).
5837
5838 if (this.chosenFormat && this.matchingFormats.indexOf(this.chosenFormat) === -1) {
5839 this.resetFormat();
5840 }
5841 }
5842 }, {
5843 key: "formatSuits",
5844 value: function formatSuits(format, international, nationalPrefix) {
5845 // When a prefix before a national (significant) number is
5846 // simply a national prefix, then it's parsed as `this.nationalPrefix`.
5847 // In more complex cases, a prefix before national (significant) number
5848 // could include a national prefix as well as some "capturing groups",
5849 // and in that case there's no info whether a national prefix has been parsed.
5850 // If national prefix is not used when formatting a phone number
5851 // using this format, but a national prefix has been entered by the user,
5852 // and was extracted, then discard such phone number format.
5853 // In Google's "AsYouType" formatter code, the equivalent would be this part:
5854 // https://github.com/google/libphonenumber/blob/0a45cfd96e71cad8edb0e162a70fcc8bd9728933/java/libphonenumber/src/com/google/i18n/phonenumbers/AsYouTypeFormatter.java#L175-L184
5855 if (nationalPrefix && !format.usesNationalPrefix() && // !format.domesticCarrierCodeFormattingRule() &&
5856 !format.nationalPrefixIsOptionalWhenFormattingInNationalFormat()) {
5857 return false;
5858 } // If national prefix is mandatory for this phone number format
5859 // and there're no guarantees that a national prefix is present in user input
5860 // then discard this phone number format as not suitable.
5861 // In Google's "AsYouType" formatter code, the equivalent would be this part:
5862 // https://github.com/google/libphonenumber/blob/0a45cfd96e71cad8edb0e162a70fcc8bd9728933/java/libphonenumber/src/com/google/i18n/phonenumbers/AsYouTypeFormatter.java#L185-L193
5863
5864
5865 if (!international && !nationalPrefix && format.nationalPrefixIsMandatoryWhenFormattingInNationalFormat()) {
5866 return false;
5867 }
5868
5869 return true;
5870 }
5871 }, {
5872 key: "formatMatches",
5873 value: function formatMatches(format, leadingDigits, leadingDigitsPatternIndex) {
5874 var leadingDigitsPatternsCount = format.leadingDigitsPatterns().length; // If this format is not restricted to a certain
5875 // leading digits pattern then it fits.
5876 // The test case could be found by searching for "leadingDigitsPatternsCount === 0".
5877
5878 if (leadingDigitsPatternsCount === 0) {
5879 return true;
5880 } // Start narrowing down the list of possible formats based on the leading digits.
5881 // (only previously matched formats take part in the narrowing down process)
5882 // `leading_digits_patterns` start with 3 digits min
5883 // and then go up from there one digit at a time.
5884
5885
5886 leadingDigitsPatternIndex = Math.min(leadingDigitsPatternIndex, leadingDigitsPatternsCount - 1);
5887 var leadingDigitsPattern = format.leadingDigitsPatterns()[leadingDigitsPatternIndex]; // Google imposes a requirement on the leading digits
5888 // to be minimum 3 digits long in order to be eligible
5889 // for checking those with a leading digits pattern.
5890 //
5891 // Since `leading_digits_patterns` start with 3 digits min,
5892 // Google's original `libphonenumber` library only starts
5893 // excluding any non-matching formats only when the
5894 // national number entered so far is at least 3 digits long,
5895 // otherwise format matching would give false negatives.
5896 //
5897 // For example, when the digits entered so far are `2`
5898 // and the leading digits pattern is `21` –
5899 // it's quite obvious in this case that the format could be the one
5900 // but due to the absence of further digits it would give false negative.
5901 //
5902 // Also, `leading_digits_patterns` doesn't always correspond to a single
5903 // digits count. For example, `60|8` pattern would already match `8`
5904 // but the `60` part would require having at least two leading digits,
5905 // so the whole pattern would require inputting two digits first in order to
5906 // decide on whether it matches the input, even when the input is "80".
5907 //
5908 // This library — `libphonenumber-js` — allows filtering by `leading_digits_patterns`
5909 // even when there's only 1 or 2 digits of the national (significant) number.
5910 // To do that, it uses a non-strict pattern matcher written specifically for that.
5911 //
5912
5913 if (leadingDigits.length < MIN_LEADING_DIGITS_LENGTH) {
5914 // Before leading digits < 3 matching was implemented:
5915 // return true
5916 //
5917 // After leading digits < 3 matching was implemented:
5918 try {
5919 return new PatternMatcher(leadingDigitsPattern).match(leadingDigits, {
5920 allowOverflow: true
5921 }) !== undefined;
5922 } catch (error)
5923 /* istanbul ignore next */
5924 {
5925 // There's a slight possibility that there could be some undiscovered bug
5926 // in the pattern matcher code. Since the "leading digits < 3 matching"
5927 // feature is not "essential" for operation, it can fall back to the old way
5928 // in case of any issues rather than halting the application's execution.
5929 console.error(error);
5930 return true;
5931 }
5932 } // If at least `MIN_LEADING_DIGITS_LENGTH` digits of a national number are
5933 // available then use the usual regular expression matching.
5934 //
5935 // The whole pattern is wrapped in round brackets (`()`) because
5936 // the pattern can use "or" operator (`|`) at the top level of the pattern.
5937 //
5938
5939
5940 return new RegExp("^(".concat(leadingDigitsPattern, ")")).test(leadingDigits);
5941 }
5942 }, {
5943 key: "getFormatFormat",
5944 value: function getFormatFormat(format, international) {
5945 return international ? format.internationalFormat() : format.format();
5946 }
5947 }, {
5948 key: "chooseFormat",
5949 value: function chooseFormat(state) {
5950 var _this3 = this;
5951
5952 var _loop = function _loop() {
5953 var format = _step2.value;
5954
5955 // If this format is currently being used
5956 // and is still suitable, then stick to it.
5957 if (_this3.chosenFormat === format) {
5958 return "break";
5959 } // Sometimes, a formatting rule inserts additional digits in a phone number,
5960 // and "as you type" formatter can't do that: it should only use the digits
5961 // that the user has input.
5962 //
5963 // For example, in Argentina, there's a format for mobile phone numbers:
5964 //
5965 // {
5966 // "pattern": "(\\d)(\\d{2})(\\d{4})(\\d{4})",
5967 // "leading_digits_patterns": ["91"],
5968 // "national_prefix_formatting_rule": "0$1",
5969 // "format": "$2 15-$3-$4",
5970 // "international_format": "$1 $2 $3-$4"
5971 // }
5972 //
5973 // In that format, `international_format` is used instead of `format`
5974 // because `format` inserts `15` in the formatted number,
5975 // and `AsYouType` formatter should only use the digits
5976 // the user has actually input, without adding any extra digits.
5977 // In this case, it wouldn't make a difference, because the `15`
5978 // is first stripped when applying `national_prefix_for_parsing`
5979 // and then re-added when using `format`, so in reality it doesn't
5980 // add any new digits to the number, but to detect that, the code
5981 // would have to be more complex: it would have to try formatting
5982 // the digits using the format and then see if any digits have
5983 // actually been added or removed, and then, every time a new digit
5984 // is input, it should re-check whether the chosen format doesn't
5985 // alter the digits.
5986 //
5987 // Google's code doesn't go that far, and so does this library:
5988 // it simply requires that a `format` doesn't add any additonal
5989 // digits to user's input.
5990 //
5991 // Also, people in general should move from inputting phone numbers
5992 // in national format (possibly with national prefixes)
5993 // and use international phone number format instead:
5994 // it's a logical thing in the modern age of mobile phones,
5995 // globalization and the internet.
5996 //
5997
5998 /* istanbul ignore if */
5999
6000
6001 if (!NON_ALTERING_FORMAT_REG_EXP.test(_this3.getFormatFormat(format, state.international))) {
6002 return "continue";
6003 }
6004
6005 if (!_this3.createTemplateForFormat(format, state)) {
6006 // Remove the format if it can't generate a template.
6007 _this3.matchingFormats = _this3.matchingFormats.filter(function (_) {
6008 return _ !== format;
6009 });
6010 return "continue";
6011 }
6012
6013 _this3.chosenFormat = format;
6014 return "break";
6015 };
6016
6017 // When there are multiple available formats, the formatter uses the first
6018 // format where a formatting template could be created.
6019 //
6020 // For some weird reason, `istanbul` says "else path not taken"
6021 // for the `for of` line below. Supposedly that means that
6022 // the loop doesn't ever go over the last element in the list.
6023 // That's true because there always is `this.chosenFormat`
6024 // when `this.matchingFormats` is non-empty.
6025 // And, for some weird reason, it doesn't think that the case
6026 // with empty `this.matchingFormats` qualifies for a valid "else" path.
6027 // So simply muting this `istanbul` warning.
6028 // It doesn't skip the contents of the `for of` loop,
6029 // it just skips the `for of` line.
6030 //
6031
6032 /* istanbul ignore next */
6033 for (var _iterator2 = _createForOfIteratorHelperLoose(this.matchingFormats.slice()), _step2; !(_step2 = _iterator2()).done;) {
6034 var _ret = _loop();
6035
6036 if (_ret === "break") break;
6037 if (_ret === "continue") continue;
6038 }
6039
6040 if (!this.chosenFormat) {
6041 // No format matches the national (significant) phone number.
6042 this.resetFormat();
6043 }
6044
6045 return this.chosenFormat;
6046 }
6047 }, {
6048 key: "createTemplateForFormat",
6049 value: function createTemplateForFormat(format, state) {
6050 // The formatter doesn't format numbers when numberPattern contains '|', e.g.
6051 // (20|3)\d{4}. In those cases we quickly return.
6052 // (Though there's no such format in current metadata)
6053
6054 /* istanbul ignore if */
6055 if (format.pattern().indexOf('|') >= 0) {
6056 return;
6057 } // Get formatting template for this phone number format
6058
6059
6060 var template = this.getTemplateForFormat(format, state); // If the national number entered is too long
6061 // for any phone number format, then abort.
6062
6063 if (template) {
6064 this.setNationalNumberTemplate(template, state);
6065 return true;
6066 }
6067 }
6068 }, {
6069 key: "getSeparatorAfterNationalPrefix",
6070 value: function getSeparatorAfterNationalPrefix(format) {
6071 // `US` metadata doesn't have a `national_prefix_formatting_rule`,
6072 // so the `if` condition below doesn't apply to `US`,
6073 // but in reality there shoudl be a separator
6074 // between a national prefix and a national (significant) number.
6075 // So `US` national prefix separator is a "special" "hardcoded" case.
6076 if (this.isNANP) {
6077 return ' ';
6078 } // If a `format` has a `national_prefix_formatting_rule`
6079 // and that rule has a separator after a national prefix,
6080 // then it means that there should be a separator
6081 // between a national prefix and a national (significant) number.
6082
6083
6084 if (format && format.nationalPrefixFormattingRule() && NATIONAL_PREFIX_SEPARATORS_PATTERN.test(format.nationalPrefixFormattingRule())) {
6085 return ' ';
6086 } // At this point, there seems to be no clear evidence that
6087 // there should be a separator between a national prefix
6088 // and a national (significant) number. So don't insert one.
6089
6090
6091 return '';
6092 }
6093 }, {
6094 key: "getInternationalPrefixBeforeCountryCallingCode",
6095 value: function getInternationalPrefixBeforeCountryCallingCode(_ref3, options) {
6096 var IDDPrefix = _ref3.IDDPrefix,
6097 missingPlus = _ref3.missingPlus;
6098
6099 if (IDDPrefix) {
6100 return options && options.spacing === false ? IDDPrefix : IDDPrefix + ' ';
6101 }
6102
6103 if (missingPlus) {
6104 return '';
6105 }
6106
6107 return '+';
6108 }
6109 }, {
6110 key: "getTemplate",
6111 value: function getTemplate(state) {
6112 if (!this.template) {
6113 return;
6114 } // `this.template` holds the template for a "complete" phone number.
6115 // The currently entered phone number is most likely not "complete",
6116 // so trim all non-populated digits.
6117
6118
6119 var index = -1;
6120 var i = 0;
6121 var internationalPrefix = state.international ? this.getInternationalPrefixBeforeCountryCallingCode(state, {
6122 spacing: false
6123 }) : '';
6124
6125 while (i < internationalPrefix.length + state.getDigitsWithoutInternationalPrefix().length) {
6126 index = this.template.indexOf(DIGIT_PLACEHOLDER, index + 1);
6127 i++;
6128 }
6129
6130 return cutAndStripNonPairedParens(this.template, index + 1);
6131 }
6132 }, {
6133 key: "setNationalNumberTemplate",
6134 value: function setNationalNumberTemplate(template, state) {
6135 this.nationalNumberTemplate = template;
6136 this.populatedNationalNumberTemplate = template; // With a new formatting template, the matched position
6137 // using the old template needs to be reset.
6138
6139 this.populatedNationalNumberTemplatePosition = -1; // For convenience, the public `.template` property
6140 // contains the whole international number
6141 // if the phone number being input is international:
6142 // 'x' for the '+' sign, 'x'es for the country phone code,
6143 // a spacebar and then the template for the formatted national number.
6144
6145 if (state.international) {
6146 this.template = this.getInternationalPrefixBeforeCountryCallingCode(state).replace(/[\d\+]/g, DIGIT_PLACEHOLDER) + repeat(DIGIT_PLACEHOLDER, state.callingCode.length) + ' ' + template;
6147 } else {
6148 this.template = template;
6149 }
6150 }
6151 /**
6152 * Generates formatting template for a national phone number,
6153 * optionally containing a national prefix, for a format.
6154 * @param {Format} format
6155 * @param {string} nationalPrefix
6156 * @return {string}
6157 */
6158
6159 }, {
6160 key: "getTemplateForFormat",
6161 value: function getTemplateForFormat(format, _ref4) {
6162 var nationalSignificantNumber = _ref4.nationalSignificantNumber,
6163 international = _ref4.international,
6164 nationalPrefix = _ref4.nationalPrefix,
6165 complexPrefixBeforeNationalSignificantNumber = _ref4.complexPrefixBeforeNationalSignificantNumber;
6166 var pattern = format.pattern();
6167 /* istanbul ignore else */
6168
6169 {
6170 pattern = pattern // Replace anything in the form of [..] with \d
6171 .replace(CREATE_CHARACTER_CLASS_PATTERN(), '\\d') // Replace any standalone digit (not the one in `{}`) with \d
6172 .replace(CREATE_STANDALONE_DIGIT_PATTERN(), '\\d');
6173 } // Generate a dummy national number (consisting of `9`s)
6174 // that fits this format's `pattern`.
6175 //
6176 // This match will always succeed,
6177 // because the "longest dummy phone number"
6178 // has enough length to accomodate any possible
6179 // national phone number format pattern.
6180 //
6181
6182
6183 var digits = LONGEST_DUMMY_PHONE_NUMBER.match(pattern)[0]; // If the national number entered is too long
6184 // for any phone number format, then abort.
6185
6186 if (nationalSignificantNumber.length > digits.length) {
6187 return;
6188 } // Get a formatting template which can be used to efficiently format
6189 // a partial number where digits are added one by one.
6190 // Below `strictPattern` is used for the
6191 // regular expression (with `^` and `$`).
6192 // This wasn't originally in Google's `libphonenumber`
6193 // and I guess they don't really need it
6194 // because they're not using "templates" to format phone numbers
6195 // but I added `strictPattern` after encountering
6196 // South Korean phone number formatting bug.
6197 //
6198 // Non-strict regular expression bug demonstration:
6199 //
6200 // this.nationalSignificantNumber : `111111111` (9 digits)
6201 //
6202 // pattern : (\d{2})(\d{3,4})(\d{4})
6203 // format : `$1 $2 $3`
6204 // digits : `9999999999` (10 digits)
6205 //
6206 // '9999999999'.replace(new RegExp(/(\d{2})(\d{3,4})(\d{4})/g), '$1 $2 $3') = "99 9999 9999"
6207 //
6208 // template : xx xxxx xxxx
6209 //
6210 // But the correct template in this case is `xx xxx xxxx`.
6211 // The template was generated incorrectly because of the
6212 // `{3,4}` variability in the `pattern`.
6213 //
6214 // The fix is, if `this.nationalSignificantNumber` has already sufficient length
6215 // to satisfy the `pattern` completely then `this.nationalSignificantNumber`
6216 // is used instead of `digits`.
6217
6218
6219 var strictPattern = new RegExp('^' + pattern + '$');
6220 var nationalNumberDummyDigits = nationalSignificantNumber.replace(/\d/g, DUMMY_DIGIT); // If `this.nationalSignificantNumber` has already sufficient length
6221 // to satisfy the `pattern` completely then use it
6222 // instead of `digits`.
6223
6224 if (strictPattern.test(nationalNumberDummyDigits)) {
6225 digits = nationalNumberDummyDigits;
6226 }
6227
6228 var numberFormat = this.getFormatFormat(format, international);
6229 var nationalPrefixIncludedInTemplate; // If a user did input a national prefix (and that's guaranteed),
6230 // and if a `format` does have a national prefix formatting rule,
6231 // then see if that national prefix formatting rule
6232 // prepends exactly the same national prefix the user has input.
6233 // If that's the case, then use the `format` with the national prefix formatting rule.
6234 // Otherwise, use the `format` without the national prefix formatting rule,
6235 // and prepend a national prefix manually to it.
6236
6237 if (this.shouldTryNationalPrefixFormattingRule(format, {
6238 international: international,
6239 nationalPrefix: nationalPrefix
6240 })) {
6241 var numberFormatWithNationalPrefix = numberFormat.replace(FIRST_GROUP_PATTERN, format.nationalPrefixFormattingRule()); // If `national_prefix_formatting_rule` of a `format` simply prepends
6242 // national prefix at the start of a national (significant) number,
6243 // then such formatting can be used with `AsYouType` formatter.
6244 // There seems to be no `else` case: everywhere in metadata,
6245 // national prefix formatting rule is national prefix + $1,
6246 // or `($1)`, in which case such format isn't even considered
6247 // when the user has input a national prefix.
6248
6249 /* istanbul ignore else */
6250
6251 if (parseDigits(format.nationalPrefixFormattingRule()) === (nationalPrefix || '') + parseDigits('$1')) {
6252 numberFormat = numberFormatWithNationalPrefix;
6253 nationalPrefixIncludedInTemplate = true; // Replace all digits of the national prefix in the formatting template
6254 // with `DIGIT_PLACEHOLDER`s.
6255
6256 if (nationalPrefix) {
6257 var i = nationalPrefix.length;
6258
6259 while (i > 0) {
6260 numberFormat = numberFormat.replace(/\d/, DIGIT_PLACEHOLDER);
6261 i--;
6262 }
6263 }
6264 }
6265 } // Generate formatting template for this phone number format.
6266
6267
6268 var template = digits // Format the dummy phone number according to the format.
6269 .replace(new RegExp(pattern), numberFormat) // Replace each dummy digit with a DIGIT_PLACEHOLDER.
6270 .replace(new RegExp(DUMMY_DIGIT, 'g'), DIGIT_PLACEHOLDER); // If a prefix of a national (significant) number is not as simple
6271 // as just a basic national prefix, then just prepend such prefix
6272 // before the national (significant) number, optionally spacing
6273 // the two with a whitespace.
6274
6275 if (!nationalPrefixIncludedInTemplate) {
6276 if (complexPrefixBeforeNationalSignificantNumber) {
6277 // Prepend the prefix to the template manually.
6278 template = repeat(DIGIT_PLACEHOLDER, complexPrefixBeforeNationalSignificantNumber.length) + ' ' + template;
6279 } else if (nationalPrefix) {
6280 // Prepend national prefix to the template manually.
6281 template = repeat(DIGIT_PLACEHOLDER, nationalPrefix.length) + this.getSeparatorAfterNationalPrefix(format) + template;
6282 }
6283 }
6284
6285 if (international) {
6286 template = applyInternationalSeparatorStyle(template);
6287 }
6288
6289 return template;
6290 }
6291 }, {
6292 key: "formatNextNationalNumberDigits",
6293 value: function formatNextNationalNumberDigits(digits) {
6294 var result = populateTemplateWithDigits(this.populatedNationalNumberTemplate, this.populatedNationalNumberTemplatePosition, digits);
6295
6296 if (!result) {
6297 // Reset the format.
6298 this.resetFormat();
6299 return;
6300 }
6301
6302 this.populatedNationalNumberTemplate = result[0];
6303 this.populatedNationalNumberTemplatePosition = result[1]; // Return the formatted phone number so far.
6304
6305 return cutAndStripNonPairedParens(this.populatedNationalNumberTemplate, this.populatedNationalNumberTemplatePosition + 1); // The old way which was good for `input-format` but is not so good
6306 // for `react-phone-number-input`'s default input (`InputBasic`).
6307 // return closeNonPairedParens(this.populatedNationalNumberTemplate, this.populatedNationalNumberTemplatePosition + 1)
6308 // .replace(new RegExp(DIGIT_PLACEHOLDER, 'g'), ' ')
6309 }
6310 }, {
6311 key: "shouldTryNationalPrefixFormattingRule",
6312 value: function shouldTryNationalPrefixFormattingRule(format, _ref5) {
6313 var international = _ref5.international,
6314 nationalPrefix = _ref5.nationalPrefix;
6315
6316 if (format.nationalPrefixFormattingRule()) {
6317 // In some countries, `national_prefix_formatting_rule` is `($1)`,
6318 // so it applies even if the user hasn't input a national prefix.
6319 // `format.usesNationalPrefix()` detects such cases.
6320 var usesNationalPrefix = format.usesNationalPrefix();
6321
6322 if (usesNationalPrefix && nationalPrefix || !usesNationalPrefix && !international) {
6323 return true;
6324 }
6325 }
6326 }
6327 }]);
6328
6329 return AsYouTypeFormatter;
6330}();
6331
6332function _slicedToArray$1(arr, i) { return _arrayWithHoles$1(arr) || _iterableToArrayLimit$1(arr, i) || _unsupportedIterableToArray$1(arr, i) || _nonIterableRest$1(); }
6333
6334function _nonIterableRest$1() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
6335
6336function _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); }
6337
6338function _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; }
6339
6340function _iterableToArrayLimit$1(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; }
6341
6342function _arrayWithHoles$1(arr) { if (Array.isArray(arr)) return arr; }
6343
6344function _classCallCheck$1(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6345
6346function _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); } }
6347
6348function _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; }
6349var VALID_FORMATTED_PHONE_NUMBER_DIGITS_PART = '[' + VALID_PUNCTUATION + VALID_DIGITS + ']+';
6350var VALID_FORMATTED_PHONE_NUMBER_DIGITS_PART_PATTERN = new RegExp('^' + VALID_FORMATTED_PHONE_NUMBER_DIGITS_PART + '$', 'i');
6351var VALID_FORMATTED_PHONE_NUMBER_PART = '(?:' + '[' + PLUS_CHARS + ']' + '[' + VALID_PUNCTUATION + VALID_DIGITS + ']*' + '|' + '[' + VALID_PUNCTUATION + VALID_DIGITS + ']+' + ')';
6352var AFTER_PHONE_NUMBER_DIGITS_END_PATTERN = new RegExp('[^' + VALID_PUNCTUATION + VALID_DIGITS + ']+' + '.*' + '$'); // Tests whether `national_prefix_for_parsing` could match
6353// different national prefixes.
6354// Matches anything that's not a digit or a square bracket.
6355
6356var COMPLEX_NATIONAL_PREFIX = /[^\d\[\]]/;
6357
6358var AsYouTypeParser = /*#__PURE__*/function () {
6359 function AsYouTypeParser(_ref) {
6360 var defaultCountry = _ref.defaultCountry,
6361 defaultCallingCode = _ref.defaultCallingCode,
6362 metadata = _ref.metadata,
6363 onNationalSignificantNumberChange = _ref.onNationalSignificantNumberChange;
6364
6365 _classCallCheck$1(this, AsYouTypeParser);
6366
6367 this.defaultCountry = defaultCountry;
6368 this.defaultCallingCode = defaultCallingCode;
6369 this.metadata = metadata;
6370 this.onNationalSignificantNumberChange = onNationalSignificantNumberChange;
6371 }
6372
6373 _createClass$1(AsYouTypeParser, [{
6374 key: "input",
6375 value: function input(text, state) {
6376 var _extractFormattedDigi = extractFormattedDigitsAndPlus(text),
6377 _extractFormattedDigi2 = _slicedToArray$1(_extractFormattedDigi, 2),
6378 formattedDigits = _extractFormattedDigi2[0],
6379 hasPlus = _extractFormattedDigi2[1];
6380
6381 var digits = parseDigits(formattedDigits); // Checks for a special case: just a leading `+` has been entered.
6382
6383 var justLeadingPlus;
6384
6385 if (hasPlus) {
6386 if (!state.digits) {
6387 state.startInternationalNumber();
6388
6389 if (!digits) {
6390 justLeadingPlus = true;
6391 }
6392 }
6393 }
6394
6395 if (digits) {
6396 this.inputDigits(digits, state);
6397 }
6398
6399 return {
6400 digits: digits,
6401 justLeadingPlus: justLeadingPlus
6402 };
6403 }
6404 /**
6405 * Inputs "next" phone number digits.
6406 * @param {string} digits
6407 * @return {string} [formattedNumber] Formatted national phone number (if it can be formatted at this stage). Returning `undefined` means "don't format the national phone number at this stage".
6408 */
6409
6410 }, {
6411 key: "inputDigits",
6412 value: function inputDigits(nextDigits, state) {
6413 var digits = state.digits;
6414 var hasReceivedThreeLeadingDigits = digits.length < 3 && digits.length + nextDigits.length >= 3; // Append phone number digits.
6415
6416 state.appendDigits(nextDigits); // Attempt to extract IDD prefix:
6417 // Some users input their phone number in international format,
6418 // but in an "out-of-country" dialing format instead of using the leading `+`.
6419 // https://github.com/catamphetamine/libphonenumber-js/issues/185
6420 // Detect such numbers as soon as there're at least 3 digits.
6421 // Google's library attempts to extract IDD prefix at 3 digits,
6422 // so this library just copies that behavior.
6423 // I guess that's because the most commot IDD prefixes are
6424 // `00` (Europe) and `011` (US).
6425 // There exist really long IDD prefixes too:
6426 // for example, in Australia the default IDD prefix is `0011`,
6427 // and it could even be as long as `14880011`.
6428 // An IDD prefix is extracted here, and then every time when
6429 // there's a new digit and the number couldn't be formatted.
6430
6431 if (hasReceivedThreeLeadingDigits) {
6432 this.extractIddPrefix(state);
6433 }
6434
6435 if (this.isWaitingForCountryCallingCode(state)) {
6436 if (!this.extractCountryCallingCode(state)) {
6437 return;
6438 }
6439 } else {
6440 state.appendNationalSignificantNumberDigits(nextDigits);
6441 } // If a phone number is being input in international format,
6442 // then it's not valid for it to have a national prefix.
6443 // Still, some people incorrectly input such numbers with a national prefix.
6444 // In such cases, only attempt to strip a national prefix if the number becomes too long.
6445 // (but that is done later, not here)
6446
6447
6448 if (!state.international) {
6449 if (!this.hasExtractedNationalSignificantNumber) {
6450 this.extractNationalSignificantNumber(state.getNationalDigits(), function (stateUpdate) {
6451 return state.update(stateUpdate);
6452 });
6453 }
6454 }
6455 }
6456 }, {
6457 key: "isWaitingForCountryCallingCode",
6458 value: function isWaitingForCountryCallingCode(_ref2) {
6459 var international = _ref2.international,
6460 callingCode = _ref2.callingCode;
6461 return international && !callingCode;
6462 } // Extracts a country calling code from a number
6463 // being entered in internatonal format.
6464
6465 }, {
6466 key: "extractCountryCallingCode",
6467 value: function extractCountryCallingCode$1(state) {
6468 var _extractCountryCallin = extractCountryCallingCode('+' + state.getDigitsWithoutInternationalPrefix(), this.defaultCountry, this.defaultCallingCode, this.metadata.metadata),
6469 countryCallingCode = _extractCountryCallin.countryCallingCode,
6470 number = _extractCountryCallin.number;
6471
6472 if (countryCallingCode) {
6473 state.setCallingCode(countryCallingCode);
6474 state.update({
6475 nationalSignificantNumber: number
6476 });
6477 return true;
6478 }
6479 }
6480 }, {
6481 key: "reset",
6482 value: function reset(numberingPlan) {
6483 if (numberingPlan) {
6484 this.hasSelectedNumberingPlan = true;
6485
6486 var nationalPrefixForParsing = numberingPlan._nationalPrefixForParsing();
6487
6488 this.couldPossiblyExtractAnotherNationalSignificantNumber = nationalPrefixForParsing && COMPLEX_NATIONAL_PREFIX.test(nationalPrefixForParsing);
6489 } else {
6490 this.hasSelectedNumberingPlan = undefined;
6491 this.couldPossiblyExtractAnotherNationalSignificantNumber = undefined;
6492 }
6493 }
6494 /**
6495 * Extracts a national (significant) number from user input.
6496 * Google's library is different in that it only applies `national_prefix_for_parsing`
6497 * and doesn't apply `national_prefix_transform_rule` after that.
6498 * https://github.com/google/libphonenumber/blob/a3d70b0487875475e6ad659af404943211d26456/java/libphonenumber/src/com/google/i18n/phonenumbers/AsYouTypeFormatter.java#L539
6499 * @return {boolean} [extracted]
6500 */
6501
6502 }, {
6503 key: "extractNationalSignificantNumber",
6504 value: function extractNationalSignificantNumber(nationalDigits, setState) {
6505 if (!this.hasSelectedNumberingPlan) {
6506 return;
6507 }
6508
6509 var _extractNationalNumbe = extractNationalNumberFromPossiblyIncompleteNumber(nationalDigits, this.metadata),
6510 nationalPrefix = _extractNationalNumbe.nationalPrefix,
6511 nationalNumber = _extractNationalNumbe.nationalNumber,
6512 carrierCode = _extractNationalNumbe.carrierCode;
6513
6514 if (nationalNumber === nationalDigits) {
6515 return;
6516 }
6517
6518 this.onExtractedNationalNumber(nationalPrefix, carrierCode, nationalNumber, nationalDigits, setState);
6519 return true;
6520 }
6521 /**
6522 * In Google's code this function is called "attempt to extract longer NDD".
6523 * "Some national prefixes are a substring of others", they say.
6524 * @return {boolean} [result] — Returns `true` if extracting a national prefix produced different results from what they were.
6525 */
6526
6527 }, {
6528 key: "extractAnotherNationalSignificantNumber",
6529 value: function extractAnotherNationalSignificantNumber(nationalDigits, prevNationalSignificantNumber, setState) {
6530 if (!this.hasExtractedNationalSignificantNumber) {
6531 return this.extractNationalSignificantNumber(nationalDigits, setState);
6532 }
6533
6534 if (!this.couldPossiblyExtractAnotherNationalSignificantNumber) {
6535 return;
6536 }
6537
6538 var _extractNationalNumbe2 = extractNationalNumberFromPossiblyIncompleteNumber(nationalDigits, this.metadata),
6539 nationalPrefix = _extractNationalNumbe2.nationalPrefix,
6540 nationalNumber = _extractNationalNumbe2.nationalNumber,
6541 carrierCode = _extractNationalNumbe2.carrierCode; // If a national prefix has been extracted previously,
6542 // then it's always extracted as additional digits are added.
6543 // That's assuming `extractNationalNumberFromPossiblyIncompleteNumber()`
6544 // doesn't do anything different from what it currently does.
6545 // So, just in case, here's this check, though it doesn't occur.
6546
6547 /* istanbul ignore if */
6548
6549
6550 if (nationalNumber === prevNationalSignificantNumber) {
6551 return;
6552 }
6553
6554 this.onExtractedNationalNumber(nationalPrefix, carrierCode, nationalNumber, nationalDigits, setState);
6555 return true;
6556 }
6557 }, {
6558 key: "onExtractedNationalNumber",
6559 value: function onExtractedNationalNumber(nationalPrefix, carrierCode, nationalSignificantNumber, nationalDigits, setState) {
6560 var complexPrefixBeforeNationalSignificantNumber;
6561 var nationalSignificantNumberMatchesInput; // This check also works with empty `this.nationalSignificantNumber`.
6562
6563 var nationalSignificantNumberIndex = nationalDigits.lastIndexOf(nationalSignificantNumber); // If the extracted national (significant) number is the
6564 // last substring of the `digits`, then it means that it hasn't been altered:
6565 // no digits have been removed from the national (significant) number
6566 // while applying `national_prefix_transform_rule`.
6567 // https://gitlab.com/catamphetamine/libphonenumber-js/-/blob/master/METADATA.md#national_prefix_for_parsing--national_prefix_transform_rule
6568
6569 if (nationalSignificantNumberIndex >= 0 && nationalSignificantNumberIndex === nationalDigits.length - nationalSignificantNumber.length) {
6570 nationalSignificantNumberMatchesInput = true; // If a prefix of a national (significant) number is not as simple
6571 // as just a basic national prefix, then such prefix is stored in
6572 // `this.complexPrefixBeforeNationalSignificantNumber` property and will be
6573 // prepended "as is" to the national (significant) number to produce
6574 // a formatted result.
6575
6576 var prefixBeforeNationalNumber = nationalDigits.slice(0, nationalSignificantNumberIndex); // `prefixBeforeNationalNumber` is always non-empty,
6577 // because `onExtractedNationalNumber()` isn't called
6578 // when a national (significant) number hasn't been actually "extracted":
6579 // when a national (significant) number is equal to the national part of `digits`,
6580 // then `onExtractedNationalNumber()` doesn't get called.
6581
6582 if (prefixBeforeNationalNumber !== nationalPrefix) {
6583 complexPrefixBeforeNationalSignificantNumber = prefixBeforeNationalNumber;
6584 }
6585 }
6586
6587 setState({
6588 nationalPrefix: nationalPrefix,
6589 carrierCode: carrierCode,
6590 nationalSignificantNumber: nationalSignificantNumber,
6591 nationalSignificantNumberMatchesInput: nationalSignificantNumberMatchesInput,
6592 complexPrefixBeforeNationalSignificantNumber: complexPrefixBeforeNationalSignificantNumber
6593 }); // `onExtractedNationalNumber()` is only called when
6594 // the national (significant) number actually did change.
6595
6596 this.hasExtractedNationalSignificantNumber = true;
6597 this.onNationalSignificantNumberChange();
6598 }
6599 }, {
6600 key: "reExtractNationalSignificantNumber",
6601 value: function reExtractNationalSignificantNumber(state) {
6602 // Attempt to extract a national prefix.
6603 //
6604 // Some people incorrectly input national prefix
6605 // in an international phone number.
6606 // For example, some people write British phone numbers as `+44(0)...`.
6607 //
6608 // Also, in some rare cases, it is valid for a national prefix
6609 // to be a part of an international phone number.
6610 // For example, mobile phone numbers in Mexico are supposed to be
6611 // dialled internationally using a `1` national prefix,
6612 // so the national prefix will be part of an international number.
6613 //
6614 // Quote from:
6615 // https://www.mexperience.com/dialing-cell-phones-in-mexico/
6616 //
6617 // "Dialing a Mexican cell phone from abroad
6618 // When you are calling a cell phone number in Mexico from outside Mexico,
6619 // it’s necessary to dial an additional “1” after Mexico’s country code
6620 // (which is “52”) and before the area code.
6621 // You also ignore the 045, and simply dial the area code and the
6622 // cell phone’s number.
6623 //
6624 // If you don’t add the “1”, you’ll receive a recorded announcement
6625 // asking you to redial using it.
6626 //
6627 // For example, if you are calling from the USA to a cell phone
6628 // in Mexico City, you would dial +52 – 1 – 55 – 1234 5678.
6629 // (Note that this is different to calling a land line in Mexico City
6630 // from abroad, where the number dialed would be +52 – 55 – 1234 5678)".
6631 //
6632 // Google's demo output:
6633 // https://libphonenumber.appspot.com/phonenumberparser?number=%2b5215512345678&country=MX
6634 //
6635 if (this.extractAnotherNationalSignificantNumber(state.getNationalDigits(), state.nationalSignificantNumber, function (stateUpdate) {
6636 return state.update(stateUpdate);
6637 })) {
6638 return true;
6639 } // If no format matches the phone number, then it could be
6640 // "a really long IDD" (quote from a comment in Google's library).
6641 // An IDD prefix is first extracted when the user has entered at least 3 digits,
6642 // and then here — every time when there's a new digit and the number
6643 // couldn't be formatted.
6644 // For example, in Australia the default IDD prefix is `0011`,
6645 // and it could even be as long as `14880011`.
6646 //
6647 // Could also check `!hasReceivedThreeLeadingDigits` here
6648 // to filter out the case when this check duplicates the one
6649 // already performed when there're 3 leading digits,
6650 // but it's not a big deal, and in most cases there
6651 // will be a suitable `format` when there're 3 leading digits.
6652 //
6653
6654
6655 if (this.extractIddPrefix(state)) {
6656 this.extractCallingCodeAndNationalSignificantNumber(state);
6657 return true;
6658 } // Google's AsYouType formatter supports sort of an "autocorrection" feature
6659 // when it "autocorrects" numbers that have been input for a country
6660 // with that country's calling code.
6661 // Such "autocorrection" feature looks weird, but different people have been requesting it:
6662 // https://github.com/catamphetamine/libphonenumber-js/issues/376
6663 // https://github.com/catamphetamine/libphonenumber-js/issues/375
6664 // https://github.com/catamphetamine/libphonenumber-js/issues/316
6665
6666
6667 if (this.fixMissingPlus(state)) {
6668 this.extractCallingCodeAndNationalSignificantNumber(state);
6669 return true;
6670 }
6671 }
6672 }, {
6673 key: "extractIddPrefix",
6674 value: function extractIddPrefix(state) {
6675 // An IDD prefix can't be present in a number written with a `+`.
6676 // Also, don't re-extract an IDD prefix if has already been extracted.
6677 var international = state.international,
6678 IDDPrefix = state.IDDPrefix,
6679 digits = state.digits;
6680 state.nationalSignificantNumber;
6681
6682 if (international || IDDPrefix) {
6683 return;
6684 } // Some users input their phone number in "out-of-country"
6685 // dialing format instead of using the leading `+`.
6686 // https://github.com/catamphetamine/libphonenumber-js/issues/185
6687 // Detect such numbers.
6688
6689
6690 var numberWithoutIDD = stripIddPrefix(digits, this.defaultCountry, this.defaultCallingCode, this.metadata.metadata);
6691
6692 if (numberWithoutIDD !== undefined && numberWithoutIDD !== digits) {
6693 // If an IDD prefix was stripped then convert the IDD-prefixed number
6694 // to international number for subsequent parsing.
6695 state.update({
6696 IDDPrefix: digits.slice(0, digits.length - numberWithoutIDD.length)
6697 });
6698 this.startInternationalNumber(state, {
6699 country: undefined,
6700 callingCode: undefined
6701 });
6702 return true;
6703 }
6704 }
6705 }, {
6706 key: "fixMissingPlus",
6707 value: function fixMissingPlus(state) {
6708 if (!state.international) {
6709 var _extractCountryCallin2 = extractCountryCallingCodeFromInternationalNumberWithoutPlusSign(state.digits, this.defaultCountry, this.defaultCallingCode, this.metadata.metadata),
6710 newCallingCode = _extractCountryCallin2.countryCallingCode;
6711 _extractCountryCallin2.number;
6712
6713 if (newCallingCode) {
6714 state.update({
6715 missingPlus: true
6716 });
6717 this.startInternationalNumber(state, {
6718 country: state.country,
6719 callingCode: newCallingCode
6720 });
6721 return true;
6722 }
6723 }
6724 }
6725 }, {
6726 key: "startInternationalNumber",
6727 value: function startInternationalNumber(state, _ref3) {
6728 var country = _ref3.country,
6729 callingCode = _ref3.callingCode;
6730 state.startInternationalNumber(country, callingCode); // If a national (significant) number has been extracted before, reset it.
6731
6732 if (state.nationalSignificantNumber) {
6733 state.resetNationalSignificantNumber();
6734 this.onNationalSignificantNumberChange();
6735 this.hasExtractedNationalSignificantNumber = undefined;
6736 }
6737 }
6738 }, {
6739 key: "extractCallingCodeAndNationalSignificantNumber",
6740 value: function extractCallingCodeAndNationalSignificantNumber(state) {
6741 if (this.extractCountryCallingCode(state)) {
6742 // `this.extractCallingCode()` is currently called when the number
6743 // couldn't be formatted during the standard procedure.
6744 // Normally, the national prefix would be re-extracted
6745 // for an international number if such number couldn't be formatted,
6746 // but since it's already not able to be formatted,
6747 // there won't be yet another retry, so also extract national prefix here.
6748 this.extractNationalSignificantNumber(state.getNationalDigits(), function (stateUpdate) {
6749 return state.update(stateUpdate);
6750 });
6751 }
6752 }
6753 }]);
6754
6755 return AsYouTypeParser;
6756}();
6757
6758function extractFormattedPhoneNumber(text) {
6759 // Attempt to extract a possible number from the string passed in.
6760 var startsAt = text.search(VALID_FORMATTED_PHONE_NUMBER_PART);
6761
6762 if (startsAt < 0) {
6763 return;
6764 } // Trim everything to the left of the phone number.
6765
6766
6767 text = text.slice(startsAt); // Trim the `+`.
6768
6769 var hasPlus;
6770
6771 if (text[0] === '+') {
6772 hasPlus = true;
6773 text = text.slice('+'.length);
6774 } // Trim everything to the right of the phone number.
6775
6776
6777 text = text.replace(AFTER_PHONE_NUMBER_DIGITS_END_PATTERN, ''); // Re-add the previously trimmed `+`.
6778
6779 if (hasPlus) {
6780 text = '+' + text;
6781 }
6782
6783 return text;
6784}
6785/**
6786 * Extracts formatted phone number digits (and a `+`) from text (if there're any).
6787 * @param {string} text
6788 * @return {any[]}
6789 */
6790
6791
6792function _extractFormattedDigitsAndPlus(text) {
6793 // Extract a formatted phone number part from text.
6794 var extractedNumber = extractFormattedPhoneNumber(text) || ''; // Trim a `+`.
6795
6796 if (extractedNumber[0] === '+') {
6797 return [extractedNumber.slice('+'.length), true];
6798 }
6799
6800 return [extractedNumber];
6801}
6802/**
6803 * Extracts formatted phone number digits (and a `+`) from text (if there're any).
6804 * @param {string} text
6805 * @return {any[]}
6806 */
6807
6808
6809function extractFormattedDigitsAndPlus(text) {
6810 var _extractFormattedDigi3 = _extractFormattedDigitsAndPlus(text),
6811 _extractFormattedDigi4 = _slicedToArray$1(_extractFormattedDigi3, 2),
6812 formattedDigits = _extractFormattedDigi4[0],
6813 hasPlus = _extractFormattedDigi4[1]; // If the extracted phone number part
6814 // can possibly be a part of some valid phone number
6815 // then parse phone number characters from a formatted phone number.
6816
6817
6818 if (!VALID_FORMATTED_PHONE_NUMBER_DIGITS_PART_PATTERN.test(formattedDigits)) {
6819 formattedDigits = '';
6820 }
6821
6822 return [formattedDigits, hasPlus];
6823}
6824
6825function _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); }
6826
6827function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
6828
6829function _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."); }
6830
6831function _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); }
6832
6833function _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; }
6834
6835function _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; }
6836
6837function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
6838
6839function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6840
6841function _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); } }
6842
6843function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
6844
6845var AsYouType$1 = /*#__PURE__*/function () {
6846 /**
6847 * @param {(string|object)?} [optionsOrDefaultCountry] - The default country used for parsing non-international phone numbers. Can also be an `options` object.
6848 * @param {Object} metadata
6849 */
6850 function AsYouType(optionsOrDefaultCountry, metadata) {
6851 _classCallCheck(this, AsYouType);
6852
6853 this.metadata = new Metadata(metadata);
6854
6855 var _this$getCountryAndCa = this.getCountryAndCallingCode(optionsOrDefaultCountry),
6856 _this$getCountryAndCa2 = _slicedToArray(_this$getCountryAndCa, 2),
6857 defaultCountry = _this$getCountryAndCa2[0],
6858 defaultCallingCode = _this$getCountryAndCa2[1];
6859
6860 this.defaultCountry = defaultCountry;
6861 this.defaultCallingCode = defaultCallingCode;
6862 this.reset();
6863 }
6864
6865 _createClass(AsYouType, [{
6866 key: "getCountryAndCallingCode",
6867 value: function getCountryAndCallingCode(optionsOrDefaultCountry) {
6868 // Set `defaultCountry` and `defaultCallingCode` options.
6869 var defaultCountry;
6870 var defaultCallingCode; // Turns out `null` also has type "object". Weird.
6871
6872 if (optionsOrDefaultCountry) {
6873 if (_typeof(optionsOrDefaultCountry) === 'object') {
6874 defaultCountry = optionsOrDefaultCountry.defaultCountry;
6875 defaultCallingCode = optionsOrDefaultCountry.defaultCallingCode;
6876 } else {
6877 defaultCountry = optionsOrDefaultCountry;
6878 }
6879 }
6880
6881 if (defaultCountry && !this.metadata.hasCountry(defaultCountry)) {
6882 defaultCountry = undefined;
6883 }
6884
6885 return [defaultCountry, defaultCallingCode];
6886 }
6887 /**
6888 * Inputs "next" phone number characters.
6889 * @param {string} text
6890 * @return {string} Formatted phone number characters that have been input so far.
6891 */
6892
6893 }, {
6894 key: "input",
6895 value: function input(text) {
6896 var _this$parser$input = this.parser.input(text, this.state),
6897 digits = _this$parser$input.digits,
6898 justLeadingPlus = _this$parser$input.justLeadingPlus;
6899
6900 if (justLeadingPlus) {
6901 this.formattedOutput = '+';
6902 } else if (digits) {
6903 this.determineTheCountryIfNeeded(); // Match the available formats by the currently available leading digits.
6904
6905 if (this.state.nationalSignificantNumber) {
6906 this.formatter.narrowDownMatchingFormats(this.state);
6907 }
6908
6909 var formattedNationalNumber;
6910
6911 if (this.metadata.hasSelectedNumberingPlan()) {
6912 formattedNationalNumber = this.formatter.format(digits, this.state);
6913 }
6914
6915 if (formattedNationalNumber === undefined) {
6916 // See if another national (significant) number could be re-extracted.
6917 if (this.parser.reExtractNationalSignificantNumber(this.state)) {
6918 this.determineTheCountryIfNeeded(); // If it could, then re-try formatting the new national (significant) number.
6919
6920 var nationalDigits = this.state.getNationalDigits();
6921
6922 if (nationalDigits) {
6923 formattedNationalNumber = this.formatter.format(nationalDigits, this.state);
6924 }
6925 }
6926 }
6927
6928 this.formattedOutput = formattedNationalNumber ? this.getFullNumber(formattedNationalNumber) : this.getNonFormattedNumber();
6929 }
6930
6931 return this.formattedOutput;
6932 }
6933 }, {
6934 key: "reset",
6935 value: function reset() {
6936 var _this = this;
6937
6938 this.state = new AsYouTypeState({
6939 onCountryChange: function onCountryChange(country) {
6940 // Before version `1.6.0`, the official `AsYouType` formatter API
6941 // included the `.country` property of an `AsYouType` instance.
6942 // Since that property (along with the others) have been moved to
6943 // `this.state`, `this.country` property is emulated for compatibility
6944 // with the old versions.
6945 _this.country = country;
6946 },
6947 onCallingCodeChange: function onCallingCodeChange(callingCode, country) {
6948 _this.metadata.selectNumberingPlan(country, callingCode);
6949
6950 _this.formatter.reset(_this.metadata.numberingPlan, _this.state);
6951
6952 _this.parser.reset(_this.metadata.numberingPlan);
6953 }
6954 });
6955 this.formatter = new AsYouTypeFormatter({
6956 state: this.state,
6957 metadata: this.metadata
6958 });
6959 this.parser = new AsYouTypeParser({
6960 defaultCountry: this.defaultCountry,
6961 defaultCallingCode: this.defaultCallingCode,
6962 metadata: this.metadata,
6963 state: this.state,
6964 onNationalSignificantNumberChange: function onNationalSignificantNumberChange() {
6965 _this.determineTheCountryIfNeeded();
6966
6967 _this.formatter.reset(_this.metadata.numberingPlan, _this.state);
6968 }
6969 });
6970 this.state.reset({
6971 country: this.defaultCountry,
6972 callingCode: this.defaultCallingCode
6973 });
6974 this.formattedOutput = '';
6975 return this;
6976 }
6977 /**
6978 * Returns `true` if the phone number is being input in international format.
6979 * In other words, returns `true` if and only if the parsed phone number starts with a `"+"`.
6980 * @return {boolean}
6981 */
6982
6983 }, {
6984 key: "isInternational",
6985 value: function isInternational() {
6986 return this.state.international;
6987 }
6988 /**
6989 * Returns the "calling code" part of the phone number when it's being input
6990 * in an international format.
6991 * If no valid calling code has been entered so far, returns `undefined`.
6992 * @return {string} [callingCode]
6993 */
6994
6995 }, {
6996 key: "getCallingCode",
6997 value: function getCallingCode() {
6998 // If the number is being input in national format and some "default calling code"
6999 // has been passed to `AsYouType` constructor, then `this.state.callingCode`
7000 // is equal to that "default calling code".
7001 //
7002 // If the number is being input in national format and no "default calling code"
7003 // has been passed to `AsYouType` constructor, then returns `undefined`,
7004 // even if a "default country" has been passed to `AsYouType` constructor.
7005 //
7006 if (this.isInternational()) {
7007 return this.state.callingCode;
7008 }
7009 } // A legacy alias.
7010
7011 }, {
7012 key: "getCountryCallingCode",
7013 value: function getCountryCallingCode() {
7014 return this.getCallingCode();
7015 }
7016 /**
7017 * Returns a two-letter country code of the phone number.
7018 * Returns `undefined` for "non-geographic" phone numbering plans.
7019 * Returns `undefined` if no phone number has been input yet.
7020 * @return {string} [country]
7021 */
7022
7023 }, {
7024 key: "getCountry",
7025 value: function getCountry() {
7026 var digits = this.state.digits; // Return `undefined` if no digits have been input yet.
7027
7028 if (digits) {
7029 return this._getCountry();
7030 }
7031 }
7032 /**
7033 * Returns a two-letter country code of the phone number.
7034 * Returns `undefined` for "non-geographic" phone numbering plans.
7035 * @return {string} [country]
7036 */
7037
7038 }, {
7039 key: "_getCountry",
7040 value: function _getCountry() {
7041 var country = this.state.country;
7042
7043 return country;
7044 }
7045 }, {
7046 key: "determineTheCountryIfNeeded",
7047 value: function determineTheCountryIfNeeded() {
7048 // Suppose a user enters a phone number in international format,
7049 // and there're several countries corresponding to that country calling code,
7050 // and a country has been derived from the number, and then
7051 // a user enters one more digit and the number is no longer
7052 // valid for the derived country, so the country should be re-derived
7053 // on every new digit in those cases.
7054 //
7055 // If the phone number is being input in national format,
7056 // then it could be a case when `defaultCountry` wasn't specified
7057 // when creating `AsYouType` instance, and just `defaultCallingCode` was specified,
7058 // and that "calling code" could correspond to a "non-geographic entity",
7059 // or there could be several countries corresponding to that country calling code.
7060 // In those cases, `this.country` is `undefined` and should be derived
7061 // from the number. Again, if country calling code is ambiguous, then
7062 // `this.country` should be re-derived with each new digit.
7063 //
7064 if (!this.state.country || this.isCountryCallingCodeAmbiguous()) {
7065 this.determineTheCountry();
7066 }
7067 } // Prepends `+CountryCode ` in case of an international phone number
7068
7069 }, {
7070 key: "getFullNumber",
7071 value: function getFullNumber(formattedNationalNumber) {
7072 var _this2 = this;
7073
7074 if (this.isInternational()) {
7075 var prefix = function prefix(text) {
7076 return _this2.formatter.getInternationalPrefixBeforeCountryCallingCode(_this2.state, {
7077 spacing: text ? true : false
7078 }) + text;
7079 };
7080
7081 var callingCode = this.state.callingCode;
7082
7083 if (!callingCode) {
7084 return prefix("".concat(this.state.getDigitsWithoutInternationalPrefix()));
7085 }
7086
7087 if (!formattedNationalNumber) {
7088 return prefix(callingCode);
7089 }
7090
7091 return prefix("".concat(callingCode, " ").concat(formattedNationalNumber));
7092 }
7093
7094 return formattedNationalNumber;
7095 }
7096 }, {
7097 key: "getNonFormattedNationalNumberWithPrefix",
7098 value: function getNonFormattedNationalNumberWithPrefix() {
7099 var _this$state = this.state,
7100 nationalSignificantNumber = _this$state.nationalSignificantNumber,
7101 complexPrefixBeforeNationalSignificantNumber = _this$state.complexPrefixBeforeNationalSignificantNumber,
7102 nationalPrefix = _this$state.nationalPrefix;
7103 var number = nationalSignificantNumber;
7104 var prefix = complexPrefixBeforeNationalSignificantNumber || nationalPrefix;
7105
7106 if (prefix) {
7107 number = prefix + number;
7108 }
7109
7110 return number;
7111 }
7112 }, {
7113 key: "getNonFormattedNumber",
7114 value: function getNonFormattedNumber() {
7115 var nationalSignificantNumberMatchesInput = this.state.nationalSignificantNumberMatchesInput;
7116 return this.getFullNumber(nationalSignificantNumberMatchesInput ? this.getNonFormattedNationalNumberWithPrefix() : this.state.getNationalDigits());
7117 }
7118 }, {
7119 key: "getNonFormattedTemplate",
7120 value: function getNonFormattedTemplate() {
7121 var number = this.getNonFormattedNumber();
7122
7123 if (number) {
7124 return number.replace(/[\+\d]/g, DIGIT_PLACEHOLDER);
7125 }
7126 }
7127 }, {
7128 key: "isCountryCallingCodeAmbiguous",
7129 value: function isCountryCallingCodeAmbiguous() {
7130 var callingCode = this.state.callingCode;
7131 var countryCodes = this.metadata.getCountryCodesForCallingCode(callingCode);
7132 return countryCodes && countryCodes.length > 1;
7133 } // Determines the country of the phone number
7134 // entered so far based on the country phone code
7135 // and the national phone number.
7136
7137 }, {
7138 key: "determineTheCountry",
7139 value: function determineTheCountry() {
7140 this.state.setCountry(getCountryByCallingCode(this.isInternational() ? this.state.callingCode : this.defaultCallingCode, this.state.nationalSignificantNumber, this.metadata));
7141 }
7142 /**
7143 * Returns a E.164 phone number value for the user's input.
7144 *
7145 * For example, for country `"US"` and input `"(222) 333-4444"`
7146 * it will return `"+12223334444"`.
7147 *
7148 * For international phone number input, it will also auto-correct
7149 * some minor errors such as using a national prefix when writing
7150 * an international phone number. For example, if the user inputs
7151 * `"+44 0 7400 000000"` then it will return an auto-corrected
7152 * `"+447400000000"` phone number value.
7153 *
7154 * Will return `undefined` if no digits have been input,
7155 * or when inputting a phone number in national format and no
7156 * default country or default "country calling code" have been set.
7157 *
7158 * @return {string} [value]
7159 */
7160
7161 }, {
7162 key: "getNumberValue",
7163 value: function getNumberValue() {
7164 var _this$state2 = this.state,
7165 digits = _this$state2.digits,
7166 callingCode = _this$state2.callingCode,
7167 country = _this$state2.country,
7168 nationalSignificantNumber = _this$state2.nationalSignificantNumber; // Will return `undefined` if no digits have been input.
7169
7170 if (!digits) {
7171 return;
7172 }
7173
7174 if (this.isInternational()) {
7175 if (callingCode) {
7176 return '+' + callingCode + nationalSignificantNumber;
7177 } else {
7178 return '+' + digits;
7179 }
7180 } else {
7181 if (country || callingCode) {
7182 var callingCode_ = country ? this.metadata.countryCallingCode() : callingCode;
7183 return '+' + callingCode_ + nationalSignificantNumber;
7184 }
7185 }
7186 }
7187 /**
7188 * Returns an instance of `PhoneNumber` class.
7189 * Will return `undefined` if no national (significant) number
7190 * digits have been entered so far, or if no `defaultCountry` has been
7191 * set and the user enters a phone number not in international format.
7192 */
7193
7194 }, {
7195 key: "getNumber",
7196 value: function getNumber() {
7197 var _this$state3 = this.state,
7198 nationalSignificantNumber = _this$state3.nationalSignificantNumber,
7199 carrierCode = _this$state3.carrierCode,
7200 callingCode = _this$state3.callingCode; // `this._getCountry()` is basically same as `this.state.country`
7201 // with the only change that it return `undefined` in case of a
7202 // "non-geographic" numbering plan instead of `"001"` "internal use" value.
7203
7204 var country = this._getCountry();
7205
7206 if (!nationalSignificantNumber) {
7207 return;
7208 }
7209
7210 if (!country && !callingCode) {
7211 return;
7212 }
7213
7214 var phoneNumber = new PhoneNumber(country || callingCode, nationalSignificantNumber, this.metadata.metadata);
7215
7216 if (carrierCode) {
7217 phoneNumber.carrierCode = carrierCode;
7218 } // Phone number extensions are not supported by "As You Type" formatter.
7219
7220
7221 return phoneNumber;
7222 }
7223 /**
7224 * Returns `true` if the phone number is "possible".
7225 * Is just a shortcut for `PhoneNumber.isPossible()`.
7226 * @return {boolean}
7227 */
7228
7229 }, {
7230 key: "isPossible",
7231 value: function isPossible() {
7232 var phoneNumber = this.getNumber();
7233
7234 if (!phoneNumber) {
7235 return false;
7236 }
7237
7238 return phoneNumber.isPossible();
7239 }
7240 /**
7241 * Returns `true` if the phone number is "valid".
7242 * Is just a shortcut for `PhoneNumber.isValid()`.
7243 * @return {boolean}
7244 */
7245
7246 }, {
7247 key: "isValid",
7248 value: function isValid() {
7249 var phoneNumber = this.getNumber();
7250
7251 if (!phoneNumber) {
7252 return false;
7253 }
7254
7255 return phoneNumber.isValid();
7256 }
7257 /**
7258 * @deprecated
7259 * This method is used in `react-phone-number-input/source/input-control.js`
7260 * in versions before `3.0.16`.
7261 */
7262
7263 }, {
7264 key: "getNationalNumber",
7265 value: function getNationalNumber() {
7266 return this.state.nationalSignificantNumber;
7267 }
7268 /**
7269 * Returns the phone number characters entered by the user.
7270 * @return {string}
7271 */
7272
7273 }, {
7274 key: "getChars",
7275 value: function getChars() {
7276 return (this.state.international ? '+' : '') + this.state.digits;
7277 }
7278 /**
7279 * Returns the template for the formatted phone number.
7280 * @return {string}
7281 */
7282
7283 }, {
7284 key: "getTemplate",
7285 value: function getTemplate() {
7286 return this.formatter.getTemplate(this.state) || this.getNonFormattedTemplate() || '';
7287 }
7288 }]);
7289
7290 return AsYouType;
7291}();
7292
7293function parsePhoneNumberWithError() {
7294 return withMetadataArgument(parsePhoneNumberWithError$1, arguments)
7295}
7296
7297function isValidPhoneNumber() {
7298 return withMetadataArgument(isValidPhoneNumber$1, arguments)
7299}
7300
7301function isPossiblePhoneNumber() {
7302 return withMetadataArgument(isPossiblePhoneNumber$1, arguments)
7303}
7304
7305// Importing from a ".js" file is a workaround for Node.js "ES Modules"
7306// importing system which is even uncapable of importing "*.json" files.
7307
7308function AsYouType(country) {
7309 return AsYouType$1.call(this, country, metadata)
7310}
7311
7312AsYouType.prototype = Object.create(AsYouType$1.prototype, {});
7313AsYouType.prototype.constructor = AsYouType;
7314
7315const countries = [
7316 { name: "Afghanistan", dial_code: "+93", code: "AF", flag: "🇦🇫" },
7317 { name: "Åland Islands", dial_code: "+358", code: "AX", flag: "🇦🇽" },
7318 { name: "Albania", dial_code: "+355", code: "AL", flag: "🇦🇱" },
7319 { name: "Algeria", dial_code: "+213", code: "DZ", flag: "🇩🇿" },
7320 {
7321 name: "American Samoa",
7322 dial_code: "+1684",
7323 code: "AS",
7324 flag: "🇦🇸",
7325 },
7326 { name: "Andorra", dial_code: "+376", code: "AD", flag: "🇦🇩" },
7327 { name: "Angola", dial_code: "+244", code: "AO", flag: "🇦🇴" },
7328 { name: "Anguilla", dial_code: "+1264", code: "AI", flag: "🇦🇮" },
7329 { name: "Antarctica", dial_code: "+672", code: "AQ", flag: "🇦🇶" },
7330 {
7331 name: "Antigua and Barbuda",
7332 dial_code: "+1268",
7333 code: "AG",
7334 flag: "🇦🇬",
7335 },
7336 { name: "Argentina", dial_code: "+54", code: "AR", flag: "🇦🇷" },
7337 { name: "Armenia", dial_code: "+374", code: "AM", flag: "🇦🇲" },
7338 { name: "Aruba", dial_code: "+297", code: "AW", flag: "🇦🇼" },
7339 { name: "Australia", dial_code: "+61", code: "AU", flag: "🇦🇺" },
7340 { name: "Austria", dial_code: "+43", code: "AT", flag: "🇦🇹" },
7341 { name: "Azerbaijan", dial_code: "+994", code: "AZ", flag: "🇦🇿" },
7342 { name: "Bahamas", dial_code: "+1242", code: "BS", flag: "🇧🇸" },
7343 { name: "Bahrain", dial_code: "+973", code: "BH", flag: "🇧🇭" },
7344 { name: "Bangladesh", dial_code: "+880", code: "BD", flag: "🇧🇩" },
7345 { name: "Barbados", dial_code: "+1246", code: "BB", flag: "🇧🇧" },
7346 { name: "Belarus", dial_code: "+375", code: "BY", flag: "🇧🇾" },
7347 { name: "Belgium", dial_code: "+32", code: "BE", flag: "🇧🇪" },
7348 { name: "Belize", dial_code: "+501", code: "BZ", flag: "🇧🇿" },
7349 { name: "Benin", dial_code: "+229", code: "BJ", flag: "🇧🇯" },
7350 { name: "Bermuda", dial_code: "+1441", code: "BM", flag: "🇧🇲" },
7351 { name: "Bhutan", dial_code: "+975", code: "BT", flag: "🇧🇹" },
7352 {
7353 name: "Bolivia, Plurinational State of bolivia",
7354 dial_code: "+591",
7355 code: "BO",
7356 flag: "🇧🇴",
7357 },
7358 {
7359 name: "Bosnia and Herzegovina",
7360 dial_code: "+387",
7361 code: "BA",
7362 flag: "🇧🇦",
7363 },
7364 { name: "Botswana", dial_code: "+267", code: "BW", flag: "🇧🇼" },
7365 { name: "Bouvet Island", dial_code: "+47", code: "BV", flag: "🏳" },
7366 { name: "Brazil", dial_code: "+55", code: "BR", flag: "🇧🇷" },
7367 {
7368 name: "British Indian Ocean Territory",
7369 dial_code: "+246",
7370 code: "IO",
7371 flag: "🇮🇴",
7372 },
7373 {
7374 name: "Brunei Darussalam",
7375 dial_code: "+673",
7376 code: "BN",
7377 flag: "🇧🇳",
7378 },
7379 { name: "Bulgaria", dial_code: "+359", code: "BG", flag: "🇧🇬" },
7380 { name: "Burkina Faso", dial_code: "+226", code: "BF", flag: "🇧🇫" },
7381 { name: "Burundi", dial_code: "+257", code: "BI", flag: "🇧🇮" },
7382 { name: "Cambodia", dial_code: "+855", code: "KH", flag: "🇰🇭" },
7383 { name: "Cameroon", dial_code: "+237", code: "CM", flag: "🇨🇲" },
7384 { name: "Canada", dial_code: "+1", code: "CA", flag: "🇨🇦" },
7385 { name: "Cape Verde", dial_code: "+238", code: "CV", flag: "🇨🇻" },
7386 {
7387 name: "Cayman Islands",
7388 dial_code: "+ 345",
7389 code: "KY",
7390 flag: "🇰🇾",
7391 },
7392 {
7393 name: "Central African Republic",
7394 dial_code: "+236",
7395 code: "CF",
7396 flag: "🇨🇫",
7397 },
7398 { name: "Chad", dial_code: "+235", code: "TD", flag: "🇹🇩" },
7399 { name: "Chile", dial_code: "+56", code: "CL", flag: "🇨🇱" },
7400 { name: "China", dial_code: "+86", code: "CN", flag: "🇨🇳" },
7401 {
7402 name: "Christmas Island",
7403 dial_code: "+61",
7404 code: "CX",
7405 flag: "🇨🇽",
7406 },
7407 {
7408 name: "Cocos (Keeling) Islands",
7409 dial_code: "+61",
7410 code: "CC",
7411 flag: "🇨🇨",
7412 },
7413 { name: "Colombia", dial_code: "+57", code: "CO", flag: "🇨🇴" },
7414 { name: "Comoros", dial_code: "+269", code: "KM", flag: "🇰🇲" },
7415 { name: "Congo", dial_code: "+242", code: "CG", flag: "🇨🇬" },
7416 {
7417 name: "Congo, The Democratic Republic of the Congo",
7418 dial_code: "+243",
7419 code: "CD",
7420 flag: "🇨🇩",
7421 },
7422 { name: "Cook Islands", dial_code: "+682", code: "CK", flag: "🇨🇰" },
7423 { name: "Costa Rica", dial_code: "+506", code: "CR", flag: "🇨🇷" },
7424 { name: "Cote d'Ivoire", dial_code: "+225", code: "CI", flag: "🇨🇮" },
7425 { name: "Croatia", dial_code: "+385", code: "HR", flag: "🇭🇷" },
7426 { name: "Cuba", dial_code: "+53", code: "CU", flag: "🇨🇺" },
7427 { name: "Cyprus", dial_code: "+357", code: "CY", flag: "🇨🇾" },
7428 { name: "Czech Republic", dial_code: "+420", code: "CZ", flag: "🇨🇿" },
7429 { name: "Denmark", dial_code: "+45", code: "DK", flag: "🇩🇰" },
7430 { name: "Djibouti", dial_code: "+253", code: "DJ", flag: "🇩🇯" },
7431 { name: "Dominica", dial_code: "+1767", code: "DM", flag: "🇩🇲" },
7432 {
7433 name: "Dominican Republic",
7434 dial_code: "+1849",
7435 code: "DO",
7436 flag: "🇨🇩",
7437 },
7438 { name: "Ecuador", dial_code: "+593", code: "EC", flag: "🇪🇨" },
7439 { name: "Egypt", dial_code: "+20", code: "EG", flag: "🇪🇬" },
7440 { name: "El Salvador", dial_code: "+503", code: "SV", flag: "🇸🇻" },
7441 {
7442 name: "Equatorial Guinea",
7443 dial_code: "+240",
7444 code: "GQ",
7445 flag: "🇬🇶",
7446 },
7447 { name: "Eritrea", dial_code: "+291", code: "ER", flag: "🇪🇷" },
7448 { name: "Estonia", dial_code: "+372", code: "EE", flag: "🇪🇪" },
7449 { name: "Ethiopia", dial_code: "+251", code: "ET", flag: "🇪🇹" },
7450 {
7451 name: "Falkland Islands (Malvinas)",
7452 dial_code: "+500",
7453 code: "FK",
7454 flag: "🇫🇰",
7455 },
7456 { name: "Faroe Islands", dial_code: "+298", code: "FO", flag: "🇫🇴" },
7457 { name: "Fiji", dial_code: "+679", code: "FJ", flag: "🇫🇯" },
7458 { name: "Finland", dial_code: "+358", code: "FI", flag: "🇫🇮" },
7459 { name: "France", dial_code: "+33", code: "FR", flag: "🇫🇷" },
7460 { name: "French Guiana", dial_code: "+594", code: "GF", flag: "🇬🇫" },
7461 {
7462 name: "French Polynesia",
7463 dial_code: "+689",
7464 code: "PF",
7465 flag: "🇵🇫",
7466 },
7467 {
7468 name: "French Southern Territories",
7469 dial_code: "+262",
7470 code: "TF",
7471 flag: "🇹🇫",
7472 },
7473 { name: "Gabon", dial_code: "+241", code: "GA", flag: "🇬🇦" },
7474 { name: "Gambia", dial_code: "+220", code: "GM", flag: "🇬🇲" },
7475 { name: "Georgia", dial_code: "+995", code: "GE", flag: "🇬🇪" },
7476 { name: "Germany", dial_code: "+49", code: "DE", flag: "🇩🇪" },
7477 { name: "Ghana", dial_code: "+233", code: "GH", flag: "🇬🇭" },
7478 { name: "Gibraltar", dial_code: "+350", code: "GI", flag: "🇬🇮" },
7479 { name: "Greece", dial_code: "+30", code: "GR", flag: "🇬🇷" },
7480 { name: "Greenland", dial_code: "+299", code: "GL", flag: "🇬🇱" },
7481 { name: "Grenada", dial_code: "+1473", code: "GD", flag: "🇬🇩" },
7482 { name: "Guadeloupe", dial_code: "+590", code: "GP", flag: "🇬🇵" },
7483 { name: "Guam", dial_code: "+1671", code: "GU", flag: "🇬🇺" },
7484 { name: "Guatemala", dial_code: "+502", code: "GT", flag: "🇬🇹" },
7485 { name: "Guernsey", dial_code: "+44", code: "GG", flag: "🇬🇬" },
7486 { name: "Guinea", dial_code: "+224", code: "GN", flag: "🇬🇳" },
7487 { name: "Guinea-Bissau", dial_code: "+245", code: "GW", flag: "🇬🇼" },
7488 { name: "Guyana", dial_code: "+592", code: "GY", flag: "🇬🇾" },
7489 { name: "Haiti", dial_code: "+509", code: "HT", flag: "🇭🇹" },
7490 {
7491 name: "Heard Island and Mcdonald Islands",
7492 dial_code: "+0",
7493 code: "HM",
7494 flag: "🏳",
7495 },
7496 {
7497 name: "Holy See (Vatican City State)",
7498 dial_code: "+379",
7499 code: "VA",
7500 flag: "🇻🇦",
7501 },
7502 { name: "Honduras", dial_code: "+504", code: "HN", flag: "🇭🇳" },
7503 { name: "Hong Kong", dial_code: "+852", code: "HK", flag: "🇭🇰" },
7504 { name: "Hungary", dial_code: "+36", code: "HU", flag: "🇭🇺" },
7505 { name: "Iceland", dial_code: "+354", code: "IS", flag: "🇮🇸" },
7506 { name: "India", dial_code: "+91", code: "IN", flag: "🇮🇳" },
7507 { name: "Indonesia", dial_code: "+62", code: "ID", flag: "🇮🇩" },
7508 {
7509 name: "Iran, Islamic Republic of Persian Gulf",
7510 dial_code: "+98",
7511 code: "IR",
7512 flag: "🇮🇷",
7513 },
7514 { name: "Iraq", dial_code: "+964", code: "IQ", flag: "🇮🇶" },
7515 { name: "Ireland", dial_code: "+353", code: "IE", flag: "🇮🇪" },
7516 { name: "Isle of Man", dial_code: "+44", code: "IM", flag: "🇮🇲" },
7517 { name: "Israel", dial_code: "+972", code: "IL", flag: "🇮🇱" },
7518 { name: "Italy", dial_code: "+39", code: "IT", flag: "🇮🇹" },
7519 { name: "Jamaica", dial_code: "+1876", code: "JM", flag: "🇯🇲" },
7520 { name: "Japan", dial_code: "+81", code: "JP", flag: "🇯🇵" },
7521 { name: "Jersey", dial_code: "+44", code: "JE", flag: "🇯🇪" },
7522 { name: "Jordan", dial_code: "+962", code: "JO", flag: "🇯🇴" },
7523 { name: "Kazakhstan", dial_code: "+7", code: "KZ", flag: "🇰🇿" },
7524 { name: "Kenya", dial_code: "+254", code: "KE", flag: "🇰🇪" },
7525 { name: "Kiribati", dial_code: "+686", code: "KI", flag: "🇰🇮" },
7526 {
7527 name: "Korea, Democratic People's Republic of Korea",
7528 dial_code: "+850",
7529 code: "KP",
7530 flag: "🇰🇵",
7531 },
7532 {
7533 name: "Korea, Republic of South Korea",
7534 dial_code: "+82",
7535 code: "KR",
7536 flag: "🇰🇷",
7537 },
7538 { name: "Kosovo", dial_code: "+383", code: "XK", flag: "🇽🇰" },
7539 { name: "Kuwait", dial_code: "+965", code: "KW", flag: "🇰🇼" },
7540 { name: "Kyrgyzstan", dial_code: "+996", code: "KG", flag: "🇰🇬" },
7541 { name: "Laos", dial_code: "+856", code: "LA", flag: "🇱🇦" },
7542 { name: "Latvia", dial_code: "+371", code: "LV", flag: "🇱🇻" },
7543 { name: "Lebanon", dial_code: "+961", code: "LB", flag: "🇱🇧" },
7544 { name: "Lesotho", dial_code: "+266", code: "LS", flag: "🇱🇸" },
7545 { name: "Liberia", dial_code: "+231", code: "LR", flag: "🇱🇷" },
7546 {
7547 name: "Libyan Arab Jamahiriya",
7548 dial_code: "+218",
7549 code: "LY",
7550 flag: "🇱🇾",
7551 },
7552 { name: "Liechtenstein", dial_code: "+423", code: "LI", flag: "🇱🇮" },
7553 { name: "Lithuania", dial_code: "+370", code: "LT", flag: "🇱🇹" },
7554 { name: "Luxembourg", dial_code: "+352", code: "LU", flag: "🇱🇺" },
7555 { name: "Macao", dial_code: "+853", code: "MO", flag: "🇲🇴" },
7556 { name: "Macedonia", dial_code: "+389", code: "MK", flag: "🇲🇰" },
7557 { name: "Madagascar", dial_code: "+261", code: "MG", flag: "🇲🇬" },
7558 { name: "Malawi", dial_code: "+265", code: "MW", flag: "🇲🇼" },
7559 { name: "Malaysia", dial_code: "+60", code: "MY", flag: "🇲🇾" },
7560 { name: "Maldives", dial_code: "+960", code: "MV", flag: "🇲🇻" },
7561 { name: "Mali", dial_code: "+223", code: "ML", flag: "🇲🇱" },
7562 { name: "Malta", dial_code: "+356", code: "MT", flag: "🇲🇹" },
7563 {
7564 name: "Marshall Islands",
7565 dial_code: "+692",
7566 code: "MH",
7567 flag: "🇲🇭",
7568 },
7569 { name: "Martinique", dial_code: "+596", code: "MQ", flag: "🇲🇶" },
7570 { name: "Mauritania", dial_code: "+222", code: "MR", flag: "🇲🇷" },
7571 { name: "Mauritius", dial_code: "+230", code: "MU", flag: "🇲🇺" },
7572 { name: "Mayotte", dial_code: "+262", code: "YT", flag: "🇾🇹" },
7573 { name: "Mexico", dial_code: "+52", code: "MX", flag: "🇲🇽" },
7574 {
7575 name: "Micronesia, Federated States of Micronesia",
7576 dial_code: "+691",
7577 code: "FM",
7578 flag: "🇫🇲",
7579 },
7580 { name: "Moldova", dial_code: "+373", code: "MD", flag: "🇲🇩" },
7581 { name: "Monaco", dial_code: "+377", code: "MC", flag: "🇲🇨" },
7582 { name: "Mongolia", dial_code: "+976", code: "MN", flag: "🇲🇳" },
7583 { name: "Montenegro", dial_code: "+382", code: "ME", flag: "🇲🇪" },
7584 { name: "Montserrat", dial_code: "+1664", code: "MS", flag: "🇲🇸" },
7585 { name: "Morocco", dial_code: "+212", code: "MA", flag: "🇲🇦" },
7586 { name: "Mozambique", dial_code: "+258", code: "MZ", flag: "🇲🇿" },
7587 { name: "Myanmar", dial_code: "+95", code: "MM", flag: "🇲🇲" },
7588 { name: "Namibia", dial_code: "+264", code: "NA", flag: "🇳🇦" },
7589 { name: "Nauru", dial_code: "+674", code: "NR", flag: "🇳🇷" },
7590 { name: "Nepal", dial_code: "+977", code: "NP", flag: "🇳🇵" },
7591 { name: "Netherlands", dial_code: "+31", code: "NL", flag: "🇳🇱" },
7592 {
7593 name: "Netherlands Antilles",
7594 dial_code: "+599",
7595 code: "AN",
7596 flag: "🇳🇱",
7597 },
7598 { name: "New Caledonia", dial_code: "+687", code: "NC", flag: "🇳🇨" },
7599 { name: "New Zealand", dial_code: "+64", code: "NZ", flag: "🇳🇿" },
7600 { name: "Nicaragua", dial_code: "+505", code: "NI", flag: "🇳🇮" },
7601 { name: "Niger", dial_code: "+227", code: "NE", flag: "🇳🇪" },
7602 { name: "Nigeria", dial_code: "+234", code: "NG", flag: "🇳🇬" },
7603 { name: "Niue", dial_code: "+683", code: "NU", flag: "🇳🇺" },
7604 { name: "Norfolk Island", dial_code: "+672", code: "NF", flag: "🇳🇫" },
7605 {
7606 name: "Northern Mariana Islands",
7607 dial_code: "+1670",
7608 code: "MP",
7609 flag: "🏳",
7610 },
7611 { name: "Norway", dial_code: "+47", code: "NO", flag: "🇳🇴" },
7612 { name: "Oman", dial_code: "+968", code: "OM", flag: "🇴🇲" },
7613 { name: "Pakistan", dial_code: "+92", code: "PK", flag: "🇵🇰" },
7614 { name: "Palau", dial_code: "+680", code: "PW", flag: "🇵🇼" },
7615 {
7616 name: "Palestinian Territory, Occupied",
7617 dial_code: "+970",
7618 code: "PS",
7619 flag: "🇵🇸",
7620 },
7621 { name: "Panama", dial_code: "+507", code: "PA", flag: "🇵🇦" },
7622 {
7623 name: "Papua New Guinea",
7624 dial_code: "+675",
7625 code: "PG",
7626 flag: "🇵🇬",
7627 },
7628 { name: "Paraguay", dial_code: "+595", code: "PY", flag: "🇵🇾" },
7629 { name: "Peru", dial_code: "+51", code: "PE", flag: "🇵🇪" },
7630 { name: "Philippines", dial_code: "+63", code: "PH", flag: "🇵🇭" },
7631 { name: "Pitcairn", dial_code: "+64", code: "PN", flag: "🇵🇳" },
7632 { name: "Poland", dial_code: "+48", code: "PL", flag: "🇵🇱" },
7633 { name: "Portugal", dial_code: "+351", code: "PT", flag: "🇵🇹" },
7634 { name: "Puerto Rico", dial_code: "+1939", code: "PR", flag: "🇵🇷" },
7635 { name: "Qatar", dial_code: "+974", code: "QA", flag: "🇶🇦" },
7636 { name: "Romania", dial_code: "+40", code: "RO", flag: "🇷🇴" },
7637 { name: "Russia", dial_code: "+7", code: "RU", flag: "🇷🇺" },
7638 { name: "Rwanda", dial_code: "+250", code: "RW", flag: "🇷🇼" },
7639 { name: "Reunion", dial_code: "+262", code: "RE", flag: "🇫🇷" },
7640 {
7641 name: "Saint Barthelemy",
7642 dial_code: "+590",
7643 code: "BL",
7644 flag: "🇧🇱",
7645 },
7646 {
7647 name: "Saint Helena, Ascension and Tristan Da Cunha",
7648 dial_code: "+290",
7649 code: "SH",
7650 flag: "🇸🇭",
7651 },
7652 {
7653 name: "Saint Kitts and Nevis",
7654 dial_code: "+1869",
7655 code: "KN",
7656 flag: "🇰🇳",
7657 },
7658 { name: "Saint Lucia", dial_code: "+1758", code: "LC", flag: "🇱🇨" },
7659 { name: "Saint Martin", dial_code: "+590", code: "MF", flag: "🏳" },
7660 {
7661 name: "Saint Pierre and Miquelon",
7662 dial_code: "+508",
7663 code: "PM",
7664 flag: "🇵🇲",
7665 },
7666 {
7667 name: "Saint Vincent and the Grenadines",
7668 dial_code: "+1784",
7669 code: "VC",
7670 flag: "🇻🇨",
7671 },
7672 { name: "Samoa", dial_code: "+685", code: "WS", flag: "🇼🇸" },
7673 { name: "San Marino", dial_code: "+378", code: "SM", flag: "🇸🇲" },
7674 {
7675 name: "Sao Tome and Principe",
7676 dial_code: "+239",
7677 code: "ST",
7678 flag: "🇸🇹",
7679 },
7680 { name: "Saudi Arabia", dial_code: "+966", code: "SA", flag: "🇸🇦" },
7681 { name: "Senegal", dial_code: "+221", code: "SN", flag: "🇸🇳" },
7682 { name: "Serbia", dial_code: "+381", code: "RS", flag: "🇷🇸" },
7683 { name: "Seychelles", dial_code: "+248", code: "SC", flag: "🇸🇨" },
7684 { name: "Sierra Leone", dial_code: "+232", code: "SL", flag: "🇸🇱" },
7685 { name: "Singapore", dial_code: "+65", code: "SG", flag: "🇸🇬" },
7686 { name: "Slovakia", dial_code: "+421", code: "SK", flag: "🇸🇰" },
7687 { name: "Slovenia", dial_code: "+386", code: "SI", flag: "🇸🇮" },
7688 {
7689 name: "Solomon Islands",
7690 dial_code: "+677",
7691 code: "SB",
7692 flag: "🇸🇧",
7693 },
7694 { name: "Somalia", dial_code: "+252", code: "SO", flag: "🇸🇴" },
7695 { name: "South Africa", dial_code: "+27", code: "ZA", flag: "🇿🇦" },
7696 { name: "South Sudan", dial_code: "+211", code: "SS", flag: "🇸🇸" },
7697 {
7698 name: "South Georgia and the South Sandwich Islands",
7699 dial_code: "+500",
7700 code: "GS",
7701 flag: "🇬🇸",
7702 },
7703 { name: "Spain", dial_code: "+34", code: "ES", flag: "🇪🇸" },
7704 { name: "Sri Lanka", dial_code: "+94", code: "LK", flag: "🇱🇰" },
7705 { name: "Sudan", dial_code: "+249", code: "SD", flag: "🇸🇩" },
7706 { name: "Suriname", dial_code: "+597", code: "SR", flag: "🇸🇷" },
7707 {
7708 name: "Svalbard and Jan Mayen",
7709 dial_code: "+47",
7710 code: "SJ",
7711 flag: "🇩🇰",
7712 },
7713 { name: "Swaziland", dial_code: "+268", code: "SZ", flag: "🇸🇿" },
7714 { name: "Sweden", dial_code: "+46", code: "SE", flag: "🇸🇪" },
7715 { name: "Switzerland", dial_code: "+41", code: "CH", flag: "🇨🇭" },
7716 {
7717 name: "Syrian Arab Republic",
7718 dial_code: "+963",
7719 code: "SY",
7720 flag: "🇸🇾",
7721 },
7722 { name: "Taiwan", dial_code: "+886", code: "TW", flag: "🇹🇼" },
7723 { name: "Tajikistan", dial_code: "+992", code: "TJ", flag: "🇹🇯" },
7724 {
7725 name: "Tanzania, United Republic of Tanzania",
7726 dial_code: "+255",
7727 code: "TZ",
7728 flag: "🇹🇿",
7729 },
7730 { name: "Thailand", dial_code: "+66", code: "TH", flag: "🇹🇭" },
7731 { name: "Timor-Leste", dial_code: "+670", code: "TL", flag: "🇹🇱" },
7732 { name: "Togo", dial_code: "+228", code: "TG", flag: "🇹🇬" },
7733 { name: "Tokelau", dial_code: "+690", code: "TK", flag: "🇹🇰" },
7734 { name: "Tonga", dial_code: "+676", code: "TO", flag: "🇹🇴" },
7735 {
7736 name: "Trinidad and Tobago",
7737 dial_code: "+1868",
7738 code: "TT",
7739 flag: "🇹🇹",
7740 },
7741 { name: "Tunisia", dial_code: "+216", code: "TN", flag: "🇹🇳" },
7742 { name: "Turkey", dial_code: "+90", code: "TR", flag: "🇹🇷" },
7743 { name: "Turkmenistan", dial_code: "+993", code: "TM", flag: "🇹🇲" },
7744 {
7745 name: "Turks and Caicos Islands",
7746 dial_code: "+1649",
7747 code: "TC",
7748 flag: "🇹🇨",
7749 },
7750 { name: "Tuvalu", dial_code: "+688", code: "TV", flag: "🇹🇻" },
7751 { name: "Uganda", dial_code: "+256", code: "UG", flag: "🇺🇬" },
7752 { name: "Ukraine", dial_code: "+380", code: "UA", flag: "🇺🇦" },
7753 {
7754 name: "United Arab Emirates",
7755 dial_code: "+971",
7756 code: "AE",
7757 flag: "🇦🇪",
7758 },
7759 { name: "United Kingdom", dial_code: "+44", code: "GB", flag: "🇬🇧" },
7760 { name: "United States", dial_code: "+1", code: "US", flag: "🇺🇸" },
7761 { name: "Uruguay", dial_code: "+598", code: "UY", flag: "🇺🇾" },
7762 { name: "Uzbekistan", dial_code: "+998", code: "UZ", flag: "🇺🇿" },
7763 { name: "Vanuatu", dial_code: "+678", code: "VU", flag: "🇻🇺" },
7764 {
7765 name: "Venezuela, Bolivarian Republic of Venezuela",
7766 dial_code: "+58",
7767 code: "VE",
7768 flag: "🇻🇪",
7769 },
7770 { name: "Vietnam", dial_code: "+84", code: "VN", flag: "🇻🇳" },
7771 {
7772 name: "Virgin Islands, British",
7773 dial_code: "+1284",
7774 code: "VG",
7775 flag: "🇻🇬",
7776 },
7777 {
7778 name: "Virgin Islands, U.S.",
7779 dial_code: "+1340",
7780 code: "VI",
7781 flag: "🇻🇮",
7782 },
7783 {
7784 name: "Wallis and Futuna",
7785 dial_code: "+681",
7786 code: "WF",
7787 flag: "🇼🇫",
7788 },
7789 { name: "Yemen", dial_code: "+967", code: "YE", flag: "🇾🇪" },
7790 { name: "Zambia", dial_code: "+260", code: "ZM", flag: "🇿🇲" },
7791 { name: "Zimbabwe", dial_code: "+263", code: "ZW", flag: "🇿🇼" },
7792];
7793
7794const timezoneCityToCountry = {
7795 Andorra: "Andorra",
7796 Dubai: "United Arab Emirates",
7797 Kabul: "Afghanistan",
7798 Tirane: "Albania",
7799 Yerevan: "Armenia",
7800 Casey: "Antarctica",
7801 Davis: "Antarctica",
7802 Mawson: "Antarctica",
7803 Palmer: "Antarctica",
7804 Rothera: "Antarctica",
7805 Troll: "Antarctica",
7806 Vostok: "Antarctica",
7807 Buenos_Aires: "Argentina",
7808 Cordoba: "Argentina",
7809 Salta: "Argentina",
7810 Jujuy: "Argentina",
7811 Tucuman: "Argentina",
7812 Catamarca: "Argentina",
7813 La_Rioja: "Argentina",
7814 San_Juan: "Argentina",
7815 Mendoza: "Argentina",
7816 San_Luis: "Argentina",
7817 Rio_Gallegos: "Argentina",
7818 Ushuaia: "Argentina",
7819 Pago_Pago: "Samoa (American)",
7820 Vienna: "Austria",
7821 Lord_Howe: "Australia",
7822 Macquarie: "Australia",
7823 Hobart: "Australia",
7824 Melbourne: "Australia",
7825 Sydney: "Australia",
7826 Broken_Hill: "Australia",
7827 Brisbane: "Australia",
7828 Lindeman: "Australia",
7829 Adelaide: "Australia",
7830 Darwin: "Australia",
7831 Perth: "Australia",
7832 Eucla: "Australia",
7833 Baku: "Azerbaijan",
7834 Barbados: "Barbados",
7835 Dhaka: "Bangladesh",
7836 Brussels: "Belgium",
7837 Sofia: "Bulgaria",
7838 Bermuda: "Bermuda",
7839 Brunei: "Brunei",
7840 La_Paz: "Bolivia",
7841 Noronha: "Brazil",
7842 Belem: "Brazil",
7843 Fortaleza: "Brazil",
7844 Recife: "Brazil",
7845 Araguaina: "Brazil",
7846 Maceio: "Brazil",
7847 Bahia: "Brazil",
7848 Sao_Paulo: "Brazil",
7849 Campo_Grande: "Brazil",
7850 Cuiaba: "Brazil",
7851 Santarem: "Brazil",
7852 Porto_Velho: "Brazil",
7853 Boa_Vista: "Brazil",
7854 Manaus: "Brazil",
7855 Eirunepe: "Brazil",
7856 Rio_Branco: "Brazil",
7857 Thimphu: "Bhutan",
7858 Minsk: "Belarus",
7859 Belize: "Belize",
7860 St_Johns: "Canada",
7861 Halifax: "Canada",
7862 Glace_Bay: "Canada",
7863 Moncton: "Canada",
7864 Goose_Bay: "Canada",
7865 Toronto: "Canada",
7866 Nipigon: "Canada",
7867 Thunder_Bay: "Canada",
7868 Iqaluit: "Canada",
7869 Pangnirtung: "Canada",
7870 Winnipeg: "Canada",
7871 Rainy_River: "Canada",
7872 Resolute: "Canada",
7873 Rankin_Inlet: "Canada",
7874 Regina: "Canada",
7875 Swift_Current: "Canada",
7876 Edmonton: "Canada",
7877 Cambridge_Bay: "Canada",
7878 Yellowknife: "Canada",
7879 Inuvik: "Canada",
7880 Dawson_Creek: "Canada",
7881 Fort_Nelson: "Canada",
7882 Whitehorse: "Canada",
7883 Dawson: "Canada",
7884 Vancouver: "Canada",
7885 Cocos: "Cocos (Keeling) Islands",
7886 Zurich: "Switzerland",
7887 Abidjan: "Côte d'Ivoire",
7888 Rarotonga: "Cook Islands",
7889 Santiago: "Chile",
7890 Punta_Arenas: "Chile",
7891 Easter: "Chile",
7892 Shanghai: "China",
7893 Urumqi: "China",
7894 Bogota: "Colombia",
7895 Costa_Rica: "Costa Rica",
7896 Havana: "Cuba",
7897 Cape_Verde: "Cape Verde",
7898 Christmas: "Christmas Island",
7899 Nicosia: "Cyprus",
7900 Famagusta: "Cyprus",
7901 Prague: "Czech Republic",
7902 Berlin: "Germany",
7903 Copenhagen: "Denmark",
7904 Santo_Domingo: "Dominican Republic",
7905 Algiers: "Algeria",
7906 Guayaquil: "Ecuador",
7907 Galapagos: "Ecuador",
7908 Tallinn: "Estonia",
7909 Cairo: "Egypt",
7910 El_Aaiun: "Western Sahara",
7911 Madrid: "Spain",
7912 Ceuta: "Spain",
7913 Canary: "Spain",
7914 Helsinki: "Finland",
7915 Fiji: "Fiji",
7916 Stanley: "Falkland Islands",
7917 Chuuk: "Micronesia",
7918 Pohnpei: "Micronesia",
7919 Kosrae: "Micronesia",
7920 Faroe: "Faroe Islands",
7921 Paris: "France",
7922 London: "Britain (UK)",
7923 Tbilisi: "Georgia",
7924 Cayenne: "French Guiana",
7925 Gibraltar: "Gibraltar",
7926 Nuuk: "Greenland",
7927 Danmarkshavn: "Greenland",
7928 Scoresbysund: "Greenland",
7929 Thule: "Greenland",
7930 Athens: "Greece",
7931 South_Georgia: "South Georgia & the South Sandwich Islands",
7932 Guatemala: "Guatemala",
7933 Guam: "Guam",
7934 Bissau: "Guinea-Bissau",
7935 Guyana: "Guyana",
7936 Hong_Kong: "Hong Kong",
7937 Tegucigalpa: "Honduras",
7938 "Port-au-Prince": "Haiti",
7939 Budapest: "Hungary",
7940 Jakarta: "Indonesia",
7941 Pontianak: "Indonesia",
7942 Makassar: "Indonesia",
7943 Jayapura: "Indonesia",
7944 Dublin: "Ireland",
7945 Jerusalem: "Israel",
7946 Kolkata: "India",
7947 Calcutta: "India",
7948 Chagos: "British Indian Ocean Territory",
7949 Baghdad: "Iraq",
7950 Tehran: "Iran",
7951 Reykjavik: "Iceland",
7952 Rome: "Italy",
7953 Jamaica: "Jamaica",
7954 Amman: "Jordan",
7955 Tokyo: "Japan",
7956 Nairobi: "Kenya",
7957 Bishkek: "Kyrgyzstan",
7958 Tarawa: "Kiribati",
7959 Kanton: "Kiribati",
7960 Kiritimati: "Kiribati",
7961 Pyongyang: "Korea (North)",
7962 Seoul: "Korea (South)",
7963 Almaty: "Kazakhstan",
7964 Qyzylorda: "Kazakhstan",
7965 Qostanay: "Kazakhstan",
7966 Aqtobe: "Kazakhstan",
7967 Aqtau: "Kazakhstan",
7968 Atyrau: "Kazakhstan",
7969 Oral: "Kazakhstan",
7970 Beirut: "Lebanon",
7971 Colombo: "Sri Lanka",
7972 Monrovia: "Liberia",
7973 Vilnius: "Lithuania",
7974 Luxembourg: "Luxembourg",
7975 Riga: "Latvia",
7976 Tripoli: "Libya",
7977 Casablanca: "Morocco",
7978 Monaco: "Monaco",
7979 Chisinau: "Moldova",
7980 Majuro: "Marshall Islands",
7981 Kwajalein: "Marshall Islands",
7982 Yangon: "Myanmar (Burma)",
7983 Ulaanbaatar: "Mongolia",
7984 Hovd: "Mongolia",
7985 Choibalsan: "Mongolia",
7986 Macau: "Macau",
7987 Martinique: "Martinique",
7988 Malta: "Malta",
7989 Mauritius: "Mauritius",
7990 Maldives: "Maldives",
7991 Mexico_City: "Mexico",
7992 Cancun: "Mexico",
7993 Merida: "Mexico",
7994 Monterrey: "Mexico",
7995 Matamoros: "Mexico",
7996 Mazatlan: "Mexico",
7997 Chihuahua: "Mexico",
7998 Ojinaga: "Mexico",
7999 Hermosillo: "Mexico",
8000 Tijuana: "Mexico",
8001 Bahia_Banderas: "Mexico",
8002 Kuala_Lumpur: "Malaysia",
8003 Kuching: "Malaysia",
8004 Maputo: "Mozambique",
8005 Windhoek: "Namibia",
8006 Noumea: "New Caledonia",
8007 Norfolk: "Norfolk Island",
8008 Lagos: "Nigeria",
8009 Managua: "Nicaragua",
8010 Amsterdam: "Netherlands",
8011 Oslo: "Norway",
8012 Kathmandu: "Nepal",
8013 Nauru: "Nauru",
8014 Niue: "Niue",
8015 Auckland: "New Zealand",
8016 Chatham: "New Zealand",
8017 Panama: "Panama",
8018 Lima: "Peru",
8019 Tahiti: "French Polynesia",
8020 Marquesas: "French Polynesia",
8021 Gambier: "French Polynesia",
8022 Port_Moresby: "Papua New Guinea",
8023 Bougainville: "Papua New Guinea",
8024 Manila: "Philippines",
8025 Karachi: "Pakistan",
8026 Warsaw: "Poland",
8027 Miquelon: "St Pierre & Miquelon",
8028 Pitcairn: "Pitcairn",
8029 Puerto_Rico: "Puerto Rico",
8030 Gaza: "Palestine",
8031 Hebron: "Palestine",
8032 Lisbon: "Portugal",
8033 Madeira: "Portugal",
8034 Azores: "Portugal",
8035 Palau: "Palau",
8036 Asuncion: "Paraguay",
8037 Qatar: "Qatar",
8038 Reunion: "Réunion",
8039 Bucharest: "Romania",
8040 Belgrade: "Serbia",
8041 Kaliningrad: "Russia",
8042 Moscow: "Russia",
8043 Simferopol: "Russia",
8044 Kirov: "Russia",
8045 Volgograd: "Russia",
8046 Astrakhan: "Russia",
8047 Saratov: "Russia",
8048 Ulyanovsk: "Russia",
8049 Samara: "Russia",
8050 Yekaterinburg: "Russia",
8051 Omsk: "Russia",
8052 Novosibirsk: "Russia",
8053 Barnaul: "Russia",
8054 Tomsk: "Russia",
8055 Novokuznetsk: "Russia",
8056 Krasnoyarsk: "Russia",
8057 Irkutsk: "Russia",
8058 Chita: "Russia",
8059 Yakutsk: "Russia",
8060 Khandyga: "Russia",
8061 Vladivostok: "Russia",
8062 "Ust-Nera": "Russia",
8063 Magadan: "Russia",
8064 Sakhalin: "Russia",
8065 Srednekolymsk: "Russia",
8066 Kamchatka: "Russia",
8067 Anadyr: "Russia",
8068 Riyadh: "Saudi Arabia",
8069 Guadalcanal: "Solomon Islands",
8070 Mahe: "Seychelles",
8071 Khartoum: "Sudan",
8072 Stockholm: "Sweden",
8073 Singapore: "Singapore",
8074 Paramaribo: "Suriname",
8075 Juba: "South Sudan",
8076 Sao_Tome: "Sao Tome & Principe",
8077 El_Salvador: "El Salvador",
8078 Damascus: "Syria",
8079 Grand_Turk: "Turks & Caicos Is",
8080 Ndjamena: "Chad",
8081 Kerguelen: "French Southern & Antarctic Lands",
8082 Bangkok: "Thailand",
8083 Dushanbe: "Tajikistan",
8084 Fakaofo: "Tokelau",
8085 Dili: "East Timor",
8086 Ashgabat: "Turkmenistan",
8087 Tunis: "Tunisia",
8088 Tongatapu: "Tonga",
8089 Istanbul: "Turkey",
8090 Funafuti: "Tuvalu",
8091 Taipei: "Taiwan",
8092 Kiev: "Ukraine",
8093 Uzhgorod: "Ukraine",
8094 Zaporozhye: "Ukraine",
8095 Wake: "US minor outlying islands",
8096 New_York: "United States",
8097 Detroit: "United States",
8098 Louisville: "United States",
8099 Monticello: "United States",
8100 Indianapolis: "United States",
8101 Vincennes: "United States",
8102 Winamac: "United States",
8103 Marengo: "United States",
8104 Petersburg: "United States",
8105 Vevay: "United States",
8106 Chicago: "United States",
8107 Tell_City: "United States",
8108 Knox: "United States",
8109 Menominee: "United States",
8110 Center: "United States",
8111 New_Salem: "United States",
8112 Beulah: "United States",
8113 Denver: "United States",
8114 Boise: "United States",
8115 Phoenix: "United States",
8116 Los_Angeles: "United States",
8117 Anchorage: "United States",
8118 Juneau: "United States",
8119 Sitka: "United States",
8120 Metlakatla: "United States",
8121 Yakutat: "United States",
8122 Nome: "United States",
8123 Adak: "United States",
8124 Honolulu: "United States",
8125 Montevideo: "Uruguay",
8126 Samarkand: "Uzbekistan",
8127 Tashkent: "Uzbekistan",
8128 Caracas: "Venezuela",
8129 Ho_Chi_Minh: "Vietnam",
8130 Efate: "Vanuatu",
8131 Wallis: "Wallis & Futuna",
8132 Apia: "Samoa (western)",
8133 Johannesburg: "South Africa",
8134 Antigua: "Antigua & Barbuda",
8135 Anguilla: "Anguilla",
8136 Luanda: "Angola",
8137 McMurdo: "Antarctica",
8138 DumontDUrville: "Antarctica",
8139 Syowa: "Antarctica",
8140 Aruba: "Aruba",
8141 Mariehamn: "Åland Islands",
8142 Sarajevo: "Bosnia & Herzegovina",
8143 Ouagadougou: "Burkina Faso",
8144 Bahrain: "Bahrain",
8145 Bujumbura: "Burundi",
8146 "Porto-Novo": "Benin",
8147 St_Barthelemy: "St Barthelemy",
8148 Kralendijk: "Caribbean NL",
8149 Nassau: "Bahamas",
8150 Gaborone: "Botswana",
8151 "Blanc-Sablon": "Canada",
8152 Atikokan: "Canada",
8153 Creston: "Canada",
8154 Kinshasa: "Congo (Dem. Rep.)",
8155 Lubumbashi: "Congo (Dem. Rep.)",
8156 Bangui: "Central African Rep.",
8157 Brazzaville: "Congo (Rep.)",
8158 Douala: "Cameroon",
8159 Curacao: "Curaçao",
8160 Busingen: "Germany",
8161 Djibouti: "Djibouti",
8162 Dominica: "Dominica",
8163 Asmara: "Eritrea",
8164 Addis_Ababa: "Ethiopia",
8165 Libreville: "Gabon",
8166 Grenada: "Grenada",
8167 Guernsey: "Guernsey",
8168 Accra: "Ghana",
8169 Banjul: "Gambia",
8170 Conakry: "Guinea",
8171 Guadeloupe: "Guadeloupe",
8172 Malabo: "Equatorial Guinea",
8173 Zagreb: "Croatia",
8174 Isle_of_Man: "Isle of Man",
8175 Jersey: "Jersey",
8176 Phnom_Penh: "Cambodia",
8177 Comoro: "Comoros",
8178 St_Kitts: "St Kitts & Nevis",
8179 Kuwait: "Kuwait",
8180 Cayman: "Cayman Islands",
8181 Vientiane: "Laos",
8182 St_Lucia: "St Lucia",
8183 Vaduz: "Liechtenstein",
8184 Maseru: "Lesotho",
8185 Podgorica: "Montenegro",
8186 Marigot: "St Martin (French)",
8187 Antananarivo: "Madagascar",
8188 Skopje: "North Macedonia",
8189 Bamako: "Mali",
8190 Saipan: "Northern Mariana Islands",
8191 Nouakchott: "Mauritania",
8192 Montserrat: "Montserrat",
8193 Blantyre: "Malawi",
8194 Niamey: "Niger",
8195 Muscat: "Oman",
8196 Kigali: "Rwanda",
8197 St_Helena: "St Helena",
8198 Ljubljana: "Slovenia",
8199 Longyearbyen: "Svalbard & Jan Mayen",
8200 Bratislava: "Slovakia",
8201 Freetown: "Sierra Leone",
8202 San_Marino: "San Marino",
8203 Dakar: "Senegal",
8204 Mogadishu: "Somalia",
8205 Lower_Princes: "St Maarten (Dutch)",
8206 Mbabane: "Eswatini (Swaziland)",
8207 Lome: "Togo",
8208 Port_of_Spain: "Trinidad & Tobago",
8209 Dar_es_Salaam: "Tanzania",
8210 Kampala: "Uganda",
8211 Midway: "US minor outlying islands",
8212 Vatican: "Vatican City",
8213 St_Vincent: "St Vincent",
8214 Tortola: "Virgin Islands (UK)",
8215 St_Thomas: "Virgin Islands (US)",
8216 Aden: "Yemen",
8217 Mayotte: "Mayotte",
8218 Lusaka: "Zambia",
8219 Harare: "Zimbabwe"
8220};
8221
8222const styles$7 = "div {\n display: grid;\n grid-template-columns: 1.5em auto;\n grid-template-rows: 1.5em;\n column-gap: 0.25ch;\n}\n\nbutton {\n grid-column: 1 / 1;\n grid-row: 1;\n pointer-events: none;\n}\n\nselect,\nspan {\n /* position */\n position: relative;\n z-index: 1;\n grid-column: 1 / 1;\n grid-row: 1;\n /* */\n cursor: pointer;\n}\n\nspan {\n z-index: 0;\n position: relative;\n display: flex;\n justify-content: center;\n}\n\nselect:not(:focus) {\n /* reset all to hide */\n background-color: transparent;\n color: transparent;\n border-color: transparent;\n}\n\nselect:focus {\n grid-column: 1 / 3;\n}\n\ninput {\n grid-column: 2 / 3;\n grid-row: 1;\n}\n";
8223
8224const find = (value, key) => {
8225 if (!value)
8226 return void 0;
8227 let fn;
8228 if (typeof value === "function")
8229 fn = value;
8230 else if (key)
8231 fn = (country) => country[key] === value;
8232 else {
8233 console.warn(`Ethier value is a function or key is not empty`);
8234 return;
8235 }
8236 return !value ? void 0 : countries.find(fn);
8237};
8238const findBySelectValue = (value) => {
8239 return find(({ name, dial_code }) => value === `${name} (${dial_code})`);
8240};
8241const findCountryByUserTimezone = () => {
8242 if (!Intl) {
8243 console.warn("We cannot automatically retrieve the country of the user because Intl is not supported.");
8244 return;
8245 }
8246 const userTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
8247 const city = userTimeZone.split("/").at(-1);
8248 const country = timezoneCityToCountry[city];
8249 return countries.find(({ name }) => name === city || name === country);
8250};
8251const InputPhone = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
8252 const props1 = _restProps(props, [
8253 "countryCode",
8254 "placeholder",
8255 "value",
8256 "wrapperProps",
8257 "onCountryChange$",
8258 "onNumberChange$",
8259 "onValidChange$"
8260 ]);
8261 useStylesScopedQrl(/* @__PURE__ */ inlinedQrl(styles$7, "InputPhone_component_useStylesScoped_PrjnwMdfAfM"));
8262 const defaultCountry = props.countryCode === "auto" ? findCountryByUserTimezone() : find(props.countryCode, "code");
8263 const inputRefSignal = useSignal();
8264 const selectRefSignal = useSignal();
8265 const numberSignal = useSignal(props.value ?? "");
8266 const countrySignal = useSignal(defaultCountry);
8267 const outputSignal = useSignal(props.value ?? "");
8268 const handleCountryChange = /* @__PURE__ */ inlinedQrl((country) => {
8269 const [props2] = useLexicalScope();
8270 if (!country)
8271 props2.onCountryChange$ && props2.onCountryChange$(void 0);
8272 else {
8273 const outputCountry = {
8274 "alpha-2": country.code,
8275 countryCode: country.dial_code.replace("+", ""),
8276 flag: country.flag,
8277 name: country.name
8278 };
8279 props2.onCountryChange$ && props2.onCountryChange$(outputCountry);
8280 }
8281 }, "InputPhone_component_handleCountryChange_TVKRbcVCe5M", [
8282 props
8283 ]);
8284 const handleNumberChange = /* @__PURE__ */ inlinedQrl((number) => {
8285 const [props2] = useLexicalScope();
8286 props2.onNumberChange$ && props2.onNumberChange$(number);
8287 }, "InputPhone_component_handleNumberChange_ijC4bjIv7T4", [
8288 props
8289 ]);
8290 const handleValidChange = /* @__PURE__ */ inlinedQrl((phone) => {
8291 const [props2] = useLexicalScope();
8292 if (!props2.onValidChange$)
8293 return;
8294 if (isValidPhoneNumber(phone))
8295 return props2.onValidChange$("VALID");
8296 if (isPossiblePhoneNumber(phone))
8297 return props2.onValidChange$("MAYBE_VALID");
8298 return props2.onValidChange$("NOT_VALID");
8299 }, "InputPhone_component_handleValidChange_KehFdHiEurU", [
8300 props
8301 ]);
8302 useVisibleTaskQrl(/* @__PURE__ */ inlinedQrl(() => {
8303 const [countrySignal2, handleCountryChange2, handleNumberChange2, handleValidChange2, outputSignal2] = useLexicalScope();
8304 handleCountryChange2(countrySignal2.value);
8305 handleNumberChange2(outputSignal2.value);
8306 handleValidChange2(outputSignal2.value);
8307 }, "InputPhone_component_useVisibleTask_RsO1KGeWb6w", [
8308 countrySignal,
8309 handleCountryChange,
8310 handleNumberChange,
8311 handleValidChange,
8312 outputSignal
8313 ]));
8314 useTaskQrl(/* @__PURE__ */ inlinedQrl(({ track }) => {
8315 const [countrySignal2, handleCountryChange2, handleNumberChange2, handleValidChange2, numberSignal2, outputSignal2, props2] = useLexicalScope();
8316 const phone = track(() => numberSignal2.value);
8317 if (!phone)
8318 return;
8319 try {
8320 const phoneNumber = parsePhoneNumberWithError(phone, countrySignal2.value?.code);
8321 if (!phoneNumber)
8322 return;
8323 if (phoneNumber.country)
8324 countrySignal2.value = find(phoneNumber.country, "code");
8325 outputSignal2.value = phone;
8326 handleValidChange2(outputSignal2.value);
8327 } catch (error) {
8328 if (error instanceof ParseError)
8329 props2.onValidChange$ && props2.onValidChange$(error.message);
8330 else
8331 throw error;
8332 } finally {
8333 handleCountryChange2(countrySignal2.value);
8334 handleNumberChange2(outputSignal2.value);
8335 }
8336 }, "InputPhone_component_useTask_VNN73XGb8GM", [
8337 countrySignal,
8338 handleCountryChange,
8339 handleNumberChange,
8340 handleValidChange,
8341 numberSignal,
8342 outputSignal,
8343 props
8344 ]));
8345 useTaskQrl(/* @__PURE__ */ inlinedQrl(({ track }) => {
8346 const [countrySignal2, handleCountryChange2, handleNumberChange2, handleValidChange2, numberSignal2, outputSignal2, props2] = useLexicalScope();
8347 const code = track(() => countrySignal2.value?.code);
8348 if (!code)
8349 return;
8350 try {
8351 const phoneNumber = parsePhoneNumberWithError(numberSignal2.value, code);
8352 if (!phoneNumber)
8353 return;
8354 if (numberSignal2.value.at(0) === "+") {
8355 const country = find(code, "code");
8356 const { nationalNumber } = phoneNumber;
8357 if (!country)
8358 return;
8359 outputSignal2.value = new AsYouType().input(`${country.dial_code}${nationalNumber}`);
8360 } else
8361 outputSignal2.value = new AsYouType(code).input(numberSignal2.value);
8362 handleValidChange2(outputSignal2.value);
8363 } catch (error) {
8364 if (numberSignal2.value.at(0) === "+") {
8365 const country = find(code, "code");
8366 country && (outputSignal2.value = country.dial_code);
8367 }
8368 if (error instanceof ParseError)
8369 props2.onValidChange$ && props2.onValidChange$(error.message);
8370 else
8371 throw error;
8372 } finally {
8373 handleCountryChange2(countrySignal2.value);
8374 handleNumberChange2(outputSignal2.value);
8375 }
8376 }, "InputPhone_component_useTask_1_1B1HJ7meQ7s", [
8377 countrySignal,
8378 handleCountryChange,
8379 handleNumberChange,
8380 handleValidChange,
8381 numberSignal,
8382 outputSignal,
8383 props
8384 ]));
8385 return /* @__PURE__ */ _jsxS("div", {
8386 ...props.wrapperProps,
8387 children: [
8388 /* @__PURE__ */ _jsxQ("button", null, {
8389 tabIndex: -1,
8390 "aria-label": _fnSignal((p0) => p0.value?.flag ? `Country of ${p0.value.name}, dial code ${p0.value.dial_code}` : `Select the country of your phone number`, [
8391 countrySignal
8392 ], "p0.value?.flag?`Country of ${p0.value.name}, dial code ${p0.value.dial_code}`:`Select the country of your phone number`")
8393 }, _fnSignal((p0) => p0.value?.flag ? p0.value?.flag : `🌐`, [
8394 countrySignal
8395 ], "p0.value?.flag?p0.value?.flag:`🌐`"), 3, null),
8396 /* @__PURE__ */ _jsxQ("select", {
8397 ref: selectRefSignal
8398 }, {
8399 title: _fnSignal((p0) => p0.value?.name, [
8400 countrySignal
8401 ], "p0.value?.name"),
8402 "aria-label": "Select the country of your phone number",
8403 onChange$: /* @__PURE__ */ inlinedQrl((_, { value }) => {
8404 const [countrySignal2, inputRefSignal2, selectRefSignal2] = useLexicalScope();
8405 countrySignal2.value = findBySelectValue(value);
8406 selectRefSignal2.value?.blur();
8407 inputRefSignal2.value?.focus();
8408 }, "InputPhone_component_div_select_onChange_9gD3AiobtTQ", [
8409 countrySignal,
8410 inputRefSignal,
8411 selectRefSignal
8412 ])
8413 }, [
8414 /* @__PURE__ */ _jsxQ("option", null, null, "Select the country's phone code", 3, null),
8415 countries.map(({ code, dial_code, name }) => /* @__PURE__ */ _jsxQ("option", {
8416 selected: countrySignal.value?.code === code
8417 }, null, `${name} (${dial_code})`, 1, code))
8418 ], 1, null),
8419 /* @__PURE__ */ _jsxS("input", {
8420 ...props1,
8421 ref: inputRefSignal,
8422 onInput$: [
8423 /* @__PURE__ */ inlinedQrl((_, { value }) => {
8424 const [countrySignal2, numberSignal2] = useLexicalScope();
8425 numberSignal2.value = new AsYouType(countrySignal2.value?.code).input(value);
8426 }, "InputPhone_component_div_input_onInput_hvnM3Jyt0X0", [
8427 countrySignal,
8428 numberSignal
8429 ]),
8430 props1.onInput$
8431 ]
8432 }, {
8433 placeholder: _fnSignal((p0) => p0.placeholder ?? "Phone number", [
8434 props
8435 ], 'p0.placeholder??"Phone number"'),
8436 type: "text",
8437 value: _fnSignal((p0) => p0.value, [
8438 outputSignal
8439 ], "p0.value")
8440 }, 0, null)
8441 ]
8442 }, null, 0, "3e_0");
8443}, "InputPhone_component_qOllc0MTLPw"));
8444
8445const inputContext = createContextId("input-context-service");
8446const Root$1 = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
8447 const uniqueId = useId();
8448 const contextService = {
8449 ref: useSignal(),
8450 id: props.id || uniqueId
8451 };
8452 useContextProvider(inputContext, contextService);
8453 return /* @__PURE__ */ _jsxS("div", {
8454 ...props,
8455 children: /* @__PURE__ */ _jsxC(Slot, null, 3, "fW_0")
8456 }, null, 0, "fW_1");
8457}, "Root_component_iuaLFshWoJw"));
8458const Label$1 = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
8459 const context = useContext(inputContext);
8460 const id = props.id || context.id;
8461 return /* @__PURE__ */ _jsxS("label", {
8462 ...props,
8463 for: id,
8464 children: /* @__PURE__ */ _jsxC(Slot, null, 3, "fW_2")
8465 }, null, 0, "fW_3");
8466}, "Label_component_2yIkWCKvJ3c"));
8467const Hint = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
8468 const context = useContext(inputContext);
8469 const id = props.id || context.id;
8470 return /* @__PURE__ */ _jsxS("div", {
8471 ...props,
8472 id: `hint-${id}`,
8473 children: /* @__PURE__ */ _jsxC(Slot, null, 3, "fW_4")
8474 }, null, 0, "fW_5");
8475}, "Hint_component_mu0m5sVo9mE"));
8476const Message = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
8477 const context = useContext(inputContext);
8478 const id = props.id || context.id;
8479 return /* @__PURE__ */ _jsxS("div", {
8480 id: `message-${id}`,
8481 ...props,
8482 children: /* @__PURE__ */ _jsxC(Slot, null, 3, "fW_6")
8483 }, {
8484 "aria-live": "polite"
8485 }, 0, "fW_7");
8486}, "Message_component_cRA10a0JQ9k"));
8487const Phone = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
8488 const context = useContext(inputContext);
8489 const id = props.id || context.id;
8490 return /* @__PURE__ */ _jsxC(InputPhone, {
8491 ...props,
8492 "aria-describedby": `hint-${id} message-${id}`,
8493 id
8494 }, 0, "fW_8");
8495}, "Phone_component_u4aRRXrWctM"));
8496
8497const input = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
8498 __proto__: null,
8499 Hint,
8500 Label: Label$1,
8501 Message,
8502 Phone,
8503 Root: Root$1,
8504 _auto_inputContext: inputContext
8505}, Symbol.toStringTag, { value: 'Module' }));
8506
8507const styles$6 = ".spinner-container {\n display: inline-flex;\n width: 1em;\n height: 1em;\n}\n\n.spinner {\n flex: 1 1 auto;\n height: 100%;\n width: 100%;\n}\n\n.track,\n.indicator {\n fill: none;\n cx: 0.5em;\n cy: 0.5em;\n transform-origin: 50% 50%;\n}\n\n.track {\n transform-origin: 0 0;\n mix-blend-mode: multiply;\n}\n\n.indicator {\n stroke-linecap: round;\n stroke-dasharray: 150% 75%;\n}\n\n@keyframes spin {\n 0% {\n transform: rotate(0deg);\n stroke-dasharray: 0.01em, 2.75em;\n }\n 50% {\n transform: rotate(450deg);\n stroke-dasharray: 1.375em, 1.375em;\n }\n 100% {\n transform: rotate(1080deg);\n stroke-dasharray: 0.01em, 2.75em;\n }\n}\n";
8508
8509const Spinner = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
8510 useStylesScopedQrl(/* @__PURE__ */ inlinedQrl(styles$6, "Spinner_component_useStylesScoped_zuLQ9EumCnU"));
8511 return /* @__PURE__ */ _jsxQ("div", {
8512 class: clsq("spinner-container", props.class)
8513 }, {
8514 style: _fnSignal((p0) => p0.style, [
8515 props
8516 ], "p0.style")
8517 }, /* @__PURE__ */ _jsxQ("svg", null, {
8518 part: "base",
8519 class: "spinner",
8520 role: "spinner"
8521 }, [
8522 /* @__PURE__ */ _jsxQ("circle", null, {
8523 class: "track",
8524 r: _fnSignal((p0) => `calc(0.5em - ${p0.width ?? "2px"}/2)`, [
8525 props
8526 ], '`calc(0.5em - ${p0.width??"2px"}/2)`'),
8527 style: _fnSignal((p0) => ({
8528 strokeWidth: p0.width ?? "2px",
8529 stroke: p0.trackColor ?? "#8080803f"
8530 }), [
8531 props
8532 ], '{strokeWidth:p0.width??"2px",stroke:p0.trackColor??"#8080803f"}')
8533 }, null, 3, null),
8534 /* @__PURE__ */ _jsxQ("circle", null, {
8535 class: "indicator",
8536 r: _fnSignal((p0) => `calc(0.5em - ${p0.width ?? "2px"}/2)`, [
8537 props
8538 ], '`calc(0.5em - ${p0.width??"2px"}/2)`'),
8539 style: _fnSignal((p0) => ({
8540 strokeWidth: p0.width ?? "2px",
8541 stroke: p0.indicatorColor ?? "#006ce9",
8542 animation: `spin ${p0.speed ?? "2s"} linear infinite`
8543 }), [
8544 props
8545 ], '{strokeWidth:p0.width??"2px",stroke:p0.indicatorColor??"#006ce9",animation:`spin ${p0.speed??"2s"} linear infinite`}')
8546 }, null, 3, null)
8547 ], 3, null), 3, "WQ_0");
8548}, "Spinner_component_ZwkJC2DeV1w"));
8549
8550const MENU_CONTEXT_NAME = "qui-menu";
8551const quiMenuContext = createContextId(MENU_CONTEXT_NAME);
8552let KEYBOARD_KEY_NAME;
8553(function(KEYBOARD_KEY_NAME2) {
8554 KEYBOARD_KEY_NAME2["ARROW_UP"] = "ArrowUp";
8555 KEYBOARD_KEY_NAME2["ARROW_DOWN"] = "ArrowDown";
8556 KEYBOARD_KEY_NAME2["ESCAPE"] = "Escape";
8557})(KEYBOARD_KEY_NAME || (KEYBOARD_KEY_NAME = {}));
8558let CSS_CLASS_NAMES;
8559(function(CSS_CLASS_NAMES2) {
8560 CSS_CLASS_NAMES2["IS_EXPANDED"] = "quiIsExpanded";
8561 CSS_CLASS_NAMES2["IS_FOCUSED"] = "quiIsFocused";
8562 CSS_CLASS_NAMES2["IS_HOVERED"] = "quiIsHovered";
8563})(CSS_CLASS_NAMES || (CSS_CLASS_NAMES = {}));
8564const Menu = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
8565 const parentId = useId();
8566 const childId = useId();
8567 const isExpanded = useSignal(props?.isExpanded || false);
8568 const isHovered = useSignal(false);
8569 const container = useSignal();
8570 const children = useStore([]);
8571 const currentButtonInFocusIndex = useSignal(-1);
8572 const triggerElementRef = useSignal();
8573 const currentId = useSignal("");
8574 const menuContextService = {
8575 currentId
8576 };
8577 useContextProvider(quiMenuContext, menuContextService);
8578 useVisibleTaskQrl(/* @__PURE__ */ inlinedQrl(({ track }) => {
8579 const [currentButtonInFocusIndex2, currentId2, isExpanded2] = useLexicalScope();
8580 track(() => isExpanded2.value);
8581 if (!isExpanded2.value) {
8582 currentButtonInFocusIndex2.value = -1;
8583 currentId2.value = "";
8584 }
8585 }, "Menu_component_useVisibleTask_z5TUX3lfqYo", [
8586 currentButtonInFocusIndex,
8587 currentId,
8588 isExpanded
8589 ]));
8590 useVisibleTaskQrl(/* @__PURE__ */ inlinedQrl(() => {
8591 const [children2, container2] = useLexicalScope();
8592 const options = container2.value?.querySelectorAll("button");
8593 if (options?.length)
8594 options.forEach((option) => children2.push(option));
8595 }, "Menu_component_useVisibleTask_1_nW9Eu00kceY", [
8596 children,
8597 container
8598 ]));
8599 useOnWindow("click", /* @__PURE__ */ inlinedQrl((event) => {
8600 const [isExpanded2, triggerElementRef2] = useLexicalScope();
8601 const target = event.target;
8602 if (isExpanded2.value && target !== triggerElementRef2.value)
8603 isExpanded2.value = false;
8604 }, "Menu_component_useOnWindow_ZOEh0cr01Zo", [
8605 isExpanded,
8606 triggerElementRef
8607 ]));
8608 return /* @__PURE__ */ _jsxQ("div", {
8609 class: clsq(props.class, {
8610 [CSS_CLASS_NAMES.IS_EXPANDED]: isExpanded.value,
8611 [CSS_CLASS_NAMES.IS_HOVERED]: isHovered.value
8612 })
8613 }, {
8614 id: parentId,
8615 onMouseEnter$: /* @__PURE__ */ inlinedQrl(() => {
8616 const [isHovered2] = useLexicalScope();
8617 return isHovered2.value = true;
8618 }, "Menu_component_div_onMouseEnter_Un3HTfrqbP4", [
8619 isHovered
8620 ]),
8621 onMouseLeave$: /* @__PURE__ */ inlinedQrl(() => {
8622 const [isHovered2] = useLexicalScope();
8623 return isHovered2.value = false;
8624 }, "Menu_component_div_onMouseLeave_ehS07sC621w", [
8625 isHovered
8626 ]),
8627 onKeyDown$: /* @__PURE__ */ inlinedQrl((event) => {
8628 const [children2, currentButtonInFocusIndex2, currentId2, isExpanded2, triggerElementRef2] = useLexicalScope();
8629 if (event.key === KEYBOARD_KEY_NAME.ESCAPE && isExpanded2.value) {
8630 isExpanded2.value = false;
8631 triggerElementRef2.value?.focus();
8632 return;
8633 }
8634 if (event.key === KEYBOARD_KEY_NAME.ARROW_DOWN || event.key === KEYBOARD_KEY_NAME.ARROW_UP) {
8635 let idx = currentButtonInFocusIndex2.value;
8636 if (event.key === KEYBOARD_KEY_NAME.ARROW_DOWN) {
8637 idx = currentButtonInFocusIndex2.value + 1;
8638 if (idx >= children2.length)
8639 idx = 0;
8640 } else if (event.key === KEYBOARD_KEY_NAME.ARROW_UP) {
8641 idx = currentButtonInFocusIndex2.value - 1;
8642 if (idx < 0)
8643 idx = children2.length - 1;
8644 }
8645 children2[idx].focus();
8646 currentId2.value = children2[idx].id;
8647 currentButtonInFocusIndex2.value = idx;
8648 }
8649 }, "Menu_component_div_onKeyDown_ImVFKNhBMvE", [
8650 children,
8651 currentButtonInFocusIndex,
8652 currentId,
8653 isExpanded,
8654 triggerElementRef
8655 ])
8656 }, [
8657 /* @__PURE__ */ _jsxC(Button, {
8658 ref: triggerElementRef,
8659 "aria-haspopup": true,
8660 get "aria-expanded"() {
8661 return isExpanded.value;
8662 },
8663 get "aria-controls"() {
8664 return isExpanded.value ? childId : "";
8665 },
8666 onClick$: /* @__PURE__ */ inlinedQrl(() => {
8667 const [isExpanded2] = useLexicalScope();
8668 return isExpanded2.value = !isExpanded2.value;
8669 }, "Menu_component_div_Button_onClick_gSpFvZoiX0s", [
8670 isExpanded
8671 ]),
8672 children: _fnSignal((p0) => p0.triggerElement || "Menu", [
8673 props
8674 ], 'p0.triggerElement||"Menu"'),
8675 [_IMMUTABLE]: {
8676 ref: _IMMUTABLE,
8677 "aria-haspopup": _IMMUTABLE,
8678 "aria-expanded": _fnSignal((p0) => p0.value, [
8679 isExpanded
8680 ], "p0.value"),
8681 "aria-controls": _fnSignal((p0, p1) => p1.value ? p0 : "", [
8682 childId,
8683 isExpanded
8684 ], 'p1.value?p0:""'),
8685 onClick$: _IMMUTABLE
8686 }
8687 }, 3, "nG_0"),
8688 /* @__PURE__ */ _jsxQ("nav", {
8689 ref: container
8690 }, {
8691 id: childId,
8692 role: "menu",
8693 "aria-labelledby": parentId,
8694 style: _fnSignal((p0) => ({
8695 visibility: p0.value ? "visible" : "hidden"
8696 }), [
8697 isExpanded
8698 ], '{visibility:p0.value?"visible":"hidden"}')
8699 }, /* @__PURE__ */ _jsxC(Slot, null, 3, "nG_1"), 1, null)
8700 ], 1, "nG_2");
8701}, "Menu_component_GMwdTIoT1z4"));
8702const MenuItem = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
8703 _jsxBranch();
8704 const myId = useId();
8705 const contextService = useContext(quiMenuContext);
8706 const isFocused = contextService.currentId.value === myId;
8707 return /* @__PURE__ */ _jsxQ("div", null, {
8708 class: _fnSignal((p0) => p0.class, [
8709 props
8710 ], "p0.class")
8711 }, props.onClick$ ? /* @__PURE__ */ _jsxC(Button, {
8712 tabIndex: -1,
8713 id: myId,
8714 class: clsq({
8715 [CSS_CLASS_NAMES.IS_FOCUSED]: isFocused
8716 }),
8717 onClick$: props.onClick$,
8718 get disabled() {
8719 return props.disabled || false;
8720 },
8721 children: /* @__PURE__ */ _jsxC(Slot, null, 3, "nG_3"),
8722 [_IMMUTABLE]: {
8723 tabIndex: _IMMUTABLE,
8724 id: _IMMUTABLE,
8725 disabled: _fnSignal((p0) => p0.disabled || false, [
8726 props
8727 ], "p0.disabled||false")
8728 }
8729 }, 0, "nG_4") : /* @__PURE__ */ _jsxC(Slot, null, 3, "nG_5"), 1, "nG_6");
8730}, "MenuItem_component_Wd5FkIK10wk"));
8731
8732const PopoverContext = createContextId("popover-context");
8733
8734const Popover = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
8735 const triggerEvent = props.triggerEvent ?? "click";
8736 const wrapperRef = useSignal();
8737 const triggerRef = useSignal();
8738 const contentRef = useSignal();
8739 const setOverlayRef$ = /* @__PURE__ */ inlinedQrl((ref) => {
8740 const [contentRef2] = useLexicalScope();
8741 if (ref)
8742 contentRef2.value = ref.value;
8743 }, "Popover_component_setOverlayRef_0udWfF7cTAI", [
8744 contentRef
8745 ]);
8746 const setTriggerRef$ = /* @__PURE__ */ inlinedQrl((ref) => {
8747 const [triggerRef2] = useLexicalScope();
8748 if (ref)
8749 triggerRef2.value = ref.value;
8750 }, "Popover_component_setTriggerRef_GUXkt8iP7ik", [
8751 triggerRef
8752 ]);
8753 const contextService = useStore({
8754 isOpen: false,
8755 triggerEvent,
8756 setTriggerRef$,
8757 setOverlayRef$
8758 });
8759 useContextProvider(PopoverContext, contextService);
8760 const closePopover = /* @__PURE__ */ inlinedQrl(async () => {
8761 const [contentRef2, contextService2, props2] = useLexicalScope();
8762 contextService2.isOpen = false;
8763 if (contentRef2) {
8764 contentRef2.value?.classList.add("close");
8765 contentRef2.value?.classList.remove("open");
8766 }
8767 if (props2.onUpdate$)
8768 await props2.onUpdate$(contextService2.isOpen);
8769 }, "Popover_component_closePopover_k1Gil9i90JI", [
8770 contentRef,
8771 contextService,
8772 props
8773 ]);
8774 const openPopover = /* @__PURE__ */ inlinedQrl(async () => {
8775 const [contentRef2, contextService2, props2] = useLexicalScope();
8776 contextService2.isOpen = true;
8777 if (contentRef2) {
8778 contentRef2.value?.classList.add("open");
8779 contentRef2.value?.classList.remove("close");
8780 }
8781 if (props2.onUpdate$)
8782 await props2.onUpdate$(contextService2.isOpen);
8783 }, "Popover_component_openPopover_gL5gEsnFqdE", [
8784 contentRef,
8785 contextService,
8786 props
8787 ]);
8788 const togglePopover = /* @__PURE__ */ inlinedQrl(async () => {
8789 const [closePopover2, contextService2, openPopover2, props2] = useLexicalScope();
8790 if (contextService2.isOpen)
8791 closePopover2();
8792 else
8793 openPopover2();
8794 if (props2.onUpdate$)
8795 await props2.onUpdate$(contextService2.isOpen);
8796 }, "Popover_component_togglePopover_wUcsAC2CDPs", [
8797 closePopover,
8798 contextService,
8799 openPopover,
8800 props
8801 ]);
8802 useTaskQrl(/* @__PURE__ */ inlinedQrl(({ track }) => {
8803 const [contentRef2, openPopover2, props2, triggerRef2] = useLexicalScope();
8804 const trigger = track(() => triggerRef2.value);
8805 const content = track(() => contentRef2.value);
8806 if (isBrowser && trigger && content) {
8807 S(trigger, content, () => {
8808 O(trigger, content, {
8809 middleware: [
8810 b$1(),
8811 E$1(),
8812 O$1(props2.offset || 0)
8813 ],
8814 placement: props2.placement
8815 }).then(({ x, y }) => {
8816 Object.assign(content.style, {
8817 left: `${x}px`,
8818 top: `${y}px`
8819 });
8820 });
8821 });
8822 if (props2.isOpen)
8823 openPopover2();
8824 }
8825 }, "Popover_component_useTask_kpkTN6NP76Y", [
8826 contentRef,
8827 openPopover,
8828 props,
8829 triggerRef
8830 ]));
8831 useVisibleTaskQrl(/* @__PURE__ */ inlinedQrl(({ track }) => {
8832 const [contextService2, props2] = useLexicalScope();
8833 track(() => props2.isOpen);
8834 contextService2.isOpen = !!props2.isOpen;
8835 }, "Popover_component_useVisibleTask_hP4F7a954yg", [
8836 contextService,
8837 props
8838 ]));
8839 useVisibleTaskQrl(/* @__PURE__ */ inlinedQrl(({ track }) => {
8840 const [closePopover2, contentRef2, contextService2, openPopover2, triggerRef2] = useLexicalScope();
8841 track(() => contextService2.isOpen);
8842 if (!triggerRef2.value || !contentRef2.value)
8843 return;
8844 if (contextService2.isOpen)
8845 openPopover2();
8846 else
8847 closePopover2();
8848 }, "Popover_component_useVisibleTask_1_iWRr6q6c5EQ", [
8849 closePopover,
8850 contentRef,
8851 contextService,
8852 openPopover,
8853 triggerRef
8854 ]));
8855 const clickHandler = /* @__PURE__ */ inlinedQrl((e) => {
8856 const [closePopover2, contentRef2, props2, togglePopover2, triggerEvent2, triggerRef2] = useLexicalScope();
8857 const isContentClicked = contentRef2.value?.contains(e.target);
8858 if (isContentClicked)
8859 return;
8860 const isTriggerClicked = triggerRef2.value?.contains(e.target);
8861 if (isTriggerClicked && triggerEvent2 === "click")
8862 togglePopover2();
8863 else {
8864 if (props2.disableClickOutSide)
8865 return;
8866 closePopover2();
8867 }
8868 }, "Popover_component_clickHandler_sDATyKm0S3o", [
8869 closePopover,
8870 contentRef,
8871 props,
8872 togglePopover,
8873 triggerEvent,
8874 triggerRef
8875 ]);
8876 return /* @__PURE__ */ _jsxQ("span", {
8877 ref: wrapperRef
8878 }, {
8879 "document:onClick$": clickHandler
8880 }, /* @__PURE__ */ _jsxC(Slot, null, 3, "ca_0"), 1, "ca_1");
8881}, "Popover_component_GIDbxXNx2UI"));
8882
8883const styles$5 = ".popover-content {\n position: absolute;\n /*box-sizing: border-box;*/\n z-index: 10;\n opacity: 0;\n transition: opacity 0.5s, top 0.5s, right 0.5s;\n pointer-events: none;\n}\n\n.popover-content.close {\n opacity: 0;\n pointer-events: none;\n}\n\n.popover-content.open {\n opacity: 1;\n pointer-events: auto;\n}\n";
8884
8885const PopoverContent = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl(() => {
8886 const ref = useSignal();
8887 const contextService = useContext(PopoverContext);
8888 useStylesScopedQrl(/* @__PURE__ */ inlinedQrl(styles$5, "PopoverContent_component_useStylesScoped_GkAnS5GbCK8"));
8889 useVisibleTaskQrl(/* @__PURE__ */ inlinedQrl(() => {
8890 const [contextService2, ref2] = useLexicalScope();
8891 contextService2.setOverlayRef$(ref2);
8892 }, "PopoverContent_component_useVisibleTask_NyTv0RdkNOo", [
8893 contextService,
8894 ref
8895 ]));
8896 return /* @__PURE__ */ _jsxQ("div", {
8897 ref
8898 }, {
8899 role: "dialog",
8900 "aria-modal": "true",
8901 "aria-label": "Popover",
8902 class: "popover-content"
8903 }, /* @__PURE__ */ _jsxC(Slot, null, 3, "Sw_0"), 1, "Sw_1");
8904}, "PopoverContent_component_xzv2AbdbzsI"));
8905
8906const styles$4 = ".popover-trigger {\n display: inline-block;\n cursor: pointer;\n}\n";
8907
8908const PopoverTrigger = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl(() => {
8909 const ref = useSignal();
8910 const contextService = useContext(PopoverContext);
8911 useStylesScopedQrl(/* @__PURE__ */ inlinedQrl(styles$4, "PopoverTrigger_component_useStylesScoped_sRhUPs1ajRg"));
8912 useVisibleTaskQrl(/* @__PURE__ */ inlinedQrl(() => {
8913 const [contextService2, ref2] = useLexicalScope();
8914 contextService2.setTriggerRef$(ref2);
8915 }, "PopoverTrigger_component_useVisibleTask_ibMaSwgs0vM", [
8916 contextService,
8917 ref
8918 ]));
8919 const mouseOverHandler = /* @__PURE__ */ inlinedQrl(() => {
8920 const [contextService2] = useLexicalScope();
8921 contextService2.isOpen = true;
8922 }, "PopoverTrigger_component_mouseOverHandler_8BIEivKn6bU", [
8923 contextService
8924 ]);
8925 return /* @__PURE__ */ _jsxQ("span", {
8926 ref,
8927 onMouseOver$: contextService.triggerEvent === "mouseOver" ? mouseOverHandler : void 0
8928 }, {
8929 role: "button",
8930 class: "popover-trigger"
8931 }, /* @__PURE__ */ _jsxC(Slot, null, 3, "AE_0"), 0, "AE_1");
8932}, "PopoverTrigger_component_b780PpzaOc0"));
8933
8934const styles$3 = ".wrapper {\n display: flex;\n}\nlabel:has(+ input) {\n opacity: 0.4;\n transition: opacity 0.3s;\n}\nlabel:has(~ input:checked) {\n opacity: 1;\n}\n";
8935
8936const Rating = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
8937 const uniqueId = useId();
8938 useStylesQrl(/* @__PURE__ */ inlinedQrl(styles$3, "Rating_component_useStyles_5CPM8lFif0o"));
8939 const state = useStore({
8940 index: 0,
8941 tempIndex: 0
8942 });
8943 const onItemClick$ = /* @__PURE__ */ inlinedQrl((index) => {
8944 const [props2, state2] = useLexicalScope();
8945 state2.index = index;
8946 if (props2.onChange$)
8947 props2.onChange$(index + 1);
8948 }, "Rating_component_onItemClick_Kgg0ONfmorA", [
8949 props,
8950 state
8951 ]);
8952 return /* @__PURE__ */ _jsxQ("span", null, {
8953 class: "wrapper"
8954 }, Array.from({
8955 length: props.total ?? 5
8956 }, (_, index) => index).map((item, i) => {
8957 const Icon = props.icon || DefaultIcon;
8958 return /* @__PURE__ */ _jsxC(RatingIcon, {
8959 name: `rating-${uniqueId}`,
8960 index: i,
8961 onChange$: /* @__PURE__ */ inlinedQrl(() => {
8962 const [i2, onItemClick$2] = useLexicalScope();
8963 return onItemClick$2(i2);
8964 }, "Rating_component_span_RatingIcon_onChange_QA052QVeZ8A", [
8965 i,
8966 onItemClick$
8967 ]),
8968 get value() {
8969 return props.value;
8970 },
8971 children: /* @__PURE__ */ _jsxC(Icon, null, 3, "wv_0"),
8972 [_IMMUTABLE]: {
8973 name: _IMMUTABLE,
8974 value: _fnSignal((p0) => p0.value, [
8975 props
8976 ], "p0.value")
8977 }
8978 }, 1, item);
8979 }), 1, "wv_1");
8980}, "Rating_component_x6Va0MlPc0o"));
8981const RatingIcon = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
8982 return /* @__PURE__ */ _jsxC(Fragment, {
8983 children: [
8984 /* @__PURE__ */ _jsxQ("label", null, {
8985 for: _fnSignal((p0) => `${p0.name}-${p0.index}`, [
8986 props
8987 ], "`${p0.name}-${p0.index}`")
8988 }, /* @__PURE__ */ _jsxC(Slot, null, 3, "wv_2"), 1, null),
8989 /* @__PURE__ */ _jsxQ("input", {
8990 onChange$: props.onChange$
8991 }, {
8992 hidden: true,
8993 type: "radio",
8994 checked: _fnSignal((p0) => p0.value === p0.index + 1, [
8995 props
8996 ], "p0.value===p0.index+1"),
8997 name: _fnSignal((p0) => p0.name, [
8998 props
8999 ], "p0.name"),
9000 id: _fnSignal((p0) => `${p0.name}-${p0.index}`, [
9001 props
9002 ], "`${p0.name}-${p0.index}`")
9003 }, null, 2, null)
9004 ]
9005 }, 1, "wv_3");
9006}, "RatingIcon_component_W7soSSdH5C0"));
9007const DefaultIcon = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl(() => /* @__PURE__ */ _jsxC(Fragment, {
9008 children: "⭐️"
9009}, 3, "wv_4"), "DefaultIcon_component_Gtj0zavuMg8"));
9010
9011const tabsContextId = createContextId("qui--tabList");
9012
9013const Tabs = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
9014 const behavior = props.behavior ?? "manual";
9015 const ref = useSignal();
9016 const selectedIndexSig = useSignal(0);
9017 const lastAssignedTabIndexSig = useSignal(-1);
9018 const lastAssignedPanelIndexSig = useSignal(-1);
9019 useTaskQrl(/* @__PURE__ */ inlinedQrl(({ track }) => {
9020 const [props2, selectedIndexSig2] = useLexicalScope();
9021 track(() => props2.selectedIndex);
9022 selectedIndexSig2.value = props2.selectedIndex || 0;
9023 }, "Tabs_component_useTask_JAN1yHp0un0", [
9024 props,
9025 selectedIndexSig
9026 ]));
9027 useTaskQrl(/* @__PURE__ */ inlinedQrl(({ track }) => {
9028 const [props2, selectedIndexSig2] = useLexicalScope();
9029 track(() => selectedIndexSig2.value);
9030 if (props2.onSelectedIndexChange$)
9031 props2.onSelectedIndexChange$(selectedIndexSig2.value);
9032 }, "Tabs_component_useTask_1_6CfaIT178Jc", [
9033 props,
9034 selectedIndexSig
9035 ]));
9036 const shouldReIndexTabsSig = useSignal(true);
9037 const tabPairsList = useStore([]);
9038 const tabsMap = useStore({});
9039 const tabPanelsMap = useStore({});
9040 const selectedTabIdSig = useComputedQrl(/* @__PURE__ */ inlinedQrl(() => {
9041 const [selectedIndexSig2, tabPairsList2] = useLexicalScope();
9042 const tabPair = tabPairsList2[selectedIndexSig2.value];
9043 if (!tabPair)
9044 return "";
9045 return tabPair.tabId;
9046 }, "Tabs_component_selectedTabIdSig_useComputed_H10SKuKjYug", [
9047 selectedIndexSig,
9048 tabPairsList
9049 ]));
9050 const reIndexTabs$ = /* @__PURE__ */ inlinedQrl(() => {
9051 const [shouldReIndexTabsSig2] = useLexicalScope();
9052 shouldReIndexTabsSig2.value = true;
9053 }, "Tabs_component_reIndexTabs_gA0lZpI2Bpc", [
9054 shouldReIndexTabsSig
9055 ]);
9056 const getMatchedPanelId$ = /* @__PURE__ */ inlinedQrl((tabId) => {
9057 const [tabsMap2] = useLexicalScope();
9058 return tabsMap2[tabId]?.tabPanelId;
9059 }, "Tabs_component_getMatchedPanelId_DD9RwxGA0jQ", [
9060 tabsMap
9061 ]);
9062 const getMatchedTabId$ = /* @__PURE__ */ inlinedQrl((panelId) => {
9063 const [tabPanelsMap2] = useLexicalScope();
9064 return tabPanelsMap2[panelId]?.tabId;
9065 }, "Tabs_component_getMatchedTabId_toTYA0ZibeU", [
9066 tabPanelsMap
9067 ]);
9068 const selectTab$ = /* @__PURE__ */ inlinedQrl((tabId) => {
9069 const [selectedIndexSig2, tabsMap2] = useLexicalScope();
9070 const tab = tabsMap2[tabId];
9071 if (!tab || tab.disabled)
9072 return;
9073 selectedIndexSig2.value = tabsMap2[tabId].index || 0;
9074 }, "Tabs_component_selectTab_FPIQh5Sqw40", [
9075 selectedIndexSig,
9076 tabsMap
9077 ]);
9078 const selectIfAutomatic$ = /* @__PURE__ */ inlinedQrl((tabId) => {
9079 const [behavior2, selectTab$2] = useLexicalScope();
9080 if (behavior2 === "automatic")
9081 selectTab$2(tabId);
9082 }, "Tabs_component_selectIfAutomatic_6MeSrmaNEEw", [
9083 behavior,
9084 selectTab$
9085 ]);
9086 const updateTabState$ = /* @__PURE__ */ inlinedQrl((tabId, state) => {
9087 const [tabsMap2] = useLexicalScope();
9088 const prevState = tabsMap2[tabId];
9089 tabsMap2[tabId] = {
9090 ...prevState,
9091 ...state
9092 };
9093 }, "Tabs_component_updateTabState_A9a7abOQrEM", [
9094 tabsMap
9095 ]);
9096 const getNextServerAssignedTabIndex$ = /* @__PURE__ */ inlinedQrl(() => {
9097 const [lastAssignedTabIndexSig2] = useLexicalScope();
9098 lastAssignedTabIndexSig2.value++;
9099 return lastAssignedTabIndexSig2.value;
9100 }, "Tabs_component_getNextServerAssignedTabIndex_D9mO08oTgas", [
9101 lastAssignedTabIndexSig
9102 ]);
9103 const getNextServerAssignedPanelIndex$ = /* @__PURE__ */ inlinedQrl(() => {
9104 const [lastAssignedPanelIndexSig2] = useLexicalScope();
9105 lastAssignedPanelIndexSig2.value++;
9106 return lastAssignedPanelIndexSig2.value;
9107 }, "Tabs_component_getNextServerAssignedPanelIndex_cd9EW4ty5sc", [
9108 lastAssignedPanelIndexSig
9109 ]);
9110 const isIndexSelected$ = /* @__PURE__ */ inlinedQrl((index) => {
9111 const [selectedIndexSig2] = useLexicalScope();
9112 return selectedIndexSig2.value === index;
9113 }, "Tabs_component_isIndexSelected_Ii7Wp9E07jc", [
9114 selectedIndexSig
9115 ]);
9116 const isTabSelected$ = /* @__PURE__ */ inlinedQrl((tabId) => {
9117 const [selectedIndexSig2, tabsMap2] = useLexicalScope();
9118 return selectedIndexSig2.value === tabsMap2[tabId]?.index;
9119 }, "Tabs_component_isTabSelected_gt004h0Wdhg", [
9120 selectedIndexSig,
9121 tabsMap
9122 ]);
9123 const isPanelSelected$ = /* @__PURE__ */ inlinedQrl((panelId) => {
9124 const [selectedIndexSig2, tabPanelsMap2] = useLexicalScope();
9125 return selectedIndexSig2.value === tabPanelsMap2[panelId]?.index;
9126 }, "Tabs_component_isPanelSelected_LBpWAol1qI0", [
9127 selectedIndexSig,
9128 tabPanelsMap
9129 ]);
9130 const onTabKeyDown$ = /* @__PURE__ */ inlinedQrl((key, currentTabId) => {
9131 const [props2, ref2, tabPairsList2, tabsMap2] = useLexicalScope();
9132 const tabsRootElement = ref2.value;
9133 const enabledTabs = tabPairsList2.filter((tabPair) => {
9134 return !tabsMap2[tabPair.tabId].disabled;
9135 });
9136 const currentFocusedTabIndex = enabledTabs.findIndex((tabPair) => tabPair.tabId === currentTabId);
9137 if (!props2.vertical && key === KeyCode.ArrowRight || props2.vertical && key === KeyCode.ArrowDown) {
9138 let nextTabId = enabledTabs[0].tabId;
9139 if (currentFocusedTabIndex < enabledTabs.length - 1)
9140 nextTabId = enabledTabs[currentFocusedTabIndex + 1].tabId;
9141 focusOnTab(nextTabId);
9142 }
9143 if (!props2.vertical && key === KeyCode.ArrowLeft || props2.vertical && key === KeyCode.ArrowUp) {
9144 let previousTabId = enabledTabs[enabledTabs.length - 1].tabId;
9145 if (currentFocusedTabIndex !== 0)
9146 previousTabId = enabledTabs[currentFocusedTabIndex - 1].tabId;
9147 focusOnTab(previousTabId);
9148 }
9149 if (key === KeyCode.Home || key === KeyCode.PageUp) {
9150 const firstTabId = enabledTabs[0].tabId;
9151 focusOnTab(firstTabId);
9152 }
9153 if (key === KeyCode.End || key === KeyCode.PageDown) {
9154 const lastTabId = enabledTabs[enabledTabs.length - 1].tabId;
9155 focusOnTab(lastTabId);
9156 }
9157 function focusOnTab(tabId) {
9158 tabsRootElement?.querySelector(`[data-tab-id='${tabId}']`)?.focus();
9159 }
9160 }, "Tabs_component_onTabKeyDown_kRDpPtziB6o", [
9161 props,
9162 ref,
9163 tabPairsList,
9164 tabsMap
9165 ]);
9166 const contextService = {
9167 selectTab$,
9168 isTabSelected$,
9169 isPanelSelected$,
9170 updateTabState$,
9171 getNextServerAssignedTabIndex$,
9172 getNextServerAssignedPanelIndex$,
9173 getMatchedPanelId$,
9174 getMatchedTabId$,
9175 isIndexSelected$,
9176 reIndexTabs$,
9177 onTabKeyDown$,
9178 selectIfAutomatic$,
9179 selectedClassName: props.selectedClassName
9180 };
9181 useContextProvider(tabsContextId, contextService);
9182 const selectEnabledIndex$ = /* @__PURE__ */ inlinedQrl((newIndex) => {
9183 const [selectedIndexSig2, tabPairsList2, tabsMap2] = useLexicalScope();
9184 if (newIndex < 0)
9185 newIndex = 0;
9186 if (newIndex >= tabPairsList2.length)
9187 newIndex = 0;
9188 let enabledTabIndex = findNextEnabledTab(tabPairsList2, newIndex);
9189 if (enabledTabIndex === -1)
9190 enabledTabIndex = findPreviousEnabledTab(tabPairsList2, newIndex);
9191 newIndex = enabledTabIndex;
9192 selectedIndexSig2.value = newIndex;
9193 function findNextEnabledTab(tabPairsList3, index) {
9194 for (let i = index; i < tabPairsList3.length; i++) {
9195 const tabId = tabPairsList3[i].tabId;
9196 if (!tabsMap2[tabId].disabled)
9197 return i;
9198 }
9199 return -1;
9200 }
9201 function findPreviousEnabledTab(tabPairsList3, index) {
9202 for (let i = index; i >= 0; i--) {
9203 const tabId = tabPairsList3[i].tabId;
9204 if (!tabsMap2[tabId].disabled)
9205 return i;
9206 }
9207 return -1;
9208 }
9209 }, "Tabs_component_selectEnabledIndex_efruyf1S66k", [
9210 selectedIndexSig,
9211 tabPairsList,
9212 tabsMap
9213 ]);
9214 useVisibleTaskQrl(/* @__PURE__ */ inlinedQrl(async function buildTabsInfoVisibleTask({ track }) {
9215 const [ref2, selectEnabledIndex$2, selectedIndexSig2, selectedTabIdSig2, shouldReIndexTabsSig2, tabPairsList2, tabPanelsMap2, tabsMap2] = useLexicalScope();
9216 track(() => shouldReIndexTabsSig2.value);
9217 if (!shouldReIndexTabsSig2.value)
9218 return;
9219 shouldReIndexTabsSig2.value = false;
9220 if (!ref2.value)
9221 return;
9222 const [tabElements, tabPanelElements] = getTabsAndPanels();
9223 let lastTabWasSelectedPreviously = false;
9224 if (selectedIndexSig2.value === tabPairsList2.length - 1)
9225 lastTabWasSelectedPreviously = true;
9226 tabPairsList2.length = 0;
9227 let deletedTabId = void 0;
9228 let indexToBeSelected = selectedIndexSig2.value;
9229 tabElements.forEach((tab, index) => {
9230 const tabId = tab.getAttribute("data-tab-id");
9231 const isTabDisabled = tab.hasAttribute("disabled");
9232 let thisTabWasDeleted = true;
9233 if (selectedTabIdSig2.value === "")
9234 thisTabWasDeleted = false;
9235 else if (selectedTabIdSig2.value === tabId) {
9236 indexToBeSelected = index;
9237 thisTabWasDeleted = false;
9238 }
9239 const tabPanelId = getTabPanelId(tabPanelElements, index);
9240 if (!tabId || !tabPanelId)
9241 throw new Error("Missing tab id or tab panel id for tab: " + index);
9242 tabPairsList2.push({
9243 tabId,
9244 tabPanelId
9245 });
9246 tabsMap2[tabId] = {
9247 tabId,
9248 tabPanelId,
9249 index,
9250 disabled: isTabDisabled
9251 };
9252 tabPanelsMap2[tabPanelId] = {
9253 tabId,
9254 tabPanelId,
9255 index
9256 };
9257 if (thisTabWasDeleted)
9258 deletedTabId = tabId;
9259 });
9260 if (tabPairsList2.length > 0) {
9261 if (lastTabWasSelectedPreviously && deletedTabId)
9262 indexToBeSelected = tabPairsList2.length - 1;
9263 }
9264 await selectEnabledIndex$2(indexToBeSelected);
9265 function getTabsAndPanels() {
9266 const tabsRootElement = ref2.value;
9267 const tabListElement = tabsRootElement.querySelector('[role="tablist"]');
9268 let tabElements2 = [];
9269 if (tabListElement)
9270 tabElements2 = Array.from(tabListElement?.children).filter((child) => {
9271 return child.getAttribute("role") === "tab";
9272 });
9273 let tabPanelElements2 = [];
9274 if (tabsRootElement.children)
9275 tabPanelElements2 = Array.from(tabsRootElement.children).filter((child) => {
9276 return child.getAttribute("role") === "tabpanel";
9277 });
9278 return [
9279 tabElements2,
9280 tabPanelElements2
9281 ];
9282 }
9283 function getTabPanelId(tabPanelElements2, index) {
9284 const tabPanelElement = tabPanelElements2[index];
9285 if (!tabPanelElement)
9286 throw new Error("Missing tab panel for tab: " + index);
9287 return tabPanelElement.getAttribute("data-tabpanel-id");
9288 }
9289 }, "Tabs_component_useVisibleTask_6Q5rp0mOaag", [
9290 ref,
9291 selectEnabledIndex$,
9292 selectedIndexSig,
9293 selectedTabIdSig,
9294 shouldReIndexTabsSig,
9295 tabPairsList,
9296 tabPanelsMap,
9297 tabsMap
9298 ]));
9299 return /* @__PURE__ */ _jsxS("div", {
9300 ref,
9301 ...props,
9302 children: /* @__PURE__ */ _jsxC(Slot, null, 3, "8n_0")
9303 }, null, 0, "8n_1");
9304}, "Tabs_component_g0doawrYNsw"));
9305
9306const TabPanel = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl(({ ...props }) => {
9307 const contextService = useContext(tabsContextId);
9308 const isSelectedSig = useSignal(false);
9309 const serverAssignedIndexSig = useSignal(void 0);
9310 const matchedTabIdSig = useSignal(void 0);
9311 const panelUID = useId();
9312 useTaskQrl(/* @__PURE__ */ inlinedQrl(async function initIndexTask({ cleanup }) {
9313 const [contextService2, serverAssignedIndexSig2] = useLexicalScope();
9314 if (isServer)
9315 serverAssignedIndexSig2.value = await contextService2.getNextServerAssignedPanelIndex$();
9316 if (isBrowser)
9317 contextService2.reIndexTabs$();
9318 cleanup(() => {
9319 contextService2.reIndexTabs$();
9320 });
9321 }, "TabPanel_component_useTask_AIZz40K1Jmg", [
9322 contextService,
9323 serverAssignedIndexSig
9324 ]));
9325 useTaskQrl(/* @__PURE__ */ inlinedQrl(async function isSelectedPanelTask({ track }) {
9326 const [contextService2, isSelectedSig2, panelUID2, serverAssignedIndexSig2] = useLexicalScope();
9327 const isSelected = await track(() => contextService2.isPanelSelected$(panelUID2));
9328 if (isServer) {
9329 isSelectedSig2.value = await contextService2.isIndexSelected$(serverAssignedIndexSig2.value);
9330 return;
9331 }
9332 isSelectedSig2.value = isSelected;
9333 }, "TabPanel_component_useTask_1_2VUqnxUyKWM", [
9334 contextService,
9335 isSelectedSig,
9336 panelUID,
9337 serverAssignedIndexSig
9338 ]));
9339 useVisibleTaskQrl(/* @__PURE__ */ inlinedQrl(async function matchedPanelIdTask({ track }) {
9340 const [contextService2, matchedTabIdSig2, panelUID2] = useLexicalScope();
9341 matchedTabIdSig2.value = await track(() => contextService2.getMatchedTabId$(panelUID2));
9342 }, "TabPanel_component_useVisibleTask_lMxuGsuAvHA", [
9343 contextService,
9344 matchedTabIdSig,
9345 panelUID
9346 ]));
9347 return /* @__PURE__ */ _jsxQ("div", {
9348 class: `${isSelectedSig.value ? "" : "is-hidden"}${props.class ? ` ${props.class}` : ""}`
9349 }, {
9350 "data-tabpanel-id": panelUID,
9351 id: "tabpanel-" + panelUID,
9352 role: "tabpanel",
9353 tabIndex: 0,
9354 hidden: _fnSignal((p0) => p0.value ? null : true, [
9355 isSelectedSig
9356 ], "p0.value?null:true"),
9357 "aria-labelledby": _fnSignal((p0) => `tab-${p0.value}`, [
9358 matchedTabIdSig
9359 ], "`tab-${p0.value}`"),
9360 style: _fnSignal((p0) => p0.value ? "display: block" : "display: none", [
9361 isSelectedSig
9362 ], 'p0.value?"display: block":"display: none"')
9363 }, /* @__PURE__ */ _jsxC(Slot, null, 3, "EC_0"), 1, "EC_1");
9364}, "TabPanel_component_3rcWDF00mPE"));
9365
9366const TabList = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
9367 return /* @__PURE__ */ _jsxS("div", {
9368 ...props,
9369 children: /* @__PURE__ */ _jsxC(Slot, null, 3, "8w_0")
9370 }, {
9371 role: "tablist"
9372 }, 0, "8w_1");
9373}, "TabList_component_Mt229u04lBc"));
9374
9375const preventedKeys = [
9376 KeyCode.Home,
9377 KeyCode.End,
9378 KeyCode.PageDown,
9379 KeyCode.PageUp,
9380 KeyCode.ArrowDown,
9381 KeyCode.ArrowUp,
9382 KeyCode.ArrowLeft,
9383 KeyCode.ArrowRight
9384];
9385const Tab = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
9386 const contextService = useContext(tabsContextId);
9387 const isSelectedSig = useSignal(false);
9388 const serverAssignedIndexSig = useSignal(void 0);
9389 const matchedTabPanelIdSig = useSignal(void 0);
9390 const elementRefSig = useSignal();
9391 const uniqueTabId = useId();
9392 const selectedClassNameSig = useComputedQrl(/* @__PURE__ */ inlinedQrl(() => {
9393 const [contextService2, props2] = useLexicalScope();
9394 return props2.selectedClassName || contextService2.selectedClassName;
9395 }, "Tab_component_selectedClassNameSig_useComputed_Luo0iPtRX04", [
9396 contextService,
9397 props
9398 ]));
9399 useTaskQrl(/* @__PURE__ */ inlinedQrl(async function indexInitTask({ cleanup }) {
9400 const [contextService2, serverAssignedIndexSig2] = useLexicalScope();
9401 if (isServer)
9402 serverAssignedIndexSig2.value = await contextService2.getNextServerAssignedTabIndex$();
9403 if (isBrowser)
9404 contextService2.reIndexTabs$();
9405 cleanup(() => {
9406 contextService2.reIndexTabs$();
9407 });
9408 }, "Tab_component_useTask_ZJ1hVpldFnQ", [
9409 contextService,
9410 serverAssignedIndexSig
9411 ]));
9412 useTaskQrl(/* @__PURE__ */ inlinedQrl(async function isSelectedTask({ track }) {
9413 const [contextService2, isSelectedSig2, props2, serverAssignedIndexSig2, uniqueTabId2] = useLexicalScope();
9414 const isTabSelected = await track(() => contextService2.isTabSelected$(uniqueTabId2));
9415 if (isServer && !props2.disabled) {
9416 isSelectedSig2.value = await contextService2.isIndexSelected$(serverAssignedIndexSig2.value);
9417 return;
9418 }
9419 isSelectedSig2.value = isTabSelected;
9420 }, "Tab_component_useTask_1_Lxi70G4Yq08", [
9421 contextService,
9422 isSelectedSig,
9423 props,
9424 serverAssignedIndexSig,
9425 uniqueTabId
9426 ]));
9427 useTaskQrl(/* @__PURE__ */ inlinedQrl(function disabledTask({ track }) {
9428 const [contextService2, props2, uniqueTabId2] = useLexicalScope();
9429 track(() => props2.disabled);
9430 if (props2.disabled)
9431 contextService2.updateTabState$(uniqueTabId2, {
9432 disabled: true
9433 });
9434 }, "Tab_component_useTask_2_yGEr7oQPOpQ", [
9435 contextService,
9436 props,
9437 uniqueTabId
9438 ]));
9439 useVisibleTaskQrl(/* @__PURE__ */ inlinedQrl(async function setMatchedTabPanelIdTask({ track }) {
9440 const [contextService2, matchedTabPanelIdSig2, uniqueTabId2] = useLexicalScope();
9441 matchedTabPanelIdSig2.value = await track(() => contextService2.getMatchedPanelId$(uniqueTabId2));
9442 }, "Tab_component_useVisibleTask_lBSiSWVU7wU", [
9443 contextService,
9444 matchedTabPanelIdSig,
9445 uniqueTabId
9446 ]));
9447 useVisibleTaskQrl(/* @__PURE__ */ inlinedQrl(function preventDefaultOnKeysVisibleTask({ cleanup }) {
9448 const [contextService2, elementRefSig2, uniqueTabId2] = useLexicalScope();
9449 function handler(event) {
9450 if (preventedKeys.includes(event.key))
9451 event.preventDefault();
9452 contextService2.onTabKeyDown$(event.key, uniqueTabId2);
9453 }
9454 elementRefSig2.value?.addEventListener("keydown", handler);
9455 cleanup(() => {
9456 elementRefSig2.value?.removeEventListener("keydown", handler);
9457 });
9458 }, "Tab_component_useVisibleTask_1_U7QbGOyVmqY", [
9459 contextService,
9460 elementRefSig,
9461 uniqueTabId
9462 ]));
9463 const selectIfAutomatic$ = /* @__PURE__ */ inlinedQrl(() => {
9464 const [contextService2, uniqueTabId2] = useLexicalScope();
9465 contextService2.selectIfAutomatic$(uniqueTabId2);
9466 }, "Tab_component_selectIfAutomatic_lwThVCy025Y", [
9467 contextService,
9468 uniqueTabId
9469 ]);
9470 return /* @__PURE__ */ _jsxQ("button", {
9471 ref: elementRefSig
9472 }, {
9473 id: "tab-" + uniqueTabId,
9474 "data-tab-id": uniqueTabId,
9475 type: "button",
9476 role: "tab",
9477 disabled: _fnSignal((p0) => p0.disabled, [
9478 props
9479 ], "p0.disabled"),
9480 "aria-disabled": _fnSignal((p0) => p0.disabled, [
9481 props
9482 ], "p0.disabled"),
9483 "aria-selected": _fnSignal((p0) => p0.value, [
9484 isSelectedSig
9485 ], "p0.value"),
9486 tabIndex: _fnSignal((p0) => p0.value ? 0 : -1, [
9487 isSelectedSig
9488 ], "p0.value?0:-1"),
9489 "aria-controls": _fnSignal((p0) => "tabpanel-" + p0.value, [
9490 matchedTabPanelIdSig
9491 ], '"tabpanel-"+p0.value'),
9492 class: _fnSignal((p0, p1, p2) => `${p0.value ? `selected ${p2.value || ""}` : ""}${p1.class ? ` ${p1.class}` : ""}`, [
9493 isSelectedSig,
9494 props,
9495 selectedClassNameSig
9496 ], '`${p0.value?`selected ${p2.value||""}`:""}${p1.class?` ${p1.class}`:""}`'),
9497 style: _fnSignal((p0) => p0.style, [
9498 props
9499 ], "p0.style"),
9500 onFocus$: selectIfAutomatic$,
9501 onMouseEnter$: selectIfAutomatic$,
9502 onClick$: /* @__PURE__ */ inlinedQrl((event) => {
9503 const [contextService2, props2, uniqueTabId2] = useLexicalScope();
9504 contextService2.selectTab$(uniqueTabId2);
9505 if (props2.onClick$)
9506 props2.onClick$(event);
9507 }, "Tab_component_button_onClick_IFqHcg6JGuU", [
9508 contextService,
9509 props,
9510 uniqueTabId
9511 ])
9512 }, /* @__PURE__ */ _jsxC(Slot, null, 3, "J8_0"), 1, "J8_1");
9513}, "Tab_component_YMTOyfPxkj4"));
9514
9515const styles$2 = "*[data-state] {\n z-index: 99;\n position: absolute;\n opacity: 0;\n}\n\n*[data-state='positioned'] {\n display: block;\n top: var(--y, 0px);\n left: var(--x, 0px);\n transition: opacity var(--duration) linear;\n opacity: 1;\n}\n\n*[data-state='unpositioned'] {\n display: block;\n visibility: 'hidden';\n opacity: 0;\n}\n\n*[data-state='closing'] {\n top: var(--y, 0px);\n left: var(--x, 0px);\n transition: opacity var(--duration) linear;\n transition-delay: var(--duration) ms;\n opacity: 0;\n}\n\n*[data-state='hidden'] {\n display: none;\n}\n";
9516
9517const Tooltip = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
9518 const props1 = _restProps(props, [
9519 "content",
9520 "position",
9521 "durationMs"
9522 ]);
9523 useStylesScopedQrl(/* @__PURE__ */ inlinedQrl(styles$2, "Tooltip_component_useStylesScoped_3jJQGcomGNw"));
9524 const id = useId();
9525 const triggerAnchor = useSignal();
9526 const tooltipAnchor = useSignal();
9527 const stateSignal = useSignal("closing");
9528 const positionSignal = useSignal({
9529 x: 0,
9530 y: 0
9531 });
9532 const Wrapper = props1.inline ? "span" : "div";
9533 const lastActivatedTimestamp = useSignal(Date.now());
9534 const update = /* @__PURE__ */ inlinedQrl(async () => {
9535 const [lastActivatedTimestamp2, positionSignal2, props2, stateSignal2, tooltipAnchor2, triggerAnchor2] = useLexicalScope();
9536 const now = Date.now();
9537 const hasMouseEnterDebounced = now - lastActivatedTimestamp2.value >= 300;
9538 if (triggerAnchor2.value && tooltipAnchor2.value && hasMouseEnterDebounced) {
9539 const { x, y } = await O(triggerAnchor2.value, tooltipAnchor2.value, {
9540 placement: props2.position ?? "top"
9541 });
9542 lastActivatedTimestamp2.value = now;
9543 positionSignal2.value = {
9544 x,
9545 y
9546 };
9547 stateSignal2.value = "positioned";
9548 }
9549 }, "Tooltip_component_update_b7EpqFj07nQ", [
9550 lastActivatedTimestamp,
9551 positionSignal,
9552 props,
9553 stateSignal,
9554 tooltipAnchor,
9555 triggerAnchor
9556 ]);
9557 const showTooltip = /* @__PURE__ */ inlinedQrl(() => {
9558 const [props2, stateSignal2, update2] = useLexicalScope();
9559 update2();
9560 setTimeout(() => stateSignal2.value = "positioned", props2.durationMs ?? 100);
9561 }, "Tooltip_component_showTooltip_f0VZ50EMnCA", [
9562 props,
9563 stateSignal,
9564 update
9565 ]);
9566 const hideTooltip = /* @__PURE__ */ inlinedQrl(() => {
9567 const [props2, stateSignal2] = useLexicalScope();
9568 setTimeout(() => stateSignal2.value = "closing", props2.durationMs ?? 100);
9569 }, "Tooltip_component_hideTooltip_o30x7aVxT7s", [
9570 props,
9571 stateSignal
9572 ]);
9573 useOnWindow("keyup", /* @__PURE__ */ inlinedQrl((e) => {
9574 const [hideTooltip2] = useLexicalScope();
9575 const key = e.key;
9576 if (key === "Escape")
9577 hideTooltip2();
9578 }, "Tooltip_component_useOnWindow_WXI9sB3m6wo", [
9579 hideTooltip
9580 ]));
9581 useVisibleTaskQrl(/* @__PURE__ */ inlinedQrl(({ track }) => {
9582 const [stateSignal2, update2] = useLexicalScope();
9583 const state = track(() => stateSignal2.value);
9584 if (state === "unpositioned")
9585 update2();
9586 }, "Tooltip_component_useVisibleTask_MxQUZYxM4x8", [
9587 stateSignal,
9588 update
9589 ]));
9590 return /* @__PURE__ */ _jsxC(Fragment, {
9591 children: [
9592 /* @__PURE__ */ _jsxC(Wrapper, {
9593 style: "width: fit-content;",
9594 tabIndex: 0,
9595 ref: triggerAnchor,
9596 onMouseEnter$: /* @__PURE__ */ inlinedQrl(() => {
9597 const [showTooltip2] = useLexicalScope();
9598 return showTooltip2();
9599 }, "Tooltip_component__Fragment_Wrapper_onMouseEnter_Ct50X7n7U6E", [
9600 showTooltip
9601 ]),
9602 onMouseLeave$: /* @__PURE__ */ inlinedQrl(() => {
9603 const [hideTooltip2] = useLexicalScope();
9604 return hideTooltip2();
9605 }, "Tooltip_component__Fragment_Wrapper_onMouseLeave_oOqwq92vOlc", [
9606 hideTooltip
9607 ]),
9608 onFocus$: /* @__PURE__ */ inlinedQrl(() => {
9609 const [showTooltip2] = useLexicalScope();
9610 return showTooltip2();
9611 }, "Tooltip_component__Fragment_Wrapper_onFocus_Xt6DxIpnfrQ", [
9612 showTooltip
9613 ]),
9614 onBlur$: /* @__PURE__ */ inlinedQrl(() => {
9615 const [hideTooltip2] = useLexicalScope();
9616 return hideTooltip2();
9617 }, "Tooltip_component__Fragment_Wrapper_onBlur_UuCe1StpMkw", [
9618 hideTooltip
9619 ]),
9620 // need an id for the tooltip;
9621 "aria-describedby": `#${id}`,
9622 children: /* @__PURE__ */ _jsxC(Slot, null, 3, "CG_0"),
9623 [_IMMUTABLE]: {
9624 style: _IMMUTABLE,
9625 tabIndex: _IMMUTABLE,
9626 ref: _IMMUTABLE,
9627 onMouseEnter$: _IMMUTABLE,
9628 onMouseLeave$: _IMMUTABLE,
9629 onFocus$: _IMMUTABLE,
9630 onBlur$: _IMMUTABLE,
9631 "aria-describedby": _IMMUTABLE
9632 }
9633 }, 1, "CG_1"),
9634 /* @__PURE__ */ _jsxC(Wrapper, {
9635 class: `${stateSignal.value} ${props1.class || ""}`,
9636 id,
9637 onAnimationEnd$: /* @__PURE__ */ inlinedQrl(() => {
9638 const [positionSignal2, stateSignal2] = useLexicalScope();
9639 if (stateSignal2.value == "closing") {
9640 stateSignal2.value = "hidden";
9641 positionSignal2.value = {
9642 x: 0,
9643 y: 0
9644 };
9645 }
9646 }, "Tooltip_component__Fragment_Wrapper_onAnimationEnd_v1ENxh73TXA", [
9647 positionSignal,
9648 stateSignal
9649 ]),
9650 ref: tooltipAnchor,
9651 role: "tooltip",
9652 ...props1,
9653 get style() {
9654 return `--duration: ${props.durationMs ?? 100}ms;--x: ${positionSignal.value.x || 0}px;--y: ${positionSignal.value.y || 0}px;`;
9655 },
9656 get "data-state"() {
9657 return stateSignal.value;
9658 },
9659 children: _fnSignal((p0) => p0.content, [
9660 props
9661 ], "p0.content"),
9662 [_IMMUTABLE]: {
9663 id: _IMMUTABLE,
9664 onAnimationEnd$: _IMMUTABLE,
9665 ref: _IMMUTABLE,
9666 role: _IMMUTABLE,
9667 style: _fnSignal((p0, p1) => `--duration: ${p1.durationMs ?? 100}ms;--x: ${p0.value.x || 0}px;--y: ${p0.value.y || 0}px;`, [
9668 positionSignal,
9669 props
9670 ], "`--duration: ${p1.durationMs??100}ms;`+`--x: ${p0.value.x||0}px;`+`--y: ${p0.value.y||0}px;`"),
9671 "data-state": _fnSignal((p0) => p0.value, [
9672 stateSignal
9673 ], "p0.value")
9674 }
9675 }, 0, "CG_2")
9676 ]
9677 }, 1, "CG_3");
9678}, "Tooltip_component_EkDvuGlapJE"));
9679
9680const Label = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl(({ ...props }) => {
9681 return /* @__PURE__ */ _jsxS("label", {
9682 ...props,
9683 children: /* @__PURE__ */ _jsxC(Slot, null, 3, "Ig_0")
9684 }, null, 0, "Ig_1");
9685}, "Label_component_Pzm7AZJhfxk"));
9686const Root = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
9687 const props1 = _restProps(props, [
9688 "checked",
9689 "disabled",
9690 "name",
9691 "ariaLabel",
9692 "id",
9693 "value",
9694 "tabIndex",
9695 "onChange"
9696 ]);
9697 return /* @__PURE__ */ _jsxS("input", {
9698 ...props1,
9699 onChange$: /* @__PURE__ */ inlinedQrl((event, element) => {
9700 const [props2] = useLexicalScope();
9701 if (props2.onChange)
9702 props2.onChange(event, element);
9703 }, "Root_component_input_onChange_1aPAS0tiahc", [
9704 props
9705 ])
9706 }, {
9707 type: "checkbox",
9708 role: "checkbox",
9709 checked: _fnSignal((p0) => p0.checked, [
9710 props
9711 ], "p0.checked"),
9712 disabled: _fnSignal((p0) => p0.disabled, [
9713 props
9714 ], "p0.disabled"),
9715 name: _fnSignal((p0) => p0.name, [
9716 props
9717 ], "p0.name"),
9718 id: _fnSignal((p0) => p0.id, [
9719 props
9720 ], "p0.id"),
9721 "aria-label": _fnSignal((p0) => p0.ariaLabel, [
9722 props
9723 ], "p0.ariaLabel"),
9724 "aria-checked": _fnSignal((p0) => p0.checked, [
9725 props
9726 ], "p0.checked"),
9727 value: _fnSignal((p0) => p0.value, [
9728 props
9729 ], "p0.value"),
9730 tabIndex: _fnSignal((p0) => p0.tabIndex, [
9731 props
9732 ], "p0.tabIndex")
9733 }, 0, "Ig_2");
9734}, "Root_component_kVvUFAgmRvA"));
9735
9736const checkbox = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
9737 __proto__: null,
9738 Label,
9739 Root
9740}, Symbol.toStringTag, { value: 'Module' }));
9741
9742const SelectContextId = createContextId("select-root");
9743
9744const NativeSelect = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl(({ ...props }) => {
9745 const selectContext = useContext(SelectContextId);
9746 const ref = useSignal();
9747 useVisibleTaskQrl(/* @__PURE__ */ inlinedQrl(function populateNativeSelect({ track }) {
9748 const [ref2, selectContext2] = useLexicalScope();
9749 const options = track(() => selectContext2.optionsStore);
9750 options.length > 0 && options.map((option) => {
9751 const optionElement = document.createElement("option");
9752 const optionValue = option.dataset.optionValue;
9753 optionElement.setAttribute("value", optionValue);
9754 ref2.value?.append(optionElement);
9755 });
9756 }, "NativeSelect_component_useVisibleTask_pVEAV0jZR2M", [
9757 ref,
9758 selectContext
9759 ]));
9760 useOn("change", /* @__PURE__ */ inlinedQrl((e) => {
9761 const [selectContext2] = useLexicalScope();
9762 const target = e.target;
9763 target.value = selectContext2.selectedOptionSig.value;
9764 }, "NativeSelect_component_useOn_P80AUva3Pw4", [
9765 selectContext
9766 ]));
9767 return /* @__PURE__ */ _jsxS("select", {
9768 ref,
9769 ...props,
9770 children: /* @__PURE__ */ _jsxQ("option", null, {
9771 value: ""
9772 }, null, 3, null),
9773 "onInput$": /* @__PURE__ */ inlinedQrl((_, elm) => {
9774 const [selectContext2] = useLexicalScope();
9775 return selectContext2.selectedOptionSig.value = elm.value;
9776 }, "NativeSelect_component_select_bind_value_RqRmmyGaw0A", [
9777 selectContext
9778 ])
9779 }, {
9780 required: true,
9781 "aria-hidden": true,
9782 tabIndex: -1,
9783 "value": selectContext.selectedOptionSig
9784 }, 0, "HX_0");
9785}, "NativeSelect_component_6RhFHBnWeog"));
9786
9787const VisuallyHidden = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl(() => {
9788 useStylesScopedQrl(/* @__PURE__ */ inlinedQrl(`
9789 .visually-hidden {
9790 display: inline-block;
9791 position: absolute;
9792 overflow: hidden;
9793 clip: rect(0 0 0 0);
9794 height: 1px;
9795 width: 1px;
9796 margin: -1px;
9797 padding: 0px;
9798 border: 0px;
9799 }
9800`, "VisuallyHidden_component_useStylesScoped_yTtqyywH0O4"));
9801 return /* @__PURE__ */ _jsxQ("span", null, {
9802 class: "visually-hidden"
9803 }, /* @__PURE__ */ _jsxC(Slot, null, 3, "dt_0"), 1, "dt_1");
9804}, "VisuallyHidden_component_FYJJRLsRmAY"));
9805
9806const SelectRoot = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
9807 _jsxBranch();
9808 const rootRefSig = useSignal();
9809 const optionsStore = useStore([]);
9810 const selectedOptionSig = useSignal("");
9811 const isOpenSig = useSignal(false);
9812 const triggerRefSig = useSignal();
9813 const listBoxRefSig = useSignal();
9814 const selectContext = {
9815 optionsStore,
9816 selectedOptionSig,
9817 isOpenSig,
9818 triggerRefSig,
9819 listBoxRefSig
9820 };
9821 useContextProvider(SelectContextId, selectContext);
9822 useOnDocument("click", /* @__PURE__ */ inlinedQrl((e) => {
9823 const [rootRefSig2, selectContext2] = useLexicalScope();
9824 const target = e.target;
9825 if (selectContext2.isOpenSig.value === true && !rootRefSig2.value?.contains(target))
9826 selectContext2.isOpenSig.value = false;
9827 }, "SelectRoot_component_useOnDocument_COnj037onYs", [
9828 rootRefSig,
9829 selectContext
9830 ]));
9831 useVisibleTaskQrl(/* @__PURE__ */ inlinedQrl(function setKeyHandler({ cleanup }) {
9832 const [rootRefSig2, selectContext2] = useLexicalScope();
9833 function keyHandler(e) {
9834 e.preventDefault();
9835 if (e.key === "Escape")
9836 selectContext2.isOpenSig.value = false;
9837 }
9838 rootRefSig2.value?.addEventListener("keydown", keyHandler);
9839 cleanup(() => {
9840 rootRefSig2.value?.removeEventListener("keydown", keyHandler);
9841 });
9842 }, "SelectRoot_component_useVisibleTask_pNx9pkBC1tI", [
9843 rootRefSig,
9844 selectContext
9845 ]));
9846 const updatePosition$ = /* @__PURE__ */ inlinedQrl((referenceEl, floatingEl) => {
9847 O(referenceEl, floatingEl, {
9848 placement: "bottom",
9849 middleware: [
9850 b$1()
9851 ]
9852 }).then(({ x, y }) => {
9853 Object.assign(floatingEl.style, {
9854 left: `${x}px`,
9855 top: `${y}px`
9856 });
9857 });
9858 }, "SelectRoot_component_updatePosition_Bp5svGmsvFc");
9859 useVisibleTaskQrl(/* @__PURE__ */ inlinedQrl(async function toggleSelectListBox({ track }) {
9860 const [selectContext2, updatePosition$2] = useLexicalScope();
9861 const trigger = track(() => selectContext2.triggerRefSig.value);
9862 const listBox = track(() => selectContext2.listBoxRefSig.value);
9863 const expanded = track(() => selectContext2.isOpenSig.value);
9864 if (!trigger || !listBox)
9865 return;
9866 if (expanded === true) {
9867 listBox.style.visibility = "hidden";
9868 await updatePosition$2(trigger, listBox);
9869 listBox.style.visibility = "visible";
9870 listBox?.focus();
9871 }
9872 if (expanded === false)
9873 trigger?.focus();
9874 }, "SelectRoot_component_useVisibleTask_1_N7H39giT6pA", [
9875 selectContext,
9876 updatePosition$
9877 ]));
9878 useVisibleTaskQrl(/* @__PURE__ */ inlinedQrl(function collectOptions({ track }) {
9879 const [selectContext2] = useLexicalScope();
9880 const listBox = track(() => selectContext2.listBoxRefSig.value);
9881 if (listBox) {
9882 const collectedOptions = Array.from(listBox.querySelectorAll('[role="option"]'));
9883 selectContext2.optionsStore.push(...collectedOptions);
9884 }
9885 }, "SelectRoot_component_useVisibleTask_2_tytKysVfH9M", [
9886 selectContext
9887 ]));
9888 return /* @__PURE__ */ _jsxS("div", {
9889 ref: rootRefSig,
9890 ...props,
9891 children: [
9892 /* @__PURE__ */ _jsxC(Slot, null, 3, "Bs_0"),
9893 props.required ? /* @__PURE__ */ _jsxC(VisuallyHidden, {
9894 children: /* @__PURE__ */ _jsxC(NativeSelect, null, 3, "Bs_1")
9895 }, 1, "Bs_2") : null
9896 ]
9897 }, null, 0, "Bs_3");
9898}, "SelectRoot_component_1P8uqC3afXw"));
9899
9900const SelectTrigger = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
9901 const selectContext = useContext(SelectContextId);
9902 const triggerRef = useSignal();
9903 selectContext.triggerRefSig = triggerRef;
9904 useVisibleTaskQrl(/* @__PURE__ */ inlinedQrl(function setClickHandler({ cleanup }) {
9905 const [selectContext2, triggerRef2] = useLexicalScope();
9906 function clickHandler(e) {
9907 e.preventDefault();
9908 selectContext2.isOpenSig.value = !selectContext2.isOpenSig.value;
9909 }
9910 triggerRef2.value?.addEventListener("click", clickHandler);
9911 cleanup(() => {
9912 triggerRef2.value?.removeEventListener("click", clickHandler);
9913 });
9914 }, "SelectTrigger_component_useVisibleTask_80qoWIXMIfc", [
9915 selectContext,
9916 triggerRef
9917 ]));
9918 useVisibleTaskQrl(/* @__PURE__ */ inlinedQrl(function setKeyHandler({ cleanup }) {
9919 const [selectContext2, triggerRef2] = useLexicalScope();
9920 function keyHandler(e) {
9921 if (e.key === "Home" || e.key === "End")
9922 e.preventDefault();
9923 if (e.key === "ArrowDown" || e.key === "ArrowUp" || e.key === "Enter" || e.key === " ")
9924 selectContext2.isOpenSig.value = true;
9925 }
9926 triggerRef2.value?.addEventListener("keydown", keyHandler);
9927 cleanup(() => {
9928 triggerRef2.value?.removeEventListener("keydown", keyHandler);
9929 });
9930 }, "SelectTrigger_component_useVisibleTask_1_wQEhBlyku50", [
9931 selectContext,
9932 triggerRef
9933 ]));
9934 return /* @__PURE__ */ _jsxS("button", {
9935 ref: triggerRef,
9936 ...props,
9937 children: /* @__PURE__ */ _jsxC(Slot, null, 3, "VR_0")
9938 }, {
9939 "aria-expanded": _fnSignal((p0) => p0.isOpenSig.value, [
9940 selectContext
9941 ], "p0.isOpenSig.value")
9942 }, 0, "VR_1");
9943}, "SelectTrigger_component_QNah0rGW5hg"));
9944
9945const SelectValue = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
9946 const props1 = _restProps(props, [
9947 "placeholder"
9948 ]);
9949 const selectContext = useContext(SelectContextId);
9950 const value = selectContext.selectedOptionSig.value;
9951 return /* @__PURE__ */ _jsxS("span", {
9952 ...props1,
9953 children: value ? value : props.placeholder
9954 }, null, 0, "2w_0");
9955}, "SelectValue_component_n92TrcEV90g"));
9956
9957const SelectMarker = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
9958 return /* @__PURE__ */ _jsxS("span", {
9959 ...props,
9960 children: /* @__PURE__ */ _jsxC(Slot, null, 3, "hy_0")
9961 }, {
9962 "aria-hidden": "true"
9963 }, 0, "hy_1");
9964}, "SelectMarker_component_V0aNrwDAk2g"));
9965
9966const SelectListBox = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
9967 const listBoxRef = useSignal();
9968 const selectContext = useContext(SelectContextId);
9969 selectContext.listBoxRefSig = listBoxRef;
9970 useVisibleTaskQrl(/* @__PURE__ */ inlinedQrl(function setKeyHandler({ cleanup }) {
9971 const [listBoxRef2, selectContext2] = useLexicalScope();
9972 function keyHandler(e) {
9973 const availableOptions = selectContext2.optionsStore.filter((option) => !(option?.getAttribute("aria-disabled") === "true"));
9974 const target = e.target;
9975 const currentIndex = availableOptions.indexOf(target);
9976 if (e.key === "ArrowDown" || e.key === "ArrowUp" || e.key === "Home" || e.key === "End" || e.key === " ")
9977 e.preventDefault();
9978 if (e.key === "ArrowDown") {
9979 if (currentIndex === availableOptions.length - 1)
9980 availableOptions[0]?.focus();
9981 else
9982 availableOptions[currentIndex + 1]?.focus();
9983 }
9984 if (e.key === "ArrowUp") {
9985 if (currentIndex <= 0)
9986 availableOptions[availableOptions.length - 1]?.focus();
9987 else
9988 availableOptions[currentIndex - 1]?.focus();
9989 }
9990 }
9991 listBoxRef2.value?.addEventListener("keydown", keyHandler);
9992 cleanup(() => {
9993 listBoxRef2.value?.removeEventListener("keydown", keyHandler);
9994 });
9995 }, "SelectListBox_component_useVisibleTask_NZcLPc4zmDI", [
9996 listBoxRef,
9997 selectContext
9998 ]));
9999 return /* @__PURE__ */ _jsxQ("ul", {
10000 ref: listBoxRef
10001 }, {
10002 role: "listbox",
10003 tabIndex: 0,
10004 style: _fnSignal((p0, p1) => `
10005 display: ${p1.isOpenSig.value ? "block" : "none"};
10006 position: absolute;
10007 z-index: 1;
10008 ${p0.style}
10009 `, [
10010 props,
10011 selectContext
10012 ], '`\n display: ${p1.isOpenSig.value?"block":"none"};\n position: absolute;\n z-index: 1;\n ${p0.style}\n `'),
10013 class: _fnSignal((p0) => p0.class, [
10014 props
10015 ], "p0.class")
10016 }, /* @__PURE__ */ _jsxC(Slot, null, 3, "bD_0"), 1, "bD_1");
10017}, "SelectListBox_component_DIywLbk0fWc"));
10018
10019const SelectLabel = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
10020 return /* @__PURE__ */ _jsxS("label", {
10021 ...props,
10022 children: /* @__PURE__ */ _jsxC(Slot, null, 3, "HV_0")
10023 }, null, 0, "HV_1");
10024}, "SelectLabel_component_a19fWjuylJ0"));
10025
10026const SelectGroup = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
10027 const props1 = _restProps(props, [
10028 "disabled"
10029 ]);
10030 return /* @__PURE__ */ _jsxS("div", {
10031 ...props1,
10032 children: /* @__PURE__ */ _jsxC(Slot, null, 3, "B4_0")
10033 }, {
10034 role: "group",
10035 "aria-disabled": _fnSignal((p0) => p0.disabled, [
10036 props
10037 ], "p0.disabled")
10038 }, 0, "B4_1");
10039}, "SelectGroup_component_cjNOIcJWsZ8"));
10040
10041const selectOptionPreventedKeys = [
10042 KeyCode.ArrowDown,
10043 KeyCode.ArrowUp
10044];
10045const SelectOption = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
10046 const props1 = _restProps(props, [
10047 "disabled",
10048 "optionValue"
10049 ]);
10050 const selectContext = useContext(SelectContextId);
10051 const optionRef = useSignal();
10052 useVisibleTaskQrl(/* @__PURE__ */ inlinedQrl(function setKeyHandler({ cleanup }) {
10053 const [optionRef2, props2, selectContext2] = useLexicalScope();
10054 function keyHandler(e) {
10055 const target = e.target;
10056 if (selectOptionPreventedKeys.includes(e.key))
10057 e.preventDefault();
10058 if (!props2.disabled && e.key === "Tab" && target.dataset.optionValue === props2.optionValue) {
10059 selectContext2.selectedOptionSig.value = props2.optionValue;
10060 selectContext2.isOpenSig.value = false;
10061 }
10062 if (!props2.disabled && (e.key === "Enter" || e.key === " ") && target.dataset.optionValue === props2.optionValue) {
10063 selectContext2.selectedOptionSig.value = props2.optionValue;
10064 selectContext2.isOpenSig.value = false;
10065 }
10066 }
10067 optionRef2.value?.addEventListener("keydown", keyHandler);
10068 cleanup(() => {
10069 optionRef2.value?.removeEventListener("keydown", keyHandler);
10070 });
10071 }, "SelectOption_component_useVisibleTask_C0A5tMhisJE", [
10072 optionRef,
10073 props,
10074 selectContext
10075 ]));
10076 return /* @__PURE__ */ _jsxS("li", {
10077 ref: optionRef,
10078 ...props1,
10079 children: /* @__PURE__ */ _jsxC(Slot, null, 3, "jc_0"),
10080 onClick$: /* @__PURE__ */ inlinedQrl(() => {
10081 const [props2, selectContext2] = useLexicalScope();
10082 if (!props2.disabled) {
10083 selectContext2.selectedOptionSig.value = props2.optionValue;
10084 selectContext2.isOpenSig.value = false;
10085 }
10086 }, "SelectOption_component_li_onClick_zdGdPG2nGAc", [
10087 props,
10088 selectContext
10089 ]),
10090 onMouseEnter$: /* @__PURE__ */ inlinedQrl((e) => {
10091 const [props2] = useLexicalScope();
10092 if (!props2.disabled) {
10093 const target = e.target;
10094 target.focus();
10095 }
10096 }, "SelectOption_component_li_onMouseEnter_S77g6fL7cdU", [
10097 props
10098 ])
10099 }, {
10100 role: "option",
10101 tabIndex: _fnSignal((p0) => p0.disabled ? -1 : 0, [
10102 props
10103 ], "p0.disabled?-1:0"),
10104 "aria-disabled": _fnSignal((p0) => p0.disabled, [
10105 props
10106 ], "p0.disabled"),
10107 "aria-selected": _fnSignal((p0, p1) => p0.optionValue === p1.selectedOptionSig.value, [
10108 props,
10109 selectContext
10110 ], "p0.optionValue===p1.selectedOptionSig.value"),
10111 "data-option-value": _fnSignal((p0) => p0.optionValue, [
10112 props
10113 ], "p0.optionValue")
10114 }, 0, "jc_1");
10115}, "SelectOption_component_CfpmGeuNdpE"));
10116
10117const getPercentage = (value, min = 0, max = 100) => {
10118 return (value - min) * 100 / (max - min);
10119};
10120const sliderContext = createContextId("slider");
10121const Slider = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
10122 const rootPositionRef = useSignal();
10123 const sliderValue = useSignal(props.value ?? 0);
10124 const minSignal = useSignal(props.min ?? 0);
10125 const maxSignal = useSignal(props.max ?? 100);
10126 const positionXSignal = useSignal();
10127 const percentageSignal = useSignal(getPercentage(props.value ?? 0, props.min ?? 0, props.max ?? 100));
10128 const contextService = {
10129 value: sliderValue,
10130 min: minSignal,
10131 max: maxSignal,
10132 positionX: positionXSignal,
10133 percentage: percentageSignal
10134 };
10135 useVisibleTaskQrl(/* @__PURE__ */ inlinedQrl(async ({ track }) => {
10136 const [contextService2, rootPositionRef2] = useLexicalScope();
10137 track(() => rootPositionRef2);
10138 contextService2.positionX.value = rootPositionRef2.value?.getBoundingClientRect().x;
10139 }, "Slider_component_useVisibleTask_NP0ylIsByoU", [
10140 contextService,
10141 rootPositionRef
10142 ]));
10143 useVisibleTaskQrl(/* @__PURE__ */ inlinedQrl(async ({ track }) => {
10144 const [contextService2, props2, sliderValue2] = useLexicalScope();
10145 const newValue = track(() => sliderValue2.value);
10146 if (props2.onChange$)
10147 props2.onChange$(newValue);
10148 contextService2.percentage.value = getPercentage(newValue, props2.min ?? 0, props2.max ?? 100);
10149 }, "Slider_component_useVisibleTask_1_R0adHmt3YDo", [
10150 contextService,
10151 props,
10152 sliderValue
10153 ]));
10154 useContextProvider(sliderContext, contextService);
10155 return /* @__PURE__ */ _jsxQ("div", {
10156 ref: rootPositionRef,
10157 style: `
10158 display: inline-block;
10159 position: relative;
10160 border: solid 1px rgb(178,178,178);
10161 border-radius: 4px;
10162 background: rgb(239,239,239);
10163 width: 100px;
10164 height: 6px;
10165 ${props.style ?? ""}
10166 `
10167 }, {
10168 class: _fnSignal((p0) => p0.class, [
10169 props
10170 ], "p0.class")
10171 }, /* @__PURE__ */ _jsxC(Slot, null, 3, "aU_0"), 1, "aU_1");
10172}, "Slider_component_kkWQbL6dvII"));
10173
10174const SliderProgress = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
10175 const contextService = useContext(sliderContext);
10176 return /* @__PURE__ */ _jsxQ("div", {
10177 style: `
10178 display: block;
10179 position: absolute;
10180 top: 0;
10181 height: 100%;
10182 left: 0;
10183 width: ${contextService.percentage.value}%;
10184 background: rgb(0,117,255);
10185 ${props.style ?? ""}
10186 `
10187 }, null, /* @__PURE__ */ _jsxC(Slot, null, 3, "qk_0"), 1, "qk_1");
10188}, "SliderProgress_component_33gj9jGWq9c"));
10189
10190const clamp = (value, min, max) => {
10191 return Math.min(max, Math.max(value, min));
10192};
10193const SliderThumb = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
10194 const mouseDownHappenedSignal = useSignal(false);
10195 const contextService = useContext(sliderContext);
10196 const handleMouseDown = /* @__PURE__ */ inlinedQrl((e) => {
10197 const [contextService2, mouseDownHappenedSignal2] = useLexicalScope();
10198 if (contextService2.positionX.value)
10199 contextService2.value.value = clamp(e.pageX - contextService2.positionX.value, contextService2.min.value, contextService2.max.value);
10200 mouseDownHappenedSignal2.value = true;
10201 }, "SliderThumb_component_handleMouseDown_D8WvLnKHNUw", [
10202 contextService,
10203 mouseDownHappenedSignal
10204 ]);
10205 useOnWindow("mousemove", /* @__PURE__ */ inlinedQrl((e) => {
10206 const [contextService2, mouseDownHappenedSignal2] = useLexicalScope();
10207 if (contextService2.positionX.value && mouseDownHappenedSignal2.value)
10208 contextService2.value.value = clamp(e.pageX - contextService2.positionX.value, contextService2.min.value, contextService2.max.value);
10209 }, "SliderThumb_component_useOnWindow_kd2cGCnxV3Y", [
10210 contextService,
10211 mouseDownHappenedSignal
10212 ]));
10213 useOnWindow("mouseup", /* @__PURE__ */ inlinedQrl((e) => {
10214 const [contextService2, mouseDownHappenedSignal2] = useLexicalScope();
10215 if (contextService2.positionX.value && mouseDownHappenedSignal2.value)
10216 contextService2.value.value = clamp(e.pageX - contextService2.positionX.value, contextService2.min.value, contextService2.max.value);
10217 mouseDownHappenedSignal2.value = false;
10218 }, "SliderThumb_component_useOnWindow_1_mV7WaK4570w", [
10219 contextService,
10220 mouseDownHappenedSignal
10221 ]));
10222 return /* @__PURE__ */ _jsxQ("div", {
10223 style: `
10224 width: 20px;
10225 height: 20px;
10226 border-radius: 20px;
10227 background: rgba(0, 0, 250);
10228 position: absolute;
10229 transform: translateX(-50%) translateY(-50%);
10230 top: 50%;
10231 left: ${contextService.percentage.value}%;
10232 ${props.style ?? ""}
10233 `
10234 }, {
10235 onMouseDown$: handleMouseDown
10236 }, /* @__PURE__ */ _jsxC(Slot, null, 3, "fJ_0"), 1, "fJ_1");
10237}, "SliderThumb_component_MhzlhYr2v00"));
10238
10239const styles$1 = "div {\n display: flex;\n align-items: center;\n white-space: nowrap;\n min-height: min-content;\n}\n";
10240
10241const Breadcrumb = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
10242 useStylesScopedQrl(/* @__PURE__ */ inlinedQrl(styles$1, "Breadcrumb_component_useStylesScoped_YdJO4h7hr8c"));
10243 return /* @__PURE__ */ _jsxS("div", {
10244 ...props,
10245 children: /* @__PURE__ */ _jsxC(Slot, null, 3, "TD_0")
10246 }, null, 0, "TD_1");
10247}, "Breadcrumb_component_qXV38D0buf0"));
10248
10249const styles = "div {\n display: flex;\n align-items: center;\n}\n\ndiv + *:before {\n content: var(--breadcrumb-divider, '/');\n padding-left: 0.3rem;\n padding-right: 0.4rem;\n display: block;\n opacity: 0.5;\n}\n";
10250
10251const BreadcrumbItem = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
10252 const rest = _restProps(props, [
10253 "style"
10254 ]);
10255 useStylesScopedQrl(/* @__PURE__ */ inlinedQrl(styles, "BreadcrumbItem_component_useStylesScoped_cV2FdW4yhEg"));
10256 return /* @__PURE__ */ _jsxS("div", {
10257 style: clsq(`--breadcrumb-divider: "${props.divider || "/"}"`, props.style),
10258 ...rest,
10259 children: /* @__PURE__ */ _jsxC(Slot, null, 3, "2g_0")
10260 }, null, 0, "2g_1");
10261}, "BreadcrumbItem_component_ey1Ts6yA9hg"));
10262
10263const NavigationBar = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
10264 return /* @__PURE__ */ _jsxS("div", {
10265 ...props,
10266 children: /* @__PURE__ */ _jsxC(Slot, null, 3, "O0_0")
10267 }, null, 0, "O0_1");
10268}, "NavigationBar_component_H8UDNL4h6Rc"));
10269
10270export { AccordionContent, AccordionHeader, AccordionItem, AccordionRoot, AccordionTrigger, AutocompleteControl, AutocompleteInput, AutocompleteLabel, AutocompleteListbox, AutocompleteOption, AutocompleteRoot, AutocompleteTrigger, Badge, Breadcrumb, BreadcrumbItem, ButtonGroup, CSS_CLASS_NAMES, Card, CardActions, CardBody, CardImage, CardTitle, carousel as Carousel, checkbox as Checkbox, checkbox as CheckboxProps, Collapse, DefaultIcon, Drawer, DrawerContent, DrawerTrigger, input as Input, InputPhone, KEYBOARD_KEY_NAME, Menu, MenuItem, NativeSelect, NavigationBar, Pagination, PaginationButton, PaginationDivider, Popover, PopoverContent, PopoverTrigger, Rating, RatingIcon, SelectGroup, SelectLabel, SelectListBox, SelectMarker, SelectOption, SelectRoot, SelectTrigger, SelectValue, Slider, SliderProgress, SliderThumb, Spinner, Tab, TabList, TabPanel, Tabs, Tooltip, accordionPreventedKeys as _auto_accordionPreventedKeys, autocompletePreventedKeys as _auto_autocompletePreventedKeys, preventedKeys$1 as _auto_preventedKeys, accordionItemContextId, accordionRootContextId, clamp, drawerContext, find, findBySelectValue, findCountryByUserTimezone, getPageFromActiveItem, getPaginationButtons, getPercentage, preventedKeys, quiMenuContext, selectOptionPreventedKeys, sliderContext, tabsContextId, useCarousel, useItems, usePages, useScroll, useVisible };