@convirza/dialer-sdk 1.0.0 → 1.0.1
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/README.md +33 -204
- package/dist/api/DialerAPI.d.ts +0 -2
- package/dist/index.cjs.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/services/CallHistoryService.d.ts +3 -11
- package/dist/ui/ConvirzaDialerElement.d.ts +1 -1
- package/dist/utils/sip-loader.d.ts +19 -0
- package/package.json +1 -1
- package/dist/api/CallHistoryAPI.d.ts +0 -16
package/dist/index.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ConvirzaDialer={})}(this,function(e){"use strict";class t{constructor(){this.element=null,this.config=null,this.callHistory=[],this.activeCallId=null,this.isMuted=!1,this.isRecording=!1,this.errorHandler=null,this.callEndedHandler=null,this.storageHandler=null}validateConfig(e){if(!e.access_token||0===e.access_token.trim().length)throw new Error("access_token is required for dialer initialization");if(!e.refresh_token||0===e.refresh_token.trim().length)throw new Error("refresh_token is required for dialer initialization")}init(e){this.validateConfig(e),this.config=e,this.element&&(this.callEndedHandler&&(this.element.removeEventListener("call-ended",this.callEndedHandler),this.callEndedHandler=null),this.element.remove()),this.element=document.createElement("convirza-dialer"),this.element.setAttribute("access-token",e.access_token),this.element.setAttribute("refresh-token",e.refresh_token),this.element.setAttribute("auto-configure","true"),e.oauth_endpoint&&this.element.setAttribute("oauth-endpoint",e.oauth_endpoint),e.api_url&&this.element.setAttribute("api-url",e.api_url),this.element.addEventListener("token-refreshed",e=>{const t=new CustomEvent("dialer-token-refreshed",{detail:e.detail,bubbles:!0});window.dispatchEvent(t)}),this.element.addEventListener("auth-failed",e=>{const t=new CustomEvent("dialer-auth-failed",{detail:e.detail,bubbles:!0});window.dispatchEvent(t)}),this.storageHandler||(this.storageHandler=e=>{"access_token"!==e.key||e.newValue||this.destroy()},window.addEventListener("storage",this.storageHandler)),this.element.setAttribute("position","bottom-right"),void 0!==e.dark_theme&&this.element.setAttribute("theme",e.dark_theme?"dark":"light"),e.primaryColor&&this.element.setAttribute("primary-color",e.primaryColor),e.accentColor&&this.element.setAttribute("accent-color",e.accentColor),e.brandName&&this.element.setAttribute("brand-name",e.brandName),e.brandLogo&&this.element.setAttribute("brand-logo",e.brandLogo),e.showPopup?this.element.setAttribute("state","expanded"):this.element.setAttribute("state","collapsed"),document.body.appendChild(this.element),this.setupEventListeners(),this.setupGlobalErrorHandlers()}setupGlobalErrorHandlers(){this.errorHandler||(this.errorHandler=e=>{const t=e instanceof ErrorEvent?e.error:new Error("Unknown error");console.error("[Dialer] Global error:",t),this.element&&this.element.dispatchEvent(new CustomEvent("dialer-error",{detail:{error:t?.message||String(t)},bubbles:!0}))},window.addEventListener("error",this.errorHandler),window.addEventListener("unhandledrejection",this.errorHandler))}refresh(){if(!this.config)throw new Error("Dialer not initialized. Call init() first.");this.init(this.config)}hidePopup(){if(!this.element)throw new Error("Dialer not initialized. Call init() first.");this.element.close()}showPopup(){if(!this.element)throw new Error("Dialer not initialized. Call init() first.");this.element.open()}getActiveCallID(){return this.activeCallId}call(e){if(!this.element)throw new Error("Dialer not initialized. Call init() first.");if(e){const t=this.element.placeCall(e);this.activeCallId=this.generateCallId(),this.callHistory.unshift({id:this.activeCallId,phoneNumber:e,timestamp:Date.now(),direction:"outbound",status:"answered"}),t.onEnded(e=>{const t=this.callHistory.find(e=>e.id===this.activeCallId);t&&(t.duration=e),this.activeCallId=null,this.isMuted=!1,this.isRecording=!1})}else this.showPopup()}mute(e){if(!this.element||!this.activeCallId)throw new Error("No active call");return this.isMuted=this.element.mute(e),this.isMuted}hold(e){if(!this.element||!this.activeCallId)throw new Error("No active call");return this.element.hold(e)}record(e){if(!this.element||!this.activeCallId)throw new Error("No active call");const t=void 0!==e?e:!this.isRecording;return t?this.element.startRecording():this.element.stopRecording(),this.isRecording=t,this.isRecording}callList(e){return e?this.callHistory.slice(0,e):[...this.callHistory]}endCall(){if(!this.element)throw new Error("Dialer not initialized");if(!this.activeCallId)throw new Error("No active call");this.element.endCall()}transfer(e){if(!this.element)throw new Error("Dialer not initialized. Call init() first.");if(!this.activeCallId)throw new Error("No active call to transfer.");const t=this.element;t.transferTarget=e,t.executeTransfer?.()}destroy(){this.element&&(this.callEndedHandler&&(this.element.removeEventListener("call-ended",this.callEndedHandler),this.callEndedHandler=null),this.element.remove(),this.element=null),this.errorHandler&&(window.removeEventListener("error",this.errorHandler),window.removeEventListener("unhandledrejection",this.errorHandler),this.errorHandler=null),this.storageHandler&&(window.removeEventListener("storage",this.storageHandler),this.storageHandler=null),this.config=null,this.activeCallId=null,this.callHistory=[],this.isMuted=!1,this.isRecording=!1}setupEventListeners(){this.element&&(this.callEndedHandler=()=>{this.activeCallId=null,this.isMuted=!1,this.isRecording=!1},this.element.addEventListener("call-ended",this.callEndedHandler))}generateCallId(){return`call-${Date.now()}-${Math.random().toString(36).substring(2,11)}`}get isMutedState(){return this.isMuted}get isRecordingState(){return this.isRecording}}const n=new t;let i=!1;class r{constructor(e,t){this.authToken=null,this.baseUrl=e.replace(/\/$/,""),this.authToken=t||null}setAuthToken(e){this.authToken=e}getHeaders(){const e={"Content-Type":"application/json"};return this.authToken&&(e.Authorization=`Bearer ${this.authToken}`),e}async fetchOrderedNumbers(e){const{domainId:t,limit:n=100,status:i="provisioned"}=e,r=new URL(`${this.baseUrl}/v3/dialer/domains/${t}/phone-numbers`);i&&r.searchParams.set("status",i),r.searchParams.set("limit",n.toString());const a=await fetch(r.toString(),{method:"GET",headers:this.getHeaders()});if(!a.ok)throw new Error(`Failed to fetch phone numbers: ${a.status} ${a.statusText}`);const o=await a.json(),s=o.data||o;return{items:s.items||[],total:s.total||0}}}class a{constructor(e,t){this.authToken=null,this.baseUrl=e.replace(/\/$/,""),this.authToken=t||null}setAuthToken(e){this.authToken=e}getHeaders(){const e={"Content-Type":"application/json"};return this.authToken&&(e.Authorization=`Bearer ${this.authToken}`),e}async fetchHistory(e){const{userId:t,sipDomain:n,limit:i=100,offset:r=0}=e,a=new URL(`${this.baseUrl}/v3/call-history`);a.searchParams.set("userId",t),a.searchParams.set("sipDomain",n),a.searchParams.set("limit",i.toString()),a.searchParams.set("offset",r.toString());const o=await fetch(a.toString(),{method:"GET",headers:this.getHeaders()});if(!o.ok)throw new Error(`Failed to fetch call history: ${o.status} ${o.statusText}`);const s=await o.json(),d=s.data||s;return Array.isArray(d.calls)&&(d.calls=d.calls.map(e=>{const t=e=>{if("number"==typeof e)return e;if("string"==typeof e){const t=parseInt(e,10);return isNaN(t)?void 0:t}};return{...e,startedAt:t(e.startedAt)??e.startedAt,endedAt:t(e.endedAt)??e.endedAt,createdAt:t(e.createdAt)??e.createdAt}})),d}async saveCall(e){const t=await fetch(`${this.baseUrl}/v3/call-history`,{method:"POST",headers:this.getHeaders(),body:JSON.stringify({...e,createdAt:Date.now()})});if(!t.ok)throw new Error(`Failed to save call: ${t.status} ${t.statusText}`);const n=await t.json(),i=n.data||n;return this.normalizeTimestamps(i)}async updateCall(e,t){const n=await fetch(`${this.baseUrl}/v3/call-history/${e}`,{method:"PATCH",headers:this.getHeaders(),body:JSON.stringify(t)});if(!n.ok)throw new Error(`Failed to update call: ${n.status} ${n.statusText}`);const i=await n.json(),r=i.data||i;return this.normalizeTimestamps(r)}normalizeTimestamps(e){const t=e=>{if("number"==typeof e)return e;if("string"==typeof e){const t=parseInt(e,10);return isNaN(t)?void 0:t}};return{...e,startedAt:t(e.startedAt)??e.startedAt,endedAt:t(e.endedAt)??e.endedAt,createdAt:t(e.createdAt)??e.createdAt}}}const o={2:"ABC",3:"DEF",4:"GHI",5:"JKL",6:"MNO",7:"PQRS",8:"TUV",9:"WXYZ"},s={idle:["dialing","error"],dialing:["ringing","connected","ended","error"],ringing:["connected","ended","error"],connected:["ended","error"],ended:["idle"],error:["idle","ended"]};class d{constructor(e={}){this.devices=[],this.onDevicesChangedCb=null,this.onMicrophoneChangedCb=null,this.onSpeakerChangedCb=null,this.deviceChangeHandler=null,this.onDevicesChangedCb=e.onDevicesChanged??null,this.onMicrophoneChangedCb=e.onMicrophoneChanged??null,this.onSpeakerChangedCb=e.onSpeakerChanged??null,"undefined"!=typeof navigator&&navigator.mediaDevices&&(this.deviceChangeHandler=()=>this.handleDeviceChange(),navigator.mediaDevices.addEventListener("devicechange",this.deviceChangeHandler))}destroy(){this.deviceChangeHandler&&"undefined"!=typeof navigator&&navigator.mediaDevices&&(navigator.mediaDevices.removeEventListener("devicechange",this.deviceChangeHandler),this.deviceChangeHandler=null),this.onDevicesChangedCb=null,this.onMicrophoneChangedCb=null,this.onSpeakerChangedCb=null}async handleDeviceChange(){const e=await this.enumerateDevices(),t=this.loadPreferences(),n=e.filter(e=>"audioinput"===e.kind),i=e.filter(e=>"audiooutput"===e.kind);if(t.microphoneId&&n.length>0){if(!n.some(e=>e.deviceId===t.microphoneId)){const e=n[0].deviceId;console.warn(`[AudioDeviceManager] Preferred mic removed — switching to ${n[0].label}`),this.savePreferences({...t,microphoneId:e}),this.onMicrophoneChangedCb?.(e)}}if(t.speakerId&&i.length>0){if(!i.some(e=>e.deviceId===t.speakerId)){const e=i[0].deviceId;console.warn(`[AudioDeviceManager] Preferred speaker removed — switching to ${i[0].label}`),this.savePreferences({...t,speakerId:e}),this.onSpeakerChangedCb?.(e)}}}async enumerateDevices(){if("undefined"==typeof navigator||!navigator.mediaDevices)return[];try{const e=await navigator.mediaDevices.enumerateDevices();return this.devices=e.filter(e=>"audioinput"===e.kind||"audiooutput"===e.kind).map(e=>({deviceId:e.deviceId,label:e.label||`${"audioinput"===e.kind?"Microphone":"Speaker"} ${e.deviceId.slice(0,8)}`,kind:e.kind})),this.onDevicesChangedCb?.(this.devices),this.devices}catch(e){return console.error("[AudioDeviceManager] Failed to enumerate devices:",e),[]}}async refreshDevices(){return this.enumerateDevices()}getMicrophones(){return this.devices.filter(e=>"audioinput"===e.kind)}getSpeakers(){return this.devices.filter(e=>"audiooutput"===e.kind)}setOnDevicesChanged(e){this.onDevicesChangedCb=e}savePreferences(e){if("undefined"!=typeof window&&"undefined"!=typeof Storage&&window.localStorage)try{localStorage.setItem(d.STORAGE_KEY,JSON.stringify(e))}catch(e){console.error("[AudioDeviceManager] Failed to save preferences:",e)}}loadPreferences(){if("undefined"==typeof window||"undefined"==typeof Storage||!window.localStorage)return{microphoneId:null,speakerId:null};try{const e=localStorage.getItem(d.STORAGE_KEY);if(e)return JSON.parse(e)}catch(e){console.error("[AudioDeviceManager] Failed to load preferences:",e)}return{microphoneId:null,speakerId:null}}async applyAudioOutputDevice(e,t){if("function"==typeof e.setSinkId)try{await e.setSinkId(t)}catch(e){throw console.error("[AudioDeviceManager] Failed to set audio output:",e),e}else console.warn("[AudioDeviceManager] Browser does not support setSinkId")}async getAudioConstraints(e){return{audio:e?{deviceId:{exact:e},echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0}:{echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0},video:!1}}}d.STORAGE_KEY="convirza_audio_devices";const l={excellent:{packetLoss:.5,jitter:20,latency:100},good:{packetLoss:1,jitter:30,latency:200},fair:{packetLoss:3,jitter:50,latency:300}};class c{constructor(e=l){this.peerConnection=null,this.intervalId=null,this.onQualityChange=null,this.lastMetrics=null,this.previousBytesReceived=0,this.previousTimestamp=0,this.thresholds=e}start(e,t=2e3){this.stop(),this.peerConnection=e,this.intervalId=window.setInterval(async()=>{await this.collectMetrics()},t)}stop(){this.intervalId&&(clearInterval(this.intervalId),this.intervalId=null),this.peerConnection=null,this.lastMetrics=null,this.previousBytesReceived=0,this.previousTimestamp=0}setOnQualityChange(e){this.onQualityChange=e}getLastMetrics(){return this.lastMetrics}async collectMetrics(){if(this.peerConnection)try{const e=await this.peerConnection.getStats();let t=0,n=0,i=0,r=0,a=0;e.forEach(e=>{if("inbound-rtp"===e.type&&"audio"===e.kind){if(e.bytesReceived&&e.timestamp){const n=e.bytesReceived,i=e.timestamp;if(this.previousTimestamp>0){const e=(i-this.previousTimestamp)/1e3;e>0&&(t=8*(n-this.previousBytesReceived)/e/1e3)}this.previousBytesReceived=n,this.previousTimestamp=i}if(void 0!==e.packetsLost&&void 0!==e.packetsReceived){const t=e.packetsReceived+e.packetsLost;t>0&&(n=e.packetsLost/t*100)}void 0!==e.jitter&&(i=1e3*e.jitter),void 0!==e.audioLevel&&(a=e.audioLevel)}"candidate-pair"===e.type&&"succeeded"===e.state&&void 0!==e.currentRoundTripTime&&(r=1e3*e.currentRoundTripTime)});const o=this.calculateQuality(n,i,r),s={bitrate:Math.round(t),packetLoss:Math.round(100*n)/100,jitter:Math.round(10*i)/10,latency:Math.round(r),audioLevel:Math.round(100*a)/100,quality:o};this.lastMetrics=s,this.onQualityChange?.(s)}catch(e){console.error("[CallQualityMonitor] Failed to collect metrics:",e)}}calculateQuality(e,t,n){const{excellent:i,good:r,fair:a}=this.thresholds;return e<=i.packetLoss&&t<=i.jitter&&n<=i.latency?"excellent":e<=r.packetLoss&&t<=r.jitter&&n<=r.latency?"good":e<=a.packetLoss&&t<=a.jitter&&n<=a.latency?"fair":"poor"}}const h={REGISTER_EXPIRES:300,QUALITY_INTERVAL_MS:2e3,STUN_SERVERS:[{urls:"stun:stun.l.google.com:19302"}],MAX_RECONNECTION_ATTEMPTS:3,RECONNECTION_TIMEOUT_S:4},u=36e5,p=50;class ${constructor(e,t={}){this.userAgent=null,this.currentSession=null,this.registerer=null,this.audioElement=null,this.isMuted=!1,this.localHangup=!1,this.currentCallUuid=null,this.currentCallIsChannelUuid=!1,this.currentCallSipCallId=null,this.reconnectAttempts=0,this.reconnectTimer=null,this.iceDisconnectedTimer=null,this.config=e,this.callbacks=t,this.audioDeviceManager=new d({onMicrophoneChanged:async e=>{if(this.currentSession)try{await this.setMicrophone(e)}catch(e){this.callbacks.onError?.(new Error(`Auto mic-swap failed: ${e.message}`))}},onSpeakerChanged:async e=>{if(this.audioElement)try{await this.setSpeaker(e)}catch{}},onDevicesChanged:e=>{this.callbacks.onDevicesChanged?.(e)}}),this.qualityMonitor=new c,this.setupQualityMonitor()}setupQualityMonitor(){this.qualityMonitor.setOnQualityChange(e=>{this.callbacks.onQualityChange?.(e)})}getLocalAudioConstraints(){const e={echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0};return this.config.microphoneId?{...e,deviceId:{ideal:this.config.microphoneId}}:e}setupAudioElement(){this.audioElement||(this.audioElement=document.createElement("audio"),this.audioElement.autoplay=!0,this.audioElement.volume=1,document.body.appendChild(this.audioElement),this.config.speakerId&&this.audioDeviceManager.applyAudioOutputDevice(this.audioElement,this.config.speakerId).catch(e=>{console.warn("[SipAdapter] Failed to apply speaker preference:",e)}))}async connect(){this.setupAudioElement();if(!("undefined"!=typeof window&&("SIP"in window||"sip"in window)))throw new Error("SIP.js not loaded. Install sip.js as peer dependency.");const e=window.SIP||window.sip,t=`${this.config.sipUsername}@${this.config.sipDomain}`;this.userAgent=new e.UA({uri:`sip:${t}`,transportOptions:{wsServers:this.config.wsServers,traceSip:!0},authorizationUser:this.config.sipUsername,password:this.config.sipPassword,displayName:this.config.displayName||this.config.sipUsername,contactName:this.config.sipUsername,register:!0,registerExpires:h.REGISTER_EXPIRES,hackWssInTransport:!0,hackViaTcp:!0,hackIpInContact:!0,contactTransport:"wss",extraSupported:[],sessionDescriptionHandlerFactoryOptions:{constraints:{audio:this.getLocalAudioConstraints(),video:!1},peerConnectionOptions:{rtcConfiguration:{iceServers:this.config.iceServers||h.STUN_SERVERS,rtcpMuxPolicy:"negotiate"},iceCheckingTimeout:15e3}}}),this.userAgent.on("registered",()=>{this.callbacks.onRegistered?.()}),this.userAgent.on("unregistered",()=>{this.callbacks.onUnregistered?.()}),this.userAgent.on("invite",e=>{this.handleIncomingCall(e)}),this.userAgent.on("registrationFailed",(e,t)=>{console.error("[SIP] Registration failed:",t),"Authorization Error"!==t&&this.scheduleReconnect(!1),this.callbacks.onRegistrationFailed?.(t)}),this.userAgent.on("transportError",()=>{console.error("[SIP] WebSocket transport error"),this.scheduleReconnect(!!this.currentSession),this.callbacks.onTransportError?.(new Error("WebSocket transport error"))}),this.userAgent.on("connecting",()=>{this.callbacks.onConnecting?.()}),this.userAgent.start()}async disconnect(){this.currentSession&&await this.endCall(),this.userAgent&&(this.userAgent.stop(),this.userAgent=null),this.audioElement&&(this.audioElement.pause(),this.audioElement.srcObject=null,this.audioElement.remove(),this.audioElement=null),this.audioDeviceManager.destroy()}async call(e,t){if(!this.userAgent)throw new Error("UserAgent not initialized. Call connect() first.");if(this.currentSession)throw new Error("Call already in progress");const n=`sip:${e}@${this.config.sipDomain}`,i={sessionDescriptionHandlerOptions:{constraints:{audio:this.getLocalAudioConstraints(),video:!1}}};if(t?.callerId){const e=t.callerIdName?`"${t.callerIdName}" <sip:${t.callerId}@${this.config.sipDomain}>`:`<sip:${t.callerId}@${this.config.sipDomain}>`;i.extraHeaders=[`P-Asserted-Identity: ${e}`]}const r=this.userAgent.invite(n,i);this.currentSession=r;try{const e=r.request?.callId??r.dialog?.id?.callId;e&&(this.currentCallSipCallId=e,this.currentCallUuid=e,this.currentCallIsChannelUuid=!1)}catch(e){console.warn("[SIP] Failed to extract Call-ID from INVITE:",e)}r.delegate={onBye:e=>{console.log("[SIP] SessionDelegate.onBye called (outbound), localHangup:",this.localHangup,"hasSession:",!!this.currentSession),!this.localHangup&&this.currentSession&&(this.cleanupSession(),this.callbacks.onCallEnded?.("remote-hangup"))}},r.on("progress",()=>{this.callbacks.onCallRinging?.()}),r.on("accepted",e=>{try{const t=e?.headers?.["x-fs-uuid"]?.[0]?.raw||e?.headers?.["X-FS-UUID"]?.[0]?.raw;if(t)this.currentCallUuid=t,this.currentCallIsChannelUuid=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(t);else{const e=r.dialog?.id?.callId??this.currentCallSipCallId;e&&(this.currentCallUuid=e),this.currentCallIsChannelUuid=!1,console.warn("[SIP] X-FS-UUID not received — using SIP Call-ID for park; backend will resolve via ESL")}}catch(e){console.warn("[SIP] Failed to extract call UUID:",e)}try{const e=r.sessionDescriptionHandler?.remoteDescription?.sdp;e&&!e.includes("a=rtcp-mux")&&console.warn("[SipAdapter] Remote SDP missing a=rtcp-mux — call may fail in strict environments")}catch{}this.setupRemoteMedia(r),this.monitorPeerConnection(r),this.startQualityMonitoring(r),this.reconnectAttempts=0,this.callbacks.onCallAnswered?.()}),r.on("info",e=>{try{const t=e?.getHeader?.("Content-Type")??"",n=e?.body??"";t.includes("application/x-recording-command")&&this.callbacks.onRecordingStateChange?.("start"===n.trim()),e.reply(200)}catch{}}),r.on("notify",e=>{try{const t=e?.body??"";t.startsWith("SIP/2.0 200")?this.callbacks.onTransferSucceeded?.():/SIP\/2.0 [45]\d\d/.test(t)&&this.callbacks.onTransferFailed?.(t.split("\r\n")[0]),e.reply(200)}catch{}}),r.on("failed",e=>{console.error("[SIP] Call failed. Error:",e),console.error("[SIP] Status:",e?.statusCode,e?.reasonPhrase),this.cleanupSession();const t=new Error(e?.reasonPhrase||"Call failed");t.statusCode=e?.statusCode,t.originalError=e,this.callbacks.onCallFailed?.(t)}),r.on("cancel",()=>{this.cleanupSession(),this.callbacks.onCallEnded?.("remote-cancel")}),r.on("rejected",(e,t)=>{const n=e?.statusCode||t;console.log("[SIP] Call rejected:",t||n),this.cleanupSession(),this.callbacks.onCallEnded?.(`rejected-${n}`)}),r.on("hold",()=>{this.callbacks.onRemoteHold?.(!0)}),r.on("unhold",()=>{this.callbacks.onRemoteHold?.(!1)})}async endCall(){if(this.currentSession){this.localHangup=!0;try{const e=this.currentSession;e.dialog?e.bye():"function"==typeof e.cancel?e.cancel():"function"==typeof e.terminate&&e.terminate()}catch(e){console.error("[SIP] Error ending call:",e)}finally{this.cleanupSession()}}}mute(e){if(!this.currentSession)return this.isMuted;const t=this.currentSession.sessionDescriptionHandler;if(!t)return this.isMuted;this.isMuted=void 0!==e?e:!this.isMuted;const n=t.peerConnection;return n&&n.getSenders().forEach(e=>{e.track&&"audio"===e.track.kind&&(e.track.enabled=!this.isMuted)}),this.isMuted}hold(e){return new Promise((t,n)=>{if(!this.currentSession)return n(new Error("No active session"));if(!this.currentSession.dialog)return n(new Error("Session not established"));const i=void 0===e||e;try{i?this.currentSession.hold():this.currentSession.unhold(),t()}catch(e){n(e)}})}sendDTMF(e){if(!this.currentSession)throw new Error("No active session");if(!this.currentSession.dialog)throw new Error("Session not established");const t={body:{contentType:"application/dtmf-relay",body:`Signal=${e}\r\nDuration=100`}};this.currentSession.sendRequest("INFO",t)}startRecording(){if(!this.currentSession)throw new Error("No active session");if(!this.currentSession.dialog)throw new Error("Session not established");this.currentSession.sendRequest("INFO",{body:{contentType:"application/x-recording-command",body:"start"}})}stopRecording(){if(!this.currentSession)throw new Error("No active session");if(!this.currentSession.dialog)throw new Error("Session not established");this.currentSession.sendRequest("INFO",{body:{contentType:"application/x-recording-command",body:"stop"}})}async park(e){if(!this.currentSession)throw new Error("No active session");if(!this.currentSession.dialog)throw new Error("Session not established");if(!this.currentCallUuid)throw new Error("Call UUID not available");if(!this.config.apiUrl)throw new Error("API URL not configured");if(!this.config.authToken)throw new Error("Auth token not configured");try{const e=new URL(this.config.apiUrl);if("https:"!==e.protocol&&"localhost"!==e.hostname&&"127.0.0.1"!==e.hostname)throw new Error("API URL must use HTTPS to protect the auth token")}catch(e){if(e.message.includes("HTTPS"))throw e;throw new Error(`Invalid API URL: ${this.config.apiUrl}`)}const t=`${this.config.apiUrl.replace(/\/$/,"")}/v3/park-slots/park`,n={callUuid:this.currentCallUuid,isChannelUuid:this.currentCallIsChannelUuid,sipCallId:this.currentCallSipCallId,slotExtension:e,domain:this.config.sipDomain},i=new AbortController,r=setTimeout(()=>i.abort(),1e4);try{const e=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.config.authToken}`},body:JSON.stringify(n),signal:i.signal});if(clearTimeout(r),!e.ok){const t=await e.text();throw new Error(`Park failed: ${e.status} ${t}`)}console.log("[SIP] Park request successful, waiting for server to transfer call")}catch(e){if(clearTimeout(r),"AbortError"===e.name)throw new Error("Park request timeout - backend not responding");throw e}}handleIncomingCall(e){let t,n=e.remoteIdentity.uri.user;console.log("[SIP] ═══ INCOMING CALL DEBUG START ═══"),console.log("[SIP] Initial fallback callerNumber from remoteIdentity.uri.user:",n);try{const i=e.request?.getHeader?.("X-Convirza-Caller-ID"),r=e.request?.getHeader?.("From"),a=e.request?.getHeader?.("P-Asserted-Identity"),o=e.request?.getHeader?.("Remote-Party-ID"),s=e.request?.getHeader?.("Contact"),d=e.request?.getHeader?.("X-Caller-ID");if(console.log("[SIP] Incoming call headers:",{"X-Convirza-Caller-ID":i,From:r,"P-Asserted-Identity":a,"Remote-Party-ID":o,Contact:s,"X-Caller-ID":d}),console.log("[SIP] Full remoteIdentity URI:",e.remoteIdentity.uri.toString()),i){console.log("[SIP] Processing X-Convirza-Caller-ID header (HIGHEST PRIORITY - bypasses FreeSWITCH)...");const e=i.match(/"([^"]+)"/);e&&e[1]?(t=e[1],console.log("[SIP] ✓ Extracted callerName from X-Convirza-Caller-ID:",t)):console.log("[SIP] ✗ No display name found in X-Convirza-Caller-ID");let r=i.match(/<sip:([^@>]+)@/);if(console.log("[SIP] Regex match with angle brackets:",r),r||(console.log("[SIP] Trying regex WITHOUT angle brackets..."),r=i.match(/sip:([^@>\s]+)@/),console.log("[SIP] Regex match without angle brackets:",r)),r&&r[1]){const e=n;n=r[1],console.log(`[SIP] ✓ Extracted callerNumber from X-Convirza-Caller-ID: ${n} (was: ${e})`)}else console.warn(`[SIP] ✗ Failed to extract number from X-Convirza-Caller-ID: ${i}`)}else if(a){console.log("[SIP] Processing P-Asserted-Identity header...");const e=a.match(/"([^"]+)"/);e&&e[1]?(t=e[1],console.log("[SIP] ✓ Extracted callerName from P-Asserted-Identity:",t)):console.log("[SIP] ✗ No display name found in P-Asserted-Identity");let i=a.match(/<sip:([^@>]+)@/);if(console.log("[SIP] Regex match with angle brackets:",i),i||(console.log("[SIP] Trying regex WITHOUT angle brackets..."),i=a.match(/sip:([^@>\s]+)@/),console.log("[SIP] Regex match without angle brackets:",i)),i&&i[1]){const e=n;n=i[1],console.log(`[SIP] ✓ Extracted callerNumber from P-Asserted-Identity: ${n} (was: ${e})`)}else console.warn(`[SIP] ✗ Failed to extract number from P-Asserted-Identity: ${a}`)}else if(o){const e=o.match(/"([^"]+)"/);e&&e[1]&&(t=e[1]);let i=o.match(/<sip:([^@>]+)@/);i||(i=o.match(/sip:([^@>\s]+)@/)),i&&i[1]?(n=i[1],console.log(`[SIP] Extracted caller ID from Remote-Party-ID: ${n}, Name: ${t||"(none)"}`)):console.warn(`[SIP] Failed to extract number from Remote-Party-ID: ${o}`)}else d&&(n=d.replace(/[<>"]/g,""),console.log(`[SIP] Extracted caller ID from X-Caller-ID: ${n}`))}catch(e){console.warn("[SIP] Failed to extract caller ID from headers, using From:",e)}console.log("[SIP] ═══ FINAL RESULT ═══"),console.log("[SIP] Final callerNumber:",n),console.log("[SIP] Final callerName:",t),console.log("[SIP] ═══ INCOMING CALL DEBUG END ═══");const i={onBye:e=>{console.log("[SIP] ===== SessionDelegate.onBye FIRED ===== localHangup:",this.localHangup,"hasSession:",!!this.currentSession),!this.localHangup&&this.currentSession&&(this.cleanupSession(),this.callbacks.onCallEnded?.("remote-hangup"))},onAck:e=>{console.log("[SIP] SessionDelegate.onAck FIRED")},onInfo:e=>{console.log("[SIP] SessionDelegate.onInfo FIRED")},onInvite:(e,t,n)=>{console.log("[SIP] SessionDelegate.onInvite FIRED")}};e.delegate=i,console.log("[SIP] SessionDelegate set on invitation"),"function"==typeof e.on&&e.on("receiveRequest",e=>{console.log("[SIP] ===== receiveRequest event FIRED ===== method:",e?.method),"BYE"===e?.method&&(console.log("[SIP] BYE request received via receiveRequest event!"),!this.localHangup&&this.currentSession&&(this.cleanupSession(),this.callbacks.onCallEnded?.("remote-hangup")))}),this.callbacks.onIncomingCall?.(n,t),this.currentSession=e;try{const t=e.request?.callId;t&&(this.currentCallSipCallId=t,this.currentCallUuid=t,this.currentCallIsChannelUuid=!1)}catch(e){console.warn("[SIP] Failed to extract Call-ID from inbound INVITE:",e)}console.log("[SIP] Verifying delegate after session assignment:",!!e.delegate),e.on("accepted",t=>{try{const e=t?.headers?.["x-fs-uuid"]?.[0]?.raw||t?.headers?.["X-FS-UUID"]?.[0]?.raw;e&&(this.currentCallUuid=e,this.currentCallIsChannelUuid=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e))}catch{}console.log("[SIP] ===== Call accepted, re-setting SessionDelegate on established session ====="),console.log("[SIP] Session state after accept:",e.state);const n={onBye:e=>{console.log("[SIP] ===== SessionDelegate.onBye FIRED ===== session state:",this.currentSession?.state,"localHangup:",this.localHangup,"hasSession:",!!this.currentSession),!this.localHangup&&this.currentSession&&(this.cleanupSession(),this.callbacks.onCallEnded?.("remote-hangup"))},onAck:t=>{console.log("[SIP] SessionDelegate.onAck FIRED, session state:",e.state)},onInfo:e=>{console.log("[SIP] SessionDelegate.onInfo FIRED")}};e.delegate=n,console.log("[SIP] SessionDelegate re-set after accept, delegate exists:",!!e.delegate),this.setupRemoteMedia(e),this.monitorPeerConnection(e),this.startQualityMonitoring(e),this.reconnectAttempts=0,this.callbacks.onCallAnswered?.()}),e.on("info",e=>{try{const t=e?.getHeader?.("Content-Type")??"",n=e?.body??"";t.includes("application/x-recording-command")&&this.callbacks.onRecordingStateChange?.("start"===n.trim()),e.reply(200)}catch{}}),e.on("notify",e=>{try{const t=e?.body??"";t.startsWith("SIP/2.0 200")?this.callbacks.onTransferSucceeded?.():/SIP\/2.0 [45]\d\d/.test(t)&&this.callbacks.onTransferFailed?.(t.split("\r\n")[0]),e.reply(200)}catch{}}),e.on("failed",e=>{console.error("[SIP] Incoming call failed:",e),this.cleanupSession(),this.callbacks.onCallFailed?.(e)}),e.on("cancel",()=>{this.cleanupSession(),this.callbacks.onCallEnded?.("remote-cancel")}),e.on("hold",()=>{this.callbacks.onRemoteHold?.(!0)}),e.on("unhold",()=>{this.callbacks.onRemoteHold?.(!1)})}async answerCall(){if(!this.currentSession)throw new Error("No incoming call");if("function"!=typeof this.currentSession.accept)throw new Error("Current session is not an incoming call");const e={sessionDescriptionHandlerOptions:{constraints:{audio:this.getLocalAudioConstraints(),video:!1}}};await this.currentSession.accept(e)}async rejectCall(){if(!this.currentSession)return;const e=window.SIP||window.sip;this.currentSession instanceof e.Invitation&&await this.currentSession.reject(),this.cleanupSession()}setupRemoteMedia(e){const t=e.sessionDescriptionHandler?.peerConnection;if(!t)return;const n=new MediaStream;t.getReceivers().forEach(e=>{e.track&&n.addTrack(e.track)}),this.audioElement&&(this.audioElement.srcObject=n),t.ontrack=e=>{if(!this.audioElement)return;const t=this.audioElement.srcObject;t?t.addTrack(e.track):this.audioElement.srcObject=e.streams[0]??new MediaStream([e.track])}}stopLocalTracks(){if(!this.currentSession)return;const e=this.currentSession.sessionDescriptionHandler?.peerConnection;e&&e.getSenders().forEach(e=>{e.track&&e.track.stop()})}cleanupSession(){if(this.iceDisconnectedTimer&&(clearTimeout(this.iceDisconnectedTimer),this.iceDisconnectedTimer=null),this.currentSession){const e=this.currentSession;["progress","accepted","terminated","bye","failed","cancel","rejected","hold","unhold","info","notify"].forEach(t=>{try{e.removeAllListeners?.(t)}catch{}})}this.qualityMonitor.stop(),this.stopLocalTracks(),this.audioElement&&(this.audioElement.srcObject=null),this.currentSession=null,this.currentCallUuid=null,this.currentCallIsChannelUuid=!1,this.currentCallSipCallId=null,this.isMuted=!1,this.localHangup=!1}startQualityMonitoring(e){const t=e.sessionDescriptionHandler?.peerConnection;t&&this.qualityMonitor.start(t,h.QUALITY_INTERVAL_MS)}get isConnected(){return null!==this.userAgent}get hasActiveCall(){return null!==this.currentSession}async setMicrophone(e){this.config.microphoneId=e;const t=this.audioDeviceManager.loadPreferences();if(t.microphoneId=e,this.audioDeviceManager.savePreferences(t),!this.currentSession)return;const n=await this.audioDeviceManager.getAudioConstraints(e||null);let i;try{i=await navigator.mediaDevices.getUserMedia(n)}catch(e){throw new Error(`Microphone access denied: ${e.message}`)}const r=i.getAudioTracks()[0];if(!r)throw i.getTracks().forEach(e=>e.stop()),new Error("No audio track returned from getUserMedia");const a=this.currentSession.sessionDescriptionHandler?.peerConnection,o=a?.getSenders().find(e=>"audio"===e.track?.kind);if(o){const e=o.track;try{await o.replaceTrack(r),e?.stop(),this.isMuted&&(r.enabled=!1)}catch(e){throw r.stop(),new Error(`Failed to switch microphone: ${e.message}`)}}else r.stop()}async setSpeaker(e){this.config.speakerId=e,this.audioElement&&await this.audioDeviceManager.applyAudioOutputDevice(this.audioElement,e);const t=this.audioDeviceManager.loadPreferences();t.speakerId=e,this.audioDeviceManager.savePreferences(t)}async getAudioDevices(){return await this.audioDeviceManager.refreshDevices(),{microphones:this.audioDeviceManager.getMicrophones(),speakers:this.audioDeviceManager.getSpeakers()}}getCallUuid(){return this.currentCallUuid}getCurrentDevices(){const e=this.audioDeviceManager.loadPreferences();return{microphoneId:this.config.microphoneId||e.microphoneId,speakerId:this.config.speakerId||e.speakerId}}getCallQuality(){return this.qualityMonitor.getLastMetrics()}async blindTransfer(e){if(!this.currentSession)throw new Error("No active call");if(!this.currentSession.dialog)throw new Error("Session not established");const t=e.includes("@")?e:`sip:${e}@${this.config.sipDomain}`;return new Promise((e,n)=>{try{const i=this.currentSession.refer(t);i.on("requestSucceeded",()=>e()),i.on("requestFailed",(e,t)=>{n(new Error(`Transfer failed: ${t||"unknown"}`))})}catch(e){n(new Error(`Transfer error: ${e.message}`))}})}monitorPeerConnection(e){const t=e?.sessionDescriptionHandler?.peerConnection;t&&(t.addEventListener("iceconnectionstatechange",()=>{const n=t.iceConnectionState;if("failed"===n){console.warn("[SIP] ICE failed — attempting ICE restart");try{t.restartIce?.(),e.reinvite?.()}catch(e){this.callbacks.onCallFailed?.(new Error("ICE connection failed"))}}else"disconnected"===n?this.iceDisconnectedTimer=window.setTimeout(()=>{"disconnected"===t.iceConnectionState&&(console.error("[SIP] ICE disconnected — no recovery after 10s"),this.callbacks.onCallFailed?.(new Error("Network connection lost")))},1e4):"connected"!==n&&"completed"!==n||this.iceDisconnectedTimer&&(clearTimeout(this.iceDisconnectedTimer),this.iceDisconnectedTimer=null)}),t.addEventListener("connectionstatechange",()=>{"failed"===t.connectionState&&(console.error("[SIP] RTCPeerConnection failed"),this.callbacks.onCallFailed?.(new Error("Peer connection failed")))}))}scheduleReconnect(e){const t=h.MAX_RECONNECTION_ATTEMPTS,n=1e3*h.RECONNECTION_TIMEOUT_S;if(null!==this.reconnectTimer)return;if(this.reconnectAttempts>=t)return console.error("[SIP] Max reconnect attempts reached"),void(e&&this.callbacks.onCallFailed?.(new Error("Connection lost after max retries")));const i=n*Math.pow(2,this.reconnectAttempts);this.reconnectAttempts++,console.warn(`[SIP] Reconnecting in ${i}ms (attempt ${this.reconnectAttempts}/${t})`),this.reconnectTimer=window.setTimeout(async()=>{this.reconnectTimer=null;try{const e=this.userAgent?.transport;e?.connect?await e.connect():this.userAgent?.start?.(),this.reconnectAttempts=0}catch(t){this.scheduleReconnect(e)}},i)}reconnect(){null!==this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.reconnectAttempts=0,this.scheduleReconnect(!!this.currentSession)}}var g={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(?:48|5[0-3579]|[6-9])|7(?:20|32|8)|[89]","(?:31|4)6|51|6(?:485|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,[["(?:(?:241|349)0\\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])|[34]\\d\\d)|91(?:(?:[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}|(?:2(?:[0-26-9]\\d|3[0-8]|4[02-9]|5[0135-9])|3(?:[0-3589]\\d|4[0-578]|6[1-9]|7[0-35-9])|7(?:[013-57-9]\\d|2[0-8])|8(?:55|6[0-8]|[78]\\d|9[02-9]))\\d{6}",[9]],["4(?:79[01]|83[0-36-9]|95[0-3])\\d{5}|4(?:[0-36]\\d|4[047-9]|[58][0-24-9]|7[02-8]|9[0-47-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]|2[23]"],"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","[024-7]\\d{7}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[024-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","(?:01\\d|8)\\d{7}",[8,10],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4 $5",["0"]]]],BL:["590","00","7090\\d{5}|(?:[56]9|[89]\\d)\\d{7}",[9],0,"0",0,0,0,0,0,[["(?:59(?:0(?:2[7-9]|3[3-7]|5[12]|87)|87\\d)|80[6-9]\\d\\d)\\d{4}"],["(?:69(?:0\\d\\d|1(?:2[2-9]|3[0-5]))|7090[0-4])\\d{4}"],["80[0-5]\\d{6}"],["8[129]\\d{7}"],0,0,0,0,["9(?:(?:39[5-7]|76[018])\\d|475[0-6])\\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-7]\\d\\d|8001)\\d{5}",[8,9],[["(\\d)(\\d{7})","$1 $2",["[23]|4[46]|50"]],["(\\d{8})","$1",["[5-7]"]],["(\\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-467]\\d{9,10}|55[0-46-9]\\d{8}|[34]\\d{7}|55\\d{7,8}|(?:5[0-46-9]|[89]\\d)\\d{7,9}",[8,9,10,11],[["(\\d{4})(\\d{4})","$1-$2",["300|4(?:0[02]|37|86)","300|4(?:0(?:0|20)|370|864)"]],["(\\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","[178]\\d{7}|[2-8]\\d{6}",[7,8],[["(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["[2-6]|7[246]|8[2-4]"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["1[67]|[78]"]]]],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-9]\\d{9}|3\\d{6}",[7,10],0,"1",0,0,0,0,0,[["(?:2(?:04|[23]6|[48]9|5[07]|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])|9(?:0[25]|42))[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(?:2[125-9]|3[23]|44|66|77|88)|6(?:22|33))[2-9]\\d{6}",[10]],0,["310\\d{4}",[7]],0,["600[2-9]\\d{6}",[10]]]],CC:["61","001[14-689]|14(?:1[14]|34|4[17]|[56]6|7[47]|88)0011","1(?:[0-79]\\d{8}(?:\\d{2})?|8[0-24-9]\\d{7})|[148]\\d{8}|1\\d{5,7}",[6,7,8,9,10,12],0,"0",0,"([59]\\d{7})$|0","8$1",0,0,[["8(?:51(?:0(?:02|31|60|89)|1(?:18|76)|223)|91(?:0(?:1[0-2]|29)|1(?:[28]2|50|79)|2(?:10|64)|3(?:[06]8|22)|4[29]8|62\\d|70[23]|959))\\d{3}",[9]],["4(?:79[01]|83[0-36-9]|95[0-3])\\d{5}|4(?:[0-36]\\d|4[047-9]|[58][0-24-9]|7[02-8]|9[0-47-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]|5\\d)\\d|2)\\d{7}|[1-68]\\d{6}",[7,8,9,10],[["(\\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{2})(\\d{4})","$1 $2 $3",["2"],"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"],["(\\d{2})(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3 $4",["5"],"0$1"]],"0"],CF:["236","00","8776\\d{4}|(?:[27]\\d|61)\\d{6}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[26-8]"]]]],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,12],[["(\\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{3})(\\d{3})(\\d{3})","$1 $2 $3",["60|809"]],["(\\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(?:10|[2-9])"]],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["3[2-5]|[47]|5[1-3578]|6[13-57]|8(?:0[1-8]|[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[03-689]|2\\d)\\d\\d|6)\\d{8}|1\\d{10}|[126]\\d{6}(?:\\d(?:\\d{2})?)?|86\\d{5,6}|(?:[3-579]\\d|8[0-57-9])\\d{5,9}",[7,8,9,10,11,12],[["(\\d{2})(\\d{5,6})","$1 $2",["(?:10|2[0-57-9])[19]|3(?:[157]|35|49|9[1-68])|4(?:1[124-9]|2[179]|6[47-9]|7|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(?:07|1[236-8]|2[5-7]|[37]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|3|4[13]|5[1-5]|7[0-79]|9[0-35-9])|(?:4[35]|59|85)[1-9]","(?:10|2[0-57-9])(?:1[02]|9[56])|8078|(?:3(?:[157]\\d|35|49|9[1-68])|4(?:1[124-9]|2[179]|[35][1-9]|6[47-9]|7\\d|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]|3\\d|4[13]|5[1-5]|7[0-79]|9[0-35-9]))1","10(?:1(?:0|23)|9[56])|2[0-57-9](?:1(?:00|23)|9[56])|80781|(?:3(?:[157]\\d|35|49|9[1-68])|4(?:1[124-9]|2[179]|[35][1-9]|6[47-9]|7\\d|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]|3\\d|4[13]|5[1-5]|7[0-79]|9[0-35-9]))12","10(?:1(?:0|23)|9[56])|2[0-57-9](?:1(?:00|23)|9[56])|807812|(?:3(?:[157]\\d|35|49|9[1-68])|4(?:1[124-9]|2[179]|[35][1-9]|6[47-9]|7\\d|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]|3\\d|4[13]|5[1-5]|7[0-79]|9[0-35-9]))123","10(?:1(?:0|23)|9[56])|2[0-57-9](?:1(?:00|23)|9[56])|(?:3(?:[157]\\d|35|49|9[1-68])|4(?:1[124-9]|2[179]|[35][1-9]|6[47-9]|7\\d|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(?:078|1[236-8]|2[5-7]|[37]\\d|5[1-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|3\\d|4[13]|5[1-5]|7[0-79]|9[0-35-9]))123"],"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])","(?:46|60\\d\\d)\\d{6}|(?:1\\d|[39])\\d{9}",[8,10,11],[["(\\d{4})(\\d{4})","$1 $2",["46"]],["(\\d{3})(\\d{7})","$1 $2",["6|90"],"($1)"],["(\\d{3})(\\d{7})","$1 $2",["3[0-357]|9[14]"]],["(\\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[01]|83[0-36-9]|95[0-3])\\d{5}|4(?:[0-36]\\d|4[047-9]|[58][0-24-9]|7[02-8]|9[0-47-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,10,11,12],[["(\\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]|3[13])"],"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,0,[["528[89]\\d{5}"],["(?:6(?:[0-79]\\d|8[0-247-9])|7(?:[016-8]\\d|2[0-8]|5[0-5]))\\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}"]]],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-57-9]\\d)\\d{7}",[9],[["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[1-57-9]"],"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",["(?:19|[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|180020",0,0,0,[["(?:1(?:1(?:3(?:[0-58]\\d\\d|73[0-5])|4(?:(?:[0-5]\\d|70)\\d|69[7-9])|(?:(?:5[0-26-9]|[78][0-49])\\d|6(?:[0-4]\\d|5[01]))\\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-3]))|(?: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","(?:694\\d|7093)\\d{5}|(?:59|[89]\\d)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[5-7]|80[6-9]|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|180020","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{8}|800\\d{5,6}",[8,9],[["(\\d{3})(\\d{5})","$1 $2",["8"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[2358]"],"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","7090\\d{5}|(?:[56]9|[89]\\d)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[5-79]|80[6-9]"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"],"0$1"]],"0",0,0,0,0,0,[["(?:59(?:0(?:0[1-68]|[14][0-24-9]|2[0-68]|3[1-9]|5[3-579]|[68][0-689]|7[08]|9\\d)|87\\d)|80[6-9]\\d\\d)\\d{4}"],["(?:69(?:0\\d\\d|1(?:2[2-9]|3[0-5]))|7090[0-4])\\d{4}"],["80[0-5]\\d{6}"],["8[129]\\d{7}"],0,0,0,0,["9(?:(?:39[5-7]|76[018])\\d|475[0-6])\\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","[2-69]\\d{8}|80\\d{5,7}|[1-79]\\d{7}|6\\d{6}",[7,8,9],[["(\\d{2})(\\d{2})(\\d{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-589]\\d{7}",[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]\\d{9,14}|(?:[1-36]|8\\d{5})\\d{6}|00\\d{9}|[1-9]\\d{8,10}|[2-9]\\d{7}",[7,8,9,10,11,12,13,14,15,16,17],[["(\\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|180020","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]|61|88)|8(?:16|2[014]|3[126]|6[136]|7[078]|8[34]|91)|(?:43|59|75)[15]|(?:1[59]|29|67)[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(?:(?: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)|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(?:3171|5[15][2-6]|61[346]|88(?:[2-7]|82))|8(?:70[2-6]|84(?:[2356]|7[19])|91(?:[3-6]|7[19]))|73[134][2-6]|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]|3[129]|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(?:[23569]|8[0-57-9])|8[1-6])|7(?:1(?:[013-8]|9[6-9])|3(?:17|2[0-49]|9[2-57])|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|8(?:28[235-7]|3))|73179|807(?:1|9[1-3])|(?:1552|6(?:(?:1[1358]|2[2457]|3[2-4]|4[235-7]|5[2-689]|6[24578])\\d|7(?:[23569]\\d|8[0-57-9])|8(?:[14-6]\\d|2[0-79]))|7(?:1(?:[013-8]\\d|9[6-9])|3(?:2[0-49]|9[2-57])|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",["16|[6-9]"],"0$1",1],["(\\d{4})(\\d{2,4})(\\d{4})","$1 $2 $3",["18[06]","18[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,11}|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,12],[["(\\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",["[03]"]]],0,0,0,0,0,0,[["0(?:669[0-79]\\d{1,6}|831\\d{2,8})|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[2356]|[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]],["3[2-8]\\d{9,10}",[11,12]],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|180020","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|427|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",["[47]"],"0$1"]],"0"],JP:["81","010","00[1-9]\\d{6,14}|[25-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",["3|4(?:2[09]|7[01])|6[1-9]","3|4(?:2(?:0|9[02-69])|7(?:0[019]|1))|6[1-9]"],"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",["[25-9]"],"0$1"]],"0",0,"(000[2569]\\d{4,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",["[36]0|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","8\\d{13}|[78]\\d{9}",[10,14],0,"8",0,0,0,0,"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",["3"],"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-6]|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","(?:[2457]\\d|33|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",["20"]],["(\\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]"]],["(\\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",["20"]]],0,0,"(15(?:0[06]|1[12]|[35]5|4[04]|6[26]|77|88|99)\\d)"],LV:["371","00","(?:[268]\\d|78|90)\\d{6}",[8],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[2679]|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{4})(\\d{5})","$1-$2",["892"],"0$1"],["(\\d{2})(\\d{7})","$1-$2",["8(?:0[0-7]|9)"],"0$1"],["(\\d)(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4 $5",["[5-8]"],"0$1"]],"0",0,0,0,0,"[5-8]"],MC:["377","00","(?:[3489]|[67]\\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",["[67]"],"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","7090\\d{5}|(?:[56]9|[89]\\d)\\d{7}",[9],0,"0",0,0,0,0,0,[["(?:59(?:0(?:0[079]|[14]3|[27][79]|3[03-7]|5[0-268]|87)|87\\d)|80[6-9]\\d\\d)\\d{4}"],["(?:69(?:0\\d\\d|1(?:2[2-9]|3[0-5]))|7090[0-4])\\d{4}"],["80[0-5]\\d{6}"],["8[129]\\d{7}"],0,0,0,0,["9(?:(?:39[5-7]|76[018])\\d|475[0-6])\\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",["4(?:[2-46]|5[3-5])|5|6(?:[1-689]|7[235-7])|7(?:[0-4]|5[2-7])|8[1-5]|(?:60|86)[23]"],"0$1"],["(\\d)(\\d{3})(\\d{3,4})","$1 $2 $3",["[12]|452|678|86","[12]|452|6788|86"],"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",["11|2[16]"],"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","7091\\d{5}|(?:[56]9|[89]\\d)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[5-79]|8(?:0[6-9]|[36])"],"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]","[2-9]\\d{9}",[10],[["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["33|5[56]|81"]],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["[2-9]"]]],0,0,0,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[0467]"]]]],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","(?:20|9\\d)\\d{8}|[78]\\d{9,13}",[10,11,12,13,14],[["(\\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","(?:222|444|(?:55|8\\d)\\d|666|777|999)\\d{4}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[24-9]"]]]],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",["30|(?: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","30|(?: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","[78]\\d{8}|[2-9]\\d{5}",[6,9],[["(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3",["[2-9]"],"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","[36-8]\\d{5,8}|4\\d{6,8}|59\\d{6}|9\\d{5,10}|(?:2\\d|5[0-8])\\d{6,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",["3[289]|4[246-8]|61|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[136]|8"]],["(\\d{4})(\\d{4})","$1 $2",["[3-7]"]]]],RE:["262","00","709\\d{6}|(?:26|[689]\\d)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[26-9]"],"0$1"]],"0",0,0,0,0,0,[["2631[0-6]\\d{4}|26(?:2\\d|30|88)\\d{5}"],["(?:69(?:2\\d\\d|3(?:[06][0-6]|1[0-3]|2[0-2]|3[0-39]|4\\d|5[0-5]|7[0-37]|8[0-8]|9[0-479]))|7092[0-3])\\d{4}"],["80\\d{7}"],["89[1-37-9]\\d{6}"],0,0,0,0,["9(?:399[0-3]|479[0-6]|76(?:2[278]|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,"[3489]",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","(?:[15]\\d|800|92)\\d{7}",[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{4})","$1 $2 $3",["8"]]],"0"],SB:["677","0[01]","[6-9]\\d{6}|[1-6]\\d{4}",[5,7],[["(\\d{2})(\\d{5})","$1 $2",["6[89]|7|8[4-9]|9(?:[1-8]|9[0-8])"]]]],SC:["248","010|0[0-2]","(?:[2489]\\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,12],[["(\\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]|7[67]|9[2-9]"]]],"0"],SR:["597","00","(?:[2-5]|[6-9]\\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-9]"]]]],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","[25-7]\\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",["[25-7]"]],["(\\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-359]\\d{8}|[1-5]\\d{7}",[8,9],[["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[1-4]|5[1-3]"],"0$1",1],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[59]"],"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|[3689]\\d|77)\\d{6}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[236-9]"]]],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|66)\\d{7}",[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(?:[1245]|3[12])"]],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["\\d"]]],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-79]"],"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{3})(\\d{5})","$1 $2",["826"],"0$1"],["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["83"],"0$1"],["(\\d{2})(\\d{2})(\\d{4})","$1 $2 $3",["82"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[25]0|37|49|8[09]"],"0$1"],["(\\d)(\\d{3,4})(\\d{4})","$1 $2 $3",["[23568]|4(?:0[02-48]|[1-478])|7[1-9]","[23568]|4(?:0[2-48]|[1-478])|(?: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,[["(?:274[27]|(?:472|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[013-79]|3[0-24679]|4[167]|5[0-3]|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-57-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-269])|7(?:0[1-46-8]|1[2-9]|2[04-8]|3[0-2478]|4[0378]|5[47]|6[02359]|7[0-59]|8[156])|8(?:0[1-68]|1[02-8]|2[0168]|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-3589]|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]|3[23]|44|66|77|88)[2-9]\\d{6}"]]],UY:["598","0(?:0|1[3-9]\\d)","0004\\d{2,9}|[1249]\\d{7}|2\\d{3,4}|(?:[49]\\d|80)\\d{5}",[4,5,6,7,8,9,10,11,12,13],[["(\\d{4,5})","$1",["21"]],["(\\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","00","(?:20|33|[5-9]\\d)\\d{7}",[9],[["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[235-9]"]]]],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,12],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(?:2[02]|[89])"],0,1],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["1[26]|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|8\\d{4})\\d{4}|[89]\\d{5}",[6,9],[["(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3",["[47-9]"]],["(\\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","(?:639\\d|7093)\\d{5}|(?:26|80|9\\d)\\d{7}",[9],0,"0",0,0,0,0,0,[["26(?:89\\d|9(?: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])|7093[5-7])\\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|[579]\\d|63)\\d{7}",[9],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[28]"],"0$1"],["(\\d{2})(\\d{7})","$1 $2",["[579]"],"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}|[235-7]\\d{8}",[9,12],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[235-7]"]]],0,0,0,0,0,0,[0,["(?:[356]|774[45])\\d{8}|7[6-8]\\d{7}"],0,0,0,0,0,0,["2\\d{8}",[9]]]],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|5[12]"]],["(\\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})|5(?:0\\d{3}|2[0-2]))\\d{7}",[7,8,9,10,12]],0,0,0,["348[57]\\d{7}",[11]],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 m(e,t){var n=Array.prototype.slice.call(t);return n.push(g),e.apply(this,n)}function f(e,t){e=e.split("-"),t=t.split("-");for(var n=e[0].split("."),i=t[0].split("."),r=0;r<3;r++){var a=Number(n[r]),o=Number(i[r]);if(a>o)return 1;if(o>a)return-1;if(!isNaN(a)&&isNaN(o))return 1;if(isNaN(a)&&!isNaN(o))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 b={}.constructor;function v(e){return null!=e&&e.constructor===b}var y=/^\d+$/;function w(e){return w="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},w(e)}function x(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function C(e,t,n){return t&&function(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,k(i.key),i)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function k(e){var t=function(e,t){if("object"!=w(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t);if("object"!=w(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e,"string");return"symbol"==w(t)?t:t+""}var S=" ext. ",I=function(){return C(function e(t){x(this,e),function(e){if(!e)throw new Error("[libphonenumber-js] `metadata` argument not passed. Check your arguments.");if(!v(e)||!v(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(v(e)?"an object of shape: { "+Object.keys(e).join(", ")+" }":"a "+N(e)+": "+e,"."))}(t),this.metadata=t,H.call(this,t)},[{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){var n,i,r;if(e&&(r=e,y.test(r)?i=e:n=e),t&&(i=t),n&&"001"!==n){var a=this.getCountryMetadata(n);if(!a)throw new Error("Unknown country: ".concat(n));this.numberingPlan=new D(a,this)}else if(i){if(!this.hasCallingCode(i))throw new Error("Unknown calling code: ".concat(i));this.numberingPlan=new D(this.getNumberingPlanMetadata(i),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 n=this.nonGeographic()[e];if(n)return n}else{var i=this.countryCallingCodes()[e];if(i&&1===i.length&&"001"===i[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}}])}(),D=function(){return C(function e(t,n){x(this,e),this.globalMetadataObject=n,this.metadata=t,H.call(this,n.metadata)},[{key:"callingCode",value:function(){return this.metadata[0]}},{key:"_getDefaultCountryMetadataForThisCallingCode",value:function(){return this.globalMetadataObject.getNumberingPlanMetadata(this.callingCode())}},{key:"getDefaultCountryMetadataForRegion",value:function(){return this._getDefaultCountryMetadataForThisCallingCode()}},{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._getDefaultCountryMetadataForThisCallingCode())||[];return t.map(function(t){return new A(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._getDefaultCountryMetadataForThisCallingCode())}},{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._getDefaultCountryMetadataForThisCallingCode())}},{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()&&T(this.types(),e))return new P(T(this.types(),e),this)}},{key:"ext",value:function(){return this.v1||this.v2?S:this.metadata[13]||S}}])}(),A=function(){return C(function e(t,n){x(this,e),this._format=t,this.metadata=n},[{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()||E.test(this.nationalPrefixFormattingRule()))}},{key:"internationalFormat",value:function(){return this._format[5]||this.format()}}])}(),E=/^\(?\$1\)?$/,P=function(){return C(function e(t,n){x(this,e),this.type=t,this.metadata=n},[{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()}}])}();function T(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 N=function(e){return w(e)};function M(e,t){var n=new I(t);if(n.hasCountry(e))return n.selectNumberingPlan(e).countryCallingCode();throw new Error("Unknown country: ".concat(e))}function H(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===f(t,"1.2.0")?this.v2=!0:-1===f(t,"1.7.35")?this.v3=!0:this.v4=!0:this.v1=!0}function R(e){return new I(e).getCountries()}function B(){return m(M,arguments)}function z(e){const t=e.toUpperCase().split("").map(e=>127397+e.charCodeAt(0));return String.fromCodePoint(...t)}const L={US:"USA",CA:"Canada",GB:"UK",AU:"Australia",IN:"India",DE:"Germany",FR:"France",ES:"Spain",IT:"Italy",JP:"Japan",CN:"China",BR:"Brazil",MX:"Mexico",RU:"Russia",KR:"South Korea",NL:"Netherlands",SE:"Sweden",CH:"Switzerland",BE:"Belgium",NO:"Norway",DK:"Denmark",FI:"Finland",PL:"Poland",PT:"Portugal",IE:"Ireland",NZ:"New Zealand",SG:"Singapore",AE:"UAE",SA:"Saudi Arabia",ZA:"South Africa",AR:"Argentina",CL:"Chile",CO:"Colombia",PH:"Philippines",MY:"Malaysia",TH:"Thailand",VN:"Vietnam",ID:"Indonesia",PK:"Pakistan",BD:"Bangladesh",EG:"Egypt",NG:"Nigeria",KE:"Kenya",TR:"Turkey",IL:"Israel",GR:"Greece",AT:"Austria",CZ:"Czech Republic",HU:"Hungary",RO:"Romania",UA:"Ukraine"},U=function(){return m(R,arguments)}().filter(e=>L[e]).map(e=>({code:e,flag:z(e),dialCode:`+${B(e)}`,name:L[e]})).sort((e,t)=>e.name.localeCompare(t.name)),F="calls";class O{constructor(){this.db=null}async init(){return new Promise((e,t)=>{const n=indexedDB.open("call_history",1);n.onerror=()=>t(n.error),n.onsuccess=()=>{this.db=n.result,e()},n.onupgradeneeded=e=>{const t=e.target.result.createObjectStore(F,{keyPath:"id",autoIncrement:!0});t.createIndex("callId","callId",{unique:!0}),t.createIndex("userId_domain",["userId","sipDomain"],{unique:!1}),t.createIndex("startedAt","startedAt",{unique:!1}),t.createIndex("status","status",{unique:!1})}})}async add(e){if(!this.db)throw new Error("Database not initialized");return new Promise((t,n)=>{const i=this.db.transaction(F,"readwrite").objectStore(F).add(e);i.onsuccess=()=>t(i.result),i.onerror=()=>n(i.error)})}async getAll(e,t,n=100){if(!this.db)throw new Error("Database not initialized");return new Promise((i,r)=>{const a=this.db.transaction(F,"readonly").objectStore(F).index("userId_domain"),o=IDBKeyRange.only([e,t]),s=a.openCursor(o,"prev"),d=[];let l=0;s.onsuccess=e=>{const t=e.target.result;t&&l<n?(d.push(t.value),l++,t.continue()):i(d)},s.onerror=()=>r(s.error)})}async getByCallId(e){if(!this.db)throw new Error("Database not initialized");return new Promise((t,n)=>{const i=this.db.transaction(F,"readonly").objectStore(F).index("callId").get(e);i.onsuccess=()=>t(i.result||null),i.onerror=()=>n(i.error)})}async update(e,t){if(!this.db)throw new Error("Database not initialized");return new Promise((n,i)=>{const r=this.db.transaction(F,"readwrite").objectStore(F),a=r.get(e);a.onsuccess=()=>{const o=a.result;if(!o)return void i(new Error(`Record ${e} not found`));const s={...o,...t},d=r.put(s);d.onsuccess=()=>n(),d.onerror=()=>i(d.error)},a.onerror=()=>i(a.error)})}async replaceAll(e,t,n){if(!this.db)throw new Error("Database not initialized");return new Promise((i,r)=>{const a=this.db.transaction(F,"readwrite").objectStore(F),o=a.index("userId_domain"),s=IDBKeyRange.only([e,t]),d=o.openCursor(s);d.onsuccess=e=>{const t=e.target.result;t?(t.delete(),t.continue()):(Array.isArray(n)&&n.length>0&&n.forEach(e=>a.add(e)),i())},d.onerror=()=>r(d.error)})}async clear(){if(!this.db)throw new Error("Database not initialized");return new Promise((e,t)=>{const n=this.db.transaction(F,"readwrite").objectStore(F).clear();n.onsuccess=()=>e(),n.onerror=()=>t(n.error)})}close(){this.db&&(this.db.close(),this.db=null)}}class _{constructor(){this.api=null,this.userId=null,this.sipDomain=null,this.initialized=!1,this.store=new O}async init(e,t,n,i){this.userId=e,this.sipDomain=t,await this.store.init(),n&&(this.api=new a(n,i)),this.initialized=!0,this.api&&this.sync().catch(e=>{console.error("[CallHistoryService] Background sync failed:",e)})}setAuthToken(e){this.api&&this.api.setAuthToken(e)}ensureInitialized(){if(!this.initialized||!this.userId||!this.sipDomain)throw new Error("CallHistoryService not initialized. Call init() first.")}async addCall(e){this.ensureInitialized();const t={callId:e.callId,userId:this.userId,sipDomain:this.sipDomain,callerIdNumber:e.callerIdNumber,callerIdName:e.callerIdName,phoneNumber:e.phoneNumber,direction:e.direction,disposition:e.disposition,startedAt:e.startedAt,endedAt:e.endedAt,durationSeconds:e.durationSeconds,recordingUrl:e.recordingUrl,createdAt:Date.now()};await this.store.add(t)}async getHistory(e=100){this.ensureInitialized();const t=await this.store.getAll(this.userId,this.sipDomain,e);if(t.length>0)return t;if(this.api)try{const t=await this.api.fetchHistory({userId:this.userId,sipDomain:this.sipDomain,limit:e});return t.calls.length>0&&await this.store.replaceAll(this.userId,this.sipDomain,t.calls),t.calls}catch(e){return console.error("[CallHistoryService] Failed to fetch from backend:",e),[]}return[]}async sync(){if(this.ensureInitialized(),this.api)try{const e=await this.api.fetchHistory({userId:this.userId,sipDomain:this.sipDomain,limit:100});e&&Array.isArray(e.calls)?(await this.store.replaceAll(this.userId,this.sipDomain,e.calls),console.log(`[CallHistoryService] Synced ${e.calls.length} calls from backend`)):console.warn("[CallHistoryService] Invalid response format from backend:",e)}catch(e){console.error("[CallHistoryService] Sync failed:",e)}else console.warn("[CallHistoryService] No API configured, skipping sync")}async updateCall(e,t){this.ensureInitialized();const n=await this.store.getByCallId(e);n&&n.id&&await this.store.update(n.id,t)}async clear(){await this.store.clear()}async clearCache(){console.log("[CallHistoryService] Clearing IndexedDB cache"),await this.store.clear(),this.api&&await this.sync()}destroy(){this.store.close(),this.userId=null,this.sipDomain=null,this.initialized=!1}}const j="https://stag-5-dialer-apis.convirza.com";class V extends HTMLElement{static get observedAttributes(){return["state","position","theme","api-url","sip-domain","sip-username","sip-password","ws-servers","ice-servers","primary-color","accent-color","brand-name","brand-logo","park-api-url","park-poll-interval","auth-token","api-base-url","domain-id","first-name","last-name","email"]}constructor(){super(),this.config={},this.callStatus="idle",this.currentCall=null,this.durationInterval=null,this.isMuted=!1,this.isOnHold=!1,this.isRecording=!1,this.phoneInputValue="",this.selectedCountry={code:"US",flag:"🇺🇸",dialCode:"+1"},this.showCountryDropdown=!1,this.longPressTimer=null,this.longPressTriggered=!1,this.boundHandlers=new Map,this.isInitialized=!1,this.currentView="dial",this.currentHistoryTab="all",this.callHistory=[],this.selectedHistoryItem=null,this.STORAGE_KEY="convirza_call_state",this.sipAdapter=null,this.incomingCallNumber=null,this.incomingCallName=null,this.showInCallKeypad=!1,this.dialedDigits="",this.audioDevices={microphones:[],speakers:[]},this.callQuality=null,this.isDragging=!1,this.dragOffset={x:0,y:0},this.fabPosition=null,this.parkAccounts=[],this.parkApiUrl=null,this.parkPollInterval=5e3,this.parkPollTimer=null,this.authToken=null,this.showRetrieveModal=!1,this.retrieveModalData=null,this.isParking=!1,this.parkingSlot=null,this.parkValidationTimer=null,this.parkValidationAttempts=0,this.errorDismissTimer=null,this.dragStartTime=0,this.hasMoved=!1,this.ringbackTone=null,this.callConnectedTime=0,this.dialTone=null,this.renderScheduled=!1,this.sharedAudioContext=null,this.ringbackBlobUrl=null,this.dialToneBlobUrl=null,this.dialToneBuffer=null,this.currentCallId=null,this.callHistorySaved=!1,this.showTransferView=!1,this.transferTarget="",this.isTransferring=!1,this.domainExtensions=[],this._activeNotification=null,this._onOnline=null,this._onOffline=null,this.phoneNumbersAPI=null,this.orderedPhoneNumbers=[],this.selectedPhoneNumber=null,this.showPhoneNumberDropdown=!1,this.loadingPhoneNumbers=!1,this.phoneNumbersError=null,this.togglePhoneNumberDropdown=e=>{e.preventDefault(),e.stopPropagation(),console.log("[Dialer] Toggling dropdown, current state:",this.showPhoneNumberDropdown),this.showPhoneNumberDropdown=!this.showPhoneNumberDropdown,console.log("[Dialer] New dropdown state:",this.showPhoneNumberDropdown),this.updatePhoneNumberDropdownDOM()},this.selectPhoneNumber=e=>{console.log("[Dialer] Selecting phone number:",e.number_str),this.selectedPhoneNumber=e,this.closePhoneNumberDropdown(),this.config.domainId&&localStorage.setItem(`convirza_selected_caller_id_${this.config.domainId}`,JSON.stringify(e));const t=this.shadow.querySelector(".selected-number");t&&(t.textContent=`${e.assigned_user_name||"Unknown"} - ${this.formatPhoneNumberDisplay(e.number||e.number_str)}`)},this.shadow=this.attachShadow({mode:"open"}),this.setupAudioTones(),this.callHistoryService=new _}setupAudioTones(){this.ringbackTone=new Audio,this.ringbackTone.loop=!0,this.ringbackTone.volume=.3;const e=44100,t=new OfflineAudioContext(1,264600,e),n=t.createBuffer(1,264600,e),i=n.getChannelData(0);for(let t=0;t<264600;t++)if(t<88200){const n=t/e;i[t]=.3*(Math.sin(2*Math.PI*440*n)+Math.sin(2*Math.PI*480*n))}else i[t]=0;const r=t.createBufferSource();r.buffer=n,r.connect(t.destination),r.start(),t.startRendering().then(e=>{const t=this.bufferToWave(e),n=new Blob([t],{type:"audio/wav"}),i=URL.createObjectURL(n);this.ringbackBlobUrl=i,this.ringbackTone&&(this.ringbackTone.src=i)}).catch(e=>{console.warn("[Dialer] Failed to generate ringback tone:",e)}),this.dialTone=new Audio,this.dialTone.volume=.2}bufferToWave(e){const t=e.length*e.numberOfChannels*2+44,n=new ArrayBuffer(t),i=new DataView(n),r=[];let a=0,o=0;const s=e=>{i.setUint16(o,e,!0),o+=2},d=e=>{i.setUint32(o,e,!0),o+=4};d(1179011410),d(t-8),d(1163280727),d(544501094),d(16),s(1),s(e.numberOfChannels),d(e.sampleRate),d(2*e.sampleRate*e.numberOfChannels),s(2*e.numberOfChannels),s(16),d(1635017060),d(t-o-4);for(let t=0;t<e.numberOfChannels;t++)r.push(e.getChannelData(t));for(;a<e.length;){for(let e=0;e<r.length;e++){const t=Math.max(-1,Math.min(1,r[e][a]));i.setInt16(o,t<0?32768*t:32767*t,!0),o+=2}a++}return n}async connectedCallback(){if(!this.isInitialized){const e=this.getAttribute("access-token"),t=this.getAttribute("refresh-token");if("true"===this.getAttribute("auto-configure"))try{if(e)await this.autoConfigureFromAccessToken(e,t);else{if(!t)throw new Error("No access_token or refresh_token provided");await this.autoConfigureFromRefreshToken(t)}}catch(e){return console.error("[Dialer] Auto-config failed:",e),void this.dispatchEvent(new CustomEvent("auth-failed",{detail:{error:e.message},bubbles:!0}))}this.updateConfig(),this.initializeSip(),this.restoreCallState(),this.initializePosition(),this.setupEventListeners(),this._onOnline=()=>{console.log("[Dialer] Network restored — reconnecting SIP"),this.sipAdapter?.reconnect?.()},this._onOffline=()=>{console.warn("[Dialer] Network lost"),this.dispatchEvent(new CustomEvent("sip-transport-error",{detail:{error:"Network offline"},bubbles:!0}))},window.addEventListener("online",this._onOnline),window.addEventListener("offline",this._onOffline),this.render(),this.isInitialized=!0}}initializePosition(){const e=this.getAttribute("position")||"bottom-right",t=window.innerWidth,n=window.innerHeight;let i=0,r=0;i=e.includes("right")?t-56-24:24,r=e.includes("bottom")?n-56-24:24,this.fabPosition={x:i,y:r},this.style.left=`${i}px`,this.style.top=`${r}px`,this.style.right="auto",this.style.bottom="auto"}disconnectedCallback(){this._onOnline&&(window.removeEventListener("online",this._onOnline),this._onOnline=null),this._onOffline&&(window.removeEventListener("offline",this._onOffline),this._onOffline=null),this.dismissIncomingCallNotification(),this.durationInterval&&(clearInterval(this.durationInterval),this.durationInterval=null),this.stopParkSlotPolling(),this.currentCall&&this.endCall(),this.sipAdapter&&(this.sipAdapter.disconnect(),this.sipAdapter=null),this.callHistoryService.destroy(),this.sharedAudioContext&&"closed"!==this.sharedAudioContext.state&&(this.sharedAudioContext.close().catch(()=>{}),this.sharedAudioContext=null),this.ringbackBlobUrl&&(URL.revokeObjectURL(this.ringbackBlobUrl),this.ringbackBlobUrl=null),this.dialToneBlobUrl&&(URL.revokeObjectURL(this.dialToneBlobUrl),this.dialToneBlobUrl=null),this.ringbackTone&&(this.ringbackTone.src="",this.ringbackTone=null),this.dialTone&&(this.dialTone.src="",this.dialTone=null),this.cleanup()}cleanup(){const e=this.boundHandlers.get("root-click");e&&this.shadow.removeEventListener("click",e);const t=this.boundHandlers.get("root-input");t&&this.shadow.removeEventListener("input",t);const n=this.boundHandlers.get("drag-mousemove");n&&document.removeEventListener("mousemove",n);const i=this.boundHandlers.get("drag-mouseup");i&&document.removeEventListener("mouseup",i);const r=this.boundHandlers.get("drag-touchmove");r&&document.removeEventListener("touchmove",r);const a=this.boundHandlers.get("drag-touchend");a&&document.removeEventListener("touchend",a),this.boundHandlers.clear(),this.isInitialized=!1}attributeChangedCallback(e,t,n){t!==n&&(this.updateConfig(),this.isInitialized&&this.render())}updateConfig(){const e=this.getAttribute("ice-servers");let t;if(e)try{t=JSON.parse(e)}catch(e){console.warn("[Dialer] Failed to parse ice-servers attribute:",e)}this.config={apiUrl:this.getAttribute("api-url")||j,sipDomain:this.getAttribute("sip-domain")||"",sipUsername:this.getAttribute("sip-username")||"",sipPassword:this.getAttribute("sip-password")||"",wsServers:this.getAttribute("ws-servers")?.split(",")||[],iceServers:t,authToken:this.getAttribute("auth-token")||void 0,primaryColor:this.getAttribute("primary-color")||"#ff6b35",accentColor:this.getAttribute("accent-color")||"#22c55e",theme:this.getAttribute("theme")||"dark",brandName:this.getAttribute("brand-name")||"Convirza",brandLogo:this.getAttribute("brand-logo")||void 0,apiBaseUrl:this.getAttribute("api-base-url")||j,domainId:this.getAttribute("domain-id")?parseInt(this.getAttribute("domain-id"),10):void 0,firstName:this.getAttribute("first-name")||void 0,lastName:this.getAttribute("last-name")||void 0,email:this.getAttribute("email")||void 0};const n=this.parkApiUrl;this.parkApiUrl=this.getAttribute("park-api-url")||(this.config.apiUrl?`${this.config.apiUrl.replace(/\/$/,"")}/v3/park-slots`:null);const i=this.getAttribute("park-poll-interval");i&&(this.parkPollInterval=parseInt(i,10)),this.authToken=this.getAttribute("auth-token")||null,console.log("[Dialer] Phone numbers config check:",{apiBaseUrl:this.config.apiBaseUrl,domainId:this.config.domainId,hasAuthToken:!!this.authToken}),this.config.apiBaseUrl&&this.authToken?(console.log("[Dialer] Initializing PhoneNumbersAPI"),this.phoneNumbersAPI=new r(this.config.apiBaseUrl,this.authToken),this.config.domainId&&(console.log("[Dialer] Fetching phone numbers on init"),this.fetchOrderedPhoneNumbers())):console.warn("[Dialer] Phone numbers API not initialized - missing apiBaseUrl or authToken"),n!==this.parkApiUrl&&this.parkApiUrl&&this.sipAdapter&&this.startParkSlotPolling(),this.style.setProperty("--primary-color",this.config.primaryColor),this.style.setProperty("--accent-color",this.config.accentColor)}isDialerEnabled(){return!!(this.config.sipDomain&&this.config.sipUsername&&this.config.wsServers&&this.config.wsServers.filter(e=>""!==e.trim()).length>0)}async autoConfigureFromAccessToken(e,t){const n=`${(this.getAttribute("oauth-endpoint")||"https://stag-5-oauth.convirza.com/oauth/internal").replace(/\/$/,"")}/session`;console.log("[Dialer] Auto-configuring from access token...");const i=await fetch(n,{method:"GET",headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json"}});if(401===i.status&&t)return console.log("[Dialer] Access token expired, refreshing..."),this.autoConfigureFromRefreshToken(t);if(!i.ok){const e=await i.text();throw new Error(`Session fetch failed: ${i.status} ${e}`)}const r=await i.json();if(200!==r.code||!r.data)throw new Error(r.message||"Session fetch failed");const{user:a}=r.data;if(!a.dialer_config||!a.dialer_config.domains||0===a.dialer_config.domains.length)throw new Error("No dialer domains configured for this user");const o=a.dialer_config.domains[0],s=o.extensions&&o.extensions.length>0?o.extensions[0]:null;if(!s)throw new Error("No extension configured for this domain");this.setAttribute("auth-token",e),this.setAttribute("sip-domain",o.sip_domain),this.setAttribute("sip-username",s.extension),this.setAttribute("sip-password",`${a.user_id}@${o.sip_domain}`),this.setAttribute("ws-servers",`wss://${o.sip_proxy_1}:8443`),this.setAttribute("domain-id",String(o.domain_id)),this.setAttribute("first-name",a.first_name||""),this.setAttribute("last-name",a.last_name||""),this.setAttribute("email",a.email||""),o.ice_servers&&Array.isArray(o.ice_servers)&&this.setAttribute("ice-servers",JSON.stringify(o.ice_servers)),console.log("[Dialer] Auto-configured successfully from access token")}async autoConfigureFromRefreshToken(e){const t=`${(this.getAttribute("oauth-endpoint")||"https://stag-5-oauth.convirza.com/oauth/internal").replace(/\/$/,"")}/refresh-token`;console.log("[Dialer] Auto-configuring from refresh token...");const n=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refresh_token:e})});if(!n.ok){const e=await n.text();throw new Error(`OAuth refresh failed: ${n.status} ${e}`)}const i=await n.json();if(200!==i.code||!i.data)throw new Error(i.message||"OAuth refresh failed");const{access_token:r,refresh_token:a,user:o}=i.data;if(!o.dialer_config||!o.dialer_config.domains||0===o.dialer_config.domains.length)throw new Error("No dialer domains configured for this user");const s=o.dialer_config.domains[0],d=s.extensions&&s.extensions.length>0?s.extensions[0]:null;if(!d)throw new Error("No extension configured for this domain");this.dispatchEvent(new CustomEvent("token-refreshed",{detail:{access_token:r,refresh_token:a,user:o},bubbles:!0})),this.setAttribute("access-token",r),this.setAttribute("refresh-token",a),this.setAttribute("auth-token",r),this.setAttribute("sip-domain",s.sip_domain),this.setAttribute("sip-username",d.extension),this.setAttribute("sip-password",`${o.user_id}@${s.sip_domain}`),this.setAttribute("ws-servers",`wss://${s.sip_proxy_1}:8443`),this.setAttribute("domain-id",String(s.domain_id)),this.setAttribute("first-name",o.first_name||""),this.setAttribute("last-name",o.last_name||""),this.setAttribute("email",o.email||""),s.ice_servers&&Array.isArray(s.ice_servers)&&this.setAttribute("ice-servers",JSON.stringify(s.ice_servers)),console.log("[Dialer] Auto-configured successfully")}initializeSip(){if(this.isDialerEnabled())try{try{this.sipAdapter=new $({sipUsername:this.config.sipUsername,sipPassword:this.config.sipPassword,sipDomain:this.config.sipDomain,wsServers:this.config.wsServers,iceServers:this.config.iceServers,apiUrl:this.config.apiUrl,authToken:this.authToken||void 0},{onRegistered:async()=>{this.dispatchEvent(new CustomEvent("sip-registered",{bubbles:!0})),this.startParkSlotPolling(),this.requestNotificationPermission(),this.fetchDomainExtensions(),this.config.apiBaseUrl&&this.config.domainId&&this.authToken&&(this.phoneNumbersAPI||(this.phoneNumbersAPI=new r(this.config.apiBaseUrl,this.authToken)),this.fetchOrderedPhoneNumbers()),await this.initializeCallHistory()},onUnregistered:()=>{this.dispatchEvent(new CustomEvent("sip-unregistered",{bubbles:!0}))},onRegistrationFailed:e=>{console.error("[Dialer] SIP registration failed:",e),this.dispatchEvent(new CustomEvent("sip-registration-failed",{detail:{cause:e},bubbles:!0}))},onTransportError:e=>{console.error("[Dialer] SIP transport error:",e),this.dispatchEvent(new CustomEvent("sip-transport-error",{detail:{error:e.message},bubbles:!0}))},onConnecting:()=>{this.dispatchEvent(new CustomEvent("sip-connecting",{bubbles:!0}))},onCallRinging:()=>{this.notifyCallRinging()},onCallAnswered:()=>{this.notifyCallAnswered()},onCallEnded:e=>{this.handleCallEnded(e)},onCallFailed:e=>{console.error("[Dialer] Call failed:",e),this.stopRingbackTone(),this.dismissIncomingCallNotification();const t=e?.statusCode,n=e?.isRejected||486===t||603===t||600===t?"rejected":"failed";this.currentCall?.phoneNumber&&this.currentCallId&&!this.callHistorySaved&&(this.callHistorySaved=!0,this.callHistoryService.addCall({callId:this.currentCallId,phoneNumber:this.currentCall.phoneNumber,callerIdNumber:this.currentCall.phoneNumber,callerIdName:this.config.sipUsername,direction:this.currentCall.direction||"outbound",disposition:n,startedAt:this.currentCall.startTime||Date.now(),endedAt:Date.now(),durationSeconds:0}).then(()=>{this.loadCallHistory()}).catch(e=>{console.error("[CallHistory] Failed to save failed call:",e)})),this.transitionState("error",e?.message||"Call failed")},onIncomingCall:(e,t)=>{this.handleIncomingCall(e,t)},onRemoteHold:e=>{this.dispatchEvent(new CustomEvent("call-remote-hold",{detail:{isOnHold:e},bubbles:!0}))},onQualityChange:e=>{this.callQuality=e,this.dispatchEvent(new CustomEvent("call-quality-change",{detail:e,bubbles:!0})),"connected"===this.callStatus&&this.render()},onRecordingStateChange:e=>{this.isRecording=e,this.render()},onTransferSucceeded:()=>{this.showTransferView=!1,this.transferTarget="",this.isTransferring=!1,this.dispatchEvent(new CustomEvent("call-transferred",{bubbles:!0}))},onTransferFailed:e=>{this.isTransferring=!1,this.dispatchEvent(new CustomEvent("dialer-error",{detail:{error:`Transfer failed: ${e}`},bubbles:!0})),this.render()},onDevicesChanged:e=>{const t=e.filter(e=>"audioinput"===e.kind),n=e.filter(e=>"audiooutput"===e.kind);this.audioDevices={microphones:t,speakers:n},this.render()},onError:e=>{console.error("[Dialer] SIP error:",e),this.dispatchEvent(new CustomEvent("dialer-error",{detail:{error:e.message},bubbles:!0}))}})}catch(e){return console.error("[Dialer] Failed to create SipAdapter:",e),void this.dispatchEvent(new CustomEvent("sip-error",{detail:{error:e.message||"SipAdapter constructor failed"},bubbles:!0}))}this.sipAdapter.connect().catch(e=>{console.error("[Dialer] SIP connection failed:",e),this.dispatchEvent(new CustomEvent("sip-error",{detail:{error:e.message},bubbles:!0}))})}catch(e){console.error("[Dialer] Failed to initialize SIP:",e)}else console.warn("[Dialer] SIP credentials not configured, dialer disabled")}async initializeCallHistory(){if(this.config.sipUsername&&this.config.sipDomain)try{await this.callHistoryService.init(this.config.sipUsername,this.config.sipDomain,this.config.apiUrl,this.authToken||void 0),console.log("[CallHistory] Service initialized"),await this.loadCallHistory()}catch(e){console.error("[CallHistory] Failed to initialize:",e)}else console.warn("[CallHistory] Missing SIP credentials, skipping initialization")}async loadCallHistory(){try{const e=await this.callHistoryService.getHistory(100);this.callHistory=e.map(e=>({id:e.callId,phoneNumber:e.phoneNumber,type:this.mapDirectionToType(e.direction,e.disposition),status:this.mapDispositionToString(e.disposition),timestamp:e.startedAt,duration:e.durationSeconds>0?e.durationSeconds:void 0})).filter(e=>"number"==typeof e.timestamp&&!isNaN(e.timestamp)).sort((e,t)=>t.timestamp-e.timestamp),this.render(),console.log(`[CallHistory] Loaded ${this.callHistory.length} calls`)}catch(e){console.error("[CallHistory] Failed to load history:",e)}}mapDirectionToType(e,t){return"missed"===t?"missed":"inbound"===e?"inbound":"outbound"}mapDispositionToString(e){switch(e){case"answered":return"Answered";case"missed":return"Missed";case"rejected":return"Rejected";case"failed":return"Failed";default:return"Unknown"}}generateCallId(){const e=this.sipAdapter?.getCallUuid();return e||"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})}isValidTransition(e,t){const n=s[e];return!!n&&n.includes(t)}transitionState(e,t){const n=this.callStatus;if(n===e)return;if(!this.isValidTransition(n,e))return console.error(`[CallState] Invalid transition: ${n} → ${e}`),void("error"!==e&&this.isValidTransition(n,"error")&&this.transitionState("error",`Invalid state transition from ${n} to ${e}`));this.callStatus=e,this.errorDismissTimer&&(window.clearTimeout(this.errorDismissTimer),this.errorDismissTimer=null),"error"===e&&(this.errorDismissTimer=window.setTimeout(()=>{this.currentCall=null,this.transitionState("idle")},3e3));const i=this.currentCall?{phoneNumber:this.currentCall.phoneNumber,startTime:this.currentCall.startTime,duration:this.currentCall.duration,status:e,errorMessage:t}:void 0;this.dispatchEvent(new CustomEvent("state-change",{detail:{oldState:n,newState:e,metadata:i},bubbles:!0})),this.persistCallState();this.needsUIRebuild(n,e)?this.render():this.performSelectiveUpdate(this.getAttribute("state")||"collapsed")}needsUIRebuild(e,t){return!![["idle","dialing"],["idle","ringing"],["dialing","connected"],["ringing","connected"],["ended","idle"],["error","idle"],["dialing","error"],["ringing","error"],["connected","error"]].some(([n,i])=>n===e&&i===t)||("idle"===t||"ended"===t||"error"===t||("idle"===e||"ended"===e||"error"===e))}getCallMetadata(){return this.currentCall?{phoneNumber:this.currentCall.phoneNumber,startTime:this.currentCall.startTime,duration:this.currentCall.duration,status:this.callStatus}:null}persistCallState(){if("undefined"!=typeof window&&window.localStorage)try{const e=this.getCallMetadata();e&&"idle"!==this.callStatus&&"ended"!==this.callStatus?localStorage.setItem(this.STORAGE_KEY,JSON.stringify(e)):localStorage.removeItem(this.STORAGE_KEY)}catch(e){console.error("[CallState] Failed to persist state:",e)}}restoreCallState(){if("undefined"!=typeof window&&window.localStorage)try{const e=localStorage.getItem(this.STORAGE_KEY);if(!e)return;const t=JSON.parse(e),n=Date.now();if(n-t.startTime>u)return void localStorage.removeItem(this.STORAGE_KEY);this.currentCall={phoneNumber:t.phoneNumber,startTime:t.startTime,duration:t.duration,direction:"outbound",callbacks:{onAnswered:[],onEnded:[]}},this.callStatus=t.status}catch(e){console.error("[CallState] Failed to restore state:",e),localStorage.removeItem(this.STORAGE_KEY)}}placeCall(e,t){if(!e)throw new Error("Phone number is required");const n=this.formatPhoneNumber(e);this.currentCallId=this.generateCallId(),this.currentView="dial",this.currentCall={phoneNumber:n,startTime:Date.now(),duration:0,direction:"outbound",callbacks:{onAnswered:[],onEnded:[]}},this.callHistorySaved=!1,this.transitionState("dialing"),this.setAttribute("state","expanded"),this.render();const i=this.selectedPhoneNumber?.number||t?.callerId,r=this.selectedPhoneNumber?.assigned_user_name||t?.displayName,a={...t,callerId:i,displayName:r};this.dispatchEvent(new CustomEvent("call-started",{detail:{phoneNumber:n,callerId:i},bubbles:!0})),this.initiateCall(n,a);const o=this;return{phoneNumber:n,get status(){return o.callStatus},get duration(){return o.currentCall?.duration||0},onAnswered(e){o.currentCall?.callbacks.onAnswered.push(e)},onEnded(e){o.currentCall?.callbacks.onEnded.push(e)},end(){o.endCall()}}}open(){this.adjustPositionForPanel(),this.setAttribute("state","expanded"),this.dispatchEvent(new CustomEvent("widget-opened",{bubbles:!0}))}close(){const e=parseInt(this.style.left||"0",10)+324,t=parseInt(this.style.top||"0",10)+694;this.style.left=`${e}px`,this.style.top=`${t}px`,this.fabPosition={x:e,y:t},this.setAttribute("state","collapsed"),this.dispatchEvent(new CustomEvent("widget-closed",{bubbles:!0}))}toggle(){"expanded"===this.getAttribute("state")?this.close():this.open()}setTheme(e){e.theme&&this.setAttribute("theme",e.theme),e.primaryColor&&this.setAttribute("primary-color",e.primaryColor),e.accentColor&&this.setAttribute("accent-color",e.accentColor),e.brandName&&this.setAttribute("brand-name",e.brandName),e.brandLogo&&this.setAttribute("brand-logo",e.brandLogo)}async clearCallHistoryCache(){await this.callHistoryService.clearCache(),await this.loadCallHistory()}mute(e){return"connected"===this.callStatus&&this.sipAdapter?(this.isMuted=this.sipAdapter.mute(e),this.dispatchEvent(new CustomEvent("sip-call-mute",{detail:{muted:this.isMuted},bubbles:!0})),this.render(),this.isMuted):this.isMuted}hold(e){return"connected"===this.callStatus&&this.sipAdapter?(this.isOnHold=void 0!==e?e:!this.isOnHold,this.sipAdapter.hold(this.isOnHold).then(()=>{this.dispatchEvent(new CustomEvent("sip-call-hold",{detail:{onHold:this.isOnHold},bubbles:!0})),this.render()}).catch(e=>{console.error("[Dialer] Hold failed:",e),this.isOnHold=!this.isOnHold}),this.isOnHold):this.isOnHold}startRecording(){if("connected"!==this.callStatus||!this.sipAdapter)throw new Error("No active call");this.sipAdapter.startRecording()}stopRecording(){if("connected"!==this.callStatus||!this.sipAdapter)throw new Error("No active call");this.sipAdapter.stopRecording()}toggleRecording(){"connected"===this.callStatus&&this.sipAdapter&&(this.isRecording=!this.isRecording,this.isRecording?this.sipAdapter.startRecording():this.sipAdapter.stopRecording(),this.dispatchEvent(new CustomEvent("recording-state-change",{detail:{recording:this.isRecording},bubbles:!0})),this.render())}parkCall(e){if("connected"!==this.callStatus||!this.sipAdapter||this.isParking)return void console.warn("[Dialer] Cannot park: no active call or already parking");if(Date.now()-this.callConnectedTime<2e3)return void console.warn("[Dialer] Call too new to park, wait a moment");const t=this.parkAccounts.find(t=>t.extension===e);if(!t)return void console.error("[Dialer] Park slot not found:",e);this.isParking=!0,this.parkingSlot=e;const n=this.currentCall?.phoneNumber||"Unknown",i=this.config.sipUsername||"Unknown";t.occupied=!0,t.parkedCall={phoneNumber:n,parkedBy:i,parkedAt:Date.now()},this.sipAdapter.park(e).then(()=>{this.parkValidationAttempts=0,this.validateParkSuccess(e,n,i,t),this.fetchParkSlots(),this.stopRingbackTone()}).catch(e=>{console.error("[Dialer] Park API failed:",e),t.occupied=!1,t.parkedCall=void 0,this.dispatchEvent(new CustomEvent("call-park-failed",{detail:{error:e.message},bubbles:!0})),this.render(),this.isParking=!1,this.parkingSlot=null})}validateParkSuccess(e,t,n,i){this.parkValidationTimer&&window.clearTimeout(this.parkValidationTimer),this.parkValidationTimer=window.setTimeout(()=>{this.parkValidationAttempts++;const r=this.parkAccounts.find(t=>t.extension===e);if(r?.occupied&&r.parkedCall)return this.dispatchEvent(new CustomEvent("call-parked",{detail:{parkExtension:e,phoneNumber:t,parkedBy:n},bubbles:!0})),this.isParking=!1,this.parkingSlot=null,void(this.parkValidationTimer=null);this.parkValidationAttempts<10?(this.fetchParkSlots(),this.validateParkSuccess(e,t,n,i)):(console.error(`[Dialer] Park validation timeout: slot ${e} never showed occupied`),i.occupied=!1,i.parkedCall=void 0,this.dispatchEvent(new CustomEvent("call-park-failed",{detail:{error:"Park operation timed out - slot did not become occupied"},bubbles:!0})),this.isParking=!1,this.parkingSlot=null,this.parkValidationTimer=null,this.render())},1e3)}confirmRetrieveParkedCall(e,t){this.retrieveModalData={extension:e,phoneNumber:t},this.showRetrieveModal=!0,this.render()}cancelRetrieve(){this.showRetrieveModal=!1,this.retrieveModalData=null,this.render()}confirmRetrieve(){this.retrieveModalData&&(this.showRetrieveModal=!1,this.retrieveParkedCall(this.retrieveModalData.extension),this.retrieveModalData=null)}retrieveParkedCall(e){if(!this.sipAdapter)return void console.error("[Dialer] Cannot retrieve: SIP adapter not initialized");if("idle"!==this.callStatus)return void console.warn("[Dialer] Cannot retrieve while on active call");const t=this.parkAccounts.find(t=>t.extension===e);if(t&&t.parkedCall){this.parkingSlot=e;try{this.placeCall(e),this.switchView("dial"),this.render()}catch(e){console.error("[Dialer] Retrieve failed:",e),this.parkingSlot=null,this.dispatchEvent(new CustomEvent("call-retrieve-failed",{detail:{error:e.message},bubbles:!0}))}}else console.error("[Dialer] Park slot empty or not found:",e)}initiateCall(e,t){if(!this.sipAdapter)return console.error("SIP adapter not initialized"),this.transitionState("error","SIP adapter not initialized"),void(this.currentCall=null);this.sipAdapter.call(e,{callerId:t?.callerId,callerIdName:t?.displayName}).then(()=>{this.dispatchEvent(new CustomEvent("sip-call-initiate",{detail:{phoneNumber:e,options:t},bubbles:!0}))}).catch(e=>{console.error("[Dialer] Failed to initiate call:",e),this.transitionState("error",e.message),this.currentCall=null})}handleCallEnded(e){if(this.stopRingbackTone(),this.callConnectedTime=0,this.showTransferView=!1,this.transferTarget="",this.isTransferring=!1,this.dismissIncomingCallNotification(),this.parkingSlot&&this.isParking){const e=this.parkAccounts.find(e=>e.extension===this.parkingSlot);e&&(e.occupied=!1,e.parkedCall=void 0),this.parkingSlot=null,this.isParking=!1}const t=this.currentCall?.duration||0,n=this.currentCall?.phoneNumber||"",i=this.currentCall?.startTime||Date.now();if(n&&this.currentCallId&&!this.callHistorySaved){const e="connected"===this.callStatus,r=this.currentCall?.direction||"outbound",a=e?"answered":"failed",o=Math.floor(t/1e3);this.callHistoryService.addCall({callId:this.currentCallId,phoneNumber:n,callerIdNumber:n,callerIdName:this.config.sipUsername,direction:r,disposition:a,startedAt:i,endedAt:Date.now(),durationSeconds:o}).then(()=>{this.loadCallHistory()}).catch(e=>{console.error("[CallHistory] Failed to save call:",e)}),this.addToCallHistory({id:this.currentCallId,phoneNumber:n,type:e?"outbound":"missed",status:e?"Outbound":"Not connected",timestamp:Date.now(),duration:e?t:void 0})}this.currentCallId=null,this.callHistorySaved=!1,this.currentCall?.callbacks.onEnded.forEach(e=>e(t)),this.dispatchEvent(new CustomEvent("call-ended",{detail:{phoneNumber:n,duration:t,reason:e},bubbles:!0})),this.durationInterval&&(clearInterval(this.durationInterval),this.durationInterval=null),this.transitionState("ended"),this.isMuted=!1,this.isOnHold=!1,this.dialedDigits="",this.showInCallKeypad=!1,"parked"===e&&"park"===this.currentView&&this.switchView("dial"),setTimeout(()=>{this.transitionState("idle"),this.currentCall=null},1e3)}addToCallHistory(e){this.callHistory.unshift(e),this.callHistory.length>p&&(this.callHistory=this.callHistory.slice(0,p)),this.dispatchEvent(new CustomEvent("history-updated",{detail:{history:this.callHistory},bubbles:!0}))}getFilteredHistory(){switch(this.currentHistoryTab){case"missed":return this.callHistory.filter(e=>"missed"===e.type);case"dialed":return this.callHistory.filter(e=>"outbound"===e.type);default:return this.callHistory}}async switchView(e){this.showTransferView=!1,this.currentView=e,this.selectedHistoryItem=null,"account"===e&&await this.refreshAudioDevicesQuietly(),this.updateMainView()}updateMainView(){const e=this.shadow.querySelector(".dialer-body"),t=this.shadow.querySelectorAll(".nav-btn");if(!e)return;t.forEach(e=>{e.getAttribute("data-view")===this.currentView?e.classList.add("active"):e.classList.remove("active")});let n="";n="idle"!==this.callStatus&&"dial"===this.currentView?this.renderActiveCall():"history"===this.currentView?this.renderHistory():"account"===this.currentView?this.renderAccount():"park"===this.currentView?this.renderPark():this.renderDialpad(),requestAnimationFrame(()=>{e.innerHTML=n,this.updateButtonStates(),this.updatePhoneInput()})}updatePhoneInput(){const e=this.shadow.getElementById("phoneInput");e&&this.phoneInputValue&&(e.value=this.phoneInputValue)}switchHistoryTab(e){this.currentHistoryTab=e,this.selectedHistoryItem=null,this.updateHistoryView()}updateHistoryView(){const e=this.shadow.querySelector(".history-list"),t=this.shadow.querySelectorAll(".tab-btn");if(!e)return;t.forEach(e=>{e.getAttribute("data-tab")===this.currentHistoryTab?e.classList.add("active"):e.classList.remove("active")});const n=this.getFilteredHistory(),i=0===n.length?this.renderEmptyHistory():n.map(e=>this.renderHistoryItem(e)).join("");requestAnimationFrame(()=>{e.innerHTML=i})}startDurationTimer(){this.durationInterval&&(clearInterval(this.durationInterval),this.durationInterval=null),this.durationInterval=window.setInterval(()=>{this.currentCall&&"connected"===this.callStatus?(this.currentCall.duration=Date.now()-this.currentCall.startTime,this.render()):this.durationInterval&&(clearInterval(this.durationInterval),this.durationInterval=null)},1e3)}handleIncomingCall(e,t){if("idle"!==this.callStatus)return console.warn("[Dialer] Incoming call rejected - already in call"),void this.sipAdapter?.rejectCall();this.incomingCallNumber=e,this.incomingCallName=t||null,this.open(),this.render(),this.showIncomingCallNotification(e,t),this.dispatchEvent(new CustomEvent("incoming-call",{detail:{phoneNumber:e,callerName:t},bubbles:!0}))}answerIncomingCall(){if(!this.incomingCallNumber||!this.sipAdapter)return;const e=this.incomingCallNumber;this.incomingCallNumber=null,this.incomingCallName=null,this.currentCallId=this.generateCallId(),this.currentCall={phoneNumber:e,startTime:Date.now(),duration:0,direction:"inbound",callbacks:{onAnswered:[],onEnded:[]}},this.transitionState("dialing"),this.sipAdapter.answerCall().then(()=>{this.dispatchEvent(new CustomEvent("call-started",{detail:{phoneNumber:e,direction:"inbound"},bubbles:!0}))}).catch(e=>{console.error("[Dialer] Failed to answer call:",e),this.transitionState("error",e.message),this.currentCall=null})}rejectIncomingCall(){if(!this.incomingCallNumber||!this.sipAdapter)return;const e=this.incomingCallNumber,t=this.generateCallId();this.incomingCallNumber=null,this.incomingCallName=null,this.dismissIncomingCallNotification(),this.sipAdapter.rejectCall().catch(e=>{console.error("[Dialer] Failed to reject call:",e)}),this.callHistoryService.addCall({callId:t,phoneNumber:e,callerIdNumber:e,callerIdName:void 0,direction:"inbound",disposition:"rejected",startedAt:Date.now(),durationSeconds:0}).then(()=>{this.loadCallHistory()}).catch(e=>{console.error("[CallHistory] Failed to save rejected call:",e)}),this.addToCallHistory({id:t,phoneNumber:e,type:"missed",status:"Missed",timestamp:Date.now()}),this.dispatchEvent(new CustomEvent("call-rejected",{detail:{phoneNumber:e},bubbles:!0})),this.render()}toggleInCallKeypad(){this.showInCallKeypad=!this.showInCallKeypad,this.showInCallKeypad||(this.dialedDigits=""),this.render()}notifyCallAnswered(){"dialing"!==this.callStatus&&"ringing"!==this.callStatus||(this.dismissIncomingCallNotification(),this.stopRingbackTone(),this.callConnectedTime=Date.now(),this.currentCall&&"outbound"===this.currentCall.direction&&(this.currentCall.startTime=this.callConnectedTime,this.currentCall.duration=0),this.transitionState("connected"),this.startDurationTimer(),this.currentCall?.callbacks.onAnswered.forEach(e=>e()),this.dispatchEvent(new CustomEvent("call-answered",{detail:{phoneNumber:this.currentCall?.phoneNumber},bubbles:!0})))}notifyCallRinging(){"dialing"===this.callStatus&&(this.playRingbackTone(),this.transitionState("ringing"))}playRingbackTone(){this.ringbackTone&&(this.ringbackTone.currentTime=0,this.ringbackTone.play().catch(e=>{console.warn("[Dialer] Failed to play ringback tone:",e)}))}stopRingbackTone(){this.ringbackTone&&(this.ringbackTone.pause(),this.ringbackTone.currentTime=0)}playDialTone(e,t){if(!this.dialTone)return;this.sharedAudioContext&&"closed"!==this.sharedAudioContext.state||(this.sharedAudioContext=new(window.AudioContext||window.webkitAudioContext));const n=this.sharedAudioContext,i=n.createBuffer(1,.1*n.sampleRate,n.sampleRate),r=i.getChannelData(0);for(let a=0;a<i.length;a++){const i=a/n.sampleRate;r[a]=.3*(Math.sin(2*Math.PI*e*i)+Math.sin(2*Math.PI*t*i))}const a=this.bufferToWave(i),o=new Blob([a],{type:"audio/wav"});this.dialToneBlobUrl&&URL.revokeObjectURL(this.dialToneBlobUrl),this.dialToneBlobUrl=URL.createObjectURL(o),this.dialTone.src=this.dialToneBlobUrl,this.dialTone.play().catch(e=>{console.warn("[Dialer] Failed to play dial tone:",e)})}playDTMFTone(e){const t={1:[697,1209],2:[697,1336],3:[697,1477],4:[770,1209],5:[770,1336],6:[770,1477],7:[852,1209],8:[852,1336],9:[852,1477],"*":[941,1209],0:[941,1336],"#":[941,1477]}[e];t&&this.playDialTone(t[0],t[1])}endCall(){"idle"!==this.callStatus&&(this.stopRingbackTone(),this.sipAdapter&&this.sipAdapter.endCall().catch(e=>{console.error("[Dialer] Error ending call:",e)}),this.dispatchEvent(new CustomEvent("sip-call-terminate",{bubbles:!0})),this.handleCallEnded("user-terminated"))}sendDTMF(e){if("connected"===this.callStatus&&this.sipAdapter)try{this.sipAdapter.sendDTMF(e),this.dispatchEvent(new CustomEvent("dtmf-sent",{detail:{digit:e},bubbles:!0}))}catch(e){console.error("[Dialer] DTMF failed:",e)}}formatPhoneNumber(e){const t=e.trim();if(/[a-zA-Z]/.test(t))return t;const n=t.replace(/\D/g,"");if(/^(7[0][0-9]|71[0-9]|720)$/.test(n))return n;const i=this.selectedCountry.dialCode.replace(/\+/,"");return n.startsWith(i)?`+${n}`:`${this.selectedCountry.dialCode}${n}`}formatPhoneNumberDisplay(e){const t=e.replace(/\D/g,"");if(11===t.length&&t.startsWith("1"))return`+1 (${t.slice(1,4)}) ${t.slice(4,7)} ${t.slice(7)}`;if(10===t.length)return`+1 (${t.slice(0,3)}) ${t.slice(3,6)} ${t.slice(6)}`;if(t.length>10){const e=t.slice(0,t.length-10),n=t.slice(-10);return`+${e} (${n.slice(0,3)}) ${n.slice(3,6)} ${n.slice(6)}`}return e}formatPhoneInputDisplay(e){const t=e.replace(/\D/g,"");return t?t.length<=3?`(${t}`:t.length<=6?`(${t.slice(0,3)}) ${t.slice(3)}`:t.length<=10?`(${t.slice(0,3)}) ${t.slice(3,6)}-${t.slice(6,10)}`:t:""}formatDuration(e){const t=Math.max(0,Math.floor(e/1e3)),n=Math.floor(t/3600),i=Math.floor(t%3600/60),r=t%60;return`${n.toString().padStart(2,"0")}:${i.toString().padStart(2,"0")}:${r.toString().padStart(2,"0")}`}formatCallTime(e){const t=new Date,n=new Date(t.getFullYear(),t.getMonth(),t.getDate()),i=new Date(e.getFullYear(),e.getMonth(),e.getDate()),r=Math.floor((n.getTime()-i.getTime())/864e5);return 0===r?e.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0}):r>0&&r<=6?e.toLocaleDateString("en-US",{weekday:"short"}):e.toLocaleDateString("en-US",{month:"short",day:"numeric"})}render(){this.renderScheduled||(this.renderScheduled=!0,requestAnimationFrame(()=>{this.renderScheduled=!1,this.performRender()}))}needsFullRender(e){if(!this.shadow.querySelector(".dialer-panel, .dialer-fab"))return!0;const t="collapsed"===e,n=!!this.shadow.querySelector(".dialer-panel"),i=!!this.shadow.querySelector(".dialer-fab");return!((!t||i)&&(t||n))||!(!this.incomingCallNumber&&!this.showRetrieveModal)}performRender(){const e=this.shadow.getElementById("phoneInput");e&&(this.phoneInputValue=e.value);const t=this.getAttribute("state")||"collapsed";if(this.needsFullRender(t)){this.shadow.innerHTML=`\n <style>\n:host {\n --primary-color: #ff6b35;\n --accent-color: #22c55e;\n --danger-color: #ef4444;\n\n /* Dark theme */\n --bg-primary-dark: #1a1a1a;\n --bg-secondary-dark: #2d2d2d;\n --text-primary-dark: #ffffff;\n --text-secondary-dark: #9ca3af;\n --border-dark: #3d3d3d;\n\n /* Light theme */\n --bg-primary-light: #ffffff;\n --bg-secondary-light: #f9fafb;\n --text-primary-light: #1f2937;\n --text-secondary-light: #6b7280;\n --border-light: #e5e7eb;\n\n position: fixed;\n z-index: 9999;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n}\n\n:host([position="top-left"]) { top: 24px; left: 24px; }\n:host([position="top-right"]) { top: 24px; right: 24px; }\n:host([position="bottom-left"]) { bottom: 24px; left: 24px; }\n:host([position="bottom-right"]) { bottom: 24px; right: 24px; }\n\n/* Dark theme (default) */\n:host([theme="dark"]) {\n --bg-primary: var(--bg-primary-dark);\n --bg-secondary: var(--bg-secondary-dark);\n --text-primary: var(--text-primary-dark);\n --text-secondary: var(--text-secondary-dark);\n --border-color: var(--border-dark);\n}\n\n/* Light theme */\n:host([theme="light"]) {\n --bg-primary: var(--bg-primary-light);\n --bg-secondary: var(--bg-secondary-light);\n --text-primary: var(--text-primary-light);\n --text-secondary: var(--text-secondary-light);\n --border-color: var(--border-light);\n}\n\n/* Default to dark if no theme set */\n:host {\n --bg-primary: var(--bg-primary-dark);\n --bg-secondary: var(--bg-secondary-dark);\n --text-primary: var(--text-primary-dark);\n --text-secondary: var(--text-secondary-dark);\n --border-color: var(--border-dark);\n}\n\n.dialer-fab {\n width: 56px;\n height: 56px;\n border-radius: 50%;\n background: var(--primary-color);\n border: none;\n color: white;\n cursor: grab;\n display: flex;\n align-items: center;\n justify-content: center;\n box-shadow: 0 10px 25px rgba(0,0,0,0.3);\n transition: all 0.3s ease;\n position: relative;\n user-select: none;\n -webkit-user-select: none;\n touch-action: none;\n}\n\n.dialer-fab:active {\n cursor: grabbing;\n}\n\n.dialer-fab:hover {\n transform: scale(1.05);\n box-shadow: 0 12px 30px rgba(0,0,0,0.4);\n}\n\n.call-indicator {\n position: absolute;\n top: 4px;\n right: 4px;\n width: 12px;\n height: 12px;\n background: var(--accent-color);\n border-radius: 50%;\n border: 2px solid white;\n animation: pulse 2s infinite;\n}\n\n@keyframes pulse {\n 0%, 100% { opacity: 1; }\n 50% { opacity: 0.5; }\n}\n\n.dialer-panel {\n width: 380px;\n height: 750px;\n background: var(--bg-primary);\n border-radius: 12px;\n box-shadow: 0 20px 60px rgba(0,0,0,0.4);\n overflow: hidden;\n display: flex;\n flex-direction: column;\n}\n\n:host([state="expanded"]) .dialer-panel {\n display: flex;\n animation: slideUp 0.3s ease;\n}\n\n:host([state="expanded"]) .dialer-fab {\n display: none;\n}\n\n@keyframes slideUp {\n from { opacity: 0; transform: translateY(20px); }\n to { opacity: 1; transform: translateY(0); }\n}\n\n.dialer-header {\n padding: 12px 16px;\n background: var(--primary-color);\n color: white;\n display: flex;\n justify-content: space-between;\n align-items: center;\n cursor: move;\n cursor: grab;\n user-select: none;\n -webkit-user-select: none;\n}\n\n.dialer-header:active {\n cursor: grabbing;\n}\n\n.header-brand {\n display: flex;\n align-items: center;\n gap: 10px;\n font-weight: 600;\n font-size: 15px;\n letter-spacing: 0.3px;\n}\n\n.brand-logo {\n max-height: 28px;\n max-width: 120px;\n object-fit: contain;\n}\n\n.header-controls {\n display: flex;\n gap: 8px;\n}\n\n.header-btn {\n width: 24px;\n height: 24px;\n background: rgba(255,255,255,0.2);\n border: none;\n border-radius: 4px;\n color: white;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n font-size: 16px;\n line-height: 1;\n}\n\n.header-btn:hover {\n background: rgba(255,255,255,0.3);\n}\n\n.dialer-body {\n padding: 24px 20px 0;\n background: var(--bg-primary);\n flex: 1;\n overflow-y: auto;\n overflow-x: hidden;\n display: flex;\n flex-direction: column;\n justify-content: space-between;\n min-height: 0;\n contain: layout style;\n will-change: contents;\n transition: opacity 0.15s ease;\n backface-visibility: hidden;\n transform: translateZ(0);\n}\n\n.brand-section {\n text-align: center;\n padding: 16px 0 8px;\n display: flex;\n justify-content: center;\n}\n\n.brand-icon {\n width: 40px;\n height: 40px;\n display: flex;\n align-items: center;\n justify-content: center;\n background: var(--bg-secondary);\n border-radius: 10px;\n border: 1px solid var(--border-color);\n}\n\n.brand-icon img {\n width: 100%;\n height: 100%;\n object-fit: contain;\n border-radius: 8px;\n}\n\n.brand-icon svg {\n width: 24px;\n height: 24px;\n color: var(--primary-color);\n}\n\n.brand-name {\n display: none;\n}\n\n.input-section {\n display: flex;\n align-items: center;\n gap: 10px;\n margin-top: 12px;\n margin-bottom: 20px;\n padding: 0 4px;\n backface-visibility: hidden;\n transform: translateZ(0);\n}\n\n.country-selector {\n position: relative;\n z-index: 100;\n}\n\n.country-btn {\n background: var(--bg-secondary);\n border: 1px solid var(--border-color);\n border-radius: 6px;\n padding: 6px 8px;\n color: var(--text-primary);\n cursor: pointer;\n display: flex;\n align-items: center;\n gap: 4px;\n font-size: 13px;\n transition: all 0.2s;\n}\n\n.country-btn:hover {\n background: var(--border-color);\n}\n\n.country-flag {\n font-size: 16px;\n line-height: 1;\n}\n\n.country-code {\n font-size: 13px;\n font-weight: 500;\n}\n\n.dropdown-icon {\n opacity: 0.6;\n transition: transform 0.2s;\n}\n\n.country-dropdown-backdrop {\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background: transparent;\n z-index: 9999;\n pointer-events: auto;\n}\n\n.country-dropdown {\n position: absolute;\n background: #1a1a1a;\n border: 1px solid #444;\n border-radius: 8px;\n box-shadow: 0 6px 16px rgba(0,0,0,0.6);\n max-height: 120px;\n overflow-y: scroll;\n overflow-x: hidden;\n -webkit-overflow-scrolling: touch;\n z-index: 10000;\n width: 200px;\n pointer-events: auto;\n}\n\n.country-dropdown::-webkit-scrollbar {\n width: 6px;\n}\n\n.country-dropdown::-webkit-scrollbar-track {\n background: rgba(255,255,255,0.05);\n border-radius: 3px;\n margin: 4px 0;\n}\n\n.country-dropdown::-webkit-scrollbar-thumb {\n background: rgba(255,255,255,0.4);\n border-radius: 3px;\n}\n\n.country-dropdown::-webkit-scrollbar-thumb:hover {\n background: rgba(255,255,255,0.5);\n}\n\n.country-option {\n width: 100%;\n background: transparent;\n border: none;\n padding: 9px 12px;\n color: var(--text-primary);\n cursor: pointer;\n display: flex;\n align-items: center;\n gap: 10px;\n font-size: 13px;\n transition: background 0.12s;\n text-align: left;\n white-space: nowrap;\n}\n\n.country-option:hover {\n background: rgba(255,255,255,0.12);\n}\n\n.country-option .country-flag {\n font-size: 18px;\n}\n\n.country-option .country-name {\n flex: 1;\n font-weight: 500;\n}\n\n.country-option .country-code {\n opacity: 0.7;\n font-size: 12px;\n font-weight: 500;\n}\n\n.phone-input-wrapper {\n flex: 1;\n position: relative;\n}\n\n.phone-input {\n width: 100%;\n min-width: 150px;\n background: transparent;\n background-color: transparent;\n border: none;\n color: var(--text-primary);\n font-size: 22px;\n font-weight: 300;\n text-align: center;\n outline: none;\n letter-spacing: 1px;\n -webkit-appearance: none;\n appearance: none;\n}\n\n.phone-input::placeholder {\n color: var(--text-secondary);\n opacity: 0.5;\n}\n\n.toggle-btn {\n background: var(--bg-secondary);\n border: 1px solid var(--border-color);\n border-radius: 6px;\n padding: 8px 10px;\n color: var(--text-secondary);\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n}\n\n.toggle-btn:hover {\n background: var(--bg-primary);\n}\n\n.toggle-btn:disabled {\n opacity: 0.3;\n cursor: not-allowed;\n}\n\n.dialpad {\n display: grid;\n grid-template-columns: repeat(3, 1fr);\n gap: 20px;\n margin-bottom: 12px;\n margin-top: 0;\n padding: 0 16px 12px;\n backface-visibility: hidden;\n transform: translateZ(0);\n position: relative;\n z-index: 0;\n animation: fadeIn 0.2s ease;\n}\n\n.dialpad-btn {\n aspect-ratio: 1;\n background: transparent;\n border: none;\n color: var(--text-primary);\n border-radius: 50%;\n font-size: 24px;\n font-weight: 300;\n cursor: pointer;\n transition: all 0.2s;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n gap: 0;\n position: relative;\n min-height: 50px;\n max-height: 70px;\n}\n\n.dialpad-btn:hover {\n background: var(--bg-secondary);\n}\n\n.dialpad-btn:active {\n transform: scale(0.95);\n}\n\n.dialpad-number {\n font-size: 24px;\n line-height: 1;\n font-weight: 300;\n}\n\n.dialpad-letters {\n font-size: 8px;\n color: var(--text-secondary);\n letter-spacing: 1.2px;\n text-transform: uppercase;\n margin-top: 2px;\n}\n\n.call-btn-wrapper {\n display: flex;\n justify-content: center;\n padding: 8px 0 12px;\n}\n\n.call-btn {\n width: 56px;\n height: 56px;\n border-radius: 50%;\n background: var(--accent-color);\n border: none;\n color: white;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n box-shadow: 0 4px 12px rgba(34, 197, 94, 0.3);\n transition: all 0.2s;\n}\n\n.call-btn:hover {\n background: #16a34a;\n transform: scale(1.05);\n}\n\n.call-btn:active {\n transform: scale(0.95);\n}\n\n.call-btn:disabled {\n background: var(--text-secondary);\n opacity: 0.5;\n cursor: not-allowed;\n transform: none;\n}\n\n.active-call {\n padding: 0;\n text-align: center;\n display: flex;\n flex-direction: column;\n height: 100%;\n justify-content: space-around;\n animation: fadeIn 0.2s ease;\n}\n\n@keyframes fadeIn {\n from { opacity: 0; }\n to { opacity: 1; }\n}\n\n.call-info {\n padding: 40px 20px 20px;\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 12px;\n}\n\n.active-call.compact .call-info {\n padding: 20px 16px 12px;\n gap: 8px;\n}\n\n.keypad-header {\n padding: 10px 16px;\n text-align: center;\n border-bottom: 1px solid rgba(255, 255, 255, 0.06);\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 8px;\n font-size: 14px;\n color: var(--text-secondary);\n}\n\n.keypad-header-number {\n font-weight: 500;\n color: var(--text-primary);\n}\n\n.keypad-header-sep {\n opacity: 0.4;\n font-size: 12px;\n}\n\n.keypad-header-duration {\n font-weight: 400;\n}\n\n.dialed-digits {\n font-size: 18px;\n font-weight: 500;\n color: var(--text-primary);\n letter-spacing: 3px;\n font-variant-numeric: tabular-nums;\n}\n\n.call-number {\n font-size: 32px;\n font-weight: 400;\n color: var(--text-primary);\n letter-spacing: 1px;\n order: 1;\n}\n\n.active-call.compact .call-number {\n font-size: 24px;\n}\n\n.call-duration {\n font-size: 16px;\n color: var(--text-primary);\n font-weight: 300;\n display: flex;\n align-items: center;\n gap: 8px;\n order: 2;\n}\n\n.duration-indicator {\n width: 8px;\n height: 8px;\n background: var(--accent-color);\n border-radius: 50%;\n display: inline-block;\n animation: pulse 2s infinite;\n}\n\n.call-status {\n font-size: 13px;\n color: var(--text-secondary);\n text-transform: capitalize;\n order: 3;\n}\n\n.call-controls {\n display: flex;\n flex-direction: column;\n gap: 20px;\n padding: 40px 20px 20px;\n}\n\n.active-call.compact .call-controls {\n padding: 16px;\n gap: 0;\n}\n\n.compact-controls {\n display: grid;\n grid-template-columns: 1fr auto 1fr;\n align-items: center;\n gap: 16px;\n padding: 16px;\n}\n\n.compact-controls-icons {\n display: flex;\n gap: 8px;\n}\n\n.compact-controls-icons:first-child {\n justify-content: flex-end;\n}\n\n.compact-controls-icons:last-child {\n justify-content: flex-start;\n}\n\n.compact-icon-btn {\n width: 40px;\n height: 40px;\n border-radius: 50%;\n border: none;\n background: rgba(255, 255, 255, 0.08);\n color: var(--text-primary);\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: all 0.2s;\n}\n\n.compact-icon-btn:hover {\n background: rgba(255, 255, 255, 0.12);\n transform: scale(1.05);\n}\n\n.compact-icon-btn.active {\n background: var(--primary-color);\n color: white;\n}\n\n.compact-icon-btn:disabled {\n opacity: 0.3;\n cursor: not-allowed;\n}\n\n.compact-end-btn {\n width: 56px;\n height: 56px;\n border-radius: 50%;\n border: none;\n background: #ef4444; /* Always red for destructive action */\n color: white;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: all 0.2s;\n flex-shrink: 0;\n}\n\n.compact-end-btn:hover {\n transform: scale(1.05);\n box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);\n}\n\n.controls-row {\n display: grid;\n grid-template-columns: repeat(3, 1fr);\n gap: 16px;\n align-items: center;\n}\n\n.controls-row-end {\n display: flex;\n justify-content: center;\n align-items: center;\n gap: 24px;\n margin-top: 16px;\n padding: 0 20px;\n}\n\n.control-btn {\n width: 60px;\n height: 60px;\n border-radius: 50%;\n border: none;\n background: var(--bg-secondary);\n color: var(--text-primary);\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: all 0.2s;\n justify-self: center;\n pointer-events: auto;\n position: relative;\n z-index: 10;\n}\n\n.active-call.compact .control-btn {\n width: 50px;\n height: 50px;\n}\n\n.control-btn:hover {\n background: var(--border-color);\n transform: scale(1.05);\n}\n\n.control-btn.active {\n background: var(--primary-color);\n color: white;\n}\n\n.control-btn:disabled {\n opacity: 0.3;\n cursor: not-allowed;\n transform: none;\n pointer-events: none;\n}\n\n.btn-label {\n display: none;\n}\n\n.end-btn {\n width: 68px;\n height: 68px;\n background: var(--danger-color);\n color: white;\n border-radius: 50%;\n border: none;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: all 0.2s;\n justify-self: center;\n}\n\n.end-btn:hover {\n background: #dc2626;\n transform: scale(1.05);\n}\n\n.end-btn:disabled {\n opacity: 0.3;\n cursor: not-allowed;\n transform: none;\n}\n\n.branding {\n padding: 10px;\n text-align: center;\n font-size: 10px;\n color: var(--text-secondary);\n border-top: 1px solid var(--border-color);\n background: var(--bg-primary);\n flex-shrink: 0;\n}\n\n/* Tabs Navigation */\n.tabs-nav {\n display: flex;\n background: var(--bg-secondary);\n border-bottom: 1px solid var(--border-color);\n // margin: 0 0 16px 0;\n flex-shrink: 0;\n}\n\n.tab-btn {\n flex: 1;\n padding: 12px 8px;\n background: transparent;\n border: none;\n border-bottom: 2px solid transparent;\n color: var(--text-secondary);\n font-size: 12px;\n font-weight: 500;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 4px;\n transition: all 0.2s;\n}\n\n.tab-btn:hover {\n background: rgba(255,255,255,0.05);\n}\n\n.tab-btn.active {\n color: var(--primary-color);\n border-bottom-color: var(--primary-color);\n}\n\n.tab-btn svg {\n width: 14px;\n height: 14px;\n}\n\n/* History View */\n.history-view {\n display: flex;\n flex-direction: column;\n flex: 1;\n min-height: 0;\n animation: fadeIn 0.2s ease;\n overflow: hidden;\n margin: -24px -20px 0;\n position: relative;\n}\n\n/* History List */\n.history-list {\n flex: 1;\n overflow-y: auto;\n overflow-x: hidden;\n margin: 0 -20px;\n position: relative;\n}\n\n.history-list.updating {\n opacity: 1;\n}\n\n.history-item {\n display: flex;\n align-items: center;\n gap: 12px;\n padding: 12px 32px;\n border-bottom: 1px solid var(--border-color);\n cursor: pointer;\n transition: background 0.15s ease;\n backface-visibility: hidden;\n transform: translateZ(0);\n}\n\n.history-item:hover {\n background: var(--bg-secondary);\n}\n\n.history-item.selected {\n background: var(--bg-secondary);\n border-left: 3px solid var(--primary-color);\n}\n\n.history-icon {\n width: 40px;\n height: 40px;\n border-radius: 50%;\n background: var(--bg-secondary);\n display: flex;\n align-items: center;\n justify-content: center;\n color: var(--text-secondary);\n flex-shrink: 0;\n}\n\n.history-icon.missed {\n color: var(--danger-color);\n}\n\n.history-icon.outbound {\n color: var(--primary-color);\n}\n\n.history-info {\n flex: 1;\n min-width: 0;\n}\n\n.history-number {\n font-size: 14px;\n font-weight: 500;\n color: var(--text-primary);\n margin-bottom: 2px;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n.history-status {\n font-size: 12px;\n color: var(--text-secondary);\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n.history-status.outbound {\n color: var(--primary-color);\n}\n\n.history-time {\n font-size: 12px;\n color: var(--text-secondary);\n text-align: right;\n flex-shrink: 0;\n white-space: nowrap;\n margin-left: 8px;\n}\n\n.history-duration {\n font-size: 11px;\n color: var(--text-secondary);\n display: block;\n margin-top: 2px;\n}\n\n.call-back-container {\n position: sticky;\n bottom: 0;\n z-index: 10;\n}\n\n.call-back-btn {\n width: 100%;\n padding: 16px 20px;\n background: var(--primary-color);\n color: white;\n border: none;\n border-radius: 0;\n font-size: 16px;\n font-weight: 600;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 10px;\n transition: opacity 0.2s ease;\n}\n\n.call-back-btn:hover {\n opacity: 0.95;\n}\n\n.call-back-btn:active {\n opacity: 0.85;\n}\n\n.empty-state {\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n padding: 60px 20px;\n text-align: center;\n color: var(--text-secondary);\n height: 100%;\n backface-visibility: hidden;\n transform: translateZ(0);\n}\n\n.empty-state svg {\n width: 48px;\n height: 48px;\n margin-bottom: 16px;\n opacity: 0.5;\n}\n\n.empty-state-text {\n font-size: 14px;\n}\n\n/* Bottom Navigation */\n.bottom-nav {\n display: flex;\n background: var(--bg-primary);\n border-top: 1px solid var(--border-color);\n flex-shrink: 0;\n}\n\n.nav-btn {\n flex: 1;\n padding: 12px 8px 10px;\n background: transparent;\n border: none;\n color: var(--text-secondary);\n cursor: pointer;\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 4px;\n font-size: 11px;\n font-weight: 500;\n transition: all 0.2s;\n}\n\n.nav-btn:hover {\n background: var(--bg-primary);\n}\n\n.nav-btn.active {\n color: var(--primary-color);\n}\n\n.nav-btn svg {\n width: 24px;\n height: 24px;\n}\n\n.dialer-footer {\n padding: 6px 16px 4px;\n text-align: center;\n background: var(--bg-primary);\n flex-shrink: 0;\n}\n\n.footer-link {\n color: var(--text-secondary);\n font-size: 10px;\n text-decoration: none;\n opacity: 0.6;\n transition: opacity 0.2s;\n line-height: 1;\n}\n\n.footer-link:hover {\n opacity: 0.9;\n text-decoration: underline;\n}\n\n@media (max-width: 420px) {\n .dialer-panel { width: calc(100vw - 48px); }\n}\n\n/* Incoming Call Modal - Compact Toast Style */\n.incoming-call-overlay {\n position: fixed;\n top: 20px;\n right: 20px;\n z-index: 10000;\n pointer-events: none;\n animation: slideInRight 0.3s cubic-bezier(0.4, 0, 0.2, 1);\n}\n\n.incoming-call-modal {\n background: var(--bg-primary);\n border-radius: 20px;\n padding: 24px;\n box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.1);\n width: 320px;\n pointer-events: auto;\n backdrop-filter: blur(20px);\n -webkit-backdrop-filter: blur(20px);\n border: 1px solid rgba(255, 255, 255, 0.08);\n}\n\n.incoming-call-info {\n text-align: center;\n margin-bottom: 20px;\n}\n\n.incoming-call-label {\n font-size: 11px;\n color: var(--text-secondary);\n text-transform: uppercase;\n letter-spacing: 1.2px;\n font-weight: 600;\n margin-bottom: 8px;\n opacity: 0.8;\n}\n\n.incoming-call-name {\n font-size: 16px;\n font-weight: 700;\n color: var(--text-primary);\n margin-bottom: 4px;\n letter-spacing: -0.2px;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n\n.incoming-call-number {\n font-size: 20px;\n font-weight: 600;\n color: var(--text-primary);\n letter-spacing: -0.3px;\n line-height: 1.3;\n}\n\n.incoming-call-actions {\n display: flex;\n gap: 12px;\n justify-content: center;\n}\n\n.incoming-call-btn {\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 6px;\n padding: 0;\n border: none;\n background: none;\n cursor: pointer;\n transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);\n position: relative;\n flex: 1;\n}\n\n.incoming-call-btn::before {\n content: '';\n width: 52px;\n height: 52px;\n border-radius: 50%;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);\n}\n\n.incoming-call-btn svg {\n position: absolute;\n top: 12px;\n left: 50%;\n transform: translateX(-50%);\n width: 28px;\n height: 28px;\n pointer-events: none;\n}\n\n.incoming-call-btn span {\n font-size: 13px;\n font-weight: 600;\n color: var(--text-primary);\n margin-top: 52px;\n}\n\n.answer-btn::before {\n background: var(--accent-color);\n box-shadow: 0 6px 20px rgba(34, 197, 94, 0.4);\n}\n\n.answer-btn svg {\n color: white;\n}\n\n.answer-btn:hover::before {\n background: #1ea94f;\n transform: scale(1.08);\n box-shadow: 0 8px 24px rgba(34, 197, 94, 0.5);\n}\n\n.answer-btn:active::before {\n transform: scale(1.02);\n}\n\n.reject-btn::before {\n background: var(--danger-color);\n box-shadow: 0 6px 20px rgba(239, 68, 68, 0.4);\n}\n\n.reject-btn svg {\n color: white;\n}\n\n.reject-btn:hover::before {\n background: #dc2626;\n transform: scale(1.08);\n box-shadow: 0 8px 24px rgba(239, 68, 68, 0.5);\n}\n\n.reject-btn:active::before {\n transform: scale(1.02);\n}\n\n@keyframes slideInRight {\n 0% {\n opacity: 0;\n transform: translateX(100px);\n }\n 100% {\n opacity: 1;\n transform: translateX(0);\n }\n}\n\n@media (max-width: 420px) {\n .incoming-call-overlay {\n top: 16px;\n right: 16px;\n left: 16px;\n }\n .incoming-call-modal {\n width: auto;\n }\n}\n\n/* In-Call Keypad Overlay */\n.incall-keypad-overlay {\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background: rgba(0, 0, 0, 0.7);\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: 10001;\n animation: fadeIn 0.2s ease-out;\n}\n\n.incall-keypad-modal {\n background: var(--bg-primary);\n border-radius: 20px;\n width: 360px;\n max-width: calc(100vw - 48px);\n box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);\n animation: slideUp 0.3s ease-out;\n}\n\n.incall-keypad-header {\n display: flex;\n justify-content: space-between;\n align-items: center;\n padding: 20px 24px;\n border-bottom: 1px solid var(--border-color);\n}\n\n.incall-keypad-header h3 {\n margin: 0;\n font-size: 18px;\n font-weight: 600;\n color: var(--text-primary);\n}\n\n.incall-dialpad {\n display: grid;\n grid-template-columns: repeat(3, 1fr);\n gap: 12px;\n padding: 24px;\n}\n\n/* Inline keypad in active call */\n.incall-keypad {\n display: grid;\n grid-template-columns: repeat(3, 1fr);\n gap: 10px;\n padding: 12px 16px 16px;\n margin-top: 0;\n}\n\n.incall-keypad .dialpad-btn {\n min-height: 56px;\n font-size: 20px;\n background: transparent;\n transition: all 0.15s;\n}\n\n.incall-keypad .dialpad-btn:hover {\n background: rgba(255, 255, 255, 0.08);\n transform: scale(1.02);\n}\n\n.incall-keypad .dialpad-btn:active {\n transform: scale(0.96);\n background: rgba(255, 255, 255, 0.12);\n}\n\n.incall-keypad .dialpad-number {\n font-size: 24px;\n font-weight: 300;\n}\n\n.incall-keypad .dialpad-letters {\n font-size: 10px;\n opacity: 0.6;\n letter-spacing: 1px;\n}\n\n@keyframes fadeIn {\n from {\n opacity: 0;\n }\n to {\n opacity: 1;\n }\n}\n\n@keyframes slideUp {\n from {\n transform: translateY(20px);\n opacity: 0;\n }\n to {\n transform: translateY(0);\n opacity: 1;\n }\n}\n\n/* Account View */\n.account-view {\n overflow-y: auto;\n overflow-x: hidden;\n flex: 1;\n backface-visibility: hidden;\n transform: translateZ(0);\n padding-bottom: 16px;\n}\n\n.account-section {\n margin-bottom: 20px;\n padding-bottom: 20px;\n border-bottom: 1px solid var(--border-color);\n overflow: hidden;\n}\n\n.account-section:last-child {\n border-bottom: none;\n margin-bottom: 0;\n padding-bottom: 0;\n}\n\n.account-section-title {\n font-size: 14px;\n font-weight: 600;\n color: var(--text-primary);\n margin: 0 0 16px 0;\n text-transform: uppercase;\n letter-spacing: 0.5px;\n}\n\n.device-selector {\n display: grid;\n grid-template-columns: minmax(90px, auto) auto minmax(0, 1fr);\n align-items: center;\n gap: 8px;\n margin-bottom: 16px;\n width: 100%;\n}\n\n.device-selector:last-child {\n margin-bottom: 0;\n}\n\n.device-label {\n display: flex;\n align-items: center;\n gap: 6px;\n font-size: 12px;\n font-weight: 500;\n color: var(--text-primary);\n white-space: nowrap;\n}\n\n.device-label svg {\n color: var(--text-secondary);\n}\n\n.device-select {\n grid-column: 3;\n padding: 8px 10px;\n border: 1px solid var(--border-color);\n border-radius: 6px;\n background: var(--bg-secondary);\n color: var(--text-primary);\n font-size: 12px;\n cursor: pointer;\n transition: border-color 0.2s;\n width: 100%;\n min-width: 0;\n max-height: 150px;\n overflow-y: auto;\n}\n\n.device-select:hover {\n border-color: var(--primary-color);\n}\n\n.device-select:focus {\n outline: none;\n border-color: var(--primary-color);\n box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.1);\n}\n\n.device-select option {\n padding: 8px;\n font-size: 12px;\n background: var(--bg-secondary);\n color: var(--text-primary);\n}\n\n.device-select-btn {\n padding: 6px;\n border: 1px solid var(--border-color);\n border-radius: 6px;\n background: var(--bg-secondary);\n color: var(--text-secondary);\n cursor: pointer;\n transition: all 0.2s;\n display: flex;\n align-items: center;\n justify-content: center;\n width: 32px;\n height: 32px;\n flex-shrink: 0;\n}\n\n.device-select-btn:hover {\n background: var(--bg-primary);\n color: var(--primary-color);\n border-color: var(--primary-color);\n}\n\n.account-info {\n display: flex;\n flex-direction: column;\n gap: 12px;\n}\n\n.account-info-row {\n display: flex;\n justify-content: space-between;\n align-items: center;\n padding: 12px;\n background: var(--bg-secondary);\n border-radius: 8px;\n gap: 12px;\n min-width: 0;\n}\n\n.account-info-label {\n font-size: 13px;\n font-weight: 500;\n color: var(--text-secondary);\n flex-shrink: 0;\n}\n\n.account-info-value {\n font-size: 13px;\n color: var(--text-primary);\n font-weight: 500;\n text-align: right;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n min-width: 0;\n}\n\n.status-connected {\n color: var(--accent-color);\n}\n\n.status-disconnected {\n color: var(--text-secondary);\n}\n\n.account-section-subtitle {\n font-size: 13px;\n color: var(--text-secondary);\n margin: -8px 0 20px 0;\n line-height: 1.5;\n}\n\n.device-row {\n display: grid;\n grid-template-columns: 100px 1fr;\n align-items: center;\n gap: 16px;\n padding: 14px 0;\n border-bottom: 1px solid var(--border-color);\n}\n\n.device-row:last-child {\n border-bottom: none;\n}\n\n.device-row-label {\n font-size: 14px;\n font-weight: 500;\n color: var(--text-primary);\n}\n\n.device-row-select {\n padding: 11px 14px;\n border: 1.5px solid var(--border-color);\n border-radius: 8px;\n background: var(--bg-secondary);\n color: var(--text-primary);\n font-size: 13px;\n font-weight: 500;\n cursor: pointer;\n transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);\n appearance: none;\n background-image: url("data:image/svg+xml,%3Csvg width='14' height='8' viewBox='0 0 14 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L7 7L13 1' stroke='%23999' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");\n background-repeat: no-repeat;\n background-position: right 12px center;\n padding-right: 40px;\n box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);\n}\n\n.device-row-select:hover {\n border-color: var(--primary-color);\n background-color: var(--bg-primary);\n box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);\n}\n\n.device-row-select:focus {\n outline: none;\n border-color: var(--primary-color);\n box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.12), 0 2px 4px rgba(0, 0, 0, 0.08);\n}\n\n.device-row-select option {\n background: var(--bg-secondary);\n color: var(--text-primary);\n padding: 12px;\n font-weight: 500;\n}\n\n/* Call Quality Indicator */\n.call-quality {\n display: flex;\n align-items: center;\n gap: 6px;\n font-size: 11px;\n padding: 4px 8px;\n border-radius: 6px;\n margin-top: 4px;\n background: var(--bg-secondary);\n width: fit-content;\n}\n\n.quality-bars {\n font-size: 10px;\n letter-spacing: 1px;\n}\n\n.quality-label {\n text-transform: capitalize;\n font-weight: 600;\n}\n\n.quality-excellent {\n color: #10b981;\n background: rgba(16, 185, 129, 0.1);\n}\n\n.quality-good {\n color: var(--accent-color);\n background: rgba(34, 197, 94, 0.1);\n}\n\n.quality-fair {\n color: #f59e0b;\n background: rgba(245, 158, 11, 0.1);\n}\n\n.quality-poor {\n color: var(--danger-color);\n background: rgba(239, 68, 68, 0.1);\n}\n\n/* Park View */\n.park-view {\n overflow-y: auto;\n overflow-x: hidden;\n flex: 1;\n backface-visibility: hidden;\n transform: translateZ(0);\n padding-bottom: 16px;\n}\n\n.park-header {\n margin-bottom: 16px;\n}\n\n.park-title {\n font-size: 14px;\n font-weight: 600;\n color: var(--text-primary);\n margin: 0 0 4px 0;\n text-transform: uppercase;\n letter-spacing: 0.5px;\n}\n\n.park-subtitle {\n font-size: 12px;\n color: var(--text-secondary);\n margin: 0;\n}\n\n.park-list,\n.park-slots {\n display: flex;\n flex-direction: column;\n gap: 8px;\n}\n\n.park-item {\n display: flex;\n align-items: center;\n gap: 12px;\n padding: 12px;\n background: var(--bg-secondary);\n border: 1px solid var(--border-color);\n border-radius: 8px;\n cursor: pointer;\n transition: all 0.2s;\n}\n\n.park-item:hover {\n background: var(--bg-hover);\n border-color: var(--primary-color);\n}\n\n.park-item.occupied {\n opacity: 0.6;\n cursor: not-allowed;\n}\n\n.park-item.occupied:hover {\n background: var(--bg-secondary);\n border-color: var(--border-color);\n}\n\n.park-item-icon {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 40px;\n height: 40px;\n background: var(--primary-color-light);\n border-radius: 50%;\n color: var(--primary-color);\n flex-shrink: 0;\n}\n\n.park-item-info {\n flex: 1;\n min-width: 0;\n}\n\n.park-item-label {\n font-size: 14px;\n font-weight: 500;\n color: var(--text-primary);\n margin-bottom: 2px;\n}\n\n.park-item-extension {\n font-size: 12px;\n color: var(--text-secondary);\n}\n\n.park-item-details {\n margin-top: 6px;\n padding-top: 6px;\n border-top: 1px solid var(--border-color);\n}\n\n.parked-caller {\n font-size: 13px;\n font-weight: 500;\n color: var(--primary-color);\n margin-bottom: 2px;\n}\n\n.parked-meta {\n font-size: 11px;\n color: var(--text-secondary);\n}\n\n.park-item-status {\n flex-shrink: 0;\n}\n\n.status-badge {\n padding: 4px 8px;\n border-radius: 4px;\n font-size: 11px;\n font-weight: 500;\n}\n\n.status-badge.available {\n color: var(--accent-color);\n background: rgba(34, 197, 94, 0.1);\n}\n\n.status-badge.occupied {\n color: var(--text-secondary);\n background: var(--bg-secondary);\n}\n\n/* Parked Call Item */\n.parked-call-item {\n display: flex;\n align-items: center;\n gap: 12px;\n padding: 12px;\n background: var(--bg-secondary);\n border: 1px solid var(--border-color);\n border-radius: 8px;\n margin-bottom: 8px;\n}\n\n.parked-call-icon {\n width: 40px;\n height: 40px;\n background: rgba(255, 107, 53, 0.1);\n border-radius: 50%;\n display: flex;\n align-items: center;\n justify-content: center;\n color: var(--primary-color);\n flex-shrink: 0;\n}\n\n.parked-call-info {\n flex: 1;\n min-width: 0;\n}\n\n.parked-call-number {\n font-size: 16px;\n font-weight: 500;\n color: var(--text-primary);\n margin-bottom: 4px;\n}\n\n.parked-call-meta {\n font-size: 12px;\n color: var(--text-secondary);\n}\n\n.retrieve-btn {\n padding: 8px 20px;\n background: var(--primary-color);\n color: white;\n border: none;\n border-radius: 6px;\n font-size: 14px;\n font-weight: 500;\n cursor: pointer;\n transition: all 0.2s;\n flex-shrink: 0;\n}\n\n.retrieve-btn:hover {\n background: #ff5722;\n transform: scale(1.02);\n}\n\n/* Park Footer */\n.park-footer {\n margin-top: 24px;\n padding-top: 16px;\n border-top: 1px solid var(--border-color);\n}\n\n.park-footer-text {\n font-size: 12px;\n color: var(--text-secondary);\n margin: 0 0 12px 0;\n}\n\n.park-slot-buttons {\n display: flex;\n flex-wrap: wrap;\n gap: 8px;\n}\n\n.park-slot-btn {\n padding: 8px 16px;\n background: var(--bg-secondary);\n border: 1px solid var(--border-color);\n border-radius: 6px;\n color: var(--text-primary);\n font-size: 14px;\n font-weight: 500;\n cursor: pointer;\n transition: all 0.2s;\n}\n\n.park-slot-btn:hover {\n background: var(--primary-color);\n color: white;\n border-color: var(--primary-color);\n}\n\n/* Transfer panel */\n.transfer-panel {\n display: flex;\n flex-direction: column;\n gap: 10px;\n padding: 12px;\n flex: 1;\n overflow: hidden;\n}\n\n.panel-header {\n display: flex;\n align-items: center;\n gap: 10px;\n font-weight: 600;\n font-size: 14px;\n color: var(--text-primary);\n}\n\n.back-btn {\n background: none;\n border: none;\n cursor: pointer;\n color: var(--primary-color);\n padding: 0;\n font-size: 13px;\n flex-shrink: 0;\n}\n\n.back-btn:hover {\n opacity: 0.8;\n}\n\n.transfer-input {\n padding: 9px 12px;\n border: 1px solid var(--border-color);\n border-radius: 8px;\n font-size: 14px;\n outline: none;\n background: var(--bg-secondary);\n color: var(--text-primary);\n transition: border-color 0.2s;\n}\n\n.transfer-input:focus {\n border-color: var(--primary-color);\n}\n\n.transfer-ext-list {\n flex: 1;\n overflow-y: auto;\n max-height: 150px;\n}\n\n.transfer-ext-item {\n display: flex;\n justify-content: space-between;\n align-items: center;\n padding: 8px 6px;\n cursor: pointer;\n border-radius: 6px;\n transition: background 0.15s;\n}\n\n.transfer-ext-item:hover {\n background: var(--bg-hover, rgba(0,0,0,0.05));\n}\n\n.ext-name {\n font-weight: 600;\n font-size: 13px;\n color: var(--text-primary);\n}\n\n.ext-num {\n font-size: 11px;\n color: var(--text-secondary);\n font-family: monospace;\n}\n\n.transfer-confirm-btn {\n padding: 10px;\n background: var(--primary-color);\n color: #fff;\n border: none;\n border-radius: 8px;\n font-size: 14px;\n font-weight: 600;\n cursor: pointer;\n transition: opacity 0.2s;\n}\n\n.transfer-confirm-btn:hover:not(:disabled) {\n opacity: 0.9;\n}\n\n.transfer-confirm-btn:disabled {\n opacity: 0.4;\n cursor: not-allowed;\n}\n\n.transfer-empty {\n font-size: 12px;\n color: var(--text-secondary);\n padding: 8px;\n text-align: center;\n}\n\n/* Notification permission row */\n.notification-permission {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 8px 12px;\n font-size: 13px;\n color: var(--text-primary);\n}\n\n.status-ok {\n color: var(--accent-color, #22c55e);\n font-weight: 600;\n}\n\n/* Phone Number Selector */\n.phone-number-selector {\n margin-bottom: 16px;\n position: relative;\n width: 100%;\n}\n\n.account-phone-selector {\n margin-top: 12px;\n}\n\n.phone-number-label {\n display: flex;\n align-items: center;\n gap: 8px;\n font-size: 14px;\n font-weight: 500;\n margin-bottom: 8px;\n color: var(--text-primary);\n}\n\n.label-hint {\n font-size: 12px;\n font-weight: 400;\n color: var(--text-secondary);\n font-style: italic;\n}\n\n.phone-number-dropdown-trigger {\n width: 100%;\n padding: 12px 16px;\n border: 1px solid var(--border-color);\n border-radius: 8px;\n background: var(--bg-secondary);\n display: flex;\n justify-content: space-between;\n align-items: center;\n cursor: pointer;\n transition: border-color 0.2s;\n}\n\n.phone-number-dropdown-trigger:hover {\n border-color: var(--primary-color);\n}\n\n.phone-number-dropdown-trigger:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n}\n\n.selected-number {\n font-size: 14px;\n font-weight: 500;\n color: var(--text-primary);\n}\n\n.dropdown-icon {\n width: 20px;\n height: 20px;\n fill: var(--text-secondary);\n transition: transform 0.2s;\n}\n\n.dropdown-icon.rotated {\n transform: rotate(180deg);\n}\n\n.phone-number-dropdown-container {\n position: relative;\n}\n\n.phone-number-dropdown {\n position: absolute;\n bottom: 100%;\n left: 0;\n right: 0;\n margin-bottom: 4px;\n background: var(--bg-primary);\n border: 1px solid var(--border-color);\n border-radius: 8px;\n box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);\n max-height: 240px;\n overflow-y: auto;\n z-index: 1000;\n}\n\n.phone-number-item {\n width: 100%;\n padding: 12px 16px;\n border: none;\n border-left: 3px solid transparent;\n background: transparent;\n text-align: left;\n cursor: pointer;\n display: flex;\n align-items: center;\n gap: 12px;\n transition: all 0.2s;\n color: var(--text-primary);\n}\n\n.phone-number-item:hover {\n background: var(--bg-secondary);\n}\n\n.phone-number-item.selected {\n border-left-color: var(--primary-color);\n background: rgba(255, 107, 53, 0.05);\n}\n\n.phone-icon {\n width: 20px;\n height: 20px;\n fill: var(--text-secondary);\n flex-shrink: 0;\n}\n\n.phone-number-info {\n display: flex;\n flex-direction: column;\n gap: 4px;\n flex: 1;\n}\n\n.number-text {\n font-size: 14px;\n font-weight: 500;\n color: var(--text-primary);\n}\n\n.number-label {\n font-size: 12px;\n color: var(--text-secondary);\n}\n\n.phone-number-empty {\n padding: 16px;\n text-align: center;\n color: var(--text-secondary);\n display: flex;\n flex-direction: column;\n gap: 12px;\n align-items: center;\n font-size: 13px;\n}\n\n.error-text {\n color: var(--danger-color);\n font-size: 13px;\n}\n\n.retry-button {\n padding: 6px 12px;\n background: var(--primary-color);\n color: white;\n border: none;\n border-radius: 4px;\n cursor: pointer;\n font-size: 13px;\n transition: opacity 0.2s;\n}\n\n.retry-button:hover {\n opacity: 0.9;\n}\n\n.loading-spinner {\n display: inline-block;\n width: 12px;\n height: 12px;\n border: 2px solid var(--text-secondary);\n border-top-color: transparent;\n border-radius: 50%;\n animation: spin 0.6s linear infinite;\n}\n\n@keyframes spin {\n to { transform: rotate(360deg); }\n}\n\n.loading-message {\n font-size: 12px;\n color: var(--text-secondary);\n text-align: center;\n margin-top: 8px;\n}\n</style>\n ${"collapsed"===t?this.renderCollapsed():this.renderExpanded()}\n ${this.incomingCallNumber?this.renderIncomingCallModal():""}\n ${this.showRetrieveModal?this.renderRetrieveModal():""}\n `;const e=this.shadow.getElementById("phoneInput");e&&this.phoneInputValue&&(e.value=this.phoneInputValue),this.isInitialized&&(this.updateButtonStates(),this.attachDragHandlers())}else this.performSelectiveUpdate(t)}performSelectiveUpdate(e){if("collapsed"===e){const e=this.shadow.querySelector(".dialer-fab");if(e){const t="connected"===this.callStatus,n=e.querySelector(".call-indicator");t&&!n?e.insertAdjacentHTML("beforeend",'<span class="call-indicator"></span>'):!t&&n&&n.remove()}}else this.updateExpandedContent();this.updateModalOverlays()}updateExpandedContent(){const e=this.shadow.querySelector(".dialer-body");if(e)if("idle"!==this.callStatus&&"ended"!==this.callStatus&&"error"!==this.callStatus)"dial"===this.currentView&&this.updateActiveCallUI();else{const t=e.querySelector(".input-section, .history-view, .account-view"),n="history"===this.currentView?"history-view":"account"===this.currentView?"account-view":"input-section";t?.classList.contains(n)?"dial"===this.currentView?(this.updatePhoneInput(),this.updateButtonStates()):this.currentView:this.updateMainView()}}updateDialedDigitsDisplay(){const e=this.shadow.querySelector(".dialed-digits");if(e)e.textContent=this.dialedDigits,e.setAttribute("title",`Dialed: ${this.dialedDigits}`);else if(this.dialedDigits){const e=this.shadow.querySelector(".keypad-header");e&&(e.innerHTML=`<div class="dialed-digits" title="Dialed: ${this.dialedDigits}">${this.dialedDigits}</div>`)}}updateActiveCallUI(){const e=this.shadow.querySelector(".active-call");if(!e){if("park"===this.currentView)return;const e=this.shadow.querySelector(".dialer-body");return void(e&&(e.innerHTML=this.renderActiveCall()))}if(!!e.querySelector(".incall-keypad")!==this.showInCallKeypad){const e=this.shadow.querySelector(".dialer-body");return void(e&&(e.innerHTML=this.renderActiveCall()))}const t=this.currentCall?.duration||0,n=e.querySelector(".keypad-header-duration");n&&(n.textContent=this.formatDuration(t));let i=e.querySelector(".call-duration");if("connected"===this.callStatus)if(i)i.innerHTML=`\n\t\t\t\t\t<span class="duration-indicator"></span>\n\t\t\t\t\t${this.formatDuration(t)}\n\t\t\t\t`;else{const n=e.querySelector(".call-info"),r=e.querySelector(".call-number");n&&r&&(r.insertAdjacentHTML("afterend",`<div class="call-duration">\n\t\t\t\t\t\t\t<span class="duration-indicator"></span>\n\t\t\t\t\t\t\t${this.formatDuration(t)}\n\t\t\t\t\t\t</div>`),i=e.querySelector(".call-duration"))}const r=e.querySelector(".call-status");if(r){const e=this.isOnHold?"On Hold":"connected"===this.callStatus?"Connected":this.callStatus;r.textContent=e}const a=e.querySelector("#muteBtn"),o=e.querySelector("#holdBtn"),s=e.querySelector("#recordBtn"),d=e.querySelector("#keypadBtn"),l=e.querySelector("#parkBtn"),c="connected"===this.callStatus;[a,o,s,d,l].forEach(e=>{e&&(c?e.removeAttribute("disabled"):e.setAttribute("disabled",""))}),a&&(this.isMuted?a.classList.add("active"):a.classList.remove("active")),o&&(this.isOnHold?o.classList.add("active"):o.classList.remove("active")),s&&(this.isRecording?s.classList.add("active"):s.classList.remove("active"))}updateModalOverlays(){const e=this.shadow.querySelector(".incoming-call-overlay");if(this.incomingCallNumber&&!e){const e=document.createElement("div");e.innerHTML=this.renderIncomingCallModal(),this.shadow.appendChild(e.firstElementChild)}else!this.incomingCallNumber&&e&&e.remove()}updateButtonStates(){const e=this.shadow.getElementById("phoneInput"),t=this.shadow.getElementById("callBtn"),n=this.shadow.getElementById("backspaceBtn"),i=e&&e.value.trim().length>0;t&&(t.disabled=!i),n&&(n.disabled=!i)}toggleCountryDropdown(){if(this.showCountryDropdown=!this.showCountryDropdown,this.showCountryDropdown){const e=this.shadow.querySelector(".dialer-panel");e&&(e.insertAdjacentHTML("beforebegin",this.renderCountryBackdrop()),e.insertAdjacentHTML("beforebegin",this.renderCountryDropdown()));const t=this.shadow.querySelector(".country-selector"),n=this.shadow.querySelector(".country-dropdown");if(t&&n){const i=t.getBoundingClientRect(),r=e?.getBoundingClientRect();r&&(n.style.position="absolute",n.style.top=i.bottom-r.top+4+"px",n.style.left=i.left-r.left+"px")}}else{const e=this.shadow.querySelector(".country-dropdown-backdrop"),t=this.shadow.querySelector(".country-dropdown");e&&e.remove(),t&&t.remove()}}selectCountry(e){const t=U.find(t=>t.code===e);if(!t)return;this.selectedCountry=t,this.showCountryDropdown=!1;const n=this.shadow.querySelector(".country-btn");n&&(n.innerHTML=`\n\t\t\t\t<span class="country-flag">${t.flag}</span>\n\t\t\t\t<span class="country-code">${t.dialCode}</span>\n\t\t\t\t<svg class="dropdown-icon" width="12" height="12" viewBox="0 0 24 24" fill="currentColor">\n\t\t\t\t\t<path d="M7 10l5 5 5-5z"/>\n\t\t\t\t</svg>\n\t\t\t`);const i=this.shadow.querySelector(".country-dropdown-backdrop"),r=this.shadow.querySelector(".country-dropdown");i&&i.remove(),r&&r.remove()}renderCollapsed(){return`\n <button class="dialer-fab" id="fab">\n <svg width="24" height="24" viewBox="0 0 24 24" fill="none">\n <path d="M20 10.999h2C22 5.869 18.127 2 12.99 2v2C17.052 4 20 6.943 20 10.999z" fill="currentColor"/>\n <path d="M13 8c2.103 0 3 .897 3 3h2c0-3.225-1.775-5-5-5v2zm3.422 5.443a1.001 1.001 0 00-1.391.043l-2.393 2.461c-.576-.11-1.734-.471-2.926-1.66-1.192-1.193-1.553-2.354-1.66-2.926l2.459-2.394a1 1 0 00.043-1.391L6.859 3.513a1 1 0 00-1.391-.087l-2.17 1.861a1 1 0 00-.29.649c-.015.25-.301 6.172 4.291 10.766C11.305 20.707 16.323 21 17.705 21c.202 0 .326-.006.359-.008a.992.992 0 00.648-.291l1.86-2.171a1 1 0 00-.086-1.391l-4.064-3.696z" fill="currentColor"/>\n </svg>\n ${"connected"===this.callStatus?'<span class="call-indicator"></span>':""}\n </button>\n `}renderExpanded(){const e=this.config.brandName||"Convirza",t=this.config.brandLogo;return`\n <div class="dialer-panel">\n <div class="dialer-header">\n <div class="header-brand">\n ${t?`<img src="${t}" alt="${e}" class="brand-logo" />`:""}\n <span>${e}</span>\n </div>\n <div class="header-controls">\n <button class="header-btn" id="minimizeBtn">−</button>\n <button class="header-btn" id="closeBtn">×</button>\n </div>\n </div>\n\n <div class="dialer-body">\n ${"idle"!==this.callStatus&&"dial"===this.currentView?this.renderActiveCall():"park"===this.currentView?this.renderPark():"history"===this.currentView?this.renderHistory():"account"===this.currentView?this.renderAccount():this.renderDialpad()}\n </div>\n\n ${this.renderBottomNav()}\n </div>\n `}renderCountryDropdown(){return`\n <div class="country-dropdown">\n ${U.map(e=>`\n <button class="country-option" data-country="${e.code}">\n <span class="country-flag">${e.flag}</span>\n <span class="country-name">${e.name}</span>\n <span class="country-code">${e.dialCode}</span>\n </button>\n `).join("")}\n </div>\n `}renderCountryBackdrop(){return'<div class="country-dropdown-backdrop" id="countryDropdownBackdrop"></div>'}renderDialpad(){return this.isDialerEnabled()?(this.config.brandName,`\n\n <div class="input-section">\n <div class="country-selector" id="countrySelector">\n <button class="country-btn" id="countryBtn">\n <span class="country-flag">${this.selectedCountry.flag}</span>\n <span class="country-code">${this.selectedCountry.dialCode}</span>\n <svg class="dropdown-icon" width="12" height="12" viewBox="0 0 24 24" fill="currentColor">\n <path d="M7 10l5 5 5-5z"/>\n </svg>\n </button>\n </div>\n <div class="phone-input-wrapper">\n <input type="text" class="phone-input" id="phoneInput" autocomplete="off"/>\n </div>\n <button class="toggle-btn" id="backspaceBtn" title="Backspace" disabled>\n <svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor">\n <path d="M22 3H7c-.69 0-1.23.35-1.59.88L0 12l5.41 8.11c.36.53.9.89 1.59.89h15c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H7.07L2.4 12l4.66-7H22v14zm-11.59-2L14 13.41 17.59 17 19 15.59 15.41 12 19 8.41 17.59 7 14 10.59 10.41 7 9 8.41 12.59 12 9 15.59z"/>\n </svg>\n </button>\n </div>\n\n <div class="dialpad">\n ${[1,2,3,4,5,6,7,8,9,"*",0,"#"].map(e=>{const t=o[e.toString()];return`\n <button class="dialpad-btn" data-digit="${e}">\n <span class="dialpad-number">${e}</span>\n ${t?`<span class="dialpad-letters">${t}</span>`:0===e?'<span class="dialpad-letters">+</span>':""}\n </button>\n `}).join("")}\n </div>\n\n \x3c!-- Phone Number Selector (Always shown) --\x3e\n <div class="phone-number-selector">\n <label class="phone-number-label">Call From</label>\n\n \x3c!-- Dropdown container always present, populated dynamically (positioned ABOVE button) --\x3e\n <div class="phone-number-dropdown-container"></div>\n\n <button\n class="phone-number-dropdown-trigger"\n id="phoneNumberDropdownBtn"\n >\n <span class="selected-number">\n ${this.selectedPhoneNumber?`${this.selectedPhoneNumber.assigned_user_name||"Unknown"} - ${this.formatPhoneNumberDisplay(this.selectedPhoneNumber.number||this.selectedPhoneNumber.number_str)}`:"No caller ID selected"}\n </span>\n <svg class="dropdown-icon ${this.showPhoneNumberDropdown?"rotated":""}" viewBox="0 0 24 24">\n <path d="M7 10l5 5 5-5z"/>\n </svg>\n </button>\n </div>\n\n <div class="call-btn-wrapper">\n <button class="call-btn" id="callBtn" disabled>\n <svg width="24" height="24" viewBox="0 0 24 24" fill="currentColor">\n <path d="M20 15.5c-1.25 0-2.45-.2-3.57-.57-.35-.11-.74-.03-1.02.24l-2.2 2.2c-2.83-1.44-5.15-3.75-6.59-6.59l2.2-2.21c.28-.26.36-.65.25-1C8.7 6.45 8.5 5.25 8.5 4c0-.55-.45-1-1-1H4c-.55 0-1 .45-1 1 0 9.39 7.61 17 17 17 .55 0 1-.45 1-1v-3.5c0-.55-.45-1-1-1z"/>\n </svg>\n </button>\n </div>\n `):this.renderDialerDisabled()}escapeHtml(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}renderTransferPanel(){return`\n <div class="transfer-panel">\n <div class="panel-header">\n <button id="cancelTransferBtn" class="back-btn">← Back</button>\n <span>Transfer to User</span>\n </div>\n <input id="transferTargetInput" class="transfer-input" type="tel"\n placeholder="User number or extension..." value="${this.escapeHtml(this.transferTarget)}" />\n <div class="transfer-ext-list">\n ${this.domainExtensions.length>0?this.domainExtensions.map(e=>`\n <div class="transfer-ext-item" data-transfer-ext="${this.escapeHtml(e.extension)}">\n <span class="ext-name">${this.escapeHtml(e.user_name||"Unknown User")}</span>\n <span class="ext-num">${this.escapeHtml(e.extension)}</span>\n </div>`).join(""):'<div class="transfer-empty">No users found</div>'}\n </div>\n <button id="confirmTransferBtn" class="transfer-confirm-btn"\n ${!this.transferTarget.trim()||this.isTransferring?"disabled":""}>\n ${this.isTransferring?"Transferring...":"Transfer Now"}\n </button>\n </div>\n `}renderActiveCall(){if(this.showTransferView)return this.renderTransferPanel();const e=this.currentCall?.phoneNumber||"",t=this.currentCall?.duration||0,n=this.isOnHold?"On Hold":"connected"===this.callStatus?"Connected":this.callStatus,i="connected"===this.callStatus;return`\n <div class="active-call ${this.showInCallKeypad?"compact":""}">\n ${this.showInCallKeypad?`\n <div class="keypad-header">\n ${this.dialedDigits?`<div class="dialed-digits" title="Dialed: ${this.dialedDigits}">${this.dialedDigits}</div>`:`\n <span class="keypad-header-number">${e}</span>\n <span class="keypad-header-sep">•</span>\n <span class="keypad-header-duration">${this.formatDuration(t)}</span>\n `}\n </div>\n `:`\n <div class="call-info">\n <div class="call-number">${e}</div>\n ${"connected"===this.callStatus?`\n <div class="call-duration">\n <span class="duration-indicator"></span>\n ${this.formatDuration(t)}\n </div>\n `:""}\n <div class="call-status">${n}</div>\n </div>\n `}\n ${this.showInCallKeypad?`\n <div class="incall-keypad">\n ${[1,2,3,4,5,6,7,8,9,"*",0,"#"].map(e=>{const t=o[e.toString()];return`\n <button class="dialpad-btn" data-dtmf="${e}">\n <span class="dialpad-number">${e}</span>\n ${t?`<span class="dialpad-letters">${t}</span>`:0===e?'<span class="dialpad-letters">+</span>':""}\n </button>\n `}).join("")}\n </div>\n `:""}\n <div class="call-controls">\n ${this.showInCallKeypad?`\n <div class="compact-controls">\n <div class="compact-controls-icons">\n <button class="compact-icon-btn ${this.isMuted?"active":""}" id="muteBtn" ${i?"":"disabled"} title="Mute">\n <svg width="18" height="18" viewBox="0 0 24 24" fill="currentColor">\n <path d="M12 14c1.66 0 3-1.34 3-3V5c0-1.66-1.34-3-3-3S9 3.34 9 5v6c0 1.66 1.34 3 3 3z"/>\n <path d="M17 11c0 2.76-2.24 5-5 5s-5-2.24-5-5H5c0 3.53 2.61 6.43 6 6.92V21h2v-3.08c3.39-.49 6-3.39 6-6.92h-2z"/>\n </svg>\n </button>\n <button class="compact-icon-btn ${this.isOnHold?"active":""}" id="holdBtn" ${i?"":"disabled"} title="Hold">\n <svg width="18" height="18" viewBox="0 0 24 24" fill="currentColor">\n <path d="M6 4h4v16H6V4zm8 0h4v16h-4V4z"/>\n </svg>\n </button>\n </div>\n <button class="compact-end-btn" id="endBtn">\n <svg width="26" height="26" viewBox="0 0 24 24" fill="currentColor">\n <path d="M12 9c-1.6 0-3.15.25-4.6.72v3.1c0 .39-.23.74-.56.9-.98.49-1.87 1.12-2.66 1.85-.18.18-.43.28-.7.28-.28 0-.53-.11-.71-.29L.29 13.08c-.18-.17-.29-.42-.29-.7 0-.28.11-.53.29-.71C3.34 8.78 7.46 7 12 7s8.66 1.78 11.71 4.67c.18.18.29.43.29.71 0 .28-.11.53-.29.71l-2.48 2.48c-.18.18-.43.29-.71.29-.27 0-.52-.11-.7-.28-.79-.74-1.68-1.36-2.66-1.85-.33-.16-.56-.5-.56-.9v-3.1C15.15 9.25 13.6 9 12 9z"/>\n </svg>\n </button>\n <div class="compact-controls-icons">\n \x3c!-- <button class="compact-icon-btn ${this.isRecording?"active":""}" id="recordBtn" ${i?"":"disabled"} title="Record" style="display:none;">\n <svg width="18" height="18" viewBox="0 0 24 24" fill="currentColor">\n <circle cx="12" cy="12" r="7"/>\n </svg>\n </button> --\x3e\n <button class="compact-icon-btn" id="parkBtn" ${i?"":"disabled"} title="Park">\n <svg width="18" height="18" viewBox="0 0 24 24" fill="currentColor">\n <path d="M13 3H6v18h4v-6h3c3.31 0 6-2.69 6-6s-2.69-6-6-6zm.2 8H10V7h3.2c1.1 0 2 .9 2 2s-.9 2-2 2z"/>\n </svg>\n </button>\n <button class="compact-icon-btn" id="transferBtn" ${i?"":"disabled"} title="Transfer">\n <svg width="18" height="18" viewBox="0 0 24 24" fill="currentColor">\n <path d="M6.62 10.79c1.44 2.83 3.76 5.14 6.59 6.59l2.2-2.2c.27-.27.67-.36 1.02-.24 1.12.37 2.33.57 3.57.57.55 0 1 .45 1 1V20c0 .55-.45 1-1 1-9.39 0-17-7.61-17-17 0-.55.45-1 1-1h3.5c.55 0 1 .45 1 1 0 1.25.2 2.45.57 3.57.11.35.03.74-.25 1.02l-2.2 2.2z M17 8l4 4-4 4V9h-3V7h3V8z"/>\n </svg>\n </button>\n <button class="compact-icon-btn" id="keypadBtn" ${i?"":"disabled"} title="Hide Keypad">\n <svg width="18" height="18" viewBox="0 0 24 24" fill="currentColor">\n <path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/>\n </svg>\n </button>\n </div>\n </div>\n `:`\n <div class="controls-row">\n <button class="control-btn ${this.isMuted?"active":""}" id="muteBtn" ${i?"":"disabled"}>\n <svg width="24" height="24" viewBox="0 0 24 24" fill="currentColor">\n <path d="M12 14c1.66 0 3-1.34 3-3V5c0-1.66-1.34-3-3-3S9 3.34 9 5v6c0 1.66 1.34 3 3 3z"/>\n <path d="M17 11c0 2.76-2.24 5-5 5s-5-2.24-5-5H5c0 3.53 2.61 6.43 6 6.92V21h2v-3.08c3.39-.49 6-3.39 6-6.92h-2z"/>\n </svg>\n </button>\n <button class="control-btn ${this.isOnHold?"active":""}" id="holdBtn" ${i?"":"disabled"}>\n <svg width="24" height="24" viewBox="0 0 24 24" fill="currentColor">\n <path d="M6 4h4v16H6V4zm8 0h4v16h-4V4z"/>\n </svg>\n </button>\n <button class="control-btn" id="keypadBtn" ${i?"":"disabled"}>\n <svg width="24" height="24" viewBox="0 0 24 24" fill="currentColor">\n <circle cx="5" cy="5" r="1.5"/>\n <circle cx="12" cy="5" r="1.5"/>\n <circle cx="19" cy="5" r="1.5"/>\n <circle cx="5" cy="12" r="1.5"/>\n <circle cx="12" cy="12" r="1.5"/>\n <circle cx="19" cy="12" r="1.5"/>\n <circle cx="5" cy="19" r="1.5"/>\n <circle cx="12" cy="19" r="1.5"/>\n <circle cx="19" cy="19" r="1.5"/>\n </svg>\n </button>\n </div>\n <div class="controls-row-end">\n <button class="end-btn" id="endBtn">\n <svg width="28" height="28" viewBox="0 0 24 24" fill="currentColor">\n <path d="M12 9c-1.6 0-3.15.25-4.6.72v3.1c0 .39-.23.74-.56.9-.98.49-1.87 1.12-2.66 1.85-.18.18-.43.28-.7.28-.28 0-.53-.11-.71-.29L.29 13.08c-.18-.17-.29-.42-.29-.7 0-.28.11-.53.29-.71C3.34 8.78 7.46 7 12 7s8.66 1.78 11.71 4.67c.18.18.29.43.29.71 0 .28-.11.53-.29.71l-2.48 2.48c-.18.18-.43.29-.71.29-.27 0-.52-.11-.7-.28-.79-.74-1.68-1.36-2.66-1.85-.33-.16-.56-.5-.56-.9v-3.1C15.15 9.25 13.6 9 12 9z"/>\n </svg>\n </button>\n <button class="control-btn" id="parkBtn" ${i?"":"disabled"} title="Park">\n <svg width="24" height="24" viewBox="0 0 24 24" fill="currentColor">\n <path d="M13 3H6v18h4v-6h3c3.31 0 6-2.69 6-6s-2.69-6-6-6zm.2 8H10V7h3.2c1.1 0 2 .9 2 2s-.9 2-2 2z"/>\n </svg>\n </button>\n <button class="control-btn" id="transferBtn" ${i?"":"disabled"} title="Transfer">\n <svg width="24" height="24" viewBox="0 0 24 24" fill="currentColor">\n <path d="M6.62 10.79c1.44 2.83 3.76 5.14 6.59 6.59l2.2-2.2c.27-.27.67-.36 1.02-.24 1.12.37 2.33.57 3.57.57.55 0 1 .45 1 1V20c0 .55-.45 1-1 1-9.39 0-17-7.61-17-17 0-.55.45-1 1-1h3.5c.55 0 1 .45 1 1 0 1.25.2 2.45.57 3.57.11.35.03.74-.25 1.02l-2.2 2.2z M17 8l4 4-4 4V9h-3V7h3V8z"/>\n </svg>\n </button>\n </div>\n `}\n </div>\n </div>\n `}renderHistory(){const e=this.getFilteredHistory();return`\n <div class="history-view">\n <div class="tabs-nav">\n <button class="tab-btn ${"all"===this.currentHistoryTab?"active":""}" data-tab="all">\n <svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor">\n <path d="M3 13h2v-2H3v2zm0 4h2v-2H3v2zm0-8h2V7H3v2zm4 4h14v-2H7v2zm0 4h14v-2H7v2zM7 7v2h14V7H7z"/>\n </svg>\n All\n </button>\n <button class="tab-btn ${"missed"===this.currentHistoryTab?"active":""}" data-tab="missed">\n <svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor">\n <path d="M19.23 15.26l-2.54-.29c-.61-.07-1.21.14-1.64.57l-1.84 1.84c-2.83-1.44-5.15-3.75-6.59-6.59l1.85-1.85c.43-.43.64-1.03.57-1.64l-.29-2.52c-.12-1.01-.97-1.77-1.99-1.77H5.03c-1.13 0-2.07.94-2 2.07.53 8.54 7.36 15.36 15.89 15.89 1.13.07 2.07-.87 2.07-2v-1.73c.01-1.01-.75-1.86-1.76-1.98z"/>\n </svg>\n Missed\n </button>\n <button class="tab-btn ${"dialed"===this.currentHistoryTab?"active":""}" data-tab="dialed">\n <svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor">\n <path d="M20 15.5c-1.25 0-2.45-.2-3.57-.57-.35-.11-.74-.03-1.02.24l-2.2 2.2c-2.83-1.44-5.15-3.75-6.59-6.59l2.2-2.21c.28-.26.36-.65.25-1C8.7 6.45 8.5 5.25 8.5 4c0-.55-.45-1-1-1H4c-.55 0-1 .45-1 1 0 9.39 7.61 17 17 17 .55 0 1-.45 1-1v-3.5c0-.55-.45-1-1-1z"/>\n </svg>\n Dialed\n </button>\n </div>\n <div class="history-list">\n ${0===e.length?this.renderEmptyHistory():e.map(e=>this.renderHistoryItem(e)).join("")}\n </div>\n <div class="callback-button-container">\n ${this.selectedHistoryItem?this.renderCallBackButton():""}\n </div>\n </div>\n `}renderDialerDisabled(){return'\n <div class="empty-state">\n <svg viewBox="0 0 24 24" fill="currentColor" opacity="0.5">\n <path d="M20 15.5c-1.25 0-2.45-.2-3.57-.57-.35-.11-.74-.03-1.02.24l-2.2 2.2c-2.83-1.44-5.15-3.75-6.59-6.59l2.2-2.21c.28-.26.36-.65.25-1C8.7 6.45 8.5 5.25 8.5 4c0-.55-.45-1-1-1H4c-.55 0-1 .45-1 1 0 9.39 7.61 17 17 17 .55 0 1-.45 1-1v-3.5c0-.55-.45-1-1-1z"/>\n </svg>\n <div class="empty-state-text">Dialer not enabled for this user</div>\n <div class="empty-state-subtext" style="margin-top: 8px; font-size: 12px; opacity: 0.7;">Contact your administrator to enable dialer access</div>\n </div>\n '}renderEmptyHistory(){return`\n <div class="empty-state">\n <svg viewBox="0 0 24 24" fill="currentColor">\n <path d="M20 15.5c-1.25 0-2.45-.2-3.57-.57-.35-.11-.74-.03-1.02.24l-2.2 2.2c-2.83-1.44-5.15-3.75-6.59-6.59l2.2-2.21c.28-.26.36-.65.25-1C8.7 6.45 8.5 5.25 8.5 4c0-.55-.45-1-1-1H4c-.55 0-1 .45-1 1 0 9.39 7.61 17 17 17 .55 0 1-.45 1-1v-3.5c0-.55-.45-1-1-1z"/>\n </svg>\n <div class="empty-state-text">${{all:"No call history",missed:"No missed calls",dialed:"No dialed calls"}[this.currentHistoryTab]}</div>\n </div>\n `}renderHistoryItem(e){const t=new Date(e.timestamp),n=isNaN(t.getTime())?"Invalid Date":this.formatCallTime(t),i=e.duration?this.formatDuration(1e3*e.duration):"",r=this.selectedHistoryItem?.id===e.id,a=this.formatPhoneNumberDisplay(e.phoneNumber);return`\n <div class="history-item ${r?"selected":""}" data-call-id="${e.id}">\n <div class="history-icon ${e.type}">\n <svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor">\n <path d="M20 15.5c-1.25 0-2.45-.2-3.57-.57-.35-.11-.74-.03-1.02.24l-2.2 2.2c-2.83-1.44-5.15-3.75-6.59-6.59l2.2-2.21c.28-.26.36-.65.25-1C8.7 6.45 8.5 5.25 8.5 4c0-.55-.45-1-1-1H4c-.55 0-1 .45-1 1 0 9.39 7.61 17 17 17 .55 0 1-.45 1-1v-3.5c0-.55-.45-1-1-1z"/>\n </svg>\n </div>\n <div class="history-info">\n <div class="history-number">${a}</div>\n <div class="history-status ${e.type}">${e.status}</div>\n </div>\n <div class="history-time">\n ${n}\n ${i?`<span class="history-duration">${i}</span>`:""}\n </div>\n </div>\n `}renderCallBackButton(){if(!this.selectedHistoryItem)return"";return`\n <div class="call-back-container">\n <button id="callBackBtn" class="call-back-btn">\n <svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor">\n <path d="M20 15.5c-1.25 0-2.45-.2-3.57-.57-.35-.11-.74-.03-1.02.24l-2.2 2.2c-2.83-1.44-5.15-3.75-6.59-6.59l2.2-2.21c.28-.26.36-.65.25-1C8.7 6.45 8.5 5.25 8.5 4c0-.55-.45-1-1-1H4c-.55 0-1 .45-1 1 0 9.39 7.61 17 17 17 .55 0 1-.45 1-1v-3.5c0-.55-.45-1-1-1z"/>\n </svg>\n Call Back ${this.formatPhoneNumberDisplay(this.selectedHistoryItem.phoneNumber)}\n </button>\n </div>\n `}renderBottomNav(){return`\n <div class="bottom-nav">\n <button class="nav-btn ${"dial"===this.currentView?"active":""}" data-view="dial">\n <svg viewBox="0 0 24 24" fill="currentColor">\n <path d="M20 15.5c-1.25 0-2.45-.2-3.57-.57-.35-.11-.74-.03-1.02.24l-2.2 2.2c-2.83-1.44-5.15-3.75-6.59-6.59l2.2-2.21c.28-.26.36-.65.25-1C8.7 6.45 8.5 5.25 8.5 4c0-.55-.45-1-1-1H4c-.55 0-1 .45-1 1 0 9.39 7.61 17 17 17 .55 0 1-.45 1-1v-3.5c0-.55-.45-1-1-1z"/>\n </svg>\n Dial\n </button>\n <button class="nav-btn ${"history"===this.currentView?"active":""}" data-view="history">\n <svg viewBox="0 0 24 24" fill="currentColor">\n <path d="M13 3c-4.97 0-9 4.03-9 9H1l3.89 3.89.07.14L9 12H6c0-3.87 3.13-7 7-7s7 3.13 7 7-3.13 7-7 7c-1.93 0-3.68-.79-4.94-2.06l-1.42 1.42C8.27 19.99 10.51 21 13 21c4.97 0 9-4.03 9-9s-4.03-9-9-9zm-1 5v5l4.28 2.54.72-1.21-3.5-2.08V8H12z"/>\n </svg>\n History\n </button>\n <button class="nav-btn ${"park"===this.currentView?"active":""}" data-view="park">\n <svg viewBox="0 0 24 24" fill="currentColor">\n <path d="M13 3H6v18h4v-6h3c3.31 0 6-2.69 6-6s-2.69-6-6-6zm.2 8H10V7h3.2c1.1 0 2 .9 2 2s-.9 2-2 2z"/>\n </svg>\n Park\n </button>\n <button class="nav-btn ${"account"===this.currentView?"active":""}" data-view="account">\n <svg viewBox="0 0 24 24" fill="currentColor">\n <path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 3c1.66 0 3 1.34 3 3s-1.34 3-3 3-3-1.34-3-3 1.34-3 3-3zm0 14.2c-2.5 0-4.71-1.28-6-3.22.03-1.99 4-3.08 6-3.08 1.99 0 5.97 1.09 6 3.08-1.29 1.94-3.5 3.22-6 3.22z"/>\n </svg>\n Account\n </button>\n </div>\n `}renderFooter(){return'\n <div class="dialer-footer">\n <a href="https://convirza.com" target="_blank" class="footer-link">\n Powered by Convirza\n </a>\n </div>\n '}renderIncomingCallModal(){return`\n <div class="incoming-call-overlay">\n <div class="incoming-call-modal">\n <div class="incoming-call-info">\n <div class="incoming-call-label">Incoming Call</div>\n ${this.incomingCallName?`<div class="incoming-call-name">${this.incomingCallName}</div>`:""}\n <div class="incoming-call-number">${this.incomingCallNumber}</div>\n </div>\n <div class="incoming-call-actions">\n <button class="incoming-call-btn reject-btn" id="rejectCallBtn">\n <svg viewBox="0 0 24 24" fill="currentColor">\n <path d="M12 9c-1.6 0-3.15.25-4.6.72v3.1c0 .39-.23.74-.56.9-.98.49-1.87 1.12-2.66 1.85-.18.18-.43.28-.7.28-.28 0-.53-.11-.71-.29L.29 13.08c-.18-.17-.29-.42-.29-.7 0-.28.11-.53.29-.71C3.34 8.78 7.46 7 12 7s8.66 1.78 11.71 4.67c.18.18.29.43.29.71 0 .28-.11.53-.29.71l-2.48 2.48c-.18.18-.43.29-.71.29-.27 0-.52-.11-.7-.28-.79-.74-1.68-1.36-2.66-1.85-.33-.16-.56-.5-.56-.9v-3.1C15.15 9.25 13.6 9 12 9z"/>\n </svg>\n <span>Decline</span>\n </button>\n <button class="incoming-call-btn answer-btn" id="answerCallBtn">\n <svg viewBox="0 0 24 24" fill="currentColor">\n <path d="M20 15.5c-1.25 0-2.45-.2-3.57-.57-.35-.11-.74-.03-1.02.24l-2.2 2.2c-2.83-1.44-5.15-3.75-6.59-6.59l2.2-2.21c.28-.26.36-.65.25-1C8.7 6.45 8.5 5.25 8.5 4c0-.55-.45-1-1-1H4c-.55 0-1 .45-1 1 0 9.39 7.61 17 17 17 .55 0 1-.45 1-1v-3.5c0-.55-.45-1-1-1z"/>\n </svg>\n <span>Answer</span>\n </button>\n </div>\n </div>\n </div>\n `}renderRetrieveModal(){const e=this.retrieveModalData;return e?`\n <div class="incoming-call-overlay">\n <div class="incoming-call-modal">\n <div class="incoming-call-icon">\n <svg width="64" height="64" viewBox="0 0 24 24" fill="currentColor">\n <path d="M13 3H6v18h4v-6h3c3.31 0 6-2.69 6-6s-2.69-6-6-6zm.2 8H10V7h3.2c1.1 0 2 .9 2 2s-.9 2-2 2z"/>\n </svg>\n </div>\n <div class="incoming-call-info">\n <div class="incoming-call-label">Retrieve Parked Call</div>\n <div class="incoming-call-number">${this.formatPhoneNumberDisplay(e.phoneNumber)}</div>\n <div class="incoming-call-status" style="font-size: 12px; color: var(--text-secondary); margin-top: 4px;">Extension ${e.extension}</div>\n </div>\n <div class="incoming-call-actions">\n <button class="incoming-call-btn reject-btn" id="cancelRetrieveBtn">\n <span>Cancel</span>\n </button>\n <button class="incoming-call-btn answer-btn" id="confirmRetrieveBtn">\n <span>Retrieve</span>\n </button>\n </div>\n </div>\n </div>\n `:""}renderAccount(){const e=this.sipAdapter?.getCurrentDevices()||{microphoneId:null,speakerId:null};return`\n <div class="account-view">\n <div class="account-section">\n <h3 class="account-section-title">Audio Devices</h3>\n <p class="account-section-subtitle">Select microphone, speaker </p>\n\n <div class="device-row">\n <label class="device-row-label">Microphone</label>\n <select class="device-row-select" id="microphoneSelect">\n <option value="">System Default</option>\n ${this.audioDevices.microphones.map(t=>`\n <option value="${t.deviceId}" ${t.deviceId===e.microphoneId?"selected":""}>\n ${t.label}\n </option>\n `).join("")}\n </select>\n </div>\n\n <div class="device-row">\n <label class="device-row-label">Speaker</label>\n <select class="device-row-select" id="speakerSelect">\n <option value="">System Default</option>\n ${this.audioDevices.speakers.map(t=>`\n <option value="${t.deviceId}" ${t.deviceId===e.speakerId?"selected":""}>\n ${t.label}\n </option>\n `).join("")}\n </select>\n </div>\n </div>\n\n <div class="account-section">\n <h3 class="account-section-title">Account Information</h3>\n <div class="account-info">\n <div class="account-info-row">\n <span class="account-info-label">First Name</span>\n <span class="account-info-value">${this.config.firstName||"—"}</span>\n </div>\n <div class="account-info-row">\n <span class="account-info-label">Last Name</span>\n <span class="account-info-value">${this.config.lastName||"—"}</span>\n </div>\n <div class="account-info-row">\n <span class="account-info-label">Email</span>\n <span class="account-info-value">${this.config.email||"—"}</span>\n </div>\n <div class="account-info-row">\n <span class="account-info-label">Connection</span>\n <span class="account-info-value ${this.sipAdapter?.isConnected?"status-connected":"status-disconnected"}">\n ${this.sipAdapter?.isConnected?"● Connected":"○ Disconnected"}\n </span>\n </div>\n </div>\n </div>\n\n ${this.renderFooter()}\n </div>\n `}renderPark(){const e="connected"===this.callStatus,t=this.parkAccounts.filter(e=>e.occupied&&e.parkedCall);return e?`\n <div class="park-view">\n <div class="park-header">\n <h3 class="park-title">Park Call</h3>\n <p class="park-subtitle">Select a parking slot</p>\n </div>\n <div class="park-slots">\n ${0===this.parkAccounts.length?'<div class="empty-state">Loading park slots...</div>':this.parkAccounts.map(e=>this.renderParkItem(e)).join("")}\n </div>\n </div>\n `:`\n <div class="park-view">\n <div class="park-header">\n <h3 class="park-title">Parked Calls</h3>\n <p class="park-subtitle">Calls waiting to be retrieved</p>\n </div>\n <div class="park-list">\n ${0===t.length?this.renderEmptyPark():t.map(e=>this.renderParkedCall(e)).join("")}\n </div>\n </div>\n `}renderEmptyPark(){return'\n <div class="empty-state">\n <svg viewBox="0 0 24 24" fill="currentColor">\n <path d="M13 3H6v18h4v-6h3c3.31 0 6-2.69 6-6s-2.69-6-6-6zm.2 8H10V7h3.2c1.1 0 2 .9 2 2s-.9 2-2 2z"/>\n </svg>\n <div class="empty-state-text">No parked calls</div>\n </div>\n '}renderParkedCall(e){if(!e.parkedCall)return"";const t=this.formatParkedDuration(e.parkedCall.parkedAt);return`\n <div class="parked-call-item" data-park-extension="${e.extension}">\n <div class="parked-call-icon">\n <svg width="24" height="24" viewBox="0 0 24 24" fill="currentColor">\n <path d="M6.62 10.79c1.44 2.83 3.76 5.14 6.59 6.59l2.2-2.2c.27-.27.67-.36 1.02-.24 1.12.37 2.33.57 3.57.57.55 0 1 .45 1 1V20c0 .55-.45 1-1 1-9.39 0-17-7.61-17-17 0-.55.45-1 1-1h3.5c.55 0 1 .45 1 1 0 1.25.2 2.45.57 3.57.11.35.03.74-.25 1.02l-2.2 2.2z"/>\n </svg>\n </div>\n <div class="parked-call-info">\n <div class="parked-call-number">${this.formatPhoneNumberDisplay(e.parkedCall.phoneNumber)}</div>\n <div class="parked-call-meta">Parked at ${t}</div>\n </div>\n <button class="retrieve-btn" data-park-extension="${e.extension}">\n Retrieve\n </button>\n </div>\n `}renderParkItem(e){const t=e.parkedCall?`\n <div class="park-item-details">\n <div class="parked-caller">${this.formatPhoneNumberDisplay(e.parkedCall.phoneNumber)}</div>\n <div class="parked-meta">Parked by ${e.parkedCall.parkedBy} • ${this.formatParkedDuration(e.parkedCall.parkedAt)}</div>\n </div>\n `:"";return`\n <div class="park-item ${e.occupied?"occupied":""}" data-park-id="${e.id}" data-park-extension="${e.extension}">\n <div class="park-item-icon">\n <svg width="24" height="24" viewBox="0 0 24 24" fill="currentColor">\n <path d="M13 3H6v18h4v-6h3c3.31 0 6-2.69 6-6s-2.69-6-6-6zm.2 8H10V7h3.2c1.1 0 2 .9 2 2s-.9 2-2 2z"/>\n </svg>\n </div>\n <div class="park-item-info">\n <div class="park-item-label">${e.label}</div>\n <div class="park-item-extension">Extension ${e.extension}</div>\n ${t}\n </div>\n <div class="park-item-status">\n ${e.occupied?'<span class="status-badge occupied">Occupied</span>':'<span class="status-badge available">Available</span>'}\n </div>\n </div>\n `}formatParkedDuration(e){const t=Math.floor((Date.now()-e)/1e3);if(t<60)return`${t}s ago`;const n=Math.floor(t/60);if(n<60)return`${n}m ago`;return`${Math.floor(n/60)}h ago`}setupEventListeners(){const e=e=>{const t=e.target,n=t.closest("button"),i=t.closest(".history-item");if("countryDropdownBackdrop"===t.id||t.classList.contains("country-dropdown-backdrop")){this.showCountryDropdown=!1;const e=this.shadow.querySelector(".country-dropdown-backdrop"),t=this.shadow.querySelector(".country-dropdown");return e&&e.remove(),void(t&&t.remove())}const r=t.closest(".phone-number-item");if(r){console.log("[Dialer] Phone number item clicked");const e=r.getAttribute("data-number-id");if(console.log("[Dialer] Looking for number_id:",e),!e)return void console.error("[Dialer] ❌ No data-number-id attribute found");const t=this.orderedPhoneNumbers.find(t=>String(t.number_id)===e);return void(t?(console.log("[Dialer] ✅ Found and selecting:",t.number_str),this.selectPhoneNumber(t)):(console.error("[Dialer] ❌ Could not find phone number with ID:",e),console.error("[Dialer] Available IDs:",this.orderedPhoneNumbers.map(e=>String(e.number_id)))))}if(this.showPhoneNumberDropdown&&!t.closest(".phone-number-selector"))return console.log("[Dialer] Closing dropdown - clicked outside"),this.showPhoneNumberDropdown=!1,void this.updatePhoneNumberDropdownDOM();if(n&&n.classList.contains("retrieve-btn")){const e=n.getAttribute("data-park-extension");if(e){const t=this.parkAccounts.find(t=>t.extension===e);t?.parkedCall&&this.confirmRetrieveParkedCall(e,t.parkedCall.phoneNumber)}return}const a=t.closest(".park-item");if(a){const e=a.getAttribute("data-park-extension"),t=a.classList.contains("occupied");if(e)if(t){const t=this.parkAccounts.find(t=>t.extension===e);t?.parkedCall&&this.confirmRetrieveParkedCall(e,t.parkedCall.phoneNumber)}else"connected"===this.callStatus&&this.parkCall(e);return}const o=t.closest("[data-transfer-ext]");if(o){const e=o.getAttribute("data-transfer-ext");return void(e&&(this.transferTarget=e,this.executeTransfer()))}if(i&&!n){const e=i.getAttribute("data-call-id");if(e){const t=this.callHistory.find(t=>t.id===e);if(t){this.selectedHistoryItem=t;const e=this.shadow.querySelector(".dialer-body");e&&(e.innerHTML=this.renderHistory())}}return}if(!n)return;const s=n.id,d=n.getAttribute("data-digit"),l=n.getAttribute("data-dtmf"),c=n.getAttribute("data-tab"),h=n.getAttribute("data-view"),u=n.getAttribute("data-country");if(u)this.selectCountry(u);else if(c)this.switchHistoryTab(c);else if(h)this.switchView(h);else if("fab"===s)this.hasMoved||this.open(),this.hasMoved=!1;else if("closeBtn"===s||"minimizeBtn"===s)this.close();else if(d){if(this.longPressTriggered)return void(this.longPressTriggered=!1);const e=this.shadow.getElementById("phoneInput");e&&(e.value+=d,this.phoneInputValue=e.value,this.updateButtonStates(),this.playDTMFTone(d))}else if("countryBtn"===s)this.toggleCountryDropdown();else if("backspaceBtn"===s){const e=this.shadow.getElementById("phoneInput");e&&e.value&&(e.value=e.value.slice(0,-1),this.phoneInputValue=e.value,this.updateButtonStates())}else if("callBtn"===s){const e=this.shadow.getElementById("phoneInput");e?.value&&this.placeCall(e.value)}else if("endBtn"===s)this.endCall();else if("muteBtn"===s)this.mute();else if("holdBtn"===s)this.hold();else if("recordBtn"===s)this.toggleRecording();else if("parkBtn"===s)this.showInCallKeypad=!1,this.switchView("park");else if("transferBtn"===s)this.showTransferView=!0,this.showInCallKeypad=!1,this.render();else if("cancelTransferBtn"===s)this.showTransferView=!1,this.transferTarget="",this.render();else if("confirmTransferBtn"===s)this.executeTransfer();else if("enableNotificationsBtn"===s)this.requestNotificationPermission();else if("keypadBtn"===s)this.toggleInCallKeypad();else if("answerCallBtn"===s)this.answerIncomingCall();else if("rejectCallBtn"===s)this.rejectIncomingCall();else if("confirmRetrieveBtn"===s)this.confirmRetrieve();else if("cancelRetrieveBtn"===s)this.cancelRetrieve();else if("callBackBtn"===s){if(this.selectedHistoryItem){const e=this.selectedHistoryItem.phoneNumber;this.selectedHistoryItem=null,this.placeCall(e)}}else l?(this.sendDTMF(l),this.playDTMFTone(l),this.dialedDigits+=l,this.updateDialedDigitsDisplay()):"refreshDevicesBtn"===s?this.refreshAudioDevices():"phoneNumberDropdownBtn"===s?this.togglePhoneNumberDropdown(e):"retryPhoneNumbersBtn"===s&&this.fetchOrderedPhoneNumbers()};this.shadow.addEventListener("click",e,!0),this.boundHandlers.set("root-click",e);const t=e=>{const t=e.target.closest("button");if(!t)return;"0"===t.getAttribute("data-digit")&&(this.longPressTimer=window.setTimeout(()=>{const e=this.shadow.getElementById("phoneInput");e&&(e.value+="+",this.phoneInputValue=e.value,this.updateButtonStates(),this.longPressTriggered=!0)},500))},n=()=>{this.longPressTimer&&(clearTimeout(this.longPressTimer),this.longPressTimer=null)};this.shadow.addEventListener("mousedown",t),this.shadow.addEventListener("mouseup",n),this.shadow.addEventListener("mouseleave",n),this.shadow.addEventListener("touchstart",t),this.shadow.addEventListener("touchend",n),this.boundHandlers.set("mousedown",t),this.boundHandlers.set("mouseup",n);const i=e=>{const t=e.target;if("phoneInput"===t.id){const e=t.selectionStart||0,n=t.value,i=this.formatPhoneInputDisplay(n),r=e+(i.length-n.length);t.value=i,this.phoneInputValue=i,t.setSelectionRange(r,r),this.updateButtonStates()}else if("transferTargetInput"===t.id){this.transferTarget=t.value;const e=this.shadow.getElementById("confirmTransferBtn");e&&(e.disabled=!this.transferTarget.trim()||this.isTransferring)}};this.shadow.addEventListener("input",i),this.boundHandlers.set("root-input",i);const r=e=>{const t=e,n=e.target;if("phoneInput"===n.id){e.preventDefault();const i=t.clipboardData?.getData("text")||"";console.log("[Dialer] Pasted text:",i);const r=i.replace(/\D/g,"");console.log("[Dialer] Extracted digits:",r);let a=r;11===r.length&&r.startsWith("1")?(a=r.slice(1),console.log("[Dialer] Stripped country code, result:",a)):10===r.length?a=r:r.length>11&&(a=r.slice(-10),console.log("[Dialer] International number, using last 10 digits:",a));const o=this.formatPhoneInputDisplay(a);console.log("[Dialer] Formatted result:",o),n.value=o,this.phoneInputValue=o;const s=o.length;n.setSelectionRange(s,s),this.updateButtonStates()}};this.shadow.addEventListener("paste",r),this.boundHandlers.set("root-paste",r);const a=e=>{const t=e.target;"microphoneSelect"===t.id?this.setMicrophone(t.value):"speakerSelect"===t.id&&this.setSpeaker(t.value)};this.shadow.addEventListener("change",a),this.boundHandlers.set("root-change",a),this.setupDragHandlers()}setupDragHandlers(){const e=e=>{if(!this.isDragging)return;this.hasMoved=!0,e.preventDefault();const t=e.clientX-this.dragOffset.x,n=e.clientY-this.dragOffset.y,i=this.getAttribute("state"),r="expanded"===i?380:56,a="expanded"===i?750:56,o=window.innerWidth-r,s=window.innerHeight-a,d=Math.max(0,Math.min(t,o)),l=Math.max(0,Math.min(n,s));this.fabPosition={x:d,y:l},this.style.left=`${d}px`,this.style.top=`${l}px`,this.style.right="auto",this.style.bottom="auto",this.removeAttribute("position")},t=()=>{this.isDragging=!1},n=e=>{if(!this.isDragging)return;this.hasMoved=!0,e.preventDefault();const t=e.touches[0],n=t.clientX-this.dragOffset.x,i=t.clientY-this.dragOffset.y,r=this.getAttribute("state"),a="expanded"===r?380:56,o="expanded"===r?750:56,s=window.innerWidth-a,d=window.innerHeight-o,l=Math.max(0,Math.min(n,s)),c=Math.max(0,Math.min(i,d));this.fabPosition={x:l,y:c},this.style.left=`${l}px`,this.style.top=`${c}px`,this.style.right="auto",this.style.bottom="auto",this.removeAttribute("position")},i=()=>{this.isDragging=!1};this.boundHandlers.set("drag-mousedown",e=>{const t=e.target;if("expanded"===this.getAttribute("state")){const e=this.shadow.querySelector(".dialer-header");if(!e?.contains(t))return;if(t.closest("button"))return}this.isDragging=!0,this.hasMoved=!1,this.dragStartTime=Date.now();const n=this.getBoundingClientRect();this.dragOffset={x:e.clientX-n.left,y:e.clientY-n.top},e.preventDefault()}),this.boundHandlers.set("drag-mousemove",e),this.boundHandlers.set("drag-mouseup",t),this.boundHandlers.set("drag-touchstart",e=>{const t=e.target;if("expanded"===this.getAttribute("state")){const e=this.shadow.querySelector(".dialer-header");if(!e?.contains(t))return;if(t.closest("button"))return}this.isDragging=!0,this.hasMoved=!1,this.dragStartTime=Date.now();const n=e.touches[0],i=this.getBoundingClientRect();this.dragOffset={x:n.clientX-i.left,y:n.clientY-i.top},e.preventDefault()}),this.boundHandlers.set("drag-touchmove",n),this.boundHandlers.set("drag-touchend",i),document.addEventListener("mousemove",e),document.addEventListener("mouseup",t),document.addEventListener("touchmove",n,{passive:!1}),document.addEventListener("touchend",i)}attachDragHandlers(){requestAnimationFrame(()=>{const e=this.getAttribute("state"),t=this.boundHandlers.get("drag-mousedown"),n=this.boundHandlers.get("drag-touchstart");if("collapsed"===e){const e=this.shadow.getElementById("fab");if(!e)return;t&&e.addEventListener("mousedown",t),n&&e.addEventListener("touchstart",n,{passive:!1})}else{const e=this.shadow.querySelector(".dialer-header");if(!e)return;t&&e.addEventListener("mousedown",t),n&&e.addEventListener("touchstart",n,{passive:!1})}})}adjustPositionForPanel(){const e=window.innerWidth,t=window.innerHeight;let n=0,i=0;if(this.style.left&&this.style.top)n=parseInt(this.style.left,10),i=parseInt(this.style.top,10);else if(this.fabPosition)n=this.fabPosition.x,i=this.fabPosition.y;else{const r=this.getAttribute("position")||"bottom-right";n=r.includes("right")?e-56-24:24,i=r.includes("bottom")?t-56-24:24}const r=e-380-10,a=t-750-10;let o=Math.min(n,r),s=Math.min(i,a);o=Math.max(10,o),s=Math.max(10,s),this.style.left=`${o}px`,this.style.top=`${s}px`,this.style.right="auto",this.style.bottom="auto",this.removeAttribute("position"),this.fabPosition={x:o,y:s}}async refreshAudioDevicesQuietly(){if(this.sipAdapter)try{this.audioDevices=await this.sipAdapter.getAudioDevices()}catch(e){console.error("[Dialer] Failed to refresh audio devices:",e)}}async refreshAudioDevices(){if(this.sipAdapter)try{this.audioDevices=await this.sipAdapter.getAudioDevices(),this.updateAccountDeviceSelectors()}catch(e){console.error("[Dialer] Failed to refresh audio devices:",e)}}updateAccountDeviceSelectors(){if("account"!==this.currentView)return;const e=this.shadow.getElementById("microphoneSelect"),t=this.shadow.getElementById("speakerSelect"),n=this.sipAdapter?.getCurrentDevices()||{microphoneId:null,speakerId:null};e&&(e.innerHTML=`\n\t\t\t\t<option value="">System Default</option>\n\t\t\t\t${this.audioDevices.microphones.map(e=>`\n\t\t\t\t\t<option value="${e.deviceId}" ${e.deviceId===n.microphoneId?"selected":""}>\n\t\t\t\t\t\t${e.label}\n\t\t\t\t\t</option>\n\t\t\t\t`).join("")}\n\t\t\t`),t&&(t.innerHTML=`\n\t\t\t\t<option value="">System Default</option>\n\t\t\t\t${this.audioDevices.speakers.map(e=>`\n\t\t\t\t\t<option value="${e.deviceId}" ${e.deviceId===n.speakerId?"selected":""}>\n\t\t\t\t\t\t${e.label}\n\t\t\t\t\t</option>\n\t\t\t\t`).join("")}\n\t\t\t`)}async setMicrophone(e){if(this.sipAdapter)try{await this.sipAdapter.setMicrophone(e||""),this.dispatchEvent(new CustomEvent("microphone-changed",{detail:{deviceId:e},bubbles:!0}))}catch(e){console.error("[Dialer] Failed to set microphone:",e)}}async setSpeaker(e){if(this.sipAdapter)try{await this.sipAdapter.setSpeaker(e||""),this.dispatchEvent(new CustomEvent("speaker-changed",{detail:{deviceId:e},bubbles:!0}))}catch(e){console.error("[Dialer] Failed to set speaker:",e)}}startParkSlotPolling(){this.parkApiUrl&&this.config.sipDomain&&(this.fetchParkSlots(),this.stopParkSlotPolling(),this.parkPollTimer=window.setInterval(()=>{this.fetchParkSlots()},this.parkPollInterval))}stopParkSlotPolling(){null!==this.parkPollTimer&&(clearInterval(this.parkPollTimer),this.parkPollTimer=null)}updateHistorySelection(e){this.shadow.querySelectorAll(".history-item").forEach(e=>e.classList.remove("selected"));const t=this.shadow.querySelector(`.history-item[data-call-id="${e}"]`);t&&t.classList.add("selected");const n=this.shadow.querySelector(".callback-button-container");n&&(n.innerHTML=this.renderCallBackButton())}async fetchParkSlots(){if(this.parkApiUrl&&this.config.sipDomain)try{const e=`${this.parkApiUrl}?domain=${encodeURIComponent(this.config.sipDomain)}`,t={};this.authToken&&(t.Authorization=`Bearer ${this.authToken}`);const n=new AbortController,i=setTimeout(()=>n.abort(),1e4);let r;try{r=await fetch(e,{headers:t,signal:n.signal})}finally{clearTimeout(i)}if(!r.ok)return void(404===r.status&&(console.warn("[Dialer] Park slots API not available (404), disabling poll"),this.stopParkSlotPolling()));const a=await r.json(),o=a.data?.slots||a.slots||[];if(Array.isArray(o)){if(this.isParking&&this.parkingSlot){const e=this.parkAccounts.find(e=>e.extension===this.parkingSlot),t=o.find(e=>e.extension===this.parkingSlot);e?.occupied&&t&&!t.occupied&&(t.occupied=e.occupied,t.parkedCall=e.parkedCall)}this.parkAccounts=o,this.render(),this.dispatchEvent(new CustomEvent("park-slots-updated",{detail:{slots:o},bubbles:!0}))}}catch(e){"AbortError"===e.name?console.warn("[Dialer] Park slots fetch timed out"):console.error("[Dialer] Failed to fetch park slots:",e)}}async fetchDomainExtensions(){if(this.config.apiUrl&&this.authToken&&this.config.sipDomain)try{const e=await fetch(`${this.config.apiUrl.replace(/\/$/,"")}/v3/extensions?sip_domain=${encodeURIComponent(this.config.sipDomain)}`,{headers:{Authorization:`Bearer ${this.authToken}`}});if(!e.ok)return;const t=await e.json();this.domainExtensions=(t?.data?.items??[]).filter(e=>e.extension!==this.config.sipUsername).map(e=>({extension:String(e.extension),user_name:e.user_name??e.name??""}))}catch{}}async fetchOrderedPhoneNumbers(){if(console.log("[Dialer] fetchOrderedPhoneNumbers called",{hasAPI:!!this.phoneNumbersAPI,domainId:this.config.domainId,apiBaseUrl:this.config.apiBaseUrl,hasAuthToken:!!this.authToken,alreadyLoading:this.loadingPhoneNumbers}),this.phoneNumbersAPI&&this.config.domainId)if(this.loadingPhoneNumbers)console.log("[Dialer] Already loading phone numbers, skipping duplicate fetch");else{this.startPhoneNumbersLoading();try{console.log("[Dialer] Fetching phone numbers from API...");const e=await this.phoneNumbersAPI.fetchOrderedNumbers({domainId:this.config.domainId,status:"provisioned",limit:100});if(console.log("[Dialer] Phone numbers received:",e),this.orderedPhoneNumbers=e.items||[],console.log("[Dialer] Set orderedPhoneNumbers, count:",this.orderedPhoneNumbers.length),this.config.domainId){const e=localStorage.getItem(`convirza_selected_caller_id_${this.config.domainId}`);if(e)try{const t=JSON.parse(e),n=this.orderedPhoneNumbers.find(e=>e.number_id===t.number_id);n&&(this.selectedPhoneNumber=n,console.log("[Dialer] Restored saved selection:",n.number_str))}catch(e){console.warn("[Dialer] Failed to restore saved caller ID selection")}}this.orderedPhoneNumbers.length>0&&!this.selectedPhoneNumber&&(this.selectedPhoneNumber=this.orderedPhoneNumbers[0],console.log("[Dialer] Auto-selected first number:",this.selectedPhoneNumber.number_str)),this.stopPhoneNumbersLoading()}catch(e){console.error("[Dialer] Failed to fetch phone numbers:",e),this.phoneNumbersError="Failed to load phone numbers",this.stopPhoneNumbersLoading()}}else console.warn("[Dialer] Cannot fetch phone numbers - missing API or domainId")}renderPhoneNumberDropdownItems(){return 0===this.orderedPhoneNumbers.length?`\n\t\t\t\t<div class="phone-number-empty">\n\t\t\t\t\t${this.phoneNumbersError?`\n\t\t\t\t\t\t<span class="error-text">${this.phoneNumbersError}</span>\n\t\t\t\t\t\t<button class="retry-button" id="retryPhoneNumbersBtn">Retry</button>\n\t\t\t\t\t`:"<span>No phone numbers available</span>"}\n\t\t\t\t</div>\n\t\t\t`:this.orderedPhoneNumbers.map(e=>`\n\t\t\t\t<button\n\t\t\t\t\tclass="phone-number-item ${e.number_id===this.selectedPhoneNumber?.number_id?"selected":""}"\n\t\t\t\t\tdata-number-id="${e.number_id}"\n\t\t\t\t>\n\t\t\t\t\t<svg class="phone-icon" viewBox="0 0 24 24" fill="currentColor">\n\t\t\t\t\t\t<path d="M20 15.5c-1.25 0-2.45-.2-3.57-.57-.35-.11-.74-.03-1.02.24l-2.2 2.2c-2.83-1.44-5.15-3.75-6.59-6.59l2.2-2.21c.28-.26.36-.65.25-1C8.7 6.45 8.5 5.25 8.5 4c0-.55-.45-1-1-1H4c-.55 0-1 .45-1 1 0 9.39 7.61 17 17 17 .55 0 1-.45 1-1v-3.5c0-.55-.45-1-1-1z"/>\n\t\t\t\t\t</svg>\n\t\t\t\t\t<div class="phone-number-info">\n\t\t\t\t\t\t<span class="number-text">${this.formatPhoneNumberDisplay(e.number||e.number_str)}</span>\n\t\t\t\t\t\t<span class="number-label">${e.assigned_user_name||(e.city||e.state?`${e.city||""}${e.city&&e.state?", ":""}${e.state||""}`:"")}</span>\n\t\t\t\t\t</div>\n\t\t\t\t</button>\n\t\t\t`).join("")}updatePhoneNumberDropdownDOM(){const e=this.shadow.querySelector(".phone-number-dropdown-container");if(e)if(this.showPhoneNumberDropdown){const t=`\n\t\t\t\t<div class="phone-number-dropdown">\n\t\t\t\t\t${this.renderPhoneNumberDropdownItems()}\n\t\t\t\t</div>\n\t\t\t`;e.innerHTML=t,console.log("[Dialer] Dropdown rendered with",this.orderedPhoneNumbers.length,"items")}else e.innerHTML="",console.log("[Dialer] Dropdown hidden");else console.warn("[Dialer] Dropdown container not found")}openPhoneNumberDropdown(){console.log("[Dialer] Opening phone number dropdown"),this.showPhoneNumberDropdown=!0,this.updatePhoneNumberDropdownDOM()}closePhoneNumberDropdown(){console.log("[Dialer] Closing phone number dropdown"),this.showPhoneNumberDropdown=!1,this.updatePhoneNumberDropdownDOM()}stopPhoneNumbersLoading(){console.log("[Dialer] Stopping phone numbers loading spinner"),this.loadingPhoneNumbers=!1,this.showPhoneNumberDropdown&&this.updatePhoneNumberDropdownDOM(),this.render()}startPhoneNumbersLoading(){console.log("[Dialer] Starting phone numbers loading spinner"),this.loadingPhoneNumbers=!0,this.phoneNumbersError=null,this.render()}async executeTransfer(){const e=this.transferTarget.trim();if(e&&this.sipAdapter&&!this.isTransferring){this.isTransferring=!0,this.render();try{await this.sipAdapter.blindTransfer(e),this.showTransferView=!1,this.transferTarget="",this.dispatchEvent(new CustomEvent("call-transferred",{detail:{target:e},bubbles:!0}))}catch(e){this.dispatchEvent(new CustomEvent("dialer-error",{detail:{error:`Transfer failed: ${e.message}`},bubbles:!0}))}finally{this.isTransferring=!1,this.render()}}}requestNotificationPermission(){"Notification"in window&&"default"===Notification.permission&&Notification.requestPermission().catch(()=>{})}showIncomingCallNotification(e,t){if("Notification"in window&&"granted"===Notification.permission){this.dismissIncomingCallNotification();try{const n=t?`${t} (${e})`:e,i=new Notification("Incoming Call",{body:`Call from ${n}`,tag:"incoming-call",requireInteraction:!0,silent:!1});i.onclick=()=>{window.focus(),this.open(),i.close()},this._activeNotification=i}catch{}}}dismissIncomingCallNotification(){this._activeNotification&&(this._activeNotification.close(),this._activeNotification=null)}}customElements.get("convirza-dialer")||customElements.define("convirza-dialer",V);e.AudioDeviceManager=d,e.CallHistoryAPI=a,e.CallQualityMonitor=c,e.ConvirzaDialer=class{constructor(e,t){this.container=null,this.state="collapsed",this.callStatus="idle",this.currentCall=null,this.durationInterval=null,this.STORAGE_KEY="convirza_call_state",this.config={position:"bottom-right",zIndex:9999,defaultState:"collapsed",primaryColor:"#6366f1",accentColor:"#22c55e",theme:"dark",brandName:"Convirza",iceServers:[{urls:"stun:stun.l.google.com:19302"}],authToken:void 0,...e},this.state=this.config.defaultState||"collapsed",this.events=t||{},this.restoreCallState()}isValidTransition(e,t){const n=s[e];return!!n&&n.includes(t)}transitionState(e,t){const n=this.callStatus;if(n===e)return;if(!this.isValidTransition(n,e))return console.error(`[CallState] Invalid transition: ${n} → ${e}`),void this.transitionState("error",`Invalid state transition from ${n} to ${e}`);this.callStatus=e;const i=this.currentCall?{phoneNumber:this.currentCall.phoneNumber,startTime:this.currentCall.startTime,duration:this.currentCall.duration,status:e,errorMessage:t}:void 0;this.events.onStateChange&&this.events.onStateChange(n,e,i),this.persistCallState(),this.render()}getCallMetadata(){return this.currentCall?{phoneNumber:this.currentCall.phoneNumber,startTime:this.currentCall.startTime,duration:this.currentCall.duration,status:this.callStatus}:null}persistCallState(){if("undefined"!=typeof window&&window.localStorage)try{const e=this.getCallMetadata();e&&"idle"!==this.callStatus&&"ended"!==this.callStatus?localStorage.setItem(this.STORAGE_KEY,JSON.stringify(e)):localStorage.removeItem(this.STORAGE_KEY)}catch(e){console.error("[CallState] Failed to persist state:",e)}}restoreCallState(){if("undefined"!=typeof window&&window.localStorage)try{const e=localStorage.getItem(this.STORAGE_KEY);if(!e)return;const t=JSON.parse(e),n=Date.now();if(n-t.startTime>36e5)return void localStorage.removeItem(this.STORAGE_KEY);this.currentCall={phoneNumber:t.phoneNumber,startTime:t.startTime,duration:t.duration,callbacks:{onAnswered:[],onEnded:[]}},this.callStatus=t.status}catch(e){console.error("[CallState] Failed to restore state:",e),localStorage.removeItem(this.STORAGE_KEY)}}mount(e){const t=e||document.body;this.container=document.createElement("div"),this.container.id="convirza-dialer-widget",this.container.className=`convirza-dialer ${this.config.position} ${this.state}`,this.container.style.zIndex=String(this.config.zIndex),this.render(),t.appendChild(this.container),this.applyCustomColors()}unmount(){this.container&&this.container.parentNode&&(this.container.parentNode.removeChild(this.container),this.container=null)}placeCall(e,t){if(!e)throw new Error("Phone number is required");const n=this.formatPhoneNumber(e);this.currentCall={phoneNumber:n,startTime:Date.now(),duration:0,callbacks:{onAnswered:[],onEnded:[]}},this.transitionState("dialing"),this.open(),this.events.onCallStarted&&this.events.onCallStarted(n),this.initiateCall(n,t);const i=this;return{phoneNumber:n,get status(){return i.callStatus},get duration(){return i.currentCall?.duration||0},onAnswered(e){i.currentCall?.callbacks.onAnswered.push(e)},onEnded(e){i.currentCall?.callbacks.onEnded.push(e)},end(){i.endCall()}}}open(){this.state="expanded",this.container&&(this.container.className=`convirza-dialer ${this.config.position} ${this.state}`),this.events.onOpen&&this.events.onOpen(),this.render()}close(){this.state="collapsed",this.container&&(this.container.className=`convirza-dialer ${this.config.position} ${this.state}`),this.events.onClose&&this.events.onClose(),this.render()}toggle(){"collapsed"===this.state?this.open():this.close()}initiateCall(e,t){throw new Error("SIP integration not configured. Override initiateCall() method.")}handleCallRinging(){this.transitionState("ringing")}handleCallAnswered(){this.transitionState("connected"),this.currentCall?.callbacks.onAnswered.forEach(e=>e()),this.startDurationTimer()}handleCallTerminated(){this.endCall()}startDurationTimer(){this.durationInterval=window.setInterval(()=>{this.currentCall&&(this.currentCall.duration=Date.now()-this.currentCall.startTime,this.render())},1e3)}stopDurationTimer(){this.durationInterval&&(clearInterval(this.durationInterval),this.durationInterval=null)}endCall(){const e=this.currentCall?.duration||0,t=this.currentCall?.phoneNumber||"";this.currentCall?.callbacks.onEnded.forEach(t=>t(e)),this.events.onCallEnded&&this.events.onCallEnded(t,e),this.stopDurationTimer(),this.transitionState("ended"),setTimeout(()=>{this.transitionState("idle"),this.currentCall=null},1e3)}isValidPhoneNumber(e){const t=e.replace(/\s+/g,"");if(/[a-zA-Z]/.test(t))return t.length>0;return/^\+?[1-9]\d{6,14}$/.test(t)}formatPhoneNumber(e){const t=e.replace(/\D/g,"");return 10===t.length?`+1${t}`:(11===t.length&&t[0],`+${t}`)}formatDuration(e){const t=Math.floor(e/1e3);return`${Math.floor(t/60)}:${(t%60).toString().padStart(2,"0")}`}applyCustomColors(){this.container&&(this.container.style.setProperty("--primary-color",this.config.primaryColor||null),this.container.style.setProperty("--accent-color",this.config.accentColor||null))}render(){this.container&&("collapsed"===this.state?this.container.innerHTML=this.renderCollapsed():this.container.innerHTML=this.renderExpanded(),this.attachEventListeners())}renderCollapsed(){return`\n <button class="dialer-fab" data-action="toggle">\n <svg width="24" height="24" viewBox="0 0 24 24" fill="none">\n <path d="M20 10.999h2C22 5.869 18.127 2 12.99 2v2C17.052 4 20 6.943 20 10.999z" fill="currentColor"/>\n <path d="M13 8c2.103 0 3 .897 3 3h2c0-3.225-1.775-5-5-5v2zm3.422 5.443a1.001 1.001 0 00-1.391.043l-2.393 2.461c-.576-.11-1.734-.471-2.926-1.66-1.192-1.193-1.553-2.354-1.66-2.926l2.459-2.394a1 1 0 00.043-1.391L6.859 3.513a1 1 0 00-1.391-.087l-2.17 1.861a1 1 0 00-.29.649c-.015.25-.301 6.172 4.291 10.766C11.305 20.707 16.323 21 17.705 21c.202 0 .326-.006.359-.008a.992.992 0 00.648-.291l1.86-2.171a1 1 0 00-.086-1.391l-4.064-3.696z" fill="currentColor"/>\n </svg>\n ${"connected"===this.callStatus?'<span class="call-indicator"></span>':""}\n </button>\n <div class="dialer-branding">Powered by Convirza</div>\n `}renderExpanded(){return`\n <div class="dialer-panel">\n <div class="dialer-header">\n <h3>Phone</h3>\n <button class="close-btn" data-action="close">\n <svg width="20" height="20" viewBox="0 0 20 20" fill="currentColor">\n <path d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z"/>\n </svg>\n </button>\n </div>\n\n ${"idle"===this.callStatus?this.renderDialpad():this.renderActiveCall()}\n </div>\n <div class="dialer-branding">Powered by Convirza</div>\n `}renderDialpad(){return`\n <div class="dialer-content">\n <input type="tel" class="phone-input" placeholder="Enter phone number" data-input="phone" />\n <div class="dialpad">\n ${[1,2,3,4,5,6,7,8,9,"*",0,"#"].map(e=>`\n <button class="dialpad-btn" data-action="dial" data-digit="${e}">\n ${e}\n </button>\n `).join("")}\n </div>\n <button class="call-btn" data-action="call">\n <svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor">\n <path d="M20 10.999h2C22 5.869 18.127 2 12.99 2v2C17.052 4 20 6.943 20 10.999z"/>\n <path d="M13 8c2.103 0 3 .897 3 3h2c0-3.225-1.775-5-5-5v2zm3.422 5.443a1.001 1.001 0 00-1.391.043l-2.393 2.461c-.576-.11-1.734-.471-2.926-1.66-1.192-1.193-1.553-2.354-1.66-2.926l2.459-2.394a1 1 0 00.043-1.391L6.859 3.513a1 1 0 00-1.391-.087l-2.17 1.861a1 1 0 00-.29.649c-.015.25-.301 6.172 4.291 10.766C11.305 20.707 16.323 21 17.705 21c.202 0 .326-.006.359-.008a.992.992 0 00.648-.291l1.86-2.171a1 1 0 00-.086-1.391l-4.064-3.696z"/>\n </svg>\n Call\n </button>\n </div>\n `}renderActiveCall(){const e=this.currentCall?.phoneNumber||"",t=this.currentCall?.duration||0;return`\n <div class="active-call">\n <div class="call-info">\n <div class="call-status">${this.callStatus}</div>\n <div class="call-number">${e}</div>\n ${"connected"===this.callStatus?`\n <div class="call-duration">${this.formatDuration(t)}</div>\n `:""}\n </div>\n\n <div class="call-controls">\n <button class="control-btn end-btn" data-action="end">\n <svg width="24" height="24" viewBox="0 0 24 24" fill="currentColor">\n <path d="M16.707 2.293A.996.996 0 0016 2c-7.72 0-14 6.28-14 14 0 .26.09.52.251.71l3.909 4.554a.999.999 0 001.55.091l3.901-4.554a.999.999 0 00-.091-1.399l-3.274-2.742C10.605 11.622 12.203 11 14 11s3.395.622 5.246 1.66l-3.274 2.742a.999.999 0 00-.091 1.399l3.901 4.554a1 1 0 001.55-.091l3.909-4.554A.995.995 0 0025 16c0-7.72-6.28-14-14-14z"/>\n </svg>\n End\n </button>\n </div>\n </div>\n `}attachEventListeners(){if(!this.container)return;const e=this.container.querySelector('[data-action="toggle"]');e&&e.addEventListener("click",()=>this.toggle());const t=this.container.querySelector('[data-action="close"]');t&&t.addEventListener("click",()=>this.close());this.container.querySelectorAll('[data-action="dial"]').forEach(e=>{e.addEventListener("click",e=>{const t=e.target.dataset.digit,n=this.container?.querySelector('[data-input="phone"]');n&&t&&(n.value+=t)})});const n=this.container.querySelector('[data-action="call"]');n&&n.addEventListener("click",()=>{const e=this.container?.querySelector('[data-input="phone"]');e?.value&&this.placeCall(e.value)});const i=this.container.querySelector('[data-action="end"]');i&&i.addEventListener("click",()=>this.endCall())}},e.ConvirzaDialerElement=V,e.DialerAPI=t,e.PhoneNumbersAPI=r,e.SipAdapter=$,e.convirzaDialer=n,e.destroyDialer=function(){i?(n.destroy(),i=!1):console.warn("[Dialer] Not initialized. Nothing to destroy.")},e.initDialer=function(e){i?console.warn("[Dialer] Already initialized. Skipping duplicate init."):(n.init(e),i=!0)},e.isDialerInitialized=function(){return i}});
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ConvirzaDialer={})}(this,function(e){"use strict";class t{constructor(){this.element=null,this.config=null,this.callHistory=[],this.activeCallId=null,this.isMuted=!1,this.isRecording=!1,this.errorHandler=null,this.callEndedHandler=null,this.storageHandler=null}validateConfig(e){if(!e.access_token||0===e.access_token.trim().length)throw new Error("access_token is required for dialer initialization");if(!e.refresh_token||0===e.refresh_token.trim().length)throw new Error("refresh_token is required for dialer initialization")}init(e){this.validateConfig(e),this.config=e,this.element&&(this.callEndedHandler&&(this.element.removeEventListener("call-ended",this.callEndedHandler),this.callEndedHandler=null),this.element.remove()),this.element=document.createElement("convirza-dialer"),this.element.setAttribute("access-token",e.access_token),this.element.setAttribute("refresh-token",e.refresh_token),this.element.setAttribute("auto-configure","true"),this.element.addEventListener("token-refreshed",e=>{const t=new CustomEvent("dialer-token-refreshed",{detail:e.detail,bubbles:!0});window.dispatchEvent(t)}),this.element.addEventListener("auth-failed",e=>{const t=new CustomEvent("dialer-auth-failed",{detail:e.detail,bubbles:!0});window.dispatchEvent(t)}),this.storageHandler||(this.storageHandler=e=>{"access_token"!==e.key||e.newValue||this.destroy()},window.addEventListener("storage",this.storageHandler)),this.element.setAttribute("position","bottom-right"),void 0!==e.dark_theme&&this.element.setAttribute("theme",e.dark_theme?"dark":"light"),e.primaryColor&&this.element.setAttribute("primary-color",e.primaryColor),e.accentColor&&this.element.setAttribute("accent-color",e.accentColor),e.brandName&&this.element.setAttribute("brand-name",e.brandName),e.brandLogo&&this.element.setAttribute("brand-logo",e.brandLogo),e.showPopup?this.element.setAttribute("state","expanded"):this.element.setAttribute("state","collapsed"),document.body.appendChild(this.element),this.setupEventListeners(),this.setupGlobalErrorHandlers()}setupGlobalErrorHandlers(){this.errorHandler||(this.errorHandler=e=>{const t=e instanceof ErrorEvent?e.error:new Error("Unknown error");console.error("[Dialer] Global error:",t),this.element&&this.element.dispatchEvent(new CustomEvent("dialer-error",{detail:{error:t?.message||String(t)},bubbles:!0}))},window.addEventListener("error",this.errorHandler),window.addEventListener("unhandledrejection",this.errorHandler))}refresh(){if(!this.config)throw new Error("Dialer not initialized. Call init() first.");this.init(this.config)}hidePopup(){if(!this.element)throw new Error("Dialer not initialized. Call init() first.");this.element.close()}showPopup(){if(!this.element)throw new Error("Dialer not initialized. Call init() first.");this.element.open()}getActiveCallID(){return this.activeCallId}call(e){if(!this.element)throw new Error("Dialer not initialized. Call init() first.");if(e){const t=this.element.placeCall(e);this.activeCallId=this.generateCallId(),this.callHistory.unshift({id:this.activeCallId,phoneNumber:e,timestamp:Date.now(),direction:"outbound",status:"answered"}),t.onEnded(e=>{const t=this.callHistory.find(e=>e.id===this.activeCallId);t&&(t.duration=e),this.activeCallId=null,this.isMuted=!1,this.isRecording=!1})}else this.showPopup()}mute(e){if(!this.element||!this.activeCallId)throw new Error("No active call");return this.isMuted=this.element.mute(e),this.isMuted}hold(e){if(!this.element||!this.activeCallId)throw new Error("No active call");return this.element.hold(e)}record(e){if(!this.element||!this.activeCallId)throw new Error("No active call");const t=void 0!==e?e:!this.isRecording;return t?this.element.startRecording():this.element.stopRecording(),this.isRecording=t,this.isRecording}callList(e){return e?this.callHistory.slice(0,e):[...this.callHistory]}endCall(){if(!this.element)throw new Error("Dialer not initialized");if(!this.activeCallId)throw new Error("No active call");this.element.endCall()}transfer(e){if(!this.element)throw new Error("Dialer not initialized. Call init() first.");if(!this.activeCallId)throw new Error("No active call to transfer.");const t=this.element;t.transferTarget=e,t.executeTransfer?.()}destroy(){this.element&&(this.callEndedHandler&&(this.element.removeEventListener("call-ended",this.callEndedHandler),this.callEndedHandler=null),this.element.remove(),this.element=null),this.errorHandler&&(window.removeEventListener("error",this.errorHandler),window.removeEventListener("unhandledrejection",this.errorHandler),this.errorHandler=null),this.storageHandler&&(window.removeEventListener("storage",this.storageHandler),this.storageHandler=null),this.config=null,this.activeCallId=null,this.callHistory=[],this.isMuted=!1,this.isRecording=!1}setupEventListeners(){this.element&&(this.callEndedHandler=()=>{this.activeCallId=null,this.isMuted=!1,this.isRecording=!1},this.element.addEventListener("call-ended",this.callEndedHandler))}generateCallId(){return`call-${Date.now()}-${Math.random().toString(36).substring(2,11)}`}get isMutedState(){return this.isMuted}get isRecordingState(){return this.isRecording}}const n=new t;let i=!1;class r{constructor(e,t){this.authToken=null,this.baseUrl=e.replace(/\/$/,""),this.authToken=t||null}setAuthToken(e){this.authToken=e}getHeaders(){const e={"Content-Type":"application/json"};return this.authToken&&(e.Authorization=`Bearer ${this.authToken}`),e}async fetchOrderedNumbers(e){const{domainId:t,limit:n=100,status:i="provisioned"}=e,r=new URL(`${this.baseUrl}/v3/dialer/domains/${t}/phone-numbers`);i&&r.searchParams.set("status",i),r.searchParams.set("limit",n.toString());const o=await fetch(r.toString(),{method:"GET",headers:this.getHeaders()});if(!o.ok)throw new Error(`Failed to fetch phone numbers: ${o.status} ${o.statusText}`);const a=await o.json(),d=a.data||a;return{items:d.items||[],total:d.total||0}}}const o={2:"ABC",3:"DEF",4:"GHI",5:"JKL",6:"MNO",7:"PQRS",8:"TUV",9:"WXYZ"},a={idle:["dialing","error"],dialing:["ringing","connected","ended","error"],ringing:["connected","ended","error"],connected:["ended","error"],ended:["idle"],error:["idle","ended"]};class d{constructor(e={}){this.devices=[],this.onDevicesChangedCb=null,this.onMicrophoneChangedCb=null,this.onSpeakerChangedCb=null,this.deviceChangeHandler=null,this.onDevicesChangedCb=e.onDevicesChanged??null,this.onMicrophoneChangedCb=e.onMicrophoneChanged??null,this.onSpeakerChangedCb=e.onSpeakerChanged??null,"undefined"!=typeof navigator&&navigator.mediaDevices&&(this.deviceChangeHandler=()=>this.handleDeviceChange(),navigator.mediaDevices.addEventListener("devicechange",this.deviceChangeHandler))}destroy(){this.deviceChangeHandler&&"undefined"!=typeof navigator&&navigator.mediaDevices&&(navigator.mediaDevices.removeEventListener("devicechange",this.deviceChangeHandler),this.deviceChangeHandler=null),this.onDevicesChangedCb=null,this.onMicrophoneChangedCb=null,this.onSpeakerChangedCb=null}async handleDeviceChange(){const e=await this.enumerateDevices(),t=this.loadPreferences(),n=e.filter(e=>"audioinput"===e.kind),i=e.filter(e=>"audiooutput"===e.kind);if(t.microphoneId&&n.length>0){if(!n.some(e=>e.deviceId===t.microphoneId)){const e=n[0].deviceId;console.warn(`[AudioDeviceManager] Preferred mic removed — switching to ${n[0].label}`),this.savePreferences({...t,microphoneId:e}),this.onMicrophoneChangedCb?.(e)}}if(t.speakerId&&i.length>0){if(!i.some(e=>e.deviceId===t.speakerId)){const e=i[0].deviceId;console.warn(`[AudioDeviceManager] Preferred speaker removed — switching to ${i[0].label}`),this.savePreferences({...t,speakerId:e}),this.onSpeakerChangedCb?.(e)}}}async enumerateDevices(){if("undefined"==typeof navigator||!navigator.mediaDevices)return[];try{const e=await navigator.mediaDevices.enumerateDevices();return this.devices=e.filter(e=>"audioinput"===e.kind||"audiooutput"===e.kind).map(e=>({deviceId:e.deviceId,label:e.label||`${"audioinput"===e.kind?"Microphone":"Speaker"} ${e.deviceId.slice(0,8)}`,kind:e.kind})),this.onDevicesChangedCb?.(this.devices),this.devices}catch(e){return console.error("[AudioDeviceManager] Failed to enumerate devices:",e),[]}}async refreshDevices(){return this.enumerateDevices()}getMicrophones(){return this.devices.filter(e=>"audioinput"===e.kind)}getSpeakers(){return this.devices.filter(e=>"audiooutput"===e.kind)}setOnDevicesChanged(e){this.onDevicesChangedCb=e}savePreferences(e){if("undefined"!=typeof window&&"undefined"!=typeof Storage&&window.localStorage)try{localStorage.setItem(d.STORAGE_KEY,JSON.stringify(e))}catch(e){console.error("[AudioDeviceManager] Failed to save preferences:",e)}}loadPreferences(){if("undefined"==typeof window||"undefined"==typeof Storage||!window.localStorage)return{microphoneId:null,speakerId:null};try{const e=localStorage.getItem(d.STORAGE_KEY);if(e)return JSON.parse(e)}catch(e){console.error("[AudioDeviceManager] Failed to load preferences:",e)}return{microphoneId:null,speakerId:null}}async applyAudioOutputDevice(e,t){if("function"==typeof e.setSinkId)try{await e.setSinkId(t)}catch(e){throw console.error("[AudioDeviceManager] Failed to set audio output:",e),e}else console.warn("[AudioDeviceManager] Browser does not support setSinkId")}async getAudioConstraints(e){return{audio:e?{deviceId:{exact:e},echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0}:{echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0},video:!1}}}d.STORAGE_KEY="convirza_audio_devices";const s={excellent:{packetLoss:.5,jitter:20,latency:100},good:{packetLoss:1,jitter:30,latency:200},fair:{packetLoss:3,jitter:50,latency:300}};class l{constructor(e=s){this.peerConnection=null,this.intervalId=null,this.onQualityChange=null,this.lastMetrics=null,this.previousBytesReceived=0,this.previousTimestamp=0,this.thresholds=e}start(e,t=2e3){this.stop(),this.peerConnection=e,this.intervalId=window.setInterval(async()=>{await this.collectMetrics()},t)}stop(){this.intervalId&&(clearInterval(this.intervalId),this.intervalId=null),this.peerConnection=null,this.lastMetrics=null,this.previousBytesReceived=0,this.previousTimestamp=0}setOnQualityChange(e){this.onQualityChange=e}getLastMetrics(){return this.lastMetrics}async collectMetrics(){if(this.peerConnection)try{const e=await this.peerConnection.getStats();let t=0,n=0,i=0,r=0,o=0;e.forEach(e=>{if("inbound-rtp"===e.type&&"audio"===e.kind){if(e.bytesReceived&&e.timestamp){const n=e.bytesReceived,i=e.timestamp;if(this.previousTimestamp>0){const e=(i-this.previousTimestamp)/1e3;e>0&&(t=8*(n-this.previousBytesReceived)/e/1e3)}this.previousBytesReceived=n,this.previousTimestamp=i}if(void 0!==e.packetsLost&&void 0!==e.packetsReceived){const t=e.packetsReceived+e.packetsLost;t>0&&(n=e.packetsLost/t*100)}void 0!==e.jitter&&(i=1e3*e.jitter),void 0!==e.audioLevel&&(o=e.audioLevel)}"candidate-pair"===e.type&&"succeeded"===e.state&&void 0!==e.currentRoundTripTime&&(r=1e3*e.currentRoundTripTime)});const a=this.calculateQuality(n,i,r),d={bitrate:Math.round(t),packetLoss:Math.round(100*n)/100,jitter:Math.round(10*i)/10,latency:Math.round(r),audioLevel:Math.round(100*o)/100,quality:a};this.lastMetrics=d,this.onQualityChange?.(d)}catch(e){console.error("[CallQualityMonitor] Failed to collect metrics:",e)}}calculateQuality(e,t,n){const{excellent:i,good:r,fair:o}=this.thresholds;return e<=i.packetLoss&&t<=i.jitter&&n<=i.latency?"excellent":e<=r.packetLoss&&t<=r.jitter&&n<=r.latency?"good":e<=o.packetLoss&&t<=o.jitter&&n<=o.latency?"fair":"poor"}}const c={REGISTER_EXPIRES:300,QUALITY_INTERVAL_MS:2e3,STUN_SERVERS:[{urls:"stun:stun.l.google.com:19302"}],MAX_RECONNECTION_ATTEMPTS:3,RECONNECTION_TIMEOUT_S:4},h=36e5,u=50;let p=null;function $(){return void 0!==window.SIP||void 0!==window.sip}async function g(){return $()?Promise.resolve():p||(p=new Promise((e,t)=>{const n=document.createElement("script");n.src="https://cdn.jsdelivr.net/npm/sip.js@0.13.8/dist/sip.js",n.async=!0;const i=setTimeout(()=>{r(),t(new Error("SIP.js load timeout after 10000ms"))},1e4),r=()=>{clearTimeout(i),n.removeEventListener("load",o),n.removeEventListener("error",a)},o=()=>{r(),$()?(console.log("[Dialer] SIP.js loaded from CDN"),e()):t(new Error("SIP.js loaded but global not found"))},a=e=>{r(),t(new Error(`Failed to load SIP.js from CDN: ${e}`))};n.addEventListener("load",o),n.addEventListener("error",a),document.head.appendChild(n)}),p)}class m{constructor(e,t={}){this.userAgent=null,this.currentSession=null,this.registerer=null,this.audioElement=null,this.isMuted=!1,this.localHangup=!1,this.currentCallUuid=null,this.currentCallIsChannelUuid=!1,this.currentCallSipCallId=null,this.reconnectAttempts=0,this.reconnectTimer=null,this.iceDisconnectedTimer=null,this.config=e,this.callbacks=t,this.audioDeviceManager=new d({onMicrophoneChanged:async e=>{if(this.currentSession)try{await this.setMicrophone(e)}catch(e){this.callbacks.onError?.(new Error(`Auto mic-swap failed: ${e.message}`))}},onSpeakerChanged:async e=>{if(this.audioElement)try{await this.setSpeaker(e)}catch{}},onDevicesChanged:e=>{this.callbacks.onDevicesChanged?.(e)}}),this.qualityMonitor=new l,this.setupQualityMonitor()}setupQualityMonitor(){this.qualityMonitor.setOnQualityChange(e=>{this.callbacks.onQualityChange?.(e)})}getLocalAudioConstraints(){const e={echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0};return this.config.microphoneId?{...e,deviceId:{ideal:this.config.microphoneId}}:e}setupAudioElement(){this.audioElement||(this.audioElement=document.createElement("audio"),this.audioElement.autoplay=!0,this.audioElement.volume=1,document.body.appendChild(this.audioElement),this.config.speakerId&&this.audioDeviceManager.applyAudioOutputDevice(this.audioElement,this.config.speakerId).catch(e=>{console.warn("[SipAdapter] Failed to apply speaker preference:",e)}))}async connect(){this.setupAudioElement(),await g();const e=window.SIP||window.sip,t=`${this.config.sipUsername}@${this.config.sipDomain}`;this.userAgent=new e.UA({uri:`sip:${t}`,transportOptions:{wsServers:this.config.wsServers,traceSip:!0},authorizationUser:this.config.sipUsername,password:this.config.sipPassword,displayName:this.config.displayName||this.config.sipUsername,contactName:this.config.sipUsername,register:!0,registerExpires:c.REGISTER_EXPIRES,hackWssInTransport:!0,hackViaTcp:!0,hackIpInContact:!0,contactTransport:"wss",extraSupported:[],sessionDescriptionHandlerFactoryOptions:{constraints:{audio:this.getLocalAudioConstraints(),video:!1},peerConnectionOptions:{rtcConfiguration:{iceServers:this.config.iceServers||c.STUN_SERVERS,rtcpMuxPolicy:"negotiate"},iceCheckingTimeout:15e3}}}),this.userAgent.on("registered",()=>{this.callbacks.onRegistered?.()}),this.userAgent.on("unregistered",()=>{this.callbacks.onUnregistered?.()}),this.userAgent.on("invite",e=>{this.handleIncomingCall(e)}),this.userAgent.on("registrationFailed",(e,t)=>{console.error("[SIP] Registration failed:",t),"Authorization Error"!==t&&this.scheduleReconnect(!1),this.callbacks.onRegistrationFailed?.(t)}),this.userAgent.on("transportError",()=>{console.error("[SIP] WebSocket transport error"),this.scheduleReconnect(!!this.currentSession),this.callbacks.onTransportError?.(new Error("WebSocket transport error"))}),this.userAgent.on("connecting",()=>{this.callbacks.onConnecting?.()}),this.userAgent.start()}async disconnect(){this.currentSession&&await this.endCall(),this.userAgent&&(this.userAgent.stop(),this.userAgent=null),this.audioElement&&(this.audioElement.pause(),this.audioElement.srcObject=null,this.audioElement.remove(),this.audioElement=null),this.audioDeviceManager.destroy()}async call(e,t){if(!this.userAgent)throw new Error("UserAgent not initialized. Call connect() first.");if(this.currentSession)throw new Error("Call already in progress");const n=`sip:${e}@${this.config.sipDomain}`,i={sessionDescriptionHandlerOptions:{constraints:{audio:this.getLocalAudioConstraints(),video:!1}}};if(t?.callerId){const e=t.callerIdName?`"${t.callerIdName}" <sip:${t.callerId}@${this.config.sipDomain}>`:`<sip:${t.callerId}@${this.config.sipDomain}>`;i.extraHeaders=[`P-Asserted-Identity: ${e}`]}const r=this.userAgent.invite(n,i);this.currentSession=r;try{const e=r.request?.callId??r.dialog?.id?.callId;e&&(this.currentCallSipCallId=e,this.currentCallUuid=e,this.currentCallIsChannelUuid=!1)}catch(e){console.warn("[SIP] Failed to extract Call-ID from INVITE:",e)}r.delegate={onBye:e=>{console.log("[SIP] SessionDelegate.onBye called (outbound), localHangup:",this.localHangup,"hasSession:",!!this.currentSession),!this.localHangup&&this.currentSession&&(this.cleanupSession(),this.callbacks.onCallEnded?.("remote-hangup"))}},r.on("progress",()=>{this.callbacks.onCallRinging?.()}),r.on("accepted",e=>{try{const t=e?.headers?.["x-fs-uuid"]?.[0]?.raw||e?.headers?.["X-FS-UUID"]?.[0]?.raw;if(t)this.currentCallUuid=t,this.currentCallIsChannelUuid=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(t);else{const e=r.dialog?.id?.callId??this.currentCallSipCallId;e&&(this.currentCallUuid=e),this.currentCallIsChannelUuid=!1,console.warn("[SIP] X-FS-UUID not received — using SIP Call-ID for park; backend will resolve via ESL")}}catch(e){console.warn("[SIP] Failed to extract call UUID:",e)}try{const e=r.sessionDescriptionHandler?.remoteDescription?.sdp;e&&!e.includes("a=rtcp-mux")&&console.warn("[SipAdapter] Remote SDP missing a=rtcp-mux — call may fail in strict environments")}catch{}this.setupRemoteMedia(r),this.monitorPeerConnection(r),this.startQualityMonitoring(r),this.reconnectAttempts=0,this.callbacks.onCallAnswered?.()}),r.on("info",e=>{try{const t=e?.getHeader?.("Content-Type")??"",n=e?.body??"";t.includes("application/x-recording-command")&&this.callbacks.onRecordingStateChange?.("start"===n.trim()),e.reply(200)}catch{}}),r.on("notify",e=>{try{const t=e?.body??"";t.startsWith("SIP/2.0 200")?this.callbacks.onTransferSucceeded?.():/SIP\/2.0 [45]\d\d/.test(t)&&this.callbacks.onTransferFailed?.(t.split("\r\n")[0]),e.reply(200)}catch{}}),r.on("failed",e=>{console.error("[SIP] Call failed. Error:",e),console.error("[SIP] Status:",e?.statusCode,e?.reasonPhrase),this.cleanupSession();const t=new Error(e?.reasonPhrase||"Call failed");t.statusCode=e?.statusCode,t.originalError=e,this.callbacks.onCallFailed?.(t)}),r.on("cancel",()=>{this.cleanupSession(),this.callbacks.onCallEnded?.("remote-cancel")}),r.on("rejected",(e,t)=>{const n=e?.statusCode||t;console.log("[SIP] Call rejected:",t||n),this.cleanupSession(),this.callbacks.onCallEnded?.(`rejected-${n}`)}),r.on("hold",()=>{this.callbacks.onRemoteHold?.(!0)}),r.on("unhold",()=>{this.callbacks.onRemoteHold?.(!1)})}async endCall(){if(this.currentSession){this.localHangup=!0;try{const e=this.currentSession;e.dialog?e.bye():"function"==typeof e.cancel?e.cancel():"function"==typeof e.terminate&&e.terminate()}catch(e){console.error("[SIP] Error ending call:",e)}finally{this.cleanupSession()}}}mute(e){if(!this.currentSession)return this.isMuted;const t=this.currentSession.sessionDescriptionHandler;if(!t)return this.isMuted;this.isMuted=void 0!==e?e:!this.isMuted;const n=t.peerConnection;return n&&n.getSenders().forEach(e=>{e.track&&"audio"===e.track.kind&&(e.track.enabled=!this.isMuted)}),this.isMuted}hold(e){return new Promise((t,n)=>{if(!this.currentSession)return n(new Error("No active session"));if(!this.currentSession.dialog)return n(new Error("Session not established"));const i=void 0===e||e;try{i?this.currentSession.hold():this.currentSession.unhold(),t()}catch(e){n(e)}})}sendDTMF(e){if(!this.currentSession)throw new Error("No active session");if(!this.currentSession.dialog)throw new Error("Session not established");const t={body:{contentType:"application/dtmf-relay",body:`Signal=${e}\r\nDuration=100`}};this.currentSession.sendRequest("INFO",t)}startRecording(){if(!this.currentSession)throw new Error("No active session");if(!this.currentSession.dialog)throw new Error("Session not established");this.currentSession.sendRequest("INFO",{body:{contentType:"application/x-recording-command",body:"start"}})}stopRecording(){if(!this.currentSession)throw new Error("No active session");if(!this.currentSession.dialog)throw new Error("Session not established");this.currentSession.sendRequest("INFO",{body:{contentType:"application/x-recording-command",body:"stop"}})}async park(e){if(!this.currentSession)throw new Error("No active session");if(!this.currentSession.dialog)throw new Error("Session not established");if(!this.currentCallUuid)throw new Error("Call UUID not available");if(!this.config.apiUrl)throw new Error("API URL not configured");if(!this.config.authToken)throw new Error("Auth token not configured");try{const e=new URL(this.config.apiUrl);if("https:"!==e.protocol&&"localhost"!==e.hostname&&"127.0.0.1"!==e.hostname)throw new Error("API URL must use HTTPS to protect the auth token")}catch(e){if(e.message.includes("HTTPS"))throw e;throw new Error(`Invalid API URL: ${this.config.apiUrl}`)}const t=`${this.config.apiUrl.replace(/\/$/,"")}/v3/park-slots/park`,n={callUuid:this.currentCallUuid,isChannelUuid:this.currentCallIsChannelUuid,sipCallId:this.currentCallSipCallId,slotExtension:e,domain:this.config.sipDomain},i=new AbortController,r=setTimeout(()=>i.abort(),1e4);try{const e=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.config.authToken}`},body:JSON.stringify(n),signal:i.signal});if(clearTimeout(r),!e.ok){const t=await e.text();throw new Error(`Park failed: ${e.status} ${t}`)}console.log("[SIP] Park request successful, waiting for server to transfer call")}catch(e){if(clearTimeout(r),"AbortError"===e.name)throw new Error("Park request timeout - backend not responding");throw e}}handleIncomingCall(e){let t,n=e.remoteIdentity.uri.user;console.log("[SIP] ═══ INCOMING CALL DEBUG START ═══"),console.log("[SIP] Initial fallback callerNumber from remoteIdentity.uri.user:",n);try{const i=e.request?.getHeader?.("X-Convirza-Caller-ID"),r=e.request?.getHeader?.("From"),o=e.request?.getHeader?.("P-Asserted-Identity"),a=e.request?.getHeader?.("Remote-Party-ID"),d=e.request?.getHeader?.("Contact"),s=e.request?.getHeader?.("X-Caller-ID");if(console.log("[SIP] Incoming call headers:",{"X-Convirza-Caller-ID":i,From:r,"P-Asserted-Identity":o,"Remote-Party-ID":a,Contact:d,"X-Caller-ID":s}),console.log("[SIP] Full remoteIdentity URI:",e.remoteIdentity.uri.toString()),i){console.log("[SIP] Processing X-Convirza-Caller-ID header (HIGHEST PRIORITY - bypasses FreeSWITCH)...");const e=i.match(/"([^"]+)"/);e&&e[1]?(t=e[1],console.log("[SIP] ✓ Extracted callerName from X-Convirza-Caller-ID:",t)):console.log("[SIP] ✗ No display name found in X-Convirza-Caller-ID");let r=i.match(/<sip:([^@>]+)@/);if(console.log("[SIP] Regex match with angle brackets:",r),r||(console.log("[SIP] Trying regex WITHOUT angle brackets..."),r=i.match(/sip:([^@>\s]+)@/),console.log("[SIP] Regex match without angle brackets:",r)),r&&r[1]){const e=n;n=r[1],console.log(`[SIP] ✓ Extracted callerNumber from X-Convirza-Caller-ID: ${n} (was: ${e})`)}else console.warn(`[SIP] ✗ Failed to extract number from X-Convirza-Caller-ID: ${i}`)}else if(o){console.log("[SIP] Processing P-Asserted-Identity header...");const e=o.match(/"([^"]+)"/);e&&e[1]?(t=e[1],console.log("[SIP] ✓ Extracted callerName from P-Asserted-Identity:",t)):console.log("[SIP] ✗ No display name found in P-Asserted-Identity");let i=o.match(/<sip:([^@>]+)@/);if(console.log("[SIP] Regex match with angle brackets:",i),i||(console.log("[SIP] Trying regex WITHOUT angle brackets..."),i=o.match(/sip:([^@>\s]+)@/),console.log("[SIP] Regex match without angle brackets:",i)),i&&i[1]){const e=n;n=i[1],console.log(`[SIP] ✓ Extracted callerNumber from P-Asserted-Identity: ${n} (was: ${e})`)}else console.warn(`[SIP] ✗ Failed to extract number from P-Asserted-Identity: ${o}`)}else if(a){const e=a.match(/"([^"]+)"/);e&&e[1]&&(t=e[1]);let i=a.match(/<sip:([^@>]+)@/);i||(i=a.match(/sip:([^@>\s]+)@/)),i&&i[1]?(n=i[1],console.log(`[SIP] Extracted caller ID from Remote-Party-ID: ${n}, Name: ${t||"(none)"}`)):console.warn(`[SIP] Failed to extract number from Remote-Party-ID: ${a}`)}else s&&(n=s.replace(/[<>"]/g,""),console.log(`[SIP] Extracted caller ID from X-Caller-ID: ${n}`))}catch(e){console.warn("[SIP] Failed to extract caller ID from headers, using From:",e)}console.log("[SIP] ═══ FINAL RESULT ═══"),console.log("[SIP] Final callerNumber:",n),console.log("[SIP] Final callerName:",t),console.log("[SIP] ═══ INCOMING CALL DEBUG END ═══");const i={onBye:e=>{console.log("[SIP] ===== SessionDelegate.onBye FIRED ===== localHangup:",this.localHangup,"hasSession:",!!this.currentSession),!this.localHangup&&this.currentSession&&(this.cleanupSession(),this.callbacks.onCallEnded?.("remote-hangup"))},onAck:e=>{console.log("[SIP] SessionDelegate.onAck FIRED")},onInfo:e=>{console.log("[SIP] SessionDelegate.onInfo FIRED")},onInvite:(e,t,n)=>{console.log("[SIP] SessionDelegate.onInvite FIRED")}};e.delegate=i,console.log("[SIP] SessionDelegate set on invitation"),"function"==typeof e.on&&e.on("receiveRequest",e=>{console.log("[SIP] ===== receiveRequest event FIRED ===== method:",e?.method),"BYE"===e?.method&&(console.log("[SIP] BYE request received via receiveRequest event!"),!this.localHangup&&this.currentSession&&(this.cleanupSession(),this.callbacks.onCallEnded?.("remote-hangup")))}),this.callbacks.onIncomingCall?.(n,t),this.currentSession=e;try{const t=e.request?.callId;t&&(this.currentCallSipCallId=t,this.currentCallUuid=t,this.currentCallIsChannelUuid=!1)}catch(e){console.warn("[SIP] Failed to extract Call-ID from inbound INVITE:",e)}console.log("[SIP] Verifying delegate after session assignment:",!!e.delegate),e.on("accepted",t=>{try{const e=t?.headers?.["x-fs-uuid"]?.[0]?.raw||t?.headers?.["X-FS-UUID"]?.[0]?.raw;e&&(this.currentCallUuid=e,this.currentCallIsChannelUuid=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e))}catch{}console.log("[SIP] ===== Call accepted, re-setting SessionDelegate on established session ====="),console.log("[SIP] Session state after accept:",e.state);const n={onBye:e=>{console.log("[SIP] ===== SessionDelegate.onBye FIRED ===== session state:",this.currentSession?.state,"localHangup:",this.localHangup,"hasSession:",!!this.currentSession),!this.localHangup&&this.currentSession&&(this.cleanupSession(),this.callbacks.onCallEnded?.("remote-hangup"))},onAck:t=>{console.log("[SIP] SessionDelegate.onAck FIRED, session state:",e.state)},onInfo:e=>{console.log("[SIP] SessionDelegate.onInfo FIRED")}};e.delegate=n,console.log("[SIP] SessionDelegate re-set after accept, delegate exists:",!!e.delegate),this.setupRemoteMedia(e),this.monitorPeerConnection(e),this.startQualityMonitoring(e),this.reconnectAttempts=0,this.callbacks.onCallAnswered?.()}),e.on("info",e=>{try{const t=e?.getHeader?.("Content-Type")??"",n=e?.body??"";t.includes("application/x-recording-command")&&this.callbacks.onRecordingStateChange?.("start"===n.trim()),e.reply(200)}catch{}}),e.on("notify",e=>{try{const t=e?.body??"";t.startsWith("SIP/2.0 200")?this.callbacks.onTransferSucceeded?.():/SIP\/2.0 [45]\d\d/.test(t)&&this.callbacks.onTransferFailed?.(t.split("\r\n")[0]),e.reply(200)}catch{}}),e.on("failed",e=>{console.error("[SIP] Incoming call failed:",e),this.cleanupSession(),this.callbacks.onCallFailed?.(e)}),e.on("cancel",()=>{this.cleanupSession(),this.callbacks.onCallEnded?.("remote-cancel")}),e.on("hold",()=>{this.callbacks.onRemoteHold?.(!0)}),e.on("unhold",()=>{this.callbacks.onRemoteHold?.(!1)})}async answerCall(){if(!this.currentSession)throw new Error("No incoming call");if("function"!=typeof this.currentSession.accept)throw new Error("Current session is not an incoming call");const e={sessionDescriptionHandlerOptions:{constraints:{audio:this.getLocalAudioConstraints(),video:!1}}};await this.currentSession.accept(e)}async rejectCall(){if(!this.currentSession)return;const e=window.SIP||window.sip;this.currentSession instanceof e.Invitation&&await this.currentSession.reject(),this.cleanupSession()}setupRemoteMedia(e){const t=e.sessionDescriptionHandler?.peerConnection;if(!t)return;const n=new MediaStream;t.getReceivers().forEach(e=>{e.track&&n.addTrack(e.track)}),this.audioElement&&(this.audioElement.srcObject=n),t.ontrack=e=>{if(!this.audioElement)return;const t=this.audioElement.srcObject;t?t.addTrack(e.track):this.audioElement.srcObject=e.streams[0]??new MediaStream([e.track])}}stopLocalTracks(){if(!this.currentSession)return;const e=this.currentSession.sessionDescriptionHandler?.peerConnection;e&&e.getSenders().forEach(e=>{e.track&&e.track.stop()})}cleanupSession(){if(this.iceDisconnectedTimer&&(clearTimeout(this.iceDisconnectedTimer),this.iceDisconnectedTimer=null),this.currentSession){const e=this.currentSession;["progress","accepted","terminated","bye","failed","cancel","rejected","hold","unhold","info","notify"].forEach(t=>{try{e.removeAllListeners?.(t)}catch{}})}this.qualityMonitor.stop(),this.stopLocalTracks(),this.audioElement&&(this.audioElement.srcObject=null),this.currentSession=null,this.currentCallUuid=null,this.currentCallIsChannelUuid=!1,this.currentCallSipCallId=null,this.isMuted=!1,this.localHangup=!1}startQualityMonitoring(e){const t=e.sessionDescriptionHandler?.peerConnection;t&&this.qualityMonitor.start(t,c.QUALITY_INTERVAL_MS)}get isConnected(){return null!==this.userAgent}get hasActiveCall(){return null!==this.currentSession}async setMicrophone(e){this.config.microphoneId=e;const t=this.audioDeviceManager.loadPreferences();if(t.microphoneId=e,this.audioDeviceManager.savePreferences(t),!this.currentSession)return;const n=await this.audioDeviceManager.getAudioConstraints(e||null);let i;try{i=await navigator.mediaDevices.getUserMedia(n)}catch(e){throw new Error(`Microphone access denied: ${e.message}`)}const r=i.getAudioTracks()[0];if(!r)throw i.getTracks().forEach(e=>e.stop()),new Error("No audio track returned from getUserMedia");const o=this.currentSession.sessionDescriptionHandler?.peerConnection,a=o?.getSenders().find(e=>"audio"===e.track?.kind);if(a){const e=a.track;try{await a.replaceTrack(r),e?.stop(),this.isMuted&&(r.enabled=!1)}catch(e){throw r.stop(),new Error(`Failed to switch microphone: ${e.message}`)}}else r.stop()}async setSpeaker(e){this.config.speakerId=e,this.audioElement&&await this.audioDeviceManager.applyAudioOutputDevice(this.audioElement,e);const t=this.audioDeviceManager.loadPreferences();t.speakerId=e,this.audioDeviceManager.savePreferences(t)}async getAudioDevices(){return await this.audioDeviceManager.refreshDevices(),{microphones:this.audioDeviceManager.getMicrophones(),speakers:this.audioDeviceManager.getSpeakers()}}getCallUuid(){return this.currentCallUuid}getCurrentDevices(){const e=this.audioDeviceManager.loadPreferences();return{microphoneId:this.config.microphoneId||e.microphoneId,speakerId:this.config.speakerId||e.speakerId}}getCallQuality(){return this.qualityMonitor.getLastMetrics()}async blindTransfer(e){if(!this.currentSession)throw new Error("No active call");if(!this.currentSession.dialog)throw new Error("Session not established");const t=e.includes("@")?e:`sip:${e}@${this.config.sipDomain}`;return new Promise((e,n)=>{try{const i=this.currentSession.refer(t);i.on("requestSucceeded",()=>e()),i.on("requestFailed",(e,t)=>{n(new Error(`Transfer failed: ${t||"unknown"}`))})}catch(e){n(new Error(`Transfer error: ${e.message}`))}})}monitorPeerConnection(e){const t=e?.sessionDescriptionHandler?.peerConnection;t&&(t.addEventListener("iceconnectionstatechange",()=>{const n=t.iceConnectionState;if("failed"===n){console.warn("[SIP] ICE failed — attempting ICE restart");try{t.restartIce?.(),e.reinvite?.()}catch(e){this.callbacks.onCallFailed?.(new Error("ICE connection failed"))}}else"disconnected"===n?this.iceDisconnectedTimer=window.setTimeout(()=>{"disconnected"===t.iceConnectionState&&(console.error("[SIP] ICE disconnected — no recovery after 10s"),this.callbacks.onCallFailed?.(new Error("Network connection lost")))},1e4):"connected"!==n&&"completed"!==n||this.iceDisconnectedTimer&&(clearTimeout(this.iceDisconnectedTimer),this.iceDisconnectedTimer=null)}),t.addEventListener("connectionstatechange",()=>{"failed"===t.connectionState&&(console.error("[SIP] RTCPeerConnection failed"),this.callbacks.onCallFailed?.(new Error("Peer connection failed")))}))}scheduleReconnect(e){const t=c.MAX_RECONNECTION_ATTEMPTS,n=1e3*c.RECONNECTION_TIMEOUT_S;if(null!==this.reconnectTimer)return;if(this.reconnectAttempts>=t)return console.error("[SIP] Max reconnect attempts reached"),void(e&&this.callbacks.onCallFailed?.(new Error("Connection lost after max retries")));const i=n*Math.pow(2,this.reconnectAttempts);this.reconnectAttempts++,console.warn(`[SIP] Reconnecting in ${i}ms (attempt ${this.reconnectAttempts}/${t})`),this.reconnectTimer=window.setTimeout(async()=>{this.reconnectTimer=null;try{const e=this.userAgent?.transport;e?.connect?await e.connect():this.userAgent?.start?.(),this.reconnectAttempts=0}catch(t){this.scheduleReconnect(e)}},i)}reconnect(){null!==this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.reconnectAttempts=0,this.scheduleReconnect(!!this.currentSession)}}var b={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(?:48|5[0-3579]|[6-9])|7(?:20|32|8)|[89]","(?:31|4)6|51|6(?:485|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,[["(?:(?:241|349)0\\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])|[34]\\d\\d)|91(?:(?:[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}|(?:2(?:[0-26-9]\\d|3[0-8]|4[02-9]|5[0135-9])|3(?:[0-3589]\\d|4[0-578]|6[1-9]|7[0-35-9])|7(?:[013-57-9]\\d|2[0-8])|8(?:55|6[0-8]|[78]\\d|9[02-9]))\\d{6}",[9]],["4(?:79[01]|83[0-36-9]|95[0-3])\\d{5}|4(?:[0-36]\\d|4[047-9]|[58][0-24-9]|7[02-8]|9[0-47-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]|2[23]"],"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","[024-7]\\d{7}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[024-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","(?:01\\d|8)\\d{7}",[8,10],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4 $5",["0"]]]],BL:["590","00","7090\\d{5}|(?:[56]9|[89]\\d)\\d{7}",[9],0,"0",0,0,0,0,0,[["(?:59(?:0(?:2[7-9]|3[3-7]|5[12]|87)|87\\d)|80[6-9]\\d\\d)\\d{4}"],["(?:69(?:0\\d\\d|1(?:2[2-9]|3[0-5]))|7090[0-4])\\d{4}"],["80[0-5]\\d{6}"],["8[129]\\d{7}"],0,0,0,0,["9(?:(?:39[5-7]|76[018])\\d|475[0-6])\\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-7]\\d\\d|8001)\\d{5}",[8,9],[["(\\d)(\\d{7})","$1 $2",["[23]|4[46]|50"]],["(\\d{8})","$1",["[5-7]"]],["(\\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-467]\\d{9,10}|55[0-46-9]\\d{8}|[34]\\d{7}|55\\d{7,8}|(?:5[0-46-9]|[89]\\d)\\d{7,9}",[8,9,10,11],[["(\\d{4})(\\d{4})","$1-$2",["300|4(?:0[02]|37|86)","300|4(?:0(?:0|20)|370|864)"]],["(\\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","[178]\\d{7}|[2-8]\\d{6}",[7,8],[["(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["[2-6]|7[246]|8[2-4]"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["1[67]|[78]"]]]],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-9]\\d{9}|3\\d{6}",[7,10],0,"1",0,0,0,0,0,[["(?:2(?:04|[23]6|[48]9|5[07]|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])|9(?:0[25]|42))[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(?:2[125-9]|3[23]|44|66|77|88)|6(?:22|33))[2-9]\\d{6}",[10]],0,["310\\d{4}",[7]],0,["600[2-9]\\d{6}",[10]]]],CC:["61","001[14-689]|14(?:1[14]|34|4[17]|[56]6|7[47]|88)0011","1(?:[0-79]\\d{8}(?:\\d{2})?|8[0-24-9]\\d{7})|[148]\\d{8}|1\\d{5,7}",[6,7,8,9,10,12],0,"0",0,"([59]\\d{7})$|0","8$1",0,0,[["8(?:51(?:0(?:02|31|60|89)|1(?:18|76)|223)|91(?:0(?:1[0-2]|29)|1(?:[28]2|50|79)|2(?:10|64)|3(?:[06]8|22)|4[29]8|62\\d|70[23]|959))\\d{3}",[9]],["4(?:79[01]|83[0-36-9]|95[0-3])\\d{5}|4(?:[0-36]\\d|4[047-9]|[58][0-24-9]|7[02-8]|9[0-47-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]|5\\d)\\d|2)\\d{7}|[1-68]\\d{6}",[7,8,9,10],[["(\\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{2})(\\d{4})","$1 $2 $3",["2"],"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"],["(\\d{2})(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3 $4",["5"],"0$1"]],"0"],CF:["236","00","8776\\d{4}|(?:[27]\\d|61)\\d{6}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[26-8]"]]]],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,12],[["(\\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{3})(\\d{3})(\\d{3})","$1 $2 $3",["60|809"]],["(\\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(?:10|[2-9])"]],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["3[2-5]|[47]|5[1-3578]|6[13-57]|8(?:0[1-8]|[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[03-689]|2\\d)\\d\\d|6)\\d{8}|1\\d{10}|[126]\\d{6}(?:\\d(?:\\d{2})?)?|86\\d{5,6}|(?:[3-579]\\d|8[0-57-9])\\d{5,9}",[7,8,9,10,11,12],[["(\\d{2})(\\d{5,6})","$1 $2",["(?:10|2[0-57-9])[19]|3(?:[157]|35|49|9[1-68])|4(?:1[124-9]|2[179]|6[47-9]|7|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(?:07|1[236-8]|2[5-7]|[37]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|3|4[13]|5[1-5]|7[0-79]|9[0-35-9])|(?:4[35]|59|85)[1-9]","(?:10|2[0-57-9])(?:1[02]|9[56])|8078|(?:3(?:[157]\\d|35|49|9[1-68])|4(?:1[124-9]|2[179]|[35][1-9]|6[47-9]|7\\d|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]|3\\d|4[13]|5[1-5]|7[0-79]|9[0-35-9]))1","10(?:1(?:0|23)|9[56])|2[0-57-9](?:1(?:00|23)|9[56])|80781|(?:3(?:[157]\\d|35|49|9[1-68])|4(?:1[124-9]|2[179]|[35][1-9]|6[47-9]|7\\d|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]|3\\d|4[13]|5[1-5]|7[0-79]|9[0-35-9]))12","10(?:1(?:0|23)|9[56])|2[0-57-9](?:1(?:00|23)|9[56])|807812|(?:3(?:[157]\\d|35|49|9[1-68])|4(?:1[124-9]|2[179]|[35][1-9]|6[47-9]|7\\d|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]|3\\d|4[13]|5[1-5]|7[0-79]|9[0-35-9]))123","10(?:1(?:0|23)|9[56])|2[0-57-9](?:1(?:00|23)|9[56])|(?:3(?:[157]\\d|35|49|9[1-68])|4(?:1[124-9]|2[179]|[35][1-9]|6[47-9]|7\\d|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(?:078|1[236-8]|2[5-7]|[37]\\d|5[1-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|3\\d|4[13]|5[1-5]|7[0-79]|9[0-35-9]))123"],"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])","(?:46|60\\d\\d)\\d{6}|(?:1\\d|[39])\\d{9}",[8,10,11],[["(\\d{4})(\\d{4})","$1 $2",["46"]],["(\\d{3})(\\d{7})","$1 $2",["6|90"],"($1)"],["(\\d{3})(\\d{7})","$1 $2",["3[0-357]|9[14]"]],["(\\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[01]|83[0-36-9]|95[0-3])\\d{5}|4(?:[0-36]\\d|4[047-9]|[58][0-24-9]|7[02-8]|9[0-47-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,10,11,12],[["(\\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]|3[13])"],"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,0,[["528[89]\\d{5}"],["(?:6(?:[0-79]\\d|8[0-247-9])|7(?:[016-8]\\d|2[0-8]|5[0-5]))\\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}"]]],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-57-9]\\d)\\d{7}",[9],[["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[1-57-9]"],"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",["(?:19|[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|180020",0,0,0,[["(?:1(?:1(?:3(?:[0-58]\\d\\d|73[0-5])|4(?:(?:[0-5]\\d|70)\\d|69[7-9])|(?:(?:5[0-26-9]|[78][0-49])\\d|6(?:[0-4]\\d|5[01]))\\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-3]))|(?: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","(?:694\\d|7093)\\d{5}|(?:59|[89]\\d)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[5-7]|80[6-9]|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|180020","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{8}|800\\d{5,6}",[8,9],[["(\\d{3})(\\d{5})","$1 $2",["8"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[2358]"],"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","7090\\d{5}|(?:[56]9|[89]\\d)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[5-79]|80[6-9]"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"],"0$1"]],"0",0,0,0,0,0,[["(?:59(?:0(?:0[1-68]|[14][0-24-9]|2[0-68]|3[1-9]|5[3-579]|[68][0-689]|7[08]|9\\d)|87\\d)|80[6-9]\\d\\d)\\d{4}"],["(?:69(?:0\\d\\d|1(?:2[2-9]|3[0-5]))|7090[0-4])\\d{4}"],["80[0-5]\\d{6}"],["8[129]\\d{7}"],0,0,0,0,["9(?:(?:39[5-7]|76[018])\\d|475[0-6])\\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","[2-69]\\d{8}|80\\d{5,7}|[1-79]\\d{7}|6\\d{6}",[7,8,9],[["(\\d{2})(\\d{2})(\\d{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-589]\\d{7}",[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]\\d{9,14}|(?:[1-36]|8\\d{5})\\d{6}|00\\d{9}|[1-9]\\d{8,10}|[2-9]\\d{7}",[7,8,9,10,11,12,13,14,15,16,17],[["(\\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|180020","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]|61|88)|8(?:16|2[014]|3[126]|6[136]|7[078]|8[34]|91)|(?:43|59|75)[15]|(?:1[59]|29|67)[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(?:(?: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)|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(?:3171|5[15][2-6]|61[346]|88(?:[2-7]|82))|8(?:70[2-6]|84(?:[2356]|7[19])|91(?:[3-6]|7[19]))|73[134][2-6]|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]|3[129]|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(?:[23569]|8[0-57-9])|8[1-6])|7(?:1(?:[013-8]|9[6-9])|3(?:17|2[0-49]|9[2-57])|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|8(?:28[235-7]|3))|73179|807(?:1|9[1-3])|(?:1552|6(?:(?:1[1358]|2[2457]|3[2-4]|4[235-7]|5[2-689]|6[24578])\\d|7(?:[23569]\\d|8[0-57-9])|8(?:[14-6]\\d|2[0-79]))|7(?:1(?:[013-8]\\d|9[6-9])|3(?:2[0-49]|9[2-57])|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",["16|[6-9]"],"0$1",1],["(\\d{4})(\\d{2,4})(\\d{4})","$1 $2 $3",["18[06]","18[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,11}|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,12],[["(\\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",["[03]"]]],0,0,0,0,0,0,[["0(?:669[0-79]\\d{1,6}|831\\d{2,8})|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[2356]|[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]],["3[2-8]\\d{9,10}",[11,12]],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|180020","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|427|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",["[47]"],"0$1"]],"0"],JP:["81","010","00[1-9]\\d{6,14}|[25-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",["3|4(?:2[09]|7[01])|6[1-9]","3|4(?:2(?:0|9[02-69])|7(?:0[019]|1))|6[1-9]"],"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",["[25-9]"],"0$1"]],"0",0,"(000[2569]\\d{4,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",["[36]0|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","8\\d{13}|[78]\\d{9}",[10,14],0,"8",0,0,0,0,"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",["3"],"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-6]|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","(?:[2457]\\d|33|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",["20"]],["(\\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]"]],["(\\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",["20"]]],0,0,"(15(?:0[06]|1[12]|[35]5|4[04]|6[26]|77|88|99)\\d)"],LV:["371","00","(?:[268]\\d|78|90)\\d{6}",[8],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[2679]|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{4})(\\d{5})","$1-$2",["892"],"0$1"],["(\\d{2})(\\d{7})","$1-$2",["8(?:0[0-7]|9)"],"0$1"],["(\\d)(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4 $5",["[5-8]"],"0$1"]],"0",0,0,0,0,"[5-8]"],MC:["377","00","(?:[3489]|[67]\\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",["[67]"],"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","7090\\d{5}|(?:[56]9|[89]\\d)\\d{7}",[9],0,"0",0,0,0,0,0,[["(?:59(?:0(?:0[079]|[14]3|[27][79]|3[03-7]|5[0-268]|87)|87\\d)|80[6-9]\\d\\d)\\d{4}"],["(?:69(?:0\\d\\d|1(?:2[2-9]|3[0-5]))|7090[0-4])\\d{4}"],["80[0-5]\\d{6}"],["8[129]\\d{7}"],0,0,0,0,["9(?:(?:39[5-7]|76[018])\\d|475[0-6])\\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",["4(?:[2-46]|5[3-5])|5|6(?:[1-689]|7[235-7])|7(?:[0-4]|5[2-7])|8[1-5]|(?:60|86)[23]"],"0$1"],["(\\d)(\\d{3})(\\d{3,4})","$1 $2 $3",["[12]|452|678|86","[12]|452|6788|86"],"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",["11|2[16]"],"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","7091\\d{5}|(?:[56]9|[89]\\d)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[5-79]|8(?:0[6-9]|[36])"],"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]","[2-9]\\d{9}",[10],[["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["33|5[56]|81"]],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["[2-9]"]]],0,0,0,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[0467]"]]]],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","(?:20|9\\d)\\d{8}|[78]\\d{9,13}",[10,11,12,13,14],[["(\\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","(?:222|444|(?:55|8\\d)\\d|666|777|999)\\d{4}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[24-9]"]]]],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",["30|(?: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","30|(?: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","[78]\\d{8}|[2-9]\\d{5}",[6,9],[["(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3",["[2-9]"],"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","[36-8]\\d{5,8}|4\\d{6,8}|59\\d{6}|9\\d{5,10}|(?:2\\d|5[0-8])\\d{6,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",["3[289]|4[246-8]|61|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[136]|8"]],["(\\d{4})(\\d{4})","$1 $2",["[3-7]"]]]],RE:["262","00","709\\d{6}|(?:26|[689]\\d)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[26-9]"],"0$1"]],"0",0,0,0,0,0,[["2631[0-6]\\d{4}|26(?:2\\d|30|88)\\d{5}"],["(?:69(?:2\\d\\d|3(?:[06][0-6]|1[0-3]|2[0-2]|3[0-39]|4\\d|5[0-5]|7[0-37]|8[0-8]|9[0-479]))|7092[0-3])\\d{4}"],["80\\d{7}"],["89[1-37-9]\\d{6}"],0,0,0,0,["9(?:399[0-3]|479[0-6]|76(?:2[278]|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,"[3489]",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","(?:[15]\\d|800|92)\\d{7}",[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{4})","$1 $2 $3",["8"]]],"0"],SB:["677","0[01]","[6-9]\\d{6}|[1-6]\\d{4}",[5,7],[["(\\d{2})(\\d{5})","$1 $2",["6[89]|7|8[4-9]|9(?:[1-8]|9[0-8])"]]]],SC:["248","010|0[0-2]","(?:[2489]\\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,12],[["(\\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]|7[67]|9[2-9]"]]],"0"],SR:["597","00","(?:[2-5]|[6-9]\\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-9]"]]]],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","[25-7]\\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",["[25-7]"]],["(\\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-359]\\d{8}|[1-5]\\d{7}",[8,9],[["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[1-4]|5[1-3]"],"0$1",1],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[59]"],"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|[3689]\\d|77)\\d{6}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[236-9]"]]],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|66)\\d{7}",[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(?:[1245]|3[12])"]],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["\\d"]]],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-79]"],"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{3})(\\d{5})","$1 $2",["826"],"0$1"],["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["83"],"0$1"],["(\\d{2})(\\d{2})(\\d{4})","$1 $2 $3",["82"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[25]0|37|49|8[09]"],"0$1"],["(\\d)(\\d{3,4})(\\d{4})","$1 $2 $3",["[23568]|4(?:0[02-48]|[1-478])|7[1-9]","[23568]|4(?:0[2-48]|[1-478])|(?: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,[["(?:274[27]|(?:472|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[013-79]|3[0-24679]|4[167]|5[0-3]|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-57-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-269])|7(?:0[1-46-8]|1[2-9]|2[04-8]|3[0-2478]|4[0378]|5[47]|6[02359]|7[0-59]|8[156])|8(?:0[1-68]|1[02-8]|2[0168]|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-3589]|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]|3[23]|44|66|77|88)[2-9]\\d{6}"]]],UY:["598","0(?:0|1[3-9]\\d)","0004\\d{2,9}|[1249]\\d{7}|2\\d{3,4}|(?:[49]\\d|80)\\d{5}",[4,5,6,7,8,9,10,11,12,13],[["(\\d{4,5})","$1",["21"]],["(\\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","00","(?:20|33|[5-9]\\d)\\d{7}",[9],[["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[235-9]"]]]],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,12],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(?:2[02]|[89])"],0,1],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["1[26]|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|8\\d{4})\\d{4}|[89]\\d{5}",[6,9],[["(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3",["[47-9]"]],["(\\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","(?:639\\d|7093)\\d{5}|(?:26|80|9\\d)\\d{7}",[9],0,"0",0,0,0,0,0,[["26(?:89\\d|9(?: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])|7093[5-7])\\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|[579]\\d|63)\\d{7}",[9],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[28]"],"0$1"],["(\\d{2})(\\d{7})","$1 $2",["[579]"],"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}|[235-7]\\d{8}",[9,12],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[235-7]"]]],0,0,0,0,0,0,[0,["(?:[356]|774[45])\\d{8}|7[6-8]\\d{7}"],0,0,0,0,0,0,["2\\d{8}",[9]]]],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|5[12]"]],["(\\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})|5(?:0\\d{3}|2[0-2]))\\d{7}",[7,8,9,10,12]],0,0,0,["348[57]\\d{7}",[11]],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 f(e,t){var n=Array.prototype.slice.call(t);return n.push(b),e.apply(this,n)}function v(e,t){e=e.split("-"),t=t.split("-");for(var n=e[0].split("."),i=t[0].split("."),r=0;r<3;r++){var o=Number(n[r]),a=Number(i[r]);if(o>a)return 1;if(a>o)return-1;if(!isNaN(o)&&isNaN(a))return 1;if(isNaN(o)&&!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 y={}.constructor;function w(e){return null!=e&&e.constructor===y}var x=/^\d+$/;function C(e){return C="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},C(e)}function k(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function S(e,t,n){return t&&function(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,I(i.key),i)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function I(e){var t=function(e,t){if("object"!=C(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t);if("object"!=C(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e,"string");return"symbol"==C(t)?t:t+""}var D=" ext. ",E=function(){return S(function e(t){k(this,e),function(e){if(!e)throw new Error("[libphonenumber-js] `metadata` argument not passed. Check your arguments.");if(!w(e)||!w(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(w(e)?"an object of shape: { "+Object.keys(e).join(", ")+" }":"a "+H(e)+": "+e,"."))}(t),this.metadata=t,B.call(this,t)},[{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){var n,i,r;if(e&&(r=e,x.test(r)?i=e:n=e),t&&(i=t),n&&"001"!==n){var o=this.getCountryMetadata(n);if(!o)throw new Error("Unknown country: ".concat(n));this.numberingPlan=new P(o,this)}else if(i){if(!this.hasCallingCode(i))throw new Error("Unknown calling code: ".concat(i));this.numberingPlan=new P(this.getNumberingPlanMetadata(i),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 n=this.nonGeographic()[e];if(n)return n}else{var i=this.countryCallingCodes()[e];if(i&&1===i.length&&"001"===i[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}}])}(),P=function(){return S(function e(t,n){k(this,e),this.globalMetadataObject=n,this.metadata=t,B.call(this,n.metadata)},[{key:"callingCode",value:function(){return this.metadata[0]}},{key:"_getDefaultCountryMetadataForThisCallingCode",value:function(){return this.globalMetadataObject.getNumberingPlanMetadata(this.callingCode())}},{key:"getDefaultCountryMetadataForRegion",value:function(){return this._getDefaultCountryMetadataForThisCallingCode()}},{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._getDefaultCountryMetadataForThisCallingCode())||[];return t.map(function(t){return new A(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._getDefaultCountryMetadataForThisCallingCode())}},{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._getDefaultCountryMetadataForThisCallingCode())}},{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()&&M(this.types(),e))return new N(M(this.types(),e),this)}},{key:"ext",value:function(){return this.v1||this.v2?D:this.metadata[13]||D}}])}(),A=function(){return S(function e(t,n){k(this,e),this._format=t,this.metadata=n},[{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()||T.test(this.nationalPrefixFormattingRule()))}},{key:"internationalFormat",value:function(){return this._format[5]||this.format()}}])}(),T=/^\(?\$1\)?$/,N=function(){return S(function e(t,n){k(this,e),this.type=t,this.metadata=n},[{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()}}])}();function M(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 H=function(e){return C(e)};function R(e,t){var n=new E(t);if(n.hasCountry(e))return n.selectNumberingPlan(e).countryCallingCode();throw new Error("Unknown country: ".concat(e))}function B(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===v(t,"1.2.0")?this.v2=!0:-1===v(t,"1.7.35")?this.v3=!0:this.v4=!0:this.v1=!0}function z(e){return new E(e).getCountries()}function L(){return f(R,arguments)}function U(e){const t=e.toUpperCase().split("").map(e=>127397+e.charCodeAt(0));return String.fromCodePoint(...t)}const F={US:"USA",CA:"Canada",GB:"UK",AU:"Australia",IN:"India",DE:"Germany",FR:"France",ES:"Spain",IT:"Italy",JP:"Japan",CN:"China",BR:"Brazil",MX:"Mexico",RU:"Russia",KR:"South Korea",NL:"Netherlands",SE:"Sweden",CH:"Switzerland",BE:"Belgium",NO:"Norway",DK:"Denmark",FI:"Finland",PL:"Poland",PT:"Portugal",IE:"Ireland",NZ:"New Zealand",SG:"Singapore",AE:"UAE",SA:"Saudi Arabia",ZA:"South Africa",AR:"Argentina",CL:"Chile",CO:"Colombia",PH:"Philippines",MY:"Malaysia",TH:"Thailand",VN:"Vietnam",ID:"Indonesia",PK:"Pakistan",BD:"Bangladesh",EG:"Egypt",NG:"Nigeria",KE:"Kenya",TR:"Turkey",IL:"Israel",GR:"Greece",AT:"Austria",CZ:"Czech Republic",HU:"Hungary",RO:"Romania",UA:"Ukraine"},O=function(){return f(z,arguments)}().filter(e=>F[e]).map(e=>({code:e,flag:U(e),dialCode:`+${L(e)}`,name:F[e]})).sort((e,t)=>e.name.localeCompare(t.name)),_="calls";class j{constructor(){this.db=null}async init(){return new Promise((e,t)=>{const n=indexedDB.open("call_history",1);n.onerror=()=>t(n.error),n.onsuccess=()=>{this.db=n.result,e()},n.onupgradeneeded=e=>{const t=e.target.result.createObjectStore(_,{keyPath:"id",autoIncrement:!0});t.createIndex("callId","callId",{unique:!0}),t.createIndex("userId_domain",["userId","sipDomain"],{unique:!1}),t.createIndex("startedAt","startedAt",{unique:!1}),t.createIndex("status","status",{unique:!1})}})}async add(e){if(!this.db)throw new Error("Database not initialized");return new Promise((t,n)=>{const i=this.db.transaction(_,"readwrite").objectStore(_).add(e);i.onsuccess=()=>t(i.result),i.onerror=()=>n(i.error)})}async getAll(e,t,n=100){if(!this.db)throw new Error("Database not initialized");return new Promise((i,r)=>{const o=this.db.transaction(_,"readonly").objectStore(_).index("userId_domain"),a=IDBKeyRange.only([e,t]),d=o.openCursor(a,"prev"),s=[];let l=0;d.onsuccess=e=>{const t=e.target.result;t&&l<n?(s.push(t.value),l++,t.continue()):i(s)},d.onerror=()=>r(d.error)})}async getByCallId(e){if(!this.db)throw new Error("Database not initialized");return new Promise((t,n)=>{const i=this.db.transaction(_,"readonly").objectStore(_).index("callId").get(e);i.onsuccess=()=>t(i.result||null),i.onerror=()=>n(i.error)})}async update(e,t){if(!this.db)throw new Error("Database not initialized");return new Promise((n,i)=>{const r=this.db.transaction(_,"readwrite").objectStore(_),o=r.get(e);o.onsuccess=()=>{const a=o.result;if(!a)return void i(new Error(`Record ${e} not found`));const d={...a,...t},s=r.put(d);s.onsuccess=()=>n(),s.onerror=()=>i(s.error)},o.onerror=()=>i(o.error)})}async replaceAll(e,t,n){if(!this.db)throw new Error("Database not initialized");return new Promise((i,r)=>{const o=this.db.transaction(_,"readwrite").objectStore(_),a=o.index("userId_domain"),d=IDBKeyRange.only([e,t]),s=a.openCursor(d);s.onsuccess=e=>{const t=e.target.result;t?(t.delete(),t.continue()):(Array.isArray(n)&&n.length>0&&n.forEach(e=>o.add(e)),i())},s.onerror=()=>r(s.error)})}async clear(){if(!this.db)throw new Error("Database not initialized");return new Promise((e,t)=>{const n=this.db.transaction(_,"readwrite").objectStore(_).clear();n.onsuccess=()=>e(),n.onerror=()=>t(n.error)})}close(){this.db&&(this.db.close(),this.db=null)}}class V{constructor(){this.userId=null,this.sipDomain=null,this.initialized=!1,this.store=new j}async init(e,t){this.userId=e,this.sipDomain=t,await this.store.init(),this.initialized=!0}ensureInitialized(){if(!this.initialized||!this.userId||!this.sipDomain)throw new Error("CallHistoryService not initialized. Call init() first.")}async addCall(e){this.ensureInitialized();const t={callId:e.callId,userId:this.userId,sipDomain:this.sipDomain,callerIdNumber:e.callerIdNumber,callerIdName:e.callerIdName,phoneNumber:e.phoneNumber,direction:e.direction,disposition:e.disposition,startedAt:e.startedAt,endedAt:e.endedAt,durationSeconds:e.durationSeconds,recordingUrl:e.recordingUrl,createdAt:Date.now()};await this.store.add(t)}async getHistory(e=100){return this.ensureInitialized(),this.store.getAll(this.userId,this.sipDomain,e)}async updateCall(e,t){this.ensureInitialized();const n=await this.store.getByCallId(e);n&&n.id&&await this.store.update(n.id,t)}async clear(){await this.store.clear()}destroy(){this.store.close(),this.userId=null,this.sipDomain=null,this.initialized=!1}}const G="https://stag-5-dialer-apis.convirza.com",q="https://stag-5-oauth.convirza.com/oauth/internal/token";class K extends HTMLElement{static get observedAttributes(){return["state","position","theme","sip-domain","sip-username","sip-password","ws-servers","ice-servers","primary-color","accent-color","brand-name","brand-logo","park-poll-interval","auth-token","domain-id","first-name","last-name","email"]}constructor(){super(),this.config={},this.callStatus="idle",this.currentCall=null,this.durationInterval=null,this.isMuted=!1,this.isOnHold=!1,this.isRecording=!1,this.phoneInputValue="",this.selectedCountry={code:"US",flag:"🇺🇸",dialCode:"+1"},this.showCountryDropdown=!1,this.longPressTimer=null,this.longPressTriggered=!1,this.boundHandlers=new Map,this.isInitialized=!1,this.currentView="dial",this.currentHistoryTab="all",this.callHistory=[],this.selectedHistoryItem=null,this.STORAGE_KEY="convirza_call_state",this.sipAdapter=null,this.incomingCallNumber=null,this.incomingCallName=null,this.showInCallKeypad=!1,this.dialedDigits="",this.audioDevices={microphones:[],speakers:[]},this.callQuality=null,this.isDragging=!1,this.dragOffset={x:0,y:0},this.fabPosition=null,this.parkAccounts=[],this.parkApiUrl=null,this.parkPollInterval=5e3,this.parkPollTimer=null,this.authToken=null,this.showRetrieveModal=!1,this.retrieveModalData=null,this.isParking=!1,this.parkingSlot=null,this.parkValidationTimer=null,this.parkValidationAttempts=0,this.errorDismissTimer=null,this.dragStartTime=0,this.hasMoved=!1,this.ringbackTone=null,this.callConnectedTime=0,this.dialTone=null,this.renderScheduled=!1,this.sharedAudioContext=null,this.ringbackBlobUrl=null,this.dialToneBlobUrl=null,this.dialToneBuffer=null,this.currentCallId=null,this.callHistorySaved=!1,this.showTransferView=!1,this.transferTarget="",this.isTransferring=!1,this.domainExtensions=[],this._activeNotification=null,this._onOnline=null,this._onOffline=null,this.phoneNumbersAPI=null,this.orderedPhoneNumbers=[],this.selectedPhoneNumber=null,this.showPhoneNumberDropdown=!1,this.loadingPhoneNumbers=!1,this.phoneNumbersError=null,this.togglePhoneNumberDropdown=e=>{e.preventDefault(),e.stopPropagation(),console.log("[Dialer] Toggling dropdown, current state:",this.showPhoneNumberDropdown),this.showPhoneNumberDropdown=!this.showPhoneNumberDropdown,console.log("[Dialer] New dropdown state:",this.showPhoneNumberDropdown),this.updatePhoneNumberDropdownDOM()},this.selectPhoneNumber=e=>{console.log("[Dialer] Selecting phone number:",e.number_str),this.selectedPhoneNumber=e,this.closePhoneNumberDropdown(),this.config.domainId&&localStorage.setItem(`convirza_selected_caller_id_${this.config.domainId}`,JSON.stringify(e));const t=this.shadow.querySelector(".selected-number");t&&(t.textContent=`${e.assigned_user_name||"Unknown"} - ${this.formatPhoneNumberDisplay(e.number||e.number_str)}`)},this.shadow=this.attachShadow({mode:"open"}),this.setupAudioTones(),this.callHistoryService=new V}setupAudioTones(){this.ringbackTone=new Audio,this.ringbackTone.loop=!0,this.ringbackTone.volume=.3;const e=44100,t=new OfflineAudioContext(1,264600,e),n=t.createBuffer(1,264600,e),i=n.getChannelData(0);for(let t=0;t<264600;t++)if(t<88200){const n=t/e;i[t]=.3*(Math.sin(2*Math.PI*440*n)+Math.sin(2*Math.PI*480*n))}else i[t]=0;const r=t.createBufferSource();r.buffer=n,r.connect(t.destination),r.start(),t.startRendering().then(e=>{const t=this.bufferToWave(e),n=new Blob([t],{type:"audio/wav"}),i=URL.createObjectURL(n);this.ringbackBlobUrl=i,this.ringbackTone&&(this.ringbackTone.src=i)}).catch(e=>{console.warn("[Dialer] Failed to generate ringback tone:",e)}),this.dialTone=new Audio,this.dialTone.volume=.2}bufferToWave(e){const t=e.length*e.numberOfChannels*2+44,n=new ArrayBuffer(t),i=new DataView(n),r=[];let o=0,a=0;const d=e=>{i.setUint16(a,e,!0),a+=2},s=e=>{i.setUint32(a,e,!0),a+=4};s(1179011410),s(t-8),s(1163280727),s(544501094),s(16),d(1),d(e.numberOfChannels),s(e.sampleRate),s(2*e.sampleRate*e.numberOfChannels),d(2*e.numberOfChannels),d(16),s(1635017060),s(t-a-4);for(let t=0;t<e.numberOfChannels;t++)r.push(e.getChannelData(t));for(;o<e.length;){for(let e=0;e<r.length;e++){const t=Math.max(-1,Math.min(1,r[e][o]));i.setInt16(a,t<0?32768*t:32767*t,!0),a+=2}o++}return n}async connectedCallback(){if(!this.isInitialized){const e=this.getAttribute("access-token"),t=this.getAttribute("refresh-token");if("true"===this.getAttribute("auto-configure"))try{if(e)await this.autoConfigureFromAccessToken(e,t);else{if(!t)throw new Error("No access_token or refresh_token provided");await this.autoConfigureFromRefreshToken(t)}}catch(e){return console.error("[Dialer] Auto-config failed:",e),void this.dispatchEvent(new CustomEvent("auth-failed",{detail:{error:e.message},bubbles:!0}))}this.updateConfig(),this.initializeSip(),this.restoreCallState(),this.initializePosition(),this.setupEventListeners(),this._onOnline=()=>{console.log("[Dialer] Network restored — reconnecting SIP"),this.sipAdapter?.reconnect?.()},this._onOffline=()=>{console.warn("[Dialer] Network lost"),this.dispatchEvent(new CustomEvent("sip-transport-error",{detail:{error:"Network offline"},bubbles:!0}))},window.addEventListener("online",this._onOnline),window.addEventListener("offline",this._onOffline),this.render(),this.isInitialized=!0}}initializePosition(){const e=this.getAttribute("position")||"bottom-right",t=window.innerWidth,n=window.innerHeight;let i=0,r=0;i=e.includes("right")?t-56-24:24,r=e.includes("bottom")?n-56-24:24,this.fabPosition={x:i,y:r},this.style.left=`${i}px`,this.style.top=`${r}px`,this.style.right="auto",this.style.bottom="auto"}disconnectedCallback(){this._onOnline&&(window.removeEventListener("online",this._onOnline),this._onOnline=null),this._onOffline&&(window.removeEventListener("offline",this._onOffline),this._onOffline=null),this.dismissIncomingCallNotification(),this.durationInterval&&(clearInterval(this.durationInterval),this.durationInterval=null),this.stopParkSlotPolling(),this.currentCall&&this.endCall(),this.sipAdapter&&(this.sipAdapter.disconnect(),this.sipAdapter=null),this.callHistoryService.destroy(),this.sharedAudioContext&&"closed"!==this.sharedAudioContext.state&&(this.sharedAudioContext.close().catch(()=>{}),this.sharedAudioContext=null),this.ringbackBlobUrl&&(URL.revokeObjectURL(this.ringbackBlobUrl),this.ringbackBlobUrl=null),this.dialToneBlobUrl&&(URL.revokeObjectURL(this.dialToneBlobUrl),this.dialToneBlobUrl=null),this.ringbackTone&&(this.ringbackTone.src="",this.ringbackTone=null),this.dialTone&&(this.dialTone.src="",this.dialTone=null),this.cleanup()}cleanup(){const e=this.boundHandlers.get("root-click");e&&this.shadow.removeEventListener("click",e);const t=this.boundHandlers.get("root-input");t&&this.shadow.removeEventListener("input",t);const n=this.boundHandlers.get("drag-mousemove");n&&document.removeEventListener("mousemove",n);const i=this.boundHandlers.get("drag-mouseup");i&&document.removeEventListener("mouseup",i);const r=this.boundHandlers.get("drag-touchmove");r&&document.removeEventListener("touchmove",r);const o=this.boundHandlers.get("drag-touchend");o&&document.removeEventListener("touchend",o),this.boundHandlers.clear(),this.isInitialized=!1}attributeChangedCallback(e,t,n){t!==n&&(this.updateConfig(),this.isInitialized&&this.render())}updateConfig(){const e=this.getAttribute("ice-servers");let t;if(e)try{t=JSON.parse(e)}catch(e){console.warn("[Dialer] Failed to parse ice-servers attribute:",e)}this.config={apiUrl:G,sipDomain:this.getAttribute("sip-domain")||"",sipUsername:this.getAttribute("sip-username")||"",sipPassword:this.getAttribute("sip-password")||"",wsServers:this.getAttribute("ws-servers")?.split(",")||[],iceServers:t,authToken:this.getAttribute("auth-token")||void 0,primaryColor:this.getAttribute("primary-color")||"#ff6b35",accentColor:this.getAttribute("accent-color")||"#22c55e",theme:this.getAttribute("theme")||"dark",brandName:this.getAttribute("brand-name")||"Convirza",brandLogo:this.getAttribute("brand-logo")||void 0,apiBaseUrl:G,domainId:this.getAttribute("domain-id")?parseInt(this.getAttribute("domain-id"),10):void 0,firstName:this.getAttribute("first-name")||void 0,lastName:this.getAttribute("last-name")||void 0,email:this.getAttribute("email")||void 0};const n=this.parkApiUrl;this.parkApiUrl=`${this.config.apiUrl.replace(/\/$/,"")}/v3/park-slots`;const i=this.getAttribute("park-poll-interval");i&&(this.parkPollInterval=parseInt(i,10)),this.authToken=this.getAttribute("auth-token")||null,console.log("[Dialer] Phone numbers config check:",{apiBaseUrl:this.config.apiBaseUrl,domainId:this.config.domainId,hasAuthToken:!!this.authToken}),this.config.apiBaseUrl&&this.authToken?(console.log("[Dialer] Initializing PhoneNumbersAPI"),this.phoneNumbersAPI=new r(this.config.apiBaseUrl,this.authToken),this.config.domainId&&(console.log("[Dialer] Fetching phone numbers on init"),this.fetchOrderedPhoneNumbers())):console.warn("[Dialer] Phone numbers API not initialized - missing apiBaseUrl or authToken"),n!==this.parkApiUrl&&this.parkApiUrl&&this.sipAdapter&&this.startParkSlotPolling(),this.style.setProperty("--primary-color",this.config.primaryColor),this.style.setProperty("--accent-color",this.config.accentColor)}isDialerEnabled(){return!!(this.config.sipDomain&&this.config.sipUsername&&this.config.wsServers&&this.config.wsServers.filter(e=>""!==e.trim()).length>0)}async autoConfigureFromAccessToken(e,t){const n=`${q.replace("/token","").replace(/\/$/,"")}/session`;console.log("[Dialer] Auto-configuring from access token...");const i=await fetch(n,{method:"GET",headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json"}});if(401===i.status&&t)return console.log("[Dialer] Access token expired, refreshing..."),this.autoConfigureFromRefreshToken(t);if(!i.ok){const e=await i.text();throw new Error(`Session fetch failed: ${i.status} ${e}`)}const r=await i.json();if(200!==r.code||!r.data)throw new Error(r.message||"Session fetch failed");const{user:o}=r.data;if(!o.dialer_config||!o.dialer_config.domains||0===o.dialer_config.domains.length)throw new Error("No dialer domains configured for this user");const a=o.dialer_config.domains[0],d=a.extensions&&a.extensions.length>0?a.extensions[0]:null;if(!d)throw new Error("No extension configured for this domain");this.setAttribute("auth-token",e),this.setAttribute("sip-domain",a.sip_domain),this.setAttribute("sip-username",d.extension),this.setAttribute("sip-password",`${o.user_id}@${a.sip_domain}`),this.setAttribute("ws-servers",`wss://${a.sip_proxy_1}:8443`),this.setAttribute("domain-id",String(a.domain_id)),this.setAttribute("first-name",o.first_name||""),this.setAttribute("last-name",o.last_name||""),this.setAttribute("email",o.email||""),a.ice_servers&&Array.isArray(a.ice_servers)&&this.setAttribute("ice-servers",JSON.stringify(a.ice_servers)),console.log("[Dialer] Auto-configured successfully from access token")}async autoConfigureFromRefreshToken(e){const t=`${q.replace("/token","").replace(/\/$/,"")}/refresh-token`;console.log("[Dialer] Auto-configuring from refresh token...");const n=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refresh_token:e})});if(!n.ok){const e=await n.text();throw new Error(`OAuth refresh failed: ${n.status} ${e}`)}const i=await n.json();if(200!==i.code||!i.data)throw new Error(i.message||"OAuth refresh failed");const{access_token:r,refresh_token:o,user:a}=i.data;if(!a.dialer_config||!a.dialer_config.domains||0===a.dialer_config.domains.length)throw new Error("No dialer domains configured for this user");const d=a.dialer_config.domains[0],s=d.extensions&&d.extensions.length>0?d.extensions[0]:null;if(!s)throw new Error("No extension configured for this domain");this.dispatchEvent(new CustomEvent("token-refreshed",{detail:{access_token:r,refresh_token:o,user:a},bubbles:!0})),this.setAttribute("access-token",r),this.setAttribute("refresh-token",o),this.setAttribute("auth-token",r),this.setAttribute("sip-domain",d.sip_domain),this.setAttribute("sip-username",s.extension),this.setAttribute("sip-password",`${a.user_id}@${d.sip_domain}`),this.setAttribute("ws-servers",`wss://${d.sip_proxy_1}:8443`),this.setAttribute("domain-id",String(d.domain_id)),this.setAttribute("first-name",a.first_name||""),this.setAttribute("last-name",a.last_name||""),this.setAttribute("email",a.email||""),d.ice_servers&&Array.isArray(d.ice_servers)&&this.setAttribute("ice-servers",JSON.stringify(d.ice_servers)),console.log("[Dialer] Auto-configured successfully")}initializeSip(){if(this.isDialerEnabled())try{try{this.sipAdapter=new m({sipUsername:this.config.sipUsername,sipPassword:this.config.sipPassword,sipDomain:this.config.sipDomain,wsServers:this.config.wsServers,iceServers:this.config.iceServers,apiUrl:this.config.apiUrl,authToken:this.authToken||void 0},{onRegistered:async()=>{this.dispatchEvent(new CustomEvent("sip-registered",{bubbles:!0})),this.startParkSlotPolling(),this.requestNotificationPermission(),this.fetchDomainExtensions(),this.config.apiBaseUrl&&this.config.domainId&&this.authToken&&(this.phoneNumbersAPI||(this.phoneNumbersAPI=new r(this.config.apiBaseUrl,this.authToken)),this.fetchOrderedPhoneNumbers()),await this.initializeCallHistory()},onUnregistered:()=>{this.dispatchEvent(new CustomEvent("sip-unregistered",{bubbles:!0}))},onRegistrationFailed:e=>{console.error("[Dialer] SIP registration failed:",e),this.dispatchEvent(new CustomEvent("sip-registration-failed",{detail:{cause:e},bubbles:!0}))},onTransportError:e=>{console.error("[Dialer] SIP transport error:",e),this.dispatchEvent(new CustomEvent("sip-transport-error",{detail:{error:e.message},bubbles:!0}))},onConnecting:()=>{this.dispatchEvent(new CustomEvent("sip-connecting",{bubbles:!0}))},onCallRinging:()=>{this.notifyCallRinging()},onCallAnswered:()=>{this.notifyCallAnswered()},onCallEnded:e=>{this.handleCallEnded(e)},onCallFailed:e=>{console.error("[Dialer] Call failed:",e),this.stopRingbackTone(),this.dismissIncomingCallNotification();const t=e?.statusCode,n=e?.isRejected||486===t||603===t||600===t?"rejected":"failed";this.currentCall?.phoneNumber&&this.currentCallId&&!this.callHistorySaved&&(this.callHistorySaved=!0,this.callHistoryService.addCall({callId:this.currentCallId,phoneNumber:this.currentCall.phoneNumber,callerIdNumber:this.currentCall.phoneNumber,callerIdName:this.config.sipUsername,direction:this.currentCall.direction||"outbound",disposition:n,startedAt:this.currentCall.startTime||Date.now(),endedAt:Date.now(),durationSeconds:0}).then(()=>{this.loadCallHistory()}).catch(e=>{console.error("[CallHistory] Failed to save failed call:",e)})),this.transitionState("error",e?.message||"Call failed")},onIncomingCall:(e,t)=>{this.handleIncomingCall(e,t)},onRemoteHold:e=>{this.dispatchEvent(new CustomEvent("call-remote-hold",{detail:{isOnHold:e},bubbles:!0}))},onQualityChange:e=>{this.callQuality=e,this.dispatchEvent(new CustomEvent("call-quality-change",{detail:e,bubbles:!0})),"connected"===this.callStatus&&this.render()},onRecordingStateChange:e=>{this.isRecording=e,this.render()},onTransferSucceeded:()=>{this.showTransferView=!1,this.transferTarget="",this.isTransferring=!1,this.dispatchEvent(new CustomEvent("call-transferred",{bubbles:!0}))},onTransferFailed:e=>{this.isTransferring=!1,this.dispatchEvent(new CustomEvent("dialer-error",{detail:{error:`Transfer failed: ${e}`},bubbles:!0})),this.render()},onDevicesChanged:e=>{const t=e.filter(e=>"audioinput"===e.kind),n=e.filter(e=>"audiooutput"===e.kind);this.audioDevices={microphones:t,speakers:n},this.render()},onError:e=>{console.error("[Dialer] SIP error:",e),this.dispatchEvent(new CustomEvent("dialer-error",{detail:{error:e.message},bubbles:!0}))}})}catch(e){return console.error("[Dialer] Failed to create SipAdapter:",e),void this.dispatchEvent(new CustomEvent("sip-error",{detail:{error:e.message||"SipAdapter constructor failed"},bubbles:!0}))}this.sipAdapter.connect().catch(e=>{console.error("[Dialer] SIP connection failed:",e),this.dispatchEvent(new CustomEvent("sip-error",{detail:{error:e.message},bubbles:!0}))})}catch(e){console.error("[Dialer] Failed to initialize SIP:",e)}else console.warn("[Dialer] SIP credentials not configured, dialer disabled")}async initializeCallHistory(){if(this.config.sipUsername&&this.config.sipDomain)try{await this.callHistoryService.init(this.config.sipUsername,this.config.sipDomain),console.log("[CallHistory] Service initialized"),await this.loadCallHistory()}catch(e){console.error("[CallHistory] Failed to initialize:",e)}else console.warn("[CallHistory] Missing SIP credentials, skipping initialization")}async loadCallHistory(){try{const e=await this.callHistoryService.getHistory(100);this.callHistory=e.map(e=>({id:e.callId,phoneNumber:e.phoneNumber,type:this.mapDirectionToType(e.direction,e.disposition),status:this.mapDispositionToString(e.disposition),timestamp:e.startedAt,duration:e.durationSeconds>0?e.durationSeconds:void 0})).filter(e=>"number"==typeof e.timestamp&&!isNaN(e.timestamp)).sort((e,t)=>t.timestamp-e.timestamp),this.render(),console.log(`[CallHistory] Loaded ${this.callHistory.length} calls`)}catch(e){console.error("[CallHistory] Failed to load history:",e)}}mapDirectionToType(e,t){return"missed"===t?"missed":"inbound"===e?"inbound":"outbound"}mapDispositionToString(e){switch(e){case"answered":return"Answered";case"missed":return"Missed";case"rejected":return"Rejected";case"failed":return"Failed";default:return"Unknown"}}generateCallId(){const e=this.sipAdapter?.getCallUuid();return e||"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})}isValidTransition(e,t){const n=a[e];return!!n&&n.includes(t)}transitionState(e,t){const n=this.callStatus;if(n===e)return;if(!this.isValidTransition(n,e))return console.error(`[CallState] Invalid transition: ${n} → ${e}`),void("error"!==e&&this.isValidTransition(n,"error")&&this.transitionState("error",`Invalid state transition from ${n} to ${e}`));this.callStatus=e,this.errorDismissTimer&&(window.clearTimeout(this.errorDismissTimer),this.errorDismissTimer=null),"error"===e&&(this.errorDismissTimer=window.setTimeout(()=>{this.currentCall=null,this.transitionState("idle")},3e3));const i=this.currentCall?{phoneNumber:this.currentCall.phoneNumber,startTime:this.currentCall.startTime,duration:this.currentCall.duration,status:e,errorMessage:t}:void 0;this.dispatchEvent(new CustomEvent("state-change",{detail:{oldState:n,newState:e,metadata:i},bubbles:!0})),this.persistCallState();this.needsUIRebuild(n,e)?this.render():this.performSelectiveUpdate(this.getAttribute("state")||"collapsed")}needsUIRebuild(e,t){return!![["idle","dialing"],["idle","ringing"],["dialing","connected"],["ringing","connected"],["ended","idle"],["error","idle"],["dialing","error"],["ringing","error"],["connected","error"]].some(([n,i])=>n===e&&i===t)||("idle"===t||"ended"===t||"error"===t||("idle"===e||"ended"===e||"error"===e))}getCallMetadata(){return this.currentCall?{phoneNumber:this.currentCall.phoneNumber,startTime:this.currentCall.startTime,duration:this.currentCall.duration,status:this.callStatus}:null}persistCallState(){if("undefined"!=typeof window&&window.localStorage)try{const e=this.getCallMetadata();e&&"idle"!==this.callStatus&&"ended"!==this.callStatus?localStorage.setItem(this.STORAGE_KEY,JSON.stringify(e)):localStorage.removeItem(this.STORAGE_KEY)}catch(e){console.error("[CallState] Failed to persist state:",e)}}restoreCallState(){if("undefined"!=typeof window&&window.localStorage)try{const e=localStorage.getItem(this.STORAGE_KEY);if(!e)return;const t=JSON.parse(e),n=Date.now();if(n-t.startTime>h)return void localStorage.removeItem(this.STORAGE_KEY);this.currentCall={phoneNumber:t.phoneNumber,startTime:t.startTime,duration:t.duration,direction:"outbound",callbacks:{onAnswered:[],onEnded:[]}},this.callStatus=t.status}catch(e){console.error("[CallState] Failed to restore state:",e),localStorage.removeItem(this.STORAGE_KEY)}}placeCall(e,t){if(!e)throw new Error("Phone number is required");const n=this.formatPhoneNumber(e);this.currentCallId=this.generateCallId(),this.currentView="dial",this.currentCall={phoneNumber:n,startTime:Date.now(),duration:0,direction:"outbound",callbacks:{onAnswered:[],onEnded:[]}},this.callHistorySaved=!1,this.transitionState("dialing"),this.setAttribute("state","expanded"),this.render();const i=this.selectedPhoneNumber?.number||t?.callerId,r=this.selectedPhoneNumber?.assigned_user_name||t?.displayName,o={...t,callerId:i,displayName:r};this.dispatchEvent(new CustomEvent("call-started",{detail:{phoneNumber:n,callerId:i},bubbles:!0})),this.initiateCall(n,o);const a=this;return{phoneNumber:n,get status(){return a.callStatus},get duration(){return a.currentCall?.duration||0},onAnswered(e){a.currentCall?.callbacks.onAnswered.push(e)},onEnded(e){a.currentCall?.callbacks.onEnded.push(e)},end(){a.endCall()}}}open(){this.adjustPositionForPanel(),this.setAttribute("state","expanded"),this.dispatchEvent(new CustomEvent("widget-opened",{bubbles:!0}))}close(){const e=parseInt(this.style.left||"0",10)+324,t=parseInt(this.style.top||"0",10)+694;this.style.left=`${e}px`,this.style.top=`${t}px`,this.fabPosition={x:e,y:t},this.setAttribute("state","collapsed"),this.dispatchEvent(new CustomEvent("widget-closed",{bubbles:!0}))}toggle(){"expanded"===this.getAttribute("state")?this.close():this.open()}setTheme(e){e.theme&&this.setAttribute("theme",e.theme),e.primaryColor&&this.setAttribute("primary-color",e.primaryColor),e.accentColor&&this.setAttribute("accent-color",e.accentColor),e.brandName&&this.setAttribute("brand-name",e.brandName),e.brandLogo&&this.setAttribute("brand-logo",e.brandLogo)}async clearCallHistoryCache(){await this.callHistoryService.clear(),await this.loadCallHistory()}mute(e){return"connected"===this.callStatus&&this.sipAdapter?(this.isMuted=this.sipAdapter.mute(e),this.dispatchEvent(new CustomEvent("sip-call-mute",{detail:{muted:this.isMuted},bubbles:!0})),this.render(),this.isMuted):this.isMuted}hold(e){return"connected"===this.callStatus&&this.sipAdapter?(this.isOnHold=void 0!==e?e:!this.isOnHold,this.sipAdapter.hold(this.isOnHold).then(()=>{this.dispatchEvent(new CustomEvent("sip-call-hold",{detail:{onHold:this.isOnHold},bubbles:!0})),this.render()}).catch(e=>{console.error("[Dialer] Hold failed:",e),this.isOnHold=!this.isOnHold}),this.isOnHold):this.isOnHold}startRecording(){if("connected"!==this.callStatus||!this.sipAdapter)throw new Error("No active call");this.sipAdapter.startRecording()}stopRecording(){if("connected"!==this.callStatus||!this.sipAdapter)throw new Error("No active call");this.sipAdapter.stopRecording()}toggleRecording(){"connected"===this.callStatus&&this.sipAdapter&&(this.isRecording=!this.isRecording,this.isRecording?this.sipAdapter.startRecording():this.sipAdapter.stopRecording(),this.dispatchEvent(new CustomEvent("recording-state-change",{detail:{recording:this.isRecording},bubbles:!0})),this.render())}parkCall(e){if("connected"!==this.callStatus||!this.sipAdapter||this.isParking)return void console.warn("[Dialer] Cannot park: no active call or already parking");if(Date.now()-this.callConnectedTime<2e3)return void console.warn("[Dialer] Call too new to park, wait a moment");const t=this.parkAccounts.find(t=>t.extension===e);if(!t)return void console.error("[Dialer] Park slot not found:",e);this.isParking=!0,this.parkingSlot=e;const n=this.currentCall?.phoneNumber||"Unknown",i=this.config.sipUsername||"Unknown";t.occupied=!0,t.parkedCall={phoneNumber:n,parkedBy:i,parkedAt:Date.now()},this.sipAdapter.park(e).then(()=>{this.parkValidationAttempts=0,this.validateParkSuccess(e,n,i,t),this.fetchParkSlots(),this.stopRingbackTone()}).catch(e=>{console.error("[Dialer] Park API failed:",e),t.occupied=!1,t.parkedCall=void 0,this.dispatchEvent(new CustomEvent("call-park-failed",{detail:{error:e.message},bubbles:!0})),this.render(),this.isParking=!1,this.parkingSlot=null})}validateParkSuccess(e,t,n,i){this.parkValidationTimer&&window.clearTimeout(this.parkValidationTimer),this.parkValidationTimer=window.setTimeout(()=>{this.parkValidationAttempts++;const r=this.parkAccounts.find(t=>t.extension===e);if(r?.occupied&&r.parkedCall)return this.dispatchEvent(new CustomEvent("call-parked",{detail:{parkExtension:e,phoneNumber:t,parkedBy:n},bubbles:!0})),this.isParking=!1,this.parkingSlot=null,void(this.parkValidationTimer=null);this.parkValidationAttempts<10?(this.fetchParkSlots(),this.validateParkSuccess(e,t,n,i)):(console.error(`[Dialer] Park validation timeout: slot ${e} never showed occupied`),i.occupied=!1,i.parkedCall=void 0,this.dispatchEvent(new CustomEvent("call-park-failed",{detail:{error:"Park operation timed out - slot did not become occupied"},bubbles:!0})),this.isParking=!1,this.parkingSlot=null,this.parkValidationTimer=null,this.render())},1e3)}confirmRetrieveParkedCall(e,t){this.retrieveModalData={extension:e,phoneNumber:t},this.showRetrieveModal=!0,this.render()}cancelRetrieve(){this.showRetrieveModal=!1,this.retrieveModalData=null,this.render()}confirmRetrieve(){this.retrieveModalData&&(this.showRetrieveModal=!1,this.retrieveParkedCall(this.retrieveModalData.extension),this.retrieveModalData=null)}retrieveParkedCall(e){if(!this.sipAdapter)return void console.error("[Dialer] Cannot retrieve: SIP adapter not initialized");if("idle"!==this.callStatus)return void console.warn("[Dialer] Cannot retrieve while on active call");const t=this.parkAccounts.find(t=>t.extension===e);if(t&&t.parkedCall){this.parkingSlot=e;try{this.placeCall(e),this.switchView("dial"),this.render()}catch(e){console.error("[Dialer] Retrieve failed:",e),this.parkingSlot=null,this.dispatchEvent(new CustomEvent("call-retrieve-failed",{detail:{error:e.message},bubbles:!0}))}}else console.error("[Dialer] Park slot empty or not found:",e)}initiateCall(e,t){if(!this.sipAdapter)return console.error("SIP adapter not initialized"),this.transitionState("error","SIP adapter not initialized"),void(this.currentCall=null);this.sipAdapter.call(e,{callerId:t?.callerId,callerIdName:t?.displayName}).then(()=>{this.dispatchEvent(new CustomEvent("sip-call-initiate",{detail:{phoneNumber:e,options:t},bubbles:!0}))}).catch(e=>{console.error("[Dialer] Failed to initiate call:",e),this.transitionState("error",e.message),this.currentCall=null})}handleCallEnded(e){if(this.stopRingbackTone(),this.callConnectedTime=0,this.showTransferView=!1,this.transferTarget="",this.isTransferring=!1,this.dismissIncomingCallNotification(),this.parkingSlot&&this.isParking){const e=this.parkAccounts.find(e=>e.extension===this.parkingSlot);e&&(e.occupied=!1,e.parkedCall=void 0),this.parkingSlot=null,this.isParking=!1}const t=this.currentCall?.duration||0,n=this.currentCall?.phoneNumber||"",i=this.currentCall?.startTime||Date.now();if(n&&this.currentCallId&&!this.callHistorySaved){const e="connected"===this.callStatus,r=this.currentCall?.direction||"outbound",o=e?"answered":"failed",a=Math.floor(t/1e3);this.callHistoryService.addCall({callId:this.currentCallId,phoneNumber:n,callerIdNumber:n,callerIdName:this.config.sipUsername,direction:r,disposition:o,startedAt:i,endedAt:Date.now(),durationSeconds:a}).then(()=>{this.loadCallHistory()}).catch(e=>{console.error("[CallHistory] Failed to save call:",e)}),this.addToCallHistory({id:this.currentCallId,phoneNumber:n,type:e?"outbound":"missed",status:e?"Outbound":"Not connected",timestamp:Date.now(),duration:e?t:void 0})}this.currentCallId=null,this.callHistorySaved=!1,this.currentCall?.callbacks.onEnded.forEach(e=>e(t)),this.dispatchEvent(new CustomEvent("call-ended",{detail:{phoneNumber:n,duration:t,reason:e},bubbles:!0})),this.durationInterval&&(clearInterval(this.durationInterval),this.durationInterval=null),this.transitionState("ended"),this.isMuted=!1,this.isOnHold=!1,this.dialedDigits="",this.showInCallKeypad=!1,"parked"===e&&"park"===this.currentView&&this.switchView("dial"),setTimeout(()=>{this.transitionState("idle"),this.currentCall=null},1e3)}addToCallHistory(e){this.callHistory.unshift(e),this.callHistory.length>u&&(this.callHistory=this.callHistory.slice(0,u)),this.dispatchEvent(new CustomEvent("history-updated",{detail:{history:this.callHistory},bubbles:!0}))}getFilteredHistory(){switch(this.currentHistoryTab){case"missed":return this.callHistory.filter(e=>"missed"===e.type);case"dialed":return this.callHistory.filter(e=>"outbound"===e.type);default:return this.callHistory}}async switchView(e){this.showTransferView=!1,this.currentView=e,this.selectedHistoryItem=null,"account"===e&&await this.refreshAudioDevicesQuietly(),this.updateMainView()}updateMainView(){const e=this.shadow.querySelector(".dialer-body"),t=this.shadow.querySelectorAll(".nav-btn");if(!e)return;t.forEach(e=>{e.getAttribute("data-view")===this.currentView?e.classList.add("active"):e.classList.remove("active")});let n="";n="idle"!==this.callStatus&&"dial"===this.currentView?this.renderActiveCall():"history"===this.currentView?this.renderHistory():"account"===this.currentView?this.renderAccount():"park"===this.currentView?this.renderPark():this.renderDialpad(),requestAnimationFrame(()=>{e.innerHTML=n,this.updateButtonStates(),this.updatePhoneInput()})}updatePhoneInput(){const e=this.shadow.getElementById("phoneInput");e&&this.phoneInputValue&&(e.value=this.phoneInputValue)}switchHistoryTab(e){this.currentHistoryTab=e,this.selectedHistoryItem=null,this.updateHistoryView()}updateHistoryView(){const e=this.shadow.querySelector(".history-list"),t=this.shadow.querySelectorAll(".tab-btn");if(!e)return;t.forEach(e=>{e.getAttribute("data-tab")===this.currentHistoryTab?e.classList.add("active"):e.classList.remove("active")});const n=this.getFilteredHistory(),i=0===n.length?this.renderEmptyHistory():n.map(e=>this.renderHistoryItem(e)).join("");requestAnimationFrame(()=>{e.innerHTML=i})}startDurationTimer(){this.durationInterval&&(clearInterval(this.durationInterval),this.durationInterval=null),this.durationInterval=window.setInterval(()=>{this.currentCall&&"connected"===this.callStatus?(this.currentCall.duration=Date.now()-this.currentCall.startTime,this.render()):this.durationInterval&&(clearInterval(this.durationInterval),this.durationInterval=null)},1e3)}handleIncomingCall(e,t){if("idle"!==this.callStatus)return console.warn("[Dialer] Incoming call rejected - already in call"),void this.sipAdapter?.rejectCall();this.incomingCallNumber=e,this.incomingCallName=t||null,this.open(),this.render(),this.showIncomingCallNotification(e,t),this.dispatchEvent(new CustomEvent("incoming-call",{detail:{phoneNumber:e,callerName:t},bubbles:!0}))}answerIncomingCall(){if(!this.incomingCallNumber||!this.sipAdapter)return;const e=this.incomingCallNumber;this.incomingCallNumber=null,this.incomingCallName=null,this.currentCallId=this.generateCallId(),this.currentCall={phoneNumber:e,startTime:Date.now(),duration:0,direction:"inbound",callbacks:{onAnswered:[],onEnded:[]}},this.transitionState("dialing"),this.sipAdapter.answerCall().then(()=>{this.dispatchEvent(new CustomEvent("call-started",{detail:{phoneNumber:e,direction:"inbound"},bubbles:!0}))}).catch(e=>{console.error("[Dialer] Failed to answer call:",e),this.transitionState("error",e.message),this.currentCall=null})}rejectIncomingCall(){if(!this.incomingCallNumber||!this.sipAdapter)return;const e=this.incomingCallNumber,t=this.generateCallId();this.incomingCallNumber=null,this.incomingCallName=null,this.dismissIncomingCallNotification(),this.sipAdapter.rejectCall().catch(e=>{console.error("[Dialer] Failed to reject call:",e)}),this.callHistoryService.addCall({callId:t,phoneNumber:e,callerIdNumber:e,callerIdName:void 0,direction:"inbound",disposition:"rejected",startedAt:Date.now(),durationSeconds:0}).then(()=>{this.loadCallHistory()}).catch(e=>{console.error("[CallHistory] Failed to save rejected call:",e)}),this.addToCallHistory({id:t,phoneNumber:e,type:"missed",status:"Missed",timestamp:Date.now()}),this.dispatchEvent(new CustomEvent("call-rejected",{detail:{phoneNumber:e},bubbles:!0})),this.render()}toggleInCallKeypad(){this.showInCallKeypad=!this.showInCallKeypad,this.showInCallKeypad||(this.dialedDigits=""),this.render()}notifyCallAnswered(){"dialing"!==this.callStatus&&"ringing"!==this.callStatus||(this.dismissIncomingCallNotification(),this.stopRingbackTone(),this.callConnectedTime=Date.now(),this.currentCall&&"outbound"===this.currentCall.direction&&(this.currentCall.startTime=this.callConnectedTime,this.currentCall.duration=0),this.transitionState("connected"),this.startDurationTimer(),this.currentCall?.callbacks.onAnswered.forEach(e=>e()),this.dispatchEvent(new CustomEvent("call-answered",{detail:{phoneNumber:this.currentCall?.phoneNumber},bubbles:!0})))}notifyCallRinging(){"dialing"===this.callStatus&&(this.playRingbackTone(),this.transitionState("ringing"))}playRingbackTone(){this.ringbackTone&&(this.ringbackTone.currentTime=0,this.ringbackTone.play().catch(e=>{console.warn("[Dialer] Failed to play ringback tone:",e)}))}stopRingbackTone(){this.ringbackTone&&(this.ringbackTone.pause(),this.ringbackTone.currentTime=0)}playDialTone(e,t){if(!this.dialTone)return;this.sharedAudioContext&&"closed"!==this.sharedAudioContext.state||(this.sharedAudioContext=new(window.AudioContext||window.webkitAudioContext));const n=this.sharedAudioContext,i=n.createBuffer(1,.1*n.sampleRate,n.sampleRate),r=i.getChannelData(0);for(let o=0;o<i.length;o++){const i=o/n.sampleRate;r[o]=.3*(Math.sin(2*Math.PI*e*i)+Math.sin(2*Math.PI*t*i))}const o=this.bufferToWave(i),a=new Blob([o],{type:"audio/wav"});this.dialToneBlobUrl&&URL.revokeObjectURL(this.dialToneBlobUrl),this.dialToneBlobUrl=URL.createObjectURL(a),this.dialTone.src=this.dialToneBlobUrl,this.dialTone.play().catch(e=>{console.warn("[Dialer] Failed to play dial tone:",e)})}playDTMFTone(e){const t={1:[697,1209],2:[697,1336],3:[697,1477],4:[770,1209],5:[770,1336],6:[770,1477],7:[852,1209],8:[852,1336],9:[852,1477],"*":[941,1209],0:[941,1336],"#":[941,1477]}[e];t&&this.playDialTone(t[0],t[1])}endCall(){"idle"!==this.callStatus&&(this.stopRingbackTone(),this.sipAdapter&&this.sipAdapter.endCall().catch(e=>{console.error("[Dialer] Error ending call:",e)}),this.dispatchEvent(new CustomEvent("sip-call-terminate",{bubbles:!0})),this.handleCallEnded("user-terminated"))}sendDTMF(e){if("connected"===this.callStatus&&this.sipAdapter)try{this.sipAdapter.sendDTMF(e),this.dispatchEvent(new CustomEvent("dtmf-sent",{detail:{digit:e},bubbles:!0}))}catch(e){console.error("[Dialer] DTMF failed:",e)}}formatPhoneNumber(e){const t=e.trim();if(/[a-zA-Z]/.test(t))return t;const n=t.replace(/\D/g,"");if(/^(7[0][0-9]|71[0-9]|720)$/.test(n))return n;const i=this.selectedCountry.dialCode.replace(/\+/,"");return n.startsWith(i)?`+${n}`:`${this.selectedCountry.dialCode}${n}`}formatPhoneNumberDisplay(e){const t=e.replace(/\D/g,"");if(11===t.length&&t.startsWith("1"))return`+1 (${t.slice(1,4)}) ${t.slice(4,7)} ${t.slice(7)}`;if(10===t.length)return`+1 (${t.slice(0,3)}) ${t.slice(3,6)} ${t.slice(6)}`;if(t.length>10){const e=t.slice(0,t.length-10),n=t.slice(-10);return`+${e} (${n.slice(0,3)}) ${n.slice(3,6)} ${n.slice(6)}`}return e}formatPhoneInputDisplay(e){const t=e.replace(/\D/g,"");return t?t.length<=3?`(${t}`:t.length<=6?`(${t.slice(0,3)}) ${t.slice(3)}`:t.length<=10?`(${t.slice(0,3)}) ${t.slice(3,6)}-${t.slice(6,10)}`:t:""}formatDuration(e){const t=Math.max(0,Math.floor(e/1e3)),n=Math.floor(t/3600),i=Math.floor(t%3600/60),r=t%60;return`${n.toString().padStart(2,"0")}:${i.toString().padStart(2,"0")}:${r.toString().padStart(2,"0")}`}formatCallTime(e){const t=new Date,n=new Date(t.getFullYear(),t.getMonth(),t.getDate()),i=new Date(e.getFullYear(),e.getMonth(),e.getDate()),r=Math.floor((n.getTime()-i.getTime())/864e5);return 0===r?e.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0}):r>0&&r<=6?e.toLocaleDateString("en-US",{weekday:"short"}):e.toLocaleDateString("en-US",{month:"short",day:"numeric"})}render(){this.renderScheduled||(this.renderScheduled=!0,requestAnimationFrame(()=>{this.renderScheduled=!1,this.performRender()}))}needsFullRender(e){if(!this.shadow.querySelector(".dialer-panel, .dialer-fab"))return!0;const t="collapsed"===e,n=!!this.shadow.querySelector(".dialer-panel"),i=!!this.shadow.querySelector(".dialer-fab");return!((!t||i)&&(t||n))||!(!this.incomingCallNumber&&!this.showRetrieveModal)}performRender(){const e=this.shadow.getElementById("phoneInput");e&&(this.phoneInputValue=e.value);const t=this.getAttribute("state")||"collapsed";if(this.needsFullRender(t)){this.shadow.innerHTML=`\n <style>\n:host {\n --primary-color: #ff6b35;\n --accent-color: #22c55e;\n --danger-color: #ef4444;\n\n /* Dark theme */\n --bg-primary-dark: #1a1a1a;\n --bg-secondary-dark: #2d2d2d;\n --text-primary-dark: #ffffff;\n --text-secondary-dark: #9ca3af;\n --border-dark: #3d3d3d;\n\n /* Light theme */\n --bg-primary-light: #ffffff;\n --bg-secondary-light: #f9fafb;\n --text-primary-light: #1f2937;\n --text-secondary-light: #6b7280;\n --border-light: #e5e7eb;\n\n position: fixed;\n z-index: 9999;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n}\n\n:host([position="top-left"]) { top: 24px; left: 24px; }\n:host([position="top-right"]) { top: 24px; right: 24px; }\n:host([position="bottom-left"]) { bottom: 24px; left: 24px; }\n:host([position="bottom-right"]) { bottom: 24px; right: 24px; }\n\n/* Dark theme (default) */\n:host([theme="dark"]) {\n --bg-primary: var(--bg-primary-dark);\n --bg-secondary: var(--bg-secondary-dark);\n --text-primary: var(--text-primary-dark);\n --text-secondary: var(--text-secondary-dark);\n --border-color: var(--border-dark);\n}\n\n/* Light theme */\n:host([theme="light"]) {\n --bg-primary: var(--bg-primary-light);\n --bg-secondary: var(--bg-secondary-light);\n --text-primary: var(--text-primary-light);\n --text-secondary: var(--text-secondary-light);\n --border-color: var(--border-light);\n}\n\n/* Default to dark if no theme set */\n:host {\n --bg-primary: var(--bg-primary-dark);\n --bg-secondary: var(--bg-secondary-dark);\n --text-primary: var(--text-primary-dark);\n --text-secondary: var(--text-secondary-dark);\n --border-color: var(--border-dark);\n}\n\n.dialer-fab {\n width: 56px;\n height: 56px;\n border-radius: 50%;\n background: var(--primary-color);\n border: none;\n color: white;\n cursor: grab;\n display: flex;\n align-items: center;\n justify-content: center;\n box-shadow: 0 10px 25px rgba(0,0,0,0.3);\n transition: all 0.3s ease;\n position: relative;\n user-select: none;\n -webkit-user-select: none;\n touch-action: none;\n}\n\n.dialer-fab:active {\n cursor: grabbing;\n}\n\n.dialer-fab:hover {\n transform: scale(1.05);\n box-shadow: 0 12px 30px rgba(0,0,0,0.4);\n}\n\n.call-indicator {\n position: absolute;\n top: 4px;\n right: 4px;\n width: 12px;\n height: 12px;\n background: var(--accent-color);\n border-radius: 50%;\n border: 2px solid white;\n animation: pulse 2s infinite;\n}\n\n@keyframes pulse {\n 0%, 100% { opacity: 1; }\n 50% { opacity: 0.5; }\n}\n\n.dialer-panel {\n width: 380px;\n height: 750px;\n background: var(--bg-primary);\n border-radius: 12px;\n box-shadow: 0 20px 60px rgba(0,0,0,0.4);\n overflow: hidden;\n display: flex;\n flex-direction: column;\n}\n\n:host([state="expanded"]) .dialer-panel {\n display: flex;\n animation: slideUp 0.3s ease;\n}\n\n:host([state="expanded"]) .dialer-fab {\n display: none;\n}\n\n@keyframes slideUp {\n from { opacity: 0; transform: translateY(20px); }\n to { opacity: 1; transform: translateY(0); }\n}\n\n.dialer-header {\n padding: 12px 16px;\n background: var(--primary-color);\n color: white;\n display: flex;\n justify-content: space-between;\n align-items: center;\n cursor: move;\n cursor: grab;\n user-select: none;\n -webkit-user-select: none;\n}\n\n.dialer-header:active {\n cursor: grabbing;\n}\n\n.header-brand {\n display: flex;\n align-items: center;\n gap: 10px;\n font-weight: 600;\n font-size: 15px;\n letter-spacing: 0.3px;\n}\n\n.brand-logo {\n max-height: 28px;\n max-width: 120px;\n object-fit: contain;\n}\n\n.header-controls {\n display: flex;\n gap: 8px;\n}\n\n.header-btn {\n width: 24px;\n height: 24px;\n background: rgba(255,255,255,0.2);\n border: none;\n border-radius: 4px;\n color: white;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n font-size: 16px;\n line-height: 1;\n}\n\n.header-btn:hover {\n background: rgba(255,255,255,0.3);\n}\n\n.dialer-body {\n padding: 24px 20px 0;\n background: var(--bg-primary);\n flex: 1;\n overflow-y: auto;\n overflow-x: hidden;\n display: flex;\n flex-direction: column;\n justify-content: space-between;\n min-height: 0;\n contain: layout style;\n will-change: contents;\n transition: opacity 0.15s ease;\n backface-visibility: hidden;\n transform: translateZ(0);\n}\n\n.brand-section {\n text-align: center;\n padding: 16px 0 8px;\n display: flex;\n justify-content: center;\n}\n\n.brand-icon {\n width: 40px;\n height: 40px;\n display: flex;\n align-items: center;\n justify-content: center;\n background: var(--bg-secondary);\n border-radius: 10px;\n border: 1px solid var(--border-color);\n}\n\n.brand-icon img {\n width: 100%;\n height: 100%;\n object-fit: contain;\n border-radius: 8px;\n}\n\n.brand-icon svg {\n width: 24px;\n height: 24px;\n color: var(--primary-color);\n}\n\n.brand-name {\n display: none;\n}\n\n.input-section {\n display: flex;\n align-items: center;\n gap: 10px;\n margin-top: 12px;\n margin-bottom: 20px;\n padding: 0 4px;\n backface-visibility: hidden;\n transform: translateZ(0);\n}\n\n.country-selector {\n position: relative;\n z-index: 100;\n}\n\n.country-btn {\n background: var(--bg-secondary);\n border: 1px solid var(--border-color);\n border-radius: 6px;\n padding: 6px 8px;\n color: var(--text-primary);\n cursor: pointer;\n display: flex;\n align-items: center;\n gap: 4px;\n font-size: 13px;\n transition: all 0.2s;\n}\n\n.country-btn:hover {\n background: var(--border-color);\n}\n\n.country-flag {\n font-size: 16px;\n line-height: 1;\n}\n\n.country-code {\n font-size: 13px;\n font-weight: 500;\n}\n\n.dropdown-icon {\n opacity: 0.6;\n transition: transform 0.2s;\n}\n\n.country-dropdown-backdrop {\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background: transparent;\n z-index: 9999;\n pointer-events: auto;\n}\n\n.country-dropdown {\n position: absolute;\n background: #1a1a1a;\n border: 1px solid #444;\n border-radius: 8px;\n box-shadow: 0 6px 16px rgba(0,0,0,0.6);\n max-height: 120px;\n overflow-y: scroll;\n overflow-x: hidden;\n -webkit-overflow-scrolling: touch;\n z-index: 10000;\n width: 200px;\n pointer-events: auto;\n}\n\n.country-dropdown::-webkit-scrollbar {\n width: 6px;\n}\n\n.country-dropdown::-webkit-scrollbar-track {\n background: rgba(255,255,255,0.05);\n border-radius: 3px;\n margin: 4px 0;\n}\n\n.country-dropdown::-webkit-scrollbar-thumb {\n background: rgba(255,255,255,0.4);\n border-radius: 3px;\n}\n\n.country-dropdown::-webkit-scrollbar-thumb:hover {\n background: rgba(255,255,255,0.5);\n}\n\n.country-option {\n width: 100%;\n background: transparent;\n border: none;\n padding: 9px 12px;\n color: var(--text-primary);\n cursor: pointer;\n display: flex;\n align-items: center;\n gap: 10px;\n font-size: 13px;\n transition: background 0.12s;\n text-align: left;\n white-space: nowrap;\n}\n\n.country-option:hover {\n background: rgba(255,255,255,0.12);\n}\n\n.country-option .country-flag {\n font-size: 18px;\n}\n\n.country-option .country-name {\n flex: 1;\n font-weight: 500;\n}\n\n.country-option .country-code {\n opacity: 0.7;\n font-size: 12px;\n font-weight: 500;\n}\n\n.phone-input-wrapper {\n flex: 1;\n position: relative;\n}\n\n.phone-input {\n width: 100%;\n min-width: 150px;\n background: transparent;\n background-color: transparent;\n border: none;\n color: var(--text-primary);\n font-size: 22px;\n font-weight: 300;\n text-align: center;\n outline: none;\n letter-spacing: 1px;\n -webkit-appearance: none;\n appearance: none;\n}\n\n.phone-input::placeholder {\n color: var(--text-secondary);\n opacity: 0.5;\n}\n\n.toggle-btn {\n background: var(--bg-secondary);\n border: 1px solid var(--border-color);\n border-radius: 6px;\n padding: 8px 10px;\n color: var(--text-secondary);\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n}\n\n.toggle-btn:hover {\n background: var(--bg-primary);\n}\n\n.toggle-btn:disabled {\n opacity: 0.3;\n cursor: not-allowed;\n}\n\n.dialpad {\n display: grid;\n grid-template-columns: repeat(3, 1fr);\n gap: 20px;\n margin-bottom: 12px;\n margin-top: 0;\n padding: 0 16px 12px;\n backface-visibility: hidden;\n transform: translateZ(0);\n position: relative;\n z-index: 0;\n animation: fadeIn 0.2s ease;\n}\n\n.dialpad-btn {\n aspect-ratio: 1;\n background: transparent;\n border: none;\n color: var(--text-primary);\n border-radius: 50%;\n font-size: 24px;\n font-weight: 300;\n cursor: pointer;\n transition: all 0.2s;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n gap: 0;\n position: relative;\n min-height: 50px;\n max-height: 70px;\n}\n\n.dialpad-btn:hover {\n background: var(--bg-secondary);\n}\n\n.dialpad-btn:active {\n transform: scale(0.95);\n}\n\n.dialpad-number {\n font-size: 24px;\n line-height: 1;\n font-weight: 300;\n}\n\n.dialpad-letters {\n font-size: 8px;\n color: var(--text-secondary);\n letter-spacing: 1.2px;\n text-transform: uppercase;\n margin-top: 2px;\n}\n\n.call-btn-wrapper {\n display: flex;\n justify-content: center;\n padding: 8px 0 12px;\n}\n\n.call-btn {\n width: 56px;\n height: 56px;\n border-radius: 50%;\n background: var(--accent-color);\n border: none;\n color: white;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n box-shadow: 0 4px 12px rgba(34, 197, 94, 0.3);\n transition: all 0.2s;\n}\n\n.call-btn:hover {\n background: #16a34a;\n transform: scale(1.05);\n}\n\n.call-btn:active {\n transform: scale(0.95);\n}\n\n.call-btn:disabled {\n background: var(--text-secondary);\n opacity: 0.5;\n cursor: not-allowed;\n transform: none;\n}\n\n.active-call {\n padding: 0;\n text-align: center;\n display: flex;\n flex-direction: column;\n height: 100%;\n justify-content: space-around;\n animation: fadeIn 0.2s ease;\n}\n\n@keyframes fadeIn {\n from { opacity: 0; }\n to { opacity: 1; }\n}\n\n.call-info {\n padding: 40px 20px 20px;\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 12px;\n}\n\n.active-call.compact .call-info {\n padding: 20px 16px 12px;\n gap: 8px;\n}\n\n.keypad-header {\n padding: 10px 16px;\n text-align: center;\n border-bottom: 1px solid rgba(255, 255, 255, 0.06);\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 8px;\n font-size: 14px;\n color: var(--text-secondary);\n}\n\n.keypad-header-number {\n font-weight: 500;\n color: var(--text-primary);\n}\n\n.keypad-header-sep {\n opacity: 0.4;\n font-size: 12px;\n}\n\n.keypad-header-duration {\n font-weight: 400;\n}\n\n.dialed-digits {\n font-size: 18px;\n font-weight: 500;\n color: var(--text-primary);\n letter-spacing: 3px;\n font-variant-numeric: tabular-nums;\n}\n\n.call-number {\n font-size: 32px;\n font-weight: 400;\n color: var(--text-primary);\n letter-spacing: 1px;\n order: 1;\n}\n\n.active-call.compact .call-number {\n font-size: 24px;\n}\n\n.call-duration {\n font-size: 16px;\n color: var(--text-primary);\n font-weight: 300;\n display: flex;\n align-items: center;\n gap: 8px;\n order: 2;\n}\n\n.duration-indicator {\n width: 8px;\n height: 8px;\n background: var(--accent-color);\n border-radius: 50%;\n display: inline-block;\n animation: pulse 2s infinite;\n}\n\n.call-status {\n font-size: 13px;\n color: var(--text-secondary);\n text-transform: capitalize;\n order: 3;\n}\n\n.call-controls {\n display: flex;\n flex-direction: column;\n gap: 20px;\n padding: 40px 20px 20px;\n}\n\n.active-call.compact .call-controls {\n padding: 16px;\n gap: 0;\n}\n\n.compact-controls {\n display: grid;\n grid-template-columns: 1fr auto 1fr;\n align-items: center;\n gap: 16px;\n padding: 16px;\n}\n\n.compact-controls-icons {\n display: flex;\n gap: 8px;\n}\n\n.compact-controls-icons:first-child {\n justify-content: flex-end;\n}\n\n.compact-controls-icons:last-child {\n justify-content: flex-start;\n}\n\n.compact-icon-btn {\n width: 40px;\n height: 40px;\n border-radius: 50%;\n border: none;\n background: rgba(255, 255, 255, 0.08);\n color: var(--text-primary);\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: all 0.2s;\n}\n\n.compact-icon-btn:hover {\n background: rgba(255, 255, 255, 0.12);\n transform: scale(1.05);\n}\n\n.compact-icon-btn.active {\n background: var(--primary-color);\n color: white;\n}\n\n.compact-icon-btn:disabled {\n opacity: 0.3;\n cursor: not-allowed;\n}\n\n.compact-end-btn {\n width: 56px;\n height: 56px;\n border-radius: 50%;\n border: none;\n background: #ef4444; /* Always red for destructive action */\n color: white;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: all 0.2s;\n flex-shrink: 0;\n}\n\n.compact-end-btn:hover {\n transform: scale(1.05);\n box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);\n}\n\n.controls-row {\n display: grid;\n grid-template-columns: repeat(3, 1fr);\n gap: 16px;\n align-items: center;\n}\n\n.controls-row-end {\n display: flex;\n justify-content: center;\n align-items: center;\n gap: 24px;\n margin-top: 16px;\n padding: 0 20px;\n}\n\n.control-btn {\n width: 60px;\n height: 60px;\n border-radius: 50%;\n border: none;\n background: var(--bg-secondary);\n color: var(--text-primary);\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: all 0.2s;\n justify-self: center;\n pointer-events: auto;\n position: relative;\n z-index: 10;\n}\n\n.active-call.compact .control-btn {\n width: 50px;\n height: 50px;\n}\n\n.control-btn:hover {\n background: var(--border-color);\n transform: scale(1.05);\n}\n\n.control-btn.active {\n background: var(--primary-color);\n color: white;\n}\n\n.control-btn:disabled {\n opacity: 0.3;\n cursor: not-allowed;\n transform: none;\n pointer-events: none;\n}\n\n.btn-label {\n display: none;\n}\n\n.end-btn {\n width: 68px;\n height: 68px;\n background: var(--danger-color);\n color: white;\n border-radius: 50%;\n border: none;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: all 0.2s;\n justify-self: center;\n}\n\n.end-btn:hover {\n background: #dc2626;\n transform: scale(1.05);\n}\n\n.end-btn:disabled {\n opacity: 0.3;\n cursor: not-allowed;\n transform: none;\n}\n\n.branding {\n padding: 10px;\n text-align: center;\n font-size: 10px;\n color: var(--text-secondary);\n border-top: 1px solid var(--border-color);\n background: var(--bg-primary);\n flex-shrink: 0;\n}\n\n/* Tabs Navigation */\n.tabs-nav {\n display: flex;\n background: var(--bg-secondary);\n border-bottom: 1px solid var(--border-color);\n // margin: 0 0 16px 0;\n flex-shrink: 0;\n}\n\n.tab-btn {\n flex: 1;\n padding: 12px 8px;\n background: transparent;\n border: none;\n border-bottom: 2px solid transparent;\n color: var(--text-secondary);\n font-size: 12px;\n font-weight: 500;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 4px;\n transition: all 0.2s;\n}\n\n.tab-btn:hover {\n background: rgba(255,255,255,0.05);\n}\n\n.tab-btn.active {\n color: var(--primary-color);\n border-bottom-color: var(--primary-color);\n}\n\n.tab-btn svg {\n width: 14px;\n height: 14px;\n}\n\n/* History View */\n.history-view {\n display: flex;\n flex-direction: column;\n flex: 1;\n min-height: 0;\n animation: fadeIn 0.2s ease;\n overflow: hidden;\n margin: -24px -20px 0;\n position: relative;\n}\n\n/* History List */\n.history-list {\n flex: 1;\n overflow-y: auto;\n overflow-x: hidden;\n margin: 0 -20px;\n position: relative;\n}\n\n.history-list.updating {\n opacity: 1;\n}\n\n.history-item {\n display: flex;\n align-items: center;\n gap: 12px;\n padding: 12px 32px;\n border-bottom: 1px solid var(--border-color);\n cursor: pointer;\n transition: background 0.15s ease;\n backface-visibility: hidden;\n transform: translateZ(0);\n}\n\n.history-item:hover {\n background: var(--bg-secondary);\n}\n\n.history-item.selected {\n background: var(--bg-secondary);\n border-left: 3px solid var(--primary-color);\n}\n\n.history-icon {\n width: 40px;\n height: 40px;\n border-radius: 50%;\n background: var(--bg-secondary);\n display: flex;\n align-items: center;\n justify-content: center;\n color: var(--text-secondary);\n flex-shrink: 0;\n}\n\n.history-icon.missed {\n color: var(--danger-color);\n}\n\n.history-icon.outbound {\n color: var(--primary-color);\n}\n\n.history-info {\n flex: 1;\n min-width: 0;\n}\n\n.history-number {\n font-size: 14px;\n font-weight: 500;\n color: var(--text-primary);\n margin-bottom: 2px;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n.history-status {\n font-size: 12px;\n color: var(--text-secondary);\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n.history-status.outbound {\n color: var(--primary-color);\n}\n\n.history-time {\n font-size: 12px;\n color: var(--text-secondary);\n text-align: right;\n flex-shrink: 0;\n white-space: nowrap;\n margin-left: 8px;\n}\n\n.history-duration {\n font-size: 11px;\n color: var(--text-secondary);\n display: block;\n margin-top: 2px;\n}\n\n.call-back-container {\n position: sticky;\n bottom: 0;\n z-index: 10;\n}\n\n.call-back-btn {\n width: 100%;\n padding: 16px 20px;\n background: var(--primary-color);\n color: white;\n border: none;\n border-radius: 0;\n font-size: 16px;\n font-weight: 600;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 10px;\n transition: opacity 0.2s ease;\n}\n\n.call-back-btn:hover {\n opacity: 0.95;\n}\n\n.call-back-btn:active {\n opacity: 0.85;\n}\n\n.empty-state {\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n padding: 60px 20px;\n text-align: center;\n color: var(--text-secondary);\n height: 100%;\n backface-visibility: hidden;\n transform: translateZ(0);\n}\n\n.empty-state svg {\n width: 48px;\n height: 48px;\n margin-bottom: 16px;\n opacity: 0.5;\n}\n\n.empty-state-text {\n font-size: 14px;\n}\n\n/* Bottom Navigation */\n.bottom-nav {\n display: flex;\n background: var(--bg-primary);\n border-top: 1px solid var(--border-color);\n flex-shrink: 0;\n}\n\n.nav-btn {\n flex: 1;\n padding: 12px 8px 10px;\n background: transparent;\n border: none;\n color: var(--text-secondary);\n cursor: pointer;\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 4px;\n font-size: 11px;\n font-weight: 500;\n transition: all 0.2s;\n}\n\n.nav-btn:hover {\n background: var(--bg-primary);\n}\n\n.nav-btn.active {\n color: var(--primary-color);\n}\n\n.nav-btn svg {\n width: 24px;\n height: 24px;\n}\n\n.dialer-footer {\n padding: 6px 16px 4px;\n text-align: center;\n background: var(--bg-primary);\n flex-shrink: 0;\n}\n\n.footer-link {\n color: var(--text-secondary);\n font-size: 10px;\n text-decoration: none;\n opacity: 0.6;\n transition: opacity 0.2s;\n line-height: 1;\n}\n\n.footer-link:hover {\n opacity: 0.9;\n text-decoration: underline;\n}\n\n@media (max-width: 420px) {\n .dialer-panel { width: calc(100vw - 48px); }\n}\n\n/* Incoming Call Modal - Compact Toast Style */\n.incoming-call-overlay {\n position: fixed;\n top: 20px;\n right: 20px;\n z-index: 10000;\n pointer-events: none;\n animation: slideInRight 0.3s cubic-bezier(0.4, 0, 0.2, 1);\n}\n\n.incoming-call-modal {\n background: var(--bg-primary);\n border-radius: 20px;\n padding: 24px;\n box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.1);\n width: 320px;\n pointer-events: auto;\n backdrop-filter: blur(20px);\n -webkit-backdrop-filter: blur(20px);\n border: 1px solid rgba(255, 255, 255, 0.08);\n}\n\n.incoming-call-info {\n text-align: center;\n margin-bottom: 20px;\n}\n\n.incoming-call-label {\n font-size: 11px;\n color: var(--text-secondary);\n text-transform: uppercase;\n letter-spacing: 1.2px;\n font-weight: 600;\n margin-bottom: 8px;\n opacity: 0.8;\n}\n\n.incoming-call-name {\n font-size: 16px;\n font-weight: 700;\n color: var(--text-primary);\n margin-bottom: 4px;\n letter-spacing: -0.2px;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n\n.incoming-call-number {\n font-size: 20px;\n font-weight: 600;\n color: var(--text-primary);\n letter-spacing: -0.3px;\n line-height: 1.3;\n}\n\n.incoming-call-actions {\n display: flex;\n gap: 12px;\n justify-content: center;\n}\n\n.incoming-call-btn {\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 6px;\n padding: 0;\n border: none;\n background: none;\n cursor: pointer;\n transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);\n position: relative;\n flex: 1;\n}\n\n.incoming-call-btn::before {\n content: '';\n width: 52px;\n height: 52px;\n border-radius: 50%;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);\n}\n\n.incoming-call-btn svg {\n position: absolute;\n top: 12px;\n left: 50%;\n transform: translateX(-50%);\n width: 28px;\n height: 28px;\n pointer-events: none;\n}\n\n.incoming-call-btn span {\n font-size: 13px;\n font-weight: 600;\n color: var(--text-primary);\n margin-top: 52px;\n}\n\n.answer-btn::before {\n background: var(--accent-color);\n box-shadow: 0 6px 20px rgba(34, 197, 94, 0.4);\n}\n\n.answer-btn svg {\n color: white;\n}\n\n.answer-btn:hover::before {\n background: #1ea94f;\n transform: scale(1.08);\n box-shadow: 0 8px 24px rgba(34, 197, 94, 0.5);\n}\n\n.answer-btn:active::before {\n transform: scale(1.02);\n}\n\n.reject-btn::before {\n background: var(--danger-color);\n box-shadow: 0 6px 20px rgba(239, 68, 68, 0.4);\n}\n\n.reject-btn svg {\n color: white;\n}\n\n.reject-btn:hover::before {\n background: #dc2626;\n transform: scale(1.08);\n box-shadow: 0 8px 24px rgba(239, 68, 68, 0.5);\n}\n\n.reject-btn:active::before {\n transform: scale(1.02);\n}\n\n@keyframes slideInRight {\n 0% {\n opacity: 0;\n transform: translateX(100px);\n }\n 100% {\n opacity: 1;\n transform: translateX(0);\n }\n}\n\n@media (max-width: 420px) {\n .incoming-call-overlay {\n top: 16px;\n right: 16px;\n left: 16px;\n }\n .incoming-call-modal {\n width: auto;\n }\n}\n\n/* In-Call Keypad Overlay */\n.incall-keypad-overlay {\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background: rgba(0, 0, 0, 0.7);\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: 10001;\n animation: fadeIn 0.2s ease-out;\n}\n\n.incall-keypad-modal {\n background: var(--bg-primary);\n border-radius: 20px;\n width: 360px;\n max-width: calc(100vw - 48px);\n box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);\n animation: slideUp 0.3s ease-out;\n}\n\n.incall-keypad-header {\n display: flex;\n justify-content: space-between;\n align-items: center;\n padding: 20px 24px;\n border-bottom: 1px solid var(--border-color);\n}\n\n.incall-keypad-header h3 {\n margin: 0;\n font-size: 18px;\n font-weight: 600;\n color: var(--text-primary);\n}\n\n.incall-dialpad {\n display: grid;\n grid-template-columns: repeat(3, 1fr);\n gap: 12px;\n padding: 24px;\n}\n\n/* Inline keypad in active call */\n.incall-keypad {\n display: grid;\n grid-template-columns: repeat(3, 1fr);\n gap: 10px;\n padding: 12px 16px 16px;\n margin-top: 0;\n}\n\n.incall-keypad .dialpad-btn {\n min-height: 56px;\n font-size: 20px;\n background: transparent;\n transition: all 0.15s;\n}\n\n.incall-keypad .dialpad-btn:hover {\n background: rgba(255, 255, 255, 0.08);\n transform: scale(1.02);\n}\n\n.incall-keypad .dialpad-btn:active {\n transform: scale(0.96);\n background: rgba(255, 255, 255, 0.12);\n}\n\n.incall-keypad .dialpad-number {\n font-size: 24px;\n font-weight: 300;\n}\n\n.incall-keypad .dialpad-letters {\n font-size: 10px;\n opacity: 0.6;\n letter-spacing: 1px;\n}\n\n@keyframes fadeIn {\n from {\n opacity: 0;\n }\n to {\n opacity: 1;\n }\n}\n\n@keyframes slideUp {\n from {\n transform: translateY(20px);\n opacity: 0;\n }\n to {\n transform: translateY(0);\n opacity: 1;\n }\n}\n\n/* Account View */\n.account-view {\n overflow-y: auto;\n overflow-x: hidden;\n flex: 1;\n backface-visibility: hidden;\n transform: translateZ(0);\n padding-bottom: 16px;\n}\n\n.account-section {\n margin-bottom: 20px;\n padding-bottom: 20px;\n border-bottom: 1px solid var(--border-color);\n overflow: hidden;\n}\n\n.account-section:last-child {\n border-bottom: none;\n margin-bottom: 0;\n padding-bottom: 0;\n}\n\n.account-section-title {\n font-size: 14px;\n font-weight: 600;\n color: var(--text-primary);\n margin: 0 0 16px 0;\n text-transform: uppercase;\n letter-spacing: 0.5px;\n}\n\n.device-selector {\n display: grid;\n grid-template-columns: minmax(90px, auto) auto minmax(0, 1fr);\n align-items: center;\n gap: 8px;\n margin-bottom: 16px;\n width: 100%;\n}\n\n.device-selector:last-child {\n margin-bottom: 0;\n}\n\n.device-label {\n display: flex;\n align-items: center;\n gap: 6px;\n font-size: 12px;\n font-weight: 500;\n color: var(--text-primary);\n white-space: nowrap;\n}\n\n.device-label svg {\n color: var(--text-secondary);\n}\n\n.device-select {\n grid-column: 3;\n padding: 8px 10px;\n border: 1px solid var(--border-color);\n border-radius: 6px;\n background: var(--bg-secondary);\n color: var(--text-primary);\n font-size: 12px;\n cursor: pointer;\n transition: border-color 0.2s;\n width: 100%;\n min-width: 0;\n max-height: 150px;\n overflow-y: auto;\n}\n\n.device-select:hover {\n border-color: var(--primary-color);\n}\n\n.device-select:focus {\n outline: none;\n border-color: var(--primary-color);\n box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.1);\n}\n\n.device-select option {\n padding: 8px;\n font-size: 12px;\n background: var(--bg-secondary);\n color: var(--text-primary);\n}\n\n.device-select-btn {\n padding: 6px;\n border: 1px solid var(--border-color);\n border-radius: 6px;\n background: var(--bg-secondary);\n color: var(--text-secondary);\n cursor: pointer;\n transition: all 0.2s;\n display: flex;\n align-items: center;\n justify-content: center;\n width: 32px;\n height: 32px;\n flex-shrink: 0;\n}\n\n.device-select-btn:hover {\n background: var(--bg-primary);\n color: var(--primary-color);\n border-color: var(--primary-color);\n}\n\n.account-info {\n display: flex;\n flex-direction: column;\n gap: 12px;\n}\n\n.account-info-row {\n display: flex;\n justify-content: space-between;\n align-items: center;\n padding: 12px;\n background: var(--bg-secondary);\n border-radius: 8px;\n gap: 12px;\n min-width: 0;\n}\n\n.account-info-label {\n font-size: 13px;\n font-weight: 500;\n color: var(--text-secondary);\n flex-shrink: 0;\n}\n\n.account-info-value {\n font-size: 13px;\n color: var(--text-primary);\n font-weight: 500;\n text-align: right;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n min-width: 0;\n}\n\n.status-connected {\n color: var(--accent-color);\n}\n\n.status-disconnected {\n color: var(--text-secondary);\n}\n\n.account-section-subtitle {\n font-size: 13px;\n color: var(--text-secondary);\n margin: -8px 0 20px 0;\n line-height: 1.5;\n}\n\n.device-row {\n display: grid;\n grid-template-columns: 100px 1fr;\n align-items: center;\n gap: 16px;\n padding: 14px 0;\n border-bottom: 1px solid var(--border-color);\n}\n\n.device-row:last-child {\n border-bottom: none;\n}\n\n.device-row-label {\n font-size: 14px;\n font-weight: 500;\n color: var(--text-primary);\n}\n\n.device-row-select {\n padding: 11px 14px;\n border: 1.5px solid var(--border-color);\n border-radius: 8px;\n background: var(--bg-secondary);\n color: var(--text-primary);\n font-size: 13px;\n font-weight: 500;\n cursor: pointer;\n transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);\n appearance: none;\n background-image: url("data:image/svg+xml,%3Csvg width='14' height='8' viewBox='0 0 14 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L7 7L13 1' stroke='%23999' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");\n background-repeat: no-repeat;\n background-position: right 12px center;\n padding-right: 40px;\n box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);\n}\n\n.device-row-select:hover {\n border-color: var(--primary-color);\n background-color: var(--bg-primary);\n box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);\n}\n\n.device-row-select:focus {\n outline: none;\n border-color: var(--primary-color);\n box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.12), 0 2px 4px rgba(0, 0, 0, 0.08);\n}\n\n.device-row-select option {\n background: var(--bg-secondary);\n color: var(--text-primary);\n padding: 12px;\n font-weight: 500;\n}\n\n/* Call Quality Indicator */\n.call-quality {\n display: flex;\n align-items: center;\n gap: 6px;\n font-size: 11px;\n padding: 4px 8px;\n border-radius: 6px;\n margin-top: 4px;\n background: var(--bg-secondary);\n width: fit-content;\n}\n\n.quality-bars {\n font-size: 10px;\n letter-spacing: 1px;\n}\n\n.quality-label {\n text-transform: capitalize;\n font-weight: 600;\n}\n\n.quality-excellent {\n color: #10b981;\n background: rgba(16, 185, 129, 0.1);\n}\n\n.quality-good {\n color: var(--accent-color);\n background: rgba(34, 197, 94, 0.1);\n}\n\n.quality-fair {\n color: #f59e0b;\n background: rgba(245, 158, 11, 0.1);\n}\n\n.quality-poor {\n color: var(--danger-color);\n background: rgba(239, 68, 68, 0.1);\n}\n\n/* Park View */\n.park-view {\n overflow-y: auto;\n overflow-x: hidden;\n flex: 1;\n backface-visibility: hidden;\n transform: translateZ(0);\n padding-bottom: 16px;\n}\n\n.park-header {\n margin-bottom: 16px;\n}\n\n.park-title {\n font-size: 14px;\n font-weight: 600;\n color: var(--text-primary);\n margin: 0 0 4px 0;\n text-transform: uppercase;\n letter-spacing: 0.5px;\n}\n\n.park-subtitle {\n font-size: 12px;\n color: var(--text-secondary);\n margin: 0;\n}\n\n.park-list,\n.park-slots {\n display: flex;\n flex-direction: column;\n gap: 8px;\n}\n\n.park-item {\n display: flex;\n align-items: center;\n gap: 12px;\n padding: 12px;\n background: var(--bg-secondary);\n border: 1px solid var(--border-color);\n border-radius: 8px;\n cursor: pointer;\n transition: all 0.2s;\n}\n\n.park-item:hover {\n background: var(--bg-hover);\n border-color: var(--primary-color);\n}\n\n.park-item.occupied {\n opacity: 0.6;\n cursor: not-allowed;\n}\n\n.park-item.occupied:hover {\n background: var(--bg-secondary);\n border-color: var(--border-color);\n}\n\n.park-item-icon {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 40px;\n height: 40px;\n background: var(--primary-color-light);\n border-radius: 50%;\n color: var(--primary-color);\n flex-shrink: 0;\n}\n\n.park-item-info {\n flex: 1;\n min-width: 0;\n}\n\n.park-item-label {\n font-size: 14px;\n font-weight: 500;\n color: var(--text-primary);\n margin-bottom: 2px;\n}\n\n.park-item-extension {\n font-size: 12px;\n color: var(--text-secondary);\n}\n\n.park-item-details {\n margin-top: 6px;\n padding-top: 6px;\n border-top: 1px solid var(--border-color);\n}\n\n.parked-caller {\n font-size: 13px;\n font-weight: 500;\n color: var(--primary-color);\n margin-bottom: 2px;\n}\n\n.parked-meta {\n font-size: 11px;\n color: var(--text-secondary);\n}\n\n.park-item-status {\n flex-shrink: 0;\n}\n\n.status-badge {\n padding: 4px 8px;\n border-radius: 4px;\n font-size: 11px;\n font-weight: 500;\n}\n\n.status-badge.available {\n color: var(--accent-color);\n background: rgba(34, 197, 94, 0.1);\n}\n\n.status-badge.occupied {\n color: var(--text-secondary);\n background: var(--bg-secondary);\n}\n\n/* Parked Call Item */\n.parked-call-item {\n display: flex;\n align-items: center;\n gap: 12px;\n padding: 12px;\n background: var(--bg-secondary);\n border: 1px solid var(--border-color);\n border-radius: 8px;\n margin-bottom: 8px;\n}\n\n.parked-call-icon {\n width: 40px;\n height: 40px;\n background: rgba(255, 107, 53, 0.1);\n border-radius: 50%;\n display: flex;\n align-items: center;\n justify-content: center;\n color: var(--primary-color);\n flex-shrink: 0;\n}\n\n.parked-call-info {\n flex: 1;\n min-width: 0;\n}\n\n.parked-call-number {\n font-size: 16px;\n font-weight: 500;\n color: var(--text-primary);\n margin-bottom: 4px;\n}\n\n.parked-call-meta {\n font-size: 12px;\n color: var(--text-secondary);\n}\n\n.retrieve-btn {\n padding: 8px 20px;\n background: var(--primary-color);\n color: white;\n border: none;\n border-radius: 6px;\n font-size: 14px;\n font-weight: 500;\n cursor: pointer;\n transition: all 0.2s;\n flex-shrink: 0;\n}\n\n.retrieve-btn:hover {\n background: #ff5722;\n transform: scale(1.02);\n}\n\n/* Park Footer */\n.park-footer {\n margin-top: 24px;\n padding-top: 16px;\n border-top: 1px solid var(--border-color);\n}\n\n.park-footer-text {\n font-size: 12px;\n color: var(--text-secondary);\n margin: 0 0 12px 0;\n}\n\n.park-slot-buttons {\n display: flex;\n flex-wrap: wrap;\n gap: 8px;\n}\n\n.park-slot-btn {\n padding: 8px 16px;\n background: var(--bg-secondary);\n border: 1px solid var(--border-color);\n border-radius: 6px;\n color: var(--text-primary);\n font-size: 14px;\n font-weight: 500;\n cursor: pointer;\n transition: all 0.2s;\n}\n\n.park-slot-btn:hover {\n background: var(--primary-color);\n color: white;\n border-color: var(--primary-color);\n}\n\n/* Transfer panel */\n.transfer-panel {\n display: flex;\n flex-direction: column;\n gap: 10px;\n padding: 12px;\n flex: 1;\n overflow: hidden;\n}\n\n.panel-header {\n display: flex;\n align-items: center;\n gap: 10px;\n font-weight: 600;\n font-size: 14px;\n color: var(--text-primary);\n}\n\n.back-btn {\n background: none;\n border: none;\n cursor: pointer;\n color: var(--primary-color);\n padding: 0;\n font-size: 13px;\n flex-shrink: 0;\n}\n\n.back-btn:hover {\n opacity: 0.8;\n}\n\n.transfer-input {\n padding: 9px 12px;\n border: 1px solid var(--border-color);\n border-radius: 8px;\n font-size: 14px;\n outline: none;\n background: var(--bg-secondary);\n color: var(--text-primary);\n transition: border-color 0.2s;\n}\n\n.transfer-input:focus {\n border-color: var(--primary-color);\n}\n\n.transfer-ext-list {\n flex: 1;\n overflow-y: auto;\n max-height: 150px;\n}\n\n.transfer-ext-item {\n display: flex;\n justify-content: space-between;\n align-items: center;\n padding: 8px 6px;\n cursor: pointer;\n border-radius: 6px;\n transition: background 0.15s;\n}\n\n.transfer-ext-item:hover {\n background: var(--bg-hover, rgba(0,0,0,0.05));\n}\n\n.ext-name {\n font-weight: 600;\n font-size: 13px;\n color: var(--text-primary);\n}\n\n.ext-num {\n font-size: 11px;\n color: var(--text-secondary);\n font-family: monospace;\n}\n\n.transfer-confirm-btn {\n padding: 10px;\n background: var(--primary-color);\n color: #fff;\n border: none;\n border-radius: 8px;\n font-size: 14px;\n font-weight: 600;\n cursor: pointer;\n transition: opacity 0.2s;\n}\n\n.transfer-confirm-btn:hover:not(:disabled) {\n opacity: 0.9;\n}\n\n.transfer-confirm-btn:disabled {\n opacity: 0.4;\n cursor: not-allowed;\n}\n\n.transfer-empty {\n font-size: 12px;\n color: var(--text-secondary);\n padding: 8px;\n text-align: center;\n}\n\n/* Notification permission row */\n.notification-permission {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 8px 12px;\n font-size: 13px;\n color: var(--text-primary);\n}\n\n.status-ok {\n color: var(--accent-color, #22c55e);\n font-weight: 600;\n}\n\n/* Phone Number Selector */\n.phone-number-selector {\n margin-bottom: 16px;\n position: relative;\n width: 100%;\n}\n\n.account-phone-selector {\n margin-top: 12px;\n}\n\n.phone-number-label {\n display: flex;\n align-items: center;\n gap: 8px;\n font-size: 14px;\n font-weight: 500;\n margin-bottom: 8px;\n color: var(--text-primary);\n}\n\n.label-hint {\n font-size: 12px;\n font-weight: 400;\n color: var(--text-secondary);\n font-style: italic;\n}\n\n.phone-number-dropdown-trigger {\n width: 100%;\n padding: 12px 16px;\n border: 1px solid var(--border-color);\n border-radius: 8px;\n background: var(--bg-secondary);\n display: flex;\n justify-content: space-between;\n align-items: center;\n cursor: pointer;\n transition: border-color 0.2s;\n}\n\n.phone-number-dropdown-trigger:hover {\n border-color: var(--primary-color);\n}\n\n.phone-number-dropdown-trigger:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n}\n\n.selected-number {\n font-size: 14px;\n font-weight: 500;\n color: var(--text-primary);\n}\n\n.dropdown-icon {\n width: 20px;\n height: 20px;\n fill: var(--text-secondary);\n transition: transform 0.2s;\n}\n\n.dropdown-icon.rotated {\n transform: rotate(180deg);\n}\n\n.phone-number-dropdown-container {\n position: relative;\n}\n\n.phone-number-dropdown {\n position: absolute;\n bottom: 100%;\n left: 0;\n right: 0;\n margin-bottom: 4px;\n background: var(--bg-primary);\n border: 1px solid var(--border-color);\n border-radius: 8px;\n box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);\n max-height: 240px;\n overflow-y: auto;\n z-index: 1000;\n}\n\n.phone-number-item {\n width: 100%;\n padding: 12px 16px;\n border: none;\n border-left: 3px solid transparent;\n background: transparent;\n text-align: left;\n cursor: pointer;\n display: flex;\n align-items: center;\n gap: 12px;\n transition: all 0.2s;\n color: var(--text-primary);\n}\n\n.phone-number-item:hover {\n background: var(--bg-secondary);\n}\n\n.phone-number-item.selected {\n border-left-color: var(--primary-color);\n background: rgba(255, 107, 53, 0.05);\n}\n\n.phone-icon {\n width: 20px;\n height: 20px;\n fill: var(--text-secondary);\n flex-shrink: 0;\n}\n\n.phone-number-info {\n display: flex;\n flex-direction: column;\n gap: 4px;\n flex: 1;\n}\n\n.number-text {\n font-size: 14px;\n font-weight: 500;\n color: var(--text-primary);\n}\n\n.number-label {\n font-size: 12px;\n color: var(--text-secondary);\n}\n\n.phone-number-empty {\n padding: 16px;\n text-align: center;\n color: var(--text-secondary);\n display: flex;\n flex-direction: column;\n gap: 12px;\n align-items: center;\n font-size: 13px;\n}\n\n.error-text {\n color: var(--danger-color);\n font-size: 13px;\n}\n\n.retry-button {\n padding: 6px 12px;\n background: var(--primary-color);\n color: white;\n border: none;\n border-radius: 4px;\n cursor: pointer;\n font-size: 13px;\n transition: opacity 0.2s;\n}\n\n.retry-button:hover {\n opacity: 0.9;\n}\n\n.loading-spinner {\n display: inline-block;\n width: 12px;\n height: 12px;\n border: 2px solid var(--text-secondary);\n border-top-color: transparent;\n border-radius: 50%;\n animation: spin 0.6s linear infinite;\n}\n\n@keyframes spin {\n to { transform: rotate(360deg); }\n}\n\n.loading-message {\n font-size: 12px;\n color: var(--text-secondary);\n text-align: center;\n margin-top: 8px;\n}\n</style>\n ${"collapsed"===t?this.renderCollapsed():this.renderExpanded()}\n ${this.incomingCallNumber?this.renderIncomingCallModal():""}\n ${this.showRetrieveModal?this.renderRetrieveModal():""}\n `;const e=this.shadow.getElementById("phoneInput");e&&this.phoneInputValue&&(e.value=this.phoneInputValue),this.isInitialized&&(this.updateButtonStates(),this.attachDragHandlers())}else this.performSelectiveUpdate(t)}performSelectiveUpdate(e){if("collapsed"===e){const e=this.shadow.querySelector(".dialer-fab");if(e){const t="connected"===this.callStatus,n=e.querySelector(".call-indicator");t&&!n?e.insertAdjacentHTML("beforeend",'<span class="call-indicator"></span>'):!t&&n&&n.remove()}}else this.updateExpandedContent();this.updateModalOverlays()}updateExpandedContent(){const e=this.shadow.querySelector(".dialer-body");if(e)if("idle"!==this.callStatus&&"ended"!==this.callStatus&&"error"!==this.callStatus)"dial"===this.currentView&&this.updateActiveCallUI();else{const t=e.querySelector(".input-section, .history-view, .account-view"),n="history"===this.currentView?"history-view":"account"===this.currentView?"account-view":"input-section";t?.classList.contains(n)?"dial"===this.currentView?(this.updatePhoneInput(),this.updateButtonStates()):this.currentView:this.updateMainView()}}updateDialedDigitsDisplay(){const e=this.shadow.querySelector(".dialed-digits");if(e)e.textContent=this.dialedDigits,e.setAttribute("title",`Dialed: ${this.dialedDigits}`);else if(this.dialedDigits){const e=this.shadow.querySelector(".keypad-header");e&&(e.innerHTML=`<div class="dialed-digits" title="Dialed: ${this.dialedDigits}">${this.dialedDigits}</div>`)}}updateActiveCallUI(){const e=this.shadow.querySelector(".active-call");if(!e){if("park"===this.currentView)return;const e=this.shadow.querySelector(".dialer-body");return void(e&&(e.innerHTML=this.renderActiveCall()))}if(!!e.querySelector(".incall-keypad")!==this.showInCallKeypad){const e=this.shadow.querySelector(".dialer-body");return void(e&&(e.innerHTML=this.renderActiveCall()))}const t=this.currentCall?.duration||0,n=e.querySelector(".keypad-header-duration");n&&(n.textContent=this.formatDuration(t));let i=e.querySelector(".call-duration");if("connected"===this.callStatus)if(i)i.innerHTML=`\n\t\t\t\t\t<span class="duration-indicator"></span>\n\t\t\t\t\t${this.formatDuration(t)}\n\t\t\t\t`;else{const n=e.querySelector(".call-info"),r=e.querySelector(".call-number");n&&r&&(r.insertAdjacentHTML("afterend",`<div class="call-duration">\n\t\t\t\t\t\t\t<span class="duration-indicator"></span>\n\t\t\t\t\t\t\t${this.formatDuration(t)}\n\t\t\t\t\t\t</div>`),i=e.querySelector(".call-duration"))}const r=e.querySelector(".call-status");if(r){const e=this.isOnHold?"On Hold":"connected"===this.callStatus?"Connected":this.callStatus;r.textContent=e}const o=e.querySelector("#muteBtn"),a=e.querySelector("#holdBtn"),d=e.querySelector("#recordBtn"),s=e.querySelector("#keypadBtn"),l=e.querySelector("#parkBtn"),c="connected"===this.callStatus;[o,a,d,s,l].forEach(e=>{e&&(c?e.removeAttribute("disabled"):e.setAttribute("disabled",""))}),o&&(this.isMuted?o.classList.add("active"):o.classList.remove("active")),a&&(this.isOnHold?a.classList.add("active"):a.classList.remove("active")),d&&(this.isRecording?d.classList.add("active"):d.classList.remove("active"))}updateModalOverlays(){const e=this.shadow.querySelector(".incoming-call-overlay");if(this.incomingCallNumber&&!e){const e=document.createElement("div");e.innerHTML=this.renderIncomingCallModal(),this.shadow.appendChild(e.firstElementChild)}else!this.incomingCallNumber&&e&&e.remove()}updateButtonStates(){const e=this.shadow.getElementById("phoneInput"),t=this.shadow.getElementById("callBtn"),n=this.shadow.getElementById("backspaceBtn"),i=e&&e.value.trim().length>0;t&&(t.disabled=!i),n&&(n.disabled=!i)}toggleCountryDropdown(){if(this.showCountryDropdown=!this.showCountryDropdown,this.showCountryDropdown){const e=this.shadow.querySelector(".dialer-panel");e&&(e.insertAdjacentHTML("beforebegin",this.renderCountryBackdrop()),e.insertAdjacentHTML("beforebegin",this.renderCountryDropdown()));const t=this.shadow.querySelector(".country-selector"),n=this.shadow.querySelector(".country-dropdown");if(t&&n){const i=t.getBoundingClientRect(),r=e?.getBoundingClientRect();r&&(n.style.position="absolute",n.style.top=i.bottom-r.top+4+"px",n.style.left=i.left-r.left+"px")}}else{const e=this.shadow.querySelector(".country-dropdown-backdrop"),t=this.shadow.querySelector(".country-dropdown");e&&e.remove(),t&&t.remove()}}selectCountry(e){const t=O.find(t=>t.code===e);if(!t)return;this.selectedCountry=t,this.showCountryDropdown=!1;const n=this.shadow.querySelector(".country-btn");n&&(n.innerHTML=`\n\t\t\t\t<span class="country-flag">${t.flag}</span>\n\t\t\t\t<span class="country-code">${t.dialCode}</span>\n\t\t\t\t<svg class="dropdown-icon" width="12" height="12" viewBox="0 0 24 24" fill="currentColor">\n\t\t\t\t\t<path d="M7 10l5 5 5-5z"/>\n\t\t\t\t</svg>\n\t\t\t`);const i=this.shadow.querySelector(".country-dropdown-backdrop"),r=this.shadow.querySelector(".country-dropdown");i&&i.remove(),r&&r.remove()}renderCollapsed(){return`\n <button class="dialer-fab" id="fab">\n <svg width="24" height="24" viewBox="0 0 24 24" fill="none">\n <path d="M20 10.999h2C22 5.869 18.127 2 12.99 2v2C17.052 4 20 6.943 20 10.999z" fill="currentColor"/>\n <path d="M13 8c2.103 0 3 .897 3 3h2c0-3.225-1.775-5-5-5v2zm3.422 5.443a1.001 1.001 0 00-1.391.043l-2.393 2.461c-.576-.11-1.734-.471-2.926-1.66-1.192-1.193-1.553-2.354-1.66-2.926l2.459-2.394a1 1 0 00.043-1.391L6.859 3.513a1 1 0 00-1.391-.087l-2.17 1.861a1 1 0 00-.29.649c-.015.25-.301 6.172 4.291 10.766C11.305 20.707 16.323 21 17.705 21c.202 0 .326-.006.359-.008a.992.992 0 00.648-.291l1.86-2.171a1 1 0 00-.086-1.391l-4.064-3.696z" fill="currentColor"/>\n </svg>\n ${"connected"===this.callStatus?'<span class="call-indicator"></span>':""}\n </button>\n `}renderExpanded(){const e=this.config.brandName||"Convirza",t=this.config.brandLogo;return`\n <div class="dialer-panel">\n <div class="dialer-header">\n <div class="header-brand">\n ${t?`<img src="${t}" alt="${e}" class="brand-logo" />`:""}\n <span>${e}</span>\n </div>\n <div class="header-controls">\n <button class="header-btn" id="minimizeBtn">−</button>\n <button class="header-btn" id="closeBtn">×</button>\n </div>\n </div>\n\n <div class="dialer-body">\n ${"idle"!==this.callStatus&&"dial"===this.currentView?this.renderActiveCall():"park"===this.currentView?this.renderPark():"history"===this.currentView?this.renderHistory():"account"===this.currentView?this.renderAccount():this.renderDialpad()}\n </div>\n\n ${this.renderBottomNav()}\n </div>\n `}renderCountryDropdown(){return`\n <div class="country-dropdown">\n ${O.map(e=>`\n <button class="country-option" data-country="${e.code}">\n <span class="country-flag">${e.flag}</span>\n <span class="country-name">${e.name}</span>\n <span class="country-code">${e.dialCode}</span>\n </button>\n `).join("")}\n </div>\n `}renderCountryBackdrop(){return'<div class="country-dropdown-backdrop" id="countryDropdownBackdrop"></div>'}renderDialpad(){return this.isDialerEnabled()?(this.config.brandName,`\n\n <div class="input-section">\n <div class="country-selector" id="countrySelector">\n <button class="country-btn" id="countryBtn">\n <span class="country-flag">${this.selectedCountry.flag}</span>\n <span class="country-code">${this.selectedCountry.dialCode}</span>\n <svg class="dropdown-icon" width="12" height="12" viewBox="0 0 24 24" fill="currentColor">\n <path d="M7 10l5 5 5-5z"/>\n </svg>\n </button>\n </div>\n <div class="phone-input-wrapper">\n <input type="text" class="phone-input" id="phoneInput" autocomplete="off"/>\n </div>\n <button class="toggle-btn" id="backspaceBtn" title="Backspace" disabled>\n <svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor">\n <path d="M22 3H7c-.69 0-1.23.35-1.59.88L0 12l5.41 8.11c.36.53.9.89 1.59.89h15c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H7.07L2.4 12l4.66-7H22v14zm-11.59-2L14 13.41 17.59 17 19 15.59 15.41 12 19 8.41 17.59 7 14 10.59 10.41 7 9 8.41 12.59 12 9 15.59z"/>\n </svg>\n </button>\n </div>\n\n <div class="dialpad">\n ${[1,2,3,4,5,6,7,8,9,"*",0,"#"].map(e=>{const t=o[e.toString()];return`\n <button class="dialpad-btn" data-digit="${e}">\n <span class="dialpad-number">${e}</span>\n ${t?`<span class="dialpad-letters">${t}</span>`:0===e?'<span class="dialpad-letters">+</span>':""}\n </button>\n `}).join("")}\n </div>\n\n \x3c!-- Phone Number Selector (Always shown) --\x3e\n <div class="phone-number-selector">\n <label class="phone-number-label">Call From</label>\n\n \x3c!-- Dropdown container always present, populated dynamically (positioned ABOVE button) --\x3e\n <div class="phone-number-dropdown-container"></div>\n\n <button\n class="phone-number-dropdown-trigger"\n id="phoneNumberDropdownBtn"\n >\n <span class="selected-number">\n ${this.selectedPhoneNumber?`${this.selectedPhoneNumber.assigned_user_name||"Unknown"} - ${this.formatPhoneNumberDisplay(this.selectedPhoneNumber.number||this.selectedPhoneNumber.number_str)}`:"No caller ID selected"}\n </span>\n <svg class="dropdown-icon ${this.showPhoneNumberDropdown?"rotated":""}" viewBox="0 0 24 24">\n <path d="M7 10l5 5 5-5z"/>\n </svg>\n </button>\n </div>\n\n <div class="call-btn-wrapper">\n <button class="call-btn" id="callBtn" disabled>\n <svg width="24" height="24" viewBox="0 0 24 24" fill="currentColor">\n <path d="M20 15.5c-1.25 0-2.45-.2-3.57-.57-.35-.11-.74-.03-1.02.24l-2.2 2.2c-2.83-1.44-5.15-3.75-6.59-6.59l2.2-2.21c.28-.26.36-.65.25-1C8.7 6.45 8.5 5.25 8.5 4c0-.55-.45-1-1-1H4c-.55 0-1 .45-1 1 0 9.39 7.61 17 17 17 .55 0 1-.45 1-1v-3.5c0-.55-.45-1-1-1z"/>\n </svg>\n </button>\n </div>\n `):this.renderDialerDisabled()}escapeHtml(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}renderTransferPanel(){return`\n <div class="transfer-panel">\n <div class="panel-header">\n <button id="cancelTransferBtn" class="back-btn">← Back</button>\n <span>Transfer to User</span>\n </div>\n <input id="transferTargetInput" class="transfer-input" type="tel"\n placeholder="User number or extension..." value="${this.escapeHtml(this.transferTarget)}" />\n <div class="transfer-ext-list">\n ${this.domainExtensions.length>0?this.domainExtensions.map(e=>`\n <div class="transfer-ext-item" data-transfer-ext="${this.escapeHtml(e.extension)}">\n <span class="ext-name">${this.escapeHtml(e.user_name||"Unknown User")}</span>\n <span class="ext-num">${this.escapeHtml(e.extension)}</span>\n </div>`).join(""):'<div class="transfer-empty">No users found</div>'}\n </div>\n <button id="confirmTransferBtn" class="transfer-confirm-btn"\n ${!this.transferTarget.trim()||this.isTransferring?"disabled":""}>\n ${this.isTransferring?"Transferring...":"Transfer Now"}\n </button>\n </div>\n `}renderActiveCall(){if(this.showTransferView)return this.renderTransferPanel();const e=this.currentCall?.phoneNumber||"",t=this.currentCall?.duration||0,n=this.isOnHold?"On Hold":"connected"===this.callStatus?"Connected":this.callStatus,i="connected"===this.callStatus;return`\n <div class="active-call ${this.showInCallKeypad?"compact":""}">\n ${this.showInCallKeypad?`\n <div class="keypad-header">\n ${this.dialedDigits?`<div class="dialed-digits" title="Dialed: ${this.dialedDigits}">${this.dialedDigits}</div>`:`\n <span class="keypad-header-number">${e}</span>\n <span class="keypad-header-sep">•</span>\n <span class="keypad-header-duration">${this.formatDuration(t)}</span>\n `}\n </div>\n `:`\n <div class="call-info">\n <div class="call-number">${e}</div>\n ${"connected"===this.callStatus?`\n <div class="call-duration">\n <span class="duration-indicator"></span>\n ${this.formatDuration(t)}\n </div>\n `:""}\n <div class="call-status">${n}</div>\n </div>\n `}\n ${this.showInCallKeypad?`\n <div class="incall-keypad">\n ${[1,2,3,4,5,6,7,8,9,"*",0,"#"].map(e=>{const t=o[e.toString()];return`\n <button class="dialpad-btn" data-dtmf="${e}">\n <span class="dialpad-number">${e}</span>\n ${t?`<span class="dialpad-letters">${t}</span>`:0===e?'<span class="dialpad-letters">+</span>':""}\n </button>\n `}).join("")}\n </div>\n `:""}\n <div class="call-controls">\n ${this.showInCallKeypad?`\n <div class="compact-controls">\n <div class="compact-controls-icons">\n <button class="compact-icon-btn ${this.isMuted?"active":""}" id="muteBtn" ${i?"":"disabled"} title="Mute">\n <svg width="18" height="18" viewBox="0 0 24 24" fill="currentColor">\n <path d="M12 14c1.66 0 3-1.34 3-3V5c0-1.66-1.34-3-3-3S9 3.34 9 5v6c0 1.66 1.34 3 3 3z"/>\n <path d="M17 11c0 2.76-2.24 5-5 5s-5-2.24-5-5H5c0 3.53 2.61 6.43 6 6.92V21h2v-3.08c3.39-.49 6-3.39 6-6.92h-2z"/>\n </svg>\n </button>\n <button class="compact-icon-btn ${this.isOnHold?"active":""}" id="holdBtn" ${i?"":"disabled"} title="Hold">\n <svg width="18" height="18" viewBox="0 0 24 24" fill="currentColor">\n <path d="M6 4h4v16H6V4zm8 0h4v16h-4V4z"/>\n </svg>\n </button>\n </div>\n <button class="compact-end-btn" id="endBtn">\n <svg width="26" height="26" viewBox="0 0 24 24" fill="currentColor">\n <path d="M12 9c-1.6 0-3.15.25-4.6.72v3.1c0 .39-.23.74-.56.9-.98.49-1.87 1.12-2.66 1.85-.18.18-.43.28-.7.28-.28 0-.53-.11-.71-.29L.29 13.08c-.18-.17-.29-.42-.29-.7 0-.28.11-.53.29-.71C3.34 8.78 7.46 7 12 7s8.66 1.78 11.71 4.67c.18.18.29.43.29.71 0 .28-.11.53-.29.71l-2.48 2.48c-.18.18-.43.29-.71.29-.27 0-.52-.11-.7-.28-.79-.74-1.68-1.36-2.66-1.85-.33-.16-.56-.5-.56-.9v-3.1C15.15 9.25 13.6 9 12 9z"/>\n </svg>\n </button>\n <div class="compact-controls-icons">\n \x3c!-- <button class="compact-icon-btn ${this.isRecording?"active":""}" id="recordBtn" ${i?"":"disabled"} title="Record" style="display:none;">\n <svg width="18" height="18" viewBox="0 0 24 24" fill="currentColor">\n <circle cx="12" cy="12" r="7"/>\n </svg>\n </button> --\x3e\n <button class="compact-icon-btn" id="parkBtn" ${i?"":"disabled"} title="Park">\n <svg width="18" height="18" viewBox="0 0 24 24" fill="currentColor">\n <path d="M13 3H6v18h4v-6h3c3.31 0 6-2.69 6-6s-2.69-6-6-6zm.2 8H10V7h3.2c1.1 0 2 .9 2 2s-.9 2-2 2z"/>\n </svg>\n </button>\n <button class="compact-icon-btn" id="transferBtn" ${i?"":"disabled"} title="Transfer">\n <svg width="18" height="18" viewBox="0 0 24 24" fill="currentColor">\n <path d="M6.62 10.79c1.44 2.83 3.76 5.14 6.59 6.59l2.2-2.2c.27-.27.67-.36 1.02-.24 1.12.37 2.33.57 3.57.57.55 0 1 .45 1 1V20c0 .55-.45 1-1 1-9.39 0-17-7.61-17-17 0-.55.45-1 1-1h3.5c.55 0 1 .45 1 1 0 1.25.2 2.45.57 3.57.11.35.03.74-.25 1.02l-2.2 2.2z M17 8l4 4-4 4V9h-3V7h3V8z"/>\n </svg>\n </button>\n <button class="compact-icon-btn" id="keypadBtn" ${i?"":"disabled"} title="Hide Keypad">\n <svg width="18" height="18" viewBox="0 0 24 24" fill="currentColor">\n <path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/>\n </svg>\n </button>\n </div>\n </div>\n `:`\n <div class="controls-row">\n <button class="control-btn ${this.isMuted?"active":""}" id="muteBtn" ${i?"":"disabled"}>\n <svg width="24" height="24" viewBox="0 0 24 24" fill="currentColor">\n <path d="M12 14c1.66 0 3-1.34 3-3V5c0-1.66-1.34-3-3-3S9 3.34 9 5v6c0 1.66 1.34 3 3 3z"/>\n <path d="M17 11c0 2.76-2.24 5-5 5s-5-2.24-5-5H5c0 3.53 2.61 6.43 6 6.92V21h2v-3.08c3.39-.49 6-3.39 6-6.92h-2z"/>\n </svg>\n </button>\n <button class="control-btn ${this.isOnHold?"active":""}" id="holdBtn" ${i?"":"disabled"}>\n <svg width="24" height="24" viewBox="0 0 24 24" fill="currentColor">\n <path d="M6 4h4v16H6V4zm8 0h4v16h-4V4z"/>\n </svg>\n </button>\n <button class="control-btn" id="keypadBtn" ${i?"":"disabled"}>\n <svg width="24" height="24" viewBox="0 0 24 24" fill="currentColor">\n <circle cx="5" cy="5" r="1.5"/>\n <circle cx="12" cy="5" r="1.5"/>\n <circle cx="19" cy="5" r="1.5"/>\n <circle cx="5" cy="12" r="1.5"/>\n <circle cx="12" cy="12" r="1.5"/>\n <circle cx="19" cy="12" r="1.5"/>\n <circle cx="5" cy="19" r="1.5"/>\n <circle cx="12" cy="19" r="1.5"/>\n <circle cx="19" cy="19" r="1.5"/>\n </svg>\n </button>\n </div>\n <div class="controls-row-end">\n <button class="end-btn" id="endBtn">\n <svg width="28" height="28" viewBox="0 0 24 24" fill="currentColor">\n <path d="M12 9c-1.6 0-3.15.25-4.6.72v3.1c0 .39-.23.74-.56.9-.98.49-1.87 1.12-2.66 1.85-.18.18-.43.28-.7.28-.28 0-.53-.11-.71-.29L.29 13.08c-.18-.17-.29-.42-.29-.7 0-.28.11-.53.29-.71C3.34 8.78 7.46 7 12 7s8.66 1.78 11.71 4.67c.18.18.29.43.29.71 0 .28-.11.53-.29.71l-2.48 2.48c-.18.18-.43.29-.71.29-.27 0-.52-.11-.7-.28-.79-.74-1.68-1.36-2.66-1.85-.33-.16-.56-.5-.56-.9v-3.1C15.15 9.25 13.6 9 12 9z"/>\n </svg>\n </button>\n <button class="control-btn" id="parkBtn" ${i?"":"disabled"} title="Park">\n <svg width="24" height="24" viewBox="0 0 24 24" fill="currentColor">\n <path d="M13 3H6v18h4v-6h3c3.31 0 6-2.69 6-6s-2.69-6-6-6zm.2 8H10V7h3.2c1.1 0 2 .9 2 2s-.9 2-2 2z"/>\n </svg>\n </button>\n <button class="control-btn" id="transferBtn" ${i?"":"disabled"} title="Transfer">\n <svg width="24" height="24" viewBox="0 0 24 24" fill="currentColor">\n <path d="M6.62 10.79c1.44 2.83 3.76 5.14 6.59 6.59l2.2-2.2c.27-.27.67-.36 1.02-.24 1.12.37 2.33.57 3.57.57.55 0 1 .45 1 1V20c0 .55-.45 1-1 1-9.39 0-17-7.61-17-17 0-.55.45-1 1-1h3.5c.55 0 1 .45 1 1 0 1.25.2 2.45.57 3.57.11.35.03.74-.25 1.02l-2.2 2.2z M17 8l4 4-4 4V9h-3V7h3V8z"/>\n </svg>\n </button>\n </div>\n `}\n </div>\n </div>\n `}renderHistory(){const e=this.getFilteredHistory();return`\n <div class="history-view">\n <div class="tabs-nav">\n <button class="tab-btn ${"all"===this.currentHistoryTab?"active":""}" data-tab="all">\n <svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor">\n <path d="M3 13h2v-2H3v2zm0 4h2v-2H3v2zm0-8h2V7H3v2zm4 4h14v-2H7v2zm0 4h14v-2H7v2zM7 7v2h14V7H7z"/>\n </svg>\n All\n </button>\n <button class="tab-btn ${"missed"===this.currentHistoryTab?"active":""}" data-tab="missed">\n <svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor">\n <path d="M19.23 15.26l-2.54-.29c-.61-.07-1.21.14-1.64.57l-1.84 1.84c-2.83-1.44-5.15-3.75-6.59-6.59l1.85-1.85c.43-.43.64-1.03.57-1.64l-.29-2.52c-.12-1.01-.97-1.77-1.99-1.77H5.03c-1.13 0-2.07.94-2 2.07.53 8.54 7.36 15.36 15.89 15.89 1.13.07 2.07-.87 2.07-2v-1.73c.01-1.01-.75-1.86-1.76-1.98z"/>\n </svg>\n Missed\n </button>\n <button class="tab-btn ${"dialed"===this.currentHistoryTab?"active":""}" data-tab="dialed">\n <svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor">\n <path d="M20 15.5c-1.25 0-2.45-.2-3.57-.57-.35-.11-.74-.03-1.02.24l-2.2 2.2c-2.83-1.44-5.15-3.75-6.59-6.59l2.2-2.21c.28-.26.36-.65.25-1C8.7 6.45 8.5 5.25 8.5 4c0-.55-.45-1-1-1H4c-.55 0-1 .45-1 1 0 9.39 7.61 17 17 17 .55 0 1-.45 1-1v-3.5c0-.55-.45-1-1-1z"/>\n </svg>\n Dialed\n </button>\n </div>\n <div class="history-list">\n ${0===e.length?this.renderEmptyHistory():e.map(e=>this.renderHistoryItem(e)).join("")}\n </div>\n <div class="callback-button-container">\n ${this.selectedHistoryItem?this.renderCallBackButton():""}\n </div>\n </div>\n `}renderDialerDisabled(){return'\n <div class="empty-state">\n <svg viewBox="0 0 24 24" fill="currentColor" opacity="0.5">\n <path d="M20 15.5c-1.25 0-2.45-.2-3.57-.57-.35-.11-.74-.03-1.02.24l-2.2 2.2c-2.83-1.44-5.15-3.75-6.59-6.59l2.2-2.21c.28-.26.36-.65.25-1C8.7 6.45 8.5 5.25 8.5 4c0-.55-.45-1-1-1H4c-.55 0-1 .45-1 1 0 9.39 7.61 17 17 17 .55 0 1-.45 1-1v-3.5c0-.55-.45-1-1-1z"/>\n </svg>\n <div class="empty-state-text">Dialer not enabled for this user</div>\n <div class="empty-state-subtext" style="margin-top: 8px; font-size: 12px; opacity: 0.7;">Contact your administrator to enable dialer access</div>\n </div>\n '}renderEmptyHistory(){return`\n <div class="empty-state">\n <svg viewBox="0 0 24 24" fill="currentColor">\n <path d="M20 15.5c-1.25 0-2.45-.2-3.57-.57-.35-.11-.74-.03-1.02.24l-2.2 2.2c-2.83-1.44-5.15-3.75-6.59-6.59l2.2-2.21c.28-.26.36-.65.25-1C8.7 6.45 8.5 5.25 8.5 4c0-.55-.45-1-1-1H4c-.55 0-1 .45-1 1 0 9.39 7.61 17 17 17 .55 0 1-.45 1-1v-3.5c0-.55-.45-1-1-1z"/>\n </svg>\n <div class="empty-state-text">${{all:"No call history",missed:"No missed calls",dialed:"No dialed calls"}[this.currentHistoryTab]}</div>\n </div>\n `}renderHistoryItem(e){const t=new Date(e.timestamp),n=isNaN(t.getTime())?"Invalid Date":this.formatCallTime(t),i=e.duration?this.formatDuration(1e3*e.duration):"",r=this.selectedHistoryItem?.id===e.id,o=this.formatPhoneNumberDisplay(e.phoneNumber);return`\n <div class="history-item ${r?"selected":""}" data-call-id="${e.id}">\n <div class="history-icon ${e.type}">\n <svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor">\n <path d="M20 15.5c-1.25 0-2.45-.2-3.57-.57-.35-.11-.74-.03-1.02.24l-2.2 2.2c-2.83-1.44-5.15-3.75-6.59-6.59l2.2-2.21c.28-.26.36-.65.25-1C8.7 6.45 8.5 5.25 8.5 4c0-.55-.45-1-1-1H4c-.55 0-1 .45-1 1 0 9.39 7.61 17 17 17 .55 0 1-.45 1-1v-3.5c0-.55-.45-1-1-1z"/>\n </svg>\n </div>\n <div class="history-info">\n <div class="history-number">${o}</div>\n <div class="history-status ${e.type}">${e.status}</div>\n </div>\n <div class="history-time">\n ${n}\n ${i?`<span class="history-duration">${i}</span>`:""}\n </div>\n </div>\n `}renderCallBackButton(){if(!this.selectedHistoryItem)return"";return`\n <div class="call-back-container">\n <button id="callBackBtn" class="call-back-btn">\n <svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor">\n <path d="M20 15.5c-1.25 0-2.45-.2-3.57-.57-.35-.11-.74-.03-1.02.24l-2.2 2.2c-2.83-1.44-5.15-3.75-6.59-6.59l2.2-2.21c.28-.26.36-.65.25-1C8.7 6.45 8.5 5.25 8.5 4c0-.55-.45-1-1-1H4c-.55 0-1 .45-1 1 0 9.39 7.61 17 17 17 .55 0 1-.45 1-1v-3.5c0-.55-.45-1-1-1z"/>\n </svg>\n Call Back ${this.formatPhoneNumberDisplay(this.selectedHistoryItem.phoneNumber)}\n </button>\n </div>\n `}renderBottomNav(){return`\n <div class="bottom-nav">\n <button class="nav-btn ${"dial"===this.currentView?"active":""}" data-view="dial">\n <svg viewBox="0 0 24 24" fill="currentColor">\n <path d="M20 15.5c-1.25 0-2.45-.2-3.57-.57-.35-.11-.74-.03-1.02.24l-2.2 2.2c-2.83-1.44-5.15-3.75-6.59-6.59l2.2-2.21c.28-.26.36-.65.25-1C8.7 6.45 8.5 5.25 8.5 4c0-.55-.45-1-1-1H4c-.55 0-1 .45-1 1 0 9.39 7.61 17 17 17 .55 0 1-.45 1-1v-3.5c0-.55-.45-1-1-1z"/>\n </svg>\n Dial\n </button>\n <button class="nav-btn ${"history"===this.currentView?"active":""}" data-view="history">\n <svg viewBox="0 0 24 24" fill="currentColor">\n <path d="M13 3c-4.97 0-9 4.03-9 9H1l3.89 3.89.07.14L9 12H6c0-3.87 3.13-7 7-7s7 3.13 7 7-3.13 7-7 7c-1.93 0-3.68-.79-4.94-2.06l-1.42 1.42C8.27 19.99 10.51 21 13 21c4.97 0 9-4.03 9-9s-4.03-9-9-9zm-1 5v5l4.28 2.54.72-1.21-3.5-2.08V8H12z"/>\n </svg>\n History\n </button>\n <button class="nav-btn ${"park"===this.currentView?"active":""}" data-view="park">\n <svg viewBox="0 0 24 24" fill="currentColor">\n <path d="M13 3H6v18h4v-6h3c3.31 0 6-2.69 6-6s-2.69-6-6-6zm.2 8H10V7h3.2c1.1 0 2 .9 2 2s-.9 2-2 2z"/>\n </svg>\n Park\n </button>\n <button class="nav-btn ${"account"===this.currentView?"active":""}" data-view="account">\n <svg viewBox="0 0 24 24" fill="currentColor">\n <path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 3c1.66 0 3 1.34 3 3s-1.34 3-3 3-3-1.34-3-3 1.34-3 3-3zm0 14.2c-2.5 0-4.71-1.28-6-3.22.03-1.99 4-3.08 6-3.08 1.99 0 5.97 1.09 6 3.08-1.29 1.94-3.5 3.22-6 3.22z"/>\n </svg>\n Account\n </button>\n </div>\n `}renderFooter(){return'\n <div class="dialer-footer">\n <a href="https://convirza.com" target="_blank" class="footer-link">\n Powered by Convirza\n </a>\n </div>\n '}renderIncomingCallModal(){return`\n <div class="incoming-call-overlay">\n <div class="incoming-call-modal">\n <div class="incoming-call-info">\n <div class="incoming-call-label">Incoming Call</div>\n ${this.incomingCallName?`<div class="incoming-call-name">${this.incomingCallName}</div>`:""}\n <div class="incoming-call-number">${this.incomingCallNumber}</div>\n </div>\n <div class="incoming-call-actions">\n <button class="incoming-call-btn reject-btn" id="rejectCallBtn">\n <svg viewBox="0 0 24 24" fill="currentColor">\n <path d="M12 9c-1.6 0-3.15.25-4.6.72v3.1c0 .39-.23.74-.56.9-.98.49-1.87 1.12-2.66 1.85-.18.18-.43.28-.7.28-.28 0-.53-.11-.71-.29L.29 13.08c-.18-.17-.29-.42-.29-.7 0-.28.11-.53.29-.71C3.34 8.78 7.46 7 12 7s8.66 1.78 11.71 4.67c.18.18.29.43.29.71 0 .28-.11.53-.29.71l-2.48 2.48c-.18.18-.43.29-.71.29-.27 0-.52-.11-.7-.28-.79-.74-1.68-1.36-2.66-1.85-.33-.16-.56-.5-.56-.9v-3.1C15.15 9.25 13.6 9 12 9z"/>\n </svg>\n <span>Decline</span>\n </button>\n <button class="incoming-call-btn answer-btn" id="answerCallBtn">\n <svg viewBox="0 0 24 24" fill="currentColor">\n <path d="M20 15.5c-1.25 0-2.45-.2-3.57-.57-.35-.11-.74-.03-1.02.24l-2.2 2.2c-2.83-1.44-5.15-3.75-6.59-6.59l2.2-2.21c.28-.26.36-.65.25-1C8.7 6.45 8.5 5.25 8.5 4c0-.55-.45-1-1-1H4c-.55 0-1 .45-1 1 0 9.39 7.61 17 17 17 .55 0 1-.45 1-1v-3.5c0-.55-.45-1-1-1z"/>\n </svg>\n <span>Answer</span>\n </button>\n </div>\n </div>\n </div>\n `}renderRetrieveModal(){const e=this.retrieveModalData;return e?`\n <div class="incoming-call-overlay">\n <div class="incoming-call-modal">\n <div class="incoming-call-icon">\n <svg width="64" height="64" viewBox="0 0 24 24" fill="currentColor">\n <path d="M13 3H6v18h4v-6h3c3.31 0 6-2.69 6-6s-2.69-6-6-6zm.2 8H10V7h3.2c1.1 0 2 .9 2 2s-.9 2-2 2z"/>\n </svg>\n </div>\n <div class="incoming-call-info">\n <div class="incoming-call-label">Retrieve Parked Call</div>\n <div class="incoming-call-number">${this.formatPhoneNumberDisplay(e.phoneNumber)}</div>\n <div class="incoming-call-status" style="font-size: 12px; color: var(--text-secondary); margin-top: 4px;">Extension ${e.extension}</div>\n </div>\n <div class="incoming-call-actions">\n <button class="incoming-call-btn reject-btn" id="cancelRetrieveBtn">\n <span>Cancel</span>\n </button>\n <button class="incoming-call-btn answer-btn" id="confirmRetrieveBtn">\n <span>Retrieve</span>\n </button>\n </div>\n </div>\n </div>\n `:""}renderAccount(){const e=this.sipAdapter?.getCurrentDevices()||{microphoneId:null,speakerId:null};return`\n <div class="account-view">\n <div class="account-section">\n <h3 class="account-section-title">Audio Devices</h3>\n <p class="account-section-subtitle">Select microphone, speaker </p>\n\n <div class="device-row">\n <label class="device-row-label">Microphone</label>\n <select class="device-row-select" id="microphoneSelect">\n <option value="">System Default</option>\n ${this.audioDevices.microphones.map(t=>`\n <option value="${t.deviceId}" ${t.deviceId===e.microphoneId?"selected":""}>\n ${t.label}\n </option>\n `).join("")}\n </select>\n </div>\n\n <div class="device-row">\n <label class="device-row-label">Speaker</label>\n <select class="device-row-select" id="speakerSelect">\n <option value="">System Default</option>\n ${this.audioDevices.speakers.map(t=>`\n <option value="${t.deviceId}" ${t.deviceId===e.speakerId?"selected":""}>\n ${t.label}\n </option>\n `).join("")}\n </select>\n </div>\n </div>\n\n <div class="account-section">\n <h3 class="account-section-title">Account Information</h3>\n <div class="account-info">\n <div class="account-info-row">\n <span class="account-info-label">First Name</span>\n <span class="account-info-value">${this.config.firstName||"—"}</span>\n </div>\n <div class="account-info-row">\n <span class="account-info-label">Last Name</span>\n <span class="account-info-value">${this.config.lastName||"—"}</span>\n </div>\n <div class="account-info-row">\n <span class="account-info-label">Email</span>\n <span class="account-info-value">${this.config.email||"—"}</span>\n </div>\n <div class="account-info-row">\n <span class="account-info-label">Connection</span>\n <span class="account-info-value ${this.sipAdapter?.isConnected?"status-connected":"status-disconnected"}">\n ${this.sipAdapter?.isConnected?"● Connected":"○ Disconnected"}\n </span>\n </div>\n </div>\n </div>\n\n ${this.renderFooter()}\n </div>\n `}renderPark(){const e="connected"===this.callStatus,t=this.parkAccounts.filter(e=>e.occupied&&e.parkedCall);return e?`\n <div class="park-view">\n <div class="park-header">\n <h3 class="park-title">Park Call</h3>\n <p class="park-subtitle">Select a parking slot</p>\n </div>\n <div class="park-slots">\n ${0===this.parkAccounts.length?'<div class="empty-state">Loading park slots...</div>':this.parkAccounts.map(e=>this.renderParkItem(e)).join("")}\n </div>\n </div>\n `:`\n <div class="park-view">\n <div class="park-header">\n <h3 class="park-title">Parked Calls</h3>\n <p class="park-subtitle">Calls waiting to be retrieved</p>\n </div>\n <div class="park-list">\n ${0===t.length?this.renderEmptyPark():t.map(e=>this.renderParkedCall(e)).join("")}\n </div>\n </div>\n `}renderEmptyPark(){return'\n <div class="empty-state">\n <svg viewBox="0 0 24 24" fill="currentColor">\n <path d="M13 3H6v18h4v-6h3c3.31 0 6-2.69 6-6s-2.69-6-6-6zm.2 8H10V7h3.2c1.1 0 2 .9 2 2s-.9 2-2 2z"/>\n </svg>\n <div class="empty-state-text">No parked calls</div>\n </div>\n '}renderParkedCall(e){if(!e.parkedCall)return"";const t=this.formatParkedDuration(e.parkedCall.parkedAt);return`\n <div class="parked-call-item" data-park-extension="${e.extension}">\n <div class="parked-call-icon">\n <svg width="24" height="24" viewBox="0 0 24 24" fill="currentColor">\n <path d="M6.62 10.79c1.44 2.83 3.76 5.14 6.59 6.59l2.2-2.2c.27-.27.67-.36 1.02-.24 1.12.37 2.33.57 3.57.57.55 0 1 .45 1 1V20c0 .55-.45 1-1 1-9.39 0-17-7.61-17-17 0-.55.45-1 1-1h3.5c.55 0 1 .45 1 1 0 1.25.2 2.45.57 3.57.11.35.03.74-.25 1.02l-2.2 2.2z"/>\n </svg>\n </div>\n <div class="parked-call-info">\n <div class="parked-call-number">${this.formatPhoneNumberDisplay(e.parkedCall.phoneNumber)}</div>\n <div class="parked-call-meta">Parked at ${t}</div>\n </div>\n <button class="retrieve-btn" data-park-extension="${e.extension}">\n Retrieve\n </button>\n </div>\n `}renderParkItem(e){const t=e.parkedCall?`\n <div class="park-item-details">\n <div class="parked-caller">${this.formatPhoneNumberDisplay(e.parkedCall.phoneNumber)}</div>\n <div class="parked-meta">Parked by ${e.parkedCall.parkedBy} • ${this.formatParkedDuration(e.parkedCall.parkedAt)}</div>\n </div>\n `:"";return`\n <div class="park-item ${e.occupied?"occupied":""}" data-park-id="${e.id}" data-park-extension="${e.extension}">\n <div class="park-item-icon">\n <svg width="24" height="24" viewBox="0 0 24 24" fill="currentColor">\n <path d="M13 3H6v18h4v-6h3c3.31 0 6-2.69 6-6s-2.69-6-6-6zm.2 8H10V7h3.2c1.1 0 2 .9 2 2s-.9 2-2 2z"/>\n </svg>\n </div>\n <div class="park-item-info">\n <div class="park-item-label">${e.label}</div>\n <div class="park-item-extension">Extension ${e.extension}</div>\n ${t}\n </div>\n <div class="park-item-status">\n ${e.occupied?'<span class="status-badge occupied">Occupied</span>':'<span class="status-badge available">Available</span>'}\n </div>\n </div>\n `}formatParkedDuration(e){const t=Math.floor((Date.now()-e)/1e3);if(t<60)return`${t}s ago`;const n=Math.floor(t/60);if(n<60)return`${n}m ago`;return`${Math.floor(n/60)}h ago`}setupEventListeners(){const e=e=>{const t=e.target,n=t.closest("button"),i=t.closest(".history-item");if("countryDropdownBackdrop"===t.id||t.classList.contains("country-dropdown-backdrop")){this.showCountryDropdown=!1;const e=this.shadow.querySelector(".country-dropdown-backdrop"),t=this.shadow.querySelector(".country-dropdown");return e&&e.remove(),void(t&&t.remove())}const r=t.closest(".phone-number-item");if(r){console.log("[Dialer] Phone number item clicked");const e=r.getAttribute("data-number-id");if(console.log("[Dialer] Looking for number_id:",e),!e)return void console.error("[Dialer] ❌ No data-number-id attribute found");const t=this.orderedPhoneNumbers.find(t=>String(t.number_id)===e);return void(t?(console.log("[Dialer] ✅ Found and selecting:",t.number_str),this.selectPhoneNumber(t)):(console.error("[Dialer] ❌ Could not find phone number with ID:",e),console.error("[Dialer] Available IDs:",this.orderedPhoneNumbers.map(e=>String(e.number_id)))))}if(this.showPhoneNumberDropdown&&!t.closest(".phone-number-selector"))return console.log("[Dialer] Closing dropdown - clicked outside"),this.showPhoneNumberDropdown=!1,void this.updatePhoneNumberDropdownDOM();if(n&&n.classList.contains("retrieve-btn")){const e=n.getAttribute("data-park-extension");if(e){const t=this.parkAccounts.find(t=>t.extension===e);t?.parkedCall&&this.confirmRetrieveParkedCall(e,t.parkedCall.phoneNumber)}return}const o=t.closest(".park-item");if(o){const e=o.getAttribute("data-park-extension"),t=o.classList.contains("occupied");if(e)if(t){const t=this.parkAccounts.find(t=>t.extension===e);t?.parkedCall&&this.confirmRetrieveParkedCall(e,t.parkedCall.phoneNumber)}else"connected"===this.callStatus&&this.parkCall(e);return}const a=t.closest("[data-transfer-ext]");if(a){const e=a.getAttribute("data-transfer-ext");return void(e&&(this.transferTarget=e,this.executeTransfer()))}if(i&&!n){const e=i.getAttribute("data-call-id");if(e){const t=this.callHistory.find(t=>t.id===e);if(t){this.selectedHistoryItem=t;const e=this.shadow.querySelector(".dialer-body");e&&(e.innerHTML=this.renderHistory())}}return}if(!n)return;const d=n.id,s=n.getAttribute("data-digit"),l=n.getAttribute("data-dtmf"),c=n.getAttribute("data-tab"),h=n.getAttribute("data-view"),u=n.getAttribute("data-country");if(u)this.selectCountry(u);else if(c)this.switchHistoryTab(c);else if(h)this.switchView(h);else if("fab"===d)this.hasMoved||this.open(),this.hasMoved=!1;else if("closeBtn"===d||"minimizeBtn"===d)this.close();else if(s){if(this.longPressTriggered)return void(this.longPressTriggered=!1);const e=this.shadow.getElementById("phoneInput");e&&(e.value+=s,this.phoneInputValue=e.value,this.updateButtonStates(),this.playDTMFTone(s))}else if("countryBtn"===d)this.toggleCountryDropdown();else if("backspaceBtn"===d){const e=this.shadow.getElementById("phoneInput");e&&e.value&&(e.value=e.value.slice(0,-1),this.phoneInputValue=e.value,this.updateButtonStates())}else if("callBtn"===d){const e=this.shadow.getElementById("phoneInput");e?.value&&this.placeCall(e.value)}else if("endBtn"===d)this.endCall();else if("muteBtn"===d)this.mute();else if("holdBtn"===d)this.hold();else if("recordBtn"===d)this.toggleRecording();else if("parkBtn"===d)this.showInCallKeypad=!1,this.switchView("park");else if("transferBtn"===d)this.showTransferView=!0,this.showInCallKeypad=!1,this.render();else if("cancelTransferBtn"===d)this.showTransferView=!1,this.transferTarget="",this.render();else if("confirmTransferBtn"===d)this.executeTransfer();else if("enableNotificationsBtn"===d)this.requestNotificationPermission();else if("keypadBtn"===d)this.toggleInCallKeypad();else if("answerCallBtn"===d)this.answerIncomingCall();else if("rejectCallBtn"===d)this.rejectIncomingCall();else if("confirmRetrieveBtn"===d)this.confirmRetrieve();else if("cancelRetrieveBtn"===d)this.cancelRetrieve();else if("callBackBtn"===d){if(this.selectedHistoryItem){const e=this.selectedHistoryItem.phoneNumber;this.selectedHistoryItem=null,this.placeCall(e)}}else l?(this.sendDTMF(l),this.playDTMFTone(l),this.dialedDigits+=l,this.updateDialedDigitsDisplay()):"refreshDevicesBtn"===d?this.refreshAudioDevices():"phoneNumberDropdownBtn"===d?this.togglePhoneNumberDropdown(e):"retryPhoneNumbersBtn"===d&&this.fetchOrderedPhoneNumbers()};this.shadow.addEventListener("click",e,!0),this.boundHandlers.set("root-click",e);const t=e=>{const t=e.target.closest("button");if(!t)return;"0"===t.getAttribute("data-digit")&&(this.longPressTimer=window.setTimeout(()=>{const e=this.shadow.getElementById("phoneInput");e&&(e.value+="+",this.phoneInputValue=e.value,this.updateButtonStates(),this.longPressTriggered=!0)},500))},n=()=>{this.longPressTimer&&(clearTimeout(this.longPressTimer),this.longPressTimer=null)};this.shadow.addEventListener("mousedown",t),this.shadow.addEventListener("mouseup",n),this.shadow.addEventListener("mouseleave",n),this.shadow.addEventListener("touchstart",t),this.shadow.addEventListener("touchend",n),this.boundHandlers.set("mousedown",t),this.boundHandlers.set("mouseup",n);const i=e=>{const t=e.target;if("phoneInput"===t.id){const e=t.selectionStart||0,n=t.value,i=this.formatPhoneInputDisplay(n),r=e+(i.length-n.length);t.value=i,this.phoneInputValue=i,t.setSelectionRange(r,r),this.updateButtonStates()}else if("transferTargetInput"===t.id){this.transferTarget=t.value;const e=this.shadow.getElementById("confirmTransferBtn");e&&(e.disabled=!this.transferTarget.trim()||this.isTransferring)}};this.shadow.addEventListener("input",i),this.boundHandlers.set("root-input",i);const r=e=>{const t=e,n=e.target;if("phoneInput"===n.id){e.preventDefault();const i=t.clipboardData?.getData("text")||"";console.log("[Dialer] Pasted text:",i);const r=i.replace(/\D/g,"");console.log("[Dialer] Extracted digits:",r);let o=r;11===r.length&&r.startsWith("1")?(o=r.slice(1),console.log("[Dialer] Stripped country code, result:",o)):10===r.length?o=r:r.length>11&&(o=r.slice(-10),console.log("[Dialer] International number, using last 10 digits:",o));const a=this.formatPhoneInputDisplay(o);console.log("[Dialer] Formatted result:",a),n.value=a,this.phoneInputValue=a;const d=a.length;n.setSelectionRange(d,d),this.updateButtonStates()}};this.shadow.addEventListener("paste",r),this.boundHandlers.set("root-paste",r);const o=e=>{const t=e.target;"microphoneSelect"===t.id?this.setMicrophone(t.value):"speakerSelect"===t.id&&this.setSpeaker(t.value)};this.shadow.addEventListener("change",o),this.boundHandlers.set("root-change",o),this.setupDragHandlers()}setupDragHandlers(){const e=e=>{if(!this.isDragging)return;this.hasMoved=!0,e.preventDefault();const t=e.clientX-this.dragOffset.x,n=e.clientY-this.dragOffset.y,i=this.getAttribute("state"),r="expanded"===i?380:56,o="expanded"===i?750:56,a=window.innerWidth-r,d=window.innerHeight-o,s=Math.max(0,Math.min(t,a)),l=Math.max(0,Math.min(n,d));this.fabPosition={x:s,y:l},this.style.left=`${s}px`,this.style.top=`${l}px`,this.style.right="auto",this.style.bottom="auto",this.removeAttribute("position")},t=()=>{this.isDragging=!1},n=e=>{if(!this.isDragging)return;this.hasMoved=!0,e.preventDefault();const t=e.touches[0],n=t.clientX-this.dragOffset.x,i=t.clientY-this.dragOffset.y,r=this.getAttribute("state"),o="expanded"===r?380:56,a="expanded"===r?750:56,d=window.innerWidth-o,s=window.innerHeight-a,l=Math.max(0,Math.min(n,d)),c=Math.max(0,Math.min(i,s));this.fabPosition={x:l,y:c},this.style.left=`${l}px`,this.style.top=`${c}px`,this.style.right="auto",this.style.bottom="auto",this.removeAttribute("position")},i=()=>{this.isDragging=!1};this.boundHandlers.set("drag-mousedown",e=>{const t=e.target;if("expanded"===this.getAttribute("state")){const e=this.shadow.querySelector(".dialer-header");if(!e?.contains(t))return;if(t.closest("button"))return}this.isDragging=!0,this.hasMoved=!1,this.dragStartTime=Date.now();const n=this.getBoundingClientRect();this.dragOffset={x:e.clientX-n.left,y:e.clientY-n.top},e.preventDefault()}),this.boundHandlers.set("drag-mousemove",e),this.boundHandlers.set("drag-mouseup",t),this.boundHandlers.set("drag-touchstart",e=>{const t=e.target;if("expanded"===this.getAttribute("state")){const e=this.shadow.querySelector(".dialer-header");if(!e?.contains(t))return;if(t.closest("button"))return}this.isDragging=!0,this.hasMoved=!1,this.dragStartTime=Date.now();const n=e.touches[0],i=this.getBoundingClientRect();this.dragOffset={x:n.clientX-i.left,y:n.clientY-i.top},e.preventDefault()}),this.boundHandlers.set("drag-touchmove",n),this.boundHandlers.set("drag-touchend",i),document.addEventListener("mousemove",e),document.addEventListener("mouseup",t),document.addEventListener("touchmove",n,{passive:!1}),document.addEventListener("touchend",i)}attachDragHandlers(){requestAnimationFrame(()=>{const e=this.getAttribute("state"),t=this.boundHandlers.get("drag-mousedown"),n=this.boundHandlers.get("drag-touchstart");if("collapsed"===e){const e=this.shadow.getElementById("fab");if(!e)return;t&&e.addEventListener("mousedown",t),n&&e.addEventListener("touchstart",n,{passive:!1})}else{const e=this.shadow.querySelector(".dialer-header");if(!e)return;t&&e.addEventListener("mousedown",t),n&&e.addEventListener("touchstart",n,{passive:!1})}})}adjustPositionForPanel(){const e=window.innerWidth,t=window.innerHeight;let n=0,i=0;if(this.style.left&&this.style.top)n=parseInt(this.style.left,10),i=parseInt(this.style.top,10);else if(this.fabPosition)n=this.fabPosition.x,i=this.fabPosition.y;else{const r=this.getAttribute("position")||"bottom-right";n=r.includes("right")?e-56-24:24,i=r.includes("bottom")?t-56-24:24}const r=e-380-10,o=t-750-10;let a=Math.min(n,r),d=Math.min(i,o);a=Math.max(10,a),d=Math.max(10,d),this.style.left=`${a}px`,this.style.top=`${d}px`,this.style.right="auto",this.style.bottom="auto",this.removeAttribute("position"),this.fabPosition={x:a,y:d}}async refreshAudioDevicesQuietly(){if(this.sipAdapter)try{this.audioDevices=await this.sipAdapter.getAudioDevices()}catch(e){console.error("[Dialer] Failed to refresh audio devices:",e)}}async refreshAudioDevices(){if(this.sipAdapter)try{this.audioDevices=await this.sipAdapter.getAudioDevices(),this.updateAccountDeviceSelectors()}catch(e){console.error("[Dialer] Failed to refresh audio devices:",e)}}updateAccountDeviceSelectors(){if("account"!==this.currentView)return;const e=this.shadow.getElementById("microphoneSelect"),t=this.shadow.getElementById("speakerSelect"),n=this.sipAdapter?.getCurrentDevices()||{microphoneId:null,speakerId:null};e&&(e.innerHTML=`\n\t\t\t\t<option value="">System Default</option>\n\t\t\t\t${this.audioDevices.microphones.map(e=>`\n\t\t\t\t\t<option value="${e.deviceId}" ${e.deviceId===n.microphoneId?"selected":""}>\n\t\t\t\t\t\t${e.label}\n\t\t\t\t\t</option>\n\t\t\t\t`).join("")}\n\t\t\t`),t&&(t.innerHTML=`\n\t\t\t\t<option value="">System Default</option>\n\t\t\t\t${this.audioDevices.speakers.map(e=>`\n\t\t\t\t\t<option value="${e.deviceId}" ${e.deviceId===n.speakerId?"selected":""}>\n\t\t\t\t\t\t${e.label}\n\t\t\t\t\t</option>\n\t\t\t\t`).join("")}\n\t\t\t`)}async setMicrophone(e){if(this.sipAdapter)try{await this.sipAdapter.setMicrophone(e||""),this.dispatchEvent(new CustomEvent("microphone-changed",{detail:{deviceId:e},bubbles:!0}))}catch(e){console.error("[Dialer] Failed to set microphone:",e)}}async setSpeaker(e){if(this.sipAdapter)try{await this.sipAdapter.setSpeaker(e||""),this.dispatchEvent(new CustomEvent("speaker-changed",{detail:{deviceId:e},bubbles:!0}))}catch(e){console.error("[Dialer] Failed to set speaker:",e)}}startParkSlotPolling(){this.parkApiUrl&&this.config.sipDomain&&(this.fetchParkSlots(),this.stopParkSlotPolling(),this.parkPollTimer=window.setInterval(()=>{this.fetchParkSlots()},this.parkPollInterval))}stopParkSlotPolling(){null!==this.parkPollTimer&&(clearInterval(this.parkPollTimer),this.parkPollTimer=null)}updateHistorySelection(e){this.shadow.querySelectorAll(".history-item").forEach(e=>e.classList.remove("selected"));const t=this.shadow.querySelector(`.history-item[data-call-id="${e}"]`);t&&t.classList.add("selected");const n=this.shadow.querySelector(".callback-button-container");n&&(n.innerHTML=this.renderCallBackButton())}async fetchParkSlots(){if(this.parkApiUrl&&this.config.sipDomain)try{const e=`${this.parkApiUrl}?domain=${encodeURIComponent(this.config.sipDomain)}`,t={};this.authToken&&(t.Authorization=`Bearer ${this.authToken}`);const n=new AbortController,i=setTimeout(()=>n.abort(),1e4);let r;try{r=await fetch(e,{headers:t,signal:n.signal})}finally{clearTimeout(i)}if(!r.ok)return void(404===r.status&&(console.warn("[Dialer] Park slots API not available (404), disabling poll"),this.stopParkSlotPolling()));const o=await r.json(),a=o.data?.slots||o.slots||[];if(Array.isArray(a)){if(this.isParking&&this.parkingSlot){const e=this.parkAccounts.find(e=>e.extension===this.parkingSlot),t=a.find(e=>e.extension===this.parkingSlot);e?.occupied&&t&&!t.occupied&&(t.occupied=e.occupied,t.parkedCall=e.parkedCall)}this.parkAccounts=a,this.render(),this.dispatchEvent(new CustomEvent("park-slots-updated",{detail:{slots:a},bubbles:!0}))}}catch(e){"AbortError"===e.name?console.warn("[Dialer] Park slots fetch timed out"):console.error("[Dialer] Failed to fetch park slots:",e)}}async fetchDomainExtensions(){if(this.config.apiUrl&&this.authToken&&this.config.sipDomain)try{const e=await fetch(`${this.config.apiUrl.replace(/\/$/,"")}/v3/extensions?sip_domain=${encodeURIComponent(this.config.sipDomain)}`,{headers:{Authorization:`Bearer ${this.authToken}`}});if(!e.ok)return;const t=await e.json();this.domainExtensions=(t?.data?.items??[]).filter(e=>e.extension!==this.config.sipUsername).map(e=>({extension:String(e.extension),user_name:e.user_name??e.name??""}))}catch{}}async fetchOrderedPhoneNumbers(){if(console.log("[Dialer] fetchOrderedPhoneNumbers called",{hasAPI:!!this.phoneNumbersAPI,domainId:this.config.domainId,apiBaseUrl:this.config.apiBaseUrl,hasAuthToken:!!this.authToken,alreadyLoading:this.loadingPhoneNumbers}),this.phoneNumbersAPI&&this.config.domainId)if(this.loadingPhoneNumbers)console.log("[Dialer] Already loading phone numbers, skipping duplicate fetch");else{this.startPhoneNumbersLoading();try{console.log("[Dialer] Fetching phone numbers from API...");const e=await this.phoneNumbersAPI.fetchOrderedNumbers({domainId:this.config.domainId,status:"provisioned",limit:100});if(console.log("[Dialer] Phone numbers received:",e),this.orderedPhoneNumbers=e.items||[],console.log("[Dialer] Set orderedPhoneNumbers, count:",this.orderedPhoneNumbers.length),this.config.domainId){const e=localStorage.getItem(`convirza_selected_caller_id_${this.config.domainId}`);if(e)try{const t=JSON.parse(e),n=this.orderedPhoneNumbers.find(e=>e.number_id===t.number_id);n&&(this.selectedPhoneNumber=n,console.log("[Dialer] Restored saved selection:",n.number_str))}catch(e){console.warn("[Dialer] Failed to restore saved caller ID selection")}}this.orderedPhoneNumbers.length>0&&!this.selectedPhoneNumber&&(this.selectedPhoneNumber=this.orderedPhoneNumbers[0],console.log("[Dialer] Auto-selected first number:",this.selectedPhoneNumber.number_str)),this.stopPhoneNumbersLoading()}catch(e){console.error("[Dialer] Failed to fetch phone numbers:",e),this.phoneNumbersError="Failed to load phone numbers",this.stopPhoneNumbersLoading()}}else console.warn("[Dialer] Cannot fetch phone numbers - missing API or domainId")}renderPhoneNumberDropdownItems(){return 0===this.orderedPhoneNumbers.length?`\n\t\t\t\t<div class="phone-number-empty">\n\t\t\t\t\t${this.phoneNumbersError?`\n\t\t\t\t\t\t<span class="error-text">${this.phoneNumbersError}</span>\n\t\t\t\t\t\t<button class="retry-button" id="retryPhoneNumbersBtn">Retry</button>\n\t\t\t\t\t`:"<span>No phone numbers available</span>"}\n\t\t\t\t</div>\n\t\t\t`:this.orderedPhoneNumbers.map(e=>`\n\t\t\t\t<button\n\t\t\t\t\tclass="phone-number-item ${e.number_id===this.selectedPhoneNumber?.number_id?"selected":""}"\n\t\t\t\t\tdata-number-id="${e.number_id}"\n\t\t\t\t>\n\t\t\t\t\t<svg class="phone-icon" viewBox="0 0 24 24" fill="currentColor">\n\t\t\t\t\t\t<path d="M20 15.5c-1.25 0-2.45-.2-3.57-.57-.35-.11-.74-.03-1.02.24l-2.2 2.2c-2.83-1.44-5.15-3.75-6.59-6.59l2.2-2.21c.28-.26.36-.65.25-1C8.7 6.45 8.5 5.25 8.5 4c0-.55-.45-1-1-1H4c-.55 0-1 .45-1 1 0 9.39 7.61 17 17 17 .55 0 1-.45 1-1v-3.5c0-.55-.45-1-1-1z"/>\n\t\t\t\t\t</svg>\n\t\t\t\t\t<div class="phone-number-info">\n\t\t\t\t\t\t<span class="number-text">${this.formatPhoneNumberDisplay(e.number||e.number_str)}</span>\n\t\t\t\t\t\t<span class="number-label">${e.assigned_user_name||(e.city||e.state?`${e.city||""}${e.city&&e.state?", ":""}${e.state||""}`:"")}</span>\n\t\t\t\t\t</div>\n\t\t\t\t</button>\n\t\t\t`).join("")}updatePhoneNumberDropdownDOM(){const e=this.shadow.querySelector(".phone-number-dropdown-container");if(e)if(this.showPhoneNumberDropdown){const t=`\n\t\t\t\t<div class="phone-number-dropdown">\n\t\t\t\t\t${this.renderPhoneNumberDropdownItems()}\n\t\t\t\t</div>\n\t\t\t`;e.innerHTML=t,console.log("[Dialer] Dropdown rendered with",this.orderedPhoneNumbers.length,"items")}else e.innerHTML="",console.log("[Dialer] Dropdown hidden");else console.warn("[Dialer] Dropdown container not found")}openPhoneNumberDropdown(){console.log("[Dialer] Opening phone number dropdown"),this.showPhoneNumberDropdown=!0,this.updatePhoneNumberDropdownDOM()}closePhoneNumberDropdown(){console.log("[Dialer] Closing phone number dropdown"),this.showPhoneNumberDropdown=!1,this.updatePhoneNumberDropdownDOM()}stopPhoneNumbersLoading(){console.log("[Dialer] Stopping phone numbers loading spinner"),this.loadingPhoneNumbers=!1,this.showPhoneNumberDropdown&&this.updatePhoneNumberDropdownDOM(),this.render()}startPhoneNumbersLoading(){console.log("[Dialer] Starting phone numbers loading spinner"),this.loadingPhoneNumbers=!0,this.phoneNumbersError=null,this.render()}async executeTransfer(){const e=this.transferTarget.trim();if(e&&this.sipAdapter&&!this.isTransferring){this.isTransferring=!0,this.render();try{await this.sipAdapter.blindTransfer(e),this.showTransferView=!1,this.transferTarget="",this.dispatchEvent(new CustomEvent("call-transferred",{detail:{target:e},bubbles:!0}))}catch(e){this.dispatchEvent(new CustomEvent("dialer-error",{detail:{error:`Transfer failed: ${e.message}`},bubbles:!0}))}finally{this.isTransferring=!1,this.render()}}}requestNotificationPermission(){"Notification"in window&&"default"===Notification.permission&&Notification.requestPermission().catch(()=>{})}showIncomingCallNotification(e,t){if("Notification"in window&&"granted"===Notification.permission){this.dismissIncomingCallNotification();try{const n=t?`${t} (${e})`:e,i=new Notification("Incoming Call",{body:`Call from ${n}`,tag:"incoming-call",requireInteraction:!0,silent:!1});i.onclick=()=>{window.focus(),this.open(),i.close()},this._activeNotification=i}catch{}}}dismissIncomingCallNotification(){this._activeNotification&&(this._activeNotification.close(),this._activeNotification=null)}}customElements.get("convirza-dialer")||customElements.define("convirza-dialer",K);e.AudioDeviceManager=d,e.CallQualityMonitor=l,e.ConvirzaDialer=class{constructor(e,t){this.container=null,this.state="collapsed",this.callStatus="idle",this.currentCall=null,this.durationInterval=null,this.STORAGE_KEY="convirza_call_state",this.config={position:"bottom-right",zIndex:9999,defaultState:"collapsed",primaryColor:"#6366f1",accentColor:"#22c55e",theme:"dark",brandName:"Convirza",iceServers:[{urls:"stun:stun.l.google.com:19302"}],authToken:void 0,...e},this.state=this.config.defaultState||"collapsed",this.events=t||{},this.restoreCallState()}isValidTransition(e,t){const n=a[e];return!!n&&n.includes(t)}transitionState(e,t){const n=this.callStatus;if(n===e)return;if(!this.isValidTransition(n,e))return console.error(`[CallState] Invalid transition: ${n} → ${e}`),void this.transitionState("error",`Invalid state transition from ${n} to ${e}`);this.callStatus=e;const i=this.currentCall?{phoneNumber:this.currentCall.phoneNumber,startTime:this.currentCall.startTime,duration:this.currentCall.duration,status:e,errorMessage:t}:void 0;this.events.onStateChange&&this.events.onStateChange(n,e,i),this.persistCallState(),this.render()}getCallMetadata(){return this.currentCall?{phoneNumber:this.currentCall.phoneNumber,startTime:this.currentCall.startTime,duration:this.currentCall.duration,status:this.callStatus}:null}persistCallState(){if("undefined"!=typeof window&&window.localStorage)try{const e=this.getCallMetadata();e&&"idle"!==this.callStatus&&"ended"!==this.callStatus?localStorage.setItem(this.STORAGE_KEY,JSON.stringify(e)):localStorage.removeItem(this.STORAGE_KEY)}catch(e){console.error("[CallState] Failed to persist state:",e)}}restoreCallState(){if("undefined"!=typeof window&&window.localStorage)try{const e=localStorage.getItem(this.STORAGE_KEY);if(!e)return;const t=JSON.parse(e),n=Date.now();if(n-t.startTime>36e5)return void localStorage.removeItem(this.STORAGE_KEY);this.currentCall={phoneNumber:t.phoneNumber,startTime:t.startTime,duration:t.duration,callbacks:{onAnswered:[],onEnded:[]}},this.callStatus=t.status}catch(e){console.error("[CallState] Failed to restore state:",e),localStorage.removeItem(this.STORAGE_KEY)}}mount(e){const t=e||document.body;this.container=document.createElement("div"),this.container.id="convirza-dialer-widget",this.container.className=`convirza-dialer ${this.config.position} ${this.state}`,this.container.style.zIndex=String(this.config.zIndex),this.render(),t.appendChild(this.container),this.applyCustomColors()}unmount(){this.container&&this.container.parentNode&&(this.container.parentNode.removeChild(this.container),this.container=null)}placeCall(e,t){if(!e)throw new Error("Phone number is required");const n=this.formatPhoneNumber(e);this.currentCall={phoneNumber:n,startTime:Date.now(),duration:0,callbacks:{onAnswered:[],onEnded:[]}},this.transitionState("dialing"),this.open(),this.events.onCallStarted&&this.events.onCallStarted(n),this.initiateCall(n,t);const i=this;return{phoneNumber:n,get status(){return i.callStatus},get duration(){return i.currentCall?.duration||0},onAnswered(e){i.currentCall?.callbacks.onAnswered.push(e)},onEnded(e){i.currentCall?.callbacks.onEnded.push(e)},end(){i.endCall()}}}open(){this.state="expanded",this.container&&(this.container.className=`convirza-dialer ${this.config.position} ${this.state}`),this.events.onOpen&&this.events.onOpen(),this.render()}close(){this.state="collapsed",this.container&&(this.container.className=`convirza-dialer ${this.config.position} ${this.state}`),this.events.onClose&&this.events.onClose(),this.render()}toggle(){"collapsed"===this.state?this.open():this.close()}initiateCall(e,t){throw new Error("SIP integration not configured. Override initiateCall() method.")}handleCallRinging(){this.transitionState("ringing")}handleCallAnswered(){this.transitionState("connected"),this.currentCall?.callbacks.onAnswered.forEach(e=>e()),this.startDurationTimer()}handleCallTerminated(){this.endCall()}startDurationTimer(){this.durationInterval=window.setInterval(()=>{this.currentCall&&(this.currentCall.duration=Date.now()-this.currentCall.startTime,this.render())},1e3)}stopDurationTimer(){this.durationInterval&&(clearInterval(this.durationInterval),this.durationInterval=null)}endCall(){const e=this.currentCall?.duration||0,t=this.currentCall?.phoneNumber||"";this.currentCall?.callbacks.onEnded.forEach(t=>t(e)),this.events.onCallEnded&&this.events.onCallEnded(t,e),this.stopDurationTimer(),this.transitionState("ended"),setTimeout(()=>{this.transitionState("idle"),this.currentCall=null},1e3)}isValidPhoneNumber(e){const t=e.replace(/\s+/g,"");if(/[a-zA-Z]/.test(t))return t.length>0;return/^\+?[1-9]\d{6,14}$/.test(t)}formatPhoneNumber(e){const t=e.replace(/\D/g,"");return 10===t.length?`+1${t}`:(11===t.length&&t[0],`+${t}`)}formatDuration(e){const t=Math.floor(e/1e3);return`${Math.floor(t/60)}:${(t%60).toString().padStart(2,"0")}`}applyCustomColors(){this.container&&(this.container.style.setProperty("--primary-color",this.config.primaryColor||null),this.container.style.setProperty("--accent-color",this.config.accentColor||null))}render(){this.container&&("collapsed"===this.state?this.container.innerHTML=this.renderCollapsed():this.container.innerHTML=this.renderExpanded(),this.attachEventListeners())}renderCollapsed(){return`\n <button class="dialer-fab" data-action="toggle">\n <svg width="24" height="24" viewBox="0 0 24 24" fill="none">\n <path d="M20 10.999h2C22 5.869 18.127 2 12.99 2v2C17.052 4 20 6.943 20 10.999z" fill="currentColor"/>\n <path d="M13 8c2.103 0 3 .897 3 3h2c0-3.225-1.775-5-5-5v2zm3.422 5.443a1.001 1.001 0 00-1.391.043l-2.393 2.461c-.576-.11-1.734-.471-2.926-1.66-1.192-1.193-1.553-2.354-1.66-2.926l2.459-2.394a1 1 0 00.043-1.391L6.859 3.513a1 1 0 00-1.391-.087l-2.17 1.861a1 1 0 00-.29.649c-.015.25-.301 6.172 4.291 10.766C11.305 20.707 16.323 21 17.705 21c.202 0 .326-.006.359-.008a.992.992 0 00.648-.291l1.86-2.171a1 1 0 00-.086-1.391l-4.064-3.696z" fill="currentColor"/>\n </svg>\n ${"connected"===this.callStatus?'<span class="call-indicator"></span>':""}\n </button>\n <div class="dialer-branding">Powered by Convirza</div>\n `}renderExpanded(){return`\n <div class="dialer-panel">\n <div class="dialer-header">\n <h3>Phone</h3>\n <button class="close-btn" data-action="close">\n <svg width="20" height="20" viewBox="0 0 20 20" fill="currentColor">\n <path d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z"/>\n </svg>\n </button>\n </div>\n\n ${"idle"===this.callStatus?this.renderDialpad():this.renderActiveCall()}\n </div>\n <div class="dialer-branding">Powered by Convirza</div>\n `}renderDialpad(){return`\n <div class="dialer-content">\n <input type="tel" class="phone-input" placeholder="Enter phone number" data-input="phone" />\n <div class="dialpad">\n ${[1,2,3,4,5,6,7,8,9,"*",0,"#"].map(e=>`\n <button class="dialpad-btn" data-action="dial" data-digit="${e}">\n ${e}\n </button>\n `).join("")}\n </div>\n <button class="call-btn" data-action="call">\n <svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor">\n <path d="M20 10.999h2C22 5.869 18.127 2 12.99 2v2C17.052 4 20 6.943 20 10.999z"/>\n <path d="M13 8c2.103 0 3 .897 3 3h2c0-3.225-1.775-5-5-5v2zm3.422 5.443a1.001 1.001 0 00-1.391.043l-2.393 2.461c-.576-.11-1.734-.471-2.926-1.66-1.192-1.193-1.553-2.354-1.66-2.926l2.459-2.394a1 1 0 00.043-1.391L6.859 3.513a1 1 0 00-1.391-.087l-2.17 1.861a1 1 0 00-.29.649c-.015.25-.301 6.172 4.291 10.766C11.305 20.707 16.323 21 17.705 21c.202 0 .326-.006.359-.008a.992.992 0 00.648-.291l1.86-2.171a1 1 0 00-.086-1.391l-4.064-3.696z"/>\n </svg>\n Call\n </button>\n </div>\n `}renderActiveCall(){const e=this.currentCall?.phoneNumber||"",t=this.currentCall?.duration||0;return`\n <div class="active-call">\n <div class="call-info">\n <div class="call-status">${this.callStatus}</div>\n <div class="call-number">${e}</div>\n ${"connected"===this.callStatus?`\n <div class="call-duration">${this.formatDuration(t)}</div>\n `:""}\n </div>\n\n <div class="call-controls">\n <button class="control-btn end-btn" data-action="end">\n <svg width="24" height="24" viewBox="0 0 24 24" fill="currentColor">\n <path d="M16.707 2.293A.996.996 0 0016 2c-7.72 0-14 6.28-14 14 0 .26.09.52.251.71l3.909 4.554a.999.999 0 001.55.091l3.901-4.554a.999.999 0 00-.091-1.399l-3.274-2.742C10.605 11.622 12.203 11 14 11s3.395.622 5.246 1.66l-3.274 2.742a.999.999 0 00-.091 1.399l3.901 4.554a1 1 0 001.55-.091l3.909-4.554A.995.995 0 0025 16c0-7.72-6.28-14-14-14z"/>\n </svg>\n End\n </button>\n </div>\n </div>\n `}attachEventListeners(){if(!this.container)return;const e=this.container.querySelector('[data-action="toggle"]');e&&e.addEventListener("click",()=>this.toggle());const t=this.container.querySelector('[data-action="close"]');t&&t.addEventListener("click",()=>this.close());this.container.querySelectorAll('[data-action="dial"]').forEach(e=>{e.addEventListener("click",e=>{const t=e.target.dataset.digit,n=this.container?.querySelector('[data-input="phone"]');n&&t&&(n.value+=t)})});const n=this.container.querySelector('[data-action="call"]');n&&n.addEventListener("click",()=>{const e=this.container?.querySelector('[data-input="phone"]');e?.value&&this.placeCall(e.value)});const i=this.container.querySelector('[data-action="end"]');i&&i.addEventListener("click",()=>this.endCall())}},e.ConvirzaDialerElement=K,e.DialerAPI=t,e.PhoneNumbersAPI=r,e.SipAdapter=m,e.convirzaDialer=n,e.destroyDialer=function(){i?(n.destroy(),i=!1):console.warn("[Dialer] Not initialized. Nothing to destroy.")},e.initDialer=function(e){i?console.warn("[Dialer] Already initialized. Skipping duplicate init."):(n.init(e),i=!0)},e.isDialerInitialized=function(){return i},e.isSipLoaded=$,e.loadSipJs=g,e.preloadSipJs=function(){$()||g().catch(e=>{console.warn("[Dialer] SIP.js preload failed:",e)})}});
|