PageSourceSearch

https://socialselling.ai/_next/static/chunks/d7f03104.2ead763333892fdb.js

js socialselling.ai collected 2026-10-05 14:50:40 UTC 282,943 bytes, 11 lines download raw bytes

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[65913],{31764:function(e){var t;t=function(){return(()=>{"use strict";var e=[,(e,t,s)=>{s.r(t),s.d(t,{LIBRARY_VERSION:()=>i});let i="0.20.0"},(e,t,s)=>{s.r(t),s.d(t,{ContentTypeUnsupportedError:()=>i.ContentTypeUnsupportedError,RequestPendingError:()=>i.RequestPendingError,SessionDescriptionHandlerError:()=>i.SessionDescriptionHandlerError,SessionTerminatedError:()=>i.SessionTerminatedError,StateTransitionError:()=>i.StateTransitionError,Ack:()=>r.Ack,Bye:()=>n.Bye,EmitterImpl:()=>o.EmitterImpl,Info:()=>a.Info,Invitation:()=>c.Invitation,Inviter:()=>h.Inviter,Message:()=>d.Message,Messager:()=>l.Messager,Notification:()=>g.Notification,PublisherState:()=>u.PublisherState,Publisher:()=>p.Publisher,Referral:()=>f.Referral,RegistererState:()=>m.RegistererState,Registerer:()=>S.Registerer,SessionState:()=>v.SessionState,Session:()=>T.Session,Subscriber:()=>b.Subscriber,SubscriptionState:()=>R.SubscriptionState,Subscription:()=>E.Subscription,TransportState:()=>y.TransportState,SIPExtension:()=>I.SIPExtension,UserAgentRegisteredOptionTags:()=>I.UserAgentRegisteredOptionTags,UserAgentState:()=>w.UserAgentState,UserAgent:()=>C.UserAgent});var i=s(3),r=s(10),n=s(11),o=s(12),a=s(13),c=s(14),h=s(37),d=s(31),l=s(38),g=s(32),u=s(39),p=s(40),f=s(33),m=s(41),S=s(42),v=s(16),T=s(15),b=s(43),R=s(45),E=s(44),y=s(47),I=s(34),w=s(48),C=s(49)},(e,t,s)=>{s.r(t),s.d(t,{ContentTypeUnsupportedError:()=>i.ContentTypeUnsupportedError,RequestPendingError:()=>r.RequestPendingError,SessionDescriptionHandlerError:()=>n.SessionDescriptionHandlerError,SessionTerminatedError:()=>o.SessionTerminatedError,StateTransitionError:()=>a.StateTransitionError});var i=s(4),r=s(6),n=s(7),o=s(8),a=s(9)},(e,t,s)=>{s.r(t),s.d(t,{ContentTypeUnsupportedError:()=>r});var i=s(5);class r extends i.Exception{constructor(e){super(e||"Unsupported content type.")}}},(e,t,s)=>{s.r(t),s.d(t,{Exception:()=>i});class i extends Error{constructor(e){super(e),Object.setPrototypeOf(this,new.target.prototype)}}},(e,t,s)=>{s.r(t),s.d(t,{RequestPendingError:()=>r});var i=s(5);class r extends i.Exception{constructor(e){super(e||"Request pending.")}}},(e,t,s)=>{s.r(t),s.d(t,{SessionDescriptionHandlerError:()=>r});var i=s(5);class r extends i.Exception{constructor(e){super(e||"Unspecified session description handler error.")}}},(e,t,s)=>{s.r(t),s.d(t,{SessionTerminatedError:()=>r});var i=s(5);class r extends i.Exception{constructor(){super("The session has terminated.")}}},(e,t,s)=>{s.r(t),s.d(t,{StateTransitionError:()=>r});var i=s(5);class r extends i.Exception{constructor(e){super(e||"An error occurred during state transition.")}}},(e,t,s)=>{s.r(t),s.d(t,{Ack:()=>i});class i{constructor(e){this.incomingAckRequest=e}get request(){return this.incomingAckRequest.message}}},(e,t,s)=>{s.r(t),s.d(t,{Bye:()=>i});class i{constructor(e){this.incomingByeRequest=e}get request(){return this.incomingByeRequest.message}accept(e){return this.incomingByeRequest.accept(e),Promise.resolve()}reject(e){return this.incomingByeRequest.reject(e),Promise.resolve()}}},(e,t,s)=>{s.r(t),s.d(t,{EmitterImpl:()=>i});class i{constructor(){this.listeners=[]}addListener(e,t){let s=t=>{this.removeListener(s),e(t)};(null==t?void 0:t.once)===!0?this.listeners.push(s):this.listeners.push(e)}emit(e){this.listeners.slice().forEach(t=>t(e))}removeAllListeners(){this.listeners=[]}removeListener(e){this.listeners=this.listeners.filter(t=>t!==e)}on(e){return this.addListener(e)}off(e){return this.removeListener(e)}once(e){return this.addListener(e,{once:!0})}}},(e,t,s)=>{s.r(t),s.d(t,{Info:()=>i});class i{constructor(e){this.incomingInfoRequest=e}get request(){return this.incomingInfoRequest.message}accept(e){return this.incomingInfoRequest.accept(e),Promise.resolve()}reject(e){return this.incomingInfoRequest.reject(e),Promise.resolve()}}},(e,t,s)=>{s.r(t),s.d(t,{Invitation:()=>f});var i=s(21),r=s(17),n=s(30),o=s(35),a=s(36),c=s(20),h=s(4),d=s(7),l=s(8),g=s(15),u=s(16),p=s(34);class f extends g.Session{constructor(e,t){super(e),this.incomingInviteRequest=t,this.disposed=!1,this.expiresTimer=void 0,this.isCanceled=!1,this.rel100="none",this.rseq=Math.floor(1e4*Math.random()),this.userNoAnswerTimer=void 0,this.waitingForPrack=!1,this.logger=e.getLogger("sip.Invitation");let s=this.incomingInviteRequest.message,r=s.getHeader("require");r&&r.toLowerCase().includes("100rel")&&(this.rel100="required");let n=s.getHeader("supported");if(n&&n.toLowerCase().includes("100rel")&&(this.rel100="supported"),s.toTag=t.toTag,"string"!=typeof s.toTag)throw TypeError("toTag should have been a string.");if(this.userNoAnswerTimer=setTimeout(()=>{t.reject({statusCode:480}),this.stateTransition(u.SessionState.Terminated)},this.userAgent.configuration.noAnswerTimeout?1e3*this.userAgent.configuration.noAnswerTimeout:6e4),s.hasHeader("expires")){let e=1e3*Number(s.getHeader("expires")||0);this.expiresTimer=setTimeout(()=>{this.state===u.SessionState.Initial&&(t.reject({statusCode:487}),this.stateTransition(u.SessionState.Terminated))},e)}let o=this.request.getHeader("P-Asserted-Identity");o&&(this._assertedIdentity=i.Grammar.nameAddrHeaderParse(o)),this._contact=this.userAgent.contact.toString();let a=s.parseHeader("Content-Disposition");a&&"render"===a.type&&(this._renderbody=s.body,this._rendertype=s.getHeader("Content-Type")),this._id=s.callId+s.fromTag,this.userAgent._sessions[this._id]=this}dispose(){if(this.disposed)return Promise.resolve();switch(this.disposed=!0,this.expiresTimer&&(clearTimeout(this.expiresTimer),this.expiresTimer=void 0),this.userNoAnswerTimer&&(clearTimeout(this.userNoAnswerTimer),this.userNoAnswerTimer=void 0),this.prackNeverArrived(),this.state){case u.SessionState.Initial:case u.SessionState.Establishing:return this.reject().then(()=>super.dispose());case u.SessionState.Established:case u.SessionState.Terminating:case u.SessionState.Terminated:return super.dispose();default:throw Error("Unknown state.")}}get autoSendAnInitialProvisionalResponse(){return"required"!==this.rel100&&this.userAgent.configuration.sendInitialProvisionalResponse}get body(){return this.incomingInviteRequest.message.body}get localIdentity(){return this.request.to}get remoteIdentity(){return this.request.from}get request(){return this.incomingInviteRequest.message}accept(e={}){if(this.logger.log("Invitation.accept"),this.state!==u.SessionState.Initial){let e=Error(`Invalid session state ${this.state}`);return this.logger.error(e.message),Promise.reject(e)}return e.sessionDescriptionHandlerModifiers&&(this.sessionDescriptionHandlerModifiers=e.sessionDescriptionHandlerModifiers),e.sessionDescriptionHandlerOptions&&(this.sessionDescriptionHandlerOptions=e.sessionDescriptionHandlerOptions),this.stateTransition(u.SessionState.Establishing),this.sendAccept(e).then(({message:e,session:t})=>{t.delegate={onAck:e=>this.onAckRequest(e),onAckTimeout:()=>this.onAckTimeout(),onBye:e=>
1this.onByeRequest(e),onInfo:e=>this.onInfoRequest(e),onInvite:e=>this.onInviteRequest(e),onMessage:e=>this.onMessageRequest(e),onNotify:e=>this.onNotifyRequest(e),onPrack:e=>this.onPrackRequest(e),onRefer:e=>this.onReferRequest(e)},this._dialog=t,this.stateTransition(u.SessionState.Established),this._replacee&&this._replacee._bye()}).catch(e=>this.handleResponseError(e))}progress(e={}){if(this.logger.log("Invitation.progress"),this.state!==u.SessionState.Initial){let e=Error(`Invalid session state ${this.state}`);return this.logger.error(e.message),Promise.reject(e)}let t=e.statusCode||180;if(t<100||t>199)throw TypeError("Invalid statusCode: "+t);return(e.sessionDescriptionHandlerModifiers&&(this.sessionDescriptionHandlerModifiers=e.sessionDescriptionHandlerModifiers),e.sessionDescriptionHandlerOptions&&(this.sessionDescriptionHandlerOptions=e.sessionDescriptionHandlerOptions),this.waitingForPrack)?(this.logger.warn("Unexpected call for progress while waiting for prack, ignoring"),Promise.resolve()):100===e.statusCode?this.sendProgressTrying().then(()=>{}).catch(e=>this.handleResponseError(e)):"required"===this.rel100||"supported"===this.rel100&&e.rel100||"supported"===this.rel100&&this.userAgent.configuration.sipExtension100rel===p.SIPExtension.Required?this.sendProgressReliableWaitForPrack(e).then(()=>{}).catch(e=>this.handleResponseError(e)):this.sendProgress(e).then(()=>{}).catch(e=>this.handleResponseError(e))}reject(e={}){if(this.logger.log("Invitation.reject"),this.state!==u.SessionState.Initial&&this.state!==u.SessionState.Establishing){let e=Error(`Invalid session state ${this.state}`);return this.logger.error(e.message),Promise.reject(e)}let t=e.statusCode||480,s=e.reasonPhrase?e.reasonPhrase:(0,c.getReasonPhrase)(t),i=e.extraHeaders||[];if(t<300||t>699)throw TypeError("Invalid statusCode: "+t);let n=e.body?(0,r.fromBodyLegacy)(e.body):void 0;return t<400?this.incomingInviteRequest.redirect([],{statusCode:t,reasonPhrase:s,extraHeaders:i,body:n}):this.incomingInviteRequest.reject({statusCode:t,reasonPhrase:s,extraHeaders:i,body:n}),this.stateTransition(u.SessionState.Terminated),Promise.resolve()}_onCancel(e){if(this.logger.log("Invitation._onCancel"),this.state!==u.SessionState.Initial&&this.state!==u.SessionState.Establishing){this.logger.error(`CANCEL received while in state ${this.state}, dropping request`);return}this.isCanceled=!0,this.incomingInviteRequest.reject({statusCode:487}),this.stateTransition(u.SessionState.Terminated)}handlePrackOfferAnswer(e){if(!this.dialog)throw Error("Dialog undefined.");let t=(0,r.getBody)(e.message);if(!t||"session"!==t.contentDisposition)return Promise.resolve(void 0);let s={sessionDescriptionHandlerOptions:this.sessionDescriptionHandlerOptions,sessionDescriptionHandlerModifiers:this.sessionDescriptionHandlerModifiers};switch(this.dialog.signalingState){case n.SignalingState.Initial:throw Error(`Invalid signaling state ${this.dialog.signalingState}.`);case n.SignalingState.Stable:return this.setAnswer(t,s).then(()=>void 0);case n.SignalingState.HaveLocalOffer:throw Error(`Invalid signaling state ${this.dialog.signalingState}.`);case n.SignalingState.HaveRemoteOffer:return this.setOfferAndGetAnswer(t,s);case n.SignalingState.Closed:default:throw Error(`Invalid signaling state ${this.dialog.signalingState}.`)}}handleResponseError(e){let t=480;if(e instanceof Error?this.logger.error(e.message):this.logger.error(e),e instanceof h.ContentTypeUnsupportedError?(this.logger.error("A session description handler occurred while sending response (content type unsupported"),t=415):e instanceof d.SessionDescriptionHandlerError?this.logger.error("A session description handler occurred while sending response"):e instanceof l.SessionTerminatedError?this.logger.error("Session ended before response could be formulated and sent (while waiting for PRACK)"):e instanceof o.TransactionStateError&&this.logger.error("Session changed state before response could be formulated and sent"),this.state===u.SessionState.Initial||this.state===u.SessionState.Establishing)try{this.incomingInviteRequest.reject({statusCode:t}),this.stateTransition(u.SessionState.Terminated)}catch(e){throw this.logger.error("An error occurred attempting to reject the request while handling another error"),e}if(this.isCanceled){this.logger.warn("An error occurred while attempting to formulate and send a response to an incoming INVITE. However a CANCEL was received and processed while doing so which can (and often does) result in errors occurring as the session terminates in the meantime. Said error is being ignored.");return}throw e}onAckTimeout(){if(this.logger.log("Invitation.onAckTimeout"),!this.dialog)throw Error("Dialog undefined.");this.logger.log("No ACK received for an extended period of time, terminating session"),this.dialog.bye(),this.stateTransition(u.SessionState.Terminated)}sendAccept(e={}){let t={sessionDescriptionHandlerOptions:this.sessionDescriptionHandlerOptions,sessionDescriptionHandlerModifiers:this.sessionDescriptionHandlerModifiers},s=e.extraHeaders||[];return this.waitingForPrack?this.waitForArrivalOfPrack().then(()=>clearTimeout(this.userNoAnswerTimer)).then(()=>this.generateResponseOfferAnswer(this.incomingInviteRequest,t)).then(e=>this.incomingInviteRequest.accept({statusCode:200,body:e,extraHeaders:s})):(clearTimeout(this.userNoAnswerTimer),this.generateResponseOfferAnswer(this.incomingInviteRequest,t).then(e=>this.incomingInviteRequest.accept({statusCode:200,body:e,extraHeaders:s})))}sendProgress(e={}){let t=e.statusCode||180,s=e.reasonPhrase,i=(e.extraHeaders||[]).slice(),n=e.body?(0,r.fromBodyLegacy)(e.body):void 0;if(183===t&&!n)return this.sendProgressWithSDP(e);try{let e=this.incomingInviteRequest.progress({statusCode:t,reasonPhrase:s,extraHeaders:i,body:n});return this._dialog=e.session,Promise.resolve(e)}catch(e){return Promise.reject(e)}}sendProgressWithSDP(e={}){let t={sessionDescriptionHandlerOptions:this.sessionDescriptionHandlerOptions,sessionDescriptionHandlerModifiers:this.sessionDescriptionHandlerModifiers},s=e.statusCode||183,i=e.reasonPhrase,r=(e.extraHeaders||[]).slice();return this.generateResponseOfferAnswer(this.incomingInviteRequest,t).then(e=>this.incomingInviteRequest.progress({statusCode:s,reasonPhrase:i,extraHeaders:r,body:e})).then(e=>(this._dialog=e.session,e))}sendProgressReliable(e={}){return e.extraHeaders=(e.extraHeaders||[]).slice(),e.extraHeaders.push("Require: 100rel"),e.extraHeaders.push("RSeq: "+Math.floor(1e4*Math.random())),this.sendProgressWithSDP(e)}sendProgressReliableWaitForPrack(e={}){let t;let s={sessionDescriptionHandlerOptions:this.sessionDescriptionHandlerOptions,sessionDescriptionHandlerModifiers:this.sessionDescriptionHandlerModifiers},i=e.statusCode||183,r=e.reasonPhrase,n=(e.extraHeaders||[]).slice();return n.push("Require: 100rel"),n.push("RSeq: "+this.rseq++),new Promise((e,o)=>{this.waitingForPrack=!0,this.generateResponseOfferAnswer(this.incomingInviteRequest,s).then(e=>(t=e,this.incomingInviteRequest.progress({statusCode:i,reasonPhrase:r,extraHeaders:n,body:t}))).then(s=>{let c,h;this._dialog=s.session,s.session.delegate={onPrack:t=>{c=t,clearTimeout(d),clearTimeout(p),this.waitingForPrack&&(this.waitingForPrack=!1,this.handlePrackOfferAnswer(c).then(t=>{try{h=c.accept({statusCode:200,body:t}),this.prackArrived(),e({prackRequest:c,prackResponse:h,progressResponse:s})}catch(e){o(e)}}).catch(e=>o(e)))}};let d=setTimeout(()=>{this.waitingForPrack&&(this.waitingForPrack=!1,this.logger.warn("No PRACK received, rejecting INVITE."),clearTimeout(p),this.reject({statusCode:504}).then(()=>o(new l.SessionTerminatedError)).catch(e=>o(e)))},64*a.Timers.T1),g=()=>{try{this.incomingInviteRequest.progress({statusCode:i,reasonPhrase:r,extraHeaders:n,body:t})}catch(e){this.waitingForPrack=!1,o(e);return}p=setTimeout(g,u*=2)},u=a.Timers.T1,p=setTimeout(g,u)}).catch(e=>{this.waitingForPrack=!1,o(e)})})}sendProgressTrying(){try{let e=this.incomingInviteRequest.trying();return Promise.resolve(e)}catch(e){return Promise.reject(e)}}waitForArrivalOfPrack(){if(this.waitingForPrackPromise)throw Error("Already waiting for PRACK");return this.waitingForPrackPromise=new Promise((e,t)=>
1{this.waitingForPrackResolve=e,this.waitingForPrackReject=t}),this.waitingForPrackPromise}prackArrived(){this.waitingForPrackResolve&&this.waitingForPrackResolve(),this.waitingForPrackPromise=void 0,this.waitingForPrackResolve=void 0,this.waitingForPrackReject=void 0}prackNeverArrived(){this.waitingForPrackReject&&this.waitingForPrackReject(new l.SessionTerminatedError),this.waitingForPrackPromise=void 0,this.waitingForPrackResolve=void 0,this.waitingForPrackReject=void 0}}},(e,t,s)=>{s.r(t),s.d(t,{Session:()=>T});var i=s(17),r=s(30),n=s(21),o=s(23),a=s(20),c=s(28),h=s(10),d=s(11),l=s(12),g=s(6),u=s(4),p=s(13),f=s(31),m=s(32),S=s(33),v=s(16);class T{constructor(e,t={}){this.pendingReinvite=!1,this.pendingReinviteAck=!1,this._state=v.SessionState.Initial,this.delegate=t.delegate,this._stateEventEmitter=new l.EmitterImpl,this._userAgent=e}dispose(){switch(this.logger.log(`Session ${this.id} in state ${this._state} is being disposed`),delete this.userAgent._sessions[this.id],this._sessionDescriptionHandler&&this._sessionDescriptionHandler.close(),this.state){case v.SessionState.Initial:case v.SessionState.Establishing:break;case v.SessionState.Established:return new Promise(e=>{this._bye({onAccept:()=>e(),onRedirect:()=>e(),onReject:()=>e()})});case v.SessionState.Terminating:case v.SessionState.Terminated:break;default:throw Error("Unknown state.")}return Promise.resolve()}get assertedIdentity(){return this._assertedIdentity}get dialog(){return this._dialog}get id(){return this._id}get replacee(){return this._replacee}get sessionDescriptionHandler(){return this._sessionDescriptionHandler}get sessionDescriptionHandlerFactory(){return this.userAgent.configuration.sessionDescriptionHandlerFactory}get sessionDescriptionHandlerModifiers(){return this._sessionDescriptionHandlerModifiers||[]}set sessionDescriptionHandlerModifiers(e){this._sessionDescriptionHandlerModifiers=e.slice()}get sessionDescriptionHandlerOptions(){return this._sessionDescriptionHandlerOptions||{}}set sessionDescriptionHandlerOptions(e){this._sessionDescriptionHandlerOptions=Object.assign({},e)}get sessionDescriptionHandlerModifiersReInvite(){return this._sessionDescriptionHandlerModifiersReInvite||[]}set sessionDescriptionHandlerModifiersReInvite(e){this._sessionDescriptionHandlerModifiersReInvite=e.slice()}get sessionDescriptionHandlerOptionsReInvite(){return this._sessionDescriptionHandlerOptionsReInvite||{}}set sessionDescriptionHandlerOptionsReInvite(e){this._sessionDescriptionHandlerOptionsReInvite=Object.assign({},e)}get state(){return this._state}get stateChange(){return this._stateEventEmitter}get userAgent(){return this._userAgent}bye(e={}){let t="Session.bye() may only be called if established session.";switch(this.state){case v.SessionState.Initial:"function"==typeof this.cancel?t+=" However Inviter.invite() has not yet been called. Perhaps you should have called Inviter.cancel()?":"function"==typeof this.reject&&(t+=" However Invitation.accept() has not yet been called. Perhaps you should have called Invitation.reject()?");break;case v.SessionState.Establishing:"function"==typeof this.cancel?t+=" However a dialog does not yet exist. Perhaps you should have called Inviter.cancel()?":"function"==typeof this.reject&&(t+=" However Invitation.accept() has not yet been called (or not yet resolved). Perhaps you should have called Invitation.reject()?");break;case v.SessionState.Established:{let t=e.requestDelegate,s=this.copyRequestOptions(e.requestOptions);return this._bye(t,s)}case v.SessionState.Terminating:t+=" However this session is already terminating.","function"==typeof this.cancel?t+=" Perhaps you have already called Inviter.cancel()?":"function"==typeof this.reject&&(t+=" Perhaps you have already called Session.bye()?");break;case v.SessionState.Terminated:t+=" However this session is already terminated.";break;default:throw Error("Unknown state")}return this.logger.error(t),Promise.reject(Error(`Invalid session state ${this.state}`))}info(e={}){if(this.state!==v.SessionState.Established)return this.logger.error("Session.info() may only be called if established session."),Promise.reject(Error(`Invalid session state ${this.state}`));let t=e.requestDelegate,s=this.copyRequestOptions(e.requestOptions);return this._info(t,s)}invite(e={}){if(this.logger.log("Session.invite"),this.state!==v.SessionState.Established)return Promise.reject(Error(`Invalid session state ${this.state}`));if(this.pendingReinvite)return Promise.reject(new g.RequestPendingError("Reinvite in progress. Please wait until complete, then try again."));this.pendingReinvite=!0,e.sessionDescriptionHandlerModifiers&&(this.sessionDescriptionHandlerModifiersReInvite=e.sessionDescriptionHandlerModifiers),e.sessionDescriptionHandlerOptions&&(this.sessionDescriptionHandlerOptionsReInvite=e.sessionDescriptionHandlerOptions);let t={onAccept:t=>{let s=(0,i.getBody)(t.message);if(!s){this.logger.error("Received 2xx response to re-INVITE without a session description"),this.ackAndBye(t,400,"Missing session description"),this.stateTransition(v.SessionState.Terminated),this.pendingReinvite=!1;return}if(e.withoutSdp){let i={sessionDescriptionHandlerOptions:this.sessionDescriptionHandlerOptionsReInvite,sessionDescriptionHandlerModifiers:this.sessionDescriptionHandlerModifiersReInvite};this.setOfferAndGetAnswer(s,i).then(e=>{t.ack({body:e})}).catch(e=>{this.logger.error("Failed to handle offer in 2xx response to re-INVITE"),this.logger.error(e.message),this.state===v.SessionState.Terminated?t.ack():(this.ackAndBye(t,488,"Bad Media Description"),this.stateTransition(v.SessionState.Terminated))}).then(()=>{this.pendingReinvite=!1,e.requestDelegate&&e.requestDelegate.onAccept&&e.requestDelegate.onAccept(t)}
1)}else{let i={sessionDescriptionHandlerOptions:this.sessionDescriptionHandlerOptionsReInvite,sessionDescriptionHandlerModifiers:this.sessionDescriptionHandlerModifiersReInvite};this.setAnswer(s,i).then(()=>{t.ack()}).catch(e=>{this.logger.error("Failed to handle answer in 2xx response to re-INVITE"),this.logger.error(e.message),this.state!==v.SessionState.Terminated?(this.ackAndBye(t,488,"Bad Media Description"),this.stateTransition(v.SessionState.Terminated)):t.ack()}).then(()=>{this.pendingReinvite=!1,e.requestDelegate&&e.requestDelegate.onAccept&&e.requestDelegate.onAccept(t)})}},onProgress:e=>{},onRedirect:e=>{},onReject:t=>{this.logger.warn("Received a non-2xx response to re-INVITE"),this.pendingReinvite=!1,e.withoutSdp?e.requestDelegate&&e.requestDelegate.onReject&&e.requestDelegate.onReject(t):this.rollbackOffer().catch(e=>{if(this.logger.error("Failed to rollback offer on non-2xx response to re-INVITE"),this.logger.error(e.message),this.state!==v.SessionState.Terminated){if(!this.dialog)throw Error("Dialog undefined.");let e=[];e.push("Reason: "+this.getReasonHeaderValue(500,"Internal Server Error")),this.dialog.bye(void 0,{extraHeaders:e}),this.stateTransition(v.SessionState.Terminated)}}).then(()=>{e.requestDelegate&&e.requestDelegate.onReject&&e.requestDelegate.onReject(t)})},onTrying:e=>{}},s=e.requestOptions||{};if(s.extraHeaders=(s.extraHeaders||[]).slice(),s.extraHeaders.push("Allow: "+c.AllowedMethods.toString()),s.extraHeaders.push("Contact: "+this._contact),e.withoutSdp){if(!this.dialog)throw this.pendingReinvite=!1,Error("Dialog undefined.");return Promise.resolve(this.dialog.invite(t,s))}let r={sessionDescriptionHandlerOptions:this.sessionDescriptionHandlerOptionsReInvite,sessionDescriptionHandlerModifiers:this.sessionDescriptionHandlerModifiersReInvite};return this.getOffer(r).then(e=>{if(!this.dialog)throw this.pendingReinvite=!1,Error("Dialog undefined.");return s.body=e,this.dialog.invite(t,s)}).catch(e=>{throw this.logger.error(e.message),this.logger.error("Failed to send re-INVITE"),this.pendingReinvite=!1,e})}message(e={}){if(this.state!==v.SessionState.Established)return this.logger.error("Session.message() may only be called if established session."),Promise.reject(Error(`Invalid session state ${this.state}`));let t=e.requestDelegate,s=this.copyRequestOptions(e.requestOptions);return this._message(t,s)}refer(e,t={}){if(this.state!==v.SessionState.Established)return this.logger.error("Session.refer() may only be called if established session."),Promise.reject(Error(`Invalid session state ${this.state}`));let s=t.requestDelegate,i=this.copyRequestOptions(t.requestOptions);return i.extraHeaders=i.extraHeaders?i.extraHeaders.concat(this.referExtraHeaders(this.referToString(e))):this.referExtraHeaders(this.referToString(e)),this._refer(t.onNotify,s,i)}_bye(e,t){if(!this.dialog)return Promise.reject(Error("Session dialog undefined."));let s=this.dialog;switch(s.sessionState){case r.SessionState.Initial:case r.SessionState.Early:throw Error(`Invalid dialog state ${s.sessionState}`);case r.SessionState.AckWait:return this.stateTransition(v.SessionState.Terminating),new Promise(i=>{s.delegate={onAck:()=>{let r=s.bye(e,t);return this.stateTransition(v.SessionState.Terminated),i(r),Promise.resolve()},onAckTimeout:()=>{let r=s.bye(e,t);this.stateTransition(v.SessionState.Terminated),i(r)}}});case r.SessionState.Confirmed:{let i=s.bye(e,t);return this.stateTransition(v.SessionState.Terminated),Promise.resolve(i)}case r.SessionState.Terminated:throw Error(`Invalid dialog state ${s.sessionState}`);default:throw Error("Unrecognized state.")}}_info(e,t){return this.dialog?Promise.resolve(this.dialog.info(e,t)):Promise.reject(Error("Session dialog undefined."))}_message(e,t){return this.dialog?Promise.resolve(this.dialog.message(e,t)):Promise.reject(Error("Session dialog undefined."))}_refer(e,t,s){return this.dialog?(this.onNotify=e,Promise.resolve(this.dialog.refer(t,s))):Promise.reject(Error("Session dialog undefined."))}ackAndBye(e,t,s){e.ack();let i=[];t&&i.push("Reason: "+this.getReasonHeaderValue(t,s)),e.session.bye(void 0,{extraHeaders:i})}onAckRequest(e){if(this.logger.log("Session.onAckRequest"),this.state!==v.SessionState.Established&&this.state!==v.SessionState.Terminating)return this.logger.error(`ACK received while in state ${this.state}, dropping request`),Promise.resolve();let t=this.dialog;if(!t)throw Error("Dialog undefined.");let s={sessionDescriptionHandlerOptions:this.pendingReinviteAck?this.sessionDescriptionHandlerOptionsReInvite:this.sessionDescriptionHandlerOptions,sessionDescriptionHandlerModifiers:this.pendingReinviteAck?this._sessionDescriptionHandlerModifiersReInvite:this._sessionDescriptionHandlerModifiers};if(this.delegate&&this.delegate.onAck){let t=new h.Ack(e);this.delegate.onAck(t)}switch(this.pendingReinviteAck=!1,t.signalingState){case r.SignalingState.Initial:{this.logger.error(`Invalid signaling state ${t.signalingState}.`);let e=["Reason: "+this.getReasonHeaderValue(488,"Bad Media Description")];return t.bye(void 0,{extraHeaders:e}),this.stateTransition(v.SessionState.Terminated),Promise.resolve()}case r.SignalingState.Stable:{let r=(0,i.getBody)(e.message);if(!r)return Promise.resolve();if("render"===r.contentDisposition)return this._renderbody=r.content,this._rendertype=r.contentType,Promise.resolve();if("session"!==r.contentDisposition)return Promise.resolve();return this.setAnswer(r,s).catch(e=>{this.logger.error(e.message);let s=["Reason: "+this.getReasonHeaderValue(488,"Bad Media Description")];t.bye(void 0,{extraHeaders:s}),this.stateTransition(v.SessionState.Terminated)})}case r.SignalingState.HaveLocalOffer:{this.logger.error(`Invalid signaling state ${t.signalingState}.`);let e=["Reason: "+this.getReasonHeaderValue(488,"Bad Media Description")];return t.bye(void 0,{extraHeaders:e}),this.stateTransition(v.SessionState.Terminated),Promise.resolve()}case r.SignalingState.HaveRemoteOffer:{this.logger.error(`Invalid signaling state ${t.signalingState}.`);let e=["Reason: "+this.getReasonHeaderValue(488,"Bad Media Description")];return t.bye(void 0,{extraHeaders:e}),this.stateTransition(v.SessionState.Terminated),Promise.resolve()}case r.SignalingState.Closed:default:throw Error(`Invalid signaling state ${t.signalingState}.`)}}
1onByeRequest(e){if(this.logger.log("Session.onByeRequest"),this.state!==v.SessionState.Established){this.logger.error(`BYE received while in state ${this.state}, dropping request`);return}if(this.delegate&&this.delegate.onBye){let t=new d.Bye(e);this.delegate.onBye(t)}else e.accept();this.stateTransition(v.SessionState.Terminated)}onInfoRequest(e){if(this.logger.log("Session.onInfoRequest"),this.state!==v.SessionState.Established){this.logger.error(`INFO received while in state ${this.state}, dropping request`);return}if(this.delegate&&this.delegate.onInfo){let t=new p.Info(e);this.delegate.onInfo(t)}else e.accept()}onInviteRequest(e){if(this.logger.log("Session.onInviteRequest"),this.state!==v.SessionState.Established){this.logger.error(`INVITE received while in state ${this.state}, dropping request`);return}this.pendingReinviteAck=!0;let t=["Contact: "+this._contact];if(e.message.hasHeader("P-Asserted-Identity")){let t=e.message.getHeader("P-Asserted-Identity");if(!t)throw Error("Header undefined.");this._assertedIdentity=n.Grammar.nameAddrHeaderParse(t)}let s={sessionDescriptionHandlerOptions:this.sessionDescriptionHandlerOptionsReInvite,sessionDescriptionHandlerModifiers:this.sessionDescriptionHandlerModifiersReInvite};this.generateResponseOfferAnswerInDialog(s).then(s=>{let i=e.accept({statusCode:200,extraHeaders:t,body:s});this.delegate&&this.delegate.onInvite&&this.delegate.onInvite(e.message,i.message,200)}).catch(s=>{if(this.logger.error(s.message),this.logger.error("Failed to handle to re-INVITE request"),!this.dialog)throw Error("Dialog undefined.");if(this.logger.error(this.dialog.signalingState),this.dialog.signalingState===r.SignalingState.Stable){let t=e.reject({statusCode:488});this.delegate&&this.delegate.onInvite&&this.delegate.onInvite(e.message,t.message,488);return}this.rollbackOffer().then(()=>{let t=e.reject({statusCode:488});this.delegate&&this.delegate.onInvite&&this.delegate.onInvite(e.message,t.message,488)}).catch(s=>{this.logger.error(s.message),this.logger.error("Failed to rollback offer on re-INVITE request");let i=e.reject({statusCode:488});if(this.state!==v.SessionState.Terminated){if(!this.dialog)throw Error("Dialog undefined.");[].push("Reason: "+this.getReasonHeaderValue(500,"Internal Server Error")),this.dialog.bye(void 0,{extraHeaders:t}),this.stateTransition(v.SessionState.Terminated)}this.delegate&&this.delegate.onInvite&&this.delegate.onInvite(e.message,i.message,488)})})}onMessageRequest(e){if(this.logger.log("Session.onMessageRequest"),this.state!==v.SessionState.Established){this.logger.error(`MESSAGE received while in state ${this.state}, dropping request`);return}if(this.delegate&&this.delegate.onMessage){let t=new f.Message(e);this.delegate.onMessage(t)}else e.accept()}onNotifyRequest(e){if(this.logger.log("Session.onNotifyRequest"),this.state!==v.SessionState.Established){this.logger.error(`NOTIFY received while in state ${this.state}, dropping request`);return}if(this.onNotify){let t=new m.Notification(e);this.onNotify(t);return}if(this.delegate&&this.delegate.onNotify){let t=new m.Notification(e);this.delegate.onNotify(t)}else e.accept()}onPrackRequest(e){if(this.logger.log("Session.onPrackRequest"),this.state!==v.SessionState.Established){this.logger.error(`PRACK received while in state ${this.state}, dropping request`);return}throw Error("Unimplemented.")}onReferRequest(e){if(this.logger.log("Session.onReferRequest"),this.state!==v.SessionState.Established){this.logger.error(`REFER received while in state ${this.state}, dropping request`);return}if(!e.message.hasHeader("refer-to")){this.logger.warn("Invalid REFER packet. A refer-to header is required. Rejecting."),e.reject();return}let t=new S.Referral(e,this);this.delegate&&this.delegate.onRefer?this.delegate.onRefer(t):(this.logger.log("No delegate available to handle REFER, automatically accepting and following."),t.accept().then(()=>t.makeInviter(this._referralInviterOptions).invite()).catch(e=>{this.logger.error(e.message)}))}generateResponseOfferAnswer(e,t){if(this.dialog)return this.generateResponseOfferAnswerInDialog(t);let s=(0,i.getBody)(e.message);return s&&"session"===s.contentDisposition?this.setOfferAndGetAnswer(s,t):this.getOffer(t)}generateResponseOfferAnswerInDialog(e){if(!this.dialog)throw Error("Dialog undefined.");switch(this.dialog.signalingState){case r.SignalingState.Initial:return this.getOffer(e);case r.SignalingState.HaveLocalOffer:return Promise.resolve(void 0);case r.SignalingState.HaveRemoteOffer:if(!this.dialog.offer)throw Error(`Session offer undefined in signaling state ${this.dialog.signalingState}.`);return this.setOfferAndGetAnswer(this.dialog.offer,e);case r.SignalingState.Stable:if(this.state!==v.SessionState.Established)return Promise.resolve(void 0);return this.getOffer(e);case r.SignalingState.Closed:default:throw Error(`Invalid signaling state ${this.dialog.signalingState}.`)}}getOffer(e){let t=this.setupSessionDescriptionHandler(),s=e.sessionDescriptionHandlerOptions,r=e.sessionDescriptionHandlerModifiers;try{return t.getDescription(s,r).then(e=>(0,i.fromBodyLegacy)(e)).catch(e=>{this.logger.error("Session.getOffer: SDH getDescription rejected...");let t=e instanceof Error?e:Error("Session.getOffer unknown error.");throw this.logger.error(t.message),t})}catch(t){this.logger.error("Session.getOffer: SDH getDescription threw...");let e=t instanceof Error?t:Error(t);return this.logger.error(e.message),Promise.reject(e)}}rollbackOffer(){let e=this.setupSessionDescriptionHandler();if(void 0===e.rollbackDescription)return Promise.resolve();try{return e.rollbackDescription().catch(e=>{this.logger.error("Session.rollbackOffer: SDH rollbackDescription rejected...");let t=e instanceof Error?e:Error("Session.rollbackOffer unknown error.");throw this.logger.error(t.message),t})}catch(t){this.logger.error("Session.rollbackOffer: SDH rollbackDescription threw...");let e=t instanceof Error?t:Error(t);return this.logger.error(e.message),Promise.reject(e)}}setAnswer(e,t){let s=this.setupSessionDescriptionHandler(),i=t.sessionDescriptionHandlerOptions,r=t.sessionDescriptionHandlerModifiers;try{if(!s.hasDescription(e.contentType))return Promise.reject(new u.ContentTypeUnsupportedError)}catch(t){this.logger.error("Session.setAnswer: SDH hasDescription threw...");let e=t instanceof Error?t:Error(t);return this.logger.error(e.message),Promise.reject(e)}try{return s.setDescription(e.content,i,r).catch(e=>{this.logger.error("Session.setAnswer: SDH setDescription rejected...");let t=e instanceof Error?e:Error("Session.setAnswer unknown error.");throw this.logger.error(t.message),t})}catch(t){this.logger.error("Session.setAnswer: SDH setDescription threw...");let e=t instanceof Error?t:Error(t);return this.logger.error(e.message),Promise.reject(e)}}setOfferAndGetAnswer(e,t){let s=this.setupSessionDescriptionHandler(),r=t.sessionDescriptionHandlerOptions,n=t.sessionDescriptionHandlerModifiers;try{if(!s.hasDescription(e.contentType))return Promise.reject(new u.ContentTypeUnsupportedError)}catch(t){this.logger.error("Session.setOfferAndGetAnswer: SDH hasDescription threw...");let e=t instanceof Error?t:Error(t);return this.logger.error(e.message),Promise.reject(e)}try{return s.setDescription(e.content,r,n).then(()=>s.getDescription(r,n)).then(e=>(0,i.fromBodyLegacy)(e)).catch(e=>{this.logger.error("Session.setOfferAndGetAnswer: SDH setDescription or getDescription rejected...");let t=e instanceof Error?e:Error("Session.setOfferAndGetAnswer unknown error.");throw this.logger.error(t.message),t})}catch(t){this.logger.error("Session.setOfferAndGetAnswer: SDH setDescription or getDescription threw...");let e=t instanceof Error?t:Error(t);return this.logger.error(e.message),Promise.reject(e)}}setSessionDescriptionHandler(e){if(this._sessionDescriptionHandler)throw Error("Session description handler defined.");this._sessionDescriptionHandler=e}setupSessionDescriptionHandler(){var e;return this._sessionDescriptionHandler||(this._sessionDescriptionHandler=this.sessionDescriptionHandlerFactory(this,this.userAgent.configuration.sessionDescriptionHandlerFactoryOptions),(null===(e=this.delegate)||void 0===e?void 0:e.onSessionDescriptionHandler)&&this.delegate.onSessionDescriptionHandler(this._sessionDescriptionHandler,!1)),this._sessionDescriptionHandler}stateTransition(e){let t=()=>{throw Error(`Invalid state transition from ${this._state} to ${e}`)};switch(this._state){case v.SessionState.Initial:e!==v.SessionState.Establishing&&e!==v.SessionState.Established&&e!==v.SessionState.Terminating&&e!==v.SessionState.Terminated&&t();break;case v.SessionState.Establishing:e!==v.SessionState.Established&&e!==v.SessionState.Terminating&&e!==v.SessionState.Terminated&&t();break;case v.SessionState.Established:e!==v.SessionState.Terminating&&e!==v.SessionState.Terminated&&t();break;case v.SessionState.Terminating:e!==v.SessionState.Terminated&&t();break;case v.SessionState.Terminated:t();break;default:throw Error("Unrecognized state.")}this._state=e,this.logger.log(`Session ${this.id} transitioned to state ${this._state}`),this._stateEventEmitter.emit(this._state),e===v.SessionState.Terminated&&this.dispose()}copyRequestOptions(e={}){return{extraHeaders:e.extraHeaders?e.extraHeaders.slice():void 0,body:e.body?{contentDisposition:e.body.contentDisposition||"render",contentType:e.body.contentType||"text/plain",content:e.body.content||""}:void 0}}getReasonHeaderValue(e,t){let s=(0,a.getReasonPhrase)(e);return!s&&t&&(s=t),"SIP;cause="+e+';text="'+s+'"'}referExtraHeaders(e){let t=[];return t.push("Referred-By: <"+this.userAgent.configuration.uri+">"),t.push("Contact: "+this._contact),t.push("Allow: "+["ACK","CANCEL","INVITE","MESSAGE","BYE","OPTIONS","INFO","NOTIFY","REFER"].toString()),t.push("Refer-To: "+e),t}referToString(e){let t;if(e instanceof o.URI)t=e.toString();else{if(!e.dialog)throw Error("Dialog undefined.");let s=e.remoteIdentity.friendlyName,i=e.dialog.remoteTarget.toString(),r=e.dialog.callId,n=e.dialog.remoteTag,o=e.dialog.localTag,a=encodeURIComponent(`${r};to-tag=${n};from-tag=${o}`);t=`"${s}" <${i}?Replaces=${a}>`}return t}}}
1,(e,t,s)=>{var i,r;s.r(t),s.d(t,{SessionState:()=>i}),(r=i||(i={})).Initial="Initial",r.Establishing="Establishing",r.Established="Established",r.Terminating="Terminating",r.Terminated="Terminated"},(e,t,s)=>{s.r(t),s.d(t,{fromBodyLegacy:()=>a,isBody:()=>c,getBody:()=>h});var i=s(18),r=s(26),n=s(27);function o(e){return"application/sdp"===e?"session":"render"}function a(e){let t="string"==typeof e?e:e.body,s="string"==typeof e?"application/sdp":e.contentType;return{contentDisposition:o(s),contentType:s,content:t}}function c(e){return!!e&&"string"==typeof e.content&&"string"==typeof e.contentType&&void 0===e.contentDisposition||"string"==typeof e.contentDisposition}function h(e){let t,s,a;if(e instanceof i.IncomingRequestMessage&&e.body){let i=e.parseHeader("Content-Disposition");t=i?i.type:void 0,s=e.parseHeader("Content-Type"),a=e.body}if(e instanceof r.IncomingResponseMessage&&e.body){let i=e.parseHeader("Content-Disposition");t=i?i.type:void 0,s=e.parseHeader("Content-Type"),a=e.body}if(e instanceof n.OutgoingRequestMessage&&e.body){if(t=e.getHeader("Content-Disposition"),s=e.getHeader("Content-Type"),"string"==typeof e.body){if(!s)throw Error("Header content type header does not equal body content type.");a=e.body}else{if(s&&s!==e.body.contentType)throw Error("Header content type header does not equal body content type.");s=e.body.contentType,a=e.body.body}}if(c(e)&&(t=e.contentDisposition,s=e.contentType,a=e.content),a){if(s&&!t&&(t=o(s)),!t)throw Error("Content disposition undefined.");if(!s)throw Error("Content type undefined.");return{contentDisposition:t,contentType:s,content:a}}}}
1,(e,t,s)=>{s.r(t),s.d(t,{IncomingRequestMessage:()=>r});var i=s(19);class r extends i.IncomingMessage{constructor(){super()}}},(e,t,s)=>{s.r(t),s.d(t,{IncomingMessage:()=>n});var i=s(21),r=s(20);class n{constructor(){this.headers={}}addHeader(e,t){let s={raw:t};e=(0,r.headerize)(e),this.headers[e]?this.headers[e].push(s):this.headers[e]=[s]}getHeader(e){let t=this.headers[(0,r.headerize)(e)];if(t&&t[0])return t[0].raw}getHeaders(e){let t=this.headers[(0,r.headerize)(e)],s=[];if(!t)return[];for(let e of t)s.push(e.raw);return s}hasHeader(e){return!!this.headers[(0,r.headerize)(e)]}parseHeader(e,t=0){if(e=(0,r.headerize)(e),!this.headers[e]||t>=this.headers[e].length)return;let s=this.headers[e][t],n=s.raw;if(s.parsed)return s.parsed;let o=i.Grammar.parse(n,e.replace(/-/g,"_"));if(-1!==o)return s.parsed=o,o;this.headers[e].splice(t,1)}s(e,t=0){return this.parseHeader(e,t)}setHeader(e,t){this.headers[(0,r.headerize)(e)]=[{raw:t}]}toString(){return this.data}}},(e,t,s)=>{s.r(t),s.d(t,{createRandomToken:()=>r,getReasonPhrase:()=>n,newTag:()=>o,headerize:()=>a,utf8Length:()=>c});let i={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",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:"Internal Server 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"};function r(e,t=32){let s="";for(let i=0;i<e;i++)s+=Math.floor(Math.random()*t).toString(t);return s}function n(e){return i[e]||""}function o(){return r(10)}function a(e){let t={"Call-Id":"Call-ID",Cseq:"CSeq","Min-Se":"Min-SE",Rack:"RAck",Rseq:"RSeq","Www-Authenticate":"WWW-Authenticate"},s=e.toLowerCase().replace(/_/g,"-").split("-"),i=s.length,r="";for(let e=0;e<i;e++)0!==e&&(r+="-"),r+=s[e].charAt(0).toUpperCase()+s[e].substring(1);return t[r]&&(r=t[r]),r}function c(e){return encodeURIComponent(e).replace(/%[A-F\d]{2}/g,"U").length}},(e,t,s)=>{s.r(t),s.d(t,{Grammar:()=>r});var i,r,n=s(22);(i=r||(r={})).parse=function(e,t){let s={startRule:t};try{n.parse(e,s)}catch(e){s.data=-1}return s.data},i.nameAddrHeaderParse=function(e){let t=i.parse(e,"Name_Addr_Header");return -1!==t?t:void 0},i.URIParse=function(e){let t=i.parse(e,"SIP_URI");return -1!==t?t:void 0}}
1,(e,t,s)=>{s.r(t),s.d(t,{SyntaxError:()=>n,parse:()=>o});var i=s(25),r=s(23);class n extends Error{constructor(e,t,s,i){super(),this.message=e,this.expected=t,this.found=s,this.location=i,this.name="SyntaxError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,n)}static buildMessage(e,t){function s(e){return e.charCodeAt(0).toString(16).toUpperCase()}function i(e){return e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,e=>"\\x0"+s(e)).replace(/[\x10-\x1F\x7F-\x9F]/g,e=>"\\x"+s(e))}function r(e){return e.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,e=>"\\x0"+s(e)).replace(/[\x10-\x1F\x7F-\x9F]/g,e=>"\\x"+s(e))}function n(e){switch(e.type){case"literal":return'"'+i(e.text)+'"';case"class":let t=e.parts.map(e=>Array.isArray(e)?r(e[0])+"-"+r(e[1]):r(e));return"["+(e.inverted?"^":"")+t+"]";case"any":return"any character";case"end":return"end of input";case"other":return e.description}}return"Expected "+function(e){let t,s;let i=e.map(n);if(i.sort(),i.length>0){for(t=1,s=1;t<i.length;t++)i[t-1]!==i[t]&&(i[s]=i[t],s++);i.length=s}switch(i.length){case 1:return i[0];case 2:return i[0]+" or "+i[1];default:return i.slice(0,-1).join(", ")+", or "+i[i.length-1]}}(e)+" but "+(t?'"'+i(t)+'"':"end of input")+" found."}}let o=function(e,t){var s,o,a;let c;t=void 0!==t?t:{};let h={},d={Contact:119,Name_Addr_Header:156,Record_Route:176,Request_Response:81,SIP_URI:45,Subscription_State:186,Supported:191,Require:182,Via:194,absoluteURI:84,Call_ID:118,Content_Disposition:130,Content_Length:135,Content_Type:136,CSeq:146,displayName:122,Event:149,From:151,host:52,Max_Forwards:154,Min_SE:213,Proxy_Authenticate:157,quoted_string:40,Refer_To:178,Replaces:179,Session_Expires:210,stun_URI:217,To:192,turn_URI:223,uuid:226,WWW_Authenticate:209,challenge:158,sipfrag:230,Referred_By:231},l=119,g=["\r\n",R("\r\n",!1),/^[0-9]/,E([["0","9"]],!1,!1),/^[a-zA-Z]/,E([["a","z"],["A","Z"]],!1,!1),/^[0-9a-fA-F]/,E([["0","9"],["a","f"],["A","F"]],!1,!1),/^[\0-\xFF]/,E([["\0","\xff"]],!1,!1),/^["]/,E(['"'],!1,!1)," ",R(" ",!1),"	",R("	",!1),/^[a-zA-Z0-9]/,E([["a","z"],["A","Z"],["0","9"]],!1,!1),";",R(";",!1),"/",R("/",!1),"?",R("?",!1),":",R(":",!1),"@",R("@",!1),"&",R("&",!1),"=",R("=",!1),"+",R("+",!1),"$",R("$",!1),",",R(",",!1),"-",R("-",!1),"_",R("_",!1),".",R(".",!1),"!",R("!",!1),"~",R("~",!1),"*",R("*",!1),"'",R("'",!1),"(",R("(",!1),")",R(")",!1),"%",R("%",!1),function(){return" "},function(){return":"},/^[!-~]/,E([["!","~"]],!1,!1),/^[\x80-\uFFFF]/,E([["\x80","ï¿¿"]],!1,!1),/^[\x80-\xBF]/,E([["\x80","\xbf"]],!1,!1),/^[a-f]/,E([["a","f"]],!1,!1),"`",R("`",!1),"<",R("<",!1),">",R(">",!1),"\\",R("\\",!1),"[",R("[",!1),"]",R("]",!1),"{",R("{",!1),"}",R("}",!1),function(){return"*"},function(){return"/"},function(){return"="},function(){return"("},function(){return")"},function(){return">"},function(){return"<"},function(){return","},function(){return";"},function(){return":"},function(){return'"'},/^[!-']/,E([["!","'"]],!1,!1),/^[*-[]/,E([["*","["]],!1,!1),/^[\]-~]/,E([["]","~"]],!1,!1),function(e){return e},/^[#-[]/,E([["#","["]],!1,!1),/^[\0-\t]/,E([["\0","	"]],!1,!1),/^[\x0B-\f]/,E([["\v","\f"]],!1,!1),/^[\x0E-\x7F]/,E([["\x0e","\x7f"]],!1,!1),function(){(t=t||{data:{}}).data.uri=new r.URI(t.data.scheme,t.data.user,t.data.host,t.data.port),delete t.data.scheme,delete t.data.user,delete t.data.host,delete t.data.host_type,delete t.data.port},function(){(t=t||{data:{}}).data.uri=new r.URI(t.data.scheme,t.data.user,t.data.host,t.data.port,t.data.uri_params,t.data.uri_headers),delete t.data.scheme,delete t.data.user,delete t.data.host,delete t.data.host_type,delete t.data.port,delete t.data.uri_params,"SIP_URI"===t.startRule&&(t.data=t.data.uri)},"sips",R("sips",!0),"sip",R("sip",!0),function(e){(t=t||{data:{}}).data.scheme=e},function(){(t=t||{data:{}}).data.user=decodeURIComponent(b().slice(0,-1))},function(){(t=t||{data:{}}).data.password=b()},function(){return(t=t||{data:{}}).data.host=b(),t.data.host},function(){return(t=t||{data:{}}).data.host_type="domain",b()},/^[a-zA-Z0-9_\-]/,E([["a","z"],["A","Z"],["0","9"],"_","-"],!1,!1),/^[a-zA-Z0-9\-]/,E([["a","z"],["A","Z"],["0","9"],"-"],!1,!1),function(){return(t=t||{data:{}}).data.host_type="IPv6",b()},"::",R("::",!1),function(){return(t=t||{data:{}}).data.host_type="IPv6",b()},function(){return(t=t||{data:{}}).data.host_type="IPv4",b()},"25",R("25",!1),/^[0-5]/,E([["0","5"]],!1,!1),"2",R("2",!1),/^[0-4]/,E([["0","4"]],!1,!1),"1",R("1",!1),/^[1-9]/,E([["1","9"]],!1,!1),function(e){return t=t||{data:{}},e=parseInt(e.join("")),t.data.port=e,e},"transport=",R("transport=",!0),"udp",R("udp",!0),"tcp",R("tcp",!0),"sctp",R("sctp",!0),"tls",R("tls",!0),function(e){(t=t||{data:{}}).data.uri_params||(t.data.uri_params={}),t.data.uri_params.transport=e.toLowerCase()},"user=",R("user=",!0),"phone",R("phone",!0),"ip",R("ip",!0),function(e){(t=t||{data:{}}).data.uri_params||(t.data.uri_params={}),t.data.uri_params.user=e.toLowerCase()},"method=",R("method=",!0),function(e){(t=t||{data:{}}).data.uri_params||(t.data.uri_params={}),t.data.uri_params.method=e},"ttl=",R("ttl=",!0),function(e){(t=t||{data:{}}).data.params||(t.data.params={}),t.data.params.ttl=e},"maddr=",R("maddr=",!0),function(e){(t=t||{data:{}}).data.uri_params||(t.data.uri_params={}),t.data.uri_params.maddr=e},"lr",R("lr",!0),function(){(t=t||{data:{}}).data.uri_params||(t.data.uri_params={}),t.data.uri_params.lr=void 0},function(e,s){(t=t||{data:{}}).data.uri_params||(t.data.uri_params={}),s=null===s?void 0:s[1],t.data.uri_params[e.toLowerCase()]=s},function(e,s){e=e.join("").toLowerCase(),s=s.join(""),(t=t||{data:{}}).data.uri_headers||(t.data.uri_headers={}),t.data.uri_headers[e]?t.data.uri_headers[e].push(s):t.data.uri_headers[e]=[s]},function(){"Refer_To"===(t=t||{data:{}}).startRule&&(t.data.uri=new r.URI(t.data.scheme,t.data.user,t.data.host,t.data.port,t.data.uri_params,t.data.uri_headers),delete t.data.scheme,delete t.data.user,delete t.data.host,delete t.data.host_type,delete t.data.port,delete t.data.uri_params)},"//",R("//",!1),function(){(t=t||{data:{}}).data.scheme=b()},R("SIP",!0),function(){(t=t||{data:{}}).data.sip_version=b()}
1,"INVITE",R("INVITE",!1),"ACK",R("ACK",!1),"VXACH",R("VXACH",!1),"OPTIONS",R("OPTIONS",!1),"BYE",R("BYE",!1),"CANCEL",R("CANCEL",!1),"REGISTER",R("REGISTER",!1),"SUBSCRIBE",R("SUBSCRIBE",!1),"NOTIFY",R("NOTIFY",!1),"REFER",R("REFER",!1),"PUBLISH",R("PUBLISH",!1),function(){return(t=t||{data:{}}).data.method=b(),t.data.method},function(e){(t=t||{data:{}}).data.status_code=parseInt(e.join(""))},function(){(t=t||{data:{}}).data.reason_phrase=b()},function(){(t=t||{data:{}}).data=b()},function(){var e,s;for(e=0,s=(t=t||{data:{}}).data.multi_header.length;e<s;e++)if(null===t.data.multi_header[e].parsed){t.data=null;break}null!==t.data?t.data=t.data.multi_header:t.data=-1},function(){var e;(t=t||{data:{}}).data.multi_header||(t.data.multi_header=[]);try{e=new i.NameAddrHeader(t.data.uri,t.data.displayName,t.data.params),delete t.data.uri,delete t.data.displayName,delete t.data.params}catch(t){e=null}t.data.multi_header.push({position:p,offset:I(f,p).start.offset,parsed:e})},function(e){'"'===(e=b().trim())[0]&&(e=e.substring(1,e.length-1)),(t=t||{data:{}}).data.displayName=e},"q",R("q",!0),function(e){(t=t||{data:{}}).data.params||(t.data.params={}),t.data.params.q=e},"expires",R("expires",!0),function(e){(t=t||{data:{}}).data.params||(t.data.params={}),t.data.params.expires=e},function(e){return parseInt(e.join(""))},"0",R("0",!1),function(){return parseFloat(b())},function(e,s){(t=t||{data:{}}).data.params||(t.data.params={}),s=null===s?void 0:s[1],t.data.params[e.toLowerCase()]=s},"render",R("render",!0),"session",R("session",!0),"icon",R("icon",!0),"alert",R("alert",!0),function(){"Content_Disposition"===(t=t||{data:{}}).startRule&&(t.data.type=b().toLowerCase())},"handling",R("handling",!0),"optional",R("optional",!0),"required",R("required",!0),function(e){(t=t||{data:{}}).data=parseInt(e.join(""))},function(){(t=t||{data:{}}).data=b()},"text",R("text",!0),"image",R("image",!0),"audio",R("audio",!0),"video",R("video",!0),"application",R("application",!0),"message",R("message",!0),"multipart",R("multipart",!0),"x-",R("x-",!0),function(e){(t=t||{data:{}}).data.value=parseInt(e.join(""))},function(e){(t=t||{data:{}}).data=e},function(e){(t=t||{data:{}}).data.event=e.toLowerCase()},function(){var e=(t=t||{data:{}}).data.tag;t.data=new i.NameAddrHeader(t.data.uri,t.data.displayName,t.data.params),e&&t.data.setParam("tag",e)},"tag",R("tag",!0),function(e){(t=t||{data:{}}).data.tag=e},function(e){(t=t||{data:{}}).data=parseInt(e.join(""))},function(e){(t=t||{data:{}}).data=e},function(){(t=t||{data:{}}).data=new i.NameAddrHeader(t.data.uri,t.data.displayName,t.data.params)},"digest",R("Digest",!0),"realm",R("realm",!0),function(e){(t=t||{data:{}}).data.realm=e},"domain",R("domain",!0),"nonce",R("nonce",!0),function(e){(t=t||{data:{}}).data.nonce=e},"opaque",R("opaque",!0),function(e){(t=t||{data:{}}).data.opaque=e},"stale",R("stale",!0),"true",R("true",!0),function(){(t=t||{data:{}}).data.stale=!0},"false",R("false",!0),function(){(t=t||{data:{}}).data.stale=!1},"algorithm",R("algorithm",!0),"md5",R("MD5",!0),"md5-sess",R("MD5-sess",!0),function(e){(t=t||{data:{}}).data.algorithm=e.toUpperCase()},"qop",R("qop",!0),"auth-int",R("auth-int",!0),"auth",R("auth",!0),function(e){(t=t||{data:{}}).data.qop||(t.data.qop=[]),t.data.qop.push(e.toLowerCase())},function(e){(t=t||{data:{}}).data.value=parseInt(e.join(""))},function(){var e,s;for(e=0,s=(t=t||{data:{}}).data.multi_header.length;e<s;e++)if(null===t.data.multi_header[e].parsed){t.data=null;break}null!==t.data?t.data=t.data.multi_header:t.data=-1},function(){var e;(t=t||{data:{}}).data.multi_header||(t.data.multi_header=[]);try{e=new i.NameAddrHeader(t.data.uri,t.data.displayName,t.data.params),delete t.data.uri,delete t.data.displayName,delete t.data.params}catch(t){e=null}t.data.multi_header.push({position:p,offset:I(f,p).start.offset,parsed:e})},function(){(t=t||{data:{}}).data=new i.NameAddrHeader(t.data.uri,t.data.displayName,t.data.params)},function(){(t=t||{data:{}}).data.replaces_from_tag&&t.data.replaces_to_tag||(t.data=-1)},function(){(t=t||{data:{}}).data={call_id:t.data}},"from-tag",R("from-tag",!0),function(e){(t=t||{data:{}}).data.replaces_from_tag=e},"to-tag",R("to-tag",!0),function(e){(t=t||{data:{}}).data.replaces_to_tag=e},"early-only",R("early-only",!0),function(){(t=t||{data:{}}).data.early_only=!0},function(e,t){return t},function(e,t){return[e].concat(t)},function(e){"Require"===(t=t||{data:{}}).startRule&&(t.data=e||[])},function(e){(t=t||{data:{}}).data.value=parseInt(e.join(""))},"active",R("active",!0),"pending",R("pending",!0),"terminated",R("terminated",!0),function(){(t=t||{data:{}}).data.state=b()},"reason",R("reason",!0),function(e){t=t||{data:{}},void 0!==e&&(t.data.reason=e)},function(e){t=t||{data:{}},void 0!==e&&(t.data.expires=e)},"retry_after",R("retry_after",!0),function(e){t=t||{data:{}},void 0!==e&&(t.data.retry_after=e)},"deactivated",R("deactivated",!0),"probation",R("probation",!0),"rejected",R("rejected",!0),"timeout",R("timeout",!0),"giveup",R("giveup",!0),"noresource",R("noresource",!0),"invariant",R("invariant",!0),function(e){"Supported"===(t=t||{data:{}}).startRule&&(t.data=e||[])},function(){var e=(t=t||{data:{}}).data.tag;t.data=new i.NameAddrHeader(t.data.uri,t.data.displayName,t.data.params),e&&t.data.setParam("tag",e)},"ttl",R("ttl",!0),function(e){(t=t||{data:{}}).data.ttl=e},"maddr",R("maddr",!0),function(e){(t=t||{data:{}}).data.maddr=e},"received",R("received",!0),function(e){(t=t||{data:{}}).data.received=e},"branch",R("branch",!0),function(e){(t=t||{data:{}}).data.branch=e},"rport",R("rport",!0),function(e){t=t||{data:{}},void 0!==e&&(t.data.rport=e.join(""))},function(e){(t=t||{data:{}}).data.protocol=e},R("UDP",!0),R("TCP",!0),R("TLS",!0),R("SCTP",!0),function(e){(t=t||{data:{}}).data.transport=e},function(){(t=t||{data:{}}).data.host=b()},function(e){(t=t||{data:{}}).data.port=parseInt(e.join(""))},function(e){return parseInt(e.join(""))},function(e){"Session_Expires"===(t=t||{data:{}}).startRule&&(t.data.deltaSeconds=e)},"refresher",R("refresher",!1),"uas",R("uas",!1),"uac",R("uac",!1),function(e){"Session_Expires"===(t=t||{data:{}}).startRule&&(t.data.refresher=e)},function(e){"Min_SE"===(t=t||{data:{}}).startRule&&(t.data=e)},"stuns",R("stuns",!0),"stun",R("stun",!0),function(e){(t=t||{data:{}}).data.scheme=e},function(e){(t=t||{data:{}}).data.host=e},"?transport=",R("?transport=",!1),"turns",R("turns",!0),"turn",R("turn",!0),function(e){(t=t||{data:{}}).data.transport=e},function(){(t=t||{data:{}}).data=b()},"Referred-By",R("Referred-By",!1),"b",R("b",!1),"cid",R("cid",!1)],u=[C('2 ""6 7!'),C('4"""5!7#'),C('4$""5!7%'),C('4&""5!7\''),C(";'.# &;("),C('4(""5!7)'),C('4*""5!7+'),C('2,""6,7-'),C('2.""6.7/'),C('40""5!71'),C('22""6273.\x89 &24""6475.} &26""6677.q &28""6879.e &2:""6:7;.Y &2<""6<7=.M &2>""6>
17?.A &2@""[email protected] &2B""6B7C.) &2D""6D7E'),C(";).# &;,"),C('2F""6F7G.} &2H""6H7I.q &2J""6J7K.e &2L""6L7M.Y &2N""6N7O.M &2P""6P7Q.A &2R""6R7S.5 &2T""6T7U.) &2V""6V7W'),C('%%2X""6X7Y/5#;#/,$;#/#$+#)(#\'#("\'#&\'#/"!&,)'),C('%%$;$0#*;$&/,#; /#$+")("\'#&\'#." &"/=#$;$/&#0#*;$&&&#/\'$8":Z" )("\'#&\'#'),C(';.." &"'),C("%$;'.# &;(0)*;'.# &;(&/?#28\"\"6879/0$;//'$8#:[# )(#'#(\"'#&'#"),C('%%$;2/&#0#*;2&&&#/g#$%$;.0#*;.&/,#;2/#$+")("\'#&\'#0=*%$;.0#*;.&/,#;2/#$+")("\'#&\'#&/#$+")("\'#&\'#/"!&,)'),C('4\\""5!7].# &;3'),C('4^""5!7_'),C('4`""5!7a'),C(';!.) &4b""5!7c'),C('%$;).\x95 &2F""6F7G.\x89 &2J""6J7K.} &2L""6L7M.q &2X""6X7Y.e &2P""6P7Q.Y &2H""6H7I.M &2@""[email protected] &2d""6d7e.5 &2R""6R7S.) &2N""6N7O/\x9e#0\x9b*;).\x95 &2F""6F7G.\x89 &2J""6J7K.} &2L""6L7M.q &2X""6X7Y.e &2P""6P7Q.Y &2H""6H7I.M &2@""[email protected] &2d""6d7e.5 &2R""6R7S.) &2N""6N7O&&&#/"!&,)'),C('%$;).\x89 &2F""6F7G.} &2L""6L7M.q &2X""6X7Y.e &2P""6P7Q.Y &2H""6H7I.M &2@""[email protected] &2d""6d7e.5 &2R""6R7S.) &2N""6N7O/\x92#0\x8f*;).\x89 &2F""6F7G.} &2L""6L7M.q &2X""6X7Y.e &2P""6P7Q.Y &2H""6H7I.M &2@""[email protected] &2d""6d7e.5 &2R""6R7S.) &2N""6N7O&&&#/"!&,)'),C('2T""6T7U.\xe3 &2V""6V7W.\xd7 &2f""6f7g.\xcb &2h""6h7i.\xbf &2:""6:7;.\xb3 &2D""6D7E.\xa7 &22""6273.\x9b &28""6879.\x8f &2j""6j7k.\x83 &;&.} &24""6475.q &2l""6l7m.e &2n""6n7o.Y &26""6677.M &2>""6>7?.A &2p""6p7q.5 &2r""6r7s.) &;\'.# &;('),C('%$;).Ä« &2F""6F7G.ğ &2J""6J7K.ē &2L""6L7M.ć &2X""6X7Y.\xfb &2P""6P7Q.\xef &2H""6H7I.\xe3 &2@""6@7A.\xd7 &2d""6d7e.\xcb &2R""6R7S.\xbf &2N""6N7O.\xb3 &2T""6T7U.\xa7 &2V""6V7W.\x9b &2f""6f7g.\x8f &2h""6h7i.\x83 &28""6879.w &2j""6j7k.k &;&.e &24""6475.Y &2l""6l7m.M &2n""6n7o.A &26""6677.5 &2p""6p7q.) &2r""6r7s/Ä´#0ı*;).Ä« &2F""6F7G.ğ &2J""6J7K.ē &2L""6L7M.ć &2X""6X7Y.\xfb &2P""6P7Q.\xef &2H""6H7I.\xe3 &2@""6@7A.\xd7 &2d""6d7e.\xcb &2R""6R7S.\xbf &2N""6N7O.\xb3 &2T""6T7U.\xa7 &2V""6V7W.\x9b &2f""6f7g.\x8f &2h""6h7i.\x83 &28""6879.w &2j""6j7k.k &;&.e &24""6475.Y &2l""6l7m.M &2n""6n7o.A &26""6677.5 &2p""6p7q.) &2r""6r7s&&&#/"!&,)'),C("%;//?#2P\"\"6P7Q/0$;//'$8#:t# )(#'#(\"'#&'#"),C("%;//?#24\"\"6475/0$;//'$8#:u# )(#'#(\"'#&'#"),C("%;//?#2>\"\"6>7?/0$;//'$8#:v# )(#'#(\"'#&'#"),C("%;//?#2T\"\"6T7U/0$;//'$8#:w# )(#'#(\"'#&'#"),C("%;//?#2V\"\"6V7W/0$;//'$8#:x# )(#'#(\"'#&'#"),C('%2h""6h7i/0#;//\'$8":y" )("\'#&\'#'),C('%;//6#2f""6f7g/\'$8":z" )("\'#&\'#'),C("%;//?#2D\"\"6D7E/0$;//'$8#:{# )(#'#(\"'#&'#"),C("%;//?#22\"\"6273/0$;//'$8#:|# )(#'#(\"'#&'#"),C("%;//?#28\"\"6879/0$;//'$8#:}# )(#'#(\"'#&'#"),C("%;//0#;&/'$8\":~\" )(\"'#&'#"),C("%;&/0#;//'$8\":~\" )(\"'#&'#"),C("%;=/T#$;G.) &;K.# &;F0/*;G.) &;K.# &;F&/,$;>/#$+#)(#'#(\"'#&'#"),C('4\x7f""5!7\x80.A &4\x81""5!7\x82.5 &4\x83""5!7\x84.) &;3.# &;.'),C("%%;//Q#;&/H$$;J.# &;K0)*;J.# &;K&/,$;&/#$+$)($'#(#'#(\"'#&'#/\"!&,)"),C("%;//]#;&/T$%$;J.# &;K0)*;J.# &;K&/\"!&,)/1$;&/($8$:\x85$!!)($'#(#'#(\"'#&'#"),C(';..G &2L""6L7M.; &4\x86""5!7\x87./ &4\x83""5!7\x84.# &;3'),C('%2j""6j7k/J#4\x88""5!7\x89.5 &4\x8a""5!7\x8b.) &4\x8c""5!7\x8d/#$+")("\'#&\'#'),C("%;N/M#28\"\"6879/>$;O.\" &\"/0$;S/'$8$:\x8e$ )($'#(#'#(\"'#&'#"),C("%;N/d#28\"\"6879/U$;O.\" &\"/G$;S/>$;_/5$;l.\" &\"/'$8&:\x8f& )(&'#(%'#($'#(#'#(\"'#&'#"),C('%3\x90""5$7\x91.) &3\x92""5#7\x93/\' 8!:\x94!! )'),C('%;P/]#%28""6879/,#;R/#$+")("\'#&\'#." &"/6$2:""6:7;/\'$8#:\x95# )(#\'#("\'#&\'#'),C("$;+.) &;-.# &;Q/2#0/*;+.) &;-.# &;Q&&&#"),C('2<""6<7=.q &2>""6>
17?.e &2@""[email protected] &2B""6B7C.M &2D""6D7E.A &22""6273.5 &26""6677.) &24""6475'),C('%$;+._ &;-.Y &2<""6<7=.M &2>""6>7?.A &2@""[email protected] &2B""6B7C.) &2D""6D7E0e*;+._ &;-.Y &2<""6<7=.M &2>""6>7?.A &2@""[email protected] &2B""6B7C.) &2D""6D7E&/& 8!:\x96! )'),C('%;T/J#%28""6879/,#;^/#$+")("\'#&\'#." &"/#$+")("\'#&\'#'),C("%;U.) &;\\.# &;X/& 8!:\x97! )"),C('%$%;V/2#2J""6J7K/#$+")("\'#&\'#0<*%;V/2#2J""6J7K/#$+")("\'#&\'#&/D#;W/;$2J""6J7K." &"/\'$8#:\x98# )(#\'#("\'#&\'#'),C('$4\x99""5!7\x9a/,#0)*4\x99""5!7\x9a&&&#'),C('%4$""5!7%/?#$4\x9b""5!7\x9c0)*4\x9b""5!7\x9c&/#$+")("\'#&\'#'),C('%2l""6l7m/?#;Y/6$2n""6n7o/\'$8#:\x9d# )(#\'#("\'#&\'#'),C('%%;Z/\xb3#28""6879/\xa4$;Z/\x9b$28""6879/\x8c$;Z/\x83$28""6879/t$;Z/k$28""6879/\\$;Z/S$28""6879/D$;Z/;$28""6879/,$;[/#$+-)(-\'#(,\'#(+\'#(*\'#()\'#((\'#(\'\'#(&\'#(%\'#($\'#(#\'#("\'#&\'#.ސ &%2\x9e""6\x9e7\x9f/\xa4#;Z/\x9b$28""6879/\x8c$;Z/\x83$28""6879/t$;Z/k$28""6879/\\$;Z/S$28""6879/D$;Z/;$28""6879/,$;[/#$+,)(,\'#(+\'#(*\'#()\'#((\'#(\'\'#(&\'#(%\'#($\'#(#\'#("\'#&\'#.Û¹ &%2\x9e""6\x9e7\x9f/\x8c#;Z/\x83$28""6879/t$;Z/k$28""6879/\\$;Z/S$28""6879/D$;Z/;$28""6879/,$;[/#$+*)(*\'#()\'#((\'#(\'\'#(&\'#(%\'#($\'#(#\'#("\'#&\'#.Ùº &%2\x9e""6\x9e7\x9f/t#;Z/k$28""6879/\\$;Z/S$28""6879/D$;Z/;$28""6879/,$;[/#$+()((\'#(\'\'#(&\'#(%\'#($\'#(#\'#("\'#&\'#.ؓ &%2\x9e""6\x9e7\x9f/\\#;Z/S$28""6879/D$;Z/;$28""6879/,$;[/#$+&)(&\'#(%\'#($\'#(#\'#("\'#&\'#.ׄ &%2\x9e""6\x9e7\x9f/D#;Z/;$28""6879/,$;[/#$+$)($\'#(#\'#("\'#&\'#.֍ &%2\x9e""6\x9e7\x9f/,#;[/#$+")("\'#&\'#.Õ® &%2\x9e""6\x9e7\x9f/,#;Z/#$+")("\'#&\'#.Տ &%;Z/\x9b#2\x9e""6\x9e7\x9f/\x8c$;Z/\x83$28""6879/t$;Z/k$28""6879/\\$;Z/S$28""6879/D$;Z/;$28""6879/,$;[/#$++)(+\'#(*\'#()\'#((\'#(\'\'#(&\'#(%\'#($\'#(#\'#("\'#&\'#.Ӈ &%;Z/\xaa#%28""6879/,#;Z/#$+")("\'#&\'#." &"/\x83$2\x9e""6\x9e7\x9f/t$;Z/k$28""6879/\\$;Z/S$28""6879/D$;Z/;$28""6879/,$;[/#$+*)(*\'#()\'#((\'#(\'\'#(&\'#(%\'#($\'#(#\'#("\'#&\'#.а &%;Z/\xb9#%28""6879/,#;Z/#$+")("\'#&\'#." &"/\x92$%28""6879/,#;Z/#$+")("\'#&\'#." &"/k$2\x9e""6\x9e7\x9f/\\$;Z/S$28""6879/D$;Z/;$28""6879/,$;[/#$+))()\'#((\'#(\'\'#(&\'#(%\'#($\'#(#\'#("\'#&\'#.Ί &%;Z/\xc8#%28""6879/,#;Z/#$+")("\'#&\'#." &"/\xa1$%28""6879/,#;Z/#$+")("\'#&\'#." &"/z$%28""6879/,#;Z/#$+")("\'#&\'#." &"/S$2\x9e""6\x9e7\x9f/D$;Z/;$28""6879/,$;[/#$+()((\'#(\'\'#(&\'#(%\'#($\'#(#\'#("\'#&\'#.˕ &%;Z/\xd7#%28""6879/,#;Z/#$+")("\'#&\'#." &"/\xb0$%28""6879/,#;Z/#$+")("\'#&\'#." &"/\x89$%28""6879/,#;Z/#$+")("\'#&\'#." &"/b$%28""6879/,#;Z/#$+")("\'#&\'#." &"/;$2\x9e""6\x9e7\x9f/,$;[/#$+\')(\'\'#(&\'#(%\'#($\'#(#\'#("\'#&\'#.ȑ &%;Z/\xfe#%28""6879/,#;Z/#$+")("\'#&\'#." &"/\xd7$%28""6879/,#;Z/#$+")("\'#&\'#." &"/\xb0$%28""6879/,#;Z/#$+")("\'#&\'#." &"/\x89$%28""6879/,#;Z/#$+")("\'#&\'#." &"/b$%28""6879/,#;Z/#$+")("\'#&\'#." &"/;$2\x9e""6\x9e7\x9f/,$;Z/#$+()((\'#(\'\'#(&\'#(%\'#($\'#(#\'#("\'#&\'#.Ħ &%;Z/Ĝ#%28""6879/,#;Z/#$+")("\'#&\'#." &"/\xf5$%28""6879/,#;Z/#$+")("\'#&\'#." &"/\xce$%28""6879/,#;Z/#$+")("\'#&\'#." &"/\xa7$%28""6879/,#;Z/#$+")("\'#&\'#." &"/\x80$%28""6879/,#;Z/#$+")("\'#&\'#." &"/Y$%28""6879/,#;Z/#$+")("\'#&\'#." &"/2$2\x9e""6\x9e7\x9f/#$+()((\'#(\'\'#(&\'#(%\'#($\'#(#\'#("\'#&\'#/& 8!:\xa0! )'),C('%;#/M#;#." &"/?$;#." &"/1$;#." &"/#$+$)($\'#(#\'#("\'#&\'#'),C("%;Z/;#28\"\"6879/,$;Z/#$+#)(#'#(\"'#&'#.# &;\\"),C("%;]/o#2J\"\"6J7K/`$;]/W$2J\"\"6J7K/H$;]/?$2J\"\"6J7K/0$;]/'$8':\xa1' )(''#(&'#(%'#($'#(#'#(\"'#&'#"),C('%2\xa2""6\xa27\xa3/2#4\xa4""5!7\xa5/#$+")("\'#&\'#.\x98 &%2\xa6""6\xa67\xa7/;#4\xa8""5!7\xa9/,$;!/#$+#)(#\'#("\'#&\'#.j &%2\xaa""6\xaa7\xab/5#;!/,$;!/#$+#)(#\'#("\'#&\'#.B &%4\xac""5!7\xad/,#;!/#$+")("\'#&\'#.# &;!'),C('%%;!." &"/[#;!." &"/M$;!." &"/?$;!." &"/1$;!." &"/#$+%)(%\'#($\'#(#\'#("\'#&\'#/\' 8!:\xae!! )'),C('$%22""6273/,#;`/#$+")("\'#&\'#0<*%22""6273/,#;`/#$+")("\'#&\'#&'),C(";a.A &;b.; &;c.5 &;d./ &;e.) &;f.# &;g"),C('%3\xaf""5*7\xb0/a#3\xb1""5#7\xb2.G &3\xb3""5#7\xb4.; &3\xb5""5$7\xb6./ &3\xb7""5#7\xb8.# &;6/($8":\xb9"! )("\'#&\'#'),C('%3\xba""5%7\xbb/I#3\xbc""5%7\xbd./ &3\xbe""5"7\xbf.# &;6/($8":\xc0"! )("\'#&\'#'),C('%3\xc1""5\'7\xc2/1#;\x90/($8":\xc3"! )("\'#&\'#'),C('%3\xc4""5$7\xc5/1#;\xf0/($8":\xc6"! )("\'#&\'#'),C('%3\xc7""5&7\xc8/1#;T/($8":\xc9"! )("\'#&\'#'),C('%3\xca""5"7\xcb/N#%2>""6>7?/,#;6/#$+")("\'#&\'#." &"/\'$8":\xcc" )("\'#&\'#'),C('%;h/P#%2>""6>7?/,#;i/#$+")("\'#&\'#." &"/)$8":\xcd""! )("\'#&\'#'),C('%$;j/&#0#*;j&&&#/"!&,)'),C('%$;j/&#0#*;j&&&#/"!&,)'),C(";k.) &;+.# &;-"),C('2l""6l7m.e &2n""6n7o.Y &24""6475.M &28""6879.A &2<""6<7=.5 &2@""6@7A.) &2B""6B7C'),C('%26""6677/n#;m/e$$%2<""6<7=/,#;m/#$+")("\'#&\'#0<*%2<""6<7=/,#;m/#$+")("\'#&\'#&/#$+#)(#\'#("\'#&\'#'),C('%;n/A#2>""6>7?/2$;o/)$8#:\xce#"" )(#\'#("\'#&\'#'),C("$;p.) &;+.# &;-/2#0/*;p.) &;+.# &;-&&&#"),C("$;p.) &;+.# &;-0/*;p.) &;+.# &;-&"),C('2l""6l7m.e &2n""6n7o.Y &24""6475.M &26""6677.A &28""6879.5 &2@""6@7A.) &2B""6B7C'),C(";\x91.# &;r"),C("%;\x90/G#;'/>$;s/5$;'/,$;\x84/#$+%)(%'#($'#(#'#(\"'#&'#"),C(";M.# &;t"),C("%;\x7f/E#28\"\"6879/6$;u.# &;x/'$8#:\xcf# )(#'#(\"'#&'#"),C('%;v.# &;w/J#%26""6677/,#;\x83/#$+")("\'#&\'#." &"/#$+")("\'#&\'#'),C('%2\xd0""6\xd07\xd1/:#;\x80/1$;w." &"/#$+#)(#\'#("\'#&\'#'),C('%24""6475/,#;{/#$+")("\'#&\'#'),C("%;z/3#$;y0#*;y&/#$+\")(\"'#&'#"),C(";*.) &;+.# &;-"),C(';+.\x8f &;-.\x89 &22""6273.} &26""6677.q &28""6879.e &2:""6:7;.Y &2<""6<7=.M &2>""6>
17?.A &2@""[email protected] &2B""6B7C.) &2D""6D7E'),C('%;|/e#$%24""6475/,#;|/#$+")("\'#&\'#0<*%24""6475/,#;|/#$+")("\'#&\'#&/#$+")("\'#&\'#'),C('%$;~0#*;~&/e#$%22""6273/,#;}/#$+")("\'#&\'#0<*%22""6273/,#;}/#$+")("\'#&\'#&/#$+")("\'#&\'#'),C("$;~0#*;~&"),C(';+.w &;-.q &28""6879.e &2:""6:7;.Y &2<""6<7=.M &2>""6>7?.A &2@""[email protected] &2B""6B7C.) &2D""6D7E'),C('%%;"/\x87#$;".G &;!.A &2@""[email protected] &2F""6F7G.) &2J""6J7K0M*;".G &;!.A &2@""[email protected] &2F""6F7G.) &2J""6J7K&/#$+")("\'#&\'#/& 8!:\xd2! )'),C(";\x81.# &;\x82"),C('%%;O/2#2:""6:7;/#$+")("\'#&\'#." &"/,#;S/#$+")("\'#&\'#." &"'),C('$;+.\x83 &;-.} &2B""6B7C.q &2D""6D7E.e &22""6273.Y &28""6879.M &2:""6:7;.A &2<""6<7=.5 &2>""6>7?.) &2@""6@7A/\x8c#0\x89*;+.\x83 &;-.} &2B""6B7C.q &2D""6D7E.e &22""6273.Y &28""6879.M &2:""6:7;.A &2<""6<7=.5 &2>""6>7?.) &2@""6@7A&&&#'),C("$;y0#*;y&"),C('%3\x92""5#7\xd3/q#24""6475/b$$;!/&#0#*;!&&&#/L$2J""6J7K/=$$;!/&#0#*;!&&&#/\'$8%:\xd4% )(%\'#($\'#(#\'#("\'#&\'#'),C('2\xd5""6\xd57\xd6'),C('2\xd7""6\xd77\xd8'),C('2\xd9""6\xd97\xda'),C('2\xdb""6\xdb7\xdc'),C('2\xdd""6\xdd7\xde'),C('2\xdf""6\xdf7\xe0'),C('2\xe1""6\xe17\xe2'),C('2\xe3""6\xe37\xe4'),C('2\xe5""6\xe57\xe6'),C('2\xe7""6\xe77\xe8'),C('2\xe9""6\xe97\xea'),C("%;\x85.Y &;\x86.S &;\x88.M &;\x89.G &;\x8a.A &;\x8b.; &;\x8c.5 &;\x8f./ &;\x8d.) &;\x8e.# &;6/& 8!:\xeb! )"),C("%;\x84/G#;'/>$;\x92/5$;'/,$;\x94/#$+%)(%'#($'#(#'#(\"'#&'#"),C("%;\x93/' 8!:\xec!! )"),C("%;!/5#;!/,$;!/#$+#)(#'#(\"'#&'#"),C("%$;*.A &;+.; &;-.5 &;3./ &;4.) &;'.# &;(0G*;*.A &;+.; &;-.5 &;3./ &;4.) &;'.# &;(&/& 8!:\xed! )"),C("%;\xb6/Y#$%;A/,#;\xb6/#$+\")(\"'#&'#06*%;A/,#;\xb6/#$+\")(\"'#&'#&/#$+\")(\"'#&'#"),C('%;9/N#%2:""6:7;/,#;9/#$+")("\'#&\'#." &"/\'$8":\xee" )("\'#&\'#'),C("%;:.c &%;\x98/Y#$%;A/,#;\x98/#$+\")(\"'#&'#06*%;A/,#;\x98/#$+\")(\"'#&'#&/#$+\")(\"'#&'#/& 8!:\xef! )"),C("%;L.# &;\x99/]#$%;B/,#;\x9b/#$+\")(\"'#&'#06*%;B/,#;\x9b/#$+\")(\"'#&'#&/'$8\":\xf0\" )(\"'#&'#"),C("%;\x9a.\" &\"/>#;@/5$;M/,$;?/#$+$)($'#(#'#(\"'#&'#"),C("%%;6/Y#$%;./,#;6/#$+\")(\"'#&'#06*%;./,#;6/#$+\")(\"'#&'#&/#$+\")(\"'#&'#.# &;H/' 8!:\xf1!! )"),C(";\x9c.) &;\x9d.# &;\xa0"),C("%3\xf2\"\"5!7\xf3/:#;</1$;\x9f/($8#:\xf4#! )(#'#(\"'#&'#"),C("%3\xf5\"\"5'7\xf6/:#;</1$;\x9e/($8#:\xf7#! )(#'#(\"'#&'#"),C("%$;!/&#0#*;!&&&#/' 8!:\xf8!! )"),C('%2\xf9""6\xf97\xfa/o#%2J""6J7K/M#;!." &"/?$;!." &"/1$;!." &"/#$+$)($\'#(#\'#("\'#&\'#." &"/\'$8":\xfb" )("\'#&\'#'),C('%;6/J#%;</,#;\xa1/#$+")("\'#&\'#." &"/)$8":\xfc""! )("\'#&\'#'),C(";6.) &;T.# &;H"),C("%;\xa3/Y#$%;B/,#;\xa4/#$+\")(\"'#&'#06*%;B/,#;\xa4/#$+\")(\"'#&'#&/#$+\")(\"'#&'#"),C('%3\xfd""5&7\xfe.G &3\xff""5\'7Ā.; &3ā""5$7Ă./ &3ă""5%7Ą.# &;6/& 8!:ą! )'),C(";\xa5.# &;\xa0"),C('%3Ć""5(7ć/M#;</D$3Ĉ""5(7ĉ./ &3Ċ""5(7ċ.# &;6/#$+#)(#\'#("\'#&\'#'),C("%;6/Y#$%;A/,#;6/#$+\")(\"'#&'#06*%;A/,#;6/#$+\")(\"'#&'#&/#$+\")(\"'#&'#"),C("%$;!/&#0#*;!&&&#/' 8!:Č!! )"),C("%;\xa9/& 8!:č! )"),C("%;\xaa/k#;;/b$;\xaf/Y$$%;B/,#;\xb0/#$+\")(\"'#&'#06*%;B/,#;\xb0/#$+\")(\"'#&'#&/#$+$)($'#(#'#(\"'#&'#"),C(";\xab.# &;\xac"),C('3Ď""5$7ď.S &3Đ""5%7đ.G &3Ē""5%7ē.; &3Ĕ""5%7ĕ./ &3Ė""5+7ė.# &;\xad'),C('3Ę""5\'7ę./ &3Ě""5)7ě.# &;\xad'),C(";6.# &;\xae"),C('%3Ĝ""5"7ĝ/,#;6/#$+")("\'#&\'#'),C(";\xad.# &;6"),C("%;6/5#;</,$;\xb1/#$+#)(#'#(\"'#&'#"),C(";6.# &;H"),C("%;\xb3/5#;./,$;\x90/#$+#)(#'#(\"'#&'#"),C("%$;!/&#0#*;!&&&#/' 8!:Ğ!! )"),C("%;\x9e/' 8!:ğ!! )"),C('%;\xb6/^#$%;B/,#;\xa0/#$+")("\'#&\'#06*%;B/,#;\xa0/#$+")("\'#&\'#&/($8":Ä "!!)("\'#&\'#'),C('%%;7/e#$%2J""6J7K/,#;7/#$+")("\'#&\'#0<*%2J""6J7K/,#;7/#$+")("\'#&\'#&/#$+")("\'#&\'#/"!&,)'),C("%;L.# &;\x99/]#$%;B/,#;\xb8/#$+\")(\"'#&'#06*%;B/,#;\xb8/#$+\")(\"'#&'#&/'$8\":Ä¡\" )(\"'#&'#"),C(";\xb9.# &;\xa0"),C("%3Ä¢\"\"5#7Ä£/:#;</1$;6/($8#:Ĥ#! )(#'#(\"'#&'#"),C("%$;!/&#0#*;!&&&#/' 8!:Ä¥!! )"),C("%;\x9e/' 8!:Ħ!! )"),C("%$;\x9a0#*;\x9a&/x#;@/o$;M/f$;?/]$$%;B/,#;\xa0/#$+\")(\"'#&'#06*%;B/,#;\xa0/#$+\")(\"'#&'#&/'$8%:ħ% )(%'#($'#(#'#(\"'#&'#"),C(";\xbe"),C("%3Ĩ\"\"5&7Ä©/k#;./b$;\xc1/Y$$%;A/,#;\xc1/#$+\")(\"'#&'#06*%;A/,#;\xc1/#$+\")(\"'#&'#&/#$+$)($'#(#'#(\"'#&'#.# &;\xbf"),C("%;6/k#;./b$;\xc0/Y$$%;A/,#;\xc0/#$+\")(\"'#&'#06*%;A/,#;\xc0/#$+\")(\"'#&'#&/#$+$)($'#(#'#(\"'#&'#"),C("%;6/;#;</2$;6.# &;H/#$+#)(#'#(\"'#&'#"),C(";\xc2.G &;\xc4.A &;\xc6.; &;\xc8.5 &;\xc9./ &;\xca.) &;\xcb.# &;\xc0"),C("%3Ī\"\"5%7Ä«/5#;</,$;\xc3/#$+#)(#'#(\"'#&'#"),C("%;I/' 8!:Ĭ!! )"),C("%3Ä­\"\"5&7Ä®/\x97#;</\x8e$;D/\x85$;\xc5/|$$%$;'/&#0#*;'&&&#/,#;\xc5/#$+\")(\"'#&'#0C*%$;'/&#0#*;'&&&#/,#;\xc5/#$+\")(\"'#&'#&/,$;E/#$+&)(&'#(%'#($'#(#'#(\"'#&'#"),C(";t.# &;w"),C("%3į\"\"5%7İ/5#;</,$;\xc7/#$+#)(#'#(\"'#&'#"),C("%;I/' 8!:ı!! )"),C("%3IJ\"\"5&7ij/:#;</1$;I/($8#:Ä´#! )(#'#(\"'#&'#"),C('%3ĵ""5%7Ķ/]#;</T$%3Ä·""5$7ĸ/& 8!:Ĺ! ).4 &%3ĺ""5%7Ä»/& 8!:ļ! )/#$+#)(#\'#("\'#&\'#'),C('%3Ľ""5)7ľ/R#;</I$3Ä¿""5#7ŀ./ &3Ł""5(7ł.# &;6/($8#:Ń#! )(#\'#("\'#&\'#'),C('%3ń""5#7Ņ/\x93#;</\x8a$;D/\x81$%;\xcc/e#$%2D""6D7E/,#;\xcc/#$+")("\'#&\'#0<*%2D""6D7E/,#;\xcc/#$+")("\'#&\'#&/#$+")("\'#&\'#/,$;E/#$+%)(%\'#($\'#(#\'#("\'#&\'#'),C('%3ņ""5(7Ň./ &3ň""5$7ʼn.# &;6/\' 8!:Ŋ!! )'),C("%;6/Y#$%;A/,#;
16/#$+\")(\"'#&'#06*%;A/,#;6/#$+\")(\"'#&'#&/#$+\")(\"'#&'#"),C("%;\xcf/G#;./>$;\xcf/5$;./,$;\x90/#$+%)(%'#($'#(#'#(\"'#&'#"),C("%$;!/&#0#*;!&&&#/' 8!:ŋ!! )"),C("%;\xd1/]#$%;A/,#;\xd1/#$+\")(\"'#&'#06*%;A/,#;\xd1/#$+\")(\"'#&'#&/'$8\":Ō\" )(\"'#&'#"),C("%;\x99/]#$%;B/,#;\xa0/#$+\")(\"'#&'#06*%;B/,#;\xa0/#$+\")(\"'#&'#&/'$8\":ō\" )(\"'#&'#"),C('%;L.O &;\x99.I &%;@." &"/:#;t/1$;?." &"/#$+#)(#\'#("\'#&\'#/]#$%;B/,#;\xa0/#$+")("\'#&\'#06*%;B/,#;\xa0/#$+")("\'#&\'#&/\'$8":Ŏ" )("\'#&\'#'),C("%;\xd4/]#$%;B/,#;\xd5/#$+\")(\"'#&'#06*%;B/,#;\xd5/#$+\")(\"'#&'#&/'$8\":ŏ\" )(\"'#&'#"),C("%;\x96/& 8!:Ő! )"),C('%3ő""5(7Œ/:#;</1$;6/($8#:œ#! )(#\'#("\'#&\'#.g &%3Ŕ""5&7ŕ/:#;</1$;6/($8#:Ŗ#! )(#\'#("\'#&\'#.: &%3ŗ""5*7Ř/& 8!:ř! ).# &;\xa0'),C('%%;6/k#$%;A/2#;6/)$8":Ś""$ )("\'#&\'#0<*%;A/2#;6/)$8":Ś""$ )("\'#&\'#&/)$8":ś""! )("\'#&\'#." &"/\' 8!:Ŝ!! )'),C("%;\xd8/Y#$%;A/,#;\xd8/#$+\")(\"'#&'#06*%;A/,#;\xd8/#$+\")(\"'#&'#&/#$+\")(\"'#&'#"),C("%;\x99/Y#$%;B/,#;\xa0/#$+\")(\"'#&'#06*%;B/,#;\xa0/#$+\")(\"'#&'#&/#$+\")(\"'#&'#"),C("%$;!/&#0#*;!&&&#/' 8!:ŝ!! )"),C("%;\xdb/Y#$%;B/,#;\xdc/#$+\")(\"'#&'#06*%;B/,#;\xdc/#$+\")(\"'#&'#&/#$+\")(\"'#&'#"),C('%3Ş""5&7ş.; &3Å ""5\'7Å¡./ &3Å¢""5*7Å£.# &;6/& 8!:Ť! )'),C("%3Å¥\"\"5&7Ŧ/:#;</1$;\xdd/($8#:ŧ#! )(#'#(\"'#&'#.} &%3\xf5\"\"5'7\xf6/:#;</1$;\x9e/($8#:Ũ#! )(#'#(\"'#&'#.P &%3Å©\"\"5+7Ū/:#;</1$;\x9e/($8#:Å«#! )(#'#(\"'#&'#.# &;\xa0"),C('3Ŭ""5+7Å­.k &3Å®""5)7ů._ &3Ű""5(7ű.S &3Ų""5\'7ų.G &3Å´""5&7ŵ.; &3Ŷ""5*7Å·./ &3Ÿ""5)7Ź.# &;6'),C(';1." &"'),C('%%;6/k#$%;A/2#;6/)$8":Ś""$ )("\'#&\'#0<*%;A/2#;6/)$8":Ś""$ )("\'#&\'#&/)$8":ś""! )("\'#&\'#." &"/\' 8!:ź!! )'),C("%;L.# &;\x99/]#$%;B/,#;\xe1/#$+\")(\"'#&'#06*%;B/,#;\xe1/#$+\")(\"'#&'#&/'$8\":Å»\" )(\"'#&'#"),C(";\xb9.# &;\xa0"),C("%;\xe3/Y#$%;A/,#;\xe3/#$+\")(\"'#&'#06*%;A/,#;\xe3/#$+\")(\"'#&'#&/#$+\")(\"'#&'#"),C("%;\xea/k#;./b$;\xed/Y$$%;B/,#;\xe4/#$+\")(\"'#&'#06*%;B/,#;\xe4/#$+\")(\"'#&'#&/#$+$)($'#(#'#(\"'#&'#"),C(";\xe5.; &;\xe6.5 &;\xe7./ &;\xe8.) &;\xe9.# &;\xa0"),C("%3ż\"\"5#7Ž/:#;</1$;\xf0/($8#:ž#! )(#'#(\"'#&'#"),C("%3Å¿\"\"5%7ƀ/:#;</1$;T/($8#:Ɓ#! )(#'#(\"'#&'#"),C("%3Ƃ\"\"5(7ƃ/F#;</=$;\\.) &;Y.# &;X/($8#:Ƅ#! )(#'#(\"'#&'#"),C("%3ƅ\"\"5&7Ɔ/:#;</1$;6/($8#:Ƈ#! )(#'#(\"'#&'#"),C("%3ƈ\"\"5%7Ɖ/A#;</8$$;!0#*;!&/($8#:Ɗ#! )(#'#(\"'#&'#"),C("%;\xeb/G#;;/>$;6/5$;;/,$;\xec/#$+%)(%'#($'#(#'#(\"'#&'#"),C('%3\x92""5#7\xd3.# &;6/\' 8!:Ƌ!! )'),C('%3\xb1""5#7ƌ.G &3\xb3""5#7ƍ.; &3\xb7""5#7Ǝ./ &3\xb5""5$7Ə.# &;6/\' 8!:Ɛ!! )'),C('%;\xee/D#%;C/,#;\xef/#$+")("\'#&\'#." &"/#$+")("\'#&\'#'),C("%;U.) &;\\.# &;X/& 8!:Ƒ! )"),C('%%;!." &"/[#;!." &"/M$;!." &"/?$;!." &"/1$;!." &"/#$+%)(%\'#($\'#(#\'#("\'#&\'#/\' 8!:ƒ!! )'),C('%%;!/?#;!." &"/1$;!." &"/#$+#)(#\'#("\'#&\'#/\' 8!:Ɠ!! )'),C(";\xbe"),C('%;\x9e/^#$%;B/,#;\xf3/#$+")("\'#&\'#06*%;B/,#;\xf3/#$+")("\'#&\'#&/($8":Ɣ"!!)("\'#&\'#'),C(";\xf4.# &;\xa0"),C('%2ƕ""6ƕ7Ɩ/L#;</C$2Ɨ""6Ɨ7Ƙ.) &2ƙ""6ƙ7ƚ/($8#:ƛ#! )(#\'#("\'#&\'#'),C('%;\x9e/^#$%;B/,#;\xa0/#$+")("\'#&\'#06*%;B/,#;\xa0/#$+")("\'#&\'#&/($8":Ɯ"!!)("\'#&\'#'),C("%;6/5#;0/,$;\xf7/#$+#)(#'#(\"'#&'#"),C("$;2.) &;4.# &;.0/*;2.) &;4.# &;.&"),C("$;%0#*;%&"),C("%;\xfa/;#28\"\"6879/,$;\xfb/#$+#)(#'#(\"'#&'#"),C('%3Ɲ""5%7ƞ.) &3Ɵ""5$7Æ /\' 8!:Æ¡!! )'),C('%;\xfc/J#%28""6879/,#;^/#$+")("\'#&\'#." &"/#$+")("\'#&\'#'),C("%;\\.) &;X.# &;\x82/' 8!:Æ¢!! )"),C(';".S &;!.M &2F""6F7G.A &2J""6J7K.5 &2H""6H7I.) &2N""6N7O'),C('2L""6L7M.\x95 &2B""6B7C.\x89 &2<""6<7=.} &2R""6R7S.q &2T""6T7U.e &2V""6V7W.Y &2P""6P7Q.M &2@""[email protected] &2D""6D7E.5 &22""6273.) &2>""6>7?'),C('%;Ā/b#28""6879/S$;\xfb/J$%2Æ£""6Æ£7Ƥ/,#;\xec/#$+")("\'#&\'#." &"/#$+$)($\'#(#\'#("\'#&\'#'),C('%3Æ¥""5%7Ʀ.) &3Ƨ""5$7ƨ/\' 8!:Æ¡!! )'),C('%3\xb1""5#7\xb2.6 &3\xb3""5#7\xb4.* &$;+0#*;+&/\' 8!:Æ©!! )'),C("%;Ą/\x87#2F\"\"6F7G/x$;ă/o$2F\"\"6F7G/`$;ă/W$2F\"\"6F7G/H$;ă/?$2F\"\"6F7G/0$;ą/'$8):ƪ) )()'#(('#(''#(&'#(%'#($'#(#'#(\"'#&'#"),C("%;#/>#;#/5$;#/,$;#/#$+$)($'#(#'#(\"'#&'#"),C("%;ă/,#;ă/#$+\")(\"'#&'#"),C("%;ă/5#;ă/,$;ă/#$+#)(#'#(\"'#&'#"),C("%;q/T#$;m0#*;m&/D$%; /,#;\xf8/#$+\")(\"'#&'#.\" &\"/#$+#)(#'#(\"'#&'#"),C('%2Æ«""6Æ«7Ƭ.) &2Æ­""6Æ­7Æ®/w#;0/n$;Ĉ/e$$%;B/2#;ĉ.# &;\xa0/#$+")("\'#&\'#0<*%;B/2#;ĉ.# &;\xa0/#$+")("\'#&\'#&/#$+$)($\'#(#\'#("\'#&\'#'),C(";\x99.# &;L"),C("%2Ư\"\"6Ư7ư/5#;</,$;Ċ/#$+#)(#'#(\"'#&'#"),C("%;D/S#;,/J$2:\"\"6:7;/;$;,.# &;T/,$;E/#$+%)(%'#($'#(#'#(\"'#&'#")],p=0,f=0,m=[{line:1,column:1}],S=0,v=[],T=0;if(void 0!==t.startRule){if(!(t.startRule in d))throw Error("Can't start parsing from rule \""+t.startRule+'".');l=d[t.startRule]}function b(){return e.substring(f,p)}function R(e,t){return{type:"literal",text:e,ignoreCase:t}}function E(e,t,s){return{type:"class",parts:e,inverted:t,ignoreCase:s}}function y(t){let s,i=m[t];if(i)return i;for(s=t-1;!m[s];)s--;for(i={line:(i=m[s]).line,column:i.column};s<t;)10===e.charCodeAt(s)?(i.line++,i.column=1):i.column++,s++;return m[t]=i,i}function I(e,t){let s=y(e),i=y(t);return{start:{offset:e,line:s.line,column:s.column},end:{offset:t,line:i.line,column:i.column}}}function w(e){p<S||(p>S&&(S=p,v=[]),v.push(e))}function C(e){return e.split("").map(e=>e.charCodeAt(0)-32)}if(t.data={},(c=function t(s){let i;let r=u[s],n=0,o=[],a=r.length,c=[],d=[];for(;;){for(;n<a;)switch(r[n]){case 0:d.push(g[r[n+1]]),n+=2;break;case 1:d.push(void 0),n++;break;case 2:d.push(null),n++;break;case 3:d.push(h),n++;break;case 4:d.push([]),n++;break;case 5:d.push(p),n++;break;case 6:d.pop(),n++;break;case 7:p=d.pop(),n++;break;case 8:d.length-=r[n+1],n+=2;break;case 9:d.splice(-2,1),n++;break;case 10:d[d.length-2].push(d.pop()),n++;break;case 11:d.push(d.splice(d.length-r[n+1],r[n+1])),n+=2;break;case 12:d.push(e.substring(d.pop(),p)),n++;break;case 13:c.push(a),o.push(n+3+r[n+1]+r[n+2]),d[d.length-1]?(a=n+3+r[n+1],n+=3):(a=n+3+r[n+1]+r[n+2],n+=3+r[n+1]);break;case 14:c.push(a),o.push(n+3+r[n+1]+r[n+2]),d[d.length-1]===h?(a=n+3+r[n+1],n+=3):(a=n+3+r[n+1]+r[n+2],n+=3+r[n+1]);break;case 15:c.push(a),o.push(n+3+r[n+1]+r[n+2]),d[d.length-1]!==h?(a=n+3+r[n+1],n+=3):(a=n+3+r[n+1]+r[n+2],n+=3+r[n+1]);break;case 16:d[d.length-1]!==h?(c.push(a),o.push(n),a=n+2+r[n+1],n+=2):n+=2+r[n+1];break;case 17:c.push(a),o.push(n+3+r[n+1]+r[n+2]),e.length>p?(a=n+3+r[n+1],n+=3):(a=n+3+r[n+1]+r[n+2],n+=3+r[n+1]);break;
1case 18:c.push(a),o.push(n+4+r[n+2]+r[n+3]),e.substr(p,g[r[n+1]].length)===g[r[n+1]]?(a=n+4+r[n+2],n+=4):(a=n+4+r[n+2]+r[n+3],n+=4+r[n+2]);break;case 19:c.push(a),o.push(n+4+r[n+2]+r[n+3]),e.substr(p,g[r[n+1]].length).toLowerCase()===g[r[n+1]]?(a=n+4+r[n+2],n+=4):(a=n+4+r[n+2]+r[n+3],n+=4+r[n+2]);break;case 20:c.push(a),o.push(n+4+r[n+2]+r[n+3]),g[r[n+1]].test(e.charAt(p))?(a=n+4+r[n+2],n+=4):(a=n+4+r[n+2]+r[n+3],n+=4+r[n+2]);break;case 21:d.push(e.substr(p,r[n+1])),p+=r[n+1],n+=2;break;case 22:d.push(g[r[n+1]]),p+=g[r[n+1]].length,n+=2;break;case 23:d.push(h),0===T&&w(g[r[n+1]]),n+=2;break;case 24:f=d[d.length-1-r[n+1]],n+=2;break;case 25:f=p,n++;break;case 26:i=r.slice(n+4,n+4+r[n+3]).map(function(e){return d[d.length-1-e]}),d.splice(d.length-r[n+2],r[n+2],g[r[n+1]].apply(null,i)),n+=4+r[n+3];break;case 27:d.push(t(r[n+1])),n+=2;break;case 28:T++,n++;break;case 29:T--,n++;break;default:throw Error("Invalid opcode: "+r[n]+".")}if(c.length>0)a=c.pop(),n=o.pop();else break}return d[0]}(l))!==h&&p===e.length)return c;throw c!==h&&p<e.length&&w({type:"end"}),s=v,o=S<e.length?e.charAt(S):null,a=S<e.length?I(S,S+1):I(S,S),new n(n.buildMessage(s,o),s,o,a)}}
1,(e,t,s)=>{s.r(t),s.d(t,{URI:()=>r,equivalentURI:()=>n});var i=s(24);class r extends i.Parameters{constructor(e="sip",t,s,i,r,n){if(super(r||{}),this.headers={},!s)throw TypeError('missing or invalid "host" parameter');for(let e in n)n.hasOwnProperty(e)&&this.setHeader(e,n[e]);this.raw={scheme:e,user:t,host:s,port:i},this.normal={scheme:e.toLowerCase(),user:t,host:s.toLowerCase(),port:i}}get scheme(){return this.normal.scheme}set scheme(e){this.raw.scheme=e,this.normal.scheme=e.toLowerCase()}get user(){return this.normal.user}set user(e){this.normal.user=this.raw.user=e}get host(){return this.normal.host}set host(e){this.raw.host=e,this.normal.host=e.toLowerCase()}get aor(){return this.normal.user+"@"+this.normal.host}get port(){return this.normal.port}set port(e){this.normal.port=this.raw.port=e}setHeader(e,t){this.headers[this.headerize(e)]=t instanceof Array?t:[t]}getHeader(e){if(e)return this.headers[this.headerize(e)]}hasHeader(e){return!!e&&!!this.headers.hasOwnProperty(this.headerize(e))}deleteHeader(e){if(e=this.headerize(e),this.headers.hasOwnProperty(e)){let t=this.headers[e];return delete this.headers[e],t}}clearHeaders(){this.headers={}}clone(){return new r(this._raw.scheme,this._raw.user||"",this._raw.host,this._raw.port,JSON.parse(JSON.stringify(this.parameters)),JSON.parse(JSON.stringify(this.headers)))}toRaw(){return this._toString(this._raw)}toString(){return this._toString(this._normal)}get _normal(){return this.normal}get _raw(){return this.raw}_toString(e){let t=e.scheme+":";for(let s in e.scheme.toLowerCase().match("^sips?$")||(t+="//"),e.user&&(t+=this.escapeUser(e.user)+"@"),t+=e.host,(e.port||0===e.port)&&(t+=":"+e.port),this.parameters)this.parameters.hasOwnProperty(s)&&(t+=";"+s,null!==this.parameters[s]&&(t+="="+this.parameters[s]));let s=[];for(let e in this.headers)if(this.headers.hasOwnProperty(e))for(let t in this.headers[e])this.headers[e].hasOwnProperty(t)&&s.push(e+"="+this.headers[e][t]);return s.length>0&&(t+="?"+s.join("&")),t}escapeUser(e){let t;try{t=decodeURIComponent(e)}catch(e){throw e}return encodeURIComponent(t).replace(/%3A/ig,":").replace(/%2B/ig,"+").replace(/%3F/ig,"?").replace(/%2F/ig,"/")}headerize(e){let t={"Call-Id":"Call-ID",Cseq:"CSeq","Min-Se":"Min-SE",Rack:"RAck",Rseq:"RSeq","Www-Authenticate":"WWW-Authenticate"},s=e.toLowerCase().replace(/_/g,"-").split("-"),i=s.length,r="";for(let e=0;e<i;e++)0!==e&&(r+="-"),r+=s[e].charAt(0).toUpperCase()+s[e].substring(1);return t[r]&&(r=t[r]),r}}function n(e,t){if(e.scheme!==t.scheme||e.user!==t.user||e.host!==t.host||e.port!==t.port||!function(e,t){let s=Object.keys(e.parameters),i=Object.keys(t.parameters);return!!(s.filter(e=>i.includes(e)).every(s=>e.parameters[s]===t.parameters[s])&&["user","ttl","method","transport"].every(s=>e.hasParam(s)&&t.hasParam(s)||!e.hasParam(s)&&!t.hasParam(s))&&["maddr"].every(s=>e.hasParam(s)&&t.hasParam(s)||!e.hasParam(s)&&!t.hasParam(s)))}(e,t))return!1;let s=Object.keys(e.headers),i=Object.keys(t.headers);if(0!==s.length||0!==i.length){if(s.length!==i.length)return!1;let r=s.filter(e=>i.includes(e));if(r.length!==i.length||!r.every(s=>e.headers[s].length&&t.headers[s].length&&e.headers[s][0]===t.headers[s][0]))return!1}return!0}},(e,t,s)=>{s.r(t),s.d(t,{Parameters:()=>i});class i{constructor(e){for(let t in this.parameters={},e)e.hasOwnProperty(t)&&this.setParam(t,e[t])}setParam(e,t){e&&(this.parameters[e.toLowerCase()]=null==t?null:t.toString())}getParam(e){if(e)return this.parameters[e.toLowerCase()]}hasParam(e){return!!(e&&void 0!==this.parameters[e.toLowerCase()])}deleteParam(e){if(e=e.toLowerCase(),this.hasParam(e)){let t=this.parameters[e];return delete this.parameters[e],t}}clearParams(){this.parameters={}}}},(e,t,s)=>{s.r(t),s.d(t,{NameAddrHeader:()=>r});var i=s(24);class r extends i.Parameters{constructor(e,t,s){super(s),this.uri=e,this._displayName=t}get friendlyName(){return this.displayName||this.uri.aor}get displayName(){return this._displayName}set displayName(e){this._displayName=e}clone(){return new r(this.uri.clone(),this._displayName,JSON.parse(JSON.stringify(this.parameters)))}toString(){let e=this.displayName||"0"===this.displayName?'"'+this.displayName+'" ':"";for(let t in e+="<"+this.uri.toString()+">",this.parameters)this.parameters.hasOwnProperty(t)&&(e+=";"+t,null!==this.parameters[t]&&(e+="="+this.parameters[t]));return e}}}
1,(e,t,s)=>{s.r(t),s.d(t,{IncomingResponseMessage:()=>r});var i=s(19);class r extends i.IncomingMessage{constructor(){super()}}},(e,t,s)=>{s.r(t),s.d(t,{OutgoingRequestMessage:()=>n});var i=s(25),r=s(20);class n{constructor(e,t,s,i,o,a,c){this.headers={},this.extraHeaders=[],this.options=n.getDefaultOptions(),o&&(this.options=Object.assign(Object.assign({},this.options),o),this.options.optionTags&&this.options.optionTags.length&&(this.options.optionTags=this.options.optionTags.slice()),this.options.routeSet&&this.options.routeSet.length&&(this.options.routeSet=this.options.routeSet.slice())),a&&a.length&&(this.extraHeaders=a.slice()),c&&(this.body={body:c.content,contentType:c.contentType}),this.method=e,this.ruri=t.clone(),this.fromURI=s.clone(),this.fromTag=this.options.fromTag?this.options.fromTag:(0,r.newTag)(),this.from=n.makeNameAddrHeader(this.fromURI,this.options.fromDisplayName,this.fromTag),this.toURI=i.clone(),this.toTag=this.options.toTag,this.to=n.makeNameAddrHeader(this.toURI,this.options.toDisplayName,this.toTag),this.callId=this.options.callId?this.options.callId:this.options.callIdPrefix+(0,r.createRandomToken)(15),this.cseq=this.options.cseq,this.setHeader("route",this.options.routeSet),this.setHeader("via",""),this.setHeader("to",this.to.toString()),this.setHeader("from",this.from.toString()),this.setHeader("cseq",this.cseq+" "+this.method),this.setHeader("call-id",this.callId),this.setHeader("max-forwards","70")}static getDefaultOptions(){return{callId:"",callIdPrefix:"",cseq:1,toDisplayName:"",toTag:"",fromDisplayName:"",fromTag:"",forceRport:!1,hackViaTcp:!1,optionTags:["outbound"],routeSet:[],userAgentString:"sip.js",viaHost:""}}static makeNameAddrHeader(e,t,s){let r={};return s&&(r.tag=s),new i.NameAddrHeader(e,t,r)}getHeader(e){let t=this.headers[(0,r.headerize)(e)];if(t){if(t[0])return t[0]}else{let t=RegExp("^\\s*"+e+"\\s*:","i");for(let e of this.extraHeaders)if(t.test(e))return e.substring(e.indexOf(":")+1).trim()}}getHeaders(e){let t=[],s=this.headers[(0,r.headerize)(e)];if(s)for(let e of s)t.push(e);else{let s=RegExp("^\\s*"+e+"\\s*:","i");for(let e of this.extraHeaders)s.test(e)&&t.push(e.substring(e.indexOf(":")+1).trim())}return t}hasHeader(e){if(this.headers[(0,r.headerize)(e)])return!0;{let t=RegExp("^\\s*"+e+"\\s*:","i");for(let e of this.extraHeaders)if(t.test(e))return!0}return!1}setHeader(e,t){this.headers[(0,r.headerize)(e)]=t instanceof Array?t:[t]}setViaHeader(e,t){this.options.hackViaTcp&&(t="TCP");let s="SIP/2.0/"+t;s+=" "+this.options.viaHost+";branch="+e,this.options.forceRport&&(s+=";rport"),this.setHeader("via",s),this.branch=e}toString(){let e="";for(let t in e+=this.method+" "+this.ruri.toRaw()+" SIP/2.0\r\n",this.headers)if(this.headers[t])for(let s of this.headers[t])e+=t+": "+s+"\r\n";for(let t of this.extraHeaders)e+=t.trim()+"\r\n";return e+="Supported: "+this.options.optionTags.join(", ")+"\r\nUser-Agent: "+this.options.userAgentString+"\r\n",this.body?"string"==typeof this.body?e+="Content-Length: "+(0,r.utf8Length)(this.body)+"\r\n\r\n"+this.body:this.body.body&&this.body.contentType?e+="Content-Type: "+this.body.contentType+"\r\nContent-Length: "+(0,r.utf8Length)(this.body.body)+"\r\n\r\n"+this.body.body:e+="Content-Length: 0\r\n\r\n":e+="Content-Length: 0\r\n\r\n",e}}},(e,t,s)=>{s.r(t),s.d(t,{AllowedMethods:()=>r});var i=s(29);let r=[i.C.ACK,i.C.BYE,i.C.CANCEL,i.C.INFO,i.C.INVITE,i.C.MESSAGE,i.C.NOTIFY,i.C.OPTIONS,i.C.PRACK,i.C.REFER,i.C.REGISTER,i.C.SUBSCRIBE]},(e,t,s)=>{var i,r;s.r(t),s.d(t,{C:()=>i}),(r=i||(i={})).ACK="ACK",r.BYE="BYE",r.CANCEL="CANCEL",r.INFO="INFO",r.INVITE="INVITE",r.MESSAGE="MESSAGE",r.NOTIFY="NOTIFY",r.OPTIONS="OPTIONS",r.REGISTER="REGISTER",r.UPDATE="UPDATE",r.SUBSCRIBE="SUBSCRIBE",r.PUBLISH="PUBLISH",r.REFER="REFER",r.PRACK="PRACK"},(e,t,s)=>{var i,r,n,o;s.r(t),s.d(t,{SessionState:()=>i,SignalingState:()=>r}),(n=i||(i={})).Initial="Initial",n.Early="Early",n.AckWait="AckWait",n.Confirmed="Confirmed",n.Terminated="Terminated",(o=r||(r={})).Initial="Initial",o.HaveLocalOffer="HaveLocalOffer",o.HaveRemoteOffer="HaveRemoteOffer",o.Stable="Stable",o.Closed="Closed"},(e,t,s)=>{s.r(t),s.d(t,{Message:()=>i});class i{constructor(e){this.incomingMessageRequest=e}get request(){return this.incomingMessageRequest.message}accept(e){return this.incomingMessageRequest.accept(e),Promise.resolve()}reject(e){return this.incomingMessageRequest.reject(e),Promise.resolve()}}}
1,(e,t,s)=>{s.r(t),s.d(t,{Notification:()=>i});class i{constructor(e){this.incomingNotifyRequest=e}get request(){return this.incomingNotifyRequest.message}accept(e){return this.incomingNotifyRequest.accept(e),Promise.resolve()}reject(e){return this.incomingNotifyRequest.reject(e),Promise.resolve()}}},(e,t,s)=>{s.r(t),s.d(t,{Referral:()=>r});var i=s(25);class r{constructor(e,t){this.incomingReferRequest=e,this.session=t}get referTo(){let e=this.incomingReferRequest.message.parseHeader("refer-to");if(!(e instanceof i.NameAddrHeader))throw Error("Failed to parse Refer-To header.");return e}get referredBy(){return this.incomingReferRequest.message.getHeader("referred-by")}get replaces(){let e=this.referTo.uri.getHeader("replaces");return e instanceof Array?e[0]:e}get request(){return this.incomingReferRequest.message}accept(e={statusCode:202}){return this.incomingReferRequest.accept(e),Promise.resolve()}reject(e){return this.incomingReferRequest.reject(e),Promise.resolve()}makeInviter(e){if(this.inviter)return this.inviter;let t=this.referTo.uri.clone();t.clearHeaders();let s=((e=e||{}).extraHeaders||[]).slice(),i=this.replaces;i&&s.push("Replaces: "+decodeURIComponent(i));let r=this.referredBy;return r&&s.push("Referred-By: "+r),e.extraHeaders=s,this.inviter=this.session.userAgent._makeInviter(t,e),this.inviter._referred=this.session,this.session._referral=this.inviter,this.inviter}}},(e,t,s)=>{var i,r;s.r(t),s.d(t,{SIPExtension:()=>i,UserAgentRegisteredOptionTags:()=>n}),(r=i||(i={})).Required="Required",r.Supported="Supported",r.Unsupported="Unsupported";let n={"100rel":!0,199:!0,answermode:!0,"early-session":!0,eventlist:!0,explicitsub:!0,"from-change":!0,"geolocation-http":!0,"geolocation-sip":!0,gin:!0,gruu:!0,histinfo:!0,ice:!0,join:!0,"multiple-refer":!0,norefersub:!0,nosub:!0,outbound:!0,path:!0,policy:!0,precondition:!0,pref:!0,privacy:!0,"recipient-list-invite":!0,"recipient-list-message":!0,"recipient-list-subscribe":!0,replaces:!0,"resource-priority":!0,"sdp-anat":!0,"sec-agree":!0,tdialog:!0,timer:!0,uui:!0}},(e,t,s)=>{s.r(t),s.d(t,{TransactionStateError:()=>r});var i=s(5);class r extends i.Exception{constructor(e){super(e||"Transaction state error.")}}},(e,t,s)=>{s.r(t),s.d(t,{Timers:()=>i});let i={T1:500,T2:4e3,T4:5e3,TIMER_B:32e3,TIMER_D:0,TIMER_F:32e3,TIMER_H:32e3,TIMER_I:0,TIMER_J:0,TIMER_K:0,TIMER_L:32e3,TIMER_M:32e3,TIMER_N:32e3,PROVISIONAL_RESPONSE_INTERVAL:6e4}},(e,t,s)=>{s.r(t),s.d(t,{Inviter:()=>d});var i=s(21),r=s(29),n=s(30),o=s(20),a=s(15),c=s(16),h=s(34);class d extends a.Session{constructor(e,t,s={}){super(e,s),this.disposed=!1,this.earlyMedia=!1,this.earlyMediaSessionDescriptionHandlers=new Map,this.isCanceled=!1,this.inviteWithoutSdp=!1,this.logger=e.getLogger("sip.Inviter"),this.earlyMedia=void 0!==s.earlyMedia?s.earlyMedia:this.earlyMedia,this.fromTag=(0,o.newTag)(),this.inviteWithoutSdp=void 0!==s.inviteWithoutSdp?s.inviteWithoutSdp:this.inviteWithoutSdp;let n=Object.assign({},s);n.params=Object.assign({},s.params);let a=s.anonymous||!1,c=e.contact.toString({anonymous:a,outbound:a?!e.contact.tempGruu:!e.contact.pubGruu});a&&e.configuration.uri&&(n.params.fromDisplayName="Anonymous",n.params.fromUri="sip:[email protected]");let d=e.userAgentCore.configuration.aor;if(n.params.fromUri&&(d="string"==typeof n.params.fromUri?i.Grammar.URIParse(n.params.fromUri):n.params.fromUri),!d)throw TypeError("Invalid from URI: "+n.params.fromUri);let l=t;if(n.params.toUri&&(l="string"==typeof n.params.toUri?i.Grammar.URIParse(n.params.toUri):n.params.toUri),!l)throw TypeError("Invalid to URI: "+n.params.toUri);let g=Object.assign({},n.params);g.fromTag=this.fromTag;let u=(n.extraHeaders||[]).slice();a&&e.configuration.uri&&(u.push("P-Preferred-Identity: "+e.configuration.uri.toString()),u.push("Privacy: id")),u.push("Contact: "+c),u.push("Allow: "+["ACK","CANCEL","INVITE","MESSAGE","BYE","OPTIONS","INFO","NOTIFY","REFER"].toString()),e.configuration.sipExtension100rel===h.SIPExtension.Required&&u.push("Require: 100rel"),e.configuration.sipExtensionReplaces===h.SIPExtension.Required&&u.push("Require: replaces"),n.extraHeaders=u,this.outgoingRequestMessage=e.userAgentCore.makeOutgoingRequestMessage(r.C.INVITE,t,d,l,g,u,void 0),this._contact=c,this._referralInviterOptions=n,this._renderbody=s.renderbody,this._rendertype=s.rendertype,s.sessionDescriptionHandlerModifiers&&(this.sessionDescriptionHandlerModifiers=s.sessionDescriptionHandlerModifiers),s.sessionDescriptionHandlerOptions&&(this.sessionDescriptionHandlerOptions=s.sessionDescriptionHandlerOptions),s.sessionDescriptionHandlerModifiersReInvite&&(this.sessionDescriptionHandlerModifiersReInvite=s.sessionDescriptionHandlerModifiersReInvite),s.sessionDescriptionHandlerOptionsReInvite&&(this.sessionDescriptionHandlerOptionsReInvite=s.sessionDescriptionHandlerOptionsReInvite),this._id=this.outgoingRequestMessage.callId+this.fromTag,this.userAgent._sessions[this._id]=this}dispose(){if(this.disposed)return Promise.resolve();switch(this.disposed=!0,this.disposeEarlyMedia(),this.state){case c.SessionState.Initial:case c.SessionState.Establishing:return this.cancel().then(()=>super.dispose());case c.SessionState.Established:case c.SessionState.Terminating:case c.SessionState.Terminated:return super.dispose();default:throw Error("Unknown state.")}}get body(){return this.outgoingRequestMessage.body}get localIdentity(){return this.outgoingRequestMessage.from}get remoteIdentity(){return this.outgoingRequestMessage.to}get request(){return this.outgoingRequestMessage}cancel(e={}){if(this.logger.log("Inviter.cancel"),this.state!==c.SessionState.Initial&&this.state!==c.SessionState.Establishing){let e=Error(`Invalid session state ${this.state}`);return this.logger.error(e.message),Promise.reject(e)}if(this.isCanceled=!0,this.stateTransition(c.SessionState.Terminating),this.outgoingInviteRequest){let t;e.statusCode&&e.reasonPhrase&&(t=function(e,t){if(e&&e<200||e>699)throw TypeError("Invalid statusCode: "+e);if(e){let s=(0,o.getReasonPhrase)(e)||t;return"SIP;cause="+e+';text="'+s+'"'}}(e.statusCode,e.reasonPhrase)),this.outgoingInviteRequest.cancel(t,e)}else this.logger.warn("Canceled session before INVITE was sent"),this.stateTransition(c.SessionState.Terminated);return Promise.resolve()}invite(e={}){if(this.logger.log("Inviter.invite"),this.state!==c.SessionState.Initial)return super.invite(e);if(e.sessionDescriptionHandlerModifiers&&(this.sessionDescriptionHandlerModifiers=e.sessionDescriptionHandlerModifiers),e.sessionDescriptionHandlerOptions&&(this.sessionDescriptionHandlerOptions=e.sessionDescriptionHandlerOptions),e.withoutSdp||this.inviteWithoutSdp)return this._renderbody&&this._rendertype&&(this.outgoingRequestMessage.body={contentType:this._rendertype,body:this._renderbody}),this.stateTransition(c.SessionState.Establishing),Promise.resolve(this.sendInvite(e));let t={sessionDescriptionHandlerModifiers:this.sessionDescriptionHandlerModifiers,sessionDescriptionHandlerOptions:this.sessionDescriptionHandlerOptions};return this.getOffer(t).then(t=>(this.outgoingRequestMessage.body={body:t.content,contentType:t.contentType},this.stateTransition(c.SessionState.Establishing),this.sendInvite(e))).catch(e=>{throw this.logger.log(e.message),this.stateTransition(c.SessionState.Terminated),e})}sendInvite(e={}){return this.outgoingInviteRequest=this.userAgent.userAgentCore.invite(this.outgoingRequestMessage,{onAccept:t=>{if(this.dialog){this.logger.log("Additional confirmed dialog, sending ACK and BYE"),this.ackAndBye(t);return}if(this.isCanceled){this.logger.log("Canceled session accepted, sending ACK and BYE"),this.ackAndBye(t),this.stateTransition(c.SessionState.Terminated);return}this.notifyReferer(t),this.onAccept(t).then(()=>{this.disposeEarlyMedia()}).catch(()=>{this.disposeEarlyMedia()}).then(()=>{e.requestDelegate&&e.requestDelegate.onAccept&&e.requestDelegate.onAccept(t)}
1)},onProgress:t=>{this.isCanceled||(this.notifyReferer(t),this.onProgress(t).catch(()=>{this.disposeEarlyMedia()}).then(()=>{e.requestDelegate&&e.requestDelegate.onProgress&&e.requestDelegate.onProgress(t)}))},onRedirect:t=>{this.notifyReferer(t),this.onRedirect(t),e.requestDelegate&&e.requestDelegate.onRedirect&&e.requestDelegate.onRedirect(t)},onReject:t=>{this.notifyReferer(t),this.onReject(t),e.requestDelegate&&e.requestDelegate.onReject&&e.requestDelegate.onReject(t)},onTrying:t=>{this.notifyReferer(t),this.onTrying(t),e.requestDelegate&&e.requestDelegate.onTrying&&e.requestDelegate.onTrying(t)}}),this.outgoingInviteRequest}disposeEarlyMedia(){this.earlyMediaSessionDescriptionHandlers.forEach(e=>{e.close()}),this.earlyMediaSessionDescriptionHandlers.clear()}notifyReferer(e){if(!this._referred)return;if(!(this._referred instanceof a.Session))throw Error("Referred session not instance of session");if(!this._referred.dialog)return;if(!e.message.statusCode)throw Error("Status code undefined.");if(!e.message.reasonPhrase)throw Error("Reason phrase undefined.");let t=e.message.statusCode,s=e.message.reasonPhrase,i=`SIP/2.0 ${t} ${s}`.trim();this._referred.dialog.notify(void 0,{extraHeaders:["Event: refer","Subscription-State: terminated"],body:{contentDisposition:"render",contentType:"message/sipfrag",content:i}}).delegate={onReject:()=>{this._referred=void 0}}}onAccept(e){if(this.logger.log("Inviter.onAccept"),this.state!==c.SessionState.Establishing)return this.logger.error(`Accept received while in state ${this.state}, dropping response`),Promise.reject(Error(`Invalid session state ${this.state}`));let t=e.message,s=e.session;switch(t.hasHeader("P-Asserted-Identity")&&(this._assertedIdentity=i.Grammar.nameAddrHeaderParse(t.getHeader("P-Asserted-Identity"))),s.delegate={onAck:e=>this.onAckRequest(e),onBye:e=>this.onByeRequest(e),onInfo:e=>this.onInfoRequest(e),onInvite:e=>this.onInviteRequest(e),onMessage:e=>this.onMessageRequest(e),onNotify:e=>this.onNotifyRequest(e),onPrack:e=>this.onPrackRequest(e),onRefer:e=>this.onReferRequest(e)},this._dialog=s,s.signalingState){case n.SignalingState.Initial:case n.SignalingState.HaveLocalOffer:return this.logger.error("Received 2xx response to INVITE without a session description"),this.ackAndBye(e,400,"Missing session description"),this.stateTransition(c.SessionState.Terminated),Promise.reject(Error("Bad Media Description"));case n.SignalingState.HaveRemoteOffer:{if(!this._dialog.offer)throw Error(`Session offer undefined in signaling state ${this._dialog.signalingState}.`);let t={sessionDescriptionHandlerModifiers:this.sessionDescriptionHandlerModifiers,sessionDescriptionHandlerOptions:this.sessionDescriptionHandlerOptions};return this.setOfferAndGetAnswer(this._dialog.offer,t).then(t=>{e.ack({body:t}),this.stateTransition(c.SessionState.Established)}).catch(t=>{throw this.ackAndBye(e,488,"Invalid session description"),this.stateTransition(c.SessionState.Terminated),t})}case n.SignalingState.Stable:{if(this.earlyMediaSessionDescriptionHandlers.size>0){let t=this.earlyMediaSessionDescriptionHandlers.get(s.id);if(!t)throw Error("Session description handler undefined.");return this.setSessionDescriptionHandler(t),this.earlyMediaSessionDescriptionHandlers.delete(s.id),e.ack(),this.stateTransition(c.SessionState.Established),Promise.resolve()}if(this.earlyMediaDialog){if(this.earlyMediaDialog!==s){this.earlyMedia&&this.logger.error("You have set the 'earlyMedia' option to 'true' which requires that your INVITE requests do not fork and yet this INVITE request did in fact fork. Consequentially and not surprisingly the end point which accepted the INVITE (confirmed dialog) does not match the end point with which early media has been setup (early dialog) and thus this session is unable to proceed. In accordance with the SIP specifications, the SIP servers your end point is connected to determine if an INVITE forks and the forking behavior of those servers cannot be controlled by this library. If you wish to use early media with this library you must configure those servers accordingly. Alternatively you may set the 'earlyMedia' to 'false' which will allow this library to function with any INVITE requests which do fork.");let t=Error("Early media dialog does not equal confirmed dialog, terminating session");return this.logger.error(t.message),this.ackAndBye(e,488,"Not Acceptable Here"),this.stateTransition(c.SessionState.Terminated),Promise.reject(t)}return e.ack(),this.stateTransition(c.SessionState.Established),Promise.resolve()}let t=s.answer;if(!t)throw Error("Answer is undefined.");let i={sessionDescriptionHandlerModifiers:this.sessionDescriptionHandlerModifiers,sessionDescriptionHandlerOptions:this.sessionDescriptionHandlerOptions};return this.setAnswer(t,i).then(()=>{let t;this._renderbody&&this._rendertype&&(t={body:{contentDisposition:"render",contentType:this._rendertype,content:this._renderbody}}),e.ack(t),this.stateTransition(c.SessionState.Established)}).catch(t=>{throw this.logger.error(t.message),this.ackAndBye(e,488,"Not Acceptable Here"),this.stateTransition(c.SessionState.Terminated),t})}case n.SignalingState.Closed:return Promise.reject(Error("Terminated."));default:throw Error("Unknown session signaling state.")}}onProgress(e){var t;if(this.logger.log("Inviter.onProgress"),this.state!==c.SessionState.Establishing)return this.logger.error(`Progress received while in state ${this.state}, dropping response`),Promise.reject(Error(`Invalid session state ${this.state}`));if(!this.outgoingInviteRequest)throw Error("Outgoing INVITE request undefined.");let s=e.message,r=e.session;s.hasHeader("P-Asserted-Identity")&&(this._assertedIdentity=i.Grammar.nameAddrHeaderParse(s.getHeader("P-Asserted-Identity")));let o=s.getHeader("require"),a=s.getHeader("rseq"),h=!!(o&&o.includes("100rel")&&a?Number(a):void 0),d=[];switch(h&&d.push("RAck: "+s.getHeader("rseq")+" "+s.getHeader("cseq")),r.signalingState){case n.SignalingState.Initial:return h&&(this.logger.warn("First reliable provisional response received MUST contain an offer when INVITE does not contain an offer."),e.prack({extraHeaders:d})),Promise.resolve();case n.SignalingState.HaveLocalOffer:return h&&e.prack({extraHeaders:d}),Promise.resolve();case n.SignalingState.HaveRemoteOffer:if(!h)return this.logger.warn("Non-reliable provisional response MUST NOT contain an initial offer, discarding response."),Promise.resolve();{let i=this.sessionDescriptionHandlerFactory(this,this.userAgent.configuration.sessionDescriptionHandlerFactoryOptions||{});return(null===(t=this.delegate)||void 0===t?void 0:t.onSessionDescriptionHandler)&&this.delegate.onSessionDescriptionHandler(i,!0),this.earlyMediaSessionDescriptionHandlers.set(r.id,i),i.setDescription(s.body,this.sessionDescriptionHandlerOptions,this.sessionDescriptionHandlerModifiers).then(()=>i.getDescription(this.sessionDescriptionHandlerOptions,this.sessionDescriptionHandlerModifiers)).then(t=>{let s={contentDisposition:"session",contentType:t.contentType,content:t.body};e.prack({extraHeaders:d,body:s})}).catch(e=>{throw this.stateTransition(c.SessionState.Terminated),e})}case n.SignalingState.Stable:if(h&&e.prack({extraHeaders:d}),this.earlyMedia&&!this.earlyMediaDialog){this.earlyMediaDialog=r;let e=r.answer;if(!e)throw Error("Answer is undefined.");let t={sessionDescriptionHandlerModifiers:this.sessionDescriptionHandlerModifiers,sessionDescriptionHandlerOptions:this.sessionDescriptionHandlerOptions};return this.setAnswer(e,t).catch(e=>{throw this.stateTransition(c.SessionState.Terminated),e})}return Promise.resolve();case n.SignalingState.Closed:return Promise.reject(Error("Terminated."));default:throw Error("Unknown session signaling state.")}}onRedirect(e){if(this.logger.log("Inviter.onRedirect"),this.state!==c.SessionState.Establishing&&this.state!==c.SessionState.Terminating){this.logger.error(`Redirect received while in state ${this.state}, dropping response`);return}this.stateTransition(c.SessionState.Terminated)}onReject(e){if(this.logger.log("Inviter.onReject"),this.state!==c.SessionState.Establishing&&this.state!==c.SessionState.Terminating){this.logger.error(`Reject received while in state ${this.state}, dropping response`);return}this.stateTransition(c.SessionState.Terminated)}onTrying(e){if(this.logger.log("Inviter.onTrying"),this.state!==c.SessionState.Establishing){this.logger.error(`Trying received while in state ${this.state}, dropping response`);return}}}}
1,(e,t,s)=>{s.r(t),s.d(t,{Messager:()=>n});var i=s(21),r=s(29);class n{constructor(e,t,s,n="text/plain",o={}){this.logger=e.getLogger("sip.Messager"),o.params=o.params||{};let a=e.userAgentCore.configuration.aor;if(o.params.fromUri&&(a="string"==typeof o.params.fromUri?i.Grammar.URIParse(o.params.fromUri):o.params.fromUri),!a)throw TypeError("Invalid from URI: "+o.params.fromUri);let c=t;if(o.params.toUri&&(c="string"==typeof o.params.toUri?i.Grammar.URIParse(o.params.toUri):o.params.toUri),!c)throw TypeError("Invalid to URI: "+o.params.toUri);let h=o.params?Object.assign({},o.params):{},d=(o.extraHeaders||[]).slice();this.request=e.userAgentCore.makeOutgoingRequestMessage(r.C.MESSAGE,t,a,c,h,d,{contentDisposition:"render",contentType:n,content:s}),this.userAgent=e}message(e={}){return this.userAgent.userAgentCore.request(this.request,e.requestDelegate),Promise.resolve()}}},(e,t,s)=>{var i,r;s.r(t),s.d(t,{PublisherState:()=>i}),(r=i||(i={})).Initial="Initial",r.Published="Published",r.Unpublished="Unpublished",r.Terminated="Terminated"},(e,t,s)=>{s.r(t),s.d(t,{Publisher:()=>a});var i=s(29),r=s(17),n=s(12),o=s(39);class a{constructor(e,t,s,r={}){let a;this.disposed=!1,this._state=o.PublisherState.Initial,this._stateEventEmitter=new n.EmitterImpl,this.userAgent=e,r.extraHeaders=(r.extraHeaders||[]).slice(),r.contentType=r.contentType||"text/plain","number"!=typeof r.expires||r.expires%1!=0?r.expires=3600:r.expires=Number(r.expires),"boolean"!=typeof r.unpublishOnClose&&(r.unpublishOnClose=!0),this.target=t,this.event=s,this.options=r,this.pubRequestExpires=r.expires,this.logger=e.getLogger("sip.Publisher");let c=r.params||{},h=c.fromUri?c.fromUri:e.userAgentCore.configuration.aor,d=c.toUri?c.toUri:t;r.body&&r.contentType&&(a={contentDisposition:"render",contentType:r.contentType,content:r.body});let l=(r.extraHeaders||[]).slice();this.request=e.userAgentCore.makeOutgoingRequestMessage(i.C.PUBLISH,t,h,d,c,l,a),this.id=this.target.toString()+":"+this.event,this.userAgent._publishers[this.id]=this}dispose(){return this.disposed?Promise.resolve():(this.disposed=!0,this.logger.log(`Publisher ${this.id} in state ${this.state} is being disposed`),delete this.userAgent._publishers[this.id],this.options.unpublishOnClose&&this.state===o.PublisherState.Published)?this.unpublish():(this.publishRefreshTimer&&(clearTimeout(this.publishRefreshTimer),this.publishRefreshTimer=void 0),this.pubRequestBody=void 0,this.pubRequestExpires=0,this.pubRequestEtag=void 0,Promise.resolve())}get state(){return this._state}get stateChange(){return this._stateEventEmitter}publish(e,t={}){if(this.publishRefreshTimer&&(clearTimeout(this.publishRefreshTimer),this.publishRefreshTimer=void 0),this.options.body=e,this.pubRequestBody=this.options.body,0===this.pubRequestExpires){if(void 0===this.options.expires)throw Error("Expires undefined.");this.pubRequestExpires=this.options.expires,this.pubRequestEtag=void 0}return this.sendPublishRequest(),Promise.resolve()}unpublish(e={}){return this.publishRefreshTimer&&(clearTimeout(this.publishRefreshTimer),this.publishRefreshTimer=void 0),this.pubRequestBody=void 0,this.pubRequestExpires=0,void 0!==this.pubRequestEtag&&this.sendPublishRequest(),Promise.resolve()}receiveResponse(e){let t=e.statusCode||0;switch(!0){case/^1[0-9]{2}$/.test(t.toString()):break;case/^2[0-9]{2}$/.test(t.toString()):if(e.hasHeader("SIP-ETag")?this.pubRequestEtag=e.getHeader("SIP-ETag"):this.logger.warn("SIP-ETag header missing in a 200-class response to PUBLISH"),e.hasHeader("Expires")){let t=Number(e.getHeader("Expires"));"number"==typeof t&&t>=0&&t<=this.pubRequestExpires?this.pubRequestExpires=t:this.logger.warn("Bad Expires header in a 200-class response to PUBLISH")}else this.logger.warn("Expires header missing in a 200-class response to PUBLISH");0!==this.pubRequestExpires?(this.publishRefreshTimer=setTimeout(()=>this.refreshRequest(),900*this.pubRequestExpires),this._state!==o.PublisherState.Published&&this.stateTransition(o.PublisherState.Published)):this.stateTransition(o.PublisherState.Unpublished);break;case/^412$/.test(t.toString()):if(void 0!==this.pubRequestEtag&&0!==this.pubRequestExpires){if(this.logger.warn("412 response to PUBLISH, recovering"),this.pubRequestEtag=void 0,void 0===this.options.body)throw Error("Body undefined.");this.publish(this.options.body)}else this.logger.warn("412 response to PUBLISH, recovery failed"),this.pubRequestExpires=0,this.stateTransition(o.PublisherState.Unpublished),this.stateTransition(o.PublisherState.Terminated);break;case/^423$/.test(t.toString()):if(0!==this.pubRequestExpires&&e.hasHeader("Min-Expires")){let t=Number(e.getHeader("Min-Expires"));if("number"==typeof t||t>
1this.pubRequestExpires){if(this.logger.warn("423 code in response to PUBLISH, adjusting the Expires value and trying to recover"),this.pubRequestExpires=t,void 0===this.options.body)throw Error("Body undefined.");this.publish(this.options.body)}else this.logger.warn("Bad 423 response Min-Expires header received for PUBLISH"),this.pubRequestExpires=0,this.stateTransition(o.PublisherState.Unpublished),this.stateTransition(o.PublisherState.Terminated)}else this.logger.warn("423 response to PUBLISH, recovery failed"),this.pubRequestExpires=0,this.stateTransition(o.PublisherState.Unpublished),this.stateTransition(o.PublisherState.Terminated);break;default:this.pubRequestExpires=0,this.stateTransition(o.PublisherState.Unpublished),this.stateTransition(o.PublisherState.Terminated)}0===this.pubRequestExpires&&(this.publishRefreshTimer&&(clearTimeout(this.publishRefreshTimer),this.publishRefreshTimer=void 0),this.pubRequestBody=void 0,this.pubRequestEtag=void 0)}send(){return this.userAgent.userAgentCore.publish(this.request,{onAccept:e=>this.receiveResponse(e.message),onProgress:e=>this.receiveResponse(e.message),onRedirect:e=>this.receiveResponse(e.message),onReject:e=>this.receiveResponse(e.message),onTrying:e=>this.receiveResponse(e.message)})}refreshRequest(){if(this.publishRefreshTimer&&(clearTimeout(this.publishRefreshTimer),this.publishRefreshTimer=void 0),this.pubRequestBody=void 0,void 0===this.pubRequestEtag)throw Error("Etag undefined");if(0===this.pubRequestExpires)throw Error("Expires zero");this.sendPublishRequest()}sendPublishRequest(){let e,t;let s=Object.assign({},this.options);s.extraHeaders=(this.options.extraHeaders||[]).slice(),s.extraHeaders.push("Event: "+this.event),s.extraHeaders.push("Expires: "+this.pubRequestExpires),void 0!==this.pubRequestEtag&&s.extraHeaders.push("SIP-If-Match: "+this.pubRequestEtag);let n=this.target,o=this.options.params||{};if(void 0!==this.pubRequestBody){if(void 0===this.options.contentType)throw Error("Content type undefined.");e={body:this.pubRequestBody,contentType:this.options.contentType}}return e&&(t=(0,r.fromBodyLegacy)(e)),this.request=this.userAgent.userAgentCore.makeOutgoingRequestMessage(i.C.PUBLISH,n,o.fromUri?o.fromUri:this.userAgent.userAgentCore.configuration.aor,o.toUri?o.toUri:this.target,o,s.extraHeaders,t),this.send()}stateTransition(e){let t=()=>{throw Error(`Invalid state transition from ${this._state} to ${e}`)};switch(this._state){case o.PublisherState.Initial:e!==o.PublisherState.Published&&e!==o.PublisherState.Unpublished&&e!==o.PublisherState.Terminated&&t();break;case o.PublisherState.Published:e!==o.PublisherState.Unpublished&&e!==o.PublisherState.Terminated&&t();break;case o.PublisherState.Unpublished:e!==o.PublisherState.Published&&e!==o.PublisherState.Terminated&&t();break;case o.PublisherState.Terminated:t();break;default:throw Error("Unrecognized state.")}this._state=e,this.logger.log(`Publication transitioned to state ${this._state}`),this._stateEventEmitter.emit(this._state),e===o.PublisherState.Terminated&&this.dispose()}}},(e,t,s)=>{var i,r;s.r(t),s.d(t,{RegistererState:()=>i}),(r=i||(i={})).Initial="Initial",r.Registered="Registered",r.Unregistered="Unregistered",r.Terminated="Terminated"},(e,t,s)=>{s.r(t),s.d(t,{Registerer:()=>h});var i=s(21),r=s(29),n=s(23),o=s(12),a=s(6),c=s(41);class h{constructor(e,t={}){this.disposed=!1,this._contacts=[],this._retryAfter=void 0,this._state=c.RegistererState.Initial,this._waiting=!1,this._stateEventEmitter=new o.EmitterImpl,this._waitingEventEmitter=new o.EmitterImpl,this.userAgent=e;let s=e.configuration.uri.clone();if(s.user=void 0,this.options=Object.assign(Object.assign(Object.assign({},h.defaultOptions()),{registrar:s}),h.stripUndefinedProperties(t)),this.options.extraContactHeaderParams=(this.options.extraContactHeaderParams||[]).slice(),this.options.extraHeaders=(this.options.extraHeaders||[]).slice(),!this.options.registrar)throw Error("Registrar undefined.");if(this.options.registrar=this.options.registrar.clone(),this.options.regId&&!this.options.instanceId?this.options.instanceId=h.newUUID():!this.options.regId&&this.options.instanceId&&(this.options.regId=1),this.options.instanceId&&-1===i.Grammar.parse(this.options.instanceId,"uuid"))throw Error("Invalid instanceId.");if(this.options.regId&&this.options.regId<0)throw Error("Invalid regId.");let n=this.options.registrar,a=this.options.params&&this.options.params.fromUri||e.userAgentCore.configuration.aor,d=this.options.params&&this.options.params.toUri||e.configuration.uri,l=this.options.params||{},g=(t.extraHeaders||[]).slice();if(this.request=e.userAgentCore.makeOutgoingRequestMessage(r.C.REGISTER,n,a,d,l,g,void 0),this.expires=this.options.expires||h.defaultExpires,this.expires<0)throw Error("Invalid expires.");if(this.refreshFrequency=this.options.refreshFrequency||h.defaultRefreshFrequency,this.refreshFrequency<50||this.refreshFrequency>99)throw Error("Invalid refresh frequency. The value represents a percentage of the expiration time and should be between 50 and 99.");this.logger=e.getLogger("sip.Registerer"),this.options.logConfiguration&&(this.logger.log("Configuration:"),Object.keys(this.options).forEac
1h(e=>{let t=this.options[e];"registrar"===e?this.logger.log("\xb7 "+e+": "+t):this.logger.log("\xb7 "+e+": "+JSON.stringify(t))})),this.id=this.request.callId+this.request.from.parameters.tag,this.userAgent._registerers[this.id]=this}static defaultOptions(){return{expires:h.defaultExpires,extraContactHeaderParams:[],extraHeaders:[],logConfiguration:!0,instanceId:"",params:{},regId:0,registrar:new n.URI("sip","anonymous","anonymous.invalid"),refreshFrequency:h.defaultRefreshFrequency}}static newUUID(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.floor(16*Math.random());return("x"===e?t:t%4+8).toString(16)})}static stripUndefinedProperties(e){return Object.keys(e).reduce((t,s)=>(void 0!==e[s]&&(t[s]=e[s]),t),{})}get contacts(){return this._contacts.slice()}get retryAfter(){return this._retryAfter}get state(){return this._state}get stateChange(){return this._stateEventEmitter}dispose(){return this.disposed?Promise.resolve():(this.disposed=!0,this.logger.log(`Registerer ${this.id} in state ${this.state} is being disposed`),delete this.userAgent._registerers[this.id],new Promise(e=>{let t=()=>{if(!this.waiting&&this._state===c.RegistererState.Registered){this.stateChange.addListener(()=>{this.terminated(),e()},{once:!0}),this.unregister();return}this.terminated(),e()};this.waiting?this.waitingChange.addListener(()=>{t()},{once:!0}):t()}))}register(e={}){if(this.state===c.RegistererState.Terminated)throw this.stateError(),Error("Registerer terminated. Unable to register.");if(this.disposed)throw this.stateError(),Error("Registerer disposed. Unable to register.");if(this.waiting)return this.waitingWarning(),Promise.reject(new a.RequestPendingError("REGISTER request already in progress, waiting for final response"));e.requestOptions&&(this.options=Object.assign(Object.assign({},this.options),e.requestOptions));let t=(this.options.extraHeaders||[]).slice();return t.push("Contact: "+this.generateContactHeader(this.expires)),t.push("Allow: "+["ACK","CANCEL","INVITE","MESSAGE","BYE","OPTIONS","INFO","NOTIFY","REFER"].toString()),this.request.cseq++,this.request.setHeader("cseq",this.request.cseq+" REGISTER"),this.request.extraHeaders=t,this.waitingToggle(!0),Promise.resolve(this.userAgent.userAgentCore.register(this.request,{onAccept:t=>{let s,r;t.message.hasHeader("expires")&&(s=Number(t.message.getHeader("expires"))),this._contacts=t.message.getHeaders("contact");let o=this._contacts.length;if(!o){this.logger.error("No Contact header in response to REGISTER, dropping response."),this.unregistered();return}for(;o--;){if(!(r=t.message.parseHeader("contact",o)))throw Error("Contact undefined");if(this.userAgent.contact.pubGruu&&(0,n.equivalentURI)(r.uri,this.userAgent.contact.pubGruu)){s=Number(r.getParam("expires"));break}if(""===this.userAgent.configuration.contactName){if(r.uri.user===this.userAgent.contact.uri.user){s=Number(r.getParam("expires"));break}}else if((0,n.equivalentURI)(r.uri,this.userAgent.contact.uri)){s=Number(r.getParam("expires"));break}r=void 0}if(void 0===r){this.logger.error("No Contact header pointing to us, dropping response"),this.unregistered(),this.waitingToggle(!1);return}if(void 0===s){this.logger.error("Contact pointing to us is missing expires parameter, dropping response"),this.unregistered(),this.waitingToggle(!1);return}if(r.hasParam("temp-gruu")){let e=r.getParam("temp-gruu");e&&(this.userAgent.contact.tempGruu=i.Grammar.URIParse(e.replace(/"/g,"")))}if(r.hasParam("pub-gruu")){let e=r.getParam("pub-gruu");e&&(this.userAgent.contact.pubGruu=i.Grammar.URIParse(e.replace(/"/g,"")))}this.registered(s),e.requestDelegate&&e.requestDelegate.onAccept&&e.requestDelegate.onAccept(t),this.waitingToggle(!1)},onProgress:t=>{e.requestDelegate&&e.requestDelegate.onProgress&&e.requestDelegate.onProgress(t)},onRedirect:t=>{this.logger.error("Redirect received. Not supported."),this.unregistered(),e.requestDelegate&&e.requestDelegate.onRedirect&&e.requestDelegate.onRedirect(t),this.waitingToggle(!1)},onReject:t=>{if(423===t.message.statusCode){if(!t.message.hasHeader("min-expires")){this.logger.error("423 response received for REGISTER without Min-Expires, dropping response"),this.unregistered(),this.waitingToggle(!1);return}this.expires=Number(t.message.getHeader("min-expires")),this.waitingToggle(!1),this.register();return}this.logger.warn(`Failed to register, status code ${t.message.statusCode}`);let s=NaN;if(500===t.message.statusCode||503===t.message.statusCode){let e=t.message.getHeader("retry-after");e&&(s=Number.parseInt(e,void 0))}this._retryAfter=isNaN(s)?void 0:s,this.unregistered(),e.requestDelegate&&e.requestDelegate.onReject&&e.requestDelegate.onReject(t),this._retryAfter=void 0,this.waitingToggle(!1)},onTrying:t=>{e.requestDelegate&&e.requestDelegate.onTrying&&e.requestDelegate.onTrying(t)}
1}))}unregister(e={}){if(this.state===c.RegistererState.Terminated)throw this.stateError(),Error("Registerer terminated. Unable to register.");if(this.disposed&&this.state!==c.RegistererState.Registered)throw this.stateError(),Error("Registerer disposed. Unable to register.");if(this.waiting)return this.waitingWarning(),Promise.reject(new a.RequestPendingError("REGISTER request already in progress, waiting for final response"));this._state===c.RegistererState.Registered||e.all||this.logger.warn("Not currently registered, but sending an unregister anyway.");let t=(e.requestOptions&&e.requestOptions.extraHeaders||[]).slice();return this.request.extraHeaders=t,e.all?(t.push("Contact: *"),t.push("Expires: 0")):t.push("Contact: "+this.generateContactHeader(0)),this.request.cseq++,this.request.setHeader("cseq",this.request.cseq+" REGISTER"),void 0!==this.registrationTimer&&(clearTimeout(this.registrationTimer),this.registrationTimer=void 0),this.waitingToggle(!0),Promise.resolve(this.userAgent.userAgentCore.register(this.request,{onAccept:t=>{this._contacts=t.message.getHeaders("contact"),this.unregistered(),e.requestDelegate&&e.requestDelegate.onAccept&&e.requestDelegate.onAccept(t),this.waitingToggle(!1)},onProgress:t=>{e.requestDelegate&&e.requestDelegate.onProgress&&e.requestDelegate.onProgress(t)},onRedirect:t=>{this.logger.error("Unregister redirected. Not currently supported."),this.unregistered(),e.requestDelegate&&e.requestDelegate.onRedirect&&e.requestDelegate.onRedirect(t),this.waitingToggle(!1)},onReject:t=>{this.logger.error(`Unregister rejected with status code ${t.message.statusCode}`),this.unregistered(),e.requestDelegate&&e.requestDelegate.onReject&&e.requestDelegate.onReject(t),this.waitingToggle(!1)},onTrying:t=>{e.requestDelegate&&e.requestDelegate.onTrying&&e.requestDelegate.onTrying(t)}}))}clearTimers(){void 0!==this.registrationTimer&&(clearTimeout(this.registrationTimer),this.registrationTimer=void 0),void 0!==this.registrationExpiredTimer&&(clearTimeout(this.registrationExpiredTimer),this.registrationExpiredTimer=void 0)}generateContactHeader(e){let t=this.userAgent.contact.toString();return this.options.regId&&this.options.instanceId&&(t+=";reg-id="+this.options.regId+';+sip.instance="<urn:uuid:'+this.options.instanceId+'>"'),this.options.extraContactHeaderParams&&this.options.extraContactHeaderParams.forEach(e=>{t+=";"+e}),t+=";expires="+e}registered(e){this.clearTimers(),this.registrationTimer=setTimeout(()=>{this.registrationTimer=void 0,this.register()},this.refreshFrequency/100*e*1e3),this.registrationExpiredTimer=setTimeout(()=>{this.logger.warn("Registration expired"),this.unregistered()},1e3*e),this._state!==c.RegistererState.Registered&&this.stateTransition(c.RegistererState.Registered)}unregistered(){this.clearTimers(),this._state!==c.RegistererState.Unregistered&&this.stateTransition(c.RegistererState.Unregistered)}terminated(){this.clearTimers(),this._state!==c.RegistererState.Terminated&&this.stateTransition(c.RegistererState.Terminated)}stateTransition(e){let t=()=>{throw Error(`Invalid state transition from ${this._state} to ${e}`)};switch(this._state){case c.RegistererState.Initial:e!==c.RegistererState.Registered&&e!==c.RegistererState.Unregistered&&e!==c.RegistererState.Terminated&&t();break;case c.RegistererState.Registered:e!==c.RegistererState.Unregistered&&e!==c.RegistererState.Terminated&&t();break;case c.RegistererState.Unregistered:e!==c.RegistererState.Registered&&e!==c.RegistererState.Terminated&&t();break;case c.RegistererState.Terminated:t();break;default:throw Error("Unrecognized state.")}this._state=e,this.logger.log(`Registration transitioned to state ${this._state}`),this._stateEventEmitter.emit(this._state),e===c.RegistererState.Terminated&&this.dispose()}get waiting(){return this._waiting}get waitingChange(){return this._waitingEventEmitter}waitingToggle(e){if(this._waiting===e)throw Error(`Invalid waiting transition from ${this._waiting} to ${e}`);this._waiting=e,this.logger.log(`Waiting toggled to ${this._waiting}`),this._waitingEventEmitter.emit(this._waiting)}
1waitingWarning(){let e="An attempt was made to send a REGISTER request while a prior one was still in progress.";e+=" RFC 3261 requires UAs MUST NOT send a new registration until they have received a final response from the registrar for the previous one or the previous REGISTER request has timed out. Note that if the transport disconnects, you still must wait for the prior request to time out before sending a new REGISTER request or alternatively dispose of the current Registerer and create a new Registerer.",this.logger.warn(e)}stateError(){let e=this.state===c.RegistererState.Terminated?"is in 'Terminated' state":"has been disposed",t=`An attempt was made to send a REGISTER request when the Registerer ${e}.`;t+=" The Registerer transitions to 'Terminated' when Registerer.dispose() is called. Perhaps you called UserAgent.stop() which dipsoses of all Registerers?",this.logger.error(t)}}h.defaultExpires=600,h.defaultRefreshFrequency=99},(e,t,s)=>{s.r(t),s.d(t,{Subscriber:()=>d});var i=s(46),r=s(17),n=s(29),o=s(28),a=s(32),c=s(44),h=s(45);class d extends c.Subscription{constructor(e,t,s,i={}){super(e,i),this.body=void 0,this.logger=e.getLogger("sip.Subscriber"),i.body&&(this.body={body:i.body,contentType:i.contentType?i.contentType:"application/sdp"}),this.targetURI=t,this.event=s,void 0===i.expires?this.expires=3600:"number"!=typeof i.expires?(this.logger.warn('Option "expires" must be a number. Using default of 3600.'),this.expires=3600):this.expires=i.expires,this.extraHeaders=(i.extraHeaders||[]).slice(),this.subscriberRequest=this.initSubscriberRequest(),this.outgoingRequestMessage=this.subscriberRequest.message,this.id=this.outgoingRequestMessage.callId+this.outgoingRequestMessage.from.parameters.tag+this.event,this._userAgent._subscriptions[this.id]=this}dispose(){return this.disposed?Promise.resolve():(this.logger.log(`Subscription ${this.id} in state ${this.state} is being disposed`),delete this._userAgent._subscriptions[this.id],this.retryAfterTimer&&(clearTimeout(this.retryAfterTimer),this.retryAfterTimer=void 0),this.subscriberRequest.dispose(),super.dispose().then(()=>{if(this.state===h.SubscriptionState.Subscribed){if(!this._dialog)throw Error("Dialog undefined.");if(this._dialog.subscriptionState===i.SubscriptionState.Pending||this._dialog.subscriptionState===i.SubscriptionState.Active){let e=this._dialog;return new Promise((t,s)=>{e.delegate={onTerminated:()=>t()},e.unsubscribe()})}}}))}subscribe(e={}){switch(this.subscriberRequest.state){case i.SubscriptionState.Initial:this.state===h.SubscriptionState.Initial&&this.stateTransition(h.SubscriptionState.NotifyWait),this.subscriberRequest.subscribe().then(e=>{e.success?(e.success.subscription&&(this._dialog=e.success.subscription,this._dialog.delegate={onNotify:e=>this.onNotify(e),onRefresh:e=>this.onRefresh(e),onTerminated:()=>{this.state!==h.SubscriptionState.Terminated&&this.stateTransition(h.SubscriptionState.Terminated)}}),this.onNotify(e.success.request)):e.failure&&this.unsubscribe()});break;case i.SubscriptionState.NotifyWait:case i.SubscriptionState.Pending:break;case i.SubscriptionState.Active:this._dialog&&(this._dialog.refresh().delegate={onAccept:e=>this.onAccepted(e),onRedirect:e=>this.unsubscribe(),onReject:e=>this.unsubscribe()});case i.SubscriptionState.Terminated:}return Promise.resolve()}unsubscribe(e={}){if(this.disposed)return Promise.resolve();switch(this.subscriberRequest.state){case i.SubscriptionState.Initial:case i.SubscriptionState.NotifyWait:break;case i.SubscriptionState.Pending:case i.SubscriptionState.Active:this._dialog&&this._dialog.unsubscribe();break;case i.SubscriptionState.Terminated:break;default:throw Error("Unknown state.")}return this.stateTransition(h.SubscriptionState.Terminated),Promise.resolve()}_refresh(){return this.subscriberRequest.state===i.SubscriptionState.Active?this.subscribe():Promise.resolve()}onAccepted(e){}onNotify(e){if(this.disposed){e.accept();return}if(this.state!==h.SubscriptionState.Subscribed&&this.stateTransition(h.SubscriptionState.Subscribed),this.delegate&&this.delegate.onNotify){let t=new a.Notification(e);this.delegate.onNotify(t)}else e.accept();let t=e.message.parseHeader("Subscription-State");if(t&&t.state&&"terminated"===t.state){if(t.reason)switch(this.logger.log(`Terminated subscription with reason ${t.reason}`),t.reason){case"deactivated":case"timeout":this.initSubscriberRequest
1(),this.subscribe();return;case"probation":case"giveup":this.initSubscriberRequest(),t.params&&t.params["retry-after"]?this.retryAfterTimer=setTimeout(()=>{this.subscribe()},t.params["retry-after"]):this.subscribe();return}this.unsubscribe()}}onRefresh(e){e.delegate={onAccept:e=>this.onAccepted(e)}}initSubscriberRequest(){let e={extraHeaders:this.extraHeaders,body:this.body?(0,r.fromBodyLegacy)(this.body):void 0};return this.subscriberRequest=new l(this._userAgent.userAgentCore,this.targetURI,this.event,this.expires,e),this.subscriberRequest.delegate={onAccept:e=>this.onAccepted(e)},this.subscriberRequest}}class l{constructor(e,t,s,i,r,a){this.core=e,this.target=t,this.event=s,this.expires=i,this.subscribed=!1,this.logger=e.loggerFactory.getLogger("sip.Subscriber"),this.delegate=a;let c="Allow: "+o.AllowedMethods.toString(),h=(r&&r.extraHeaders||[]).slice();h.push(c),h.push("Event: "+this.event),h.push("Expires: "+this.expires),h.push("Contact: "+this.core.configuration.contact.toString());let d=r&&r.body;this.message=e.makeOutgoingRequestMessage(n.C.SUBSCRIBE,this.target,this.core.configuration.aor,this.target,{},h,d)}dispose(){this.request&&(this.request.waitNotifyStop(),this.request.dispose(),this.request=void 0)}get state(){return this.subscription?this.subscription.subscriptionState:this.subscribed?i.SubscriptionState.NotifyWait:i.SubscriptionState.Initial}subscribe(){return this.subscribed?Promise.reject(Error("Not in initial state. Did you call subscribe more than once?")):(this.subscribed=!0,new Promise(e=>{if(!this.message)throw Error("Message undefined.");this.request=this.core.subscribe(this.message,{onAccept:e=>{this.delegate&&this.delegate.onAccept&&this.delegate.onAccept(e)},onNotify:t=>{this.subscription=t.subscription,this.subscription&&(this.subscription.autoRefresh=!0),e({success:t})},onNotifyTimeout:()=>{e({failure:{}})},onRedirect:t=>{e({failure:{response:t}})},onReject:t=>{e({failure:{response:t}})}})}))}}},(e,t,s)=>{s.r(t),s.d(t,{Subscription:()=>n});var i=s(12),r=s(45);class n{constructor(e,t={}){this._disposed=!1,this._state=r.SubscriptionState.Initial,this._logger=e.getLogger("sip.Subscription"),this._stateEventEmitter=new i.EmitterImpl,this._userAgent=e,this.delegate=t.delegate}dispose(){return this._disposed||(this._disposed=!0,this._stateEventEmitter.removeAllListeners()),Promise.resolve()}get dialog(){return this._dialog}get disposed(){return this._disposed}get state(){return this._state}get stateChange(){return this._stateEventEmitter}stateTransition(e){let t=()=>{throw Error(`Invalid state transition from ${this._state} to ${e}`)};switch(this._state){case r.SubscriptionState.Initial:e!==r.SubscriptionState.NotifyWait&&e!==r.SubscriptionState.Terminated&&t();break;case r.SubscriptionState.NotifyWait:e!==r.SubscriptionState.Subscribed&&e!==r.SubscriptionState.Terminated&&t();break;case r.SubscriptionState.Subscribed:e!==r.SubscriptionState.Terminated&&t();break;case r.SubscriptionState.Terminated:t();break;default:throw Error("Unrecognized state.")}this._state!==e&&(this._state=e,this._logger.log(`Subscription ${this._dialog?this._dialog.id:void 0} transitioned to ${this._state}`),this._stateEventEmitter.emit(this._state),e===r.SubscriptionState.Terminated&&this.dispose())}}},(e,t,s)=>{var i,r;s.r(t),s.d(t,{SubscriptionState:()=>i}),(r=i||(i={})).Initial="Initial",r.NotifyWait="NotifyWait",r.Subscribed="Subscribed",r.Terminated="Terminated"},(e,t,s)=>{var i,r;s.r(t),s.d(t,{SubscriptionState:()=>i}),(r=i||(i={})).Initial="Initial",r.NotifyWait="NotifyWait",r.Pending="Pending",r.Active="Active",r.Terminated="Terminated"},(e,t,s)=>{var i,r;s.r(t),s.d(t,{TransportState:()=>i}),(r=i||(i={})).Connecting="Connecting",r.Connected="Connected",r.Disconnecting="Disconnecting",r.Disconnected="Disconnected"},(e,t,s)=>{var i,r;s.r(t),s.d(t,{UserAgentState:()=>i}),(r=i||(i={})).Started="Started",r.Stopped="Stopped"},(e,t,s)=>{s.r(t),s.d(t,{UserAgent:()=>y});var i=s(23),r=s(50),n=s(51),o=s(21),a=s(58),c=s(60),h=s(98),d=s(18),l=s(26),g=s(20),u=s(53),p=s(57),f=s(1),m=s(12),S=s(14),v=s(37),T=s(31),b=s(32),R=s(34),E=s(48);class y{constructor(e={}){switch(this._publishers={},this._registerers={},this._sessions={},this._subscriptions={},this._state=E.UserAgentState.Stopped,this.unloadListener=()=>{this.stop()},this._stateEventEmitter=new m.EmitterImpl,this.delegate=e.delegate,this.options=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},y.defaultOptions()),{sipjsId:(0,g.createRandomToken)(5)}),{uri:new i.URI("sip","anonymous."+(0,g.createRandomToken)(6),"anonymous.invalid")}
1),{viaHost:(0,g.createRandomToken)(12)+".invalid"}),y.stripUndefinedProperties(e)),this.options.hackIpInContact&&("boolean"==typeof this.options.hackIpInContact&&this.options.hackIpInContact?this.options.viaHost="192.0.2."+Math.floor(254*Math.random()+1):this.options.hackIpInContact&&(this.options.viaHost=this.options.hackIpInContact)),this.loggerFactory=new r.LoggerFactory,this.logger=this.loggerFactory.getLogger("sip.UserAgent"),this.loggerFactory.builtinEnabled=this.options.logBuiltinEnabled,this.loggerFactory.connector=this.options.logConnector,this.options.logLevel){case"error":this.loggerFactory.level=n.Levels.error;break;case"warn":this.loggerFactory.level=n.Levels.warn;break;case"log":this.loggerFactory.level=n.Levels.log;break;case"debug":this.loggerFactory.level=n.Levels.debug}if(this.options.logConfiguration&&(this.logger.log("Configuration:"),Object.keys(this.options).forEach(e=>{let t=this.options[e];switch(e){case"uri":case"sessionDescriptionHandlerFactory":this.logger.log("\xb7 "+e+": "+t);break;case"authorizationPassword":this.logger.log("\xb7 "+e+": NOT SHOWN");break;case"transportConstructor":this.logger.log("\xb7 "+e+": "+t.name);break;default:this.logger.log("\xb7 "+e+": "+JSON.stringify(t))}})),this.options.transportOptions){let t=this.options.transportOptions,s=t.maxReconnectionAttempts,i=t.reconnectionTimeout;void 0!==s&&this.logger.warn('The transport option "maxReconnectionAttempts" as has apparently been specified and has been deprecated. It will no longer be available starting with SIP.js release 0.16.0. Please update accordingly.'),void 0!==i&&this.logger.warn('The transport option "reconnectionTimeout" as has apparently been specified and has been deprecated. It will no longer be available starting with SIP.js release 0.16.0. Please update accordingly.'),void 0===e.reconnectionDelay&&void 0!==i&&(this.options.reconnectionDelay=i),void 0===e.reconnectionAttempts&&void 0!==s&&(this.options.reconnectionAttempts=s)}void 0!==e.reconnectionDelay&&this.logger.warn('The user agent option "reconnectionDelay" as has apparently been specified and has been deprecated. It will no longer be available starting with SIP.js release 0.16.0. Please update accordingly.'),void 0!==e.reconnectionAttempts&&this.logger.warn('The user agent option "reconnectionAttempts" as has apparently been specified and has been deprecated. It will no longer be available starting with SIP.js release 0.16.0. Please update accordingly.'),this._transport=new this.options.transportConstructor(this.getLogger("sip.Transport"),this.options.transportOptions),this.initTransportCallbacks(),this._contact=this.initContact(),this._userAgentCore=this.initCore(),this.options.autoStart&&this.start()}static makeURI(e){return o.Grammar.URIParse(e)}static defaultOptions(){return{allowLegacyNotifications:!1,authorizationHa1:"",authorizationPassword:"",authorizationUsername:"",autoStart:!1,autoStop:!0,delegate:{},contactName:"",contactParams:{transport:"ws"},displayName:"",forceRport:!1,hackAllowUnregisteredOptionTags:!1,hackIpInContact:!1,hackViaTcp:!1,logBuiltinEnabled:!0,logConfiguration:!0,logConnector:()=>{},logLevel:"log",noAnswerTimeout:60,preloadedRouteSet:[],reconnectionAttempts:0,reconnectionDelay:4,sendInitialProvisionalResponse:!0,sessionDescriptionHandlerFactory:(0,u.defaultSessionDescriptionHandlerFactory)(),sessionDescriptionHandlerFactoryOptions:{},sipExtension100rel:R.SIPExtension.Unsupported,sipExtensionReplaces:R.SIPExtension.Unsupported,sipExtensionExtraSupported:[],sipjsId:"",transportConstructor:p.Transport,transportOptions:{},uri:new i.URI("sip","anonymous","anonymous.invalid"),userAgentString:"SIP.js/"+f.LIBRARY_VERSION,viaHost:""}}static stripUndefinedProperties(e){return Object.keys(e).reduce((t,s)=>(void 0!==e[s]&&(t[s]=e[s]),t),{})}get configuration(){return this.options}get contact(){return this._contact}get state(){return this._state}get stateChange(){return this._stateEventEmitter}get transport(){return this._transport}get userAgentCore(){return this._userAgentCore}getLogger(e,t){return this.loggerFactory.getLogger(e,t)}static getLogger(){return this.logger}getLoggerFactory(){return this.loggerFactory}isConnected(){return this.transport.isConnected()}reconnect(){return this.state===E.UserAgentState.Stopped?Promise.reject(Error("User agent stopped.")):Promise.resolve().then(()=>this.transport.connect())}
1start(){if(this.state===E.UserAgentState.Started)return this.logger.warn("User agent already started"),Promise.resolve();if(this.logger.log(`Starting ${this.configuration.uri}`),this.transitionState(E.UserAgentState.Started),this.options.autoStop){let e="undefined"!=typeof chrome&&!!chrome.app&&!!chrome.app.runtime;"undefined"==typeof window||"function"!=typeof window.addEventListener||e||window.addEventListener("unload",this.unloadListener)}return this.transport.connect()}async stop(){if(this.state===E.UserAgentState.Stopped)return this.logger.warn("User agent already stopped"),Promise.resolve();if(this.logger.log(`Stopping ${this.configuration.uri}`),this.transitionState(E.UserAgentState.Stopped),this.options.autoStop){let e="undefined"!=typeof chrome&&!!chrome.app&&!!chrome.app.runtime;"undefined"!=typeof window&&window.removeEventListener&&!e&&window.removeEventListener("unload",this.unloadListener)}let e=Object.assign({},this._publishers),t=Object.assign({},this._registerers),s=Object.assign({},this._sessions),i=Object.assign({},this._subscriptions),r=this.transport,n=this.userAgentCore;for(let e in this.logger.log("Dispose of registerers"),t)t[e]&&await t[e].dispose().catch(t=>{throw this.logger.error(t.message),delete this._registerers[e],t});for(let e in this.logger.log("Dispose of sessions"),s)s[e]&&await s[e].dispose().catch(t=>{throw this.logger.error(t.message),delete this._sessions[e],t});for(let e in this.logger.log("Dispose of subscriptions"),i)i[e]&&await i[e].dispose().catch(t=>{throw this.logger.error(t.message),delete this._subscriptions[e],t});for(let t in this.logger.log("Dispose of publishers"),e)e[t]&&await e[t].dispose().catch(e=>{throw this.logger.error(e.message),delete this._publishers[t],e});this.logger.log("Dispose of transport"),await r.dispose().catch(e=>{throw this.logger.error(e.message),e}),this.logger.log("Dispose of core"),n.dispose()}_makeInviter(e,t){return new v.Inviter(this,e,t)}attemptReconnection(e=1){let t=this.options.reconnectionAttempts,s=this.options.reconnectionDelay;if(e>t){this.logger.log("Maximum reconnection attempts reached");return}this.logger.log(`Reconnection attempt ${e} of ${t} - trying`),setTimeout(()=>{this.reconnect().then(()=>{this.logger.log(`Reconnection attempt ${e} of ${t} - succeeded`)}).catch(s=>{this.logger.error(s.message),this.logger.log(`Reconnection attempt ${e} of ${t} - failed`),this.attemptReconnection(++e)})},1===e?0:1e3*s)}initContact(){let e=""!==this.options.contactName?this.options.contactName:(0,g.createRandomToken)(8),t=this.options.contactParams;return{pubGruu:void 0,tempGruu:void 0,uri:new i.URI("sip",e,this.options.viaHost,void 0,t),toString:(e={})=>{let s=e.anonymous||!1,i=e.outbound||!1,r="<";return s?r+=this.contact.tempGruu||`sip:[email protected];transport=${t.transport?t.transport:"ws"}`:r+=this.contact.pubGruu||this.contact.uri,i&&(r+=";ob"),r+=">"}}}initCore(){let e=[];e.push("outbound"),this.options.sipExtension100rel===R.SIPExtension.Supported&&e.push("100rel"),this.options.sipExtensionReplaces===R.SIPExtension.Supported&&e.push("replaces"),this.options.sipExtensionExtraSupported&&e.push(...this.options.sipExtensionExtraSupported),this.options.hackAllowUnregisteredOptionTags||(e=e.filter(e=>R.UserAgentRegisteredOptionTags[e]));let t=(e=Array.from(new Set(e))).slice();(this.contact.pubGruu||this.contact.tempGruu)&&t.push("gruu");let s={aor:this.options.uri,contact:this.contact,displayName:this.options.displayName,loggerFactory:this.loggerFactory,hackViaTcp:this.options.hackViaTcp,routeSet:this.options.preloadedRouteSet,supportedOptionTags:e,supportedOptionTagsResponse:t,sipjsId:this.options.sipjsId,userAgentHeaderFieldValue:this.options.userAgentString,viaForceRport:this.options.forceRport,viaHost:this.options.viaHost,authenticationFactory:()=>{let e=this.options.authorizationUsername?this.options.authorizationUsername:this.options.uri.user,t=this.options.authorizationPassword?this.options.authorizationPassword:void 0,s=this.options.authorizationHa1?this.options.authorizationHa1:void 0;return new a.DigestAuthentication(this.getLoggerFactory(),s,e,t)},transportAccessor:()=>this.transport};return new c.UserAgentCore(s,{onInvite:e=>{var t;let s=new S.Invitation(this,e);if(e.delegate={onCancel:e=>{s._onCancel(e)},onTransportError:e=>{this.logger.error("A transport error has occurred while handling an incoming INVITE request.")}},e.trying(),this.options.sipExtensionReplaces!==R.SIPExtension.Unsupported){let t=e.message.parseHeader("replaces");if(t){let e=t.call_id;if("string"!=typeof e)throw Error("Type of call id is not string");let i=t.replaces_to_tag;if("string"!=typeof i)throw Error("Type of to tag is not string");let r=t.replaces_from_tag;if("string"!=typeof r)throw Error("type of from tag is not string");let n=this.userAgentCore.dialogs.get(e+i+r);if(!n){s.reject({statusCode:481});return}
1if(!n.early&&!0===t.early_only){s.reject({statusCode:486});return}let o=this._sessions[e+r]||this._sessions[e+i]||void 0;if(!o)throw Error("Session does not exist.");s._replacee=o}}if(null===(t=this.delegate)||void 0===t?void 0:t.onInvite){if(s.autoSendAnInitialProvisionalResponse){s.progress().then(()=>{var e;if((null===(e=this.delegate)||void 0===e?void 0:e.onInvite)===void 0)throw Error("onInvite undefined.");this.delegate.onInvite(s)});return}this.delegate.onInvite(s);return}s.reject({statusCode:486})},onMessage:e=>{if(this.delegate&&this.delegate.onMessage){let t=new T.Message(e);this.delegate.onMessage(t)}else e.accept()},onNotify:e=>{if(this.delegate&&this.delegate.onNotify){let t=new b.Notification(e);this.delegate.onNotify(t)}else this.options.allowLegacyNotifications?e.accept():e.reject({statusCode:481})},onRefer:e=>{this.logger.warn("Received an out of dialog REFER request"),this.delegate&&this.delegate.onReferRequest?this.delegate.onReferRequest(e):e.reject({statusCode:405})},onRegister:e=>{this.logger.warn("Received an out of dialog REGISTER request"),this.delegate&&this.delegate.onRegisterRequest?this.delegate.onRegisterRequest(e):e.reject({statusCode:405})},onSubscribe:e=>{this.logger.warn("Received an out of dialog SUBSCRIBE request"),this.delegate&&this.delegate.onSubscribeRequest?this.delegate.onSubscribeRequest(e):e.reject({statusCode:405})}})}initTransportCallbacks(){this.transport.onConnect=()=>this.onTransportConnect(),this.transport.onDisconnect=e=>this.onTransportDisconnect(e),this.transport.onMessage=e=>this.onTransportMessage(e)}onTransportConnect(){this.state!==E.UserAgentState.Stopped&&this.delegate&&this.delegate.onConnect&&this.delegate.onConnect()}onTransportDisconnect(e){this.state!==E.UserAgentState.Stopped&&(this.delegate&&this.delegate.onDisconnect&&this.delegate.onDisconnect(e),e&&this.options.reconnectionAttempts>0&&this.attemptReconnection())}onTransportMessage(e){let t=h.Parser.parseMessage(e,this.getLogger("sip.Parser"));if(!t){this.logger.warn("Failed to parse incoming message. Dropping.");return}if(this.state===E.UserAgentState.Stopped&&t instanceof d.IncomingRequestMessage){this.logger.warn(`Received ${t.method} request while stopped. Dropping.`);return}let s=()=>{for(let e of["from","to","call_id","cseq","via"])if(!t.hasHeader(e))return this.logger.warn(`Missing mandatory header field : ${e}.`),!1;return!0};if(t instanceof d.IncomingRequestMessage){if(!s()){this.logger.warn("Request missing mandatory header field. Dropping.");return}if(!t.toTag&&t.callId.substr(0,5)===this.options.sipjsId){this.userAgentCore.replyStateless(t,{statusCode:482});return}let e=(0,g.utf8Length)(t.body),i=t.getHeader("content-length");if(i&&e<Number(i)){this.userAgentCore.replyStateless(t,{statusCode:400});return}}if(t instanceof l.IncomingResponseMessage){if(!s()){this.logger.warn("Response missing mandatory header field. Dropping.");return}if(t.getHeaders("via").length>1){this.logger.warn("More than one Via header field present in the response. Dropping.");return}if(t.via.host!==this.options.viaHost||void 0!==t.via.port){this.logger.warn("Via sent-by in the response does not match UA Via host value. Dropping.");return}let e=(0,g.utf8Length)(t.body),i=t.getHeader("content-length");if(i&&e<Number(i)){this.logger.warn("Message body length is lower than the value in Content-Length header field. Dropping.");return}}if(t instanceof d.IncomingRequestMessage){this.userAgentCore.receiveIncomingRequestFromTransport(t);return}if(t instanceof l.IncomingResponseMessage){this.userAgentCore.receiveIncomingResponseFromTransport(t);return}throw Error("Invalid message type.")}transitionState(e,t){let s=()=>{throw Error(`Invalid state transition from ${this._state} to ${e}`)};switch(this._state){case E.UserAgentState.Started:e!==E.UserAgentState.Stopped&&s();break;case E.UserAgentState.Stopped:e!==E.UserAgentState.Started&&s();break;default:throw Error("Unknown state.")}this.logger.log(`Transitioned from ${this._state} to ${e}`),this._state=e,this._stateEventEmitter.emit(this._state)}}},(e,t,s)=>{s.r(t),s.d(t,{LoggerFactory:()=>n});var i=s(51),r=s(52);class n{constructor(){this.builtinEnabled=!0,this._level=i.Levels.log,this.loggers={},this.logger=this.getLogger("sip:loggerfactory")}
1get level(){return this._level}set level(e){e>=0&&e<=3?this._level=e:e>3?this._level=3:i.Levels.hasOwnProperty(e)?this._level=e:this.logger.error("invalid 'level' parameter value: "+JSON.stringify(e))}get connector(){return this._connector}set connector(e){e?"function"==typeof e?this._connector=e:this.logger.error("invalid 'connector' parameter value: "+JSON.stringify(e)):this._connector=void 0}getLogger(e,t){if(t&&3===this.level)return new r.Logger(this,e,t);if(this.loggers[e])return this.loggers[e];{let t=new r.Logger(this,e);return this.loggers[e]=t,t}}genericLog(e,t,s,r){this.level>=e&&this.builtinEnabled&&this.print(e,t,s,r),this.connector&&this.connector(i.Levels[e],t,s,r)}print(e,t,s,r){if("string"==typeof r){let e=[new Date,t];s&&e.push(s),r=e.concat(r).join(" | ")}switch(e){case i.Levels.error:console.error(r);break;case i.Levels.warn:console.warn(r);break;case i.Levels.log:console.log(r);break;case i.Levels.debug:console.debug(r)}}}},(e,t,s)=>{var i,r;s.r(t),s.d(t,{Levels:()=>i}),(r=i||(i={}))[r.error=0]="error",r[r.warn=1]="warn",r[r.log=2]="log",r[r.debug=3]="debug"},(e,t,s)=>{s.r(t),s.d(t,{Logger:()=>r});var i=s(51);class r{constructor(e,t,s){this.logger=e,this.category=t,this.label=s}error(e){this.genericLog(i.Levels.error,e)}warn(e){this.genericLog(i.Levels.warn,e)}log(e){this.genericLog(i.Levels.log,e)}debug(e){this.genericLog(i.Levels.debug,e)}genericLog(e,t){this.logger.genericLog(e,this.category,this.label,t)}get level(){return this.logger.level}set level(e){this.logger.level=e}}},(e,t,s)=>{s.r(t),s.d(t,{defaultSessionDescriptionHandlerFactory:()=>o});var i=s(54),r=s(55),n=s(56);function o(e){return(t,s)=>{void 0===e&&(e=(0,i.defaultMediaStreamFactory)());let o={iceGatheringTimeout:(null==s?void 0:s.iceGatheringTimeout)!==void 0?null==s?void 0:s.iceGatheringTimeout:5e3,peerConnectionConfiguration:Object.assign(Object.assign({},(0,r.defaultPeerConnectionConfiguration)()),null==s?void 0:s.peerConnectionConfiguration)},a=t.userAgent.getLogger("sip.SessionDescriptionHandler");return new n.SessionDescriptionHandler(a,e,o)}}}
1,(e,t,s)=>{function i(){return e=>e.audio||e.video?void 0===navigator.mediaDevices?Promise.reject(Error("Media devices not available in insecure contexts.")):navigator.mediaDevices.getUserMedia.call(navigator.mediaDevices,e):Promise.resolve(new MediaStream)}s.r(t),s.d(t,{defaultMediaStreamFactory:()=>i})},(e,t,s)=>{function i(){return{bundlePolicy:"balanced",certificates:void 0,iceCandidatePoolSize:0,iceServers:[{urls:"stun:stun.l.google.com:19302"}],iceTransportPolicy:"all",peerIdentity:void 0,rtcpMuxPolicy:"require"}}s.r(t),s.d(t,{defaultPeerConnectionConfiguration:()=>i})},(e,t,s)=>{s.r(t),s.d(t,{SessionDescriptionHandler:()=>i});class i{constructor(e,t,s){e.debug("SessionDescriptionHandler.constructor"),this.logger=e,this.mediaStreamFactory=t,this.sessionDescriptionHandlerConfiguration=s,this._localMediaStream=new MediaStream,this._remoteMediaStream=new MediaStream,this._peerConnection=new RTCPeerConnection(null==s?void 0:s.peerConnectionConfiguration),this.initPeerConnectionEventHandlers()}get localMediaStream(){return this._localMediaStream}get remoteMediaStream(){return this._remoteMediaStream}get dataChannel(){return this._dataChannel}get peerConnection(){return this._peerConnection}get peerConnectionDelegate(){return this._peerConnectionDelegate}set peerConnectionDelegate(e){this._peerConnectionDelegate=e}static dispatchAddTrackEvent(e,t){e.dispatchEvent(new MediaStreamTrackEvent("addtrack",{track:t}))}static dispatchRemoveTrackEvent(e,t){e.dispatchEvent(new MediaStreamTrackEvent("removetrack",{track:t}))}close(){this.logger.debug("SessionDescriptionHandler.close"),void 0!==this._peerConnection&&(this._peerConnection.getReceivers().forEach(e=>{e.track&&e.track.stop()}),this._peerConnection.getSenders().forEach(e=>{e.track&&e.track.stop()}),this._dataChannel&&this._dataChannel.close(),this._peerConnection.close(),this._peerConnection=void 0)}getDescription(e,t){var s,i;if(this.logger.debug("SessionDescriptionHandler.getDescription"),void 0===this._peerConnection)return Promise.reject(Error("Peer connection closed."));this.onDataChannel=null==e?void 0:e.onDataChannel;let r=null===(s=null==e?void 0:e.offerOptions)||void 0===s?void 0:s.iceRestart,n=(null==e?void 0:e.iceGatheringTimeout)===void 0?null===(i=this.sessionDescriptionHandlerConfiguration)||void 0===i?void 0:i.iceGatheringTimeout:null==e?void 0:e.iceGatheringTimeout;return this.getLocalMediaStream(e).then(()=>this.updateDirection(e)).then(()=>this.createDataChannel(e)).then(()=>this.createLocalOfferOrAnswer(e)).then(e=>this.applyModifiers(e,t)).then(e=>this.setLocalSessionDescription(e)).then(()=>this.waitForIceGatheringComplete(r,n)).then(()=>this.getLocalSessionDescription()).then(e=>({body:e.sdp,contentType:"application/sdp"})).catch(e=>{throw this.logger.error("SessionDescriptionHandler.getDescription failed - "+e),e})}hasDescription(e){return this.logger.debug("SessionDescriptionHandler.hasDescription"),"application/sdp"===e}sendDtmf(e,t){if(this.logger.debug("SessionDescriptionHandler.sendDtmf"),void 0===this._peerConnection)return this.logger.error("SessionDescriptionHandler.sendDtmf failed - peer connection closed"),!1;let s=this._peerConnection.getSenders();if(0===s.length)return this.logger.error("SessionDescriptionHandler.sendDtmf failed - no senders"),!1;let i=s[0].dtmf;if(!i)return this.logger.error("SessionDescriptionHandler.sendDtmf failed - no DTMF sender"),!1;let r=null==t?void 0:t.duration,n=null==t?void 0:t.interToneGap;try{i.insertDTMF(e,r,n)}catch(e){return this.logger.error(e),!1}return this.logger.log("SessionDescriptionHandler.sendDtmf sent via RTP: "+e.toString()),!0}setDescription(e,t,s){if(this.logger.debug("SessionDescriptionHandler.setDescription"),void 0===this._peerConnection)return Promise.reject(Error("Peer connection closed."));this.onDataChannel=null==t?void 0:t.onDataChannel;let i="have-local-offer"===this._peerConnection.signalingState?"answer":"offer";return this.getLocalMediaStream(t).then(()=>this.applyModifiers({sdp:e,type:i},s)).then(e=>this.setRemoteSessionDescription(e)).catch(e=>{throw this.logger.error("SessionDescriptionHandler.setDescription failed - "+e),e})}applyModifiers(e,t){return(this.logger.debug("SessionDescriptionHandler.applyModifiers"),t&&0!==t.length)?t.reduce((e,t)=>
1e.then(t),Promise.resolve(e)).then(e=>{if(this.logger.debug("SessionDescriptionHandler.applyModifiers - modified sdp"),!e.sdp||!e.type)throw Error("Invalid SDP.");return{sdp:e.sdp,type:e.type}}):Promise.resolve(e)}createDataChannel(e){if(void 0===this._peerConnection)return Promise.reject(Error("Peer connection closed."));if((null==e?void 0:e.dataChannel)!==!0||this._dataChannel)return Promise.resolve();switch(this._peerConnection.signalingState){case"stable":this.logger.debug("SessionDescriptionHandler.createDataChannel - creating data channel");try{return this._dataChannel=this._peerConnection.createDataChannel((null==e?void 0:e.dataChannelLabel)||"",null==e?void 0:e.dataChannelOptions),this.onDataChannel&&this.onDataChannel(this._dataChannel),Promise.resolve()}catch(e){return Promise.reject(e)}case"have-remote-offer":return Promise.resolve();default:return Promise.reject(Error("Invalid signaling state "+this._peerConnection.signalingState))}}createLocalOfferOrAnswer(e){if(void 0===this._peerConnection)return Promise.reject(Error("Peer connection closed."));switch(this._peerConnection.signalingState){case"stable":return this.logger.debug("SessionDescriptionHandler.createLocalOfferOrAnswer - creating SDP offer"),this._peerConnection.createOffer(null==e?void 0:e.offerOptions);case"have-remote-offer":return this.logger.debug("SessionDescriptionHandler.createLocalOfferOrAnswer - creating SDP answer"),this._peerConnection.createAnswer(null==e?void 0:e.answerOptions);default:return Promise.reject(Error("Invalid signaling state "+this._peerConnection.signalingState))}}getLocalMediaStream(e){if(this.logger.debug("SessionDescriptionHandler.getLocalMediaStream"),void 0===this._peerConnection)return Promise.reject(Error("Peer connection closed."));let t=Object.assign({},null==e?void 0:e.constraints);if(this.localMediaStreamConstraints){if(t.audio=t.audio||this.localMediaStreamConstraints.audio,t.video=t.video||this.localMediaStreamConstraints.video,JSON.stringify(this.localMediaStreamConstraints.audio)===JSON.stringify(t.audio)&&JSON.stringify(this.localMediaStreamConstraints.video)===JSON.stringify(t.video))return Promise.resolve()}else void 0===t.audio&&void 0===t.video&&(t={audio:!0});return this.localMediaStreamConstraints=t,this.mediaStreamFactory(t,this).then(e=>this.setLocalMediaStream(e))}setLocalMediaStream(e){if(this.logger.debug("SessionDescriptionHandler.setLocalMediaStream"),!this._peerConnection)throw Error("Peer connection undefined.");let t=this._peerConnection,s=this._localMediaStream,r=[],n=e=>{let n=e.kind;if("audio"!==n&&"video"!==n)throw Error(`Unknown new track kind ${n}.`);let o=t.getSenders().find(e=>e.track&&e.track.kind===n);o?r.push(new Promise(e=>{this.logger.debug(`SessionDescriptionHandler.setLocalMediaStream - replacing sender ${n} track`),e()}).then(()=>o.replaceTrack(e).then(()=>{let t=s.getTracks().find(e=>e.kind===n);t&&(t.stop(),s.removeTrack(t),i.dispatchRemoveTrackEvent(s,t)),s.addTrack(e),i.dispatchAddTrackEvent(s,e)}).catch(e=>{throw this.logger.error(`SessionDescriptionHandler.setLocalMediaStream - failed to replace sender ${n} track`),e}))):r.push(new Promise(e=>{this.logger.debug(`SessionDescriptionHandler.setLocalMediaStream - adding sender ${n} track`),e()}).then(()=>{try{t.addTrack(e,s)}catch(e){throw this.logger.error(`SessionDescriptionHandler.setLocalMediaStream - failed to add sender ${n} track`),e}s.addTrack(e),i.dispatchAddTrackEvent(s,e)}))},o=e.getAudioTracks();o.length&&n(o[0]);let a=e.getVideoTracks();return a.length&&n(a[0]),r.reduce((e,t)=>e.then(()=>t),Promise.resolve())}getLocalSessionDescription(){if(this.logger.debug("SessionDescriptionHandler.getLocalSessionDescription"),void 0===this._peerConnection)return Promise.reject(Error("Peer connection closed."));let e=this._peerConnection.localDescription;return e?Promise.resolve(e):Promise.reject(Error("Failed to get local session description"))}setLocalSessionDescription(e){return(this.logger.debug("SessionDescriptionHandler.setLocalSessionDescription"),void 0===this._peerConnection)?Promise.reject(Error("Peer connection closed.")):this._peerConnection.setLocalDescription(e)}setRemoteSessionDescription(e){let t;if(this.logger.debug("SessionDescriptionHandler.setRemoteSessionDescription"),void 0===this._peerConnection)return Promise.reject(Error("Peer connection closed."));let s=e.sdp;switch(this._peerConnection.signalingState){case"stable":t="offer";break;case"have-local-offer":t="answer";break;default:return Promise.reject(Error("Invalid signaling state "+this._peerConnection.signalingState))}return s?this._peerConnection.setRemoteDescription({sdp:s,type:t}):(this.logger.error("SessionDescriptionHandler.setRemoteSessionDescription failed - cannot set null sdp"),Promise.reject(Error("SDP is undefined")))}setRemoteTrack(e){this.logger.debug("SessionDescriptionHandler.setRemoteTrack");let t=this._remoteMediaStream;t.getTrackById(e.id)?this.logger.debug(`SessionDescriptionHandler.setRemoteTrack - have remote ${e.kind} track`):"audio"===e.kind?(this.logger.debug(`SessionDescriptionHandler.setRemoteTrack - adding remote ${e.kind}
1 track`),t.getAudioTracks().forEach(e=>{e.stop(),t.removeTrack(e),i.dispatchRemoveTrackEvent(t,e)}),t.addTrack(e),i.dispatchAddTrackEvent(t,e)):"video"===e.kind&&(this.logger.debug(`SessionDescriptionHandler.setRemoteTrack - adding remote ${e.kind} track`),t.getVideoTracks().forEach(e=>{e.stop(),t.removeTrack(e),i.dispatchRemoveTrackEvent(t,e)}),t.addTrack(e),i.dispatchAddTrackEvent(t,e))}updateDirection(e){if(void 0===this._peerConnection)return Promise.reject(Error("Peer connection closed."));switch(this._peerConnection.signalingState){case"stable":this.logger.debug("SessionDescriptionHandler.updateDirection - setting offer direction");{let t=t=>{switch(t){case"inactive":case"recvonly":return(null==e?void 0:e.hold)?"inactive":"recvonly";case"sendonly":case"sendrecv":return(null==e?void 0:e.hold)?"sendonly":"sendrecv";case"stopped":return"stopped";default:throw Error("Should never happen")}};this._peerConnection.getTransceivers().forEach(e=>{if(e.direction){let s=t(e.direction);e.direction!==s&&(e.direction=s)}})}break;case"have-remote-offer":this.logger.debug("SessionDescriptionHandler.updateDirection - setting answer direction");{let t=(()=>{let e=this._peerConnection.remoteDescription;if(!e)throw Error("Failed to read remote offer");let t=/a=sendrecv\r\n|a=sendonly\r\n|a=recvonly\r\n|a=inactive\r\n/.exec(e.sdp);if(t)switch(t[0]){case"a=inactive\r\n":return"inactive";case"a=recvonly\r\n":return"recvonly";case"a=sendonly\r\n":return"sendonly";case"a=sendrecv\r\n":break;default:throw Error("Should never happen")}return"sendrecv"})(),s=(()=>{switch(t){case"inactive":return"inactive";case"recvonly":return"sendonly";case"sendonly":return(null==e?void 0:e.hold)?"inactive":"recvonly";case"sendrecv":return(null==e?void 0:e.hold)?"sendonly":"sendrecv";default:throw Error("Should never happen")}})();this._peerConnection.getTransceivers().forEach(e=>{e.direction&&"stopped"!==e.direction&&e.direction!==s&&(e.direction=s)})}break;default:return Promise.reject(Error("Invalid signaling state "+this._peerConnection.signalingState))}return Promise.resolve()}iceGatheringComplete(){this.logger.debug("SessionDescriptionHandler.iceGatheringComplete"),void 0!==this.iceGatheringCompleteTimeoutId&&(this.logger.debug("SessionDescriptionHandler.iceGatheringComplete - clearing timeout"),clearTimeout(this.iceGatheringCompleteTimeoutId),this.iceGatheringCompleteTimeoutId=void 0),void 0!==this.iceGatheringCompletePromise&&(this.logger.debug("SessionDescriptionHandler.iceGatheringComplete - resolving promise"),this.iceGatheringCompleteResolve&&this.iceGatheringCompleteResolve(),this.iceGatheringCompletePromise=void 0,this.iceGatheringCompleteResolve=void 0,this.iceGatheringCompleteReject=void 0)}waitForIceGatheringComplete(e=!1,t=0){return(this.logger.debug("SessionDescriptionHandler.waitForIceGatheringToComplete"),void 0===this._peerConnection)?Promise.reject("Peer connection closed."):e||"complete"!==this._peerConnection.iceGatheringState?(void 0!==this.iceGatheringCompletePromise&&(this.logger.debug("SessionDescriptionHandler.waitForIceGatheringToComplete - rejecting prior waiting promise"),this.iceGatheringCompleteReject&&this.iceGatheringCompleteReject(Error("Promise superseded.")),this.iceGatheringCompletePromise=void 0,this.iceGatheringCompleteResolve=void 0,this.iceGatheringCompleteReject=void 0),this.iceGatheringCompletePromise=new Promise((e,s)=>{this.iceGatheringCompleteResolve=e,this.iceGatheringCompleteReject=s,t>0&&(this.logger.debug("SessionDescriptionHandler.waitForIceGatheringToComplete - timeout in "+t),this.iceGatheringCompleteTimeoutId=setTimeout(()=>{this.logger.debug("SessionDescriptionHandler.waitForIceGatheringToComplete - timeout"),this.iceGatheringComplete()},t))}),this.iceGatheringCompletePromise):(this.logger.debug("SessionDescriptionHandler.waitForIceGatheringToComplete - already complete"),Promise.resolve())}initPeerConnectionEventHandlers(){if(this.logger.debug("SessionDescriptionHandler.initPeerConnectionEventHandlers"),!this._peerConnection)throw Error("Peer connection undefined.");let e=this._peerConnection;e.onconnectionstatechange=t=>{var s;let i=e.connectionState;this.logger.debug(`SessionDescriptionHandler.onconnectionstatechange ${i}
1`),(null===(s=this._peerConnectionDelegate)||void 0===s?void 0:s.onconnectionstatechange)&&this._peerConnectionDelegate.onconnectionstatechange(t)},e.ondatachannel=e=>{var t;this.logger.debug("SessionDescriptionHandler.ondatachannel"),this._dataChannel=e.channel,this.onDataChannel&&this.onDataChannel(this._dataChannel),(null===(t=this._peerConnectionDelegate)||void 0===t?void 0:t.ondatachannel)&&this._peerConnectionDelegate.ondatachannel(e)},e.onicecandidate=e=>{var t;this.logger.debug("SessionDescriptionHandler.onicecandidate"),(null===(t=this._peerConnectionDelegate)||void 0===t?void 0:t.onicecandidate)&&this._peerConnectionDelegate.onicecandidate(e)},e.onicecandidateerror=e=>{var t;this.logger.debug("SessionDescriptionHandler.onicecandidateerror"),(null===(t=this._peerConnectionDelegate)||void 0===t?void 0:t.onicecandidateerror)&&this._peerConnectionDelegate.onicecandidateerror(e)},e.oniceconnectionstatechange=t=>{var s;let i=e.iceConnectionState;this.logger.debug(`SessionDescriptionHandler.oniceconnectionstatechange ${i}`),(null===(s=this._peerConnectionDelegate)||void 0===s?void 0:s.oniceconnectionstatechange)&&this._peerConnectionDelegate.oniceconnectionstatechange(t)},e.onicegatheringstatechange=t=>{var s;let i=e.iceGatheringState;this.logger.debug(`SessionDescriptionHandler.onicegatheringstatechange ${i}`),"complete"===i&&this.iceGatheringComplete(),(null===(s=this._peerConnectionDelegate)||void 0===s?void 0:s.onicegatheringstatechange)&&this._peerConnectionDelegate.onicegatheringstatechange(t)},e.onnegotiationneeded=e=>{var t;this.logger.debug("SessionDescriptionHandler.onnegotiationneeded"),(null===(t=this._peerConnectionDelegate)||void 0===t?void 0:t.onnegotiationneeded)&&this._peerConnectionDelegate.onnegotiationneeded(e)},e.onsignalingstatechange=t=>{var s;let i=e.signalingState;this.logger.debug(`SessionDescriptionHandler.onsignalingstatechange ${i}`),(null===(s=this._peerConnectionDelegate)||void 0===s?void 0:s.onsignalingstatechange)&&this._peerConnectionDelegate.onsignalingstatechange(t)},e.onstatsended=e=>{var t;this.logger.debug("SessionDescriptionHandler.onstatsended"),(null===(t=this._peerConnectionDelegate)||void 0===t?void 0:t.onstatsended)&&this._peerConnectionDelegate.onstatsended(e)},e.ontrack=e=>{var t;let s=e.track.kind,i=e.track.enabled?"enabled":"disabled";this.logger.debug(`SessionDescriptionHandler.ontrack ${s} ${i}`),this.setRemoteTrack(e.track),(null===(t=this._peerConnectionDelegate)||void 0===t?void 0:t.ontrack)&&this._peerConnectionDelegate.ontrack(e)}}}},(e,t,s)=>{s.r(t),s.d(t,{Transport:()=>a});var i=s(12),r=s(9),n=s(47),o=s(21);class a{constructor(e,t){if(this._state=n.TransportState.Disconnected,this.transitioningState=!1,this._stateEventEmitter=new i.EmitterImpl,this.logger=e,t){let e=null==t?void 0:t.wsServers,s=null==t?void 0:t.maxReconnectionAttempts;void 0!==e&&this.logger.warn('The transport option "wsServers" as has apparently been specified and has been deprecated. It will no longer be available starting with SIP.js release 0.16.0. Please update accordingly.'),void 0!==s&&this.logger.warn('The transport option "maxReconnectionAttempts" as has apparently been specified and has been deprecated. It will no longer be available starting with SIP.js release 0.16.0. Please update accordingly.'),e&&!t.server&&("string"==typeof e&&(t.server=e),e instanceof Array&&(t.server=e[0]))}this.configuration=Object.assign(Object.assign({},a.defaultOptions),t);let s=this.configuration.server,r=o.Grammar.parse(s,"absoluteURI");if(-1===r)throw this.logger.error(`Invalid WebSocket Server URL "${s}"`),Error("Invalid WebSocket Server URL");if(!["wss","ws","udp"].includes(r.scheme))throw this.logger.error(`Invalid scheme in WebSocket Server URL "${s}"`),Error("Invalid scheme in WebSocket Server URL");this._protocol=r.scheme.toUpperCase()}dispose(){return this.disconnect()}get protocol(){return this._protocol}get server(){return this.configuration.server}get state(){return this._state}get stateChange(){return this._stateEventEmitter}get ws(){return this._ws}connect(){return this._connect()}disconnect(){return this._disconnect()}
1isConnected(){return this.state===n.TransportState.Connected}send(e){return this._send(e)}_connect(){let e;switch(this.logger.log(`Connecting ${this.server}`),this.state){case n.TransportState.Connecting:if(this.transitioningState)return Promise.reject(this.transitionLoopDetectedError(n.TransportState.Connecting));if(!this.connectPromise)throw Error("Connect promise must be defined.");return this.connectPromise;case n.TransportState.Connected:if(this.transitioningState)return Promise.reject(this.transitionLoopDetectedError(n.TransportState.Connecting));if(this.connectPromise)throw Error("Connect promise must not be defined.");return Promise.resolve();case n.TransportState.Disconnecting:if(this.connectPromise)throw Error("Connect promise must not be defined.");try{this.transitionState(n.TransportState.Connecting)}catch(e){if(e instanceof r.StateTransitionError)return Promise.reject(e);throw e}break;case n.TransportState.Disconnected:if(this.connectPromise)throw Error("Connect promise must not be defined.");try{this.transitionState(n.TransportState.Connecting)}catch(e){if(e instanceof r.StateTransitionError)return Promise.reject(e);throw e}break;default:throw Error("Unknown state")}try{(e=new WebSocket(this.server,"sip")).binaryType="arraybuffer",e.addEventListener("close",t=>this.onWebSocketClose(t,e)),e.addEventListener("error",t=>this.onWebSocketError(t,e)),e.addEventListener("open",t=>this.onWebSocketOpen(t,e)),e.addEventListener("message",t=>this.onWebSocketMessage(t,e)),this._ws=e}catch(e){return this._ws=void 0,this.logger.error("WebSocket construction failed."),this.logger.error(e),new Promise((t,s)=>{this.connectResolve=t,this.connectReject=s,this.transitionState(n.TransportState.Disconnected,e)})}return this.connectPromise=new Promise((t,s)=>{this.connectResolve=t,this.connectReject=s,this.connectTimeout=setTimeout(()=>{this.logger.warn("Connect timed out. Exceeded time set in configuration.connectionTimeout: "+this.configuration.connectionTimeout+"s."),e.close(1e3)},1e3*this.configuration.connectionTimeout)}),this.connectPromise}_disconnect(){switch(this.logger.log(`Disconnecting ${this.server}`),this.state){case n.TransportState.Connecting:if(this.disconnectPromise)throw Error("Disconnect promise must not be defined.");try{this.transitionState(n.TransportState.Disconnecting)}catch(e){if(e instanceof r.StateTransitionError)return Promise.reject(e);throw e}break;case n.TransportState.Connected:if(this.disconnectPromise)throw Error("Disconnect promise must not be defined.");try{this.transitionState(n.TransportState.Disconnecting)}catch(e){if(e instanceof r.StateTransitionError)return Promise.reject(e);throw e}break;case n.TransportState.Disconnecting:if(this.transitioningState)return Promise.reject(this.transitionLoopDetectedError(n.TransportState.Disconnecting));if(!this.disconnectPromise)throw Error("Disconnect promise must be defined.");return this.disconnectPromise;case n.TransportState.Disconnected:if(this.transitioningState)return Promise.reject(this.transitionLoopDetectedError(n.TransportState.Disconnecting));if(this.disconnectPromise)throw Error("Disconnect promise must not be defined.");return Promise.resolve();default:throw Error("Unknown state")}if(!this._ws)throw Error("WebSocket must be defined.");let e=this._ws;return this.disconnectPromise=new Promise((t,s)=>{this.disconnectResolve=t,this.disconnectReject=s;try{e.close(1e3)}catch(e){throw this.logger.error("WebSocket close failed."),this.logger.error(e),e}}),this.disconnectPromise}_send(e){if(!0===this.configuration.traceSip&&this.logger.log("Sending WebSocket message:\n\n"+e+"\n"),this._state!==n.TransportState.Connected)return Promise.reject(Error("Not connected."));if(!this._ws)throw Error("WebSocket undefined.");try{this._ws.send(e)}catch(e){if(e instanceof Error)return Promise.reject(e);return Promise.reject(Error("WebSocket send failed."))}return Promise.resolve()}onWebSocketClose(e,t){if(t!==this._ws)return;let s=`WebSocket closed ${this.server} (code: ${e.code})`,i=this.disconnectPromise?void 0:Error(s);i&&this.logger.warn("WebSocket closed unexpectedly"),this.logger.log(s),this._ws=void 0,this.transitionState(n.TransportState.Disconnected,i)}onWebSocketError(e,t){t===this._ws&&this.logger.error("WebSocket error occurred.")}onWebSocketMessage(e,t){let s;if(t!==this._ws)return;let i=e.data;if(/^(\r\n)+$/.test(i)){this.clearKeepAliveTimeout(),!0===this.configuration.traceSip&&this.logger.log("Received WebSocket message with CRLF Keep Alive response");return}if(!i){this.logger.warn("Received empty message, discarding...");return}if("string"!=typeof i){try{s=new TextDecoder().decode(new Uint8Array(i))}catch(e){this.logger.error(e),this.logger.error("Received WebSocket binary message failed to be converted into string, message discarded");return}!0===this.configuration.traceSip&&this.logger.log("Received WebSocket binary message:\n\n"+s+"\n")}else s=i,!0===this.configuration.traceSip&&this.logger.log("Received WebSocket text message:\n\n"+s+"\n");
1if(this.state!==n.TransportState.Connected){this.logger.warn("Received message while not connected, discarding...");return}if(this.onMessage)try{this.onMessage(s)}catch(e){throw this.logger.error(e),this.logger.error("Exception thrown by onMessage callback"),e}}onWebSocketOpen(e,t){t===this._ws&&this._state===n.TransportState.Connecting&&(this.logger.log(`WebSocket opened ${this.server}`),this.transitionState(n.TransportState.Connected))}transitionLoopDetectedError(e){let t="A state transition loop has been detected.";return t+=` An attempt to transition from ${this._state} to ${e} before the prior transition completed. Perhaps you are synchronously calling connect() or disconnect() from a callback or state change handler?`,this.logger.error(t),new r.StateTransitionError("Loop detected.")}transitionState(e,t){let s=()=>{throw Error(`Invalid state transition from ${this._state} to ${e}`)};if(this.transitioningState)throw this.transitionLoopDetectedError(e);switch(this.transitioningState=!0,this._state){case n.TransportState.Connecting:e!==n.TransportState.Connected&&e!==n.TransportState.Disconnecting&&e!==n.TransportState.Disconnected&&s();break;case n.TransportState.Connected:e!==n.TransportState.Disconnecting&&e!==n.TransportState.Disconnected&&s();break;case n.TransportState.Disconnecting:e!==n.TransportState.Connecting&&e!==n.TransportState.Disconnected&&s();break;case n.TransportState.Disconnected:e!==n.TransportState.Connecting&&s();break;default:throw Error("Unknown state.")}let i=this._state;this._state=e;let r=this.connectResolve,o=this.connectReject;i===n.TransportState.Connecting&&(this.connectPromise=void 0,this.connectResolve=void 0,this.connectReject=void 0);let a=this.disconnectResolve,c=this.disconnectReject;if(i===n.TransportState.Disconnecting&&(this.disconnectPromise=void 0,this.disconnectResolve=void 0,this.disconnectReject=void 0),this.connectTimeout&&(clearTimeout(this.connectTimeout),this.connectTimeout=void 0),this.logger.log(`Transitioned from ${i} to ${this._state}`),this._stateEventEmitter.emit(this._state),e===n.TransportState.Connected&&(this.startSendingKeepAlives(),this.onConnect))try{this.onConnect()}catch(e){throw this.logger.error(e),this.logger.error("Exception thrown by onConnect callback"),e}if(i===n.TransportState.Connected&&(this.stopSendingKeepAlives(),this.onDisconnect))try{t?this.onDisconnect(t):this.onDisconnect()}catch(e){throw this.logger.error(e),this.logger.error("Exception thrown by onDisconnect callback"),e}if(i===n.TransportState.Connecting){if(!r)throw Error("Connect resolve undefined.");if(!o)throw Error("Connect reject undefined.");e===n.TransportState.Connected?r():o(t||Error("Connect aborted."))}if(i===n.TransportState.Disconnecting){if(!a)throw Error("Disconnect resolve undefined.");if(!c)throw Error("Disconnect reject undefined.");e===n.TransportState.Disconnected?a():c(t||Error("Disconnect aborted."))}this.transitioningState=!1}clearKeepAliveTimeout(){this.keepAliveDebounceTimeout&&clearTimeout(this.keepAliveDebounceTimeout),this.keepAliveDebounceTimeout=void 0}sendKeepAlive(){return this.keepAliveDebounceTimeout?Promise.resolve():(this.keepAliveDebounceTimeout=setTimeout(()=>{this.clearKeepAliveTimeout()},1e3*this.configuration.keepAliveDebounce),this.send("\r\n\r\n"))}startSendingKeepAlives(){this.configuration.keepAliveInterval&&!this.keepAliveInterval&&(this.keepAliveInterval=setInterval(()=>{this.sendKeepAlive(),this.startSendingKeepAlives()},(e=>{let t=.8*e;return 1e3*(Math.random()*(e-t)+t)})(this.configuration.keepAliveInterval)))}stopSendingKeepAlives(){this.keepAliveInterval&&clearInterval(this.keepAliveInterval),this.keepAliveDebounceTimeout&&clearTimeout(this.keepAliveDebounceTimeout),this.keepAliveInterval=void 0,this.keepAliveDebounceTimeout=void 0}}a.defaultOptions={server:"",connectionTimeout:5,keepAliveInterval:0,keepAliveDebounce:10,traceSip:!0}},(e,t,s)=>{s.r(t),s.d(t,{DigestAuthentication:()=>o});var i=s(59),r=s(20);function n(e){return i.Md5.hashStr(e)}class o{constructor(e,t,s,i){this.logger=e.getLogger("sipjs.digestauthentication"),this.username=s,this.password=i,this.ha1=t,this.nc=0,this.ncHex="00000000"}
1authenticate(e,t,s){if(this.algorithm=t.algorithm,this.realm=t.realm,this.nonce=t.nonce,this.opaque=t.opaque,this.stale=t.stale,this.algorithm){if("MD5"!==this.algorithm)return this.logger.warn("challenge with Digest algorithm different than 'MD5', authentication aborted"),!1}else this.algorithm="MD5";if(!this.realm)return this.logger.warn("challenge without Digest realm, authentication aborted"),!1;if(!this.nonce)return this.logger.warn("challenge without Digest nonce, authentication aborted"),!1;if(t.qop){if(t.qop.indexOf("auth")>-1)this.qop="auth";else{if(!(t.qop.indexOf("auth-int")>-1))return this.logger.warn("challenge without Digest qop different than 'auth' or 'auth-int', authentication aborted"),!1;this.qop="auth-int"}}else this.qop=void 0;return this.method=e.method,this.uri=e.ruri,this.cnonce=(0,r.createRandomToken)(12),this.nc+=1,this.updateNcHex(),4294967296===this.nc&&(this.nc=1,this.ncHex="00000001"),this.calculateResponse(s),!0}toString(){let e=[];if(!this.response)throw Error("response field does not exist, cannot generate Authorization header");return e.push("algorithm="+this.algorithm),e.push('username="'+this.username+'"'),e.push('realm="'+this.realm+'"'),e.push('nonce="'+this.nonce+'"'),e.push('uri="'+this.uri+'"'),e.push('response="'+this.response+'"'),this.opaque&&e.push('opaque="'+this.opaque+'"'),this.qop&&(e.push("qop="+this.qop),e.push('cnonce="'+this.cnonce+'"'),e.push("nc="+this.ncHex)),"Digest "+e.join(", ")}updateNcHex(){let e=Number(this.nc).toString(16);this.ncHex="00000000".substr(0,8-e.length)+e}calculateResponse(e){let t,s;(""===(t=this.ha1)||void 0===t)&&(t="function"==typeof this.password?n(this.username+":"+this.realm+":"+this.password()):n(this.username+":"+this.realm+":"+this.password)),"auth"===this.qop?(s=n(this.method+":"+this.uri),this.response=n(t+":"+this.nonce+":"+this.ncHex+":"+this.cnonce+":auth:"+s)):"auth-int"===this.qop?(s=n(this.method+":"+this.uri+":"+n(e||"")),this.response=n(t+":"+this.nonce+":"+this.ncHex+":"+this.cnonce+":auth-int:"+s)):void 0===this.qop&&(s=n(this.method+":"+this.uri),this.response=n(t+":"+this.nonce+":"+s))}}},(e,t,s)=>{s.r(t),s.d(t,{Md5:()=>i});class i{constructor(){this._dataLength=0,this._bufferLength=0,this._state=new Int32Array(4),this._buffer=new ArrayBuffer(68),this._buffer8=new Uint8Array(this._buffer,0,68),this._buffer32=new Uint32Array(this._buffer,0,17),this.start()}static hashStr(e,t=!1){return this.onePassHasher.start().appendStr(e).end(t)}static hashAsciiStr(e,t=!1){return this.onePassHasher.start().appendAsciiStr(e).end(t)}static _hex(e){let t,s,r,n;let o=i.hexChars,a=i.hexOut;for(n=0;n<4;n+=1)for(r=0,s=8*n,t=e[n];r<8;r+=2)a[s+1+r]=o.charAt(15&t),t>>>=4,a[s+0+r]=o.charAt(15&t),t>>>=4;return a.join("")}static _md5cycle(e,t){let s=e[0],i=e[1],r=e[2],n=e[3];s+=(i&r|~i&n)+t[0]-680876936|0,n+=((s=(s<<7|s>>>25)+i|0)&i|~s&r)+t[1]-389564586|0,r+=((n=(n<<12|n>>>20)+s|0)&s|~n&i)+t[2]+606105819|0,i+=((r=(r<<17|r>>>15)+n|0)&n|~r&s)+t[3]-1044525330|0,s+=((i=(i<<22|i>>>10)+r|0)&r|~i&n)+t[4]-176418897|0,n+=((s=(s<<7|s>>>25)+i|0)&i|~s&r)+t[5]+1200080426|0,r+=((n=(n<<12|n>>>20)+s|0)&s|~n&i)+t[6]-1473231341|0,i+=((r=(r<<17|r>>>15)+n|0)&n|~r&s)+t[7]-45705983|0,s+=((i=(i<<22|i>>>10)+r|0)&r|~i&n)+t[8]+1770035416|0,n+=((s=(s<<7|s>>>25)+i|0)&i|~s&r)+t[9]-1958414417|0,r+=((n=(n<<12|n>>>20)+s|0)&s|~n&i)+t[10]-42063|0,i+=((r=(r<<17|r>>>15)+n|0)&n|~r&s)+t[11]-1990404162|0,s+=((i=(i<<22|i>>>10)+r|0)&r|~i&n)+t[12]+1804603682|0,n+=((s=(s<<7|s>>>25)+i|0)&i|~s&r)+t[13]-40341101|0,r+=((n=(n<<12|n>>>20)+s|0)&s|~n&i)+t[14]-1502002290|0,i+=((r=(r<<17|r>>>15)+n|0)&n|~r&s)+t[15]+1236535329|0,s+=((i=(i<<22|i>>>10)+r|0)&n|r&~n)+t[1]-165796510|0,n+=((s=(s<<5|s>>>27)+i|0)&r|i&~r)+t[6]-1069501632|0,r+=((n=(n<<9|n>>>23)+s|0)&i|s&~i)+t[11]+643717713|0,i+=((r=(r<<14|r>>>18)+n|0)&s|n&~s)+t[0]-373897302|0,s+=((i=(i<<20|i>>>12)+r|0)&n|r&~n)+t[5]-701558691|0,n+=((s=(s<<5|s>>>27)+i|0)&r|i&~r)+t[10]+38016083|0,r+=((n=(n<<9|n>>>23)+s|0)&i|s&~i)+t[15]-660478335|0,i+=((r=(r<<14|r>>>18)+n|0)&s|n&~s)+t[4]-405537848|0,s+=((i=(i<<20|i>>>12)+r|0)&n|r&~n)+t[9]+568446438|0,n+=((s=(s<<5|s>>>27)+i|0)&r|i&~r)+t[14]-1019803690|0,r+=((n=(n<<9|n>>>23)+s|0)&i|s&~i)+t[3]-187363961|0,i+=((r=(r<<14|r>>>18)+n|0)&s|n&~s)+t[8]+1163531501|0,s+=((i=(i<<20|i>>>12)+r|0)&n|r&~n)+t[13]-1444681467|0,n+=((s=(s<<5|s>>>27)+i|0)&r|i&~r)+t[2]-51403784|0,r+=((n=(n<<9|n>>>23)+s|0)&i|s&~i)+t[7]+1735328473|0,i+=((r=(r<<14|r>>>18)+n|0)&s|n&~s)+t[12]-1926607734|0,s+=((i=(i<<20|i>>>12)+r|0)^r^n)+t[5]-378558|0,n+=((s=(s<<4|s>>>28)+i|0)^i^r)+t[8]-2022574463|0,r+=((n=(n<<11|n>>>21)+s|0)^s^i)+t[11]+1839030562|0,i+=((r=(r<<16|r>>>16)+n|0)^n^s)+t[14]-35309556|0,s+=((i=(i<<23|i>>>9)+r|0)^r^n)+t[1]-1530992060|0,n+=((s=(s<<4|s>>>28)+i|0)^i^r)+t[4]+1272893353|0,r+=((n=(n<<11|n>>>21)+s|0)^s^i)+t[7]-155497632|0,i+=((r=(r<<16|r>>>
116)+n|0)^n^s)+t[10]-1094730640|0,s+=((i=(i<<23|i>>>9)+r|0)^r^n)+t[13]+681279174|0,n+=((s=(s<<4|s>>>28)+i|0)^i^r)+t[0]-358537222|0,r+=((n=(n<<11|n>>>21)+s|0)^s^i)+t[3]-722521979|0,i+=((r=(r<<16|r>>>16)+n|0)^n^s)+t[6]+76029189|0,s+=((i=(i<<23|i>>>9)+r|0)^r^n)+t[9]-640364487|0,n+=((s=(s<<4|s>>>28)+i|0)^i^r)+t[12]-421815835|0,r+=((n=(n<<11|n>>>21)+s|0)^s^i)+t[15]+530742520|0,i+=((r=(r<<16|r>>>16)+n|0)^n^s)+t[2]-995338651|0,i=(i<<23|i>>>9)+r|0,s+=(r^(i|~n))+t[0]-198630844|0,s=(s<<6|s>>>26)+i|0,n+=(i^(s|~r))+t[7]+1126891415|0,n=(n<<10|n>>>22)+s|0,r+=(s^(n|~i))+t[14]-1416354905|0,r=(r<<15|r>>>17)+n|0,i+=(n^(r|~s))+t[5]-57434055|0,i=(i<<21|i>>>11)+r|0,s+=(r^(i|~n))+t[12]+1700485571|0,s=(s<<6|s>>>26)+i|0,n+=(i^(s|~r))+t[3]-1894986606|0,n=(n<<10|n>>>22)+s|0,r+=(s^(n|~i))+t[10]-1051523|0,r=(r<<15|r>>>17)+n|0,i+=(n^(r|~s))+t[1]-2054922799|0,i=(i<<21|i>>>11)+r|0,s+=(r^(i|~n))+t[8]+1873313359|0,s=(s<<6|s>>>26)+i|0,n+=(i^(s|~r))+t[15]-30611744|0,n=(n<<10|n>>>22)+s|0,r+=(s^(n|~i))+t[6]-1560198380|0,r=(r<<15|r>>>17)+n|0,i+=(n^(r|~s))+t[13]+1309151649|0,i=(i<<21|i>>>11)+r|0,s+=(r^(i|~n))+t[4]-145523070|0,s=(s<<6|s>>>26)+i|0,n+=(i^(s|~r))+t[11]-1120210379|0,n=(n<<10|n>>>22)+s|0,r+=(s^(n|~i))+t[2]+718787259|0,r=(r<<15|r>>>17)+n|0,i+=(n^(r|~s))+t[9]-343485551|0,i=(i<<21|i>>>11)+r|0,e[0]=s+e[0]|0,e[1]=i+e[1]|0,e[2]=r+e[2]|0,e[3]=n+e[3]|0}start(){return this._dataLength=0,this._bufferLength=0,this._state.set(i.stateIdentity),this}appendStr(e){let t,s;let r=this._buffer8,n=this._buffer32,o=this._bufferLength;for(s=0;s<e.length;s+=1){if((t=e.charCodeAt(s))<128)r[o++]=t;else if(t<2048)r[o++]=(t>>>6)+192,r[o++]=63&t|128;else if(t<55296||t>56319)r[o++]=(t>>>12)+224,r[o++]=t>>>6&63|128,r[o++]=63&t|128;else{if((t=(t-55296)*1024+(e.charCodeAt(++s)-56320)+65536)>1114111)throw Error("Unicode standard supports code points up to U+10FFFF");r[o++]=(t>>>18)+240,r[o++]=t>>>12&63|128,r[o++]=t>>>6&63|128,r[o++]=63&t|128}o>=64&&(this._dataLength+=64,i._md5cycle(this._state,n),o-=64,n[0]=n[16])}return this._bufferLength=o,this}appendAsciiStr(e){let t;let s=this._buffer8,r=this._buffer32,n=this._bufferLength,o=0;for(;;){for(t=Math.min(e.length-o,64-n);t--;)s[n++]=e.charCodeAt(o++);if(n<64)break;this._dataLength+=64,i._md5cycle(this._state,r),n=0}return this._bufferLength=n,this}appendByteArray(e){let t;let s=this._buffer8,r=this._buffer32,n=this._bufferLength,o=0;for(;;){for(t=Math.min(e.length-o,64-n);t--;)s[n++]=e[o++];if(n<64)break;this._dataLength+=64,i._md5cycle(this._state,r),n=0}return this._bufferLength=n,this}getState(){let e=this._state;return{buffer:String.fromCharCode.apply(null,this._buffer8),buflen:this._bufferLength,length:this._dataLength,state:[e[0],e[1],e[2],e[3]]}}setState(e){let t;let s=e.buffer,i=e.state,r=this._state;for(t=0,this._dataLength=e.length,this._bufferLength=e.buflen,r[0]=i[0],r[1]=i[1],r[2]=i[2],r[3]=i[3];t<s.length;t+=1)this._buffer8[t]=s.charCodeAt(t)}end(e=!1){let t;let s=this._bufferLength,r=this._buffer8,n=this._buffer32,o=(s>>2)+1;if(this._dataLength+=s,r[s]=128,r[s+1]=r[s+2]=r[s+3]=0,n.set(i.buffer32Identity.subarray(o),o),s>55&&(i._md5cycle(this._state,n),n.set(i.buffer32Identity)),(t=8*this._dataLength)<=4294967295)n[14]=t;else{let e=t.toString(16).match(/(.*?)(.{0,8})$/);if(null===e)return;let s=parseInt(e[2],16),i=parseInt(e[1],16)||0;n[14]=s,n[15]=i}return i._md5cycle(this._state,n),e?this._state:i._hex(this._state)}}i.stateIdentity=new Int32Array([1732584193,-271733879,-1732584194,271733878]),i.buffer32Identity=new Int32Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),i.hexChars="0123456789abcdef",i.hexOut=[],i.onePassHasher=new i,"5d41402abc4b2a76b9719d911017c592"!==i.hashStr("hello")&&console.error("Md5 self test failed.")},(e,t,s)=>{s.r(t),s.d(t,{UserAgentCore:()=>y});var i=s(29),r=s(27),n=s(83),o=s(64),a=s(63),c=s(71),h=s(61),d=s(76),l=s(90),g=s(91),u=s(92),p=s(62),f=s(95),m=s(87),S=s(86),v=s(89),T=s(96),b=s(97),R=s(28);let E=["application/sdp","application/dtmf-relay"];class y{constructor(e,t={}){this.userAgentClients=new Map,this.userAgentServers=new Map,this.configuration=e,this.delegate=t,this.dialogs=new Map,this.subscribers=new Map,this.logger=e.loggerFactory.getLogger("sip.user-agent-core")}dispose(){this.reset()}
1reset(){this.dialogs.forEach(e=>e.dispose()),this.dialogs.clear(),this.subscribers.forEach(e=>e.dispose()),this.subscribers.clear(),this.userAgentClients.forEach(e=>e.dispose()),this.userAgentClients.clear(),this.userAgentServers.forEach(e=>e.dispose()),this.userAgentServers.clear()}get loggerFactory(){return this.configuration.loggerFactory}get transport(){let e=this.configuration.transportAccessor();if(!e)throw Error("Transport undefined.");return e}invite(e,t){return new h.InviteUserAgentClient(this,e,t)}message(e,t){return new d.MessageUserAgentClient(this,e,t)}publish(e,t){return new l.PublishUserAgentClient(this,e,t)}register(e,t){return new g.RegisterUserAgentClient(this,e,t)}subscribe(e,t){return new u.SubscribeUserAgentClient(this,e,t)}request(e,t){return new p.UserAgentClient(o.NonInviteClientTransaction,this,e,t)}makeOutgoingRequestMessage(e,t,s,n,o,a,c){let h=this.configuration.sipjsId,d=this.configuration.displayName,l=this.configuration.viaForceRport,g=this.configuration.hackViaTcp,u=this.configuration.supportedOptionTags.slice();e===i.C.REGISTER&&u.push("path","gruu"),e===i.C.INVITE&&(this.configuration.contact.pubGruu||this.configuration.contact.tempGruu)&&u.push("gruu");let p=this.configuration.routeSet,f=Object.assign(Object.assign({},{callIdPrefix:h,forceRport:l,fromDisplayName:d,hackViaTcp:g,optionTags:u,routeSet:p,userAgentString:this.configuration.userAgentHeaderFieldValue,viaHost:this.configuration.viaHost}),o);return new r.OutgoingRequestMessage(e,t,s,n,f,a,c)}receiveIncomingRequestFromTransport(e){this.receiveRequestFromTransport(e)}receiveIncomingResponseFromTransport(e){this.receiveResponseFromTransport(e)}replyStateless(e,t){let s=this.configuration.userAgentHeaderFieldValue,i=this.configuration.supportedOptionTagsResponse;t=Object.assign(Object.assign({},t),{userAgent:s,supported:i});
1let r=(0,n.constructOutgoingResponse)(e,t);return this.transport.send(r.message).catch(t=>{t instanceof Error&&this.logger.error(t.message),this.logger.error(`Transport error occurred sending stateless reply to ${e.method} request.`)}),r}receiveRequestFromTransport(e){let t=e.viaBranch,s=this.userAgentServers.get(t);if(e.method===i.C.ACK&&s&&s.transaction.state===a.TransactionState.Accepted&&s instanceof f.InviteUserAgentServer){this.logger.warn(`Discarding out of dialog ACK after 2xx response sent on transaction ${t}.`);return}if(e.method===i.C.CANCEL){s?(this.replyStateless(e,{statusCode:200}),s.transaction instanceof c.InviteServerTransaction&&s.transaction.state===a.TransactionState.Proceeding&&s instanceof f.InviteUserAgentServer&&s.receiveCancel(e)):this.replyStateless(e,{statusCode:481});return}if(s){s.transaction.receiveRequest(e);return}this.receiveRequest(e)}receiveRequest(e){let t,s,r,n;if(!R.AllowedMethods.includes(e.method)){let t="Allow: "+R.AllowedMethods.toString();this.replyStateless(e,{statusCode:405,extraHeaders:[t]});return}if(!e.ruri)throw Error("Request-URI undefined.");if("sip"!==e.ruri.scheme){this.replyStateless(e,{statusCode:416});return}let o=e.ruri;if(!((t=this.configuration.aor)&&t.user===o.user)&&!((s=this.configuration.contact.uri)&&s.user===o.user||(r=this.configuration.contact.pubGruu)&&r.user===o.user||(n=this.configuration.contact.tempGruu)&&n.user===o.user)){this.logger.warn("Request-URI does not point to us."),e.method!==i.C.ACK&&this.replyStateless(e,{statusCode:404});return}if(e.method===i.C.INVITE&&!e.hasHeader("Contact")){this.replyStateless(e,{statusCode:400,reasonPhrase:"Missing Contact Header"});return}if(!e.toTag){let t=e.viaBranch;if(!this.userAgentServers.has(t)&&Array.from(this.userAgentServers.values()).some(t=>t.transaction.request.fromTag===e.fromTag&&t.transaction.request.callId===e.callId&&t.transaction.request.cseq===e.cseq)){this.replyStateless(e,{statusCode:482});return}}e.toTag?this.receiveInsideDialogRequest(e):this.receiveOutsideDialogRequest(e)}receiveInsideDialogRequest(e){if(e.method===i.C.NOTIFY){let t=e.parseHeader("Event");if(!t||!t.event){this.replyStateless(e,{statusCode:489});return}let s=e.callId+e.toTag+t.event,i=this.subscribers.get(s);if(i){let t=new m.NotifyUserAgentServer(this,e);i.onNotify(t);return}}let t=e.callId+e.toTag+e.fromTag,s=this.dialogs.get(t);if(s){if(e.method===i.C.OPTIONS){let t="Allow: "+R.AllowedMethods.toString(),s="Accept: "+E.toString();this.replyStateless(e,{statusCode:200,extraHeaders:[t,s]});return}s.receiveRequest(e);return}e.method!==i.C.ACK&&this.replyStateless(e,{statusCode:481})}receiveOutsideDialogRequest(e){switch(e.method){case i.C.ACK:break;case i.C.BYE:this.replyStateless(e,{statusCode:481});break;case i.C.CANCEL:throw Error(`Unexpected out of dialog request method ${e.method}.`);case i.C.INFO:this.replyStateless(e,{statusCode:405});break;case i.C.INVITE:{let t=new f.InviteUserAgentServer(this,e);this.delegate.onInvite?this.delegate.onInvite(t):t.reject()}break;case i.C.MESSAGE:{let t=new S.MessageUserAgentServer(this,e);this.delegate.onMessage?this.delegate.onMessage(t):t.accept()}break;case i.C.NOTIFY:{let t=new m.NotifyUserAgentServer(this,e);this.delegate.onNotify?this.delegate.onNotify(t):t.reject({statusCode:405})}break;case i.C.OPTIONS:{let t="Allow: "+R.AllowedMethods.toString(),s="Accept: "+E.toString();this.replyStateless(e,{statusCode:200,extraHeaders:[t,s]})}break;case i.C.REFER:{let t=new v.ReferUserAgentServer(this,e);this.delegate.onRefer?this.delegate.onRefer(t):t.reject({statusCode:405})}break;case i.C.REGISTER:{let t=new T.RegisterUserAgentServer(this,e);this.delegate.onRegister?this.delegate.onRegister(t):t.reject({statusCode:405})}break;case i.C.SUBSCRIBE:{let t=new b.SubscribeUserAgentServer(this,e);this.delegate.onSubscribe?this.delegate.onSubscribe(t):t.reject({statusCode:480})}break;default:throw Error(`Unexpected out of dialog request method ${e.method}.`)}}receiveResponseFromTransport(e){if(e.getHeaders("via").length>1){this.logger.warn("More than one Via header field present in the response, dropping");return}let t=e.viaBranch+e.method,s=this.userAgentClients.get(t);s?s.transaction.receiveResponse(e):this.logger.warn(`Discarding unmatched ${e.statusCode} response to ${e.method} ${t}.`)}}}
1,(e,t,s)=>{s.r(t),s.d(t,{InviteUserAgentClient:()=>h});var i=s(69),r=s(70),n=s(30),o=s(68),a=s(63),c=s(62);class h extends c.UserAgentClient{constructor(e,t,s){super(o.InviteClientTransaction,e,t,s),this.confirmedDialogAcks=new Map,this.confirmedDialogs=new Map,this.earlyDialogs=new Map,this.delegate=s}dispose(){this.earlyDialogs.forEach(e=>e.dispose()),this.earlyDialogs.clear(),super.dispose()}onTransportError(e){if(this.transaction.state===a.TransactionState.Calling)return super.onTransportError(e);this.logger.error(e.message),this.logger.error("User agent client request transport error while sending ACK.")}receiveResponse(e){if(!this.authenticationGuard(e))return;let t=e.statusCode?e.statusCode.toString():"";if(!t)throw Error("Response status code undefined.");switch(!0){case/^100$/.test(t):this.delegate&&this.delegate.onTrying&&this.delegate.onTrying({message:e});return;case/^1[0-9]{2}$/.test(t):{if(!e.toTag){this.logger.warn("Non-100 1xx INVITE response received without a to tag, dropping.");return}if(!e.parseHeader("contact")){this.logger.error("Non-100 1xx INVITE response received without a Contact header field, dropping.");return}let t=i.Dialog.initialDialogStateForUserAgentClient(this.message,e),s=this.earlyDialogs.get(t.id);if(!s){let e=this.transaction;if(!(e instanceof o.InviteClientTransaction))throw Error("Transaction not instance of InviteClientTransaction.");s=new r.SessionDialog(e,this.core,t),this.earlyDialogs.set(s.id,s)}if(!s.reliableSequenceGuard(e)){this.logger.warn("1xx INVITE reliable response received out of order or is a retransmission, dropping.");return}(s.signalingState===n.SignalingState.Initial||s.signalingState===n.SignalingState.HaveLocalOffer)&&s.signalingStateTransition(e);let a=s;this.delegate&&this.delegate.onProgress&&this.delegate.onProgress({message:e,session:a,prack:e=>a.prack(void 0,e)})}return;case/^2[0-9]{2}$/.test(t):{if(!e.toTag){this.logger.error("2xx INVITE response received without a to tag, dropping.");return}if(!e.parseHeader("contact")){this.logger.error("2xx INVITE response received without a Contact header field, dropping.");return}let t=i.Dialog.initialDialogStateForUserAgentClient(this.message,e),s=this.confirmedDialogs.get(t.id);if(s){let e=this.confirmedDialogAcks.get(t.id);if(e){let t=this.transaction;if(!(t instanceof o.InviteClientTransaction))throw Error("Client transaction not instance of InviteClientTransaction.");t.ackResponse(e.message)}return}if(s=this.earlyDialogs.get(t.id))s.confirm(),s.recomputeRouteSet(e),this.earlyDialogs.delete(s.id),this.confirmedDialogs.set(s.id,s);else{let e=this.transaction;if(!(e instanceof o.InviteClientTransaction))throw Error("Transaction not instance of InviteClientTransaction.");s=new r.SessionDialog(e,this.core,t),this.confirmedDialogs.set(s.id,s)}(s.signalingState===n.SignalingState.Initial||s.signalingState===n.SignalingState.HaveLocalOffer)&&s.signalingStateTransition(e);let a=s;if(this.delegate&&this.delegate.onAccept)this.delegate.onAccept({message:e,session:a,ack:e=>{let t=a.ack(e);return this.confirmedDialogAcks.set(a.id,t),t}});else{let e=a.ack();this.confirmedDialogAcks.set(a.id,e)}}return;case/^3[0-9]{2}
1$/.test(t):this.earlyDialogs.forEach(e=>e.dispose()),this.earlyDialogs.clear(),this.delegate&&this.delegate.onRedirect&&this.delegate.onRedirect({message:e});return;case/^[4-6][0-9]{2}$/.test(t):this.earlyDialogs.forEach(e=>e.dispose()),this.earlyDialogs.clear(),this.delegate&&this.delegate.onReject&&this.delegate.onReject({message:e});return;default:throw Error(`Invalid status code ${t}`)}throw Error(`Executing what should be an unreachable code path receiving ${t} response.`)}}},(e,t,s)=>{s.r(t),s.d(t,{UserAgentClient:()=>a});var i=s(29),r=s(26),n=s(63),o=s(64);class a{constructor(e,t,s,i){this.transactionConstructor=e,this.core=t,this.message=s,this.delegate=i,this.challenged=!1,this.stale=!1,this.logger=this.loggerFactory.getLogger("sip.user-agent-client"),this.init()}dispose(){this.transaction.dispose()}get loggerFactory(){return this.core.loggerFactory}get transaction(){if(!this._transaction)throw Error("Transaction undefined.");return this._transaction}cancel(e,t={}){if(!this.transaction)throw Error("Transaction undefined.");if(!this.message.to)throw Error("To undefined.");if(!this.message.from)throw Error("From undefined.");let s=this.core.makeOutgoingRequestMessage(i.C.CANCEL,this.message.ruri,this.message.from.uri,this.message.to.uri,{toTag:this.message.toTag,fromTag:this.message.fromTag,callId:this.message.callId,cseq:this.message.cseq},t.extraHeaders);return s.branch=this.message.branch,this.message.headers.Route&&(s.headers.Route=this.message.headers.Route),e&&s.setHeader("Reason",e),this.transaction.state===n.TransactionState.Proceeding?new a(o.NonInviteClientTransaction,this.core,s):this.transaction.addStateChangeListener(()=>{this.transaction&&this.transaction.state===n.TransactionState.Proceeding&&new a(o.NonInviteClientTransaction,this.core,s)},{once:!0}),s}authenticationGuard(e,t){let s,i;let r=e.statusCode;if(!r)throw Error("Response status code undefined.");if(401!==r&&407!==r)return!0;if(401===r?(s=e.parseHeader("www-authenticate"),i="authorization"):(s=e.parseHeader("proxy-authenticate"),i="proxy-authorization"),!s)return this.logger.warn(r+" with wrong or missing challenge, cannot authenticate"),!0;if(this.challenged&&(this.stale||!0!==s.stale))return this.logger.warn(r+" apparently in authentication loop, cannot authenticate"),!0;if(!this.credentials&&(this.credentials=this.core.configuration.authenticationFactory(),!this.credentials))return this.logger.warn("Unable to obtain credentials, cannot authenticate"),!0;if(!this.credentials.authenticate(this.message,s))return!0;this.challenged=!0,s.stale&&(this.stale=!0);let n=this.message.cseq+=1;return t&&t.localSequenceNumber&&(t.incrementLocalSequenceNumber(),n=this.message.cseq=t.localSequenceNumber),this.message.setHeader("cseq",n+" "+this.message.method),this.message.setHeader(i,this.credentials.toString()),this.init(),!1}onRequestTimeout(){this.logger.warn("User agent client request timed out. Generating internal 408 Request Timeout.");let e=new r.IncomingResponseMessage;e.statusCode=408,e.reasonPhrase="Request Timeout",this.receiveResponse(e)}onTransportError(e){this.logger.error(e.message),this.logger.error("User agent client request transport error. Generating internal 503 Service Unavailable.");let t=new r.IncomingResponseMessage;t.statusCode=503,t.reasonPhrase="Service Unavailable",this.receiveResponse(t)}receiveResponse(e){if(!this.authenticationGuard(e))return;let t=e.statusCode?e.statusCode.toString():"";if(!t)throw Error("Response status code undefined.");switch(!0){case/^100$/.test(t):this.delegate&&this.delegate.onTrying&&this.delegate.onTrying({message:e});break;case/^1[0-9]{2}$/.test(t):this.delegate&&this.delegate.onProgress&&this.delegate.onProgress({message:e});break;case/^2[0-9]{2}$/.test(t):this.delegate&&this.delegate.onAccept&&this.delegate.onAccept({message:e});break;case/^3[0-9]{2}$/.test(t):this.delegate&&this.delegate.onRedirect&&this.delegate.onRedirect({message:e});break;case/^[4-6][0-9]{2}$/.test(t):this.delegate&&this.delegate.onReject&&this.delegate.onReject({message:e});break;default:throw Error(`Invalid status code ${t}`)}}init(){let e={loggerFactory:this.loggerFactory,onRequestTimeout:()=>this.onRequestTimeout(),onStateChange:e=>{e===n.TransactionState.Terminated&&(this.core.userAgentClients.delete(s),t===this._transaction&&this.dispose())},onTransportError:e=>this.onTransportError(e),receiveResponse:e=>this.receiveResponse(e)},t=new this.transactionConstructor(this.message,this.core.transport,e);this._transaction=t;let s=t.id+t.request.method;this.core.userAgentClients.set(s,this)}}}
1,(e,t,s)=>{var i,r;s.r(t),s.d(t,{TransactionState:()=>i}),(r=i||(i={})).Accepted="Accepted",r.Calling="Calling",r.Completed="Completed",r.Confirmed="Confirmed",r.Proceeding="Proceeding",r.Terminated="Terminated",r.Trying="Trying"},(e,t,s)=>{s.r(t),s.d(t,{NonInviteClientTransaction:()=>o});var i=s(36),r=s(65),n=s(63);class o extends r.ClientTransaction{constructor(e,t,s){super(e,t,s,n.TransactionState.Trying,"sip.transaction.nict"),this.F=setTimeout(()=>this.timerF(),i.Timers.TIMER_F),this.send(e.toString()).catch(e=>{this.logTransportError(e,"Failed to send initial outgoing request.")})}dispose(){this.F&&(clearTimeout(this.F),this.F=void 0),this.K&&(clearTimeout(this.K),this.K=void 0),super.dispose()}get kind(){return"nict"}receiveResponse(e){let t=e.statusCode;if(!t||t<100||t>699)throw Error(`Invalid status code ${t}`);switch(this.state){case n.TransactionState.Trying:if(t>=100&&t<=199){this.stateTransition(n.TransactionState.Proceeding),this.user.receiveResponse&&this.user.receiveResponse(e);return}if(t>=200&&t<=699){if(this.stateTransition(n.TransactionState.Completed),408===t){this.onRequestTimeout();return}this.user.receiveResponse&&this.user.receiveResponse(e);return}break;case n.TransactionState.Proceeding:if(t>=100&&t<=199&&this.user.receiveResponse)return this.user.receiveResponse(e);if(t>=200&&t<=699){if(this.stateTransition(n.TransactionState.Completed),408===t){this.onRequestTimeout();return}this.user.receiveResponse&&this.user.receiveResponse(e);return}break;case n.TransactionState.Completed:case n.TransactionState.Terminated:return;default:throw Error(`Invalid state ${this.state}`)}let s=`Non-INVITE client transaction received unexpected ${t} response while in state ${this.state}.`;this.logger.warn(s)}onTransportError(e){this.user.onTransportError&&this.user.onTransportError(e),this.stateTransition(n.TransactionState.Terminated,!0)}typeToString(){return"non-INVITE client transaction"}stateTransition(e,t=!1){let s=()=>{throw Error(`Invalid state transition from ${this.state} to ${e}`)};switch(e){case n.TransactionState.Trying:s();break;case n.TransactionState.Proceeding:this.state!==n.TransactionState.Trying&&s();break;case n.TransactionState.Completed:this.state!==n.TransactionState.Trying&&this.state!==n.TransactionState.Proceeding&&s();break;case n.TransactionState.Terminated:this.state===n.TransactionState.Trying||this.state===n.TransactionState.Proceeding||this.state===n.TransactionState.Completed||t||s();break;default:s()}e===n.TransactionState.Completed&&(this.F&&(clearTimeout(this.F),this.F=void 0),this.K=setTimeout(()=>this.timerK(),i.Timers.TIMER_K)),e===n.TransactionState.Terminated&&this.dispose(),this.setState(e)}timerF(){this.logger.debug(`Timer F expired for non-INVITE client transaction ${this.id}.`),(this.state===n.TransactionState.Trying||this.state===n.TransactionState.Proceeding)&&(this.onRequestTimeout(),this.stateTransition(n.TransactionState.Terminated))}timerK(){this.state===n.TransactionState.Completed&&this.stateTransition(n.TransactionState.Terminated)}}}
1,(e,t,s)=>{s.r(t),s.d(t,{ClientTransaction:()=>r});var i=s(66);class r extends i.Transaction{constructor(e,t,s,i,n){super(t,s,r.makeId(e),i,n),this._request=e,this.user=s,e.setViaHeader(this.id,t.protocol)}static makeId(e){if("CANCEL"!==e.method)return"z9hG4bK"+Math.floor(1e7*Math.random());if(!e.branch)throw Error("Outgoing CANCEL request without a branch.");return e.branch}get request(){return this._request}onRequestTimeout(){this.user.onRequestTimeout&&this.user.onRequestTimeout()}}},(e,t,s)=>{s.r(t),s.d(t,{Transaction:()=>r});var i=s(67);class r{constructor(e,t,s,i,r){this._transport=e,this._user=t,this._id=s,this._state=i,this.listeners=[],this.logger=t.loggerFactory.getLogger(r,s),this.logger.debug(`Constructing ${this.typeToString()} with id ${this.id}.`)}dispose(){this.logger.debug(`Destroyed ${this.typeToString()} with id ${this.id}.`)}get id(){return this._id}get kind(){throw Error("Invalid kind.")}get state(){return this._state}get transport(){return this._transport}addStateChangeListener(e,t){let s=()=>{this.removeStateChangeListener(s),e()};(null==t?void 0:t.once)===!0?this.listeners.push(s):this.listeners.push(e)}notifyStateChangeListeners(){this.listeners.slice().forEach(e=>e())}removeStateChangeListener(e){this.listeners=this.listeners.filter(t=>t!==e)}logTransportError(e,t){this.logger.error(e.message),this.logger.error(`Transport error occurred in ${this.typeToString()} with id ${this.id}.`),this.logger.error(t)}send(e){return this.transport.send(e).catch(e=>{let t;if(e instanceof i.TransportError)throw this.onTransportError(e),e;throw t=e&&"string"==typeof e.message?new i.TransportError(e.message):new i.TransportError,this.onTransportError(t),t})}setState(e){this.logger.debug(`State change to "${e}" on ${this.typeToString()} with id ${this.id}.`),this._state=e,this._user.onStateChange&&this._user.onStateChange(e),this.notifyStateChangeListeners()}typeToString(){return"UnknownType"}}},(e,t,s)=>{s.r(t),s.d(t,{TransportError:()=>r});var i=s(5);class r extends i.Exception{constructor(e){super(e||"Unspecified transport error.")}}},(e,t,s)=>{s.r(t),s.d(t,{InviteClientTransaction:()=>o});var i=s(36),r=s(65),n=s(63);class o extends r.ClientTransaction{constructor(e,t,s){super(e,t,s,n.TransactionState.Calling,"sip.transaction.ict"),this.ackRetransmissionCache=new Map,this.B=setTimeout(()=>this.timerB(),i.Timers.TIMER_B),this.send(e.toString()).catch(e=>{this.logTransportError(e,"Failed to send initial outgoing request.")})}dispose(){this.B&&(clearTimeout(this.B),this.B=void 0),this.D&&(clearTimeout(this.D),this.D=void 0),this.M&&(clearTimeout(this.M),this.M=void 0),super.dispose()}get kind(){return"ict"}ackResponse(e){let t=e.toTag;if(!t)throw Error("To tag undefined.");e.setViaHeader("z9hG4bK"+Math.floor(1e7*Math.random()),this.transport.protocol),this.ackRetransmissionCache.set(t,e),this.send(e.toString()).catch(e=>{this.logTransportError(e,"Failed to send ACK to 2xx response.")})}receiveResponse(e){let t=e.statusCode;if(!t||t<100||t>699)throw Error(`Invalid status code ${t}`);switch(this.state){case n.TransactionState.Calling:if(t>=100&&t<=199){this.stateTransition(n.TransactionState.Proceeding),this.user.receiveResponse&&this.user.receiveResponse(e);return}if(t>=200&&t<=299){this.ackRetransmissionCache.set(e.toTag,void 0),this.stateTransition(n.TransactionState.Accepted),this.user.receiveResponse&&this.user.receiveResponse(e);return}if(t>=300&&t<=699){this.stateTransition(n.TransactionState.Completed),this.ack(e),this.user.receiveResponse&&this.user.receiveResponse(e);return}break;case n.TransactionState.Proceeding:if(t>=100&&t<=199){this.user.receiveResponse&&this.user.receiveResponse(e);return}if(t>=200&&t<=299){this.ackRetransmissionCache.set(e.toTag,void 0),this.stateTransition(n.TransactionState.Accepted),this.user.receiveResponse&&this.user.receiveResponse(e);return}if(t>=300&&t<=699){this.stateTransition(n.TransactionState.Completed),this.ack(e),this.user.receiveResponse&&this.user.receiveResponse(e);return}break;case n.TransactionState.Accepted:if(t>=200&&t<=299){if(!this.ackRetransmissionCache.has(e.toTag)){this.ackRetransmissionCache.set(e.toTag,void 0),this.user.receiveResponse&&this.user.receiveResponse(e);return}let t=this.ackRetransmissionCache.get(e.toTag);t&&this.send(t.toString()).catch(e=>{this.logTransportError(e,"Failed to send retransmission of ACK to 2xx response.")});return}break;case n.TransactionState.Completed:if(t>=300&&t<=699){this.ack(e);return}break;case n.TransactionState.Terminated:break;default:throw Error(`Invalid state ${this.state}`)}let s=`Received unexpected ${t} response while in state ${this.state}.`;this.logger.warn(s)}onTransportError(e){this.user.onTransportError&&this.user.onTransportError(e),this.stateTransition(n.TransactionState.Terminated,!0)}typeToString(){return"INVITE client transaction"}ack(e){let t=this.request.ruri,s=this.request.callId,i=this.request.cseq,r=this.request.getHeader("from"),n=e.getHeader("to"),o=this.request.getHeader("via"),a=this.request.getHeader("route");
1if(!r)throw Error("From undefined.");if(!n)throw Error("To undefined.");if(!o)throw Error("Via undefined.");let c=`ACK ${t} SIP/2.0\r
2`;a&&(c+=`Route: ${a}\r
3`),c+=`Via: ${o}\r
4To: ${n}\r
5From: ${r}\r
6Call-ID: ${s}\r
7CSeq: ${i} ACK\r
8Max-Forwards: 70\r
9Content-Length: 0\r
10\r
11`,this.send(c).catch(e=>{this.logTransportError(e,"Failed to send ACK to non-2xx response.")})}stateTransition(e,t=!1){let s=()=>{throw Error(`Invalid state transition from ${this.state} to ${e}`)};switch(e){case n.TransactionState.Calling:s();break;case n.TransactionState.Proceeding:this.state!==n.TransactionState.Calling&&s();break;case n.TransactionState.Accepted:case n.TransactionState.Completed:this.state!==n.TransactionState.Calling&&this.state!==n.TransactionState.Proceeding&&s();break;case n.TransactionState.Terminated:this.state===n.TransactionState.Calling||this.state===n.TransactionState.Accepted||this.state===n.TransactionState.Completed||t||s();break;default:s()}this.B&&(clearTimeout(this.B),this.B=void 0),n.TransactionState.Proceeding,e===n.TransactionState.Completed&&(this.D=setTimeout(()=>this.timerD(),i.Timers.TIMER_D)),e===n.TransactionState.Accepted&&(this.M=setTimeout(()=>this.timerM(),i.Timers.TIMER_M)),e===n.TransactionState.Terminated&&this.dispose(),this.setState(e)}timerA(){}timerB(){this.logger.debug(`Timer B expired for INVITE client transaction ${this.id}.`),this.state===n.TransactionState.Calling&&(this.onRequestTimeout(),this.stateTransition(n.TransactionState.Terminated))}timerD(){this.logger.debug(`Timer D expired for INVITE client transaction ${this.id}.`),this.state===n.TransactionState.Completed&&this.stateTransition(n.TransactionState.Terminated)}timerM(){this.logger.debug(`Timer M expired for INVITE client transaction ${this.id}.`),this.state===n.TransactionState.Accepted&&this.stateTransition(n.TransactionState.Terminated)}}}
11,(e,t,s)=>{s.r(t),s.d(t,{Dialog:()=>n});var i=s(25),r=s(29);class n{constructor(e,t){this.core=e,this.dialogState=t,this.core.dialogs.set(this.id,this)}static initialDialogStateForUserAgentClient(e,t){let s=t.getHeaders("record-route").reverse(),r=t.parseHeader("contact");if(!r)throw Error("Contact undefined.");if(!(r instanceof i.NameAddrHeader))throw Error("Contact not instance of NameAddrHeader.");let n=r.uri,o=e.cseq,a=e.callId,c=e.fromTag,h=t.toTag;if(!a)throw Error("Call id undefined.");if(!c)throw Error("From tag undefined.");if(!h)throw Error("To tag undefined.");if(!e.from)throw Error("From undefined.");if(!e.to)throw Error("To undefined.");let d=e.from.uri,l=e.to.uri;if(!t.statusCode)throw Error("Incoming response status code undefined.");return{id:a+c+h,early:t.statusCode<200,callId:a,localTag:c,remoteTag:h,localSequenceNumber:o,remoteSequenceNumber:void 0,localURI:d,remoteURI:l,remoteTarget:n,routeSet:s,secure:!1}}static initialDialogStateForUserAgentServer(e,t,s=!1){let r=e.getHeaders("record-route"),n=e.parseHeader("contact");if(!n)throw Error("Contact undefined.");if(!(n instanceof i.NameAddrHeader))throw Error("Contact not instance of NameAddrHeader.");let o=n.uri,a=e.cseq,c=e.callId,h=e.fromTag,d=e.from.uri;return{id:c+t+h,early:s,callId:c,localTag:t,remoteTag:h,localSequenceNumber:void 0,remoteSequenceNumber:a,localURI:e.to.uri,remoteURI:d,remoteTarget:o,routeSet:r,secure:!1}}dispose(){this.core.dialogs.delete(this.id)}get id(){return this.dialogState.id}get early(){return this.dialogState.early}get callId(){return this.dialogState.callId}get localTag(){return this.dialogState.localTag}get remoteTag(){return this.dialogState.remoteTag}get localSequenceNumber(){return this.dialogState.localSequenceNumber}get remoteSequenceNumber(){return this.dialogState.remoteSequenceNumber}get localURI(){return this.dialogState.localURI}get remoteURI(){return this.dialogState.remoteURI}get remoteTarget(){return this.dialogState.remoteTarget}get routeSet(){return this.dialogState.routeSet}get secure(){return this.dialogState.secure}get userAgentCore(){return this.core}confirm(){this.dialogState.early=!1}receiveRequest(e){if(e.method!==r.C.ACK){if(this.remoteSequenceNumber){if(e.cseq<=this.remoteSequenceNumber)throw Error("Out of sequence in dialog request. Did you forget to call sequenceGuard()?");this.dialogState.remoteSequenceNumber=e.cseq}this.remoteSequenceNumber||(this.dialogState.remoteSequenceNumber=e.cseq)}}recomputeRouteSet(e){this.dialogState.routeSet=e.getHeaders("record-route").reverse()}createOutgoingRequestMessage(e,t){let s;let i=this.remoteURI,r=this.remoteTag,n=this.localURI,o=this.localTag,a=this.callId;s=t&&t.cseq?t.cseq:this.dialogState.localSequenceNumber?this.dialogState.localSequenceNumber+=1:this.dialogState.localSequenceNumber=1;let c=this.remoteTarget,h=this.routeSet,d=t&&t.extraHeaders,l=t&&t.body;return this.userAgentCore.makeOutgoingRequestMessage(e,c,n,i,{callId:a,cseq:s,fromTag:o,toTag:r,routeSet:h},d,l)}incrementLocalSequenceNumber(){if(!this.dialogState.localSequenceNumber)throw Error("Local sequence number undefined.");this.dialogState.localSequenceNumber+=1}sequenceGuard(e){return e.method===r.C.ACK||!this.remoteSequenceNumber||!(e.cseq<=this.remoteSequenceNumber)||(this.core.replyStateless(e,{statusCode:500}),!1)}}}
11,(e,t,s)=>{s.r(t),s.d(t,{SessionDialog:()=>D});var i=s(29),r=s(25),n=s(17),o=s(18),a=s(26),c=s(27),h=s(30),d=s(36),l=s(71),g=s(68),u=s(63),p=s(73),f=s(80),m=s(74),S=s(84),v=s(76),T=s(86),b=s(77),R=s(87),E=s(78),y=s(88),I=s(75),w=s(85),C=s(79),$=s(89),A=s(69);class D extends A.Dialog{constructor(e,t,s,i){super(t,s),this.initialTransaction=e,this._signalingState=h.SignalingState.Initial,this.ackWait=!1,this.ackProcessing=!1,this.delegate=i,e instanceof l.InviteServerTransaction&&(this.ackWait=!0),this.early||this.start2xxRetransmissionTimer(),this.signalingStateTransition(e.request),this.logger=t.loggerFactory.getLogger("sip.invite-dialog"),this.logger.log(`INVITE dialog ${this.id} constructed`)}dispose(){super.dispose(),this._signalingState=h.SignalingState.Closed,this._offer=void 0,this._answer=void 0,this.invite2xxTimer&&(clearTimeout(this.invite2xxTimer),this.invite2xxTimer=void 0),this.logger.log(`INVITE dialog ${this.id} destroyed`)}get sessionState(){return this.early?h.SessionState.Early:this.ackWait?h.SessionState.AckWait:this._signalingState===h.SignalingState.Closed?h.SessionState.Terminated:h.SessionState.Confirmed}get signalingState(){return this._signalingState}get offer(){return this._offer}get answer(){return this._answer}confirm(){this.early&&this.start2xxRetransmissionTimer(),super.confirm()}reConfirm(){this.reinviteUserAgentServer&&this.startReInvite2xxRetransmissionTimer()}ack(e={}){let t;if(this.logger.log(`INVITE dialog ${this.id} sending ACK request`),this.reinviteUserAgentClient){if(!(this.reinviteUserAgentClient.transaction instanceof g.InviteClientTransaction))throw Error("Transaction not instance of InviteClientTransaction.");t=this.reinviteUserAgentClient.transaction,this.reinviteUserAgentClient=void 0}else{if(!(this.initialTransaction instanceof g.InviteClientTransaction))throw Error("Initial transaction not instance of InviteClientTransaction.");t=this.initialTransaction}let s=this.createOutgoingRequestMessage(i.C.ACK,{cseq:t.request.cseq,extraHeaders:e.extraHeaders,body:e.body});return t.ackResponse(s),this.signalingStateTransition(s),{message:s}}bye(e,t){if(this.logger.log(`INVITE dialog ${this.id} sending BYE request`),this.initialTransaction instanceof l.InviteServerTransaction){if(this.early)throw Error("UAS MUST NOT send a BYE on early dialogs.");if(this.ackWait&&this.initialTransaction.state!==u.TransactionState.Terminated)throw Error("UAS MUST NOT send a BYE on a confirmed dialog until it has received an ACK for its 2xx response or until the server transaction times out.")}return new p.ByeUserAgentClient(this,e,t)}info(e,t){if(this.logger.log(`INVITE dialog ${this.id} sending INFO request`),this.early)throw Error("Dialog not confirmed.");return new m.InfoUserAgentClient(this,e,t)}invite(e,t){if(this.logger.log(`INVITE dialog ${this.id} sending INVITE request`),this.early)throw Error("Dialog not confirmed.");if(this.reinviteUserAgentClient)throw Error("There is an ongoing re-INVITE client transaction.");if(this.reinviteUserAgentServer)throw Error("There is an ongoing re-INVITE server transaction.");return new I.ReInviteUserAgentClient(this,e,t)}message(e,t){if(this.logger.log(`INVITE dialog ${this.id} sending MESSAGE request`),this.early)throw Error("Dialog not confirmed.");let s=this.createOutgoingRequestMessage(i.C.MESSAGE,t);return new v.MessageUserAgentClient(this.core,s,e)}notify(e,t){if(this.logger.log(`INVITE dialog ${this.id} sending NOTIFY request`),this.early)throw Error("Dialog not confirmed.");return new b.NotifyUserAgentClient(this,e,t)}prack(e,t){return this.logger.log(`INVITE dialog ${this.id} sending PRACK request`),new E.PrackUserAgentClient(this,e,t)}refer(e,t){if(this.logger.log(`INVITE dialog ${this.id} sending REFER request`),this.early)throw Error("Dialog not confirmed.");return new C.ReferUserAgentClient(this,e,t)}receiveRequest(e){if(this.logger.log(`INVITE dialog ${this.id} received ${e.method} request`),e.method===i.C.ACK){if(this.ackWait){if(this.initialTransaction instanceof g.InviteClientTransaction||this.initialTransaction.request.cseq!==e.cseq){this.logger.warn(`INVITE dialog ${this.id} received unexpected ${e.method} request, dropping.`);return}this.ackWait=!1}else{if(!this.reinviteUserAgentServer||this.reinviteUserAgentServer.transaction.request.cseq!==e.cseq){this.logger.warn(`INVITE dialog ${this.id} received unexpected ${e.method} request, dropping.`);return}this.reinviteUserAgentServer=void 0}if(this.signalingStateTransition(e),this.delegate&&this.delegate.onAck){let t=this.delegate.onAck({message:e});t instanceof Promise&&(this.ackProcessing=!0,t.then(()=>this.ackProcessing=!1).catch(()=>this.ackProcessing=!1))}return}if(!this.sequenceGuard(e)){this.logger.log(`INVITE dialog ${this.id} rejected out of order ${e.method} request.`);return}if(super.receiveRequest(e),e.method===i.C.INVITE){let t=[`Retry-After: ${Math.floor(10*Math.random())+1}`];if(this.ackProcessing||this.ackWait&&this.signalingState!==h.SignalingState.Stable){this.core.replyStateless(e,{statusCode:500,extraHeaders:t}),(()=>{let e=this.ackWait?"waiting for initial ACK":"processing initial ACK";this.logger.warn(`INVITE dialog ${this.id}
11 received re-INVITE while ${e}`);let t="RFC 5407 suggests the following to avoid this race condition... ";t+=" Note: Implementation issues are outside the scope of this document, but the following tip is provided for avoiding race conditions of this type.  The caller can delay sending re-INVITE F6 for some period of time (2 seconds, perhaps), after which the caller can reasonably assume that its ACK has been received.  Implementors can decouple the actions of the user (e.g., pressing the hold button) from the actions of the protocol (the sending of re-INVITE F6), so that the UA can behave like this.  In this case, it is the implementor's choice as to how long to wait.  In most cases, such an implementation may be useful to prevent the type of race condition shown in this section. This document expresses no preference about whether or not they should wait for an ACK to be delivered.  After considering the impact on user experience, implementors should decide whether or not to wait for a while, because the user experience depends on the implementation and has no direct bearing on protocol behavior.",this.logger.warn(t)})();return}if(this.reinviteUserAgentServer){this.core.replyStateless(e,{statusCode:500,extraHeaders:t});return}if(this.reinviteUserAgentClient){this.core.replyStateless(e,{statusCode:491});return}}if(e.method===i.C.INVITE){let t=e.parseHeader("contact");if(!t)throw Error("Contact undefined.");if(!(t instanceof r.NameAddrHeader))throw Error("Contact not instance of NameAddrHeader.");this.dialogState.remoteTarget=t.uri}switch(e.method){case i.C.BYE:{let t=new f.ByeUserAgentServer(this,e);this.delegate&&this.delegate.onBye?this.delegate.onBye(t):t.accept(),this.dispose()}break;case i.C.INFO:{let t=new S.InfoUserAgentServer(this,e);this.delegate&&this.delegate.onInfo?this.delegate.onInfo(t):t.reject({statusCode:469,extraHeaders:["Recv-Info:"]})}break;case i.C.INVITE:{let t=new w.ReInviteUserAgentServer(this,e);this.signalingStateTransition(e),this.delegate&&this.delegate.onInvite?this.delegate.onInvite(t):t.reject({statusCode:488})}break;case i.C.MESSAGE:{let t=new T.MessageUserAgentServer(this.core,e);this.delegate&&this.delegate.onMessage?this.delegate.onMessage(t):t.accept()}break;case i.C.NOTIFY:{let t=new R.NotifyUserAgentServer(this,e);this.delegate&&this.delegate.onNotify?this.delegate.onNotify(t):t.accept()}break;case i.C.PRACK:{let t=new y.PrackUserAgentServer(this,e);this.delegate&&this.delegate.onPrack?this.delegate.onPrack(t):t.accept()}break;case i.C.REFER:{let t=new $.ReferUserAgentServer(this,e);this.delegate&&this.delegate.onRefer?this.delegate.onRefer(t):t.reject()}break;default:this.logger.log(`INVITE dialog ${this.id} received unimplemented ${e.method} request`),this.core.replyStateless(e,{statusCode:501})}}reliableSequenceGuard(e){let t=e.statusCode;if(!t)throw Error("Status code undefined");if(t>100&&t<200){let t=e.getHeader("require"),s=e.getHeader("rseq"),i=t&&t.includes("100rel")&&s?Number(s):void 0;if(i){if(this.rseq&&this.rseq+1!==i)return!1;this.rseq=this.rseq?this.rseq+1:i}}return!0}signalingStateRollback(){(this._signalingState===h.SignalingState.HaveLocalOffer||this.signalingState===h.SignalingState.HaveRemoteOffer)&&this._rollbackOffer&&this._rollbackAnswer&&(this._signalingState=h.SignalingState.Stable,this._offer=this._rollbackOffer,this._answer=this._rollbackAnswer)}signalingStateTransition(e){let t=(0,n.getBody)(e);if(t&&"session"===t.contentDisposition){if(this._signalingState===h.SignalingState.Stable&&(this._rollbackOffer=this._offer,this._rollbackAnswer=this._answer),e instanceof o.IncomingRequestMessage||e instanceof a.IncomingResponseMessage)switch(this._signalingState){case h.SignalingState.Initial:case h.SignalingState.Stable:this._signalingState=h.SignalingState.HaveRemoteOffer,this._offer=t,this._answer=void 0;break;case h.SignalingState.HaveLocalOffer:this._signalingState=h.SignalingState.Stable,this._answer=t;break;case h.SignalingState.HaveRemoteOffer:case h.SignalingState.Closed:break;default:throw Error("Unexpected signaling state.")}if(e instanceof c.OutgoingRequestMessage||(0,n.isBody)(e))switch(this._signalingState){case h.SignalingState.Initial:case h.SignalingState.Stable:this._signalingState=h.SignalingState.HaveLocalOffer,this._offer=t,this._answer=void 0;break;case h.SignalingState.HaveLocalOffer:break;case h.SignalingState.HaveRemoteOffer:this._signalingState=h.SignalingState.Stable,this._answer=t;break;case h.SignalingState.Closed:break;default:throw Error("Unexpected signaling state.")}}}start2xxRetransmissionTimer(){if(this.initialTransaction instanceof l.InviteServerTransaction){let e=this.initialTransaction,t=d.Timers.T1,s=()=>
11{if(!this.ackWait){this.invite2xxTimer=void 0;return}this.logger.log("No ACK for 2xx response received, attempting retransmission"),e.retransmitAcceptedResponse(),t=Math.min(2*t,d.Timers.T2),this.invite2xxTimer=setTimeout(s,t)};this.invite2xxTimer=setTimeout(s,t);let i=()=>{e.state===u.TransactionState.Terminated&&(e.removeStateChangeListener(i),this.invite2xxTimer&&(clearTimeout(this.invite2xxTimer),this.invite2xxTimer=void 0),this.ackWait&&(this.delegate&&this.delegate.onAckTimeout?this.delegate.onAckTimeout():this.bye()))};e.addStateChangeListener(i)}}startReInvite2xxRetransmissionTimer(){if(this.reinviteUserAgentServer&&this.reinviteUserAgentServer.transaction instanceof l.InviteServerTransaction){let e=this.reinviteUserAgentServer.transaction,t=d.Timers.T1,s=()=>{if(!this.reinviteUserAgentServer){this.invite2xxTimer=void 0;return}this.logger.log("No ACK for 2xx response received, attempting retransmission"),e.retransmitAcceptedResponse(),t=Math.min(2*t,d.Timers.T2),this.invite2xxTimer=setTimeout(s,t)};this.invite2xxTimer=setTimeout(s,t);let i=()=>{e.state===u.TransactionState.Terminated&&(e.removeStateChangeListener(i),this.invite2xxTimer&&(clearTimeout(this.invite2xxTimer),this.invite2xxTimer=void 0),this.reinviteUserAgentServer)};e.addStateChangeListener(i)}}}}
11,(e,t,s)=>{s.r(t),s.d(t,{InviteServerTransaction:()=>a});var i=s(29),r=s(36),n=s(72),o=s(63);class a extends n.ServerTransaction{constructor(e,t,s){super(e,t,s,o.TransactionState.Proceeding,"sip.transaction.ist")}dispose(){this.stopProgressExtensionTimer(),this.H&&(clearTimeout(this.H),this.H=void 0),this.I&&(clearTimeout(this.I),this.I=void 0),this.L&&(clearTimeout(this.L),this.L=void 0),super.dispose()}get kind(){return"ist"}receiveRequest(e){switch(this.state){case o.TransactionState.Proceeding:if(e.method===i.C.INVITE){this.lastProvisionalResponse&&this.send(this.lastProvisionalResponse).catch(e=>{this.logTransportError(e,"Failed to send retransmission of provisional response.")});return}break;case o.TransactionState.Accepted:if(e.method===i.C.INVITE)return;break;case o.TransactionState.Completed:if(e.method===i.C.INVITE){if(!this.lastFinalResponse)throw Error("Last final response undefined.");this.send(this.lastFinalResponse).catch(e=>{this.logTransportError(e,"Failed to send retransmission of final response.")});return}if(e.method===i.C.ACK){this.stateTransition(o.TransactionState.Confirmed);return}break;case o.TransactionState.Confirmed:case o.TransactionState.Terminated:if(e.method===i.C.INVITE||e.method===i.C.ACK)return;break;default:throw Error(`Invalid state ${this.state}`)}let t=`INVITE server transaction received unexpected ${e.method} request while in state ${this.state}.`;this.logger.warn(t)}receiveResponse(e,t){if(e<100||e>699)throw Error(`Invalid status code ${e}`);switch(this.state){case o.TransactionState.Proceeding:if(e>=100&&e<=199){this.lastProvisionalResponse=t,e>100&&this.startProgressExtensionTimer(),this.send(t).catch(e=>{this.logTransportError(e,"Failed to send 1xx response.")});return}if(e>=200&&e<=299){this.lastFinalResponse=t,this.stateTransition(o.TransactionState.Accepted),this.send(t).catch(e=>{this.logTransportError(e,"Failed to send 2xx response.")});return}if(e>=300&&e<=699){this.lastFinalResponse=t,this.stateTransition(o.TransactionState.Completed),this.send(t).catch(e=>{this.logTransportError(e,"Failed to send non-2xx final response.")});return}break;case o.TransactionState.Accepted:if(e>=200&&e<=299){this.send(t).catch(e=>{this.logTransportError(e,"Failed to send 2xx response.")});return}break;case o.TransactionState.Completed:case o.TransactionState.Confirmed:case o.TransactionState.Terminated:break;default:throw Error(`Invalid state ${this.state}`)}let s=`INVITE server transaction received unexpected ${e} response from TU while in state ${this.state}.`;throw this.logger.error(s),Error(s)}retransmitAcceptedResponse(){this.state===o.TransactionState.Accepted&&this.lastFinalResponse&&this.send(this.lastFinalResponse).catch(e=>{this.logTransportError(e,"Failed to send 2xx response.")})}onTransportError(e){this.user.onTransportError&&this.user.onTransportError(e)}typeToString(){return"INVITE server transaction"}stateTransition(e){let t=()=>{throw Error(`Invalid state transition from ${this.state} to ${e}`)};switch(e){case o.TransactionState.Proceeding:t();break;case o.TransactionState.Accepted:case o.TransactionState.Completed:this.state!==o.TransactionState.Proceeding&&t();break;case o.TransactionState.Confirmed:this.state!==o.TransactionState.Completed&&t();break;case o.TransactionState.Terminated:this.state!==o.TransactionState.Accepted&&this.state!==o.TransactionState.Completed&&this.state!==o.TransactionState.Confirmed&&t();break;default:t()}this.stopProgressExtensionTimer(),e===o.TransactionState.Accepted&&(this.L=setTimeout(()=>this.timerL(),r.Timers.TIMER_L)),e===o.TransactionState.Completed&&(this.H=setTimeout(()=>this.timerH(),r.Timers.TIMER_H)),e===o.TransactionState.Confirmed&&(this.I=setTimeout(()=>this.timerI(),r.Timers.TIMER_I)),e===o.TransactionState.Terminated&&this.dispose(),this.setState(e)}startProgressExtensionTimer(){void 0===this.progressExtensionTimer&&(this.progressExtensionTimer=setInterval(()=>{if(this.logger.debug(`Progress extension timer expired for INVITE server transaction ${this.id}.`),!this.lastProvisionalResponse)throw Error("Last provisional response undefined.");this.send(this.lastProvisionalResponse).catch(e=>{this.logTransportError(e,"Failed to send retransmission of provisional response.")})},r.Timers.PROVISIONAL_RESPONSE_INTERVAL))}stopProgressExtensionTimer(){void 0!==this.progressExtensionTimer&&(clearInterval(this.progressExtensionTimer),this.progressExtensionTimer=void 0)}timerG(){}timerH(){this.logger.debug(`Timer H expired for INVITE server transaction ${this.id}.`),this.state===o.TransactionState.Completed&&(this.logger.warn("ACK to negative final response was never received, terminating transaction."),this.stateTransition(o.TransactionState.Terminated))}timerI(){this.logger.debug(`Timer I expired for INVITE server transaction ${this.id}.`),this.stateTransition(o.TransactionState.Terminated)}timerL(){this.logger.debug(`Timer L expired for INVITE server transaction ${this.id}.`),this.state===o.TransactionState.Accepted&&this.stateTransition(o.TransactionState.Terminated)}}}
11,(e,t,s)=>{s.r(t),s.d(t,{ServerTransaction:()=>r});var i=s(66);class r extends i.Transaction{constructor(e,t,s,i,r){super(t,s,e.viaBranch,i,r),this._request=e,this.user=s}get request(){return this._request}}},(e,t,s)=>{s.r(t),s.d(t,{ByeUserAgentClient:()=>o});var i=s(29),r=s(64),n=s(62);class o extends n.UserAgentClient{constructor(e,t,s){super(r.NonInviteClientTransaction,e.userAgentCore,e.createOutgoingRequestMessage(i.C.BYE,s),t),e.dispose()}}},(e,t,s)=>{s.r(t),s.d(t,{InfoUserAgentClient:()=>o});var i=s(29),r=s(64),n=s(62);class o extends n.UserAgentClient{constructor(e,t,s){super(r.NonInviteClientTransaction,e.userAgentCore,e.createOutgoingRequestMessage(i.C.INFO,s),t)}}},(e,t,s)=>{s.r(t),s.d(t,{ReInviteUserAgentClient:()=>o});var i=s(29),r=s(68),n=s(62);class o extends n.UserAgentClient{constructor(e,t,s){let n=e.createOutgoingRequestMessage(i.C.INVITE,s);super(r.InviteClientTransaction,e.userAgentCore,n,t),this.delegate=t,e.signalingStateTransition(n),e.reinviteUserAgentClient=this,this.dialog=e}receiveResponse(e){if(!this.authenticationGuard(e,this.dialog))return;let t=e.statusCode?e.statusCode.toString():"";if(!t)throw Error("Response status code undefined.");switch(!0){case/^100$/.test(t):this.delegate&&this.delegate.onTrying&&this.delegate.onTrying({message:e});break;case/^1[0-9]{2}$/.test(t):this.delegate&&this.delegate.onProgress&&this.delegate.onProgress({message:e,session:this.dialog,prack:e=>{throw Error("Unimplemented.")}});break;case/^2[0-9]{2}$/.test(t):this.dialog.signalingStateTransition(e),this.delegate&&this.delegate.onAccept&&this.delegate.onAccept({message:e,session:this.dialog,ack:e=>this.dialog.ack(e)});break;case/^3[0-9]{2}$/.test(t):this.dialog.signalingStateRollback(),this.dialog.reinviteUserAgentClient=void 0,this.delegate&&this.delegate.onRedirect&&this.delegate.onRedirect({message:e});break;case/^[4-6][0-9]{2}$/.test(t):this.dialog.signalingStateRollback(),this.dialog.reinviteUserAgentClient=void 0,this.delegate&&this.delegate.onReject&&this.delegate.onReject({message:e});break;default:throw Error(`Invalid status code ${t}`)}}}},(e,t,s)=>{s.r(t),s.d(t,{MessageUserAgentClient:()=>n});var i=s(64),r=s(62);class n extends r.UserAgentClient{constructor(e,t,s){super(i.NonInviteClientTransaction,e,t,s)}}},(e,t,s)=>{s.r(t),s.d(t,{NotifyUserAgentClient:()=>o});var i=s(29),r=s(64),n=s(62);class o extends n.UserAgentClient{constructor(e,t,s){super(r.NonInviteClientTransaction,e.userAgentCore,e.createOutgoingRequestMessage(i.C.NOTIFY,s),t)}}},(e,t,s)=>{s.r(t),s.d(t,{PrackUserAgentClient:()=>o});var i=s(29),r=s(64),n=s(62);class o extends n.UserAgentClient{constructor(e,t,s){let n=e.createOutgoingRequestMessage(i.C.PRACK,s);super(r.NonInviteClientTransaction,e.userAgentCore,n,t),e.signalingStateTransition(n)}}}
11,(e,t,s)=>{s.r(t),s.d(t,{ReferUserAgentClient:()=>o});var i=s(29),r=s(64),n=s(62);class o extends n.UserAgentClient{constructor(e,t,s){super(r.NonInviteClientTransaction,e.userAgentCore,e.createOutgoingRequestMessage(i.C.REFER,s),t)}}},(e,t,s)=>{s.r(t),s.d(t,{ByeUserAgentServer:()=>n});var i=s(82),r=s(81);class n extends r.UserAgentServer{constructor(e,t,s){super(i.NonInviteServerTransaction,e.userAgentCore,t,s)}}},(e,t,s)=>{s.r(t),s.d(t,{UserAgentServer:()=>h});var i=s(35),r=s(83),n=s(20),o=s(71),a=s(63),c=s(82);class h{constructor(e,t,s,i){this.transactionConstructor=e,this.core=t,this.message=s,this.delegate=i,this.logger=this.loggerFactory.getLogger("sip.user-agent-server"),this.toTag=s.toTag?s.toTag:(0,n.newTag)(),this.init()}dispose(){this.transaction.dispose()}get loggerFactory(){return this.core.loggerFactory}get transaction(){if(!this._transaction)throw Error("Transaction undefined.");return this._transaction}accept(e={statusCode:200}){if(!this.acceptable)throw new i.TransactionStateError(`${this.message.method} not acceptable in state ${this.transaction.state}.`);let t=e.statusCode;if(t<200||t>299)throw TypeError(`Invalid statusCode: ${t}`);return this.reply(e)}progress(e={statusCode:180}){if(!this.progressable)throw new i.TransactionStateError(`${this.message.method} not progressable in state ${this.transaction.state}.`);let t=e.statusCode;if(t<101||t>199)throw TypeError(`Invalid statusCode: ${t}`);return this.reply(e)}redirect(e,t={statusCode:302}){if(!this.redirectable)throw new i.TransactionStateError(`${this.message.method} not redirectable in state ${this.transaction.state}.`);let s=t.statusCode;if(s<300||s>399)throw TypeError(`Invalid statusCode: ${s}`);let r=[];return e.forEach(e=>r.push(`Contact: ${e.toString()}`)),t.extraHeaders=(t.extraHeaders||[]).concat(r),this.reply(t)}reject(e={statusCode:480}){if(!this.rejectable)throw new i.TransactionStateError(`${this.message.method} not rejectable in state ${this.transaction.state}.`);let t=e.statusCode;if(t<400||t>699)throw TypeError(`Invalid statusCode: ${t}`);return this.reply(e)}trying(e){if(!this.tryingable)throw new i.TransactionStateError(`${this.message.method} not tryingable in state ${this.transaction.state}.`);return this.reply({statusCode:100})}receiveCancel(e){this.delegate&&this.delegate.onCancel&&this.delegate.onCancel(e)}get acceptable(){if(this.transaction instanceof o.InviteServerTransaction)return this.transaction.state===a.TransactionState.Proceeding||this.transaction.state===a.TransactionState.Accepted;if(this.transaction instanceof c.NonInviteServerTransaction)return this.transaction.state===a.TransactionState.Trying||this.transaction.state===a.TransactionState.Proceeding;throw Error("Unknown transaction type.")}get progressable(){if(this.transaction instanceof o.InviteServerTransaction)return this.transaction.state===a.TransactionState.Proceeding;if(this.transaction instanceof c.NonInviteServerTransaction)return!1;throw Error("Unknown transaction type.")}get redirectable(){if(this.transaction instanceof o.InviteServerTransaction)return this.transaction.state===a.TransactionState.Proceeding;if(this.transaction instanceof c.NonInviteServerTransaction)return this.transaction.state===a.TransactionState.Trying||this.transaction.state===a.TransactionState.Proceeding;throw Error("Unknown transaction type.")}get rejectable(){if(this.transaction instanceof o.InviteServerTransaction)return this.transaction.state===a.TransactionState.Proceeding;if(this.transaction instanceof c.NonInviteServerTransaction)return this.transaction.state===a.TransactionState.Trying||this.transaction.state===a.TransactionState.Proceeding;throw Error("Unknown transaction type.")}get tryingable(){if(this.transaction instanceof o.InviteServerTransaction)return this.transaction.state===a.TransactionState.Proceeding;if(this.transaction instanceof c.NonInviteServerTransaction)return this.transaction.state===a.TransactionState.Trying;throw Error("Unknown transaction type.")}reply(e){e.toTag||100===e.statusCode||(e.toTag=this.toTag),e.userAgent=e.userAgent||this.core.configuration.userAgentHeaderFieldValue,e.supported=e.supported||this.core.configuration.supportedOptionTagsResponse;let t=(0,r.constructOutgoingResponse)(this.message,e);return this.transaction.receiveResponse(e.statusCode,t.message),t}init(){let e={loggerFactory:this.loggerFactory,onStateChange:e=>{e===a.TransactionState.Terminated&&(this.core.userAgentServers.delete(s),this.dispose())},onTransportError:e=>{this.logger.error(e.message),this.delegate&&this.delegate.onTransportError?this.delegate.onTransportError(e):this.logger.error("User agent server response transport error.")}},t=new this.transactionConstructor(this.message,this.core.transport,e);this._transaction=t;let s=t.id;this.core.userAgentServers.set(t.id,this)}}}
11,(e,t,s)=>{s.r(t),s.d(t,{NonInviteServerTransaction:()=>o});var i=s(36),r=s(72),n=s(63);class o extends r.ServerTransaction{constructor(e,t,s){super(e,t,s,n.TransactionState.Trying,"sip.transaction.nist")}dispose(){this.J&&(clearTimeout(this.J),this.J=void 0),super.dispose()}get kind(){return"nist"}receiveRequest(e){switch(this.state){case n.TransactionState.Trying:break;case n.TransactionState.Proceeding:if(!this.lastResponse)throw Error("Last response undefined.");this.send(this.lastResponse).catch(e=>{this.logTransportError(e,"Failed to send retransmission of provisional response.")});break;case n.TransactionState.Completed:if(!this.lastResponse)throw Error("Last response undefined.");this.send(this.lastResponse).catch(e=>{this.logTransportError(e,"Failed to send retransmission of final response.")});break;case n.TransactionState.Terminated:break;default:throw Error(`Invalid state ${this.state}`)}}receiveResponse(e,t){if(e<100||e>699)throw Error(`Invalid status code ${e}`);if(e>100&&e<=199)throw Error("Provisional response other than 100 not allowed.");switch(this.state){case n.TransactionState.Trying:if(this.lastResponse=t,e>=100&&e<200){this.stateTransition(n.TransactionState.Proceeding),this.send(t).catch(e=>{this.logTransportError(e,"Failed to send provisional response.")});return}if(e>=200&&e<=699){this.stateTransition(n.TransactionState.Completed),this.send(t).catch(e=>{this.logTransportError(e,"Failed to send final response.")});return}break;case n.TransactionState.Proceeding:if(this.lastResponse=t,e>=200&&e<=699){this.stateTransition(n.TransactionState.Completed),this.send(t).catch(e=>{this.logTransportError(e,"Failed to send final response.")});return}break;case n.TransactionState.Completed:return;case n.TransactionState.Terminated:break;default:throw Error(`Invalid state ${this.state}`)}let s=`Non-INVITE server transaction received unexpected ${e} response from TU while in state ${this.state}.`;throw this.logger.error(s),Error(s)}onTransportError(e){this.user.onTransportError&&this.user.onTransportError(e),this.stateTransition(n.TransactionState.Terminated,!0)}typeToString(){return"non-INVITE server transaction"}stateTransition(e,t=!1){let s=()=>{throw Error(`Invalid state transition from ${this.state} to ${e}`)};switch(e){case n.TransactionState.Trying:s();break;case n.TransactionState.Proceeding:this.state!==n.TransactionState.Trying&&s();break;case n.TransactionState.Completed:this.state!==n.TransactionState.Trying&&this.state!==n.TransactionState.Proceeding&&s();break;case n.TransactionState.Terminated:this.state===n.TransactionState.Proceeding||this.state===n.TransactionState.Completed||t||s();break;default:s()}e===n.TransactionState.Completed&&(this.J=setTimeout(()=>this.timerJ(),i.Timers.TIMER_J)),e===n.TransactionState.Terminated&&this.dispose(),this.setState(e)}timerJ(){this.logger.debug(`Timer J expired for NON-INVITE server transaction ${this.id}.`),this.state===n.TransactionState.Completed&&this.stateTransition(n.TransactionState.Terminated)}}}
11,(e,t,s)=>{s.r(t),s.d(t,{constructOutgoingResponse:()=>r});var i=s(20);function r(e,t){if(t.statusCode<100||t.statusCode>699)throw TypeError("Invalid statusCode: "+t.statusCode);let s=t.reasonPhrase?t.reasonPhrase:(0,i.getReasonPhrase)(t.statusCode),r="SIP/2.0 "+t.statusCode+" "+s+"\r\n";t.statusCode>=100&&t.statusCode,t.statusCode;let n="From: "+e.getHeader("From")+"\r\n",o="Call-ID: "+e.callId+"\r\n",a="CSeq: "+e.cseq+" "+e.method+"\r\n",c=e.getHeaders("via").reduce((e,t)=>e+"Via: "+t+"\r\n",""),h="To: "+e.getHeader("to");if(t.statusCode>100&&!e.parseHeader("to").hasParam("tag")){let e=t.toTag;e||(e=(0,i.newTag)()),h+=";tag="+e}h+="\r\n";let d="";t.supported&&(d="Supported: "+t.supported.join(", ")+"\r\n");let l="";t.userAgent&&(l="User-Agent: "+t.userAgent+"\r\n");let g="";return t.extraHeaders&&(g=t.extraHeaders.reduce((e,t)=>e+t.trim()+"\r\n","")),r+=c+n+h+a+o+d+l+g,t.body?r+="Content-Type: "+t.body.contentType+"\r\nContent-Length: "+(0,i.utf8Length)(t.body.content)+"\r\n\r\n"+t.body.content:r+="Content-Length: 0\r\n\r\n",{message:r}}},(e,t,s)=>{s.r(t),s.d(t,{InfoUserAgentServer:()=>n});var i=s(82),r=s(81);class n extends r.UserAgentServer{constructor(e,t,s){super(i.NonInviteServerTransaction,e.userAgentCore,t,s)}}},(e,t,s)=>{s.r(t),s.d(t,{ReInviteUserAgentServer:()=>n});var i=s(71),r=s(81);class n extends r.UserAgentServer{constructor(e,t,s){super(i.InviteServerTransaction,e.userAgentCore,t,s),e.reinviteUserAgentServer=this,this.dialog=e}accept(e={statusCode:200}){e.extraHeaders=e.extraHeaders||[],e.extraHeaders=e.extraHeaders.concat(this.dialog.routeSet.map(e=>`Record-Route: ${e}`));let t=super.accept(e),s=this.dialog,i=Object.assign(Object.assign({},t),{session:s});return e.body&&this.dialog.signalingStateTransition(e.body),this.dialog.reConfirm(),i}progress(e={statusCode:180}){let t=super.progress(e),s=this.dialog,i=Object.assign(Object.assign({},t),{session:s});return e.body&&this.dialog.signalingStateTransition(e.body),i}redirect(e,t={statusCode:302}){throw this.dialog.signalingStateRollback(),this.dialog.reinviteUserAgentServer=void 0,Error("Unimplemented.")}reject(e={statusCode:488}){return this.dialog.signalingStateRollback(),this.dialog.reinviteUserAgentServer=void 0,super.reject(e)}}},(e,t,s)=>{s.r(t),s.d(t,{MessageUserAgentServer:()=>n});var i=s(82),r=s(81);class n extends r.UserAgentServer{constructor(e,t,s){super(i.NonInviteServerTransaction,e,t,s)}}},(e,t,s)=>{s.r(t),s.d(t,{NotifyUserAgentServer:()=>n});var i=s(82),r=s(81);class n extends r.UserAgentServer{constructor(e,t,s){super(i.NonInviteServerTransaction,void 0!==e.userAgentCore?e.userAgentCore:e,t,s)}}},(e,t,s)=>{s.r(t),s.d(t,{PrackUserAgentServer:()=>n});var i=s(82),r=s(81);class n extends r.UserAgentServer{constructor(e,t,s){super(i.NonInviteServerTransaction,e.userAgentCore,t,s),e.signalingStateTransition(t),this.dialog=e}accept(e={statusCode:200}){return e.body&&this.dialog.signalingStateTransition(e.body),super.accept(e)}}},(e,t,s)=>{s.r(t),s.d(t,{ReferUserAgentServer:()=>n});var i=s(82),r=s(81);class n extends r.UserAgentServer{constructor(e,t,s){super(i.NonInviteServerTransaction,void 0!==e.userAgentCore?e.userAgentCore:e,t,s)}}},(e,t,s)=>{s.r(t),s.d(t,{PublishUserAgentClient:()=>n});var i=s(64),r=s(62);class n extends r.UserAgentClient{constructor(e,t,s){super(i.NonInviteClientTransaction,e,t,s)}}},(e,t,s)=>{s.r(t),s.d(t,{RegisterUserAgentClient:()=>n});var i=s(64),r=s(62);class n extends r.UserAgentClient{constructor(e,t,s){super(i.NonInviteClientTransaction,e,t,s)}}},(e,t,s)=>{s.r(t),s.d(t,{SubscribeUserAgentClient:()=>c});var i=s(93),r=s(46),n=s(36),o=s(64),a=s(62);class c extends a.UserAgentClient{constructor(e,t,s){let i=t.getHeader("Event");if(!i)throw Error("Event undefined");let n=t.getHeader("Expires");if(!n)throw Error("Expires undefined");super(o.NonInviteClientTransaction,e,t,s),this.delegate=s,this.subscriberId=t.callId+t.fromTag+i,this.subscriptionExpiresRequested=this.subscriptionExpires=Number(n),this.subscriptionEvent=i,this.subscriptionState=r.SubscriptionState.NotifyWait,this.waitNotifyStart()}dispose(){super.dispose()}onNotify(e){let t=e.message.parseHeader("Event").event;if(!t||t!==this.subscriptionEvent){this.logger.warn("Failed to parse event."),e.reject({statusCode:489});return}let s=e.message.parseHeader("Subscription-State");if(!s||!s.state){this.logger.warn("Failed to parse subscription state."),e.reject({statusCode:489});return}let n=s.state;
11switch(n){case"pending":case"active":case"terminated":break;default:this.logger.warn(`Invalid subscription state ${n}`),e.reject({statusCode:489});return}if("terminated"!==n&&!e.message.parseHeader("contact")){this.logger.warn("Failed to parse contact."),e.reject({statusCode:489});return}if(this.dialog)throw Error("Dialog already created. This implementation only supports install of single subscriptions.");switch(this.waitNotifyStop(),this.subscriptionExpires=s.expires?Math.min(this.subscriptionExpires,Math.max(s.expires,0)):this.subscriptionExpires,n){case"pending":this.subscriptionState=r.SubscriptionState.Pending;break;case"active":this.subscriptionState=r.SubscriptionState.Active;break;case"terminated":this.subscriptionState=r.SubscriptionState.Terminated;break;default:throw Error(`Unrecognized state ${n}.`)}if(this.subscriptionState!==r.SubscriptionState.Terminated){let t=i.SubscriptionDialog.initialDialogStateForSubscription(this.message,e.message);this.dialog=new i.SubscriptionDialog(this.subscriptionEvent,this.subscriptionExpires,this.subscriptionState,this.core,t)}if(this.delegate&&this.delegate.onNotify){let t=this.dialog;this.delegate.onNotify({request:e,subscription:t})}else e.accept()}waitNotifyStart(){this.N||(this.core.subscribers.set(this.subscriberId,this),this.N=setTimeout(()=>this.timerN(),n.Timers.TIMER_N))}waitNotifyStop(){this.N&&(this.core.subscribers.delete(this.subscriberId),clearTimeout(this.N),this.N=void 0)}receiveResponse(e){if(this.authenticationGuard(e)){if(e.statusCode&&e.statusCode>=200&&e.statusCode<300){let t=e.getHeader("Expires");if(t){let e=Number(t);e>this.subscriptionExpiresRequested&&this.logger.warn("Expires header in a 200-class response to SUBSCRIBE with a higher value than the one in the request"),e<this.subscriptionExpires&&(this.subscriptionExpires=e)}else this.logger.warn("Expires header missing in a 200-class response to SUBSCRIBE");this.dialog&&this.dialog.subscriptionExpires>this.subscriptionExpires&&(this.dialog.subscriptionExpires=this.subscriptionExpires)}e.statusCode&&e.statusCode>=300&&e.statusCode<700&&this.waitNotifyStop(),super.receiveResponse(e)}}timerN(){this.logger.warn("Timer N expired for SUBSCRIBE user agent client. Timed out waiting for NOTIFY."),this.waitNotifyStop(),this.delegate&&this.delegate.onNotifyTimeout&&this.delegate.onNotifyTimeout()}}},(e,t,s)=>{s.r(t),s.d(t,{SubscriptionDialog:()=>l});var i=s(25),r=s(29),n=s(46),o=s(36),a=s(28),c=s(87),h=s(94),d=s(69);class l extends d.Dialog{constructor(e,t,s,i,r,n){super(i,r),this.delegate=n,this._autoRefresh=!1,this._subscriptionEvent=e,this._subscriptionExpires=t,this._subscriptionExpiresInitial=t,this._subscriptionExpiresLastSet=Math.floor(Date.now()/1e3),this._subscriptionRefresh=void 0,this._subscriptionRefreshLastSet=void 0,this._subscriptionState=s,this.logger=i.loggerFactory.getLogger("sip.subscribe-dialog"),this.logger.log(`SUBSCRIBE dialog ${this.id} constructed`)}static initialDialogStateForSubscription(e,t){let s=t.getHeaders("record-route"),r=t.parseHeader("contact");if(!r)throw Error("Contact undefined.");if(!(r instanceof i.NameAddrHeader))throw Error("Contact not instance of NameAddrHeader.");let n=r.uri,o=e.cseq,a=e.callId,c=e.fromTag,h=t.fromTag;if(!a)throw Error("Call id undefined.");if(!c)throw Error("From tag undefined.");if(!h)throw Error("To tag undefined.");if(!e.from)throw Error("From undefined.");if(!e.to)throw Error("To undefined.");return{id:a+c+h,early:!1,callId:a,localTag:c,remoteTag:h,localSequenceNumber:o,remoteSequenceNumber:void 0,localURI:e.from.uri,remoteURI:e.to.uri,remoteTarget:n,routeSet:s,secure:!1}}dispose(){super.dispose(),this.N&&(clearTimeout(this.N),this.N=void 0),this.refreshTimerClear(),this.logger.log(`SUBSCRIBE dialog ${this.id} destroyed`)}get autoRefresh(){return this._autoRefresh}set autoRefresh(e){this._autoRefresh=!0,this.refreshTimerSet()}get subscriptionEvent(){return this._subscriptionEvent}get subscriptionExpires(){let e=Math.floor(Date.now()/1e3)-this._subscriptionExpiresLastSet;return Math.max(this._subscriptionExpires-e,0)}set subscriptionExpires(e){if(e<0)throw Error("Expires must be greater than or equal to zero.");if(this._subscriptionExpires=e,this._subscriptionExpiresLastSet=Math.floor(Date.now()/1e3),this.autoRefresh){let t=this.subscriptionRefresh;(void 0===t||t>=e)&&this.refreshTimerSet()}}get subscriptionExpiresInitial(){return this._subscriptionExpiresInitial}get subscriptionRefresh(){if(void 0===this._subscriptionRefresh||void 0===this._subscriptionRefreshLastSet)return;let e=Math.floor(Date.now()/1e3)-this._subscriptionRefreshLastSet;return Math.max(this._subscriptionRefresh-e,0)}get subscriptionState(){return this._subscriptionState}receiveRequest(e){if(this.logger.log(`SUBSCRIBE dialog ${this.id} received ${e.method} request`),!this.sequenceGuard(e)){this.logger.log(`SUBSCRIBE dialog ${this.id} rejected out of order ${e.method} request.`);return}(super.receiveRequest(e),e.method===r.C.NOTIFY)?this.onNotify(e):(this.logger.log(`SUBSCRIBE dialog ${this.id} received unimplemented ${e.method} request`),this.core.replyStateless(e,{statusCode:501}))}refresh(){let e="Allow: "+a.AllowedMethods.toString(),t={};return t.extraHeaders=(t.extraHeaders||[]).slice(),t.extraHeaders.push(e),t.extraHeaders.push("Event: "+this.subscriptionEvent),t.extraHeaders.push("Expires: "+this.subscriptionExpiresInitial),t.extraHeaders.push("Contact: "+this.core.configuration.contact.toString()),this.subscribe(void 0,t)}subscribe(e,t={}){if(this.subscriptionState!==n.SubscriptionState.Pending&&this.subscriptionState!==n.SubscriptionState.Active)throw Error(`Invalid state ${this.subscriptionState}. May only re-subscribe while in state "pending" or "active".`);this.logger.log(`SUBSCRIBE dialog ${this.id} sending SUBSCRIBE request`);let s=new h.ReSubscribeUserAgentClient(this,e,t);return this.N&&(clearTimeout(this.N),this.N=void 0),this.N=setTimeout(()=>this.timerN(),o.Timers.TIMER_N),s}terminate(){this.stateTransition(n.SubscriptionState.Terminated),this.onTerminated()}unsubscribe(){let e="Allow: "+a.AllowedMethods.toString(),t={};return t.extraHeaders=(t.extraHeaders||[]).slice(),t.extraHeaders.push(e),t.extraHeaders.push("Event: "+this.subscriptionEvent),t.extraHeaders.push("Expires: 0"),t.extraHeaders.push("Contact: "+this.core.configuration.contact.toString()),this.subscribe(void 0,t)}onNotify(e){let t=e.parseHeader("Event").event;if(!t||t!==this.subscriptionEvent){this.core.replyStateless(e,{statusCode:489});return}this.N&&(clearTimeout(this.N),this.N=void 0);let s=e.parseHeader("Subscription-State");if(!s||!s.state){this.core.replyStateless(e,{statusCode:489});return}let i=s.state,r=s.expires?Math.max(s.expires,0):void 0;
11switch(i){case"pending":this.stateTransition(n.SubscriptionState.Pending,r);break;case"active":this.stateTransition(n.SubscriptionState.Active,r);break;case"terminated":this.stateTransition(n.SubscriptionState.Terminated,r);break;default:this.logger.warn("Unrecognized subscription state.")}let o=new c.NotifyUserAgentServer(this,e);this.delegate&&this.delegate.onNotify?this.delegate.onNotify(o):o.accept()}onRefresh(e){this.delegate&&this.delegate.onRefresh&&this.delegate.onRefresh(e)}onTerminated(){this.delegate&&this.delegate.onTerminated&&this.delegate.onTerminated()}refreshTimerClear(){this.refreshTimer&&(clearTimeout(this.refreshTimer),this.refreshTimer=void 0)}refreshTimerSet(){if(this.refreshTimerClear(),this.autoRefresh&&this.subscriptionExpires>0){let e=900*this.subscriptionExpires;this._subscriptionRefresh=Math.floor(e/1e3),this._subscriptionRefreshLastSet=Math.floor(Date.now()/1e3),this.refreshTimer=setTimeout(()=>{this.refreshTimer=void 0,this._subscriptionRefresh=void 0,this._subscriptionRefreshLastSet=void 0,this.onRefresh(this.refresh())},e)}}stateTransition(e,t){let s=()=>{this.logger.warn(`Invalid subscription state transition from ${this.subscriptionState} to ${e}`)};switch(e){case n.SubscriptionState.Initial:case n.SubscriptionState.NotifyWait:s();return;case n.SubscriptionState.Pending:if(this.subscriptionState!==n.SubscriptionState.NotifyWait&&this.subscriptionState!==n.SubscriptionState.Pending){s();return}break;case n.SubscriptionState.Active:case n.SubscriptionState.Terminated:if(this.subscriptionState!==n.SubscriptionState.NotifyWait&&this.subscriptionState!==n.SubscriptionState.Pending&&this.subscriptionState!==n.SubscriptionState.Active){s();return}break;default:s();return}e===n.SubscriptionState.Pending&&t&&(this.subscriptionExpires=t),e===n.SubscriptionState.Active&&t&&(this.subscriptionExpires=t),e===n.SubscriptionState.Terminated&&this.dispose(),this._subscriptionState=e}timerN(){this.logger.warn("Timer N expired for SUBSCRIBE dialog. Timed out waiting for NOTIFY."),this.subscriptionState!==n.SubscriptionState.Terminated&&(this.stateTransition(n.SubscriptionState.Terminated),this.onTerminated())}}},(e,t,s)=>{s.r(t),s.d(t,{ReSubscribeUserAgentClient:()=>o});var i=s(29),r=s(64),n=s(62);class o extends n.UserAgentClient{constructor(e,t,s){super(r.NonInviteClientTransaction,e.userAgentCore,e.createOutgoingRequestMessage(i.C.SUBSCRIBE,s),t),this.dialog=e}waitNotifyStop(){}receiveResponse(e){if(e.statusCode&&e.statusCode>=200&&e.statusCode<300){let t=e.getHeader("Expires");if(t){let e=Number(t);this.dialog.subscriptionExpires>e&&(this.dialog.subscriptionExpires=e)}else this.logger.warn("Expires header missing in a 200-class response to SUBSCRIBE")}e.statusCode&&e.statusCode>=400&&e.statusCode<700&&[404,405,410,416,480,481,482,483,484,485,489,501,604].includes(e.statusCode)&&this.dialog.terminate(),super.receiveResponse(e)}}},(e,t,s)=>{s.r(t),s.d(t,{InviteUserAgentServer:()=>d});var i=s(69),r=s(70),n=s(35),o=s(30),a=s(71),c=s(28),h=s(81);class d extends h.UserAgentServer{constructor(e,t,s){super(a.InviteServerTransaction,e,t,s),this.core=e}dispose(){this.earlyDialog&&this.earlyDialog.dispose(),super.dispose()}accept(e={statusCode:200}){if(!this.acceptable)throw new n.TransactionStateError(`${this.message.method} not acceptable in state ${this.transaction.state}.`);if(!this.confirmedDialog){if(this.earlyDialog)this.earlyDialog.confirm(),this.confirmedDialog=this.earlyDialog,this.earlyDialog=void 0;else{let e=this.transaction;if(!(e instanceof a.InviteServerTransaction))throw Error("Transaction not instance of InviteClientTransaction.");let t=i.Dialog.initialDialogStateForUserAgentServer(this.message,this.toTag);this.confirmedDialog=new r.SessionDialog(e,this.core,t)}}let t=this.message.getHeaders("record-route").map(e=>`Record-Route: ${e}`),s=`Contact: ${this.core.configuration.contact.toString()}`,h="Allow: "+c.AllowedMethods.toString();if(!e.body){if(this.confirmedDialog.signalingState===o.SignalingState.Stable)e.body=this.confirmedDialog.answer;else if(this.confirmedDialog.signalingState===o.SignalingState.Initial||this.confirmedDialog.signalingState===o.SignalingState.HaveRemoteOffer)throw Error("Response must have a body.")}e.statusCode=e.statusCode||200,e.extraHeaders=e.extraHeaders||[],e.extraHeaders=e.extraHeaders.concat(t),e.extraHeaders.push(h),e.extraHeaders.push(s);let d=super.accept(e),l=this.confirmedDialog,g=Object.assign(Object.assign({},d),{session:l});return e.body&&this.confirmedDialog.signalingState!==o.SignalingState.Stable&&this.confirmedDialog.signalingStateTransition(e.body),g}
11progress(e={statusCode:180}){if(!this.progressable)throw new n.TransactionStateError(`${this.message.method} not progressable in state ${this.transaction.state}.`);if(!this.earlyDialog){let e=this.transaction;if(!(e instanceof a.InviteServerTransaction))throw Error("Transaction not instance of InviteClientTransaction.");let t=i.Dialog.initialDialogStateForUserAgentServer(this.message,this.toTag,!0);this.earlyDialog=new r.SessionDialog(e,this.core,t)}let t=this.message.getHeaders("record-route").map(e=>`Record-Route: ${e}`),s=`Contact: ${this.core.configuration.contact}`;e.extraHeaders=e.extraHeaders||[],e.extraHeaders=e.extraHeaders.concat(t),e.extraHeaders.push(s);let c=super.progress(e),h=this.earlyDialog,d=Object.assign(Object.assign({},c),{session:h});return e.body&&this.earlyDialog.signalingState!==o.SignalingState.Stable&&this.earlyDialog.signalingStateTransition(e.body),d}redirect(e,t={statusCode:302}){return super.redirect(e,t)}reject(e={statusCode:486}){return super.reject(e)}}},(e,t,s)=>{s.r(t),s.d(t,{RegisterUserAgentServer:()=>n});var i=s(82),r=s(81);class n extends r.UserAgentServer{constructor(e,t,s){super(i.NonInviteServerTransaction,e,t,s),this.core=e}}},(e,t,s)=>{s.r(t),s.d(t,{SubscribeUserAgentServer:()=>n});var i=s(82),r=s(81);class n extends r.UserAgentServer{constructor(e,t,s){super(i.NonInviteServerTransaction,e,t,s),this.core=e}}},(e,t,s)=>{s.r(t),s.d(t,{Parser:()=>i});var i,r=s(21),n=s(18),o=s(26);!function(e){function t(e,t){let s=t,i=0,r=0;if(e.substring(s,s+2).match(/(^\r\n)/))return -2;for(;0===i;){if(-1===(r=e.indexOf("\r\n",s)))return r;!e.substring(r+2,r+4).match(/(^\r\n)/)&&e.charAt(r+2).match(/(^\s+)/)?s=r+2:i=r}return i}function s(e,t,s,i){let n;let a=t.indexOf(":",s),c=t.substring(s,a).trim(),h=t.substring(a+1,i).trim();switch(c.toLowerCase()){case"via":case"v":e.addHeader("via",h),1===e.getHeaders("via").length?(n=e.parseHeader("Via"))&&(e.via=n,e.viaBranch=n.branch):n=0;break;case"from":case"f":e.setHeader("from",h),(n=e.parseHeader("from"))&&(e.from=n,e.fromTag=n.getParam("tag"));break;case"to":case"t":e.setHeader("to",h),(n=e.parseHeader("to"))&&(e.to=n,e.toTag=n.getParam("tag"));break;case"record-route":if(-1===(n=r.Grammar.parse(h,"Record_Route"))||!(n instanceof Array)){n=void 0;break}n.forEach(t=>{e.addHeader("record-route",h.substring(t.position,t.offset)),e.headers["Record-Route"][e.getHeaders("record-route").length-1].parsed=t.parsed});break;case"call-id":case"i":e.setHeader("call-id",h),(n=e.parseHeader("call-id"))&&(e.callId=h);break;case"contact":case"m":if(-1===(n=r.Grammar.parse(h,"Contact"))||!(n instanceof Array)){n=void 0;break}n.forEach(t=>{e.addHeader("contact",h.substring(t.position,t.offset)),e.headers.Contact[e.getHeaders("contact").length-1].parsed=t.parsed});break;case"content-length":case"l":e.setHeader("content-length",h),n=e.parseHeader("content-length");break;case"content-type":case"c":e.setHeader("content-type",h),n=e.parseHeader("content-type");break;case"cseq":e.setHeader("cseq",h),(n=e.parseHeader("cseq"))&&(e.cseq=n.value),e instanceof o.IncomingResponseMessage&&(e.method=n.method);break;case"max-forwards":e.setHeader("max-forwards",h),n=e.parseHeader("max-forwards");break;case"www-authenticate":e.setHeader("www-authenticate",h),n=e.parseHeader("www-authenticate");break;case"proxy-authenticate":e.setHeader("proxy-authenticate",h),n=e.parseHeader("proxy-authenticate");break;case"refer-to":case"r":e.setHeader("refer-to",h),(n=e.parseHeader("refer-to"))&&(e.referTo=n);break;default:e.addHeader(c.toLowerCase(),h),n=0}return void 0!==n||{error:"error parsing header '"+c+"'"}}e.getHeader=t,e.parseHeader=s,e.parseMessage=function(e,i){let a,c,h=0,d=e.indexOf("\r\n");if(-1===d){i.warn("no CRLF found, not a SIP message, discarded");return}let l=e.substring(0,d),g=r.Grammar.parse(l,"Request_Response");if(-1===g){i.warn('error parsing first line of SIP message: "'+l+'"');return}for(g.status_code?((a=new o.IncomingResponseMessage).statusCode=g.status_code,a.reasonPhrase=g.reason_phrase):((a=new n.IncomingRequestMessage).method=g.method,a.ruri=g.uri),a.data=e,h=d+2;;){if(-2===(d=t(e,h))){c=h+2;break}if(-1===d){i.error("malformed message");return}let r=s(a,e,h,d);if(r&&!0!==r){i.error(r.error);return}h=d+2}
11return a.hasHeader("content-length")?a.body=e.substr(c,Number(a.getHeader("content-length"))):a.body=e.substring(c),a}}(i||(i={}))},(e,t,s)=>{s.r(t),s.d(t,{Grammar:()=>i.Grammar,NameAddrHeader:()=>r.NameAddrHeader,Parameters:()=>n.Parameters,URI:()=>o.URI,equivalentURI:()=>o.equivalentURI});var i=s(21),r=s(25),n=s(24),o=s(23)},(e,t,s)=>{s.r(t),s.d(t,{Dialog:()=>i.Dialog,SessionDialog:()=>i.SessionDialog,SubscriptionDialog:()=>i.SubscriptionDialog,Exception:()=>r.Exception,TransactionStateError:()=>r.TransactionStateError,TransportError:()=>r.TransportError,Levels:()=>n.Levels,Logger:()=>n.Logger,LoggerFactory:()=>n.LoggerFactory,C:()=>o.C,DigestAuthentication:()=>o.DigestAuthentication,Grammar:()=>o.Grammar,IncomingMessage:()=>o.IncomingMessage,IncomingRequestMessage:()=>o.IncomingRequestMessage,IncomingResponseMessage:()=>o.IncomingResponseMessage,NameAddrHeader:()=>o.NameAddrHeader,OutgoingRequestMessage:()=>o.OutgoingRequestMessage,Parameters:()=>o.Parameters,Parser:()=>o.Parser,URI:()=>o.URI,constructOutgoingResponse:()=>o.constructOutgoingResponse,equivalentURI:()=>o.equivalentURI,fromBodyLegacy:()=>o.fromBodyLegacy,getBody:()=>o.getBody,isBody:()=>o.isBody,SessionState:()=>a.SessionState,SignalingState:()=>a.SignalingState,SubscriptionState:()=>c.SubscriptionState,ClientTransaction:()=>h.ClientTransaction,InviteClientTransaction:()=>h.InviteClientTransaction,InviteServerTransaction:()=>h.InviteServerTransaction,NonInviteClientTransaction:()=>h.NonInviteClientTransaction,NonInviteServerTransaction:()=>h.NonInviteServerTransaction,ServerTransaction:()=>h.ServerTransaction,Transaction:()=>h.Transaction,TransactionState:()=>h.TransactionState,UserAgentCore:()=>d.UserAgentCore,ByeUserAgentClient:()=>l.ByeUserAgentClient,ByeUserAgentServer:()=>l.ByeUserAgentServer,CancelUserAgentClient:()=>l.CancelUserAgentClient,InfoUserAgentClient:()=>l.InfoUserAgentClient,InfoUserAgentServer:()=>l.InfoUserAgentServer,InviteUserAgentClient:()=>l.InviteUserAgentClient,InviteUserAgentServer:()=>l.InviteUserAgentServer,MessageUserAgentClient:()=>l.MessageUserAgentClient,MessageUserAgentServer:()=>l.MessageUserAgentServer,NotifyUserAgentClient:()=>l.NotifyUserAgentClient,NotifyUserAgentServer:()=>l.NotifyUserAgentServer,PrackUserAgentClient:()=>l.PrackUserAgentClient,PrackUserAgentServer:()=>l.PrackUserAgentServer,PublishUserAgentClient:()=>l.PublishUserAgentClient,ReInviteUserAgentClient:()=>l.ReInviteUserAgentClient,ReInviteUserAgentServer:()=>l.ReInviteUserAgentServer,ReSubscribeUserAgentClient:()=>l.ReSubscribeUserAgentClient,ReSubscribeUserAgentServer:()=>l.ReSubscribeUserAgentServer,ReferUserAgentClient:()=>l.ReferUserAgentClient,ReferUserAgentServer:()=>l.ReferUserAgentServer,RegisterUserAgentClient:()=>l.RegisterUserAgentClient,RegisterUserAgentServer:()=>l.RegisterUserAgentServer,SubscribeUserAgentClient:()=>l.SubscribeUserAgentClient,SubscribeUserAgentServer:()=>l.SubscribeUserAgentServer,UserAgentClient:()=>l.UserAgentClient,UserAgentServer:()=>l.UserAgentServer,Timers:()=>g.Timers});var i=s(101),r=s(102),n=s(103),o=s(104),a=s(106),c=s(107),h=s(108),d=s(109),l=s(110),g=s(36)},(e,t,s)=>{s.r(t),s.d(t,{Dialog:()=>i.Dialog,SessionDialog:()=>r.SessionDialog,SubscriptionDialog:()=>n.SubscriptionDialog});var i=s(69),r=s(70),n=s(93)},(e,t,s)=>{s.r(t),s.d(t,{Exception:()=>i.Exception,TransactionStateError:()=>r.TransactionStateError,TransportError:()=>n.TransportError});var i=s(5),r=s(35),n=s(67)},(e,t,s)=>{s.r(t),s.d(t,{Levels:()=>i.Levels,LoggerFactory:()=>r.LoggerFactory,Logger:()=>n.Logger});var i=s(51),r=s(50),n=s(52)},(e,t,s)=>{s.r(t),s.d(t,{Grammar:()=>i.Grammar,NameAddrHeader:()=>i.NameAddrHeader,Parameters:()=>i.Parameters,URI:()=>i.URI,equivalentURI:()=>i.equivalentURI,C:()=>r.C,fromBodyLegacy:()=>n.fromBodyLegacy,getBody:()=>n.getBody,isBody:()=>n.isBody,DigestAuthentication:()=>o.DigestAuthentication,IncomingMessage:()=>a.IncomingMessage,IncomingRequestMessage:()=>c.IncomingRequestMessage,IncomingResponseMessage:()=>h.IncomingResponseMessage,OutgoingRequestMessage:()=>d.OutgoingRequestMessage,constructOutgoingResponse:()=>l.constructOutgoingResponse,Parser:()=>g.Parser});var i=s(99),r=s(105),n=s(17),o=s(58),a=s(19),c=s(18),h=s(26),d=s(27),l=s(83),g=s(98)}
11,(e,t,s)=>{s.r(t),s.d(t,{C:()=>i.C});var i=s(29)},(e,t,s)=>{s.r(t),s.d(t,{SessionState:()=>i.SessionState,SignalingState:()=>i.SignalingState});var i=s(30)},(e,t,s)=>{s.r(t),s.d(t,{SubscriptionState:()=>i.SubscriptionState});var i=s(46)},(e,t,s)=>{s.r(t),s.d(t,{ClientTransaction:()=>i.ClientTransaction,InviteClientTransaction:()=>r.InviteClientTransaction,InviteServerTransaction:()=>n.InviteServerTransaction,NonInviteClientTransaction:()=>o.NonInviteClientTransaction,NonInviteServerTransaction:()=>a.NonInviteServerTransaction,ServerTransaction:()=>c.ServerTransaction,TransactionState:()=>h.TransactionState,Transaction:()=>d.Transaction});var i=s(65),r=s(68),n=s(71),o=s(64),a=s(82),c=s(72),h=s(63),d=s(66)},(e,t,s)=>{s.r(t),s.d(t,{UserAgentCore:()=>i.UserAgentCore});var i=s(60)},(e,t,s)=>{s.r(t),s.d(t,{ByeUserAgentClient:()=>i.ByeUserAgentClient,ByeUserAgentServer:()=>r.ByeUserAgentServer,CancelUserAgentClient:()=>n.CancelUserAgentClient,InfoUserAgentClient:()=>o.InfoUserAgentClient,InfoUserAgentServer:()=>a.InfoUserAgentServer,InviteUserAgentClient:()=>c.InviteUserAgentClient,InviteUserAgentServer:()=>h.InviteUserAgentServer,MessageUserAgentClient:()=>d.MessageUserAgentClient,MessageUserAgentServer:()=>l.MessageUserAgentServer,NotifyUserAgentClient:()=>g.NotifyUserAgentClient,NotifyUserAgentServer:()=>u.NotifyUserAgentServer,PublishUserAgentClient:()=>p.PublishUserAgentClient,PrackUserAgentClient:()=>f.PrackUserAgentClient,PrackUserAgentServer:()=>m.PrackUserAgentServer,ReInviteUserAgentClient:()=>S.ReInviteUserAgentClient,ReInviteUserAgentServer:()=>v.ReInviteUserAgentServer,ReSubscribeUserAgentClient:()=>T.ReSubscribeUserAgentClient,ReSubscribeUserAgentServer:()=>b.ReSubscribeUserAgentServer,ReferUserAgentClient:()=>R.ReferUserAgentClient,ReferUserAgentServer:()=>E.ReferUserAgentServer,RegisterUserAgentClient:()=>y.RegisterUserAgentClient,RegisterUserAgentServer:()=>I.RegisterUserAgentServer,SubscribeUserAgentClient:()=>w.SubscribeUserAgentClient,SubscribeUserAgentServer:()=>C.SubscribeUserAgentServer,UserAgentClient:()=>$.UserAgentClient,UserAgentServer:()=>A.UserAgentServer});var i=s(73),r=s(80),n=s(111),o=s(74),a=s(84),c=s(61),h=s(95),d=s(76),l=s(86),g=s(77),u=s(87),p=s(90),f=s(78),m=s(88),S=s(75),v=s(85),T=s(94),b=s(112),R=s(79),E=s(89),y=s(91),I=s(96),w=s(92),C=s(97),$=s(62),A=s(81)},(e,t,s)=>{s.r(t),s.d(t,{CancelUserAgentClient:()=>n});var i=s(64),r=s(62);class n extends r.UserAgentClient{constructor(e,t,s){super(i.NonInviteClientTransaction,e,t,s)}}},(e,t,s)=>{s.r(t),s.d(t,{ReSubscribeUserAgentServer:()=>n});var i=s(82),r=s(81);class n extends r.UserAgentServer{constructor(e,t,s){super(i.NonInviteServerTransaction,e.userAgentCore,t,s)}}},(e,t,s)=>{s.r(t),s.d(t,{addMidLines:()=>i.addMidLines,cleanJitsiSdpImageattr:()=>i.cleanJitsiSdpImageattr,holdModifier:()=>i.holdModifier,stripG722:()=>i.stripG722,stripRtpPayload:()=>i.stripRtpPayload,stripTcpCandidates:()=>i.stripTcpCandidates,stripTelephoneEvent:()=>i.stripTelephoneEvent,stripVideo:()=>i.stripVideo,SessionDescriptionHandler:()=>r.SessionDescriptionHandler,defaultMediaStreamFactory:()=>r.defaultMediaStreamFactory,defaultPeerConnectionConfiguration:()=>r.defaultPeerConnectionConfiguration,defaultSessionDescriptionHandlerFactory:()=>r.defaultSessionDescriptionHandlerFactory,SimpleUser:()=>n.SimpleUser,Transport:()=>o.Transport});var i=s(114),r=s(116),n=s(117),o=s(119)},(e,t,s)=>{s.r(t),s.d(t,{addMidLines:()=>i.addMidLines,cleanJitsiSdpImageattr:()=>i.cleanJitsiSdpImageattr,holdModifier:()=>i.holdModifier,stripG722:()=>i.stripG722,stripRtpPayload:()=>i.stripRtpPayload,stripTcpCandidates:()=>i.stripTcpCandidates,stripTelephoneEvent:()=>i.stripTelephoneEvent,stripVideo:()=>i.stripVideo});var i=s(115)},(e,t,s)=>{s.r(t),s.d(t,{stripTcpCandidates:()=>n,stripTelephoneEvent:()=>o,cleanJitsiSdpImageattr:()=>a,stripG722:()=>c,stripRtpPayload:()=>h,stripVideo:()=>d,addMidLines:()=>l,holdModifier:()=>g});let i=(e,t)=>{let s;let i=[],r=e.split(/\r\n/);for(let e=0;e<r.length;){let n=r[e];if(/^m=(?:audio|video)/.test(n))s={index:e,stripped:[]},i.push(s);else if(s){let i=/^a=rtpmap:(\d+) ([^/]+)\//.exec(n);if(i&&t===i[2]){r.splice(e,1),s.stripped.push(i[1]);continue}}e++}for(let e of i){let t=r[e.index].split(" ");for(let s=3;s<t.length;){if(-1!==e.stripped.indexOf(t[s])){t.splice(s,1);continue}s++}r[e.index]=t.join(" ")}return r.join("\r\n")},r=(e,t)=>{let s=RegExp("m="+t+".*$","gm"),i=RegExp("^a=group:.*$","gm");if(s.test(e)){let s;let r=(e=e.split(/^m=/gm).filter(e=>{if(e.substr(0,t.length)===t){if(s=e.match(/^a=mid:.*$/gm)){let e=s[0].match(/:.+$/g);e&&(s=e[0].substr(1))}return!1}return!0}).join("m=")).match(i);if(r&&1===r.length){let t=r[0],n=RegExp(" *"+s+"[^ ]*","g");t=t.replace(n,""),e=e.split(i).join(t)}}return e};function n(e){return e.sdp=(e.sdp||"").replace(/^a=candidate:\d+ \d+ tcp .*?\r\n/img,""),Promise.resolve(e)}function o(e){return e.sdp=i(e.sdp||"","telephone-event"),Promise.resolve(e)}function a(e){return e.sdp=(e.sdp||"").replace(/^(a=imageattr:.*?)(x|y)=\[0-/gm,"$1$2=[1:"),Promise.resolve(e)}function c(e){return e.sdp=i(e.sdp||"","G722"),Promise.resolve(e)}function h(e){return t=>(t.sdp=i(t.sdp||"",e),Promise.resolve(t))}function d(e){return e.sdp=r(e.sdp||"","video"),Promise.resolve(e)}function l(e){let t=e.sdp||"";if(-1===t.search(/^a=mid.*$/gm)){let s=t.match(/^m=.*$/gm),i=t.split(/^m=.*$/gm);
11s&&s.forEach((e,t)=>{s[t]=e+"\na=mid:"+t}),i.forEach((e,t)=>{s&&s[t]&&(i[t]=e+s[t])}),t=i.join(""),e.sdp=t}return Promise.resolve(e)}function g(e){if(!e.sdp||!e.type)throw Error("Invalid SDP");let t=e.sdp,s=e.type;return t&&(t=/a=(sendrecv|sendonly|recvonly|inactive)/.test(t)?(t=t.replace(/a=sendrecv\r\n/g,"a=sendonly\r\n")).replace(/a=recvonly\r\n/g,"a=inactive\r\n"):t.replace(/(m=[^\r]*\r\n)/g,"$1a=sendonly\r\n")),Promise.resolve({sdp:t,type:s})}},(e,t,s)=>{s.r(t),s.d(t,{defaultMediaStreamFactory:()=>i.defaultMediaStreamFactory,defaultPeerConnectionConfiguration:()=>r.defaultPeerConnectionConfiguration,defaultSessionDescriptionHandlerFactory:()=>n.defaultSessionDescriptionHandlerFactory,SessionDescriptionHandler:()=>o.SessionDescriptionHandler});var i=s(54),r=s(55),n=s(53),o=s(56)},(e,t,s)=>{s.r(t),s.d(t,{SimpleUser:()=>i.SimpleUser});var i=s(118)},(e,t,s)=>{s.r(t),s.d(t,{SimpleUser:()=>p});var i=s(49),r=s(48),n=s(42),o=s(41),a=s(37),c=s(14),h=s(38),d=s(16),l=s(6),g=s(56),u=s(57);class p{constructor(e,t={}){this.attemptingReconnection=!1,this.connectRequested=!1,this.held=!1,this.muted=!1,this.registerer=void 0,this.registerRequested=!1,this.session=void 0,this.delegate=t.delegate,this.options=Object.assign({},t);let s=Object.assign({},t.userAgentOptions);if(s.transportConstructor||(s.transportConstructor=u.Transport),s.transportOptions||(s.transportOptions={server:e}),!s.uri&&t.aor){let e=i.UserAgent.makeURI(t.aor);if(!e)throw Error(`Failed to create valid URI from ${t.aor}`);s.uri=e}this.userAgent=new i.UserAgent(s),this.userAgent.delegate={onConnect:()=>{this.logger.log(`[${this.id}] Connected`),this.delegate&&this.delegate.onServerConnect&&this.delegate.onServerConnect(),this.registerer&&this.registerRequested&&(this.logger.log(`[${this.id}] Registering...`),this.registerer.register().catch(e=>{this.logger.error(`[${this.id}] Error occurred registering after connection with server was obtained.`),this.logger.error(e.toString())}))},onDisconnect:e=>{this.logger.log(`[${this.id}] Disconnected`),this.delegate&&this.delegate.onServerDisconnect&&this.delegate.onServerDisconnect(e),this.session&&(this.logger.log(`[${this.id}] Hanging up...`),this.hangup().catch(e=>{this.logger.error(`[${this.id}] Error occurred hanging up call after connection with server was lost.`),this.logger.error(e.toString())})),this.registerer&&(this.logger.log(`[${this.id}] Unregistering...`),this.registerer.unregister().catch(e=>{this.logger.error(`[${this.id}] Error occurred unregistering after connection with server was lost.`),this.logger.error(e.toString())})),e&&this.attemptReconnection()},onInvite:e=>{if(this.logger.log(`[${this.id}] Received INVITE`),this.session){this.logger.warn(`[${this.id}] Session already in progress, rejecting INVITE...`),e.reject().then(()=>{this.logger.log(`[${this.id}] Rejected INVITE`)}).catch(e=>{this.logger.error(`[${this.id}] Failed to reject INVITE`),this.logger.error(e.toString())});return}let t={sessionDescriptionHandlerOptions:{constraints:this.constraints}};this.initSession(e,t),this.delegate&&this.delegate.onCallReceived?this.delegate.onCallReceived():(this.logger.warn(`[${this.id}] No handler available, rejecting INVITE...`),e.reject().then(()=>{this.logger.log(`[${this.id}] Rejected INVITE`)}).catch(e=>{this.logger.error(`[${this.id}] Failed to reject INVITE`),this.logger.error(e.toString())}))},onMessage:e=>{e.accept().then(()=>{this.delegate&&this.delegate.onMessageReceived&&this.delegate.onMessageReceived(e.request.body)})}},this.logger=this.userAgent.getLogger("sip.SimpleUser"),window.addEventListener("online",()=>{this.logger.log(`[${this.id}] Online`),this.attemptReconnection()})}get id(){return this.options.userAgentOptions&&this.options.userAgentOptions.displayName||"Anonymous"}get localMediaStream(){var e;let t=null===(e=this.session)||void 0===e?void 0:e.sessionDescriptionHandler;if(t){if(!(t instanceof g.SessionDescriptionHandler))throw Error("Session description handler not instance of web SessionDescriptionHandler");return t.localMediaStream}}get remoteMediaStream(){var e;let t=null===(e=this.session)||void 0===e?void 0:e.sessionDescriptionHandler;if(t){if(!(t instanceof g.SessionDescriptionHandler))throw Error("Session description handler not instance of web SessionDescriptionHandler");return t.remoteMediaStream}}get localAudioTrack(){var e;return null===(e=this.localMediaStream)||void 0===e?void 0:e.getTracks().find(e=>"audio"===e.kind)}get localVideoTrack(){var e;return null===(e=this.localMediaStream)||void 0===e?void 0:e.getTracks().find(e=>"video"===e.kind)}get remoteAudioTrack(){var e;return null===(e=this.remoteMediaStream)||void 0===e?void 0:e.getTracks().find(e=>"audio"===e.kind)}get remoteVideoTrack(){var e;return null===(e=this.remoteMediaStream)||void 0===e?void 0:e.getTracks().find(e=>"video"===e.kind)}connect(){return(this.logger.log(`[${this.id}] Connecting UserAgent...`),this.connectRequested=!0,this.userAgent.
11state!==r.UserAgentState.Started)?this.userAgent.start():this.userAgent.reconnect()}disconnect(){return this.logger.log(`[${this.id}] Disconnecting UserAgent...`),this.connectRequested=!1,this.userAgent.stop()}isConnected(){return this.userAgent.isConnected()}register(e,t){return this.logger.log(`[${this.id}] Registering UserAgent...`),this.registerRequested=!0,this.registerer||(this.registerer=new n.Registerer(this.userAgent,e),this.registerer.stateChange.addListener(e=>{switch(e){case o.RegistererState.Initial:break;case o.RegistererState.Registered:this.delegate&&this.delegate.onRegistered&&this.delegate.onRegistered();break;case o.RegistererState.Unregistered:this.delegate&&this.delegate.onUnregistered&&this.delegate.onUnregistered();break;case o.RegistererState.Terminated:this.registerer=void 0;break;default:throw Error("Unknown registerer state.")}})),this.registerer.register(t).then(()=>{})}unregister(e){return(this.logger.log(`[${this.id}] Unregistering UserAgent...`),this.registerRequested=!1,this.registerer)?this.registerer.unregister(e).then(()=>{}):Promise.resolve()}call(e,t,s){if(this.logger.log(`[${this.id}] Beginning Session...`),this.session)return Promise.reject(Error("Session already exists."));let r=i.UserAgent.makeURI(e);if(!r)return Promise.reject(Error(`Failed to create a valid URI from "${e}"`));t||(t={}),t.sessionDescriptionHandlerOptions||(t.sessionDescriptionHandlerOptions={}),t.sessionDescriptionHandlerOptions.constraints||(t.sessionDescriptionHandlerOptions.constraints=this.constraints);let n=new a.Inviter(this.userAgent,r,t);return this.sendInvite(n,t,s).then(()=>{})}hangup(){return this.logger.log(`[${this.id}] Hangup...`),this.terminate()}answer(e){return(this.logger.log(`[${this.id}] Accepting Invitation...`),this.session)?this.session instanceof c.Invitation?(e||(e={}),e.sessionDescriptionHandlerOptions||(e.sessionDescriptionHandlerOptions={}),e.sessionDescriptionHandlerOptions.constraints||(e.sessionDescriptionHandlerOptions.constraints=this.constraints),this.session.accept(e)):Promise.reject(Error("Session not instance of Invitation.")):Promise.reject(Error("Session does not exist."))}decline(){return(this.logger.log(`[${this.id}] rejecting Invitation...`),this.session)?this.session instanceof c.Invitation?this.session.reject():Promise.reject(Error("Session not instance of Invitation.")):Promise.reject(Error("Session does not exist."))}hold(){return this.logger.log(`[${this.id}] holding session...`),this.setHold(!0)}unhold(){return this.logger.log(`[${this.id}] unholding session...`),this.setHold(!1)}isHeld(){return this.held}mute(){this.logger.log(`[${this.id}] disabling media tracks...`),this.setMute(!0)}unmute(){this.logger.log(`[${this.id}] enabling media tracks...`),this.setMute(!1)}isMuted(){return this.muted}sendDTMF(e){return(this.logger.log(`[${this.id}] sending DTMF...`),/^[0-9A-D#*,]$/.exec(e))?this.session?(this.logger.log(`[${this.id}] Sending DTMF tone: ${e}`),this.session.info({requestOptions:{body:{contentDisposition:"render",contentType:"application/dtmf-relay",content:"Signal="+e+"\r\nDuration=2000"}}}).then(()=>{})):Promise.reject(Error("Session does not exist.")):Promise.reject(Error("Invalid DTMF tone."))}message(e,t){this.logger.log(`[${this.id}] sending message...`);let s=i.UserAgent.makeURI(e);return s?new h.Messager(this.userAgent,s,t).message():Promise.reject(Error(`Failed to create a valid URI from "${e}"`))}get constraints(){var e;let t={audio:!0,video:!1};return(null===(e=this.options.media)||void 0===e?void 0:e.constraints)&&(t=Object.assign({},this.options.media.constraints)),t}attemptReconnection(e=1){let t=this.options.reconnectionAttempts||3,s=this.options.reconnectionDelay||4;if(!this.connectRequested){this.logger.log(`[${this.id}] Reconnection not currently desired`);return}if(this.attemptingReconnection&&this.logger.log(`[${this.id}] Reconnection attempt already in progress`),e>t){this.logger.log(`[${this.id}] Reconnection maximum attempts reached`);return}1===e?this.logger.log(`[${this.id}] Reconnection attempt ${e} of ${t} - trying`):this.logger.log(`[${this.id}] Reconnection attempt ${e} of ${t} - trying in ${s} seconds`),this.attemptingReconnection=!0,setTimeout(()=>{if(!this.connectRequested){this.logger.log(`[${this.id}] Reconnection attempt ${e} of ${t} - aborted`),this.attemptingReconnection=!1;return}this.userAgent.reconnect().then(()=>{this.logger.log(`[${this.id}] Reconnection attempt ${e} of ${t} - succeeded`),this.attemptingReconnection=!1}).catch(s=>{this.logger.log(`[${this.id}] Reconnection attempt ${e} of ${t} - failed`),this.logger.error(s.message),this.attemptingReconnection=!1,this.attemptReconnection(++e)})},1===e?0:1e3*s)}cleanupMedia(){this.options.media&&(this.options.media.local&&this.options.media.local.video&&(this.options.media.local.video.srcObject=null,this.options.media.local.video.pause()),this.options.media.remote&&(this.options.media.remote.audio&&(this.options.media.remote.audio.srcObject=null,this.options.media.remote.audio.pause()),this.options.media.remote.video&&(this.options.media.remote.video.srcObject=null,this.options.media.remote.video.pause())))}enableReceiverTracks(e){if(!this.session)throw Error("Session does not exist.");let t=this.session.sessionDescriptionHandler;if(!(t instanceof g.SessionDescriptionHandler))throw Error("Session's session description handler not instance of SessionDescriptionHandler.");let s=t.peerConnection;if(!s)throw Error("Peer connection closed.");
11s.getReceivers().forEach(t=>{t.track&&(t.track.enabled=e)})}enableSenderTracks(e){if(!this.session)throw Error("Session does not exist.");let t=this.session.sessionDescriptionHandler;if(!(t instanceof g.SessionDescriptionHandler))throw Error("Session's session description handler not instance of SessionDescriptionHandler.");let s=t.peerConnection;if(!s)throw Error("Peer connection closed.");s.getSenders().forEach(t=>{t.track&&(t.track.enabled=e)})}initSession(e,t){this.session=e,this.delegate&&this.delegate.onCallCreated&&this.delegate.onCallCreated(),this.session.stateChange.addListener(t=>{if(this.session===e)switch(this.logger.log(`[${this.id}] session state changed to ${t}`),t){case d.SessionState.Initial:case d.SessionState.Establishing:break;case d.SessionState.Established:this.setupLocalMedia(),this.setupRemoteMedia(),this.delegate&&this.delegate.onCallAnswered&&this.delegate.onCallAnswered();break;case d.SessionState.Terminating:case d.SessionState.Terminated:this.session=void 0,this.cleanupMedia(),this.delegate&&this.delegate.onCallHangup&&this.delegate.onCallHangup();break;default:throw Error("Unknown session state.")}}),this.session.delegate={onInfo:e=>{var t;let s,i;if((null===(t=this.delegate)||void 0===t?void 0:t.onCallDTMFReceived)===void 0){e.reject();return}let r=e.request.getHeader("content-type");if(!r||!/^application\/dtmf-relay/i.exec(r)){e.reject();return}let n=e.request.body.split("\r\n",2);if(2!==n.length){e.reject();return}let o=/^(Signal\s*?=\s*?)([0-9A-D#*]{1})(\s)?.*/;if(o.test(n[0])&&(s=n[0].replace(o,"$2")),!s){e.reject();return}let a=/^(Duration\s?=\s?)([0-9]{1,4})(\s)?.*/;if(a.test(n[1])&&(i=parseInt(n[1].replace(a,"$2"),10)),!i){e.reject();return}e.accept().then(()=>{if(this.delegate&&this.delegate.onCallDTMFReceived){if(!s||!i)throw Error("Tone or duration undefined.");this.delegate.onCallDTMFReceived(s,i)}}).catch(e=>{this.logger.error(e.message)})},onRefer:e=>{e.accept().then(()=>this.sendInvite(e.makeInviter(t),t)).catch(e=>{this.logger.error(e.message)})}}}sendInvite(e,t,s){return this.initSession(e,t),e.invite(s).then(()=>{this.logger.log(`[${this.id}] sent INVITE`)})}setHold(e){if(!this.session)return Promise.reject(Error("Session does not exist."));let t=this.session;if(this.held===e)return Promise.resolve();if(!(this.session.sessionDescriptionHandler instanceof g.SessionDescriptionHandler))throw Error("Session's session description handler not instance of SessionDescriptionHandler.");let s=t.sessionDescriptionHandlerOptionsReInvite;return s.hold=e,t.sessionDescriptionHandlerOptionsReInvite=s,this.session.invite({requestDelegate:{onAccept:()=>{this.held=e,this.enableReceiverTracks(!this.held),this.enableSenderTracks(!this.held&&!this.muted),this.delegate&&this.delegate.onCallHold&&this.delegate.onCallHold(this.held)},onReject:()=>{this.logger.warn(`[${this.id}] re-invite request was rejected`),this.enableReceiverTracks(!this.held),this.enableSenderTracks(!this.held&&!this.muted),this.delegate&&this.delegate.onCallHold&&this.delegate.onCallHold(this.held)}}}).then(()=>{this.enableReceiverTracks(!e),this.enableSenderTracks(!e&&!this.muted)}).catch(e=>{throw e instanceof l.RequestPendingError&&this.logger.error(`[${this.id}] A hold request is already in progress.`),e})}setMute(e){if(!this.session){this.logger.warn(`[${this.id}] A session is required to enabled/disable media tracks`);return}if(this.session.state!==d.SessionState.Established){this.logger.warn(`[${this.id}] An established session is required to enable/disable media tracks`);return}this.muted=e,this.enableSenderTracks(!this.held&&!this.muted)}setupLocalMedia(){var e,t;if(!this.session)throw Error("Session does not exist.");let s=null===(t=null===(e=this.options.media)||void 0===e?void 0:e.local)||void 0===t?void 0:t.video;
11if(s){let e=this.localMediaStream;if(!e)throw Error("Local media stream undefiend.");s.srcObject=e,s.volume=0,s.play().catch(e=>{this.logger.error(`[${this.id}] Failed to play local media`),this.logger.error(e.message)})}}setupRemoteMedia(){var e,t,s,i;if(!this.session)throw Error("Session does not exist.");let r=(null===(t=null===(e=this.options.media)||void 0===e?void 0:e.remote)||void 0===t?void 0:t.video)||(null===(i=null===(s=this.options.media)||void 0===s?void 0:s.remote)||void 0===i?void 0:i.audio);if(r){let e=this.remoteMediaStream;if(!e)throw Error("Remote media stream undefiend.");r.autoplay=!0,r.srcObject=e,r.play().catch(e=>{this.logger.error(`[${this.id}] Failed to play remote media`),this.logger.error(e.message)}),e.onaddtrack=()=>{this.logger.log(`[${this.id}] Remote media onaddtrack`),r.load(),r.play().catch(e=>{this.logger.error(`[${this.id}] Failed to play remote media`),this.logger.error(e.message)})}}}terminate(){if(this.logger.log(`[${this.id}] Terminating...`),!this.session)return Promise.reject(Error("Session does not exist."));switch(this.session.state){case d.SessionState.Initial:if(this.session instanceof a.Inviter)return this.session.cancel().then(()=>{this.logger.log(`[${this.id}] Inviter never sent INVITE (canceled)`)});if(this.session instanceof c.Invitation)return this.session.reject().then(()=>{this.logger.log(`[${this.id}] Invitation rejected (sent 480)`)});throw Error("Unknown session type.");case d.SessionState.Establishing:if(this.session instanceof a.Inviter)return this.session.cancel().then(()=>{this.logger.log(`[${this.id}] Inviter canceled (sent CANCEL)`)});if(this.session instanceof c.Invitation)return this.session.reject().then(()=>{this.logger.log(`[${this.id}] Invitation rejected (sent 480)`)});throw Error("Unknown session type.");case d.SessionState.Established:return this.session.bye().then(()=>{this.logger.log(`[${this.id}] Session ended (sent BYE)`)});case d.SessionState.Terminating:case d.SessionState.Terminated:break;default:throw Error("Unknown state")}return this.logger.log(`[${this.id}] Terminating in state ${this.session.state}, no action taken`),Promise.resolve()}}},(e,t,s)=>{s.r(t),s.d(t,{Transport:()=>i.Transport});var i=s(57)}],t={};function s(i){var r=t[i];if(void 0!==r)return r.exports;var n=t[i]={exports:{}};return e[i](n,n.exports,s),n.exports}s.d=(e,t)=>{for(var i in t)s.o(t,i)&&!s.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},s.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),s.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var i={};return(()=>{s.r(i),s.d(i,{name:()=>c,version:()=>a,Ack:()=>t.Ack,Bye:()=>t.Bye,ContentTypeUnsupportedError:()=>t.ContentTypeUnsupportedError,EmitterImpl:()=>t.EmitterImpl,Info:()=>t.Info,Invitation:()=>t.Invitation,Inviter:()=>t.Inviter,Message:()=>t.Message,Messager:()=>t.Messager,Notification:()=>t.Notification,Publisher:()=>t.Publisher,PublisherState:()=>t.PublisherState,Referral:()=>t.Referral,Registerer:()=>t.Registerer,RegistererState:()=>t.RegistererState,RequestPendingError:()=>t.RequestPendingError,SIPExtension:()=>t.SIPExtension,Session:()=>t.Session,SessionDescriptionHandlerError:()=>t.SessionDescriptionHandlerError,SessionState:()=>t.SessionState,SessionTerminatedError:()=>t.SessionTerminatedError,StateTransitionError:()=>t.StateTransitionError,Subscriber:()=>t.Subscriber,Subscription:()=>t.Subscription,SubscriptionState:()=>t.SubscriptionState,TransportState:()=>t.TransportState,UserAgent:()=>t.UserAgent,UserAgentRegisteredOptionTags:()=>t.UserAgentRegisteredOptionTags,UserAgentState:()=>t.UserAgentState,Grammar:()=>r.Grammar,NameAddrHeader:()=>r.NameAddrHeader,Parameters:()=>r.Parameters,URI:()=>r.URI,equivalentURI:()=>r.equivalentURI,Core:()=>n,Web:()=>o});var e=s(1),t=s(2),r=s(99),n=s(100),o=s(113);let a=e.LIBRARY_VERSION,c="sip.js"})(),i})()},e.exports=t()}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.