@wazo/sdk 1.0.0-alpha.4 → 1.0.0-alpha.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/wazo-sdk.js CHANGED
@@ -39,5 +39,5 @@ var Ye=function(){var e=new RegExp('(?:false|true|null|[\\{\\}\\[\\]]|(?:-?\\b(?
39
39
 
40
40
  See the Apache Version 2.0 License for specific language governing permissions
41
41
  and limitations under the License.
42
- ***************************************************************************** */function ad(e,t){function i(){this.constructor=e}sd(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}function od(e,t){var i="function"==typeof Symbol&&e[Symbol.iterator];if(!i)return e;var n,r,s=i.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=s.next()).done;)a.push(n.value)}catch(e){r={error:e}}finally{try{n&&!n.done&&(i=s.return)&&i.call(s)}finally{if(r)throw r.error}}return a}var cd=function(e,t){this.target=t,this.type=e},dd=function(e){function t(t,i){var n=e.call(this,"error",i)||this;return n.message=t.message,n.error=t,n}return ad(t,e),t}(cd),ld=function(e){function t(t,i,n){void 0===t&&(t=1e3),void 0===i&&(i="");var r=e.call(this,"close",n)||this;return r.wasClean=!0,r.code=t,r.reason=i,r}return ad(t,e),t}(cd),hd=function(){if("undefined"!=typeof WebSocket)return WebSocket},ud={maxReconnectionDelay:1e4,minReconnectionDelay:1e3+4e3*Math.random(),minUptime:5e3,reconnectionDelayGrowFactor:1.3,connectionTimeout:4e3,maxRetries:1/0,maxEnqueuedMessages:1/0,startClosed:!1,debug:!1},pd=function(){function e(e,t,i){var n=this;void 0===i&&(i={}),this._listeners={error:[],message:[],open:[],close:[]},this._retryCount=-1,this._shouldReconnect=!0,this._connectLock=!1,this._binaryType="blob",this._closeCalled=!1,this._messageQueue=[],this.onclose=null,this.onerror=null,this.onmessage=null,this.onopen=null,this._handleOpen=function(e){n._debug("open event");var t=n._options.minUptime,i=void 0===t?ud.minUptime:t;clearTimeout(n._connectTimeout),n._uptimeTimeout=setTimeout((function(){return n._acceptOpen()}),i),n._ws.binaryType=n._binaryType,n._messageQueue.forEach((function(e){return n._ws.send(e)})),n._messageQueue=[],n.onopen&&n.onopen(e),n._listeners.open.forEach((function(t){return n._callEventListener(e,t)}))},this._handleMessage=function(e){n._debug("message event"),n.onmessage&&n.onmessage(e),n._listeners.message.forEach((function(t){return n._callEventListener(e,t)}))},this._handleError=function(e){n._debug("error event",e.message),n._disconnect(void 0,"TIMEOUT"===e.message?"timeout":void 0),n.onerror&&n.onerror(e),n._debug("exec error listeners"),n._listeners.error.forEach((function(t){return n._callEventListener(e,t)})),n._connect()},this._handleClose=function(e){n._debug("close event"),n._clearTimeouts(),n._shouldReconnect&&n._connect(),n.onclose&&n.onclose(e),n._listeners.close.forEach((function(t){return n._callEventListener(e,t)}))},this._url=e,this._protocols=t,this._options=i,this._options.startClosed&&(this._shouldReconnect=!1),this._connect()}return Object.defineProperty(e,"CONNECTING",{get:function(){return 0},enumerable:!0,configurable:!0}),Object.defineProperty(e,"OPEN",{get:function(){return 1},enumerable:!0,configurable:!0}),Object.defineProperty(e,"CLOSING",{get:function(){return 2},enumerable:!0,configurable:!0}),Object.defineProperty(e,"CLOSED",{get:function(){return 3},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"CONNECTING",{get:function(){return e.CONNECTING},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"OPEN",{get:function(){return e.OPEN},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"CLOSING",{get:function(){return e.CLOSING},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"CLOSED",{get:function(){return e.CLOSED},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"binaryType",{get:function(){return this._ws?this._ws.binaryType:this._binaryType},set:function(e){this._binaryType=e,this._ws&&(this._ws.binaryType=e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"retryCount",{get:function(){return Math.max(this._retryCount,0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"bufferedAmount",{get:function(){return this._messageQueue.reduce((function(e,t){return"string"==typeof t?e+=t.length:t instanceof Blob?e+=t.size:e+=t.byteLength,e}),0)+(this._ws?this._ws.bufferedAmount:0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"extensions",{get:function(){return this._ws?this._ws.extensions:""},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"protocol",{get:function(){return this._ws?this._ws.protocol:""},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"readyState",{get:function(){return this._ws?this._ws.readyState:this._options.startClosed?e.CLOSED:e.CONNECTING},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"url",{get:function(){return this._ws?this._ws.url:""},enumerable:!0,configurable:!0}),e.prototype.close=function(e,t){void 0===e&&(e=1e3),this._closeCalled=!0,this._shouldReconnect=!1,this._clearTimeouts(),this._ws?this._ws.readyState!==this.CLOSED?this._ws.close(e,t):this._debug("close: already closed"):this._debug("close enqueued: no ws instance")},e.prototype.reconnect=function(e,t){this._shouldReconnect=!0,this._closeCalled=!1,this._retryCount=-1,this._ws&&this._ws.readyState!==this.CLOSED?(this._disconnect(e,t),this._connect()):this._connect()},e.prototype.send=function(e){if(this._ws&&this._ws.readyState===this.OPEN)this._debug("send",e),this._ws.send(e);else{var t=this._options.maxEnqueuedMessages,i=void 0===t?ud.maxEnqueuedMessages:t;this._messageQueue.length<i&&(this._debug("enqueue",e),this._messageQueue.push(e))}},e.prototype.addEventListener=function(e,t){this._listeners[e]&&this._listeners[e].push(t)},e.prototype.dispatchEvent=function(e){var t,i,n=this._listeners[e.type];if(n)try{for(var r=function(e){var t="function"==typeof Symbol&&e[Symbol.iterator],i=0;return t?t.call(e):{next:function(){return e&&i>=e.length&&(e=void 0),{value:e&&e[i++],done:!e}}}}(n),s=r.next();!s.done;s=r.next()){var a=s.value;this._callEventListener(e,a)}}catch(e){t={error:e}}finally{try{s&&!s.done&&(i=r.return)&&i.call(r)}finally{if(t)throw t.error}}return!0},e.prototype.removeEventListener=function(e,t){this._listeners[e]&&(this._listeners[e]=this._listeners[e].filter((function(e){return e!==t})))},e.prototype._debug=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._options.debug&&console.log.apply(console,function(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(od(arguments[t]));return e}(["RWS>"],e))},e.prototype._getNextDelay=function(){var e=this._options,t=e.reconnectionDelayGrowFactor,i=void 0===t?ud.reconnectionDelayGrowFactor:t,n=e.minReconnectionDelay,r=void 0===n?ud.minReconnectionDelay:n,s=e.maxReconnectionDelay,a=void 0===s?ud.maxReconnectionDelay:s,o=0;return this._retryCount>0&&(o=r*Math.pow(i,this._retryCount-1))>a&&(o=a),this._debug("next delay",o),o},e.prototype._wait=function(){var e=this;return new Promise((function(t){setTimeout(t,e._getNextDelay())}))},e.prototype._getNextUrl=function(e){if("string"==typeof e)return Promise.resolve(e);if("function"==typeof e){var t=e();if("string"==typeof t)return Promise.resolve(t);if(t.then)return t}throw Error("Invalid URL")},e.prototype._connect=function(){var e=this;if(!this._connectLock&&this._shouldReconnect){this._connectLock=!0;var t=this._options,i=t.maxRetries,n=void 0===i?ud.maxRetries:i,r=t.connectionTimeout,s=void 0===r?ud.connectionTimeout:r,a=t.WebSocket,o=void 0===a?hd():a;if(this._retryCount>=n)this._debug("max retries reached",this._retryCount,">=",n);else{if(this._retryCount++,this._debug("connect",this._retryCount),this._removeListeners(),void 0===(c=o)||!c||2!==c.CLOSING)throw Error("No valid WebSocket class provided");var c;this._wait().then((function(){return e._getNextUrl(e._url)})).then((function(t){e._closeCalled||(e._debug("connect",{url:t,protocols:e._protocols}),e._ws=e._protocols?new o(t,e._protocols):new o(t),e._ws.binaryType=e._binaryType,e._connectLock=!1,e._addListeners(),e._connectTimeout=setTimeout((function(){return e._handleTimeout()}),s))}))}}},e.prototype._handleTimeout=function(){this._debug("timeout event"),this._handleError(new dd(Error("TIMEOUT"),this))},e.prototype._disconnect=function(e,t){if(void 0===e&&(e=1e3),this._clearTimeouts(),this._ws){this._removeListeners();try{this._ws.close(e,t),this._handleClose(new ld(e,t,this))}catch(e){}}},e.prototype._acceptOpen=function(){this._debug("accept open"),this._retryCount=0},e.prototype._callEventListener=function(e,t){"handleEvent"in t?t.handleEvent(e):t(e)},e.prototype._removeListeners=function(){this._ws&&(this._debug("removeListeners"),this._ws.removeEventListener("open",this._handleOpen),this._ws.removeEventListener("close",this._handleClose),this._ws.removeEventListener("message",this._handleMessage),this._ws.removeEventListener("error",this._handleError))},e.prototype._addListeners=function(){this._ws&&(this._debug("addListeners"),this._ws.addEventListener("open",this._handleOpen),this._ws.addEventListener("close",this._handleClose),this._ws.addEventListener("message",this._handleMessage),this._ws.addEventListener("error",this._handleError))},e.prototype._clearTimeouts=function(){clearTimeout(this._connectTimeout),clearTimeout(this._uptimeTimeout)},e}();const gd={ON_OPEN:"onopen",ON_MESSAGE:"onmessage",ON_ERROR:"onerror",ON_CLOSE:"onclose",INITIALIZED:"initialized",ON_AUTH_FAILED:"on_auth_failed"},fd="auth_session_expire_soon",md="favorite_added",vd="favorite_deleted",yd="user_status_update",Sd="chat_message_sent",bd="chat_message_received",wd="endpoint_status_update",Ed="users_forwards_busy_updated",Cd="users_forwards_noanswer_updated",Td="users_forwards_unconditional_updated",$d="users_services_dnd_updated",_d="user_voicemail_message_created",xd="user_voicemail_message_updated",Id="user_voicemail_message_deleted",Rd="call_log_user_created",Ad="call_created",Pd="call_answered",Dd="call_dtmf_created",Nd="call_ended",kd="call_updated",Od="call_held",Fd="call_resumed",Md="auth_user_external_auth_added",Hd="auth_user_external_auth_deleted",Ld="chatd_presence_updated",jd="chatd_user_room_message_created",Bd="chatd_user_room_created",Ud="conference_user_participant_joined",Vd="conference_user_participant_left",qd="conference_user_participant_talk_started",Gd="conference_user_participant_talk_stopped",Kd="meeting_user_participant_joined",Wd="meeting_user_participant_left",zd="switchboard_queued_calls_updated",Yd="switchboard_queued_call_answered",Jd="switchboard_held_calls_updated",Zd="switchboard_held_call_answered",Xd="fax_outbound_user_created",Qd="fax_outbound_user_succeeded",el="fax_outbound_user_failed",tl="application_call_dtmf_received",il="application_call_entered",nl="application_call_initiated",rl="application_call_deleted",sl="application_call_updated",al="application_call_answered",ol="application_progress_started",cl="application_progress_stopped",dl="application_destination_node_created",ll="application_node_created",hl="application_node_deleted",ul="application_node_updated",pl="application_playback_created",gl="application_playback_deleted",fl="application_snoop_created",ml="application_snoop_deleted",vl="application_snoop_updated",yl="application_user_outgoing_call_created",Sl="trunk_status_updated",bl="line_status_updated",wl="agent_status_update",El="agent_paused",Cl="agent_unpaused",Tl="conference_adhoc_participant_left",$l="conference_adhoc_deleted",_l="meeting_user_progress",xl="meeting_user_guest_authorization_created",Il=[Sd,bd,jd,Bd],Rl="20.09",Al=B.loggerFor("wazo-ws"),Pl=B.loggerFor("wazo-ws-message");class Dl extends Mi{initialized;session;host;version;token;events;options;socket;_boundOnHeartbeat;heartbeat;onHeartBeatTimeout;heartbeatCb;eventLists;static eventLists;constructor({host:e,token:t,version:i,events:n,heartbeat:r,session:s},a={host:e,token:t,version:1,events:[],heartbeat:{},session:null}){super(),this.initialized=!1,this.socket=null,this.host=e,this.token=t,this.events=n,this.options=a,this.version=i,this.session=s,this._boundOnHeartbeat=this._onHeartbeat.bind(this);const{delay:o,timeout:c,max:d}=r||{};this.heartbeat=new _c(o,c,d),this.heartbeat.setSendHeartbeat(this.pingServer.bind(this)),this.heartbeat.setOnHeartbeatTimeout(this._onHeartbeatTimeout.bind(this)),this.eventLists=Dl.eventLists}connect(){Al.info("connect method started",{host:this.host,token:R(this.token)}),this.socket=new pd(this._getUrl.bind(this),[],this.options),this.options.binaryType&&(this.socket.binaryType=this.options.binaryType),this.socket.onopen=()=>{Al.info("on Wazo WS open",{method:"connect",host:this.host}),this.eventEmitter.emit(gd.ON_OPEN)},this.socket.onerror=e=>{Al.error("on Wazo WS error",e.target),this.eventEmitter.emit(gd.ON_ERROR,e)},this.socket.onmessage=e=>{this.eventEmitter.emit(gd.ON_MESSAGE,e.data);const t=JSON.parse("string"==typeof e.data?e.data:"{}");let{name:i}=t;t.data&&t.data.name&&(i=t.data.name),-1===Il.indexOf(i)?Pl.trace(B.removeSlashes(e.data),{method:"onmessage"}):Pl.trace(`{"name": "${i}", "info": "content not shown"}`,{method:"onmessage"}),this.initialized?this._handleMessage(t):this._handleInitMessage(t,this.socket)},this.socket.onclose=e=>{if(Al.info("on Wazo WS close",{reason:e.reason,code:e.code,readyState:e.target.readyState,host:this.host,token:R(this.token)}),this.initialized=!1,this.eventEmitter.emit(gd.ON_CLOSE,e),4002===e.code)this.eventEmitter.emit(gd.ON_AUTH_FAILED)},this.socket.onerror=e=>{Al.info("Wazo WS error",{message:e.message,code:e.code,readyState:e.target.readyState})}}close(e=!1){Al.info("Wazo WS close",{socket:!!this.socket,host:this.host,token:R(this.token)}),this.socket&&(3!==this.socket.readyState?(this.socket.close(1e3),this.initialized=!1,e&&(this.host=null,this.token=null,this.socket=null)):Al.warn("Trying to close an already closed websocket, bailing.",{url:this._getUrl()}))}updateToken(e){this.token=e,Al.info("Wazo WS updating token",{url:this._getUrl(),token:R(e),socket:!!this.socket}),this.socket&&(this.isConnected()&&Number(this.version)>=2?this.socket.send(JSON.stringify({op:"token",data:{token:e}})):this.isConnected()||this.reconnect("token refreshed"))}hasHeartbeat(){return this.heartbeat.hasHeartbeat}startHeartbeat(){Al.info("Wazo WS start heartbeat",{host:this.host,token:R(this.token)}),this.socket?(this.off("pong",this._boundOnHeartbeat),this.on("pong",this._boundOnHeartbeat),this.heartbeat.start()):this.heartbeat.stop()}stopHeartbeat(){Al.info("Wazo WS stop heartbeat",{host:this.host,token:R(this.token)}),this.heartbeat.stop()}setOnHeartbeatTimeout(e){this.onHeartBeatTimeout=e}setOnHeartbeatCallback(e){this.heartbeatCb=e}pingServer(){if(this.socket&&this.isConnected())try{this.socket.send(JSON.stringify({op:"ping",data:{payload:"pong"}}))}catch(e){}}isConnected(){return this.socket&&this.socket.readyState===this.socket.OPEN}reconnect(e){Al.info("Wazo WS reconnect",{reason:e,socket:!!this.socket,host:this.host,token:R(this.token)}),this.socket&&this.socket.reconnect(0,e)}_handleInitMessage(e,t){switch(e.op){case"init":this.events?.forEach((e=>{const i={op:"subscribe",data:{event_name:e}};t.send(JSON.stringify(i))})),t.send(JSON.stringify({op:"start"}));break;case"subscribe":break;case"start":this.initialized=!0,this.eventEmitter.emit(gd.INITIALIZED);break;default:this.eventEmitter.emit("message",e)}}_handleMessage(e){if("pong"===e.op)return this.eventEmitter.emit("pong",e.data),void(this.heartbeatCb&&this.heartbeatCb());1!==this.version?Number(this.version)>=2&&"event"===e.op&&this.eventEmitter.emit(e.data.name,e.data):this.eventEmitter.emit(e.name,e)}_getUrl(){this.host&&this.token||this.close();let e=`wss://${this.host||""}/api/websocketd/?token=${this.token||""}&version=${this.version}`;return this.session&&(e+=`&userUuid=${this.session.uuid}`),Al.info("Wazo WS url computed to reconnect",{url:e.replace(this.token,R(this.token))}),e}_onHeartbeat(e){"pong"===e.payload&&(this.heartbeat.onHeartbeat(),Al.log("on heartbeat received from Wazo WS"))}async _onHeartbeatTimeout(){Al.log("heartbeat timed out",{host:this.host,token:R(this.token)}),this.close(),this.eventEmitter.emit(gd.ON_CLOSE,new Error("Websocket ping failure.")),this.onHeartBeatTimeout&&this.onHeartBeatTimeout()}}Dl.eventLists=[fd,md,vd,yd,Sd,bd,wd,Ed,Cd,Td,$d,_d,xd,Id,Rd,Pd,Ad,Dd,Nd,kd,Od,Fd,Md,Hd,Ld,jd,Bd,Ud,Vd,Kd,Wd,qd,Gd,zd,Yd,Jd,Zd,Xd,Qd,el,tl,il,nl,rl,sl,al,ol,cl,dl,ll,hl,ul,pl,gl,fl,ml,vl,yl,Sl,bl,wl,El,Cl,Tl,$l,_l,xl];var Nl=Object.freeze({__proto__:null,AGENT_PAUSED:El,AGENT_STATUS_UPDATE:wl,AGENT_UNPAUSED:Cl,APPLICATION_CALL_ANSWERED:al,APPLICATION_CALL_DELETED:rl,APPLICATION_CALL_DTMF_RECEIVED:tl,APPLICATION_CALL_ENTERED:il,APPLICATION_CALL_INITIATED:nl,APPLICATION_CALL_UPDATED:sl,APPLICATION_DESTINATION_NODE_CREATED:dl,APPLICATION_NODE_CREATED:ll,APPLICATION_NODE_DELETED:hl,APPLICATION_NODE_UPDATED:ul,APPLICATION_PLAYBACK_CREATED:pl,APPLICATION_PLAYBACK_DELETED:gl,APPLICATION_PROGRESS_STARTED:ol,APPLICATION_PROGRESS_STOPPED:cl,APPLICATION_SNOOP_CREATED:fl,APPLICATION_SNOOP_DELETED:ml,APPLICATION_SNOOP_UPDATED:vl,APPLICATION_USER_OUTGOING_CALL_CREATED:yl,AUTH_SESSION_EXPIRE_SOON:fd,AUTH_USER_EXTERNAL_AUTH_ADDED:Md,AUTH_USER_EXTERNAL_AUTH_DELETED:Hd,CALL_ANSWERED:Pd,CALL_CREATED:Ad,CALL_DTMF_CREATED:Dd,CALL_ENDED:Nd,CALL_HELD:Od,CALL_LOG_USER_CREATED:Rd,CALL_RESUMED:Fd,CALL_UPDATED:kd,CHATD_PRESENCE_UPDATED:Ld,CHATD_USER_ROOM_CREATED:Bd,CHATD_USER_ROOM_MESSAGE_CREATED:jd,CHAT_MESSAGE_RECEIVED:bd,CHAT_MESSAGE_SENT:Sd,CONFERENCE_ADHOC_DELETED:$l,CONFERENCE_ADHOC_PARTICIPANT_LEFT:Tl,CONFERENCE_USER_PARTICIPANT_JOINED:Ud,CONFERENCE_USER_PARTICIPANT_LEFT:Vd,CONFERENCE_USER_PARTICIPANT_TALK_STARTED:qd,CONFERENCE_USER_PARTICIPANT_TALK_STOPPED:Gd,ENDPOINT_STATUS_UPDATE:wd,FAVORITE_ADDED:md,FAVORITE_DELETED:vd,FAX_OUTBOUND_USER_CREATED:Xd,FAX_OUTBOUND_USER_FAILED:el,FAX_OUTBOUND_USER_SUCCEEDED:Qd,HEARTBEAT_ENGINE_VERSION:Rl,LINE_STATUS_UPDATED:bl,MEETING_USER_GUEST_AUTHORIZATION_CREATED:xl,MEETING_USER_PARTICIPANT_JOINED:Kd,MEETING_USER_PARTICIPANT_LEFT:Wd,MEETING_USER_PROGRESS:_l,SOCKET_EVENTS:gd,SWITCHBOARD_HELD_CALLS_UPDATED:Jd,SWITCHBOARD_HELD_CALL_ANSWERED:Zd,SWITCHBOARD_QUEUED_CALLS_UPDATED:zd,SWITCHBOARD_QUEUED_CALL_ANSWERED:Yd,TRUNK_STATUS_UPDATED:Sl,USERS_FORWARDS_BUSY_UPDATED:Ed,USERS_FORWARDS_NOANSWER_UPDATED:Cd,USERS_FORWARDS_UNCONDITIONAL_UPDATED:Td,USERS_SERVICES_DND_UPDATED:$d,USER_STATUS_UPDATE:yd,USER_VOICEMAIL_MESSAGE_CREATED:_d,USER_VOICEMAIL_MESSAGE_DELETED:Id,USER_VOICEMAIL_MESSAGE_UPDATED:xd,default:Dl});const{SOCKET_EVENTS:kl,...Ol}=Nl,Fl=[...Object.values(kl),...Object.values(Ol)],Ml=B.loggerFor("simple-ws-client");class Hl extends Mi{ws;eventLists;CONFERENCE_USER_PARTICIPANT_JOINED;CONFERENCE_USER_PARTICIPANT_LEFT;MEETING_USER_PARTICIPANT_JOINED;MEETING_USER_PARTICIPANT_LEFT;CALL_CREATED;constructor(){super(),Object.keys(Ol).forEach((e=>{this[e]=Ol[e]})),Object.keys(kl).forEach((e=>{this[e]=kl[e]})),this.eventLists=Dl.eventLists,this.ws=null}open(e,t){Ml.info("open simple WebSocket",{host:e,token:R(t.token)}),this.ws=new Dl({host:e,token:t.token,events:["*"],version:2,session:t},{rejectUnauthorized:!1,binaryType:"arraybuffer"}),this.ws.connect(),Fl.forEach((e=>{this.ws&&this.ws.on(e,(t=>{this.eventEmitter.emit(e,t)}))}))}updateToken(e){Ml.info("update token via simple Websocket",{token:e,ws:!!this.ws}),this.ws&&this.ws.updateToken(e)}isOpen(){return this.ws?.isConnected()||!1}close(e=!1){Ml.info("Closing event transport websocket",{force:e,ws:!!this.ws}),this.ws&&this.ws.close(e),this.unbind()}}global.wazoWebsocketInstance||(global.wazoWebsocketInstance=new Hl);var Ll=global.wazoWebsocketInstance;const jl=B.loggerFor("room");class Bl extends Mi{room;uuid;name;number;callId;isTalking;streams;videoStreams;audioMuted;videoMuted;screensharing;isOnHold;banned;extra;ON_UPDATED;ON_START_TALKING;ON_STOP_TALKING;ON_DISCONNECT;ON_STREAM_SUBSCRIBED;ON_STREAM_UNSUBSCRIBED;ON_AUDIO_MUTED;ON_AUDIO_UNMUTED;ON_VIDEO_MUTED;ON_VIDEO_UNMUTED;ON_SCREENSHARING;ON_STOP_SCREENSHARING;ON_EXTRA_CHANGE;ON_HOLD;ON_RESUME;ON_BAN;constructor(e,t,i={}){super(),this.room=e,this.uuid=t.user_uuid,this.name=(t.caller_id_name||"").replace("\\'","'"),this.number=t.caller_id_number,this.callId=t.call_id,this.isTalking=!1,this.streams=[],this.videoStreams=[],this.audioMuted=!1,this.videoMuted=!1,this.screensharing=!1,this.isOnHold=!1,this.extra=i,this.banned=!1,this.ON_UPDATED="participant/ON_UPDATED",this.ON_START_TALKING="participant/ON_START_TALKING",this.ON_STOP_TALKING="participant/ON_STOP_TALKING",this.ON_DISCONNECT="participant/ON_DISCONNECT",this.ON_STREAM_SUBSCRIBED="participant/ON_STREAM_SUBSCRIBED",this.ON_STREAM_UNSUBSCRIBED="participant/ON_STREAM_UNSUBSCRIBED",this.ON_AUDIO_MUTED="participant/ON_AUDIO_MUTED",this.ON_AUDIO_UNMUTED="participant/ON_AUDIO_UNMUTED",this.ON_VIDEO_MUTED="participant/ON_VIDEO_MUTED",this.ON_VIDEO_UNMUTED="participant/ON_VIDEO_UNMUTED",this.ON_SCREENSHARING="participant/ON_SCREENSHARING",this.ON_STOP_SCREENSHARING="participant/ON_STOP_SCREENSHARING",this.ON_EXTRA_CHANGE="participant/ON_EXTRA_CHANGE",this.ON_HOLD="participant/ON_HOLD",this.ON_RESUME="participant/ON_RESUME",this.ON_BAN="participant/ON_BAN"}triggerEvent(e,...t){this.eventEmitter.emit.apply(this.eventEmitter,[e,...t]),this.eventEmitter.emit.apply(this.eventEmitter,[this.ON_UPDATED,...t])}triggerUpdate(e,t=!0){const i={callId:this.callId};switch(e){case this.ON_START_TALKING:case this.ON_STOP_TALKING:i.isTalking=this.isTalking;break;case this.ON_AUDIO_MUTED:case this.ON_AUDIO_UNMUTED:i.audioMuted=this.audioMuted;break;case this.ON_VIDEO_MUTED:case this.ON_VIDEO_UNMUTED:i.videoMuted=this.videoMuted;break;case this.ON_SCREENSHARING:case this.ON_STOP_SCREENSHARING:i.screensharing=this.screensharing;break;case this.ON_HOLD:case this.ON_RESUME:i.isOnHold=this.isOnHold;break;case this.ON_EXTRA_CHANGE:i.extra=this.extra;break;case this.ON_BAN:i.banned=!0}t&&this.broadcastStatus(i),this.eventEmitter.emit(e,i),this.eventEmitter.emit(this.ON_UPDATED,e,i)}onTalking(e){jl.info("on participant talking",{name:this.name,isTalking:e,callId:this.callId}),this.isTalking=e,this.triggerUpdate(this.isTalking?this.ON_START_TALKING:this.ON_STOP_TALKING,!1)}onDisconnect(){return this.triggerEvent(this.ON_DISCONNECT)}onStreamSubscribed(e){return this.triggerEvent(this.ON_STREAM_SUBSCRIBED,e)}onStreamUnSubscribed(e){return this.triggerEvent(this.ON_STREAM_UNSUBSCRIBED,e)}onAudioMuted(e=!0){this.audioMuted||(this.audioMuted=!0,this.triggerUpdate(this.ON_AUDIO_MUTED,e))}onAudioUnMuted(e=!0){this.audioMuted&&(this.audioMuted=!1,this.triggerUpdate(this.ON_AUDIO_UNMUTED,e))}onVideoMuted(e=!0){this.videoMuted||(this.videoMuted=!0,this.triggerUpdate(this.ON_VIDEO_MUTED,e))}onVideoUnMuted(e=!0){this.videoMuted&&(this.videoMuted=!1,this.triggerUpdate(this.ON_VIDEO_UNMUTED,e))}onScreensharing(e=!0){this.screensharing||(this.screensharing=!0,this.triggerUpdate(this.ON_SCREENSHARING,e))}onStopScreensharing(e=!0){this.screensharing&&(this.screensharing=!1,this.triggerUpdate(this.ON_STOP_SCREENSHARING,e))}onHold(e=!0){this.isOnHold||(this.isOnHold=!0,this.triggerUpdate(this.ON_HOLD,e))}onResume(e=!0){this.isOnHold&&(this.isOnHold=!1,this.triggerUpdate(this.ON_RESUME,e))}onBan(e=!0){this.banned=!0,this.triggerUpdate(this.ON_BAN,e)}getStatus(){return{callId:this.callId,audioMuted:this.audioMuted,videoMuted:this.videoMuted,screensharing:this.screensharing,isTalking:this.isTalking,extra:this.extra}}updateStatus(e,t=!0){jl.info("updating participant status",{name:this.name,status:e}),void 0!==e.audioMuted&&e.audioMuted!==this.audioMuted&&(e.audioMuted?this.onAudioMuted(t):this.onAudioUnMuted(t)),void 0!==e.videoMuted&&e.videoMuted!==this.videoMuted&&(e.videoMuted?this.onVideoMuted(t):this.onVideoUnMuted(t)),void 0!==e.screensharing&&e.screensharing!==this.screensharing&&(e.screensharing?this.onScreensharing(t):this.onStopScreensharing(t)),void 0!==e.isOnHold&&e.isOnHold!==this.isOnHold&&(e.isOnHold?this.onHold(t):this.onResume(t)),e.banned&&this.onBan(!1),void 0!==e.extra&&JSON.stringify(this.extra)!==JSON.stringify(e.extra)&&(this.extra={...this.extra,...e.extra},!this.extra.contact||this.extra.contact instanceof Xt||(this.extra.contact=new Xt(this.extra.contact)),this.triggerUpdate(this.ON_EXTRA_CHANGE,t))}broadcastStatus(e=null,t=null){const i=e||this.getStatus();jl.info("broadcasting participant status",{callId:this.callId,status:i}),t&&!this.streams.length&&rd.phone&&rd.phone._sendReinviteMessage(this.room?.callSession,!1),this.room?.sendSignal({type:Vl,origin:this.callId,status:i})}resetStreams(e){this.streams=e,this.videoStreams=e}async ban(e=null){const{meetingUuid:t}=this.room||{};if(!t)throw new Error("Attempting to ban a participant without a `meetingUuid`");return this.onBan(!0),e&&await this.delay(e),gn().calld.banMeetingParticipant(t,this.callId)}async delay(e){return new Promise((t=>setTimeout(t,e)))}}class Ul extends Bl{constructor(e,t,i={}){super(e,t,i),"<unknown>"===this.name&&(this.name=String(this.number))}}const Vl="signal/PARTICIPANT_UPDATE",ql="signal/PARTICIPANT_REQUEST",Gl=B.loggerFor("sdk-room");let Kl=class e extends Mi{callSession;name;extension;sourceId;meetingUuid;participants;callId;connected;localParticipant;_callIdStreamIdMap;_unassociatedVideoStreams;_unassociatedParticipants;_boundOnParticipantJoined;_boundOnParticipantLeft;_boundOnMessage;_boundOnChat;_boundOnSignal;_boundSaveLocalVideoStream;_boundOnReinvite;audioStream;extra;roomAudioElement;CONFERENCE_USER_PARTICIPANT_JOINED;CONFERENCE_USER_PARTICIPANT_LEFT;MEETING_USER_PARTICIPANT_JOINED;MEETING_USER_PARTICIPANT_LEFT;ON_SHARE_SCREEN_ENDED;ON_MESSAGE;ON_CHAT;ON_SIGNAL;ON_AUDIO_STREAM;ON_VIDEO_STREAM;ON_REMOVE_STREAM;ON_DISCONNECTED;ON_JOINED;ON_VIDEO_INPUT_CHANGE;constructor(e,t,i,n,r,s={}){super(),Gl.info("room initialized",{callId:n,extension:t,sourceId:i,meetingUuid:r}),this.callSession=e,this.extension=t,this.sourceId=i,this.meetingUuid=r,this.callId=n,this.participants=[],this.connected=!1,this.localParticipant=null,this._callIdStreamIdMap={},this._unassociatedVideoStreams={},this._unassociatedParticipants={},this.audioStream=null,this.extra=s,this.CONFERENCE_USER_PARTICIPANT_JOINED=ig.Websocket.CONFERENCE_USER_PARTICIPANT_JOINED,this.CONFERENCE_USER_PARTICIPANT_LEFT=ig.Websocket.CONFERENCE_USER_PARTICIPANT_LEFT,this.MEETING_USER_PARTICIPANT_JOINED=ig.Websocket.MEETING_USER_PARTICIPANT_JOINED,this.MEETING_USER_PARTICIPANT_LEFT=ig.Websocket.MEETING_USER_PARTICIPANT_LEFT,this.ON_SHARE_SCREEN_ENDED=ig.Phone.ON_SHARE_SCREEN_ENDED,this.ON_MESSAGE=ig.Phone.ON_MESSAGE,this.ON_CHAT=ig.Phone.ON_CHAT,this.ON_SIGNAL=ig.Phone.ON_SIGNAL,this.ON_AUDIO_STREAM=ig.Phone.ON_AUDIO_STREAM,this.ON_VIDEO_STREAM=ig.Phone.ON_VIDEO_STREAM,this.ON_REMOVE_STREAM=ig.Phone.ON_REMOVE_STREAM,this.ON_VIDEO_INPUT_CHANGE=ig.Phone.ON_VIDEO_INPUT_CHANGE,this.ON_DISCONNECTED="room/ON_DISCONNECTED",this.ON_JOINED="room/ON_JOINED",this._boundOnParticipantJoined=this._onParticipantJoined.bind(this),this._boundOnParticipantLeft=this._onParticipantLeft.bind(this),this._boundOnMessage=this._onMessage.bind(this),this._boundOnChat=this._onChat.bind(this),this._boundOnSignal=this._onSignal.bind(this),this._boundSaveLocalVideoStream=this._saveLocalVideoStream.bind(this),this._boundOnReinvite=this._onReinvite.bind(this),this.unbind(),this._bindEvents(),this._transferEvents()}static async connect({extension:t,constraints:i,audioOnly:n=!1,extra:r,room:s,meeting:a}){if(Gl.info("connecting to room",{extension:t,audioOnly:n,room:!!s}),!s){await ig.Phone.connect({media:i});const a=i&&!!i.video;a&&ig.Phone.checkSfu(),ig.Websocket.once(ig.Websocket.CALL_CREATED,(({data:e})=>{Gl.info("room call received via WS",{callId:e.call_id}),s&&s.setCallId(e.call_id)}));const o=await ig.Phone.call(t,a,null,n,!0);s=new e(o,t,null,null,null,r),await new Promise(((e,t)=>{ig.Phone.once(ig.Phone.ON_CALL_ACCEPTED,e),ig.Phone.once(ig.Phone.ON_CALL_FAILED,t)}))}if(s&&s.callSession&&s.callSession.call&&s.setCallId(s.callSession.call.id),a)a&&(Gl.info("Already connected to meeting",{uuid:a.uuid,name:a.name}),s.setMeetingUuid(a.uuid),s.setName(a.name));else{const e=await gn().dird.fetchConferenceSource("default"),i=await gn().dird.fetchConferenceContacts(e.items[0]),n=i?.find((e=>e.numbers?.find((e=>String(e.number)===String(t)))));Gl.info("connected to room",{sourceId:n?n.sourceId:null,name:n?n.name:null}),n&&(s.setSourceId(parseInt(`${n.sourceId}`,10)),s.setName(`${n.name}`))}return s}static disconnect(){Gl.info("static disconnection to room"),ig.Phone.disconnect()}async disconnect(){Gl.info("disconnection to room called"),await ig.Phone.hangup(this.callSession),this.callSession=void 0,this.eventEmitter.emit(this.ON_DISCONNECTED,this),this.connected=!1,this.unbind(),ig.Phone.off(this.ON_MESSAGE,this._boundOnMessage),ig.Phone.off(this.ON_CHAT,this._boundOnChat),ig.Phone.off(this.ON_SIGNAL,this._boundOnSignal),ig.Phone.off(this.ON_VIDEO_INPUT_CHANGE,this._boundSaveLocalVideoStream),ig.Phone.phone?.off(ig.Phone.phone.client.ON_REINVITE,this._boundOnReinvite),ig.Websocket.off(this.CONFERENCE_USER_PARTICIPANT_JOINED,this._boundOnParticipantJoined),ig.Websocket.off(this.CONFERENCE_USER_PARTICIPANT_LEFT,this._boundOnParticipantLeft),ig.Websocket.off(this.MEETING_USER_PARTICIPANT_JOINED,this._boundOnParticipantJoined),ig.Websocket.off(this.MEETING_USER_PARTICIPANT_LEFT,this._boundOnParticipantLeft)}setSourceId(e){Gl.info("set room source id",{sourceId:e}),this.sourceId=e}setMeetingUuid(e){Gl.info("set meeting uuid",{meetingUuid:e}),this.meetingUuid=e}setCallId(e){Gl.info("set room call id",{callId:e}),e&&(this.callId=e)}setName(e){Gl.info("set room name",{name:e}),this.name=e}sendMessage(e,t=null){return ig.Phone.sendMessage(e,t)}sendChat(e){return ig.Phone.sendChat(e)}sendSignal(e){return ig.Phone.sendSignal(e)}async startScreenSharing(e){Gl.info("start room screen sharing",{constraints:e});const t=await ig.Phone.startScreenSharing(e,this.callSession);return t?(this._onScreenSharing(),t):(console.warn("screensharing stream is null (likely due to user cancellation)"),null)}async stopScreenSharing(e=!0){Gl.info("stop room screen sharing"),await ig.Phone.stopScreenSharing(this.callSession,e),this.localParticipant&&(this._updateLocalParticipantStream(),this.localParticipant.onStopScreensharing())}turnCameraOff(){Gl.info("turn room camera off"),ig.Phone.turnCameraOff(this.callSession),this.localParticipant&&this.localParticipant.onVideoMuted()}turnCameraOn(){Gl.info("turn room camera on"),ig.Phone.turnCameraOn(this.callSession),this.localParticipant&&this.localParticipant.onVideoUnMuted()}mute(){Gl.info("mute room"),ig.Phone.mute(this.callSession),this.sendMuteStatus()}unmute(){Gl.info("unmute room"),ig.Phone.unmute(this.callSession),this.sendUnMuteStatus()}sendMuteStatus(){this.localParticipant&&this.localParticipant.onAudioMuted()}sendUnMuteStatus(){this.localParticipant&&this.localParticipant.onAudioUnMuted()}hold(){Gl.info("hold room"),ig.Phone.hold(this.callSession),this.localParticipant&&this.localParticipant.onHold()}async resume(){Gl.info("resume room");const e=await ig.Phone.resume(this.callSession);this.localParticipant&&(this._updateLocalParticipantStream(),this.localParticipant.onResume(),!e&&this.localParticipant.screensharing&&this.localParticipant.onStopScreensharing())}_updateLocalParticipantStream(){const e=ig.Phone.getLocalStream(this.callSession);if(this.localParticipant&&e){const t=new ig.Stream(e);this.localParticipant.resetStreams([t])}}sendDTMF(e){Gl.info("send room DTMF",{tone:e}),ig.Phone.sendDTMF(e,this.callSession)}async sendReinvite(e=null){Gl.info("send room reinvite",{callId:this.callSession?this.callSession.getId():null,newConstraints:e});const t=this.localParticipant&&this.localParticipant.screensharing;ig.Phone.on(ig.Phone.ON_SHARE_SCREEN_STARTED,(()=>{ig.Phone.phone&&ig.Phone.phone.currentScreenShare&&this._onScreenSharing()}));const i=await(ig.Phone.phone?.sendReinvite(this.callSession,e,!0));if(this.localParticipant&&e&&e.video){const e=ig.Phone.phone?.getLocalVideoStream(this.callSession);e&&this._associateStreamTo(e,this.localParticipant)}else this.localParticipant&&t&&e&&!e.video&&this.localParticipant.onStopScreensharing();return i}hasALocalVideoTrack(){return ig.Phone.hasALocalVideoTrack(this.callSession)}getLocalStream(){return ig.Phone.getLocalStream(this.callSession)}getRemoteStream(){return ig.Phone.getRemoteStream(this.callSession)}getRemoteVideoStream(){return ig.Phone.getRemoteVideoStream(this.callSession)}_bindEvents(){ig.Phone.phone&&ig.Phone.phone.currentSipSession&&(ig.Phone.phone.currentSipSession.sessionDescriptionHandler?.on("setDescription",(({type:e,sdp:t})=>{"offer"===e&&this._mapMsid(t)})),ig.Phone.phone.on(ig.Phone.phone.client.ON_REINVITE,this._boundOnReinvite),this.on(this.ON_AUDIO_STREAM,(async e=>{if(Gl.info("on room audio stream"),this.audioStream=e,this.roomAudioElement)this.roomAudioElement.srcObject=e;else{const t=Ms(ig.Phone.phone?.currentSipSession);this.roomAudioElement=await(ig.Phone.phone?.createAudioElementFor(t)),this.roomAudioElement.srcObject=e}})),this.on(this.ON_VIDEO_STREAM,((e,t,i,n)=>{Gl.info("on room video stream",{streamId:t}),this._mapMsid(n.body.body),this._unassociatedVideoStreams[t]=e;const r=this._getCallIdFromTrackId(t),s=r?this._getParticipantFromCallId(r):null;s&&this.__associateStreams(s)})),this.on(this.ON_REMOVE_STREAM,(e=>{Gl.info("on room remove stream");const t=this.participants.find((t=>t.streams.find((t=>t&&t.id===e.id))));t&&(t.videoStreams=t.videoStreams.filter((t=>t.id!==e.id)),t.streams=t.streams.filter((t=>t.id!==e.id)),t.onStreamUnSubscribed(e))})))}_onScreenSharing(){this.localParticipant&&this.localParticipant.onScreensharing()}_onReinvite(e,t){const i=t.body||t.message.body;i&&(this._mapMsid(i),this.participants.forEach((e=>{this.__associateStreams(e)})))}_mapMsid(e){Es.parse(e).media.filter((e=>!!e.label)).map((({label:e,msid:t})=>({label:String(e),streamId:t?.split(" ")[0],trackId:t?.split(" ")[1]}))).forEach((({label:e,streamId:t,trackId:i})=>{this._callIdStreamIdMap[String(e)]={streamId:t,trackId:i};const n=String(e),r=this._unassociatedParticipants[n]||this._getParticipantFromCallId(n);r&&this.__associateStreams(r)}))}_transferEvents(){ig.Websocket.on(this.CONFERENCE_USER_PARTICIPANT_JOINED,this._boundOnParticipantJoined),ig.Websocket.on(this.CONFERENCE_USER_PARTICIPANT_LEFT,this._boundOnParticipantLeft),ig.Websocket.on(this.MEETING_USER_PARTICIPANT_JOINED,this._boundOnParticipantJoined),ig.Websocket.on(this.MEETING_USER_PARTICIPANT_LEFT,this._boundOnParticipantLeft),ig.Phone.on(this.ON_MESSAGE,this._boundOnMessage),ig.Phone.on(this.ON_CHAT,this._boundOnChat),ig.Phone.on(this.ON_SIGNAL,this._boundOnSignal),ig.Phone.on(this.ON_VIDEO_INPUT_CHANGE,this._boundSaveLocalVideoStream),[this.ON_AUDIO_STREAM,this.ON_VIDEO_STREAM,this.ON_REMOVE_STREAM].forEach((e=>ig.Phone.on(e,((...t)=>this.eventEmitter.emit.apply(this.eventEmitter,[e,...t])))))}_onMessage(e){if("MESSAGE"!==e.method)return null;let t;try{t=JSON.parse(e.body)}catch(e){return null}switch(t.type){case"ConfbridgeTalking":{const e=t.channels[0],{id:i,talking_status:n}=e,r="on"===n,s=this.participants.findIndex((e=>e.callId===i));if(-1===s)return;this.participants[s].onTalking(r);break}}return this.eventEmitter.emit(this.ON_MESSAGE,t),t}_onChat(e){this.eventEmitter.emit(this.ON_CHAT,e)}_onSignal(e){const{type:t}=e;switch(t){case Vl:{const{status:t}=e,i=this._getParticipantFromCallId(t.callId);i&&i.updateStatus(t,!1);break}case ql:{const{callId:t,origin:i}=e;!this.localParticipant||t&&t!==this.localParticipant.callId||this.localParticipant.broadcastStatus(null,!0);const n=this._getParticipantFromCallId(i.callId);n&&(Gl.info("trigger room requester status",{origin:i}),n.triggerUpdate("REQUESTER_UPDATE"));break}case ig.Phone.ON_MESSAGE_TRACK_UPDATED:{const{callId:t,update:i}=e,n=this.participants.findIndex((e=>e.callId===t));-1!==n&&(this.participants[n]=this._onParticipantTrackUpdate(this.participants[n],i));break}default:console.warn("uncaught signal",e)}this.eventEmitter.emit(ig.Phone.ON_SIGNAL,e)}async _onParticipantJoined(e){const t=e.data,i=ig.Auth.getSession();let n=[];if(t.user_uuid===i?.uuid){Gl.info("room current user joined");const t=this.sourceId||e.data.conference_id;let i;try{this.meetingUuid?(Gl.info("fetching meeting participants",{meetingUuid:this.meetingUuid}),i=await gn().calld.getMeetingParticipantsAsUser(this.meetingUuid)):(Gl.info("fetching conference participants",{conferenceId:t}),i=await gn().calld.getConferenceParticipantsAsUser(t))}catch(e){Gl.error("room participants fetching, error",e)}if(i){Gl.info("conference participants fetched",{nb:i.items.length}),n=i.items.map((e=>e.call_id===this.callId&&e.call_id?new ig.LocalParticipant(this,e,this.extra):new ig.RemoteParticipant(this,e))),this.participants=n;const e=n.find((e=>e instanceof ig.LocalParticipant));!this.localParticipant&&e&&this._onLocalParticipantJoined(e),n.forEach((e=>this._isParticipantJoining(e))),this.eventEmitter.emit(this.ON_JOINED,e,n)}return this.participants}const r=this.participants.some((e=>e.callId===t.call_id))?null:new ig.RemoteParticipant(this,t);return Gl.info("other room user joined",{callId:t.call_id,remoteParticipant:!!r}),r&&(this.participants.push(r),this._isParticipantJoining(r)),r}_onLocalParticipantJoined(e){this.localParticipant=e;const t=this._getLocalVideoStream();t&&this._saveLocalVideoStream(t),this.connected=!0,e.broadcastStatus(null,!0),this.localParticipant&&this.sendSignal({type:ql,origin:this.localParticipant.getStatus()})}_isParticipantJoining(e){this.__associateStreams(e),e instanceof Ul&&this.eventEmitter.emit(this.CONFERENCE_USER_PARTICIPANT_JOINED,e)}_saveLocalVideoStream(e){const{localParticipant:t}=this;if(!t)return;const i=new ig.Stream(e,t);return i&&(t.resetStreams([i]),t.onStreamSubscribed(i)),i}_onParticipantLeft(e){const t=this.participants.find((t=>t&&t.callId===e.data.call_id));t&&t.onDisconnect(),this.participants=this.participants.filter((t=>t&&t.callId!==e.data.call_id)),this.eventEmitter.emit(this.CONFERENCE_USER_PARTICIPANT_LEFT,t)}_onParticipantTrackUpdate(e,t){const i=e,{trackId:n,streamId:r}=this._callIdStreamIdMap[i.callId]||{},s=ig.Phone.phone?.currentSipSession?.sessionDescriptionHandler?.peerConnection,a=s.getRemoteStreams().find((e=>e.id===r||e.getTracks().some((e=>e.id===n))));return"downgrade"===t?(i.resetStreams([]),i.onStreamUnSubscribed(a),i):(a&&this._associateStreamTo(a,i),i)}__associateStreams(e){const{trackId:t}=this._callIdStreamIdMap[e.callId]||{};if(!t)return void(this._unassociatedParticipants[e.callId]=e);if(!t||!e||!this.localParticipant||e.callId===this.localParticipant.callId)return;const i=this._getStreamIdFrTrackId(t),n=this._getUnassociatedMapIdFromTrackIdOrStreamId(t,i),r=n?this._unassociatedVideoStreams[n]:null;r&&(this._associateStreamTo(r,e),n&&delete this._unassociatedVideoStreams[n],delete this._unassociatedParticipants[e.callId])}_getUnassociatedMapIdFromTrackIdOrStreamId(e,t){if(e in this._unassociatedVideoStreams)return e;if(t&&t in this._unassociatedVideoStreams)return t;const i=Object.values(this._unassociatedVideoStreams).findIndex((e=>e&&e.id===t));return-1===i?null:Object.keys(this._unassociatedVideoStreams)[i]}_getStreamIdFrTrackId(e){const t=Object.values(this._callIdStreamIdMap).find((t=>t.trackId===e));return t?t.streamId:null}_associateStreamTo(e,t){const i=new ig.Stream(e,t);t.streams.push(i),t.videoStreams.push(i),t.onStreamSubscribed(i)}_getCallIdFromTrackId(e){return Object.keys(this._callIdStreamIdMap).find((t=>this._callIdStreamIdMap[t].trackId===e))}_getParticipantFromCallId(e){return this.participants.find((t=>t.callId===e))}_getLocalVideoStream(){return ig.Phone.getLocalVideoStream(this.callSession)}};const Wl=B.loggerFor("sdk-sip-room");class zl extends Kl{static async connect({extension:e,constraints:t,audioOnly:i=!1,extra:n,room:r}){if(Wl.info("connecting to sip room",{extension:e,audioOnly:i,room:!!r}),!r){await ig.Phone.connect({media:t});const s=t&&!!t.video,a=await ig.Phone.call(e,s,null,i,!0);r=new zl(a,e,null,null,n)}return r&&r.callSession&&r.callSession.call&&r.setCallId(r.callSession.call.id),Wl.info("connected to room",{extension:r.extension}),r}mute(){Wl.info("mute sip room"),ig.Phone.mute(this.callSession,!1),this.sendMuteStatus()}unmute(){Wl.info("unmute sip room"),ig.Phone.unmute(this.callSession,!1),this.sendUnMuteStatus()}getLocalGuestName(){return ig.Phone.phone?.client.userAgent?.options.displayName||null}_transferEvents(){ig.Phone.on(this.ON_MESSAGE,this._boundOnMessage),ig.Phone.on(this.ON_CHAT,this._boundOnChat),ig.Phone.on(this.ON_SIGNAL,this._boundOnSignal),ig.Phone.on(this.ON_VIDEO_INPUT_CHANGE,this._boundSaveLocalVideoStream),[this.ON_AUDIO_STREAM,this.ON_VIDEO_STREAM,this.ON_REMOVE_STREAM].forEach((e=>ig.Phone.on(e,((...t)=>this.eventEmitter.emit.apply(this.eventEmitter,[e,...t])))))}_onMessage(e){const t=super._onMessage(e);if(!t)return;const i=()=>t.channels[0];switch(t.type){case"ConfbridgeWelcome":t.channels.forEach((e=>{this._onParticipantJoined(e)}));break;case"ConfbridgeJoin":{const e=i();this._onParticipantJoined(e);break}case"ConfbridgeLeave":{const e=i();this._onParticipantLeft({data:{call_id:e.id}});break}}}async _onParticipantJoined(e){const t=e.channelvars.WAZO_SIP_CALL_ID===this._getCurrentSipCallIs(),i=e.id,n=t?ig.LocalParticipant:ig.RemoteParticipant,r=e.caller?e.caller.name:null,s=new n(this,{caller_id_name:r,call_id:i},t?{guestName:this.getLocalGuestName()}:{}),a=this.participants.findIndex((e=>e.callId===s.callId));if(-1===a||!r)return t&&(this.callSession&&(this.callSession.ringing=!1),this._onLocalParticipantJoined(s),setTimeout((()=>{this.eventEmitter.emit(this.ON_JOINED,s,this.participants)}),1e3)),this.participants.push(s),this._isParticipantJoining(s),s;this.participants[a].name=r}_getCurrentSipCallIs(){return Ms(ig.Phone.phone?.currentSipSession)}}class Yl{htmlStream;participant;static detachStream(e){e.getTracks().filter((e=>e.enabled)).forEach((e=>e.stop()))}constructor(e,t){this.htmlStream=e,this.participant=t}attach(e){const t=e||document.createElement("video"),i=this.participant instanceof ig.LocalParticipant;return t.autoplay=!0,t.srcObject=this.htmlStream,t.muted=i,i&&(t.style.transform="scale(-1, 1)"),t.onloadedmetadata=()=>{(this.htmlStream?this.htmlStream.getVideoTracks():[]).forEach((e=>{e.enabled=!0,e.loaded=!0}))},t}detach(){Yl.detachStream(this.htmlStream)}hasVideo(){return!!this.htmlStream&&this.htmlStream.getTracks().some((e=>"video"===e.kind&&"ended"!==e.readyState))}get id(){return this.htmlStream?this.htmlStream.id:null}}class Jl{async findMultipleContactsByNumber(e,t){return gn().dird.findMultipleContactsByNumber(e,t)}}global.wazoDirectoryInstance||(global.wazoDirectoryInstance=new Jl);var Zl=global.wazoDirectoryInstance;class Xl{async getCurrentUser(){const e=ig.Auth.getSession();return gn().confd.getUser(`${e?e.uuid:""}`)}}global.wazoConfigurationInstance||(global.wazoConfigurationInstance=new Xl);var Ql=global.wazoConfigurationInstance;const eh=async(e,t={})=>{const i={};i[e]=!(Object.keys(t).length>0)||t;const n=await navigator.mediaDevices.getUserMedia(i);return new ig.Stream(n,new ig.LocalParticipant(null,{call_id:"some-call-id",caller_id_name:"some-call-id-name"}))};class th{sound;vibration;static parse(e){return new th(e?{sound:e.sound,vibration:e.vibration}:{sound:!0,vibration:!0})}static newFrom(e){return Ut(e,th)}constructor({sound:e,vibration:t}={sound:!0,vibration:!0}){this.sound=e,this.vibration=t}setSound(e){return this.sound=e,this}setVibration(e){return this.vibration=e,this}enable(){return this.vibration=!0,this.sound=!0,this}disable(){return this.vibration=!1,this.sound=!1,this}isEnabled(){return this.sound||this.vibration}}class ih{id;name;connectedCallSession;participants;constructor({id:e,connectedCallSession:t,participants:i,name:n}){this.id=e,this.connectedCallSession=t,this.participants=i,this.name=n}getExtension(){return this.connectedCallSession?this.connectedCallSession.number:null}connect(e){return new ih({...this,connectedCallSession:e})}has(e){return!!this.connectedCallSession&&this.connectedCallSession.is(e)}addParticipant(e,t,i=null){return this.participants.some((i=>i.uuid===e||i.extension===t))?this:new ih({...this,participants:[...this.participants,{uuid:e,extension:t,talking:i}]})}updateParticipant(e,t,i=!1){const n=this.participants.findIndex((t=>t.uuid===e));if(-1===n&&!i)return this;const r=[...this.participants];return-1!==n?r[n]={...r[n],...t}:r.push(t),new ih({...this,participants:r})}updateParticipantByExtension(e,t,i=!1){const n=this.participants.findIndex((t=>t.extension===e));if(-1===n&&!i)return this;const r=[...this.participants];return-1!==n?r[n]={...r[n],...t}:r.push(t),new ih({...this,participants:r})}hasCallWithId(e){return!!this.connectedCallSession&&this.connectedCallSession.getId()===e}disconnect(){return new ih({...this,connectedCallSession:null})}removeParticipantWithUUID(e){return new ih({...this,participants:this.participants.filter((t=>t.uuid!==e))})}removeParticipantWithExtension(e){return new ih({...this,participants:this.participants.filter((t=>t.extension!==e))})}updateFrom(e){vi(this,e)}static newFrom(e){return Ut(e,ih)}}class nh{static STATE;id;callSession;callerIdName;callerIdNumber;answerTime;participantId;state;switchboardName;switchboardUuid;type;static parse(e){return new nh({id:e.id,callSession:e.callSession||null,callerIdName:e.caller_id_name||null,callerIdNumber:e.caller_id_number||null,participantId:e.participantId||null,answerTime:e.startTime,state:e.state,switchboardName:e.switchboardName,switchboardUuid:e.switchboardUuid})}constructor({id:e,callSession:t,callerIdName:i,callerIdNumber:n,participantId:r,answerTime:s,state:a,switchboardName:o,switchboardUuid:c}){this.id=e,this.callSession=t,this.callerIdName=i,this.callerIdNumber=n,this.participantId=r,this.answerTime=s,this.state=a,this.switchboardName=o,this.switchboardUuid=c,this.type="SwitchboardCall"}updateFrom(e){vi(this,e)}getId(){return this.id}static newFrom(e){return Ut(e,nh)}}nh.STATE={INCOMING:"incoming",ONGOING:"ongoing",HELD:"held"};const rh=e=>`enterprise.app.${e}`,sh=["chat","video","call_recording","fax","mobile_double_call","mobile_gsm","meeting","caller_id"].map(rh);var ah=new class{_hasChat;_hasVideo;_hasCallRecording;_hasFax;_hasMobileDoubleCall;_hasMobileGsm;_hasMeeting;_hasCallerID;constructor(){this._hasChat=!0,this._hasVideo=!0,this._hasCallRecording=!0,this._hasFax=!0,this._hasMobileDoubleCall=!0,this._hasMobileGsm=!0,this._hasMeeting=!0,this._hasCallerID=!1}async fetchAccess(){let e;try{e=await gn().auth.getRestrictionPolicies(sh)}catch(e){}if(!e)return;const{scopes:t}=e;this._hasChat=this._hasFeatures(t,"chat"),this._hasVideo=this._hasFeatures(t,"video"),this._hasCallRecording=this._hasFeatures(t,"call_recording"),this._hasFax=this._hasFeatures(t,"fax"),this._hasMobileDoubleCall=this._hasFeatures(t,"mobile_double_call"),this._hasMobileGsm=this._hasFeatures(t,"mobile_gsm"),this._hasMeeting=this._hasFeatures(t,"meeting"),this._hasCallerID=this._hasFeatures(t,"caller_id")}hasChat(){return this._hasChat}hasVideo(){return this._hasVideo}hasCallRecording(){return this._hasCallRecording}hasFax(){return this._hasFax}hasMobileDoubleCall(){return this._hasMobileDoubleCall}hasMobileGsm(){return this._hasMobileGsm}hasMeeting(){return this._hasMeeting}hasCallerID(){return this._hasCallerID}_hasFeatures(e,t){const i=rh(t);return!e||!(i in e)||!0===e[i]}},oh={name:"API",check:async(e,t)=>{const i=new rn({server:e});i.setToken(t.token),i.disableErrorLogging();const n=(e,t)=>{const i=t instanceof w?"server error":"api error";throw new Error(`${e} fails with status (${t.status}, ${i}) : ${t.message}`)};try{await i.auth.getPushNotificationSenderId(t.uuid),await i.auth.getProviders(t.uuid)}catch(e){n("wazo-auth",e)}try{await i.callLogd.listCallLogs()}catch(e){n("wazo-callogd",e)}try{await i.calld.listCalls()}catch(e){n("wazo-calld",e)}try{await i.calld.listVoicemails()}catch(e){404!==e.status&&n("wazo-calld",e)}try{await i.chatd.getState(t.uuid),await i.chatd.getContactStatusInfo(t.uuid),await i.chatd.getUserRooms()}catch(e){n("wazo-chatd",e)}try{await i.confd.getInfos(),await i.confd.getUser(t.uuid)}catch(e){n("wazo-confd",e)}try{await i.dird.listPersonalContacts(),await i.dird.listFavorites(t.primaryContext()),await i.dird.fetchWazoSource(t.primaryContext());const e=await i.dird.fetchConferenceSource(t.primaryContext());await i.dird.fetchConferenceContacts(e.items[0])}catch(e){n("wazo-dird",e)}try{await i.webhookd.getSubscriptions()}catch(e){n("wazo-webhookd",e)}}},ch={name:"List of AOR",check:async(e,t)=>{const i=new rn({server:e});i.setToken(t.token),i.disableErrorLogging();const n=t.primaryWebRtcLine();if(!n)return"No WebRTC line for this user";const{username:r}=n;try{const e=await i.amid.getAors(r),t=e.length,n=e.filter((e=>"Reachable"===e.status));return`Number of AOR: ${t} (${n.length} Avail, ${t-n.length} Unavail)`}catch(e){if(401===e.status)return"Not available for this user";throw e}}};var dh={name:"Symmetric NAT",check:()=>new Promise(((e,t)=>{if("undefined"==typeof MediaStream)return e("Skipped on node");const i={},n=[];let r=0;const s=new RTCPeerConnection({iceServers:[{urls:"stun:stun.wazo.io:443"},{urls:"stun:stun1.l.google.com:19302"},{urls:"stun:stun2.l.google.com:19302"}]});let a;const o=()=>{if(clearTimeout(a),0===Object.keys(i).length)return void t(new Error(`Timed out (8000ms), ${r} candidates : ${n.join(", ")}`));1===i[Object.keys(i)[0]].length?e():t(new Error("Symmetric NAT detected, you should use a TURN server."))};a=setTimeout(o,8e3),s.createDataChannel("wazo-check-nat"),s.onicecandidate=e=>{if(r++,e.candidate&&n.push(e.candidate.candidate),e.candidate&&-1!==e.candidate.candidate.indexOf("srflx")){const t=Zs(e.candidate.candidate);t.relatedPort&&(i[t.relatedPort]||(i[t.relatedPort]=[]),i[t.relatedPort].push(t.port))}else e.candidate||o()},s.createOffer().then((e=>s.setLocalDescription(e)))}))};const lh=e=>{const t=e.split(".");return 4===t.length&&t.every((e=>parseInt(e,10)>=0&&parseInt(e,10)<=255))};var hh={name:"Non IP v4 ice",check:(e,t,i)=>new Promise(((e,t)=>{if("undefined"==typeof MediaStream)return void e("Skipped on node");const n=x(),r={offerToReceiveAudio:1},s=[],a={iceServers:[{urls:"stun:stun1.l.google.com:19302"},{urls:"stun:stun2.l.google.com:19302"}]};let o=!1;i&&i.stun_servers&&(a.iceServers={...i.stun_servers.split(",").map((e=>({urls:e}))),...a.iceServers}),i&&i.turn_servers&&(a.iceServers=[...JSON.parse(i.turn_servers),...a.iceServers||[]],a.iceTransportPolicy="relay");const c=new RTCPeerConnection(a);c.createDataChannel("wazo-check-ipv4"),c.onicecandidate=i=>{if(i.candidate){const e=i.candidate.candidate;if(-1!==e.indexOf("srflx")||-1!==e.indexOf("relay")){o=!0;const e=Zs(i.candidate.candidate);s.push(e.ip)}}else if(!i.candidate){if(!o)return t(new Error("No `srflx` or `relay` found in candidate. Please consider using a TURN server."));if(s.every(lh))e(null);else{const e=s.find((e=>!lh(e)));t(new Error(`Non IPv4 ice candidate found : ${e}.`))}}},c.createOffer(r).then((e=>c.setLocalDescription(e))).then((e=>n?c.createOffer(r):e)).then((e=>n?c.setLocalDescription(e):e))}))},uh=[ch,oh,{name:"Event transport (WS)",check:(e,t)=>new Promise(((i,n)=>{const r=new Dl({host:e,token:t.token,version:2}),s=e=>{r.close(),n(new Error(e))},a=()=>{r.stopHeartbeat(),r.close(),i()};r.on(gd.ON_ERROR,(e=>{s(`Connection error : ${e}`)})),r.on(gd.ON_OPEN,(()=>{t.hasEngineVersionGte(Rl)?(r.setOnHeartbeatTimeout((()=>{s("No response to heartbeat")})),r.setOnHeartbeatCallback((()=>{a()})),r.startHeartbeat()):a()})),r.connect()}))},{name:"WebRTC Transport (WS) ~30s",check:(e,t)=>new Promise(((i,n)=>{const[r,s=443]=e.split(":"),a=new Zc({host:r,port:s,media:{audio:!0}},t),o=e=>{a.close(),n(new Error(e))};a.on(a.TRANSPORT_ERROR,(e=>{o(`Transport error : ${e}`)})),a.on(a.REGISTERED,(()=>{a.setOnHeartbeatTimeout((()=>{o("No response to heartbeat")})),a.setOnHeartbeatCallback((()=>{(async()=>{a.stopHeartbeat(),await a.close(),i()})()})),a.startHeartbeat()}))}))},{name:"WebRTC",check:(e,t)=>new Promise(((i,n)=>{if("undefined"==typeof MediaStream)return i("Skipped on node");const[r,s=443]=e.split(":"),a=new Zc({host:r,port:s,media:{audio:!0}},t),o=e=>{a.close(),n(new Error(e))};a.on(a.TRANSPORT_ERROR,(e=>{o(`Transport error : ${e}`)})),a.on(a.REGISTERED,(()=>{const e=a.call("*10");if(!e||!Ms(e))return o("Unable to make call through WebRTC");setTimeout((()=>{a.hangup(e),(async()=>{a.stopHeartbeat(),await a.close(),i()})()}),1e3)}))}))},dh,hh];const ph=B.loggerFor("engine-check");class gh{session;server;externalAppConfig;checks;constructor(e,t,i={}){this.server=e,this.session=t,this.externalAppConfig=i,this.checks=[...uh]}async check(e=(()=>{}),t=(()=>{})){await this._addEngineVersion(),ph.info("Engine check starting");for(let i=0;i<this.checks.length;i++){const{name:n,check:r}=this.checks[i];ph.info(`Checking ${n} ...`),e(n);try{const e=await r(this.server,this.session,this.externalAppConfig);ph.info(`Checking ${n} success.`,{result:e}),t(n,e)}catch(e){ph.info(`Checking ${n} failure`,{message:e.message}),t(n,e)}}ph.info("Engine check done.")}addCheck(e){this.checks.push(e)}async _addEngineVersion(){if(!this.session.engineVersion){const e=new rn({server:this.server});e.setToken(this.session.token);const{wazo_version:t}=await e.confd.getInfos();this.session.engineVersion=t}}}function fh(){const e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:void 0;if(e.__xstate__)return e.__xstate__}const mh=e=>{if("undefined"==typeof window)return;const t=fh();t&&t.register(e)};class vh{constructor(e){this._process=e,this._active=!1,this._current=null,this._last=null}start(){this._active=!0,this.flush()}clear(){this._current&&(this._current.next=null,this._last=this._current)}enqueue(e){const t={value:e,next:null};if(this._current)return this._last.next=t,void(this._last=t);this._current=t,this._last=t,this._active&&this.flush()}flush(){for(;this._current;){const e=this._current;this._process(e.value),this._current=e.next}this._last=null}}const yh=".",Sh="",bh="xstate.init",wh="xstate.stop";function Eh(e,t){return{type:`xstate.done.state.${e}`,output:t}}function Ch(e){return{type:bh,input:e}}function Th(e){setTimeout((()=>{throw e}))}const $h="function"==typeof Symbol&&Symbol.observable||"@@observable";function _h(e,t){return`${e.sessionId}.${t}`}let xh=0;function Ih(e,t){const i=Ah(e),n=Ah(t);return"string"==typeof n?"string"==typeof i&&n===i:"string"==typeof i?i in n:Object.keys(i).every((e=>e in n&&Ih(i[e],n[e])))}function Rh(e){if(Oh(e))return e;let t=[],i="";for(let n=0;n<e.length;n++){switch(e.charCodeAt(n)){case 92:i+=e[n+1],n++;continue;case 46:t.push(i),i="";continue}i+=e[n]}return t.push(i),t}function Ah(e){if((t=e)&&"object"==typeof t&&"machine"in t&&"value"in t)return e.value;var t;if("string"!=typeof e)return e;return function(e){if(1===e.length)return e[0];const t={};let i=t;for(let t=0;t<e.length-1;t++)if(t===e.length-2)i[e[t]]=e[t+1];else{const n=i;i={},n[e[t]]=i}return t}(Rh(e))}function Ph(e,t){const i={},n=Object.keys(e);for(let r=0;r<n.length;r++){const s=n[r];i[s]=t(e[s],s,e,r)}return i}function Dh(e){return Oh(e)?e:[e]}function Nh(e){return void 0===e?[]:Dh(e)}function kh(e,t,i,n){return"function"==typeof e?e({context:t,event:i,self:n}):e}function Oh(e){return Array.isArray(e)}function Fh(e){return Dh(e).map((e=>void 0===e||"string"==typeof e?{target:e}:e))}function Mh(e){if(void 0!==e&&e!==Sh)return Nh(e)}function Hh(e,t,i){const n="object"==typeof e,r=n?e:void 0;return{next:(n?e.next:e)?.bind(r),error:(n?e.error:t)?.bind(r),complete:(n?e.complete:i)?.bind(r)}}function Lh(e,t){return`${t}.${e}`}function jh(e,t){const i=t.match(/^xstate\.invoke\.(\d+)\.(.*)/);if(!i)return e.implementations.actors[t];const[,n,r]=i,s=e.getStateNodeById(r).config.invoke;return(Array.isArray(s)?s[n]:s).src}const Bh=1;let Uh=function(e){return e[e.NotStarted=0]="NotStarted",e[e.Running=1]="Running",e[e.Stopped=2]="Stopped",e}({});const Vh={clock:{setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e)},logger:console.log.bind(console),devTools:!1};class qh{constructor(e,t){this.logic=e,this._snapshot=void 0,this.clock=void 0,this.options=void 0,this.id=void 0,this.mailbox=new vh(this._process.bind(this)),this.observers=new Set,this.eventListeners=new Map,this.logger=void 0,this._processingStatus=Uh.NotStarted,this._parent=void 0,this._syncSnapshot=void 0,this.ref=void 0,this._actorScope=void 0,this._systemId=void 0,this.sessionId=void 0,this.system=void 0,this._doneEvent=void 0,this.src=void 0,this._deferred=[];const i={...Vh,...t},{clock:n,logger:r,parent:s,syncSnapshot:a,id:o,systemId:c,inspect:d}=i;this.system=s?s.system:function(e,t){const i=new Map,n=new Map,r=new WeakMap,s=new Set,a={},{clock:o,logger:c}=t,d={schedule:(e,t,i,n,r=Math.random().toString(36).slice(2))=>{const s={source:e,target:t,event:i,delay:n,id:r,startedAt:Date.now()},c=_h(e,r);l._snapshot._scheduledEvents[c]=s;const d=o.setTimeout((()=>{delete a[c],delete l._snapshot._scheduledEvents[c],l._relay(e,t,i)}),n);a[c]=d},cancel:(e,t)=>{const i=_h(e,t),n=a[i];delete a[i],delete l._snapshot._scheduledEvents[i],o.clearTimeout(n)},cancelAll:e=>{for(const t in l._snapshot._scheduledEvents){const i=l._snapshot._scheduledEvents[t];i.source===e&&d.cancel(e,i.id)}}},l={_snapshot:{_scheduledEvents:(t?.snapshot&&t.snapshot.scheduler)??{}},_bookId:()=>"x:"+xh++,_register:(e,t)=>(i.set(e,t),e),_unregister:e=>{i.delete(e.sessionId);const t=r.get(e);void 0!==t&&(n.delete(t),r.delete(e))},get:e=>n.get(e),_set:(e,t)=>{const i=n.get(e);if(i&&i!==t)throw new Error(`Actor with system ID '${e}' already exists.`);n.set(e,t),r.set(t,e)},inspect:e=>{s.add(e)},_sendInspectionEvent:t=>{if(!s.size)return;const i={...t,rootId:e.sessionId};s.forEach((e=>e.next?.(i)))},_relay:(e,t,i)=>{l._sendInspectionEvent({type:"@xstate.event",sourceRef:e,actorRef:t,event:i}),t._send(i)},scheduler:d,getSnapshot:()=>({_scheduledEvents:{...l._snapshot._scheduledEvents}}),start:()=>{const e=l._snapshot._scheduledEvents;l._snapshot._scheduledEvents={};for(const t in e){const{source:i,target:n,event:r,delay:s,id:a}=e[t];d.schedule(i,n,r,s,a)}},_clock:o,_logger:c};return l}(this,{clock:n,logger:r}),d&&!s&&this.system.inspect(Hh(d)),this.sessionId=this.system._bookId(),this.id=o??this.sessionId,this.logger=t?.logger??this.system._logger,this.clock=t?.clock??this.system._clock,this._parent=s,this._syncSnapshot=a,this.options=i,this.src=i.src??e,this.ref=this,this._actorScope={self:this,id:this.id,sessionId:this.sessionId,logger:this.logger,defer:e=>{this._deferred.push(e)},system:this.system,stopChild:e=>{if(e._parent!==this)throw new Error(`Cannot stop child actor ${e.id} of ${this.id} because it is not a child`);e._stop()},emit:e=>{const t=this.eventListeners.get(e.type),i=this.eventListeners.get("*");if(!t&&!i)return;const n=new Set([...t?t.values():[],...i?i.values():[]]);for(const t of Array.from(n))t(e)}},this.send=this.send.bind(this),this.system._sendInspectionEvent({type:"@xstate.actor",actorRef:this}),c&&(this._systemId=c,this.system._set(c,this)),this._initState(t?.snapshot??t?.state),c&&"active"!==this._snapshot.status&&this.system._unregister(this)}_initState(e){try{this._snapshot=e?this.logic.restoreSnapshot?this.logic.restoreSnapshot(e,this._actorScope):e:this.logic.getInitialSnapshot(this._actorScope,this.options?.input)}catch(e){this._snapshot={status:"error",output:void 0,error:e}}}update(e,t){let i;for(this._snapshot=e;i=this._deferred.shift();)try{i()}catch(t){this._deferred.length=0,this._snapshot={...e,status:"error",error:t}}switch(this._snapshot.status){case"active":for(const t of this.observers)try{t.next?.(e)}catch(e){Th(e)}break;case"done":for(const t of this.observers)try{t.next?.(e)}catch(e){Th(e)}this._stopProcedure(),this._complete(),this._doneEvent=(n=this.id,r=this._snapshot.output,{type:`xstate.done.actor.${n}`,output:r}),this._parent&&this.system._relay(this,this._parent,this._doneEvent);break;case"error":this._error(this._snapshot.error)}var n,r;this.system._sendInspectionEvent({type:"@xstate.snapshot",actorRef:this,event:t,snapshot:e})}subscribe(e,t,i){const n=Hh(e,t,i);if(this._processingStatus!==Uh.Stopped)this.observers.add(n);else switch(this._snapshot.status){case"done":try{n.complete?.()}catch(e){Th(e)}break;case"error":{const e=this._snapshot.error;if(n.error)try{n.error(e)}catch(e){Th(e)}else Th(e);break}}return{unsubscribe:()=>{this.observers.delete(n)}}}on(e,t){let i=this.eventListeners.get(e);i||(i=new Set,this.eventListeners.set(e,i));const n=t.bind(void 0);return i.add(n),{unsubscribe:()=>{i.delete(n)}}}start(){if(this._processingStatus===Uh.Running)return this;this._syncSnapshot&&this.subscribe({next:e=>{"active"===e.status&&this.system._relay(this,this._parent,{type:`xstate.snapshot.${this.id}`,snapshot:e})},error:()=>{}}),this.system._register(this.sessionId,this),this._systemId&&this.system._set(this._systemId,this),this._processingStatus=Uh.Running;const e=Ch(this.options.input);this.system._sendInspectionEvent({type:"@xstate.event",sourceRef:this._parent,actorRef:this,event:e});switch(this._snapshot.status){case"done":return this.update(this._snapshot,e),this;case"error":return this._error(this._snapshot.error),this}if(this._parent||this.system.start(),this.logic.start)try{this.logic.start(this._snapshot,this._actorScope)}catch(e){return this._snapshot={...this._snapshot,status:"error",error:e},this._error(e),this}return this.update(this._snapshot,e),this.options.devTools&&this.attachDevTools(),this.mailbox.start(),this}_process(e){let t,i;try{t=this.logic.transition(this._snapshot,e,this._actorScope)}catch(e){i={err:e}}if(i){const{err:e}=i;return this._snapshot={...this._snapshot,status:"error",error:e},void this._error(e)}this.update(t,e),e.type===wh&&(this._stopProcedure(),this._complete())}_stop(){return this._processingStatus===Uh.Stopped?this:(this.mailbox.clear(),this._processingStatus===Uh.NotStarted?(this._processingStatus=Uh.Stopped,this):(this.mailbox.enqueue({type:wh}),this))}stop(){if(this._parent)throw new Error("A non-root actor cannot be stopped directly.");return this._stop()}_complete(){for(const e of this.observers)try{e.complete?.()}catch(e){Th(e)}this.observers.clear()}_reportError(e){if(!this.observers.size)return void(this._parent||Th(e));let t=!1;for(const i of this.observers){const n=i.error;t||=!n;try{n?.(e)}catch(e){Th(e)}}this.observers.clear(),t&&Th(e)}_error(e){this._stopProcedure(),this._reportError(e),this._parent&&this.system._relay(this,this._parent,{type:`xstate.error.actor.${this.id}`,error:e})}_stopProcedure(){return this._processingStatus!==Uh.Running||(this.system.scheduler.cancelAll(this),this.mailbox.clear(),this.mailbox=new vh(this._process.bind(this)),this._processingStatus=Uh.Stopped,this.system._unregister(this)),this}_send(e){this._processingStatus!==Uh.Stopped&&this.mailbox.enqueue(e)}send(e){this.system._relay(void 0,this,e)}attachDevTools(){const{devTools:e}=this.options;if(e){("function"==typeof e?e:mh)(this)}}toJSON(){return{xstate$$type:Bh,id:this.id}}getPersistedSnapshot(e){return this.logic.getPersistedSnapshot(this._snapshot,e)}[$h](){return this}getSnapshot(){return this._snapshot}}function Gh(e,...[t]){return new qh(e,t)}function Kh(e,t,i,n,{sendId:r}){return[t,"function"==typeof r?r(i,n):r]}function Wh(e,t){e.defer((()=>{e.system.scheduler.cancel(e.self,t)}))}function zh(e,t,i,n,{id:r,systemId:s,src:a,input:o,syncSnapshot:c}){const d="string"==typeof a?jh(t.machine,a):a,l="function"==typeof r?r(i):r;let h;return d&&(h=Gh(d,{id:l,src:a,parent:e.self,syncSnapshot:c,systemId:s,input:"function"==typeof o?o({context:t.context,event:i.event,self:e.self}):o})),[Gu(t,{children:{...t.children,[l]:h}}),{id:r,actorRef:h}]}function Yh(e,{id:t,actorRef:i}){i&&e.defer((()=>{i._processingStatus!==Uh.Stopped&&i.start()}))}function Jh(...[e,{id:t,systemId:i,input:n,syncSnapshot:r=!1}={}]){function s(e,t){}return s.type="snapshot.spawnChild",s.id=t,s.systemId=i,s.src=e,s.input=n,s.syncSnapshot=r,s.resolve=zh,s.execute=Yh,s}function Zh(e,t,i,n,{actorRef:r}){const s="function"==typeof r?r(i,n):r,a="string"==typeof s?t.children[s]:s;let o=t.children;return a&&(o={...o},delete o[a.id]),[Gu(t,{children:o}),a]}function Xh(e,t){t&&(e.system._unregister(t),t._processingStatus===Uh.Running?e.defer((()=>{e.stopChild(t)})):e.stopChild(t))}function Qh(e){function t(e,t){}return t.type="xstate.stopChild",t.actorRef=e,t.resolve=Zh,t.execute=Xh,t}function eu(e,t,i,n){const{machine:r}=n,s="function"==typeof e,a=s?e:r.implementations.guards["string"==typeof e?e:e.type];if(!s&&!a)throw new Error(`Guard '${"string"==typeof e?e:e.type}' is not implemented.'.`);if("function"!=typeof a)return eu(a,t,i,n);const o={context:t,event:i},c=s||"string"==typeof e?void 0:"params"in e?"function"==typeof e.params?e.params({context:t,event:i}):e.params:void 0;if(!("check"in a))return a(o,c);return a.check(n,o,a)}const tu=e=>"atomic"===e.type||"final"===e.type;function iu(e){return Object.values(e.states).filter((e=>"history"!==e.type))}function nu(e,t){const i=[];if(t===e)return i;let n=e.parent;for(;n&&n!==t;)i.push(n),n=n.parent;return i}function ru(e){const t=new Set(e),i=au(t);for(const e of t)if("compound"!==e.type||i.get(e)&&i.get(e).length){if("parallel"===e.type)for(const i of iu(e))if("history"!==i.type&&!t.has(i)){const e=gu(i);for(const i of e)t.add(i)}}else gu(e).forEach((e=>t.add(e)));for(const e of t){let i=e.parent;for(;i;)t.add(i),i=i.parent}return t}function su(e,t){const i=t.get(e);if(!i)return{};if("compound"===e.type){const e=i[0];if(!e)return{};if(tu(e))return e.key}const n={};for(const e of i)n[e.key]=su(e,t);return n}function au(e){const t=new Map;for(const i of e)t.has(i)||t.set(i,[]),i.parent&&(t.has(i.parent)||t.set(i.parent,[]),t.get(i.parent).push(i));return t}function ou(e,t){return su(e,au(ru(t)))}function cu(e,t){return"compound"===t.type?iu(t).some((t=>"final"===t.type&&e.has(t))):"parallel"===t.type?iu(t).every((t=>cu(e,t))):"final"===t.type}const du=e=>"#"===e[0];function lu(e){const t=e.config.after;if(!t)return[];const i=(t,i)=>{const n=(r=t,s=e.id,{type:`xstate.after.${r}.${s}`});var r,s;const a=n.type;return e.entry.push(function(e,t){function i(e,t){}return i.type="xstate.raise",i.event=e,i.id=t?.id,i.delay=t?.delay,i.resolve=Wu,i.execute=zu,i}(n,{id:a,delay:t})),e.exit.push(function(e){function t(e,t){}return t.type="xstate.cancel",t.sendId=e,t.resolve=Kh,t.execute=Wh,t}(a)),a};return Object.keys(t).flatMap(((e,n)=>{const r=t[e],s="string"==typeof r?{target:r}:r,a=Number.isNaN(+e)?e:+e,o=i(a);return Nh(s).map((e=>({...e,event:o,delay:a})))})).map((t=>{const{delay:i}=t;return{...hu(e,t.event,t),delay:i}}))}function hu(e,t,i){const n=Mh(i.target),r=i.reenter??!1,s=function(e,t){if(void 0===t)return;return t.map((t=>{if("string"!=typeof t)return t;if(du(t))return e.machine.getStateNodeById(t);const i=t[0]===yh;if(i&&!e.parent)return vu(e,t.slice(1));const n=i?e.key+t:t;if(!e.parent)throw new Error(`Invalid target: "${t}" is not a valid target from the root node. Did you mean ".${t}"?`);try{return vu(e.parent,n)}catch(t){throw new Error(`Invalid transition definition for state node '${e.id}':\n${t.message}`)}}))}(e,n),a={...i,actions:Nh(i.actions),guard:i.guard,target:s,source:e,reenter:r,eventType:t,toJSON:()=>({...a,source:`#${e.id}`,target:s?s.map((e=>`#${e.id}`)):void 0})};return a}function uu(e){const t=Mh(e.config.target);return t?{target:t.map((t=>"string"==typeof t?vu(e.parent,t):t))}:e.parent.initial}function pu(e){return"history"===e.type}function gu(e){const t=fu(e);for(const i of t)for(const n of nu(i,e))t.add(n);return t}function fu(e){const t=new Set;return function e(i){if(!t.has(i))if(t.add(i),"compound"===i.type)e(i.initial.target[0]);else if("parallel"===i.type)for(const t of iu(i))e(t)}(e),t}function mu(e,t){if(du(t))return e.machine.getStateNodeById(t);if(!e.states)throw new Error(`Unable to retrieve child state '${t}' from '${e.id}'; no child states exist.`);const i=e.states[t];if(!i)throw new Error(`Child state '${t}' does not exist on '${e.id}'`);return i}function vu(e,t){if("string"==typeof t&&du(t))try{return e.machine.getStateNodeById(t)}catch(e){}const i=Rh(t).slice();let n=e;for(;i.length;){const e=i.shift();if(!e.length)break;n=mu(n,e)}return n}function yu(e,t){if("string"==typeof t){const i=e.states[t];if(!i)throw new Error(`State '${t}' does not exist on '${e.id}'`);return[e,i]}const i=Object.keys(t),n=i.map((t=>mu(e,t))).filter(Boolean);return[e.machine.root,e].concat(n,i.reduce(((i,n)=>{const r=mu(e,n);if(!r)return i;const s=yu(r,t[n]);return i.concat(s)}),[]))}function Su(e,t,i,n){return"string"==typeof t?function(e,t,i,n){const r=mu(e,t).next(i,n);return r&&r.length?r:e.next(i,n)}(e,t,i,n):1===Object.keys(t).length?function(e,t,i,n){const r=Object.keys(t),s=Su(mu(e,r[0]),t[r[0]],i,n);return s&&s.length?s:e.next(i,n)}(e,t,i,n):function(e,t,i,n){const r=[];for(const s of Object.keys(t)){const a=t[s];if(!a)continue;const o=Su(mu(e,s),a,i,n);o&&r.push(...o)}return r.length?r:e.next(i,n)}(e,t,i,n)}function bu(e){return Object.keys(e.states).map((t=>e.states[t])).filter((e=>"history"===e.type))}function wu(e,t){let i=e;for(;i.parent&&i.parent!==t;)i=i.parent;return i.parent===t}function Eu(e,t){const i=new Set(e),n=new Set(t);for(const e of i)if(n.has(e))return!0;for(const e of n)if(i.has(e))return!0;return!1}function Cu(e,t,i){const n=new Set;for(const r of e){let e=!1;const s=new Set;for(const a of n)if(Eu(_u([r],t,i),_u([a],t,i))){if(!wu(r.source,a.source)){e=!0;break}s.add(a)}if(!e){for(const e of s)n.delete(e);n.add(r)}}return Array.from(n)}function Tu(e,t){if(!e.target)return[];const i=new Set;for(const n of e.target)if(pu(n))if(t[n.id])for(const e of t[n.id])i.add(e);else for(const e of Tu(uu(n),t))i.add(e);else i.add(n);return[...i]}function $u(e,t){const i=Tu(e,t);if(!i)return;if(!e.reenter&&i.every((t=>t===e.source||wu(t,e.source))))return e.source;const n=function(e){const[t,...i]=e;for(const e of nu(t,void 0))if(i.every((t=>wu(t,e))))return e}(i.concat(e.source));return n||(e.reenter?void 0:e.source.machine.root)}function _u(e,t,i){const n=new Set;for(const r of e)if(r.target?.length){const e=$u(r,i);r.reenter&&r.source===e&&n.add(e);for(const i of t)wu(i,e)&&n.add(i)}return[...n]}function xu(e,t,i,n,r,s){if(!e.length)return t;const a=new Set(t._nodes);let o=t.historyValue;const c=Cu(e,a,o);let d=t;r||([d,o]=function(e,t,i,n,r,s,a){let o=e;const c=_u(n,r,s);let d;c.sort(((e,t)=>t.order-e.order));for(const e of c)for(const t of bu(e)){let i;i="deep"===t.history?t=>tu(t)&&wu(t,e):t=>t.parent===e,d??={...s},d[t.id]=Array.from(r).filter(i)}for(const e of c)o=ku(o,t,i,[...e.exit,...e.invoke.map((e=>Qh(e.id)))],a),r.delete(e);return[o,d||s]}(d,n,i,c,a,o,s)),d=ku(d,n,i,c.flatMap((e=>e.actions)),s),d=function(e,t,i,n,r,s,a,o){let c=e;const d=new Set,l=new Set;(function(e,t,i,n){for(const r of e){const e=$u(r,t);for(const s of r.target||[])pu(s)||r.source===s&&r.source===e&&!r.reenter||(n.add(s),i.add(s)),Ru(s,t,i,n);const s=Tu(r,t);for(const a of s){const s=nu(a,e);"parallel"===e?.type&&s.push(e),Au(n,t,i,s,!r.source.parent&&r.reenter?void 0:e)}}})(n,a,l,d),o&&l.add(e.machine.root);const h=new Set;for(const e of[...d].sort(((e,t)=>e.order-t.order))){r.add(e);const n=[];n.push(...e.entry);for(const t of e.invoke)n.push(Jh(t.src,{...t,syncSnapshot:!!t.onSnapshot}));if(l.has(e)){const t=e.initial.actions;n.push(...t)}if(c=ku(c,t,i,n,s,e.invoke.map((e=>e.id))),"final"===e.type){const n=e.parent;let a="parallel"===n?.type?n:n?.parent,o=a||e;for("compound"===n?.type&&s.push(Eh(n.id,void 0!==e.output?kh(e.output,c.context,t,i.self):void 0));"parallel"===a?.type&&!h.has(a)&&cu(r,a);)h.add(a),s.push(Eh(a.id)),o=a,a=a.parent;if(a)continue;c=Gu(c,{status:"done",output:Iu(c,t,i,c.machine.root,o)})}}return c}(d,n,i,c,a,s,o,r);const l=[...a];"done"===d.status&&(d=ku(d,n,i,l.sort(((e,t)=>t.order-e.order)).flatMap((e=>e.exit)),s));try{return o===t.historyValue&&function(e,t){if(e.length!==t.size)return!1;for(const i of e)if(!t.has(i))return!1;return!0}(t._nodes,a)?d:Gu(d,{_nodes:l,historyValue:o})}catch(e){throw e}}function Iu(e,t,i,n,r){if(void 0===n.output)return;const s=Eh(r.id,void 0!==r.output&&r.parent?kh(r.output,e.context,t,i.self):void 0);return kh(n.output,e.context,s,i.self)}function Ru(e,t,i,n){if(pu(e))if(t[e.id]){const r=t[e.id];for(const e of r)n.add(e),Ru(e,t,i,n);for(const s of r)Pu(s,e.parent,n,t,i)}else{const r=uu(e);for(const s of r.target)n.add(s),r===e.parent?.initial&&i.add(e.parent),Ru(s,t,i,n);for(const s of r.target)Pu(s,e.parent,n,t,i)}else if("compound"===e.type){const[r]=e.initial.target;pu(r)||(n.add(r),i.add(r)),Ru(r,t,i,n),Pu(r,e,n,t,i)}else if("parallel"===e.type)for(const r of iu(e).filter((e=>!pu(e))))[...n].some((e=>wu(e,r)))||(pu(r)||(n.add(r),i.add(r)),Ru(r,t,i,n))}function Au(e,t,i,n,r){for(const s of n)if(r&&!wu(s,r)||e.add(s),"parallel"===s.type)for(const n of iu(s).filter((e=>!pu(e))))[...e].some((e=>wu(e,n)))||(e.add(n),Ru(n,t,i,e))}function Pu(e,t,i,n,r){Au(i,n,r,nu(e,t))}let Du=!1;function Nu(e,t,i,n,r,s){const{machine:a}=e;let o=e;for(const c of n){const d="function"==typeof c,l=d?c:a.implementations.actions["string"==typeof c?c:c.type];if(!l)continue;const h={context:o.context,event:t,self:i.self,system:i.system},u=d||"string"==typeof c?void 0:"params"in c?"function"==typeof c.params?c.params({context:o.context,event:t}):c.params:void 0;function p(){i.system._sendInspectionEvent({type:"@xstate.action",actorRef:i.self,action:{type:"string"==typeof c?c:"object"==typeof c?c.type:c.name||"(anonymous)",params:u}});try{Du=l,l(h,u)}finally{Du=!1}}if(!("resolve"in l)){i.self._processingStatus===Uh.Running?p():i.defer((()=>{p()}));continue}const g=l,[f,m,v]=g.resolve(i,o,h,u,l,r);o=f,"retryResolve"in g&&s?.push([g,m]),"execute"in g&&(i.self._processingStatus===Uh.Running?g.execute(i,m):i.defer(g.execute.bind(null,i,m))),v&&(o=Nu(o,t,i,v,r,s))}return o}function ku(e,t,i,n,r,s){const a=s?[]:void 0,o=Nu(e,t,i,n,{internalQueue:r,deferredActorIds:s},a);return a?.forEach((([e,t])=>{e.retryResolve(i,o,t)})),o}function Ou(e,t,i,n=[]){let r=e;const s=[];function a(e,t,n){i.system._sendInspectionEvent({type:"@xstate.microstep",actorRef:i.self,event:t,snapshot:e,_transitions:n}),s.push(e)}if(t.type===wh)return r=Gu(Fu(r,t,i),{status:"stopped"}),a(r,t,[]),{snapshot:r,microstates:s};let o=t;if(o.type!==bh){const t=o,c=function(e){return e.type.startsWith("xstate.error.actor")}(t),d=Mu(t,r);if(c&&!d.length)return r=Gu(e,{status:"error",error:t.error}),a(r,t,[]),{snapshot:r,microstates:s};r=xu(d,e,i,o,!1,n),a(r,t,d)}let c=!0;for(;"active"===r.status;){let e=c?Hu(r,o):[];const t=e.length?r:void 0;if(!e.length){if(!n.length)break;o=n.shift(),e=Mu(o,r)}r=xu(e,r,i,o,!1,n),c=r!==t,a(r,o,e)}return"active"!==r.status&&Fu(r,o,i),{snapshot:r,microstates:s}}function Fu(e,t,i){return ku(e,t,i,Object.values(e.children).map((e=>Qh(e))),[])}function Mu(e,t){return t.machine.getTransitionData(t,e)}function Hu(e,t){const i=new Set,n=e._nodes.filter(tu);for(const r of n)e:for(const n of[r].concat(nu(r,void 0)))if(n.always)for(const r of n.always)if(void 0===r.guard||eu(r.guard,e.context,t,e)){i.add(r);break e}return Cu(Array.from(i),new Set(e._nodes),e.historyValue)}const Lu=function(e){return Ih(e,this.value)},ju=function(e){return this.tags.has(e)},Bu=function(e){const t=this.machine.getTransitionData(this,e);return!!t?.length&&t.some((e=>void 0!==e.target||e.actions.length))},Uu=function(){const{_nodes:e,tags:t,machine:i,getMeta:n,toJSON:r,can:s,hasTag:a,matches:o,...c}=this;return{...c,tags:Array.from(t)}},Vu=function(){return this._nodes.reduce(((e,t)=>(void 0!==t.meta&&(e[t.id]=t.meta),e)),{})};function qu(e,t){return{status:e.status,output:e.output,error:e.error,machine:t,context:e.context,_nodes:e._nodes,value:ou(t.root,e._nodes),tags:new Set(e._nodes.flatMap((e=>e.tags))),children:e.children,historyValue:e.historyValue||{},matches:Lu,hasTag:ju,can:Bu,getMeta:Vu,toJSON:Uu}}function Gu(e,t={}){return qu({...e,...t},e.machine)}function Ku(e){let t;for(const i in e){const n=e[i];if(n&&"object"==typeof n)if("sessionId"in n&&"send"in n&&"ref"in n)t??=Array.isArray(e)?e.slice():{...e},t[i]={xstate$$type:Bh,id:n.id};else{const r=Ku(n);r!==n&&(t??=Array.isArray(e)?e.slice():{...e},t[i]=r)}}return t??e}function Wu(e,t,i,n,{event:r,id:s,delay:a},{internalQueue:o}){const c=t.machine.implementations.delays;if("string"==typeof r)throw new Error(`Only event objects may be used with raise; use raise({ type: "${r}" }) instead`);const d="function"==typeof r?r(i,n):r;let l;if("string"==typeof a){const e=c&&c[a];l="function"==typeof e?e(i,n):e}else l="function"==typeof a?a(i,n):a;return"number"!=typeof l&&o.push(d),[t,{event:d,id:s,delay:l}]}function zu(e,t){const{event:i,delay:n,id:r}=t;"number"!=typeof n||e.defer((()=>{const t=e.self;e.system.scheduler.schedule(t,t,i,n,r)}))}function Yu(e,{machine:t,context:i},n,r){return(s,a)=>{const o=((s,a={})=>{const{systemId:o,input:c}=a;if("string"==typeof s){const d=jh(t,s);if(!d)throw new Error(`Actor logic '${s}' not implemented in machine '${t.id}'`);const l=Gh(d,{id:a.id,parent:e.self,syncSnapshot:a.syncSnapshot,input:"function"==typeof c?c({context:i,event:n,self:e.self}):c,src:s,systemId:o});return r[l.id]=l,l}return Gh(s,{id:a.id,parent:e.self,syncSnapshot:a.syncSnapshot,input:a.input,src:s,systemId:o})})(s,a);return r[o.id]=o,e.defer((()=>{o._processingStatus!==Uh.Stopped&&o.start()})),o}}function Ju(e,t,i,n,{assignment:r}){if(!t.context)throw new Error("Cannot assign to undefined `context`. Ensure that `context` is defined in the machine config.");const s={},a={context:t.context,event:i.event,spawn:Yu(e,t,i.event,s),self:e.self,system:e.system};let o={};if("function"==typeof r)o=r(a,n);else for(const e of Object.keys(r)){const t=r[e];o[e]="function"==typeof t?t(a,n):t}return[Gu(t,{context:Object.assign({},t.context,o),children:Object.keys(s).length?{...t.children,...s}:t.children})]}function Zu(e){function t(e,t){}return t.type="xstate.assign",t.assignment=e,t.resolve=Ju,t}const Xu=new WeakMap;function Qu(e,t,i){let n=Xu.get(e);return n?t in n||(n[t]=i()):(n={[t]:i()},Xu.set(e,n)),n[t]}const ep={},tp=e=>"string"==typeof e?{type:e}:"function"==typeof e?"resolve"in e?{type:e.type}:{type:e.name}:e;class ip{constructor(e,t){if(this.config=e,this.key=void 0,this.id=void 0,this.type=void 0,this.path=void 0,this.states=void 0,this.history=void 0,this.entry=void 0,this.exit=void 0,this.parent=void 0,this.machine=void 0,this.meta=void 0,this.output=void 0,this.order=-1,this.description=void 0,this.tags=[],this.transitions=void 0,this.always=void 0,this.parent=t._parent,this.key=t._key,this.machine=t._machine,this.path=this.parent?this.parent.path.concat(this.key):[],this.id=this.config.id||[this.machine.id,...this.path].join(yh),this.type=this.config.type||(this.config.states&&Object.keys(this.config.states).length?"compound":this.config.history?"history":"atomic"),this.description=this.config.description,this.order=this.machine.idMap.size,this.machine.idMap.set(this.id,this),this.states=this.config.states?Ph(this.config.states,((e,t)=>new ip(e,{_parent:this,_key:t,_machine:this.machine}))):ep,"compound"===this.type&&!this.config.initial)throw new Error(`No initial state specified for compound state node "#${this.id}". Try adding { initial: "${Object.keys(this.states)[0]}" } to the state config.`);this.history=!0===this.config.history?"shallow":this.config.history||!1,this.entry=Nh(this.config.entry).slice(),this.exit=Nh(this.config.exit).slice(),this.meta=this.config.meta,this.output="final"!==this.type&&this.parent?void 0:this.config.output,this.tags=Nh(e.tags).slice()}_initialize(){this.transitions=function(e){const t=new Map;if(e.config.on)for(const i of Object.keys(e.config.on)){if(""===i)throw new Error('Null events ("") cannot be specified as a transition key. Use `always: { ... }` instead.');const n=e.config.on[i];t.set(i,Fh(n).map((t=>hu(e,i,t))))}if(e.config.onDone){const i=`xstate.done.state.${e.id}`;t.set(i,Fh(e.config.onDone).map((t=>hu(e,i,t))))}for(const i of e.invoke){if(i.onDone){const n=`xstate.done.actor.${i.id}`;t.set(n,Fh(i.onDone).map((t=>hu(e,n,t))))}if(i.onError){const n=`xstate.error.actor.${i.id}`;t.set(n,Fh(i.onError).map((t=>hu(e,n,t))))}if(i.onSnapshot){const n=`xstate.snapshot.${i.id}`;t.set(n,Fh(i.onSnapshot).map((t=>hu(e,n,t))))}}for(const i of e.after){let e=t.get(i.eventType);e||(e=[],t.set(i.eventType,e)),e.push(i)}return t}(this),this.config.always&&(this.always=Fh(this.config.always).map((e=>hu(this,"",e)))),Object.keys(this.states).forEach((e=>{this.states[e]._initialize()}))}get definition(){return{id:this.id,key:this.key,version:this.machine.version,type:this.type,initial:this.initial?{target:this.initial.target,source:this,actions:this.initial.actions.map(tp),eventType:null,reenter:!1,toJSON:()=>({target:this.initial.target.map((e=>`#${e.id}`)),source:`#${this.id}`,actions:this.initial.actions.map(tp),eventType:null})}:void 0,history:this.history,states:Ph(this.states,(e=>e.definition)),on:this.on,transitions:[...this.transitions.values()].flat().map((e=>({...e,actions:e.actions.map(tp)}))),entry:this.entry.map(tp),exit:this.exit.map(tp),meta:this.meta,order:this.order||-1,output:this.output,invoke:this.invoke,description:this.description,tags:this.tags}}toJSON(){return this.definition}get invoke(){return Qu(this,"invoke",(()=>Nh(this.config.invoke).map(((e,t)=>{const{src:i,systemId:n}=e,r=e.id??Lh(this.id,t),s="string"==typeof i?i:`xstate.invoke.${Lh(this.id,t)}`;return{...e,src:s,id:r,systemId:n,toJSON(){const{onDone:t,onError:i,...n}=e;return{...n,type:"xstate.invoke",src:s,id:r}}}}))))}get on(){return Qu(this,"on",(()=>[...this.transitions].flatMap((([e,t])=>t.map((t=>[e,t])))).reduce(((e,[t,i])=>(e[t]=e[t]||[],e[t].push(i),e)),{})))}get after(){return Qu(this,"delayedTransitions",(()=>lu(this)))}get initial(){return Qu(this,"initial",(()=>function(e,t){const i="string"==typeof t?e.states[t]:t?e.states[t.target]:void 0;if(!i&&t)throw new Error(`Initial state node "${t}" not found on parent state node #${e.id}`);const n={source:e,actions:t&&"string"!=typeof t?Nh(t.actions):[],eventType:null,reenter:!1,target:i?[i]:[],toJSON:()=>({...n,source:`#${e.id}`,target:i?[`#${i.id}`]:[]})};return n}(this,this.config.initial)))}next(e,t){const i=t.type,n=[];let r;const s=Qu(this,`candidates-${i}`,(()=>function(e,t){const i=e.transitions.get(t)||[...e.transitions.keys()].filter((e=>{if("*"===e)return!0;if(!e.endsWith(".*"))return!1;const i=e.split("."),n=t.split(".");for(let e=0;e<i.length;e++){const t=i[e],r=n[e];if("*"===t)return e===i.length-1;if(t!==r)return!1}return!0})).sort(((e,t)=>t.length-e.length)).flatMap((t=>e.transitions.get(t)));return i}(this,i)));for(const a of s){const{guard:s}=a,o=e.context;let c=!1;try{c=!s||eu(s,o,t,e)}catch(e){const t="string"==typeof s?s:"object"==typeof s?s.type:void 0;throw new Error(`Unable to evaluate guard ${t?`'${t}' `:""}in transition for event '${i}' in state node '${this.id}':\n${e.message}`)}if(c){n.push(...a.actions),r=a;break}}return r?[r]:void 0}get events(){return Qu(this,"events",(()=>{const{states:e}=this,t=new Set(this.ownEvents);if(e)for(const i of Object.keys(e)){const n=e[i];if(n.states)for(const e of n.events)t.add(`${e}`)}return Array.from(t)}))}get ownEvents(){const e=new Set([...this.transitions.keys()].filter((e=>this.transitions.get(e).some((e=>!(!e.target&&!e.actions.length&&!e.reenter))))));return Array.from(e)}}class np{constructor(e,t){this.config=e,this.version=void 0,this.schemas=void 0,this.implementations=void 0,this.__xstatenode=!0,this.idMap=new Map,this.root=void 0,this.id=void 0,this.states=void 0,this.events=void 0,this.__TResolvedTypesMeta=void 0,this.id=e.id||"(machine)",this.implementations={actors:t?.actors??{},actions:t?.actions??{},delays:t?.delays??{},guards:t?.guards??{}},this.version=this.config.version,this.schemas=this.config.schemas,this.transition=this.transition.bind(this),this.getInitialSnapshot=this.getInitialSnapshot.bind(this),this.getPersistedSnapshot=this.getPersistedSnapshot.bind(this),this.restoreSnapshot=this.restoreSnapshot.bind(this),this.start=this.start.bind(this),this.root=new ip(e,{_key:this.id,_machine:this}),this.root._initialize(),this.states=this.root.states,this.events=this.root.events}provide(e){const{actions:t,guards:i,actors:n,delays:r}=this.implementations;return new np(this.config,{actions:{...t,...e.actions},guards:{...i,...e.guards},actors:{...n,...e.actors},delays:{...r,...e.delays}})}resolveState(e){const t=(i=this.root,n=e.value,ou(i,[...ru(yu(i,n))]));var i,n;const r=ru(yu(this.root,t));return qu({_nodes:[...r],context:e.context||{},children:{},status:cu(r,this.root)?"done":e.status||"active",output:e.output,error:e.error,historyValue:e.historyValue},this)}transition(e,t,i){return Ou(e,t,i).snapshot}microstep(e,t,i){return Ou(e,t,i).microstates}getTransitionData(e,t){return Su(this.root,e.value,e,t)||[]}getPreInitialState(e,t,i){const{context:n}=this.config,r=qu({context:"function"!=typeof n&&n?n:{},_nodes:[this.root],children:{},status:"active"},this);if("function"==typeof n){return ku(r,t,e,[Zu((({spawn:e,event:t,self:i})=>n({spawn:e,input:t.input,self:i})))],i)}return r}getInitialSnapshot(e,t){const i=Ch(t),n=[],r=this.getPreInitialState(e,i,n),s=xu([{target:[...fu(this.root)],source:this.root,reenter:!0,actions:[],eventType:null,toJSON:null}],r,e,i,!0,n),{snapshot:a}=Ou(s,i,e,n);return a}start(e){Object.values(e.children).forEach((e=>{"active"===e.getSnapshot().status&&e.start()}))}getStateNodeById(e){const t=Rh(e),i=t.slice(1),n=du(t[0])?t[0].slice(1):t[0],r=this.idMap.get(n);if(!r)throw new Error(`Child state node '#${n}' does not exist on machine '${this.id}'`);return vu(r,i)}get definition(){return this.root.definition}toJSON(){return this.definition}getPersistedSnapshot(e,t){return function(e,t){const{_nodes:i,tags:n,machine:r,children:s,context:a,can:o,hasTag:c,matches:d,getMeta:l,toJSON:h,...u}=e,p={};for(const e in s){const i=s[e];p[e]={snapshot:i.getPersistedSnapshot(t),src:i.src,systemId:i._systemId,syncSnapshot:i._syncSnapshot}}return{...u,context:Ku(a),children:p}}(e,t)}restoreSnapshot(e,t){const i={},n=e.children;Object.keys(n).forEach((e=>{const r=n[e],s=r.snapshot,a=r.src,o="string"==typeof a?jh(this,a):a;if(!o)return;const c=Gh(o,{id:e,parent:t.self,syncSnapshot:r.syncSnapshot,snapshot:s,src:a,systemId:r.systemId});i[e]=c}));const r=qu({...e,children:i,_nodes:Array.from(ru(yu(this.root,e.value)))},this);let s=new Set;return function e(t,i){if(!s.has(t)){s.add(t);for(let n in t){const r=t[n];if(r&&"object"==typeof r){if("xstate$$type"in r&&r.xstate$$type===Bh){t[n]=i[r.id];continue}e(r,i)}}}}(r.context,i),r}}function rp({schemas:e,actors:t,actions:i,guards:n,delays:r}){return{createMachine:s=>function(e,t){return new np(e,t)}({...s,schemas:e},{actors:t,actions:i,guards:n,delays:r})}}class sp extends Error{state;constructor(e,t){super(e),this.state=t}}const ap="unregistered",op="registering",cp="registered",dp="register",lp="registerDone",hp="unregister",up="unregistered",pp="transportClosed",gp=rp({}).createMachine({id:"softphone",initial:ap,context:{},states:{[ap]:{on:{[dp]:op}},[op]:{on:{[lp]:cp,[pp]:ap,[up]:ap}},[cp]:{on:{[hp]:ap,[pp]:ap}}}}),fp=B.loggerFor("sip.js"),mp=B.loggerFor("sip"),vp=["Received WebSocket text message:","Sending WebSocket message:"],yp=(e,t,i,n)=>{const r=n&&n.indexOf?vp.findIndex((e=>-1!==n.indexOf(e))):-1;if("sip.Transport"===t&&-1!==r){const e=0===r?"receiving":"sending",i=n.replace(`${vp[r]}\n\n`,"").replace("\r\n","\n");mp.trace(i,{className:t,direction:e})}else fp.trace(n,{className:t})},Sp="idle",bp="ringing",wp="progress",Ep="established",Cp="terminated",Tp="ongoing",$p="held",_p="muted",xp="incomingCall",Ip="makeCall",Rp="accept",Ap="remotlyAccepted",Pp="reject",Dp="hangup",Np="hold",kp="resume",Op="mute",Fp="unMute",Mp=rp({guards:{isRegistered:()=>eg.state===cp}}).createMachine({id:"call",initial:Sp,context:{},states:{[Sp]:{on:{[xp]:{guard:"isRegistered",target:bp},[Ip]:{guard:"isRegistered",target:wp}}},[wp]:{on:{[Dp]:{guard:"isRegistered",target:Cp},[Ap]:{guard:"isRegistered",target:Ep}}},[bp]:{on:{[Rp]:{guard:"isRegistered",target:Ep},[Pp]:{guard:"isRegistered",target:Cp}}},[Ep]:{initial:Tp,on:{[Dp]:{guard:"isRegistered",target:Cp},[Np]:{guard:"isRegistered",target:`.${$p}`},[Op]:{guard:"isRegistered",target:`.${_p}`}},states:{[Tp]:{},[$p]:{on:{[kp]:{guard:"isRegistered",target:Tp}}},[_p]:{on:{[Fp]:{guard:"isRegistered",target:Tp}}}}},[Cp]:{}}});class Hp extends Error{state;action;constructor(e,t,i){super(e),this.action=t,this.state=i}}const Lp=B.loggerFor("state-machine"),jp=e=>e.getSnapshot().value,Bp=(e,t)=>e.getSnapshot().can({type:t}),Up=(e,t)=>{if(!Bp(e,t)){const i=e.getSnapshot().value,n=`Invalid state transition from ${i} with action ${t}`;throw Lp.warn(n),new Hp(n,t,i)}},Vp=(e,t)=>{if(!((e,t)=>jp(e)===t)(e,t)){const e=`Invalid state ${t}`;throw Lp.warn(e),new sp(e,t)}},qp=B.loggerFor("call"),Gp="message/TYPE_SIGNAL";class Kp extends Oi.EventEmitter{callActor;apiId;sipCall;talkingToIds;creationTime;answerTime;endTime;phone;shouldSendReinvite=!1;recording=!1;displayName;number;currentScreenShare;static newFrom(e){return Ut(e,Kp)}static parseCall(e){const t={id:e.sipCallId,stateChange:{addListener:()=>{}},remoteIdentity:{uri:{_normal:{user:e.calleeNumber}}},sessionDescriptionHandler:{localMediaStream:{getTracks:()=>e.isVideo?[{kind:"video",readyState:"live"}]:[]}}},i=new Kp(t,eg);i.apiId=e.id,i.answerTime=new Date(+e.startingTime);const n=i.callActor.getSnapshot();return e.isUp()&&(n.value={[Ep]:Tp}),e.muted&&(n.value={[Ep]:_p}),e.isRinging()&&(n.value=bp),e.isRecording()&&(i.recording=!0),i.callActor.update(n),i}constructor(e,t){super(),this.callActor=Gh(Mp),this.callActor.start(),this.creationTime=new Date,this.phone=t,this.sipCall=e,this.number=js(e),this.displayName=Bs(e),this._bindEvents()}async accept(e={}){return Up(this.callActor,Rp),qp.info("call - accept",{id:this.id,...e}),this._sendAction(Rp),this.phone.holdAllCalls(this),this.shouldSendReinvite=!1,this.answerTime=new Date,this.phone.client.answer(this.sipCall,e.withCamera).then((()=>(qp.info("call - accepted",{id:this.id,...e}),this.emit("locallyAccepted",this),this.id))).catch((e=>{throw qp.error(e),this.hangup(),e}))}async reject(){return Up(this.callActor,Pp),qp.info("call - reject",{id:this.id}),this.phone.emit(Yp,"call rejected locally"),this.shouldSendReinvite=!1,this.hangup()}async hangup(){return Up(this.callActor,Dp),qp.info("call - hangup",{id:this.id}),await this.phone.client.hangup(this.sipCall),this.phone.onCallTerminated(this),!0}forceCancel(){try{this.sipCall.outgoingInviteRequest.cancel()}catch(e){qp.info("call - force cancel, error",e)}}startConference(){}mute(){Up(this.callActor,Op),qp.info("call - mute",{id:this.id}),this._sendAction(Op),this.phone.client.mute(this.sipCall),this.emit("muted")}unMute(){Up(this.callActor,Fp),qp.info("call - un-mute",{id:this.id}),this._sendAction(Fp),this.phone.client.unmute(this.sipCall),this.emit("unMuted")}async hold(){Up(this.callActor,Np),qp.info("call - hold",{id:this.id}),this._sendAction(Np);const e=na(this.sipCall);this.currentScreenShare&&this.currentScreenShare.sipSessionId===this.id&&await this.stopScreenSharing(!1),e&&await Ea(this.sipCall);const t=this.phone.client.hold(this.sipCall,this.isConference(),e);return this.emit("held"),t}async resume(){Up(this.callActor,kp),this._sendAction(kp);const e=this.isConference(),t=na(this.sipCall),i=this.currentScreenShare&&this.currentScreenShare.sipSessionId===this.id,n=this.currentScreenShare&&this.currentScreenShare.desktop;qp.info("call - resume",{id:this.id,isConference:e,hasVideo:t,wasScreensharing:i,wasDesktop:n});const r=this.phone.client.unhold(this.sipCall,e);if(t){const t={audio:!1,video:!0,screen:i,desktop:n};await Ca(this.sipCall,t,e)}const s=e=>{const t=this.currentScreenShare&&this.currentScreenShare.hadVideo;e&&this._onScreenSharing(e,t,n)};return this.emit("resumed"),r.then((()=>{const e=this.getLocalVideoStream();return i&&s(this.getLocalVideoStream()),e}))}turnCameraOn(){Vp(this.callActor,Ep),qp.info("call - turn camera on",{id:this.id}),ga(this.sipCall,!0),this.emit("onCameraResumed")}turnCameraOff(){Vp(this.callActor,Ep),qp.info("call - turn camera off",{id:this.id}),ga(this.sipCall,!1),this.emit("onCameraDisabled")}isMuted(){return this._hasEstablishedState(_p)}isCameraMuted(){return(e=>{const t=e.sessionDescriptionHandler,i=t?.peerConnection;if(i?.getSenders){for(const e of i.getSenders())if(e&&e.track&&"video"===e.track.kind)return!e.track.enabled}else for(const e of i.getLocalStreams())for(const t of e.getVideoTracks())return!t.enabled;return!0})(this.sipCall)}isHeld(){return this._hasEstablishedState($p)}isEstablishing(){return this.sipCall.state===mi.Establishing}isEstablished(){return Ep in this.state}isRinging(){return this.state===bp}isOutgoing(){return this.sipCall instanceof yr}isIncoming(){return!this.isOutgoing()}isConference(){return Xs(this.sipCall)?.sfu}transfer(e){return Vp(this.callActor,Ep),qp.info("call - transfer",{id:this.id,target:e}),this.phone.client.transfer(this.sipCall,e)}atxfer(){return Vp(this.callActor,Ep),qp.info("call - atxfer",{id:this.id}),this.phone.client.atxfer(this.sipCall)}sendDigits(e){Vp(this.callActor,Ep),qp.info("call - send digits",{id:this.id,digits:e}),this.phone.client.sendDTMF(this.sipCall,e)}startNetworkMonitoring(e=1e3){return Vp(this.callActor,Ep),qp.info("call - start network monitoring",{id:this.id}),this.phone.client.startNetworkMonitoring(this.sipCall,e)}stopNetworkMonitoring(){return Vp(this.callActor,Ep),qp.info("call - stop network monitoring",{id:this.id}),this.phone.client.stopNetworkMonitoring(this.sipCall)}async getStats(){return ua(this.sipCall)}async sendReinvite(e={}){Vp(this.callActor,Ep),qp.info("call - send reinvite",{id:this.id,...e});const t=e.constraints?.screen,i=t||e.constraints?.video;if(!e.constraints||i){if(i){if(!await this._upgradeToVideo(e))return}return this.phone.client.reinvite(this.sipCall,e.constraints,e.conference,e.audioOnly,e.iceRestart)}this._downgradeToAudio()}sendMessage(e,t="text/plain"){return Vp(this.callActor,Ep),qp.info("call - send message",{id:this.id,body:e}),this.phone.client.sendMessage(this.sipCall,e,t)}sendChat(e){Vp(this.callActor,Ep),qp.info("call - send chat",{id:this.id,content:e}),this.sendMessage(JSON.stringify({type:"message/TYPE_CHAT",content:e}),"application/json")}sendSignal(e){Vp(this.callActor,Ep),qp.info("call - send signal",{id:this.id,content:e}),this.sendMessage(JSON.stringify({type:Gp,content:e}),"application/json")}async startScreenSharing(e){Vp(this.callActor,Ep),qp.info("call - start screen sharing",{constraints:e,id:this.id});const t=await wa(e);if(!t)throw new Error(`Can't create media stream for screensharing with: ${JSON.stringify(e)}`);const i=t.getVideoTracks()[0],n=Xs(this.sipCall),r=n&&n.getSenders&&n.getSenders().find((e=>e&&e.track&&"video"===e.track.kind)),s=Qs(this.sipCall),a=s?s.getTracks().find((e=>"video"===e.kind)):null,o=!!a;return a&&s&&(a.enabled=!1,a.stop(),s.removeTrack(a)),s&&s.addTrack(i),r&&r.replaceTrack(i),this._onScreenSharing(t,o,e.desktop),t}async stopScreenSharing(e=!0){if(Vp(this.callActor,Ep),!this.currentScreenShare)return;qp.info("call - stop screen sharing",{restoreLocalStream:e});let t=null;try{if(this.currentScreenShare.stream&&this.currentScreenShare.stream.getTracks().filter((e=>e.enabled&&"video"===e.kind)).forEach((e=>e.stop())),e){const e=this.isConference(),i={audio:!1,video:this.currentScreenShare.hadVideo};this._downgradeToAudio(!1),await new Promise((e=>setTimeout(e,500))),t=await this.sendReinvite({constraints:i,conference:e})}}catch(e){console.warn(e)}return this.emit("onScreenShareEnded"),this.currentScreenShare=null,t}onScreenShareReinvite(e,t){const i=Qs(this.sipCall);qp.info("call - updrading directly in screensharing mode",{id:this.id,tracks:i?.getTracks()}),this._onScreenSharing(i,!1,t)}onAccepted(){this._sendAction(Ap),this.emit("remotelyAccepted")}onProgress(){this.emit("progress")}onEarlyMedia(){this.emit("earlyMedia")}onTrack(e){this.emit("track",e)}onError(e){this.emit("error",e)}onCallIncoming(){this._sendAction(xp)}onRejected(){this.endTime=new Date,this.emit("rejected"),this.phone.onCallTerminated(this)}onNetworkStats(e,t){this.emit("webRtcStats",e,t)}getRemoteStream(){return ta(this.sipCall)}getRemoteVideoStream(){return la(this.sipCall)}hasRemoteVideo(){return ca(this.sipCall)}hasLocalVideo(){return na(this.sipCall)}getLocalStream(){return Qs(this.sipCall)}getLocalVideoStream(){return sa(this.sipCall)}hasALocalVideoTrack(){return ra(this.sipCall)}isVideoRemotelyHeld(){return oa(this.sipCall)}onReinvite(e,t,i,n){this.emit("reinvite",e,t,i,n)}updateFrom(e){vi(this,e)}is(e){return e&&this.id&&this.id===e.id}shouldAutoAnswer(){return!!this.sipCall.request.getHeader("alert-info")}get id(){return Ms(this.sipCall)}get state(){return jp(this.callActor)}_hasEstablishedState(e){const t=this.state;return"object"==typeof t&&Ep in t&&t[Ep]===e}_bindEvents(){if(this.sipCall instanceof yr){const e=this.sipCall._onCancel.bind(this.sipCall);this.sipCall._onCancel=t=>{qp.trace("call - on sip session canceled",{callId:t.callId,id:this.id}),e(t);const i=-1!==t.data.indexOf("cause=26")&&-1!==t.data.indexOf("completed elsewhere");this.emit("canceled",i)}}if(this.sipCall?.stateChange?.addListener((e=>{switch(e){case mi.Terminating:qp.info("call - terminating",{id:this.id}),this.emit("terminating");break;case mi.Terminated:return qp.info("call - terminated",{id:this.id}),this.endTime=new Date,this.emit("ended"),this.phone.onCallTerminated(this)}})),!this.sipCall.sessionDescriptionHandler)return;const e=this.sipCall.sessionDescriptionHandler.peerConnection;e?(e.ontrack=e=>{const t=e,[i]=t.streams,n=t&&t.track&&t.track.kind;return qp.info("call - on track stream called on the peer connection",{id:this.id,streamId:i?i.id:null,tracks:i?i.getTracks():null,kind:n}),"audio"===n?this.emit("onAudioStream",i):this.emit("onVideoStream",i,t.track.id,t)},e.onremovestream=e=>{qp.info("call - on remove stream called on the peer connection",{id:e.stream.id,tracks:e.stream.getTracks()}),this.emit("onRemoveStream",e.stream)}):qp.warn("call - no peer connection",{id:this.id})}_downgradeToAudio(e=!0){return Vp(this.callActor,Ep),qp.info("call - downgrade to audio",{id:this.id,withMessage:e}),Ea(this.sipCall),e&&this._sendReinviteMessage(!1),!0}async _upgradeToVideo(e={}){Vp(this.callActor,Ep),qp.info("call - upgrade to video",{id:this.id,...e});const t=e.constraints?.screen,i=e.constraints?.desktop,n=this.sipCall.sessionDescriptionHandlerOptionsReInvite,r=n?.audioOnly,s=await Ca(this.sipCall,e.constraints||{},!!e.conference);return!s||(this._sendReinviteMessage(!0),t&&this._onScreenSharing(s,!1,i),!(!e.conference||!r))}_sendReinviteMessage(e){Vp(this.callActor,Ep),qp.info("call - sending reinvite message",{id:this.id,isUpgrade:e}),setTimeout((()=>{this.sendMessage(JSON.stringify({type:Gp,content:{type:"onTrackUpdated",update:e?"upgrade":"downgrade",sipCallId:this.id,callId:this.apiId,number:this.number}}))}),2500)}_onScreenSharing(e,t,i){const n=e.getVideoTracks()[0],r=this.phone.client.getPeerConnection(this.id),s=r&&r.getSenders&&r.getSenders().find((e=>e&&e.track&&"video"===e.track.kind));qp.info("call - on screensharing",{hadVideo:t,id:this.id,screenTrack:n}),n&&(n.onended=()=>{qp.info("call - on screenshare ended",{hadVideo:t,id:this.id,screenTrack:n}),this.emit("onScreenShareEnding")}),this.currentScreenShare={stream:e,hadVideo:t,sender:s,desktop:i},ma(this.sipCall,e),this.emit("onScreenShareStarted",e)}_sendAction(e){this.callActor.send({type:e})}}const Wp="incoming",zp="disconnected",Yp="terminateSound",Jp="playRingSound",Zp="playInboundCallSound",Xp=B.loggerFor("softphone");class Qp extends Oi.EventEmitter{audioOutputDeviceId;audioRingDeviceId;audioOutputVolume;audioRingVolume;calls;client;session;sipLine;softphoneActor;options;shouldSendReinvite;ringingEnabled=!0;constructor(){super(),this.calls=[],this.softphoneActor=Gh(gp),this.softphoneActor.start()}connect(e={}){this.calls=[],this.options=e,this.audioOutputVolume=1,this.audioRingVolume=1;const t=ig.Auth.getHost(),i=ig.Auth.getSession();if(!t||!i)throw new Error("Please connect to the server using `Wazo.Auth.logIn` or `Wazo.Auth.authenticate` before using Room.connect().");if(this.session=i,this.sipLine=this.getPrimaryWebRtcLine(),!this.sipLine)throw new Error("Sorry, no sip lines found for this user");return this.options.userUuid=i.uuid||"",this.connectWithCredentials(t,this.sipLine,i.displayName(),e)}async hangupAllCalls(){return Promise.all(this.calls.map((e=>e.hangup())))}async disconnect(){return Up(this.softphoneActor,hp),this.client?(await this.hangupAllCalls(),this.client.unregister()):null}getPrimaryWebRtcLine(){return this.session?.primaryWebRtcLine()||null}async connectWithCredentials(e,t,i,n={}){Up(this.softphoneActor,dp),this.softphoneActor.send({type:dp});const[r,s=443]=e.split(":");let a={...n};return a.media=a.media||{audio:!0,video:!1},a.uaConfigOverrides=a.uaConfigOverrides||{},B.enabled&&(a=((e={})=>{const t=e;return t.uaConfigOverrides&&(t.uaConfigOverrides.traceSip=!0),t.log=t.log||{},t.log.builtinEnabled=!1,t.log.logLevel="debug",t.log.connector=yp,t})(a)),this.client=new Zc({host:r,port:"string"==typeof s?parseInt(s,10):s,displayName:i,authorizationUser:t.username,password:t.secret,uri:`${t.username}@${e}`,...a},void 0,a.uaConfigOverrides),this._bindEvents(),this.client.register().catch((e=>{Xp.error("softphone - register error",{message:e.message,stack:e.stack}),this._sendAction(hp)}))}reconnect(){Xp.info("softphone - reconnect",{client:!!this.client}),this.client&&this.client.attemptReconnection()}async call(e){if(Xp.info("softphone - call",e),!e.params.To)return Xp.warn("softphone - calling with empty number, bailing."),Promise.resolve(null);if(this.state===op&&(Xp.info("softphone - calling when registering, waiting for Softphone to be registered ..."),await((e,t,i=5e3)=>Promise.race([new Promise((i=>{e.subscribe((e=>{e.value===t&&i(null)}))})),new Promise(((e,n)=>setTimeout((()=>n(new Error(`Waited for state ${t} timeout.`))),i)))]))(this.softphoneActor,cp)),this.state!==ap)throw new sp(`Invalid state ${ap}`,ap);let t;this.holdAllCalls();try{t=this.client.call(e.params.To,e.withCamera,e.audioOnly,e.conference,e);const i=new Kp(t,this);return this.emit("outgoing",i),i}catch(e){return Xp.warn("softphone - call, error",{message:e.message,stack:e.stack}),Promise.resolve(null)}}removeCall(e){this.calls=this.calls.filter((t=>t.id!==e.id))}onCallTerminated(e){Xp.info("softphone - on call terminated",{id:e.id});const t=this.getCurrentCall(),i=t?.id===e.id,n=e.isRinging(),r=i&&n,s=this.getIncomingCalls(),a=s.length;r&&setTimeout((()=>{this.emit(Yp,e,"call terminated")}),5);const o=i?a:r;if(Xp.info("Softphone - check to re-trigger incoming call",{shouldRetrigger:o,nbIncomingCalls:a}),o&&a>1){const i=s.find((t=>t.id!==e.id));setTimeout((()=>{this.ringingEnabled&&(t?this.emit(Jp,this.audioRingDeviceId,this.audioRingVolume,i):this.emit(Zp,this.audioOutputDeviceId,this.audioOutputVolume,i)),this.emit(Wp,i)}),100)}e.sipCall.isCanceled||setTimeout((()=>{this.emit("playHangupSound",this.audioOutputDeviceId,this.audioOutputVolume,e)}),10),this.client.onCallEnded(e.sipCall),this.removeCall(e)}enableRinging(){Xp.info("softphone - enable ringing"),this.ringingEnabled=!0}disableRinging(){Xp.info("softphone - disable ringing"),this.ringingEnabled=!1}holdAllCalls(e=null){this.calls.filter((t=>!t.isHeld()&&t.id===e?.id)).forEach((e=>e.hold()))}startHeartbeat(){Xp.info("softphone - start heartbeat",{client:!!this.client,hasHeartbeat:this.client.hasHeartbeat()}),this.client&&!this.client.hasHeartbeat()&&this.client.startHeartbeat()}stopHeartbeat(){Xp.info("softphone - stop heartbeat",{client:!!this.client}),this.client&&this.client.stopHeartbeat()}setMediaConstraints(e){this.client.setMediaConstraints(e)}changeAudioOutputDevice(e){return Xp.info("softphone - change audio device",{deviceId:e}),this.audioOutputDeviceId=e,this.client.changeAudioOutputDevice(e)}changeAudioInputDevice(e,t){Xp.info("softphone - changeAudio input device",{deviceId:e});const i=this.getCurrentCall();return this.client.changeAudioInputDevice(e,i?.sipCall,t)}changeVideoInputDevice(e){Xp.info("softphone - change video input device",{deviceId:e});const t=this.getCurrentCall();return this.client.changeVideoInputDevice(e,t?.sipCall)}changeRingDevice(e){Xp.info("softphone - changing ring device",{id:e}),this.audioRingDeviceId=e}hasSfu(){return this.sipLine?.hasVideoConference()||!1}changeAudioVolume(e){Xp.info("softphone - changing audio volume",{volume:e}),this.audioOutputVolume=e,this.client.changeAudioOutputVolume(e)}changeRingVolume(e){Xp.info("softphone - changing ring volume",{volume:e}),this.audioRingVolume=e}getCurrentCall(){return this.getActiveCalls()[0]}getActiveCalls(){return this.calls.filter((e=>e.isEstablished()))}getIncomingCalls(){return this.calls.filter((e=>e.isRinging()))}get state(){return jp(this.softphoneActor)}get user(){return this.client?.userAgent?.contact?.uri?.user}getUserAgent(){return this.client?.config?.userAgentString||"softphone"}isRegistered(){return this.state===cp}_bindEvents(){this.client.on(this.client.INVITE,(e=>{const t=new Kp(e,this);Xp.info("softphone - on invite",{callId:t.id,number:t.number}),t.onCallIncoming(),this.calls.push(t),this.emit(Wp,t),this.getCurrentCall()?this.emit(Zp,this.audioOutputDeviceId,this.audioOutputVolume,t):this.ringingEnabled&&this.emit(Jp,this.audioRingDeviceId,this.audioRingVolume,t)})),this.client.on(this.client.ON_REINVITE,((e,t,i,n,r)=>{Xp.info("softphone - on reinvite",{callId:e.id,inviteId:t.callId,updatedCalleeName:i,updatedNumber:n,hadRemoteVideo:r}),this._onCallEvent(e,"onReinvite",t,i,n,r)})),this.client.on(this.client.ACCEPTED,(async e=>{const t=this._getCall(e);this.emit(Yp,t,"call accepted"),this._onCallEvent(e,"onAccepted"),this.audioOutputDeviceId&&await this.client.changeAudioOutputDevice(this.audioOutputDeviceId)})),this.client.on(this.client.ON_ERROR,((e,t)=>{this._onCallEvent(t,"onError",e)})),this.client.on(this.client.REJECTED,(e=>{this._onCallEvent(e,"onRejected")})),this.client.on(this.client.ON_PROGRESS,(e=>{this._onCallEvent(e,"onProgress")})),this.client.on(this.client.ON_EARLY_MEDIA,(e=>{this._onCallEvent(e,"onEarlyMedia")})),this.client.on(this.client.ON_TRACK,((e,t)=>{this._onCallEvent(e,"onTrack",t)})),this.client.on(this.client.ON_NETWORK_STATS,((e,t,i)=>{this._onCallEvent(e,"onNetworkStats",t,i)})),this.client.on(this.client.ON_SCREEN_SHARING_REINVITE,((e,t,i)=>{this._onCallEvent(e,"onScreenshareReinvite",t,i)})),this.client.on(this.client.UNREGISTERED,(()=>{Xp.info("softphone - unregistered"),this.emit("unregistered"),this._sendAction(up)})),this.client.on(this.client.ON_DISCONNECTED,(()=>{Xp.info("softphone - disconnected"),this.emit(zp),this._sendAction(pp)})),this.client.on(this.client.REGISTERED,(()=>{Xp.info("softphone - registered",{state:jp(this.softphoneActor)}),Bp(this.softphoneActor,lp)?(this.stopHeartbeat(),this._sendAction(lp),this.emit("registered"),this.shouldSendReinvite&&(this.shouldSendReinvite=!1,this.calls.filter((e=>e.isEstablished())).forEach((e=>{e.sendReinvite({conference:e.isConference(),iceRestart:!0})})))):Xp.warn("softphone - registered but not in REGISTERING state",{state:jp(this.softphoneActor)})})),this.client.on(this.client.CONNECTED,(()=>{Xp.info("softphone - connected"),this.stopHeartbeat()})),this.client.on(this.client.DISCONNECTED,(()=>{Xp.info("softphone - disconnected"),this.emit(zp),this.client.hasHeartbeat()||this.startHeartbeat(),this.shouldSendReinvite=this.calls.length>0})),this.client.on("onVideoInputChange",(e=>{this.emit("videoInputChange",e)})),this.client.on(this.client.MESSAGE,(e=>{this._onMessage(e),this.emit("message",e)})),this.client.setOnHeartbeatTimeout((()=>{this.emit("heartbeatTimeout")})),this.client.setOnHeartbeatCallback((()=>{this.emit("heartbeat")}))}_sendAction(e){this.softphoneActor.send({type:e})}_getCall(e){return this.calls.find((t=>t.id===e.id))}_onCallEvent(e,t,...i){Xp.warn("softphone - received call event",{eventName:t,sipId:e.id});const n=this._getCall(e);n?n[t](...i):Xp.warn("softphone - no call found to send the event",{eventName:t,sipId:e.id})}_onMessage(e){if(!e||"MESSAGE"!==e.method)return;let t;try{t=JSON.parse(e.body||"")}catch(e){return}const{type:i,content:n}=t;switch(i){case"message/TYPE_CHAT":this.emit("phone/ON_CHAT",n);break;case"message/TYPE_SIGNAL":this.emit("phone/ON_SIGNAL",n)}}}var eg=new Qp;const tg={Auth:Cn,Phone:rd,Websocket:Ll,Room:Kl,SipRoom:zl,RemoteParticipant:Ul,LocalParticipant:class extends Bl{},Participant:Bl,Stream:Yl,createLocalVideoStream:async e=>eh("video",e),createLocalAudioStream:async e=>eh("audio",e),Configuration:Ql,Directory:Zl,getApiClient:gn,IssueReporter:B,loggerFor:B.loggerFor.bind(B),Features:ah,Checker:gh,Voice:{Softphone:eg,Call:Kp},domain:{BadResponse:b,ServerError:w,Call:fi,CallLog:Yi,CTIPhone:Bi,Recording:zi,ChatMessage:pi,ChatRoom:Ji,Contact:Xt,ForwardOption:Gt,Line:Vt,NotificationOptions:th,Profile:Yt,Session:ti,Voicemail:gi,Relocation:ui,ConferenceRoom:ih,CallSession:yi,IndirectTransfer:Xi,SwitchboardCall:nh,WebRTCPhone:vo,Meeting:ci,SoftphoneClass:Qp},get api(){return gn()},get agentd(){return gn().agentd},get amid(){return gn().amid},get application(){return gn().application},get auth(){return gn().auth},get callLogd(){return gn().callLogd},get calld(){return gn().calld},get chatd(){return gn().chatd},get confd(){return gn().confd},get dird(){return gn().dird},get webhookd(){return gn().webhookd},InvalidSubscription:fn,InvalidAuthorization:mn,CanceledCallError:Jc,SFUNotAvailableError:Xc,NoTenantIdError:vn,NoDomainNameError:yn,NoSamlRouteError:Sn,SamlConfigError:bn};"undefined"!=typeof window&&(window.Wazo=tg),"undefined"!=typeof global&&(global.Wazo=tg);var ig=tg;var ng={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])|7(?:[013-57-9]\\d|2[0-8]))\\d|3(?:(?:[0-3589]\\d|6[1-9]|7[0-35-9])\\d|4(?:[0-578]\\d|90)))\\d\\d|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])|3\\d\\d)|(?:6[0-8]|[78]\\d)\\d{3}|9(?:[02-9]\\d{3}|1(?:(?:[0-58]\\d|6[0135-9])\\d|7(?:0[0-24-9]|[1-9]\\d)|9(?:[0-46-9]\\d|5[0-79])))))\\d{3}",[9]],["4(?:(?:79|94)[01]|83[0-389])\\d{5}|4(?:[0-3]\\d|4[047-9]|5[0-25-9]|6[0-36-9]|7[02-8]|8[0-24-9]|9[0-37-9])\\d{6}",[9]],["180(?:0\\d{3}|2)\\d{3}",[7,10]],["190[0-26]\\d{6}",[10]],0,0,0,["163\\d{2,6}",[5,6,7,8,9]],["14(?:5(?:1[0458]|[23][458])|71\\d)\\d{4}",[9]],["13(?:00\\d{6}(?:\\d{2})?|45[0-4]\\d{3})|13\\d{4}",[6,8,10,12]]],"0011"],AW:["297","00","(?:[25-79]\\d\\d|800)\\d{4}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[25-9]"]]]],AX:["358","00|99(?:[01469]|5(?:[14]1|3[23]|5[59]|77|88|9[09]))","2\\d{4,9}|35\\d{4,5}|(?:60\\d\\d|800)\\d{4,6}|7\\d{5,11}|(?:[14]\\d|3[0-46-9]|50)\\d{4,8}",[5,6,7,8,9,10,11,12],0,"0",0,0,0,0,"18",0,"00"],AZ:["994","00","365\\d{6}|(?:[124579]\\d|60|88)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["90"],"0$1"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["1[28]|2|365|46","1[28]|2|365[45]|46","1[28]|2|365(?:4|5[02])|46"],"(0$1)"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[13-9]"],"0$1"]],"0"],BA:["387","00","6\\d{8}|(?:[35689]\\d|49|70)\\d{6}",[8,9],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["6[1-3]|[7-9]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2-$3",["[3-5]|6[56]"],"0$1"],["(\\d{2})(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3 $4",["6"],"0$1"]],"0"],BB:["1","011","(?:246|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([2-9]\\d{6})$|1","246$1",0,"246"],BD:["880","00","[1-469]\\d{9}|8[0-79]\\d{7,8}|[2-79]\\d{8}|[2-9]\\d{7}|[3-9]\\d{6}|[57-9]\\d{5}",[6,7,8,9,10],[["(\\d{2})(\\d{4,6})","$1-$2",["31[5-8]|[459]1"],"0$1"],["(\\d{3})(\\d{3,7})","$1-$2",["3(?:[67]|8[013-9])|4(?:6[168]|7|[89][18])|5(?:6[128]|9)|6(?:[15]|28|4[14])|7[2-589]|8(?:0[014-9]|[12])|9[358]|(?:3[2-5]|4[235]|5[2-578]|6[0389]|76|8[3-7]|9[24])1|(?:44|66)[01346-9]"],"0$1"],["(\\d{4})(\\d{3,6})","$1-$2",["[13-9]|22"],"0$1"],["(\\d)(\\d{7,8})","$1-$2",["2"],"0$1"]],"0"],BE:["32","00","4\\d{8}|[1-9]\\d{7}",[8,9],[["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["(?:80|9)0"],"0$1"],["(\\d)(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[239]|4[23]"],"0$1"],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[15-8]"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["4"],"0$1"]],"0"],BF:["226","00","[025-7]\\d{7}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[025-7]"]]]],BG:["359","00","00800\\d{7}|[2-7]\\d{6,7}|[89]\\d{6,8}|2\\d{5}",[6,7,8,9,12],[["(\\d)(\\d)(\\d{2})(\\d{2})","$1 $2 $3 $4",["2"],"0$1"],["(\\d{3})(\\d{4})","$1 $2",["43[1-6]|70[1-9]"],"0$1"],["(\\d)(\\d{3})(\\d{3,4})","$1 $2 $3",["2"],"0$1"],["(\\d{2})(\\d{3})(\\d{2,3})","$1 $2 $3",["[356]|4[124-7]|7[1-9]|8[1-6]|9[1-7]"],"0$1"],["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["(?:70|8)0"],"0$1"],["(\\d{3})(\\d{3})(\\d{2})","$1 $2 $3",["43[1-7]|7"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[48]|9[08]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["9"],"0$1"]],"0"],BH:["973","00","[136-9]\\d{7}",[8],[["(\\d{4})(\\d{4})","$1 $2",["[13679]|8[02-4679]"]]]],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]|3[3-7]|5[12]|87)\\d{4}"],["69(?:0\\d\\d|1(?:2[2-9]|3[0-5])|4(?:0[89]|1[2-6]|9\\d)|6(?:1[016-9]|5[0-4]|[67]\\d))\\d{4}"],["80[0-5]\\d{6}"],0,0,0,0,0,["9(?:(?:39[5-7]|76[018])\\d|475[0-5])\\d{4}"]]],BM:["1","011","(?:441|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([2-9]\\d{6})$|1","441$1",0,"441"],BN:["673","00","[2-578]\\d{6}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[2-578]"]]]],BO:["591","00(?:1\\d)?","(?:[2-467]\\d\\d|8001)\\d{5}",[8,9],[["(\\d)(\\d{7})","$1 $2",["[23]|4[46]"]],["(\\d{8})","$1",["[67]"]],["(\\d{3})(\\d{2})(\\d{4})","$1 $2 $3",["8"]]],"0",0,"0(1\\d)?"],BQ:["599","00","(?:[34]1|7\\d)\\d{5}",[7],0,0,0,0,0,0,"[347]"],BR:["55","00(?:1[245]|2[1-35]|31|4[13]|[56]5|99)","(?:[1-46-9]\\d\\d|5(?:[0-46-9]\\d|5[0-46-9]))\\d{8}|[1-9]\\d{9}|[3589]\\d{8}|[34]\\d{7}",[8,9,10,11],[["(\\d{4})(\\d{4})","$1-$2",["300|4(?:0[02]|37)","4(?:02|37)0|[34]00"]],["(\\d{3})(\\d{2,3})(\\d{4})","$1 $2 $3",["(?:[358]|90)0"],"0$1"],["(\\d{2})(\\d{4})(\\d{4})","$1 $2-$3",["(?:[14689][1-9]|2[12478]|3[1-578]|5[13-5]|7[13-579])[2-57]"],"($1)"],["(\\d{2})(\\d{5})(\\d{4})","$1 $2-$3",["[16][1-9]|[2-57-9]"],"($1)"]],"0",0,"(?:0|90)(?:(1[245]|2[1-35]|31|4[13]|[56]5|99)(\\d{10,11}))?","$2"],BS:["1","011","(?:242|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([3-8]\\d{6})$|1","242$1",0,"242"],BT:["975","00","[17]\\d{7}|[2-8]\\d{6}",[7,8],[["(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["[2-68]|7[246]"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["1[67]|7"]]]],BW:["267","00","(?:0800|(?:[37]|800)\\d)\\d{6}|(?:[2-6]\\d|90)\\d{5}",[7,8,10],[["(\\d{2})(\\d{5})","$1 $2",["90"]],["(\\d{3})(\\d{4})","$1 $2",["[24-6]|3[15-9]"]],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[37]"]],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["0"]],["(\\d{3})(\\d{4})(\\d{3})","$1 $2 $3",["8"]]]],BY:["375","810","(?:[12]\\d|33|44|902)\\d{7}|8(?:0[0-79]\\d{5,7}|[1-7]\\d{9})|8(?:1[0-489]|[5-79]\\d)\\d{7}|8[1-79]\\d{6,7}|8[0-79]\\d{5}|8\\d{5}",[6,7,8,9,10,11],[["(\\d{3})(\\d{3})","$1 $2",["800"],"8 $1"],["(\\d{3})(\\d{2})(\\d{2,4})","$1 $2 $3",["800"],"8 $1"],["(\\d{4})(\\d{2})(\\d{3})","$1 $2-$3",["1(?:5[169]|6[3-5]|7[179])|2(?:1[35]|2[34]|3[3-5])","1(?:5[169]|6(?:3[1-3]|4|5[125])|7(?:1[3-9]|7[0-24-6]|9[2-7]))|2(?:1[35]|2[34]|3[3-5])"],"8 0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2-$3-$4",["1(?:[56]|7[467])|2[1-3]"],"8 0$1"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2-$3-$4",["[1-4]"],"8 0$1"],["(\\d{3})(\\d{3,4})(\\d{4})","$1 $2 $3",["[89]"],"8 $1"]],"8",0,"0|80?",0,0,0,0,"8~10"],BZ:["501","00","(?:0800\\d|[2-8])\\d{6}",[7,11],[["(\\d{3})(\\d{4})","$1-$2",["[2-8]"]],["(\\d)(\\d{3})(\\d{4})(\\d{3})","$1-$2-$3-$4",["0"]]]],CA:["1","011","(?:[2-8]\\d|90)\\d{8}|3\\d{6}",[7,10],0,"1",0,0,0,0,0,[["(?:2(?:04|[23]6|[48]9|50|63)|3(?:06|43|54|6[578]|82)|4(?:03|1[68]|[26]8|3[178]|50|74)|5(?:06|1[49]|48|79|8[147])|6(?:04|[18]3|39|47|72)|7(?:0[59]|42|53|78|8[02])|8(?:[06]7|19|25|7[39])|90[25])[2-9]\\d{6}",[10]],["",[10]],["8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",[10]],["900[2-9]\\d{6}",[10]],["52(?:3(?:[2-46-9][02-9]\\d|5(?:[02-46-9]\\d|5[0-46-9]))|4(?:[2-478][02-9]\\d|5(?:[034]\\d|2[024-9]|5[0-46-9])|6(?:0[1-9]|[2-9]\\d)|9(?:[05-9]\\d|2[0-5]|49)))\\d{4}|52[34][2-9]1[02-9]\\d{4}|(?:5(?:00|2[125-9]|33|44|66|77|88)|622)[2-9]\\d{6}",[10]],0,["310\\d{4}",[7]],0,["600[2-9]\\d{6}",[10]]]],CC:["61","001[14-689]|14(?:1[14]|34|4[17]|[56]6|7[47]|88)0011","1(?:[0-79]\\d{8}(?:\\d{2})?|8[0-24-9]\\d{7})|[148]\\d{8}|1\\d{5,7}",[6,7,8,9,10,12],0,"0",0,"([59]\\d{7})$|0","8$1",0,0,[["8(?:51(?:0(?:02|31|60|89)|1(?:18|76)|223)|91(?:0(?:1[0-2]|29)|1(?:[28]2|50|79)|2(?:10|64)|3(?:[06]8|22)|4[29]8|62\\d|70[23]|959))\\d{3}",[9]],["4(?:(?:79|94)[01]|83[0-389])\\d{5}|4(?:[0-3]\\d|4[047-9]|5[0-25-9]|6[0-36-9]|7[02-8]|8[0-24-9]|9[0-37-9])\\d{6}",[9]],["180(?:0\\d{3}|2)\\d{3}",[7,10]],["190[0-26]\\d{6}",[10]],0,0,0,0,["14(?:5(?:1[0458]|[23][458])|71\\d)\\d{4}",[9]],["13(?:00\\d{6}(?:\\d{2})?|45[0-4]\\d{3})|13\\d{4}",[6,8,10,12]]],"0011"],CD:["243","00","[189]\\d{8}|[1-68]\\d{6}",[7,9],[["(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3",["88"],"0$1"],["(\\d{2})(\\d{5})","$1 $2",["[1-6]"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["1"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[89]"],"0$1"]],"0"],CF:["236","00","(?:[27]\\d{3}|8776)\\d{4}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[278]"]]]],CG:["242","00","222\\d{6}|(?:0\\d|80)\\d{7}",[9],[["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["8"]],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[02]"]]]],CH:["41","00","8\\d{11}|[2-9]\\d{8}",[9],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["8[047]|90"],"0$1"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[2-79]|81"],"0$1"],["(\\d{3})(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4 $5",["8"],"0$1"]],"0"],CI:["225","00","[02]\\d{9}",[10],[["(\\d{2})(\\d{2})(\\d)(\\d{5})","$1 $2 $3 $4",["2"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{4})","$1 $2 $3 $4",["0"]]]],CK:["682","00","[2-578]\\d{4}",[5],[["(\\d{2})(\\d{3})","$1 $2",["[2-578]"]]]],CL:["56","(?:0|1(?:1[0-69]|2[02-5]|5[13-58]|69|7[0167]|8[018]))0","12300\\d{6}|6\\d{9,10}|[2-9]\\d{8}",[9,10,11],[["(\\d{5})(\\d{4})","$1 $2",["219","2196"],"($1)"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["44"]],["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["2[1-36]"],"($1)"],["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["9[2-9]"]],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["3[2-5]|[47]|5[1-3578]|6[13-57]|8(?:0[1-9]|[1-9])"],"($1)"],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["60|8"]],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["1"]],["(\\d{3})(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3 $4",["60"]]]],CM:["237","00","[26]\\d{8}|88\\d{6,7}",[8,9],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["88"]],["(\\d)(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4 $5",["[26]|88"]]]],CN:["86","00|1(?:[12]\\d|79)\\d\\d00","1[127]\\d{8,9}|2\\d{9}(?:\\d{2})?|[12]\\d{6,7}|86\\d{6}|(?:1[03-689]\\d|6)\\d{7,9}|(?:[3-579]\\d|8[0-57-9])\\d{6,9}",[7,8,9,10,11,12],[["(\\d{2})(\\d{5,6})","$1 $2",["(?:10|2[0-57-9])[19]","(?:10|2[0-57-9])(?:10|9[56])","10(?:10|9[56])|2[0-57-9](?:100|9[56])"],"0$1"],["(\\d{3})(\\d{5,6})","$1 $2",["3(?:[157]|35|49|9[1-68])|4(?:[17]|2[179]|6[47-9]|8[23])|5(?:[1357]|2[37]|4[36]|6[1-46]|80)|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|[379]|4[13]|5[1-5])|(?:4[35]|59|85)[1-9]","(?:3(?:[157]\\d|35|49|9[1-68])|4(?:[17]\\d|2[179]|[35][1-9]|6[47-9]|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]\\d|5[1-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|[379]\\d|4[13]|5[1-5]))[19]","85[23](?:10|95)|(?:3(?:[157]\\d|35|49|9[1-68])|4(?:[17]\\d|2[179]|[35][1-9]|6[47-9]|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]\\d|5[14-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|[379]\\d|4[13]|5[1-5]))(?:10|9[56])","85[23](?:100|95)|(?:3(?:[157]\\d|35|49|9[1-68])|4(?:[17]\\d|2[179]|[35][1-9]|6[47-9]|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]\\d|5[14-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|[379]\\d|4[13]|5[1-5]))(?:100|9[56])"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["(?:4|80)0"]],["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["10|2(?:[02-57-9]|1[1-9])","10|2(?:[02-57-9]|1[1-9])","10[0-79]|2(?:[02-57-9]|1[1-79])|(?:10|21)8(?:0[1-9]|[1-9])"],"0$1",1],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["3(?:[3-59]|7[02-68])|4(?:[26-8]|3[3-9]|5[2-9])|5(?:3[03-9]|[468]|7[028]|9[2-46-9])|6|7(?:[0-247]|3[04-9]|5[0-4689]|6[2368])|8(?:[1-358]|9[1-7])|9(?:[013479]|5[1-5])|(?:[34]1|55|79|87)[02-9]"],"0$1",1],["(\\d{3})(\\d{7,8})","$1 $2",["9"]],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["80"],"0$1",1],["(\\d{3})(\\d{4})(\\d{4})","$1 $2 $3",["[3-578]"],"0$1",1],["(\\d{3})(\\d{4})(\\d{4})","$1 $2 $3",["1[3-9]"]],["(\\d{2})(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3 $4",["[12]"],"0$1",1]],"0",0,"(1(?:[12]\\d|79)\\d\\d)|0",0,0,0,0,"00"],CO:["57","00(?:4(?:[14]4|56)|[579])","(?:60\\d\\d|9101)\\d{6}|(?:1\\d|3)\\d{9}",[10,11],[["(\\d{3})(\\d{7})","$1 $2",["6"],"($1)"],["(\\d{3})(\\d{7})","$1 $2",["3[0-357]|91"]],["(\\d)(\\d{3})(\\d{7})","$1-$2-$3",["1"],"0$1",0,"$1 $2 $3"]],"0",0,"0([3579]|4(?:[14]4|56))?"],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","(?:[2-7]|8\\d\\d)\\d{7}|[2-47]\\d{6}|[34]\\d{5}",[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",["[56]"],"0$1"],["(\\d{3})(\\d{7})","$1 $2",["8"],"0$1"]],"0"],CV:["238","0","(?:[2-59]\\d\\d|800)\\d{4}",[7],[["(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3",["[2-589]"]]]],CW:["599","00","(?:[34]1|60|(?:7|9\\d)\\d)\\d{5}",[7,8],[["(\\d{3})(\\d{4})","$1 $2",["[3467]"]],["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["9[4-8]"]]],0,0,0,0,0,"[69]"],CX:["61","001[14-689]|14(?:1[14]|34|4[17]|[56]6|7[47]|88)0011","1(?:[0-79]\\d{8}(?:\\d{2})?|8[0-24-9]\\d{7})|[148]\\d{8}|1\\d{5,7}",[6,7,8,9,10,12],0,"0",0,"([59]\\d{7})$|0","8$1",0,0,[["8(?:51(?:0(?:01|30|59|88)|1(?:17|46|75)|2(?:22|35))|91(?:00[6-9]|1(?:[28]1|49|78)|2(?:09|63)|3(?:12|26|75)|4(?:56|97)|64\\d|7(?:0[01]|1[0-2])|958))\\d{3}",[9]],["4(?:(?:79|94)[01]|83[0-389])\\d{5}|4(?:[0-3]\\d|4[047-9]|5[0-25-9]|6[0-36-9]|7[02-8]|8[0-24-9]|9[0-37-9])\\d{6}",[9]],["180(?:0\\d{3}|2)\\d{3}",[7,10]],["190[0-26]\\d{6}",[10]],0,0,0,0,["14(?:5(?:1[0458]|[23][458])|71\\d)\\d{4}",[9]],["13(?:00\\d{6}(?:\\d{2})?|45[0-4]\\d{3})|13\\d{4}",[6,8,10,12]]],"0011"],CY:["357","00","(?:[279]\\d|[58]0)\\d{6}",[8],[["(\\d{2})(\\d{6})","$1 $2",["[257-9]"]]]],CZ:["420","00","(?:[2-578]\\d|60)\\d{7}|9\\d{8,11}",[9],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[2-8]|9[015-7]"]],["(\\d{2})(\\d{3})(\\d{3})(\\d{2})","$1 $2 $3 $4",["96"]],["(\\d{2})(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["9"]],["(\\d{3})(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["9"]]]],DE:["49","00","[2579]\\d{5,14}|49(?:[34]0|69|8\\d)\\d\\d?|49(?:37|49|60|7[089]|9\\d)\\d{1,3}|49(?:2[024-9]|3[2-689]|7[1-7])\\d{1,8}|(?:1|[368]\\d|4[0-8])\\d{3,13}|49(?:[015]\\d|2[13]|31|[46][1-8])\\d{1,9}",[4,5,6,7,8,9,10,11,12,13,14,15],[["(\\d{2})(\\d{3,13})","$1 $2",["3[02]|40|[68]9"],"0$1"],["(\\d{3})(\\d{3,12})","$1 $2",["2(?:0[1-389]|1[124]|2[18]|3[14])|3(?:[35-9][15]|4[015])|906|(?:2[4-9]|4[2-9]|[579][1-9]|[68][1-8])1","2(?:0[1-389]|12[0-8])|3(?:[35-9][15]|4[015])|906|2(?:[13][14]|2[18])|(?:2[4-9]|4[2-9]|[579][1-9]|[68][1-8])1"],"0$1"],["(\\d{4})(\\d{2,11})","$1 $2",["[24-6]|3(?:[3569][02-46-9]|4[2-4679]|7[2-467]|8[2-46-8])|70[2-8]|8(?:0[2-9]|[1-8])|90[7-9]|[79][1-9]","[24-6]|3(?:3(?:0[1-467]|2[127-9]|3[124578]|7[1257-9]|8[1256]|9[145])|4(?:2[135]|4[13578]|9[1346])|5(?:0[14]|2[1-3589]|6[1-4]|7[13468]|8[13568])|6(?:2[1-489]|3[124-6]|6[13]|7[12579]|8[1-356]|9[135])|7(?:2[1-7]|4[145]|6[1-5]|7[1-4])|8(?:21|3[1468]|6|7[1467]|8[136])|9(?:0[12479]|2[1358]|4[134679]|6[1-9]|7[136]|8[147]|9[1468]))|70[2-8]|8(?:0[2-9]|[1-8])|90[7-9]|[79][1-9]|3[68]4[1347]|3(?:47|60)[1356]|3(?:3[46]|46|5[49])[1246]|3[4579]3[1357]"],"0$1"],["(\\d{3})(\\d{4})","$1 $2",["138"],"0$1"],["(\\d{5})(\\d{2,10})","$1 $2",["3"],"0$1"],["(\\d{3})(\\d{5,11})","$1 $2",["181"],"0$1"],["(\\d{3})(\\d)(\\d{4,10})","$1 $2 $3",["1(?:3|80)|9"],"0$1"],["(\\d{3})(\\d{7,8})","$1 $2",["1[67]"],"0$1"],["(\\d{3})(\\d{7,12})","$1 $2",["8"],"0$1"],["(\\d{5})(\\d{6})","$1 $2",["185","1850","18500"],"0$1"],["(\\d{3})(\\d{4})(\\d{4})","$1 $2 $3",["7"],"0$1"],["(\\d{4})(\\d{7})","$1 $2",["18[68]"],"0$1"],["(\\d{4})(\\d{7})","$1 $2",["15[1279]"],"0$1"],["(\\d{5})(\\d{6})","$1 $2",["15[03568]","15(?:[0568]|31)"],"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",["[89]"],"0$1"],["(\\d{2})(\\d{8})","$1 $2",["1"],"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{5})","$1",["20[2-59]"],"0$1"],["(\\d{3})(\\d{3,7})","$1 $2",["(?:[1-3]0|[68])0|70[07-9]"],"0$1"],["(\\d{2})(\\d{4,8})","$1 $2",["[14]|2[09]|50|7[135]"],"0$1"],["(\\d{2})(\\d{6,10})","$1 $2",["7"],"0$1"],["(\\d)(\\d{4,9})","$1 $2",["(?:1[3-79]|[2568])[1-8]|3(?:0[1-9]|[1-9])|9"],"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|70)\\d|69[7-9])|(?:(?:5[0-26-9]|[78][0-49])\\d|6(?:[0-4]\\d|50))\\d)|(?:2(?:(?:0[024-9]|2[3-9]|3[3-79]|4[1-689]|[58][02-9]|6[0-47-9]|7[013-9]|9\\d)\\d|1(?:[0-7]\\d|8[0-2]))|(?:3(?:0\\d|1[0-8]|[25][02-9]|3[02-579]|[468][0-46-9]|7[1-35-79]|9[2-578])|4(?:0[03-9]|[137]\\d|[28][02-57-9]|4[02-69]|5[0-8]|[69][0-79])|5(?:0[1-35-9]|[16]\\d|2[024-9]|3[015689]|4[02-9]|5[03-9]|7[0-35-9]|8[0-468]|9[0-57-9])|6(?:0[034689]|1\\d|2[0-35689]|[38][013-9]|4[1-467]|5[0-69]|6[13-9]|7[0-8]|9[0-24578])|7(?:0[0246-9]|2\\d|3[0236-8]|4[03-9]|5[0-46-9]|6[013-9]|7[0-35-9]|8[024-9]|9[02-9])|8(?:0[35-9]|2[1-57-9]|3[02-578]|4[0-578]|5[124-9]|6[2-69]|7\\d|8[02-9]|9[02569])|9(?:0[02-589]|[18]\\d|2[02-689]|3[1-57-9]|4[2-9]|5[0-579]|6[2-47-9]|7[0-24578]|9[2-57]))\\d)\\d)|2(?:0[013478]|3[0189]|4[017]|8[0-46-9]|9[0-2])\\d{3})\\d{4}|1(?:2(?:0(?:46[1-4]|87[2-9])|545[1-79]|76(?:2\\d|3[1-8]|6[1-6])|9(?:7(?:2[0-4]|3[2-5])|8(?:2[2-8]|7[0-47-9]|8[3-5])))|3(?:6(?:38[2-5]|47[23])|8(?:47[04-9]|64[0157-9]))|4(?:044[1-7]|20(?:2[23]|8\\d)|6(?:0(?:30|5[2-57]|6[1-8]|7[2-8])|140)|8(?:052|87[1-3]))|5(?:2(?:4(?:3[2-79]|6\\d)|76\\d)|6(?:26[06-9]|686))|6(?:06(?:4\\d|7[4-79])|295[5-7]|35[34]\\d|47(?:24|61)|59(?:5[08]|6[67]|74)|9(?:55[0-4]|77[23]))|7(?:26(?:6[13-9]|7[0-7])|(?:442|688)\\d|50(?:2[0-3]|[3-68]2|76))|8(?:27[56]\\d|37(?:5[2-5]|8[239])|843[2-58])|9(?:0(?:0(?:6[1-8]|85)|52\\d)|3583|4(?:66[1-8]|9(?:2[01]|81))|63(?:23|3[1-4])|9561))\\d{3}",[9,10]],["7(?:457[0-57-9]|700[01]|911[028])\\d{5}|7(?:[1-3]\\d\\d|4(?:[0-46-9]\\d|5[0-689])|5(?:0[0-8]|[13-9]\\d|2[0-35-9])|7(?:0[1-9]|[1-7]\\d|8[02-9]|9[0-689])|8(?:[014-9]\\d|[23][0-8])|9(?:[024-9]\\d|1[02-9]|3[0-689]))\\d{6}",[10]],["80[08]\\d{7}|800\\d{6}|8001111"],["(?:8(?:4[2-5]|7[0-3])|9(?:[01]\\d|8[2-49]))\\d{7}|845464\\d",[7,10]],["70\\d{8}",[10]],0,["(?:3[0347]|55)\\d{8}",[10]],["76(?:464|652)\\d{5}|76(?:0[0-28]|2[356]|34|4[01347]|5[49]|6[0-369]|77|8[14]|9[139])\\d{6}",[10]],["56\\d{8}",[10]]],0," x"],GD:["1","011","(?:473|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([2-9]\\d{6})$|1","473$1",0,"473"],GE:["995","00","(?:[3-57]\\d\\d|800)\\d{6}",[9],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["70"],"0$1"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["32"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[57]"]],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[348]"],"0$1"]],"0"],GF:["594","00","[56]94\\d{6}|(?:80|9\\d)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[56]|9[47]"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[89]"],"0$1"]],"0"],GG:["44","00","(?:1481|[357-9]\\d{3})\\d{6}|8\\d{6}(?:\\d{2})?",[7,9,10],0,"0",0,"([25-9]\\d{5})$|0","1481$1",0,0,[["1481[25-9]\\d{5}",[10]],["7(?:(?:781|839)\\d|911[17])\\d{5}",[10]],["80[08]\\d{7}|800\\d{6}|8001111"],["(?:8(?:4[2-5]|7[0-3])|9(?:[01]\\d|8[0-3]))\\d{7}|845464\\d",[7,10]],["70\\d{8}",[10]],0,["(?:3[0347]|55)\\d{8}",[10]],["76(?:464|652)\\d{5}|76(?:0[0-28]|2[356]|34|4[01347]|5[49]|6[0-369]|77|8[14]|9[139])\\d{6}",[10]],["56\\d{8}",[10]]]],GH:["233","00","(?:[235]\\d{3}|800)\\d{5}",[8,9],[["(\\d{3})(\\d{5})","$1 $2",["8"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[235]"],"0$1"]],"0"],GI:["350","00","(?:[25]\\d|60)\\d{6}",[8],[["(\\d{3})(\\d{5})","$1 $2",["2"]]]],GL:["299","00","(?:19|[2-689]\\d|70)\\d{4}",[6],[["(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3",["19|[2-9]"]]]],GM:["220","00","[2-9]\\d{6}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[2-9]"]]]],GN:["224","00","722\\d{6}|(?:3|6\\d)\\d{7}",[8,9],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["3"]],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[67]"]]]],GP:["590","00","590\\d{6}|(?:69|80|9\\d)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[569]"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"],"0$1"]],"0",0,0,0,0,0,[["590(?:0[1-68]|[14][0-24-9]|2[0-68]|3[1-9]|5[3-579]|[68][0-689]|7[08]|9\\d)\\d{4}"],["69(?:0\\d\\d|1(?:2[2-9]|3[0-5])|4(?:0[89]|1[2-6]|9\\d)|6(?:1[016-9]|5[0-4]|[67]\\d))\\d{4}"],["80[0-5]\\d{6}"],0,0,0,0,0,["9(?:(?:39[5-7]|76[018])\\d|475[0-5])\\d{4}"]]],GQ:["240","00","222\\d{6}|(?:3\\d|55|[89]0)\\d{7}",[9],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[235]"]],["(\\d{3})(\\d{6})","$1 $2",["[89]"]]]],GR:["30","00","5005000\\d{3}|8\\d{9,11}|(?:[269]\\d|70)\\d{8}",[10,11,12],[["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["21|7"]],["(\\d{4})(\\d{6})","$1 $2",["2(?:2|3[2-57-9]|4[2-469]|5[2-59]|6[2-9]|7[2-69]|8[2-49])|5"]],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["[2689]"]],["(\\d{3})(\\d{3,4})(\\d{5})","$1 $2 $3",["8"]]]],GT:["502","00","80\\d{6}|(?:1\\d{3}|[2-7])\\d{7}",[8,11],[["(\\d{4})(\\d{4})","$1 $2",["[2-8]"]],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["1"]]]],GU:["1","011","(?:[58]\\d\\d|671|900)\\d{7}",[10],0,"1",0,"([2-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","(?:[2-8]\\d{3}|9008)\\d{3}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[2-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",["6|7[245]"],"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-57]"],"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})|(?:43|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]|43"]],["(\\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[2-9]\\d{7,8}|(?:31|43)\\d{8}",[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\\d))\\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)|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])|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])|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[0459]|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[26-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]|9[29])|5(?:2|3(?:[045]|9[0-8])|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[0-2469])|3(?:[29]|60)|49|51|6(?:[0-24]|36|5[0-3589]|7[23]|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]))|(?: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]|9(?:[0-58]|6[4-9]|7[0-35689]))|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]|60|7(?:[017-9]|6[6-8]))|49|51|6(?:[0-24]|36[2-57-9]|5(?:[0-389]|5[23])|6(?:[01]|9[178])|7(?:2[2-468]|3[78])|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]"],"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",0,"(000[259]\\d{6})$|(?:(?:003768)0?)|0","$1"],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-9]\\d{8}",[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","(?:[245]\\d|33|77|88)\\d{7}|(?:2\\d|[4-6])\\d{6}",[7,8,9],[["(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["4[67]|[56]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["2"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[2-578]"],"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]"],"(0-$1)",1],["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["[7-9]"],"0 $1",1],["(\\d{2})(\\d{6})","$1 $2",["37|4(?:[15]|6[1-8])"],"(0-$1)",1],["(\\d{3})(\\d{5})","$1 $2",["[3-6]"],"(0-$1)",1]],"0",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{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["5[45]"],"0$1"],["(\\d{4})(\\d{5})","$1-$2",["5(?:2[2-46-9]|3[3-9]|9)|8(?:0[89]|92)"],"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,[["5(?:2(?:[0-25-79]\\d|3[1-578]|4[02-46-8]|8[0235-7])|3(?:[0-47]\\d|5[02-9]|6[02-8]|8[014-9]|9[3-9])|(?:4[067]|5[03])\\d)\\d{5}"],["(?:6(?:[0-79]\\d|8[0-247-9])|7(?:[0167]\\d|2[0-4]|5[01]|8[0-3]))\\d{6}"],["80[0-7]\\d{6}"],["89\\d{7}"],0,0,0,0,["(?:592(?:4[0-2]|93)|80[89]\\d\\d)\\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]|3[03-7]|5[0-268]|87)\\d{4}"],["69(?:0\\d\\d|1(?:2[2-9]|3[0-5])|4(?:0[89]|1[2-6]|9\\d)|6(?:1[016-9]|5[0-4]|[67]\\d))\\d{4}"],["80[0-5]\\d{6}"],0,0,0,0,0,["9(?:(?:39[5-7]|76[018])\\d|475[0-5])\\d{4}"]]],MG:["261","00","[23]\\d{8}",[9],[["(\\d{2})(\\d{2})(\\d{3})(\\d{2})","$1 $2 $3 $4",["[23]"],"0$1"]],"0",0,"([24-9]\\d{6})$|0","20$1"],MH:["692","011","329\\d{4}|(?:[256]\\d|45)\\d{5}",[7],[["(\\d{3})(\\d{4})","$1-$2",["[2-6]"]]],"1"],MK:["389","00","[2-578]\\d{7}",[8],[["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["2|34[47]|4(?:[37]7|5[47]|64)"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[347]"],"0$1"],["(\\d{3})(\\d)(\\d{2})(\\d{2})","$1 $2 $3 $4",["[58]"],"0$1"]],"0"],ML:["223","00","[24-9]\\d{7}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[24-9]"]]]],MM:["95","00","1\\d{5,7}|95\\d{6}|(?:[4-7]|9[0-46-9])\\d{6,8}|(?:2|8\\d)\\d{5,8}",[6,7,8,9,10],[["(\\d)(\\d{2})(\\d{3})","$1 $2 $3",["16|2"],"0$1"],["(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3",["[45]|6(?:0[23]|[1-689]|7[235-7])|7(?:[0-4]|5[2-7])|8[1-6]"],"0$1"],["(\\d)(\\d{3})(\\d{3,4})","$1 $2 $3",["[12]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[4-7]|8[1-35]"],"0$1"],["(\\d)(\\d{3})(\\d{4,6})","$1 $2 $3",["9(?:2[0-4]|[35-9]|4[137-9])"],"0$1"],["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["2"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["8"],"0$1"],["(\\d)(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["92"],"0$1"],["(\\d)(\\d{5})(\\d{4})","$1 $2 $3",["9"],"0$1"]],"0"],MN:["976","001","[12]\\d{7,9}|[5-9]\\d{7}",[8,9,10],[["(\\d{2})(\\d{2})(\\d{4})","$1 $2 $3",["[12]1"],"0$1"],["(\\d{4})(\\d{4})","$1 $2",["[5-9]"]],["(\\d{3})(\\d{5,6})","$1 $2",["[12]2[1-3]"],"0$1"],["(\\d{4})(\\d{5,6})","$1 $2",["[12](?:27|3[2-8]|4[2-68]|5[1-4689])","[12](?:27|3[2-8]|4[2-68]|5[1-4689])[0-3]"],"0$1"],["(\\d{5})(\\d{4,5})","$1 $2",["[12]"],"0$1"]],"0"],MO:["853","00","0800\\d{3}|(?:28|[68]\\d)\\d{6}",[7,8],[["(\\d{4})(\\d{3})","$1 $2",["0"]],["(\\d{4})(\\d{4})","$1 $2",["[268]"]]]],MP:["1","011","[58]\\d{9}|(?:67|90)0\\d{7}",[10],0,"1",0,"([2-9]\\d{6})$|1","670$1",0,"670"],MQ:["596","00","596\\d{6}|(?:69|80|9\\d)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[569]"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"],"0$1"]],"0"],MR:["222","00","(?:[2-4]\\d\\d|800)\\d{5}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[2-48]"]]]],MS:["1","011","(?:[58]\\d\\d|664|900)\\d{7}",[10],0,"1",0,"([34]\\d{6})$|1","664$1",0,"664"],MT:["356","00","3550\\d{4}|(?:[2579]\\d\\d|800)\\d{5}",[8],[["(\\d{4})(\\d{4})","$1 $2",["[2357-9]"]]]],MU:["230","0(?:0|[24-7]0|3[03])","(?:[57]|8\\d\\d)\\d{7}|[2-468]\\d{6}",[7,8,10],[["(\\d{3})(\\d{4})","$1 $2",["[2-46]|8[013]"]],["(\\d{4})(\\d{4})","$1 $2",["[57]"]],["(\\d{5})(\\d{5})","$1 $2",["8"]]],0,0,0,0,0,0,0,"020"],MV:["960","0(?:0|19)","(?:800|9[0-57-9]\\d)\\d{7}|[34679]\\d{6}",[7,10],[["(\\d{3})(\\d{4})","$1-$2",["[34679]"]],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["[89]"]]],0,0,0,0,0,0,0,"00"],MW:["265","00","(?:[1289]\\d|31|77)\\d{7}|1\\d{6}",[7,9],[["(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["1[2-9]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["2"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[137-9]"],"0$1"]],"0"],MX:["52","0[09]","1(?:(?:22|44|7[27]|87|9[69])[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-689]|8[1-69]|9[1-578])|[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[047]"]]]],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","2[0-24-9]\\d{8}|[78]\\d{10,13}|[7-9]\\d{9}|[1-9]\\d{7}|[124-7]\\d{6}",[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-6]|7(?:0[0-689]|[1-79])|8[2-9]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["[7-9]"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["20[129]"],"0$1"],["(\\d{4})(\\d{2})(\\d{4})","$1 $2 $3",["2"],"0$1"],["(\\d{3})(\\d{4})(\\d{4,5})","$1 $2 $3",["[78]"],"0$1"],["(\\d{3})(\\d{5})(\\d{5,6})","$1 $2 $3",["[78]"],"0$1"]],"0"],NI:["505","00","(?:1800|[25-8]\\d{3})\\d{4}",[8],[["(\\d{4})(\\d{4})","$1 $2",["[125-8]"]]]],NL:["31","00","(?:[124-7]\\d\\d|3(?:[02-9]\\d|1[0-8]))\\d{6}|8\\d{6,9}|9\\d{6,10}|1\\d{4,5}",[5,6,7,8,9,10,11],[["(\\d{3})(\\d{4,7})","$1 $2",["[89]0"],"0$1"],["(\\d{2})(\\d{7})","$1 $2",["66"],"0$1"],["(\\d)(\\d{8})","$1 $2",["6"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["1[16-8]|2[259]|3[124]|4[17-9]|5[124679]"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[1-578]|91"],"0$1"],["(\\d{3})(\\d{3})(\\d{5})","$1 $2 $3",["9"],"0$1"]],"0"],NO:["47","00","(?:0|[2-9]\\d{3})\\d{4}",[5,8],[["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["8"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[2-79]"]]],0,0,0,0,0,"[02-689]|7[0-8]"],NP:["977","00","(?:1\\d|9)\\d{9}|[1-9]\\d{7}",[8,10,11],[["(\\d)(\\d{7})","$1-$2",["1[2-6]"],"0$1"],["(\\d{2})(\\d{6})","$1-$2",["1[01]|[2-8]|9(?:[1-59]|[67][2-6])"],"0$1"],["(\\d{3})(\\d{7})","$1-$2",["9"]]],"0"],NR:["674","00","(?:444|(?:55|8\\d)\\d|666)\\d{4}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[4-68]"]]]],NU:["683","00","(?:[4-7]|888\\d)\\d{3}",[4,7],[["(\\d{3})(\\d{4})","$1 $2",["8"]]]],NZ:["64","0(?:0|161)","[1289]\\d{9}|50\\d{5}(?:\\d{2,3})?|[27-9]\\d{7,8}|(?:[34]\\d|6[0-35-9])\\d{6}|8\\d{4,6}",[5,6,7,8,9,10],[["(\\d{2})(\\d{3,8})","$1 $2",["8[1-79]"],"0$1"],["(\\d{3})(\\d{2})(\\d{2,3})","$1 $2 $3",["50[036-8]|8|90","50(?:[0367]|88)|8|90"],"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)|[589]"],"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"],"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-7])"],"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-6]))\\d{4}"],["69(?:2\\d\\d|3(?:[06][0-6]|1[013]|2[0-2]|3[0-39]|4\\d|5[0-5]|7[0-37]|8[0-8]|9[0-479]))\\d{4}"],["80\\d{7}"],["89[1-37-9]\\d{6}"],0,0,0,0,["9(?:399[0-3]|479[0-5]|76(?:2[27]|3[0-37]))\\d{4}"],["8(?:1[019]|2[0156]|84|90)\\d{6}"]]],RO:["40","00","(?:[236-8]\\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",["[236-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",["2"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[7-9]"],"0$1"]],"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-9]|[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|79)\\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",["[348]|64|79|90"]],["(\\d{2})(\\d{5,7})","$1 $2",["1|28|6[0-35-9]|77|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}|(?:80\\d|900)\\d{4}(?:\\d{4})?",[7,8,11],[["(\\d{3})(\\d{4})","$1 $2",["[89]"]],["(\\d{4})(\\d{4})","$1 $2",["[267]"]],["(\\d{3})(\\d{4})(\\d{4})","$1 $2 $3",["[89]"]]]],SX:["1","011","7215\\d{6}|(?:[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"(5\\d{6})$|1","721$1",0,"721"],SY:["963","00","[1-39]\\d{8}|[1-5]\\d{7}",[8,9],[["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[1-5]"],"0$1",1],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["9"],"0$1",1]],"0"],SZ:["268","00","0800\\d{4}|(?:[237]\\d|900)\\d{6}",[8,9],[["(\\d{4})(\\d{4})","$1 $2",["[0237]"]],["(\\d{5})(\\d{4})","$1 $2",["9"]]]],TA:["290","00","8\\d{3}",[4],0,0,0,0,0,0,"8"],TC:["1","011","(?:[58]\\d\\d|649|900)\\d{7}",[10],0,"1",0,"([2-479]\\d{6})$|1","649$1",0,"649"],TD:["235","00|16","(?:22|[69]\\d|77)\\d{6}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[2679]"]]],0,0,0,0,0,0,0,"00"],TG:["228","00","[279]\\d{7}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[279]"]]]],TH:["66","00[1-9]","(?:001800|[2-57]|[689]\\d)\\d{7}|1\\d{7,9}",[8,9,10,13],[["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["2"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[13-9]"],"0$1"],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["1"]]],"0"],TJ:["992","810","[0-57-9]\\d{8}",[9],[["(\\d{6})(\\d)(\\d{2})","$1 $2 $3",["331","3317"]],["(\\d{3})(\\d{2})(\\d{4})","$1 $2 $3",["44[02-479]|[34]7"]],["(\\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|71)\\d{6}",[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",["[67]"],"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]|61[06])","5(?:[0-59]|61[06]1)"],"0$1",1],["(\\d{3})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[24][1-8]|3[1-9]"],"(0$1)",1],["(\\d{3})(\\d{3})(\\d{6,7})","$1 $2 $3",["80"],"0$1",1]],"0"],TT:["1","011","(?:[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([2-46-8]\\d{6})$|1","868$1",0,"868"],TV:["688","00","(?:2|7\\d\\d|90)\\d{4}",[5,6,7],[["(\\d{2})(\\d{3})","$1 $2",["2"]],["(\\d{2})(\\d{4})","$1 $2",["90"]],["(\\d{2})(\\d{5})","$1 $2",["7"]]]],TW:["886","0(?:0[25-79]|19)","[2-689]\\d{8}|7\\d{9,10}|[2-8]\\d{7}|2\\d{6}",[7,8,9,10,11],[["(\\d{2})(\\d)(\\d{4})","$1 $2 $3",["202"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[258]0"],"0$1"],["(\\d)(\\d{3,4})(\\d{4})","$1 $2 $3",["[23568]|4(?:0[02-48]|[1-47-9])|7[1-9]","[23568]|4(?:0[2-48]|[1-47-9])|(?:400|7)[1-9]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[49]"],"0$1"],["(\\d{2})(\\d{4})(\\d{4,5})","$1 $2 $3",["7"],"0$1"]],"0",0,0,0,0,0,0,0,"#"],TZ:["255","00[056]","(?:[25-8]\\d|41|90)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{4})","$1 $2 $3",["[89]"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[24]"],"0$1"],["(\\d{2})(\\d{7})","$1 $2",["5"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[67]"],"0$1"]],"0"],UA:["380","00","[89]\\d{9}|[3-9]\\d{8}",[9,10],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["6[12][29]|(?:3[1-8]|4[136-8]|5[12457]|6[49])2|(?:56|65)[24]","6[12][29]|(?:35|4[1378]|5[12457]|6[49])2|(?:56|65)[24]|(?:3[1-46-8]|46)2[013-9]"],"0$1"],["(\\d{4})(\\d{5})","$1 $2",["3[1-8]|4(?:[1367]|[45][6-9]|8[4-6])|5(?:[1-5]|6[0135689]|7[4-6])|6(?:[12][3-7]|[459])","3[1-8]|4(?:[1367]|[45][6-9]|8[4-6])|5(?:[1-5]|6(?:[015689]|3[02389])|7[4-6])|6(?:[12][3-7]|[459])"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[3-7]|89|9[1-9]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["[89]"],"0$1"]],"0",0,0,0,0,0,0,"0~0"],UG:["256","00[057]","800\\d{6}|(?:[29]0|[347]\\d)\\d{7}",[9],[["(\\d{4})(\\d{5})","$1 $2",["202","2024"],"0$1"],["(\\d{3})(\\d{6})","$1 $2",["[27-9]|4(?:6[45]|[7-9])"],"0$1"],["(\\d{2})(\\d{7})","$1 $2",["[34]"],"0$1"]],"0"],US:["1","011","[2-9]\\d{9}|3\\d{6}",[10],[["(\\d{3})(\\d{4})","$1-$2",["310"],0,1],["(\\d{3})(\\d{3})(\\d{4})","($1) $2-$3",["[2-9]"],0,1,"$1-$2-$3"]],"1",0,0,0,0,0,[["(?:5056(?:[0-35-9]\\d|4[468])|7302[0-4]\\d)\\d{4}|(?:472[24]|505[2-57-9]|7306|983[2-47-9])\\d{6}|(?:2(?:0[1-35-9]|1[02-9]|2[03-57-9]|3[1459]|4[08]|5[1-46]|6[0279]|7[0269]|8[13])|3(?:0[1-57-9]|1[02-9]|2[013569]|3[0-24679]|4[167]|5[0-2]|6[01349]|8[056])|4(?:0[124-9]|1[02-579]|2[3-5]|3[0245]|4[023578]|58|6[349]|7[0589]|8[04])|5(?:0[1-47-9]|1[0235-8]|20|3[0149]|4[01]|5[179]|6[1-47]|7[0-5]|8[0256])|6(?:0[1-35-9]|1[024-9]|2[03689]|3[016]|4[0156]|5[01679]|6[0-279]|78|8[0-29])|7(?:0[1-46-8]|1[2-9]|2[04-8]|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\\d{2,9}|[1249]\\d{7}|(?:[49]\\d|80)\\d{5}",[6,7,8,9,10,11,12,13],[["(\\d{3})(\\d{3,4})","$1 $2",["0"]],["(\\d{3})(\\d{4})","$1 $2",["[49]0|8"],"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{2,4})","$1 $2 $3",["0"]],["(\\d{3})(\\d{3})(\\d{3})(\\d{2,4})","$1 $2 $3 $4",["0"]]],"0",0,0,0,0,0,0,"00"," int. "],UZ:["998","810","(?:20|33|[5-79]\\d|88)\\d{7}",[9],[["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[235-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",["6"],"0$1",1],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[357-9]"],"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","2\\d{7,8}|3\\d{7,11}|(?:4\\d\\d|[89]00)\\d{5}",[8,9,10,11,12],[["(\\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",["2|39"],"0$1"],["(\\d{2})(\\d{7,10})","$1 $2",["3"],"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","(?:80|9\\d)\\d{7}|(?:26|63)9\\d{6}",[9],0,"0",0,0,0,0,0,[["269(?:0[0-467]|15|5[0-4]|6\\d|[78]0)\\d{4}"],["639(?:0[0-79]|1[019]|[267]\\d|3[09]|40|5[05-9]|9[04-79])\\d{4}"],["80\\d{7}"],0,0,0,0,0,["9(?:(?:39|47)8[01]|769\\d)\\d{4}"]]],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,"6\\d{9}|[0-36-9]\\d{8}",[9,10],[["(\\d)(\\d{3})(\\d{5})","$1 $2 $3",["[0-37-9]"]],["(\\d)(\\d{3})(\\d{5,6})","$1 $2 $3",["6"]]],0,0,0,0,0,0,[0,["6\\d{9}|[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[0-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}"]]]}};function rg(e){return rg="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},rg(e)}function sg(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function ag(e){var t=lg();return function(){var i,n=ug(e);if(t){var r=ug(this).constructor;i=Reflect.construct(n,arguments,r)}else i=n.apply(this,arguments);return function(e,t){if(t&&("object"===rg(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return og(e)}(this,i)}}function og(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function cg(e){var t="function"==typeof Map?new Map:void 0;return cg=function(e){if(null===e||(i=e,-1===Function.toString.call(i).indexOf("[native code]")))return e;var i;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return dg(e,arguments,ug(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),hg(n,e)},cg(e)}function dg(e,t,i){return dg=lg()?Reflect.construct:function(e,t,i){var n=[null];n.push.apply(n,t);var r=new(Function.bind.apply(e,n));return i&&hg(r,i.prototype),r},dg.apply(null,arguments)}function lg(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function hg(e,t){return hg=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},hg(e,t)}function ug(e){return ug=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},ug(e)}var pg=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&hg(e,t)}(s,e);var t,i,n,r=ag(s);function s(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,s),t=r.call(this,e),Object.setPrototypeOf(og(t),s.prototype),t.name=t.constructor.name,t}return t=s,i&&sg(t.prototype,i),n&&sg(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}(cg(Error)),gg=2,fg=17,mg=3,vg="0-90-9٠-٩۰-۹",yg="".concat("-‐-―−ー-").concat("//").concat("..").concat("  ­​⁠ ").concat("()()[]\\[\\]").concat("~⁓∼~");function Sg(e,t){e=e.split("-"),t=t.split("-");for(var i=e[0].split("."),n=t[0].split("."),r=0;r<3;r++){var s=Number(i[r]),a=Number(n[r]);if(s>a)return 1;if(a>s)return-1;if(!isNaN(s)&&isNaN(a))return 1;if(isNaN(s)&&!isNaN(a))return-1}return e[1]&&t[1]?e[1]>t[1]?1:e[1]<t[1]?-1:0:!e[1]&&t[1]?1:e[1]&&!t[1]?-1:0}var bg={}.constructor;function wg(e){return null!=e&&e.constructor===bg}function Eg(e){return Eg="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Eg(e)}function Cg(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Tg(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function $g(e,t,i){return t&&Tg(e.prototype,t),i&&Tg(e,i),Object.defineProperty(e,"prototype",{writable:!1}),e}var _g=" ext. ",xg=/^\d+$/,Ig=function(){function e(t){Cg(this,e),function(e){if(!e)throw new Error("[libphonenumber-js] `metadata` argument not passed. Check your arguments.");if(!wg(e)||!wg(e.countries))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(wg(e)?"an object of shape: { "+Object.keys(e).join(", ")+" }":"a "+kg(e)+": "+e,"."))}(t),this.metadata=t,Fg.call(this,t)}return $g(e,[{key:"getCountries",value:function(){return Object.keys(this.metadata.countries).filter((function(e){return"001"!==e}))}},{key:"getCountryMetadata",value:function(e){return this.metadata.countries[e]}},{key:"nonGeographic",value:function(){if(!(this.v1||this.v2||this.v3))return this.metadata.nonGeographic||this.metadata.nonGeographical}},{key:"hasCountry",value:function(e){return void 0!==this.getCountryMetadata(e)}},{key:"hasCallingCode",value:function(e){if(this.getCountryCodesForCallingCode(e))return!0;if(this.nonGeographic()){if(this.nonGeographic()[e])return!0}else{var t=this.countryCallingCodes()[e];if(t&&1===t.length&&"001"===t[0])return!0}}},{key:"isNonGeographicCallingCode",value:function(e){return this.nonGeographic()?!!this.nonGeographic()[e]:!this.getCountryCodesForCallingCode(e)}},{key:"country",value:function(e){return this.selectNumberingPlan(e)}},{key:"selectNumberingPlan",value:function(e,t){if(e&&xg.test(e)&&(t=e,e=null),e&&"001"!==e){if(!this.hasCountry(e))throw new Error("Unknown country: ".concat(e));this.numberingPlan=new Rg(this.getCountryMetadata(e),this)}else if(t){if(!this.hasCallingCode(t))throw new Error("Unknown calling code: ".concat(t));this.numberingPlan=new Rg(this.getNumberingPlanMetadata(t),this)}else this.numberingPlan=void 0;return this}},{key:"getCountryCodesForCallingCode",value:function(e){var t=this.countryCallingCodes()[e];if(t){if(1===t.length&&3===t[0].length)return;return t}}},{key:"getCountryCodeForCallingCode",value:function(e){var t=this.getCountryCodesForCallingCode(e);if(t)return t[0]}},{key:"getNumberingPlanMetadata",value:function(e){var t=this.getCountryCodeForCallingCode(e);if(t)return this.getCountryMetadata(t);if(this.nonGeographic()){var i=this.nonGeographic()[e];if(i)return i}else{var n=this.countryCallingCodes()[e];if(n&&1===n.length&&"001"===n[0])return this.metadata.countries["001"]}}},{key:"countryCallingCode",value:function(){return this.numberingPlan.callingCode()}},{key:"IDDPrefix",value:function(){return this.numberingPlan.IDDPrefix()}},{key:"defaultIDDPrefix",value:function(){return this.numberingPlan.defaultIDDPrefix()}},{key:"nationalNumberPattern",value:function(){return this.numberingPlan.nationalNumberPattern()}},{key:"possibleLengths",value:function(){return this.numberingPlan.possibleLengths()}},{key:"formats",value:function(){return this.numberingPlan.formats()}},{key:"nationalPrefixForParsing",value:function(){return this.numberingPlan.nationalPrefixForParsing()}},{key:"nationalPrefixTransformRule",value:function(){return this.numberingPlan.nationalPrefixTransformRule()}},{key:"leadingDigits",value:function(){return this.numberingPlan.leadingDigits()}},{key:"hasTypes",value:function(){return this.numberingPlan.hasTypes()}},{key:"type",value:function(e){return this.numberingPlan.type(e)}},{key:"ext",value:function(){return this.numberingPlan.ext()}},{key:"countryCallingCodes",value:function(){return this.v1?this.metadata.country_phone_code_to_countries:this.metadata.country_calling_codes}},{key:"chooseCountryByCountryCallingCode",value:function(e){return this.selectNumberingPlan(e)}},{key:"hasSelectedNumberingPlan",value:function(){return void 0!==this.numberingPlan}}]),e}(),Rg=function(){function e(t,i){Cg(this,e),this.globalMetadataObject=i,this.metadata=t,Fg.call(this,i.metadata)}return $g(e,[{key:"callingCode",value:function(){return this.metadata[0]}},{key:"getDefaultCountryMetadataForRegion",value:function(){return this.globalMetadataObject.getNumberingPlanMetadata(this.callingCode())}},{key:"IDDPrefix",value:function(){if(!this.v1&&!this.v2)return this.metadata[1]}},{key:"defaultIDDPrefix",value:function(){if(!this.v1&&!this.v2)return this.metadata[12]}},{key:"nationalNumberPattern",value:function(){return this.v1||this.v2?this.metadata[1]:this.metadata[2]}},{key:"possibleLengths",value:function(){if(!this.v1)return this.metadata[this.v2?2:3]}},{key:"_getFormats",value:function(e){return e[this.v1?2:this.v2?3:4]}},{key:"formats",value:function(){var e=this,t=this._getFormats(this.metadata)||this._getFormats(this.getDefaultCountryMetadataForRegion())||[];return t.map((function(t){return new Ag(t,e)}))}},{key:"nationalPrefix",value:function(){return this.metadata[this.v1?3:this.v2?4:5]}},{key:"_getNationalPrefixFormattingRule",value:function(e){return e[this.v1?4:this.v2?5:6]}},{key:"nationalPrefixFormattingRule",value:function(){return this._getNationalPrefixFormattingRule(this.metadata)||this._getNationalPrefixFormattingRule(this.getDefaultCountryMetadataForRegion())}},{key:"_nationalPrefixForParsing",value:function(){return this.metadata[this.v1?5:this.v2?6:7]}},{key:"nationalPrefixForParsing",value:function(){return this._nationalPrefixForParsing()||this.nationalPrefix()}},{key:"nationalPrefixTransformRule",value:function(){return this.metadata[this.v1?6:this.v2?7:8]}},{key:"_getNationalPrefixIsOptionalWhenFormatting",value:function(){return!!this.metadata[this.v1?7:this.v2?8:9]}},{key:"nationalPrefixIsOptionalWhenFormattingInNationalFormat",value:function(){return this._getNationalPrefixIsOptionalWhenFormatting(this.metadata)||this._getNationalPrefixIsOptionalWhenFormatting(this.getDefaultCountryMetadataForRegion())}},{key:"leadingDigits",value:function(){return this.metadata[this.v1?8:this.v2?9:10]}},{key:"types",value:function(){return this.metadata[this.v1?9:this.v2?10:11]}},{key:"hasTypes",value:function(){return(!this.types()||0!==this.types().length)&&!!this.types()}},{key:"type",value:function(e){if(this.hasTypes()&&Ng(this.types(),e))return new Dg(Ng(this.types(),e),this)}},{key:"ext",value:function(){return this.v1||this.v2?_g:this.metadata[13]||_g}}]),e}(),Ag=function(){function e(t,i){Cg(this,e),this._format=t,this.metadata=i}return $g(e,[{key:"pattern",value:function(){return this._format[0]}},{key:"format",value:function(){return this._format[1]}},{key:"leadingDigitsPatterns",value:function(){return this._format[2]||[]}},{key:"nationalPrefixFormattingRule",value:function(){return this._format[3]||this.metadata.nationalPrefixFormattingRule()}},{key:"nationalPrefixIsOptionalWhenFormattingInNationalFormat",value:function(){return!!this._format[4]||this.metadata.nationalPrefixIsOptionalWhenFormattingInNationalFormat()}},{key:"nationalPrefixIsMandatoryWhenFormattingInNationalFormat",value:function(){return this.usesNationalPrefix()&&!this.nationalPrefixIsOptionalWhenFormattingInNationalFormat()}},{key:"usesNationalPrefix",value:function(){return!(!this.nationalPrefixFormattingRule()||Pg.test(this.nationalPrefixFormattingRule()))}},{key:"internationalFormat",value:function(){return this._format[5]||this.format()}}]),e}(),Pg=/^\(?\$1\)?$/,Dg=function(){function e(t,i){Cg(this,e),this.type=t,this.metadata=i}return $g(e,[{key:"pattern",value:function(){return this.metadata.v1?this.type:this.type[0]}},{key:"possibleLengths",value:function(){if(!this.metadata.v1)return this.type[1]||this.metadata.possibleLengths()}}]),e}();function Ng(e,t){switch(t){case"FIXED_LINE":return e[0];case"MOBILE":return e[1];case"TOLL_FREE":return e[2];case"PREMIUM_RATE":return e[3];case"PERSONAL_NUMBER":return e[4];case"VOICEMAIL":return e[5];case"UAN":return e[6];case"PAGER":return e[7];case"VOIP":return e[8];case"SHARED_COST":return e[9]}}var kg=function(e){return Eg(e)};function Og(e,t){if((t=new Ig(t)).hasCountry(e))return t.country(e).countryCallingCode();throw new Error("Unknown country: ".concat(e))}function Fg(e){var t=e.version;"number"==typeof t?(this.v1=1===t,this.v2=2===t,this.v3=3===t,this.v4=4===t):t?-1===Sg(t,"1.2.0")?this.v2=!0:-1===Sg(t,"1.7.35")?this.v3=!0:this.v4=!0:this.v1=!0}var Mg=function(e){return"([".concat(vg,"]{1,").concat(e,"})")};function Hg(e){var t="[  \\t,]*",i="[:\\..]?[  \\t,-]*",n="#?",r="[  \\t]*";return";ext="+Mg("20")+"|"+(t+"(?:e?xt(?:ensi(?:ó?|ó))?n?|e?xtn?|доб|anexo)"+i+Mg("20")+n)+"|"+(t+"(?:[xx##~~]|int|int)"+i+Mg("9")+n)+"|"+("[- ]+"+Mg("6")+"#")+"|"+(r+"(?:,{2}|;)"+i+Mg("15")+n)+"|"+(r+"(?:,)+"+i+Mg("9")+n)}var Lg="["+vg+"]{"+gg+"}",jg="[++]{0,1}(?:["+yg+"]*["+vg+"]){3,}["+yg+vg+"]*",Bg=new RegExp("^[++]{0,1}(?:["+yg+"]*["+vg+"]){1,2}$","i"),Ug=jg+"(?:"+Hg()+")?",Vg=new RegExp("^"+Lg+"$|^"+Ug+"$","i");var qg=new RegExp("(?:"+Hg()+")$","i");function Gg(e,t){var i="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(i)return(i=i.call(e)).next.bind(i);if(Array.isArray(e)||(i=function(e,t){if(!e)return;if("string"==typeof e)return Kg(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);"Object"===i&&e.constructor&&(i=e.constructor.name);if("Map"===i||"Set"===i)return Array.from(e);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return Kg(e,t)}(e))||t&&e&&"number"==typeof e.length){i&&(e=i);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Kg(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i<t;i++)n[i]=e[i];return n}var Wg={0:"0",1:"1",2:"2",3:"3",4:"4",5:"5",6:"6",7:"7",8:"8",9:"9","0":"0","1":"1","2":"2","3":"3","4":"4","5":"5","6":"6","7":"7","8":"8","9":"9","٠":"0","١":"1","٢":"2","٣":"3","٤":"4","٥":"5","٦":"6","٧":"7","٨":"8","٩":"9","۰":"0","۱":"1","۲":"2","۳":"3","۴":"4","۵":"5","۶":"6","۷":"7","۸":"8","۹":"9"};function zg(e){return Wg[e]}function Yg(e){for(var t,i="",n=Gg(e.split(""));!(t=n()).done;){var r=zg(t.value);r&&(i+=r)}return i}function Jg(e,t){var i="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(i)return(i=i.call(e)).next.bind(i);if(Array.isArray(e)||(i=function(e,t){if(!e)return;if("string"==typeof e)return Zg(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);"Object"===i&&e.constructor&&(i=e.constructor.name);if("Map"===i||"Set"===i)return Array.from(e);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return Zg(e,t)}(e))||t&&e&&"number"==typeof e.length){i&&(e=i);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Zg(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i<t;i++)n[i]=e[i];return n}function Xg(e){for(var t,i="",n=Jg(e.split(""));!(t=n()).done;){i+=Qg(t.value,i)||""}return i}function Qg(e,t,i){return"+"===e?t?void("function"==typeof i&&i("end")):"+":zg(e)}function ef(e,t){var i="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(i)return(i=i.call(e)).next.bind(i);if(Array.isArray(e)||(i=function(e,t){if(!e)return;if("string"==typeof e)return tf(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);"Object"===i&&e.constructor&&(i=e.constructor.name);if("Map"===i||"Set"===i)return Array.from(e);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return tf(e,t)}(e))||t&&e&&"number"==typeof e.length){i&&(e=i);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function tf(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i<t;i++)n[i]=e[i];return n}function nf(e,t){return rf(e,void 0,t)}function rf(e,t,i){var n=i.type(t),r=n&&n.possibleLengths()||i.possibleLengths();if(!r)return"IS_POSSIBLE";if("FIXED_LINE_OR_MOBILE"===t){if(!i.type("FIXED_LINE"))return rf(e,"MOBILE",i);var s=i.type("MOBILE");s&&(r=function(e,t){for(var i,n=e.slice(),r=ef(t);!(i=r()).done;){var s=i.value;e.indexOf(s)<0&&n.push(s)}return n.sort((function(e,t){return e-t}))}(r,s.possibleLengths()))}else if(t&&!n)return"INVALID_LENGTH";var a=e.length,o=r[0];return o===a?"IS_POSSIBLE":o>a?"TOO_SHORT":r[r.length-1]<a?"TOO_LONG":r.indexOf(a,1)>=0?"IS_POSSIBLE":"INVALID_LENGTH"}function sf(e,t){return"IS_POSSIBLE"===nf(e,t)}function af(e,t){return e=e||"",new RegExp("^(?:"+t+")$").test(e)}function of(e,t){var i="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(i)return(i=i.call(e)).next.bind(i);if(Array.isArray(e)||(i=function(e,t){if(!e)return;if("string"==typeof e)return cf(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);"Object"===i&&e.constructor&&(i=e.constructor.name);if("Map"===i||"Set"===i)return Array.from(e);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return cf(e,t)}(e))||t&&e&&"number"==typeof e.length){i&&(e=i);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function cf(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i<t;i++)n[i]=e[i];return n}var df=["MOBILE","PREMIUM_RATE","TOLL_FREE","SHARED_COST","VOIP","PERSONAL_NUMBER","PAGER","UAN","VOICEMAIL"];function lf(e,t,i){if(t=t||{},e.country||e.countryCallingCode){(i=new Ig(i)).selectNumberingPlan(e.country,e.countryCallingCode);var n=t.v2?e.nationalNumber:e.phone;if(af(n,i.nationalNumberPattern())){if(hf(n,"FIXED_LINE",i))return i.type("MOBILE")&&""===i.type("MOBILE").pattern()?"FIXED_LINE_OR_MOBILE":i.type("MOBILE")?hf(n,"MOBILE",i)?"FIXED_LINE_OR_MOBILE":"FIXED_LINE":"FIXED_LINE_OR_MOBILE";for(var r,s=of(df);!(r=s()).done;){var a=r.value;if(hf(n,a,i))return a}}}}function hf(e,t,i){return!(!(t=i.type(t))||!t.pattern())&&(!(t.possibleLengths()&&t.possibleLengths().indexOf(e.length)<0)&&af(e,t.pattern()))}function uf(e,t,i){var n=new Ig(i).getCountryCodesForCallingCode(e);return n?n.filter((function(e){return function(e,t,i){var n=new Ig(i);if(n.selectNumberingPlan(t),n.numberingPlan.possibleLengths().indexOf(e.length)>=0)return!0;return!1}(t,e,i)})):[]}function pf(e){return e.replace(new RegExp("[".concat(yg,"]+"),"g")," ").trim()}var gf=/(\$\d)/;function ff(e,t,i){var n=i.useInternationalFormat,r=i.withNationalPrefix;i.carrierCode,i.metadata;var s=e.replace(new RegExp(t.pattern()),n?t.internationalFormat():r&&t.nationalPrefixFormattingRule()?t.format().replace(gf,t.nationalPrefixFormattingRule()):t.format());return n?pf(s):s}var mf=/^[\d]+(?:[~\u2053\u223C\uFF5E][\d]+)?$/;function vf(e,t){var i="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(i)return(i=i.call(e)).next.bind(i);if(Array.isArray(e)||(i=function(e,t){if(!e)return;if("string"==typeof e)return yf(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);"Object"===i&&e.constructor&&(i=e.constructor.name);if("Map"===i||"Set"===i)return Array.from(e);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return yf(e,t)}(e))||t&&e&&"number"==typeof e.length){i&&(e=i);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function yf(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i<t;i++)n[i]=e[i];return n}function Sf(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function bf(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?Sf(Object(i),!0).forEach((function(t){wf(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):Sf(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function wf(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}var Ef={formatExtension:function(e,t,i){return"".concat(e).concat(i.ext()).concat(t)}};function Cf(e,t,i,n){if(i=i?bf(bf({},Ef),i):Ef,n=new Ig(n),e.country&&"001"!==e.country){if(!n.hasCountry(e.country))throw new Error("Unknown country: ".concat(e.country));n.country(e.country)}else{if(!e.countryCallingCode)return e.phone||"";n.selectNumberingPlan(e.countryCallingCode)}var r,s=n.countryCallingCode(),a=i.v2?e.nationalNumber:e.phone;switch(t){case"NATIONAL":return a?$f(r=Tf(a,e.carrierCode,"NATIONAL",n,i),e.ext,n,i.formatExtension):"";case"INTERNATIONAL":return a?(r=Tf(a,null,"INTERNATIONAL",n,i),$f(r="+".concat(s," ").concat(r),e.ext,n,i.formatExtension)):"+".concat(s);case"E.164":return"+".concat(s).concat(a);case"RFC3966":return function(e){var t=e.number,i=e.ext;if(!t)return"";if("+"!==t[0])throw new Error('"formatRFC3966()" expects "number" to be in E.164 format.');return"tel:".concat(t).concat(i?";ext="+i:"")}({number:"+".concat(s).concat(a),ext:e.ext});case"IDD":if(!i.fromCountry)return;var o=function(e,t,i,n,r){var s=Og(n,r.metadata);if(s===i){var a=Tf(e,t,"NATIONAL",r);return"1"===i?i+" "+a:a}var o=function(e,t,i){var n=new Ig(i);return n.selectNumberingPlan(e,t),n.defaultIDDPrefix()?n.defaultIDDPrefix():mf.test(n.IDDPrefix())?n.IDDPrefix():void 0}(n,void 0,r.metadata);if(o)return"".concat(o," ").concat(i," ").concat(Tf(e,null,"INTERNATIONAL",r))}(a,e.carrierCode,s,i.fromCountry,n);return $f(o,e.ext,n,i.formatExtension);default:throw new Error('Unknown "format" argument passed to "formatNumber()": "'.concat(t,'"'))}}function Tf(e,t,i,n,r){var s=function(e,t){for(var i,n=vf(e);!(i=n()).done;){var r=i.value;if(r.leadingDigitsPatterns().length>0){var s=r.leadingDigitsPatterns()[r.leadingDigitsPatterns().length-1];if(0!==t.search(s))continue}if(af(t,r.pattern()))return r}}(n.formats(),e);return s?ff(e,s,{useInternationalFormat:"INTERNATIONAL"===i,withNationalPrefix:!s.nationalPrefixIsOptionalWhenFormattingInNationalFormat()||!r||!1!==r.nationalPrefix,carrierCode:t,metadata:n}):e}function $f(e,t,i,n){return t?n(e,t,i):e}function _f(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function xf(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?_f(Object(i),!0).forEach((function(t){If(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):_f(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function If(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function Rf(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var Af=function(){function e(t,i,n){if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),!t)throw new TypeError("`country` or `countryCallingCode` not passed");if(!i)throw new TypeError("`nationalNumber` not passed");if(!n)throw new TypeError("`metadata` not passed");var r=function(e,t){var i,n,r=new Ig(t);Pf(e)?(i=e,r.selectNumberingPlan(i),n=r.countryCallingCode()):n=e;return{country:i,countryCallingCode:n}}(t,n),s=r.country,a=r.countryCallingCode;this.country=s,this.countryCallingCode=a,this.nationalNumber=i,this.number="+"+this.countryCallingCode+this.nationalNumber,this.getMetadata=function(){return n}}var t,i,n;return t=e,i=[{key:"setExt",value:function(e){this.ext=e}},{key:"getPossibleCountries",value:function(){return this.country?[this.country]:uf(this.countryCallingCode,this.nationalNumber,this.getMetadata())}},{key:"isPossible",value:function(){return function(e,t,i){if(void 0===t&&(t={}),i=new Ig(i),t.v2){if(!e.countryCallingCode)throw new Error("Invalid phone number object passed");i.selectNumberingPlan(e.countryCallingCode)}else{if(!e.phone)return!1;if(e.country){if(!i.hasCountry(e.country))throw new Error("Unknown country: ".concat(e.country));i.country(e.country)}else{if(!e.countryCallingCode)throw new Error("Invalid phone number object passed");i.selectNumberingPlan(e.countryCallingCode)}}if(i.possibleLengths())return sf(e.phone||e.nationalNumber,i);if(e.countryCallingCode&&i.isNonGeographicCallingCode(e.countryCallingCode))return!0;throw new Error('Missing "possibleLengths" in metadata. Perhaps the metadata has been generated before v1.0.18.')}(this,{v2:!0},this.getMetadata())}},{key:"isValid",value:function(){return function(e,t,i){return t=t||{},(i=new Ig(i)).selectNumberingPlan(e.country,e.countryCallingCode),i.hasTypes()?void 0!==lf(e,t,i.metadata):af(t.v2?e.nationalNumber:e.phone,i.nationalNumberPattern())}(this,{v2:!0},this.getMetadata())}},{key:"isNonGeographic",value:function(){return new Ig(this.getMetadata()).isNonGeographicCallingCode(this.countryCallingCode)}},{key:"isEqual",value:function(e){return this.number===e.number&&this.ext===e.ext}},{key:"getType",value:function(){return lf(this,{v2:!0},this.getMetadata())}},{key:"format",value:function(e,t){return Cf(this,e,t?xf(xf({},t),{},{v2:!0}):{v2:!0},this.getMetadata())}},{key:"formatNational",value:function(e){return this.format("NATIONAL",e)}},{key:"formatInternational",value:function(e){return this.format("INTERNATIONAL",e)}},{key:"getURI",value:function(e){return this.format("RFC3966",e)}}],i&&Rf(t.prototype,i),n&&Rf(t,n),Object.defineProperty(t,"prototype",{writable:!1}),e}(),Pf=function(e){return/^[A-Z]{2}$/.test(e)};var Df=new RegExp("(["+vg+"])");function Nf(e,t,i,n){if(t){var r=new Ig(n);r.selectNumberingPlan(t,i);var s=new RegExp(r.IDDPrefix());if(0===e.search(s)){var a=(e=e.slice(e.match(s)[0].length)).match(Df);if(!(a&&null!=a[1]&&a[1].length>0&&"0"===a[1]))return e}}}function kf(e,t){if(e&&t.numberingPlan.nationalPrefixForParsing()){var i=new RegExp("^(?:"+t.numberingPlan.nationalPrefixForParsing()+")"),n=i.exec(e);if(n){var r,s,a,o=n.length-1,c=o>0&&n[o];if(t.nationalPrefixTransformRule()&&c)r=e.replace(i,t.nationalPrefixTransformRule()),o>1&&(s=n[1]);else{var d=n[0];r=e.slice(d.length),c&&(s=n[1])}if(c){var l=e.indexOf(n[1]);e.slice(0,l)===t.numberingPlan.nationalPrefix()&&(a=t.numberingPlan.nationalPrefix())}else a=n[0];return{nationalNumber:r,nationalPrefix:a,carrierCode:s}}}return{nationalNumber:e}}function Of(e,t){var i=kf(e,t),n=i.carrierCode,r=i.nationalNumber;if(r!==e){if(!function(e,t,i){if(af(e,i.nationalNumberPattern())&&!af(t,i.nationalNumberPattern()))return!1;return!0}(e,r,t))return{nationalNumber:e};if(t.possibleLengths()&&!function(e,t){switch(nf(e,t)){case"TOO_SHORT":case"INVALID_LENGTH":return!1;default:return!0}}(r,t))return{nationalNumber:e}}return{nationalNumber:r,carrierCode:n}}function Ff(e,t,i,n){var r=t?Og(t,n):i;if(0===e.indexOf(r)){(n=new Ig(n)).selectNumberingPlan(t,i);var s=e.slice(r.length),a=Of(s,n).nationalNumber,o=Of(e,n).nationalNumber;if(!af(o,n.nationalNumberPattern())&&af(a,n.nationalNumberPattern())||"TOO_LONG"===nf(o,n))return{countryCallingCode:r,number:s}}return{number:e}}function Mf(e,t,i,n){if(!e)return{};var r;if("+"!==e[0]){var s=Nf(e,t,i,n);if(!s||s===e){if(t||i){var a=Ff(e,t,i,n),o=a.countryCallingCode,c=a.number;if(o)return{countryCallingCodeSource:"FROM_NUMBER_WITHOUT_PLUS_SIGN",countryCallingCode:o,number:c}}return{number:e}}r=!0,e="+"+s}if("0"===e[1])return{};n=new Ig(n);for(var d=2;d-1<=mg&&d<=e.length;){var l=e.slice(1,d);if(n.hasCallingCode(l))return n.selectNumberingPlan(l),{countryCallingCodeSource:r?"FROM_NUMBER_WITH_IDD":"FROM_NUMBER_WITH_PLUS_SIGN",countryCallingCode:l,number:e.slice(d)};d++}return{}}function Hf(e,t){var i="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(i)return(i=i.call(e)).next.bind(i);if(Array.isArray(e)||(i=function(e,t){if(!e)return;if("string"==typeof e)return Lf(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);"Object"===i&&e.constructor&&(i=e.constructor.name);if("Map"===i||"Set"===i)return Array.from(e);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return Lf(e,t)}(e))||t&&e&&"number"==typeof e.length){i&&(e=i);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Lf(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i<t;i++)n[i]=e[i];return n}function jf(e,t){var i=t.countries,n=t.defaultCountry,r=t.metadata;r=new Ig(r);for(var s,a=[],o=Hf(i);!(s=o()).done;){var c=s.value;if(r.country(c),r.leadingDigits()){if(e&&0===e.search(r.leadingDigits()))return c}else if(lf({phone:e,country:c},void 0,r.metadata)){if(!n)return c;if(c===n)return c;a.push(c)}}if(a.length>0)return a[0]}var Bf=!1;function Uf(e,t){var i=t.nationalNumber,n=t.defaultCountry,r=t.metadata;if(Bf&&r.isNonGeographicCallingCode(e))return"001";var s=r.getCountryCodesForCallingCode(e);return s?1===s.length?s[0]:jf(i,{countries:s,defaultCountry:n,metadata:r.metadata}):void 0}var Vf="+",qf="(["+vg+"]|[\\-\\.\\(\\)]?)",Gf=new RegExp("^\\"+Vf+qf+"*["+vg+"]"+qf+"*$","g"),Kf=new RegExp("^("+("["+vg+"]+((\\-)*["+vg+"])*")+"\\.)*"+("[a-zA-Z]+((\\-)*["+vg+"])*")+"\\.?$","g"),Wf="tel:",zf=";phone-context=",Yf=";isub=";function Jf(e,t){var i,n=t.extractFormattedPhoneNumber,r=function(e){var t=e.indexOf(zf);if(t<0)return null;var i=t+zf.length;if(i>=e.length)return"";var n=e.indexOf(";",i);return n>=0?e.substring(i,n):e.substring(i)}(e);if(!function(e){return null===e||0!==e.length&&(Gf.test(e)||Kf.test(e))}(r))throw new pg("NOT_A_NUMBER");if(null===r)i=n(e)||"";else{i="",r.charAt(0)===Vf&&(i+=r);var s,a=e.indexOf(Wf);s=a>=0?a+Wf.length:0;var o=e.indexOf(zf);i+=e.substring(s,o)}var c=i.indexOf(Yf);if(c>0&&(i=i.substring(0,c)),""!==i)return i}var Zf=250,Xf=new RegExp("[++"+vg+"]"),Qf=new RegExp("[^"+vg+"#]+$");function em(e,t,i){if(t=t||{},i=new Ig(i),t.defaultCountry&&!i.hasCountry(t.defaultCountry)){if(t.v2)throw new pg("INVALID_COUNTRY");throw new Error("Unknown country: ".concat(t.defaultCountry))}var n=function(e,t,i){var n=Jf(e,{extractFormattedPhoneNumber:function(e){return function(e,t,i){if(!e)return;if(e.length>Zf){if(i)throw new pg("TOO_LONG");return}if(!1===t)return e;var n=e.search(Xf);if(n<0)return;return e.slice(n).replace(Qf,"")}(e,i,t)}});if(!n)return{};if(!function(e){return e.length>=gg&&Vg.test(e)}(n))return function(e){return Bg.test(e)}(n)?{error:"TOO_SHORT"}:{};var r=function(e){var t=e.search(qg);if(t<0)return{};for(var i=e.slice(0,t),n=e.match(qg),r=1;r<n.length;){if(n[r])return{number:i,ext:n[r]};r++}}(n);if(r.ext)return r;return{number:n}}(e,t.v2,t.extract),r=n.number,s=n.ext,a=n.error;if(!r){if(t.v2){if("TOO_SHORT"===a)throw new pg("TOO_SHORT");throw new pg("NOT_A_NUMBER")}return{}}var o=function(e,t,i,n){var r,s=Mf(Xg(e),t,i,n.metadata),a=s.countryCallingCodeSource,o=s.countryCallingCode,c=s.number;if(o)n.selectNumberingPlan(o);else{if(!c||!t&&!i)return{};n.selectNumberingPlan(t,i),t&&(r=t),o=i||Og(t,n.metadata)}if(!c)return{countryCallingCodeSource:a,countryCallingCode:o};var d=Of(Xg(c),n),l=d.nationalNumber,h=d.carrierCode,u=Uf(o,{nationalNumber:l,defaultCountry:t,metadata:n});u&&(r=u,"001"===u||n.country(r));return{country:r,countryCallingCode:o,countryCallingCodeSource:a,nationalNumber:l,carrierCode:h}}(r,t.defaultCountry,t.defaultCallingCode,i),c=o.country,d=o.nationalNumber,l=o.countryCallingCode,h=o.countryCallingCodeSource,u=o.carrierCode;if(!i.hasSelectedNumberingPlan()){if(t.v2)throw new pg("INVALID_COUNTRY");return{}}if(!d||d.length<gg){if(t.v2)throw new pg("TOO_SHORT");return{}}if(d.length>fg){if(t.v2)throw new pg("TOO_LONG");return{}}if(t.v2){var p=new Af(l,d,i.metadata);return c&&(p.country=c),u&&(p.carrierCode=u),s&&(p.ext=s),p.__countryCallingCodeSource=h,p}var g=!!(t.extended?i.hasSelectedNumberingPlan():c)&&af(d,i.nationalNumberPattern());return t.extended?{country:c,countryCallingCode:l,carrierCode:u,valid:g,possible:!!g||!(!0!==t.extended||!i.possibleLengths()||!sf(d,i)),phone:d,ext:s}:g?function(e,t,i){var n={country:e,phone:t};i&&(n.ext=i);return n}(c,d,s):{}}function tm(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function im(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?tm(Object(i),!0).forEach((function(t){nm(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):tm(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function nm(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function rm(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function sm(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function am(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==i)return;var n,r,s=[],a=!0,o=!1;try{for(i=i.call(e);!(a=(n=i.next()).done)&&(s.push(n.value),!t||s.length!==t);a=!0);}catch(e){o=!0,r=e}finally{try{a||null==i.return||i.return()}finally{if(o)throw r}}return s}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return om(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);"Object"===i&&e.constructor&&(i=e.constructor.name);if("Map"===i||"Set"===i)return Array.from(e);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return om(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function om(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i<t;i++)n[i]=e[i];return n}function cm(e){var t,i,n,r=am(Array.prototype.slice.call(e),4),s=r[0],a=r[1],o=r[2],c=r[3];if("string"!=typeof s)throw new TypeError("A text for parsing must be a string.");if(t=s,a&&"string"!=typeof a){if(!wg(a))throw new Error("Invalid second argument: ".concat(a));o?(i=a,n=o):n=a}else c?(i=o,n=c):(i=void 0,n=o),a&&(i=function(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?rm(Object(i),!0).forEach((function(t){sm(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):rm(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}({defaultCountry:a},i));return{text:t,options:i,metadata:n}}function dm(){var e=cm(arguments);return function(e,t,i){return em(e,im(im({},t),{},{v2:!0}),i)}(e.text,e.options,e.metadata)}function lm(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var hm=function(){function e(t){var i=t.onCountryChange,n=t.onCallingCodeChange;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.onCountryChange=i,this.onCallingCodeChange=n}var t,i,n;return t=e,(i=[{key:"reset",value:function(e){var t=e.country,i=e.callingCode;this.international=!1,this.missingPlus=!1,this.IDDPrefix=void 0,this.callingCode=void 0,this.digits="",this.resetNationalSignificantNumber(),this.initCountryAndCallingCode(t,i)}},{key:"resetNationalSignificantNumber",value:function(){this.nationalSignificantNumber=this.getNationalDigits(),this.nationalSignificantNumberMatchesInput=!0,this.nationalPrefix=void 0,this.carrierCode=void 0,this.complexPrefixBeforeNationalSignificantNumber=void 0}},{key:"update",value:function(e){for(var t=0,i=Object.keys(e);t<i.length;t++){var n=i[t];this[n]=e[n]}}},{key:"initCountryAndCallingCode",value:function(e,t){this.setCountry(e),this.setCallingCode(t)}},{key:"setCountry",value:function(e){this.country=e,this.onCountryChange(e)}},{key:"setCallingCode",value:function(e){this.callingCode=e,this.onCallingCodeChange(e,this.country)}},{key:"startInternationalNumber",value:function(e,t){this.international=!0,this.initCountryAndCallingCode(e,t)}},{key:"appendDigits",value:function(e){this.digits+=e}},{key:"appendNationalSignificantNumberDigits",value:function(e){this.nationalSignificantNumber+=e}},{key:"getNationalDigits",value:function(){return this.international?this.digits.slice((this.IDDPrefix?this.IDDPrefix.length:0)+(this.callingCode?this.callingCode.length:0)):this.digits}},{key:"getDigitsWithoutInternationalPrefix",value:function(){return this.international&&this.IDDPrefix?this.digits.slice(this.IDDPrefix.length):this.digits}}])&&lm(t.prototype,i),n&&lm(t,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();function um(e,t){var i="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(i)return(i=i.call(e)).next.bind(i);if(Array.isArray(e)||(i=function(e,t){if(!e)return;if("string"==typeof e)return pm(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);"Object"===i&&e.constructor&&(i=e.constructor.name);if("Map"===i||"Set"===i)return Array.from(e);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return pm(e,t)}(e))||t&&e&&"number"==typeof e.length){i&&(e=i);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function pm(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i<t;i++)n[i]=e[i];return n}var gm="x",fm=new RegExp(gm);function mm(e,t){if(t<1)return"";for(var i="";t>1;)1&t&&(i+=e),t>>=1,e+=e;return i+e}function vm(e,t){return")"===e[t]&&t++,function(e){var t=[],i=0;for(;i<e.length;)"("===e[i]?t.push(i):")"===e[i]&&t.pop(),i++;var n=0,r="";t.push(e.length);for(var s=0,a=t;s<a.length;s++){var o=a[s];r+=e.slice(n,o),n=o+1}return r}(e.slice(0,t))}function ym(e,t,i){var n=i.metadata,r=i.shouldTryNationalPrefixFormattingRule,s=i.getSeparatorAfterNationalPrefix;if(new RegExp("^(?:".concat(t.pattern(),")$")).test(e.nationalSignificantNumber))return function(e,t,i){var n=i.metadata,r=i.shouldTryNationalPrefixFormattingRule,s=i.getSeparatorAfterNationalPrefix;if(e.nationalSignificantNumber,e.international,e.nationalPrefix,e.carrierCode,r(t)){var a=Sm(e,t,{useNationalPrefixFormattingRule:!0,getSeparatorAfterNationalPrefix:s,metadata:n});if(a)return a}return Sm(e,t,{useNationalPrefixFormattingRule:!1,getSeparatorAfterNationalPrefix:s,metadata:n})}(e,t,{metadata:n,shouldTryNationalPrefixFormattingRule:r,getSeparatorAfterNationalPrefix:s})}function Sm(e,t,i){var n=i.metadata,r=i.useNationalPrefixFormattingRule,s=i.getSeparatorAfterNationalPrefix,a=ff(e.nationalSignificantNumber,t,{carrierCode:e.carrierCode,useInternationalFormat:e.international,withNationalPrefix:r,metadata:n});if(r||(e.nationalPrefix?a=e.nationalPrefix+s(t)+a:e.complexPrefixBeforeNationalSignificantNumber&&(a=e.complexPrefixBeforeNationalSignificantNumber+" "+a)),function(e,t){return Yg(e)===t.getNationalDigits()}(a,e))return a}function bm(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var wm=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}var t,i,n;return t=e,(i=[{key:"parse",value:function(e){if(this.context=[{or:!0,instructions:[]}],this.parsePattern(e),1!==this.context.length)throw new Error("Non-finalized contexts left when pattern parse ended");var t=this.context[0],i=t.branches,n=t.instructions;if(i)return{op:"|",args:i.concat([$m(n)])};if(0===n.length)throw new Error("Pattern is required");return 1===n.length?n[0]:n}},{key:"startContext",value:function(e){this.context.push(e)}},{key:"endContext",value:function(){this.context.pop()}},{key:"getContext",value:function(){return this.context[this.context.length-1]}},{key:"parsePattern",value:function(e){if(!e)throw new Error("Pattern is required");var t=e.match(Tm);if(t){var i=t[1],n=e.slice(0,t.index),r=e.slice(t.index+i.length);switch(i){case"(?:":n&&this.parsePattern(n),this.startContext({or:!0,instructions:[],branches:[]});break;case")":if(!this.getContext().or)throw new Error('")" operator must be preceded by "(?:" operator');if(n&&this.parsePattern(n),0===this.getContext().instructions.length)throw new Error('No instructions found after "|" operator in an "or" group');var s=this.getContext().branches;s.push($m(this.getContext().instructions)),this.endContext(),this.getContext().instructions.push({op:"|",args:s});break;case"|":if(!this.getContext().or)throw new Error('"|" operator can only be used inside "or" groups');if(n&&this.parsePattern(n),!this.getContext().branches){if(1!==this.context.length)throw new Error('"branches" not found in an "or" group context');this.getContext().branches=[]}this.getContext().branches.push($m(this.getContext().instructions)),this.getContext().instructions=[];break;case"[":n&&this.parsePattern(n),this.startContext({oneOfSet:!0});break;case"]":if(!this.getContext().oneOfSet)throw new Error('"]" operator must be preceded by "[" operator');this.endContext(),this.getContext().instructions.push({op:"[]",args:Em(n)});break;default:throw new Error("Unknown operator: ".concat(i))}r&&this.parsePattern(r)}else{if(Cm.test(e))throw new Error("Illegal characters found in a pattern: ".concat(e));this.getContext().instructions=this.getContext().instructions.concat(e.split(""))}}}])&&bm(t.prototype,i),n&&bm(t,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();function Em(e){for(var t=[],i=0;i<e.length;){if("-"===e[i]){if(0===i||i===e.length-1)throw new Error("Couldn't parse a one-of set pattern: ".concat(e));for(var n=e[i-1].charCodeAt(0)+1,r=e[i+1].charCodeAt(0)-1,s=n;s<=r;)t.push(String.fromCharCode(s)),s++}else t.push(e[i]);i++}return t}var Cm=/[\(\)\[\]\?\:\|]/,Tm=new RegExp("(\\||\\(\\?\\:|\\)|\\[|\\])");function $m(e){return 1===e.length?e[0]:e}function _m(e,t){var i="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(i)return(i=i.call(e)).next.bind(i);if(Array.isArray(e)||(i=function(e,t){if(!e)return;if("string"==typeof e)return xm(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);"Object"===i&&e.constructor&&(i=e.constructor.name);if("Map"===i||"Set"===i)return Array.from(e);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return xm(e,t)}(e))||t&&e&&"number"==typeof e.length){i&&(e=i);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function xm(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i<t;i++)n[i]=e[i];return n}function Im(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var Rm=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.matchTree=(new wm).parse(t)}var t,i,n;return t=e,i=[{key:"match",value:function(e){var t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).allowOverflow;if(!e)throw new Error("String is required");var i=Am(e.split(""),this.matchTree,!0);if(i&&i.match&&delete i.matchedChars,!i||!i.overflow||t)return i}}],i&&Im(t.prototype,i),n&&Im(t,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();function Am(e,t,i){if("string"==typeof t){var n=e.join("");return 0===t.indexOf(n)?e.length===t.length?{match:!0,matchedChars:e}:{partialMatch:!0}:0===n.indexOf(t)?i&&e.length>t.length?{overflow:!0}:{match:!0,matchedChars:e.slice(0,t.length)}:void 0}if(Array.isArray(t)){for(var r=e.slice(),s=0;s<t.length;){var a=Am(r,t[s],i&&s===t.length-1);if(!a)return;if(a.overflow)return a;if(!a.match){if(a.partialMatch)return{partialMatch:!0};throw new Error("Unsupported match result:\n".concat(JSON.stringify(a,null,2)))}if(0===(r=r.slice(a.matchedChars.length)).length)return s===t.length-1?{match:!0,matchedChars:e}:{partialMatch:!0};s++}return i?{overflow:!0}:{match:!0,matchedChars:e.slice(0,e.length-r.length)}}switch(t.op){case"|":for(var o,c,d=_m(t.args);!(c=d()).done;){var l=Am(e,c.value,i);if(l){if(l.overflow)return l;if(l.match)return{match:!0,matchedChars:l.matchedChars};if(!l.partialMatch)throw new Error("Unsupported match result:\n".concat(JSON.stringify(l,null,2)));o=!0}}return o?{partialMatch:!0}:void 0;case"[]":for(var h,u=_m(t.args);!(h=u()).done;){var p=h.value;if(e[0]===p)return 1===e.length?{match:!0,matchedChars:e}:i?{overflow:!0}:{match:!0,matchedChars:[p]}}return;default:throw new Error("Unsupported instruction tree: ".concat(t))}}function Pm(e,t){var i="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(i)return(i=i.call(e)).next.bind(i);if(Array.isArray(e)||(i=function(e,t){if(!e)return;if("string"==typeof e)return Dm(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);"Object"===i&&e.constructor&&(i=e.constructor.name);if("Map"===i||"Set"===i)return Array.from(e);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return Dm(e,t)}(e))||t&&e&&"number"==typeof e.length){i&&(e=i);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Dm(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i<t;i++)n[i]=e[i];return n}function Nm(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var km=mm("9",15),Om=/[- ]/,Fm=new RegExp("["+yg+"]*\\$1["+yg+"]*(\\$\\d["+yg+"]*)*$"),Mm=function(){function e(t){t.state;var i=t.metadata;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.metadata=i,this.resetFormat()}var t,i,n;return t=e,i=[{key:"resetFormat",value:function(){this.chosenFormat=void 0,this.template=void 0,this.nationalNumberTemplate=void 0,this.populatedNationalNumberTemplate=void 0,this.populatedNationalNumberTemplatePosition=-1}},{key:"reset",value:function(e,t){this.resetFormat(),e?(this.isNANP="1"===e.callingCode(),this.matchingFormats=e.formats(),t.nationalSignificantNumber&&this.narrowDownMatchingFormats(t)):(this.isNANP=void 0,this.matchingFormats=[])}},{key:"format",value:function(e,t){var i=this;if(function(e,t){return"IS_POSSIBLE"===nf(e,t)}(t.nationalSignificantNumber,this.metadata))for(var n,r=Pm(this.matchingFormats);!(n=r()).done;){var s=n.value,a=ym(t,s,{metadata:this.metadata,shouldTryNationalPrefixFormattingRule:function(e){return i.shouldTryNationalPrefixFormattingRule(e,{international:t.international,nationalPrefix:t.nationalPrefix})},getSeparatorAfterNationalPrefix:function(e){return i.getSeparatorAfterNationalPrefix(e)}});if(a)return this.resetFormat(),this.chosenFormat=s,this.setNationalNumberTemplate(a.replace(/\d/g,gm),t),this.populatedNationalNumberTemplate=a,this.populatedNationalNumberTemplatePosition=this.template.lastIndexOf(gm),a}return this.formatNationalNumberWithNextDigits(e,t)}},{key:"formatNationalNumberWithNextDigits",value:function(e,t){var i=this.chosenFormat,n=this.chooseFormat(t);if(n)return n===i?this.formatNextNationalNumberDigits(e):this.formatNextNationalNumberDigits(t.getNationalDigits())}},{key:"narrowDownMatchingFormats",value:function(e){var t=this,i=e.nationalSignificantNumber,n=e.nationalPrefix,r=e.international,s=i,a=s.length-3;a<0&&(a=0),this.matchingFormats=this.matchingFormats.filter((function(e){return t.formatSuits(e,r,n)&&t.formatMatches(e,s,a)})),this.chosenFormat&&-1===this.matchingFormats.indexOf(this.chosenFormat)&&this.resetFormat()}},{key:"formatSuits",value:function(e,t,i){return!(i&&!e.usesNationalPrefix()&&!e.nationalPrefixIsOptionalWhenFormattingInNationalFormat()||!t&&!i&&e.nationalPrefixIsMandatoryWhenFormattingInNationalFormat())}},{key:"formatMatches",value:function(e,t,i){var n=e.leadingDigitsPatterns().length;if(0===n)return!0;i=Math.min(i,n-1);var r=e.leadingDigitsPatterns()[i];if(t.length<3)try{return void 0!==new Rm(r).match(t,{allowOverflow:!0})}catch(e){return console.error(e),!0}return new RegExp("^(".concat(r,")")).test(t)}},{key:"getFormatFormat",value:function(e,t){return t?e.internationalFormat():e.format()}},{key:"chooseFormat",value:function(e){for(var t,i=this,n=function(){var n=t.value;return i.chosenFormat===n?"break":Fm.test(i.getFormatFormat(n,e.international))?i.createTemplateForFormat(n,e)?(i.chosenFormat=n,"break"):(i.matchingFormats=i.matchingFormats.filter((function(e){return e!==n})),"continue"):"continue"},r=Pm(this.matchingFormats.slice());!(t=r()).done;){var s=n();if("break"===s)break}return this.chosenFormat||this.resetFormat(),this.chosenFormat}},{key:"createTemplateForFormat",value:function(e,t){if(!(e.pattern().indexOf("|")>=0)){var i=this.getTemplateForFormat(e,t);return i?(this.setNationalNumberTemplate(i,t),!0):void 0}}},{key:"getSeparatorAfterNationalPrefix",value:function(e){return this.isNANP||e&&e.nationalPrefixFormattingRule()&&Om.test(e.nationalPrefixFormattingRule())?" ":""}},{key:"getInternationalPrefixBeforeCountryCallingCode",value:function(e,t){var i=e.IDDPrefix,n=e.missingPlus;return i?t&&!1===t.spacing?i:i+" ":n?"":"+"}},{key:"getTemplate",value:function(e){if(this.template){for(var t=-1,i=0,n=e.international?this.getInternationalPrefixBeforeCountryCallingCode(e,{spacing:!1}):"";i<n.length+e.getDigitsWithoutInternationalPrefix().length;)t=this.template.indexOf(gm,t+1),i++;return vm(this.template,t+1)}}},{key:"setNationalNumberTemplate",value:function(e,t){this.nationalNumberTemplate=e,this.populatedNationalNumberTemplate=e,this.populatedNationalNumberTemplatePosition=-1,t.international?this.template=this.getInternationalPrefixBeforeCountryCallingCode(t).replace(/[\d\+]/g,gm)+mm(gm,t.callingCode.length)+" "+e:this.template=e}},{key:"getTemplateForFormat",value:function(e,t){var i=t.nationalSignificantNumber,n=t.international,r=t.nationalPrefix,s=t.complexPrefixBeforeNationalSignificantNumber,a=e.pattern();a=a.replace(/\[([^\[\]])*\]/g,"\\d").replace(/\d(?=[^,}][^,}])/g,"\\d");var o=km.match(a)[0];if(!(i.length>o.length)){var c=new RegExp("^"+a+"$"),d=i.replace(/\d/g,"9");c.test(d)&&(o=d);var l,h=this.getFormatFormat(e,n);if(this.shouldTryNationalPrefixFormattingRule(e,{international:n,nationalPrefix:r})){var u=h.replace(gf,e.nationalPrefixFormattingRule());if(Yg(e.nationalPrefixFormattingRule())===(r||"")+Yg("$1")&&(h=u,l=!0,r))for(var p=r.length;p>0;)h=h.replace(/\d/,gm),p--}var g=o.replace(new RegExp(a),h).replace(new RegExp("9","g"),gm);return l||(s?g=mm(gm,s.length)+" "+g:r&&(g=mm(gm,r.length)+this.getSeparatorAfterNationalPrefix(e)+g)),n&&(g=pf(g)),g}}},{key:"formatNextNationalNumberDigits",value:function(e){var t=function(e,t,i){for(var n,r=um(i.split(""));!(n=r()).done;){var s=n.value;if(e.slice(t+1).search(fm)<0)return;t=e.search(fm),e=e.replace(fm,s)}return[e,t]}(this.populatedNationalNumberTemplate,this.populatedNationalNumberTemplatePosition,e);if(t)return this.populatedNationalNumberTemplate=t[0],this.populatedNationalNumberTemplatePosition=t[1],vm(this.populatedNationalNumberTemplate,this.populatedNationalNumberTemplatePosition+1);this.resetFormat()}},{key:"shouldTryNationalPrefixFormattingRule",value:function(e,t){var i=t.international,n=t.nationalPrefix;if(e.nationalPrefixFormattingRule()){var r=e.usesNationalPrefix();if(r&&n||!r&&!i)return!0}}}],i&&Nm(t.prototype,i),n&&Nm(t,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();function Hm(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==i)return;var n,r,s=[],a=!0,o=!1;try{for(i=i.call(e);!(a=(n=i.next()).done)&&(s.push(n.value),!t||s.length!==t);a=!0);}catch(e){o=!0,r=e}finally{try{a||null==i.return||i.return()}finally{if(o)throw r}}return s}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return Lm(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);"Object"===i&&e.constructor&&(i=e.constructor.name);if("Map"===i||"Set"===i)return Array.from(e);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return Lm(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Lm(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i<t;i++)n[i]=e[i];return n}function jm(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var Bm=new RegExp("^"+("["+yg+vg+"]+")+"$","i"),Um="(?:[++]["+yg+vg+"]*|["+yg+vg+"]+)",Vm=new RegExp("[^"+yg+vg+"]+.*$"),qm=/[^\d\[\]]/,Gm=function(){function e(t){var i=t.defaultCountry,n=t.defaultCallingCode,r=t.metadata,s=t.onNationalSignificantNumberChange;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.defaultCountry=i,this.defaultCallingCode=n,this.metadata=r,this.onNationalSignificantNumberChange=s}var t,i,n;return t=e,(i=[{key:"input",value:function(e,t){var i,n=function(e){var t=function(e){var t=function(e){var t,i=e.search(Um);if(!(i<0))return"+"===(e=e.slice(i))[0]&&(t=!0,e=e.slice(1)),e=e.replace(Vm,""),t&&(e="+"+e),e}(e)||"";return"+"===t[0]?[t.slice(1),!0]:[t]}(e),i=Hm(t,2),n=i[0],r=i[1];return Bm.test(n)||(n=""),[n,r]}(e),r=Hm(n,2),s=r[0],a=r[1],o=Yg(s);return a&&(t.digits||(t.startInternationalNumber(),o||(i=!0))),o&&this.inputDigits(o,t),{digits:o,justLeadingPlus:i}}},{key:"inputDigits",value:function(e,t){var i=t.digits,n=i.length<3&&i.length+e.length>=3;if(t.appendDigits(e),n&&this.extractIddPrefix(t),this.isWaitingForCountryCallingCode(t)){if(!this.extractCountryCallingCode(t))return}else t.appendNationalSignificantNumberDigits(e);t.international||this.hasExtractedNationalSignificantNumber||this.extractNationalSignificantNumber(t.getNationalDigits(),(function(e){return t.update(e)}))}},{key:"isWaitingForCountryCallingCode",value:function(e){var t=e.international,i=e.callingCode;return t&&!i}},{key:"extractCountryCallingCode",value:function(e){var t=Mf("+"+e.getDigitsWithoutInternationalPrefix(),this.defaultCountry,this.defaultCallingCode,this.metadata.metadata),i=t.countryCallingCode,n=t.number;if(i)return e.setCallingCode(i),e.update({nationalSignificantNumber:n}),!0}},{key:"reset",value:function(e){if(e){this.hasSelectedNumberingPlan=!0;var t=e._nationalPrefixForParsing();this.couldPossiblyExtractAnotherNationalSignificantNumber=t&&qm.test(t)}else this.hasSelectedNumberingPlan=void 0,this.couldPossiblyExtractAnotherNationalSignificantNumber=void 0}},{key:"extractNationalSignificantNumber",value:function(e,t){if(this.hasSelectedNumberingPlan){var i=kf(e,this.metadata),n=i.nationalPrefix,r=i.nationalNumber,s=i.carrierCode;if(r!==e)return this.onExtractedNationalNumber(n,s,r,e,t),!0}}},{key:"extractAnotherNationalSignificantNumber",value:function(e,t,i){if(!this.hasExtractedNationalSignificantNumber)return this.extractNationalSignificantNumber(e,i);if(this.couldPossiblyExtractAnotherNationalSignificantNumber){var n=kf(e,this.metadata),r=n.nationalPrefix,s=n.nationalNumber,a=n.carrierCode;if(s!==t)return this.onExtractedNationalNumber(r,a,s,e,i),!0}}},{key:"onExtractedNationalNumber",value:function(e,t,i,n,r){var s,a,o=n.lastIndexOf(i);if(o>=0&&o===n.length-i.length){a=!0;var c=n.slice(0,o);c!==e&&(s=c)}r({nationalPrefix:e,carrierCode:t,nationalSignificantNumber:i,nationalSignificantNumberMatchesInput:a,complexPrefixBeforeNationalSignificantNumber:s}),this.hasExtractedNationalSignificantNumber=!0,this.onNationalSignificantNumberChange()}},{key:"reExtractNationalSignificantNumber",value:function(e){return!!this.extractAnotherNationalSignificantNumber(e.getNationalDigits(),e.nationalSignificantNumber,(function(t){return e.update(t)}))||(this.extractIddPrefix(e)||this.fixMissingPlus(e)?(this.extractCallingCodeAndNationalSignificantNumber(e),!0):void 0)}},{key:"extractIddPrefix",value:function(e){var t=e.international,i=e.IDDPrefix,n=e.digits;if(e.nationalSignificantNumber,!t&&!i){var r=Nf(n,this.defaultCountry,this.defaultCallingCode,this.metadata.metadata);return void 0!==r&&r!==n?(e.update({IDDPrefix:n.slice(0,n.length-r.length)}),this.startInternationalNumber(e,{country:void 0,callingCode:void 0}),!0):void 0}}},{key:"fixMissingPlus",value:function(e){if(!e.international){var t=Ff(e.digits,this.defaultCountry,this.defaultCallingCode,this.metadata.metadata),i=t.countryCallingCode;if(t.number,i)return e.update({missingPlus:!0}),this.startInternationalNumber(e,{country:e.country,callingCode:i}),!0}}},{key:"startInternationalNumber",value:function(e,t){var i=t.country,n=t.callingCode;e.startInternationalNumber(i,n),e.nationalSignificantNumber&&(e.resetNationalSignificantNumber(),this.onNationalSignificantNumberChange(),this.hasExtractedNationalSignificantNumber=void 0)}},{key:"extractCallingCodeAndNationalSignificantNumber",value:function(e){this.extractCountryCallingCode(e)&&this.extractNationalSignificantNumber(e.getNationalDigits(),(function(t){return e.update(t)}))}}])&&jm(t.prototype,i),n&&jm(t,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();function Km(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==i)return;var n,r,s=[],a=!0,o=!1;try{for(i=i.call(e);!(a=(n=i.next()).done)&&(s.push(n.value),!t||s.length!==t);a=!0);}catch(e){o=!0,r=e}finally{try{a||null==i.return||i.return()}finally{if(o)throw r}}return s}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return Wm(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);"Object"===i&&e.constructor&&(i=e.constructor.name);if("Map"===i||"Set"===i)return Array.from(e);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return Wm(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Wm(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i<t;i++)n[i]=e[i];return n}function zm(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var Ym=function(){function e(t,i){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.metadata=new Ig(i);var n=Km(this.getCountryAndCallingCode(t),2),r=n[0],s=n[1];this.defaultCountry=r,this.defaultCallingCode=s,this.reset()}var t,i,n;return t=e,i=[{key:"getCountryAndCallingCode",value:function(e){var t,i;return e&&(wg(e)?(t=e.defaultCountry,i=e.defaultCallingCode):t=e),t&&!this.metadata.hasCountry(t)&&(t=void 0),[t,i]}},{key:"input",value:function(e){var t=this.parser.input(e,this.state),i=t.digits;if(t.justLeadingPlus)this.formattedOutput="+";else if(i){var n;if(this.determineTheCountryIfNeeded(),this.state.nationalSignificantNumber&&this.formatter.narrowDownMatchingFormats(this.state),this.metadata.hasSelectedNumberingPlan()&&(n=this.formatter.format(i,this.state)),void 0===n&&this.parser.reExtractNationalSignificantNumber(this.state)){this.determineTheCountryIfNeeded();var r=this.state.getNationalDigits();r&&(n=this.formatter.format(r,this.state))}this.formattedOutput=n?this.getFullNumber(n):this.getNonFormattedNumber()}return this.formattedOutput}},{key:"reset",value:function(){var e=this;return this.state=new hm({onCountryChange:function(t){e.country=t},onCallingCodeChange:function(t,i){e.metadata.selectNumberingPlan(i,t),e.formatter.reset(e.metadata.numberingPlan,e.state),e.parser.reset(e.metadata.numberingPlan)}}),this.formatter=new Mm({state:this.state,metadata:this.metadata}),this.parser=new Gm({defaultCountry:this.defaultCountry,defaultCallingCode:this.defaultCallingCode,metadata:this.metadata,state:this.state,onNationalSignificantNumberChange:function(){e.determineTheCountryIfNeeded(),e.formatter.reset(e.metadata.numberingPlan,e.state)}}),this.state.reset({country:this.defaultCountry,callingCode:this.defaultCallingCode}),this.formattedOutput="",this}},{key:"isInternational",value:function(){return this.state.international}},{key:"getCallingCode",value:function(){if(this.isInternational())return this.state.callingCode}},{key:"getCountryCallingCode",value:function(){return this.getCallingCode()}},{key:"getCountry",value:function(){if(this.state.digits)return this._getCountry()}},{key:"_getCountry",value:function(){return this.state.country}},{key:"determineTheCountryIfNeeded",value:function(){this.state.country&&!this.isCountryCallingCodeAmbiguous()||this.determineTheCountry()}},{key:"getFullNumber",value:function(e){var t=this;if(this.isInternational()){var i=function(e){return t.formatter.getInternationalPrefixBeforeCountryCallingCode(t.state,{spacing:!!e})+e},n=this.state.callingCode;return i(n?e?"".concat(n," ").concat(e):n:"".concat(this.state.getDigitsWithoutInternationalPrefix()))}return e}},{key:"getNonFormattedNationalNumberWithPrefix",value:function(){var e=this.state,t=e.nationalSignificantNumber,i=e.complexPrefixBeforeNationalSignificantNumber,n=e.nationalPrefix,r=t,s=i||n;return s&&(r=s+r),r}},{key:"getNonFormattedNumber",value:function(){var e=this.state.nationalSignificantNumberMatchesInput;return this.getFullNumber(e?this.getNonFormattedNationalNumberWithPrefix():this.state.getNationalDigits())}},{key:"getNonFormattedTemplate",value:function(){var e=this.getNonFormattedNumber();if(e)return e.replace(/[\+\d]/g,gm)}},{key:"isCountryCallingCodeAmbiguous",value:function(){var e=this.state.callingCode,t=this.metadata.getCountryCodesForCallingCode(e);return t&&t.length>1}},{key:"determineTheCountry",value:function(){this.state.setCountry(Uf(this.isInternational()?this.state.callingCode:this.defaultCallingCode,{nationalNumber:this.state.nationalSignificantNumber,defaultCountry:this.defaultCountry,metadata:this.metadata}))}},{key:"getNumberValue",value:function(){var e=this.state,t=e.digits,i=e.callingCode,n=e.country,r=e.nationalSignificantNumber;if(t)return this.isInternational()?i?"+"+i+r:"+"+t:n||i?"+"+(n?this.metadata.countryCallingCode():i)+r:void 0}},{key:"getNumber",value:function(){var e=this.state,t=e.nationalSignificantNumber,i=e.carrierCode,n=e.callingCode,r=this._getCountry();if(t&&(r||n)){if(r&&r===this.defaultCountry){var s=new Ig(this.metadata.metadata);s.selectNumberingPlan(r);var a=s.numberingPlan.callingCode(),o=this.metadata.getCountryCodesForCallingCode(a);if(o.length>1){var c=jf(t,{countries:o,defaultCountry:this.defaultCountry,metadata:this.metadata.metadata});c&&(r=c)}}var d=new Af(r||n,t,this.metadata.metadata);return i&&(d.carrierCode=i),d}}},{key:"isPossible",value:function(){var e=this.getNumber();return!!e&&e.isPossible()}},{key:"isValid",value:function(){var e=this.getNumber();return!!e&&e.isValid()}},{key:"getNationalNumber",value:function(){return this.state.nationalSignificantNumber}},{key:"getChars",value:function(){return(this.state.international?"+":"")+this.state.digits}},{key:"getTemplate",value:function(){return this.formatter.getTemplate(this.state)||this.getNonFormattedTemplate()||""}}],i&&zm(t.prototype,i),n&&zm(t,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();function Jm(){return function(e,t){var i=Array.prototype.slice.call(t);return i.push(ng),e.apply(this,i)}(dm,arguments)}function Zm(e){return Ym.call(this,e,ng)}Zm.prototype=Object.create(Ym.prototype,{}),Zm.prototype.constructor=Zm;const Xm=/[^+*\d]/g,Qm=["US","FR","GB","AU"],ev=(e,t,i=Qm)=>{const n=[...new Set([t,...i])].filter(Boolean);let r;for(let t=0;t<n.length;t++){if(r=Jm(e,n[t]),r.isValid())break}return r},tv=(e,t,i=!1,n=Qm)=>{if(!e)return e;const r=String(e);if(!(e=>!(!e||e.length<=5||e.includes("#")||e.includes("*")||e.match(/[aA-zZ]/)))(r))return r;let s="";if(i)s=new Zm(t).input(r);else try{const i=ev(r,t,n);i?.isValid()?(a=String(i.country),o=t,s="US"===a&&"CA"===o||"US"===o&&"CA"===a||a===o?i.formatNational():i.formatInternational()):s=e}catch(t){s=e}var a,o;return s},iv=e=>e.replace(Xm,"");e.AdHocAPIConference=Tn,e.Agent=en,e.ApiCall=fi,e.ApiRequester=G,e.BadResponse=b,e.COUNTRIES={AUSTRALIA:"AU",BELGIUM:"BE",CANADA:"CA",FRANCE:"FR",GERMANY:"DE",ISRAEL:"IL",ITALY:"IT",LUXEMBOURG:"LU",MALAYSIA:"MY",MONACO:"MC",NETHERLANDS:"NL",POLAND:"PL",PORTUGAL:"PT",UNITED_KINGDOM:"GB",UNITED_STATES:"US",SPAIN:"ES",SWITZERLAND:"CH"},e.CTIPhone=Bi,e.Call=Kp,e.CallApi=Hi,e.CallLog=Yi,e.CallSession=yi,e.CallerID=ri,e.ChatMessage=pi,e.ChatRoom=Ji,e.Checker=gh,e.Contact=Xt,e.DebugDevice=class{connectToCall(){console.info("DebugDevice - Connected to call")}disconnectFromCall(){console.info("DebugDevice - Disconnected from call")}ringback(){console.info("DebugDevice - Ringback")}stopRingback(){console.info("DebugDevice - Stop ringback")}playRingtone(){console.info("DebugDevice - Play ringtone")}stopRingtone(){console.info("DebugDevice - Stop ringtone")}mute(){console.info("DebugDevice - Mute")}unmute(){console.info("DebugDevice - Unmute")}putOnSpeaker(){console.info("DebugDevice - Put on speaker")}putOffSpeaker(){console.info("DebugDevice - Put off speaker")}},e.Emitter=Mi,e.ExternalApp=oi,e.FORWARD_KEYS=qt,e.Features=ah,e.ForwardOption=Gt,e.Incall=Kt,e.IndirectTransfer=Xi,e.InvalidState=sp,e.InvalidStateTransition=Hp,e.IssueReporter=B,e.LINE_STATE=zt,e.Line=Vt,e.Meeting=ci,e.MeetingAuthorization=di,e.MeetingStatus=Qi,e.NotificationOptions=th,e.PROFILE_STATE=Wt,e.Profile=Yt,e.Recording=zi,e.Relocation=ui,e.Room=ih,e.SFUNotAvailableError=Xc,e.SOCKET_EVENTS=gd,e.ServerError=w,e.Session=ti,e.SessionDescriptionHandler=Ks,e.SipLine=ai,e.Softphone=Qp,e.SwitchboardCall=nh,e.Voicemail=gi,e.WazoApiClient=rn,e.WebRTCClient=Zc,e.WebRTCPhone=vo,e.WebSocketClient=Dl,e.camelToUnderscore=I,e.default=ig,e.getApiClient=gn,e.getCallableNumber=(e,t)=>{try{const i=t?tv(e,t):e;return iv(i)}catch(t){return e}},e.getDisplayableNumber=tv,e.guessParsePhoneNumber=ev,e.obfuscateToken=R,e.parsePhoneNumber=iv,e.setApiToken=on,e.setCurrentServer=an,e.setIsMobile=(e,t=null)=>{global.wazoIsMobile[String(t)]=e},e.setOnRefreshToken=dn,e.setOnRefreshTokenError=ln,Object.defineProperty(e,"__esModule",{value:!0})}));
42
+ ***************************************************************************** */function ad(e,t){function i(){this.constructor=e}sd(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}function od(e,t){var i="function"==typeof Symbol&&e[Symbol.iterator];if(!i)return e;var n,r,s=i.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=s.next()).done;)a.push(n.value)}catch(e){r={error:e}}finally{try{n&&!n.done&&(i=s.return)&&i.call(s)}finally{if(r)throw r.error}}return a}var cd=function(e,t){this.target=t,this.type=e},dd=function(e){function t(t,i){var n=e.call(this,"error",i)||this;return n.message=t.message,n.error=t,n}return ad(t,e),t}(cd),ld=function(e){function t(t,i,n){void 0===t&&(t=1e3),void 0===i&&(i="");var r=e.call(this,"close",n)||this;return r.wasClean=!0,r.code=t,r.reason=i,r}return ad(t,e),t}(cd),hd=function(){if("undefined"!=typeof WebSocket)return WebSocket},ud={maxReconnectionDelay:1e4,minReconnectionDelay:1e3+4e3*Math.random(),minUptime:5e3,reconnectionDelayGrowFactor:1.3,connectionTimeout:4e3,maxRetries:1/0,maxEnqueuedMessages:1/0,startClosed:!1,debug:!1},pd=function(){function e(e,t,i){var n=this;void 0===i&&(i={}),this._listeners={error:[],message:[],open:[],close:[]},this._retryCount=-1,this._shouldReconnect=!0,this._connectLock=!1,this._binaryType="blob",this._closeCalled=!1,this._messageQueue=[],this.onclose=null,this.onerror=null,this.onmessage=null,this.onopen=null,this._handleOpen=function(e){n._debug("open event");var t=n._options.minUptime,i=void 0===t?ud.minUptime:t;clearTimeout(n._connectTimeout),n._uptimeTimeout=setTimeout((function(){return n._acceptOpen()}),i),n._ws.binaryType=n._binaryType,n._messageQueue.forEach((function(e){return n._ws.send(e)})),n._messageQueue=[],n.onopen&&n.onopen(e),n._listeners.open.forEach((function(t){return n._callEventListener(e,t)}))},this._handleMessage=function(e){n._debug("message event"),n.onmessage&&n.onmessage(e),n._listeners.message.forEach((function(t){return n._callEventListener(e,t)}))},this._handleError=function(e){n._debug("error event",e.message),n._disconnect(void 0,"TIMEOUT"===e.message?"timeout":void 0),n.onerror&&n.onerror(e),n._debug("exec error listeners"),n._listeners.error.forEach((function(t){return n._callEventListener(e,t)})),n._connect()},this._handleClose=function(e){n._debug("close event"),n._clearTimeouts(),n._shouldReconnect&&n._connect(),n.onclose&&n.onclose(e),n._listeners.close.forEach((function(t){return n._callEventListener(e,t)}))},this._url=e,this._protocols=t,this._options=i,this._options.startClosed&&(this._shouldReconnect=!1),this._connect()}return Object.defineProperty(e,"CONNECTING",{get:function(){return 0},enumerable:!0,configurable:!0}),Object.defineProperty(e,"OPEN",{get:function(){return 1},enumerable:!0,configurable:!0}),Object.defineProperty(e,"CLOSING",{get:function(){return 2},enumerable:!0,configurable:!0}),Object.defineProperty(e,"CLOSED",{get:function(){return 3},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"CONNECTING",{get:function(){return e.CONNECTING},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"OPEN",{get:function(){return e.OPEN},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"CLOSING",{get:function(){return e.CLOSING},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"CLOSED",{get:function(){return e.CLOSED},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"binaryType",{get:function(){return this._ws?this._ws.binaryType:this._binaryType},set:function(e){this._binaryType=e,this._ws&&(this._ws.binaryType=e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"retryCount",{get:function(){return Math.max(this._retryCount,0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"bufferedAmount",{get:function(){return this._messageQueue.reduce((function(e,t){return"string"==typeof t?e+=t.length:t instanceof Blob?e+=t.size:e+=t.byteLength,e}),0)+(this._ws?this._ws.bufferedAmount:0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"extensions",{get:function(){return this._ws?this._ws.extensions:""},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"protocol",{get:function(){return this._ws?this._ws.protocol:""},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"readyState",{get:function(){return this._ws?this._ws.readyState:this._options.startClosed?e.CLOSED:e.CONNECTING},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"url",{get:function(){return this._ws?this._ws.url:""},enumerable:!0,configurable:!0}),e.prototype.close=function(e,t){void 0===e&&(e=1e3),this._closeCalled=!0,this._shouldReconnect=!1,this._clearTimeouts(),this._ws?this._ws.readyState!==this.CLOSED?this._ws.close(e,t):this._debug("close: already closed"):this._debug("close enqueued: no ws instance")},e.prototype.reconnect=function(e,t){this._shouldReconnect=!0,this._closeCalled=!1,this._retryCount=-1,this._ws&&this._ws.readyState!==this.CLOSED?(this._disconnect(e,t),this._connect()):this._connect()},e.prototype.send=function(e){if(this._ws&&this._ws.readyState===this.OPEN)this._debug("send",e),this._ws.send(e);else{var t=this._options.maxEnqueuedMessages,i=void 0===t?ud.maxEnqueuedMessages:t;this._messageQueue.length<i&&(this._debug("enqueue",e),this._messageQueue.push(e))}},e.prototype.addEventListener=function(e,t){this._listeners[e]&&this._listeners[e].push(t)},e.prototype.dispatchEvent=function(e){var t,i,n=this._listeners[e.type];if(n)try{for(var r=function(e){var t="function"==typeof Symbol&&e[Symbol.iterator],i=0;return t?t.call(e):{next:function(){return e&&i>=e.length&&(e=void 0),{value:e&&e[i++],done:!e}}}}(n),s=r.next();!s.done;s=r.next()){var a=s.value;this._callEventListener(e,a)}}catch(e){t={error:e}}finally{try{s&&!s.done&&(i=r.return)&&i.call(r)}finally{if(t)throw t.error}}return!0},e.prototype.removeEventListener=function(e,t){this._listeners[e]&&(this._listeners[e]=this._listeners[e].filter((function(e){return e!==t})))},e.prototype._debug=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._options.debug&&console.log.apply(console,function(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(od(arguments[t]));return e}(["RWS>"],e))},e.prototype._getNextDelay=function(){var e=this._options,t=e.reconnectionDelayGrowFactor,i=void 0===t?ud.reconnectionDelayGrowFactor:t,n=e.minReconnectionDelay,r=void 0===n?ud.minReconnectionDelay:n,s=e.maxReconnectionDelay,a=void 0===s?ud.maxReconnectionDelay:s,o=0;return this._retryCount>0&&(o=r*Math.pow(i,this._retryCount-1))>a&&(o=a),this._debug("next delay",o),o},e.prototype._wait=function(){var e=this;return new Promise((function(t){setTimeout(t,e._getNextDelay())}))},e.prototype._getNextUrl=function(e){if("string"==typeof e)return Promise.resolve(e);if("function"==typeof e){var t=e();if("string"==typeof t)return Promise.resolve(t);if(t.then)return t}throw Error("Invalid URL")},e.prototype._connect=function(){var e=this;if(!this._connectLock&&this._shouldReconnect){this._connectLock=!0;var t=this._options,i=t.maxRetries,n=void 0===i?ud.maxRetries:i,r=t.connectionTimeout,s=void 0===r?ud.connectionTimeout:r,a=t.WebSocket,o=void 0===a?hd():a;if(this._retryCount>=n)this._debug("max retries reached",this._retryCount,">=",n);else{if(this._retryCount++,this._debug("connect",this._retryCount),this._removeListeners(),void 0===(c=o)||!c||2!==c.CLOSING)throw Error("No valid WebSocket class provided");var c;this._wait().then((function(){return e._getNextUrl(e._url)})).then((function(t){e._closeCalled||(e._debug("connect",{url:t,protocols:e._protocols}),e._ws=e._protocols?new o(t,e._protocols):new o(t),e._ws.binaryType=e._binaryType,e._connectLock=!1,e._addListeners(),e._connectTimeout=setTimeout((function(){return e._handleTimeout()}),s))}))}}},e.prototype._handleTimeout=function(){this._debug("timeout event"),this._handleError(new dd(Error("TIMEOUT"),this))},e.prototype._disconnect=function(e,t){if(void 0===e&&(e=1e3),this._clearTimeouts(),this._ws){this._removeListeners();try{this._ws.close(e,t),this._handleClose(new ld(e,t,this))}catch(e){}}},e.prototype._acceptOpen=function(){this._debug("accept open"),this._retryCount=0},e.prototype._callEventListener=function(e,t){"handleEvent"in t?t.handleEvent(e):t(e)},e.prototype._removeListeners=function(){this._ws&&(this._debug("removeListeners"),this._ws.removeEventListener("open",this._handleOpen),this._ws.removeEventListener("close",this._handleClose),this._ws.removeEventListener("message",this._handleMessage),this._ws.removeEventListener("error",this._handleError))},e.prototype._addListeners=function(){this._ws&&(this._debug("addListeners"),this._ws.addEventListener("open",this._handleOpen),this._ws.addEventListener("close",this._handleClose),this._ws.addEventListener("message",this._handleMessage),this._ws.addEventListener("error",this._handleError))},e.prototype._clearTimeouts=function(){clearTimeout(this._connectTimeout),clearTimeout(this._uptimeTimeout)},e}();const gd={ON_OPEN:"onopen",ON_MESSAGE:"onmessage",ON_ERROR:"onerror",ON_CLOSE:"onclose",INITIALIZED:"initialized",ON_AUTH_FAILED:"on_auth_failed"},fd="auth_session_expire_soon",md="favorite_added",vd="favorite_deleted",yd="user_status_update",Sd="chat_message_sent",bd="chat_message_received",wd="endpoint_status_update",Ed="users_forwards_busy_updated",Cd="users_forwards_noanswer_updated",Td="users_forwards_unconditional_updated",$d="users_services_dnd_updated",_d="user_voicemail_message_created",xd="user_voicemail_message_updated",Id="user_voicemail_message_deleted",Rd="call_log_user_created",Ad="call_created",Pd="call_answered",Dd="call_dtmf_created",Nd="call_ended",kd="call_updated",Od="call_held",Fd="call_resumed",Md="auth_user_external_auth_added",Hd="auth_user_external_auth_deleted",Ld="chatd_presence_updated",jd="chatd_user_room_message_created",Bd="chatd_user_room_created",Ud="conference_user_participant_joined",Vd="conference_user_participant_left",qd="conference_user_participant_talk_started",Gd="conference_user_participant_talk_stopped",Kd="meeting_user_participant_joined",Wd="meeting_user_participant_left",zd="switchboard_queued_calls_updated",Yd="switchboard_queued_call_answered",Jd="switchboard_held_calls_updated",Zd="switchboard_held_call_answered",Xd="fax_outbound_user_created",Qd="fax_outbound_user_succeeded",el="fax_outbound_user_failed",tl="application_call_dtmf_received",il="application_call_entered",nl="application_call_initiated",rl="application_call_deleted",sl="application_call_updated",al="application_call_answered",ol="application_progress_started",cl="application_progress_stopped",dl="application_destination_node_created",ll="application_node_created",hl="application_node_deleted",ul="application_node_updated",pl="application_playback_created",gl="application_playback_deleted",fl="application_snoop_created",ml="application_snoop_deleted",vl="application_snoop_updated",yl="application_user_outgoing_call_created",Sl="trunk_status_updated",bl="line_status_updated",wl="agent_status_update",El="agent_paused",Cl="agent_unpaused",Tl="conference_adhoc_participant_left",$l="conference_adhoc_deleted",_l="meeting_user_progress",xl="meeting_user_guest_authorization_created",Il=[Sd,bd,jd,Bd],Rl="20.09",Al=B.loggerFor("wazo-ws"),Pl=B.loggerFor("wazo-ws-message");class Dl extends Mi{initialized;session;host;version;token;events;options;socket;_boundOnHeartbeat;heartbeat;onHeartBeatTimeout;heartbeatCb;eventLists;static eventLists;constructor({host:e,token:t,version:i,events:n,heartbeat:r,session:s},a={host:e,token:t,version:1,events:[],heartbeat:{},session:null}){super(),this.initialized=!1,this.socket=null,this.host=e,this.token=t,this.events=n,this.options=a,this.version=i,this.session=s,this._boundOnHeartbeat=this._onHeartbeat.bind(this);const{delay:o,timeout:c,max:d}=r||{};this.heartbeat=new _c(o,c,d),this.heartbeat.setSendHeartbeat(this.pingServer.bind(this)),this.heartbeat.setOnHeartbeatTimeout(this._onHeartbeatTimeout.bind(this)),this.eventLists=Dl.eventLists}connect(){Al.info("connect method started",{host:this.host,token:R(this.token)}),this.socket=new pd(this._getUrl.bind(this),[],this.options),this.options.binaryType&&(this.socket.binaryType=this.options.binaryType),this.socket.onopen=()=>{Al.info("on Wazo WS open",{method:"connect",host:this.host}),this.eventEmitter.emit(gd.ON_OPEN)},this.socket.onerror=e=>{Al.error("on Wazo WS error",e.target),this.eventEmitter.emit(gd.ON_ERROR,e)},this.socket.onmessage=e=>{this.eventEmitter.emit(gd.ON_MESSAGE,e.data);const t=JSON.parse("string"==typeof e.data?e.data:"{}");let{name:i}=t;t.data&&t.data.name&&(i=t.data.name),-1===Il.indexOf(i)?Pl.trace(B.removeSlashes(e.data),{method:"onmessage"}):Pl.trace(`{"name": "${i}", "info": "content not shown"}`,{method:"onmessage"}),this.initialized?this._handleMessage(t):this._handleInitMessage(t,this.socket)},this.socket.onclose=e=>{if(Al.info("on Wazo WS close",{reason:e.reason,code:e.code,readyState:e.target.readyState,host:this.host,token:R(this.token)}),this.initialized=!1,this.eventEmitter.emit(gd.ON_CLOSE,e),4002===e.code)this.eventEmitter.emit(gd.ON_AUTH_FAILED)},this.socket.onerror=e=>{Al.info("Wazo WS error",{message:e.message,code:e.code,readyState:e.target.readyState})}}close(e=!1){Al.info("Wazo WS close",{socket:!!this.socket,host:this.host,token:R(this.token)}),this.socket&&(3!==this.socket.readyState?(this.socket.close(1e3),this.initialized=!1,e&&(this.host=null,this.token=null,this.socket=null)):Al.warn("Trying to close an already closed websocket, bailing.",{url:this._getUrl()}))}updateToken(e){this.token=e,Al.info("Wazo WS updating token",{url:this._getUrl(),token:R(e),socket:!!this.socket}),this.socket&&(this.isConnected()&&Number(this.version)>=2?this.socket.send(JSON.stringify({op:"token",data:{token:e}})):this.isConnected()||this.reconnect("token refreshed"))}hasHeartbeat(){return this.heartbeat.hasHeartbeat}startHeartbeat(){Al.info("Wazo WS start heartbeat",{host:this.host,token:R(this.token)}),this.socket?(this.off("pong",this._boundOnHeartbeat),this.on("pong",this._boundOnHeartbeat),this.heartbeat.start()):this.heartbeat.stop()}stopHeartbeat(){Al.info("Wazo WS stop heartbeat",{host:this.host,token:R(this.token)}),this.heartbeat.stop()}setOnHeartbeatTimeout(e){this.onHeartBeatTimeout=e}setOnHeartbeatCallback(e){this.heartbeatCb=e}pingServer(){if(this.socket&&this.isConnected())try{this.socket.send(JSON.stringify({op:"ping",data:{payload:"pong"}}))}catch(e){}}isConnected(){return this.socket&&this.socket.readyState===this.socket.OPEN}reconnect(e){Al.info("Wazo WS reconnect",{reason:e,socket:!!this.socket,host:this.host,token:R(this.token)}),this.socket&&this.socket.reconnect(0,e)}_handleInitMessage(e,t){switch(e.op){case"init":this.events?.forEach((e=>{const i={op:"subscribe",data:{event_name:e}};t.send(JSON.stringify(i))})),t.send(JSON.stringify({op:"start"}));break;case"subscribe":break;case"start":this.initialized=!0,this.eventEmitter.emit(gd.INITIALIZED);break;default:this.eventEmitter.emit("message",e)}}_handleMessage(e){if("pong"===e.op)return this.eventEmitter.emit("pong",e.data),void(this.heartbeatCb&&this.heartbeatCb());1!==this.version?Number(this.version)>=2&&"event"===e.op&&this.eventEmitter.emit(e.data.name,e.data):this.eventEmitter.emit(e.name,e)}_getUrl(){this.host&&this.token||this.close();let e=`wss://${this.host||""}/api/websocketd/?token=${this.token||""}&version=${this.version}`;return this.session&&(e+=`&userUuid=${this.session.uuid}`),Al.info("Wazo WS url computed to reconnect",{url:e.replace(this.token,R(this.token))}),e}_onHeartbeat(e){"pong"===e.payload&&(this.heartbeat.onHeartbeat(),Al.log("on heartbeat received from Wazo WS"))}async _onHeartbeatTimeout(){Al.log("heartbeat timed out",{host:this.host,token:R(this.token)}),this.close(),this.eventEmitter.emit(gd.ON_CLOSE,new Error("Websocket ping failure.")),this.onHeartBeatTimeout&&this.onHeartBeatTimeout()}}Dl.eventLists=[fd,md,vd,yd,Sd,bd,wd,Ed,Cd,Td,$d,_d,xd,Id,Rd,Pd,Ad,Dd,Nd,kd,Od,Fd,Md,Hd,Ld,jd,Bd,Ud,Vd,Kd,Wd,qd,Gd,zd,Yd,Jd,Zd,Xd,Qd,el,tl,il,nl,rl,sl,al,ol,cl,dl,ll,hl,ul,pl,gl,fl,ml,vl,yl,Sl,bl,wl,El,Cl,Tl,$l,_l,xl];var Nl=Object.freeze({__proto__:null,AGENT_PAUSED:El,AGENT_STATUS_UPDATE:wl,AGENT_UNPAUSED:Cl,APPLICATION_CALL_ANSWERED:al,APPLICATION_CALL_DELETED:rl,APPLICATION_CALL_DTMF_RECEIVED:tl,APPLICATION_CALL_ENTERED:il,APPLICATION_CALL_INITIATED:nl,APPLICATION_CALL_UPDATED:sl,APPLICATION_DESTINATION_NODE_CREATED:dl,APPLICATION_NODE_CREATED:ll,APPLICATION_NODE_DELETED:hl,APPLICATION_NODE_UPDATED:ul,APPLICATION_PLAYBACK_CREATED:pl,APPLICATION_PLAYBACK_DELETED:gl,APPLICATION_PROGRESS_STARTED:ol,APPLICATION_PROGRESS_STOPPED:cl,APPLICATION_SNOOP_CREATED:fl,APPLICATION_SNOOP_DELETED:ml,APPLICATION_SNOOP_UPDATED:vl,APPLICATION_USER_OUTGOING_CALL_CREATED:yl,AUTH_SESSION_EXPIRE_SOON:fd,AUTH_USER_EXTERNAL_AUTH_ADDED:Md,AUTH_USER_EXTERNAL_AUTH_DELETED:Hd,CALL_ANSWERED:Pd,CALL_CREATED:Ad,CALL_DTMF_CREATED:Dd,CALL_ENDED:Nd,CALL_HELD:Od,CALL_LOG_USER_CREATED:Rd,CALL_RESUMED:Fd,CALL_UPDATED:kd,CHATD_PRESENCE_UPDATED:Ld,CHATD_USER_ROOM_CREATED:Bd,CHATD_USER_ROOM_MESSAGE_CREATED:jd,CHAT_MESSAGE_RECEIVED:bd,CHAT_MESSAGE_SENT:Sd,CONFERENCE_ADHOC_DELETED:$l,CONFERENCE_ADHOC_PARTICIPANT_LEFT:Tl,CONFERENCE_USER_PARTICIPANT_JOINED:Ud,CONFERENCE_USER_PARTICIPANT_LEFT:Vd,CONFERENCE_USER_PARTICIPANT_TALK_STARTED:qd,CONFERENCE_USER_PARTICIPANT_TALK_STOPPED:Gd,ENDPOINT_STATUS_UPDATE:wd,FAVORITE_ADDED:md,FAVORITE_DELETED:vd,FAX_OUTBOUND_USER_CREATED:Xd,FAX_OUTBOUND_USER_FAILED:el,FAX_OUTBOUND_USER_SUCCEEDED:Qd,HEARTBEAT_ENGINE_VERSION:Rl,LINE_STATUS_UPDATED:bl,MEETING_USER_GUEST_AUTHORIZATION_CREATED:xl,MEETING_USER_PARTICIPANT_JOINED:Kd,MEETING_USER_PARTICIPANT_LEFT:Wd,MEETING_USER_PROGRESS:_l,SOCKET_EVENTS:gd,SWITCHBOARD_HELD_CALLS_UPDATED:Jd,SWITCHBOARD_HELD_CALL_ANSWERED:Zd,SWITCHBOARD_QUEUED_CALLS_UPDATED:zd,SWITCHBOARD_QUEUED_CALL_ANSWERED:Yd,TRUNK_STATUS_UPDATED:Sl,USERS_FORWARDS_BUSY_UPDATED:Ed,USERS_FORWARDS_NOANSWER_UPDATED:Cd,USERS_FORWARDS_UNCONDITIONAL_UPDATED:Td,USERS_SERVICES_DND_UPDATED:$d,USER_STATUS_UPDATE:yd,USER_VOICEMAIL_MESSAGE_CREATED:_d,USER_VOICEMAIL_MESSAGE_DELETED:Id,USER_VOICEMAIL_MESSAGE_UPDATED:xd,default:Dl});const{SOCKET_EVENTS:kl,...Ol}=Nl,Fl=[...Object.values(kl),...Object.values(Ol)],Ml=B.loggerFor("simple-ws-client");class Hl extends Mi{ws;eventLists;CONFERENCE_USER_PARTICIPANT_JOINED;CONFERENCE_USER_PARTICIPANT_LEFT;MEETING_USER_PARTICIPANT_JOINED;MEETING_USER_PARTICIPANT_LEFT;CALL_CREATED;constructor(){super(),Object.keys(Ol).forEach((e=>{this[e]=Ol[e]})),Object.keys(kl).forEach((e=>{this[e]=kl[e]})),this.eventLists=Dl.eventLists,this.ws=null}open(e,t){Ml.info("open simple WebSocket",{host:e,token:R(t.token)}),this.ws=new Dl({host:e,token:t.token,events:["*"],version:2,session:t},{rejectUnauthorized:!1,binaryType:"arraybuffer"}),this.ws.connect(),Fl.forEach((e=>{this.ws&&this.ws.on(e,(t=>{this.eventEmitter.emit(e,t)}))}))}updateToken(e){Ml.info("update token via simple Websocket",{token:e,ws:!!this.ws}),this.ws&&this.ws.updateToken(e)}isOpen(){return this.ws?.isConnected()||!1}close(e=!1){Ml.info("Closing event transport websocket",{force:e,ws:!!this.ws}),this.ws&&this.ws.close(e),this.unbind()}}global.wazoWebsocketInstance||(global.wazoWebsocketInstance=new Hl);var Ll=global.wazoWebsocketInstance;const jl=B.loggerFor("room");class Bl extends Mi{room;uuid;name;number;callId;isTalking;streams;videoStreams;audioMuted;videoMuted;screensharing;isOnHold;banned;extra;ON_UPDATED;ON_START_TALKING;ON_STOP_TALKING;ON_DISCONNECT;ON_STREAM_SUBSCRIBED;ON_STREAM_UNSUBSCRIBED;ON_AUDIO_MUTED;ON_AUDIO_UNMUTED;ON_VIDEO_MUTED;ON_VIDEO_UNMUTED;ON_SCREENSHARING;ON_STOP_SCREENSHARING;ON_EXTRA_CHANGE;ON_HOLD;ON_RESUME;ON_BAN;constructor(e,t,i={}){super(),this.room=e,this.uuid=t.user_uuid,this.name=(t.caller_id_name||"").replace("\\'","'"),this.number=t.caller_id_number,this.callId=t.call_id,this.isTalking=!1,this.streams=[],this.videoStreams=[],this.audioMuted=!1,this.videoMuted=!1,this.screensharing=!1,this.isOnHold=!1,this.extra=i,this.banned=!1,this.ON_UPDATED="participant/ON_UPDATED",this.ON_START_TALKING="participant/ON_START_TALKING",this.ON_STOP_TALKING="participant/ON_STOP_TALKING",this.ON_DISCONNECT="participant/ON_DISCONNECT",this.ON_STREAM_SUBSCRIBED="participant/ON_STREAM_SUBSCRIBED",this.ON_STREAM_UNSUBSCRIBED="participant/ON_STREAM_UNSUBSCRIBED",this.ON_AUDIO_MUTED="participant/ON_AUDIO_MUTED",this.ON_AUDIO_UNMUTED="participant/ON_AUDIO_UNMUTED",this.ON_VIDEO_MUTED="participant/ON_VIDEO_MUTED",this.ON_VIDEO_UNMUTED="participant/ON_VIDEO_UNMUTED",this.ON_SCREENSHARING="participant/ON_SCREENSHARING",this.ON_STOP_SCREENSHARING="participant/ON_STOP_SCREENSHARING",this.ON_EXTRA_CHANGE="participant/ON_EXTRA_CHANGE",this.ON_HOLD="participant/ON_HOLD",this.ON_RESUME="participant/ON_RESUME",this.ON_BAN="participant/ON_BAN"}triggerEvent(e,...t){this.eventEmitter.emit.apply(this.eventEmitter,[e,...t]),this.eventEmitter.emit.apply(this.eventEmitter,[this.ON_UPDATED,...t])}triggerUpdate(e,t=!0){const i={callId:this.callId};switch(e){case this.ON_START_TALKING:case this.ON_STOP_TALKING:i.isTalking=this.isTalking;break;case this.ON_AUDIO_MUTED:case this.ON_AUDIO_UNMUTED:i.audioMuted=this.audioMuted;break;case this.ON_VIDEO_MUTED:case this.ON_VIDEO_UNMUTED:i.videoMuted=this.videoMuted;break;case this.ON_SCREENSHARING:case this.ON_STOP_SCREENSHARING:i.screensharing=this.screensharing;break;case this.ON_HOLD:case this.ON_RESUME:i.isOnHold=this.isOnHold;break;case this.ON_EXTRA_CHANGE:i.extra=this.extra;break;case this.ON_BAN:i.banned=!0}t&&this.broadcastStatus(i),this.eventEmitter.emit(e,i),this.eventEmitter.emit(this.ON_UPDATED,e,i)}onTalking(e){jl.info("on participant talking",{name:this.name,isTalking:e,callId:this.callId}),this.isTalking=e,this.triggerUpdate(this.isTalking?this.ON_START_TALKING:this.ON_STOP_TALKING,!1)}onDisconnect(){return this.triggerEvent(this.ON_DISCONNECT)}onStreamSubscribed(e){return this.triggerEvent(this.ON_STREAM_SUBSCRIBED,e)}onStreamUnSubscribed(e){return this.triggerEvent(this.ON_STREAM_UNSUBSCRIBED,e)}onAudioMuted(e=!0){this.audioMuted||(this.audioMuted=!0,this.triggerUpdate(this.ON_AUDIO_MUTED,e))}onAudioUnMuted(e=!0){this.audioMuted&&(this.audioMuted=!1,this.triggerUpdate(this.ON_AUDIO_UNMUTED,e))}onVideoMuted(e=!0){this.videoMuted||(this.videoMuted=!0,this.triggerUpdate(this.ON_VIDEO_MUTED,e))}onVideoUnMuted(e=!0){this.videoMuted&&(this.videoMuted=!1,this.triggerUpdate(this.ON_VIDEO_UNMUTED,e))}onScreensharing(e=!0){this.screensharing||(this.screensharing=!0,this.triggerUpdate(this.ON_SCREENSHARING,e))}onStopScreensharing(e=!0){this.screensharing&&(this.screensharing=!1,this.triggerUpdate(this.ON_STOP_SCREENSHARING,e))}onHold(e=!0){this.isOnHold||(this.isOnHold=!0,this.triggerUpdate(this.ON_HOLD,e))}onResume(e=!0){this.isOnHold&&(this.isOnHold=!1,this.triggerUpdate(this.ON_RESUME,e))}onBan(e=!0){this.banned=!0,this.triggerUpdate(this.ON_BAN,e)}getStatus(){return{callId:this.callId,audioMuted:this.audioMuted,videoMuted:this.videoMuted,screensharing:this.screensharing,isTalking:this.isTalking,extra:this.extra}}updateStatus(e,t=!0){jl.info("updating participant status",{name:this.name,status:e}),void 0!==e.audioMuted&&e.audioMuted!==this.audioMuted&&(e.audioMuted?this.onAudioMuted(t):this.onAudioUnMuted(t)),void 0!==e.videoMuted&&e.videoMuted!==this.videoMuted&&(e.videoMuted?this.onVideoMuted(t):this.onVideoUnMuted(t)),void 0!==e.screensharing&&e.screensharing!==this.screensharing&&(e.screensharing?this.onScreensharing(t):this.onStopScreensharing(t)),void 0!==e.isOnHold&&e.isOnHold!==this.isOnHold&&(e.isOnHold?this.onHold(t):this.onResume(t)),e.banned&&this.onBan(!1),void 0!==e.extra&&JSON.stringify(this.extra)!==JSON.stringify(e.extra)&&(this.extra={...this.extra,...e.extra},!this.extra.contact||this.extra.contact instanceof Xt||(this.extra.contact=new Xt(this.extra.contact)),this.triggerUpdate(this.ON_EXTRA_CHANGE,t))}broadcastStatus(e=null,t=null){const i=e||this.getStatus();jl.info("broadcasting participant status",{callId:this.callId,status:i}),t&&!this.streams.length&&rd.phone&&rd.phone._sendReinviteMessage(this.room?.callSession,!1),this.room?.sendSignal({type:Vl,origin:this.callId,status:i})}resetStreams(e){this.streams=e,this.videoStreams=e}async ban(e=null){const{meetingUuid:t}=this.room||{};if(!t)throw new Error("Attempting to ban a participant without a `meetingUuid`");return this.onBan(!0),e&&await this.delay(e),gn().calld.banMeetingParticipant(t,this.callId)}async delay(e){return new Promise((t=>setTimeout(t,e)))}}class Ul extends Bl{constructor(e,t,i={}){super(e,t,i),"<unknown>"===this.name&&(this.name=String(this.number))}}const Vl="signal/PARTICIPANT_UPDATE",ql="signal/PARTICIPANT_REQUEST",Gl=B.loggerFor("sdk-room");let Kl=class e extends Mi{callSession;name;extension;sourceId;meetingUuid;participants;callId;connected;localParticipant;_callIdStreamIdMap;_unassociatedVideoStreams;_unassociatedParticipants;_boundOnParticipantJoined;_boundOnParticipantLeft;_boundOnMessage;_boundOnChat;_boundOnSignal;_boundSaveLocalVideoStream;_boundOnReinvite;audioStream;extra;roomAudioElement;CONFERENCE_USER_PARTICIPANT_JOINED;CONFERENCE_USER_PARTICIPANT_LEFT;MEETING_USER_PARTICIPANT_JOINED;MEETING_USER_PARTICIPANT_LEFT;ON_SHARE_SCREEN_ENDED;ON_MESSAGE;ON_CHAT;ON_SIGNAL;ON_AUDIO_STREAM;ON_VIDEO_STREAM;ON_REMOVE_STREAM;ON_DISCONNECTED;ON_JOINED;ON_VIDEO_INPUT_CHANGE;constructor(e,t,i,n,r,s={}){super(),Gl.info("room initialized",{callId:n,extension:t,sourceId:i,meetingUuid:r}),this.callSession=e,this.extension=t,this.sourceId=i,this.meetingUuid=r,this.callId=n,this.participants=[],this.connected=!1,this.localParticipant=null,this._callIdStreamIdMap={},this._unassociatedVideoStreams={},this._unassociatedParticipants={},this.audioStream=null,this.extra=s,this.CONFERENCE_USER_PARTICIPANT_JOINED=ig.Websocket.CONFERENCE_USER_PARTICIPANT_JOINED,this.CONFERENCE_USER_PARTICIPANT_LEFT=ig.Websocket.CONFERENCE_USER_PARTICIPANT_LEFT,this.MEETING_USER_PARTICIPANT_JOINED=ig.Websocket.MEETING_USER_PARTICIPANT_JOINED,this.MEETING_USER_PARTICIPANT_LEFT=ig.Websocket.MEETING_USER_PARTICIPANT_LEFT,this.ON_SHARE_SCREEN_ENDED=ig.Phone.ON_SHARE_SCREEN_ENDED,this.ON_MESSAGE=ig.Phone.ON_MESSAGE,this.ON_CHAT=ig.Phone.ON_CHAT,this.ON_SIGNAL=ig.Phone.ON_SIGNAL,this.ON_AUDIO_STREAM=ig.Phone.ON_AUDIO_STREAM,this.ON_VIDEO_STREAM=ig.Phone.ON_VIDEO_STREAM,this.ON_REMOVE_STREAM=ig.Phone.ON_REMOVE_STREAM,this.ON_VIDEO_INPUT_CHANGE=ig.Phone.ON_VIDEO_INPUT_CHANGE,this.ON_DISCONNECTED="room/ON_DISCONNECTED",this.ON_JOINED="room/ON_JOINED",this._boundOnParticipantJoined=this._onParticipantJoined.bind(this),this._boundOnParticipantLeft=this._onParticipantLeft.bind(this),this._boundOnMessage=this._onMessage.bind(this),this._boundOnChat=this._onChat.bind(this),this._boundOnSignal=this._onSignal.bind(this),this._boundSaveLocalVideoStream=this._saveLocalVideoStream.bind(this),this._boundOnReinvite=this._onReinvite.bind(this),this.unbind(),this._bindEvents(),this._transferEvents()}static async connect({extension:t,constraints:i,audioOnly:n=!1,extra:r,room:s,meeting:a}){if(Gl.info("connecting to room",{extension:t,audioOnly:n,room:!!s}),!s){await ig.Phone.connect({media:i});const a=i&&!!i.video;a&&ig.Phone.checkSfu(),ig.Websocket.once(ig.Websocket.CALL_CREATED,(({data:e})=>{Gl.info("room call received via WS",{callId:e.call_id}),s&&s.setCallId(e.call_id)}));const o=await ig.Phone.call(t,a,null,n,!0);s=new e(o,t,null,null,null,r),await new Promise(((e,t)=>{ig.Phone.once(ig.Phone.ON_CALL_ACCEPTED,e),ig.Phone.once(ig.Phone.ON_CALL_FAILED,t)}))}if(s&&s.callSession&&s.callSession.call&&s.setCallId(s.callSession.call.id),a)a&&(Gl.info("Already connected to meeting",{uuid:a.uuid,name:a.name}),s.setMeetingUuid(a.uuid),s.setName(a.name));else{const e=await gn().dird.fetchConferenceSource("default"),i=await gn().dird.fetchConferenceContacts(e.items[0]),n=i?.find((e=>e.numbers?.find((e=>String(e.number)===String(t)))));Gl.info("connected to room",{sourceId:n?n.sourceId:null,name:n?n.name:null}),n&&(s.setSourceId(parseInt(`${n.sourceId}`,10)),s.setName(`${n.name}`))}return s}static disconnect(){Gl.info("static disconnection to room"),ig.Phone.disconnect()}async disconnect(){Gl.info("disconnection to room called"),await ig.Phone.hangup(this.callSession),this.callSession=void 0,this.eventEmitter.emit(this.ON_DISCONNECTED,this),this.connected=!1,this.unbind(),ig.Phone.off(this.ON_MESSAGE,this._boundOnMessage),ig.Phone.off(this.ON_CHAT,this._boundOnChat),ig.Phone.off(this.ON_SIGNAL,this._boundOnSignal),ig.Phone.off(this.ON_VIDEO_INPUT_CHANGE,this._boundSaveLocalVideoStream),ig.Phone.phone?.off(ig.Phone.phone.client.ON_REINVITE,this._boundOnReinvite),ig.Websocket.off(this.CONFERENCE_USER_PARTICIPANT_JOINED,this._boundOnParticipantJoined),ig.Websocket.off(this.CONFERENCE_USER_PARTICIPANT_LEFT,this._boundOnParticipantLeft),ig.Websocket.off(this.MEETING_USER_PARTICIPANT_JOINED,this._boundOnParticipantJoined),ig.Websocket.off(this.MEETING_USER_PARTICIPANT_LEFT,this._boundOnParticipantLeft)}setSourceId(e){Gl.info("set room source id",{sourceId:e}),this.sourceId=e}setMeetingUuid(e){Gl.info("set meeting uuid",{meetingUuid:e}),this.meetingUuid=e}setCallId(e){Gl.info("set room call id",{callId:e}),e&&(this.callId=e)}setName(e){Gl.info("set room name",{name:e}),this.name=e}sendMessage(e,t=null){return ig.Phone.sendMessage(e,t)}sendChat(e){return ig.Phone.sendChat(e)}sendSignal(e){return ig.Phone.sendSignal(e)}async startScreenSharing(e){Gl.info("start room screen sharing",{constraints:e});const t=await ig.Phone.startScreenSharing(e,this.callSession);return t?(this._onScreenSharing(),t):(console.warn("screensharing stream is null (likely due to user cancellation)"),null)}async stopScreenSharing(e=!0){Gl.info("stop room screen sharing"),await ig.Phone.stopScreenSharing(this.callSession,e),this.localParticipant&&(this._updateLocalParticipantStream(),this.localParticipant.onStopScreensharing())}turnCameraOff(){Gl.info("turn room camera off"),ig.Phone.turnCameraOff(this.callSession),this.localParticipant&&this.localParticipant.onVideoMuted()}turnCameraOn(){Gl.info("turn room camera on"),ig.Phone.turnCameraOn(this.callSession),this.localParticipant&&this.localParticipant.onVideoUnMuted()}mute(){Gl.info("mute room"),ig.Phone.mute(this.callSession),this.sendMuteStatus()}unmute(){Gl.info("unmute room"),ig.Phone.unmute(this.callSession),this.sendUnMuteStatus()}sendMuteStatus(){this.localParticipant&&this.localParticipant.onAudioMuted()}sendUnMuteStatus(){this.localParticipant&&this.localParticipant.onAudioUnMuted()}hold(){Gl.info("hold room"),ig.Phone.hold(this.callSession),this.localParticipant&&this.localParticipant.onHold()}async resume(){Gl.info("resume room");const e=await ig.Phone.resume(this.callSession);this.localParticipant&&(this._updateLocalParticipantStream(),this.localParticipant.onResume(),!e&&this.localParticipant.screensharing&&this.localParticipant.onStopScreensharing())}_updateLocalParticipantStream(){const e=ig.Phone.getLocalStream(this.callSession);if(this.localParticipant&&e){const t=new ig.Stream(e);this.localParticipant.resetStreams([t])}}sendDTMF(e){Gl.info("send room DTMF",{tone:e}),ig.Phone.sendDTMF(e,this.callSession)}async sendReinvite(e=null){Gl.info("send room reinvite",{callId:this.callSession?this.callSession.getId():null,newConstraints:e});const t=this.localParticipant&&this.localParticipant.screensharing;ig.Phone.on(ig.Phone.ON_SHARE_SCREEN_STARTED,(()=>{ig.Phone.phone&&ig.Phone.phone.currentScreenShare&&this._onScreenSharing()}));const i=await(ig.Phone.phone?.sendReinvite(this.callSession,e,!0));if(this.localParticipant&&e&&e.video){const e=ig.Phone.phone?.getLocalVideoStream(this.callSession);e&&this._associateStreamTo(e,this.localParticipant)}else this.localParticipant&&t&&e&&!e.video&&this.localParticipant.onStopScreensharing();return i}hasALocalVideoTrack(){return ig.Phone.hasALocalVideoTrack(this.callSession)}getLocalStream(){return ig.Phone.getLocalStream(this.callSession)}getRemoteStream(){return ig.Phone.getRemoteStream(this.callSession)}getRemoteVideoStream(){return ig.Phone.getRemoteVideoStream(this.callSession)}_bindEvents(){ig.Phone.phone&&ig.Phone.phone.currentSipSession&&(ig.Phone.phone.currentSipSession.sessionDescriptionHandler?.on("setDescription",(({type:e,sdp:t})=>{"offer"===e&&this._mapMsid(t)})),ig.Phone.phone.on(ig.Phone.phone.client.ON_REINVITE,this._boundOnReinvite),this.on(this.ON_AUDIO_STREAM,(async e=>{if(Gl.info("on room audio stream"),this.audioStream=e,this.roomAudioElement)this.roomAudioElement.srcObject=e;else{const t=Ms(ig.Phone.phone?.currentSipSession);this.roomAudioElement=await(ig.Phone.phone?.createAudioElementFor(t)),this.roomAudioElement.srcObject=e}})),this.on(this.ON_VIDEO_STREAM,((e,t,i,n)=>{Gl.info("on room video stream",{streamId:t}),this._mapMsid(n.body.body),this._unassociatedVideoStreams[t]=e;const r=this._getCallIdFromTrackId(t),s=r?this._getParticipantFromCallId(r):null;s&&this.__associateStreams(s)})),this.on(this.ON_REMOVE_STREAM,(e=>{Gl.info("on room remove stream");const t=this.participants.find((t=>t.streams.find((t=>t&&t.id===e.id))));t&&(t.videoStreams=t.videoStreams.filter((t=>t.id!==e.id)),t.streams=t.streams.filter((t=>t.id!==e.id)),t.onStreamUnSubscribed(e))})))}_onScreenSharing(){this.localParticipant&&this.localParticipant.onScreensharing()}_onReinvite(e,t){const i=t.body||t.message.body;i&&(this._mapMsid(i),this.participants.forEach((e=>{this.__associateStreams(e)})))}_mapMsid(e){Es.parse(e).media.filter((e=>!!e.label)).map((({label:e,msid:t})=>({label:String(e),streamId:t?.split(" ")[0],trackId:t?.split(" ")[1]}))).forEach((({label:e,streamId:t,trackId:i})=>{this._callIdStreamIdMap[String(e)]={streamId:t,trackId:i};const n=String(e),r=this._unassociatedParticipants[n]||this._getParticipantFromCallId(n);r&&this.__associateStreams(r)}))}_transferEvents(){ig.Websocket.on(this.CONFERENCE_USER_PARTICIPANT_JOINED,this._boundOnParticipantJoined),ig.Websocket.on(this.CONFERENCE_USER_PARTICIPANT_LEFT,this._boundOnParticipantLeft),ig.Websocket.on(this.MEETING_USER_PARTICIPANT_JOINED,this._boundOnParticipantJoined),ig.Websocket.on(this.MEETING_USER_PARTICIPANT_LEFT,this._boundOnParticipantLeft),ig.Phone.on(this.ON_MESSAGE,this._boundOnMessage),ig.Phone.on(this.ON_CHAT,this._boundOnChat),ig.Phone.on(this.ON_SIGNAL,this._boundOnSignal),ig.Phone.on(this.ON_VIDEO_INPUT_CHANGE,this._boundSaveLocalVideoStream),[this.ON_AUDIO_STREAM,this.ON_VIDEO_STREAM,this.ON_REMOVE_STREAM].forEach((e=>ig.Phone.on(e,((...t)=>this.eventEmitter.emit.apply(this.eventEmitter,[e,...t])))))}_onMessage(e){if("MESSAGE"!==e.method)return null;let t;try{t=JSON.parse(e.body)}catch(e){return null}switch(t.type){case"ConfbridgeTalking":{const e=t.channels[0],{id:i,talking_status:n}=e,r="on"===n,s=this.participants.findIndex((e=>e.callId===i));if(-1===s)return;this.participants[s].onTalking(r);break}}return this.eventEmitter.emit(this.ON_MESSAGE,t),t}_onChat(e){this.eventEmitter.emit(this.ON_CHAT,e)}_onSignal(e){const{type:t}=e;switch(t){case Vl:{const{status:t}=e,i=this._getParticipantFromCallId(t.callId);i&&i.updateStatus(t,!1);break}case ql:{const{callId:t,origin:i}=e;!this.localParticipant||t&&t!==this.localParticipant.callId||this.localParticipant.broadcastStatus(null,!0);const n=this._getParticipantFromCallId(i.callId);n&&(Gl.info("trigger room requester status",{origin:i}),n.triggerUpdate("REQUESTER_UPDATE"));break}case ig.Phone.ON_MESSAGE_TRACK_UPDATED:{const{callId:t,update:i}=e,n=this.participants.findIndex((e=>e.callId===t));-1!==n&&(this.participants[n]=this._onParticipantTrackUpdate(this.participants[n],i));break}default:console.warn("uncaught signal",e)}this.eventEmitter.emit(ig.Phone.ON_SIGNAL,e)}async _onParticipantJoined(e){const t=e.data,i=ig.Auth.getSession();let n=[];if(t.user_uuid===i?.uuid){Gl.info("room current user joined");const t=this.sourceId||e.data.conference_id;let i;try{this.meetingUuid?(Gl.info("fetching meeting participants",{meetingUuid:this.meetingUuid}),i=await gn().calld.getMeetingParticipantsAsUser(this.meetingUuid)):(Gl.info("fetching conference participants",{conferenceId:t}),i=await gn().calld.getConferenceParticipantsAsUser(t))}catch(e){Gl.error("room participants fetching, error",e)}if(i){Gl.info("conference participants fetched",{nb:i.items.length}),n=i.items.map((e=>e.call_id===this.callId&&e.call_id?new ig.LocalParticipant(this,e,this.extra):new ig.RemoteParticipant(this,e))),this.participants=n;const e=n.find((e=>e instanceof ig.LocalParticipant));!this.localParticipant&&e&&this._onLocalParticipantJoined(e),n.forEach((e=>this._isParticipantJoining(e))),this.eventEmitter.emit(this.ON_JOINED,e,n)}return this.participants}const r=this.participants.some((e=>e.callId===t.call_id))?null:new ig.RemoteParticipant(this,t);return Gl.info("other room user joined",{callId:t.call_id,remoteParticipant:!!r}),r&&(this.participants.push(r),this._isParticipantJoining(r)),r}_onLocalParticipantJoined(e){this.localParticipant=e;const t=this._getLocalVideoStream();t&&this._saveLocalVideoStream(t),this.connected=!0,e.broadcastStatus(null,!0),this.localParticipant&&this.sendSignal({type:ql,origin:this.localParticipant.getStatus()})}_isParticipantJoining(e){this.__associateStreams(e),e instanceof Ul&&this.eventEmitter.emit(this.CONFERENCE_USER_PARTICIPANT_JOINED,e)}_saveLocalVideoStream(e){const{localParticipant:t}=this;if(!t)return;const i=new ig.Stream(e,t);return i&&(t.resetStreams([i]),t.onStreamSubscribed(i)),i}_onParticipantLeft(e){const t=this.participants.find((t=>t&&t.callId===e.data.call_id));t&&t.onDisconnect(),this.participants=this.participants.filter((t=>t&&t.callId!==e.data.call_id)),this.eventEmitter.emit(this.CONFERENCE_USER_PARTICIPANT_LEFT,t)}_onParticipantTrackUpdate(e,t){const i=e,{trackId:n,streamId:r}=this._callIdStreamIdMap[i.callId]||{},s=ig.Phone.phone?.currentSipSession?.sessionDescriptionHandler?.peerConnection,a=s.getRemoteStreams().find((e=>e.id===r||e.getTracks().some((e=>e.id===n))));return"downgrade"===t?(i.resetStreams([]),i.onStreamUnSubscribed(a),i):(a&&this._associateStreamTo(a,i),i)}__associateStreams(e){const{trackId:t}=this._callIdStreamIdMap[e.callId]||{};if(!t)return void(this._unassociatedParticipants[e.callId]=e);if(!t||!e||!this.localParticipant||e.callId===this.localParticipant.callId)return;const i=this._getStreamIdFrTrackId(t),n=this._getUnassociatedMapIdFromTrackIdOrStreamId(t,i),r=n?this._unassociatedVideoStreams[n]:null;r&&(this._associateStreamTo(r,e),n&&delete this._unassociatedVideoStreams[n],delete this._unassociatedParticipants[e.callId])}_getUnassociatedMapIdFromTrackIdOrStreamId(e,t){if(e in this._unassociatedVideoStreams)return e;if(t&&t in this._unassociatedVideoStreams)return t;const i=Object.values(this._unassociatedVideoStreams).findIndex((e=>e&&e.id===t));return-1===i?null:Object.keys(this._unassociatedVideoStreams)[i]}_getStreamIdFrTrackId(e){const t=Object.values(this._callIdStreamIdMap).find((t=>t.trackId===e));return t?t.streamId:null}_associateStreamTo(e,t){const i=new ig.Stream(e,t);t.streams.push(i),t.videoStreams.push(i),t.onStreamSubscribed(i)}_getCallIdFromTrackId(e){return Object.keys(this._callIdStreamIdMap).find((t=>this._callIdStreamIdMap[t].trackId===e))}_getParticipantFromCallId(e){return this.participants.find((t=>t.callId===e))}_getLocalVideoStream(){return ig.Phone.getLocalVideoStream(this.callSession)}};const Wl=B.loggerFor("sdk-sip-room");class zl extends Kl{static async connect({extension:e,constraints:t,audioOnly:i=!1,extra:n,room:r}){if(Wl.info("connecting to sip room",{extension:e,audioOnly:i,room:!!r}),!r){await ig.Phone.connect({media:t});const s=t&&!!t.video,a=await ig.Phone.call(e,s,null,i,!0);r=new zl(a,e,null,null,n)}return r&&r.callSession&&r.callSession.call&&r.setCallId(r.callSession.call.id),Wl.info("connected to room",{extension:r.extension}),r}mute(){Wl.info("mute sip room"),ig.Phone.mute(this.callSession,!1),this.sendMuteStatus()}unmute(){Wl.info("unmute sip room"),ig.Phone.unmute(this.callSession,!1),this.sendUnMuteStatus()}getLocalGuestName(){return ig.Phone.phone?.client.userAgent?.options.displayName||null}_transferEvents(){ig.Phone.on(this.ON_MESSAGE,this._boundOnMessage),ig.Phone.on(this.ON_CHAT,this._boundOnChat),ig.Phone.on(this.ON_SIGNAL,this._boundOnSignal),ig.Phone.on(this.ON_VIDEO_INPUT_CHANGE,this._boundSaveLocalVideoStream),[this.ON_AUDIO_STREAM,this.ON_VIDEO_STREAM,this.ON_REMOVE_STREAM].forEach((e=>ig.Phone.on(e,((...t)=>this.eventEmitter.emit.apply(this.eventEmitter,[e,...t])))))}_onMessage(e){const t=super._onMessage(e);if(!t)return;const i=()=>t.channels[0];switch(t.type){case"ConfbridgeWelcome":t.channels.forEach((e=>{this._onParticipantJoined(e)}));break;case"ConfbridgeJoin":{const e=i();this._onParticipantJoined(e);break}case"ConfbridgeLeave":{const e=i();this._onParticipantLeft({data:{call_id:e.id}});break}}}async _onParticipantJoined(e){const t=e.channelvars.WAZO_SIP_CALL_ID===this._getCurrentSipCallIs(),i=e.id,n=t?ig.LocalParticipant:ig.RemoteParticipant,r=e.caller?e.caller.name:null,s=new n(this,{caller_id_name:r,call_id:i},t?{guestName:this.getLocalGuestName()}:{}),a=this.participants.findIndex((e=>e.callId===s.callId));if(-1===a||!r)return t&&(this.callSession&&(this.callSession.ringing=!1),this._onLocalParticipantJoined(s),setTimeout((()=>{this.eventEmitter.emit(this.ON_JOINED,s,this.participants)}),1e3)),this.participants.push(s),this._isParticipantJoining(s),s;this.participants[a].name=r}_getCurrentSipCallIs(){return Ms(ig.Phone.phone?.currentSipSession)}}class Yl{htmlStream;participant;static detachStream(e){e.getTracks().filter((e=>e.enabled)).forEach((e=>e.stop()))}constructor(e,t){this.htmlStream=e,this.participant=t}attach(e){const t=e||document.createElement("video"),i=this.participant instanceof ig.LocalParticipant;return t.autoplay=!0,t.srcObject=this.htmlStream,t.muted=i,i&&(t.style.transform="scale(-1, 1)"),t.onloadedmetadata=()=>{(this.htmlStream?this.htmlStream.getVideoTracks():[]).forEach((e=>{e.enabled=!0,e.loaded=!0}))},t}detach(){Yl.detachStream(this.htmlStream)}hasVideo(){return!!this.htmlStream&&this.htmlStream.getTracks().some((e=>"video"===e.kind&&"ended"!==e.readyState))}get id(){return this.htmlStream?this.htmlStream.id:null}}class Jl{async findMultipleContactsByNumber(e,t){return gn().dird.findMultipleContactsByNumber(e,t)}}global.wazoDirectoryInstance||(global.wazoDirectoryInstance=new Jl);var Zl=global.wazoDirectoryInstance;class Xl{async getCurrentUser(){const e=ig.Auth.getSession();return gn().confd.getUser(`${e?e.uuid:""}`)}}global.wazoConfigurationInstance||(global.wazoConfigurationInstance=new Xl);var Ql=global.wazoConfigurationInstance;const eh=async(e,t={})=>{const i={};i[e]=!(Object.keys(t).length>0)||t;const n=await navigator.mediaDevices.getUserMedia(i);return new ig.Stream(n,new ig.LocalParticipant(null,{call_id:"some-call-id",caller_id_name:"some-call-id-name"}))};class th{sound;vibration;static parse(e){return new th(e?{sound:e.sound,vibration:e.vibration}:{sound:!0,vibration:!0})}static newFrom(e){return Ut(e,th)}constructor({sound:e,vibration:t}={sound:!0,vibration:!0}){this.sound=e,this.vibration=t}setSound(e){return this.sound=e,this}setVibration(e){return this.vibration=e,this}enable(){return this.vibration=!0,this.sound=!0,this}disable(){return this.vibration=!1,this.sound=!1,this}isEnabled(){return this.sound||this.vibration}}class ih{id;name;connectedCallSession;participants;constructor({id:e,connectedCallSession:t,participants:i,name:n}){this.id=e,this.connectedCallSession=t,this.participants=i,this.name=n}getExtension(){return this.connectedCallSession?this.connectedCallSession.number:null}connect(e){return new ih({...this,connectedCallSession:e})}has(e){return!!this.connectedCallSession&&this.connectedCallSession.is(e)}addParticipant(e,t,i=null){return this.participants.some((i=>i.uuid===e||i.extension===t))?this:new ih({...this,participants:[...this.participants,{uuid:e,extension:t,talking:i}]})}updateParticipant(e,t,i=!1){const n=this.participants.findIndex((t=>t.uuid===e));if(-1===n&&!i)return this;const r=[...this.participants];return-1!==n?r[n]={...r[n],...t}:r.push(t),new ih({...this,participants:r})}updateParticipantByExtension(e,t,i=!1){const n=this.participants.findIndex((t=>t.extension===e));if(-1===n&&!i)return this;const r=[...this.participants];return-1!==n?r[n]={...r[n],...t}:r.push(t),new ih({...this,participants:r})}hasCallWithId(e){return!!this.connectedCallSession&&this.connectedCallSession.getId()===e}disconnect(){return new ih({...this,connectedCallSession:null})}removeParticipantWithUUID(e){return new ih({...this,participants:this.participants.filter((t=>t.uuid!==e))})}removeParticipantWithExtension(e){return new ih({...this,participants:this.participants.filter((t=>t.extension!==e))})}updateFrom(e){vi(this,e)}static newFrom(e){return Ut(e,ih)}}class nh{static STATE;id;callSession;callerIdName;callerIdNumber;answerTime;participantId;state;switchboardName;switchboardUuid;type;static parse(e){return new nh({id:e.id,callSession:e.callSession||null,callerIdName:e.caller_id_name||null,callerIdNumber:e.caller_id_number||null,participantId:e.participantId||null,answerTime:e.startTime,state:e.state,switchboardName:e.switchboardName,switchboardUuid:e.switchboardUuid})}constructor({id:e,callSession:t,callerIdName:i,callerIdNumber:n,participantId:r,answerTime:s,state:a,switchboardName:o,switchboardUuid:c}){this.id=e,this.callSession=t,this.callerIdName=i,this.callerIdNumber=n,this.participantId=r,this.answerTime=s,this.state=a,this.switchboardName=o,this.switchboardUuid=c,this.type="SwitchboardCall"}updateFrom(e){vi(this,e)}getId(){return this.id}static newFrom(e){return Ut(e,nh)}}nh.STATE={INCOMING:"incoming",ONGOING:"ongoing",HELD:"held"};const rh=e=>`enterprise.app.${e}`,sh=["chat","video","call_recording","fax","mobile_double_call","mobile_gsm","meeting","caller_id"].map(rh);var ah=new class{_hasChat;_hasVideo;_hasCallRecording;_hasFax;_hasMobileDoubleCall;_hasMobileGsm;_hasMeeting;_hasCallerID;constructor(){this._hasChat=!0,this._hasVideo=!0,this._hasCallRecording=!0,this._hasFax=!0,this._hasMobileDoubleCall=!0,this._hasMobileGsm=!0,this._hasMeeting=!0,this._hasCallerID=!1}async fetchAccess(){let e;try{e=await gn().auth.getRestrictionPolicies(sh)}catch(e){}if(!e)return;const{scopes:t}=e;this._hasChat=this._hasFeatures(t,"chat"),this._hasVideo=this._hasFeatures(t,"video"),this._hasCallRecording=this._hasFeatures(t,"call_recording"),this._hasFax=this._hasFeatures(t,"fax"),this._hasMobileDoubleCall=this._hasFeatures(t,"mobile_double_call"),this._hasMobileGsm=this._hasFeatures(t,"mobile_gsm"),this._hasMeeting=this._hasFeatures(t,"meeting"),this._hasCallerID=this._hasFeatures(t,"caller_id")}hasChat(){return this._hasChat}hasVideo(){return this._hasVideo}hasCallRecording(){return this._hasCallRecording}hasFax(){return this._hasFax}hasMobileDoubleCall(){return this._hasMobileDoubleCall}hasMobileGsm(){return this._hasMobileGsm}hasMeeting(){return this._hasMeeting}hasCallerID(){return this._hasCallerID}_hasFeatures(e,t){const i=rh(t);return!e||!(i in e)||!0===e[i]}},oh={name:"API",check:async(e,t)=>{const i=new rn({server:e});i.setToken(t.token),i.disableErrorLogging();const n=(e,t)=>{const i=t instanceof w?"server error":"api error";throw new Error(`${e} fails with status (${t.status}, ${i}) : ${t.message}`)};try{await i.auth.getPushNotificationSenderId(t.uuid),await i.auth.getProviders(t.uuid)}catch(e){n("wazo-auth",e)}try{await i.callLogd.listCallLogs()}catch(e){n("wazo-callogd",e)}try{await i.calld.listCalls()}catch(e){n("wazo-calld",e)}try{await i.calld.listVoicemails()}catch(e){404!==e.status&&n("wazo-calld",e)}try{await i.chatd.getState(t.uuid),await i.chatd.getContactStatusInfo(t.uuid),await i.chatd.getUserRooms()}catch(e){n("wazo-chatd",e)}try{await i.confd.getInfos(),await i.confd.getUser(t.uuid)}catch(e){n("wazo-confd",e)}try{await i.dird.listPersonalContacts(),await i.dird.listFavorites(t.primaryContext()),await i.dird.fetchWazoSource(t.primaryContext());const e=await i.dird.fetchConferenceSource(t.primaryContext());await i.dird.fetchConferenceContacts(e.items[0])}catch(e){n("wazo-dird",e)}try{await i.webhookd.getSubscriptions()}catch(e){n("wazo-webhookd",e)}}},ch={name:"List of AOR",check:async(e,t)=>{const i=new rn({server:e});i.setToken(t.token),i.disableErrorLogging();const n=t.primaryWebRtcLine();if(!n)return"No WebRTC line for this user";const{username:r}=n;try{const e=await i.amid.getAors(r),t=e.length,n=e.filter((e=>"Reachable"===e.status));return`Number of AOR: ${t} (${n.length} Avail, ${t-n.length} Unavail)`}catch(e){if(401===e.status)return"Not available for this user";throw e}}};var dh={name:"Symmetric NAT",check:()=>new Promise(((e,t)=>{if("undefined"==typeof MediaStream)return e("Skipped on node");const i={},n=[];let r=0;const s=new RTCPeerConnection({iceServers:[{urls:"stun:stun.wazo.io:443"},{urls:"stun:stun1.l.google.com:19302"},{urls:"stun:stun2.l.google.com:19302"}]});let a;const o=()=>{if(clearTimeout(a),0===Object.keys(i).length)return void t(new Error(`Timed out (8000ms), ${r} candidates : ${n.join(", ")}`));1===i[Object.keys(i)[0]].length?e():t(new Error("Symmetric NAT detected, you should use a TURN server."))};a=setTimeout(o,8e3),s.createDataChannel("wazo-check-nat"),s.onicecandidate=e=>{if(r++,e.candidate&&n.push(e.candidate.candidate),e.candidate&&-1!==e.candidate.candidate.indexOf("srflx")){const t=Zs(e.candidate.candidate);t.relatedPort&&(i[t.relatedPort]||(i[t.relatedPort]=[]),i[t.relatedPort].push(t.port))}else e.candidate||o()},s.createOffer().then((e=>s.setLocalDescription(e)))}))};const lh=e=>{const t=e.split(".");return 4===t.length&&t.every((e=>parseInt(e,10)>=0&&parseInt(e,10)<=255))};var hh={name:"Non IP v4 ice",check:(e,t,i)=>new Promise(((e,t)=>{if("undefined"==typeof MediaStream)return void e("Skipped on node");const n=x(),r={offerToReceiveAudio:1},s=[],a={iceServers:[{urls:"stun:stun1.l.google.com:19302"},{urls:"stun:stun2.l.google.com:19302"}]};let o=!1;i&&i.stun_servers&&(a.iceServers={...i.stun_servers.split(",").map((e=>({urls:e}))),...a.iceServers}),i&&i.turn_servers&&(a.iceServers=[...JSON.parse(i.turn_servers),...a.iceServers||[]],a.iceTransportPolicy="relay");const c=new RTCPeerConnection(a);c.createDataChannel("wazo-check-ipv4"),c.onicecandidate=i=>{if(i.candidate){const e=i.candidate.candidate;if(-1!==e.indexOf("srflx")||-1!==e.indexOf("relay")){o=!0;const e=Zs(i.candidate.candidate);s.push(e.ip)}}else if(!i.candidate){if(!o)return t(new Error("No `srflx` or `relay` found in candidate. Please consider using a TURN server."));if(s.every(lh))e(null);else{const e=s.find((e=>!lh(e)));t(new Error(`Non IPv4 ice candidate found : ${e}.`))}}},c.createOffer(r).then((e=>c.setLocalDescription(e))).then((e=>n?c.createOffer(r):e)).then((e=>n?c.setLocalDescription(e):e))}))},uh=[ch,oh,{name:"Event transport (WS)",check:(e,t)=>new Promise(((i,n)=>{const r=new Dl({host:e,token:t.token,version:2}),s=e=>{r.close(),n(new Error(e))},a=()=>{r.stopHeartbeat(),r.close(),i()};r.on(gd.ON_ERROR,(e=>{s(`Connection error : ${e}`)})),r.on(gd.ON_OPEN,(()=>{t.hasEngineVersionGte(Rl)?(r.setOnHeartbeatTimeout((()=>{s("No response to heartbeat")})),r.setOnHeartbeatCallback((()=>{a()})),r.startHeartbeat()):a()})),r.connect()}))},{name:"WebRTC Transport (WS) ~30s",check:(e,t)=>new Promise(((i,n)=>{const[r,s=443]=e.split(":"),a=new Zc({host:r,port:s,media:{audio:!0}},t),o=e=>{a.close(),n(new Error(e))};a.on(a.TRANSPORT_ERROR,(e=>{o(`Transport error : ${e}`)})),a.on(a.REGISTERED,(()=>{a.setOnHeartbeatTimeout((()=>{o("No response to heartbeat")})),a.setOnHeartbeatCallback((()=>{(async()=>{a.stopHeartbeat(),await a.close(),i()})()})),a.startHeartbeat()}))}))},{name:"WebRTC",check:(e,t)=>new Promise(((i,n)=>{if("undefined"==typeof MediaStream)return i("Skipped on node");const[r,s=443]=e.split(":"),a=new Zc({host:r,port:s,media:{audio:!0}},t),o=e=>{a.close(),n(new Error(e))};a.on(a.TRANSPORT_ERROR,(e=>{o(`Transport error : ${e}`)})),a.on(a.REGISTERED,(()=>{const e=a.call("*10");if(!e||!Ms(e))return o("Unable to make call through WebRTC");setTimeout((()=>{a.hangup(e),(async()=>{a.stopHeartbeat(),await a.close(),i()})()}),1e3)}))}))},dh,hh];const ph=B.loggerFor("engine-check");class gh{session;server;externalAppConfig;checks;constructor(e,t,i={}){this.server=e,this.session=t,this.externalAppConfig=i,this.checks=[...uh]}async check(e=(()=>{}),t=(()=>{})){await this._addEngineVersion(),ph.info("Engine check starting");for(let i=0;i<this.checks.length;i++){const{name:n,check:r}=this.checks[i];ph.info(`Checking ${n} ...`),e(n);try{const e=await r(this.server,this.session,this.externalAppConfig);ph.info(`Checking ${n} success.`,{result:e}),t(n,e)}catch(e){ph.info(`Checking ${n} failure`,{message:e.message}),t(n,e)}}ph.info("Engine check done.")}addCheck(e){this.checks.push(e)}async _addEngineVersion(){if(!this.session.engineVersion){const e=new rn({server:this.server});e.setToken(this.session.token);const{wazo_version:t}=await e.confd.getInfos();this.session.engineVersion=t}}}function fh(){const e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:void 0;if(e.__xstate__)return e.__xstate__}const mh=e=>{if("undefined"==typeof window)return;const t=fh();t&&t.register(e)};class vh{constructor(e){this._process=e,this._active=!1,this._current=null,this._last=null}start(){this._active=!0,this.flush()}clear(){this._current&&(this._current.next=null,this._last=this._current)}enqueue(e){const t={value:e,next:null};if(this._current)return this._last.next=t,void(this._last=t);this._current=t,this._last=t,this._active&&this.flush()}flush(){for(;this._current;){const e=this._current;this._process(e.value),this._current=e.next}this._last=null}}const yh=".",Sh="",bh="xstate.init",wh="xstate.stop";function Eh(e,t){return{type:`xstate.done.state.${e}`,output:t}}function Ch(e){return{type:bh,input:e}}function Th(e){setTimeout((()=>{throw e}))}const $h="function"==typeof Symbol&&Symbol.observable||"@@observable";function _h(e,t){return`${e.sessionId}.${t}`}let xh=0;function Ih(e,t){const i=Ah(e),n=Ah(t);return"string"==typeof n?"string"==typeof i&&n===i:"string"==typeof i?i in n:Object.keys(i).every((e=>e in n&&Ih(i[e],n[e])))}function Rh(e){if(Oh(e))return e;let t=[],i="";for(let n=0;n<e.length;n++){switch(e.charCodeAt(n)){case 92:i+=e[n+1],n++;continue;case 46:t.push(i),i="";continue}i+=e[n]}return t.push(i),t}function Ah(e){if((t=e)&&"object"==typeof t&&"machine"in t&&"value"in t)return e.value;var t;if("string"!=typeof e)return e;return function(e){if(1===e.length)return e[0];const t={};let i=t;for(let t=0;t<e.length-1;t++)if(t===e.length-2)i[e[t]]=e[t+1];else{const n=i;i={},n[e[t]]=i}return t}(Rh(e))}function Ph(e,t){const i={},n=Object.keys(e);for(let r=0;r<n.length;r++){const s=n[r];i[s]=t(e[s],s,e,r)}return i}function Dh(e){return Oh(e)?e:[e]}function Nh(e){return void 0===e?[]:Dh(e)}function kh(e,t,i,n){return"function"==typeof e?e({context:t,event:i,self:n}):e}function Oh(e){return Array.isArray(e)}function Fh(e){return Dh(e).map((e=>void 0===e||"string"==typeof e?{target:e}:e))}function Mh(e){if(void 0!==e&&e!==Sh)return Nh(e)}function Hh(e,t,i){const n="object"==typeof e,r=n?e:void 0;return{next:(n?e.next:e)?.bind(r),error:(n?e.error:t)?.bind(r),complete:(n?e.complete:i)?.bind(r)}}function Lh(e,t){return`${t}.${e}`}function jh(e,t){const i=t.match(/^xstate\.invoke\.(\d+)\.(.*)/);if(!i)return e.implementations.actors[t];const[,n,r]=i,s=e.getStateNodeById(r).config.invoke;return(Array.isArray(s)?s[n]:s).src}const Bh=1;let Uh=function(e){return e[e.NotStarted=0]="NotStarted",e[e.Running=1]="Running",e[e.Stopped=2]="Stopped",e}({});const Vh={clock:{setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e)},logger:console.log.bind(console),devTools:!1};class qh{constructor(e,t){this.logic=e,this._snapshot=void 0,this.clock=void 0,this.options=void 0,this.id=void 0,this.mailbox=new vh(this._process.bind(this)),this.observers=new Set,this.eventListeners=new Map,this.logger=void 0,this._processingStatus=Uh.NotStarted,this._parent=void 0,this._syncSnapshot=void 0,this.ref=void 0,this._actorScope=void 0,this._systemId=void 0,this.sessionId=void 0,this.system=void 0,this._doneEvent=void 0,this.src=void 0,this._deferred=[];const i={...Vh,...t},{clock:n,logger:r,parent:s,syncSnapshot:a,id:o,systemId:c,inspect:d}=i;this.system=s?s.system:function(e,t){const i=new Map,n=new Map,r=new WeakMap,s=new Set,a={},{clock:o,logger:c}=t,d={schedule:(e,t,i,n,r=Math.random().toString(36).slice(2))=>{const s={source:e,target:t,event:i,delay:n,id:r,startedAt:Date.now()},c=_h(e,r);l._snapshot._scheduledEvents[c]=s;const d=o.setTimeout((()=>{delete a[c],delete l._snapshot._scheduledEvents[c],l._relay(e,t,i)}),n);a[c]=d},cancel:(e,t)=>{const i=_h(e,t),n=a[i];delete a[i],delete l._snapshot._scheduledEvents[i],o.clearTimeout(n)},cancelAll:e=>{for(const t in l._snapshot._scheduledEvents){const i=l._snapshot._scheduledEvents[t];i.source===e&&d.cancel(e,i.id)}}},l={_snapshot:{_scheduledEvents:(t?.snapshot&&t.snapshot.scheduler)??{}},_bookId:()=>"x:"+xh++,_register:(e,t)=>(i.set(e,t),e),_unregister:e=>{i.delete(e.sessionId);const t=r.get(e);void 0!==t&&(n.delete(t),r.delete(e))},get:e=>n.get(e),_set:(e,t)=>{const i=n.get(e);if(i&&i!==t)throw new Error(`Actor with system ID '${e}' already exists.`);n.set(e,t),r.set(t,e)},inspect:e=>{s.add(e)},_sendInspectionEvent:t=>{if(!s.size)return;const i={...t,rootId:e.sessionId};s.forEach((e=>e.next?.(i)))},_relay:(e,t,i)=>{l._sendInspectionEvent({type:"@xstate.event",sourceRef:e,actorRef:t,event:i}),t._send(i)},scheduler:d,getSnapshot:()=>({_scheduledEvents:{...l._snapshot._scheduledEvents}}),start:()=>{const e=l._snapshot._scheduledEvents;l._snapshot._scheduledEvents={};for(const t in e){const{source:i,target:n,event:r,delay:s,id:a}=e[t];d.schedule(i,n,r,s,a)}},_clock:o,_logger:c};return l}(this,{clock:n,logger:r}),d&&!s&&this.system.inspect(Hh(d)),this.sessionId=this.system._bookId(),this.id=o??this.sessionId,this.logger=t?.logger??this.system._logger,this.clock=t?.clock??this.system._clock,this._parent=s,this._syncSnapshot=a,this.options=i,this.src=i.src??e,this.ref=this,this._actorScope={self:this,id:this.id,sessionId:this.sessionId,logger:this.logger,defer:e=>{this._deferred.push(e)},system:this.system,stopChild:e=>{if(e._parent!==this)throw new Error(`Cannot stop child actor ${e.id} of ${this.id} because it is not a child`);e._stop()},emit:e=>{const t=this.eventListeners.get(e.type),i=this.eventListeners.get("*");if(!t&&!i)return;const n=new Set([...t?t.values():[],...i?i.values():[]]);for(const t of Array.from(n))t(e)}},this.send=this.send.bind(this),this.system._sendInspectionEvent({type:"@xstate.actor",actorRef:this}),c&&(this._systemId=c,this.system._set(c,this)),this._initState(t?.snapshot??t?.state),c&&"active"!==this._snapshot.status&&this.system._unregister(this)}_initState(e){try{this._snapshot=e?this.logic.restoreSnapshot?this.logic.restoreSnapshot(e,this._actorScope):e:this.logic.getInitialSnapshot(this._actorScope,this.options?.input)}catch(e){this._snapshot={status:"error",output:void 0,error:e}}}update(e,t){let i;for(this._snapshot=e;i=this._deferred.shift();)try{i()}catch(t){this._deferred.length=0,this._snapshot={...e,status:"error",error:t}}switch(this._snapshot.status){case"active":for(const t of this.observers)try{t.next?.(e)}catch(e){Th(e)}break;case"done":for(const t of this.observers)try{t.next?.(e)}catch(e){Th(e)}this._stopProcedure(),this._complete(),this._doneEvent=(n=this.id,r=this._snapshot.output,{type:`xstate.done.actor.${n}`,output:r}),this._parent&&this.system._relay(this,this._parent,this._doneEvent);break;case"error":this._error(this._snapshot.error)}var n,r;this.system._sendInspectionEvent({type:"@xstate.snapshot",actorRef:this,event:t,snapshot:e})}subscribe(e,t,i){const n=Hh(e,t,i);if(this._processingStatus!==Uh.Stopped)this.observers.add(n);else switch(this._snapshot.status){case"done":try{n.complete?.()}catch(e){Th(e)}break;case"error":{const e=this._snapshot.error;if(n.error)try{n.error(e)}catch(e){Th(e)}else Th(e);break}}return{unsubscribe:()=>{this.observers.delete(n)}}}on(e,t){let i=this.eventListeners.get(e);i||(i=new Set,this.eventListeners.set(e,i));const n=t.bind(void 0);return i.add(n),{unsubscribe:()=>{i.delete(n)}}}start(){if(this._processingStatus===Uh.Running)return this;this._syncSnapshot&&this.subscribe({next:e=>{"active"===e.status&&this.system._relay(this,this._parent,{type:`xstate.snapshot.${this.id}`,snapshot:e})},error:()=>{}}),this.system._register(this.sessionId,this),this._systemId&&this.system._set(this._systemId,this),this._processingStatus=Uh.Running;const e=Ch(this.options.input);this.system._sendInspectionEvent({type:"@xstate.event",sourceRef:this._parent,actorRef:this,event:e});switch(this._snapshot.status){case"done":return this.update(this._snapshot,e),this;case"error":return this._error(this._snapshot.error),this}if(this._parent||this.system.start(),this.logic.start)try{this.logic.start(this._snapshot,this._actorScope)}catch(e){return this._snapshot={...this._snapshot,status:"error",error:e},this._error(e),this}return this.update(this._snapshot,e),this.options.devTools&&this.attachDevTools(),this.mailbox.start(),this}_process(e){let t,i;try{t=this.logic.transition(this._snapshot,e,this._actorScope)}catch(e){i={err:e}}if(i){const{err:e}=i;return this._snapshot={...this._snapshot,status:"error",error:e},void this._error(e)}this.update(t,e),e.type===wh&&(this._stopProcedure(),this._complete())}_stop(){return this._processingStatus===Uh.Stopped?this:(this.mailbox.clear(),this._processingStatus===Uh.NotStarted?(this._processingStatus=Uh.Stopped,this):(this.mailbox.enqueue({type:wh}),this))}stop(){if(this._parent)throw new Error("A non-root actor cannot be stopped directly.");return this._stop()}_complete(){for(const e of this.observers)try{e.complete?.()}catch(e){Th(e)}this.observers.clear()}_reportError(e){if(!this.observers.size)return void(this._parent||Th(e));let t=!1;for(const i of this.observers){const n=i.error;t||=!n;try{n?.(e)}catch(e){Th(e)}}this.observers.clear(),t&&Th(e)}_error(e){this._stopProcedure(),this._reportError(e),this._parent&&this.system._relay(this,this._parent,{type:`xstate.error.actor.${this.id}`,error:e})}_stopProcedure(){return this._processingStatus!==Uh.Running||(this.system.scheduler.cancelAll(this),this.mailbox.clear(),this.mailbox=new vh(this._process.bind(this)),this._processingStatus=Uh.Stopped,this.system._unregister(this)),this}_send(e){this._processingStatus!==Uh.Stopped&&this.mailbox.enqueue(e)}send(e){this.system._relay(void 0,this,e)}attachDevTools(){const{devTools:e}=this.options;if(e){("function"==typeof e?e:mh)(this)}}toJSON(){return{xstate$$type:Bh,id:this.id}}getPersistedSnapshot(e){return this.logic.getPersistedSnapshot(this._snapshot,e)}[$h](){return this}getSnapshot(){return this._snapshot}}function Gh(e,...[t]){return new qh(e,t)}function Kh(e,t,i,n,{sendId:r}){return[t,"function"==typeof r?r(i,n):r]}function Wh(e,t){e.defer((()=>{e.system.scheduler.cancel(e.self,t)}))}function zh(e,t,i,n,{id:r,systemId:s,src:a,input:o,syncSnapshot:c}){const d="string"==typeof a?jh(t.machine,a):a,l="function"==typeof r?r(i):r;let h;return d&&(h=Gh(d,{id:l,src:a,parent:e.self,syncSnapshot:c,systemId:s,input:"function"==typeof o?o({context:t.context,event:i.event,self:e.self}):o})),[Gu(t,{children:{...t.children,[l]:h}}),{id:r,actorRef:h}]}function Yh(e,{id:t,actorRef:i}){i&&e.defer((()=>{i._processingStatus!==Uh.Stopped&&i.start()}))}function Jh(...[e,{id:t,systemId:i,input:n,syncSnapshot:r=!1}={}]){function s(e,t){}return s.type="snapshot.spawnChild",s.id=t,s.systemId=i,s.src=e,s.input=n,s.syncSnapshot=r,s.resolve=zh,s.execute=Yh,s}function Zh(e,t,i,n,{actorRef:r}){const s="function"==typeof r?r(i,n):r,a="string"==typeof s?t.children[s]:s;let o=t.children;return a&&(o={...o},delete o[a.id]),[Gu(t,{children:o}),a]}function Xh(e,t){t&&(e.system._unregister(t),t._processingStatus===Uh.Running?e.defer((()=>{e.stopChild(t)})):e.stopChild(t))}function Qh(e){function t(e,t){}return t.type="xstate.stopChild",t.actorRef=e,t.resolve=Zh,t.execute=Xh,t}function eu(e,t,i,n){const{machine:r}=n,s="function"==typeof e,a=s?e:r.implementations.guards["string"==typeof e?e:e.type];if(!s&&!a)throw new Error(`Guard '${"string"==typeof e?e:e.type}' is not implemented.'.`);if("function"!=typeof a)return eu(a,t,i,n);const o={context:t,event:i},c=s||"string"==typeof e?void 0:"params"in e?"function"==typeof e.params?e.params({context:t,event:i}):e.params:void 0;if(!("check"in a))return a(o,c);return a.check(n,o,a)}const tu=e=>"atomic"===e.type||"final"===e.type;function iu(e){return Object.values(e.states).filter((e=>"history"!==e.type))}function nu(e,t){const i=[];if(t===e)return i;let n=e.parent;for(;n&&n!==t;)i.push(n),n=n.parent;return i}function ru(e){const t=new Set(e),i=au(t);for(const e of t)if("compound"!==e.type||i.get(e)&&i.get(e).length){if("parallel"===e.type)for(const i of iu(e))if("history"!==i.type&&!t.has(i)){const e=gu(i);for(const i of e)t.add(i)}}else gu(e).forEach((e=>t.add(e)));for(const e of t){let i=e.parent;for(;i;)t.add(i),i=i.parent}return t}function su(e,t){const i=t.get(e);if(!i)return{};if("compound"===e.type){const e=i[0];if(!e)return{};if(tu(e))return e.key}const n={};for(const e of i)n[e.key]=su(e,t);return n}function au(e){const t=new Map;for(const i of e)t.has(i)||t.set(i,[]),i.parent&&(t.has(i.parent)||t.set(i.parent,[]),t.get(i.parent).push(i));return t}function ou(e,t){return su(e,au(ru(t)))}function cu(e,t){return"compound"===t.type?iu(t).some((t=>"final"===t.type&&e.has(t))):"parallel"===t.type?iu(t).every((t=>cu(e,t))):"final"===t.type}const du=e=>"#"===e[0];function lu(e){const t=e.config.after;if(!t)return[];const i=(t,i)=>{const n=(r=t,s=e.id,{type:`xstate.after.${r}.${s}`});var r,s;const a=n.type;return e.entry.push(function(e,t){function i(e,t){}return i.type="xstate.raise",i.event=e,i.id=t?.id,i.delay=t?.delay,i.resolve=Wu,i.execute=zu,i}(n,{id:a,delay:t})),e.exit.push(function(e){function t(e,t){}return t.type="xstate.cancel",t.sendId=e,t.resolve=Kh,t.execute=Wh,t}(a)),a};return Object.keys(t).flatMap(((e,n)=>{const r=t[e],s="string"==typeof r?{target:r}:r,a=Number.isNaN(+e)?e:+e,o=i(a);return Nh(s).map((e=>({...e,event:o,delay:a})))})).map((t=>{const{delay:i}=t;return{...hu(e,t.event,t),delay:i}}))}function hu(e,t,i){const n=Mh(i.target),r=i.reenter??!1,s=function(e,t){if(void 0===t)return;return t.map((t=>{if("string"!=typeof t)return t;if(du(t))return e.machine.getStateNodeById(t);const i=t[0]===yh;if(i&&!e.parent)return vu(e,t.slice(1));const n=i?e.key+t:t;if(!e.parent)throw new Error(`Invalid target: "${t}" is not a valid target from the root node. Did you mean ".${t}"?`);try{return vu(e.parent,n)}catch(t){throw new Error(`Invalid transition definition for state node '${e.id}':\n${t.message}`)}}))}(e,n),a={...i,actions:Nh(i.actions),guard:i.guard,target:s,source:e,reenter:r,eventType:t,toJSON:()=>({...a,source:`#${e.id}`,target:s?s.map((e=>`#${e.id}`)):void 0})};return a}function uu(e){const t=Mh(e.config.target);return t?{target:t.map((t=>"string"==typeof t?vu(e.parent,t):t))}:e.parent.initial}function pu(e){return"history"===e.type}function gu(e){const t=fu(e);for(const i of t)for(const n of nu(i,e))t.add(n);return t}function fu(e){const t=new Set;return function e(i){if(!t.has(i))if(t.add(i),"compound"===i.type)e(i.initial.target[0]);else if("parallel"===i.type)for(const t of iu(i))e(t)}(e),t}function mu(e,t){if(du(t))return e.machine.getStateNodeById(t);if(!e.states)throw new Error(`Unable to retrieve child state '${t}' from '${e.id}'; no child states exist.`);const i=e.states[t];if(!i)throw new Error(`Child state '${t}' does not exist on '${e.id}'`);return i}function vu(e,t){if("string"==typeof t&&du(t))try{return e.machine.getStateNodeById(t)}catch(e){}const i=Rh(t).slice();let n=e;for(;i.length;){const e=i.shift();if(!e.length)break;n=mu(n,e)}return n}function yu(e,t){if("string"==typeof t){const i=e.states[t];if(!i)throw new Error(`State '${t}' does not exist on '${e.id}'`);return[e,i]}const i=Object.keys(t),n=i.map((t=>mu(e,t))).filter(Boolean);return[e.machine.root,e].concat(n,i.reduce(((i,n)=>{const r=mu(e,n);if(!r)return i;const s=yu(r,t[n]);return i.concat(s)}),[]))}function Su(e,t,i,n){return"string"==typeof t?function(e,t,i,n){const r=mu(e,t).next(i,n);return r&&r.length?r:e.next(i,n)}(e,t,i,n):1===Object.keys(t).length?function(e,t,i,n){const r=Object.keys(t),s=Su(mu(e,r[0]),t[r[0]],i,n);return s&&s.length?s:e.next(i,n)}(e,t,i,n):function(e,t,i,n){const r=[];for(const s of Object.keys(t)){const a=t[s];if(!a)continue;const o=Su(mu(e,s),a,i,n);o&&r.push(...o)}return r.length?r:e.next(i,n)}(e,t,i,n)}function bu(e){return Object.keys(e.states).map((t=>e.states[t])).filter((e=>"history"===e.type))}function wu(e,t){let i=e;for(;i.parent&&i.parent!==t;)i=i.parent;return i.parent===t}function Eu(e,t){const i=new Set(e),n=new Set(t);for(const e of i)if(n.has(e))return!0;for(const e of n)if(i.has(e))return!0;return!1}function Cu(e,t,i){const n=new Set;for(const r of e){let e=!1;const s=new Set;for(const a of n)if(Eu(_u([r],t,i),_u([a],t,i))){if(!wu(r.source,a.source)){e=!0;break}s.add(a)}if(!e){for(const e of s)n.delete(e);n.add(r)}}return Array.from(n)}function Tu(e,t){if(!e.target)return[];const i=new Set;for(const n of e.target)if(pu(n))if(t[n.id])for(const e of t[n.id])i.add(e);else for(const e of Tu(uu(n),t))i.add(e);else i.add(n);return[...i]}function $u(e,t){const i=Tu(e,t);if(!i)return;if(!e.reenter&&i.every((t=>t===e.source||wu(t,e.source))))return e.source;const n=function(e){const[t,...i]=e;for(const e of nu(t,void 0))if(i.every((t=>wu(t,e))))return e}(i.concat(e.source));return n||(e.reenter?void 0:e.source.machine.root)}function _u(e,t,i){const n=new Set;for(const r of e)if(r.target?.length){const e=$u(r,i);r.reenter&&r.source===e&&n.add(e);for(const i of t)wu(i,e)&&n.add(i)}return[...n]}function xu(e,t,i,n,r,s){if(!e.length)return t;const a=new Set(t._nodes);let o=t.historyValue;const c=Cu(e,a,o);let d=t;r||([d,o]=function(e,t,i,n,r,s,a){let o=e;const c=_u(n,r,s);let d;c.sort(((e,t)=>t.order-e.order));for(const e of c)for(const t of bu(e)){let i;i="deep"===t.history?t=>tu(t)&&wu(t,e):t=>t.parent===e,d??={...s},d[t.id]=Array.from(r).filter(i)}for(const e of c)o=ku(o,t,i,[...e.exit,...e.invoke.map((e=>Qh(e.id)))],a),r.delete(e);return[o,d||s]}(d,n,i,c,a,o,s)),d=ku(d,n,i,c.flatMap((e=>e.actions)),s),d=function(e,t,i,n,r,s,a,o){let c=e;const d=new Set,l=new Set;(function(e,t,i,n){for(const r of e){const e=$u(r,t);for(const s of r.target||[])pu(s)||r.source===s&&r.source===e&&!r.reenter||(n.add(s),i.add(s)),Ru(s,t,i,n);const s=Tu(r,t);for(const a of s){const s=nu(a,e);"parallel"===e?.type&&s.push(e),Au(n,t,i,s,!r.source.parent&&r.reenter?void 0:e)}}})(n,a,l,d),o&&l.add(e.machine.root);const h=new Set;for(const e of[...d].sort(((e,t)=>e.order-t.order))){r.add(e);const n=[];n.push(...e.entry);for(const t of e.invoke)n.push(Jh(t.src,{...t,syncSnapshot:!!t.onSnapshot}));if(l.has(e)){const t=e.initial.actions;n.push(...t)}if(c=ku(c,t,i,n,s,e.invoke.map((e=>e.id))),"final"===e.type){const n=e.parent;let a="parallel"===n?.type?n:n?.parent,o=a||e;for("compound"===n?.type&&s.push(Eh(n.id,void 0!==e.output?kh(e.output,c.context,t,i.self):void 0));"parallel"===a?.type&&!h.has(a)&&cu(r,a);)h.add(a),s.push(Eh(a.id)),o=a,a=a.parent;if(a)continue;c=Gu(c,{status:"done",output:Iu(c,t,i,c.machine.root,o)})}}return c}(d,n,i,c,a,s,o,r);const l=[...a];"done"===d.status&&(d=ku(d,n,i,l.sort(((e,t)=>t.order-e.order)).flatMap((e=>e.exit)),s));try{return o===t.historyValue&&function(e,t){if(e.length!==t.size)return!1;for(const i of e)if(!t.has(i))return!1;return!0}(t._nodes,a)?d:Gu(d,{_nodes:l,historyValue:o})}catch(e){throw e}}function Iu(e,t,i,n,r){if(void 0===n.output)return;const s=Eh(r.id,void 0!==r.output&&r.parent?kh(r.output,e.context,t,i.self):void 0);return kh(n.output,e.context,s,i.self)}function Ru(e,t,i,n){if(pu(e))if(t[e.id]){const r=t[e.id];for(const e of r)n.add(e),Ru(e,t,i,n);for(const s of r)Pu(s,e.parent,n,t,i)}else{const r=uu(e);for(const s of r.target)n.add(s),r===e.parent?.initial&&i.add(e.parent),Ru(s,t,i,n);for(const s of r.target)Pu(s,e.parent,n,t,i)}else if("compound"===e.type){const[r]=e.initial.target;pu(r)||(n.add(r),i.add(r)),Ru(r,t,i,n),Pu(r,e,n,t,i)}else if("parallel"===e.type)for(const r of iu(e).filter((e=>!pu(e))))[...n].some((e=>wu(e,r)))||(pu(r)||(n.add(r),i.add(r)),Ru(r,t,i,n))}function Au(e,t,i,n,r){for(const s of n)if(r&&!wu(s,r)||e.add(s),"parallel"===s.type)for(const n of iu(s).filter((e=>!pu(e))))[...e].some((e=>wu(e,n)))||(e.add(n),Ru(n,t,i,e))}function Pu(e,t,i,n,r){Au(i,n,r,nu(e,t))}let Du=!1;function Nu(e,t,i,n,r,s){const{machine:a}=e;let o=e;for(const c of n){const d="function"==typeof c,l=d?c:a.implementations.actions["string"==typeof c?c:c.type];if(!l)continue;const h={context:o.context,event:t,self:i.self,system:i.system},u=d||"string"==typeof c?void 0:"params"in c?"function"==typeof c.params?c.params({context:o.context,event:t}):c.params:void 0;function p(){i.system._sendInspectionEvent({type:"@xstate.action",actorRef:i.self,action:{type:"string"==typeof c?c:"object"==typeof c?c.type:c.name||"(anonymous)",params:u}});try{Du=l,l(h,u)}finally{Du=!1}}if(!("resolve"in l)){i.self._processingStatus===Uh.Running?p():i.defer((()=>{p()}));continue}const g=l,[f,m,v]=g.resolve(i,o,h,u,l,r);o=f,"retryResolve"in g&&s?.push([g,m]),"execute"in g&&(i.self._processingStatus===Uh.Running?g.execute(i,m):i.defer(g.execute.bind(null,i,m))),v&&(o=Nu(o,t,i,v,r,s))}return o}function ku(e,t,i,n,r,s){const a=s?[]:void 0,o=Nu(e,t,i,n,{internalQueue:r,deferredActorIds:s},a);return a?.forEach((([e,t])=>{e.retryResolve(i,o,t)})),o}function Ou(e,t,i,n=[]){let r=e;const s=[];function a(e,t,n){i.system._sendInspectionEvent({type:"@xstate.microstep",actorRef:i.self,event:t,snapshot:e,_transitions:n}),s.push(e)}if(t.type===wh)return r=Gu(Fu(r,t,i),{status:"stopped"}),a(r,t,[]),{snapshot:r,microstates:s};let o=t;if(o.type!==bh){const t=o,c=function(e){return e.type.startsWith("xstate.error.actor")}(t),d=Mu(t,r);if(c&&!d.length)return r=Gu(e,{status:"error",error:t.error}),a(r,t,[]),{snapshot:r,microstates:s};r=xu(d,e,i,o,!1,n),a(r,t,d)}let c=!0;for(;"active"===r.status;){let e=c?Hu(r,o):[];const t=e.length?r:void 0;if(!e.length){if(!n.length)break;o=n.shift(),e=Mu(o,r)}r=xu(e,r,i,o,!1,n),c=r!==t,a(r,o,e)}return"active"!==r.status&&Fu(r,o,i),{snapshot:r,microstates:s}}function Fu(e,t,i){return ku(e,t,i,Object.values(e.children).map((e=>Qh(e))),[])}function Mu(e,t){return t.machine.getTransitionData(t,e)}function Hu(e,t){const i=new Set,n=e._nodes.filter(tu);for(const r of n)e:for(const n of[r].concat(nu(r,void 0)))if(n.always)for(const r of n.always)if(void 0===r.guard||eu(r.guard,e.context,t,e)){i.add(r);break e}return Cu(Array.from(i),new Set(e._nodes),e.historyValue)}const Lu=function(e){return Ih(e,this.value)},ju=function(e){return this.tags.has(e)},Bu=function(e){const t=this.machine.getTransitionData(this,e);return!!t?.length&&t.some((e=>void 0!==e.target||e.actions.length))},Uu=function(){const{_nodes:e,tags:t,machine:i,getMeta:n,toJSON:r,can:s,hasTag:a,matches:o,...c}=this;return{...c,tags:Array.from(t)}},Vu=function(){return this._nodes.reduce(((e,t)=>(void 0!==t.meta&&(e[t.id]=t.meta),e)),{})};function qu(e,t){return{status:e.status,output:e.output,error:e.error,machine:t,context:e.context,_nodes:e._nodes,value:ou(t.root,e._nodes),tags:new Set(e._nodes.flatMap((e=>e.tags))),children:e.children,historyValue:e.historyValue||{},matches:Lu,hasTag:ju,can:Bu,getMeta:Vu,toJSON:Uu}}function Gu(e,t={}){return qu({...e,...t},e.machine)}function Ku(e){let t;for(const i in e){const n=e[i];if(n&&"object"==typeof n)if("sessionId"in n&&"send"in n&&"ref"in n)t??=Array.isArray(e)?e.slice():{...e},t[i]={xstate$$type:Bh,id:n.id};else{const r=Ku(n);r!==n&&(t??=Array.isArray(e)?e.slice():{...e},t[i]=r)}}return t??e}function Wu(e,t,i,n,{event:r,id:s,delay:a},{internalQueue:o}){const c=t.machine.implementations.delays;if("string"==typeof r)throw new Error(`Only event objects may be used with raise; use raise({ type: "${r}" }) instead`);const d="function"==typeof r?r(i,n):r;let l;if("string"==typeof a){const e=c&&c[a];l="function"==typeof e?e(i,n):e}else l="function"==typeof a?a(i,n):a;return"number"!=typeof l&&o.push(d),[t,{event:d,id:s,delay:l}]}function zu(e,t){const{event:i,delay:n,id:r}=t;"number"!=typeof n||e.defer((()=>{const t=e.self;e.system.scheduler.schedule(t,t,i,n,r)}))}function Yu(e,{machine:t,context:i},n,r){return(s,a)=>{const o=((s,a={})=>{const{systemId:o,input:c}=a;if("string"==typeof s){const d=jh(t,s);if(!d)throw new Error(`Actor logic '${s}' not implemented in machine '${t.id}'`);const l=Gh(d,{id:a.id,parent:e.self,syncSnapshot:a.syncSnapshot,input:"function"==typeof c?c({context:i,event:n,self:e.self}):c,src:s,systemId:o});return r[l.id]=l,l}return Gh(s,{id:a.id,parent:e.self,syncSnapshot:a.syncSnapshot,input:a.input,src:s,systemId:o})})(s,a);return r[o.id]=o,e.defer((()=>{o._processingStatus!==Uh.Stopped&&o.start()})),o}}function Ju(e,t,i,n,{assignment:r}){if(!t.context)throw new Error("Cannot assign to undefined `context`. Ensure that `context` is defined in the machine config.");const s={},a={context:t.context,event:i.event,spawn:Yu(e,t,i.event,s),self:e.self,system:e.system};let o={};if("function"==typeof r)o=r(a,n);else for(const e of Object.keys(r)){const t=r[e];o[e]="function"==typeof t?t(a,n):t}return[Gu(t,{context:Object.assign({},t.context,o),children:Object.keys(s).length?{...t.children,...s}:t.children})]}function Zu(e){function t(e,t){}return t.type="xstate.assign",t.assignment=e,t.resolve=Ju,t}const Xu=new WeakMap;function Qu(e,t,i){let n=Xu.get(e);return n?t in n||(n[t]=i()):(n={[t]:i()},Xu.set(e,n)),n[t]}const ep={},tp=e=>"string"==typeof e?{type:e}:"function"==typeof e?"resolve"in e?{type:e.type}:{type:e.name}:e;class ip{constructor(e,t){if(this.config=e,this.key=void 0,this.id=void 0,this.type=void 0,this.path=void 0,this.states=void 0,this.history=void 0,this.entry=void 0,this.exit=void 0,this.parent=void 0,this.machine=void 0,this.meta=void 0,this.output=void 0,this.order=-1,this.description=void 0,this.tags=[],this.transitions=void 0,this.always=void 0,this.parent=t._parent,this.key=t._key,this.machine=t._machine,this.path=this.parent?this.parent.path.concat(this.key):[],this.id=this.config.id||[this.machine.id,...this.path].join(yh),this.type=this.config.type||(this.config.states&&Object.keys(this.config.states).length?"compound":this.config.history?"history":"atomic"),this.description=this.config.description,this.order=this.machine.idMap.size,this.machine.idMap.set(this.id,this),this.states=this.config.states?Ph(this.config.states,((e,t)=>new ip(e,{_parent:this,_key:t,_machine:this.machine}))):ep,"compound"===this.type&&!this.config.initial)throw new Error(`No initial state specified for compound state node "#${this.id}". Try adding { initial: "${Object.keys(this.states)[0]}" } to the state config.`);this.history=!0===this.config.history?"shallow":this.config.history||!1,this.entry=Nh(this.config.entry).slice(),this.exit=Nh(this.config.exit).slice(),this.meta=this.config.meta,this.output="final"!==this.type&&this.parent?void 0:this.config.output,this.tags=Nh(e.tags).slice()}_initialize(){this.transitions=function(e){const t=new Map;if(e.config.on)for(const i of Object.keys(e.config.on)){if(""===i)throw new Error('Null events ("") cannot be specified as a transition key. Use `always: { ... }` instead.');const n=e.config.on[i];t.set(i,Fh(n).map((t=>hu(e,i,t))))}if(e.config.onDone){const i=`xstate.done.state.${e.id}`;t.set(i,Fh(e.config.onDone).map((t=>hu(e,i,t))))}for(const i of e.invoke){if(i.onDone){const n=`xstate.done.actor.${i.id}`;t.set(n,Fh(i.onDone).map((t=>hu(e,n,t))))}if(i.onError){const n=`xstate.error.actor.${i.id}`;t.set(n,Fh(i.onError).map((t=>hu(e,n,t))))}if(i.onSnapshot){const n=`xstate.snapshot.${i.id}`;t.set(n,Fh(i.onSnapshot).map((t=>hu(e,n,t))))}}for(const i of e.after){let e=t.get(i.eventType);e||(e=[],t.set(i.eventType,e)),e.push(i)}return t}(this),this.config.always&&(this.always=Fh(this.config.always).map((e=>hu(this,"",e)))),Object.keys(this.states).forEach((e=>{this.states[e]._initialize()}))}get definition(){return{id:this.id,key:this.key,version:this.machine.version,type:this.type,initial:this.initial?{target:this.initial.target,source:this,actions:this.initial.actions.map(tp),eventType:null,reenter:!1,toJSON:()=>({target:this.initial.target.map((e=>`#${e.id}`)),source:`#${this.id}`,actions:this.initial.actions.map(tp),eventType:null})}:void 0,history:this.history,states:Ph(this.states,(e=>e.definition)),on:this.on,transitions:[...this.transitions.values()].flat().map((e=>({...e,actions:e.actions.map(tp)}))),entry:this.entry.map(tp),exit:this.exit.map(tp),meta:this.meta,order:this.order||-1,output:this.output,invoke:this.invoke,description:this.description,tags:this.tags}}toJSON(){return this.definition}get invoke(){return Qu(this,"invoke",(()=>Nh(this.config.invoke).map(((e,t)=>{const{src:i,systemId:n}=e,r=e.id??Lh(this.id,t),s="string"==typeof i?i:`xstate.invoke.${Lh(this.id,t)}`;return{...e,src:s,id:r,systemId:n,toJSON(){const{onDone:t,onError:i,...n}=e;return{...n,type:"xstate.invoke",src:s,id:r}}}}))))}get on(){return Qu(this,"on",(()=>[...this.transitions].flatMap((([e,t])=>t.map((t=>[e,t])))).reduce(((e,[t,i])=>(e[t]=e[t]||[],e[t].push(i),e)),{})))}get after(){return Qu(this,"delayedTransitions",(()=>lu(this)))}get initial(){return Qu(this,"initial",(()=>function(e,t){const i="string"==typeof t?e.states[t]:t?e.states[t.target]:void 0;if(!i&&t)throw new Error(`Initial state node "${t}" not found on parent state node #${e.id}`);const n={source:e,actions:t&&"string"!=typeof t?Nh(t.actions):[],eventType:null,reenter:!1,target:i?[i]:[],toJSON:()=>({...n,source:`#${e.id}`,target:i?[`#${i.id}`]:[]})};return n}(this,this.config.initial)))}next(e,t){const i=t.type,n=[];let r;const s=Qu(this,`candidates-${i}`,(()=>function(e,t){const i=e.transitions.get(t)||[...e.transitions.keys()].filter((e=>{if("*"===e)return!0;if(!e.endsWith(".*"))return!1;const i=e.split("."),n=t.split(".");for(let e=0;e<i.length;e++){const t=i[e],r=n[e];if("*"===t)return e===i.length-1;if(t!==r)return!1}return!0})).sort(((e,t)=>t.length-e.length)).flatMap((t=>e.transitions.get(t)));return i}(this,i)));for(const a of s){const{guard:s}=a,o=e.context;let c=!1;try{c=!s||eu(s,o,t,e)}catch(e){const t="string"==typeof s?s:"object"==typeof s?s.type:void 0;throw new Error(`Unable to evaluate guard ${t?`'${t}' `:""}in transition for event '${i}' in state node '${this.id}':\n${e.message}`)}if(c){n.push(...a.actions),r=a;break}}return r?[r]:void 0}get events(){return Qu(this,"events",(()=>{const{states:e}=this,t=new Set(this.ownEvents);if(e)for(const i of Object.keys(e)){const n=e[i];if(n.states)for(const e of n.events)t.add(`${e}`)}return Array.from(t)}))}get ownEvents(){const e=new Set([...this.transitions.keys()].filter((e=>this.transitions.get(e).some((e=>!(!e.target&&!e.actions.length&&!e.reenter))))));return Array.from(e)}}class np{constructor(e,t){this.config=e,this.version=void 0,this.schemas=void 0,this.implementations=void 0,this.__xstatenode=!0,this.idMap=new Map,this.root=void 0,this.id=void 0,this.states=void 0,this.events=void 0,this.__TResolvedTypesMeta=void 0,this.id=e.id||"(machine)",this.implementations={actors:t?.actors??{},actions:t?.actions??{},delays:t?.delays??{},guards:t?.guards??{}},this.version=this.config.version,this.schemas=this.config.schemas,this.transition=this.transition.bind(this),this.getInitialSnapshot=this.getInitialSnapshot.bind(this),this.getPersistedSnapshot=this.getPersistedSnapshot.bind(this),this.restoreSnapshot=this.restoreSnapshot.bind(this),this.start=this.start.bind(this),this.root=new ip(e,{_key:this.id,_machine:this}),this.root._initialize(),this.states=this.root.states,this.events=this.root.events}provide(e){const{actions:t,guards:i,actors:n,delays:r}=this.implementations;return new np(this.config,{actions:{...t,...e.actions},guards:{...i,...e.guards},actors:{...n,...e.actors},delays:{...r,...e.delays}})}resolveState(e){const t=(i=this.root,n=e.value,ou(i,[...ru(yu(i,n))]));var i,n;const r=ru(yu(this.root,t));return qu({_nodes:[...r],context:e.context||{},children:{},status:cu(r,this.root)?"done":e.status||"active",output:e.output,error:e.error,historyValue:e.historyValue},this)}transition(e,t,i){return Ou(e,t,i).snapshot}microstep(e,t,i){return Ou(e,t,i).microstates}getTransitionData(e,t){return Su(this.root,e.value,e,t)||[]}getPreInitialState(e,t,i){const{context:n}=this.config,r=qu({context:"function"!=typeof n&&n?n:{},_nodes:[this.root],children:{},status:"active"},this);if("function"==typeof n){return ku(r,t,e,[Zu((({spawn:e,event:t,self:i})=>n({spawn:e,input:t.input,self:i})))],i)}return r}getInitialSnapshot(e,t){const i=Ch(t),n=[],r=this.getPreInitialState(e,i,n),s=xu([{target:[...fu(this.root)],source:this.root,reenter:!0,actions:[],eventType:null,toJSON:null}],r,e,i,!0,n),{snapshot:a}=Ou(s,i,e,n);return a}start(e){Object.values(e.children).forEach((e=>{"active"===e.getSnapshot().status&&e.start()}))}getStateNodeById(e){const t=Rh(e),i=t.slice(1),n=du(t[0])?t[0].slice(1):t[0],r=this.idMap.get(n);if(!r)throw new Error(`Child state node '#${n}' does not exist on machine '${this.id}'`);return vu(r,i)}get definition(){return this.root.definition}toJSON(){return this.definition}getPersistedSnapshot(e,t){return function(e,t){const{_nodes:i,tags:n,machine:r,children:s,context:a,can:o,hasTag:c,matches:d,getMeta:l,toJSON:h,...u}=e,p={};for(const e in s){const i=s[e];p[e]={snapshot:i.getPersistedSnapshot(t),src:i.src,systemId:i._systemId,syncSnapshot:i._syncSnapshot}}return{...u,context:Ku(a),children:p}}(e,t)}restoreSnapshot(e,t){const i={},n=e.children;Object.keys(n).forEach((e=>{const r=n[e],s=r.snapshot,a=r.src,o="string"==typeof a?jh(this,a):a;if(!o)return;const c=Gh(o,{id:e,parent:t.self,syncSnapshot:r.syncSnapshot,snapshot:s,src:a,systemId:r.systemId});i[e]=c}));const r=qu({...e,children:i,_nodes:Array.from(ru(yu(this.root,e.value)))},this);let s=new Set;return function e(t,i){if(!s.has(t)){s.add(t);for(let n in t){const r=t[n];if(r&&"object"==typeof r){if("xstate$$type"in r&&r.xstate$$type===Bh){t[n]=i[r.id];continue}e(r,i)}}}}(r.context,i),r}}function rp({schemas:e,actors:t,actions:i,guards:n,delays:r}){return{createMachine:s=>function(e,t){return new np(e,t)}({...s,schemas:e},{actors:t,actions:i,guards:n,delays:r})}}class sp extends Error{state;constructor(e,t){super(e),this.state=t}}const ap="unregistered",op="registering",cp="registered",dp="register",lp="registerDone",hp="unregister",up="unregistered",pp="transportClosed",gp=rp({}).createMachine({id:"softphone",initial:ap,context:{},states:{[ap]:{on:{[dp]:op}},[op]:{on:{[lp]:cp,[pp]:ap,[up]:ap}},[cp]:{on:{[hp]:ap,[pp]:ap}}}}),fp=B.loggerFor("sip.js"),mp=B.loggerFor("sip"),vp=["Received WebSocket text message:","Sending WebSocket message:"],yp=(e,t,i,n)=>{const r=n&&n.indexOf?vp.findIndex((e=>-1!==n.indexOf(e))):-1;if("sip.Transport"===t&&-1!==r){const e=0===r?"receiving":"sending",i=n.replace(`${vp[r]}\n\n`,"").replace("\r\n","\n");mp.trace(i,{className:t,direction:e})}else fp.trace(n,{className:t})},Sp="idle",bp="ringing",wp="progress",Ep="established",Cp="terminated",Tp="ongoing",$p="held",_p="muted",xp="incomingCall",Ip="makeCall",Rp="accept",Ap="remotlyAccepted",Pp="reject",Dp="hangup",Np="hold",kp="resume",Op="mute",Fp="unMute",Mp=rp({guards:{isRegistered:()=>eg.state===cp}}).createMachine({id:"call",initial:Sp,context:{},states:{[Sp]:{on:{[xp]:{guard:"isRegistered",target:bp},[Ip]:{guard:"isRegistered",target:wp}}},[wp]:{on:{[Dp]:{guard:"isRegistered",target:Cp},[Ap]:{guard:"isRegistered",target:Ep}}},[bp]:{on:{[Rp]:{guard:"isRegistered",target:Ep},[Pp]:{guard:"isRegistered",target:Cp}}},[Ep]:{initial:Tp,on:{[Dp]:{guard:"isRegistered",target:Cp},[Np]:{guard:"isRegistered",target:`.${$p}`},[Op]:{guard:"isRegistered",target:`.${_p}`}},states:{[Tp]:{},[$p]:{on:{[kp]:{guard:"isRegistered",target:Tp}}},[_p]:{on:{[Fp]:{guard:"isRegistered",target:Tp}}}}},[Cp]:{}}});class Hp extends Error{state;action;constructor(e,t,i){super(e),this.action=t,this.state=i}}const Lp=B.loggerFor("state-machine"),jp=e=>e.getSnapshot().value,Bp=(e,t)=>e.getSnapshot().can({type:t}),Up=(e,t)=>{if(!Bp(e,t)){const i=e.getSnapshot().value,n=`Invalid state transition from ${i} with action ${t}`;throw Lp.warn(n),new Hp(n,t,i)}},Vp=(e,t)=>{if(!((e,t)=>jp(e)===t)(e,t)){const e=`Invalid state ${t}`;throw Lp.warn(e),new sp(e,t)}},qp=B.loggerFor("call"),Gp="message/TYPE_SIGNAL";class Kp extends Oi.EventEmitter{callActor;apiId;sipCall;talkingToIds;creationTime;answerTime;endTime;phone;shouldSendReinvite=!1;recording=!1;displayName;number;currentScreenShare;static newFrom(e){return Ut(e,Kp)}static parseCall(e){const t={id:e.sipCallId,stateChange:{addListener:()=>{}},remoteIdentity:{uri:{_normal:{user:e.calleeNumber}}},sessionDescriptionHandler:{localMediaStream:{getTracks:()=>e.isVideo?[{kind:"video",readyState:"live"}]:[]}}},i=new Kp(t,eg);i.apiId=e.id,i.answerTime=new Date(+e.startingTime);const n=i.callActor.getSnapshot();return e.isUp()&&(n.value={[Ep]:Tp}),e.muted&&(n.value={[Ep]:_p}),e.isRinging()&&(n.value=bp),e.isRecording()&&(i.recording=!0),i.callActor.update(n),i}constructor(e,t){super(),this.callActor=Gh(Mp),this.callActor.start(),this.creationTime=new Date,this.phone=t,this.sipCall=e,this.number=js(e),this.displayName=Bs(e),this._bindEvents()}async accept(e={}){return Up(this.callActor,Rp),qp.info("call - accept",{id:this.id,...e}),this._sendAction(Rp),this.phone.holdAllCalls(this),this.shouldSendReinvite=!1,this.answerTime=new Date,this.phone.client.answer(this.sipCall,e.withCamera).then((()=>(qp.info("call - accepted",{id:this.id,...e}),this.emit("locallyAccepted",this),this.id))).catch((e=>{throw qp.error(e),this.hangup(),e}))}async reject(){return Up(this.callActor,Pp),qp.info("call - reject",{id:this.id}),this.phone.emit(Yp,"call rejected locally"),this.shouldSendReinvite=!1,this.hangup()}async hangup(){return Up(this.callActor,Dp),qp.info("call - hangup",{id:this.id}),await this.phone.client.hangup(this.sipCall),this.phone.onCallTerminated(this),!0}forceCancel(){try{this.sipCall.outgoingInviteRequest.cancel()}catch(e){qp.info("call - force cancel, error",e)}}startConference(){}mute(){Up(this.callActor,Op),qp.info("call - mute",{id:this.id}),this._sendAction(Op),this.phone.client.mute(this.sipCall),this.emit("muted")}unMute(){Up(this.callActor,Fp),qp.info("call - un-mute",{id:this.id}),this._sendAction(Fp),this.phone.client.unmute(this.sipCall),this.emit("unMuted")}async hold(){Up(this.callActor,Np),qp.info("call - hold",{id:this.id}),this._sendAction(Np);const e=na(this.sipCall);this.currentScreenShare&&this.currentScreenShare.sipSessionId===this.id&&await this.stopScreenSharing(!1),e&&await Ea(this.sipCall);const t=this.phone.client.hold(this.sipCall,this.isConference(),e);return this.emit("held"),t}async resume(){Up(this.callActor,kp),this._sendAction(kp);const e=this.isConference(),t=na(this.sipCall),i=this.currentScreenShare&&this.currentScreenShare.sipSessionId===this.id,n=this.currentScreenShare&&this.currentScreenShare.desktop;qp.info("call - resume",{id:this.id,isConference:e,hasVideo:t,wasScreensharing:i,wasDesktop:n});const r=this.phone.client.unhold(this.sipCall,e);if(t){const t={audio:!1,video:!0,screen:i,desktop:n};await Ca(this.sipCall,t,e)}const s=e=>{const t=this.currentScreenShare&&this.currentScreenShare.hadVideo;e&&this._onScreenSharing(e,t,n)};return this.emit("resumed"),r.then((()=>{const e=this.getLocalVideoStream();return i&&s(this.getLocalVideoStream()),e}))}turnCameraOn(){Vp(this.callActor,Ep),qp.info("call - turn camera on",{id:this.id}),ga(this.sipCall,!0),this.emit("onCameraResumed")}turnCameraOff(){Vp(this.callActor,Ep),qp.info("call - turn camera off",{id:this.id}),ga(this.sipCall,!1),this.emit("onCameraDisabled")}isMuted(){return this._hasEstablishedState(_p)}isCameraMuted(){return(e=>{const t=e.sessionDescriptionHandler,i=t?.peerConnection;if(i?.getSenders){for(const e of i.getSenders())if(e&&e.track&&"video"===e.track.kind)return!e.track.enabled}else for(const e of i.getLocalStreams())for(const t of e.getVideoTracks())return!t.enabled;return!0})(this.sipCall)}isHeld(){return this._hasEstablishedState($p)}isEstablishing(){return this.sipCall.state===mi.Establishing}isEstablished(){return Ep in this.state}isRinging(){return this.state===bp}isOutgoing(){return this.sipCall instanceof yr}isIncoming(){return!this.isOutgoing()}isConference(){return Xs(this.sipCall)?.sfu}transfer(e){return Vp(this.callActor,Ep),qp.info("call - transfer",{id:this.id,target:e}),this.phone.client.transfer(this.sipCall,e)}atxfer(){return Vp(this.callActor,Ep),qp.info("call - atxfer",{id:this.id}),this.phone.client.atxfer(this.sipCall)}sendDigits(e){Vp(this.callActor,Ep),qp.info("call - send digits",{id:this.id,digits:e}),this.phone.client.sendDTMF(this.sipCall,e)}startNetworkMonitoring(e=1e3){return Vp(this.callActor,Ep),qp.info("call - start network monitoring",{id:this.id}),this.phone.client.startNetworkMonitoring(this.sipCall,e)}stopNetworkMonitoring(){return Vp(this.callActor,Ep),qp.info("call - stop network monitoring",{id:this.id}),this.phone.client.stopNetworkMonitoring(this.sipCall)}async getStats(){return ua(this.sipCall)}async sendReinvite(e={}){Vp(this.callActor,Ep),qp.info("call - send reinvite",{id:this.id,...e});const t=e.constraints?.screen,i=t||e.constraints?.video;if(!e.constraints||i){if(i){if(!await this._upgradeToVideo(e))return}return this.phone.client.reinvite(this.sipCall,e.constraints,e.conference,e.audioOnly,e.iceRestart)}this._downgradeToAudio()}sendMessage(e,t="text/plain"){return Vp(this.callActor,Ep),qp.info("call - send message",{id:this.id,body:e}),this.phone.client.sendMessage(this.sipCall,e,t)}sendChat(e){Vp(this.callActor,Ep),qp.info("call - send chat",{id:this.id,content:e}),this.sendMessage(JSON.stringify({type:"message/TYPE_CHAT",content:e}),"application/json")}sendSignal(e){Vp(this.callActor,Ep),qp.info("call - send signal",{id:this.id,content:e}),this.sendMessage(JSON.stringify({type:Gp,content:e}),"application/json")}async startScreenSharing(e){Vp(this.callActor,Ep),qp.info("call - start screen sharing",{constraints:e,id:this.id});const t=await wa(e);if(!t)throw new Error(`Can't create media stream for screensharing with: ${JSON.stringify(e)}`);const i=t.getVideoTracks()[0],n=Xs(this.sipCall),r=n&&n.getSenders&&n.getSenders().find((e=>e&&e.track&&"video"===e.track.kind)),s=Qs(this.sipCall),a=s?s.getTracks().find((e=>"video"===e.kind)):null,o=!!a;return a&&s&&(a.enabled=!1,a.stop(),s.removeTrack(a)),s&&s.addTrack(i),r&&r.replaceTrack(i),this._onScreenSharing(t,o,e.desktop),t}async stopScreenSharing(e=!0){if(Vp(this.callActor,Ep),!this.currentScreenShare)return;qp.info("call - stop screen sharing",{restoreLocalStream:e});let t=null;try{if(this.currentScreenShare.stream&&this.currentScreenShare.stream.getTracks().filter((e=>e.enabled&&"video"===e.kind)).forEach((e=>e.stop())),e){const e=this.isConference(),i={audio:!1,video:this.currentScreenShare.hadVideo};this._downgradeToAudio(!1),await new Promise((e=>setTimeout(e,500))),t=await this.sendReinvite({constraints:i,conference:e})}}catch(e){console.warn(e)}return this.emit("onScreenShareEnded"),this.currentScreenShare=null,t}onScreenShareReinvite(e,t){const i=Qs(this.sipCall);qp.info("call - updrading directly in screensharing mode",{id:this.id,tracks:i?.getTracks()}),this._onScreenSharing(i,!1,t)}onAccepted(){this._sendAction(Ap),this.emit("remotelyAccepted")}onProgress(){this.emit("progress")}onEarlyMedia(){this.emit("earlyMedia")}onTrack(e){this.emit("track",e)}onError(e){this.emit("error",e)}onCallIncoming(){this._sendAction(xp)}onRejected(){this.endTime=new Date,this.emit("rejected"),this.phone.onCallTerminated(this)}onNetworkStats(e,t){this.emit("webRtcStats",e,t)}getRemoteStream(){return ta(this.sipCall)}getRemoteVideoStream(){return la(this.sipCall)}hasRemoteVideo(){return ca(this.sipCall)}hasLocalVideo(){return na(this.sipCall)}getLocalStream(){return Qs(this.sipCall)}getLocalVideoStream(){return sa(this.sipCall)}hasALocalVideoTrack(){return ra(this.sipCall)}isVideoRemotelyHeld(){return oa(this.sipCall)}onReinvite(e,t,i,n){this.emit("reinvite",e,t,i,n)}updateFrom(e){vi(this,e)}is(e){return e&&this.id&&this.id===e.id}shouldAutoAnswer(){return!!this.sipCall.request?.getHeader("alert-info")}get id(){return Ms(this.sipCall)}get state(){return jp(this.callActor)}_hasEstablishedState(e){const t=this.state;return"object"==typeof t&&Ep in t&&t[Ep]===e}_bindEvents(){if(this.sipCall instanceof yr){const e=this.sipCall._onCancel.bind(this.sipCall);this.sipCall._onCancel=t=>{qp.trace("call - on sip session canceled",{callId:t.callId,id:this.id}),e(t);const i=-1!==t.data.indexOf("cause=26")&&-1!==t.data.indexOf("completed elsewhere");this.emit("canceled",i)}}if(this.sipCall?.stateChange?.addListener((e=>{switch(e){case mi.Terminating:qp.info("call - terminating",{id:this.id}),this.emit("terminating");break;case mi.Terminated:return qp.info("call - terminated",{id:this.id}),this.endTime=new Date,this.emit("ended"),this.phone.onCallTerminated(this)}})),!this.sipCall.sessionDescriptionHandler)return;const e=this.sipCall.sessionDescriptionHandler.peerConnection;e?(e.ontrack=e=>{const t=e,[i]=t.streams,n=t&&t.track&&t.track.kind;return qp.info("call - on track stream called on the peer connection",{id:this.id,streamId:i?i.id:null,tracks:i?i.getTracks():null,kind:n}),"audio"===n?this.emit("onAudioStream",i):this.emit("onVideoStream",i,t.track.id,t)},e.onremovestream=e=>{qp.info("call - on remove stream called on the peer connection",{id:e.stream.id,tracks:e.stream.getTracks()}),this.emit("onRemoveStream",e.stream)}):qp.warn("call - no peer connection",{id:this.id})}_downgradeToAudio(e=!0){return Vp(this.callActor,Ep),qp.info("call - downgrade to audio",{id:this.id,withMessage:e}),Ea(this.sipCall),e&&this._sendReinviteMessage(!1),!0}async _upgradeToVideo(e={}){Vp(this.callActor,Ep),qp.info("call - upgrade to video",{id:this.id,...e});const t=e.constraints?.screen,i=e.constraints?.desktop,n=this.sipCall.sessionDescriptionHandlerOptionsReInvite,r=n?.audioOnly,s=await Ca(this.sipCall,e.constraints||{},!!e.conference);return!s||(this._sendReinviteMessage(!0),t&&this._onScreenSharing(s,!1,i),!(!e.conference||!r))}_sendReinviteMessage(e){Vp(this.callActor,Ep),qp.info("call - sending reinvite message",{id:this.id,isUpgrade:e}),setTimeout((()=>{this.sendMessage(JSON.stringify({type:Gp,content:{type:"onTrackUpdated",update:e?"upgrade":"downgrade",sipCallId:this.id,callId:this.apiId,number:this.number}}))}),2500)}_onScreenSharing(e,t,i){const n=e.getVideoTracks()[0],r=this.phone.client.getPeerConnection(this.id),s=r&&r.getSenders&&r.getSenders().find((e=>e&&e.track&&"video"===e.track.kind));qp.info("call - on screensharing",{hadVideo:t,id:this.id,screenTrack:n}),n&&(n.onended=()=>{qp.info("call - on screenshare ended",{hadVideo:t,id:this.id,screenTrack:n}),this.emit("onScreenShareEnding")}),this.currentScreenShare={stream:e,hadVideo:t,sender:s,desktop:i},ma(this.sipCall,e),this.emit("onScreenShareStarted",e)}_sendAction(e){this.callActor.send({type:e})}}const Wp="incoming",zp="disconnected",Yp="terminateSound",Jp="playRingSound",Zp="playInboundCallSound",Xp=B.loggerFor("softphone");class Qp extends Oi.EventEmitter{audioOutputDeviceId;audioRingDeviceId;audioOutputVolume;audioRingVolume;calls;client;session;sipLine;softphoneActor;options;shouldSendReinvite;ringingEnabled=!0;constructor(){super(),this.calls=[],this.softphoneActor=Gh(gp),this.softphoneActor.start()}connect(e={}){this.calls=[],this.options=e,this.audioOutputVolume=1,this.audioRingVolume=1;const t=ig.Auth.getHost(),i=ig.Auth.getSession();if(!t||!i)throw new Error("Please connect to the server using `Wazo.Auth.logIn` or `Wazo.Auth.authenticate` before using Room.connect().");if(this.session=i,this.sipLine=this.getPrimaryWebRtcLine(),!this.sipLine)throw new Error("Sorry, no sip lines found for this user");return this.options.userUuid=i.uuid||"",this.connectWithCredentials(t,this.sipLine,i.displayName(),e)}async hangupAllCalls(){return Promise.all(this.calls.map((e=>e.hangup())))}async disconnect(){return Up(this.softphoneActor,hp),this.client?(await this.hangupAllCalls(),this.client.unregister()):null}getPrimaryWebRtcLine(){return this.session?.primaryWebRtcLine()||null}async connectWithCredentials(e,t,i,n={}){Up(this.softphoneActor,dp),this.softphoneActor.send({type:dp});const[r,s=443]=e.split(":");let a={...n};return a.media=a.media||{audio:!0,video:!1},a.uaConfigOverrides=a.uaConfigOverrides||{},B.enabled&&(a=((e={})=>{const t=e;return t.uaConfigOverrides&&(t.uaConfigOverrides.traceSip=!0),t.log=t.log||{},t.log.builtinEnabled=!1,t.log.logLevel="debug",t.log.connector=yp,t})(a)),this.client=new Zc({host:r,port:"string"==typeof s?parseInt(s,10):s,displayName:i,authorizationUser:t.username,password:t.secret,uri:`${t.username}@${e}`,...a},void 0,a.uaConfigOverrides),this._bindEvents(),this.client.register().catch((e=>{Xp.error("softphone - register error",{message:e.message,stack:e.stack}),this._sendAction(hp)}))}reconnect(){Xp.info("softphone - reconnect",{client:!!this.client}),this.client&&this.client.attemptReconnection()}async call(e){if(Xp.info("softphone - call",e),!e.params.To)return Xp.warn("softphone - calling with empty number, bailing."),Promise.resolve(null);if(this.state===op&&(Xp.info("softphone - calling when registering, waiting for Softphone to be registered ..."),await((e,t,i=5e3)=>Promise.race([new Promise((i=>{e.subscribe((e=>{e.value===t&&i(null)}))})),new Promise(((e,n)=>setTimeout((()=>n(new Error(`Waited for state ${t} timeout.`))),i)))]))(this.softphoneActor,cp)),this.state!==ap)throw new sp(`Invalid state ${ap}`,ap);let t;this.holdAllCalls();try{t=this.client.call(e.params.To,e.withCamera,e.audioOnly,e.conference,e);const i=new Kp(t,this);return this.emit("outgoing",i),i}catch(e){return Xp.warn("softphone - call, error",{message:e.message,stack:e.stack}),Promise.resolve(null)}}removeCall(e){this.calls=this.calls.filter((t=>t.id!==e.id))}onCallTerminated(e){Xp.info("softphone - on call terminated",{id:e.id});const t=this.getCurrentCall(),i=t?.id===e.id,n=e.isRinging(),r=i&&n,s=this.getIncomingCalls(),a=s.length;r&&setTimeout((()=>{this.emit(Yp,e,"call terminated")}),5);const o=i?a:r;if(Xp.info("Softphone - check to re-trigger incoming call",{shouldRetrigger:o,nbIncomingCalls:a}),o&&a>1){const i=s.find((t=>t.id!==e.id));setTimeout((()=>{this.ringingEnabled&&(t?this.emit(Jp,this.audioRingDeviceId,this.audioRingVolume,i):this.emit(Zp,this.audioOutputDeviceId,this.audioOutputVolume,i)),this.emit(Wp,i)}),100)}e.sipCall.isCanceled||setTimeout((()=>{this.emit("playHangupSound",this.audioOutputDeviceId,this.audioOutputVolume,e)}),10),this.client.onCallEnded(e.sipCall),this.removeCall(e)}enableRinging(){Xp.info("softphone - enable ringing"),this.ringingEnabled=!0}disableRinging(){Xp.info("softphone - disable ringing"),this.ringingEnabled=!1}holdAllCalls(e=null){this.calls.filter((t=>!t.isHeld()&&t.id===e?.id)).forEach((e=>e.hold()))}startHeartbeat(){Xp.info("softphone - start heartbeat",{client:!!this.client,hasHeartbeat:this.client.hasHeartbeat()}),this.client&&!this.client.hasHeartbeat()&&this.client.startHeartbeat()}stopHeartbeat(){Xp.info("softphone - stop heartbeat",{client:!!this.client}),this.client&&this.client.stopHeartbeat()}setMediaConstraints(e){this.client.setMediaConstraints(e)}changeAudioOutputDevice(e){return Xp.info("softphone - change audio device",{deviceId:e}),this.audioOutputDeviceId=e,this.client.changeAudioOutputDevice(e)}changeAudioInputDevice(e,t){Xp.info("softphone - changeAudio input device",{deviceId:e});const i=this.getCurrentCall();return this.client.changeAudioInputDevice(e,i?.sipCall,t)}changeVideoInputDevice(e){Xp.info("softphone - change video input device",{deviceId:e});const t=this.getCurrentCall();return this.client.changeVideoInputDevice(e,t?.sipCall)}changeRingDevice(e){Xp.info("softphone - changing ring device",{id:e}),this.audioRingDeviceId=e}hasSfu(){return this.sipLine?.hasVideoConference()||!1}changeAudioVolume(e){Xp.info("softphone - changing audio volume",{volume:e}),this.audioOutputVolume=e,this.client.changeAudioOutputVolume(e)}changeRingVolume(e){Xp.info("softphone - changing ring volume",{volume:e}),this.audioRingVolume=e}getCurrentCall(){return this.getActiveCalls()[0]}getActiveCalls(){return this.calls.filter((e=>e.isEstablished()))}getIncomingCalls(){return this.calls.filter((e=>e.isRinging()))}get state(){return jp(this.softphoneActor)}get user(){return this.client?.userAgent?.contact?.uri?.user}getUserAgent(){return this.client?.config?.userAgentString||"softphone"}isRegistered(){return this.state===cp}_bindEvents(){this.client.on(this.client.INVITE,(e=>{const t=new Kp(e,this);Xp.info("softphone - on invite",{callId:t.id,number:t.number}),t.onCallIncoming(),this.calls.push(t),this.emit(Wp,t),this.getCurrentCall()?this.emit(Zp,this.audioOutputDeviceId,this.audioOutputVolume,t):this.ringingEnabled&&this.emit(Jp,this.audioRingDeviceId,this.audioRingVolume,t)})),this.client.on(this.client.ON_REINVITE,((e,t,i,n,r)=>{Xp.info("softphone - on reinvite",{callId:e.id,inviteId:t.callId,updatedCalleeName:i,updatedNumber:n,hadRemoteVideo:r}),this._onCallEvent(e,"onReinvite",t,i,n,r)})),this.client.on(this.client.ACCEPTED,(async e=>{const t=this._getCall(e);this.emit(Yp,t,"call accepted"),this._onCallEvent(e,"onAccepted"),this.audioOutputDeviceId&&await this.client.changeAudioOutputDevice(this.audioOutputDeviceId)})),this.client.on(this.client.ON_ERROR,((e,t)=>{this._onCallEvent(t,"onError",e)})),this.client.on(this.client.REJECTED,(e=>{this._onCallEvent(e,"onRejected")})),this.client.on(this.client.ON_PROGRESS,(e=>{this._onCallEvent(e,"onProgress")})),this.client.on(this.client.ON_EARLY_MEDIA,(e=>{this._onCallEvent(e,"onEarlyMedia")})),this.client.on(this.client.ON_TRACK,((e,t)=>{this._onCallEvent(e,"onTrack",t)})),this.client.on(this.client.ON_NETWORK_STATS,((e,t,i)=>{this._onCallEvent(e,"onNetworkStats",t,i)})),this.client.on(this.client.ON_SCREEN_SHARING_REINVITE,((e,t,i)=>{this._onCallEvent(e,"onScreenshareReinvite",t,i)})),this.client.on(this.client.UNREGISTERED,(()=>{Xp.info("softphone - unregistered"),this.emit("unregistered"),this._sendAction(up)})),this.client.on(this.client.ON_DISCONNECTED,(()=>{Xp.info("softphone - disconnected"),this.emit(zp),this._sendAction(pp)})),this.client.on(this.client.REGISTERED,(()=>{Xp.info("softphone - registered",{state:jp(this.softphoneActor)}),Bp(this.softphoneActor,lp)?(this.stopHeartbeat(),this._sendAction(lp),this.emit("registered"),this.shouldSendReinvite&&(this.shouldSendReinvite=!1,this.calls.filter((e=>e.isEstablished())).forEach((e=>{e.sendReinvite({conference:e.isConference(),iceRestart:!0})})))):Xp.warn("softphone - registered but not in REGISTERING state",{state:jp(this.softphoneActor)})})),this.client.on(this.client.CONNECTED,(()=>{Xp.info("softphone - connected"),this.stopHeartbeat()})),this.client.on(this.client.DISCONNECTED,(()=>{Xp.info("softphone - disconnected"),this.emit(zp),this.client.hasHeartbeat()||this.startHeartbeat(),this.shouldSendReinvite=this.calls.length>0})),this.client.on("onVideoInputChange",(e=>{this.emit("videoInputChange",e)})),this.client.on(this.client.MESSAGE,(e=>{this._onMessage(e),this.emit("message",e)})),this.client.setOnHeartbeatTimeout((()=>{this.emit("heartbeatTimeout")})),this.client.setOnHeartbeatCallback((()=>{this.emit("heartbeat")}))}_sendAction(e){this.softphoneActor.send({type:e})}_getCall(e){return this.calls.find((t=>t.id===e.id))}_onCallEvent(e,t,...i){Xp.warn("softphone - received call event",{eventName:t,sipId:e.id});const n=this._getCall(e);n?n[t](...i):Xp.warn("softphone - no call found to send the event",{eventName:t,sipId:e.id})}_onMessage(e){if(!e||"MESSAGE"!==e.method)return;let t;try{t=JSON.parse(e.body||"")}catch(e){return}const{type:i,content:n}=t;switch(i){case"message/TYPE_CHAT":this.emit("phone/ON_CHAT",n);break;case"message/TYPE_SIGNAL":this.emit("phone/ON_SIGNAL",n)}}}var eg=new Qp;const tg={Auth:Cn,Phone:rd,Websocket:Ll,Room:Kl,SipRoom:zl,RemoteParticipant:Ul,LocalParticipant:class extends Bl{},Participant:Bl,Stream:Yl,createLocalVideoStream:async e=>eh("video",e),createLocalAudioStream:async e=>eh("audio",e),Configuration:Ql,Directory:Zl,getApiClient:gn,IssueReporter:B,loggerFor:B.loggerFor.bind(B),Features:ah,Checker:gh,Voice:{Softphone:eg,Call:Kp},domain:{BadResponse:b,ServerError:w,Call:fi,CallLog:Yi,CTIPhone:Bi,Recording:zi,ChatMessage:pi,ChatRoom:Ji,Contact:Xt,ForwardOption:Gt,Line:Vt,NotificationOptions:th,Profile:Yt,Session:ti,Voicemail:gi,Relocation:ui,ConferenceRoom:ih,CallSession:yi,IndirectTransfer:Xi,SwitchboardCall:nh,WebRTCPhone:vo,Meeting:ci,SoftphoneClass:Qp},get api(){return gn()},get agentd(){return gn().agentd},get amid(){return gn().amid},get application(){return gn().application},get auth(){return gn().auth},get callLogd(){return gn().callLogd},get calld(){return gn().calld},get chatd(){return gn().chatd},get confd(){return gn().confd},get dird(){return gn().dird},get webhookd(){return gn().webhookd},InvalidSubscription:fn,InvalidAuthorization:mn,CanceledCallError:Jc,SFUNotAvailableError:Xc,NoTenantIdError:vn,NoDomainNameError:yn,NoSamlRouteError:Sn,SamlConfigError:bn};"undefined"!=typeof window&&(window.Wazo=tg),"undefined"!=typeof global&&(global.Wazo=tg);var ig=tg;var ng={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])|7(?:[013-57-9]\\d|2[0-8]))\\d|3(?:(?:[0-3589]\\d|6[1-9]|7[0-35-9])\\d|4(?:[0-578]\\d|90)))\\d\\d|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])|3\\d\\d)|(?:6[0-8]|[78]\\d)\\d{3}|9(?:[02-9]\\d{3}|1(?:(?:[0-58]\\d|6[0135-9])\\d|7(?:0[0-24-9]|[1-9]\\d)|9(?:[0-46-9]\\d|5[0-79])))))\\d{3}",[9]],["4(?:(?:79|94)[01]|83[0-389])\\d{5}|4(?:[0-3]\\d|4[047-9]|5[0-25-9]|6[0-36-9]|7[02-8]|8[0-24-9]|9[0-37-9])\\d{6}",[9]],["180(?:0\\d{3}|2)\\d{3}",[7,10]],["190[0-26]\\d{6}",[10]],0,0,0,["163\\d{2,6}",[5,6,7,8,9]],["14(?:5(?:1[0458]|[23][458])|71\\d)\\d{4}",[9]],["13(?:00\\d{6}(?:\\d{2})?|45[0-4]\\d{3})|13\\d{4}",[6,8,10,12]]],"0011"],AW:["297","00","(?:[25-79]\\d\\d|800)\\d{4}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[25-9]"]]]],AX:["358","00|99(?:[01469]|5(?:[14]1|3[23]|5[59]|77|88|9[09]))","2\\d{4,9}|35\\d{4,5}|(?:60\\d\\d|800)\\d{4,6}|7\\d{5,11}|(?:[14]\\d|3[0-46-9]|50)\\d{4,8}",[5,6,7,8,9,10,11,12],0,"0",0,0,0,0,"18",0,"00"],AZ:["994","00","365\\d{6}|(?:[124579]\\d|60|88)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["90"],"0$1"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["1[28]|2|365|46","1[28]|2|365[45]|46","1[28]|2|365(?:4|5[02])|46"],"(0$1)"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[13-9]"],"0$1"]],"0"],BA:["387","00","6\\d{8}|(?:[35689]\\d|49|70)\\d{6}",[8,9],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["6[1-3]|[7-9]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2-$3",["[3-5]|6[56]"],"0$1"],["(\\d{2})(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3 $4",["6"],"0$1"]],"0"],BB:["1","011","(?:246|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([2-9]\\d{6})$|1","246$1",0,"246"],BD:["880","00","[1-469]\\d{9}|8[0-79]\\d{7,8}|[2-79]\\d{8}|[2-9]\\d{7}|[3-9]\\d{6}|[57-9]\\d{5}",[6,7,8,9,10],[["(\\d{2})(\\d{4,6})","$1-$2",["31[5-8]|[459]1"],"0$1"],["(\\d{3})(\\d{3,7})","$1-$2",["3(?:[67]|8[013-9])|4(?:6[168]|7|[89][18])|5(?:6[128]|9)|6(?:[15]|28|4[14])|7[2-589]|8(?:0[014-9]|[12])|9[358]|(?:3[2-5]|4[235]|5[2-578]|6[0389]|76|8[3-7]|9[24])1|(?:44|66)[01346-9]"],"0$1"],["(\\d{4})(\\d{3,6})","$1-$2",["[13-9]|22"],"0$1"],["(\\d)(\\d{7,8})","$1-$2",["2"],"0$1"]],"0"],BE:["32","00","4\\d{8}|[1-9]\\d{7}",[8,9],[["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["(?:80|9)0"],"0$1"],["(\\d)(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[239]|4[23]"],"0$1"],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[15-8]"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["4"],"0$1"]],"0"],BF:["226","00","[025-7]\\d{7}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[025-7]"]]]],BG:["359","00","00800\\d{7}|[2-7]\\d{6,7}|[89]\\d{6,8}|2\\d{5}",[6,7,8,9,12],[["(\\d)(\\d)(\\d{2})(\\d{2})","$1 $2 $3 $4",["2"],"0$1"],["(\\d{3})(\\d{4})","$1 $2",["43[1-6]|70[1-9]"],"0$1"],["(\\d)(\\d{3})(\\d{3,4})","$1 $2 $3",["2"],"0$1"],["(\\d{2})(\\d{3})(\\d{2,3})","$1 $2 $3",["[356]|4[124-7]|7[1-9]|8[1-6]|9[1-7]"],"0$1"],["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["(?:70|8)0"],"0$1"],["(\\d{3})(\\d{3})(\\d{2})","$1 $2 $3",["43[1-7]|7"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[48]|9[08]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["9"],"0$1"]],"0"],BH:["973","00","[136-9]\\d{7}",[8],[["(\\d{4})(\\d{4})","$1 $2",["[13679]|8[02-4679]"]]]],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]|3[3-7]|5[12]|87)\\d{4}"],["69(?:0\\d\\d|1(?:2[2-9]|3[0-5])|4(?:0[89]|1[2-6]|9\\d)|6(?:1[016-9]|5[0-4]|[67]\\d))\\d{4}"],["80[0-5]\\d{6}"],0,0,0,0,0,["9(?:(?:39[5-7]|76[018])\\d|475[0-5])\\d{4}"]]],BM:["1","011","(?:441|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([2-9]\\d{6})$|1","441$1",0,"441"],BN:["673","00","[2-578]\\d{6}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[2-578]"]]]],BO:["591","00(?:1\\d)?","(?:[2-467]\\d\\d|8001)\\d{5}",[8,9],[["(\\d)(\\d{7})","$1 $2",["[23]|4[46]"]],["(\\d{8})","$1",["[67]"]],["(\\d{3})(\\d{2})(\\d{4})","$1 $2 $3",["8"]]],"0",0,"0(1\\d)?"],BQ:["599","00","(?:[34]1|7\\d)\\d{5}",[7],0,0,0,0,0,0,"[347]"],BR:["55","00(?:1[245]|2[1-35]|31|4[13]|[56]5|99)","(?:[1-46-9]\\d\\d|5(?:[0-46-9]\\d|5[0-46-9]))\\d{8}|[1-9]\\d{9}|[3589]\\d{8}|[34]\\d{7}",[8,9,10,11],[["(\\d{4})(\\d{4})","$1-$2",["300|4(?:0[02]|37)","4(?:02|37)0|[34]00"]],["(\\d{3})(\\d{2,3})(\\d{4})","$1 $2 $3",["(?:[358]|90)0"],"0$1"],["(\\d{2})(\\d{4})(\\d{4})","$1 $2-$3",["(?:[14689][1-9]|2[12478]|3[1-578]|5[13-5]|7[13-579])[2-57]"],"($1)"],["(\\d{2})(\\d{5})(\\d{4})","$1 $2-$3",["[16][1-9]|[2-57-9]"],"($1)"]],"0",0,"(?:0|90)(?:(1[245]|2[1-35]|31|4[13]|[56]5|99)(\\d{10,11}))?","$2"],BS:["1","011","(?:242|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([3-8]\\d{6})$|1","242$1",0,"242"],BT:["975","00","[17]\\d{7}|[2-8]\\d{6}",[7,8],[["(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["[2-68]|7[246]"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["1[67]|7"]]]],BW:["267","00","(?:0800|(?:[37]|800)\\d)\\d{6}|(?:[2-6]\\d|90)\\d{5}",[7,8,10],[["(\\d{2})(\\d{5})","$1 $2",["90"]],["(\\d{3})(\\d{4})","$1 $2",["[24-6]|3[15-9]"]],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[37]"]],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["0"]],["(\\d{3})(\\d{4})(\\d{3})","$1 $2 $3",["8"]]]],BY:["375","810","(?:[12]\\d|33|44|902)\\d{7}|8(?:0[0-79]\\d{5,7}|[1-7]\\d{9})|8(?:1[0-489]|[5-79]\\d)\\d{7}|8[1-79]\\d{6,7}|8[0-79]\\d{5}|8\\d{5}",[6,7,8,9,10,11],[["(\\d{3})(\\d{3})","$1 $2",["800"],"8 $1"],["(\\d{3})(\\d{2})(\\d{2,4})","$1 $2 $3",["800"],"8 $1"],["(\\d{4})(\\d{2})(\\d{3})","$1 $2-$3",["1(?:5[169]|6[3-5]|7[179])|2(?:1[35]|2[34]|3[3-5])","1(?:5[169]|6(?:3[1-3]|4|5[125])|7(?:1[3-9]|7[0-24-6]|9[2-7]))|2(?:1[35]|2[34]|3[3-5])"],"8 0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2-$3-$4",["1(?:[56]|7[467])|2[1-3]"],"8 0$1"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2-$3-$4",["[1-4]"],"8 0$1"],["(\\d{3})(\\d{3,4})(\\d{4})","$1 $2 $3",["[89]"],"8 $1"]],"8",0,"0|80?",0,0,0,0,"8~10"],BZ:["501","00","(?:0800\\d|[2-8])\\d{6}",[7,11],[["(\\d{3})(\\d{4})","$1-$2",["[2-8]"]],["(\\d)(\\d{3})(\\d{4})(\\d{3})","$1-$2-$3-$4",["0"]]]],CA:["1","011","(?:[2-8]\\d|90)\\d{8}|3\\d{6}",[7,10],0,"1",0,0,0,0,0,[["(?:2(?:04|[23]6|[48]9|50|63)|3(?:06|43|54|6[578]|82)|4(?:03|1[68]|[26]8|3[178]|50|74)|5(?:06|1[49]|48|79|8[147])|6(?:04|[18]3|39|47|72)|7(?:0[59]|42|53|78|8[02])|8(?:[06]7|19|25|7[39])|90[25])[2-9]\\d{6}",[10]],["",[10]],["8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",[10]],["900[2-9]\\d{6}",[10]],["52(?:3(?:[2-46-9][02-9]\\d|5(?:[02-46-9]\\d|5[0-46-9]))|4(?:[2-478][02-9]\\d|5(?:[034]\\d|2[024-9]|5[0-46-9])|6(?:0[1-9]|[2-9]\\d)|9(?:[05-9]\\d|2[0-5]|49)))\\d{4}|52[34][2-9]1[02-9]\\d{4}|(?:5(?:00|2[125-9]|33|44|66|77|88)|622)[2-9]\\d{6}",[10]],0,["310\\d{4}",[7]],0,["600[2-9]\\d{6}",[10]]]],CC:["61","001[14-689]|14(?:1[14]|34|4[17]|[56]6|7[47]|88)0011","1(?:[0-79]\\d{8}(?:\\d{2})?|8[0-24-9]\\d{7})|[148]\\d{8}|1\\d{5,7}",[6,7,8,9,10,12],0,"0",0,"([59]\\d{7})$|0","8$1",0,0,[["8(?:51(?:0(?:02|31|60|89)|1(?:18|76)|223)|91(?:0(?:1[0-2]|29)|1(?:[28]2|50|79)|2(?:10|64)|3(?:[06]8|22)|4[29]8|62\\d|70[23]|959))\\d{3}",[9]],["4(?:(?:79|94)[01]|83[0-389])\\d{5}|4(?:[0-3]\\d|4[047-9]|5[0-25-9]|6[0-36-9]|7[02-8]|8[0-24-9]|9[0-37-9])\\d{6}",[9]],["180(?:0\\d{3}|2)\\d{3}",[7,10]],["190[0-26]\\d{6}",[10]],0,0,0,0,["14(?:5(?:1[0458]|[23][458])|71\\d)\\d{4}",[9]],["13(?:00\\d{6}(?:\\d{2})?|45[0-4]\\d{3})|13\\d{4}",[6,8,10,12]]],"0011"],CD:["243","00","[189]\\d{8}|[1-68]\\d{6}",[7,9],[["(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3",["88"],"0$1"],["(\\d{2})(\\d{5})","$1 $2",["[1-6]"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["1"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[89]"],"0$1"]],"0"],CF:["236","00","(?:[27]\\d{3}|8776)\\d{4}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[278]"]]]],CG:["242","00","222\\d{6}|(?:0\\d|80)\\d{7}",[9],[["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["8"]],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[02]"]]]],CH:["41","00","8\\d{11}|[2-9]\\d{8}",[9],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["8[047]|90"],"0$1"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[2-79]|81"],"0$1"],["(\\d{3})(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4 $5",["8"],"0$1"]],"0"],CI:["225","00","[02]\\d{9}",[10],[["(\\d{2})(\\d{2})(\\d)(\\d{5})","$1 $2 $3 $4",["2"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{4})","$1 $2 $3 $4",["0"]]]],CK:["682","00","[2-578]\\d{4}",[5],[["(\\d{2})(\\d{3})","$1 $2",["[2-578]"]]]],CL:["56","(?:0|1(?:1[0-69]|2[02-5]|5[13-58]|69|7[0167]|8[018]))0","12300\\d{6}|6\\d{9,10}|[2-9]\\d{8}",[9,10,11],[["(\\d{5})(\\d{4})","$1 $2",["219","2196"],"($1)"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["44"]],["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["2[1-36]"],"($1)"],["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["9[2-9]"]],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["3[2-5]|[47]|5[1-3578]|6[13-57]|8(?:0[1-9]|[1-9])"],"($1)"],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["60|8"]],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["1"]],["(\\d{3})(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3 $4",["60"]]]],CM:["237","00","[26]\\d{8}|88\\d{6,7}",[8,9],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["88"]],["(\\d)(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4 $5",["[26]|88"]]]],CN:["86","00|1(?:[12]\\d|79)\\d\\d00","1[127]\\d{8,9}|2\\d{9}(?:\\d{2})?|[12]\\d{6,7}|86\\d{6}|(?:1[03-689]\\d|6)\\d{7,9}|(?:[3-579]\\d|8[0-57-9])\\d{6,9}",[7,8,9,10,11,12],[["(\\d{2})(\\d{5,6})","$1 $2",["(?:10|2[0-57-9])[19]","(?:10|2[0-57-9])(?:10|9[56])","10(?:10|9[56])|2[0-57-9](?:100|9[56])"],"0$1"],["(\\d{3})(\\d{5,6})","$1 $2",["3(?:[157]|35|49|9[1-68])|4(?:[17]|2[179]|6[47-9]|8[23])|5(?:[1357]|2[37]|4[36]|6[1-46]|80)|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|[379]|4[13]|5[1-5])|(?:4[35]|59|85)[1-9]","(?:3(?:[157]\\d|35|49|9[1-68])|4(?:[17]\\d|2[179]|[35][1-9]|6[47-9]|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]\\d|5[1-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|[379]\\d|4[13]|5[1-5]))[19]","85[23](?:10|95)|(?:3(?:[157]\\d|35|49|9[1-68])|4(?:[17]\\d|2[179]|[35][1-9]|6[47-9]|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]\\d|5[14-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|[379]\\d|4[13]|5[1-5]))(?:10|9[56])","85[23](?:100|95)|(?:3(?:[157]\\d|35|49|9[1-68])|4(?:[17]\\d|2[179]|[35][1-9]|6[47-9]|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]\\d|5[14-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|[379]\\d|4[13]|5[1-5]))(?:100|9[56])"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["(?:4|80)0"]],["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["10|2(?:[02-57-9]|1[1-9])","10|2(?:[02-57-9]|1[1-9])","10[0-79]|2(?:[02-57-9]|1[1-79])|(?:10|21)8(?:0[1-9]|[1-9])"],"0$1",1],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["3(?:[3-59]|7[02-68])|4(?:[26-8]|3[3-9]|5[2-9])|5(?:3[03-9]|[468]|7[028]|9[2-46-9])|6|7(?:[0-247]|3[04-9]|5[0-4689]|6[2368])|8(?:[1-358]|9[1-7])|9(?:[013479]|5[1-5])|(?:[34]1|55|79|87)[02-9]"],"0$1",1],["(\\d{3})(\\d{7,8})","$1 $2",["9"]],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["80"],"0$1",1],["(\\d{3})(\\d{4})(\\d{4})","$1 $2 $3",["[3-578]"],"0$1",1],["(\\d{3})(\\d{4})(\\d{4})","$1 $2 $3",["1[3-9]"]],["(\\d{2})(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3 $4",["[12]"],"0$1",1]],"0",0,"(1(?:[12]\\d|79)\\d\\d)|0",0,0,0,0,"00"],CO:["57","00(?:4(?:[14]4|56)|[579])","(?:60\\d\\d|9101)\\d{6}|(?:1\\d|3)\\d{9}",[10,11],[["(\\d{3})(\\d{7})","$1 $2",["6"],"($1)"],["(\\d{3})(\\d{7})","$1 $2",["3[0-357]|91"]],["(\\d)(\\d{3})(\\d{7})","$1-$2-$3",["1"],"0$1",0,"$1 $2 $3"]],"0",0,"0([3579]|4(?:[14]4|56))?"],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","(?:[2-7]|8\\d\\d)\\d{7}|[2-47]\\d{6}|[34]\\d{5}",[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",["[56]"],"0$1"],["(\\d{3})(\\d{7})","$1 $2",["8"],"0$1"]],"0"],CV:["238","0","(?:[2-59]\\d\\d|800)\\d{4}",[7],[["(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3",["[2-589]"]]]],CW:["599","00","(?:[34]1|60|(?:7|9\\d)\\d)\\d{5}",[7,8],[["(\\d{3})(\\d{4})","$1 $2",["[3467]"]],["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["9[4-8]"]]],0,0,0,0,0,"[69]"],CX:["61","001[14-689]|14(?:1[14]|34|4[17]|[56]6|7[47]|88)0011","1(?:[0-79]\\d{8}(?:\\d{2})?|8[0-24-9]\\d{7})|[148]\\d{8}|1\\d{5,7}",[6,7,8,9,10,12],0,"0",0,"([59]\\d{7})$|0","8$1",0,0,[["8(?:51(?:0(?:01|30|59|88)|1(?:17|46|75)|2(?:22|35))|91(?:00[6-9]|1(?:[28]1|49|78)|2(?:09|63)|3(?:12|26|75)|4(?:56|97)|64\\d|7(?:0[01]|1[0-2])|958))\\d{3}",[9]],["4(?:(?:79|94)[01]|83[0-389])\\d{5}|4(?:[0-3]\\d|4[047-9]|5[0-25-9]|6[0-36-9]|7[02-8]|8[0-24-9]|9[0-37-9])\\d{6}",[9]],["180(?:0\\d{3}|2)\\d{3}",[7,10]],["190[0-26]\\d{6}",[10]],0,0,0,0,["14(?:5(?:1[0458]|[23][458])|71\\d)\\d{4}",[9]],["13(?:00\\d{6}(?:\\d{2})?|45[0-4]\\d{3})|13\\d{4}",[6,8,10,12]]],"0011"],CY:["357","00","(?:[279]\\d|[58]0)\\d{6}",[8],[["(\\d{2})(\\d{6})","$1 $2",["[257-9]"]]]],CZ:["420","00","(?:[2-578]\\d|60)\\d{7}|9\\d{8,11}",[9],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[2-8]|9[015-7]"]],["(\\d{2})(\\d{3})(\\d{3})(\\d{2})","$1 $2 $3 $4",["96"]],["(\\d{2})(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["9"]],["(\\d{3})(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["9"]]]],DE:["49","00","[2579]\\d{5,14}|49(?:[34]0|69|8\\d)\\d\\d?|49(?:37|49|60|7[089]|9\\d)\\d{1,3}|49(?:2[024-9]|3[2-689]|7[1-7])\\d{1,8}|(?:1|[368]\\d|4[0-8])\\d{3,13}|49(?:[015]\\d|2[13]|31|[46][1-8])\\d{1,9}",[4,5,6,7,8,9,10,11,12,13,14,15],[["(\\d{2})(\\d{3,13})","$1 $2",["3[02]|40|[68]9"],"0$1"],["(\\d{3})(\\d{3,12})","$1 $2",["2(?:0[1-389]|1[124]|2[18]|3[14])|3(?:[35-9][15]|4[015])|906|(?:2[4-9]|4[2-9]|[579][1-9]|[68][1-8])1","2(?:0[1-389]|12[0-8])|3(?:[35-9][15]|4[015])|906|2(?:[13][14]|2[18])|(?:2[4-9]|4[2-9]|[579][1-9]|[68][1-8])1"],"0$1"],["(\\d{4})(\\d{2,11})","$1 $2",["[24-6]|3(?:[3569][02-46-9]|4[2-4679]|7[2-467]|8[2-46-8])|70[2-8]|8(?:0[2-9]|[1-8])|90[7-9]|[79][1-9]","[24-6]|3(?:3(?:0[1-467]|2[127-9]|3[124578]|7[1257-9]|8[1256]|9[145])|4(?:2[135]|4[13578]|9[1346])|5(?:0[14]|2[1-3589]|6[1-4]|7[13468]|8[13568])|6(?:2[1-489]|3[124-6]|6[13]|7[12579]|8[1-356]|9[135])|7(?:2[1-7]|4[145]|6[1-5]|7[1-4])|8(?:21|3[1468]|6|7[1467]|8[136])|9(?:0[12479]|2[1358]|4[134679]|6[1-9]|7[136]|8[147]|9[1468]))|70[2-8]|8(?:0[2-9]|[1-8])|90[7-9]|[79][1-9]|3[68]4[1347]|3(?:47|60)[1356]|3(?:3[46]|46|5[49])[1246]|3[4579]3[1357]"],"0$1"],["(\\d{3})(\\d{4})","$1 $2",["138"],"0$1"],["(\\d{5})(\\d{2,10})","$1 $2",["3"],"0$1"],["(\\d{3})(\\d{5,11})","$1 $2",["181"],"0$1"],["(\\d{3})(\\d)(\\d{4,10})","$1 $2 $3",["1(?:3|80)|9"],"0$1"],["(\\d{3})(\\d{7,8})","$1 $2",["1[67]"],"0$1"],["(\\d{3})(\\d{7,12})","$1 $2",["8"],"0$1"],["(\\d{5})(\\d{6})","$1 $2",["185","1850","18500"],"0$1"],["(\\d{3})(\\d{4})(\\d{4})","$1 $2 $3",["7"],"0$1"],["(\\d{4})(\\d{7})","$1 $2",["18[68]"],"0$1"],["(\\d{4})(\\d{7})","$1 $2",["15[1279]"],"0$1"],["(\\d{5})(\\d{6})","$1 $2",["15[03568]","15(?:[0568]|31)"],"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",["[89]"],"0$1"],["(\\d{2})(\\d{8})","$1 $2",["1"],"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{5})","$1",["20[2-59]"],"0$1"],["(\\d{3})(\\d{3,7})","$1 $2",["(?:[1-3]0|[68])0|70[07-9]"],"0$1"],["(\\d{2})(\\d{4,8})","$1 $2",["[14]|2[09]|50|7[135]"],"0$1"],["(\\d{2})(\\d{6,10})","$1 $2",["7"],"0$1"],["(\\d)(\\d{4,9})","$1 $2",["(?:1[3-79]|[2568])[1-8]|3(?:0[1-9]|[1-9])|9"],"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|70)\\d|69[7-9])|(?:(?:5[0-26-9]|[78][0-49])\\d|6(?:[0-4]\\d|50))\\d)|(?:2(?:(?:0[024-9]|2[3-9]|3[3-79]|4[1-689]|[58][02-9]|6[0-47-9]|7[013-9]|9\\d)\\d|1(?:[0-7]\\d|8[0-2]))|(?:3(?:0\\d|1[0-8]|[25][02-9]|3[02-579]|[468][0-46-9]|7[1-35-79]|9[2-578])|4(?:0[03-9]|[137]\\d|[28][02-57-9]|4[02-69]|5[0-8]|[69][0-79])|5(?:0[1-35-9]|[16]\\d|2[024-9]|3[015689]|4[02-9]|5[03-9]|7[0-35-9]|8[0-468]|9[0-57-9])|6(?:0[034689]|1\\d|2[0-35689]|[38][013-9]|4[1-467]|5[0-69]|6[13-9]|7[0-8]|9[0-24578])|7(?:0[0246-9]|2\\d|3[0236-8]|4[03-9]|5[0-46-9]|6[013-9]|7[0-35-9]|8[024-9]|9[02-9])|8(?:0[35-9]|2[1-57-9]|3[02-578]|4[0-578]|5[124-9]|6[2-69]|7\\d|8[02-9]|9[02569])|9(?:0[02-589]|[18]\\d|2[02-689]|3[1-57-9]|4[2-9]|5[0-579]|6[2-47-9]|7[0-24578]|9[2-57]))\\d)\\d)|2(?:0[013478]|3[0189]|4[017]|8[0-46-9]|9[0-2])\\d{3})\\d{4}|1(?:2(?:0(?:46[1-4]|87[2-9])|545[1-79]|76(?:2\\d|3[1-8]|6[1-6])|9(?:7(?:2[0-4]|3[2-5])|8(?:2[2-8]|7[0-47-9]|8[3-5])))|3(?:6(?:38[2-5]|47[23])|8(?:47[04-9]|64[0157-9]))|4(?:044[1-7]|20(?:2[23]|8\\d)|6(?:0(?:30|5[2-57]|6[1-8]|7[2-8])|140)|8(?:052|87[1-3]))|5(?:2(?:4(?:3[2-79]|6\\d)|76\\d)|6(?:26[06-9]|686))|6(?:06(?:4\\d|7[4-79])|295[5-7]|35[34]\\d|47(?:24|61)|59(?:5[08]|6[67]|74)|9(?:55[0-4]|77[23]))|7(?:26(?:6[13-9]|7[0-7])|(?:442|688)\\d|50(?:2[0-3]|[3-68]2|76))|8(?:27[56]\\d|37(?:5[2-5]|8[239])|843[2-58])|9(?:0(?:0(?:6[1-8]|85)|52\\d)|3583|4(?:66[1-8]|9(?:2[01]|81))|63(?:23|3[1-4])|9561))\\d{3}",[9,10]],["7(?:457[0-57-9]|700[01]|911[028])\\d{5}|7(?:[1-3]\\d\\d|4(?:[0-46-9]\\d|5[0-689])|5(?:0[0-8]|[13-9]\\d|2[0-35-9])|7(?:0[1-9]|[1-7]\\d|8[02-9]|9[0-689])|8(?:[014-9]\\d|[23][0-8])|9(?:[024-9]\\d|1[02-9]|3[0-689]))\\d{6}",[10]],["80[08]\\d{7}|800\\d{6}|8001111"],["(?:8(?:4[2-5]|7[0-3])|9(?:[01]\\d|8[2-49]))\\d{7}|845464\\d",[7,10]],["70\\d{8}",[10]],0,["(?:3[0347]|55)\\d{8}",[10]],["76(?:464|652)\\d{5}|76(?:0[0-28]|2[356]|34|4[01347]|5[49]|6[0-369]|77|8[14]|9[139])\\d{6}",[10]],["56\\d{8}",[10]]],0," x"],GD:["1","011","(?:473|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([2-9]\\d{6})$|1","473$1",0,"473"],GE:["995","00","(?:[3-57]\\d\\d|800)\\d{6}",[9],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["70"],"0$1"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["32"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[57]"]],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[348]"],"0$1"]],"0"],GF:["594","00","[56]94\\d{6}|(?:80|9\\d)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[56]|9[47]"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[89]"],"0$1"]],"0"],GG:["44","00","(?:1481|[357-9]\\d{3})\\d{6}|8\\d{6}(?:\\d{2})?",[7,9,10],0,"0",0,"([25-9]\\d{5})$|0","1481$1",0,0,[["1481[25-9]\\d{5}",[10]],["7(?:(?:781|839)\\d|911[17])\\d{5}",[10]],["80[08]\\d{7}|800\\d{6}|8001111"],["(?:8(?:4[2-5]|7[0-3])|9(?:[01]\\d|8[0-3]))\\d{7}|845464\\d",[7,10]],["70\\d{8}",[10]],0,["(?:3[0347]|55)\\d{8}",[10]],["76(?:464|652)\\d{5}|76(?:0[0-28]|2[356]|34|4[01347]|5[49]|6[0-369]|77|8[14]|9[139])\\d{6}",[10]],["56\\d{8}",[10]]]],GH:["233","00","(?:[235]\\d{3}|800)\\d{5}",[8,9],[["(\\d{3})(\\d{5})","$1 $2",["8"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[235]"],"0$1"]],"0"],GI:["350","00","(?:[25]\\d|60)\\d{6}",[8],[["(\\d{3})(\\d{5})","$1 $2",["2"]]]],GL:["299","00","(?:19|[2-689]\\d|70)\\d{4}",[6],[["(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3",["19|[2-9]"]]]],GM:["220","00","[2-9]\\d{6}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[2-9]"]]]],GN:["224","00","722\\d{6}|(?:3|6\\d)\\d{7}",[8,9],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["3"]],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[67]"]]]],GP:["590","00","590\\d{6}|(?:69|80|9\\d)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[569]"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"],"0$1"]],"0",0,0,0,0,0,[["590(?:0[1-68]|[14][0-24-9]|2[0-68]|3[1-9]|5[3-579]|[68][0-689]|7[08]|9\\d)\\d{4}"],["69(?:0\\d\\d|1(?:2[2-9]|3[0-5])|4(?:0[89]|1[2-6]|9\\d)|6(?:1[016-9]|5[0-4]|[67]\\d))\\d{4}"],["80[0-5]\\d{6}"],0,0,0,0,0,["9(?:(?:39[5-7]|76[018])\\d|475[0-5])\\d{4}"]]],GQ:["240","00","222\\d{6}|(?:3\\d|55|[89]0)\\d{7}",[9],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[235]"]],["(\\d{3})(\\d{6})","$1 $2",["[89]"]]]],GR:["30","00","5005000\\d{3}|8\\d{9,11}|(?:[269]\\d|70)\\d{8}",[10,11,12],[["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["21|7"]],["(\\d{4})(\\d{6})","$1 $2",["2(?:2|3[2-57-9]|4[2-469]|5[2-59]|6[2-9]|7[2-69]|8[2-49])|5"]],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["[2689]"]],["(\\d{3})(\\d{3,4})(\\d{5})","$1 $2 $3",["8"]]]],GT:["502","00","80\\d{6}|(?:1\\d{3}|[2-7])\\d{7}",[8,11],[["(\\d{4})(\\d{4})","$1 $2",["[2-8]"]],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["1"]]]],GU:["1","011","(?:[58]\\d\\d|671|900)\\d{7}",[10],0,"1",0,"([2-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","(?:[2-8]\\d{3}|9008)\\d{3}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[2-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",["6|7[245]"],"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-57]"],"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})|(?:43|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]|43"]],["(\\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[2-9]\\d{7,8}|(?:31|43)\\d{8}",[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\\d))\\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)|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])|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])|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[0459]|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[26-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]|9[29])|5(?:2|3(?:[045]|9[0-8])|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[0-2469])|3(?:[29]|60)|49|51|6(?:[0-24]|36|5[0-3589]|7[23]|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]))|(?: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]|9(?:[0-58]|6[4-9]|7[0-35689]))|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]|60|7(?:[017-9]|6[6-8]))|49|51|6(?:[0-24]|36[2-57-9]|5(?:[0-389]|5[23])|6(?:[01]|9[178])|7(?:2[2-468]|3[78])|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]"],"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",0,"(000[259]\\d{6})$|(?:(?:003768)0?)|0","$1"],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-9]\\d{8}",[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","(?:[245]\\d|33|77|88)\\d{7}|(?:2\\d|[4-6])\\d{6}",[7,8,9],[["(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["4[67]|[56]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["2"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[2-578]"],"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]"],"(0-$1)",1],["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["[7-9]"],"0 $1",1],["(\\d{2})(\\d{6})","$1 $2",["37|4(?:[15]|6[1-8])"],"(0-$1)",1],["(\\d{3})(\\d{5})","$1 $2",["[3-6]"],"(0-$1)",1]],"0",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{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["5[45]"],"0$1"],["(\\d{4})(\\d{5})","$1-$2",["5(?:2[2-46-9]|3[3-9]|9)|8(?:0[89]|92)"],"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,[["5(?:2(?:[0-25-79]\\d|3[1-578]|4[02-46-8]|8[0235-7])|3(?:[0-47]\\d|5[02-9]|6[02-8]|8[014-9]|9[3-9])|(?:4[067]|5[03])\\d)\\d{5}"],["(?:6(?:[0-79]\\d|8[0-247-9])|7(?:[0167]\\d|2[0-4]|5[01]|8[0-3]))\\d{6}"],["80[0-7]\\d{6}"],["89\\d{7}"],0,0,0,0,["(?:592(?:4[0-2]|93)|80[89]\\d\\d)\\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]|3[03-7]|5[0-268]|87)\\d{4}"],["69(?:0\\d\\d|1(?:2[2-9]|3[0-5])|4(?:0[89]|1[2-6]|9\\d)|6(?:1[016-9]|5[0-4]|[67]\\d))\\d{4}"],["80[0-5]\\d{6}"],0,0,0,0,0,["9(?:(?:39[5-7]|76[018])\\d|475[0-5])\\d{4}"]]],MG:["261","00","[23]\\d{8}",[9],[["(\\d{2})(\\d{2})(\\d{3})(\\d{2})","$1 $2 $3 $4",["[23]"],"0$1"]],"0",0,"([24-9]\\d{6})$|0","20$1"],MH:["692","011","329\\d{4}|(?:[256]\\d|45)\\d{5}",[7],[["(\\d{3})(\\d{4})","$1-$2",["[2-6]"]]],"1"],MK:["389","00","[2-578]\\d{7}",[8],[["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["2|34[47]|4(?:[37]7|5[47]|64)"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[347]"],"0$1"],["(\\d{3})(\\d)(\\d{2})(\\d{2})","$1 $2 $3 $4",["[58]"],"0$1"]],"0"],ML:["223","00","[24-9]\\d{7}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[24-9]"]]]],MM:["95","00","1\\d{5,7}|95\\d{6}|(?:[4-7]|9[0-46-9])\\d{6,8}|(?:2|8\\d)\\d{5,8}",[6,7,8,9,10],[["(\\d)(\\d{2})(\\d{3})","$1 $2 $3",["16|2"],"0$1"],["(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3",["[45]|6(?:0[23]|[1-689]|7[235-7])|7(?:[0-4]|5[2-7])|8[1-6]"],"0$1"],["(\\d)(\\d{3})(\\d{3,4})","$1 $2 $3",["[12]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[4-7]|8[1-35]"],"0$1"],["(\\d)(\\d{3})(\\d{4,6})","$1 $2 $3",["9(?:2[0-4]|[35-9]|4[137-9])"],"0$1"],["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["2"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["8"],"0$1"],["(\\d)(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["92"],"0$1"],["(\\d)(\\d{5})(\\d{4})","$1 $2 $3",["9"],"0$1"]],"0"],MN:["976","001","[12]\\d{7,9}|[5-9]\\d{7}",[8,9,10],[["(\\d{2})(\\d{2})(\\d{4})","$1 $2 $3",["[12]1"],"0$1"],["(\\d{4})(\\d{4})","$1 $2",["[5-9]"]],["(\\d{3})(\\d{5,6})","$1 $2",["[12]2[1-3]"],"0$1"],["(\\d{4})(\\d{5,6})","$1 $2",["[12](?:27|3[2-8]|4[2-68]|5[1-4689])","[12](?:27|3[2-8]|4[2-68]|5[1-4689])[0-3]"],"0$1"],["(\\d{5})(\\d{4,5})","$1 $2",["[12]"],"0$1"]],"0"],MO:["853","00","0800\\d{3}|(?:28|[68]\\d)\\d{6}",[7,8],[["(\\d{4})(\\d{3})","$1 $2",["0"]],["(\\d{4})(\\d{4})","$1 $2",["[268]"]]]],MP:["1","011","[58]\\d{9}|(?:67|90)0\\d{7}",[10],0,"1",0,"([2-9]\\d{6})$|1","670$1",0,"670"],MQ:["596","00","596\\d{6}|(?:69|80|9\\d)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[569]"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"],"0$1"]],"0"],MR:["222","00","(?:[2-4]\\d\\d|800)\\d{5}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[2-48]"]]]],MS:["1","011","(?:[58]\\d\\d|664|900)\\d{7}",[10],0,"1",0,"([34]\\d{6})$|1","664$1",0,"664"],MT:["356","00","3550\\d{4}|(?:[2579]\\d\\d|800)\\d{5}",[8],[["(\\d{4})(\\d{4})","$1 $2",["[2357-9]"]]]],MU:["230","0(?:0|[24-7]0|3[03])","(?:[57]|8\\d\\d)\\d{7}|[2-468]\\d{6}",[7,8,10],[["(\\d{3})(\\d{4})","$1 $2",["[2-46]|8[013]"]],["(\\d{4})(\\d{4})","$1 $2",["[57]"]],["(\\d{5})(\\d{5})","$1 $2",["8"]]],0,0,0,0,0,0,0,"020"],MV:["960","0(?:0|19)","(?:800|9[0-57-9]\\d)\\d{7}|[34679]\\d{6}",[7,10],[["(\\d{3})(\\d{4})","$1-$2",["[34679]"]],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["[89]"]]],0,0,0,0,0,0,0,"00"],MW:["265","00","(?:[1289]\\d|31|77)\\d{7}|1\\d{6}",[7,9],[["(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["1[2-9]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["2"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[137-9]"],"0$1"]],"0"],MX:["52","0[09]","1(?:(?:22|44|7[27]|87|9[69])[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-689]|8[1-69]|9[1-578])|[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[047]"]]]],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","2[0-24-9]\\d{8}|[78]\\d{10,13}|[7-9]\\d{9}|[1-9]\\d{7}|[124-7]\\d{6}",[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-6]|7(?:0[0-689]|[1-79])|8[2-9]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["[7-9]"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["20[129]"],"0$1"],["(\\d{4})(\\d{2})(\\d{4})","$1 $2 $3",["2"],"0$1"],["(\\d{3})(\\d{4})(\\d{4,5})","$1 $2 $3",["[78]"],"0$1"],["(\\d{3})(\\d{5})(\\d{5,6})","$1 $2 $3",["[78]"],"0$1"]],"0"],NI:["505","00","(?:1800|[25-8]\\d{3})\\d{4}",[8],[["(\\d{4})(\\d{4})","$1 $2",["[125-8]"]]]],NL:["31","00","(?:[124-7]\\d\\d|3(?:[02-9]\\d|1[0-8]))\\d{6}|8\\d{6,9}|9\\d{6,10}|1\\d{4,5}",[5,6,7,8,9,10,11],[["(\\d{3})(\\d{4,7})","$1 $2",["[89]0"],"0$1"],["(\\d{2})(\\d{7})","$1 $2",["66"],"0$1"],["(\\d)(\\d{8})","$1 $2",["6"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["1[16-8]|2[259]|3[124]|4[17-9]|5[124679]"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[1-578]|91"],"0$1"],["(\\d{3})(\\d{3})(\\d{5})","$1 $2 $3",["9"],"0$1"]],"0"],NO:["47","00","(?:0|[2-9]\\d{3})\\d{4}",[5,8],[["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["8"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[2-79]"]]],0,0,0,0,0,"[02-689]|7[0-8]"],NP:["977","00","(?:1\\d|9)\\d{9}|[1-9]\\d{7}",[8,10,11],[["(\\d)(\\d{7})","$1-$2",["1[2-6]"],"0$1"],["(\\d{2})(\\d{6})","$1-$2",["1[01]|[2-8]|9(?:[1-59]|[67][2-6])"],"0$1"],["(\\d{3})(\\d{7})","$1-$2",["9"]]],"0"],NR:["674","00","(?:444|(?:55|8\\d)\\d|666)\\d{4}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[4-68]"]]]],NU:["683","00","(?:[4-7]|888\\d)\\d{3}",[4,7],[["(\\d{3})(\\d{4})","$1 $2",["8"]]]],NZ:["64","0(?:0|161)","[1289]\\d{9}|50\\d{5}(?:\\d{2,3})?|[27-9]\\d{7,8}|(?:[34]\\d|6[0-35-9])\\d{6}|8\\d{4,6}",[5,6,7,8,9,10],[["(\\d{2})(\\d{3,8})","$1 $2",["8[1-79]"],"0$1"],["(\\d{3})(\\d{2})(\\d{2,3})","$1 $2 $3",["50[036-8]|8|90","50(?:[0367]|88)|8|90"],"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)|[589]"],"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"],"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-7])"],"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-6]))\\d{4}"],["69(?:2\\d\\d|3(?:[06][0-6]|1[013]|2[0-2]|3[0-39]|4\\d|5[0-5]|7[0-37]|8[0-8]|9[0-479]))\\d{4}"],["80\\d{7}"],["89[1-37-9]\\d{6}"],0,0,0,0,["9(?:399[0-3]|479[0-5]|76(?:2[27]|3[0-37]))\\d{4}"],["8(?:1[019]|2[0156]|84|90)\\d{6}"]]],RO:["40","00","(?:[236-8]\\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",["[236-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",["2"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[7-9]"],"0$1"]],"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-9]|[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|79)\\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",["[348]|64|79|90"]],["(\\d{2})(\\d{5,7})","$1 $2",["1|28|6[0-35-9]|77|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}|(?:80\\d|900)\\d{4}(?:\\d{4})?",[7,8,11],[["(\\d{3})(\\d{4})","$1 $2",["[89]"]],["(\\d{4})(\\d{4})","$1 $2",["[267]"]],["(\\d{3})(\\d{4})(\\d{4})","$1 $2 $3",["[89]"]]]],SX:["1","011","7215\\d{6}|(?:[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"(5\\d{6})$|1","721$1",0,"721"],SY:["963","00","[1-39]\\d{8}|[1-5]\\d{7}",[8,9],[["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[1-5]"],"0$1",1],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["9"],"0$1",1]],"0"],SZ:["268","00","0800\\d{4}|(?:[237]\\d|900)\\d{6}",[8,9],[["(\\d{4})(\\d{4})","$1 $2",["[0237]"]],["(\\d{5})(\\d{4})","$1 $2",["9"]]]],TA:["290","00","8\\d{3}",[4],0,0,0,0,0,0,"8"],TC:["1","011","(?:[58]\\d\\d|649|900)\\d{7}",[10],0,"1",0,"([2-479]\\d{6})$|1","649$1",0,"649"],TD:["235","00|16","(?:22|[69]\\d|77)\\d{6}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[2679]"]]],0,0,0,0,0,0,0,"00"],TG:["228","00","[279]\\d{7}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[279]"]]]],TH:["66","00[1-9]","(?:001800|[2-57]|[689]\\d)\\d{7}|1\\d{7,9}",[8,9,10,13],[["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["2"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[13-9]"],"0$1"],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["1"]]],"0"],TJ:["992","810","[0-57-9]\\d{8}",[9],[["(\\d{6})(\\d)(\\d{2})","$1 $2 $3",["331","3317"]],["(\\d{3})(\\d{2})(\\d{4})","$1 $2 $3",["44[02-479]|[34]7"]],["(\\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|71)\\d{6}",[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",["[67]"],"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]|61[06])","5(?:[0-59]|61[06]1)"],"0$1",1],["(\\d{3})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[24][1-8]|3[1-9]"],"(0$1)",1],["(\\d{3})(\\d{3})(\\d{6,7})","$1 $2 $3",["80"],"0$1",1]],"0"],TT:["1","011","(?:[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([2-46-8]\\d{6})$|1","868$1",0,"868"],TV:["688","00","(?:2|7\\d\\d|90)\\d{4}",[5,6,7],[["(\\d{2})(\\d{3})","$1 $2",["2"]],["(\\d{2})(\\d{4})","$1 $2",["90"]],["(\\d{2})(\\d{5})","$1 $2",["7"]]]],TW:["886","0(?:0[25-79]|19)","[2-689]\\d{8}|7\\d{9,10}|[2-8]\\d{7}|2\\d{6}",[7,8,9,10,11],[["(\\d{2})(\\d)(\\d{4})","$1 $2 $3",["202"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[258]0"],"0$1"],["(\\d)(\\d{3,4})(\\d{4})","$1 $2 $3",["[23568]|4(?:0[02-48]|[1-47-9])|7[1-9]","[23568]|4(?:0[2-48]|[1-47-9])|(?:400|7)[1-9]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[49]"],"0$1"],["(\\d{2})(\\d{4})(\\d{4,5})","$1 $2 $3",["7"],"0$1"]],"0",0,0,0,0,0,0,0,"#"],TZ:["255","00[056]","(?:[25-8]\\d|41|90)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{4})","$1 $2 $3",["[89]"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[24]"],"0$1"],["(\\d{2})(\\d{7})","$1 $2",["5"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[67]"],"0$1"]],"0"],UA:["380","00","[89]\\d{9}|[3-9]\\d{8}",[9,10],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["6[12][29]|(?:3[1-8]|4[136-8]|5[12457]|6[49])2|(?:56|65)[24]","6[12][29]|(?:35|4[1378]|5[12457]|6[49])2|(?:56|65)[24]|(?:3[1-46-8]|46)2[013-9]"],"0$1"],["(\\d{4})(\\d{5})","$1 $2",["3[1-8]|4(?:[1367]|[45][6-9]|8[4-6])|5(?:[1-5]|6[0135689]|7[4-6])|6(?:[12][3-7]|[459])","3[1-8]|4(?:[1367]|[45][6-9]|8[4-6])|5(?:[1-5]|6(?:[015689]|3[02389])|7[4-6])|6(?:[12][3-7]|[459])"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[3-7]|89|9[1-9]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["[89]"],"0$1"]],"0",0,0,0,0,0,0,"0~0"],UG:["256","00[057]","800\\d{6}|(?:[29]0|[347]\\d)\\d{7}",[9],[["(\\d{4})(\\d{5})","$1 $2",["202","2024"],"0$1"],["(\\d{3})(\\d{6})","$1 $2",["[27-9]|4(?:6[45]|[7-9])"],"0$1"],["(\\d{2})(\\d{7})","$1 $2",["[34]"],"0$1"]],"0"],US:["1","011","[2-9]\\d{9}|3\\d{6}",[10],[["(\\d{3})(\\d{4})","$1-$2",["310"],0,1],["(\\d{3})(\\d{3})(\\d{4})","($1) $2-$3",["[2-9]"],0,1,"$1-$2-$3"]],"1",0,0,0,0,0,[["(?:5056(?:[0-35-9]\\d|4[468])|7302[0-4]\\d)\\d{4}|(?:472[24]|505[2-57-9]|7306|983[2-47-9])\\d{6}|(?:2(?:0[1-35-9]|1[02-9]|2[03-57-9]|3[1459]|4[08]|5[1-46]|6[0279]|7[0269]|8[13])|3(?:0[1-57-9]|1[02-9]|2[013569]|3[0-24679]|4[167]|5[0-2]|6[01349]|8[056])|4(?:0[124-9]|1[02-579]|2[3-5]|3[0245]|4[023578]|58|6[349]|7[0589]|8[04])|5(?:0[1-47-9]|1[0235-8]|20|3[0149]|4[01]|5[179]|6[1-47]|7[0-5]|8[0256])|6(?:0[1-35-9]|1[024-9]|2[03689]|3[016]|4[0156]|5[01679]|6[0-279]|78|8[0-29])|7(?:0[1-46-8]|1[2-9]|2[04-8]|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\\d{2,9}|[1249]\\d{7}|(?:[49]\\d|80)\\d{5}",[6,7,8,9,10,11,12,13],[["(\\d{3})(\\d{3,4})","$1 $2",["0"]],["(\\d{3})(\\d{4})","$1 $2",["[49]0|8"],"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{2,4})","$1 $2 $3",["0"]],["(\\d{3})(\\d{3})(\\d{3})(\\d{2,4})","$1 $2 $3 $4",["0"]]],"0",0,0,0,0,0,0,"00"," int. "],UZ:["998","810","(?:20|33|[5-79]\\d|88)\\d{7}",[9],[["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[235-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",["6"],"0$1",1],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[357-9]"],"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","2\\d{7,8}|3\\d{7,11}|(?:4\\d\\d|[89]00)\\d{5}",[8,9,10,11,12],[["(\\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",["2|39"],"0$1"],["(\\d{2})(\\d{7,10})","$1 $2",["3"],"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","(?:80|9\\d)\\d{7}|(?:26|63)9\\d{6}",[9],0,"0",0,0,0,0,0,[["269(?:0[0-467]|15|5[0-4]|6\\d|[78]0)\\d{4}"],["639(?:0[0-79]|1[019]|[267]\\d|3[09]|40|5[05-9]|9[04-79])\\d{4}"],["80\\d{7}"],0,0,0,0,0,["9(?:(?:39|47)8[01]|769\\d)\\d{4}"]]],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,"6\\d{9}|[0-36-9]\\d{8}",[9,10],[["(\\d)(\\d{3})(\\d{5})","$1 $2 $3",["[0-37-9]"]],["(\\d)(\\d{3})(\\d{5,6})","$1 $2 $3",["6"]]],0,0,0,0,0,0,[0,["6\\d{9}|[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[0-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}"]]]}};function rg(e){return rg="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},rg(e)}function sg(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function ag(e){var t=lg();return function(){var i,n=ug(e);if(t){var r=ug(this).constructor;i=Reflect.construct(n,arguments,r)}else i=n.apply(this,arguments);return function(e,t){if(t&&("object"===rg(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return og(e)}(this,i)}}function og(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function cg(e){var t="function"==typeof Map?new Map:void 0;return cg=function(e){if(null===e||(i=e,-1===Function.toString.call(i).indexOf("[native code]")))return e;var i;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return dg(e,arguments,ug(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),hg(n,e)},cg(e)}function dg(e,t,i){return dg=lg()?Reflect.construct:function(e,t,i){var n=[null];n.push.apply(n,t);var r=new(Function.bind.apply(e,n));return i&&hg(r,i.prototype),r},dg.apply(null,arguments)}function lg(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function hg(e,t){return hg=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},hg(e,t)}function ug(e){return ug=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},ug(e)}var pg=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&hg(e,t)}(s,e);var t,i,n,r=ag(s);function s(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,s),t=r.call(this,e),Object.setPrototypeOf(og(t),s.prototype),t.name=t.constructor.name,t}return t=s,i&&sg(t.prototype,i),n&&sg(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}(cg(Error)),gg=2,fg=17,mg=3,vg="0-90-9٠-٩۰-۹",yg="".concat("-‐-―−ー-").concat("//").concat("..").concat("  ­​⁠ ").concat("()()[]\\[\\]").concat("~⁓∼~");function Sg(e,t){e=e.split("-"),t=t.split("-");for(var i=e[0].split("."),n=t[0].split("."),r=0;r<3;r++){var s=Number(i[r]),a=Number(n[r]);if(s>a)return 1;if(a>s)return-1;if(!isNaN(s)&&isNaN(a))return 1;if(isNaN(s)&&!isNaN(a))return-1}return e[1]&&t[1]?e[1]>t[1]?1:e[1]<t[1]?-1:0:!e[1]&&t[1]?1:e[1]&&!t[1]?-1:0}var bg={}.constructor;function wg(e){return null!=e&&e.constructor===bg}function Eg(e){return Eg="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Eg(e)}function Cg(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Tg(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function $g(e,t,i){return t&&Tg(e.prototype,t),i&&Tg(e,i),Object.defineProperty(e,"prototype",{writable:!1}),e}var _g=" ext. ",xg=/^\d+$/,Ig=function(){function e(t){Cg(this,e),function(e){if(!e)throw new Error("[libphonenumber-js] `metadata` argument not passed. Check your arguments.");if(!wg(e)||!wg(e.countries))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(wg(e)?"an object of shape: { "+Object.keys(e).join(", ")+" }":"a "+kg(e)+": "+e,"."))}(t),this.metadata=t,Fg.call(this,t)}return $g(e,[{key:"getCountries",value:function(){return Object.keys(this.metadata.countries).filter((function(e){return"001"!==e}))}},{key:"getCountryMetadata",value:function(e){return this.metadata.countries[e]}},{key:"nonGeographic",value:function(){if(!(this.v1||this.v2||this.v3))return this.metadata.nonGeographic||this.metadata.nonGeographical}},{key:"hasCountry",value:function(e){return void 0!==this.getCountryMetadata(e)}},{key:"hasCallingCode",value:function(e){if(this.getCountryCodesForCallingCode(e))return!0;if(this.nonGeographic()){if(this.nonGeographic()[e])return!0}else{var t=this.countryCallingCodes()[e];if(t&&1===t.length&&"001"===t[0])return!0}}},{key:"isNonGeographicCallingCode",value:function(e){return this.nonGeographic()?!!this.nonGeographic()[e]:!this.getCountryCodesForCallingCode(e)}},{key:"country",value:function(e){return this.selectNumberingPlan(e)}},{key:"selectNumberingPlan",value:function(e,t){if(e&&xg.test(e)&&(t=e,e=null),e&&"001"!==e){if(!this.hasCountry(e))throw new Error("Unknown country: ".concat(e));this.numberingPlan=new Rg(this.getCountryMetadata(e),this)}else if(t){if(!this.hasCallingCode(t))throw new Error("Unknown calling code: ".concat(t));this.numberingPlan=new Rg(this.getNumberingPlanMetadata(t),this)}else this.numberingPlan=void 0;return this}},{key:"getCountryCodesForCallingCode",value:function(e){var t=this.countryCallingCodes()[e];if(t){if(1===t.length&&3===t[0].length)return;return t}}},{key:"getCountryCodeForCallingCode",value:function(e){var t=this.getCountryCodesForCallingCode(e);if(t)return t[0]}},{key:"getNumberingPlanMetadata",value:function(e){var t=this.getCountryCodeForCallingCode(e);if(t)return this.getCountryMetadata(t);if(this.nonGeographic()){var i=this.nonGeographic()[e];if(i)return i}else{var n=this.countryCallingCodes()[e];if(n&&1===n.length&&"001"===n[0])return this.metadata.countries["001"]}}},{key:"countryCallingCode",value:function(){return this.numberingPlan.callingCode()}},{key:"IDDPrefix",value:function(){return this.numberingPlan.IDDPrefix()}},{key:"defaultIDDPrefix",value:function(){return this.numberingPlan.defaultIDDPrefix()}},{key:"nationalNumberPattern",value:function(){return this.numberingPlan.nationalNumberPattern()}},{key:"possibleLengths",value:function(){return this.numberingPlan.possibleLengths()}},{key:"formats",value:function(){return this.numberingPlan.formats()}},{key:"nationalPrefixForParsing",value:function(){return this.numberingPlan.nationalPrefixForParsing()}},{key:"nationalPrefixTransformRule",value:function(){return this.numberingPlan.nationalPrefixTransformRule()}},{key:"leadingDigits",value:function(){return this.numberingPlan.leadingDigits()}},{key:"hasTypes",value:function(){return this.numberingPlan.hasTypes()}},{key:"type",value:function(e){return this.numberingPlan.type(e)}},{key:"ext",value:function(){return this.numberingPlan.ext()}},{key:"countryCallingCodes",value:function(){return this.v1?this.metadata.country_phone_code_to_countries:this.metadata.country_calling_codes}},{key:"chooseCountryByCountryCallingCode",value:function(e){return this.selectNumberingPlan(e)}},{key:"hasSelectedNumberingPlan",value:function(){return void 0!==this.numberingPlan}}]),e}(),Rg=function(){function e(t,i){Cg(this,e),this.globalMetadataObject=i,this.metadata=t,Fg.call(this,i.metadata)}return $g(e,[{key:"callingCode",value:function(){return this.metadata[0]}},{key:"getDefaultCountryMetadataForRegion",value:function(){return this.globalMetadataObject.getNumberingPlanMetadata(this.callingCode())}},{key:"IDDPrefix",value:function(){if(!this.v1&&!this.v2)return this.metadata[1]}},{key:"defaultIDDPrefix",value:function(){if(!this.v1&&!this.v2)return this.metadata[12]}},{key:"nationalNumberPattern",value:function(){return this.v1||this.v2?this.metadata[1]:this.metadata[2]}},{key:"possibleLengths",value:function(){if(!this.v1)return this.metadata[this.v2?2:3]}},{key:"_getFormats",value:function(e){return e[this.v1?2:this.v2?3:4]}},{key:"formats",value:function(){var e=this,t=this._getFormats(this.metadata)||this._getFormats(this.getDefaultCountryMetadataForRegion())||[];return t.map((function(t){return new Ag(t,e)}))}},{key:"nationalPrefix",value:function(){return this.metadata[this.v1?3:this.v2?4:5]}},{key:"_getNationalPrefixFormattingRule",value:function(e){return e[this.v1?4:this.v2?5:6]}},{key:"nationalPrefixFormattingRule",value:function(){return this._getNationalPrefixFormattingRule(this.metadata)||this._getNationalPrefixFormattingRule(this.getDefaultCountryMetadataForRegion())}},{key:"_nationalPrefixForParsing",value:function(){return this.metadata[this.v1?5:this.v2?6:7]}},{key:"nationalPrefixForParsing",value:function(){return this._nationalPrefixForParsing()||this.nationalPrefix()}},{key:"nationalPrefixTransformRule",value:function(){return this.metadata[this.v1?6:this.v2?7:8]}},{key:"_getNationalPrefixIsOptionalWhenFormatting",value:function(){return!!this.metadata[this.v1?7:this.v2?8:9]}},{key:"nationalPrefixIsOptionalWhenFormattingInNationalFormat",value:function(){return this._getNationalPrefixIsOptionalWhenFormatting(this.metadata)||this._getNationalPrefixIsOptionalWhenFormatting(this.getDefaultCountryMetadataForRegion())}},{key:"leadingDigits",value:function(){return this.metadata[this.v1?8:this.v2?9:10]}},{key:"types",value:function(){return this.metadata[this.v1?9:this.v2?10:11]}},{key:"hasTypes",value:function(){return(!this.types()||0!==this.types().length)&&!!this.types()}},{key:"type",value:function(e){if(this.hasTypes()&&Ng(this.types(),e))return new Dg(Ng(this.types(),e),this)}},{key:"ext",value:function(){return this.v1||this.v2?_g:this.metadata[13]||_g}}]),e}(),Ag=function(){function e(t,i){Cg(this,e),this._format=t,this.metadata=i}return $g(e,[{key:"pattern",value:function(){return this._format[0]}},{key:"format",value:function(){return this._format[1]}},{key:"leadingDigitsPatterns",value:function(){return this._format[2]||[]}},{key:"nationalPrefixFormattingRule",value:function(){return this._format[3]||this.metadata.nationalPrefixFormattingRule()}},{key:"nationalPrefixIsOptionalWhenFormattingInNationalFormat",value:function(){return!!this._format[4]||this.metadata.nationalPrefixIsOptionalWhenFormattingInNationalFormat()}},{key:"nationalPrefixIsMandatoryWhenFormattingInNationalFormat",value:function(){return this.usesNationalPrefix()&&!this.nationalPrefixIsOptionalWhenFormattingInNationalFormat()}},{key:"usesNationalPrefix",value:function(){return!(!this.nationalPrefixFormattingRule()||Pg.test(this.nationalPrefixFormattingRule()))}},{key:"internationalFormat",value:function(){return this._format[5]||this.format()}}]),e}(),Pg=/^\(?\$1\)?$/,Dg=function(){function e(t,i){Cg(this,e),this.type=t,this.metadata=i}return $g(e,[{key:"pattern",value:function(){return this.metadata.v1?this.type:this.type[0]}},{key:"possibleLengths",value:function(){if(!this.metadata.v1)return this.type[1]||this.metadata.possibleLengths()}}]),e}();function Ng(e,t){switch(t){case"FIXED_LINE":return e[0];case"MOBILE":return e[1];case"TOLL_FREE":return e[2];case"PREMIUM_RATE":return e[3];case"PERSONAL_NUMBER":return e[4];case"VOICEMAIL":return e[5];case"UAN":return e[6];case"PAGER":return e[7];case"VOIP":return e[8];case"SHARED_COST":return e[9]}}var kg=function(e){return Eg(e)};function Og(e,t){if((t=new Ig(t)).hasCountry(e))return t.country(e).countryCallingCode();throw new Error("Unknown country: ".concat(e))}function Fg(e){var t=e.version;"number"==typeof t?(this.v1=1===t,this.v2=2===t,this.v3=3===t,this.v4=4===t):t?-1===Sg(t,"1.2.0")?this.v2=!0:-1===Sg(t,"1.7.35")?this.v3=!0:this.v4=!0:this.v1=!0}var Mg=function(e){return"([".concat(vg,"]{1,").concat(e,"})")};function Hg(e){var t="[  \\t,]*",i="[:\\..]?[  \\t,-]*",n="#?",r="[  \\t]*";return";ext="+Mg("20")+"|"+(t+"(?:e?xt(?:ensi(?:ó?|ó))?n?|e?xtn?|доб|anexo)"+i+Mg("20")+n)+"|"+(t+"(?:[xx##~~]|int|int)"+i+Mg("9")+n)+"|"+("[- ]+"+Mg("6")+"#")+"|"+(r+"(?:,{2}|;)"+i+Mg("15")+n)+"|"+(r+"(?:,)+"+i+Mg("9")+n)}var Lg="["+vg+"]{"+gg+"}",jg="[++]{0,1}(?:["+yg+"]*["+vg+"]){3,}["+yg+vg+"]*",Bg=new RegExp("^[++]{0,1}(?:["+yg+"]*["+vg+"]){1,2}$","i"),Ug=jg+"(?:"+Hg()+")?",Vg=new RegExp("^"+Lg+"$|^"+Ug+"$","i");var qg=new RegExp("(?:"+Hg()+")$","i");function Gg(e,t){var i="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(i)return(i=i.call(e)).next.bind(i);if(Array.isArray(e)||(i=function(e,t){if(!e)return;if("string"==typeof e)return Kg(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);"Object"===i&&e.constructor&&(i=e.constructor.name);if("Map"===i||"Set"===i)return Array.from(e);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return Kg(e,t)}(e))||t&&e&&"number"==typeof e.length){i&&(e=i);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Kg(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i<t;i++)n[i]=e[i];return n}var Wg={0:"0",1:"1",2:"2",3:"3",4:"4",5:"5",6:"6",7:"7",8:"8",9:"9","0":"0","1":"1","2":"2","3":"3","4":"4","5":"5","6":"6","7":"7","8":"8","9":"9","٠":"0","١":"1","٢":"2","٣":"3","٤":"4","٥":"5","٦":"6","٧":"7","٨":"8","٩":"9","۰":"0","۱":"1","۲":"2","۳":"3","۴":"4","۵":"5","۶":"6","۷":"7","۸":"8","۹":"9"};function zg(e){return Wg[e]}function Yg(e){for(var t,i="",n=Gg(e.split(""));!(t=n()).done;){var r=zg(t.value);r&&(i+=r)}return i}function Jg(e,t){var i="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(i)return(i=i.call(e)).next.bind(i);if(Array.isArray(e)||(i=function(e,t){if(!e)return;if("string"==typeof e)return Zg(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);"Object"===i&&e.constructor&&(i=e.constructor.name);if("Map"===i||"Set"===i)return Array.from(e);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return Zg(e,t)}(e))||t&&e&&"number"==typeof e.length){i&&(e=i);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Zg(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i<t;i++)n[i]=e[i];return n}function Xg(e){for(var t,i="",n=Jg(e.split(""));!(t=n()).done;){i+=Qg(t.value,i)||""}return i}function Qg(e,t,i){return"+"===e?t?void("function"==typeof i&&i("end")):"+":zg(e)}function ef(e,t){var i="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(i)return(i=i.call(e)).next.bind(i);if(Array.isArray(e)||(i=function(e,t){if(!e)return;if("string"==typeof e)return tf(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);"Object"===i&&e.constructor&&(i=e.constructor.name);if("Map"===i||"Set"===i)return Array.from(e);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return tf(e,t)}(e))||t&&e&&"number"==typeof e.length){i&&(e=i);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function tf(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i<t;i++)n[i]=e[i];return n}function nf(e,t){return rf(e,void 0,t)}function rf(e,t,i){var n=i.type(t),r=n&&n.possibleLengths()||i.possibleLengths();if(!r)return"IS_POSSIBLE";if("FIXED_LINE_OR_MOBILE"===t){if(!i.type("FIXED_LINE"))return rf(e,"MOBILE",i);var s=i.type("MOBILE");s&&(r=function(e,t){for(var i,n=e.slice(),r=ef(t);!(i=r()).done;){var s=i.value;e.indexOf(s)<0&&n.push(s)}return n.sort((function(e,t){return e-t}))}(r,s.possibleLengths()))}else if(t&&!n)return"INVALID_LENGTH";var a=e.length,o=r[0];return o===a?"IS_POSSIBLE":o>a?"TOO_SHORT":r[r.length-1]<a?"TOO_LONG":r.indexOf(a,1)>=0?"IS_POSSIBLE":"INVALID_LENGTH"}function sf(e,t){return"IS_POSSIBLE"===nf(e,t)}function af(e,t){return e=e||"",new RegExp("^(?:"+t+")$").test(e)}function of(e,t){var i="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(i)return(i=i.call(e)).next.bind(i);if(Array.isArray(e)||(i=function(e,t){if(!e)return;if("string"==typeof e)return cf(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);"Object"===i&&e.constructor&&(i=e.constructor.name);if("Map"===i||"Set"===i)return Array.from(e);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return cf(e,t)}(e))||t&&e&&"number"==typeof e.length){i&&(e=i);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function cf(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i<t;i++)n[i]=e[i];return n}var df=["MOBILE","PREMIUM_RATE","TOLL_FREE","SHARED_COST","VOIP","PERSONAL_NUMBER","PAGER","UAN","VOICEMAIL"];function lf(e,t,i){if(t=t||{},e.country||e.countryCallingCode){(i=new Ig(i)).selectNumberingPlan(e.country,e.countryCallingCode);var n=t.v2?e.nationalNumber:e.phone;if(af(n,i.nationalNumberPattern())){if(hf(n,"FIXED_LINE",i))return i.type("MOBILE")&&""===i.type("MOBILE").pattern()?"FIXED_LINE_OR_MOBILE":i.type("MOBILE")?hf(n,"MOBILE",i)?"FIXED_LINE_OR_MOBILE":"FIXED_LINE":"FIXED_LINE_OR_MOBILE";for(var r,s=of(df);!(r=s()).done;){var a=r.value;if(hf(n,a,i))return a}}}}function hf(e,t,i){return!(!(t=i.type(t))||!t.pattern())&&(!(t.possibleLengths()&&t.possibleLengths().indexOf(e.length)<0)&&af(e,t.pattern()))}function uf(e,t,i){var n=new Ig(i).getCountryCodesForCallingCode(e);return n?n.filter((function(e){return function(e,t,i){var n=new Ig(i);if(n.selectNumberingPlan(t),n.numberingPlan.possibleLengths().indexOf(e.length)>=0)return!0;return!1}(t,e,i)})):[]}function pf(e){return e.replace(new RegExp("[".concat(yg,"]+"),"g")," ").trim()}var gf=/(\$\d)/;function ff(e,t,i){var n=i.useInternationalFormat,r=i.withNationalPrefix;i.carrierCode,i.metadata;var s=e.replace(new RegExp(t.pattern()),n?t.internationalFormat():r&&t.nationalPrefixFormattingRule()?t.format().replace(gf,t.nationalPrefixFormattingRule()):t.format());return n?pf(s):s}var mf=/^[\d]+(?:[~\u2053\u223C\uFF5E][\d]+)?$/;function vf(e,t){var i="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(i)return(i=i.call(e)).next.bind(i);if(Array.isArray(e)||(i=function(e,t){if(!e)return;if("string"==typeof e)return yf(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);"Object"===i&&e.constructor&&(i=e.constructor.name);if("Map"===i||"Set"===i)return Array.from(e);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return yf(e,t)}(e))||t&&e&&"number"==typeof e.length){i&&(e=i);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function yf(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i<t;i++)n[i]=e[i];return n}function Sf(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function bf(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?Sf(Object(i),!0).forEach((function(t){wf(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):Sf(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function wf(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}var Ef={formatExtension:function(e,t,i){return"".concat(e).concat(i.ext()).concat(t)}};function Cf(e,t,i,n){if(i=i?bf(bf({},Ef),i):Ef,n=new Ig(n),e.country&&"001"!==e.country){if(!n.hasCountry(e.country))throw new Error("Unknown country: ".concat(e.country));n.country(e.country)}else{if(!e.countryCallingCode)return e.phone||"";n.selectNumberingPlan(e.countryCallingCode)}var r,s=n.countryCallingCode(),a=i.v2?e.nationalNumber:e.phone;switch(t){case"NATIONAL":return a?$f(r=Tf(a,e.carrierCode,"NATIONAL",n,i),e.ext,n,i.formatExtension):"";case"INTERNATIONAL":return a?(r=Tf(a,null,"INTERNATIONAL",n,i),$f(r="+".concat(s," ").concat(r),e.ext,n,i.formatExtension)):"+".concat(s);case"E.164":return"+".concat(s).concat(a);case"RFC3966":return function(e){var t=e.number,i=e.ext;if(!t)return"";if("+"!==t[0])throw new Error('"formatRFC3966()" expects "number" to be in E.164 format.');return"tel:".concat(t).concat(i?";ext="+i:"")}({number:"+".concat(s).concat(a),ext:e.ext});case"IDD":if(!i.fromCountry)return;var o=function(e,t,i,n,r){var s=Og(n,r.metadata);if(s===i){var a=Tf(e,t,"NATIONAL",r);return"1"===i?i+" "+a:a}var o=function(e,t,i){var n=new Ig(i);return n.selectNumberingPlan(e,t),n.defaultIDDPrefix()?n.defaultIDDPrefix():mf.test(n.IDDPrefix())?n.IDDPrefix():void 0}(n,void 0,r.metadata);if(o)return"".concat(o," ").concat(i," ").concat(Tf(e,null,"INTERNATIONAL",r))}(a,e.carrierCode,s,i.fromCountry,n);return $f(o,e.ext,n,i.formatExtension);default:throw new Error('Unknown "format" argument passed to "formatNumber()": "'.concat(t,'"'))}}function Tf(e,t,i,n,r){var s=function(e,t){for(var i,n=vf(e);!(i=n()).done;){var r=i.value;if(r.leadingDigitsPatterns().length>0){var s=r.leadingDigitsPatterns()[r.leadingDigitsPatterns().length-1];if(0!==t.search(s))continue}if(af(t,r.pattern()))return r}}(n.formats(),e);return s?ff(e,s,{useInternationalFormat:"INTERNATIONAL"===i,withNationalPrefix:!s.nationalPrefixIsOptionalWhenFormattingInNationalFormat()||!r||!1!==r.nationalPrefix,carrierCode:t,metadata:n}):e}function $f(e,t,i,n){return t?n(e,t,i):e}function _f(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function xf(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?_f(Object(i),!0).forEach((function(t){If(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):_f(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function If(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function Rf(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var Af=function(){function e(t,i,n){if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),!t)throw new TypeError("`country` or `countryCallingCode` not passed");if(!i)throw new TypeError("`nationalNumber` not passed");if(!n)throw new TypeError("`metadata` not passed");var r=function(e,t){var i,n,r=new Ig(t);Pf(e)?(i=e,r.selectNumberingPlan(i),n=r.countryCallingCode()):n=e;return{country:i,countryCallingCode:n}}(t,n),s=r.country,a=r.countryCallingCode;this.country=s,this.countryCallingCode=a,this.nationalNumber=i,this.number="+"+this.countryCallingCode+this.nationalNumber,this.getMetadata=function(){return n}}var t,i,n;return t=e,i=[{key:"setExt",value:function(e){this.ext=e}},{key:"getPossibleCountries",value:function(){return this.country?[this.country]:uf(this.countryCallingCode,this.nationalNumber,this.getMetadata())}},{key:"isPossible",value:function(){return function(e,t,i){if(void 0===t&&(t={}),i=new Ig(i),t.v2){if(!e.countryCallingCode)throw new Error("Invalid phone number object passed");i.selectNumberingPlan(e.countryCallingCode)}else{if(!e.phone)return!1;if(e.country){if(!i.hasCountry(e.country))throw new Error("Unknown country: ".concat(e.country));i.country(e.country)}else{if(!e.countryCallingCode)throw new Error("Invalid phone number object passed");i.selectNumberingPlan(e.countryCallingCode)}}if(i.possibleLengths())return sf(e.phone||e.nationalNumber,i);if(e.countryCallingCode&&i.isNonGeographicCallingCode(e.countryCallingCode))return!0;throw new Error('Missing "possibleLengths" in metadata. Perhaps the metadata has been generated before v1.0.18.')}(this,{v2:!0},this.getMetadata())}},{key:"isValid",value:function(){return function(e,t,i){return t=t||{},(i=new Ig(i)).selectNumberingPlan(e.country,e.countryCallingCode),i.hasTypes()?void 0!==lf(e,t,i.metadata):af(t.v2?e.nationalNumber:e.phone,i.nationalNumberPattern())}(this,{v2:!0},this.getMetadata())}},{key:"isNonGeographic",value:function(){return new Ig(this.getMetadata()).isNonGeographicCallingCode(this.countryCallingCode)}},{key:"isEqual",value:function(e){return this.number===e.number&&this.ext===e.ext}},{key:"getType",value:function(){return lf(this,{v2:!0},this.getMetadata())}},{key:"format",value:function(e,t){return Cf(this,e,t?xf(xf({},t),{},{v2:!0}):{v2:!0},this.getMetadata())}},{key:"formatNational",value:function(e){return this.format("NATIONAL",e)}},{key:"formatInternational",value:function(e){return this.format("INTERNATIONAL",e)}},{key:"getURI",value:function(e){return this.format("RFC3966",e)}}],i&&Rf(t.prototype,i),n&&Rf(t,n),Object.defineProperty(t,"prototype",{writable:!1}),e}(),Pf=function(e){return/^[A-Z]{2}$/.test(e)};var Df=new RegExp("(["+vg+"])");function Nf(e,t,i,n){if(t){var r=new Ig(n);r.selectNumberingPlan(t,i);var s=new RegExp(r.IDDPrefix());if(0===e.search(s)){var a=(e=e.slice(e.match(s)[0].length)).match(Df);if(!(a&&null!=a[1]&&a[1].length>0&&"0"===a[1]))return e}}}function kf(e,t){if(e&&t.numberingPlan.nationalPrefixForParsing()){var i=new RegExp("^(?:"+t.numberingPlan.nationalPrefixForParsing()+")"),n=i.exec(e);if(n){var r,s,a,o=n.length-1,c=o>0&&n[o];if(t.nationalPrefixTransformRule()&&c)r=e.replace(i,t.nationalPrefixTransformRule()),o>1&&(s=n[1]);else{var d=n[0];r=e.slice(d.length),c&&(s=n[1])}if(c){var l=e.indexOf(n[1]);e.slice(0,l)===t.numberingPlan.nationalPrefix()&&(a=t.numberingPlan.nationalPrefix())}else a=n[0];return{nationalNumber:r,nationalPrefix:a,carrierCode:s}}}return{nationalNumber:e}}function Of(e,t){var i=kf(e,t),n=i.carrierCode,r=i.nationalNumber;if(r!==e){if(!function(e,t,i){if(af(e,i.nationalNumberPattern())&&!af(t,i.nationalNumberPattern()))return!1;return!0}(e,r,t))return{nationalNumber:e};if(t.possibleLengths()&&!function(e,t){switch(nf(e,t)){case"TOO_SHORT":case"INVALID_LENGTH":return!1;default:return!0}}(r,t))return{nationalNumber:e}}return{nationalNumber:r,carrierCode:n}}function Ff(e,t,i,n){var r=t?Og(t,n):i;if(0===e.indexOf(r)){(n=new Ig(n)).selectNumberingPlan(t,i);var s=e.slice(r.length),a=Of(s,n).nationalNumber,o=Of(e,n).nationalNumber;if(!af(o,n.nationalNumberPattern())&&af(a,n.nationalNumberPattern())||"TOO_LONG"===nf(o,n))return{countryCallingCode:r,number:s}}return{number:e}}function Mf(e,t,i,n){if(!e)return{};var r;if("+"!==e[0]){var s=Nf(e,t,i,n);if(!s||s===e){if(t||i){var a=Ff(e,t,i,n),o=a.countryCallingCode,c=a.number;if(o)return{countryCallingCodeSource:"FROM_NUMBER_WITHOUT_PLUS_SIGN",countryCallingCode:o,number:c}}return{number:e}}r=!0,e="+"+s}if("0"===e[1])return{};n=new Ig(n);for(var d=2;d-1<=mg&&d<=e.length;){var l=e.slice(1,d);if(n.hasCallingCode(l))return n.selectNumberingPlan(l),{countryCallingCodeSource:r?"FROM_NUMBER_WITH_IDD":"FROM_NUMBER_WITH_PLUS_SIGN",countryCallingCode:l,number:e.slice(d)};d++}return{}}function Hf(e,t){var i="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(i)return(i=i.call(e)).next.bind(i);if(Array.isArray(e)||(i=function(e,t){if(!e)return;if("string"==typeof e)return Lf(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);"Object"===i&&e.constructor&&(i=e.constructor.name);if("Map"===i||"Set"===i)return Array.from(e);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return Lf(e,t)}(e))||t&&e&&"number"==typeof e.length){i&&(e=i);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Lf(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i<t;i++)n[i]=e[i];return n}function jf(e,t){var i=t.countries,n=t.defaultCountry,r=t.metadata;r=new Ig(r);for(var s,a=[],o=Hf(i);!(s=o()).done;){var c=s.value;if(r.country(c),r.leadingDigits()){if(e&&0===e.search(r.leadingDigits()))return c}else if(lf({phone:e,country:c},void 0,r.metadata)){if(!n)return c;if(c===n)return c;a.push(c)}}if(a.length>0)return a[0]}var Bf=!1;function Uf(e,t){var i=t.nationalNumber,n=t.defaultCountry,r=t.metadata;if(Bf&&r.isNonGeographicCallingCode(e))return"001";var s=r.getCountryCodesForCallingCode(e);return s?1===s.length?s[0]:jf(i,{countries:s,defaultCountry:n,metadata:r.metadata}):void 0}var Vf="+",qf="(["+vg+"]|[\\-\\.\\(\\)]?)",Gf=new RegExp("^\\"+Vf+qf+"*["+vg+"]"+qf+"*$","g"),Kf=new RegExp("^("+("["+vg+"]+((\\-)*["+vg+"])*")+"\\.)*"+("[a-zA-Z]+((\\-)*["+vg+"])*")+"\\.?$","g"),Wf="tel:",zf=";phone-context=",Yf=";isub=";function Jf(e,t){var i,n=t.extractFormattedPhoneNumber,r=function(e){var t=e.indexOf(zf);if(t<0)return null;var i=t+zf.length;if(i>=e.length)return"";var n=e.indexOf(";",i);return n>=0?e.substring(i,n):e.substring(i)}(e);if(!function(e){return null===e||0!==e.length&&(Gf.test(e)||Kf.test(e))}(r))throw new pg("NOT_A_NUMBER");if(null===r)i=n(e)||"";else{i="",r.charAt(0)===Vf&&(i+=r);var s,a=e.indexOf(Wf);s=a>=0?a+Wf.length:0;var o=e.indexOf(zf);i+=e.substring(s,o)}var c=i.indexOf(Yf);if(c>0&&(i=i.substring(0,c)),""!==i)return i}var Zf=250,Xf=new RegExp("[++"+vg+"]"),Qf=new RegExp("[^"+vg+"#]+$");function em(e,t,i){if(t=t||{},i=new Ig(i),t.defaultCountry&&!i.hasCountry(t.defaultCountry)){if(t.v2)throw new pg("INVALID_COUNTRY");throw new Error("Unknown country: ".concat(t.defaultCountry))}var n=function(e,t,i){var n=Jf(e,{extractFormattedPhoneNumber:function(e){return function(e,t,i){if(!e)return;if(e.length>Zf){if(i)throw new pg("TOO_LONG");return}if(!1===t)return e;var n=e.search(Xf);if(n<0)return;return e.slice(n).replace(Qf,"")}(e,i,t)}});if(!n)return{};if(!function(e){return e.length>=gg&&Vg.test(e)}(n))return function(e){return Bg.test(e)}(n)?{error:"TOO_SHORT"}:{};var r=function(e){var t=e.search(qg);if(t<0)return{};for(var i=e.slice(0,t),n=e.match(qg),r=1;r<n.length;){if(n[r])return{number:i,ext:n[r]};r++}}(n);if(r.ext)return r;return{number:n}}(e,t.v2,t.extract),r=n.number,s=n.ext,a=n.error;if(!r){if(t.v2){if("TOO_SHORT"===a)throw new pg("TOO_SHORT");throw new pg("NOT_A_NUMBER")}return{}}var o=function(e,t,i,n){var r,s=Mf(Xg(e),t,i,n.metadata),a=s.countryCallingCodeSource,o=s.countryCallingCode,c=s.number;if(o)n.selectNumberingPlan(o);else{if(!c||!t&&!i)return{};n.selectNumberingPlan(t,i),t&&(r=t),o=i||Og(t,n.metadata)}if(!c)return{countryCallingCodeSource:a,countryCallingCode:o};var d=Of(Xg(c),n),l=d.nationalNumber,h=d.carrierCode,u=Uf(o,{nationalNumber:l,defaultCountry:t,metadata:n});u&&(r=u,"001"===u||n.country(r));return{country:r,countryCallingCode:o,countryCallingCodeSource:a,nationalNumber:l,carrierCode:h}}(r,t.defaultCountry,t.defaultCallingCode,i),c=o.country,d=o.nationalNumber,l=o.countryCallingCode,h=o.countryCallingCodeSource,u=o.carrierCode;if(!i.hasSelectedNumberingPlan()){if(t.v2)throw new pg("INVALID_COUNTRY");return{}}if(!d||d.length<gg){if(t.v2)throw new pg("TOO_SHORT");return{}}if(d.length>fg){if(t.v2)throw new pg("TOO_LONG");return{}}if(t.v2){var p=new Af(l,d,i.metadata);return c&&(p.country=c),u&&(p.carrierCode=u),s&&(p.ext=s),p.__countryCallingCodeSource=h,p}var g=!!(t.extended?i.hasSelectedNumberingPlan():c)&&af(d,i.nationalNumberPattern());return t.extended?{country:c,countryCallingCode:l,carrierCode:u,valid:g,possible:!!g||!(!0!==t.extended||!i.possibleLengths()||!sf(d,i)),phone:d,ext:s}:g?function(e,t,i){var n={country:e,phone:t};i&&(n.ext=i);return n}(c,d,s):{}}function tm(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function im(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?tm(Object(i),!0).forEach((function(t){nm(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):tm(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function nm(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function rm(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function sm(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function am(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==i)return;var n,r,s=[],a=!0,o=!1;try{for(i=i.call(e);!(a=(n=i.next()).done)&&(s.push(n.value),!t||s.length!==t);a=!0);}catch(e){o=!0,r=e}finally{try{a||null==i.return||i.return()}finally{if(o)throw r}}return s}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return om(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);"Object"===i&&e.constructor&&(i=e.constructor.name);if("Map"===i||"Set"===i)return Array.from(e);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return om(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function om(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i<t;i++)n[i]=e[i];return n}function cm(e){var t,i,n,r=am(Array.prototype.slice.call(e),4),s=r[0],a=r[1],o=r[2],c=r[3];if("string"!=typeof s)throw new TypeError("A text for parsing must be a string.");if(t=s,a&&"string"!=typeof a){if(!wg(a))throw new Error("Invalid second argument: ".concat(a));o?(i=a,n=o):n=a}else c?(i=o,n=c):(i=void 0,n=o),a&&(i=function(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?rm(Object(i),!0).forEach((function(t){sm(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):rm(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}({defaultCountry:a},i));return{text:t,options:i,metadata:n}}function dm(){var e=cm(arguments);return function(e,t,i){return em(e,im(im({},t),{},{v2:!0}),i)}(e.text,e.options,e.metadata)}function lm(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var hm=function(){function e(t){var i=t.onCountryChange,n=t.onCallingCodeChange;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.onCountryChange=i,this.onCallingCodeChange=n}var t,i,n;return t=e,(i=[{key:"reset",value:function(e){var t=e.country,i=e.callingCode;this.international=!1,this.missingPlus=!1,this.IDDPrefix=void 0,this.callingCode=void 0,this.digits="",this.resetNationalSignificantNumber(),this.initCountryAndCallingCode(t,i)}},{key:"resetNationalSignificantNumber",value:function(){this.nationalSignificantNumber=this.getNationalDigits(),this.nationalSignificantNumberMatchesInput=!0,this.nationalPrefix=void 0,this.carrierCode=void 0,this.complexPrefixBeforeNationalSignificantNumber=void 0}},{key:"update",value:function(e){for(var t=0,i=Object.keys(e);t<i.length;t++){var n=i[t];this[n]=e[n]}}},{key:"initCountryAndCallingCode",value:function(e,t){this.setCountry(e),this.setCallingCode(t)}},{key:"setCountry",value:function(e){this.country=e,this.onCountryChange(e)}},{key:"setCallingCode",value:function(e){this.callingCode=e,this.onCallingCodeChange(e,this.country)}},{key:"startInternationalNumber",value:function(e,t){this.international=!0,this.initCountryAndCallingCode(e,t)}},{key:"appendDigits",value:function(e){this.digits+=e}},{key:"appendNationalSignificantNumberDigits",value:function(e){this.nationalSignificantNumber+=e}},{key:"getNationalDigits",value:function(){return this.international?this.digits.slice((this.IDDPrefix?this.IDDPrefix.length:0)+(this.callingCode?this.callingCode.length:0)):this.digits}},{key:"getDigitsWithoutInternationalPrefix",value:function(){return this.international&&this.IDDPrefix?this.digits.slice(this.IDDPrefix.length):this.digits}}])&&lm(t.prototype,i),n&&lm(t,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();function um(e,t){var i="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(i)return(i=i.call(e)).next.bind(i);if(Array.isArray(e)||(i=function(e,t){if(!e)return;if("string"==typeof e)return pm(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);"Object"===i&&e.constructor&&(i=e.constructor.name);if("Map"===i||"Set"===i)return Array.from(e);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return pm(e,t)}(e))||t&&e&&"number"==typeof e.length){i&&(e=i);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function pm(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i<t;i++)n[i]=e[i];return n}var gm="x",fm=new RegExp(gm);function mm(e,t){if(t<1)return"";for(var i="";t>1;)1&t&&(i+=e),t>>=1,e+=e;return i+e}function vm(e,t){return")"===e[t]&&t++,function(e){var t=[],i=0;for(;i<e.length;)"("===e[i]?t.push(i):")"===e[i]&&t.pop(),i++;var n=0,r="";t.push(e.length);for(var s=0,a=t;s<a.length;s++){var o=a[s];r+=e.slice(n,o),n=o+1}return r}(e.slice(0,t))}function ym(e,t,i){var n=i.metadata,r=i.shouldTryNationalPrefixFormattingRule,s=i.getSeparatorAfterNationalPrefix;if(new RegExp("^(?:".concat(t.pattern(),")$")).test(e.nationalSignificantNumber))return function(e,t,i){var n=i.metadata,r=i.shouldTryNationalPrefixFormattingRule,s=i.getSeparatorAfterNationalPrefix;if(e.nationalSignificantNumber,e.international,e.nationalPrefix,e.carrierCode,r(t)){var a=Sm(e,t,{useNationalPrefixFormattingRule:!0,getSeparatorAfterNationalPrefix:s,metadata:n});if(a)return a}return Sm(e,t,{useNationalPrefixFormattingRule:!1,getSeparatorAfterNationalPrefix:s,metadata:n})}(e,t,{metadata:n,shouldTryNationalPrefixFormattingRule:r,getSeparatorAfterNationalPrefix:s})}function Sm(e,t,i){var n=i.metadata,r=i.useNationalPrefixFormattingRule,s=i.getSeparatorAfterNationalPrefix,a=ff(e.nationalSignificantNumber,t,{carrierCode:e.carrierCode,useInternationalFormat:e.international,withNationalPrefix:r,metadata:n});if(r||(e.nationalPrefix?a=e.nationalPrefix+s(t)+a:e.complexPrefixBeforeNationalSignificantNumber&&(a=e.complexPrefixBeforeNationalSignificantNumber+" "+a)),function(e,t){return Yg(e)===t.getNationalDigits()}(a,e))return a}function bm(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var wm=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}var t,i,n;return t=e,(i=[{key:"parse",value:function(e){if(this.context=[{or:!0,instructions:[]}],this.parsePattern(e),1!==this.context.length)throw new Error("Non-finalized contexts left when pattern parse ended");var t=this.context[0],i=t.branches,n=t.instructions;if(i)return{op:"|",args:i.concat([$m(n)])};if(0===n.length)throw new Error("Pattern is required");return 1===n.length?n[0]:n}},{key:"startContext",value:function(e){this.context.push(e)}},{key:"endContext",value:function(){this.context.pop()}},{key:"getContext",value:function(){return this.context[this.context.length-1]}},{key:"parsePattern",value:function(e){if(!e)throw new Error("Pattern is required");var t=e.match(Tm);if(t){var i=t[1],n=e.slice(0,t.index),r=e.slice(t.index+i.length);switch(i){case"(?:":n&&this.parsePattern(n),this.startContext({or:!0,instructions:[],branches:[]});break;case")":if(!this.getContext().or)throw new Error('")" operator must be preceded by "(?:" operator');if(n&&this.parsePattern(n),0===this.getContext().instructions.length)throw new Error('No instructions found after "|" operator in an "or" group');var s=this.getContext().branches;s.push($m(this.getContext().instructions)),this.endContext(),this.getContext().instructions.push({op:"|",args:s});break;case"|":if(!this.getContext().or)throw new Error('"|" operator can only be used inside "or" groups');if(n&&this.parsePattern(n),!this.getContext().branches){if(1!==this.context.length)throw new Error('"branches" not found in an "or" group context');this.getContext().branches=[]}this.getContext().branches.push($m(this.getContext().instructions)),this.getContext().instructions=[];break;case"[":n&&this.parsePattern(n),this.startContext({oneOfSet:!0});break;case"]":if(!this.getContext().oneOfSet)throw new Error('"]" operator must be preceded by "[" operator');this.endContext(),this.getContext().instructions.push({op:"[]",args:Em(n)});break;default:throw new Error("Unknown operator: ".concat(i))}r&&this.parsePattern(r)}else{if(Cm.test(e))throw new Error("Illegal characters found in a pattern: ".concat(e));this.getContext().instructions=this.getContext().instructions.concat(e.split(""))}}}])&&bm(t.prototype,i),n&&bm(t,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();function Em(e){for(var t=[],i=0;i<e.length;){if("-"===e[i]){if(0===i||i===e.length-1)throw new Error("Couldn't parse a one-of set pattern: ".concat(e));for(var n=e[i-1].charCodeAt(0)+1,r=e[i+1].charCodeAt(0)-1,s=n;s<=r;)t.push(String.fromCharCode(s)),s++}else t.push(e[i]);i++}return t}var Cm=/[\(\)\[\]\?\:\|]/,Tm=new RegExp("(\\||\\(\\?\\:|\\)|\\[|\\])");function $m(e){return 1===e.length?e[0]:e}function _m(e,t){var i="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(i)return(i=i.call(e)).next.bind(i);if(Array.isArray(e)||(i=function(e,t){if(!e)return;if("string"==typeof e)return xm(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);"Object"===i&&e.constructor&&(i=e.constructor.name);if("Map"===i||"Set"===i)return Array.from(e);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return xm(e,t)}(e))||t&&e&&"number"==typeof e.length){i&&(e=i);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function xm(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i<t;i++)n[i]=e[i];return n}function Im(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var Rm=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.matchTree=(new wm).parse(t)}var t,i,n;return t=e,i=[{key:"match",value:function(e){var t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).allowOverflow;if(!e)throw new Error("String is required");var i=Am(e.split(""),this.matchTree,!0);if(i&&i.match&&delete i.matchedChars,!i||!i.overflow||t)return i}}],i&&Im(t.prototype,i),n&&Im(t,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();function Am(e,t,i){if("string"==typeof t){var n=e.join("");return 0===t.indexOf(n)?e.length===t.length?{match:!0,matchedChars:e}:{partialMatch:!0}:0===n.indexOf(t)?i&&e.length>t.length?{overflow:!0}:{match:!0,matchedChars:e.slice(0,t.length)}:void 0}if(Array.isArray(t)){for(var r=e.slice(),s=0;s<t.length;){var a=Am(r,t[s],i&&s===t.length-1);if(!a)return;if(a.overflow)return a;if(!a.match){if(a.partialMatch)return{partialMatch:!0};throw new Error("Unsupported match result:\n".concat(JSON.stringify(a,null,2)))}if(0===(r=r.slice(a.matchedChars.length)).length)return s===t.length-1?{match:!0,matchedChars:e}:{partialMatch:!0};s++}return i?{overflow:!0}:{match:!0,matchedChars:e.slice(0,e.length-r.length)}}switch(t.op){case"|":for(var o,c,d=_m(t.args);!(c=d()).done;){var l=Am(e,c.value,i);if(l){if(l.overflow)return l;if(l.match)return{match:!0,matchedChars:l.matchedChars};if(!l.partialMatch)throw new Error("Unsupported match result:\n".concat(JSON.stringify(l,null,2)));o=!0}}return o?{partialMatch:!0}:void 0;case"[]":for(var h,u=_m(t.args);!(h=u()).done;){var p=h.value;if(e[0]===p)return 1===e.length?{match:!0,matchedChars:e}:i?{overflow:!0}:{match:!0,matchedChars:[p]}}return;default:throw new Error("Unsupported instruction tree: ".concat(t))}}function Pm(e,t){var i="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(i)return(i=i.call(e)).next.bind(i);if(Array.isArray(e)||(i=function(e,t){if(!e)return;if("string"==typeof e)return Dm(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);"Object"===i&&e.constructor&&(i=e.constructor.name);if("Map"===i||"Set"===i)return Array.from(e);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return Dm(e,t)}(e))||t&&e&&"number"==typeof e.length){i&&(e=i);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Dm(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i<t;i++)n[i]=e[i];return n}function Nm(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var km=mm("9",15),Om=/[- ]/,Fm=new RegExp("["+yg+"]*\\$1["+yg+"]*(\\$\\d["+yg+"]*)*$"),Mm=function(){function e(t){t.state;var i=t.metadata;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.metadata=i,this.resetFormat()}var t,i,n;return t=e,i=[{key:"resetFormat",value:function(){this.chosenFormat=void 0,this.template=void 0,this.nationalNumberTemplate=void 0,this.populatedNationalNumberTemplate=void 0,this.populatedNationalNumberTemplatePosition=-1}},{key:"reset",value:function(e,t){this.resetFormat(),e?(this.isNANP="1"===e.callingCode(),this.matchingFormats=e.formats(),t.nationalSignificantNumber&&this.narrowDownMatchingFormats(t)):(this.isNANP=void 0,this.matchingFormats=[])}},{key:"format",value:function(e,t){var i=this;if(function(e,t){return"IS_POSSIBLE"===nf(e,t)}(t.nationalSignificantNumber,this.metadata))for(var n,r=Pm(this.matchingFormats);!(n=r()).done;){var s=n.value,a=ym(t,s,{metadata:this.metadata,shouldTryNationalPrefixFormattingRule:function(e){return i.shouldTryNationalPrefixFormattingRule(e,{international:t.international,nationalPrefix:t.nationalPrefix})},getSeparatorAfterNationalPrefix:function(e){return i.getSeparatorAfterNationalPrefix(e)}});if(a)return this.resetFormat(),this.chosenFormat=s,this.setNationalNumberTemplate(a.replace(/\d/g,gm),t),this.populatedNationalNumberTemplate=a,this.populatedNationalNumberTemplatePosition=this.template.lastIndexOf(gm),a}return this.formatNationalNumberWithNextDigits(e,t)}},{key:"formatNationalNumberWithNextDigits",value:function(e,t){var i=this.chosenFormat,n=this.chooseFormat(t);if(n)return n===i?this.formatNextNationalNumberDigits(e):this.formatNextNationalNumberDigits(t.getNationalDigits())}},{key:"narrowDownMatchingFormats",value:function(e){var t=this,i=e.nationalSignificantNumber,n=e.nationalPrefix,r=e.international,s=i,a=s.length-3;a<0&&(a=0),this.matchingFormats=this.matchingFormats.filter((function(e){return t.formatSuits(e,r,n)&&t.formatMatches(e,s,a)})),this.chosenFormat&&-1===this.matchingFormats.indexOf(this.chosenFormat)&&this.resetFormat()}},{key:"formatSuits",value:function(e,t,i){return!(i&&!e.usesNationalPrefix()&&!e.nationalPrefixIsOptionalWhenFormattingInNationalFormat()||!t&&!i&&e.nationalPrefixIsMandatoryWhenFormattingInNationalFormat())}},{key:"formatMatches",value:function(e,t,i){var n=e.leadingDigitsPatterns().length;if(0===n)return!0;i=Math.min(i,n-1);var r=e.leadingDigitsPatterns()[i];if(t.length<3)try{return void 0!==new Rm(r).match(t,{allowOverflow:!0})}catch(e){return console.error(e),!0}return new RegExp("^(".concat(r,")")).test(t)}},{key:"getFormatFormat",value:function(e,t){return t?e.internationalFormat():e.format()}},{key:"chooseFormat",value:function(e){for(var t,i=this,n=function(){var n=t.value;return i.chosenFormat===n?"break":Fm.test(i.getFormatFormat(n,e.international))?i.createTemplateForFormat(n,e)?(i.chosenFormat=n,"break"):(i.matchingFormats=i.matchingFormats.filter((function(e){return e!==n})),"continue"):"continue"},r=Pm(this.matchingFormats.slice());!(t=r()).done;){var s=n();if("break"===s)break}return this.chosenFormat||this.resetFormat(),this.chosenFormat}},{key:"createTemplateForFormat",value:function(e,t){if(!(e.pattern().indexOf("|")>=0)){var i=this.getTemplateForFormat(e,t);return i?(this.setNationalNumberTemplate(i,t),!0):void 0}}},{key:"getSeparatorAfterNationalPrefix",value:function(e){return this.isNANP||e&&e.nationalPrefixFormattingRule()&&Om.test(e.nationalPrefixFormattingRule())?" ":""}},{key:"getInternationalPrefixBeforeCountryCallingCode",value:function(e,t){var i=e.IDDPrefix,n=e.missingPlus;return i?t&&!1===t.spacing?i:i+" ":n?"":"+"}},{key:"getTemplate",value:function(e){if(this.template){for(var t=-1,i=0,n=e.international?this.getInternationalPrefixBeforeCountryCallingCode(e,{spacing:!1}):"";i<n.length+e.getDigitsWithoutInternationalPrefix().length;)t=this.template.indexOf(gm,t+1),i++;return vm(this.template,t+1)}}},{key:"setNationalNumberTemplate",value:function(e,t){this.nationalNumberTemplate=e,this.populatedNationalNumberTemplate=e,this.populatedNationalNumberTemplatePosition=-1,t.international?this.template=this.getInternationalPrefixBeforeCountryCallingCode(t).replace(/[\d\+]/g,gm)+mm(gm,t.callingCode.length)+" "+e:this.template=e}},{key:"getTemplateForFormat",value:function(e,t){var i=t.nationalSignificantNumber,n=t.international,r=t.nationalPrefix,s=t.complexPrefixBeforeNationalSignificantNumber,a=e.pattern();a=a.replace(/\[([^\[\]])*\]/g,"\\d").replace(/\d(?=[^,}][^,}])/g,"\\d");var o=km.match(a)[0];if(!(i.length>o.length)){var c=new RegExp("^"+a+"$"),d=i.replace(/\d/g,"9");c.test(d)&&(o=d);var l,h=this.getFormatFormat(e,n);if(this.shouldTryNationalPrefixFormattingRule(e,{international:n,nationalPrefix:r})){var u=h.replace(gf,e.nationalPrefixFormattingRule());if(Yg(e.nationalPrefixFormattingRule())===(r||"")+Yg("$1")&&(h=u,l=!0,r))for(var p=r.length;p>0;)h=h.replace(/\d/,gm),p--}var g=o.replace(new RegExp(a),h).replace(new RegExp("9","g"),gm);return l||(s?g=mm(gm,s.length)+" "+g:r&&(g=mm(gm,r.length)+this.getSeparatorAfterNationalPrefix(e)+g)),n&&(g=pf(g)),g}}},{key:"formatNextNationalNumberDigits",value:function(e){var t=function(e,t,i){for(var n,r=um(i.split(""));!(n=r()).done;){var s=n.value;if(e.slice(t+1).search(fm)<0)return;t=e.search(fm),e=e.replace(fm,s)}return[e,t]}(this.populatedNationalNumberTemplate,this.populatedNationalNumberTemplatePosition,e);if(t)return this.populatedNationalNumberTemplate=t[0],this.populatedNationalNumberTemplatePosition=t[1],vm(this.populatedNationalNumberTemplate,this.populatedNationalNumberTemplatePosition+1);this.resetFormat()}},{key:"shouldTryNationalPrefixFormattingRule",value:function(e,t){var i=t.international,n=t.nationalPrefix;if(e.nationalPrefixFormattingRule()){var r=e.usesNationalPrefix();if(r&&n||!r&&!i)return!0}}}],i&&Nm(t.prototype,i),n&&Nm(t,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();function Hm(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==i)return;var n,r,s=[],a=!0,o=!1;try{for(i=i.call(e);!(a=(n=i.next()).done)&&(s.push(n.value),!t||s.length!==t);a=!0);}catch(e){o=!0,r=e}finally{try{a||null==i.return||i.return()}finally{if(o)throw r}}return s}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return Lm(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);"Object"===i&&e.constructor&&(i=e.constructor.name);if("Map"===i||"Set"===i)return Array.from(e);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return Lm(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Lm(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i<t;i++)n[i]=e[i];return n}function jm(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var Bm=new RegExp("^"+("["+yg+vg+"]+")+"$","i"),Um="(?:[++]["+yg+vg+"]*|["+yg+vg+"]+)",Vm=new RegExp("[^"+yg+vg+"]+.*$"),qm=/[^\d\[\]]/,Gm=function(){function e(t){var i=t.defaultCountry,n=t.defaultCallingCode,r=t.metadata,s=t.onNationalSignificantNumberChange;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.defaultCountry=i,this.defaultCallingCode=n,this.metadata=r,this.onNationalSignificantNumberChange=s}var t,i,n;return t=e,(i=[{key:"input",value:function(e,t){var i,n=function(e){var t=function(e){var t=function(e){var t,i=e.search(Um);if(!(i<0))return"+"===(e=e.slice(i))[0]&&(t=!0,e=e.slice(1)),e=e.replace(Vm,""),t&&(e="+"+e),e}(e)||"";return"+"===t[0]?[t.slice(1),!0]:[t]}(e),i=Hm(t,2),n=i[0],r=i[1];return Bm.test(n)||(n=""),[n,r]}(e),r=Hm(n,2),s=r[0],a=r[1],o=Yg(s);return a&&(t.digits||(t.startInternationalNumber(),o||(i=!0))),o&&this.inputDigits(o,t),{digits:o,justLeadingPlus:i}}},{key:"inputDigits",value:function(e,t){var i=t.digits,n=i.length<3&&i.length+e.length>=3;if(t.appendDigits(e),n&&this.extractIddPrefix(t),this.isWaitingForCountryCallingCode(t)){if(!this.extractCountryCallingCode(t))return}else t.appendNationalSignificantNumberDigits(e);t.international||this.hasExtractedNationalSignificantNumber||this.extractNationalSignificantNumber(t.getNationalDigits(),(function(e){return t.update(e)}))}},{key:"isWaitingForCountryCallingCode",value:function(e){var t=e.international,i=e.callingCode;return t&&!i}},{key:"extractCountryCallingCode",value:function(e){var t=Mf("+"+e.getDigitsWithoutInternationalPrefix(),this.defaultCountry,this.defaultCallingCode,this.metadata.metadata),i=t.countryCallingCode,n=t.number;if(i)return e.setCallingCode(i),e.update({nationalSignificantNumber:n}),!0}},{key:"reset",value:function(e){if(e){this.hasSelectedNumberingPlan=!0;var t=e._nationalPrefixForParsing();this.couldPossiblyExtractAnotherNationalSignificantNumber=t&&qm.test(t)}else this.hasSelectedNumberingPlan=void 0,this.couldPossiblyExtractAnotherNationalSignificantNumber=void 0}},{key:"extractNationalSignificantNumber",value:function(e,t){if(this.hasSelectedNumberingPlan){var i=kf(e,this.metadata),n=i.nationalPrefix,r=i.nationalNumber,s=i.carrierCode;if(r!==e)return this.onExtractedNationalNumber(n,s,r,e,t),!0}}},{key:"extractAnotherNationalSignificantNumber",value:function(e,t,i){if(!this.hasExtractedNationalSignificantNumber)return this.extractNationalSignificantNumber(e,i);if(this.couldPossiblyExtractAnotherNationalSignificantNumber){var n=kf(e,this.metadata),r=n.nationalPrefix,s=n.nationalNumber,a=n.carrierCode;if(s!==t)return this.onExtractedNationalNumber(r,a,s,e,i),!0}}},{key:"onExtractedNationalNumber",value:function(e,t,i,n,r){var s,a,o=n.lastIndexOf(i);if(o>=0&&o===n.length-i.length){a=!0;var c=n.slice(0,o);c!==e&&(s=c)}r({nationalPrefix:e,carrierCode:t,nationalSignificantNumber:i,nationalSignificantNumberMatchesInput:a,complexPrefixBeforeNationalSignificantNumber:s}),this.hasExtractedNationalSignificantNumber=!0,this.onNationalSignificantNumberChange()}},{key:"reExtractNationalSignificantNumber",value:function(e){return!!this.extractAnotherNationalSignificantNumber(e.getNationalDigits(),e.nationalSignificantNumber,(function(t){return e.update(t)}))||(this.extractIddPrefix(e)||this.fixMissingPlus(e)?(this.extractCallingCodeAndNationalSignificantNumber(e),!0):void 0)}},{key:"extractIddPrefix",value:function(e){var t=e.international,i=e.IDDPrefix,n=e.digits;if(e.nationalSignificantNumber,!t&&!i){var r=Nf(n,this.defaultCountry,this.defaultCallingCode,this.metadata.metadata);return void 0!==r&&r!==n?(e.update({IDDPrefix:n.slice(0,n.length-r.length)}),this.startInternationalNumber(e,{country:void 0,callingCode:void 0}),!0):void 0}}},{key:"fixMissingPlus",value:function(e){if(!e.international){var t=Ff(e.digits,this.defaultCountry,this.defaultCallingCode,this.metadata.metadata),i=t.countryCallingCode;if(t.number,i)return e.update({missingPlus:!0}),this.startInternationalNumber(e,{country:e.country,callingCode:i}),!0}}},{key:"startInternationalNumber",value:function(e,t){var i=t.country,n=t.callingCode;e.startInternationalNumber(i,n),e.nationalSignificantNumber&&(e.resetNationalSignificantNumber(),this.onNationalSignificantNumberChange(),this.hasExtractedNationalSignificantNumber=void 0)}},{key:"extractCallingCodeAndNationalSignificantNumber",value:function(e){this.extractCountryCallingCode(e)&&this.extractNationalSignificantNumber(e.getNationalDigits(),(function(t){return e.update(t)}))}}])&&jm(t.prototype,i),n&&jm(t,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();function Km(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==i)return;var n,r,s=[],a=!0,o=!1;try{for(i=i.call(e);!(a=(n=i.next()).done)&&(s.push(n.value),!t||s.length!==t);a=!0);}catch(e){o=!0,r=e}finally{try{a||null==i.return||i.return()}finally{if(o)throw r}}return s}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return Wm(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);"Object"===i&&e.constructor&&(i=e.constructor.name);if("Map"===i||"Set"===i)return Array.from(e);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return Wm(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Wm(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i<t;i++)n[i]=e[i];return n}function zm(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var Ym=function(){function e(t,i){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.metadata=new Ig(i);var n=Km(this.getCountryAndCallingCode(t),2),r=n[0],s=n[1];this.defaultCountry=r,this.defaultCallingCode=s,this.reset()}var t,i,n;return t=e,i=[{key:"getCountryAndCallingCode",value:function(e){var t,i;return e&&(wg(e)?(t=e.defaultCountry,i=e.defaultCallingCode):t=e),t&&!this.metadata.hasCountry(t)&&(t=void 0),[t,i]}},{key:"input",value:function(e){var t=this.parser.input(e,this.state),i=t.digits;if(t.justLeadingPlus)this.formattedOutput="+";else if(i){var n;if(this.determineTheCountryIfNeeded(),this.state.nationalSignificantNumber&&this.formatter.narrowDownMatchingFormats(this.state),this.metadata.hasSelectedNumberingPlan()&&(n=this.formatter.format(i,this.state)),void 0===n&&this.parser.reExtractNationalSignificantNumber(this.state)){this.determineTheCountryIfNeeded();var r=this.state.getNationalDigits();r&&(n=this.formatter.format(r,this.state))}this.formattedOutput=n?this.getFullNumber(n):this.getNonFormattedNumber()}return this.formattedOutput}},{key:"reset",value:function(){var e=this;return this.state=new hm({onCountryChange:function(t){e.country=t},onCallingCodeChange:function(t,i){e.metadata.selectNumberingPlan(i,t),e.formatter.reset(e.metadata.numberingPlan,e.state),e.parser.reset(e.metadata.numberingPlan)}}),this.formatter=new Mm({state:this.state,metadata:this.metadata}),this.parser=new Gm({defaultCountry:this.defaultCountry,defaultCallingCode:this.defaultCallingCode,metadata:this.metadata,state:this.state,onNationalSignificantNumberChange:function(){e.determineTheCountryIfNeeded(),e.formatter.reset(e.metadata.numberingPlan,e.state)}}),this.state.reset({country:this.defaultCountry,callingCode:this.defaultCallingCode}),this.formattedOutput="",this}},{key:"isInternational",value:function(){return this.state.international}},{key:"getCallingCode",value:function(){if(this.isInternational())return this.state.callingCode}},{key:"getCountryCallingCode",value:function(){return this.getCallingCode()}},{key:"getCountry",value:function(){if(this.state.digits)return this._getCountry()}},{key:"_getCountry",value:function(){return this.state.country}},{key:"determineTheCountryIfNeeded",value:function(){this.state.country&&!this.isCountryCallingCodeAmbiguous()||this.determineTheCountry()}},{key:"getFullNumber",value:function(e){var t=this;if(this.isInternational()){var i=function(e){return t.formatter.getInternationalPrefixBeforeCountryCallingCode(t.state,{spacing:!!e})+e},n=this.state.callingCode;return i(n?e?"".concat(n," ").concat(e):n:"".concat(this.state.getDigitsWithoutInternationalPrefix()))}return e}},{key:"getNonFormattedNationalNumberWithPrefix",value:function(){var e=this.state,t=e.nationalSignificantNumber,i=e.complexPrefixBeforeNationalSignificantNumber,n=e.nationalPrefix,r=t,s=i||n;return s&&(r=s+r),r}},{key:"getNonFormattedNumber",value:function(){var e=this.state.nationalSignificantNumberMatchesInput;return this.getFullNumber(e?this.getNonFormattedNationalNumberWithPrefix():this.state.getNationalDigits())}},{key:"getNonFormattedTemplate",value:function(){var e=this.getNonFormattedNumber();if(e)return e.replace(/[\+\d]/g,gm)}},{key:"isCountryCallingCodeAmbiguous",value:function(){var e=this.state.callingCode,t=this.metadata.getCountryCodesForCallingCode(e);return t&&t.length>1}},{key:"determineTheCountry",value:function(){this.state.setCountry(Uf(this.isInternational()?this.state.callingCode:this.defaultCallingCode,{nationalNumber:this.state.nationalSignificantNumber,defaultCountry:this.defaultCountry,metadata:this.metadata}))}},{key:"getNumberValue",value:function(){var e=this.state,t=e.digits,i=e.callingCode,n=e.country,r=e.nationalSignificantNumber;if(t)return this.isInternational()?i?"+"+i+r:"+"+t:n||i?"+"+(n?this.metadata.countryCallingCode():i)+r:void 0}},{key:"getNumber",value:function(){var e=this.state,t=e.nationalSignificantNumber,i=e.carrierCode,n=e.callingCode,r=this._getCountry();if(t&&(r||n)){if(r&&r===this.defaultCountry){var s=new Ig(this.metadata.metadata);s.selectNumberingPlan(r);var a=s.numberingPlan.callingCode(),o=this.metadata.getCountryCodesForCallingCode(a);if(o.length>1){var c=jf(t,{countries:o,defaultCountry:this.defaultCountry,metadata:this.metadata.metadata});c&&(r=c)}}var d=new Af(r||n,t,this.metadata.metadata);return i&&(d.carrierCode=i),d}}},{key:"isPossible",value:function(){var e=this.getNumber();return!!e&&e.isPossible()}},{key:"isValid",value:function(){var e=this.getNumber();return!!e&&e.isValid()}},{key:"getNationalNumber",value:function(){return this.state.nationalSignificantNumber}},{key:"getChars",value:function(){return(this.state.international?"+":"")+this.state.digits}},{key:"getTemplate",value:function(){return this.formatter.getTemplate(this.state)||this.getNonFormattedTemplate()||""}}],i&&zm(t.prototype,i),n&&zm(t,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();function Jm(){return function(e,t){var i=Array.prototype.slice.call(t);return i.push(ng),e.apply(this,i)}(dm,arguments)}function Zm(e){return Ym.call(this,e,ng)}Zm.prototype=Object.create(Ym.prototype,{}),Zm.prototype.constructor=Zm;const Xm=/[^+*\d]/g,Qm=["US","FR","GB","AU"],ev=(e,t,i=Qm)=>{const n=[...new Set([t,...i])].filter(Boolean);let r;for(let t=0;t<n.length;t++){if(r=Jm(e,n[t]),r.isValid())break}return r},tv=(e,t,i=!1,n=Qm)=>{if(!e)return e;const r=String(e);if(!(e=>!(!e||e.length<=5||e.includes("#")||e.includes("*")||e.match(/[aA-zZ]/)))(r))return r;let s="";if(i)s=new Zm(t).input(r);else try{const i=ev(r,t,n);i?.isValid()?(a=String(i.country),o=t,s="US"===a&&"CA"===o||"US"===o&&"CA"===a||a===o?i.formatNational():i.formatInternational()):s=e}catch(t){s=e}var a,o;return s},iv=e=>e.replace(Xm,"");e.AdHocAPIConference=Tn,e.Agent=en,e.ApiCall=fi,e.ApiRequester=G,e.BadResponse=b,e.COUNTRIES={AUSTRALIA:"AU",BELGIUM:"BE",CANADA:"CA",FRANCE:"FR",GERMANY:"DE",ISRAEL:"IL",ITALY:"IT",LUXEMBOURG:"LU",MALAYSIA:"MY",MONACO:"MC",NETHERLANDS:"NL",POLAND:"PL",PORTUGAL:"PT",UNITED_KINGDOM:"GB",UNITED_STATES:"US",SPAIN:"ES",SWITZERLAND:"CH"},e.CTIPhone=Bi,e.Call=Kp,e.CallApi=Hi,e.CallLog=Yi,e.CallSession=yi,e.CallerID=ri,e.ChatMessage=pi,e.ChatRoom=Ji,e.Checker=gh,e.Contact=Xt,e.DebugDevice=class{connectToCall(){console.info("DebugDevice - Connected to call")}disconnectFromCall(){console.info("DebugDevice - Disconnected from call")}ringback(){console.info("DebugDevice - Ringback")}stopRingback(){console.info("DebugDevice - Stop ringback")}playRingtone(){console.info("DebugDevice - Play ringtone")}stopRingtone(){console.info("DebugDevice - Stop ringtone")}mute(){console.info("DebugDevice - Mute")}unmute(){console.info("DebugDevice - Unmute")}putOnSpeaker(){console.info("DebugDevice - Put on speaker")}putOffSpeaker(){console.info("DebugDevice - Put off speaker")}},e.Emitter=Mi,e.ExternalApp=oi,e.FORWARD_KEYS=qt,e.Features=ah,e.ForwardOption=Gt,e.Incall=Kt,e.IndirectTransfer=Xi,e.InvalidState=sp,e.InvalidStateTransition=Hp,e.IssueReporter=B,e.LINE_STATE=zt,e.Line=Vt,e.Meeting=ci,e.MeetingAuthorization=di,e.MeetingStatus=Qi,e.NotificationOptions=th,e.PROFILE_STATE=Wt,e.Profile=Yt,e.Recording=zi,e.Relocation=ui,e.Room=ih,e.SFUNotAvailableError=Xc,e.SOCKET_EVENTS=gd,e.ServerError=w,e.Session=ti,e.SessionDescriptionHandler=Ks,e.SipLine=ai,e.Softphone=Qp,e.SwitchboardCall=nh,e.Voicemail=gi,e.WazoApiClient=rn,e.WebRTCClient=Zc,e.WebRTCPhone=vo,e.WebSocketClient=Dl,e.camelToUnderscore=I,e.default=ig,e.getApiClient=gn,e.getCallableNumber=(e,t)=>{try{const i=t?tv(e,t):e;return iv(i)}catch(t){return e}},e.getDisplayableNumber=tv,e.guessParsePhoneNumber=ev,e.obfuscateToken=R,e.parsePhoneNumber=iv,e.setApiToken=on,e.setCurrentServer=an,e.setIsMobile=(e,t=null)=>{global.wazoIsMobile[String(t)]=e},e.setOnRefreshToken=dn,e.setOnRefreshTokenError=ln,Object.defineProperty(e,"__esModule",{value:!0})}));
43
43
  //# sourceMappingURL=wazo-sdk.js.map