UNPKG

@kmhgmbh/dialer-vue-components

Version:

VueJS components for telephony and dialer functions 2

3 lines 307 kB
(function(Oe,f){typeof exports=="object"&&typeof module<"u"?f(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],f):(Oe=typeof globalThis<"u"?globalThis:Oe||self,f(Oe.dialerVueComponents={},Oe.Vue))})(this,function(Oe,f){"use strict";var Xc=Object.defineProperty;var Zc=(Oe,f,pt)=>f in Oe?Xc(Oe,f,{enumerable:!0,configurable:!0,writable:!0,value:pt}):Oe[f]=pt;var he=(Oe,f,pt)=>(Zc(Oe,typeof f!="symbol"?f+"":f,pt),pt);class pt{constructor(n){he(this,"baseUrl");this.baseUrl=n.baseUrl!==void 0?n.baseUrl:"http://localhost:8082"}async authenticate(n,s,a){try{const u=await this.fetchPrivateToken();return console.log("✓ Reused existing session cookie, skipping full sign-in"),u}catch(u){console.log("ℹ No valid session cookie, performing full sign-in flow",u)}try{const u=await this.fetchVerificationToken();console.log("✓ Step 1: Verification token obtained");const t=await this.fetchPublicKey();console.log("✓ Step 2: Public key obtained");const _=await this.importPublicKey(t);console.log("✓ Step 3: Public key imported");const p=JSON.stringify({__HRequestVerificationToken:u,login:n,password:s,station:a,timeZone:"W. Europe Standard Time",network:"",InHermesLogin:!0}),o=await this.encryptDataHybrid(p,_);console.log("✓ Step 4: Login data encrypted"),await this.signIn(u,o),console.log("✓ Step 5: Sign in successful, cookies obtained");const T=await this.fetchPrivateToken();return console.log("✓ Step 6: Private Token obtained"),T}catch(u){throw console.error("❌ Authentication failed:",u),u}}async fetchVerificationToken(){console.log("BASE URL:",this.baseUrl);const n=`${this.baseUrl}/hermes360/Admin/launcher/login`;console.log("🌐 Step 1: Fetching login page from:",n);const s=await fetch(n,{method:"GET",credentials:"include"});if(console.log("📦 Step 1 Response status:",s.status),console.log("📦 Step 1 Response headers:",Object.fromEntries(s.headers.entries())),s.headers.get("set-cookie")?console.log("🍪 Step 1 Set-Cookie header received"):console.warn("⚠️ Step 1: No Set-Cookie header in response"),!s.ok)throw new Error(`Failed to fetch login page: ${s.status}`);const u=await s.text(),t=this.parseVerificationToken(u);if(!t)throw new Error("__HRequestVerificationToken not found in login page");return console.log("✅ Step 1: Verification token extracted"),t}parseVerificationToken(n){const u=new DOMParser().parseFromString(n,"text/html").querySelector("#login-form");if(!u)return null;const t=u.querySelector('input[name="__HRequestVerificationToken"]');return(t==null?void 0:t.value)||null}async fetchPublicKey(){const n=`${this.baseUrl}/hermes360/Admin/Launcher/api/Authentification/GetPublicKey`,s=await fetch(n,{method:"GET",credentials:"include",headers:{Accept:"application/json"}});if(s.headers.get("set-cookie")&&console.log("🍪 Step 2 Set-Cookie header received"),!s.ok)throw new Error(`Failed to fetch public key: ${s.status}`);const u=await s.json();return console.log("✅ Step 2: Public key received"),u.publicKey}toBase64Url(n){return n.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async importPublicKey(n){const a=new DOMParser().parseFromString(n,"text/xml"),u=a.getElementsByTagName("Modulus")[0],t=a.getElementsByTagName("Exponent")[0];if(!u||!t)throw new Error("Invalid public key XML format");const _=u.textContent||"",p=t.textContent||"",o=this.toBase64Url(_),T=this.toBase64Url(p),g={kty:"RSA",n:o,e:T,alg:"RSA-OAEP-256",ext:!0};return crypto.subtle.importKey("jwk",g,{name:"RSA-OAEP",hash:"SHA-256"},!0,["encrypt"])}async encryptDataHybrid(n,s){const a=await crypto.subtle.generateKey({name:"AES-GCM",length:256},!0,["encrypt","decrypt"]),t=new TextEncoder().encode(n),_=crypto.getRandomValues(new Uint8Array(12)),p=await crypto.subtle.encrypt({name:"AES-GCM",iv:_},a,t),o=await crypto.subtle.exportKey("raw",a),T=await crypto.subtle.encrypt({name:"RSA-OAEP"},s,o),g=btoa(String.fromCharCode(...new Uint8Array(p))),C=btoa(String.fromCharCode(...new Uint8Array(T))),b=btoa(String.fromCharCode(..._));return{encryptedData:g,encryptedAesKey:C,iv:b}}async signIn(n,s){const a=`${this.baseUrl}/hermes360/Admin/Launcher/api/Authentification/SignIn`;console.log("🌐 Step 4: Signing in to:",a);const u=new URLSearchParams;u.append("__HRequestVerificationToken",n),u.append("encryptedData",s.encryptedData),u.append("encryptedAesKey",s.encryptedAesKey),u.append("iv",s.iv);const t=await fetch(a,{method:"POST",credentials:"include",headers:{Accept:"application/json, text/javascript, */*; q=0.01","Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"},body:u.toString()});if(t.headers.get("set-cookie")?console.log("🍪 Step 4 Set-Cookie header received"):console.error("❌ Step 4: No Set-Cookie header! Cookies not received!"),t.status===401)throw new Error("Authentication failed: Invalid credentials (401)");if(!t.ok)throw new Error(`Sign in failed: ${t.status}`);try{const p=await t.json();if(p.Result&&p.Result!==0){const T={1:"Account is disabled",2:"Account is blocked",3:"Password reset required",7:"Account does not exist"}[p.Result]||`Unknown error (Result: ${p.Result})`;throw new Error(`Sign in failed: ${T}`)}}catch(p){if(p instanceof SyntaxError){console.log("✅ Step 4: Empty response (expected), checking for cookies...");return}throw p}console.log("✅ Step 4: Sign in successful")}async fetchPrivateToken(){const n=`${this.baseUrl}/hermes360/PlateformPublication/api/login/Agent`,s=await fetch(n,{method:"POST",credentials:"include",headers:{Accept:"application/json, text/javascript, */*; q=0.01","Content-Type":"application/json; charset=UTF-8"},body:JSON.stringify({Oid:"",Token:""})});if(!s.ok)throw new Error(`Failed to fetch Private Token: ${s.status}`);const a=await s.json();if(!a.PT||!a.Oid)throw console.error("❌ Invalid Private Token response"),new Error("Invalid Private Token response - PT or Oid is empty. This indicates missing authentication cookies (Vocalcom.Application.Token, SessionCookieToken). Check if Step 4 (SignIn) set the cookies correctly.");return console.log("✅ Step 5: Private Token obtained successfully"),a}}const Y={CONNECTED:"CONNECTED",DISCONNECTED:"DISCONNECTED",LOGGED_IN:"LOGGED_IN",LOGGED_OUT:"LOGGED_OUT",SESSION_START:"SESSION_START",SESSION_END:"SESSION_END",SESSION_STATE:"SESSION_STATE",AGENT_STATE:"AGENT_STATE",TELEPHONY_STATE:"TELEPHONY_STATE",RECORD_START:"RECORD_START",RECORD_STOP:"RECORD_STOP",ERROR:"ERROR",CONNECTION_ERROR:"CONNECTION_ERROR",CALL_TRANSFERRED:"CALL_TRANSFERRED",DEBUG:"DEBUG"},jn={Off:0,Waiting:1,Working:2,Pause:3},Xt={online:["Online"],afterCall:["Nach dem Anruf","After call"],preview:["Vorschau Aufruf","Preview call"],onHold:["Online (Kunde wartend)","Online (client on Hold)"]};class Pi{constructor(){he(this,"GLOABL_CONTEXT_TYPE",0);he(this,"TELEPHONY_CONTEXT_TYPE",1);he(this,"agentLink",{});he(this,"subscribers",[]);he(this,"logger",!1);he(this,"campaign",null);he(this,"config",null);he(this,"username",null);he(this,"password",null);he(this,"extension",null);he(this,"isSessionOpened",!1);he(this,"currentAgentState",null);he(this,"currentTelephonyState",null);he(this,"currentCallSessionId",null);he(this,"isOutboundUser",!1);he(this,"PhoneNumberTypes",null);he(this,"isLoggedIn",!1);he(this,"authService",null);he(this,"pendingLogin",null);he(this,"loginRetryIntervalId",null);he(this,"loginPollingStartedAt",0);he(this,"LOGIN_POLLING_INTERVAL_MS",500);he(this,"LOGIN_POLLING_TIMEOUT_MS",3e4);console.log("AgentLinkAdapter created")}subscribe(n){if(this.subscribers.includes(n)){console.log("Subject: Observer has been attached already.");return}this.subscribers.push(n)}unsubscribe(n){this.subscribers=this.subscribers.filter(s=>s!==n)}notify(n,s="",a=void 0){this.subscribers.forEach(u=>{u.value={state:n,message:s,code:a}})}setConfig(n){if(this.config=n,n.hermesBaseUrl!==void 0||n.useHermesAuth){const s=n.hermesBaseUrl!==void 0?n.hermesBaseUrl:"";this.authService=new pt({baseUrl:s})}}init(n){this.agentLink||this.notify(Y.ERROR,"Please set the config settings"),this.removeAllIdsFromSessionStorage(),!(this.agentLink&&this.agentLink.Connected)&&(window.parent.Log=(s,a,u)=>{this.logger&&console.log(s,u);try{this.catchEvents(u)}catch(t){console.error(t)}},typeof window.screenRecorder>"u"&&(window.screenRecorder=null),typeof window.allowDesktopSharing>"u"&&(window.allowDesktopSharing=!1),window.parent.agentlink_object_path="hermes/",window.parent.agentlink_default_protocol="WEBSOCKET",window.parent.websock_protocol="wss",window.parent.websock_proto="wss",window.parent.websock_port=443,this.agentLink=new window.AgentLinkClass(443,"wss"),this.PhoneNumberTypes=window.parent.PhoneNumberTypes||{},Object.assign(this.agentLink,this.config),this.isOutboundUser=n,this.agentLink.attachEvent("OnConnect",s=>this.onConnect(s)),this.agentLink.attachEvent("OnUserIdentification",()=>this.onUserIdentification()),this.agentLink.attachEvent("OnAgentStateChange",(s,a,u)=>this.onAgentStateChanged(s,a,u)),this.agentLink.attachEvent("OnSessionOpen",()=>this.onSessionOpen()),this.agentLink.attachEvent("OnSessionClose",()=>this.onSessionClose()),this.agentLink.attachEvent("OnSessionStateChange",(s,a,u,t)=>this.onSessionStateChange(s,a,u,t)),this.agentLink.attachEvent("OnDisconnect",()=>this.onDisconnect()),this.agentLink.attachEvent("OnTelephonyRecordStart",s=>this.onTelephonyRecordStart(s)),this.agentLink.attachEvent("OnTelephonyRecordStop",s=>this.onTelephonyRecordStop(s)),this.agentLink.Connect())}isActionReady(n){try{const s=window.TelephonySessionActionAllowed[n];return this.agentLink.Telephony.GetSession().ActionIsReady(s)}catch{return!1}}async login(n,s,a){if(!(this.agentLink.LoggedIn||this.isLoggedIn)){this.username=n,this.password=s,this.extension=a;try{if(this.authService){const u=await this.authService.authenticate(n,s,a);this.pendingLogin={id:u.Id.toString(),password:u.Password,station:a,pt:u.PT}}else console.log("⚠️ Using legacy login method (no authService configured)"),this.pendingLogin={id:n,password:s,station:a};this._startLoginPolling()}catch(u){throw console.error("❌ Login failed:",u),this.pendingLogin=null,u instanceof Error?this.notify(Y.CONNECTION_ERROR,u.message):this.notify(Y.CONNECTION_ERROR,"Authentifizierung fehlgeschlagen"),u}}}_startLoginPolling(){this.loginRetryIntervalId||(this.loginPollingStartedAt=Date.now(),this._tryLogin(),this.loginRetryIntervalId=setInterval(()=>{if(Date.now()-this.loginPollingStartedAt>=this.LOGIN_POLLING_TIMEOUT_MS){this._stopLoginRetry(),this.pendingLogin=null,this.notify(Y.CONNECTION_ERROR,"Anmeldung fehlgeschlagen: AgentLink wurde nicht rechtzeitig bereit (Timeout).");return}this._tryLogin()},this.LOGIN_POLLING_INTERVAL_MS))}_tryLogin(){var _;if(!this.pendingLogin)return;if(this.agentLink.LoggedIn||this.isLoggedIn){this.pendingLogin=null,this._stopLoginRetry();return}const n=window.AgentActionAllowed??((_=window.parent)==null?void 0:_.AgentActionAllowed);if(!n||!this.agentLink.ActionIsReady(n.Login))return;this._stopLoginRetry();const{id:s,password:a,station:u,pt:t}=this.pendingLogin;this.pendingLogin=null,this.isLoggedIn=!0,console.log("✓ AgentLink login initiated",t?"with Private Token":"(legacy)"),this.agentLink.Login(s,a,u,t)}_stopLoginRetry(){this.loginRetryIntervalId&&(clearInterval(this.loginRetryIntervalId),this.loginRetryIntervalId=null)}logout(){this.agentLink.LoggedIn&&this.agentLink.Logout(),this.isLoggedIn=!1,this.pendingLogin=null,this._stopLoginRetry(),this.removeAllIdsFromSessionStorage()}call(n,s,a){s?this.agentLink.Telephony.GetSession().PreviewCall(n):this.agentLink.Telephony.ActionIsReady(window.parent.ContextActionAllowed.ManualCall)?this.campaign?this.agentLink.Telephony.ManualCall(this.campaign.id,n,null,null,1,a):this.notify(Y.ERROR,"Es ist keine Kampagne gesetzt."):this.notify(Y.ERROR,"Manueller Anruf nicht erlaubt.")}hangup(){const n=this.agentLink.Telephony.GetSession();n&&n.Hangup(),this.isOutboundUser||this.logout()}hold(){const n=this.agentLink.Telephony.GetSession();n&&n.Hold()}retrieve(){const n=this.agentLink.Telephony.GetSession();n&&n.Retrieve()}redial(n){const s=this.agentLink.Telephony.GetSession();s&&s.Redial(n)}previewCancel(){const n=this.agentLink.Telephony.GetSession();n&&n.PreviewCancel()}getSessionId(){if(this.agentLink.LoggedIn){const n=this.agentLink.Telephony.GetSession();if(n)return n.SessionId}return null}getSession(){if(this.agentLink.LoggedIn){const n=this.agentLink.Telephony.GetSession();if(n)return n}return null}getManualCampaigns(){const n=[];for(let s=0;s<this.agentLink.ManualCampaigns.Count;s+=1){const a=JSON.parse(JSON.stringify(this.agentLink.ManualCampaigns.Item(s))),u={description:a.Description,id:a.CampaignId};n.push(u)}return n}setManualCamapaign(n){this.campaign=n}setLogger(n){this.logger=n}getLogger(){return this.logger}getCampaigns(){const n=[];for(let s=0;s<this.agentLink.Campaigns.Count;s+=1){const a=this.agentLink.Campaigns.Item(s);let u=!0;a.State===window.CampaignStates.Close&&(u=!1),n.push({name:a.Description,queue:a.Queue,campaignId:a.CampaignId,type:a.Type,state:a.State,dialing:a.Dialing,active:u})}return n}getQueues(){const n=[];for(let s=0;s<this.agentLink.Telephony.Queues.Count;s+=1){const a=this.agentLink.Telephony.Queues.Item(s);n.push({name:a.Description,queue:a.QueueId,active:a.EnabledBy})}return n}getPauseOptions(){const n=[];for(let s=0;s<this.agentLink.PauseCodes.Count;s+=1){const a=this.agentLink.PauseCodes.Item(s);n.push({description:a.Description,code:a.Code,duration:a.Duration})}return n}requestPause(n){this.agentLink.ActionIsReady(window.AgentActionAllowed.Pause)?this.agentLink.RequestPause(n,0):this.notify(Y.ERROR,"Pause aktuell nicht möglich.")}stopPause(){this.agentLink.RequestReady()}startRecording(n){this.isSessionOpened?this.agentLink.Record(n):this.notify(Y.ERROR,"Keine aktive Session vorhanden.")}stopRecording(){this.agentLink.RecordStop(!0)}catchEvents(n){n.includes("MAXRING_ATTEMPTED")&&this.notify(Y.ERROR,"Max. Ringversuch"),n.includes("InvalidAgentIdentification")&&this.notify(Y.CONNECTION_ERROR,"Ungültige Anmeldedaten"),n.includes("The phone number dialed is not valid")&&this.notify(Y.ERROR,"Ungültige Rufnummer"),n.includes("InvalidStationIdentification")&&this.notify(Y.CONNECTION_ERROR,"Keine Verbindung mit der Nebenstelle möglich"),n.includes("AgentAlreadyMonitored")&&this.notify(Y.CONNECTION_ERROR,"Die Nebenstelle ist bereits verbunden"),n.includes("StationNotConnected")&&this.notify(Y.CONNECTION_ERROR,"Station nicht verbunden – bitte SIP/WebRTC-Verbindung prüfen"),n.includes("SipStationAlreadyConnected")&&this.notify(Y.CONNECTION_ERROR,"Die Station wird bereits von einer anderen Sitzung verwendet")}onConnect(n){n?(this.notify(Y.CONNECTED),this._tryLogin()):(this.isLoggedIn=!1,this.notify(Y.DISCONNECTED))}onUserIdentification(){this.agentLink.LoggedIn?this.notify(Y.LOGGED_IN):(this.isLoggedIn=!1,this.notify(Y.LOGGED_OUT))}onAgentStateChanged(n,s,a){n===this.GLOABL_CONTEXT_TYPE&&(this.currentAgentState=a,this.notify(Y.AGENT_STATE,a,s)),n===this.TELEPHONY_CONTEXT_TYPE&&(this.currentTelephonyState=a,this.notify(Y.TELEPHONY_STATE,a,s)),this._tryLogin()}getAgentState(){return this.currentAgentState}getTelephonyState(){return this.currentTelephonyState}onSessionOpen(){const n=this.getSession();this.currentCallSessionId=this.getSessionId(),this.notify(Y.SESSION_START,{sessionId:n.SessionId,indice:n.Indice,contactNumber:n.ContactNumber,campaignId:n.CampaignId,campaignType:n.CampaignType,campaignDescription:n.CampaignDescription}),this.isSessionOpened=!0}onSessionClose(){this.notify(Y.SESSION_END,{sessionId:this.currentCallSessionId}),this.currentCallSessionId=null,this.isSessionOpened=!1}onSessionStateChange(n,s,a,u){this.notify(Y.SESSION_STATE,{contextType:n,sessionId:s,label:u},a)}onDisconnect(){this.notify(Y.DISCONNECTED),this.isLoggedIn=!1}onTelephonyRecordStart(n){this.notify(Y.RECORD_START,n)}onTelephonyRecordStop(n){this.notify(Y.RECORD_STOP,n)}startQueue(n,s,a){console.log("Starting Queue: ",a),this.agentLink.StartQueue(n,s),this.addIdToSessionStorage(s)}stopQueue(n,s,a){console.log("Stoping Queue: ",a),this.agentLink.StopQueue(n,s),this.removeIdFromSessionStorage(s)}doInternalBlindTransfer(n){this.isActionReady("BlindTransfer")&&(this.agentLink.Telephony.GetSession().BlindTransfer(n,this.PhoneNumberTypes.Internal),this.notify(Y.CALL_TRANSFERRED))}doBlindTransfer(n,s=!1){this.agentLink.Telephony.GetSession().BlindTransfer(n,s?this.PhoneNumberTypes.External:this.PhoneNumberTypes.Did,""),this.notify(Y.CALL_TRANSFERRED)}handoverCall(){this.agentLink.Telephony.GetSession().Transfer(),this.notify(Y.CALL_TRANSFERRED)}doWarmHandover(n,s=!1){this.agentLink.Telephony.GetSession().ConsultationCall(n,s?this.PhoneNumberTypes.External:this.PhoneNumberTypes.Did,""),this.notify(Y.CALL_TRANSFERRED)}setCallStatus(n){this.previewCancel(),this.agentLink.Telephony.GetSession().SetCallStatus(n.status,n.details,n.followupDateTime,n.followupPhoneNumber,n.followUpValidity,n.comment)}addIdToSessionStorage(n){const s=JSON.parse(sessionStorage.getItem("activeCampaigns"))||[];s.includes(n)||(s.push(n),sessionStorage.setItem("activeCampaigns",JSON.stringify(s)))}removeIdFromSessionStorage(n){const a=(JSON.parse(sessionStorage.getItem("activeCampaigns"))||[]).filter(u=>u!==n);sessionStorage.setItem("activeCampaigns",JSON.stringify(a))}checkIdInSessionStorage(n){return(JSON.parse(sessionStorage.getItem("activeCampaigns"))||[]).includes(n)}removeAllIdsFromSessionStorage(){sessionStorage.removeItem("activeCampaigns")}}function $i(){const d={};function n(u,t){d[u]||(d[u]=[]),d[u].push(t)}function s(u,t){if(!d[u])return;const _=d[u].indexOf(t);_>-1&&d[u].splice(_,1)}function a(u,...t){d[u]&&d[u].forEach(_=>{_(...t)})}return{on:n,off:s,emit:a}}function Mi(d){return d&&d.__esModule&&Object.prototype.hasOwnProperty.call(d,"default")?d.default:d}const Kn={_from:"jssip@3.13.6",_id:"jssip@3.13.6",_inBundle:!1,_integrity:"sha512-Bf1ndrSuqpO87/AG56WACR7kKcCvKOzaIQROu7JUMh0qFaGOV4NuR+wsnaXa7f3/d6xhwVczczFyt1ywJmTjPg==",_location:"/jssip",_phantomChildren:{},_requested:{type:"version",registry:!0,raw:"jssip@3.13.6",name:"jssip",escapedName:"jssip",rawSpec:"3.13.6",saveSpec:null,fetchSpec:"3.13.6"},_requiredBy:["/"],_resolved:"https://registry.npmjs.org/jssip/-/jssip-3.13.6.tgz",_shasum:"5af3c453b1594a822fe2ffa8a50ceadbd491b40c",_spec:"jssip@3.13.6",_where:"/Users/ruslan.ibraev/kmh/dialer-vue-components",bugs:{url:"https://github.com/versatica/JsSIP/issues"},bundleDependencies:!1,contributors:[{name:"José Luis Millán",email:"jmillan@aliax.net",url:"https://github.com/jmillan"},{name:"Iñaki Baz Castillo",email:"ibc@aliax.net",url:"https://inakibaz.me"}],dependencies:{debug:"^4.3.1",events:"^3.3.0","sdp-transform":"^2.14.1"},deprecated:!1,description:"The Javascript SIP library",devDependencies:{"@eslint/eslintrc":"^3.3.3","@eslint/js":"^9.39.2","@types/debug":"^4.1.12","@types/events":"^3.0.3","@types/jest":"^30.0.0","@types/node":"^25.0.10",cpx:"^1.5.0",esbuild:"^0.27.2",eslint:"^9.39.1","eslint-config-prettier":"^10.1.8","eslint-plugin-jest":"^29.12.1","eslint-plugin-prettier":"^5.5.5",globals:"^17.0.0",jest:"^30.2.0","open-cli":"^8.0.0",pegjs:"^0.7.0",prettier:"^3.8.1","ts-jest":"^29.4.6",typedoc:"^0.28.16",typescript:"^5.9.3","typescript-eslint":"^8.53.1"},files:["LICENSE","README.md","npm-scripts.mjs","lib"],homepage:"https://jssip.net",keywords:["sip","websocket","webrtc","node","browser","library"],license:"MIT",main:"lib/JsSIP.js",name:"jssip",repository:{type:"git",url:"git+https://github.com/versatica/JsSIP.git"},scripts:{build:"node npm-scripts.mjs build",coverage:"node npm-scripts.mjs coverage",docs:"node npm-scripts.mjs docs","docs:check":"node npm-scripts.mjs docs:check","docs:watch":"node npm-scripts.mjs docs:watch",lint:"node npm-scripts.mjs lint","lint:fix":"node npm-scripts.mjs lint:fix",release:"node npm-scripts.mjs release",test:"node npm-scripts.mjs test","typescript:build":"node npm-scripts.mjs typescript:build"},title:"JsSIP",types:"lib/JsSIP.d.ts",version:"3.13.6"},Yn=Kn;var ge={USER_AGENT:`${Yn.title} ${Yn.version}`,SIP:"sip",SIPS:"sips",causes:{CONNECTION_ERROR:"Connection Error",REQUEST_TIMEOUT:"Request Timeout",SIP_FAILURE_CODE:"SIP Failure Code",INTERNAL_ERROR:"Internal Error",BUSY:"Busy",REJECTED:"Rejected",REDIRECTED:"Redirected",UNAVAILABLE:"Unavailable",NOT_FOUND:"Not Found",ADDRESS_INCOMPLETE:"Address Incomplete",INCOMPATIBLE_SDP:"Incompatible SDP",MISSING_SDP:"Missing SDP",AUTHENTICATION_ERROR:"Authentication Error",BYE:"Terminated",WEBRTC_ERROR:"WebRTC Error",CANCELED:"Canceled",NO_ANSWER:"No Answer",EXPIRES:"Expires",NO_ACK:"No ACK",DIALOG_ERROR:"Dialog Error",USER_DENIED_MEDIA_ACCESS:"User Denied Media Access",BAD_MEDIA_DESCRIPTION:"Bad Media Description",RTP_TIMEOUT:"RTP Timeout"},SIP_ERROR_CAUSES:{REDIRECTED:[300,301,302,305,380],BUSY:[486,600],REJECTED:[403,603],NOT_FOUND:[404,604],UNAVAILABLE:[480,410,408,430],ADDRESS_INCOMPLETE:[484,424],INCOMPATIBLE_SDP:[488,606],AUTHENTICATION_ERROR:[401,407]},ACK:"ACK",BYE:"BYE",CANCEL:"CANCEL",INFO:"INFO",INVITE:"INVITE",MESSAGE:"MESSAGE",NOTIFY:"NOTIFY",OPTIONS:"OPTIONS",REGISTER:"REGISTER",REFER:"REFER",UPDATE:"UPDATE",SUBSCRIBE:"SUBSCRIBE",DTMF_TRANSPORT:{INFO:"INFO",RFC2833:"RFC2833"},REASON_PHRASE:{100:"Trying",180:"Ringing",181:"Call Is Being Forwarded",182:"Queued",183:"Session Progress",199:"Early Dialog Terminated",200:"OK",202:"Accepted",204:"No Notification",300:"Multiple Choices",301:"Moved Permanently",302:"Moved Temporarily",305:"Use Proxy",380:"Alternative Service",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Timeout",410:"Gone",412:"Conditional Request Failed",413:"Request Entity Too Large",414:"Request-URI Too Long",415:"Unsupported Media Type",416:"Unsupported URI Scheme",417:"Unknown Resource-Priority",420:"Bad Extension",421:"Extension Required",422:"Session Interval Too Small",423:"Interval Too Brief",424:"Bad Location Information",428:"Use Identity Header",429:"Provide Referrer Identity",430:"Flow Failed",433:"Anonymity Disallowed",436:"Bad Identity-Info",437:"Unsupported Certificate",438:"Invalid Identity Header",439:"First Hop Lacks Outbound Support",440:"Max-Breadth Exceeded",469:"Bad Info Package",470:"Consent Needed",478:"Unresolvable Destination",480:"Temporarily Unavailable",481:"Call/Transaction Does Not Exist",482:"Loop Detected",483:"Too Many Hops",484:"Address Incomplete",485:"Ambiguous",486:"Busy Here",487:"Request Terminated",488:"Not Acceptable Here",489:"Bad Event",491:"Request Pending",493:"Undecipherable",494:"Security Agreement Required",500:"JsSIP Internal Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Server Time-out",505:"Version Not Supported",513:"Message Too Large",580:"Precondition Failure",600:"Busy Everywhere",603:"Decline",604:"Does Not Exist Anywhere",606:"Not Acceptable"},ALLOWED_METHODS:"INVITE,ACK,CANCEL,BYE,UPDATE,MESSAGE,OPTIONS,REFER,INFO,NOTIFY,SUBSCRIBE",ACCEPTED_BODY_TYPES:"application/sdp, application/dtmf-relay",MAX_FORWARDS:69,SESSION_EXPIRES:90,MIN_SESSION_EXPIRES:60,CONNECTION_RECOVERY_MAX_INTERVAL:30,CONNECTION_RECOVERY_MIN_INTERVAL:2};class Hi extends Error{constructor(n,s){super(),this.code=1,this.name="CONFIGURATION_ERROR",this.parameter=n,this.value=s,this.message=this.value?`Invalid value ${JSON.stringify(this.value)} for parameter "${this.parameter}"`:`Missing parameter: ${this.parameter}`}}class Fi extends Error{constructor(n){super(),this.code=2,this.name="INVALID_STATE_ERROR",this.status=n,this.message=`Invalid status: ${n}`}}class Bi extends Error{constructor(n){super(),this.code=3,this.name="NOT_SUPPORTED_ERROR",this.message=n}}class qi extends Error{constructor(n){super(),this.code=4,this.name="NOT_READY_ERROR",this.message=n}}var et={ConfigurationError:Hi,InvalidStateError:Fi,NotSupportedError:Bi,NotReadyError:qi},Ce={},Os,zn;function xs(){if(zn)return Os;zn=1;const d=dt(),n=Qe();return Os=class Ui{static parse(a){if(a=n.parse(a,"Name_Addr_Header"),a!==-1)return a}constructor(a,u,t){if(!a||!(a instanceof d))throw new TypeError('missing or invalid "uri" parameter');this._uri=a,this._parameters={},this.display_name=u;for(const _ in t)Object.prototype.hasOwnProperty.call(t,_)&&this.setParam(_,t[_])}get uri(){return this._uri}get display_name(){return this._display_name}set display_name(a){this._display_name=a===0?"0":a}setParam(a,u){a&&(this._parameters[a.toLowerCase()]=typeof u>"u"||u===null?null:u.toString())}getParam(a){if(a)return this._parameters[a.toLowerCase()]}hasParam(a){if(a)return this._parameters.hasOwnProperty(a.toLowerCase())&&!0||!1}deleteParam(a){if(a=a.toLowerCase(),this._parameters.hasOwnProperty(a)){const u=this._parameters[a];return delete this._parameters[a],u}}clearParams(){this._parameters={}}clone(){return new Ui(this._uri.clone(),this._display_name,JSON.parse(JSON.stringify(this._parameters)))}_quote(a){return a.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}toString(){let a=this._display_name?`"${this._quote(this._display_name)}" `:"";a+=`<${this._uri.toString()}>`;for(const u in this._parameters)Object.prototype.hasOwnProperty.call(this._parameters,u)&&(a+=`;${u}`,this._parameters[u]!==null&&(a+=`=${this._parameters[u]}`));return a}},Os}var Ds,Qn;function Qe(){return Qn||(Qn=1,Ds=function(){function d(s){return'"'+s.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\x08/g,"\\b").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\f/g,"\\f").replace(/\r/g,"\\r").replace(/[\x00-\x07\x0B\x0E-\x1F\x80-\uFFFF]/g,escape)+'"'}var n={parse:function(s,a){var u={CRLF:T,DIGIT:g,ALPHA:C,HEXDIG:b,WSP:U,OCTET:F,DQUOTE:$,SP:A,HTAB:Z,alphanum:Q,reserved:se,unreserved:E,mark:D,escaped:j,LWS:P,SWS:B,HCOLON:ee,TEXT_UTF8_TRIM:L,TEXT_UTF8char:w,UTF8_NONASCII:R,UTF8_CONT:x,LHEX:Te,token:z,token_nodot:Le,separators:Ke,word:Ne,STAR:Me,SLASH:Fe,EQUAL:re,LPAREN:Be,RPAREN:Ye,RAQUOT:ze,LAQUOT:qe,COMMA:V,SEMI:K,COLON:Ve,LDQUOT:Pe,RDQUOT:_t,comment:X,ctext:q,quoted_string:ne,quoted_string_clean:le,qdtext:pe,quoted_pair:me,SIP_URI_noparams:oe,SIP_URI:Ze,uri_scheme:$e,uri_scheme_sips:_s,uri_scheme_sip:ps,userinfo:Nt,user:N,user_unreserved:te,password:Se,hostport:De,host:it,hostname:En,domainlabel:vn,toplabel:Qr,IPv6reference:An,IPv6address:bn,h16:G,ls32:Ge,IPv4address:Gt,dec_octet:Wt,port:Jr,uri_parameters:Xr,uri_parameter:yn,transport_param:Zr,user_param:el,method_param:tl,ttl_param:sl,maddr_param:nl,lr_param:rl,other_param:ll,pname:il,pvalue:ol,paramchar:jt,param_unreserved:al,headers:ul,header:ms,hname:cl,hvalue:fl,hnv_unreserved:Kt,Request_Response:_c,Request_Line:dl,Request_URI:hl,absoluteURI:Rn,hier_part:_l,net_path:pl,abs_path:gs,opaque_part:ml,uric:Yt,uric_no_slash:gl,path_segments:Tl,segment:Ts,param:wn,pchar:zt,scheme:Sl,authority:Cl,srvr:El,reg_name:vl,query:Al,SIP_Version:In,INVITEm:bl,ACKm:yl,OPTIONSm:Rl,BYEm:wl,CANCELm:Il,REGISTERm:Nl,SUBSCRIBEm:Ol,NOTIFYm:xl,REFERm:Dl,Method:Ss,Status_Line:kl,Status_Code:Ul,extension_code:Ll,Reason_Phrase:Pl,Allow_Events:pc,Call_ID:mc,Contact:gc,contact_param:Cs,name_addr:Et,display_name:Es,contact_params:Nn,c_p_q:$l,c_p_expires:Ml,delta_seconds:vt,qvalue:Hl,generic_param:Ae,gen_value:Fl,Content_Disposition:Tc,disp_type:Bl,disp_param:On,handling_param:ql,Content_Encoding:Sc,Content_Length:Cc,Content_Type:Ec,media_type:Vl,m_type:Gl,discrete_type:Wl,composite_type:jl,extension_token:vs,x_token:Kl,m_subtype:Yl,m_parameter:xn,m_value:zl,CSeq:vc,CSeq_value:Ql,Expires:Ac,Event:bc,event_type:Qt,From:yc,from_param:Dn,tag_param:kn,Max_Forwards:Rc,Min_Expires:wc,Name_Addr_Header:Ic,Proxy_Authenticate:Nc,challenge:Un,other_challenge:Jl,auth_param:Jt,digest_cln:As,realm:Xl,realm_value:Zl,domain:ei,URI:bs,nonce:ti,nonce_value:si,opaque:ni,stale:ri,algorithm:li,qop_options:ii,qop_value:ys,Proxy_Require:Oc,Record_Route:xc,rec_route:Rs,Reason:Dc,reason_param:Ln,reason_cause:oi,Require:kc,Route:Uc,route_param:ws,Subscription_State:Lc,substate_value:ai,subexp_params:Pn,event_reason_value:ui,Subject:Pc,Supported:$c,To:Mc,to_param:$n,Via:Hc,via_param:Is,via_params:Mn,via_ttl:ci,via_maddr:fi,via_received:di,via_branch:hi,response_port:_i,rport:pi,sent_protocol:mi,protocol_name:gi,transport:Ti,sent_by:Si,via_host:Ci,via_port:Ei,ttl:Hn,WWW_Authenticate:Fc,Session_Expires:Bc,s_e_expires:vi,s_e_params:Fn,s_e_refresher:Ai,extension_header:qc,header_value:bi,message_body:Vc,uuid_URI:Gc,uuid:yi,hex4:ft,hex8:Ri,hex12:wi,Refer_To:Wc,Replaces:jc,call_id:Ii,replaces_param:Bn,to_tag:Ni,from_tag:Oi,early_flag:xi};if(a!==void 0){if(u[a]===void 0)throw new Error("Invalid rule name: "+d(a)+".")}else a="CRLF";var t=0,_=0,p=[];function o(e){t<_||(t>_&&(_=t,p=[]),p.push(e))}function T(){var e;return s.substr(t,2)===`\r `?(e=`\r `,t+=2):(e=null,o('"\\r\\n"')),e}function g(){var e;return/^[0-9]/.test(s.charAt(t))?(e=s.charAt(t),t++):(e=null,o("[0-9]")),e}function C(){var e;return/^[a-zA-Z]/.test(s.charAt(t))?(e=s.charAt(t),t++):(e=null,o("[a-zA-Z]")),e}function b(){var e;return/^[0-9a-fA-F]/.test(s.charAt(t))?(e=s.charAt(t),t++):(e=null,o("[0-9a-fA-F]")),e}function U(){var e;return e=A(),e===null&&(e=Z()),e}function F(){var e;return/^[\0-\xFF]/.test(s.charAt(t))?(e=s.charAt(t),t++):(e=null,o("[\\0-\\xFF]")),e}function $(){var e;return/^["]/.test(s.charAt(t))?(e=s.charAt(t),t++):(e=null,o('["]')),e}function A(){var e;return s.charCodeAt(t)===32?(e=" ",t++):(e=null,o('" "')),e}function Z(){var e;return s.charCodeAt(t)===9?(e=" ",t++):(e=null,o('"\\t"')),e}function Q(){var e;return/^[a-zA-Z0-9]/.test(s.charAt(t))?(e=s.charAt(t),t++):(e=null,o("[a-zA-Z0-9]")),e}function se(){var e;return s.charCodeAt(t)===59?(e=";",t++):(e=null,o('";"')),e===null&&(s.charCodeAt(t)===47?(e="/",t++):(e=null,o('"/"')),e===null&&(s.charCodeAt(t)===63?(e="?",t++):(e=null,o('"?"')),e===null&&(s.charCodeAt(t)===58?(e=":",t++):(e=null,o('":"')),e===null&&(s.charCodeAt(t)===64?(e="@",t++):(e=null,o('"@"')),e===null&&(s.charCodeAt(t)===38?(e="&",t++):(e=null,o('"&"')),e===null&&(s.charCodeAt(t)===61?(e="=",t++):(e=null,o('"="')),e===null&&(s.charCodeAt(t)===43?(e="+",t++):(e=null,o('"+"')),e===null&&(s.charCodeAt(t)===36?(e="$",t++):(e=null,o('"$"')),e===null&&(s.charCodeAt(t)===44?(e=",",t++):(e=null,o('","'))))))))))),e}function E(){var e;return e=Q(),e===null&&(e=D()),e}function D(){var e;return s.charCodeAt(t)===45?(e="-",t++):(e=null,o('"-"')),e===null&&(s.charCodeAt(t)===95?(e="_",t++):(e=null,o('"_"')),e===null&&(s.charCodeAt(t)===46?(e=".",t++):(e=null,o('"."')),e===null&&(s.charCodeAt(t)===33?(e="!",t++):(e=null,o('"!"')),e===null&&(s.charCodeAt(t)===126?(e="~",t++):(e=null,o('"~"')),e===null&&(s.charCodeAt(t)===42?(e="*",t++):(e=null,o('"*"')),e===null&&(s.charCodeAt(t)===39?(e="'",t++):(e=null,o(`"'"`)),e===null&&(s.charCodeAt(t)===40?(e="(",t++):(e=null,o('"("')),e===null&&(s.charCodeAt(t)===41?(e=")",t++):(e=null,o('")"')))))))))),e}function j(){var e,r,l,i,c;return i=t,c=t,s.charCodeAt(t)===37?(e="%",t++):(e=null,o('"%"')),e!==null?(r=b(),r!==null?(l=b(),l!==null?e=[e,r,l]:(e=null,t=c)):(e=null,t=c)):(e=null,t=c),e!==null&&(e=function(h,m){return m.join("")}(i,e)),e===null&&(t=i),e}function P(){var e,r,l,i,c,h;for(i=t,c=t,h=t,e=[],r=U();r!==null;)e.push(r),r=U();if(e!==null?(r=T(),r!==null?e=[e,r]:(e=null,t=h)):(e=null,t=h),e=e!==null?e:"",e!==null){if(l=U(),l!==null)for(r=[];l!==null;)r.push(l),l=U();else r=null;r!==null?e=[e,r]:(e=null,t=c)}else e=null,t=c;return e!==null&&(e=function(m){return" "}()),e===null&&(t=i),e}function B(){var e;return e=P(),e=e!==null?e:"",e}function ee(){var e,r,l,i,c;for(i=t,c=t,e=[],r=A(),r===null&&(r=Z());r!==null;)e.push(r),r=A(),r===null&&(r=Z());return e!==null?(s.charCodeAt(t)===58?(r=":",t++):(r=null,o('":"')),r!==null?(l=B(),l!==null?e=[e,r,l]:(e=null,t=c)):(e=null,t=c)):(e=null,t=c),e!==null&&(e=function(h){return":"}()),e===null&&(t=i),e}function L(){var e,r,l,i,c,h,m;if(c=t,h=t,r=w(),r!==null)for(e=[];r!==null;)e.push(r),r=w();else e=null;if(e!==null){for(r=[],m=t,l=[],i=P();i!==null;)l.push(i),i=P();for(l!==null?(i=w(),i!==null?l=[l,i]:(l=null,t=m)):(l=null,t=m);l!==null;){for(r.push(l),m=t,l=[],i=P();i!==null;)l.push(i),i=P();l!==null?(i=w(),i!==null?l=[l,i]:(l=null,t=m)):(l=null,t=m)}r!==null?e=[e,r]:(e=null,t=h)}else e=null,t=h;return e!==null&&(e=function(v){return s.substring(t,v)}(c)),e===null&&(t=c),e}function w(){var e;return/^[!-~]/.test(s.charAt(t))?(e=s.charAt(t),t++):(e=null,o("[!-~]")),e===null&&(e=R()),e}function R(){var e;return/^[\x80-\uFFFF]/.test(s.charAt(t))?(e=s.charAt(t),t++):(e=null,o("[\\x80-\\uFFFF]")),e}function x(){var e;return/^[\x80-\xBF]/.test(s.charAt(t))?(e=s.charAt(t),t++):(e=null,o("[\\x80-\\xBF]")),e}function Te(){var e;return e=g(),e===null&&(/^[a-f]/.test(s.charAt(t))?(e=s.charAt(t),t++):(e=null,o("[a-f]"))),e}function z(){var e,r,l;if(l=t,r=Q(),r===null&&(s.charCodeAt(t)===45?(r="-",t++):(r=null,o('"-"')),r===null&&(s.charCodeAt(t)===46?(r=".",t++):(r=null,o('"."')),r===null&&(s.charCodeAt(t)===33?(r="!",t++):(r=null,o('"!"')),r===null&&(s.charCodeAt(t)===37?(r="%",t++):(r=null,o('"%"')),r===null&&(s.charCodeAt(t)===42?(r="*",t++):(r=null,o('"*"')),r===null&&(s.charCodeAt(t)===95?(r="_",t++):(r=null,o('"_"')),r===null&&(s.charCodeAt(t)===43?(r="+",t++):(r=null,o('"+"')),r===null&&(s.charCodeAt(t)===96?(r="`",t++):(r=null,o('"`"')),r===null&&(s.charCodeAt(t)===39?(r="'",t++):(r=null,o(`"'"`)),r===null&&(s.charCodeAt(t)===126?(r="~",t++):(r=null,o('"~"')))))))))))),r!==null)for(e=[];r!==null;)e.push(r),r=Q(),r===null&&(s.charCodeAt(t)===45?(r="-",t++):(r=null,o('"-"')),r===null&&(s.charCodeAt(t)===46?(r=".",t++):(r=null,o('"."')),r===null&&(s.charCodeAt(t)===33?(r="!",t++):(r=null,o('"!"')),r===null&&(s.charCodeAt(t)===37?(r="%",t++):(r=null,o('"%"')),r===null&&(s.charCodeAt(t)===42?(r="*",t++):(r=null,o('"*"')),r===null&&(s.charCodeAt(t)===95?(r="_",t++):(r=null,o('"_"')),r===null&&(s.charCodeAt(t)===43?(r="+",t++):(r=null,o('"+"')),r===null&&(s.charCodeAt(t)===96?(r="`",t++):(r=null,o('"`"')),r===null&&(s.charCodeAt(t)===39?(r="'",t++):(r=null,o(`"'"`)),r===null&&(s.charCodeAt(t)===126?(r="~",t++):(r=null,o('"~"'))))))))))));else e=null;return e!==null&&(e=function(i){return s.substring(t,i)}(l)),e===null&&(t=l),e}function Le(){var e,r,l;if(l=t,r=Q(),r===null&&(s.charCodeAt(t)===45?(r="-",t++):(r=null,o('"-"')),r===null&&(s.charCodeAt(t)===33?(r="!",t++):(r=null,o('"!"')),r===null&&(s.charCodeAt(t)===37?(r="%",t++):(r=null,o('"%"')),r===null&&(s.charCodeAt(t)===42?(r="*",t++):(r=null,o('"*"')),r===null&&(s.charCodeAt(t)===95?(r="_",t++):(r=null,o('"_"')),r===null&&(s.charCodeAt(t)===43?(r="+",t++):(r=null,o('"+"')),r===null&&(s.charCodeAt(t)===96?(r="`",t++):(r=null,o('"`"')),r===null&&(s.charCodeAt(t)===39?(r="'",t++):(r=null,o(`"'"`)),r===null&&(s.charCodeAt(t)===126?(r="~",t++):(r=null,o('"~"'))))))))))),r!==null)for(e=[];r!==null;)e.push(r),r=Q(),r===null&&(s.charCodeAt(t)===45?(r="-",t++):(r=null,o('"-"')),r===null&&(s.charCodeAt(t)===33?(r="!",t++):(r=null,o('"!"')),r===null&&(s.charCodeAt(t)===37?(r="%",t++):(r=null,o('"%"')),r===null&&(s.charCodeAt(t)===42?(r="*",t++):(r=null,o('"*"')),r===null&&(s.charCodeAt(t)===95?(r="_",t++):(r=null,o('"_"')),r===null&&(s.charCodeAt(t)===43?(r="+",t++):(r=null,o('"+"')),r===null&&(s.charCodeAt(t)===96?(r="`",t++):(r=null,o('"`"')),r===null&&(s.charCodeAt(t)===39?(r="'",t++):(r=null,o(`"'"`)),r===null&&(s.charCodeAt(t)===126?(r="~",t++):(r=null,o('"~"')))))))))));else e=null;return e!==null&&(e=function(i){return s.substring(t,i)}(l)),e===null&&(t=l),e}function Ke(){var e;return s.charCodeAt(t)===40?(e="(",t++):(e=null,o('"("')),e===null&&(s.charCodeAt(t)===41?(e=")",t++):(e=null,o('")"')),e===null&&(s.charCodeAt(t)===60?(e="<",t++):(e=null,o('"<"')),e===null&&(s.charCodeAt(t)===62?(e=">",t++):(e=null,o('">"')),e===null&&(s.charCodeAt(t)===64?(e="@",t++):(e=null,o('"@"')),e===null&&(s.charCodeAt(t)===44?(e=",",t++):(e=null,o('","')),e===null&&(s.charCodeAt(t)===59?(e=";",t++):(e=null,o('";"')),e===null&&(s.charCodeAt(t)===58?(e=":",t++):(e=null,o('":"')),e===null&&(s.charCodeAt(t)===92?(e="\\",t++):(e=null,o('"\\\\"')),e===null&&(e=$(),e===null&&(s.charCodeAt(t)===47?(e="/",t++):(e=null,o('"/"')),e===null&&(s.charCodeAt(t)===91?(e="[",t++):(e=null,o('"["')),e===null&&(s.charCodeAt(t)===93?(e="]",t++):(e=null,o('"]"')),e===null&&(s.charCodeAt(t)===63?(e="?",t++):(e=null,o('"?"')),e===null&&(s.charCodeAt(t)===61?(e="=",t++):(e=null,o('"="')),e===null&&(s.charCodeAt(t)===123?(e="{",t++):(e=null,o('"{"')),e===null&&(s.charCodeAt(t)===125?(e="}",t++):(e=null,o('"}"')),e===null&&(e=A(),e===null&&(e=Z())))))))))))))))))),e}function Ne(){var e,r,l;if(l=t,r=Q(),r===null&&(s.charCodeAt(t)===45?(r="-",t++):(r=null,o('"-"')),r===null&&(s.charCodeAt(t)===46?(r=".",t++):(r=null,o('"."')),r===null&&(s.charCodeAt(t)===33?(r="!",t++):(r=null,o('"!"')),r===null&&(s.charCodeAt(t)===37?(r="%",t++):(r=null,o('"%"')),r===null&&(s.charCodeAt(t)===42?(r="*",t++):(r=null,o('"*"')),r===null&&(s.charCodeAt(t)===95?(r="_",t++):(r=null,o('"_"')),r===null&&(s.charCodeAt(t)===43?(r="+",t++):(r=null,o('"+"')),r===null&&(s.charCodeAt(t)===96?(r="`",t++):(r=null,o('"`"')),r===null&&(s.charCodeAt(t)===39?(r="'",t++):(r=null,o(`"'"`)),r===null&&(s.charCodeAt(t)===126?(r="~",t++):(r=null,o('"~"')),r===null&&(s.charCodeAt(t)===40?(r="(",t++):(r=null,o('"("')),r===null&&(s.charCodeAt(t)===41?(r=")",t++):(r=null,o('")"')),r===null&&(s.charCodeAt(t)===60?(r="<",t++):(r=null,o('"<"')),r===null&&(s.charCodeAt(t)===62?(r=">",t++):(r=null,o('">"')),r===null&&(s.charCodeAt(t)===58?(r=":",t++):(r=null,o('":"')),r===null&&(s.charCodeAt(t)===92?(r="\\",t++):(r=null,o('"\\\\"')),r===null&&(r=$(),r===null&&(s.charCodeAt(t)===47?(r="/",t++):(r=null,o('"/"')),r===null&&(s.charCodeAt(t)===91?(r="[",t++):(r=null,o('"["')),r===null&&(s.charCodeAt(t)===93?(r="]",t++):(r=null,o('"]"')),r===null&&(s.charCodeAt(t)===63?(r="?",t++):(r=null,o('"?"')),r===null&&(s.charCodeAt(t)===123?(r="{",t++):(r=null,o('"{"')),r===null&&(s.charCodeAt(t)===125?(r="}",t++):(r=null,o('"}"'))))))))))))))))))))))))),r!==null)for(e=[];r!==null;)e.push(r),r=Q(),r===null&&(s.charCodeAt(t)===45?(r="-",t++):(r=null,o('"-"')),r===null&&(s.charCodeAt(t)===46?(r=".",t++):(r=null,o('"."')),r===null&&(s.charCodeAt(t)===33?(r="!",t++):(r=null,o('"!"')),r===null&&(s.charCodeAt(t)===37?(r="%",t++):(r=null,o('"%"')),r===null&&(s.charCodeAt(t)===42?(r="*",t++):(r=null,o('"*"')),r===null&&(s.charCodeAt(t)===95?(r="_",t++):(r=null,o('"_"')),r===null&&(s.charCodeAt(t)===43?(r="+",t++):(r=null,o('"+"')),r===null&&(s.charCodeAt(t)===96?(r="`",t++):(r=null,o('"`"')),r===null&&(s.charCodeAt(t)===39?(r="'",t++):(r=null,o(`"'"`)),r===null&&(s.charCodeAt(t)===126?(r="~",t++):(r=null,o('"~"')),r===null&&(s.charCodeAt(t)===40?(r="(",t++):(r=null,o('"("')),r===null&&(s.charCodeAt(t)===41?(r=")",t++):(r=null,o('")"')),r===null&&(s.charCodeAt(t)===60?(r="<",t++):(r=null,o('"<"')),r===null&&(s.charCodeAt(t)===62?(r=">",t++):(r=null,o('">"')),r===null&&(s.charCodeAt(t)===58?(r=":",t++):(r=null,o('":"')),r===null&&(s.charCodeAt(t)===92?(r="\\",t++):(r=null,o('"\\\\"')),r===null&&(r=$(),r===null&&(s.charCodeAt(t)===47?(r="/",t++):(r=null,o('"/"')),r===null&&(s.charCodeAt(t)===91?(r="[",t++):(r=null,o('"["')),r===null&&(s.charCodeAt(t)===93?(r="]",t++):(r=null,o('"]"')),r===null&&(s.charCodeAt(t)===63?(r="?",t++):(r=null,o('"?"')),r===null&&(s.charCodeAt(t)===123?(r="{",t++):(r=null,o('"{"')),r===null&&(s.charCodeAt(t)===125?(r="}",t++):(r=null,o('"}"')))))))))))))))))))))))));else e=null;return e!==null&&(e=function(i){return s.substring(t,i)}(l)),e===null&&(t=l),e}function Me(){var e,r,l,i,c;return i=t,c=t,e=B(),e!==null?(s.charCodeAt(t)===42?(r="*",t++):(r=null,o('"*"')),r!==null?(l=B(),l!==null?e=[e,r,l]:(e=null,t=c)):(e=null,t=c)):(e=null,t=c),e!==null&&(e=function(h){return"*"}()),e===null&&(t=i),e}function Fe(){var e,r,l,i,c;return i=t,c=t,e=B(),e!==null?(s.charCodeAt(t)===47?(r="/",t++):(r=null,o('"/"')),r!==null?(l=B(),l!==null?e=[e,r,l]:(e=null,t=c)):(e=null,t=c)):(e=null,t=c),e!==null&&(e=function(h){return"/"}()),e===null&&(t=i),e}function re(){var e,r,l,i,c;return i=t,c=t,e=B(),e!==null?(s.charCodeAt(t)===61?(r="=",t++):(r=null,o('"="')),r!==null?(l=B(),l!==null?e=[e,r,l]:(e=null,t=c)):(e=null,t=c)):(e=null,t=c),e!==null&&(e=function(h){return"="}()),e===null&&(t=i),e}function Be(){var e,r,l,i,c;return i=t,c=t,e=B(),e!==null?(s.charCodeAt(t)===40?(r="(",t++):(r=null,o('"("')),r!==null?(l=B(),l!==null?e=[e,r,l]:(e=null,t=c)):(e=null,t=c)):(e=null,t=c),e!==null&&(e=function(h){return"("}()),e===null&&(t=i),e}function Ye(){var e,r,l,i,c;return i=t,c=t,e=B(),e!==null?(s.charCodeAt(t)===41?(r=")",t++):(r=null,o('")"')),r!==null?(l=B(),l!==null?e=[e,r,l]:(e=null,t=c)):(e=null,t=c)):(e=null,t=c),e!==null&&(e=function(h){return")"}()),e===null&&(t=i),e}function ze(){var e,r,l,i;return l=t,i=t,s.charCodeAt(t)===62?(e=">",t++):(e=null,o('">"')),e!==null?(r=B(),r!==null?e=[e,r]:(e=null,t=i)):(e=null,t=i),e!==null&&(e=function(c){return">"}()),e===null&&(t=l),e}function qe(){var e,r,l,i;return l=t,i=t,e=B(),e!==null?(s.charCodeAt(t)===60?(r="<",t++):(r=null,o('"<"')),r!==null?e=[e,r]:(e=null,t=i)):(e=null,t=i),e!==null&&(e=function(c){return"<"}()),e===null&&(t=l),e}function V(){var e,r,l,i,c;return i=t,c=t,e=B(),e!==null?(s.charCodeAt(t)===44?(r=",",t++):(r=null,o('","')),r!==null?(l=B(),l!==null?e=[e,r,l]:(e=null,t=c)):(e=null,t=c)):(e=null,t=c),e!==null&&(e=function(h){return","}()),e===null&&(t=i),e}function K(){var e,r,l,i,c;return i=t,c=t,e=B(),e!==null?(s.charCodeAt(t)===59?(r=";",t++):(r=null,o('";"')),r!==null?(l=B(),l!==null?e=[e,r,l]:(e=null,t=c)):(e=null,t=c)):(e=null,t=c),e!==null&&(e=function(h){return";"}()),e===null&&(t=i),e}function Ve(){var e,r,l,i,c;return i=t,c=t,e=B(),e!==null?(s.charCodeAt(t)===58?(r=":",t++):(r=null,o('":"')),r!==null?(l=B(),l!==null?e=[e,r,l]:(e=null,t=c)):(e=null,t=c)):(e=null,t=c),e!==null&&(e=function(h){return":"}()),e===null&&(t=i),e}function Pe(){var e,r,l,i;return l=t,i=t,e=B(),e!==null?(r=$(),r!==null?e=[e,r]:(e=null,t=i)):(e=null,t=i),e!==null&&(e=function(c){return'"'}()),e===null&&(t=l),e}function _t(){var e,r,l,i;return l=t,i=t,e=$(),e!==null?(r=B(),r!==null?e=[e,r]:(e=null,t=i)):(e=null,t=i),e!==null&&(e=function(c){return'"'}()),e===null&&(t=l),e}function X(){var e,r,l,i;if(i=t,e=Be(),e!==null){for(r=[],l=q(),l===null&&(l=me(),l===null&&(l=X()));l!==null;)r.push(l),l=q(),l===null&&(l=me(),l===null&&(l=X()));r!==null?(l=Ye(),l!==null?e=[e,r,l]:(e=null,t=i)):(e=null,t=i)}else e=null,t=i;return e}function q(){var e;return/^[!-']/.test(s.charAt(t))?(e=s.charAt(t),t++):(e=null,o("[!-']")),e===null&&(/^[*-[]/.test(s.charAt(t))?(e=s.charAt(t),t++):(e=null,o("[*-[]")),e===null&&(/^[\]-~]/.test(s.charAt(t))?(e=s.charAt(t),t++):(e=null,o("[\\]-~]")),e===null&&(e=R(),e===null&&(e=P())))),e}function ne(){var e,r,l,i,c,h;if(c=t,h=t,e=B(),e!==null)if(r=$(),r!==null){for(l=[],i=pe(),i===null&&(i=me());i!==null;)l.push(i),i=pe(),i===null&&(i=me());l!==null?(i=$(),i!==null?e=[e,r,l,i]:(e=null,t=h)):(e=null,t=h)}else e=null,t=h;else e=null,t=h;return e!==null&&(e=function(m){return s.substring(t,m)}(c)),e===null&&(t=c),e}function le(){var e,r,l,i,c,h;if(c=t,h=t,e=B(),e!==null)if(r=$(),r!==null){for(l=[],i=pe(),i===null&&(i=me());i!==null;)l.push(i),i=pe(),i===null&&(i=me());l!==null?(i=$(),i!==null?e=[e,r,l,i]:(e=null,t=h)):(e=null,t=h)}else e=null,t=h;else e=null,t=h;return e!==null&&(e=function(m){var v=s.substring(t,m).trim();return v.substring(1,v.length-1).replace(/\\([\x00-\x09\x0b-\x0c\x0e-\x7f])/g,"$1")}(c)),e===null&&(t=c),e}function pe(){var e;return e=P(),e===null&&(s.charCodeAt(t)===33?(e="!",t++):(e=null,o('"!"')),e===null&&(/^[#-[]/.test(s.charAt(t))?(e=s.charAt(t),t++):(e=null,o("[#-[]")),e===null&&(/^[\]-~]/.test(s.charAt(t))?(e=s.charAt(t),t++):(e=null,o("[\\]-~]")),e===null&&(e=R())))),e}function me(){var e,r,l;return l=t,s.charCodeAt(t)===92?(e="\\",t++):(e=null,o('"\\\\"')),e!==null?(/^[\0-\t]/.test(s.charAt(t))?(r=s.charAt(t),t++):(r=null,o("[\\0-\\t]")),r===null&&(/^[\x0B-\f]/.test(s.charAt(t))?(r=s.charAt(t),t++):(r=null,o("[\\x0B-\\f]")),r===null&&(/^[\x0E-]/.test(s.charAt(t))?(r=s.charAt(t),t++):(r=null,o("[\\x0E-]")))),r!==null?e=[e,r]:(e=null,t=l)):(e=null,t=l),e}function oe(){var e,r,l,i,c,h;return c=t,h=t,e=$e(),e!==null?(s.charCodeAt(t)===58?(r=":",t++):(r=null,o('":"')),r!==null?(l=Nt(),l=l!==null?l:"",l!==null?(i=De(),i!==null?e=[e,r,l,i]:(e=null,t=h)):(e=null,t=h)):(e=null,t=h)):(e=null,t=h),e!==null&&(e=function(m){try{S.uri=new Di(S.scheme,S.user,S.host,S.port),delete S.scheme,delete S.user,delete S.host,delete S.host_type,delete S.port}catch{S=-1}}()),e===null&&(t=c),e}function Ze(){var e,r,l,i,c,h,m,v;return m=t,v=t,e=$e(),e!==null?(s.charCodeAt(t)===58?(r=":",t++):(r=null,o('":"')),r!==null?(l=Nt(),l=l!==null?l:"",l!==null?(i=De(),i!==null?(c=Xr(),c!==null?(h=ul(),h=h!==null?h:"",h!==null?e=[e,r,l,i,c,h]:(e=null,t=v)):(e=null,t=v)):(e=null,t=v)):(e=null,t=v)):(e=null,t=v)):(e=null,t=v),e!==null&&(e=function(O){try{S.uri=new Di(S.scheme,S.user,S.host,S.port,S.uri_params,S.uri_headers),delete S.scheme,delete S.user,delete S.host,delete S.host_type,delete S.port,delete S.uri_params,a==="SIP_URI"&&(S=S.uri)}catch{S=-1}}()),e===null&&(t=m),e}function $e(){var e;return e=_s(),e===null&&(e=ps()),e}function _s(){var e,r;return r=t,s.substr(t,4).toLowerCase()==="sips"?(e=s.substr(t,4),t+=4):(e=null,o('"sips"')),e!==null&&(e=function(l,i){S.scheme=i.toLowerCase()}(r,e)),e===null&&(t=r),e}function ps(){var e,r;return r=t,s.substr(t,3).toLowerCase()==="sip"?(e=s.substr(t,3),t+=3):(e=null,o('"sip"')),e!==null&&(e=function(l,i){S.scheme=i.toLowerCase()}(r,e)),e===null&&(t=r),e}function Nt(){var e,r,l,i,c,h;return i=t,c=t,e=N(),e!==null?(h=t,s.charCodeAt(t)===58?(r=":",t++):(r=null,o('":"')),r!==null?(l=Se(),l!==null?r=[r,l]:(r=null,t=h)):(r=null,t=h),r=r!==null?r:"",r!==null?(s.charCodeAt(t)===64?(l="@",t++):(l=null,o('"@"')),l!==null?e=[e,r,l]:(e=null,t=c)):(e=null,t=c)):(e=null,t=c),e!==null&&(e=function(m){S.user=decodeURIComponent(s.substring(t-1,m))}(i)),e===null&&(t=i),e}function N(){var e,r;if(r=E(),r===null&&(r=j(),r===null&&(r=te())),r!==null)for(e=[];r!==null;)e.push(r),r=E(),r===null&&(r=j(),r===null&&(r=te()));else e=null;return e}function te(){var e;return s.charCodeAt(t)===38?(e="&",t++):(e=null,o('"&"')),e===null&&(s.charCodeAt(t)===61?(e="=",t++):(e=null,o('"="')),e===null&&(s.charCodeAt(t)===43?(e="+",t++):(e=null,o('"+"')),e===null&&(s.charCodeAt(t)===36?(e="$",t++):(e=null,o('"$"')),e===null&&(s.charCodeAt(t)===44?(e=",",t++):(e=null,o('","')),e===null&&(s.charCodeAt(t)===59?(e=";",t++):(e=null,o('";"')),e===null&&(s.charCodeAt(t)===63?(e="?",t++):(e=null,o('"?"')),e===null&&(s.charCodeAt(t)===47?(e="/",t++):(e=null,o('"/"'))))))))),e}function Se(){var e,r,l;for(l=t,e=[],r=E(),r===null&&(r=j(),r===null&&(s.charCodeAt(t)===38?(r="&",t++):(r=null,o('"&"')),r===null&&(s.charCodeAt(t)===61?(r="=",t++):(r=null,o('"="')),r===null&&(s.charCodeAt(t)===43?(r="+",t++):(r=null,o('"+"')),r===null&&(s.charCodeAt(t)===36?(r="$",t++):(r=null,o('"$"')),r===null&&(s.charCodeAt(t)===44?(r=",",t++):(r=null,o('","'))))))));r!==null;)e.push(r),r=E(),r===null&&(r=j(),r===null&&(s.charCodeAt(t)===38?(r="&",t++):(r=null,o('"&"')),r===null&&(s.charCodeAt(t)===61?(r="=",t++):(r=null,o('"="')),r===null&&(s.charCodeAt(t)===43?(r="+",t++):(r=null,o('"+"')),r===null&&(s.charCodeAt(t)===36?(r="$",t++):(r=null,o('"$"')),r===null&&(s.charCodeAt(t)===44?(r=",",t++):(r=null,o('","'))))))));return e!==null&&(e=function(i){S.password=s.substring(t,i)}(l)),e===null&&(t=l),e}function De(){var e,r,l,i,c;return i=t,e=it(),e!==null?(c=t,s.charCodeAt(t)===58?(r=":",t++):(r=null,o('":"')),r!==null?(l=Jr(),l!==null?r=[r,l]:(r=null,t=c)):(r=null,t=c),r=r!==null?r:"",r!==null?e=[e,r]:(e=null,t=i)):(e=null,t=i),e}function it(){var e,r;return r=t,e=En(),e===null&&(e=Gt(),e===null&&(e=An())),e!==null&&(e=function(l){return S.host=s.substring(t,l).toLowerCase(),S.host}(r)),e===null&&(t=r),e}function En(){var e,r,l,i,c,h;for(i=t,c=t,e=[],h=t,r=vn(),r!==null?(s.charCodeAt(t)===46?(l=".",t++):(l=null,o('"."')),l!==null?r=[r,l]:(r=null,t=h)):(r=null,t=h);r!==null;)e.push(r),h=t,r=vn(),r!==null?(s.charCodeAt(t)===46?(l=".",t++):(l=null,o('"."')),l!==null?r=[r,l]:(r=null,t=h)):(r=null,t=h);return e!==null?(r=Qr(),r!==null?(s.charCodeAt(t)===46?(l=".",t++):(l=null,o('"."')),l=l!==null?l:"",l!==null?e=[e,r,l]:(e=null,t=c)):(e=null,t=c)):(e=null,t=c),e!==null&&(e=function(m){return S.host_type="domain",s.substring(t,m)}(i)),e===null&&(t=i),e}function vn(){var e,r,l,i;if(i=t,e=Q(),e!==null){for(r=[],l=Q(),l===null&&(s.charCodeAt(t)===45?(l="-",t++):(l=null,o('"-"')),l===null&&(s.charCodeAt(t)===95?(l="_",t++):(l=null,o('"_"'))));l!==null;)r.push(l),l=Q(),l===null&&(s.charCodeAt(t)===45?(l="-",t++):(l=null,o('"-"')),l===null&&(s.charCodeAt(t)===95?(l="_",t++):(l=null,o('"_"'))));r!==null?e=[e,r]:(e=null,t=i)}else e=null,t=i;return e}function Qr(){var e,r,l,i;if(i=t,e=C(),e!==null){for(r=[],l=Q(),l===null&&(s.charCodeAt(t)===45?(l="-",t++):(l=null,o('"-"')),l===null&&(s.charCodeAt(t)===95?(l="_",t++):(l=null,o('"_"'))));l!==null;)r.push(l),l=Q(),l===null&&(s.charCodeAt(t)===45?(l="-",t++):(l=null,o('"-"')),l===null&&(s.charCodeAt(t)===95?(l="_",t++):(l=null,o('"_"'))));r!==null?e=[e,r]:(e=null,t=i)}else e=null,t=i;return e}function An(){var e,r,l,i,c;return i=t,c=t,s.charCodeAt(t)===91?(e="[",t++):(e=null,o('"["')),e!==null?(r=bn(),r!==null?(s.charCodeAt(t)===93?(l="]",t++):(l=null,o('"]"')),l!==null?e=[e,r,l]:(e=null,t=c)):(e=null,t=c)):(e=null,t=c),e!==null&&(e=function(h){return S.host_type="IPv6",s.substring(t,h)}(i)),e===null&&(t=i),e}function bn(){var e,r,l,i,c,h,m,v,O,J,de,ot,Ns,Vn,y,W;return Vn=t,y=t,e=G(),e!==null?(s.charCodeAt(t)===58?(r=":",t++):(r=null,o('":"')),r!==null?(l=G(),l!==null?(s.charCodeAt(t)===58?(i=":",t++):(i=null,o('":"')),i!==null?(c=G(),c!==null?(s.charCodeAt(t)===58?(h=":",t++):(h=null,o('":"')),h!==null?(m=G(),m!==null?(s.charCodeAt(t)===58?(v=":",t++):(v=null,o('":"')),v!==null?(O=G(),O!==null?(s.charCodeAt(t)===58?(J=":",t++):(J=null,