@tbisoftware/phone 1.0.12 → 2.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +266 -108
- package/dist/components/phone.d.ts +3 -0
- package/dist/components/phone.d.ts.map +1 -0
- package/dist/context/PhoneContext.d.ts +23 -0
- package/dist/context/PhoneContext.d.ts.map +1 -0
- package/dist/core/PhoneManager.d.ts +94 -0
- package/dist/core/PhoneManager.d.ts.map +1 -0
- package/dist/core/index.cjs +1 -0
- package/dist/core/index.d.ts +7 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +7 -0
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/usePhoneManager.d.ts +69 -0
- package/dist/hooks/usePhoneManager.d.ts.map +1 -0
- package/dist/index-Br8w8pI3.cjs +68 -0
- package/dist/index-TymkBND5.js +8237 -0
- package/dist/index.cjs +1 -68
- package/dist/index.d.ts +9 -1
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -8616
- package/dist/react/Phone.d.ts +3 -0
- package/dist/react/Phone.d.ts.map +1 -0
- package/dist/react/PhoneContext.d.ts +23 -0
- package/dist/react/PhoneContext.d.ts.map +1 -0
- package/dist/react/index.cjs +1 -0
- package/dist/react/index.d.ts +7 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +9 -0
- package/dist/react/usePhoneManager.d.ts +67 -0
- package/dist/react/usePhoneManager.d.ts.map +1 -0
- package/dist/types/index.d.ts +56 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/usePhoneManager-OZM1GaNS.js +536 -0
- package/dist/usePhoneManager-uj2opBKT.cjs +1 -0
- package/dist/utils/cn.d.ts +5 -0
- package/dist/utils/cn.d.ts.map +1 -0
- package/dist/utils/formatDuration.d.ts +5 -0
- package/dist/utils/formatDuration.d.ts.map +1 -0
- package/dist/vue/index.cjs +1 -0
- package/dist/vue/index.d.ts +8 -0
- package/dist/vue/index.d.ts.map +1 -0
- package/dist/vue/index.js +706 -0
- package/dist/vue/usePhone.d.ts +59 -0
- package/dist/vue/usePhone.d.ts.map +1 -0
- package/dist/vue/usePhoneManager.d.ts +72 -0
- package/dist/vue/usePhoneManager.d.ts.map +1 -0
- package/package.json +34 -4
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";function $l(...O){return O.filter(Boolean).join(" ")}function kl(O){const y=Math.floor(O/3600),i=Math.floor(O%3600/60),_=O%60;return y>0?`${y.toString().padStart(2,"0")}:${i.toString().padStart(2,"0")}:${_.toString().padStart(2,"0")}`:`${i.toString().padStart(2,"0")}:${_.toString().padStart(2,"0")}`}const ql={calling:"Llamando",waitingResponse:"Esperando respuesta...",cancel:"Cancelar",hangUp:"Colgar",callEnded:"Llamada finalizada",duration:"Duración",inactive:"Inactivo",inCall:"En llamada",placeholder:"Número a llamar",callHistory:"Historial de llamadas",noCallsRegistered:"No hay llamadas registradas",callsRegistered:"llamada(s) registrada(s)",noCalls:"No hay llamadas",startingCall:"Iniciando llamada a",callInProgress:"Ya hay una llamada en curso"};function Gl(O){return O&&O.__esModule&&Object.prototype.hasOwnProperty.call(O,"default")?O.default:O}const Bl="JsSIP",Wl="3.11.1",zn={title:Bl,version:Wl};var Mt,un;function ie(){if(un)return Mt;un=1;const O=zn;return Mt={USER_AGENT:`${O.title} ${O.version}`,SIP:"sip",SIPS:"sips",causes:{CONNECTION_ERROR:"Connection Error",REQUEST_TIMEOUT:"Request Timeout",SIP_FAILURE_CODE:"SIP Failure Code",INTERNAL_ERROR:"Internal Error",BUSY:"Busy",REJECTED:"Rejected",REDIRECTED:"Redirected",UNAVAILABLE:"Unavailable",NOT_FOUND:"Not Found",ADDRESS_INCOMPLETE:"Address Incomplete",INCOMPATIBLE_SDP:"Incompatible SDP",MISSING_SDP:"Missing SDP",AUTHENTICATION_ERROR:"Authentication Error",BYE:"Terminated",WEBRTC_ERROR:"WebRTC Error",CANCELED:"Canceled",NO_ANSWER:"No Answer",EXPIRES:"Expires",NO_ACK:"No ACK",DIALOG_ERROR:"Dialog Error",USER_DENIED_MEDIA_ACCESS:"User Denied Media Access",BAD_MEDIA_DESCRIPTION:"Bad Media Description",RTP_TIMEOUT:"RTP Timeout"},SIP_ERROR_CAUSES:{REDIRECTED:[300,301,302,305,380],BUSY:[486,600],REJECTED:[403,603],NOT_FOUND:[404,604],UNAVAILABLE:[480,410,408,430],ADDRESS_INCOMPLETE:[484,424],INCOMPATIBLE_SDP:[488,606],AUTHENTICATION_ERROR:[401,407]},ACK:"ACK",BYE:"BYE",CANCEL:"CANCEL",INFO:"INFO",INVITE:"INVITE",MESSAGE:"MESSAGE",NOTIFY:"NOTIFY",OPTIONS:"OPTIONS",REGISTER:"REGISTER",REFER:"REFER",UPDATE:"UPDATE",SUBSCRIBE:"SUBSCRIBE",DTMF_TRANSPORT:{INFO:"INFO",RFC2833:"RFC2833"},REASON_PHRASE:{100:"Trying",180:"Ringing",181:"Call Is Being Forwarded",182:"Queued",183:"Session Progress",199:"Early Dialog Terminated",200:"OK",202:"Accepted",204:"No Notification",300:"Multiple Choices",301:"Moved Permanently",302:"Moved Temporarily",305:"Use Proxy",380:"Alternative Service",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Timeout",410:"Gone",412:"Conditional Request Failed",413:"Request Entity Too Large",414:"Request-URI Too Long",415:"Unsupported Media Type",416:"Unsupported URI Scheme",417:"Unknown Resource-Priority",420:"Bad Extension",421:"Extension Required",422:"Session Interval Too Small",423:"Interval Too Brief",424:"Bad Location Information",428:"Use Identity Header",429:"Provide Referrer Identity",430:"Flow Failed",433:"Anonymity Disallowed",436:"Bad Identity-Info",437:"Unsupported Certificate",438:"Invalid Identity Header",439:"First Hop Lacks Outbound Support",440:"Max-Breadth Exceeded",469:"Bad Info Package",470:"Consent Needed",478:"Unresolvable Destination",480:"Temporarily Unavailable",481:"Call/Transaction Does Not Exist",482:"Loop Detected",483:"Too Many Hops",484:"Address Incomplete",485:"Ambiguous",486:"Busy Here",487:"Request Terminated",488:"Not Acceptable Here",489:"Bad Event",491:"Request Pending",493:"Undecipherable",494:"Security Agreement Required",500:"JsSIP Internal Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Server Time-out",505:"Version Not Supported",513:"Message Too Large",580:"Precondition Failure",600:"Busy Everywhere",603:"Decline",604:"Does Not Exist Anywhere",606:"Not Acceptable"},ALLOWED_METHODS:"INVITE,ACK,CANCEL,BYE,UPDATE,MESSAGE,OPTIONS,REFER,INFO,NOTIFY",ACCEPTED_BODY_TYPES:"application/sdp, application/dtmf-relay",MAX_FORWARDS:69,SESSION_EXPIRES:90,MIN_SESSION_EXPIRES:60,CONNECTION_RECOVERY_MAX_INTERVAL:30,CONNECTION_RECOVERY_MIN_INTERVAL:2},Mt}var Ht,cn;function Re(){if(cn)return Ht;cn=1;class O extends Error{constructor(t,h){super(),this.code=1,this.name="CONFIGURATION_ERROR",this.parameter=t,this.value=h,this.message=this.value?`Invalid value ${JSON.stringify(this.value)} for parameter "${this.parameter}"`:`Missing parameter: ${this.parameter}`}}class y extends Error{constructor(t){super(),this.code=2,this.name="INVALID_STATE_ERROR",this.status=t,this.message=`Invalid status: ${t}`}}class i extends Error{constructor(t){super(),this.code=3,this.name="NOT_SUPPORTED_ERROR",this.message=t}}class _ extends Error{constructor(t){super(),this.code=4,this.name="NOT_READY_ERROR",this.message=t}}return Ht={ConfigurationError:O,InvalidStateError:y,NotSupportedError:i,NotReadyError:_},Ht}var ne={},Ft,fn;function Ts(){if(fn)return Ft;fn=1;const O=ye(),y=ge();return Ft=class Yn{static parse(_){if(_=y.parse(_,"Name_Addr_Header"),_!==-1)return _}constructor(_,E,t){if(!_||!(_ instanceof O))throw new TypeError('missing or invalid "uri" parameter');this._uri=_,this._parameters={},this.display_name=E;for(const h in t)Object.prototype.hasOwnProperty.call(t,h)&&this.setParam(h,t[h])}get uri(){return this._uri}get display_name(){return this._display_name}set display_name(_){this._display_name=_===0?"0":_}setParam(_,E){_&&(this._parameters[_.toLowerCase()]=typeof E>"u"||E===null?null:E.toString())}getParam(_){if(_)return this._parameters[_.toLowerCase()]}hasParam(_){if(_)return this._parameters.hasOwnProperty(_.toLowerCase())&&!0||!1}deleteParam(_){if(_=_.toLowerCase(),this._parameters.hasOwnProperty(_)){const E=this._parameters[_];return delete this._parameters[_],E}}clearParams(){this._parameters={}}clone(){return new Yn(this._uri.clone(),this._display_name,JSON.parse(JSON.stringify(this._parameters)))}_quote(_){return _.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}toString(){let _=this._display_name?`"${this._quote(this._display_name)}" `:"";_+=`<${this._uri.toString()}>`;for(const E in this._parameters)Object.prototype.hasOwnProperty.call(this._parameters,E)&&(_+=`;${E}`,this._parameters[E]!==null&&(_+=`=${this._parameters[E]}`));return _}},Ft}var $t,hn;function ge(){return hn||(hn=1,$t=(function(){function O(i){return'"'+i.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\x08/g,"\\b").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\f/g,"\\f").replace(/\r/g,"\\r").replace(/[\x00-\x07\x0B\x0E-\x1F\x80-\uFFFF]/g,escape)+'"'}var y={parse:function(i,_){var E={CRLF:g,DIGIT:c,ALPHA:R,HEXDIG:x,WSP:S,OCTET:N,DQUOTE:k,SP:C,HTAB:I,alphanum:H,reserved:F,unreserved:o,mark:f,escaped:T,LWS:p,SWS:A,HCOLON:D,TEXT_UTF8_TRIM:v,TEXT_UTF8char:w,UTF8_NONASCII:U,UTF8_CONT:M,LHEX:ee,token:B,token_nodot:ae,separators:fe,word:ce,STAR:Y,SLASH:he,EQUAL:J,LPAREN:we,RPAREN:be,RAQUOT:Se,LAQUOT:Ee,COMMA:Q,SEMI:z,COLON:Ne,LDQUOT:Ae,RDQUOT:Ve,comment:j,ctext:V,quoted_string:K,quoted_string_clean:X,qdtext:se,quoted_pair:re,SIP_URI_noparams:Z,SIP_URI:Te,uri_scheme:de,uri_scheme_sips:vs,uri_scheme_sip:Ss,userinfo:je,user:Es,user_unreserved:ht,password:As,hostport:Ke,host:Pe,hostname:dt,domainlabel:_t,toplabel:Rs,IPv6reference:pt,IPv6address:mt,h16:q,ls32:_e,IPv4address:Le,dec_octet:Me,port:ys,uri_parameters:Is,uri_parameter:gt,transport_param:ws,user_param:bs,method_param:Ns,ttl_param:Os,maddr_param:Ds,lr_param:xs,other_param:Us,pname:Ps,pvalue:Ls,paramchar:He,param_unreserved:Ms,headers:Hs,header:ze,hname:Fs,hvalue:$s,hnv_unreserved:Fe,Request_Response:tl,Request_Line:ks,Request_URI:qs,absoluteURI:Tt,hier_part:Gs,net_path:Bs,abs_path:Ye,opaque_part:Ws,uric:$e,uric_no_slash:Vs,path_segments:js,segment:Je,param:Ct,pchar:ke,scheme:Ks,authority:zs,srvr:Ys,reg_name:Js,query:Xs,SIP_Version:vt,INVITEm:Qs,ACKm:Zs,OPTIONSm:er,BYEm:tr,CANCELm:sr,REGISTERm:rr,SUBSCRIBEm:nr,NOTIFYm:lr,REFERm:ir,Method:Xe,Status_Line:ar,Status_Code:or,extension_code:ur,Reason_Phrase:cr,Allow_Events:sl,Call_ID:rl,Contact:nl,contact_param:Qe,name_addr:Oe,display_name:Ze,contact_params:St,c_p_q:fr,c_p_expires:hr,delta_seconds:De,qvalue:dr,generic_param:le,gen_value:_r,Content_Disposition:ll,disp_type:pr,disp_param:Et,handling_param:mr,Content_Encoding:il,Content_Length:al,Content_Type:ol,media_type:gr,m_type:Tr,discrete_type:Cr,composite_type:vr,extension_token:et,x_token:Sr,m_subtype:Er,m_parameter:At,m_value:Ar,CSeq:ul,CSeq_value:Rr,Expires:cl,Event:fl,event_type:qe,From:hl,from_param:Rt,tag_param:yt,Max_Forwards:dl,Min_Expires:_l,Name_Addr_Header:pl,Proxy_Authenticate:ml,challenge:It,other_challenge:yr,auth_param:Ge,digest_cln:tt,realm:Ir,realm_value:wr,domain:br,URI:st,nonce:Nr,nonce_value:Or,opaque:Dr,stale:xr,algorithm:Ur,qop_options:Pr,qop_value:rt,Proxy_Require:gl,Record_Route:Tl,rec_route:nt,Reason:Cl,reason_param:wt,reason_cause:Lr,Require:vl,Route:Sl,route_param:lt,Subscription_State:El,substate_value:Mr,subexp_params:bt,event_reason_value:Hr,Subject:Al,Supported:Rl,To:yl,to_param:Nt,Via:Il,via_param:it,via_params:Ot,via_ttl:Fr,via_maddr:$r,via_received:kr,via_branch:qr,response_port:Gr,rport:Br,sent_protocol:Wr,protocol_name:Vr,transport:jr,sent_by:Kr,via_host:zr,via_port:Yr,ttl:Dt,WWW_Authenticate:wl,Session_Expires:bl,s_e_expires:Jr,s_e_params:xt,s_e_refresher:Xr,extension_header:Nl,header_value:Qr,message_body:Ol,uuid_URI:Dl,uuid:Zr,hex4:Ce,hex8:en,hex12:tn,Refer_To:xl,Replaces:Ul,call_id:sn,replaces_param:Ut,to_tag:rn,from_tag:nn,early_flag:ln};if(_!==void 0){if(E[_]===void 0)throw new Error("Invalid rule name: "+O(_)+".")}else _="CRLF";var t=0,h=0,d=[];function l(e){t<h||(t>h&&(h=t,d=[]),d.push(e))}function g(){var e;return i.substr(t,2)===`\r
|
|
2
|
+
`?(e=`\r
|
|
3
|
+
`,t+=2):(e=null,l('"\\r\\n"')),e}function c(){var e;return/^[0-9]/.test(i.charAt(t))?(e=i.charAt(t),t++):(e=null,l("[0-9]")),e}function R(){var e;return/^[a-zA-Z]/.test(i.charAt(t))?(e=i.charAt(t),t++):(e=null,l("[a-zA-Z]")),e}function x(){var e;return/^[0-9a-fA-F]/.test(i.charAt(t))?(e=i.charAt(t),t++):(e=null,l("[0-9a-fA-F]")),e}function S(){var e;return e=C(),e===null&&(e=I()),e}function N(){var e;return/^[\0-\xFF]/.test(i.charAt(t))?(e=i.charAt(t),t++):(e=null,l("[\\0-\\xFF]")),e}function k(){var e;return/^["]/.test(i.charAt(t))?(e=i.charAt(t),t++):(e=null,l('["]')),e}function C(){var e;return i.charCodeAt(t)===32?(e=" ",t++):(e=null,l('" "')),e}function I(){var e;return i.charCodeAt(t)===9?(e=" ",t++):(e=null,l('"\\t"')),e}function H(){var e;return/^[a-zA-Z0-9]/.test(i.charAt(t))?(e=i.charAt(t),t++):(e=null,l("[a-zA-Z0-9]")),e}function F(){var e;return i.charCodeAt(t)===59?(e=";",t++):(e=null,l('";"')),e===null&&(i.charCodeAt(t)===47?(e="/",t++):(e=null,l('"/"')),e===null&&(i.charCodeAt(t)===63?(e="?",t++):(e=null,l('"?"')),e===null&&(i.charCodeAt(t)===58?(e=":",t++):(e=null,l('":"')),e===null&&(i.charCodeAt(t)===64?(e="@",t++):(e=null,l('"@"')),e===null&&(i.charCodeAt(t)===38?(e="&",t++):(e=null,l('"&"')),e===null&&(i.charCodeAt(t)===61?(e="=",t++):(e=null,l('"="')),e===null&&(i.charCodeAt(t)===43?(e="+",t++):(e=null,l('"+"')),e===null&&(i.charCodeAt(t)===36?(e="$",t++):(e=null,l('"$"')),e===null&&(i.charCodeAt(t)===44?(e=",",t++):(e=null,l('","'))))))))))),e}function o(){var e;return e=H(),e===null&&(e=f()),e}function f(){var e;return i.charCodeAt(t)===45?(e="-",t++):(e=null,l('"-"')),e===null&&(i.charCodeAt(t)===95?(e="_",t++):(e=null,l('"_"')),e===null&&(i.charCodeAt(t)===46?(e=".",t++):(e=null,l('"."')),e===null&&(i.charCodeAt(t)===33?(e="!",t++):(e=null,l('"!"')),e===null&&(i.charCodeAt(t)===126?(e="~",t++):(e=null,l('"~"')),e===null&&(i.charCodeAt(t)===42?(e="*",t++):(e=null,l('"*"')),e===null&&(i.charCodeAt(t)===39?(e="'",t++):(e=null,l(`"'"`)),e===null&&(i.charCodeAt(t)===40?(e="(",t++):(e=null,l('"("')),e===null&&(i.charCodeAt(t)===41?(e=")",t++):(e=null,l('")"')))))))))),e}function T(){var e,s,r,n,a;return n=t,a=t,i.charCodeAt(t)===37?(e="%",t++):(e=null,l('"%"')),e!==null?(s=x(),s!==null?(r=x(),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u,m){return m.join("")})(n,e)),e===null&&(t=n),e}function p(){var e,s,r,n,a,u;for(n=t,a=t,u=t,e=[],s=S();s!==null;)e.push(s),s=S();if(e!==null?(s=g(),s!==null?e=[e,s]:(e=null,t=u)):(e=null,t=u),e=e!==null?e:"",e!==null){if(r=S(),r!==null)for(s=[];r!==null;)s.push(r),r=S();else s=null;s!==null?e=[e,s]:(e=null,t=a)}else e=null,t=a;return e!==null&&(e=(function(m){return" "})()),e===null&&(t=n),e}function A(){var e;return e=p(),e=e!==null?e:"",e}function D(){var e,s,r,n,a;for(n=t,a=t,e=[],s=C(),s===null&&(s=I());s!==null;)e.push(s),s=C(),s===null&&(s=I());return e!==null?(i.charCodeAt(t)===58?(s=":",t++):(s=null,l('":"')),s!==null?(r=A(),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u){return":"})()),e===null&&(t=n),e}function v(){var e,s,r,n,a,u,m;if(a=t,u=t,s=w(),s!==null)for(e=[];s!==null;)e.push(s),s=w();else e=null;if(e!==null){for(s=[],m=t,r=[],n=p();n!==null;)r.push(n),n=p();for(r!==null?(n=w(),n!==null?r=[r,n]:(r=null,t=m)):(r=null,t=m);r!==null;){for(s.push(r),m=t,r=[],n=p();n!==null;)r.push(n),n=p();r!==null?(n=w(),n!==null?r=[r,n]:(r=null,t=m)):(r=null,t=m)}s!==null?e=[e,s]:(e=null,t=u)}else e=null,t=u;return e!==null&&(e=(function(P){return i.substring(t,P)})(a)),e===null&&(t=a),e}function w(){var e;return/^[!-~]/.test(i.charAt(t))?(e=i.charAt(t),t++):(e=null,l("[!-~]")),e===null&&(e=U()),e}function U(){var e;return/^[\x80-\uFFFF]/.test(i.charAt(t))?(e=i.charAt(t),t++):(e=null,l("[\\x80-\\uFFFF]")),e}function M(){var e;return/^[\x80-\xBF]/.test(i.charAt(t))?(e=i.charAt(t),t++):(e=null,l("[\\x80-\\xBF]")),e}function ee(){var e;return e=c(),e===null&&(/^[a-f]/.test(i.charAt(t))?(e=i.charAt(t),t++):(e=null,l("[a-f]"))),e}function B(){var e,s,r;if(r=t,s=H(),s===null&&(i.charCodeAt(t)===45?(s="-",t++):(s=null,l('"-"')),s===null&&(i.charCodeAt(t)===46?(s=".",t++):(s=null,l('"."')),s===null&&(i.charCodeAt(t)===33?(s="!",t++):(s=null,l('"!"')),s===null&&(i.charCodeAt(t)===37?(s="%",t++):(s=null,l('"%"')),s===null&&(i.charCodeAt(t)===42?(s="*",t++):(s=null,l('"*"')),s===null&&(i.charCodeAt(t)===95?(s="_",t++):(s=null,l('"_"')),s===null&&(i.charCodeAt(t)===43?(s="+",t++):(s=null,l('"+"')),s===null&&(i.charCodeAt(t)===96?(s="`",t++):(s=null,l('"`"')),s===null&&(i.charCodeAt(t)===39?(s="'",t++):(s=null,l(`"'"`)),s===null&&(i.charCodeAt(t)===126?(s="~",t++):(s=null,l('"~"')))))))))))),s!==null)for(e=[];s!==null;)e.push(s),s=H(),s===null&&(i.charCodeAt(t)===45?(s="-",t++):(s=null,l('"-"')),s===null&&(i.charCodeAt(t)===46?(s=".",t++):(s=null,l('"."')),s===null&&(i.charCodeAt(t)===33?(s="!",t++):(s=null,l('"!"')),s===null&&(i.charCodeAt(t)===37?(s="%",t++):(s=null,l('"%"')),s===null&&(i.charCodeAt(t)===42?(s="*",t++):(s=null,l('"*"')),s===null&&(i.charCodeAt(t)===95?(s="_",t++):(s=null,l('"_"')),s===null&&(i.charCodeAt(t)===43?(s="+",t++):(s=null,l('"+"')),s===null&&(i.charCodeAt(t)===96?(s="`",t++):(s=null,l('"`"')),s===null&&(i.charCodeAt(t)===39?(s="'",t++):(s=null,l(`"'"`)),s===null&&(i.charCodeAt(t)===126?(s="~",t++):(s=null,l('"~"'))))))))))));else e=null;return e!==null&&(e=(function(n){return i.substring(t,n)})(r)),e===null&&(t=r),e}function ae(){var e,s,r;if(r=t,s=H(),s===null&&(i.charCodeAt(t)===45?(s="-",t++):(s=null,l('"-"')),s===null&&(i.charCodeAt(t)===33?(s="!",t++):(s=null,l('"!"')),s===null&&(i.charCodeAt(t)===37?(s="%",t++):(s=null,l('"%"')),s===null&&(i.charCodeAt(t)===42?(s="*",t++):(s=null,l('"*"')),s===null&&(i.charCodeAt(t)===95?(s="_",t++):(s=null,l('"_"')),s===null&&(i.charCodeAt(t)===43?(s="+",t++):(s=null,l('"+"')),s===null&&(i.charCodeAt(t)===96?(s="`",t++):(s=null,l('"`"')),s===null&&(i.charCodeAt(t)===39?(s="'",t++):(s=null,l(`"'"`)),s===null&&(i.charCodeAt(t)===126?(s="~",t++):(s=null,l('"~"'))))))))))),s!==null)for(e=[];s!==null;)e.push(s),s=H(),s===null&&(i.charCodeAt(t)===45?(s="-",t++):(s=null,l('"-"')),s===null&&(i.charCodeAt(t)===33?(s="!",t++):(s=null,l('"!"')),s===null&&(i.charCodeAt(t)===37?(s="%",t++):(s=null,l('"%"')),s===null&&(i.charCodeAt(t)===42?(s="*",t++):(s=null,l('"*"')),s===null&&(i.charCodeAt(t)===95?(s="_",t++):(s=null,l('"_"')),s===null&&(i.charCodeAt(t)===43?(s="+",t++):(s=null,l('"+"')),s===null&&(i.charCodeAt(t)===96?(s="`",t++):(s=null,l('"`"')),s===null&&(i.charCodeAt(t)===39?(s="'",t++):(s=null,l(`"'"`)),s===null&&(i.charCodeAt(t)===126?(s="~",t++):(s=null,l('"~"')))))))))));else e=null;return e!==null&&(e=(function(n){return i.substring(t,n)})(r)),e===null&&(t=r),e}function fe(){var e;return i.charCodeAt(t)===40?(e="(",t++):(e=null,l('"("')),e===null&&(i.charCodeAt(t)===41?(e=")",t++):(e=null,l('")"')),e===null&&(i.charCodeAt(t)===60?(e="<",t++):(e=null,l('"<"')),e===null&&(i.charCodeAt(t)===62?(e=">",t++):(e=null,l('">"')),e===null&&(i.charCodeAt(t)===64?(e="@",t++):(e=null,l('"@"')),e===null&&(i.charCodeAt(t)===44?(e=",",t++):(e=null,l('","')),e===null&&(i.charCodeAt(t)===59?(e=";",t++):(e=null,l('";"')),e===null&&(i.charCodeAt(t)===58?(e=":",t++):(e=null,l('":"')),e===null&&(i.charCodeAt(t)===92?(e="\\",t++):(e=null,l('"\\\\"')),e===null&&(e=k(),e===null&&(i.charCodeAt(t)===47?(e="/",t++):(e=null,l('"/"')),e===null&&(i.charCodeAt(t)===91?(e="[",t++):(e=null,l('"["')),e===null&&(i.charCodeAt(t)===93?(e="]",t++):(e=null,l('"]"')),e===null&&(i.charCodeAt(t)===63?(e="?",t++):(e=null,l('"?"')),e===null&&(i.charCodeAt(t)===61?(e="=",t++):(e=null,l('"="')),e===null&&(i.charCodeAt(t)===123?(e="{",t++):(e=null,l('"{"')),e===null&&(i.charCodeAt(t)===125?(e="}",t++):(e=null,l('"}"')),e===null&&(e=C(),e===null&&(e=I())))))))))))))))))),e}function ce(){var e,s,r;if(r=t,s=H(),s===null&&(i.charCodeAt(t)===45?(s="-",t++):(s=null,l('"-"')),s===null&&(i.charCodeAt(t)===46?(s=".",t++):(s=null,l('"."')),s===null&&(i.charCodeAt(t)===33?(s="!",t++):(s=null,l('"!"')),s===null&&(i.charCodeAt(t)===37?(s="%",t++):(s=null,l('"%"')),s===null&&(i.charCodeAt(t)===42?(s="*",t++):(s=null,l('"*"')),s===null&&(i.charCodeAt(t)===95?(s="_",t++):(s=null,l('"_"')),s===null&&(i.charCodeAt(t)===43?(s="+",t++):(s=null,l('"+"')),s===null&&(i.charCodeAt(t)===96?(s="`",t++):(s=null,l('"`"')),s===null&&(i.charCodeAt(t)===39?(s="'",t++):(s=null,l(`"'"`)),s===null&&(i.charCodeAt(t)===126?(s="~",t++):(s=null,l('"~"')),s===null&&(i.charCodeAt(t)===40?(s="(",t++):(s=null,l('"("')),s===null&&(i.charCodeAt(t)===41?(s=")",t++):(s=null,l('")"')),s===null&&(i.charCodeAt(t)===60?(s="<",t++):(s=null,l('"<"')),s===null&&(i.charCodeAt(t)===62?(s=">",t++):(s=null,l('">"')),s===null&&(i.charCodeAt(t)===58?(s=":",t++):(s=null,l('":"')),s===null&&(i.charCodeAt(t)===92?(s="\\",t++):(s=null,l('"\\\\"')),s===null&&(s=k(),s===null&&(i.charCodeAt(t)===47?(s="/",t++):(s=null,l('"/"')),s===null&&(i.charCodeAt(t)===91?(s="[",t++):(s=null,l('"["')),s===null&&(i.charCodeAt(t)===93?(s="]",t++):(s=null,l('"]"')),s===null&&(i.charCodeAt(t)===63?(s="?",t++):(s=null,l('"?"')),s===null&&(i.charCodeAt(t)===123?(s="{",t++):(s=null,l('"{"')),s===null&&(i.charCodeAt(t)===125?(s="}",t++):(s=null,l('"}"'))))))))))))))))))))))))),s!==null)for(e=[];s!==null;)e.push(s),s=H(),s===null&&(i.charCodeAt(t)===45?(s="-",t++):(s=null,l('"-"')),s===null&&(i.charCodeAt(t)===46?(s=".",t++):(s=null,l('"."')),s===null&&(i.charCodeAt(t)===33?(s="!",t++):(s=null,l('"!"')),s===null&&(i.charCodeAt(t)===37?(s="%",t++):(s=null,l('"%"')),s===null&&(i.charCodeAt(t)===42?(s="*",t++):(s=null,l('"*"')),s===null&&(i.charCodeAt(t)===95?(s="_",t++):(s=null,l('"_"')),s===null&&(i.charCodeAt(t)===43?(s="+",t++):(s=null,l('"+"')),s===null&&(i.charCodeAt(t)===96?(s="`",t++):(s=null,l('"`"')),s===null&&(i.charCodeAt(t)===39?(s="'",t++):(s=null,l(`"'"`)),s===null&&(i.charCodeAt(t)===126?(s="~",t++):(s=null,l('"~"')),s===null&&(i.charCodeAt(t)===40?(s="(",t++):(s=null,l('"("')),s===null&&(i.charCodeAt(t)===41?(s=")",t++):(s=null,l('")"')),s===null&&(i.charCodeAt(t)===60?(s="<",t++):(s=null,l('"<"')),s===null&&(i.charCodeAt(t)===62?(s=">",t++):(s=null,l('">"')),s===null&&(i.charCodeAt(t)===58?(s=":",t++):(s=null,l('":"')),s===null&&(i.charCodeAt(t)===92?(s="\\",t++):(s=null,l('"\\\\"')),s===null&&(s=k(),s===null&&(i.charCodeAt(t)===47?(s="/",t++):(s=null,l('"/"')),s===null&&(i.charCodeAt(t)===91?(s="[",t++):(s=null,l('"["')),s===null&&(i.charCodeAt(t)===93?(s="]",t++):(s=null,l('"]"')),s===null&&(i.charCodeAt(t)===63?(s="?",t++):(s=null,l('"?"')),s===null&&(i.charCodeAt(t)===123?(s="{",t++):(s=null,l('"{"')),s===null&&(i.charCodeAt(t)===125?(s="}",t++):(s=null,l('"}"')))))))))))))))))))))))));else e=null;return e!==null&&(e=(function(n){return i.substring(t,n)})(r)),e===null&&(t=r),e}function Y(){var e,s,r,n,a;return n=t,a=t,e=A(),e!==null?(i.charCodeAt(t)===42?(s="*",t++):(s=null,l('"*"')),s!==null?(r=A(),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u){return"*"})()),e===null&&(t=n),e}function he(){var e,s,r,n,a;return n=t,a=t,e=A(),e!==null?(i.charCodeAt(t)===47?(s="/",t++):(s=null,l('"/"')),s!==null?(r=A(),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u){return"/"})()),e===null&&(t=n),e}function J(){var e,s,r,n,a;return n=t,a=t,e=A(),e!==null?(i.charCodeAt(t)===61?(s="=",t++):(s=null,l('"="')),s!==null?(r=A(),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u){return"="})()),e===null&&(t=n),e}function we(){var e,s,r,n,a;return n=t,a=t,e=A(),e!==null?(i.charCodeAt(t)===40?(s="(",t++):(s=null,l('"("')),s!==null?(r=A(),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u){return"("})()),e===null&&(t=n),e}function be(){var e,s,r,n,a;return n=t,a=t,e=A(),e!==null?(i.charCodeAt(t)===41?(s=")",t++):(s=null,l('")"')),s!==null?(r=A(),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u){return")"})()),e===null&&(t=n),e}function Se(){var e,s,r,n;return r=t,n=t,i.charCodeAt(t)===62?(e=">",t++):(e=null,l('">"')),e!==null?(s=A(),s!==null?e=[e,s]:(e=null,t=n)):(e=null,t=n),e!==null&&(e=(function(a){return">"})()),e===null&&(t=r),e}function Ee(){var e,s,r,n;return r=t,n=t,e=A(),e!==null?(i.charCodeAt(t)===60?(s="<",t++):(s=null,l('"<"')),s!==null?e=[e,s]:(e=null,t=n)):(e=null,t=n),e!==null&&(e=(function(a){return"<"})()),e===null&&(t=r),e}function Q(){var e,s,r,n,a;return n=t,a=t,e=A(),e!==null?(i.charCodeAt(t)===44?(s=",",t++):(s=null,l('","')),s!==null?(r=A(),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u){return","})()),e===null&&(t=n),e}function z(){var e,s,r,n,a;return n=t,a=t,e=A(),e!==null?(i.charCodeAt(t)===59?(s=";",t++):(s=null,l('";"')),s!==null?(r=A(),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u){return";"})()),e===null&&(t=n),e}function Ne(){var e,s,r,n,a;return n=t,a=t,e=A(),e!==null?(i.charCodeAt(t)===58?(s=":",t++):(s=null,l('":"')),s!==null?(r=A(),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u){return":"})()),e===null&&(t=n),e}function Ae(){var e,s,r,n;return r=t,n=t,e=A(),e!==null?(s=k(),s!==null?e=[e,s]:(e=null,t=n)):(e=null,t=n),e!==null&&(e=(function(a){return'"'})()),e===null&&(t=r),e}function Ve(){var e,s,r,n;return r=t,n=t,e=k(),e!==null?(s=A(),s!==null?e=[e,s]:(e=null,t=n)):(e=null,t=n),e!==null&&(e=(function(a){return'"'})()),e===null&&(t=r),e}function j(){var e,s,r,n;if(n=t,e=we(),e!==null){for(s=[],r=V(),r===null&&(r=re(),r===null&&(r=j()));r!==null;)s.push(r),r=V(),r===null&&(r=re(),r===null&&(r=j()));s!==null?(r=be(),r!==null?e=[e,s,r]:(e=null,t=n)):(e=null,t=n)}else e=null,t=n;return e}function V(){var e;return/^[!-']/.test(i.charAt(t))?(e=i.charAt(t),t++):(e=null,l("[!-']")),e===null&&(/^[*-[]/.test(i.charAt(t))?(e=i.charAt(t),t++):(e=null,l("[*-[]")),e===null&&(/^[\]-~]/.test(i.charAt(t))?(e=i.charAt(t),t++):(e=null,l("[\\]-~]")),e===null&&(e=U(),e===null&&(e=p())))),e}function K(){var e,s,r,n,a,u;if(a=t,u=t,e=A(),e!==null)if(s=k(),s!==null){for(r=[],n=se(),n===null&&(n=re());n!==null;)r.push(n),n=se(),n===null&&(n=re());r!==null?(n=k(),n!==null?e=[e,s,r,n]:(e=null,t=u)):(e=null,t=u)}else e=null,t=u;else e=null,t=u;return e!==null&&(e=(function(m){return i.substring(t,m)})(a)),e===null&&(t=a),e}function X(){var e,s,r,n,a,u;if(a=t,u=t,e=A(),e!==null)if(s=k(),s!==null){for(r=[],n=se(),n===null&&(n=re());n!==null;)r.push(n),n=se(),n===null&&(n=re());r!==null?(n=k(),n!==null?e=[e,s,r,n]:(e=null,t=u)):(e=null,t=u)}else e=null,t=u;else e=null,t=u;return e!==null&&(e=(function(m){var P=i.substring(t,m).trim();return P.substring(1,P.length-1).replace(/\\([\x00-\x09\x0b-\x0c\x0e-\x7f])/g,"$1")})(a)),e===null&&(t=a),e}function se(){var e;return e=p(),e===null&&(i.charCodeAt(t)===33?(e="!",t++):(e=null,l('"!"')),e===null&&(/^[#-[]/.test(i.charAt(t))?(e=i.charAt(t),t++):(e=null,l("[#-[]")),e===null&&(/^[\]-~]/.test(i.charAt(t))?(e=i.charAt(t),t++):(e=null,l("[\\]-~]")),e===null&&(e=U())))),e}function re(){var e,s,r;return r=t,i.charCodeAt(t)===92?(e="\\",t++):(e=null,l('"\\\\"')),e!==null?(/^[\0-\t]/.test(i.charAt(t))?(s=i.charAt(t),t++):(s=null,l("[\\0-\\t]")),s===null&&(/^[\x0B-\f]/.test(i.charAt(t))?(s=i.charAt(t),t++):(s=null,l("[\\x0B-\\f]")),s===null&&(/^[\x0E-]/.test(i.charAt(t))?(s=i.charAt(t),t++):(s=null,l("[\\x0E-]")))),s!==null?e=[e,s]:(e=null,t=r)):(e=null,t=r),e}function Z(){var e,s,r,n,a,u;return a=t,u=t,e=de(),e!==null?(i.charCodeAt(t)===58?(s=":",t++):(s=null,l('":"')),s!==null?(r=je(),r=r!==null?r:"",r!==null?(n=Ke(),n!==null?e=[e,s,r,n]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=(function(m){try{b.uri=new an(b.scheme,b.user,b.host,b.port),delete b.scheme,delete b.user,delete b.host,delete b.host_type,delete b.port}catch{b=-1}})()),e===null&&(t=a),e}function Te(){var e,s,r,n,a,u,m,P;return m=t,P=t,e=de(),e!==null?(i.charCodeAt(t)===58?(s=":",t++):(s=null,l('":"')),s!==null?(r=je(),r=r!==null?r:"",r!==null?(n=Ke(),n!==null?(a=Is(),a!==null?(u=Hs(),u=u!==null?u:"",u!==null?e=[e,s,r,n,a,u]:(e=null,t=P)):(e=null,t=P)):(e=null,t=P)):(e=null,t=P)):(e=null,t=P)):(e=null,t=P),e!==null&&(e=(function($){try{b.uri=new an(b.scheme,b.user,b.host,b.port,b.uri_params,b.uri_headers),delete b.scheme,delete b.user,delete b.host,delete b.host_type,delete b.port,delete b.uri_params,_==="SIP_URI"&&(b=b.uri)}catch{b=-1}})()),e===null&&(t=m),e}function de(){var e;return e=vs(),e===null&&(e=Ss()),e}function vs(){var e,s;return s=t,i.substr(t,4).toLowerCase()==="sips"?(e=i.substr(t,4),t+=4):(e=null,l('"sips"')),e!==null&&(e=(function(r,n){b.scheme=n.toLowerCase()})(s,e)),e===null&&(t=s),e}function Ss(){var e,s;return s=t,i.substr(t,3).toLowerCase()==="sip"?(e=i.substr(t,3),t+=3):(e=null,l('"sip"')),e!==null&&(e=(function(r,n){b.scheme=n.toLowerCase()})(s,e)),e===null&&(t=s),e}function je(){var e,s,r,n,a,u;return n=t,a=t,e=Es(),e!==null?(u=t,i.charCodeAt(t)===58?(s=":",t++):(s=null,l('":"')),s!==null?(r=As(),r!==null?s=[s,r]:(s=null,t=u)):(s=null,t=u),s=s!==null?s:"",s!==null?(i.charCodeAt(t)===64?(r="@",t++):(r=null,l('"@"')),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(m){b.user=decodeURIComponent(i.substring(t-1,m))})(n)),e===null&&(t=n),e}function Es(){var e,s;if(s=o(),s===null&&(s=T(),s===null&&(s=ht())),s!==null)for(e=[];s!==null;)e.push(s),s=o(),s===null&&(s=T(),s===null&&(s=ht()));else e=null;return e}function ht(){var e;return i.charCodeAt(t)===38?(e="&",t++):(e=null,l('"&"')),e===null&&(i.charCodeAt(t)===61?(e="=",t++):(e=null,l('"="')),e===null&&(i.charCodeAt(t)===43?(e="+",t++):(e=null,l('"+"')),e===null&&(i.charCodeAt(t)===36?(e="$",t++):(e=null,l('"$"')),e===null&&(i.charCodeAt(t)===44?(e=",",t++):(e=null,l('","')),e===null&&(i.charCodeAt(t)===59?(e=";",t++):(e=null,l('";"')),e===null&&(i.charCodeAt(t)===63?(e="?",t++):(e=null,l('"?"')),e===null&&(i.charCodeAt(t)===47?(e="/",t++):(e=null,l('"/"'))))))))),e}function As(){var e,s,r;for(r=t,e=[],s=o(),s===null&&(s=T(),s===null&&(i.charCodeAt(t)===38?(s="&",t++):(s=null,l('"&"')),s===null&&(i.charCodeAt(t)===61?(s="=",t++):(s=null,l('"="')),s===null&&(i.charCodeAt(t)===43?(s="+",t++):(s=null,l('"+"')),s===null&&(i.charCodeAt(t)===36?(s="$",t++):(s=null,l('"$"')),s===null&&(i.charCodeAt(t)===44?(s=",",t++):(s=null,l('","'))))))));s!==null;)e.push(s),s=o(),s===null&&(s=T(),s===null&&(i.charCodeAt(t)===38?(s="&",t++):(s=null,l('"&"')),s===null&&(i.charCodeAt(t)===61?(s="=",t++):(s=null,l('"="')),s===null&&(i.charCodeAt(t)===43?(s="+",t++):(s=null,l('"+"')),s===null&&(i.charCodeAt(t)===36?(s="$",t++):(s=null,l('"$"')),s===null&&(i.charCodeAt(t)===44?(s=",",t++):(s=null,l('","'))))))));return e!==null&&(e=(function(n){b.password=i.substring(t,n)})(r)),e===null&&(t=r),e}function Ke(){var e,s,r,n,a;return n=t,e=Pe(),e!==null?(a=t,i.charCodeAt(t)===58?(s=":",t++):(s=null,l('":"')),s!==null?(r=ys(),r!==null?s=[s,r]:(s=null,t=a)):(s=null,t=a),s=s!==null?s:"",s!==null?e=[e,s]:(e=null,t=n)):(e=null,t=n),e}function Pe(){var e,s;return s=t,e=dt(),e===null&&(e=Le(),e===null&&(e=pt())),e!==null&&(e=(function(r){return b.host=i.substring(t,r).toLowerCase(),b.host})(s)),e===null&&(t=s),e}function dt(){var e,s,r,n,a,u;for(n=t,a=t,e=[],u=t,s=_t(),s!==null?(i.charCodeAt(t)===46?(r=".",t++):(r=null,l('"."')),r!==null?s=[s,r]:(s=null,t=u)):(s=null,t=u);s!==null;)e.push(s),u=t,s=_t(),s!==null?(i.charCodeAt(t)===46?(r=".",t++):(r=null,l('"."')),r!==null?s=[s,r]:(s=null,t=u)):(s=null,t=u);return e!==null?(s=Rs(),s!==null?(i.charCodeAt(t)===46?(r=".",t++):(r=null,l('"."')),r=r!==null?r:"",r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(m){return b.host_type="domain",i.substring(t,m)})(n)),e===null&&(t=n),e}function _t(){var e,s,r,n;if(n=t,e=H(),e!==null){for(s=[],r=H(),r===null&&(i.charCodeAt(t)===45?(r="-",t++):(r=null,l('"-"')),r===null&&(i.charCodeAt(t)===95?(r="_",t++):(r=null,l('"_"'))));r!==null;)s.push(r),r=H(),r===null&&(i.charCodeAt(t)===45?(r="-",t++):(r=null,l('"-"')),r===null&&(i.charCodeAt(t)===95?(r="_",t++):(r=null,l('"_"'))));s!==null?e=[e,s]:(e=null,t=n)}else e=null,t=n;return e}function Rs(){var e,s,r,n;if(n=t,e=R(),e!==null){for(s=[],r=H(),r===null&&(i.charCodeAt(t)===45?(r="-",t++):(r=null,l('"-"')),r===null&&(i.charCodeAt(t)===95?(r="_",t++):(r=null,l('"_"'))));r!==null;)s.push(r),r=H(),r===null&&(i.charCodeAt(t)===45?(r="-",t++):(r=null,l('"-"')),r===null&&(i.charCodeAt(t)===95?(r="_",t++):(r=null,l('"_"'))));s!==null?e=[e,s]:(e=null,t=n)}else e=null,t=n;return e}function pt(){var e,s,r,n,a;return n=t,a=t,i.charCodeAt(t)===91?(e="[",t++):(e=null,l('"["')),e!==null?(s=mt(),s!==null?(i.charCodeAt(t)===93?(r="]",t++):(r=null,l('"]"')),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u){return b.host_type="IPv6",i.substring(t,u)})(n)),e===null&&(t=n),e}function mt(){var e,s,r,n,a,u,m,P,$,W,te,me,at,Lt,L,G;return Lt=t,L=t,e=q(),e!==null?(i.charCodeAt(t)===58?(s=":",t++):(s=null,l('":"')),s!==null?(r=q(),r!==null?(i.charCodeAt(t)===58?(n=":",t++):(n=null,l('":"')),n!==null?(a=q(),a!==null?(i.charCodeAt(t)===58?(u=":",t++):(u=null,l('":"')),u!==null?(m=q(),m!==null?(i.charCodeAt(t)===58?(P=":",t++):(P=null,l('":"')),P!==null?($=q(),$!==null?(i.charCodeAt(t)===58?(W=":",t++):(W=null,l('":"')),W!==null?(te=q(),te!==null?(i.charCodeAt(t)===58?(me=":",t++):(me=null,l('":"')),me!==null?(at=_e(),at!==null?e=[e,s,r,n,a,u,m,P,$,W,te,me,at]:(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L),e===null&&(L=t,i.substr(t,2)==="::"?(e="::",t+=2):(e=null,l('"::"')),e!==null?(s=q(),s!==null?(i.charCodeAt(t)===58?(r=":",t++):(r=null,l('":"')),r!==null?(n=q(),n!==null?(i.charCodeAt(t)===58?(a=":",t++):(a=null,l('":"')),a!==null?(u=q(),u!==null?(i.charCodeAt(t)===58?(m=":",t++):(m=null,l('":"')),m!==null?(P=q(),P!==null?(i.charCodeAt(t)===58?($=":",t++):($=null,l('":"')),$!==null?(W=q(),W!==null?(i.charCodeAt(t)===58?(te=":",t++):(te=null,l('":"')),te!==null?(me=_e(),me!==null?e=[e,s,r,n,a,u,m,P,$,W,te,me]:(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L),e===null&&(L=t,i.substr(t,2)==="::"?(e="::",t+=2):(e=null,l('"::"')),e!==null?(s=q(),s!==null?(i.charCodeAt(t)===58?(r=":",t++):(r=null,l('":"')),r!==null?(n=q(),n!==null?(i.charCodeAt(t)===58?(a=":",t++):(a=null,l('":"')),a!==null?(u=q(),u!==null?(i.charCodeAt(t)===58?(m=":",t++):(m=null,l('":"')),m!==null?(P=q(),P!==null?(i.charCodeAt(t)===58?($=":",t++):($=null,l('":"')),$!==null?(W=_e(),W!==null?e=[e,s,r,n,a,u,m,P,$,W]:(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L),e===null&&(L=t,i.substr(t,2)==="::"?(e="::",t+=2):(e=null,l('"::"')),e!==null?(s=q(),s!==null?(i.charCodeAt(t)===58?(r=":",t++):(r=null,l('":"')),r!==null?(n=q(),n!==null?(i.charCodeAt(t)===58?(a=":",t++):(a=null,l('":"')),a!==null?(u=q(),u!==null?(i.charCodeAt(t)===58?(m=":",t++):(m=null,l('":"')),m!==null?(P=_e(),P!==null?e=[e,s,r,n,a,u,m,P]:(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L),e===null&&(L=t,i.substr(t,2)==="::"?(e="::",t+=2):(e=null,l('"::"')),e!==null?(s=q(),s!==null?(i.charCodeAt(t)===58?(r=":",t++):(r=null,l('":"')),r!==null?(n=q(),n!==null?(i.charCodeAt(t)===58?(a=":",t++):(a=null,l('":"')),a!==null?(u=_e(),u!==null?e=[e,s,r,n,a,u]:(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L),e===null&&(L=t,i.substr(t,2)==="::"?(e="::",t+=2):(e=null,l('"::"')),e!==null?(s=q(),s!==null?(i.charCodeAt(t)===58?(r=":",t++):(r=null,l('":"')),r!==null?(n=_e(),n!==null?e=[e,s,r,n]:(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L),e===null&&(L=t,i.substr(t,2)==="::"?(e="::",t+=2):(e=null,l('"::"')),e!==null?(s=_e(),s!==null?e=[e,s]:(e=null,t=L)):(e=null,t=L),e===null&&(L=t,i.substr(t,2)==="::"?(e="::",t+=2):(e=null,l('"::"')),e!==null?(s=q(),s!==null?e=[e,s]:(e=null,t=L)):(e=null,t=L),e===null&&(L=t,e=q(),e!==null?(i.substr(t,2)==="::"?(s="::",t+=2):(s=null,l('"::"')),s!==null?(r=q(),r!==null?(i.charCodeAt(t)===58?(n=":",t++):(n=null,l('":"')),n!==null?(a=q(),a!==null?(i.charCodeAt(t)===58?(u=":",t++):(u=null,l('":"')),u!==null?(m=q(),m!==null?(i.charCodeAt(t)===58?(P=":",t++):(P=null,l('":"')),P!==null?($=q(),$!==null?(i.charCodeAt(t)===58?(W=":",t++):(W=null,l('":"')),W!==null?(te=_e(),te!==null?e=[e,s,r,n,a,u,m,P,$,W,te]:(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L),e===null&&(L=t,e=q(),e!==null?(G=t,i.charCodeAt(t)===58?(s=":",t++):(s=null,l('":"')),s!==null?(r=q(),r!==null?s=[s,r]:(s=null,t=G)):(s=null,t=G),s=s!==null?s:"",s!==null?(i.substr(t,2)==="::"?(r="::",t+=2):(r=null,l('"::"')),r!==null?(n=q(),n!==null?(i.charCodeAt(t)===58?(a=":",t++):(a=null,l('":"')),a!==null?(u=q(),u!==null?(i.charCodeAt(t)===58?(m=":",t++):(m=null,l('":"')),m!==null?(P=q(),P!==null?(i.charCodeAt(t)===58?($=":",t++):($=null,l('":"')),$!==null?(W=_e(),W!==null?e=[e,s,r,n,a,u,m,P,$,W]:(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L),e===null&&(L=t,e=q(),e!==null?(G=t,i.charCodeAt(t)===58?(s=":",t++):(s=null,l('":"')),s!==null?(r=q(),r!==null?s=[s,r]:(s=null,t=G)):(s=null,t=G),s=s!==null?s:"",s!==null?(G=t,i.charCodeAt(t)===58?(r=":",t++):(r=null,l('":"')),r!==null?(n=q(),n!==null?r=[r,n]:(r=null,t=G)):(r=null,t=G),r=r!==null?r:"",r!==null?(i.substr(t,2)==="::"?(n="::",t+=2):(n=null,l('"::"')),n!==null?(a=q(),a!==null?(i.charCodeAt(t)===58?(u=":",t++):(u=null,l('":"')),u!==null?(m=q(),m!==null?(i.charCodeAt(t)===58?(P=":",t++):(P=null,l('":"')),P!==null?($=_e(),$!==null?e=[e,s,r,n,a,u,m,P,$]:(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L),e===null&&(L=t,e=q(),e!==null?(G=t,i.charCodeAt(t)===58?(s=":",t++):(s=null,l('":"')),s!==null?(r=q(),r!==null?s=[s,r]:(s=null,t=G)):(s=null,t=G),s=s!==null?s:"",s!==null?(G=t,i.charCodeAt(t)===58?(r=":",t++):(r=null,l('":"')),r!==null?(n=q(),n!==null?r=[r,n]:(r=null,t=G)):(r=null,t=G),r=r!==null?r:"",r!==null?(G=t,i.charCodeAt(t)===58?(n=":",t++):(n=null,l('":"')),n!==null?(a=q(),a!==null?n=[n,a]:(n=null,t=G)):(n=null,t=G),n=n!==null?n:"",n!==null?(i.substr(t,2)==="::"?(a="::",t+=2):(a=null,l('"::"')),a!==null?(u=q(),u!==null?(i.charCodeAt(t)===58?(m=":",t++):(m=null,l('":"')),m!==null?(P=_e(),P!==null?e=[e,s,r,n,a,u,m,P]:(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L),e===null&&(L=t,e=q(),e!==null?(G=t,i.charCodeAt(t)===58?(s=":",t++):(s=null,l('":"')),s!==null?(r=q(),r!==null?s=[s,r]:(s=null,t=G)):(s=null,t=G),s=s!==null?s:"",s!==null?(G=t,i.charCodeAt(t)===58?(r=":",t++):(r=null,l('":"')),r!==null?(n=q(),n!==null?r=[r,n]:(r=null,t=G)):(r=null,t=G),r=r!==null?r:"",r!==null?(G=t,i.charCodeAt(t)===58?(n=":",t++):(n=null,l('":"')),n!==null?(a=q(),a!==null?n=[n,a]:(n=null,t=G)):(n=null,t=G),n=n!==null?n:"",n!==null?(G=t,i.charCodeAt(t)===58?(a=":",t++):(a=null,l('":"')),a!==null?(u=q(),u!==null?a=[a,u]:(a=null,t=G)):(a=null,t=G),a=a!==null?a:"",a!==null?(i.substr(t,2)==="::"?(u="::",t+=2):(u=null,l('"::"')),u!==null?(m=_e(),m!==null?e=[e,s,r,n,a,u,m]:(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L),e===null&&(L=t,e=q(),e!==null?(G=t,i.charCodeAt(t)===58?(s=":",t++):(s=null,l('":"')),s!==null?(r=q(),r!==null?s=[s,r]:(s=null,t=G)):(s=null,t=G),s=s!==null?s:"",s!==null?(G=t,i.charCodeAt(t)===58?(r=":",t++):(r=null,l('":"')),r!==null?(n=q(),n!==null?r=[r,n]:(r=null,t=G)):(r=null,t=G),r=r!==null?r:"",r!==null?(G=t,i.charCodeAt(t)===58?(n=":",t++):(n=null,l('":"')),n!==null?(a=q(),a!==null?n=[n,a]:(n=null,t=G)):(n=null,t=G),n=n!==null?n:"",n!==null?(G=t,i.charCodeAt(t)===58?(a=":",t++):(a=null,l('":"')),a!==null?(u=q(),u!==null?a=[a,u]:(a=null,t=G)):(a=null,t=G),a=a!==null?a:"",a!==null?(G=t,i.charCodeAt(t)===58?(u=":",t++):(u=null,l('":"')),u!==null?(m=q(),m!==null?u=[u,m]:(u=null,t=G)):(u=null,t=G),u=u!==null?u:"",u!==null?(i.substr(t,2)==="::"?(m="::",t+=2):(m=null,l('"::"')),m!==null?(P=q(),P!==null?e=[e,s,r,n,a,u,m,P]:(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L),e===null&&(L=t,e=q(),e!==null?(G=t,i.charCodeAt(t)===58?(s=":",t++):(s=null,l('":"')),s!==null?(r=q(),r!==null?s=[s,r]:(s=null,t=G)):(s=null,t=G),s=s!==null?s:"",s!==null?(G=t,i.charCodeAt(t)===58?(r=":",t++):(r=null,l('":"')),r!==null?(n=q(),n!==null?r=[r,n]:(r=null,t=G)):(r=null,t=G),r=r!==null?r:"",r!==null?(G=t,i.charCodeAt(t)===58?(n=":",t++):(n=null,l('":"')),n!==null?(a=q(),a!==null?n=[n,a]:(n=null,t=G)):(n=null,t=G),n=n!==null?n:"",n!==null?(G=t,i.charCodeAt(t)===58?(a=":",t++):(a=null,l('":"')),a!==null?(u=q(),u!==null?a=[a,u]:(a=null,t=G)):(a=null,t=G),a=a!==null?a:"",a!==null?(G=t,i.charCodeAt(t)===58?(u=":",t++):(u=null,l('":"')),u!==null?(m=q(),m!==null?u=[u,m]:(u=null,t=G)):(u=null,t=G),u=u!==null?u:"",u!==null?(G=t,i.charCodeAt(t)===58?(m=":",t++):(m=null,l('":"')),m!==null?(P=q(),P!==null?m=[m,P]:(m=null,t=G)):(m=null,t=G),m=m!==null?m:"",m!==null?(i.substr(t,2)==="::"?(P="::",t+=2):(P=null,l('"::"')),P!==null?e=[e,s,r,n,a,u,m,P]:(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L))))))))))))))),e!==null&&(e=(function(Fl){return b.host_type="IPv6",i.substring(t,Fl)})(Lt)),e===null&&(t=Lt),e}function q(){var e,s,r,n,a;return a=t,e=x(),e!==null?(s=x(),s=s!==null?s:"",s!==null?(r=x(),r=r!==null?r:"",r!==null?(n=x(),n=n!==null?n:"",n!==null?e=[e,s,r,n]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e}function _e(){var e,s,r,n;return n=t,e=q(),e!==null?(i.charCodeAt(t)===58?(s=":",t++):(s=null,l('":"')),s!==null?(r=q(),r!==null?e=[e,s,r]:(e=null,t=n)):(e=null,t=n)):(e=null,t=n),e===null&&(e=Le()),e}function Le(){var e,s,r,n,a,u,m,P,$;return P=t,$=t,e=Me(),e!==null?(i.charCodeAt(t)===46?(s=".",t++):(s=null,l('"."')),s!==null?(r=Me(),r!==null?(i.charCodeAt(t)===46?(n=".",t++):(n=null,l('"."')),n!==null?(a=Me(),a!==null?(i.charCodeAt(t)===46?(u=".",t++):(u=null,l('"."')),u!==null?(m=Me(),m!==null?e=[e,s,r,n,a,u,m]:(e=null,t=$)):(e=null,t=$)):(e=null,t=$)):(e=null,t=$)):(e=null,t=$)):(e=null,t=$)):(e=null,t=$),e!==null&&(e=(function(W){return b.host_type="IPv4",i.substring(t,W)})(P)),e===null&&(t=P),e}function Me(){var e,s,r,n;return n=t,i.substr(t,2)==="25"?(e="25",t+=2):(e=null,l('"25"')),e!==null?(/^[0-5]/.test(i.charAt(t))?(s=i.charAt(t),t++):(s=null,l("[0-5]")),s!==null?e=[e,s]:(e=null,t=n)):(e=null,t=n),e===null&&(n=t,i.charCodeAt(t)===50?(e="2",t++):(e=null,l('"2"')),e!==null?(/^[0-4]/.test(i.charAt(t))?(s=i.charAt(t),t++):(s=null,l("[0-4]")),s!==null?(r=c(),r!==null?e=[e,s,r]:(e=null,t=n)):(e=null,t=n)):(e=null,t=n),e===null&&(n=t,i.charCodeAt(t)===49?(e="1",t++):(e=null,l('"1"')),e!==null?(s=c(),s!==null?(r=c(),r!==null?e=[e,s,r]:(e=null,t=n)):(e=null,t=n)):(e=null,t=n),e===null&&(n=t,/^[1-9]/.test(i.charAt(t))?(e=i.charAt(t),t++):(e=null,l("[1-9]")),e!==null?(s=c(),s!==null?e=[e,s]:(e=null,t=n)):(e=null,t=n),e===null&&(e=c())))),e}function ys(){var e,s,r,n,a,u,m;return u=t,m=t,e=c(),e=e!==null?e:"",e!==null?(s=c(),s=s!==null?s:"",s!==null?(r=c(),r=r!==null?r:"",r!==null?(n=c(),n=n!==null?n:"",n!==null?(a=c(),a=a!==null?a:"",a!==null?e=[e,s,r,n,a]:(e=null,t=m)):(e=null,t=m)):(e=null,t=m)):(e=null,t=m)):(e=null,t=m),e!==null&&(e=(function(P,$){return $=parseInt($.join("")),b.port=$,$})(u,e)),e===null&&(t=u),e}function Is(){var e,s,r,n;for(e=[],n=t,i.charCodeAt(t)===59?(s=";",t++):(s=null,l('";"')),s!==null?(r=gt(),r!==null?s=[s,r]:(s=null,t=n)):(s=null,t=n);s!==null;)e.push(s),n=t,i.charCodeAt(t)===59?(s=";",t++):(s=null,l('";"')),s!==null?(r=gt(),r!==null?s=[s,r]:(s=null,t=n)):(s=null,t=n);return e}function gt(){var e;return e=ws(),e===null&&(e=bs(),e===null&&(e=Ns(),e===null&&(e=Os(),e===null&&(e=Ds(),e===null&&(e=xs(),e===null&&(e=Us())))))),e}function ws(){var e,s,r,n;return r=t,n=t,i.substr(t,10).toLowerCase()==="transport="?(e=i.substr(t,10),t+=10):(e=null,l('"transport="')),e!==null?(i.substr(t,3).toLowerCase()==="udp"?(s=i.substr(t,3),t+=3):(s=null,l('"udp"')),s===null&&(i.substr(t,3).toLowerCase()==="tcp"?(s=i.substr(t,3),t+=3):(s=null,l('"tcp"')),s===null&&(i.substr(t,4).toLowerCase()==="sctp"?(s=i.substr(t,4),t+=4):(s=null,l('"sctp"')),s===null&&(i.substr(t,3).toLowerCase()==="tls"?(s=i.substr(t,3),t+=3):(s=null,l('"tls"')),s===null&&(s=B())))),s!==null?e=[e,s]:(e=null,t=n)):(e=null,t=n),e!==null&&(e=(function(a,u){b.uri_params||(b.uri_params={}),b.uri_params.transport=u.toLowerCase()})(r,e[1])),e===null&&(t=r),e}function bs(){var e,s,r,n;return r=t,n=t,i.substr(t,5).toLowerCase()==="user="?(e=i.substr(t,5),t+=5):(e=null,l('"user="')),e!==null?(i.substr(t,5).toLowerCase()==="phone"?(s=i.substr(t,5),t+=5):(s=null,l('"phone"')),s===null&&(i.substr(t,2).toLowerCase()==="ip"?(s=i.substr(t,2),t+=2):(s=null,l('"ip"')),s===null&&(s=B())),s!==null?e=[e,s]:(e=null,t=n)):(e=null,t=n),e!==null&&(e=(function(a,u){b.uri_params||(b.uri_params={}),b.uri_params.user=u.toLowerCase()})(r,e[1])),e===null&&(t=r),e}function Ns(){var e,s,r,n;return r=t,n=t,i.substr(t,7).toLowerCase()==="method="?(e=i.substr(t,7),t+=7):(e=null,l('"method="')),e!==null?(s=Xe(),s!==null?e=[e,s]:(e=null,t=n)):(e=null,t=n),e!==null&&(e=(function(a,u){b.uri_params||(b.uri_params={}),b.uri_params.method=u})(r,e[1])),e===null&&(t=r),e}function Os(){var e,s,r,n;return r=t,n=t,i.substr(t,4).toLowerCase()==="ttl="?(e=i.substr(t,4),t+=4):(e=null,l('"ttl="')),e!==null?(s=Dt(),s!==null?e=[e,s]:(e=null,t=n)):(e=null,t=n),e!==null&&(e=(function(a,u){b.params||(b.params={}),b.params.ttl=u})(r,e[1])),e===null&&(t=r),e}function Ds(){var e,s,r,n;return r=t,n=t,i.substr(t,6).toLowerCase()==="maddr="?(e=i.substr(t,6),t+=6):(e=null,l('"maddr="')),e!==null?(s=Pe(),s!==null?e=[e,s]:(e=null,t=n)):(e=null,t=n),e!==null&&(e=(function(a,u){b.uri_params||(b.uri_params={}),b.uri_params.maddr=u})(r,e[1])),e===null&&(t=r),e}function xs(){var e,s,r,n,a,u;return n=t,a=t,i.substr(t,2).toLowerCase()==="lr"?(e=i.substr(t,2),t+=2):(e=null,l('"lr"')),e!==null?(u=t,i.charCodeAt(t)===61?(s="=",t++):(s=null,l('"="')),s!==null?(r=B(),r!==null?s=[s,r]:(s=null,t=u)):(s=null,t=u),s=s!==null?s:"",s!==null?e=[e,s]:(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(m){b.uri_params||(b.uri_params={}),b.uri_params.lr=void 0})()),e===null&&(t=n),e}function Us(){var e,s,r,n,a,u;return n=t,a=t,e=Ps(),e!==null?(u=t,i.charCodeAt(t)===61?(s="=",t++):(s=null,l('"="')),s!==null?(r=Ls(),r!==null?s=[s,r]:(s=null,t=u)):(s=null,t=u),s=s!==null?s:"",s!==null?e=[e,s]:(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(m,P,$){b.uri_params||(b.uri_params={}),typeof $>"u"?$=void 0:$=$[1],b.uri_params[P.toLowerCase()]=$})(n,e[0],e[1])),e===null&&(t=n),e}function Ps(){var e,s,r;if(r=t,s=He(),s!==null)for(e=[];s!==null;)e.push(s),s=He();else e=null;return e!==null&&(e=(function(n,a){return a.join("")})(r,e)),e===null&&(t=r),e}function Ls(){var e,s,r;if(r=t,s=He(),s!==null)for(e=[];s!==null;)e.push(s),s=He();else e=null;return e!==null&&(e=(function(n,a){return a.join("")})(r,e)),e===null&&(t=r),e}function He(){var e;return e=Ms(),e===null&&(e=o(),e===null&&(e=T())),e}function Ms(){var e;return i.charCodeAt(t)===91?(e="[",t++):(e=null,l('"["')),e===null&&(i.charCodeAt(t)===93?(e="]",t++):(e=null,l('"]"')),e===null&&(i.charCodeAt(t)===47?(e="/",t++):(e=null,l('"/"')),e===null&&(i.charCodeAt(t)===58?(e=":",t++):(e=null,l('":"')),e===null&&(i.charCodeAt(t)===38?(e="&",t++):(e=null,l('"&"')),e===null&&(i.charCodeAt(t)===43?(e="+",t++):(e=null,l('"+"')),e===null&&(i.charCodeAt(t)===36?(e="$",t++):(e=null,l('"$"')))))))),e}function Hs(){var e,s,r,n,a,u,m;if(u=t,i.charCodeAt(t)===63?(e="?",t++):(e=null,l('"?"')),e!==null)if(s=ze(),s!==null){for(r=[],m=t,i.charCodeAt(t)===38?(n="&",t++):(n=null,l('"&"')),n!==null?(a=ze(),a!==null?n=[n,a]:(n=null,t=m)):(n=null,t=m);n!==null;)r.push(n),m=t,i.charCodeAt(t)===38?(n="&",t++):(n=null,l('"&"')),n!==null?(a=ze(),a!==null?n=[n,a]:(n=null,t=m)):(n=null,t=m);r!==null?e=[e,s,r]:(e=null,t=u)}else e=null,t=u;else e=null,t=u;return e}function ze(){var e,s,r,n,a;return n=t,a=t,e=Fs(),e!==null?(i.charCodeAt(t)===61?(s="=",t++):(s=null,l('"="')),s!==null?(r=$s(),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u,m,P){m=m.join("").toLowerCase(),P=P.join(""),b.uri_headers||(b.uri_headers={}),b.uri_headers[m]?b.uri_headers[m].push(P):b.uri_headers[m]=[P]})(n,e[0],e[2])),e===null&&(t=n),e}function Fs(){var e,s;if(s=Fe(),s===null&&(s=o(),s===null&&(s=T())),s!==null)for(e=[];s!==null;)e.push(s),s=Fe(),s===null&&(s=o(),s===null&&(s=T()));else e=null;return e}function $s(){var e,s;for(e=[],s=Fe(),s===null&&(s=o(),s===null&&(s=T()));s!==null;)e.push(s),s=Fe(),s===null&&(s=o(),s===null&&(s=T()));return e}function Fe(){var e;return i.charCodeAt(t)===91?(e="[",t++):(e=null,l('"["')),e===null&&(i.charCodeAt(t)===93?(e="]",t++):(e=null,l('"]"')),e===null&&(i.charCodeAt(t)===47?(e="/",t++):(e=null,l('"/"')),e===null&&(i.charCodeAt(t)===63?(e="?",t++):(e=null,l('"?"')),e===null&&(i.charCodeAt(t)===58?(e=":",t++):(e=null,l('":"')),e===null&&(i.charCodeAt(t)===43?(e="+",t++):(e=null,l('"+"')),e===null&&(i.charCodeAt(t)===36?(e="$",t++):(e=null,l('"$"')))))))),e}function tl(){var e;return e=ar(),e===null&&(e=ks()),e}function ks(){var e,s,r,n,a,u;return u=t,e=Xe(),e!==null?(s=C(),s!==null?(r=qs(),r!==null?(n=C(),n!==null?(a=vt(),a!==null?e=[e,s,r,n,a]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e}function qs(){var e;return e=Te(),e===null&&(e=Tt()),e}function Tt(){var e,s,r,n;return n=t,e=Ks(),e!==null?(i.charCodeAt(t)===58?(s=":",t++):(s=null,l('":"')),s!==null?(r=Gs(),r===null&&(r=Ws()),r!==null?e=[e,s,r]:(e=null,t=n)):(e=null,t=n)):(e=null,t=n),e}function Gs(){var e,s,r,n,a;return n=t,e=Bs(),e===null&&(e=Ye()),e!==null?(a=t,i.charCodeAt(t)===63?(s="?",t++):(s=null,l('"?"')),s!==null?(r=Xs(),r!==null?s=[s,r]:(s=null,t=a)):(s=null,t=a),s=s!==null?s:"",s!==null?e=[e,s]:(e=null,t=n)):(e=null,t=n),e}function Bs(){var e,s,r,n;return n=t,i.substr(t,2)==="//"?(e="//",t+=2):(e=null,l('"//"')),e!==null?(s=zs(),s!==null?(r=Ye(),r=r!==null?r:"",r!==null?e=[e,s,r]:(e=null,t=n)):(e=null,t=n)):(e=null,t=n),e}function Ye(){var e,s,r;return r=t,i.charCodeAt(t)===47?(e="/",t++):(e=null,l('"/"')),e!==null?(s=js(),s!==null?e=[e,s]:(e=null,t=r)):(e=null,t=r),e}function Ws(){var e,s,r,n;if(n=t,e=Vs(),e!==null){for(s=[],r=$e();r!==null;)s.push(r),r=$e();s!==null?e=[e,s]:(e=null,t=n)}else e=null,t=n;return e}function $e(){var e;return e=F(),e===null&&(e=o(),e===null&&(e=T())),e}function Vs(){var e;return e=o(),e===null&&(e=T(),e===null&&(i.charCodeAt(t)===59?(e=";",t++):(e=null,l('";"')),e===null&&(i.charCodeAt(t)===63?(e="?",t++):(e=null,l('"?"')),e===null&&(i.charCodeAt(t)===58?(e=":",t++):(e=null,l('":"')),e===null&&(i.charCodeAt(t)===64?(e="@",t++):(e=null,l('"@"')),e===null&&(i.charCodeAt(t)===38?(e="&",t++):(e=null,l('"&"')),e===null&&(i.charCodeAt(t)===61?(e="=",t++):(e=null,l('"="')),e===null&&(i.charCodeAt(t)===43?(e="+",t++):(e=null,l('"+"')),e===null&&(i.charCodeAt(t)===36?(e="$",t++):(e=null,l('"$"')),e===null&&(i.charCodeAt(t)===44?(e=",",t++):(e=null,l('","')))))))))))),e}function js(){var e,s,r,n,a,u;if(a=t,e=Je(),e!==null){for(s=[],u=t,i.charCodeAt(t)===47?(r="/",t++):(r=null,l('"/"')),r!==null?(n=Je(),n!==null?r=[r,n]:(r=null,t=u)):(r=null,t=u);r!==null;)s.push(r),u=t,i.charCodeAt(t)===47?(r="/",t++):(r=null,l('"/"')),r!==null?(n=Je(),n!==null?r=[r,n]:(r=null,t=u)):(r=null,t=u);s!==null?e=[e,s]:(e=null,t=a)}else e=null,t=a;return e}function Je(){var e,s,r,n,a,u;for(a=t,e=[],s=ke();s!==null;)e.push(s),s=ke();if(e!==null){for(s=[],u=t,i.charCodeAt(t)===59?(r=";",t++):(r=null,l('";"')),r!==null?(n=Ct(),n!==null?r=[r,n]:(r=null,t=u)):(r=null,t=u);r!==null;)s.push(r),u=t,i.charCodeAt(t)===59?(r=";",t++):(r=null,l('";"')),r!==null?(n=Ct(),n!==null?r=[r,n]:(r=null,t=u)):(r=null,t=u);s!==null?e=[e,s]:(e=null,t=a)}else e=null,t=a;return e}function Ct(){var e,s;for(e=[],s=ke();s!==null;)e.push(s),s=ke();return e}function ke(){var e;return e=o(),e===null&&(e=T(),e===null&&(i.charCodeAt(t)===58?(e=":",t++):(e=null,l('":"')),e===null&&(i.charCodeAt(t)===64?(e="@",t++):(e=null,l('"@"')),e===null&&(i.charCodeAt(t)===38?(e="&",t++):(e=null,l('"&"')),e===null&&(i.charCodeAt(t)===61?(e="=",t++):(e=null,l('"="')),e===null&&(i.charCodeAt(t)===43?(e="+",t++):(e=null,l('"+"')),e===null&&(i.charCodeAt(t)===36?(e="$",t++):(e=null,l('"$"')),e===null&&(i.charCodeAt(t)===44?(e=",",t++):(e=null,l('","')))))))))),e}function Ks(){var e,s,r,n,a;if(n=t,a=t,e=R(),e!==null){for(s=[],r=R(),r===null&&(r=c(),r===null&&(i.charCodeAt(t)===43?(r="+",t++):(r=null,l('"+"')),r===null&&(i.charCodeAt(t)===45?(r="-",t++):(r=null,l('"-"')),r===null&&(i.charCodeAt(t)===46?(r=".",t++):(r=null,l('"."'))))));r!==null;)s.push(r),r=R(),r===null&&(r=c(),r===null&&(i.charCodeAt(t)===43?(r="+",t++):(r=null,l('"+"')),r===null&&(i.charCodeAt(t)===45?(r="-",t++):(r=null,l('"-"')),r===null&&(i.charCodeAt(t)===46?(r=".",t++):(r=null,l('"."'))))));s!==null?e=[e,s]:(e=null,t=a)}else e=null,t=a;return e!==null&&(e=(function(u){b.scheme=i.substring(t,u)})(n)),e===null&&(t=n),e}function zs(){var e;return e=Ys(),e===null&&(e=Js()),e}function Ys(){var e,s,r,n;return r=t,n=t,e=je(),e!==null?(i.charCodeAt(t)===64?(s="@",t++):(s=null,l('"@"')),s!==null?e=[e,s]:(e=null,t=n)):(e=null,t=n),e=e!==null?e:"",e!==null?(s=Ke(),s!==null?e=[e,s]:(e=null,t=r)):(e=null,t=r),e=e!==null?e:"",e}function Js(){var e,s;if(s=o(),s===null&&(s=T(),s===null&&(i.charCodeAt(t)===36?(s="$",t++):(s=null,l('"$"')),s===null&&(i.charCodeAt(t)===44?(s=",",t++):(s=null,l('","')),s===null&&(i.charCodeAt(t)===59?(s=";",t++):(s=null,l('";"')),s===null&&(i.charCodeAt(t)===58?(s=":",t++):(s=null,l('":"')),s===null&&(i.charCodeAt(t)===64?(s="@",t++):(s=null,l('"@"')),s===null&&(i.charCodeAt(t)===38?(s="&",t++):(s=null,l('"&"')),s===null&&(i.charCodeAt(t)===61?(s="=",t++):(s=null,l('"="')),s===null&&(i.charCodeAt(t)===43?(s="+",t++):(s=null,l('"+"'))))))))))),s!==null)for(e=[];s!==null;)e.push(s),s=o(),s===null&&(s=T(),s===null&&(i.charCodeAt(t)===36?(s="$",t++):(s=null,l('"$"')),s===null&&(i.charCodeAt(t)===44?(s=",",t++):(s=null,l('","')),s===null&&(i.charCodeAt(t)===59?(s=";",t++):(s=null,l('";"')),s===null&&(i.charCodeAt(t)===58?(s=":",t++):(s=null,l('":"')),s===null&&(i.charCodeAt(t)===64?(s="@",t++):(s=null,l('"@"')),s===null&&(i.charCodeAt(t)===38?(s="&",t++):(s=null,l('"&"')),s===null&&(i.charCodeAt(t)===61?(s="=",t++):(s=null,l('"="')),s===null&&(i.charCodeAt(t)===43?(s="+",t++):(s=null,l('"+"')))))))))));else e=null;return e}function Xs(){var e,s;for(e=[],s=$e();s!==null;)e.push(s),s=$e();return e}function vt(){var e,s,r,n,a,u,m,P;if(m=t,P=t,i.substr(t,3).toLowerCase()==="sip"?(e=i.substr(t,3),t+=3):(e=null,l('"SIP"')),e!==null)if(i.charCodeAt(t)===47?(s="/",t++):(s=null,l('"/"')),s!==null){if(n=c(),n!==null)for(r=[];n!==null;)r.push(n),n=c();else r=null;if(r!==null)if(i.charCodeAt(t)===46?(n=".",t++):(n=null,l('"."')),n!==null){if(u=c(),u!==null)for(a=[];u!==null;)a.push(u),u=c();else a=null;a!==null?e=[e,s,r,n,a]:(e=null,t=P)}else e=null,t=P;else e=null,t=P}else e=null,t=P;else e=null,t=P;return e!==null&&(e=(function($){b.sip_version=i.substring(t,$)})(m)),e===null&&(t=m),e}function Qs(){var e;return i.substr(t,6)==="INVITE"?(e="INVITE",t+=6):(e=null,l('"INVITE"')),e}function Zs(){var e;return i.substr(t,3)==="ACK"?(e="ACK",t+=3):(e=null,l('"ACK"')),e}function er(){var e;return i.substr(t,7)==="OPTIONS"?(e="OPTIONS",t+=7):(e=null,l('"OPTIONS"')),e}function tr(){var e;return i.substr(t,3)==="BYE"?(e="BYE",t+=3):(e=null,l('"BYE"')),e}function sr(){var e;return i.substr(t,6)==="CANCEL"?(e="CANCEL",t+=6):(e=null,l('"CANCEL"')),e}function rr(){var e;return i.substr(t,8)==="REGISTER"?(e="REGISTER",t+=8):(e=null,l('"REGISTER"')),e}function nr(){var e;return i.substr(t,9)==="SUBSCRIBE"?(e="SUBSCRIBE",t+=9):(e=null,l('"SUBSCRIBE"')),e}function lr(){var e;return i.substr(t,6)==="NOTIFY"?(e="NOTIFY",t+=6):(e=null,l('"NOTIFY"')),e}function ir(){var e;return i.substr(t,5)==="REFER"?(e="REFER",t+=5):(e=null,l('"REFER"')),e}function Xe(){var e,s;return s=t,e=Qs(),e===null&&(e=Zs(),e===null&&(e=er(),e===null&&(e=tr(),e===null&&(e=sr(),e===null&&(e=rr(),e===null&&(e=nr(),e===null&&(e=lr(),e===null&&(e=ir(),e===null&&(e=B()))))))))),e!==null&&(e=(function(r){return b.method=i.substring(t,r),b.method})(s)),e===null&&(t=s),e}function ar(){var e,s,r,n,a,u;return u=t,e=vt(),e!==null?(s=C(),s!==null?(r=or(),r!==null?(n=C(),n!==null?(a=cr(),a!==null?e=[e,s,r,n,a]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e}function or(){var e,s;return s=t,e=ur(),e!==null&&(e=(function(r,n){b.status_code=parseInt(n.join(""))})(s,e)),e===null&&(t=s),e}function ur(){var e,s,r,n;return n=t,e=c(),e!==null?(s=c(),s!==null?(r=c(),r!==null?e=[e,s,r]:(e=null,t=n)):(e=null,t=n)):(e=null,t=n),e}function cr(){var e,s,r;for(r=t,e=[],s=F(),s===null&&(s=o(),s===null&&(s=T(),s===null&&(s=U(),s===null&&(s=M(),s===null&&(s=C(),s===null&&(s=I()))))));s!==null;)e.push(s),s=F(),s===null&&(s=o(),s===null&&(s=T(),s===null&&(s=U(),s===null&&(s=M(),s===null&&(s=C(),s===null&&(s=I()))))));return e!==null&&(e=(function(n){b.reason_phrase=i.substring(t,n)})(r)),e===null&&(t=r),e}function sl(){var e,s,r,n,a,u;if(a=t,e=qe(),e!==null){for(s=[],u=t,r=Q(),r!==null?(n=qe(),n!==null?r=[r,n]:(r=null,t=u)):(r=null,t=u);r!==null;)s.push(r),u=t,r=Q(),r!==null?(n=qe(),n!==null?r=[r,n]:(r=null,t=u)):(r=null,t=u);s!==null?e=[e,s]:(e=null,t=a)}else e=null,t=a;return e}function rl(){var e,s,r,n,a,u;return n=t,a=t,e=ce(),e!==null?(u=t,i.charCodeAt(t)===64?(s="@",t++):(s=null,l('"@"')),s!==null?(r=ce(),r!==null?s=[s,r]:(s=null,t=u)):(s=null,t=u),s=s!==null?s:"",s!==null?e=[e,s]:(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(m){b=i.substring(t,m)})(n)),e===null&&(t=n),e}function nl(){var e,s,r,n,a,u,m;if(a=t,e=Y(),e===null)if(u=t,e=Qe(),e!==null){for(s=[],m=t,r=Q(),r!==null?(n=Qe(),n!==null?r=[r,n]:(r=null,t=m)):(r=null,t=m);r!==null;)s.push(r),m=t,r=Q(),r!==null?(n=Qe(),n!==null?r=[r,n]:(r=null,t=m)):(r=null,t=m);s!==null?e=[e,s]:(e=null,t=u)}else e=null,t=u;return e!==null&&(e=(function(P){var $,W;for(W=b.multi_header.length,$=0;$<W;$++)if(b.multi_header[$].parsed===null){b=null;break}b!==null?b=b.multi_header:b=-1})()),e===null&&(t=a),e}function Qe(){var e,s,r,n,a,u,m;if(a=t,u=t,e=Z(),e===null&&(e=Oe()),e!==null){for(s=[],m=t,r=z(),r!==null?(n=St(),n!==null?r=[r,n]:(r=null,t=m)):(r=null,t=m);r!==null;)s.push(r),m=t,r=z(),r!==null?(n=St(),n!==null?r=[r,n]:(r=null,t=m)):(r=null,t=m);s!==null?e=[e,s]:(e=null,t=u)}else e=null,t=u;return e!==null&&(e=(function(P){var $;b.multi_header||(b.multi_header=[]);try{$=new Ue(b.uri,b.display_name,b.params),delete b.uri,delete b.display_name,delete b.params}catch{$=null}b.multi_header.push({possition:t,offset:P,parsed:$})})(a)),e===null&&(t=a),e}function Oe(){var e,s,r,n,a;return a=t,e=Ze(),e=e!==null?e:"",e!==null?(s=Ee(),s!==null?(r=Te(),r!==null?(n=Se(),n!==null?e=[e,s,r,n]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e}function Ze(){var e,s,r,n,a,u,m;if(a=t,u=t,e=B(),e!==null){for(s=[],m=t,r=p(),r!==null?(n=B(),n!==null?r=[r,n]:(r=null,t=m)):(r=null,t=m);r!==null;)s.push(r),m=t,r=p(),r!==null?(n=B(),n!==null?r=[r,n]:(r=null,t=m)):(r=null,t=m);s!==null?e=[e,s]:(e=null,t=u)}else e=null,t=u;return e===null&&(e=X()),e!==null&&(e=(function(P,$){typeof $=="string"?b.display_name=$:b.display_name=$[1].reduce(function(W,te){return W+te[0]+te[1]},$[0])})(a,e)),e===null&&(t=a),e}function St(){var e;return e=fr(),e===null&&(e=hr(),e===null&&(e=le())),e}function fr(){var e,s,r,n,a;return n=t,a=t,i.substr(t,1).toLowerCase()==="q"?(e=i.substr(t,1),t++):(e=null,l('"q"')),e!==null?(s=J(),s!==null?(r=dr(),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u,m){b.params||(b.params={}),b.params.q=m})(n,e[2])),e===null&&(t=n),e}function hr(){var e,s,r,n,a;return n=t,a=t,i.substr(t,7).toLowerCase()==="expires"?(e=i.substr(t,7),t+=7):(e=null,l('"expires"')),e!==null?(s=J(),s!==null?(r=De(),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u,m){b.params||(b.params={}),b.params.expires=m})(n,e[2])),e===null&&(t=n),e}function De(){var e,s,r;if(r=t,s=c(),s!==null)for(e=[];s!==null;)e.push(s),s=c();else e=null;return e!==null&&(e=(function(n,a){return parseInt(a.join(""))})(r,e)),e===null&&(t=r),e}function dr(){var e,s,r,n,a,u,m,P;return u=t,m=t,i.charCodeAt(t)===48?(e="0",t++):(e=null,l('"0"')),e!==null?(P=t,i.charCodeAt(t)===46?(s=".",t++):(s=null,l('"."')),s!==null?(r=c(),r=r!==null?r:"",r!==null?(n=c(),n=n!==null?n:"",n!==null?(a=c(),a=a!==null?a:"",a!==null?s=[s,r,n,a]:(s=null,t=P)):(s=null,t=P)):(s=null,t=P)):(s=null,t=P),s=s!==null?s:"",s!==null?e=[e,s]:(e=null,t=m)):(e=null,t=m),e!==null&&(e=(function($){return parseFloat(i.substring(t,$))})(u)),e===null&&(t=u),e}function le(){var e,s,r,n,a,u;return n=t,a=t,e=B(),e!==null?(u=t,s=J(),s!==null?(r=_r(),r!==null?s=[s,r]:(s=null,t=u)):(s=null,t=u),s=s!==null?s:"",s!==null?e=[e,s]:(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(m,P,$){b.params||(b.params={}),typeof $>"u"?$=void 0:$=$[1],b.params[P.toLowerCase()]=$})(n,e[0],e[1])),e===null&&(t=n),e}function _r(){var e;return e=B(),e===null&&(e=Pe(),e===null&&(e=K())),e}function ll(){var e,s,r,n,a,u;if(a=t,e=pr(),e!==null){for(s=[],u=t,r=z(),r!==null?(n=Et(),n!==null?r=[r,n]:(r=null,t=u)):(r=null,t=u);r!==null;)s.push(r),u=t,r=z(),r!==null?(n=Et(),n!==null?r=[r,n]:(r=null,t=u)):(r=null,t=u);s!==null?e=[e,s]:(e=null,t=a)}else e=null,t=a;return e}function pr(){var e;return i.substr(t,6).toLowerCase()==="render"?(e=i.substr(t,6),t+=6):(e=null,l('"render"')),e===null&&(i.substr(t,7).toLowerCase()==="session"?(e=i.substr(t,7),t+=7):(e=null,l('"session"')),e===null&&(i.substr(t,4).toLowerCase()==="icon"?(e=i.substr(t,4),t+=4):(e=null,l('"icon"')),e===null&&(i.substr(t,5).toLowerCase()==="alert"?(e=i.substr(t,5),t+=5):(e=null,l('"alert"')),e===null&&(e=B())))),e}function Et(){var e;return e=mr(),e===null&&(e=le()),e}function mr(){var e,s,r,n;return n=t,i.substr(t,8).toLowerCase()==="handling"?(e=i.substr(t,8),t+=8):(e=null,l('"handling"')),e!==null?(s=J(),s!==null?(i.substr(t,8).toLowerCase()==="optional"?(r=i.substr(t,8),t+=8):(r=null,l('"optional"')),r===null&&(i.substr(t,8).toLowerCase()==="required"?(r=i.substr(t,8),t+=8):(r=null,l('"required"')),r===null&&(r=B())),r!==null?e=[e,s,r]:(e=null,t=n)):(e=null,t=n)):(e=null,t=n),e}function il(){var e,s,r,n,a,u;if(a=t,e=B(),e!==null){for(s=[],u=t,r=Q(),r!==null?(n=B(),n!==null?r=[r,n]:(r=null,t=u)):(r=null,t=u);r!==null;)s.push(r),u=t,r=Q(),r!==null?(n=B(),n!==null?r=[r,n]:(r=null,t=u)):(r=null,t=u);s!==null?e=[e,s]:(e=null,t=a)}else e=null,t=a;return e}function al(){var e,s,r;if(r=t,s=c(),s!==null)for(e=[];s!==null;)e.push(s),s=c();else e=null;return e!==null&&(e=(function(n,a){b=parseInt(a.join(""))})(r,e)),e===null&&(t=r),e}function ol(){var e,s;return s=t,e=gr(),e!==null&&(e=(function(r){b=i.substring(t,r)})(s)),e===null&&(t=s),e}function gr(){var e,s,r,n,a,u,m,P;if(m=t,e=Tr(),e!==null)if(s=he(),s!==null)if(r=Er(),r!==null){for(n=[],P=t,a=z(),a!==null?(u=At(),u!==null?a=[a,u]:(a=null,t=P)):(a=null,t=P);a!==null;)n.push(a),P=t,a=z(),a!==null?(u=At(),u!==null?a=[a,u]:(a=null,t=P)):(a=null,t=P);n!==null?e=[e,s,r,n]:(e=null,t=m)}else e=null,t=m;else e=null,t=m;else e=null,t=m;return e}function Tr(){var e;return e=Cr(),e===null&&(e=vr()),e}function Cr(){var e;return i.substr(t,4).toLowerCase()==="text"?(e=i.substr(t,4),t+=4):(e=null,l('"text"')),e===null&&(i.substr(t,5).toLowerCase()==="image"?(e=i.substr(t,5),t+=5):(e=null,l('"image"')),e===null&&(i.substr(t,5).toLowerCase()==="audio"?(e=i.substr(t,5),t+=5):(e=null,l('"audio"')),e===null&&(i.substr(t,5).toLowerCase()==="video"?(e=i.substr(t,5),t+=5):(e=null,l('"video"')),e===null&&(i.substr(t,11).toLowerCase()==="application"?(e=i.substr(t,11),t+=11):(e=null,l('"application"')),e===null&&(e=et()))))),e}function vr(){var e;return i.substr(t,7).toLowerCase()==="message"?(e=i.substr(t,7),t+=7):(e=null,l('"message"')),e===null&&(i.substr(t,9).toLowerCase()==="multipart"?(e=i.substr(t,9),t+=9):(e=null,l('"multipart"')),e===null&&(e=et())),e}function et(){var e;return e=B(),e===null&&(e=Sr()),e}function Sr(){var e,s,r;return r=t,i.substr(t,2).toLowerCase()==="x-"?(e=i.substr(t,2),t+=2):(e=null,l('"x-"')),e!==null?(s=B(),s!==null?e=[e,s]:(e=null,t=r)):(e=null,t=r),e}function Er(){var e;return e=et(),e===null&&(e=B()),e}function At(){var e,s,r,n;return n=t,e=B(),e!==null?(s=J(),s!==null?(r=Ar(),r!==null?e=[e,s,r]:(e=null,t=n)):(e=null,t=n)):(e=null,t=n),e}function Ar(){var e;return e=B(),e===null&&(e=K()),e}function ul(){var e,s,r,n;return n=t,e=Rr(),e!==null?(s=p(),s!==null?(r=Xe(),r!==null?e=[e,s,r]:(e=null,t=n)):(e=null,t=n)):(e=null,t=n),e}function Rr(){var e,s,r;if(r=t,s=c(),s!==null)for(e=[];s!==null;)e.push(s),s=c();else e=null;return e!==null&&(e=(function(n,a){b.value=parseInt(a.join(""))})(r,e)),e===null&&(t=r),e}function cl(){var e,s;return s=t,e=De(),e!==null&&(e=(function(r,n){b=n})(s,e)),e===null&&(t=s),e}function fl(){var e,s,r,n,a,u,m;if(a=t,u=t,e=qe(),e!==null){for(s=[],m=t,r=z(),r!==null?(n=le(),n!==null?r=[r,n]:(r=null,t=m)):(r=null,t=m);r!==null;)s.push(r),m=t,r=z(),r!==null?(n=le(),n!==null?r=[r,n]:(r=null,t=m)):(r=null,t=m);s!==null?e=[e,s]:(e=null,t=u)}else e=null,t=u;return e!==null&&(e=(function(P,$){b.event=$.join("").toLowerCase()})(a,e[0])),e===null&&(t=a),e}function qe(){var e,s,r,n,a,u;if(a=t,e=ae(),e!==null){for(s=[],u=t,i.charCodeAt(t)===46?(r=".",t++):(r=null,l('"."')),r!==null?(n=ae(),n!==null?r=[r,n]:(r=null,t=u)):(r=null,t=u);r!==null;)s.push(r),u=t,i.charCodeAt(t)===46?(r=".",t++):(r=null,l('"."')),r!==null?(n=ae(),n!==null?r=[r,n]:(r=null,t=u)):(r=null,t=u);s!==null?e=[e,s]:(e=null,t=a)}else e=null,t=a;return e}function hl(){var e,s,r,n,a,u,m;if(a=t,u=t,e=Z(),e===null&&(e=Oe()),e!==null){for(s=[],m=t,r=z(),r!==null?(n=Rt(),n!==null?r=[r,n]:(r=null,t=m)):(r=null,t=m);r!==null;)s.push(r),m=t,r=z(),r!==null?(n=Rt(),n!==null?r=[r,n]:(r=null,t=m)):(r=null,t=m);s!==null?e=[e,s]:(e=null,t=u)}else e=null,t=u;return e!==null&&(e=(function(P){var $=b.tag;try{b=new Ue(b.uri,b.display_name,b.params),$&&b.setParam("tag",$)}catch{b=-1}})()),e===null&&(t=a),e}function Rt(){var e;return e=yt(),e===null&&(e=le()),e}function yt(){var e,s,r,n,a;return n=t,a=t,i.substr(t,3).toLowerCase()==="tag"?(e=i.substr(t,3),t+=3):(e=null,l('"tag"')),e!==null?(s=J(),s!==null?(r=B(),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u,m){b.tag=m})(n,e[2])),e===null&&(t=n),e}function dl(){var e,s,r;if(r=t,s=c(),s!==null)for(e=[];s!==null;)e.push(s),s=c();else e=null;return e!==null&&(e=(function(n,a){b=parseInt(a.join(""))})(r,e)),e===null&&(t=r),e}function _l(){var e,s;return s=t,e=De(),e!==null&&(e=(function(r,n){b=n})(s,e)),e===null&&(t=s),e}function pl(){var e,s,r,n,a,u,m,P,$,W;for(P=t,$=t,e=[],s=Ze();s!==null;)e.push(s),s=Ze();if(e!==null)if(s=Ee(),s!==null)if(r=Te(),r!==null)if(n=Se(),n!==null){for(a=[],W=t,u=z(),u!==null?(m=le(),m!==null?u=[u,m]:(u=null,t=W)):(u=null,t=W);u!==null;)a.push(u),W=t,u=z(),u!==null?(m=le(),m!==null?u=[u,m]:(u=null,t=W)):(u=null,t=W);a!==null?e=[e,s,r,n,a]:(e=null,t=$)}else e=null,t=$;else e=null,t=$;else e=null,t=$;else e=null,t=$;return e!==null&&(e=(function(te){try{b=new Ue(b.uri,b.display_name,b.params)}catch{b=-1}})()),e===null&&(t=P),e}function ml(){var e;return e=It(),e}function It(){var e,s,r,n,a,u,m,P;if(m=t,i.substr(t,6).toLowerCase()==="digest"?(e=i.substr(t,6),t+=6):(e=null,l('"Digest"')),e!==null)if(s=p(),s!==null)if(r=tt(),r!==null){for(n=[],P=t,a=Q(),a!==null?(u=tt(),u!==null?a=[a,u]:(a=null,t=P)):(a=null,t=P);a!==null;)n.push(a),P=t,a=Q(),a!==null?(u=tt(),u!==null?a=[a,u]:(a=null,t=P)):(a=null,t=P);n!==null?e=[e,s,r,n]:(e=null,t=m)}else e=null,t=m;else e=null,t=m;else e=null,t=m;return e===null&&(e=yr()),e}function yr(){var e,s,r,n,a,u,m,P;if(m=t,e=B(),e!==null)if(s=p(),s!==null)if(r=Ge(),r!==null){for(n=[],P=t,a=Q(),a!==null?(u=Ge(),u!==null?a=[a,u]:(a=null,t=P)):(a=null,t=P);a!==null;)n.push(a),P=t,a=Q(),a!==null?(u=Ge(),u!==null?a=[a,u]:(a=null,t=P)):(a=null,t=P);n!==null?e=[e,s,r,n]:(e=null,t=m)}else e=null,t=m;else e=null,t=m;else e=null,t=m;return e}function Ge(){var e,s,r,n;return n=t,e=B(),e!==null?(s=J(),s!==null?(r=B(),r===null&&(r=K()),r!==null?e=[e,s,r]:(e=null,t=n)):(e=null,t=n)):(e=null,t=n),e}function tt(){var e;return e=Ir(),e===null&&(e=br(),e===null&&(e=Nr(),e===null&&(e=Dr(),e===null&&(e=xr(),e===null&&(e=Ur(),e===null&&(e=Pr(),e===null&&(e=Ge()))))))),e}function Ir(){var e,s,r,n;return n=t,i.substr(t,5).toLowerCase()==="realm"?(e=i.substr(t,5),t+=5):(e=null,l('"realm"')),e!==null?(s=J(),s!==null?(r=wr(),r!==null?e=[e,s,r]:(e=null,t=n)):(e=null,t=n)):(e=null,t=n),e}function wr(){var e,s;return s=t,e=X(),e!==null&&(e=(function(r,n){b.realm=n})(s,e)),e===null&&(t=s),e}function br(){var e,s,r,n,a,u,m,P,$;if(P=t,i.substr(t,6).toLowerCase()==="domain"?(e=i.substr(t,6),t+=6):(e=null,l('"domain"')),e!==null)if(s=J(),s!==null)if(r=Ae(),r!==null)if(n=st(),n!==null){if(a=[],$=t,m=C(),m!==null)for(u=[];m!==null;)u.push(m),m=C();else u=null;for(u!==null?(m=st(),m!==null?u=[u,m]:(u=null,t=$)):(u=null,t=$);u!==null;){if(a.push(u),$=t,m=C(),m!==null)for(u=[];m!==null;)u.push(m),m=C();else u=null;u!==null?(m=st(),m!==null?u=[u,m]:(u=null,t=$)):(u=null,t=$)}a!==null?(u=Ve(),u!==null?e=[e,s,r,n,a,u]:(e=null,t=P)):(e=null,t=P)}else e=null,t=P;else e=null,t=P;else e=null,t=P;else e=null,t=P;return e}function st(){var e;return e=Tt(),e===null&&(e=Ye()),e}function Nr(){var e,s,r,n;return n=t,i.substr(t,5).toLowerCase()==="nonce"?(e=i.substr(t,5),t+=5):(e=null,l('"nonce"')),e!==null?(s=J(),s!==null?(r=Or(),r!==null?e=[e,s,r]:(e=null,t=n)):(e=null,t=n)):(e=null,t=n),e}function Or(){var e,s;return s=t,e=X(),e!==null&&(e=(function(r,n){b.nonce=n})(s,e)),e===null&&(t=s),e}function Dr(){var e,s,r,n,a;return n=t,a=t,i.substr(t,6).toLowerCase()==="opaque"?(e=i.substr(t,6),t+=6):(e=null,l('"opaque"')),e!==null?(s=J(),s!==null?(r=X(),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u,m){b.opaque=m})(n,e[2])),e===null&&(t=n),e}function xr(){var e,s,r,n,a;return n=t,i.substr(t,5).toLowerCase()==="stale"?(e=i.substr(t,5),t+=5):(e=null,l('"stale"')),e!==null?(s=J(),s!==null?(a=t,i.substr(t,4).toLowerCase()==="true"?(r=i.substr(t,4),t+=4):(r=null,l('"true"')),r!==null&&(r=(function(u){b.stale=!0})()),r===null&&(t=a),r===null&&(a=t,i.substr(t,5).toLowerCase()==="false"?(r=i.substr(t,5),t+=5):(r=null,l('"false"')),r!==null&&(r=(function(u){b.stale=!1})()),r===null&&(t=a)),r!==null?e=[e,s,r]:(e=null,t=n)):(e=null,t=n)):(e=null,t=n),e}function Ur(){var e,s,r,n,a;return n=t,a=t,i.substr(t,9).toLowerCase()==="algorithm"?(e=i.substr(t,9),t+=9):(e=null,l('"algorithm"')),e!==null?(s=J(),s!==null?(i.substr(t,3).toLowerCase()==="md5"?(r=i.substr(t,3),t+=3):(r=null,l('"MD5"')),r===null&&(i.substr(t,8).toLowerCase()==="md5-sess"?(r=i.substr(t,8),t+=8):(r=null,l('"MD5-sess"')),r===null&&(r=B())),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u,m){b.algorithm=m.toUpperCase()})(n,e[2])),e===null&&(t=n),e}function Pr(){var e,s,r,n,a,u,m,P,$,W;if(P=t,i.substr(t,3).toLowerCase()==="qop"?(e=i.substr(t,3),t+=3):(e=null,l('"qop"')),e!==null)if(s=J(),s!==null)if(r=Ae(),r!==null){if($=t,n=rt(),n!==null){for(a=[],W=t,i.charCodeAt(t)===44?(u=",",t++):(u=null,l('","')),u!==null?(m=rt(),m!==null?u=[u,m]:(u=null,t=W)):(u=null,t=W);u!==null;)a.push(u),W=t,i.charCodeAt(t)===44?(u=",",t++):(u=null,l('","')),u!==null?(m=rt(),m!==null?u=[u,m]:(u=null,t=W)):(u=null,t=W);a!==null?n=[n,a]:(n=null,t=$)}else n=null,t=$;n!==null?(a=Ve(),a!==null?e=[e,s,r,n,a]:(e=null,t=P)):(e=null,t=P)}else e=null,t=P;else e=null,t=P;else e=null,t=P;return e}function rt(){var e,s;return s=t,i.substr(t,8).toLowerCase()==="auth-int"?(e=i.substr(t,8),t+=8):(e=null,l('"auth-int"')),e===null&&(i.substr(t,4).toLowerCase()==="auth"?(e=i.substr(t,4),t+=4):(e=null,l('"auth"')),e===null&&(e=B())),e!==null&&(e=(function(r,n){b.qop||(b.qop=[]),b.qop.push(n.toLowerCase())})(s,e)),e===null&&(t=s),e}function gl(){var e,s,r,n,a,u;if(a=t,e=B(),e!==null){for(s=[],u=t,r=Q(),r!==null?(n=B(),n!==null?r=[r,n]:(r=null,t=u)):(r=null,t=u);r!==null;)s.push(r),u=t,r=Q(),r!==null?(n=B(),n!==null?r=[r,n]:(r=null,t=u)):(r=null,t=u);s!==null?e=[e,s]:(e=null,t=a)}else e=null,t=a;return e}function Tl(){var e,s,r,n,a,u,m;if(a=t,u=t,e=nt(),e!==null){for(s=[],m=t,r=Q(),r!==null?(n=nt(),n!==null?r=[r,n]:(r=null,t=m)):(r=null,t=m);r!==null;)s.push(r),m=t,r=Q(),r!==null?(n=nt(),n!==null?r=[r,n]:(r=null,t=m)):(r=null,t=m);s!==null?e=[e,s]:(e=null,t=u)}else e=null,t=u;return e!==null&&(e=(function(P){var $,W;for(W=b.multi_header.length,$=0;$<W;$++)if(b.multi_header[$].parsed===null){b=null;break}b!==null?b=b.multi_header:b=-1})()),e===null&&(t=a),e}function nt(){var e,s,r,n,a,u,m;if(a=t,u=t,e=Oe(),e!==null){for(s=[],m=t,r=z(),r!==null?(n=le(),n!==null?r=[r,n]:(r=null,t=m)):(r=null,t=m);r!==null;)s.push(r),m=t,r=z(),r!==null?(n=le(),n!==null?r=[r,n]:(r=null,t=m)):(r=null,t=m);s!==null?e=[e,s]:(e=null,t=u)}else e=null,t=u;return e!==null&&(e=(function(P){var $;b.multi_header||(b.multi_header=[]);try{$=new Ue(b.uri,b.display_name,b.params),delete b.uri,delete b.display_name,delete b.params}catch{$=null}b.multi_header.push({possition:t,offset:P,parsed:$})})(a)),e===null&&(t=a),e}function Cl(){var e,s,r,n,a,u,m;if(a=t,u=t,i.substr(t,3).toLowerCase()==="sip"?(e=i.substr(t,3),t+=3):(e=null,l('"SIP"')),e===null&&(e=B()),e!==null){for(s=[],m=t,r=z(),r!==null?(n=wt(),n!==null?r=[r,n]:(r=null,t=m)):(r=null,t=m);r!==null;)s.push(r),m=t,r=z(),r!==null?(n=wt(),n!==null?r=[r,n]:(r=null,t=m)):(r=null,t=m);s!==null?e=[e,s]:(e=null,t=u)}else e=null,t=u;return e!==null&&(e=(function(P,$){if(b.protocol=$.toLowerCase(),b.params||(b.params={}),b.params.text&&b.params.text[0]==='"'){var W=b.params.text;b.text=W.substring(1,W.length-1),delete b.params.text}})(a,e[0])),e===null&&(t=a),e}function wt(){var e;return e=Lr(),e===null&&(e=le()),e}function Lr(){var e,s,r,n,a,u;if(a=t,u=t,i.substr(t,5).toLowerCase()==="cause"?(e=i.substr(t,5),t+=5):(e=null,l('"cause"')),e!==null)if(s=J(),s!==null){if(n=c(),n!==null)for(r=[];n!==null;)r.push(n),n=c();else r=null;r!==null?e=[e,s,r]:(e=null,t=u)}else e=null,t=u;else e=null,t=u;return e!==null&&(e=(function(m,P){b.cause=parseInt(P.join(""))})(a,e[2])),e===null&&(t=a),e}function vl(){var e,s,r,n,a,u;if(a=t,e=B(),e!==null){for(s=[],u=t,r=Q(),r!==null?(n=B(),n!==null?r=[r,n]:(r=null,t=u)):(r=null,t=u);r!==null;)s.push(r),u=t,r=Q(),r!==null?(n=B(),n!==null?r=[r,n]:(r=null,t=u)):(r=null,t=u);s!==null?e=[e,s]:(e=null,t=a)}else e=null,t=a;return e}function Sl(){var e,s,r,n,a,u;if(a=t,e=lt(),e!==null){for(s=[],u=t,r=Q(),r!==null?(n=lt(),n!==null?r=[r,n]:(r=null,t=u)):(r=null,t=u);r!==null;)s.push(r),u=t,r=Q(),r!==null?(n=lt(),n!==null?r=[r,n]:(r=null,t=u)):(r=null,t=u);s!==null?e=[e,s]:(e=null,t=a)}else e=null,t=a;return e}function lt(){var e,s,r,n,a,u;if(a=t,e=Oe(),e!==null){for(s=[],u=t,r=z(),r!==null?(n=le(),n!==null?r=[r,n]:(r=null,t=u)):(r=null,t=u);r!==null;)s.push(r),u=t,r=z(),r!==null?(n=le(),n!==null?r=[r,n]:(r=null,t=u)):(r=null,t=u);s!==null?e=[e,s]:(e=null,t=a)}else e=null,t=a;return e}function El(){var e,s,r,n,a,u;if(a=t,e=Mr(),e!==null){for(s=[],u=t,r=z(),r!==null?(n=bt(),n!==null?r=[r,n]:(r=null,t=u)):(r=null,t=u);r!==null;)s.push(r),u=t,r=z(),r!==null?(n=bt(),n!==null?r=[r,n]:(r=null,t=u)):(r=null,t=u);s!==null?e=[e,s]:(e=null,t=a)}else e=null,t=a;return e}function Mr(){var e,s;return s=t,i.substr(t,6).toLowerCase()==="active"?(e=i.substr(t,6),t+=6):(e=null,l('"active"')),e===null&&(i.substr(t,7).toLowerCase()==="pending"?(e=i.substr(t,7),t+=7):(e=null,l('"pending"')),e===null&&(i.substr(t,10).toLowerCase()==="terminated"?(e=i.substr(t,10),t+=10):(e=null,l('"terminated"')),e===null&&(e=B()))),e!==null&&(e=(function(r){b.state=i.substring(t,r)})(s)),e===null&&(t=s),e}function bt(){var e,s,r,n,a;return n=t,a=t,i.substr(t,6).toLowerCase()==="reason"?(e=i.substr(t,6),t+=6):(e=null,l('"reason"')),e!==null?(s=J(),s!==null?(r=Hr(),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u,m){typeof m<"u"&&(b.reason=m)})(n,e[2])),e===null&&(t=n),e===null&&(n=t,a=t,i.substr(t,7).toLowerCase()==="expires"?(e=i.substr(t,7),t+=7):(e=null,l('"expires"')),e!==null?(s=J(),s!==null?(r=De(),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u,m){typeof m<"u"&&(b.expires=m)})(n,e[2])),e===null&&(t=n),e===null&&(n=t,a=t,i.substr(t,11).toLowerCase()==="retry_after"?(e=i.substr(t,11),t+=11):(e=null,l('"retry_after"')),e!==null?(s=J(),s!==null?(r=De(),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u,m){typeof m<"u"&&(b.retry_after=m)})(n,e[2])),e===null&&(t=n),e===null&&(e=le()))),e}function Hr(){var e;return i.substr(t,11).toLowerCase()==="deactivated"?(e=i.substr(t,11),t+=11):(e=null,l('"deactivated"')),e===null&&(i.substr(t,9).toLowerCase()==="probation"?(e=i.substr(t,9),t+=9):(e=null,l('"probation"')),e===null&&(i.substr(t,8).toLowerCase()==="rejected"?(e=i.substr(t,8),t+=8):(e=null,l('"rejected"')),e===null&&(i.substr(t,7).toLowerCase()==="timeout"?(e=i.substr(t,7),t+=7):(e=null,l('"timeout"')),e===null&&(i.substr(t,6).toLowerCase()==="giveup"?(e=i.substr(t,6),t+=6):(e=null,l('"giveup"')),e===null&&(i.substr(t,10).toLowerCase()==="noresource"?(e=i.substr(t,10),t+=10):(e=null,l('"noresource"')),e===null&&(i.substr(t,9).toLowerCase()==="invariant"?(e=i.substr(t,9),t+=9):(e=null,l('"invariant"')),e===null&&(e=B()))))))),e}function Al(){var e;return e=v(),e=e!==null?e:"",e}function Rl(){var e,s,r,n,a,u;if(a=t,e=B(),e!==null){for(s=[],u=t,r=Q(),r!==null?(n=B(),n!==null?r=[r,n]:(r=null,t=u)):(r=null,t=u);r!==null;)s.push(r),u=t,r=Q(),r!==null?(n=B(),n!==null?r=[r,n]:(r=null,t=u)):(r=null,t=u);s!==null?e=[e,s]:(e=null,t=a)}else e=null,t=a;return e=e!==null?e:"",e}function yl(){var e,s,r,n,a,u,m;if(a=t,u=t,e=Z(),e===null&&(e=Oe()),e!==null){for(s=[],m=t,r=z(),r!==null?(n=Nt(),n!==null?r=[r,n]:(r=null,t=m)):(r=null,t=m);r!==null;)s.push(r),m=t,r=z(),r!==null?(n=Nt(),n!==null?r=[r,n]:(r=null,t=m)):(r=null,t=m);s!==null?e=[e,s]:(e=null,t=u)}else e=null,t=u;return e!==null&&(e=(function(P){var $=b.tag;try{b=new Ue(b.uri,b.display_name,b.params),$&&b.setParam("tag",$)}catch{b=-1}})()),e===null&&(t=a),e}function Nt(){var e;return e=yt(),e===null&&(e=le()),e}function Il(){var e,s,r,n,a,u;if(a=t,e=it(),e!==null){for(s=[],u=t,r=Q(),r!==null?(n=it(),n!==null?r=[r,n]:(r=null,t=u)):(r=null,t=u);r!==null;)s.push(r),u=t,r=Q(),r!==null?(n=it(),n!==null?r=[r,n]:(r=null,t=u)):(r=null,t=u);s!==null?e=[e,s]:(e=null,t=a)}else e=null,t=a;return e}function it(){var e,s,r,n,a,u,m,P;if(m=t,e=Wr(),e!==null)if(s=p(),s!==null)if(r=Kr(),r!==null){for(n=[],P=t,a=z(),a!==null?(u=Ot(),u!==null?a=[a,u]:(a=null,t=P)):(a=null,t=P);a!==null;)n.push(a),P=t,a=z(),a!==null?(u=Ot(),u!==null?a=[a,u]:(a=null,t=P)):(a=null,t=P);n!==null?e=[e,s,r,n]:(e=null,t=m)}else e=null,t=m;else e=null,t=m;else e=null,t=m;return e}function Ot(){var e;return e=Fr(),e===null&&(e=$r(),e===null&&(e=kr(),e===null&&(e=qr(),e===null&&(e=Gr(),e===null&&(e=le()))))),e}function Fr(){var e,s,r,n,a;return n=t,a=t,i.substr(t,3).toLowerCase()==="ttl"?(e=i.substr(t,3),t+=3):(e=null,l('"ttl"')),e!==null?(s=J(),s!==null?(r=Dt(),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u,m){b.ttl=m})(n,e[2])),e===null&&(t=n),e}function $r(){var e,s,r,n,a;return n=t,a=t,i.substr(t,5).toLowerCase()==="maddr"?(e=i.substr(t,5),t+=5):(e=null,l('"maddr"')),e!==null?(s=J(),s!==null?(r=Pe(),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u,m){b.maddr=m})(n,e[2])),e===null&&(t=n),e}function kr(){var e,s,r,n,a;return n=t,a=t,i.substr(t,8).toLowerCase()==="received"?(e=i.substr(t,8),t+=8):(e=null,l('"received"')),e!==null?(s=J(),s!==null?(r=Le(),r===null&&(r=mt()),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u,m){b.received=m})(n,e[2])),e===null&&(t=n),e}function qr(){var e,s,r,n,a;return n=t,a=t,i.substr(t,6).toLowerCase()==="branch"?(e=i.substr(t,6),t+=6):(e=null,l('"branch"')),e!==null?(s=J(),s!==null?(r=B(),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u,m){b.branch=m})(n,e[2])),e===null&&(t=n),e}function Gr(){var e,s,r,n,a;return n=t,i.substr(t,5).toLowerCase()==="rport"?(e=i.substr(t,5),t+=5):(e=null,l('"rport"')),e!==null?(a=t,s=J(),s!==null?(r=Br(),r!==null?s=[s,r]:(s=null,t=a)):(s=null,t=a),s=s!==null?s:"",s!==null?e=[e,s]:(e=null,t=n)):(e=null,t=n),e}function Br(){var e,s,r,n,a,u,m;return u=t,m=t,e=c(),e=e!==null?e:"",e!==null?(s=c(),s=s!==null?s:"",s!==null?(r=c(),r=r!==null?r:"",r!==null?(n=c(),n=n!==null?n:"",n!==null?(a=c(),a=a!==null?a:"",a!==null?e=[e,s,r,n,a]:(e=null,t=m)):(e=null,t=m)):(e=null,t=m)):(e=null,t=m)):(e=null,t=m),e!==null&&(e=(function(P,$){b.rport=parseInt($.join(""))})(u,e)),e===null&&(t=u),e}function Wr(){var e,s,r,n,a,u;return u=t,e=Vr(),e!==null?(s=he(),s!==null?(r=B(),r!==null?(n=he(),n!==null?(a=jr(),a!==null?e=[e,s,r,n,a]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e}function Vr(){var e,s;return s=t,i.substr(t,3).toLowerCase()==="sip"?(e=i.substr(t,3),t+=3):(e=null,l('"SIP"')),e===null&&(e=B()),e!==null&&(e=(function(r,n){b.protocol=n})(s,e)),e===null&&(t=s),e}function jr(){var e,s;return s=t,i.substr(t,3).toLowerCase()==="udp"?(e=i.substr(t,3),t+=3):(e=null,l('"UDP"')),e===null&&(i.substr(t,3).toLowerCase()==="tcp"?(e=i.substr(t,3),t+=3):(e=null,l('"TCP"')),e===null&&(i.substr(t,3).toLowerCase()==="tls"?(e=i.substr(t,3),t+=3):(e=null,l('"TLS"')),e===null&&(i.substr(t,4).toLowerCase()==="sctp"?(e=i.substr(t,4),t+=4):(e=null,l('"SCTP"')),e===null&&(e=B())))),e!==null&&(e=(function(r,n){b.transport=n})(s,e)),e===null&&(t=s),e}function Kr(){var e,s,r,n,a;return n=t,e=zr(),e!==null?(a=t,s=Ne(),s!==null?(r=Yr(),r!==null?s=[s,r]:(s=null,t=a)):(s=null,t=a),s=s!==null?s:"",s!==null?e=[e,s]:(e=null,t=n)):(e=null,t=n),e}function zr(){var e,s;return s=t,e=Le(),e===null&&(e=pt(),e===null&&(e=dt())),e!==null&&(e=(function(r){b.host=i.substring(t,r)})(s)),e===null&&(t=s),e}function Yr(){var e,s,r,n,a,u,m;return u=t,m=t,e=c(),e=e!==null?e:"",e!==null?(s=c(),s=s!==null?s:"",s!==null?(r=c(),r=r!==null?r:"",r!==null?(n=c(),n=n!==null?n:"",n!==null?(a=c(),a=a!==null?a:"",a!==null?e=[e,s,r,n,a]:(e=null,t=m)):(e=null,t=m)):(e=null,t=m)):(e=null,t=m)):(e=null,t=m),e!==null&&(e=(function(P,$){b.port=parseInt($.join(""))})(u,e)),e===null&&(t=u),e}function Dt(){var e,s,r,n,a;return n=t,a=t,e=c(),e!==null?(s=c(),s=s!==null?s:"",s!==null?(r=c(),r=r!==null?r:"",r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u,m){return parseInt(m.join(""))})(n,e)),e===null&&(t=n),e}function wl(){var e;return e=It(),e}function bl(){var e,s,r,n,a,u;if(a=t,e=Jr(),e!==null){for(s=[],u=t,r=z(),r!==null?(n=xt(),n!==null?r=[r,n]:(r=null,t=u)):(r=null,t=u);r!==null;)s.push(r),u=t,r=z(),r!==null?(n=xt(),n!==null?r=[r,n]:(r=null,t=u)):(r=null,t=u);s!==null?e=[e,s]:(e=null,t=a)}else e=null,t=a;return e}function Jr(){var e,s;return s=t,e=De(),e!==null&&(e=(function(r,n){b.expires=n})(s,e)),e===null&&(t=s),e}function xt(){var e;return e=Xr(),e===null&&(e=le()),e}function Xr(){var e,s,r,n,a;return n=t,a=t,i.substr(t,9).toLowerCase()==="refresher"?(e=i.substr(t,9),t+=9):(e=null,l('"refresher"')),e!==null?(s=J(),s!==null?(i.substr(t,3).toLowerCase()==="uac"?(r=i.substr(t,3),t+=3):(r=null,l('"uac"')),r===null&&(i.substr(t,3).toLowerCase()==="uas"?(r=i.substr(t,3),t+=3):(r=null,l('"uas"'))),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u,m){b.refresher=m.toLowerCase()})(n,e[2])),e===null&&(t=n),e}function Nl(){var e,s,r,n;return n=t,e=B(),e!==null?(s=D(),s!==null?(r=Qr(),r!==null?e=[e,s,r]:(e=null,t=n)):(e=null,t=n)):(e=null,t=n),e}function Qr(){var e,s;for(e=[],s=w(),s===null&&(s=M(),s===null&&(s=p()));s!==null;)e.push(s),s=w(),s===null&&(s=M(),s===null&&(s=p()));return e}function Ol(){var e,s;for(e=[],s=N();s!==null;)e.push(s),s=N();return e}function Dl(){var e,s,r;return r=t,i.substr(t,5)==="uuid:"?(e="uuid:",t+=5):(e=null,l('"uuid:"')),e!==null?(s=Zr(),s!==null?e=[e,s]:(e=null,t=r)):(e=null,t=r),e}function Zr(){var e,s,r,n,a,u,m,P,$,W,te;return W=t,te=t,e=en(),e!==null?(i.charCodeAt(t)===45?(s="-",t++):(s=null,l('"-"')),s!==null?(r=Ce(),r!==null?(i.charCodeAt(t)===45?(n="-",t++):(n=null,l('"-"')),n!==null?(a=Ce(),a!==null?(i.charCodeAt(t)===45?(u="-",t++):(u=null,l('"-"')),u!==null?(m=Ce(),m!==null?(i.charCodeAt(t)===45?(P="-",t++):(P=null,l('"-"')),P!==null?($=tn(),$!==null?e=[e,s,r,n,a,u,m,P,$]:(e=null,t=te)):(e=null,t=te)):(e=null,t=te)):(e=null,t=te)):(e=null,t=te)):(e=null,t=te)):(e=null,t=te)):(e=null,t=te)):(e=null,t=te),e!==null&&(e=(function(me,at){b=i.substring(t+5,me)})(W,e[0])),e===null&&(t=W),e}function Ce(){var e,s,r,n,a;return a=t,e=x(),e!==null?(s=x(),s!==null?(r=x(),r!==null?(n=x(),n!==null?e=[e,s,r,n]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e}function en(){var e,s,r;return r=t,e=Ce(),e!==null?(s=Ce(),s!==null?e=[e,s]:(e=null,t=r)):(e=null,t=r),e}function tn(){var e,s,r,n;return n=t,e=Ce(),e!==null?(s=Ce(),s!==null?(r=Ce(),r!==null?e=[e,s,r]:(e=null,t=n)):(e=null,t=n)):(e=null,t=n),e}function xl(){var e,s,r,n,a,u,m;if(a=t,u=t,e=Z(),e===null&&(e=Oe()),e!==null){for(s=[],m=t,r=z(),r!==null?(n=le(),n!==null?r=[r,n]:(r=null,t=m)):(r=null,t=m);r!==null;)s.push(r),m=t,r=z(),r!==null?(n=le(),n!==null?r=[r,n]:(r=null,t=m)):(r=null,t=m);s!==null?e=[e,s]:(e=null,t=u)}else e=null,t=u;return e!==null&&(e=(function(P){try{b=new Ue(b.uri,b.display_name,b.params)}catch{b=-1}})()),e===null&&(t=a),e}function Ul(){var e,s,r,n,a,u;if(a=t,e=sn(),e!==null){for(s=[],u=t,r=z(),r!==null?(n=Ut(),n!==null?r=[r,n]:(r=null,t=u)):(r=null,t=u);r!==null;)s.push(r),u=t,r=z(),r!==null?(n=Ut(),n!==null?r=[r,n]:(r=null,t=u)):(r=null,t=u);s!==null?e=[e,s]:(e=null,t=a)}else e=null,t=a;return e}function sn(){var e,s,r,n,a,u;return n=t,a=t,e=ce(),e!==null?(u=t,i.charCodeAt(t)===64?(s="@",t++):(s=null,l('"@"')),s!==null?(r=ce(),r!==null?s=[s,r]:(s=null,t=u)):(s=null,t=u),s=s!==null?s:"",s!==null?e=[e,s]:(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(m){b.call_id=i.substring(t,m)})(n)),e===null&&(t=n),e}function Ut(){var e;return e=rn(),e===null&&(e=nn(),e===null&&(e=ln(),e===null&&(e=le()))),e}function rn(){var e,s,r,n,a;return n=t,a=t,i.substr(t,6)==="to-tag"?(e="to-tag",t+=6):(e=null,l('"to-tag"')),e!==null?(s=J(),s!==null?(r=B(),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u,m){b.to_tag=m})(n,e[2])),e===null&&(t=n),e}function nn(){var e,s,r,n,a;return n=t,a=t,i.substr(t,8)==="from-tag"?(e="from-tag",t+=8):(e=null,l('"from-tag"')),e!==null?(s=J(),s!==null?(r=B(),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u,m){b.from_tag=m})(n,e[2])),e===null&&(t=n),e}function ln(){var e,s;return s=t,i.substr(t,10)==="early-only"?(e="early-only",t+=10):(e=null,l('"early-only"')),e!==null&&(e=(function(r){b.early_only=!0})()),e===null&&(t=s),e}function Pl(e){e.sort();for(var s=null,r=[],n=0;n<e.length;n++)e[n]!==s&&(r.push(e[n]),s=e[n]);return r}function Ll(){for(var e=1,s=1,r=!1,n=0;n<Math.max(t,h);n++){var a=i.charAt(n);a===`
|
|
4
|
+
`?(r||e++,s=1,r=!1):a==="\r"||a==="\u2028"||a==="\u2029"?(e++,s=1,r=!0):(s++,r=!1)}return{line:e,column:s}}var an=ye(),Ue=Ts(),b={},Ml=E[_]();if(Ml===null||t!==i.length){var Pt=Math.max(t,h),Hl=Pt<i.length?i.charAt(Pt):null,on=Ll();return new this.SyntaxError(Pl(d),Hl,Pt,on.line,on.column),-1}return b},toSource:function(){return this._source}};return y.SyntaxError=function(i,_,E,t,h){function d(l,g){var c,R;switch(l.length){case 0:c="end of input";break;case 1:c=l[0];break;default:c=l.slice(0,l.length-1).join(", ")+" or "+l[l.length-1]}return R=g?O(g):"end of input","Expected "+c+" but "+R+" found."}this.name="SyntaxError",this.expected=i,this.found=_,this.message=d(i,_),this.offset=E,this.line=t,this.column=h},y.SyntaxError.prototype=Error.prototype,y})()),$t}var kt,dn;function ye(){if(dn)return kt;dn=1;const O=ie(),y=ue(),i=ge();return kt=class Jn{static parse(E){if(E=i.parse(E,"SIP_URI"),E!==-1)return E}constructor(E,t,h,d,l={},g={}){if(!h)throw new TypeError('missing or invalid "host" parameter');this._parameters={},this._headers={},this._scheme=E||O.SIP,this._user=t,this._host=h,this._port=d;for(const c in l)Object.prototype.hasOwnProperty.call(l,c)&&this.setParam(c,l[c]);for(const c in g)Object.prototype.hasOwnProperty.call(g,c)&&this.setHeader(c,g[c])}get scheme(){return this._scheme}set scheme(E){this._scheme=E.toLowerCase()}get user(){return this._user}set user(E){this._user=E}get host(){return this._host}set host(E){this._host=E.toLowerCase()}get port(){return this._port}set port(E){this._port=E===0?E:parseInt(E,10)||null}setParam(E,t){E&&(this._parameters[E.toLowerCase()]=typeof t>"u"||t===null?null:t.toString())}getParam(E){if(E)return this._parameters[E.toLowerCase()]}hasParam(E){if(E)return this._parameters.hasOwnProperty(E.toLowerCase())&&!0||!1}deleteParam(E){if(E=E.toLowerCase(),this._parameters.hasOwnProperty(E)){const t=this._parameters[E];return delete this._parameters[E],t}}clearParams(){this._parameters={}}setHeader(E,t){this._headers[y.headerize(E)]=Array.isArray(t)?t:[t]}getHeader(E){if(E)return this._headers[y.headerize(E)]}hasHeader(E){if(E)return this._headers.hasOwnProperty(y.headerize(E))&&!0||!1}deleteHeader(E){if(E=y.headerize(E),this._headers.hasOwnProperty(E)){const t=this._headers[E];return delete this._headers[E],t}}clearHeaders(){this._headers={}}clone(){return new Jn(this._scheme,this._user,this._host,this._port,JSON.parse(JSON.stringify(this._parameters)),JSON.parse(JSON.stringify(this._headers)))}toString(){const E=[];let t=`${this._scheme}:`;this._user&&(t+=`${y.escapeUser(this._user)}@`),t+=this._host,(this._port||this._port===0)&&(t+=`:${this._port}`);for(const h in this._parameters)Object.prototype.hasOwnProperty.call(this._parameters,h)&&(t+=`;${h}`,this._parameters[h]!==null&&(t+=`=${this._parameters[h]}`));for(const h in this._headers)if(Object.prototype.hasOwnProperty.call(this._headers,h))for(const d of this._headers[h])E.push(`${h}=${d}`);return E.length>0&&(t+=`?${E.join("&")}`),t}toAor(E){let t=`${this._scheme}:`;return this._user&&(t+=`${y.escapeUser(this._user)}@`),t+=this._host,E&&(this._port||this._port===0)&&(t+=`:${this._port}`),t}},kt}var _n;function ue(){if(_n)return ne;_n=1;const O=ie(),y=ye(),i=ge();ne.str_utf8_length=h=>unescape(encodeURIComponent(h)).length;const _=ne.isFunction=h=>h!==void 0?Object.prototype.toString.call(h)==="[object Function]":!1;ne.isString=h=>h!==void 0?Object.prototype.toString.call(h)==="[object String]":!1,ne.isDecimal=h=>!isNaN(h)&&parseFloat(h)===parseInt(h,10),ne.isEmpty=h=>h===null||h===""||h===void 0||Array.isArray(h)&&h.length===0||typeof h=="number"&&isNaN(h),ne.hasMethods=function(h,...d){for(const l of d)if(_(h[l]))return!1;return!0};const E=ne.createRandomToken=(h,d=32)=>{let l,g,c="";for(l=0;l<h;l++)g=Math.random()*d|0,c+=g.toString(d);return c};ne.newTag=()=>E(10),ne.newUUID=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,d=>{const l=Math.random()*16|0;return(d==="x"?l:l&3|8).toString(16)}),ne.hostType=h=>{if(h){if(h=i.parse(h,"host"),h!==-1)return h.host_type}else return};const t=ne.escapeUser=h=>encodeURIComponent(decodeURIComponent(h)).replace(/%3A/ig,":").replace(/%2B/ig,"+").replace(/%3F/ig,"?").replace(/%2F/ig,"/");return ne.normalizeTarget=(h,d)=>{if(h){if(h instanceof y)return h;if(typeof h=="string"){const l=h.split("@");let g,c;switch(l.length){case 1:if(!d)return;g=h,c=d;break;case 2:g=l[0],c=l[1];break;default:g=l.slice(0,l.length-1).join("@"),c=l[l.length-1]}g=g.replace(/^(sips?|tel):/i,""),/^[-.()]*\+?[0-9\-.()]+$/.test(g)&&(g=g.replace(/[-.()]/g,"")),h=`${O.SIP}:${t(g)}@${c}`;let R;return(R=y.parse(h))?R:void 0}else return}else return},ne.headerize=h=>{const d={"Call-Id":"Call-ID",Cseq:"CSeq","Www-Authenticate":"WWW-Authenticate"},l=h.toLowerCase().replace(/_/g,"-").split("-");let g="";const c=l.length;let R;for(R=0;R<c;R++)R!==0&&(g+="-"),g+=l[R].charAt(0).toUpperCase()+l[R].substring(1);return d[g]&&(g=d[g]),g},ne.sipErrorCause=h=>{for(const d in O.SIP_ERROR_CAUSES)if(O.SIP_ERROR_CAUSES[d].indexOf(h)!==-1)return O.causes[d];return O.causes.SIP_FAILURE_CODE},ne.getRandomTestNetIP=()=>{function h(d,l){return Math.floor(Math.random()*(l-d+1)+d)}return`192.0.2.${h(1,254)}`},ne.calculateMD5=h=>{function d(j,V){return j<<V|j>>>32-V}function l(j,V){const K=j&2147483648,X=V&2147483648,se=j&1073741824,re=V&1073741824,Z=(j&1073741823)+(V&1073741823);return se&re?Z^2147483648^K^X:se|re?Z&1073741824?Z^3221225472^K^X:Z^1073741824^K^X:Z^K^X}function g(j,V,K){return j&V|~j&K}function c(j,V,K){return j&K|V&~K}function R(j,V,K){return j^V^K}function x(j,V,K){return V^(j|~K)}function S(j,V,K,X,se,re,Z){return j=l(j,l(l(g(V,K,X),se),Z)),l(d(j,re),V)}function N(j,V,K,X,se,re,Z){return j=l(j,l(l(c(V,K,X),se),Z)),l(d(j,re),V)}function k(j,V,K,X,se,re,Z){return j=l(j,l(l(R(V,K,X),se),Z)),l(d(j,re),V)}function C(j,V,K,X,se,re,Z){return j=l(j,l(l(x(V,K,X),se),Z)),l(d(j,re),V)}function I(j){let V;const K=j.length,X=K+8,re=((X-X%64)/64+1)*16,Z=new Array(re-1);let Te=0,de=0;for(;de<K;)V=(de-de%4)/4,Te=de%4*8,Z[V]=Z[V]|j.charCodeAt(de)<<Te,de++;return V=(de-de%4)/4,Te=de%4*8,Z[V]=Z[V]|128<<Te,Z[re-2]=K<<3,Z[re-1]=K>>>29,Z}function H(j){let V="",K="",X,se;for(se=0;se<=3;se++)X=j>>>se*8&255,K=`0${X.toString(16)}`,V=V+K.substr(K.length-2,2);return V}function F(j){let V="";for(let K=0;K<j.length;K++){const X=j.charCodeAt(K);X<128?V+=String.fromCharCode(X):X>127&&X<2048?(V+=String.fromCharCode(X>>6|192),V+=String.fromCharCode(X&63|128)):(V+=String.fromCharCode(X>>12|224),V+=String.fromCharCode(X>>6&63|128),V+=String.fromCharCode(X&63|128))}return V}let o=[],f,T,p,A,D,v,w,U,M;const ee=7,B=12,ae=17,fe=22,ce=5,Y=9,he=14,J=20,we=4,be=11,Se=16,Ee=23,Q=6,z=10,Ne=15,Ae=21;for(h=F(h),o=I(h),v=1732584193,w=4023233417,U=2562383102,M=271733878,f=0;f<o.length;f+=16)T=v,p=w,A=U,D=M,v=S(v,w,U,M,o[f+0],ee,3614090360),M=S(M,v,w,U,o[f+1],B,3905402710),U=S(U,M,v,w,o[f+2],ae,606105819),w=S(w,U,M,v,o[f+3],fe,3250441966),v=S(v,w,U,M,o[f+4],ee,4118548399),M=S(M,v,w,U,o[f+5],B,1200080426),U=S(U,M,v,w,o[f+6],ae,2821735955),w=S(w,U,M,v,o[f+7],fe,4249261313),v=S(v,w,U,M,o[f+8],ee,1770035416),M=S(M,v,w,U,o[f+9],B,2336552879),U=S(U,M,v,w,o[f+10],ae,4294925233),w=S(w,U,M,v,o[f+11],fe,2304563134),v=S(v,w,U,M,o[f+12],ee,1804603682),M=S(M,v,w,U,o[f+13],B,4254626195),U=S(U,M,v,w,o[f+14],ae,2792965006),w=S(w,U,M,v,o[f+15],fe,1236535329),v=N(v,w,U,M,o[f+1],ce,4129170786),M=N(M,v,w,U,o[f+6],Y,3225465664),U=N(U,M,v,w,o[f+11],he,643717713),w=N(w,U,M,v,o[f+0],J,3921069994),v=N(v,w,U,M,o[f+5],ce,3593408605),M=N(M,v,w,U,o[f+10],Y,38016083),U=N(U,M,v,w,o[f+15],he,3634488961),w=N(w,U,M,v,o[f+4],J,3889429448),v=N(v,w,U,M,o[f+9],ce,568446438),M=N(M,v,w,U,o[f+14],Y,3275163606),U=N(U,M,v,w,o[f+3],he,4107603335),w=N(w,U,M,v,o[f+8],J,1163531501),v=N(v,w,U,M,o[f+13],ce,2850285829),M=N(M,v,w,U,o[f+2],Y,4243563512),U=N(U,M,v,w,o[f+7],he,1735328473),w=N(w,U,M,v,o[f+12],J,2368359562),v=k(v,w,U,M,o[f+5],we,4294588738),M=k(M,v,w,U,o[f+8],be,2272392833),U=k(U,M,v,w,o[f+11],Se,1839030562),w=k(w,U,M,v,o[f+14],Ee,4259657740),v=k(v,w,U,M,o[f+1],we,2763975236),M=k(M,v,w,U,o[f+4],be,1272893353),U=k(U,M,v,w,o[f+7],Se,4139469664),w=k(w,U,M,v,o[f+10],Ee,3200236656),v=k(v,w,U,M,o[f+13],we,681279174),M=k(M,v,w,U,o[f+0],be,3936430074),U=k(U,M,v,w,o[f+3],Se,3572445317),w=k(w,U,M,v,o[f+6],Ee,76029189),v=k(v,w,U,M,o[f+9],we,3654602809),M=k(M,v,w,U,o[f+12],be,3873151461),U=k(U,M,v,w,o[f+15],Se,530742520),w=k(w,U,M,v,o[f+2],Ee,3299628645),v=C(v,w,U,M,o[f+0],Q,4096336452),M=C(M,v,w,U,o[f+7],z,1126891415),U=C(U,M,v,w,o[f+14],Ne,2878612391),w=C(w,U,M,v,o[f+5],Ae,4237533241),v=C(v,w,U,M,o[f+12],Q,1700485571),M=C(M,v,w,U,o[f+3],z,2399980690),U=C(U,M,v,w,o[f+10],Ne,4293915773),w=C(w,U,M,v,o[f+1],Ae,2240044497),v=C(v,w,U,M,o[f+8],Q,1873313359),M=C(M,v,w,U,o[f+15],z,4264355552),U=C(U,M,v,w,o[f+6],Ne,2734768916),w=C(w,U,M,v,o[f+13],Ae,1309151649),v=C(v,w,U,M,o[f+4],Q,4149444226),M=C(M,v,w,U,o[f+11],z,3174756917),U=C(U,M,v,w,o[f+2],Ne,718787259),w=C(w,U,M,v,o[f+9],Ae,3951481745),v=l(v,T),w=l(w,p),U=l(U,A),M=l(M,D);return(H(v)+H(w)+H(U)+H(M)).toLowerCase()},ne.closeMediaStream=h=>{if(h)try{let d;if(h.getTracks){d=h.getTracks();for(const l of d)l.stop()}else{d=h.getAudioTracks();for(const l of d)l.stop();d=h.getVideoTracks();for(const l of d)l.stop()}}catch{(typeof h.stop=="function"||typeof h.stop=="object")&&h.stop()}},ne.cloneArray=h=>h&&h.slice()||[],ne.cloneObject=(h,d={})=>h&&Object.assign({},h)||d,ne}var ot={exports:{}},pn;function Ie(){if(pn)return ot.exports;pn=1;var O=typeof Reflect=="object"?Reflect:null,y=O&&typeof O.apply=="function"?O.apply:function(f,T,p){return Function.prototype.apply.call(f,T,p)},i;O&&typeof O.ownKeys=="function"?i=O.ownKeys:Object.getOwnPropertySymbols?i=function(f){return Object.getOwnPropertyNames(f).concat(Object.getOwnPropertySymbols(f))}:i=function(f){return Object.getOwnPropertyNames(f)};function _(o){console&&console.warn&&console.warn(o)}var E=Number.isNaN||function(f){return f!==f};function t(){t.init.call(this)}ot.exports=t,ot.exports.once=I,t.EventEmitter=t,t.prototype._events=void 0,t.prototype._eventsCount=0,t.prototype._maxListeners=void 0;var h=10;function d(o){if(typeof o!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof o)}Object.defineProperty(t,"defaultMaxListeners",{enumerable:!0,get:function(){return h},set:function(o){if(typeof o!="number"||o<0||E(o))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+o+".");h=o}}),t.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},t.prototype.setMaxListeners=function(f){if(typeof f!="number"||f<0||E(f))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+f+".");return this._maxListeners=f,this};function l(o){return o._maxListeners===void 0?t.defaultMaxListeners:o._maxListeners}t.prototype.getMaxListeners=function(){return l(this)},t.prototype.emit=function(f){for(var T=[],p=1;p<arguments.length;p++)T.push(arguments[p]);var A=f==="error",D=this._events;if(D!==void 0)A=A&&D.error===void 0;else if(!A)return!1;if(A){var v;if(T.length>0&&(v=T[0]),v instanceof Error)throw v;var w=new Error("Unhandled error."+(v?" ("+v.message+")":""));throw w.context=v,w}var U=D[f];if(U===void 0)return!1;if(typeof U=="function")y(U,this,T);else for(var M=U.length,ee=N(U,M),p=0;p<M;++p)y(ee[p],this,T);return!0};function g(o,f,T,p){var A,D,v;if(d(T),D=o._events,D===void 0?(D=o._events=Object.create(null),o._eventsCount=0):(D.newListener!==void 0&&(o.emit("newListener",f,T.listener?T.listener:T),D=o._events),v=D[f]),v===void 0)v=D[f]=T,++o._eventsCount;else if(typeof v=="function"?v=D[f]=p?[T,v]:[v,T]:p?v.unshift(T):v.push(T),A=l(o),A>0&&v.length>A&&!v.warned){v.warned=!0;var w=new Error("Possible EventEmitter memory leak detected. "+v.length+" "+String(f)+" listeners added. Use emitter.setMaxListeners() to increase limit");w.name="MaxListenersExceededWarning",w.emitter=o,w.type=f,w.count=v.length,_(w)}return o}t.prototype.addListener=function(f,T){return g(this,f,T,!1)},t.prototype.on=t.prototype.addListener,t.prototype.prependListener=function(f,T){return g(this,f,T,!0)};function c(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function R(o,f,T){var p={fired:!1,wrapFn:void 0,target:o,type:f,listener:T},A=c.bind(p);return A.listener=T,p.wrapFn=A,A}t.prototype.once=function(f,T){return d(T),this.on(f,R(this,f,T)),this},t.prototype.prependOnceListener=function(f,T){return d(T),this.prependListener(f,R(this,f,T)),this},t.prototype.removeListener=function(f,T){var p,A,D,v,w;if(d(T),A=this._events,A===void 0)return this;if(p=A[f],p===void 0)return this;if(p===T||p.listener===T)--this._eventsCount===0?this._events=Object.create(null):(delete A[f],A.removeListener&&this.emit("removeListener",f,p.listener||T));else if(typeof p!="function"){for(D=-1,v=p.length-1;v>=0;v--)if(p[v]===T||p[v].listener===T){w=p[v].listener,D=v;break}if(D<0)return this;D===0?p.shift():k(p,D),p.length===1&&(A[f]=p[0]),A.removeListener!==void 0&&this.emit("removeListener",f,w||T)}return this},t.prototype.off=t.prototype.removeListener,t.prototype.removeAllListeners=function(f){var T,p,A;if(p=this._events,p===void 0)return this;if(p.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):p[f]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete p[f]),this;if(arguments.length===0){var D=Object.keys(p),v;for(A=0;A<D.length;++A)v=D[A],v!=="removeListener"&&this.removeAllListeners(v);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(T=p[f],typeof T=="function")this.removeListener(f,T);else if(T!==void 0)for(A=T.length-1;A>=0;A--)this.removeListener(f,T[A]);return this};function x(o,f,T){var p=o._events;if(p===void 0)return[];var A=p[f];return A===void 0?[]:typeof A=="function"?T?[A.listener||A]:[A]:T?C(A):N(A,A.length)}t.prototype.listeners=function(f){return x(this,f,!0)},t.prototype.rawListeners=function(f){return x(this,f,!1)},t.listenerCount=function(o,f){return typeof o.listenerCount=="function"?o.listenerCount(f):S.call(o,f)},t.prototype.listenerCount=S;function S(o){var f=this._events;if(f!==void 0){var T=f[o];if(typeof T=="function")return 1;if(T!==void 0)return T.length}return 0}t.prototype.eventNames=function(){return this._eventsCount>0?i(this._events):[]};function N(o,f){for(var T=new Array(f),p=0;p<f;++p)T[p]=o[p];return T}function k(o,f){for(;f+1<o.length;f++)o[f]=o[f+1];o.pop()}function C(o){for(var f=new Array(o.length),T=0;T<f.length;++T)f[T]=o[T].listener||o[T];return f}function I(o,f){return new Promise(function(T,p){function A(v){o.removeListener(f,D),p(v)}function D(){typeof o.removeListener=="function"&&o.removeListener("error",A),T([].slice.call(arguments))}F(o,f,D,{once:!0}),f!=="error"&&H(o,A,{once:!0})})}function H(o,f,T){typeof o.on=="function"&&F(o,"error",f,T)}function F(o,f,T,p){if(typeof o.on=="function")p.once?o.once(f,T):o.on(f,T);else if(typeof o.addEventListener=="function")o.addEventListener(f,function A(D){p.once&&o.removeEventListener(f,A),T(D)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof o)}return ot.exports}var ut={exports:{}},qt,mn;function Vl(){if(mn)return qt;mn=1;var O=1e3,y=O*60,i=y*60,_=i*24,E=_*7,t=_*365.25;qt=function(c,R){R=R||{};var x=typeof c;if(x==="string"&&c.length>0)return h(c);if(x==="number"&&isFinite(c))return R.long?l(c):d(c);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(c))};function h(c){if(c=String(c),!(c.length>100)){var R=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(c);if(R){var x=parseFloat(R[1]),S=(R[2]||"ms").toLowerCase();switch(S){case"years":case"year":case"yrs":case"yr":case"y":return x*t;case"weeks":case"week":case"w":return x*E;case"days":case"day":case"d":return x*_;case"hours":case"hour":case"hrs":case"hr":case"h":return x*i;case"minutes":case"minute":case"mins":case"min":case"m":return x*y;case"seconds":case"second":case"secs":case"sec":case"s":return x*O;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return x;default:return}}}}function d(c){var R=Math.abs(c);return R>=_?Math.round(c/_)+"d":R>=i?Math.round(c/i)+"h":R>=y?Math.round(c/y)+"m":R>=O?Math.round(c/O)+"s":c+"ms"}function l(c){var R=Math.abs(c);return R>=_?g(c,R,_,"day"):R>=i?g(c,R,i,"hour"):R>=y?g(c,R,y,"minute"):R>=O?g(c,R,O,"second"):c+" ms"}function g(c,R,x,S){var N=R>=x*1.5;return Math.round(c/x)+" "+S+(N?"s":"")}return qt}var Gt,gn;function jl(){if(gn)return Gt;gn=1;function O(y){_.debug=_,_.default=_,_.coerce=g,_.disable=d,_.enable=t,_.enabled=l,_.humanize=Vl(),_.destroy=c,Object.keys(y).forEach(R=>{_[R]=y[R]}),_.names=[],_.skips=[],_.formatters={};function i(R){let x=0;for(let S=0;S<R.length;S++)x=(x<<5)-x+R.charCodeAt(S),x|=0;return _.colors[Math.abs(x)%_.colors.length]}_.selectColor=i;function _(R){let x,S=null,N,k;function C(...I){if(!C.enabled)return;const H=C,F=Number(new Date),o=F-(x||F);H.diff=o,H.prev=x,H.curr=F,x=F,I[0]=_.coerce(I[0]),typeof I[0]!="string"&&I.unshift("%O");let f=0;I[0]=I[0].replace(/%([a-zA-Z%])/g,(p,A)=>{if(p==="%%")return"%";f++;const D=_.formatters[A];if(typeof D=="function"){const v=I[f];p=D.call(H,v),I.splice(f,1),f--}return p}),_.formatArgs.call(H,I),(H.log||_.log).apply(H,I)}return C.namespace=R,C.useColors=_.useColors(),C.color=_.selectColor(R),C.extend=E,C.destroy=_.destroy,Object.defineProperty(C,"enabled",{enumerable:!0,configurable:!1,get:()=>S!==null?S:(N!==_.namespaces&&(N=_.namespaces,k=_.enabled(R)),k),set:I=>{S=I}}),typeof _.init=="function"&&_.init(C),C}function E(R,x){const S=_(this.namespace+(typeof x>"u"?":":x)+R);return S.log=this.log,S}function t(R){_.save(R),_.namespaces=R,_.names=[],_.skips=[];const x=(typeof R=="string"?R:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const S of x)S[0]==="-"?_.skips.push(S.slice(1)):_.names.push(S)}function h(R,x){let S=0,N=0,k=-1,C=0;for(;S<R.length;)if(N<x.length&&(x[N]===R[S]||x[N]==="*"))x[N]==="*"?(k=N,C=S,N++):(S++,N++);else if(k!==-1)N=k+1,C++,S=C;else return!1;for(;N<x.length&&x[N]==="*";)N++;return N===x.length}function d(){const R=[..._.names,..._.skips.map(x=>"-"+x)].join(",");return _.enable(""),R}function l(R){for(const x of _.skips)if(h(R,x))return!1;for(const x of _.names)if(h(R,x))return!0;return!1}function g(R){return R instanceof Error?R.stack||R.message:R}function c(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return _.enable(_.load()),_}return Gt=O,Gt}var Tn;function ps(){return Tn||(Tn=1,(function(O,y){y.formatArgs=_,y.save=E,y.load=t,y.useColors=i,y.storage=h(),y.destroy=(()=>{let l=!1;return()=>{l||(l=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),y.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function i(){if(typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let l;return typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&(l=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(l[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function _(l){if(l[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+l[0]+(this.useColors?"%c ":" ")+"+"+O.exports.humanize(this.diff),!this.useColors)return;const g="color: "+this.color;l.splice(1,0,g,"color: inherit");let c=0,R=0;l[0].replace(/%[a-zA-Z%]/g,x=>{x!=="%%"&&(c++,x==="%c"&&(R=c))}),l.splice(R,0,g)}y.log=console.debug||console.log||(()=>{});function E(l){try{l?y.storage.setItem("debug",l):y.storage.removeItem("debug")}catch{}}function t(){let l;try{l=y.storage.getItem("debug")||y.storage.getItem("DEBUG")}catch{}return!l&&typeof process<"u"&&"env"in process&&(l=process.env.DEBUG),l}function h(){try{return localStorage}catch{}}O.exports=jl()(y);const{formatters:d}=O.exports;d.j=function(l){try{return JSON.stringify(l)}catch(g){return"[UnexpectedJSONParseError]: "+g.message}}})(ut,ut.exports)),ut.exports}var Bt,Cn;function oe(){if(Cn)return Bt;Cn=1;const O=ps(),y="JsSIP";return Bt=class{constructor(_){_?(this._debug=O.default(`${y}:${_}`),this._warn=O.default(`${y}:WARN:${_}`),this._error=O.default(`${y}:ERROR:${_}`)):(this._debug=O.default(y),this._warn=O.default(`${y}:WARN`),this._error=O.default(`${y}:ERROR`)),this._debug.log=console.info.bind(console),this._warn.log=console.warn.bind(console),this._error.log=console.error.bind(console)}get debug(){return this._debug}get warn(){return this._warn}get error(){return this._error}},Bt}var pe={},Wt={},Vt={exports:{}},vn;function Cs(){if(vn)return Vt.exports;vn=1;var O=Vt.exports={v:[{name:"version",reg:/^(\d*)$/}],o:[{name:"origin",reg:/^(\S*) (\d*) (\d*) (\S*) IP(\d) (\S*)/,names:["username","sessionId","sessionVersion","netType","ipVer","address"],format:"%s %s %d %s IP%d %s"}],s:[{name:"name"}],i:[{name:"description"}],u:[{name:"uri"}],e:[{name:"email"}],p:[{name:"phone"}],z:[{name:"timezones"}],r:[{name:"repeats"}],t:[{name:"timing",reg:/^(\d*) (\d*)/,names:["start","stop"],format:"%d %d"}],c:[{name:"connection",reg:/^IN IP(\d) (\S*)/,names:["version","ip"],format:"IN IP%d %s"}],b:[{push:"bandwidth",reg:/^(TIAS|AS|CT|RR|RS):(\d*)/,names:["type","limit"],format:"%s:%s"}],m:[{reg:/^(\w*) (\d*) ([\w/]*)(?: (.*))?/,names:["type","port","protocol","payloads"],format:"%s %d %s %s"}],a:[{push:"rtp",reg:/^rtpmap:(\d*) ([\w\-.]*)(?:\s*\/(\d*)(?:\s*\/(\S*))?)?/,names:["payload","codec","rate","encoding"],format:function(y){return y.encoding?"rtpmap:%d %s/%s/%s":y.rate?"rtpmap:%d %s/%s":"rtpmap:%d %s"}},{push:"fmtp",reg:/^fmtp:(\d*) ([\S| ]*)/,names:["payload","config"],format:"fmtp:%d %s"},{name:"control",reg:/^control:(.*)/,format:"control:%s"},{name:"rtcp",reg:/^rtcp:(\d*)(?: (\S*) IP(\d) (\S*))?/,names:["port","netType","ipVer","address"],format:function(y){return y.address!=null?"rtcp:%d %s IP%d %s":"rtcp:%d"}},{push:"rtcpFbTrrInt",reg:/^rtcp-fb:(\*|\d*) trr-int (\d*)/,names:["payload","value"],format:"rtcp-fb:%s trr-int %d"},{push:"rtcpFb",reg:/^rtcp-fb:(\*|\d*) ([\w-_]*)(?: ([\w-_]*))?/,names:["payload","type","subtype"],format:function(y){return y.subtype!=null?"rtcp-fb:%s %s %s":"rtcp-fb:%s %s"}},{push:"ext",reg:/^extmap:(\d+)(?:\/(\w+))?(?: (urn:ietf:params:rtp-hdrext:encrypt))? (\S*)(?: (\S*))?/,names:["value","direction","encrypt-uri","uri","config"],format:function(y){return"extmap:%d"+(y.direction?"/%s":"%v")+(y["encrypt-uri"]?" %s":"%v")+" %s"+(y.config?" %s":"")}},{name:"extmapAllowMixed",reg:/^(extmap-allow-mixed)/},{push:"crypto",reg:/^crypto:(\d*) ([\w_]*) (\S*)(?: (\S*))?/,names:["id","suite","config","sessionConfig"],format:function(y){return y.sessionConfig!=null?"crypto:%d %s %s %s":"crypto:%d %s %s"}},{name:"setup",reg:/^setup:(\w*)/,format:"setup:%s"},{name:"connectionType",reg:/^connection:(new|existing)/,format:"connection:%s"},{name:"mid",reg:/^mid:([^\s]*)/,format:"mid:%s"},{name:"msid",reg:/^msid:(.*)/,format:"msid:%s"},{name:"ptime",reg:/^ptime:(\d*(?:\.\d*)*)/,format:"ptime:%d"},{name:"maxptime",reg:/^maxptime:(\d*(?:\.\d*)*)/,format:"maxptime:%d"},{name:"direction",reg:/^(sendrecv|recvonly|sendonly|inactive)/},{name:"icelite",reg:/^(ice-lite)/},{name:"iceUfrag",reg:/^ice-ufrag:(\S*)/,format:"ice-ufrag:%s"},{name:"icePwd",reg:/^ice-pwd:(\S*)/,format:"ice-pwd:%s"},{name:"fingerprint",reg:/^fingerprint:(\S*) (\S*)/,names:["type","hash"],format:"fingerprint:%s %s"},{push:"candidates",reg:/^candidate:(\S*) (\d*) (\S*) (\d*) (\S*) (\d*) typ (\S*)(?: raddr (\S*) rport (\d*))?(?: tcptype (\S*))?(?: generation (\d*))?(?: network-id (\d*))?(?: network-cost (\d*))?/,names:["foundation","component","transport","priority","ip","port","type","raddr","rport","tcptype","generation","network-id","network-cost"],format:function(y){var i="candidate:%s %d %s %d %s %d typ %s";return i+=y.raddr!=null?" raddr %s rport %d":"%v%v",i+=y.tcptype!=null?" tcptype %s":"%v",y.generation!=null&&(i+=" generation %d"),i+=y["network-id"]!=null?" network-id %d":"%v",i+=y["network-cost"]!=null?" network-cost %d":"%v",i}},{name:"endOfCandidates",reg:/^(end-of-candidates)/},{name:"remoteCandidates",reg:/^remote-candidates:(.*)/,format:"remote-candidates:%s"},{name:"iceOptions",reg:/^ice-options:(\S*)/,format:"ice-options:%s"},{push:"ssrcs",reg:/^ssrc:(\d*) ([\w_-]*)(?::(.*))?/,names:["id","attribute","value"],format:function(y){var i="ssrc:%d";return y.attribute!=null&&(i+=" %s",y.value!=null&&(i+=":%s")),i}},{push:"ssrcGroups",reg:/^ssrc-group:([\x21\x23\x24\x25\x26\x27\x2A\x2B\x2D\x2E\w]*) (.*)/,names:["semantics","ssrcs"],format:"ssrc-group:%s %s"},{name:"msidSemantic",reg:/^msid-semantic:\s?(\w*) (\S*)/,names:["semantic","token"],format:"msid-semantic: %s %s"},{push:"groups",reg:/^group:(\w*) (.*)/,names:["type","mids"],format:"group:%s %s"},{name:"rtcpMux",reg:/^(rtcp-mux)/},{name:"rtcpRsize",reg:/^(rtcp-rsize)/},{name:"sctpmap",reg:/^sctpmap:([\w_/]*) (\S*)(?: (\S*))?/,names:["sctpmapNumber","app","maxMessageSize"],format:function(y){return y.maxMessageSize!=null?"sctpmap:%s %s %s":"sctpmap:%s %s"}},{name:"xGoogleFlag",reg:/^x-google-flag:([^\s]*)/,format:"x-google-flag:%s"},{push:"rids",reg:/^rid:([\d\w]+) (\w+)(?: ([\S| ]*))?/,names:["id","direction","params"],format:function(y){return y.params?"rid:%s %s %s":"rid:%s %s"}},{push:"imageattrs",reg:new RegExp("^imageattr:(\\d+|\\*)[\\s\\t]+(send|recv)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*)(?:[\\s\\t]+(recv|send)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*))?"),names:["pt","dir1","attrs1","dir2","attrs2"],format:function(y){return"imageattr:%s %s %s"+(y.dir2?" %s %s":"")}},{name:"simulcast",reg:new RegExp("^simulcast:(send|recv) ([a-zA-Z0-9\\-_~;,]+)(?:\\s?(send|recv) ([a-zA-Z0-9\\-_~;,]+))?$"),names:["dir1","list1","dir2","list2"],format:function(y){return"simulcast:%s %s"+(y.dir2?" %s %s":"")}},{name:"simulcast_03",reg:/^simulcast:[\s\t]+([\S+\s\t]+)$/,names:["value"],format:"simulcast: %s"},{name:"framerate",reg:/^framerate:(\d+(?:$|\.\d+))/,format:"framerate:%s"},{name:"sourceFilter",reg:/^source-filter: *(excl|incl) (\S*) (IP4|IP6|\*) (\S*) (.*)/,names:["filterMode","netType","addressTypes","destAddress","srcList"],format:"source-filter: %s %s %s %s %s"},{name:"bundleOnly",reg:/^(bundle-only)/},{name:"label",reg:/^label:(.+)/,format:"label:%s"},{name:"sctpPort",reg:/^sctp-port:(\d+)$/,format:"sctp-port:%s"},{name:"maxMessageSize",reg:/^max-message-size:(\d+)$/,format:"max-message-size:%s"},{push:"tsRefClocks",reg:/^ts-refclk:([^\s=]*)(?:=(\S*))?/,names:["clksrc","clksrcExt"],format:function(y){return"ts-refclk:%s"+(y.clksrcExt!=null?"=%s":"")}},{name:"mediaClk",reg:/^mediaclk:(?:id=(\S*))? *([^\s=]*)(?:=(\S*))?(?: *rate=(\d+)\/(\d+))?/,names:["id","mediaClockName","mediaClockValue","rateNumerator","rateDenominator"],format:function(y){var i="mediaclk:";return i+=y.id!=null?"id=%s %s":"%v%s",i+=y.mediaClockValue!=null?"=%s":"",i+=y.rateNumerator!=null?" rate=%s":"",i+=y.rateDenominator!=null?"/%s":"",i}},{name:"keywords",reg:/^keywds:(.+)$/,format:"keywds:%s"},{name:"content",reg:/^content:(.+)/,format:"content:%s"},{name:"bfcpFloorCtrl",reg:/^floorctrl:(c-only|s-only|c-s)/,format:"floorctrl:%s"},{name:"bfcpConfId",reg:/^confid:(\d+)/,format:"confid:%s"},{name:"bfcpUserId",reg:/^userid:(\d+)/,format:"userid:%s"},{name:"bfcpFloorId",reg:/^floorid:(.+) (?:m-stream|mstrm):(.+)/,names:["id","mStream"],format:"floorid:%s mstrm:%s"},{push:"invalid",names:["value"]}]};return Object.keys(O).forEach(function(y){var i=O[y];i.forEach(function(_){_.reg||(_.reg=/(.*)/),_.format||(_.format="%s")})}),Vt.exports}var Sn;function Kl(){return Sn||(Sn=1,(function(O){var y=function(d){return String(Number(d))===d?Number(d):d},i=function(d,l,g,c){if(c&&!g)l[c]=y(d[1]);else for(var R=0;R<g.length;R+=1)d[R+1]!=null&&(l[g[R]]=y(d[R+1]))},_=function(d,l,g){var c=d.name&&d.names;d.push&&!l[d.push]?l[d.push]=[]:c&&!l[d.name]&&(l[d.name]={});var R=d.push?{}:c?l[d.name]:l;i(g.match(d.reg),R,d.names,d.name),d.push&&l[d.push].push(R)},E=Cs(),t=RegExp.prototype.test.bind(/^([a-z])=(.*)/);O.parse=function(d){var l={},g=[],c=l;return d.split(/(\r\n|\r|\n)/).filter(t).forEach(function(R){var x=R[0],S=R.slice(2);x==="m"&&(g.push({rtp:[],fmtp:[]}),c=g[g.length-1]);for(var N=0;N<(E[x]||[]).length;N+=1){var k=E[x][N];if(k.reg.test(S))return _(k,c,S)}}),l.media=g,l};var h=function(d,l){var g=l.split(/=(.+)/,2);return g.length===2?d[g[0]]=y(g[1]):g.length===1&&l.length>1&&(d[g[0]]=void 0),d};O.parseParams=function(d){return d.split(/;\s?/).reduce(h,{})},O.parseFmtpConfig=O.parseParams,O.parsePayloads=function(d){return d.toString().split(" ").map(Number)},O.parseRemoteCandidates=function(d){for(var l=[],g=d.split(" ").map(y),c=0;c<g.length;c+=3)l.push({component:g[c],ip:g[c+1],port:g[c+2]});return l},O.parseImageAttributes=function(d){return d.split(" ").map(function(l){return l.substring(1,l.length-1).split(",").reduce(h,{})})},O.parseSimulcastStreamList=function(d){return d.split(";").map(function(l){return l.split(",").map(function(g){var c,R=!1;return g[0]!=="~"?c=y(g):(c=y(g.substring(1,g.length)),R=!0),{scid:c,paused:R}})})}})(Wt)),Wt}var jt,En;function zl(){if(En)return jt;En=1;var O=Cs(),y=/%[sdv%]/g,i=function(h){var d=1,l=arguments,g=l.length;return h.replace(y,function(c){if(d>=g)return c;var R=l[d];switch(d+=1,c){case"%%":return"%";case"%s":return String(R);case"%d":return Number(R);case"%v":return""}})},_=function(h,d,l){var g=d.format instanceof Function?d.format(d.push?l:l[d.name]):d.format,c=[h+"="+g];if(d.names)for(var R=0;R<d.names.length;R+=1){var x=d.names[R];d.name?c.push(l[d.name][x]):c.push(l[d.names[R]])}else c.push(l[d.name]);return i.apply(null,c)},E=["v","o","s","i","u","e","p","c","b","t","r","z","a"],t=["i","c","b","a"];return jt=function(h,d){d=d||{},h.version==null&&(h.version=0),h.name==null&&(h.name=" "),h.media.forEach(function(R){R.payloads==null&&(R.payloads="")});var l=d.outerOrder||E,g=d.innerOrder||t,c=[];return l.forEach(function(R){O[R].forEach(function(x){x.name in h&&h[x.name]!=null?c.push(_(R,x,h)):x.push in h&&h[x.push]!=null&&h[x.push].forEach(function(S){c.push(_(R,x,S))})})}),h.media.forEach(function(R){c.push(_("m",O.m[0],R)),g.forEach(function(x){O[x].forEach(function(S){S.name in R&&R[S.name]!=null?c.push(_(x,S,R)):S.push in R&&R[S.push]!=null&&R[S.push].forEach(function(N){c.push(_(x,S,N))})})})}),c.join(`\r
|
|
5
|
+
`)+`\r
|
|
6
|
+
`},jt}var An;function Xn(){if(An)return pe;An=1;var O=Kl(),y=zl(),i=Cs();return pe.grammar=i,pe.write=y,pe.parse=O.parse,pe.parseParams=O.parseParams,pe.parseFmtpConfig=O.parseFmtpConfig,pe.parsePayloads=O.parsePayloads,pe.parseRemoteCandidates=O.parseRemoteCandidates,pe.parseImageAttributes=O.parseImageAttributes,pe.parseSimulcastStreamList=O.parseSimulcastStreamList,pe}var Kt,Rn;function ve(){if(Rn)return Kt;Rn=1;const O=Xn(),y=oe(),i=ie(),_=ue(),E=Ts(),t=ge(),h=new y("SIPMessage");class d{constructor(S,N,k,C,I,H){if(!S||!N||!k)return null;C=C||{},this.ua=k,this.headers={},this.method=S,this.ruri=N,this.body=H,this.extraHeaders=_.cloneArray(I),this.ua.configuration.extra_headers&&(this.extraHeaders=this.extraHeaders.concat(this.ua.configuration.extra_headers)),C.route_set?this.setHeader("route",C.route_set):k.configuration.use_preloaded_route&&this.setHeader("route",`<${k.transport.sip_uri};lr>`),this.setHeader("via",""),this.setHeader("max-forwards",i.MAX_FORWARDS);const F=C.to_uri||N,o=C.to_tag?{tag:C.to_tag}:null,f=typeof C.to_display_name<"u"?C.to_display_name:null;this.to=new E(F,f,o),this.setHeader("to",this.to.toString());const T=C.from_uri||k.configuration.uri,p={tag:C.from_tag||_.newTag()};let A;typeof C.from_display_name<"u"?A=C.from_display_name:k.configuration.display_name?A=k.configuration.display_name:A=null,this.from=new E(T,A,p),this.setHeader("from",this.from.toString());const D=C.call_id||k.configuration.jssip_id+_.createRandomToken(15);this.call_id=D,this.setHeader("call-id",D);const v=C.cseq||Math.floor(Math.random()*1e4);this.cseq=v,this.setHeader("cseq",`${v} ${S}`)}setHeader(S,N){const k=new RegExp(`^\\s*${S}\\s*:`,"i");for(let C=0;C<this.extraHeaders.length;C++)k.test(this.extraHeaders[C])&&this.extraHeaders.splice(C,1);this.headers[_.headerize(S)]=Array.isArray(N)?N:[N]}getHeader(S){const N=this.headers[_.headerize(S)];if(N){if(N[0])return N[0]}else{const k=new RegExp(`^\\s*${S}\\s*:`,"i");for(const C of this.extraHeaders)if(k.test(C))return C.substring(C.indexOf(":")+1).trim()}}getHeaders(S){const N=this.headers[_.headerize(S)],k=[];if(N){for(const C of N)k.push(C);return k}else{const C=new RegExp(`^\\s*${S}\\s*:`,"i");for(const I of this.extraHeaders)C.test(I)&&k.push(I.substring(I.indexOf(":")+1).trim());return k}}hasHeader(S){if(this.headers[_.headerize(S)])return!0;{const N=new RegExp(`^\\s*${S}\\s*:`,"i");for(const k of this.extraHeaders)if(N.test(k))return!0}return!1}parseSDP(S){return!S&&this.sdp?this.sdp:(this.sdp=O.parse(this.body||""),this.sdp)}toString(){let S=`${this.method} ${this.ruri} SIP/2.0\r
|
|
7
|
+
`;for(const C in this.headers)if(Object.prototype.hasOwnProperty.call(this.headers,C))for(const I of this.headers[C])S+=`${C}: ${I}\r
|
|
8
|
+
`;for(const C of this.extraHeaders)S+=`${C.trim()}\r
|
|
9
|
+
`;const N=[];switch(this.method){case i.REGISTER:N.push("path","gruu");break;case i.INVITE:this.ua.configuration.session_timers&&N.push("timer"),(this.ua.contact.pub_gruu||this.ua.contact.temp_gruu)&&N.push("gruu"),N.push("ice","replaces");break;case i.UPDATE:this.ua.configuration.session_timers&&N.push("timer"),N.push("ice");break}N.push("outbound");const k=this.ua.configuration.user_agent||i.USER_AGENT;if(S+=`Allow: ${i.ALLOWED_METHODS}\r
|
|
10
|
+
`,S+=`Supported: ${N}\r
|
|
11
|
+
`,S+=`User-Agent: ${k}\r
|
|
12
|
+
`,this.body){const C=_.str_utf8_length(this.body);S+=`Content-Length: ${C}\r
|
|
13
|
+
\r
|
|
14
|
+
`,S+=this.body}else S+=`Content-Length: 0\r
|
|
15
|
+
\r
|
|
16
|
+
`;return S}clone(){const S=new d(this.method,this.ruri,this.ua);return Object.keys(this.headers).forEach(function(N){S.headers[N]=this.headers[N].slice()},this),S.body=this.body,S.extraHeaders=_.cloneArray(this.extraHeaders),S.to=this.to,S.from=this.from,S.call_id=this.call_id,S.cseq=this.cseq,S}}class l extends d{constructor(S,N,k,C,I){super(i.INVITE,S,N,k,C,I),this.transaction=null}cancel(S){this.transaction.cancel(S)}clone(){const S=new l(this.ruri,this.ua);return Object.keys(this.headers).forEach(function(N){S.headers[N]=this.headers[N].slice()},this),S.body=this.body,S.extraHeaders=_.cloneArray(this.extraHeaders),S.to=this.to,S.from=this.from,S.call_id=this.call_id,S.cseq=this.cseq,S.transaction=this.transaction,S}}class g{constructor(){this.data=null,this.headers=null,this.method=null,this.via=null,this.via_branch=null,this.call_id=null,this.cseq=null,this.from=null,this.from_tag=null,this.to=null,this.to_tag=null,this.body=null,this.sdp=null}addHeader(S,N){const k={raw:N};S=_.headerize(S),this.headers[S]?this.headers[S].push(k):this.headers[S]=[k]}getHeader(S){const N=this.headers[_.headerize(S)];if(N){if(N[0])return N[0].raw}else return}getHeaders(S){const N=this.headers[_.headerize(S)],k=[];if(!N)return[];for(const C of N)k.push(C.raw);return k}hasHeader(S){return!!this.headers[_.headerize(S)]}parseHeader(S,N=0){if(S=_.headerize(S),this.headers[S]){if(N>=this.headers[S].length){h.debug(`not so many "${S}" headers present`);return}}else{h.debug(`header "${S}" not present`);return}const k=this.headers[S][N],C=k.raw;if(k.parsed)return k.parsed;const I=t.parse(C,S.replace(/-/g,"_"));if(I===-1){this.headers[S].splice(N,1),h.debug(`error parsing "${S}" header field with value "${C}"`);return}else return k.parsed=I,I}s(S,N){return this.parseHeader(S,N)}setHeader(S,N){const k={raw:N};this.headers[_.headerize(S)]=[k]}parseSDP(S){return!S&&this.sdp?this.sdp:(this.sdp=O.parse(this.body||""),this.sdp)}toString(){return this.data}}class c extends g{constructor(S){super(),this.ua=S,this.headers={},this.ruri=null,this.transport=null,this.server_transaction=null}reply(S,N,k,C,I,H){const F=[];let o=this.getHeader("To");if(S=S||null,N=N||null,!S||S<100||S>699)throw new TypeError(`Invalid status_code: ${S}`);if(N&&typeof N!="string"&&!(N instanceof String))throw new TypeError(`Invalid reason_phrase: ${N}`);N=N||i.REASON_PHRASE[S]||"",k=_.cloneArray(k),this.ua.configuration.extra_headers&&(k=k.concat(this.ua.configuration.extra_headers));let f=`SIP/2.0 ${S} ${N}\r
|
|
17
|
+
`;if(this.method===i.INVITE&&S>100&&S<=200){const p=this.getHeaders("record-route");for(const A of p)f+=`Record-Route: ${A}\r
|
|
18
|
+
`}const T=this.getHeaders("via");for(const p of T)f+=`Via: ${p}\r
|
|
19
|
+
`;!this.to_tag&&S>100?o+=`;tag=${_.newTag()}`:this.to_tag&&!this.s("to").hasParam("tag")&&(o+=`;tag=${this.to_tag}`),f+=`To: ${o}\r
|
|
20
|
+
`,f+=`From: ${this.getHeader("From")}\r
|
|
21
|
+
`,f+=`Call-ID: ${this.call_id}\r
|
|
22
|
+
`,f+=`CSeq: ${this.cseq} ${this.method}\r
|
|
23
|
+
`;for(const p of k)f+=`${p.trim()}\r
|
|
24
|
+
`;switch(this.method){case i.INVITE:this.ua.configuration.session_timers&&F.push("timer"),(this.ua.contact.pub_gruu||this.ua.contact.temp_gruu)&&F.push("gruu"),F.push("ice","replaces");break;case i.UPDATE:this.ua.configuration.session_timers&&F.push("timer"),C&&F.push("ice"),F.push("replaces")}if(F.push("outbound"),this.method===i.OPTIONS?(f+=`Allow: ${i.ALLOWED_METHODS}\r
|
|
25
|
+
`,f+=`Accept: ${i.ACCEPTED_BODY_TYPES}\r
|
|
26
|
+
`):S===405?f+=`Allow: ${i.ALLOWED_METHODS}\r
|
|
27
|
+
`:S===415&&(f+=`Accept: ${i.ACCEPTED_BODY_TYPES}\r
|
|
28
|
+
`),f+=`Supported: ${F}\r
|
|
29
|
+
`,C){const p=_.str_utf8_length(C);f+=`Content-Type: application/sdp\r
|
|
30
|
+
`,f+=`Content-Length: ${p}\r
|
|
31
|
+
\r
|
|
32
|
+
`,f+=C}else f+=`Content-Length: 0\r
|
|
33
|
+
\r
|
|
34
|
+
`;this.server_transaction.receiveResponse(S,f,I,H)}reply_sl(S=null,N=null){const k=this.getHeaders("via");if(!S||S<100||S>699)throw new TypeError(`Invalid status_code: ${S}`);if(N&&typeof N!="string"&&!(N instanceof String))throw new TypeError(`Invalid reason_phrase: ${N}`);N=N||i.REASON_PHRASE[S]||"";let C=`SIP/2.0 ${S} ${N}\r
|
|
35
|
+
`;for(const H of k)C+=`Via: ${H}\r
|
|
36
|
+
`;let I=this.getHeader("To");if(!this.to_tag&&S>100?I+=`;tag=${_.newTag()}`:this.to_tag&&!this.s("to").hasParam("tag")&&(I+=`;tag=${this.to_tag}`),C+=`To: ${I}\r
|
|
37
|
+
`,C+=`From: ${this.getHeader("From")}\r
|
|
38
|
+
`,C+=`Call-ID: ${this.call_id}\r
|
|
39
|
+
`,C+=`CSeq: ${this.cseq} ${this.method}\r
|
|
40
|
+
`,this.ua.configuration.extra_headers)for(const H of this.ua.configuration.extra_headers)C+=`${H.trim()}\r
|
|
41
|
+
`;C+=`Content-Length: 0\r
|
|
42
|
+
\r
|
|
43
|
+
`,this.transport.send(C)}}class R extends g{constructor(){super(),this.headers={},this.status_code=null,this.reason_phrase=null}}return Kt={OutgoingRequest:d,InitialOutgoingInviteRequest:l,IncomingRequest:c,IncomingResponse:R},Kt}var zt,yn;function Yl(){if(yn)return zt;yn=1;const O=oe(),y=ue(),i=new O("DigestAuthentication");return zt=class{constructor(E){this._credentials=E,this._cnonce=null,this._nc=0,this._ncHex="00000000",this._algorithm=null,this._realm=null,this._nonce=null,this._opaque=null,this._stale=null,this._qop=null,this._method=null,this._uri=null,this._ha1=null,this._response=null}get(E){switch(E){case"realm":return this._realm;case"ha1":return this._ha1;default:i.warn('get() | cannot get "%s" parameter',E);return}}authenticate({method:E,ruri:t,body:h},d,l=null){if(this._algorithm=d.algorithm,this._realm=d.realm,this._nonce=d.nonce,this._opaque=d.opaque,this._stale=d.stale,this._algorithm){if(this._algorithm!=="MD5")return i.warn('authenticate() | challenge with Digest algorithm different than "MD5", authentication aborted'),!1}else this._algorithm="MD5";if(!this._nonce)return i.warn("authenticate() | challenge without Digest nonce, authentication aborted"),!1;if(!this._realm)return i.warn("authenticate() | challenge without Digest realm, authentication aborted"),!1;if(!this._credentials.password){if(!this._credentials.ha1)return i.warn("authenticate() | no plain SIP password nor ha1 provided, authentication aborted"),!1;if(this._credentials.realm!==this._realm)return i.warn('authenticate() | no plain SIP password, and stored `realm` does not match the given `realm`, cannot authenticate [stored:"%s", given:"%s"]',this._credentials.realm,this._realm),!1}if(d.qop)if(d.qop.indexOf("auth-int")>-1)this._qop="auth-int";else if(d.qop.indexOf("auth")>-1)this._qop="auth";else return i.warn('authenticate() | challenge without Digest qop different than "auth" or "auth-int", authentication aborted'),!1;else this._qop=null;this._method=E,this._uri=t,this._cnonce=l||y.createRandomToken(12),this._nc+=1;const g=Number(this._nc).toString(16);this._ncHex="00000000".substr(0,8-g.length)+g,this._nc===4294967296&&(this._nc=1,this._ncHex="00000001"),this._credentials.password?this._ha1=y.calculateMD5(`${this._credentials.username}:${this._realm}:${this._credentials.password}`):this._ha1=this._credentials.ha1;let c,R;return this._qop==="auth"?(c=`${this._method}:${this._uri}`,R=y.calculateMD5(c),i.debug('authenticate() | using qop=auth [a2:"%s"]',c),this._response=y.calculateMD5(`${this._ha1}:${this._nonce}:${this._ncHex}:${this._cnonce}:auth:${R}`)):this._qop==="auth-int"?(c=`${this._method}:${this._uri}:${y.calculateMD5(h||"")}`,R=y.calculateMD5(c),i.debug('authenticate() | using qop=auth-int [a2:"%s"]',c),this._response=y.calculateMD5(`${this._ha1}:${this._nonce}:${this._ncHex}:${this._cnonce}:auth-int:${R}`)):this._qop===null&&(c=`${this._method}:${this._uri}`,R=y.calculateMD5(c),i.debug('authenticate() | using qop=null [a2:"%s"]',c),this._response=y.calculateMD5(`${this._ha1}:${this._nonce}:${R}`)),i.debug("authenticate() | response generated"),!0}toString(){const E=[];if(!this._response)throw new Error("response field does not exist, cannot generate Authorization header");return E.push(`algorithm=${this._algorithm}`),E.push(`username="${this._credentials.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(", ")}`}},zt}var Yt,In;function Qn(){if(In)return Yt;In=1;const O=500,y=4e3,i=5e3;return Yt={T1:O,T2:y,T4:i,TIMER_B:64*O,TIMER_D:0*O,TIMER_F:64*O,TIMER_H:64*O,TIMER_I:0*O,TIMER_J:0*O,TIMER_K:0*i,TIMER_L:64*O,TIMER_M:64*O,PROVISIONAL_RESPONSE_INTERVAL:6e4},Yt}var Jt,wn;function Be(){if(wn)return Jt;wn=1;const O=Ie().EventEmitter,y=oe(),i=ie(),_=ve(),E=Qn(),t=new y("NonInviteClientTransaction"),h=new y("InviteClientTransaction"),d=new y("AckClientTransaction"),l=new y("NonInviteServerTransaction"),g=new y("InviteServerTransaction"),c={STATUS_TRYING:1,STATUS_PROCEEDING:2,STATUS_CALLING:3,STATUS_ACCEPTED:4,STATUS_COMPLETED:5,STATUS_TERMINATED:6,STATUS_CONFIRMED:7,NON_INVITE_CLIENT:"nict",NON_INVITE_SERVER:"nist",INVITE_CLIENT:"ict",INVITE_SERVER:"ist"};class R extends O{constructor(H,F,o,f){super(),this.type=c.NON_INVITE_CLIENT,this.id=`z9hG4bK${Math.floor(Math.random()*1e7)}`,this.ua=H,this.transport=F,this.request=o,this.eventHandlers=f;let T=`SIP/2.0/${F.via_transport}`;T+=` ${H.configuration.via_host};branch=${this.id}`,this.request.setHeader("via",T),this.ua.newTransaction(this)}get C(){return c}stateChanged(H){this.state=H,this.emit("stateChanged")}send(){this.stateChanged(c.STATUS_TRYING),this.F=setTimeout(()=>{this.timer_F()},E.TIMER_F),this.transport.send(this.request)||this.onTransportError()}onTransportError(){t.debug(`transport error occurred, deleting transaction ${this.id}`),clearTimeout(this.F),clearTimeout(this.K),this.stateChanged(c.STATUS_TERMINATED),this.ua.destroyTransaction(this),this.eventHandlers.onTransportError()}timer_F(){t.debug(`Timer F expired for transaction ${this.id}`),this.stateChanged(c.STATUS_TERMINATED),this.ua.destroyTransaction(this),this.eventHandlers.onRequestTimeout()}timer_K(){this.stateChanged(c.STATUS_TERMINATED),this.ua.destroyTransaction(this)}receiveResponse(H){const F=H.status_code;if(F<200)switch(this.state){case c.STATUS_TRYING:case c.STATUS_PROCEEDING:this.stateChanged(c.STATUS_PROCEEDING),this.eventHandlers.onReceiveResponse(H);break}else switch(this.state){case c.STATUS_TRYING:case c.STATUS_PROCEEDING:this.stateChanged(c.STATUS_COMPLETED),clearTimeout(this.F),F===408?this.eventHandlers.onRequestTimeout():this.eventHandlers.onReceiveResponse(H),this.K=setTimeout(()=>{this.timer_K()},E.TIMER_K);break;case c.STATUS_COMPLETED:break}}}class x extends O{constructor(H,F,o,f){super(),this.type=c.INVITE_CLIENT,this.id=`z9hG4bK${Math.floor(Math.random()*1e7)}`,this.ua=H,this.transport=F,this.request=o,this.eventHandlers=f,o.transaction=this;let T=`SIP/2.0/${F.via_transport}`;T+=` ${H.configuration.via_host};branch=${this.id}`,this.request.setHeader("via",T),this.ua.newTransaction(this)}get C(){return c}stateChanged(H){this.state=H,this.emit("stateChanged")}send(){this.stateChanged(c.STATUS_CALLING),this.B=setTimeout(()=>{this.timer_B()},E.TIMER_B),this.transport.send(this.request)||this.onTransportError()}onTransportError(){clearTimeout(this.B),clearTimeout(this.D),clearTimeout(this.M),this.state!==c.STATUS_ACCEPTED&&(h.debug(`transport error occurred, deleting transaction ${this.id}`),this.eventHandlers.onTransportError()),this.stateChanged(c.STATUS_TERMINATED),this.ua.destroyTransaction(this)}timer_M(){h.debug(`Timer M expired for transaction ${this.id}`),this.state===c.STATUS_ACCEPTED&&(clearTimeout(this.B),this.stateChanged(c.STATUS_TERMINATED),this.ua.destroyTransaction(this))}timer_B(){h.debug(`Timer B expired for transaction ${this.id}`),this.state===c.STATUS_CALLING&&(this.stateChanged(c.STATUS_TERMINATED),this.ua.destroyTransaction(this),this.eventHandlers.onRequestTimeout())}timer_D(){h.debug(`Timer D expired for transaction ${this.id}`),clearTimeout(this.B),this.stateChanged(c.STATUS_TERMINATED),this.ua.destroyTransaction(this)}sendACK(H){const F=new _.OutgoingRequest(i.ACK,this.request.ruri,this.ua,{route_set:this.request.getHeaders("route"),call_id:this.request.getHeader("call-id"),cseq:this.request.cseq});F.setHeader("from",this.request.getHeader("from")),F.setHeader("via",this.request.getHeader("via")),F.setHeader("to",H.getHeader("to")),this.D=setTimeout(()=>{this.timer_D()},E.TIMER_D),this.transport.send(F)}cancel(H){if(this.state!==c.STATUS_PROCEEDING)return;const F=new _.OutgoingRequest(i.CANCEL,this.request.ruri,this.ua,{route_set:this.request.getHeaders("route"),call_id:this.request.getHeader("call-id"),cseq:this.request.cseq});F.setHeader("from",this.request.getHeader("from")),F.setHeader("via",this.request.getHeader("via")),F.setHeader("to",this.request.getHeader("to")),H&&F.setHeader("reason",H),this.transport.send(F)}receiveResponse(H){const F=H.status_code;if(F>=100&&F<=199)switch(this.state){case c.STATUS_CALLING:this.stateChanged(c.STATUS_PROCEEDING),this.eventHandlers.onReceiveResponse(H);break;case c.STATUS_PROCEEDING:this.eventHandlers.onReceiveResponse(H);break}else if(F>=200&&F<=299)switch(this.state){case c.STATUS_CALLING:case c.STATUS_PROCEEDING:this.stateChanged(c.STATUS_ACCEPTED),this.M=setTimeout(()=>{this.timer_M()},E.TIMER_M),this.eventHandlers.onReceiveResponse(H);break;case c.STATUS_ACCEPTED:this.eventHandlers.onReceiveResponse(H);break}else if(F>=300&&F<=699)switch(this.state){case c.STATUS_CALLING:case c.STATUS_PROCEEDING:this.stateChanged(c.STATUS_COMPLETED),this.sendACK(H),this.eventHandlers.onReceiveResponse(H);break;case c.STATUS_COMPLETED:this.sendACK(H);break}}}class S extends O{constructor(H,F,o,f){super(),this.id=`z9hG4bK${Math.floor(Math.random()*1e7)}`,this.transport=F,this.request=o,this.eventHandlers=f;let T=`SIP/2.0/${F.via_transport}`;T+=` ${H.configuration.via_host};branch=${this.id}`,this.request.setHeader("via",T)}get C(){return c}send(){this.transport.send(this.request)||this.onTransportError()}onTransportError(){d.debug(`transport error occurred for transaction ${this.id}`),this.eventHandlers.onTransportError()}}class N extends O{constructor(H,F,o){super(),this.type=c.NON_INVITE_SERVER,this.id=o.via_branch,this.ua=H,this.transport=F,this.request=o,this.last_response="",o.server_transaction=this,this.state=c.STATUS_TRYING,H.newTransaction(this)}get C(){return c}stateChanged(H){this.state=H,this.emit("stateChanged")}timer_J(){l.debug(`Timer J expired for transaction ${this.id}`),this.stateChanged(c.STATUS_TERMINATED),this.ua.destroyTransaction(this)}onTransportError(){this.transportError||(this.transportError=!0,l.debug(`transport error occurred, deleting transaction ${this.id}`),clearTimeout(this.J),this.stateChanged(c.STATUS_TERMINATED),this.ua.destroyTransaction(this))}receiveResponse(H,F,o,f){if(H===100)switch(this.state){case c.STATUS_TRYING:this.stateChanged(c.STATUS_PROCEEDING),this.transport.send(F)||this.onTransportError();break;case c.STATUS_PROCEEDING:this.last_response=F,this.transport.send(F)?o&&o():(this.onTransportError(),f&&f());break}else if(H>=200&&H<=699)switch(this.state){case c.STATUS_TRYING:case c.STATUS_PROCEEDING:this.stateChanged(c.STATUS_COMPLETED),this.last_response=F,this.J=setTimeout(()=>{this.timer_J()},E.TIMER_J),this.transport.send(F)?o&&o():(this.onTransportError(),f&&f());break;case c.STATUS_COMPLETED:break}}}class k extends O{constructor(H,F,o){super(),this.type=c.INVITE_SERVER,this.id=o.via_branch,this.ua=H,this.transport=F,this.request=o,this.last_response="",o.server_transaction=this,this.state=c.STATUS_PROCEEDING,H.newTransaction(this),this.resendProvisionalTimer=null,o.reply(100)}get C(){return c}stateChanged(H){this.state=H,this.emit("stateChanged")}timer_H(){g.debug(`Timer H expired for transaction ${this.id}`),this.state===c.STATUS_COMPLETED&&g.debug("ACK not received, dialog will be terminated"),this.stateChanged(c.STATUS_TERMINATED),this.ua.destroyTransaction(this)}timer_I(){this.stateChanged(c.STATUS_TERMINATED),this.ua.destroyTransaction(this)}timer_L(){g.debug(`Timer L expired for transaction ${this.id}`),this.state===c.STATUS_ACCEPTED&&(this.stateChanged(c.STATUS_TERMINATED),this.ua.destroyTransaction(this))}onTransportError(){this.transportError||(this.transportError=!0,g.debug(`transport error occurred, deleting transaction ${this.id}`),this.resendProvisionalTimer!==null&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null),clearTimeout(this.L),clearTimeout(this.H),clearTimeout(this.I),this.stateChanged(c.STATUS_TERMINATED),this.ua.destroyTransaction(this))}resend_provisional(){this.transport.send(this.last_response)||this.onTransportError()}receiveResponse(H,F,o,f){if(H>=100&&H<=199&&this.state===c.STATUS_PROCEEDING&&(this.transport.send(F)||this.onTransportError(),this.last_response=F),H>100&&H<=199&&this.state===c.STATUS_PROCEEDING)this.resendProvisionalTimer===null&&(this.resendProvisionalTimer=setInterval(()=>{this.resend_provisional()},E.PROVISIONAL_RESPONSE_INTERVAL));else if(H>=200&&H<=299)switch(this.state){case c.STATUS_PROCEEDING:this.stateChanged(c.STATUS_ACCEPTED),this.last_response=F,this.L=setTimeout(()=>{this.timer_L()},E.TIMER_L),this.resendProvisionalTimer!==null&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null);case c.STATUS_ACCEPTED:this.transport.send(F)?o&&o():(this.onTransportError(),f&&f());break}else H>=300&&H<=699&&this.state===c.STATUS_PROCEEDING&&(this.resendProvisionalTimer!==null&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null),this.transport.send(F)?(this.stateChanged(c.STATUS_COMPLETED),this.H=setTimeout(()=>{this.timer_H()},E.TIMER_H),o&&o()):(this.onTransportError(),f&&f()))}}function C({_transactions:I},H){let F;switch(H.method){case i.INVITE:if(F=I.ist[H.via_branch],F){switch(F.state){case c.STATUS_PROCEEDING:F.transport.send(F.last_response);break;case c.STATUS_ACCEPTED:break}return!0}break;case i.ACK:if(F=I.ist[H.via_branch],F){if(F.state===c.STATUS_ACCEPTED)return!1;if(F.state===c.STATUS_COMPLETED)return F.state=c.STATUS_CONFIRMED,F.I=setTimeout(()=>{F.timer_I()},E.TIMER_I),!0}else return!1;break;case i.CANCEL:return F=I.ist[H.via_branch],F?(H.reply_sl(200),F.state!==c.STATUS_PROCEEDING):(H.reply_sl(481),!0);default:if(F=I.nist[H.via_branch],F){switch(F.state){case c.STATUS_TRYING:break;case c.STATUS_PROCEEDING:case c.STATUS_COMPLETED:F.transport.send(F.last_response);break}return!0}break}}return Jt={C:c,NonInviteClientTransaction:R,InviteClientTransaction:x,AckClientTransaction:S,NonInviteServerTransaction:N,InviteServerTransaction:k,checkTransaction:C},Jt}var Xt,bn;function We(){if(bn)return Xt;bn=1;const O=oe(),y=ie(),i=Yl(),_=Be(),E=new O("RequestSender"),t={onRequestTimeout:()=>{},onTransportError:()=>{},onReceiveResponse:()=>{},onAuthenticated:()=>{}};return Xt=class{constructor(d,l,g){this._ua=d,this._eventHandlers=g,this._method=l.method,this._request=l,this._auth=null,this._challenged=!1,this._staled=!1;for(const c in t)Object.prototype.hasOwnProperty.call(t,c)&&(this._eventHandlers[c]||(this._eventHandlers[c]=t[c]));d.status===d.C.STATUS_USER_CLOSED&&(this._method!==y.BYE||this._method!==y.ACK)&&this._eventHandlers.onTransportError()}send(){const d={onRequestTimeout:()=>{this._eventHandlers.onRequestTimeout()},onTransportError:()=>{this._eventHandlers.onTransportError()},onReceiveResponse:l=>{this._receiveResponse(l)}};switch(this._method){case"INVITE":this.clientTransaction=new _.InviteClientTransaction(this._ua,this._ua.transport,this._request,d);break;case"ACK":this.clientTransaction=new _.AckClientTransaction(this._ua,this._ua.transport,this._request,d);break;default:this.clientTransaction=new _.NonInviteClientTransaction(this._ua,this._ua.transport,this._request,d)}this._ua._configuration.authorization_jwt&&this._request.setHeader("Authorization",this._ua._configuration.authorization_jwt),this.clientTransaction.send()}_receiveResponse(d){let l,g;const c=d.status_code;if((c===401||c===407)&&(this._ua.configuration.password!==null||this._ua.configuration.ha1!==null)){if(d.status_code===401?(l=d.parseHeader("www-authenticate"),g="authorization"):(l=d.parseHeader("proxy-authenticate"),g="proxy-authorization"),!l){E.debug(`${d.status_code} with wrong or missing challenge, cannot authenticate`),this._eventHandlers.onReceiveResponse(d);return}if(!this._challenged||!this._staled&&l.stale===!0){if(this._auth||(this._auth=new i({username:this._ua.configuration.authorization_user,password:this._ua.configuration.password,realm:this._ua.configuration.realm,ha1:this._ua.configuration.ha1})),!this._auth.authenticate(this._request,l)){this._eventHandlers.onReceiveResponse(d);return}this._challenged=!0,this._ua.set("realm",this._auth.get("realm")),this._ua.set("ha1",this._auth.get("ha1")),l.stale&&(this._staled=!0),this._request=this._request.clone(),this._request.cseq+=1,this._request.setHeader("cseq",`${this._request.cseq} ${this._method}`),this._request.setHeader(g,this._auth.toString()),this._eventHandlers.onAuthenticated(this._request),this.send()}else this._eventHandlers.onReceiveResponse(d)}else this._eventHandlers.onReceiveResponse(d)}},Xt}var Qt,Nn;function Jl(){if(Nn)return Qt;Nn=1;const O=oe(),y=ue(),i=ie(),_=ve(),E=We(),t=new O("Registrator"),h=10;return Qt=class{constructor(l,g){this._reg_id=1,this._ua=l,this._transport=g,this._registrar=l.configuration.registrar_server,this._expires=l.configuration.register_expires,this._call_id=y.createRandomToken(22),this._cseq=0,this._to_uri=l.configuration.uri,this._registrationTimer=null,this._registering=!1,this._registered=!1,this._contact=this._ua.contact.toString(),this._contact+=";+sip.ice",this._extraHeaders=[],this._extraContactParams="",this._sipInstance=`"<urn:uuid:${this._ua.configuration.instance_id}>"`,this._contact+=`;reg-id=${this._reg_id}`,this._contact+=`;+sip.instance=${this._sipInstance}`}get registered(){return this._registered}setExtraHeaders(l){Array.isArray(l)||(l=[]),this._extraHeaders=l.slice()}setExtraContactParams(l){l instanceof Object||(l={}),this._extraContactParams="";for(const g in l)if(Object.prototype.hasOwnProperty.call(l,g)){const c=l[g];this._extraContactParams+=`;${g}`,c&&(this._extraContactParams+=`=${c}`)}}register(){if(this._registering){t.debug("Register request in progress...");return}const l=this._extraHeaders.slice();let g;this._expires?(g=`${this._contact};expires=${this._expires}${this._extraContactParams}`,l.push(`Expires: ${this._expires}`)):g=`${this._contact}${this._extraContactParams}`,l.push(`Contact: ${g}`);let c=y.newTag();this._ua.configuration.register_from_tag_trail&&(typeof this._ua.configuration.register_from_tag_trail=="function"?c+=this._ua.configuration.register_from_tag_trail():c+=this._ua.configuration.register_from_tag_trail);const R=new _.OutgoingRequest(i.REGISTER,this._registrar,this._ua,{to_uri:this._to_uri,call_id:this._call_id,cseq:this._cseq+=1,from_tag:c},l),x=new E(this._ua,R,{onRequestTimeout:()=>{this._registrationFailure(null,i.causes.REQUEST_TIMEOUT)},onTransportError:()=>{this._registrationFailure(null,i.causes.CONNECTION_ERROR)},onAuthenticated:()=>{this._cseq+=1},onReceiveResponse:S=>{if(S.cseq===this._cseq)switch(this._registrationTimer!==null&&(clearTimeout(this._registrationTimer),this._registrationTimer=null),!0){case/^1[0-9]{2}$/.test(S.status_code):break;case/^2[0-9]{2}$/.test(S.status_code):{if(this._registering=!1,!S.hasHeader("Contact")){t.debug("no Contact header in response to REGISTER, response ignored");break}const N=S.headers.Contact.reduce((H,F)=>H.concat(F.parsed),[]);let k=N.find(H=>this._sipInstance===H.getParam("+sip.instance")&&this._reg_id===parseInt(H.getParam("reg-id")));if(k||(k=N.find(H=>H.uri.user===this._ua.contact.uri.user)),!k){t.debug("no Contact header pointing to us, response ignored");break}let C=k.getParam("expires");!C&&S.hasHeader("expires")&&(C=S.getHeader("expires")),C||(C=this._expires),C=Number(C),C<h&&(C=h);const I=C>64?C*1e3/2+Math.floor((C/2-32)*1e3*Math.random()):C*1e3-5e3;this._registrationTimer=setTimeout(()=>{this._registrationTimer=null,this._ua.listeners("registrationExpiring").length===0?this.register():this._ua.emit("registrationExpiring")},I),k.hasParam("temp-gruu")&&(this._ua.contact.temp_gruu=k.getParam("temp-gruu").replace(/"/g,"")),k.hasParam("pub-gruu")&&(this._ua.contact.pub_gruu=k.getParam("pub-gruu").replace(/"/g,"")),this._registered||(this._registered=!0,this._ua.registered({response:S}));break}case/^423$/.test(S.status_code):{S.hasHeader("min-expires")?(this._expires=Number(S.getHeader("min-expires")),this._expires<h&&(this._expires=h),this._registering=!1,this.register()):(t.debug("423 response received for REGISTER without Min-Expires"),this._registrationFailure(S,i.causes.SIP_FAILURE_CODE));break}default:{const N=y.sipErrorCause(S.status_code);this._registrationFailure(S,N)}}}});this._registering=!0,x.send()}unregister(l={}){if(!this._registered){t.debug("already unregistered");return}this._registered=!1,this._registrationTimer!==null&&(clearTimeout(this._registrationTimer),this._registrationTimer=null);const g=this._extraHeaders.slice();l.all?g.push(`Contact: *${this._extraContactParams}`):g.push(`Contact: ${this._contact};expires=0${this._extraContactParams}`),g.push("Expires: 0");const c=new _.OutgoingRequest(i.REGISTER,this._registrar,this._ua,{to_uri:this._to_uri,call_id:this._call_id,cseq:this._cseq+=1},g);new E(this._ua,c,{onRequestTimeout:()=>{this._unregistered(null,i.causes.REQUEST_TIMEOUT)},onTransportError:()=>{this._unregistered(null,i.causes.CONNECTION_ERROR)},onAuthenticated:()=>{this._cseq+=1},onReceiveResponse:x=>{switch(!0){case/^1[0-9]{2}$/.test(x.status_code):break;case/^2[0-9]{2}$/.test(x.status_code):this._unregistered(x);break;default:{const S=y.sipErrorCause(x.status_code);this._unregistered(x,S)}}}}).send()}close(){this._registered&&this.unregister()}onTransportClosed(){this._registering=!1,this._registrationTimer!==null&&(clearTimeout(this._registrationTimer),this._registrationTimer=null),this._registered&&(this._registered=!1,this._ua.unregistered({}))}_registrationFailure(l,g){this._registering=!1,this._ua.registrationFailed({response:l||null,cause:g}),this._registered&&(this._registered=!1,this._ua.unregistered({response:l||null,cause:g}))}_unregistered(l,g){this._registering=!1,this._registered=!1,this._ua.unregistered({response:l||null,cause:g||null})}},Qt}var Zt,On;function Xl(){if(On)return Zt;On=1;const O=ie(),y=Be(),i=We(),_={onRequestTimeout:()=>{},onTransportError:()=>{},onSuccessResponse:()=>{},onErrorResponse:()=>{},onAuthenticated:()=>{},onDialogError:()=>{}};return Zt=class{constructor(t,h,d){this._dialog=t,this._ua=t._ua,this._request=h,this._eventHandlers=d,this._reattempt=!1,this._reattemptTimer=null;for(const l in _)Object.prototype.hasOwnProperty.call(_,l)&&(this._eventHandlers[l]||(this._eventHandlers[l]=_[l]))}get request(){return this._request}send(){const t=new i(this._ua,this._request,{onRequestTimeout:()=>{this._eventHandlers.onRequestTimeout()},onTransportError:()=>{this._eventHandlers.onTransportError()},onAuthenticated:h=>{this._eventHandlers.onAuthenticated(h)},onReceiveResponse:h=>{this._receiveResponse(h)}});if(t.send(),(this._request.method===O.INVITE||this._request.method===O.UPDATE&&this._request.body)&&t.clientTransaction.state!==y.C.STATUS_TERMINATED){this._dialog.uac_pending_reply=!0;const h=()=>{(t.clientTransaction.state===y.C.STATUS_ACCEPTED||t.clientTransaction.state===y.C.STATUS_COMPLETED||t.clientTransaction.state===y.C.STATUS_TERMINATED)&&(t.clientTransaction.removeListener("stateChanged",h),this._dialog.uac_pending_reply=!1)};t.clientTransaction.on("stateChanged",h)}}_receiveResponse(t){t.status_code===408||t.status_code===481?this._eventHandlers.onDialogError(t):t.method===O.INVITE&&t.status_code===491?this._reattempt?this._eventHandlers.onErrorResponse(t):(this._request.cseq=this._dialog.local_seqnum+=1,this._reattemptTimer=setTimeout(()=>{this._dialog.isTerminated()||(this._reattempt=!0,this.send())},1e3)):t.status_code>=200&&t.status_code<300?this._eventHandlers.onSuccessResponse(t):t.status_code>=300&&this._eventHandlers.onErrorResponse(t)}},Zt}var es,Dn;function Ql(){if(Dn)return es;Dn=1;const O=oe(),y=ve(),i=ie(),_=Be(),E=Xl(),t=ue(),h=new O("Dialog"),d={STATUS_EARLY:1,STATUS_CONFIRMED:2,STATUS_TERMINATED:3};return es=class{static get C(){return d}constructor(g,c,R,x=d.STATUS_CONFIRMED){if(this._owner=g,this._ua=g._ua,this._uac_pending_reply=!1,this._uas_pending_reply=!1,!c.hasHeader("contact"))return{error:"unable to create a Dialog without Contact header field"};c instanceof y.IncomingResponse&&(x=c.status_code<200?d.STATUS_EARLY:d.STATUS_CONFIRMED);const S=c.parseHeader("contact");R==="UAS"?(this._id={call_id:c.call_id,local_tag:c.to_tag,remote_tag:c.from_tag,toString(){return this.call_id+this.local_tag+this.remote_tag}},this._state=x,this._remote_seqnum=c.cseq,this._local_uri=c.parseHeader("to").uri,this._remote_uri=c.parseHeader("from").uri,this._remote_target=S.uri,this._route_set=c.getHeaders("record-route"),this.incoming_ack_seqnum=c.cseq,this.outgoing_ack_seqnum=null):R==="UAC"&&(this._id={call_id:c.call_id,local_tag:c.from_tag,remote_tag:c.to_tag,toString(){return this.call_id+this.local_tag+this.remote_tag}},this._state=x,this._local_seqnum=c.cseq,this._local_uri=c.parseHeader("from").uri,this._remote_uri=c.parseHeader("to").uri,this._remote_target=S.uri,this._route_set=c.getHeaders("record-route").reverse(),this.incoming_ack_seqnum=null,this.outgoing_ack_seqnum=this._local_seqnum),this._ua.newDialog(this),h.debug(`new ${R} dialog created with status ${this._state===d.STATUS_EARLY?"EARLY":"CONFIRMED"}`)}get id(){return this._id}get local_seqnum(){return this._local_seqnum}set local_seqnum(g){this._local_seqnum=g}get owner(){return this._owner}get uac_pending_reply(){return this._uac_pending_reply}set uac_pending_reply(g){this._uac_pending_reply=g}get uas_pending_reply(){return this._uas_pending_reply}isTerminated(){return this._status===d.STATUS_TERMINATED}update(g,c){this._state=d.STATUS_CONFIRMED,h.debug(`dialog ${this._id.toString()} changed to CONFIRMED state`),c==="UAC"&&(this._route_set=g.getHeaders("record-route").reverse())}terminate(){h.debug(`dialog ${this._id.toString()} deleted`),this._ua.destroyDialog(this),this._state=d.STATUS_TERMINATED}sendRequest(g,c={}){const R=t.cloneArray(c.extraHeaders),x=t.cloneObject(c.eventHandlers),S=c.body||null,N=this._createRequest(g,R,S);return x.onAuthenticated=()=>{this._local_seqnum+=1,N.method===i.INVITE&&(this._outgoing_ack_seqnum=this._local_seqnum)},new E(this,N,x).send(),N}receiveRequest(g){this._checkInDialogRequest(g)&&(g.method===i.ACK&&this.incoming_ack_seqnum!==null?this.incoming_ack_seqnum=null:g.method===i.INVITE&&(this.incoming_ack_seqnum=g.cseq),this._owner.receiveRequest(g))}_createRequest(g,c,R){c=t.cloneArray(c),this._local_seqnum||(this._local_seqnum=Math.floor(Math.random()*1e4));const x=g===i.CANCEL||g===i.ACK?this.outgoing_ack_seqnum:this._local_seqnum+=1;return g===i.INVITE&&(this.outgoing_ack_seqnum=x),new y.OutgoingRequest(g,this._remote_target,this._ua,{cseq:x,call_id:this._id.call_id,from_uri:this._local_uri,from_tag:this._id.local_tag,to_uri:this._remote_uri,to_tag:this._id.remote_tag,route_set:this._route_set},c,R)}_checkInDialogRequest(g){if(!this._remote_seqnum)this._remote_seqnum=g.cseq;else if(g.cseq<this._remote_seqnum)if(g.method===i.ACK){if(this.incoming_ack_seqnum===null||g.cseq!==this.incoming_ack_seqnum)return!1}else return g.reply(500),!1;else g.cseq>this._remote_seqnum&&(this._remote_seqnum=g.cseq);if(g.method===i.INVITE||g.method===i.UPDATE&&g.body){if(this._uac_pending_reply===!0)g.reply(491);else if(this._uas_pending_reply===!0){const c=(Math.random()*10|0)+1;return g.reply(500,null,[`Retry-After:${c}`]),!1}else{this._uas_pending_reply=!0;const c=()=>{(g.server_transaction.state===_.C.STATUS_ACCEPTED||g.server_transaction.state===_.C.STATUS_COMPLETED||g.server_transaction.state===_.C.STATUS_TERMINATED)&&(g.server_transaction.removeListener("stateChanged",c),this._uas_pending_reply=!1)};g.server_transaction.on("stateChanged",c)}g.hasHeader("contact")&&g.server_transaction.on("stateChanged",()=>{g.server_transaction.state===_.C.STATUS_ACCEPTED&&(this._remote_target=g.parseHeader("contact").uri)})}else g.method===i.NOTIFY&&g.hasHeader("contact")&&g.server_transaction.on("stateChanged",()=>{g.server_transaction.state===_.C.STATUS_COMPLETED&&(this._remote_target=g.parseHeader("contact").uri)});return!0}},es}var ct={exports:{}},xn;function Zl(){if(xn)return ct.exports;xn=1;const O=Ie().EventEmitter,y=oe(),i=ie(),_=Re(),E=ue(),t=new y("RTCSession:DTMF"),h={MIN_DURATION:70,MAX_DURATION:6e3,DEFAULT_DURATION:100,MIN_INTER_TONE_GAP:50,DEFAULT_INTER_TONE_GAP:500};return ct.exports=class extends O{constructor(l){super(),this._session=l,this._direction=null,this._tone=null,this._duration=null,this._request=null}get tone(){return this._tone}get duration(){return this._duration}send(l,g={}){if(l===void 0)throw new TypeError("Not enough arguments");if(this._direction="outgoing",this._session.status!==this._session.C.STATUS_CONFIRMED&&this._session.status!==this._session.C.STATUS_WAITING_FOR_ACK&&this._session.status!==this._session.C.STATUS_1XX_RECEIVED)throw new _.InvalidStateError(this._session.status);const c=E.cloneArray(g.extraHeaders);if(this.eventHandlers=E.cloneObject(g.eventHandlers),typeof l=="string")l=l.toUpperCase();else if(typeof l=="number")l=l.toString();else throw new TypeError(`Invalid tone: ${l}`);if(l.match(/^[0-9A-DR#*]$/))this._tone=l;else throw new TypeError(`Invalid tone: ${l}`);this._duration=g.duration,c.push("Content-Type: application/dtmf-relay");let R=`Signal=${this._tone}\r
|
|
44
|
+
`;R+=`Duration=${this._duration}`,this._session.newDTMF({originator:"local",dtmf:this,request:this._request}),this._session.sendRequest(i.INFO,{extraHeaders:c,eventHandlers:{onSuccessResponse:x=>{this.emit("succeeded",{originator:"remote",response:x})},onErrorResponse:x=>{this.eventHandlers.onFailed&&this.eventHandlers.onFailed(),this.emit("failed",{originator:"remote",response:x})},onRequestTimeout:()=>{this._session.onRequestTimeout()},onTransportError:()=>{this._session.onTransportError()},onDialogError:()=>{this._session.onDialogError()}},body:R})}init_incoming(l){const g=/^(Signal\s*?=\s*?)([0-9A-D#*]{1})(\s)?.*/,c=/^(Duration\s?=\s?)([0-9]{1,4})(\s)?.*/;if(this._direction="incoming",this._request=l,l.reply(200),l.body){const R=l.body.split(`
|
|
45
|
+
`);R.length>=1&&g.test(R[0])&&(this._tone=R[0].replace(g,"$2")),R.length>=2&&c.test(R[1])&&(this._duration=parseInt(R[1].replace(c,"$2"),10))}this._duration||(this._duration=h.DEFAULT_DURATION),this._tone?this._session.newDTMF({originator:"remote",dtmf:this,request:l}):t.debug("invalid INFO DTMF received, discarded")}},ct.exports.C=h,ct.exports}var ts,Un;function ei(){if(Un)return ts;Un=1;const O=Ie().EventEmitter,y=ie(),i=Re(),_=ue();return ts=class extends O{constructor(t){super(),this._session=t,this._direction=null,this._contentType=null,this._body=null}get contentType(){return this._contentType}get body(){return this._body}send(t,h,d={}){if(this._direction="outgoing",t===void 0)throw new TypeError("Not enough arguments");if(this._session.status!==this._session.C.STATUS_CONFIRMED&&this._session.status!==this._session.C.STATUS_WAITING_FOR_ACK)throw new i.InvalidStateError(this._session.status);this._contentType=t,this._body=h;const l=_.cloneArray(d.extraHeaders);l.push(`Content-Type: ${t}`),this._session.newInfo({originator:"local",info:this,request:this.request}),this._session.sendRequest(y.INFO,{extraHeaders:l,eventHandlers:{onSuccessResponse:g=>{this.emit("succeeded",{originator:"remote",response:g})},onErrorResponse:g=>{this.emit("failed",{originator:"remote",response:g})},onTransportError:()=>{this._session.onTransportError()},onRequestTimeout:()=>{this._session.onRequestTimeout()},onDialogError:()=>{this._session.onDialogError()}},body:h})}init_incoming(t){this._direction="incoming",this.request=t,t.reply(200),this._contentType=t.hasHeader("Content-Type")?t.getHeader("Content-Type").toLowerCase():void 0,this._body=t.body,this._session.newInfo({originator:"remote",info:this,request:t})}},ts}var ss,Pn;function ti(){if(Pn)return ss;Pn=1;const O=oe(),y=ie(),i=new O("RTCSession:ReferNotifier"),_={event_type:"refer",body_type:"message/sipfrag;version=2.0",expires:300};return ss=class{constructor(t,h,d){this._session=t,this._id=h,this._expires=d||_.expires,this._active=!0,this.notify(100)}notify(t,h){if(i.debug("notify()"),this._active===!1)return;h=h||y.REASON_PHRASE[t]||"";let d;t>=200?d="terminated;reason=noresource":d=`active;expires=${this._expires}`,this._session.sendRequest(y.NOTIFY,{extraHeaders:[`Event: ${_.event_type};id=${this._id}`,`Subscription-State: ${d}`,`Content-Type: ${_.body_type}`],body:`SIP/2.0 ${t} ${h}`,eventHandlers:{onErrorResponse(){this._active=!1}}})}},ss}var rs,Ln;function si(){if(Ln)return rs;Ln=1;const O=Ie().EventEmitter,y=oe(),i=ie(),_=ge(),E=ue(),t=new y("RTCSession:ReferSubscriber");return rs=class extends O{constructor(d){super(),this._id=null,this._session=d}get id(){return this._id}sendRefer(d,l={}){t.debug("sendRefer()");const g=E.cloneArray(l.extraHeaders),c=E.cloneObject(l.eventHandlers);for(const N in c)Object.prototype.hasOwnProperty.call(c,N)&&this.on(N,c[N]);let R=null;l.replaces&&(R=l.replaces._request.call_id,R+=`;to-tag=${l.replaces._to_tag}`,R+=`;from-tag=${l.replaces._from_tag}`,R=encodeURIComponent(R));const x=`Refer-To: <${d}${R?`?Replaces=${R}`:""}>`;if(g.push(x),!g.some(N=>N.toLowerCase().startsWith("referred-by:"))){const N=`Referred-By: <${this._session._ua._configuration.uri._scheme}:${this._session._ua._configuration.uri._user}@${this._session._ua._configuration.uri._host}>`;g.push(N)}g.push(`Contact: ${this._session.contact}`);const S=this._session.sendRequest(i.REFER,{extraHeaders:g,eventHandlers:{onSuccessResponse:N=>{this._requestSucceeded(N)},onErrorResponse:N=>{this._requestFailed(N,i.causes.REJECTED)},onTransportError:()=>{this._requestFailed(null,i.causes.CONNECTION_ERROR)},onRequestTimeout:()=>{this._requestFailed(null,i.causes.REQUEST_TIMEOUT)},onDialogError:()=>{this._requestFailed(null,i.causes.DIALOG_ERROR)}}});this._id=S.cseq}receiveNotify(d){if(t.debug("receiveNotify()"),!d.body)return;const l=_.parse(d.body.trim().split(`\r
|
|
46
|
+
`,1)[0],"Status_Line");if(l===-1){t.debug(`receiveNotify() | error parsing NOTIFY body: "${d.body}"`);return}switch(!0){case/^100$/.test(l.status_code):this.emit("trying",{request:d,status_line:l});break;case/^1[0-9]{2}$/.test(l.status_code):this.emit("progress",{request:d,status_line:l});break;case/^2[0-9]{2}$/.test(l.status_code):this.emit("accepted",{request:d,status_line:l});break;default:this.emit("failed",{request:d,status_line:l});break}}_requestSucceeded(d){t.debug("REFER succeeded"),t.debug('emit "requestSucceeded"'),this.emit("requestSucceeded",{response:d})}_requestFailed(d,l){t.debug("REFER failed"),t.debug('emit "requestFailed"'),this.emit("requestFailed",{response:d||null,cause:l})}},rs}var ns,Mn;function Zn(){if(Mn)return ns;Mn=1;const O=Ie().EventEmitter,y=Xn(),i=oe(),_=ie(),E=Re(),t=Be(),h=ue(),d=Qn(),l=ve(),g=Ql(),c=We(),R=Zl(),x=ei(),S=ti(),N=si(),k=ye(),C=new i("RTCSession"),I={STATUS_NULL:0,STATUS_INVITE_SENT:1,STATUS_1XX_RECEIVED:2,STATUS_INVITE_RECEIVED:3,STATUS_WAITING_FOR_ANSWER:4,STATUS_ANSWERED:5,STATUS_WAITING_FOR_ACK:6,STATUS_CANCELED:7,STATUS_TERMINATED:8,STATUS_CONFIRMED:9},H=["audio","video"];return ns=class ms extends O{static get C(){return I}constructor(o){C.debug("new"),super(),this._id=null,this._ua=o,this._status=I.STATUS_NULL,this._dialog=null,this._earlyDialogs={},this._contact=null,this._from_tag=null,this._to_tag=null,this._connection=null,this._connectionPromiseQueue=Promise.resolve(),this._request=null,this._is_canceled=!1,this._cancel_reason="",this._is_confirmed=!1,this._late_sdp=!1,this._rtcOfferConstraints=null,this._rtcAnswerConstraints=null,this._localMediaStream=null,this._localMediaStreamLocallyGenerated=!1,this._rtcReady=!0,this._iceReady=!1,this._timers={ackTimer:null,expiresTimer:null,invite2xxTimer:null,userNoAnswerTimer:null},this._direction=null,this._local_identity=null,this._remote_identity=null,this._start_time=null,this._end_time=null,this._tones=null,this._audioMuted=!1,this._videoMuted=!1,this._localHold=!1,this._remoteHold=!1,this._sessionTimers={enabled:this._ua.configuration.session_timers,refreshMethod:this._ua.configuration.session_timers_refresh_method,defaultExpires:_.SESSION_EXPIRES,currentExpires:null,running:!1,refresher:!1,timer:null},this._referSubscribers={},this._data={}}get C(){return I}get causes(){return _.causes}get id(){return this._id}get connection(){return this._connection}get contact(){return this._contact}get direction(){return this._direction}get local_identity(){return this._local_identity}get remote_identity(){return this._remote_identity}get start_time(){return this._start_time}get end_time(){return this._end_time}get data(){return this._data}set data(o){this._data=o}get status(){return this._status}isInProgress(){switch(this._status){case I.STATUS_NULL:case I.STATUS_INVITE_SENT:case I.STATUS_1XX_RECEIVED:case I.STATUS_INVITE_RECEIVED:case I.STATUS_WAITING_FOR_ANSWER:return!0;default:return!1}}isEstablished(){switch(this._status){case I.STATUS_ANSWERED:case I.STATUS_WAITING_FOR_ACK:case I.STATUS_CONFIRMED:return!0;default:return!1}}isEnded(){switch(this._status){case I.STATUS_CANCELED:case I.STATUS_TERMINATED:return!0;default:return!1}}isMuted(){return{audio:this._audioMuted,video:this._videoMuted}}isOnHold(){return{local:this._localHold,remote:this._remoteHold}}connect(o,f={},T){C.debug("connect()");const p=o,A=h.cloneObject(f.eventHandlers),D=h.cloneArray(f.extraHeaders),v=h.cloneObject(f.mediaConstraints,{audio:!0,video:!0}),w=f.mediaStream||null,U=h.cloneObject(f.pcConfig,{iceServers:[]}),M=f.rtcConstraints||null,ee=f.rtcOfferConstraints||null;if(this._rtcOfferConstraints=ee,this._rtcAnswerConstraints=f.rtcAnswerConstraints||null,this._data=f.data||this._data,o===void 0)throw new TypeError("Not enough arguments");if(this._status!==I.STATUS_NULL)throw new E.InvalidStateError(this._status);if(!window.RTCPeerConnection)throw new E.NotSupportedError("WebRTC not supported");if(o=this._ua.normalizeTarget(o),!o)throw new TypeError(`Invalid target: ${p}`);this._sessionTimers.enabled&&h.isDecimal(f.sessionTimersExpires)&&(f.sessionTimersExpires>=_.MIN_SESSION_EXPIRES?this._sessionTimers.defaultExpires=f.sessionTimersExpires:this._sessionTimers.defaultExpires=_.SESSION_EXPIRES);for(const fe in A)Object.prototype.hasOwnProperty.call(A,fe)&&this.on(fe,A[fe]);this._from_tag=h.newTag();const B=f.anonymous||!1,ae={from_tag:this._from_tag};this._contact=this._ua.contact.toString({anonymous:B,outbound:!0}),B?(ae.from_display_name="Anonymous",ae.from_uri=new k("sip","anonymous","anonymous.invalid"),D.push(`P-Preferred-Identity: ${this._ua.configuration.uri.toString()}`),D.push("Privacy: id")):f.fromUserName&&(ae.from_uri=new k("sip",f.fromUserName,this._ua.configuration.uri.host),D.push(`P-Preferred-Identity: ${this._ua.configuration.uri.toString()}`)),f.fromDisplayName&&(ae.from_display_name=f.fromDisplayName),D.push(`Contact: ${this._contact}`),D.push("Content-Type: application/sdp"),this._sessionTimers.enabled&&D.push(`Session-Expires: ${this._sessionTimers.defaultExpires}${this._ua.configuration.session_timers_force_refresher?";refresher=uac":""}`),this._request=new l.InitialOutgoingInviteRequest(o,this._ua,ae,D),this._id=this._request.call_id+this._from_tag,this._createRTCConnection(U,M),this._direction="outgoing",this._local_identity=this._request.from,this._remote_identity=this._request.to,T&&T(this),this._newRTCSession("local",this._request),this._sendInitialRequest(v,ee,w)}init_incoming(o,f){C.debug("init_incoming()");let T;const p=o.hasHeader("Content-Type")?o.getHeader("Content-Type").toLowerCase():void 0;if(o.body&&p!=="application/sdp"){o.reply(415);return}if(this._status=I.STATUS_INVITE_RECEIVED,this._from_tag=o.from_tag,this._id=o.call_id+this._from_tag,this._request=o,this._contact=this._ua.contact.toString(),o.hasHeader("expires")&&(T=o.getHeader("expires")*1e3),o.to_tag=h.newTag(),!this._createDialog(o,"UAS",!0)){o.reply(500,"Missing Contact header field");return}o.body?this._late_sdp=!1:this._late_sdp=!0,this._status=I.STATUS_WAITING_FOR_ANSWER,this._timers.userNoAnswerTimer=setTimeout(()=>{o.reply(408),this._failed("local",null,_.causes.NO_ANSWER)},this._ua.configuration.no_answer_timeout),T&&(this._timers.expiresTimer=setTimeout(()=>{this._status===I.STATUS_WAITING_FOR_ANSWER&&(o.reply(487),this._failed("system",null,_.causes.EXPIRES))},T)),this._direction="incoming",this._local_identity=o.to,this._remote_identity=o.from,f&&f(this),this._newRTCSession("remote",o),this._status!==I.STATUS_TERMINATED&&(o.reply(180,null,[`Contact: ${this._contact}`]),this._progress("local",null))}answer(o={}){C.debug("answer()");const f=this._request,T=h.cloneArray(o.extraHeaders),p=h.cloneObject(o.mediaConstraints),A=o.mediaStream||null,D=h.cloneObject(o.pcConfig,{iceServers:[]}),v=o.rtcConstraints||null,w=o.rtcAnswerConstraints||null,U=h.cloneObject(o.rtcOfferConstraints);let M,ee=!1,B=!1,ae=!1,fe=!1;if(this._rtcAnswerConstraints=w,this._rtcOfferConstraints=o.rtcOfferConstraints||null,this._data=o.data||this._data,this._direction!=="incoming")throw new E.NotSupportedError('"answer" not supported for outgoing RTCSession');if(this._status!==I.STATUS_WAITING_FOR_ANSWER)throw new E.InvalidStateError(this._status);if(this._sessionTimers.enabled&&h.isDecimal(o.sessionTimersExpires)&&(o.sessionTimersExpires>=_.MIN_SESSION_EXPIRES?this._sessionTimers.defaultExpires=o.sessionTimersExpires:this._sessionTimers.defaultExpires=_.SESSION_EXPIRES),this._status=I.STATUS_ANSWERED,!this._createDialog(f,"UAS")){f.reply(500,"Error creating dialog");return}clearTimeout(this._timers.userNoAnswerTimer),T.unshift(`Contact: ${this._contact}`);const ce=f.parseSDP();Array.isArray(ce.media)||(ce.media=[ce.media]);for(const Y of ce.media)Y.type==="audio"&&(ee=!0,(!Y.direction||Y.direction==="sendrecv")&&(ae=!0)),Y.type==="video"&&(B=!0,(!Y.direction||Y.direction==="sendrecv")&&(fe=!0));if(A&&p.audio===!1){M=A.getAudioTracks();for(const Y of M)A.removeTrack(Y)}if(A&&p.video===!1){M=A.getVideoTracks();for(const Y of M)A.removeTrack(Y)}!A&&p.audio===void 0&&(p.audio=ae),!A&&p.video===void 0&&(p.video=fe),!A&&!ee&&!U.offerToReceiveAudio&&(p.audio=!1),!A&&!B&&!U.offerToReceiveVideo&&(p.video=!1),this._createRTCConnection(D,v),Promise.resolve().then(()=>{if(A)return A;if(p.audio||p.video)return this._localMediaStreamLocallyGenerated=!0,navigator.mediaDevices.getUserMedia(p).catch(Y=>{throw this._status===I.STATUS_TERMINATED?new Error("terminated"):(f.reply(480),this._failed("local",null,_.causes.USER_DENIED_MEDIA_ACCESS),C.warn('emit "getusermediafailed" [error:%o]',Y),this.emit("getusermediafailed",Y),new Error("getUserMedia() failed"))})}).then(Y=>{if(this._status===I.STATUS_TERMINATED)throw new Error("terminated");this._localMediaStream=Y,Y&&Y.getTracks().forEach(he=>{this._connection.addTrack(he,Y)})}).then(()=>{if(this._late_sdp)return;const Y={originator:"remote",type:"offer",sdp:f.body};C.debug('emit "sdp"'),this.emit("sdp",Y);const he=new RTCSessionDescription({type:"offer",sdp:Y.sdp});return this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(he)).catch(J=>{throw f.reply(488),this._failed("system",null,_.causes.WEBRTC_ERROR),C.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',J),this.emit("peerconnection:setremotedescriptionfailed",J),new Error("peerconnection.setRemoteDescription() failed")}),this._connectionPromiseQueue}).then(()=>{if(this._status===I.STATUS_TERMINATED)throw new Error("terminated");return this._connecting(f),this._late_sdp?this._createLocalDescription("offer",this._rtcOfferConstraints).catch(()=>{throw f.reply(500),new Error("_createLocalDescription() failed")}):this._createLocalDescription("answer",w).catch(()=>{throw f.reply(500),new Error("_createLocalDescription() failed")})}).then(Y=>{if(this._status===I.STATUS_TERMINATED)throw new Error("terminated");this._handleSessionTimersInIncomingRequest(f,T),f.reply(200,null,T,Y,()=>{this._status=I.STATUS_WAITING_FOR_ACK,this._setInvite2xxTimer(f,Y),this._setACKTimer(),this._accepted("local")},()=>{this._failed("system",null,_.causes.CONNECTION_ERROR)})}).catch(Y=>{this._status!==I.STATUS_TERMINATED&&(C.warn(`answer() failed: ${Y.message}`),this._failed("system",Y.message,_.causes.INTERNAL_ERROR))})}terminate(o={}){C.debug("terminate()");const f=o.cause||_.causes.BYE,T=h.cloneArray(o.extraHeaders),p=o.body;let A,D=o.status_code,v=o.reason_phrase;if(this._status===I.STATUS_TERMINATED)throw new E.InvalidStateError(this._status);switch(this._status){case I.STATUS_NULL:case I.STATUS_INVITE_SENT:case I.STATUS_1XX_RECEIVED:if(C.debug("canceling session"),D&&(D<200||D>=700))throw new TypeError(`Invalid status_code: ${D}`);D&&(v=v||_.REASON_PHRASE[D]||"",A=`SIP ;cause=${D} ;text="${v}"`),this._status===I.STATUS_NULL||this._status===I.STATUS_INVITE_SENT?(this._is_canceled=!0,this._cancel_reason=A):this._status===I.STATUS_1XX_RECEIVED&&this._request.cancel(A),this._status=I.STATUS_CANCELED,this._failed("local",null,_.causes.CANCELED);break;case I.STATUS_WAITING_FOR_ANSWER:case I.STATUS_ANSWERED:if(C.debug("rejecting session"),D=D||480,D<300||D>=700)throw new TypeError(`Invalid status_code: ${D}`);this._request.reply(D,v,T,p),this._failed("local",null,_.causes.REJECTED);break;case I.STATUS_WAITING_FOR_ACK:case I.STATUS_CONFIRMED:if(C.debug("terminating session"),v=o.reason_phrase||_.REASON_PHRASE[D]||"",D&&(D<200||D>=700))throw new TypeError(`Invalid status_code: ${D}`);if(D&&T.push(`Reason: SIP ;cause=${D}; text="${v}"`),this._status===I.STATUS_WAITING_FOR_ACK&&this._direction==="incoming"&&this._request.server_transaction.state!==t.C.STATUS_TERMINATED){const w=this._dialog;this.receiveRequest=({method:U})=>{U===_.ACK&&(this.sendRequest(_.BYE,{extraHeaders:T,body:p}),w.terminate())},this._request.server_transaction.on("stateChanged",()=>{this._request.server_transaction.state===t.C.STATUS_TERMINATED&&(this.sendRequest(_.BYE,{extraHeaders:T,body:p}),w.terminate())}),this._ended("local",null,f),this._dialog=w,this._ua.newDialog(w)}else this.sendRequest(_.BYE,{extraHeaders:T,body:p}),this._ended("local",null,f)}}sendDTMF(o,f={}){C.debug("sendDTMF() | tones: %s",o);let T=f.duration||null,p=f.interToneGap||null;const A=f.transportType||_.DTMF_TRANSPORT.INFO;if(o===void 0)throw new TypeError("Not enough arguments");if(this._status!==I.STATUS_CONFIRMED&&this._status!==I.STATUS_WAITING_FOR_ACK&&this._status!==I.STATUS_1XX_RECEIVED)throw new E.InvalidStateError(this._status);if(A!==_.DTMF_TRANSPORT.INFO&&A!==_.DTMF_TRANSPORT.RFC2833)throw new TypeError(`invalid transportType: ${A}`);if(typeof o=="number"&&(o=o.toString()),!o||typeof o!="string"||!o.match(/^[0-9A-DR#*,]+$/i))throw new TypeError(`Invalid tones: ${o}`);if(T&&!h.isDecimal(T))throw new TypeError(`Invalid tone duration: ${T}`);if(T?T<R.C.MIN_DURATION?(C.debug(`"duration" value is lower than the minimum allowed, setting it to ${R.C.MIN_DURATION} milliseconds`),T=R.C.MIN_DURATION):T>R.C.MAX_DURATION?(C.debug(`"duration" value is greater than the maximum allowed, setting it to ${R.C.MAX_DURATION} milliseconds`),T=R.C.MAX_DURATION):T=Math.abs(T):T=R.C.DEFAULT_DURATION,f.duration=T,p&&!h.isDecimal(p))throw new TypeError(`Invalid interToneGap: ${p}`);if(p?p<R.C.MIN_INTER_TONE_GAP?(C.debug(`"interToneGap" value is lower than the minimum allowed, setting it to ${R.C.MIN_INTER_TONE_GAP} milliseconds`),p=R.C.MIN_INTER_TONE_GAP):p=Math.abs(p):p=R.C.DEFAULT_INTER_TONE_GAP,A===_.DTMF_TRANSPORT.RFC2833){const v=this._getDTMFRTPSender();v&&(o=v.toneBuffer+o,v.insertDTMF(o,T,p));return}if(this._tones){this._tones+=o;return}this._tones=o,D.call(this);function D(){let v;if(this._status===I.STATUS_TERMINATED||!this._tones){this._tones=null;return}const w=this._tones[0];if(this._tones=this._tones.substring(1),w===",")v=2e3;else{const U=new R(this);f.eventHandlers={onFailed:()=>{this._tones=null}},U.send(w,f),v=T+p}setTimeout(D.bind(this),v)}}sendInfo(o,f,T={}){if(C.debug("sendInfo()"),this._status!==I.STATUS_CONFIRMED&&this._status!==I.STATUS_WAITING_FOR_ACK&&this._status!==I.STATUS_1XX_RECEIVED)throw new E.InvalidStateError(this._status);new x(this).send(o,f,T)}mute(o={audio:!0,video:!1}){C.debug("mute()");let f=!1,T=!1;this._audioMuted===!1&&o.audio&&(f=!0,this._audioMuted=!0,this._toggleMuteAudio(!0)),this._videoMuted===!1&&o.video&&(T=!0,this._videoMuted=!0,this._toggleMuteVideo(!0)),(f===!0||T===!0)&&this._onmute({audio:f,video:T})}unmute(o={audio:!0,video:!0}){C.debug("unmute()");let f=!1,T=!1;this._audioMuted===!0&&o.audio&&(f=!0,this._audioMuted=!1,this._localHold===!1&&this._toggleMuteAudio(!1)),this._videoMuted===!0&&o.video&&(T=!0,this._videoMuted=!1,this._localHold===!1&&this._toggleMuteVideo(!1)),(f===!0||T===!0)&&this._onunmute({audio:f,video:T})}hold(o={},f){if(C.debug("hold()"),this._status!==I.STATUS_WAITING_FOR_ACK&&this._status!==I.STATUS_CONFIRMED||this._localHold===!0||!this.isReadyToReOffer())return!1;this._localHold=!0,this._onhold("local");const T={succeeded:()=>{f&&f()},failed:()=>{this.terminate({cause:_.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Hold Failed"})}};return o.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:T,extraHeaders:o.extraHeaders}):this._sendReinvite({eventHandlers:T,extraHeaders:o.extraHeaders}),!0}unhold(o={},f){if(C.debug("unhold()"),this._status!==I.STATUS_WAITING_FOR_ACK&&this._status!==I.STATUS_CONFIRMED||this._localHold===!1||!this.isReadyToReOffer())return!1;this._localHold=!1,this._onunhold("local");const T={succeeded:()=>{f&&f()},failed:()=>{this.terminate({cause:_.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Unhold Failed"})}};return o.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:T,extraHeaders:o.extraHeaders}):this._sendReinvite({eventHandlers:T,extraHeaders:o.extraHeaders}),!0}renegotiate(o={},f){C.debug("renegotiate()");const T=o.rtcOfferConstraints||null;if(this._status!==I.STATUS_WAITING_FOR_ACK&&this._status!==I.STATUS_CONFIRMED||!this.isReadyToReOffer())return!1;const p={succeeded:()=>{f&&f()},failed:()=>{this.terminate({cause:_.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Media Renegotiation Failed"})}};return this._setLocalMediaStatus(),o.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:p,rtcOfferConstraints:T,extraHeaders:o.extraHeaders}):this._sendReinvite({eventHandlers:p,rtcOfferConstraints:T,extraHeaders:o.extraHeaders}),!0}refer(o,f){C.debug("refer()");const T=o;if(this._status!==I.STATUS_WAITING_FOR_ACK&&this._status!==I.STATUS_CONFIRMED)return!1;if(o=this._ua.normalizeTarget(o),!o)throw new TypeError(`Invalid target: ${T}`);const p=new N(this);p.sendRefer(o,f);const A=p.id;return this._referSubscribers[A]=p,p.on("requestFailed",()=>{delete this._referSubscribers[A]}),p.on("accepted",()=>{delete this._referSubscribers[A]}),p.on("failed",()=>{delete this._referSubscribers[A]}),p}sendRequest(o,f){if(C.debug("sendRequest()"),this._dialog)return this._dialog.sendRequest(o,f);{const T=Object.values(this._earlyDialogs);if(T.length>0)return T[0].sendRequest(o,f);C.warn("sendRequest() | no valid early dialog found");return}}receiveRequest(o){if(C.debug("receiveRequest()"),o.method===_.CANCEL)(this._status===I.STATUS_WAITING_FOR_ANSWER||this._status===I.STATUS_ANSWERED)&&(this._status=I.STATUS_CANCELED,this._request.reply(487),this._failed("remote",o,_.causes.CANCELED));else switch(o.method){case _.ACK:if(this._status!==I.STATUS_WAITING_FOR_ACK)return;if(this._status=I.STATUS_CONFIRMED,clearTimeout(this._timers.ackTimer),clearTimeout(this._timers.invite2xxTimer),this._late_sdp){if(!o.body){this.terminate({cause:_.causes.MISSING_SDP,status_code:400});break}const f={originator:"remote",type:"answer",sdp:o.body};C.debug('emit "sdp"'),this.emit("sdp",f);const T=new RTCSessionDescription({type:"answer",sdp:f.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(T)).then(()=>{this._is_confirmed||this._confirmed("remote",o)}).catch(p=>{this.terminate({cause:_.causes.BAD_MEDIA_DESCRIPTION,status_code:488}),C.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',p),this.emit("peerconnection:setremotedescriptionfailed",p)})}else this._is_confirmed||this._confirmed("remote",o);break;case _.BYE:this._status===I.STATUS_CONFIRMED||this._status===I.STATUS_WAITING_FOR_ACK?(o.reply(200),this._ended("remote",o,_.causes.BYE)):this._status===I.STATUS_INVITE_RECEIVED||this._status===I.STATUS_WAITING_FOR_ANSWER?(o.reply(200),this._request.reply(487,"BYE Received"),this._ended("remote",o,_.causes.BYE)):o.reply(403,"Wrong Status");break;case _.INVITE:this._status===I.STATUS_CONFIRMED?o.hasHeader("replaces")?this._receiveReplaces(o):this._receiveReinvite(o):o.reply(403,"Wrong Status");break;case _.INFO:if(this._status===I.STATUS_1XX_RECEIVED||this._status===I.STATUS_WAITING_FOR_ANSWER||this._status===I.STATUS_ANSWERED||this._status===I.STATUS_WAITING_FOR_ACK||this._status===I.STATUS_CONFIRMED){const f=o.hasHeader("Content-Type")?o.getHeader("Content-Type").toLowerCase():void 0;f&&f.match(/^application\/dtmf-relay/i)?new R(this).init_incoming(o):f!==void 0?new x(this).init_incoming(o):o.reply(415)}else o.reply(403,"Wrong Status");break;case _.UPDATE:this._status===I.STATUS_CONFIRMED?this._receiveUpdate(o):o.reply(403,"Wrong Status");break;case _.REFER:this._status===I.STATUS_CONFIRMED?this._receiveRefer(o):o.reply(403,"Wrong Status");break;case _.NOTIFY:this._status===I.STATUS_CONFIRMED?this._receiveNotify(o):o.reply(403,"Wrong Status");break;default:o.reply(501)}}onTransportError(){C.warn("onTransportError()"),this._status!==I.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:_.causes.CONNECTION_ERROR,cause:_.causes.CONNECTION_ERROR})}onRequestTimeout(){C.warn("onRequestTimeout()"),this._status!==I.STATUS_TERMINATED&&this.terminate({status_code:408,reason_phrase:_.causes.REQUEST_TIMEOUT,cause:_.causes.REQUEST_TIMEOUT})}onDialogError(){C.warn("onDialogError()"),this._status!==I.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:_.causes.DIALOG_ERROR,cause:_.causes.DIALOG_ERROR})}newDTMF(o){C.debug("newDTMF()"),this.emit("newDTMF",o)}newInfo(o){C.debug("newInfo()"),this.emit("newInfo",o)}isReadyToReOffer(){return this._rtcReady?this._dialog?this._dialog.uac_pending_reply===!0||this._dialog.uas_pending_reply===!0?(C.debug("isReadyToReOffer() | there is another INVITE/UPDATE transaction in progress"),!1):!0:(C.debug("isReadyToReOffer() | session not established yet"),!1):(C.debug("isReadyToReOffer() | internal WebRTC status not ready"),!1)}_close(){if(C.debug("close()"),this._localMediaStream&&this._localMediaStreamLocallyGenerated&&(C.debug("close() | closing local MediaStream"),h.closeMediaStream(this._localMediaStream)),this._status!==I.STATUS_TERMINATED){if(this._status=I.STATUS_TERMINATED,this._connection)try{this._connection.close()}catch(o){C.warn("close() | error closing the RTCPeerConnection: %o",o)}for(const o in this._timers)Object.prototype.hasOwnProperty.call(this._timers,o)&&clearTimeout(this._timers[o]);clearTimeout(this._sessionTimers.timer),this._dialog&&(this._dialog.terminate(),delete this._dialog);for(const o in this._earlyDialogs)Object.prototype.hasOwnProperty.call(this._earlyDialogs,o)&&(this._earlyDialogs[o].terminate(),delete this._earlyDialogs[o]);for(const o in this._referSubscribers)Object.prototype.hasOwnProperty.call(this._referSubscribers,o)&&delete this._referSubscribers[o];this._ua.destroyRTCSession(this)}}_setInvite2xxTimer(o,f){let T=d.T1;function p(){this._status===I.STATUS_WAITING_FOR_ACK&&(o.reply(200,null,[`Contact: ${this._contact}`],f),T<d.T2&&(T=T*2,T>d.T2&&(T=d.T2)),this._timers.invite2xxTimer=setTimeout(p.bind(this),T))}this._timers.invite2xxTimer=setTimeout(p.bind(this),T)}_setACKTimer(){this._timers.ackTimer=setTimeout(()=>{this._status===I.STATUS_WAITING_FOR_ACK&&(C.debug("no ACK received, terminating the session"),clearTimeout(this._timers.invite2xxTimer),this.sendRequest(_.BYE),this._ended("remote",null,_.causes.NO_ACK))},d.TIMER_H)}_createRTCConnection(o,f){this._connection=new RTCPeerConnection(o,f),this._connection.addEventListener("iceconnectionstatechange",()=>{this._connection.iceConnectionState==="failed"&&this.terminate({cause:_.causes.RTP_TIMEOUT,status_code:408,reason_phrase:_.causes.RTP_TIMEOUT})}),C.debug('emit "peerconnection"'),this.emit("peerconnection",{peerconnection:this._connection})}_createLocalDescription(o,f){if(C.debug("createLocalDescription()"),o!=="offer"&&o!=="answer")throw new Error(`createLocalDescription() | invalid type "${o}"`);const T=this._connection;return this._rtcReady=!1,Promise.resolve().then(()=>o==="offer"?T.createOffer(f).catch(p=>(C.warn('emit "peerconnection:createofferfailed" [error:%o]',p),this.emit("peerconnection:createofferfailed",p),Promise.reject(p))):T.createAnswer(f).catch(p=>(C.warn('emit "peerconnection:createanswerfailed" [error:%o]',p),this.emit("peerconnection:createanswerfailed",p),Promise.reject(p)))).then(p=>T.setLocalDescription(p).catch(A=>(this._rtcReady=!0,C.warn('emit "peerconnection:setlocaldescriptionfailed" [error:%o]',A),this.emit("peerconnection:setlocaldescriptionfailed",A),Promise.reject(A)))).then(()=>{const p=f&&f.iceRestart;if(T.iceGatheringState==="complete"&&!p||T.iceGatheringState==="gathering"&&this._iceReady){this._rtcReady=!0;const A={originator:"local",type:o,sdp:T.localDescription.sdp};return C.debug('emit "sdp"'),this.emit("sdp",A),Promise.resolve(A.sdp)}return new Promise(A=>{let D=!1,v,w;this._iceReady=!1;const U=()=>{if(D)return;T.removeEventListener("icecandidate",v),T.removeEventListener("icegatheringstatechange",w),D=!0,this._rtcReady=!0,this._iceReady=!0;const M={originator:"local",type:o,sdp:T.localDescription.sdp};C.debug('emit "sdp"'),this.emit("sdp",M),A(M.sdp)};T.addEventListener("icecandidate",v=M=>{const ee=M.candidate;ee?this.emit("icecandidate",{candidate:ee,ready:U}):U()}),T.addEventListener("icegatheringstatechange",w=()=>{T.iceGatheringState==="complete"&&U()})})})}_createDialog(o,f,T){const p=f==="UAS"?o.to_tag:o.from_tag,A=f==="UAS"?o.from_tag:o.to_tag,D=o.call_id+p+A;let v=this._earlyDialogs[D];if(T)return v?!0:(v=new g(this,o,f,g.C.STATUS_EARLY),v.error?(C.debug(v.error),this._failed("remote",o,_.causes.INTERNAL_ERROR),!1):(this._earlyDialogs[D]=v,!0));{if(this._from_tag=o.from_tag,this._to_tag=o.to_tag,v)return v.update(o,f),this._dialog=v,delete this._earlyDialogs[D],!0;const w=new g(this,o,f);return w.error?(C.debug(w.error),this._failed("remote",o,_.causes.INTERNAL_ERROR),!1):(this._dialog=w,!0)}}_receiveReinvite(o){C.debug("receiveReinvite()");const f=o.hasHeader("Content-Type")?o.getHeader("Content-Type").toLowerCase():void 0,T={request:o,callback:void 0,reject:A.bind(this)};let p=!1;function A(v={}){p=!0;const w=v.status_code||403,U=v.reason_phrase||"",M=h.cloneArray(v.extraHeaders);if(this._status!==I.STATUS_CONFIRMED)return!1;if(w<300||w>=700)throw new TypeError(`Invalid status_code: ${w}`);o.reply(w,U,M)}if(this.emit("reinvite",T),p)return;if(this._late_sdp=!1,!o.body){this._late_sdp=!0,this._remoteHold&&(this._remoteHold=!1,this._onunhold("remote")),this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._createLocalDescription("offer",this._rtcOfferConstraints)).then(v=>{D.call(this,v)}).catch(()=>{o.reply(500)});return}if(f!=="application/sdp"){C.debug("invalid Content-Type"),o.reply(415);return}this._processInDialogSdpOffer(o).then(v=>{this._status!==I.STATUS_TERMINATED&&D.call(this,v)}).catch(v=>{C.warn(v)});function D(v){const w=[`Contact: ${this._contact}`];this._handleSessionTimersInIncomingRequest(o,w),this._late_sdp&&(v=this._mangleOffer(v)),o.reply(200,null,w,v,()=>{this._status=I.STATUS_WAITING_FOR_ACK,this._setInvite2xxTimer(o,v),this._setACKTimer()}),typeof T.callback=="function"&&T.callback()}}_receiveUpdate(o){C.debug("receiveUpdate()");const f=o.hasHeader("Content-Type")?o.getHeader("Content-Type").toLowerCase():void 0,T={request:o,callback:void 0,reject:A.bind(this)};let p=!1;function A(v={}){p=!0;const w=v.status_code||403,U=v.reason_phrase||"",M=h.cloneArray(v.extraHeaders);if(this._status!==I.STATUS_CONFIRMED)return!1;if(w<300||w>=700)throw new TypeError(`Invalid status_code: ${w}`);o.reply(w,U,M)}if(this.emit("update",T),p)return;if(!o.body){D.call(this,null);return}if(f!=="application/sdp"){C.debug("invalid Content-Type"),o.reply(415);return}this._processInDialogSdpOffer(o).then(v=>{this._status!==I.STATUS_TERMINATED&&D.call(this,v)}).catch(v=>{C.warn(v)});function D(v){const w=[`Contact: ${this._contact}`];this._handleSessionTimersInIncomingRequest(o,w),o.reply(200,null,w,v),typeof T.callback=="function"&&T.callback()}}_processInDialogSdpOffer(o){C.debug("_processInDialogSdpOffer()");const f=o.parseSDP();let T=!1;for(const D of f.media){if(H.indexOf(D.type)===-1)continue;const v=D.direction||f.direction||"sendrecv";if(v==="sendonly"||v==="inactive")T=!0;else{T=!1;break}}const p={originator:"remote",type:"offer",sdp:o.body};C.debug('emit "sdp"'),this.emit("sdp",p);const A=new RTCSessionDescription({type:"offer",sdp:p.sdp});return this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>{if(this._status===I.STATUS_TERMINATED)throw new Error("terminated");return this._connection.setRemoteDescription(A).catch(D=>{throw o.reply(488),C.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',D),this.emit("peerconnection:setremotedescriptionfailed",D),D})}).then(()=>{if(this._status===I.STATUS_TERMINATED)throw new Error("terminated");this._remoteHold===!0&&T===!1?(this._remoteHold=!1,this._onunhold("remote")):this._remoteHold===!1&&T===!0&&(this._remoteHold=!0,this._onhold("remote"))}).then(()=>{if(this._status===I.STATUS_TERMINATED)throw new Error("terminated");return this._createLocalDescription("answer",this._rtcAnswerConstraints).catch(D=>{throw o.reply(500),C.warn('emit "peerconnection:createtelocaldescriptionfailed" [error:%o]',D),D})}).catch(D=>{C.warn("_processInDialogSdpOffer() failed [error: %o]",D)}),this._connectionPromiseQueue}_receiveRefer(o){if(C.debug("receiveRefer()"),!o.refer_to){C.debug("no Refer-To header field present in REFER"),o.reply(400);return}if(o.refer_to.uri.scheme!==_.SIP){C.debug("Refer-To header field points to a non-SIP URI scheme"),o.reply(416);return}o.reply(202);const f=new S(this,o.cseq);C.debug('emit "refer"'),this.emit("refer",{request:o,accept:(A,D)=>{T.call(this,A,D)},reject:()=>{p.call(this)}});function T(A,D={}){if(A=typeof A=="function"?A:null,this._status!==I.STATUS_WAITING_FOR_ACK&&this._status!==I.STATUS_CONFIRMED)return!1;const v=new ms(this._ua);if(v.on("progress",({response:w})=>{f.notify(w.status_code,w.reason_phrase)}),v.on("accepted",({response:w})=>{f.notify(w.status_code,w.reason_phrase)}),v.on("_failed",({message:w,cause:U})=>{w?f.notify(w.status_code,w.reason_phrase):f.notify(487,U)}),o.refer_to.uri.hasHeader("replaces")){const w=decodeURIComponent(o.refer_to.uri.getHeader("replaces"));D.extraHeaders=h.cloneArray(D.extraHeaders),D.extraHeaders.push(`Replaces: ${w}`)}v.connect(o.refer_to.uri.toAor(),D,A)}function p(){f.notify(603)}}_receiveNotify(o){switch(C.debug("receiveNotify()"),o.event||o.reply(400),o.event.event){case"refer":{let f,T;if(o.event.params&&o.event.params.id)f=o.event.params.id,T=this._referSubscribers[f];else if(Object.keys(this._referSubscribers).length===1)T=this._referSubscribers[Object.keys(this._referSubscribers)[0]];else{o.reply(400,"Missing event id parameter");return}if(!T){o.reply(481,"Subscription does not exist");return}T.receiveNotify(o),o.reply(200);break}default:o.reply(489)}}_receiveReplaces(o){C.debug("receiveReplaces()");function f(p){if(this._status!==I.STATUS_WAITING_FOR_ACK&&this._status!==I.STATUS_CONFIRMED)return!1;const A=new ms(this._ua);A.on("confirmed",()=>{this.terminate()}),A.init_incoming(o,p)}function T(){C.debug("Replaced INVITE rejected by the user"),o.reply(486)}this.emit("replaces",{request:o,accept:p=>{f.call(this,p)},reject:()=>{T.call(this)}})}_sendInitialRequest(o,f,T){const p=new c(this._ua,this._request,{onRequestTimeout:()=>{this.onRequestTimeout()},onTransportError:()=>{this.onTransportError()},onAuthenticated:A=>{this._request=A},onReceiveResponse:A=>{this._receiveInviteResponse(A)}});Promise.resolve().then(()=>{if(T)return T;if(o.audio||o.video)return this._localMediaStreamLocallyGenerated=!0,navigator.mediaDevices.getUserMedia(o).catch(A=>{throw this._status===I.STATUS_TERMINATED?new Error("terminated"):(this._failed("local",null,_.causes.USER_DENIED_MEDIA_ACCESS),C.warn('emit "getusermediafailed" [error:%o]',A),this.emit("getusermediafailed",A),A)})}).then(A=>{if(this._status===I.STATUS_TERMINATED)throw new Error("terminated");return this._localMediaStream=A,A&&A.getTracks().forEach(D=>{this._connection.addTrack(D,A)}),this._connecting(this._request),this._createLocalDescription("offer",f).catch(D=>{throw this._failed("local",null,_.causes.WEBRTC_ERROR),D})}).then(A=>{if(this._is_canceled||this._status===I.STATUS_TERMINATED)throw new Error("terminated");this._request.body=A,this._status=I.STATUS_INVITE_SENT,C.debug('emit "sending" [request:%o]',this._request),this.emit("sending",{request:this._request}),p.send()}).catch(A=>{this._status!==I.STATUS_TERMINATED&&C.warn(A)})}_getDTMFRTPSender(){const o=this._connection.getSenders().find(f=>f.track&&f.track.kind==="audio");if(!(o&&o.dtmf)){C.warn("sendDTMF() | no local audio track to send DTMF with");return}return o.dtmf}_receiveInviteResponse(o){if(C.debug("receiveInviteResponse()"),this._dialog&&o.status_code>=200&&o.status_code<=299)if(this._dialog.id.call_id===o.call_id&&this._dialog.id.local_tag===o.from_tag&&this._dialog.id.remote_tag===o.to_tag){this.sendRequest(_.ACK);return}else{const f=new g(this,o,"UAC");if(f.error!==void 0){C.debug(f.error);return}this.sendRequest(_.ACK),this.sendRequest(_.BYE);return}if(this._is_canceled){o.status_code>=100&&o.status_code<200?this._request.cancel(this._cancel_reason):o.status_code>=200&&o.status_code<299&&this._acceptAndTerminate(o);return}if(!(this._status!==I.STATUS_INVITE_SENT&&this._status!==I.STATUS_1XX_RECEIVED))switch(!0){case/^100$/.test(o.status_code):this._status=I.STATUS_1XX_RECEIVED;break;case/^1[0-9]{2}$/.test(o.status_code):{if(!o.to_tag){C.debug("1xx response received without to tag");break}if(o.hasHeader("contact")&&!this._createDialog(o,"UAC",!0))break;if(this._status=I.STATUS_1XX_RECEIVED,!o.body){this._progress("remote",o);break}const f={originator:"remote",type:"answer",sdp:o.body};C.debug('emit "sdp"'),this.emit("sdp",f);const T=new RTCSessionDescription({type:"answer",sdp:f.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(T)).then(()=>this._progress("remote",o)).catch(p=>{C.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',p),this.emit("peerconnection:setremotedescriptionfailed",p)});break}case/^2[0-9]{2}$/.test(o.status_code):{if(this._status=I.STATUS_CONFIRMED,!o.body){this._acceptAndTerminate(o,400,_.causes.MISSING_SDP),this._failed("remote",o,_.causes.BAD_MEDIA_DESCRIPTION);break}if(!this._createDialog(o,"UAC"))break;const f={originator:"remote",type:"answer",sdp:o.body};C.debug('emit "sdp"'),this.emit("sdp",f);const T=new RTCSessionDescription({type:"answer",sdp:f.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>{if(this._connection.signalingState==="stable")return this._connection.createOffer(this._rtcOfferConstraints).then(p=>this._connection.setLocalDescription(p)).catch(p=>{this._acceptAndTerminate(o,500,p.toString()),this._failed("local",o,_.causes.WEBRTC_ERROR)})}).then(()=>{this._connection.setRemoteDescription(T).then(()=>{this._handleSessionTimersInIncomingResponse(o),this._accepted("remote",o),this.sendRequest(_.ACK),this._confirmed("local",null)}).catch(p=>{this._acceptAndTerminate(o,488,"Not Acceptable Here"),this._failed("remote",o,_.causes.BAD_MEDIA_DESCRIPTION),C.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',p),this.emit("peerconnection:setremotedescriptionfailed",p)})});break}default:{const f=h.sipErrorCause(o.status_code);this._failed("remote",o,f)}}}_sendReinvite(o={}){C.debug("sendReinvite()");const f=h.cloneArray(o.extraHeaders),T=h.cloneObject(o.eventHandlers),p=o.rtcOfferConstraints||this._rtcOfferConstraints||null;let A=!1;f.push(`Contact: ${this._contact}`),f.push("Content-Type: application/sdp"),this._sessionTimers.running&&f.push(`Session-Expires: ${this._sessionTimers.currentExpires};refresher=${this._sessionTimers.refresher?"uac":"uas"}`),this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._createLocalDescription("offer",p)).then(w=>{w=this._mangleOffer(w);const U={originator:"local",type:"offer",sdp:w};C.debug('emit "sdp"'),this.emit("sdp",U),this.sendRequest(_.INVITE,{extraHeaders:f,body:w,eventHandlers:{onSuccessResponse:M=>{D.call(this,M),A=!0},onErrorResponse:M=>{v.call(this,M)},onTransportError:()=>{this.onTransportError()},onRequestTimeout:()=>{this.onRequestTimeout()},onDialogError:()=>{this.onDialogError()}}})}).catch(()=>{v()});function D(w){if(this._status===I.STATUS_TERMINATED||(this.sendRequest(_.ACK),A))return;if(this._handleSessionTimersInIncomingResponse(w),w.body){if(!w.hasHeader("Content-Type")||w.getHeader("Content-Type").toLowerCase()!=="application/sdp"){v.call(this);return}}else{v.call(this);return}const U={originator:"remote",type:"answer",sdp:w.body};C.debug('emit "sdp"'),this.emit("sdp",U);const M=new RTCSessionDescription({type:"answer",sdp:U.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(M)).then(()=>{T.succeeded&&T.succeeded(w)}).catch(ee=>{v.call(this),C.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',ee),this.emit("peerconnection:setremotedescriptionfailed",ee)})}function v(w){T.failed&&T.failed(w)}}_sendUpdate(o={}){C.debug("sendUpdate()");const f=h.cloneArray(o.extraHeaders),T=h.cloneObject(o.eventHandlers),p=o.rtcOfferConstraints||this._rtcOfferConstraints||null,A=o.sdpOffer||!1;let D=!1;f.push(`Contact: ${this._contact}`),this._sessionTimers.running&&f.push(`Session-Expires: ${this._sessionTimers.currentExpires};refresher=${this._sessionTimers.refresher?"uac":"uas"}`),A?(f.push("Content-Type: application/sdp"),this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._createLocalDescription("offer",p)).then(U=>{U=this._mangleOffer(U);const M={originator:"local",type:"offer",sdp:U};C.debug('emit "sdp"'),this.emit("sdp",M),this.sendRequest(_.UPDATE,{extraHeaders:f,body:U,eventHandlers:{onSuccessResponse:ee=>{v.call(this,ee),D=!0},onErrorResponse:ee=>{w.call(this,ee)},onTransportError:()=>{this.onTransportError()},onRequestTimeout:()=>{this.onRequestTimeout()},onDialogError:()=>{this.onDialogError()}}})}).catch(()=>{w.call(this)})):this.sendRequest(_.UPDATE,{extraHeaders:f,eventHandlers:{onSuccessResponse:U=>{v.call(this,U)},onErrorResponse:U=>{w.call(this,U)},onTransportError:()=>{this.onTransportError()},onRequestTimeout:()=>{this.onRequestTimeout()},onDialogError:()=>{this.onDialogError()}}});function v(U){if(this._status!==I.STATUS_TERMINATED&&!D)if(this._handleSessionTimersInIncomingResponse(U),A){if(U.body){if(!U.hasHeader("Content-Type")||U.getHeader("Content-Type").toLowerCase()!=="application/sdp"){w.call(this);return}}else{w.call(this);return}const M={originator:"remote",type:"answer",sdp:U.body};C.debug('emit "sdp"'),this.emit("sdp",M);const ee=new RTCSessionDescription({type:"answer",sdp:M.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(ee)).then(()=>{T.succeeded&&T.succeeded(U)}).catch(B=>{w.call(this),C.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',B),this.emit("peerconnection:setremotedescriptionfailed",B)})}else T.succeeded&&T.succeeded(U)}function w(U){T.failed&&T.failed(U)}}_acceptAndTerminate(o,f,T){C.debug("acceptAndTerminate()");const p=[];f&&(T=T||_.REASON_PHRASE[f]||"",p.push(`Reason: SIP ;cause=${f}; text="${T}"`)),(this._dialog||this._createDialog(o,"UAC"))&&(this.sendRequest(_.ACK),this.sendRequest(_.BYE,{extraHeaders:p})),this._status=I.STATUS_TERMINATED}_mangleOffer(o){if(!this._localHold&&!this._remoteHold)return o;if(o=y.parse(o),this._localHold&&!this._remoteHold){C.debug("mangleOffer() | me on hold, mangling offer");for(const f of o.media)H.indexOf(f.type)!==-1&&(f.direction?f.direction==="sendrecv"?f.direction="sendonly":f.direction==="recvonly"&&(f.direction="inactive"):f.direction="sendonly")}else if(this._localHold&&this._remoteHold){C.debug("mangleOffer() | both on hold, mangling offer");for(const f of o.media)H.indexOf(f.type)!==-1&&(f.direction="inactive")}else if(this._remoteHold){C.debug("mangleOffer() | remote on hold, mangling offer");for(const f of o.media)H.indexOf(f.type)!==-1&&(f.direction?f.direction==="sendrecv"?f.direction="recvonly":f.direction==="recvonly"&&(f.direction="inactive"):f.direction="recvonly")}return y.write(o)}_setLocalMediaStatus(){let o=!0,f=!0;(this._localHold||this._remoteHold)&&(o=!1,f=!1),this._audioMuted&&(o=!1),this._videoMuted&&(f=!1),this._toggleMuteAudio(!o),this._toggleMuteVideo(!f)}_handleSessionTimersInIncomingRequest(o,f){if(!this._sessionTimers.enabled)return;let T;o.session_expires&&o.session_expires>=_.MIN_SESSION_EXPIRES?(this._sessionTimers.currentExpires=o.session_expires,T=o.session_expires_refresher||"uas"):(this._sessionTimers.currentExpires=this._sessionTimers.defaultExpires,T="uas"),f.push(`Session-Expires: ${this._sessionTimers.currentExpires};refresher=${T}`),this._sessionTimers.refresher=T==="uas",this._runSessionTimer()}_handleSessionTimersInIncomingResponse(o){if(!this._sessionTimers.enabled)return;let f;o.session_expires&&o.session_expires>=_.MIN_SESSION_EXPIRES?(this._sessionTimers.currentExpires=o.session_expires,f=o.session_expires_refresher||"uac"):(this._sessionTimers.currentExpires=this._sessionTimers.defaultExpires,f="uac"),this._sessionTimers.refresher=f==="uac",this._runSessionTimer()}_runSessionTimer(){const o=this._sessionTimers.currentExpires;this._sessionTimers.running=!0,clearTimeout(this._sessionTimers.timer),this._sessionTimers.refresher?this._sessionTimers.timer=setTimeout(()=>{this._status!==I.STATUS_TERMINATED&&this.isReadyToReOffer()&&(C.debug("runSessionTimer() | sending session refresh request"),this._sessionTimers.refreshMethod===_.UPDATE?this._sendUpdate():this._sendReinvite())},o*500):this._sessionTimers.timer=setTimeout(()=>{this._status!==I.STATUS_TERMINATED&&(C.warn("runSessionTimer() | timer expired, terminating the session"),this.terminate({cause:_.causes.REQUEST_TIMEOUT,status_code:408,reason_phrase:"Session Timer Expired"}))},o*1100)}_toggleMuteAudio(o){const f=this._connection.getSenders().filter(T=>T.track&&T.track.kind==="audio");for(const T of f)T.track.enabled=!o}_toggleMuteVideo(o){const f=this._connection.getSenders().filter(T=>T.track&&T.track.kind==="video");for(const T of f)T.track.enabled=!o}_newRTCSession(o,f){C.debug("newRTCSession()"),this._ua.newRTCSession(this,{originator:o,session:this,request:f})}_connecting(o){C.debug("session connecting"),C.debug('emit "connecting"'),this.emit("connecting",{request:o})}_progress(o,f){C.debug("session progress"),C.debug('emit "progress"'),this.emit("progress",{originator:o,response:f||null})}_accepted(o,f){C.debug("session accepted"),this._start_time=new Date,C.debug('emit "accepted"'),this.emit("accepted",{originator:o,response:f||null})}_confirmed(o,f){C.debug("session confirmed"),this._is_confirmed=!0,C.debug('emit "confirmed"'),this.emit("confirmed",{originator:o,ack:f||null})}_ended(o,f,T){C.debug("session ended"),this._end_time=new Date,this._close(),C.debug('emit "ended"'),this.emit("ended",{originator:o,message:f||null,cause:T})}_failed(o,f,T){C.debug("session failed"),C.debug('emit "_failed"'),this.emit("_failed",{originator:o,message:f||null,cause:T}),this._close(),C.debug('emit "failed"'),this.emit("failed",{originator:o,message:f||null,cause:T})}_onhold(o){C.debug("session onhold"),this._setLocalMediaStatus(),C.debug('emit "hold"'),this.emit("hold",{originator:o})}_onunhold(o){C.debug("session onunhold"),this._setLocalMediaStatus(),C.debug('emit "unhold"'),this.emit("unhold",{originator:o})}_onmute({audio:o,video:f}){C.debug("session onmute"),this._setLocalMediaStatus(),C.debug('emit "muted"'),this.emit("muted",{audio:o,video:f})}_onunmute({audio:o,video:f}){C.debug("session onunmute"),this._setLocalMediaStatus(),C.debug('emit "unmuted"'),this.emit("unmuted",{audio:o,video:f})}},ns}var ls,Hn;function ri(){if(Hn)return ls;Hn=1;const O=Ie().EventEmitter,y=oe(),i=ie(),_=ve(),E=ue(),t=We(),h=Re(),d=ye(),l=new y("Message");return ls=class extends O{constructor(c){super(),this._ua=c,this._request=null,this._closed=!1,this._direction=null,this._local_identity=null,this._remote_identity=null,this._is_replied=!1,this._data={}}get direction(){return this._direction}get local_identity(){return this._local_identity}get remote_identity(){return this._remote_identity}send(c,R,x={}){const S=c;if(c===void 0||R===void 0)throw new TypeError("Not enough arguments");if(c=this._ua.normalizeTarget(c),!c)throw new TypeError(`Invalid target: ${S}`);const N=E.cloneArray(x.extraHeaders),k=E.cloneObject(x.eventHandlers),C=x.contentType||"text/plain",I={};x.fromUserName&&(I.from_uri=new d("sip",x.fromUserName,this._ua.configuration.uri.host),N.push(`P-Preferred-Identity: ${this._ua.configuration.uri.toString()}`)),x.fromDisplayName&&(I.from_display_name=x.fromDisplayName);for(const F in k)Object.prototype.hasOwnProperty.call(k,F)&&this.on(F,k[F]);N.push(`Content-Type: ${C}`),this._request=new _.OutgoingRequest(i.MESSAGE,c,this._ua,I,N),R&&(this._request.body=R);const H=new t(this._ua,this._request,{onRequestTimeout:()=>{this._onRequestTimeout()},onTransportError:()=>{this._onTransportError()},onReceiveResponse:F=>{this._receiveResponse(F)}});this._newMessage("local",this._request),H.send()}init_incoming(c){this._request=c,this._newMessage("remote",c),this._is_replied||(this._is_replied=!0,c.reply(200)),this._close()}accept(c={}){const R=E.cloneArray(c.extraHeaders),x=c.body;if(this._direction!=="incoming")throw new h.NotSupportedError('"accept" not supported for outgoing Message');if(this._is_replied)throw new Error("incoming Message already replied");this._is_replied=!0,this._request.reply(200,null,R,x)}reject(c={}){const R=c.status_code||480,x=c.reason_phrase,S=E.cloneArray(c.extraHeaders),N=c.body;if(this._direction!=="incoming")throw new h.NotSupportedError('"reject" not supported for outgoing Message');if(this._is_replied)throw new Error("incoming Message already replied");if(R<300||R>=700)throw new TypeError(`Invalid status_code: ${R}`);this._is_replied=!0,this._request.reply(R,x,S,N)}_receiveResponse(c){if(!this._closed)switch(!0){case/^1[0-9]{2}$/.test(c.status_code):break;case/^2[0-9]{2}$/.test(c.status_code):this._succeeded("remote",c);break;default:{const R=E.sipErrorCause(c.status_code);this._failed("remote",c,R);break}}}_onRequestTimeout(){this._closed||this._failed("system",null,i.causes.REQUEST_TIMEOUT)}_onTransportError(){this._closed||this._failed("system",null,i.causes.CONNECTION_ERROR)}_close(){this._closed=!0,this._ua.destroyMessage(this)}_newMessage(c,R){c==="remote"?(this._direction="incoming",this._local_identity=R.to,this._remote_identity=R.from):c==="local"&&(this._direction="outgoing",this._local_identity=R.from,this._remote_identity=R.to),this._ua.newMessage(this,{originator:c,message:this,request:R})}_failed(c,R,x){l.debug("MESSAGE failed"),this._close(),l.debug('emit "failed"'),this.emit("failed",{originator:c,response:R||null,cause:x})}_succeeded(c,R){l.debug("MESSAGE succeeded"),this._close(),l.debug('emit "succeeded"'),this.emit("succeeded",{originator:c,response:R})}},ls}var is,Fn;function ni(){if(Fn)return is;Fn=1;const O=Ie().EventEmitter,y=oe(),i=ie(),_=ve(),E=ue(),t=We(),h=Re(),d=new y("Options");return is=class extends O{constructor(g){super(),this._ua=g,this._request=null,this._closed=!1,this._direction=null,this._local_identity=null,this._remote_identity=null,this._is_replied=!1,this._data={}}get direction(){return this._direction}get local_identity(){return this._local_identity}get remote_identity(){return this._remote_identity}send(g,c,R={}){const x=g;if(g===void 0)throw new TypeError("A target is required for OPTIONS");if(g=this._ua.normalizeTarget(g),!g)throw new TypeError(`Invalid target: ${x}`);const S=E.cloneArray(R.extraHeaders),N=E.cloneObject(R.eventHandlers),k=R.contentType||"application/sdp";for(const I in N)Object.prototype.hasOwnProperty.call(N,I)&&this.on(I,N[I]);S.push(`Content-Type: ${k}`),this._request=new _.OutgoingRequest(i.OPTIONS,g,this._ua,null,S),c&&(this._request.body=c);const C=new t(this._ua,this._request,{onRequestTimeout:()=>{this._onRequestTimeout()},onTransportError:()=>{this._onTransportError()},onReceiveResponse:I=>{this._receiveResponse(I)}});this._newOptions("local",this._request),C.send()}init_incoming(g){this._request=g,this._newOptions("remote",g),this._is_replied||(this._is_replied=!0,g.reply(200)),this._close()}accept(g={}){const c=E.cloneArray(g.extraHeaders),R=g.body;if(this._direction!=="incoming")throw new h.NotSupportedError('"accept" not supported for outgoing Options');if(this._is_replied)throw new Error("incoming Options already replied");this._is_replied=!0,this._request.reply(200,null,c,R)}reject(g={}){const c=g.status_code||480,R=g.reason_phrase,x=E.cloneArray(g.extraHeaders),S=g.body;if(this._direction!=="incoming")throw new h.NotSupportedError('"reject" not supported for outgoing Options');if(this._is_replied)throw new Error("incoming Options already replied");if(c<300||c>=700)throw new TypeError(`Invalid status_code: ${c}`);this._is_replied=!0,this._request.reply(c,R,x,S)}_receiveResponse(g){if(!this._closed)switch(!0){case/^1[0-9]{2}$/.test(g.status_code):break;case/^2[0-9]{2}$/.test(g.status_code):this._succeeded("remote",g);break;default:{const c=E.sipErrorCause(g.status_code);this._failed("remote",g,c);break}}}_onRequestTimeout(){this._closed||this._failed("system",null,i.causes.REQUEST_TIMEOUT)}_onTransportError(){this._closed||this._failed("system",null,i.causes.CONNECTION_ERROR)}_close(){this._closed=!0,this._ua.destroyMessage(this)}_newOptions(g,c){g==="remote"?(this._direction="incoming",this._local_identity=c.to,this._remote_identity=c.from):g==="local"&&(this._direction="outgoing",this._local_identity=c.from,this._remote_identity=c.to),this._ua.newOptions(this,{originator:g,message:this,request:c})}_failed(g,c,R){d.debug("OPTIONS failed"),this._close(),d.debug('emit "failed"'),this.emit("failed",{originator:g,response:c||null,cause:R})}_succeeded(g,c){d.debug("OPTIONS succeeded"),this._close(),d.debug('emit "succeeded"'),this.emit("succeeded",{originator:g,response:c})}},is}var as={},$n;function el(){if($n)return as;$n=1;const O=oe(),y=ue(),i=ge(),_=new O("Socket");return as.isSocket=E=>{if(Array.isArray(E))return!1;if(typeof E>"u")return _.warn("undefined JsSIP.Socket instance"),!1;try{if(!y.isString(E.url))throw _.warn("missing or invalid JsSIP.Socket url property"),new Error("Missing or invalid JsSIP.Socket url property");if(!y.isString(E.via_transport))throw _.warn("missing or invalid JsSIP.Socket via_transport property"),new Error("Missing or invalid JsSIP.Socket via_transport property");if(i.parse(E.sip_uri,"SIP_URI")===-1)throw _.warn("missing or invalid JsSIP.Socket sip_uri property"),new Error("missing or invalid JsSIP.Socket sip_uri property")}catch{return!1}try{["connect","disconnect","send"].forEach(t=>{if(!y.isFunction(E[t]))throw _.warn(`missing or invalid JsSIP.Socket method: ${t}`),new Error(`Missing or invalid JsSIP.Socket method: ${t}`)})}catch{return!1}return!0},as}var os,kn;function li(){if(kn)return os;kn=1;const O=oe(),y=el(),i=ie(),_=new O("Transport"),E={STATUS_CONNECTED:0,STATUS_CONNECTING:1,STATUS_DISCONNECTED:2,SOCKET_STATUS_READY:0,SOCKET_STATUS_ERROR:1,recovery_options:{min_interval:i.CONNECTION_RECOVERY_MIN_INTERVAL,max_interval:i.CONNECTION_RECOVERY_MAX_INTERVAL}};return os=class{constructor(h,d=E.recovery_options){_.debug("new()"),this.status=E.STATUS_DISCONNECTED,this.socket=null,this.sockets=[],this.recovery_options=d,this.recover_attempts=0,this.recovery_timer=null,this.close_requested=!1;try{this.textDecoder=new TextDecoder("utf8")}catch(l){_.warn(`cannot use TextDecoder: ${l}`)}if(typeof h>"u")throw new TypeError("Invalid argument. undefined 'sockets' argument");h instanceof Array||(h=[h]),h.forEach(function(l){if(!y.isSocket(l.socket))throw new TypeError("Invalid argument. invalid 'JsSIP.Socket' instance");if(l.weight&&!Number(l.weight))throw new TypeError("Invalid argument. 'weight' attribute is not a number");this.sockets.push({socket:l.socket,weight:l.weight||0,status:E.SOCKET_STATUS_READY})},this),this._getSocket()}get via_transport(){return this.socket.via_transport}get url(){return this.socket.url}get sip_uri(){return this.socket.sip_uri}connect(){if(_.debug("connect()"),this.isConnected()){_.debug("Transport is already connected");return}else if(this.isConnecting()){_.debug("Transport is connecting");return}this.close_requested=!1,this.status=E.STATUS_CONNECTING,this.onconnecting({socket:this.socket,attempts:this.recover_attempts}),this.close_requested||(this.socket.onconnect=this._onConnect.bind(this),this.socket.ondisconnect=this._onDisconnect.bind(this),this.socket.ondata=this._onData.bind(this),this.socket.connect())}disconnect(){_.debug("close()"),this.close_requested=!0,this.recover_attempts=0,this.status=E.STATUS_DISCONNECTED,this.recovery_timer!==null&&(clearTimeout(this.recovery_timer),this.recovery_timer=null),this.socket.onconnect=()=>{},this.socket.ondisconnect=()=>{},this.socket.ondata=()=>{},this.socket.disconnect(),this.ondisconnect({socket:this.socket,error:!1})}send(h){if(_.debug("send()"),!this.isConnected())return _.warn("unable to send message, transport is not connected"),!1;const d=h.toString();return _.debug(`sending message:
|
|
47
|
+
|
|
48
|
+
${d}
|
|
49
|
+
`),this.socket.send(d)}isConnected(){return this.status===E.STATUS_CONNECTED}isConnecting(){return this.status===E.STATUS_CONNECTING}_reconnect(){this.recover_attempts+=1;let h=Math.floor(Math.random()*Math.pow(2,this.recover_attempts)+1);h<this.recovery_options.min_interval?h=this.recovery_options.min_interval:h>this.recovery_options.max_interval&&(h=this.recovery_options.max_interval),_.debug(`reconnection attempt: ${this.recover_attempts}. next connection attempt in ${h} seconds`),this.recovery_timer=setTimeout(()=>{!this.close_requested&&!(this.isConnected()||this.isConnecting())&&(this._getSocket(),this.connect())},h*1e3)}_getSocket(){let h=[];if(this.sockets.forEach(l=>{l.status!==E.SOCKET_STATUS_ERROR&&(h.length===0?h.push(l):l.weight>h[0].weight?h=[l]:l.weight===h[0].weight&&h.push(l))}),h.length===0){this.sockets.forEach(l=>{l.status=E.SOCKET_STATUS_READY}),this._getSocket();return}const d=Math.floor(Math.random()*h.length);this.socket=h[d].socket}_onConnect(){this.recover_attempts=0,this.status=E.STATUS_CONNECTED,this.recovery_timer!==null&&(clearTimeout(this.recovery_timer),this.recovery_timer=null),this.onconnect({socket:this})}_onDisconnect(h,d,l){this.status=E.STATUS_DISCONNECTED,this.ondisconnect({socket:this.socket,error:h,code:d,reason:l}),!this.close_requested&&(this.sockets.forEach(function(g){this.socket===g.socket&&(g.status=E.SOCKET_STATUS_ERROR)},this),this._reconnect(h))}_onData(h){if(h===`\r
|
|
50
|
+
\r
|
|
51
|
+
`){_.debug("received message with double-CRLF Keep Alive request");try{this.socket.send(`\r
|
|
52
|
+
`)}catch(d){_.warn(`error sending Keep Alive response: ${d}`)}return}if(h===`\r
|
|
53
|
+
`){_.debug("received message with CRLF Keep Alive response");return}else if(typeof h!="string"){try{this.textDecoder?h=this.textDecoder.decode(h):h=String.fromCharCode.apply(null,new Uint8Array(h))}catch{_.debug("received binary message failed to be converted into string, message discarded");return}_.debug(`received binary message:
|
|
54
|
+
|
|
55
|
+
${h}
|
|
56
|
+
`)}else _.debug(`received text message:
|
|
57
|
+
|
|
58
|
+
${h}
|
|
59
|
+
`);this.ondata({transport:this,message:h})}},os}var us={},qn;function ii(){if(qn)return us;qn=1;const O=oe(),y=ge(),i=ve(),_=new O("Parser");us.parseMessage=(h,d)=>{let l,g,c=h.indexOf(`\r
|
|
60
|
+
`);if(c===-1){_.warn("parseMessage() | no CRLF found, not a SIP message");return}const R=h.substring(0,c);let x=y.parse(R,"Request_Response");if(x===-1){_.warn(`parseMessage() | error parsing first line of SIP message: "${R}"`);return}else x.status_code?(l=new i.IncomingResponse,l.status_code=x.status_code,l.reason_phrase=x.reason_phrase):(l=new i.IncomingRequest(d),l.method=x.method,l.ruri=x.uri);l.data=h;let S=c+2;for(;;){if(c=E(h,S),c===-2){g=S+2;break}else if(c===-1){_.warn("parseMessage() | malformed message");return}if(x=t(l,h,S,c),x!==!0){_.warn("parseMessage() |",x.error);return}S=c+2}if(l.hasHeader("content-length")){const N=l.getHeader("content-length");l.body=h.substr(g,N)}else l.body=h.substring(g);return l};function E(h,d){let l=d,g=0,c=0;if(h.substring(l,l+2).match(/(^\r\n)/))return-2;for(;g===0;){if(c=h.indexOf(`\r
|
|
61
|
+
`,l),c===-1)return c;!h.substring(c+2,c+4).match(/(^\r\n)/)&&h.charAt(c+2).match(/(^\s+)/)?l=c+2:g=c}return g}function t(h,d,l,g){let c;const R=d.indexOf(":",l),x=d.substring(l,R).trim(),S=d.substring(R+1,g).trim();switch(x.toLowerCase()){case"via":case"v":h.addHeader("via",S),h.getHeaders("via").length===1?(c=h.parseHeader("Via"),c&&(h.via=c,h.via_branch=c.branch)):c=0;break;case"from":case"f":h.setHeader("from",S),c=h.parseHeader("from"),c&&(h.from=c,h.from_tag=c.getParam("tag"));break;case"to":case"t":h.setHeader("to",S),c=h.parseHeader("to"),c&&(h.to=c,h.to_tag=c.getParam("tag"));break;case"record-route":if(c=y.parse(S,"Record_Route"),c===-1)c=void 0;else for(const N of c)h.addHeader("record-route",S.substring(N.possition,N.offset)),h.headers["Record-Route"][h.getHeaders("record-route").length-1].parsed=N.parsed;break;case"call-id":case"i":h.setHeader("call-id",S),c=h.parseHeader("call-id"),c&&(h.call_id=S);break;case"contact":case"m":if(c=y.parse(S,"Contact"),c===-1)c=void 0;else for(const N of c)h.addHeader("contact",S.substring(N.possition,N.offset)),h.headers.Contact[h.getHeaders("contact").length-1].parsed=N.parsed;break;case"content-length":case"l":h.setHeader("content-length",S),c=h.parseHeader("content-length");break;case"content-type":case"c":h.setHeader("content-type",S),c=h.parseHeader("content-type");break;case"cseq":h.setHeader("cseq",S),c=h.parseHeader("cseq"),c&&(h.cseq=c.value),h instanceof i.IncomingResponse&&(h.method=c.method);break;case"max-forwards":h.setHeader("max-forwards",S),c=h.parseHeader("max-forwards");break;case"www-authenticate":h.setHeader("www-authenticate",S),c=h.parseHeader("www-authenticate");break;case"proxy-authenticate":h.setHeader("proxy-authenticate",S),c=h.parseHeader("proxy-authenticate");break;case"session-expires":case"x":h.setHeader("session-expires",S),c=h.parseHeader("session-expires"),c&&(h.session_expires=c.expires,h.session_expires_refresher=c.refresher);break;case"refer-to":case"r":h.setHeader("refer-to",S),c=h.parseHeader("refer-to"),c&&(h.refer_to=c);break;case"replaces":h.setHeader("replaces",S),c=h.parseHeader("replaces"),c&&(h.replaces=c);break;case"event":case"o":h.setHeader("event",S),c=h.parseHeader("event"),c&&(h.event=c);break;default:h.addHeader(x,S),c=0}return c===void 0?{error:`error parsing header "${x}"`}:!0}return us}var cs,Gn;function ai(){if(Gn)return cs;Gn=1;const O=oe(),y=ie(),i=ve(),_=ue(),E=new O("sanityCheck"),t=[I],h=[R,x,S,N],d=[k,C];let l,g,c;cs=(F,o,f)=>{l=F,g=o,c=f;for(const T of t)if(T()===!1)return!1;if(l instanceof i.IncomingRequest){for(const T of h)if(T()===!1)return!1}else if(l instanceof i.IncomingResponse){for(const T of d)if(T()===!1)return!1}return!0};function R(){if(l.s("to").uri.scheme!=="sip")return H(416),!1}function x(){if(!l.to_tag&&l.call_id.substr(0,5)===g.configuration.jssip_id)return H(482),!1}function S(){const F=_.str_utf8_length(l.body),o=l.getHeader("content-length");if(F<o)return H(400),!1}function N(){const F=l.from_tag,o=l.call_id,f=l.cseq;let T;if(!l.to_tag)if(l.method===y.INVITE){if(g._transactions.ist[l.via_branch])return!1;for(const p in g._transactions.ist)if(Object.prototype.hasOwnProperty.call(g._transactions.ist,p)&&(T=g._transactions.ist[p],T.request.from_tag===F&&T.request.call_id===o&&T.request.cseq===f))return H(482),!1}else{if(g._transactions.nist[l.via_branch])return!1;for(const p in g._transactions.nist)if(Object.prototype.hasOwnProperty.call(g._transactions.nist,p)&&(T=g._transactions.nist[p],T.request.from_tag===F&&T.request.call_id===o&&T.request.cseq===f))return H(482),!1}}function k(){if(l.getHeaders("via").length>1)return E.debug("more than one Via header field present in the response, dropping the response"),!1}function C(){const F=_.str_utf8_length(l.body),o=l.getHeader("content-length");if(F<o)return E.debug("message body length is lower than the value in Content-Length header field, dropping the response"),!1}function I(){const F=["from","to","call_id","cseq","via"];for(const o of F)if(!l.hasHeader(o))return E.debug(`missing mandatory header field : ${o}, dropping the response`),!1}function H(F){const o=l.getHeaders("via");let f,T=`SIP/2.0 ${F} ${y.REASON_PHRASE[F]}\r
|
|
62
|
+
`;for(const p of o)T+=`Via: ${p}\r
|
|
63
|
+
`;f=l.getHeader("To"),l.to_tag||(f+=`;tag=${_.newTag()}`),T+=`To: ${f}\r
|
|
64
|
+
`,T+=`From: ${l.getHeader("From")}\r
|
|
65
|
+
`,T+=`Call-ID: ${l.call_id}\r
|
|
66
|
+
`,T+=`CSeq: ${l.cseq} ${l.method}\r
|
|
67
|
+
`,T+=`\r
|
|
68
|
+
`,c.send(T)}return cs}var ft={},Bn;function oi(){if(Bn)return ft;Bn=1;const O=ue(),y=ie(),i=ge(),_=ye(),E=el(),t=Re();ft.settings={authorization_user:null,password:null,realm:null,ha1:null,authorization_jwt:null,display_name:null,uri:null,contact_uri:null,instance_id:null,use_preloaded_route:!1,session_timers:!0,session_timers_refresh_method:y.UPDATE,session_timers_force_refresher:!1,no_answer_timeout:60,register:!0,register_expires:600,register_from_tag_trail:"",registrar_server:null,sockets:null,connection_recovery_max_interval:y.CONNECTION_RECOVERY_MAX_INTERVAL,connection_recovery_min_interval:y.CONNECTION_RECOVERY_MIN_INTERVAL,extra_headers:null,via_host:`${O.createRandomToken(12)}.invalid`};const h={mandatory:{sockets(d){const l=[];if(E.isSocket(d))l.push({socket:d});else if(Array.isArray(d)&&d.length)for(const g of d)Object.prototype.hasOwnProperty.call(g,"socket")&&E.isSocket(g.socket)?l.push(g):E.isSocket(g)&&l.push({socket:g});else return;return l},uri(d){/^sip:/i.test(d)||(d=`${y.SIP}:${d}`);const l=_.parse(d);if(l)return l.user?l:void 0}},optional:{authorization_user(d){if(i.parse(`"${d}"`,"quoted_string")!==-1)return d},authorization_jwt(d){if(typeof d=="string")return d},user_agent(d){if(typeof d=="string")return d},connection_recovery_max_interval(d){if(O.isDecimal(d)){const l=Number(d);if(l>0)return l}},connection_recovery_min_interval(d){if(O.isDecimal(d)){const l=Number(d);if(l>0)return l}},contact_uri(d){if(typeof d=="string"){const l=i.parse(d,"SIP_URI");if(l!==-1)return l}},display_name(d){return d},instance_id(d){if(/^uuid:/i.test(d)&&(d=d.substr(5)),i.parse(d,"uuid")!==-1)return d},no_answer_timeout(d){if(O.isDecimal(d)){const l=Number(d);if(l>0)return l}},session_timers(d){if(typeof d=="boolean")return d},session_timers_refresh_method(d){if(typeof d=="string"&&(d=d.toUpperCase(),d===y.INVITE||d===y.UPDATE))return d},session_timers_force_refresher(d){if(typeof d=="boolean")return d},password(d){return String(d)},realm(d){return String(d)},ha1(d){return String(d)},register(d){if(typeof d=="boolean")return d},register_expires(d){if(O.isDecimal(d)){const l=Number(d);if(l>=0)return l}},register_from_tag_trail(d){return typeof d=="function"?d:String(d)},registrar_server(d){/^sip:/i.test(d)||(d=`${y.SIP}:${d}`);const l=_.parse(d);if(l)return l.user?void 0:l},use_preloaded_route(d){if(typeof d=="boolean")return d},extra_headers(d){const l=[];if(Array.isArray(d)&&d.length)for(const g of d)typeof g=="string"&&l.push(g);else return;return l}}};return ft.load=(d,l)=>{for(const g in h.mandatory)if(l.hasOwnProperty(g)){const c=l[g],R=h.mandatory[g](c);if(R!==void 0)d[g]=R;else throw new t.ConfigurationError(g,c)}else throw new t.ConfigurationError(g);for(const g in h.optional)if(l.hasOwnProperty(g)){const c=l[g];if(O.isEmpty(c))continue;const R=h.optional[g](c);if(R!==void 0)d[g]=R;else throw new t.ConfigurationError(g,c)}},ft}var fs,Wn;function ui(){if(Wn)return fs;Wn=1;const O=Ie().EventEmitter,y=oe(),i=ie(),_=Jl(),E=Zn(),t=ri(),h=ni(),d=Be(),l=li(),g=ue(),c=Re(),R=ye(),x=ii(),S=ve(),N=ai(),k=oi(),C=new y("UA"),I={STATUS_INIT:0,STATUS_READY:1,STATUS_USER_CLOSED:2,STATUS_NOT_READY:3,CONFIGURATION_ERROR:1,NETWORK_ERROR:2};fs=class extends O{static get C(){return I}constructor(p){if(!p)throw new TypeError("Not enough arguments");const A=["password","ha1","authorization_jwt"];C.debug("new() [configuration:%o]",Object.entries(p).filter(([D])=>!A.includes(D))),super(),this._cache={credentials:{}},this._configuration=Object.assign({},k.settings),this._dynConfiguration={},this._dialogs={},this._applicants={},this._sessions={},this._transport=null,this._contact=null,this._status=I.STATUS_INIT,this._error=null,this._transactions={nist:{},nict:{},ist:{},ict:{}},this._data={},this._closeTimer=null;try{this._loadConfig(p)}catch(D){throw this._status=I.STATUS_NOT_READY,this._error=I.CONFIGURATION_ERROR,D}this._registrator=new _(this)}get C(){return I}get status(){return this._status}get contact(){return this._contact}get configuration(){return this._configuration}get transport(){return this._transport}start(){C.debug("start()"),this._status===I.STATUS_INIT?this._transport.connect():this._status===I.STATUS_USER_CLOSED?(C.debug("restarting UA"),this._closeTimer!==null&&(clearTimeout(this._closeTimer),this._closeTimer=null,this._transport.disconnect()),this._status=I.STATUS_INIT,this._transport.connect()):this._status===I.STATUS_READY?C.debug("UA is in READY status, not restarted"):C.debug("ERROR: connection is down, Auto-Recovery system is trying to reconnect"),this._dynConfiguration.register=this._configuration.register}register(){C.debug("register()"),this._dynConfiguration.register=!0,this._registrator.register()}unregister(p){C.debug("unregister()"),this._dynConfiguration.register=!1,this._registrator.unregister(p)}registrator(){return this._registrator}isRegistered(){return this._registrator.registered}isConnected(){return this._transport.isConnected()}call(p,A){C.debug("call()");const D=new E(this);return D.connect(p,A),D}sendMessage(p,A,D){C.debug("sendMessage()");const v=new t(this);return v.send(p,A,D),v}sendOptions(p,A,D){C.debug("sendOptions()");const v=new h(this);return v.send(p,A,D),v}terminateSessions(p){C.debug("terminateSessions()");for(const A in this._sessions)this._sessions[A].isEnded()||this._sessions[A].terminate(p)}stop(){if(C.debug("stop()"),this._dynConfiguration={},this._status===I.STATUS_USER_CLOSED){C.debug("UA already closed");return}this._registrator.close();const p=Object.keys(this._sessions).length;for(const D in this._sessions)if(Object.prototype.hasOwnProperty.call(this._sessions,D)){C.debug(`closing session ${D}`);try{this._sessions[D].terminate()}catch{}}for(const D in this._applicants)if(Object.prototype.hasOwnProperty.call(this._applicants,D))try{this._applicants[D].close()}catch{}this._status=I.STATUS_USER_CLOSED,Object.keys(this._transactions.nict).length+Object.keys(this._transactions.nist).length+Object.keys(this._transactions.ict).length+Object.keys(this._transactions.ist).length===0&&p===0?this._transport.disconnect():this._closeTimer=setTimeout(()=>{this._closeTimer=null,this._transport.disconnect()},2e3)}normalizeTarget(p){return g.normalizeTarget(p,this._configuration.hostport_params)}get(p){switch(p){case"authorization_user":return this._configuration.authorization_user;case"realm":return this._configuration.realm;case"ha1":return this._configuration.ha1;case"authorization_jwt":return this._configuration.authorization_jwt;default:C.warn('get() | cannot get "%s" parameter in runtime',p);return}}set(p,A){switch(p){case"authorization_user":{this._configuration.authorization_user=String(A);break}case"password":{this._configuration.password=String(A);break}case"realm":{this._configuration.realm=String(A);break}case"ha1":{this._configuration.ha1=String(A),this._configuration.password=null;break}case"authorization_jwt":{this._configuration.authorization_jwt=String(A);break}case"display_name":{this._configuration.display_name=A;break}case"extra_headers":{this._configuration.extra_headers=A;break}default:return C.warn('set() | cannot set "%s" parameter in runtime',p),!1}return!0}newTransaction(p){this._transactions[p.type][p.id]=p,this.emit("newTransaction",{transaction:p})}destroyTransaction(p){delete this._transactions[p.type][p.id],this.emit("transactionDestroyed",{transaction:p})}newDialog(p){this._dialogs[p.id]=p}destroyDialog(p){delete this._dialogs[p.id]}newMessage(p,A){this._applicants[p]=p,this.emit("newMessage",A)}newOptions(p,A){this._applicants[p]=p,this.emit("newOptions",A)}destroyMessage(p){delete this._applicants[p]}newRTCSession(p,A){this._sessions[p.id]=p,this.emit("newRTCSession",A)}destroyRTCSession(p){delete this._sessions[p.id]}registered(p){this.emit("registered",p)}unregistered(p){this.emit("unregistered",p)}registrationFailed(p){this.emit("registrationFailed",p)}receiveRequest(p){const A=p.method;if(p.ruri.user!==this._configuration.uri.user&&p.ruri.user!==this._contact.uri.user){C.debug("Request-URI does not point to us"),p.method!==i.ACK&&p.reply_sl(404);return}if(p.ruri.scheme===i.SIPS){p.reply_sl(416);return}if(d.checkTransaction(this,p))return;if(A===i.INVITE?new d.InviteServerTransaction(this,this._transport,p):A!==i.ACK&&A!==i.CANCEL&&new d.NonInviteServerTransaction(this,this._transport,p),A===i.OPTIONS){if(this.listeners("newOptions").length===0){p.reply(200);return}new h(this).init_incoming(p)}else if(A===i.MESSAGE){if(this.listeners("newMessage").length===0){p.reply(405);return}new t(this).init_incoming(p)}else if(A===i.INVITE&&!p.to_tag&&this.listeners("newRTCSession").length===0){p.reply(405);return}let D,v;if(p.to_tag)D=this._findDialog(p.call_id,p.from_tag,p.to_tag),D?D.receiveRequest(p):A===i.NOTIFY?(v=this._findSession(p),v?v.receiveRequest(p):(C.debug("received NOTIFY request for a non existent subscription"),p.reply(481,"Subscription does not exist"))):A!==i.ACK&&p.reply(481);else switch(A){case i.INVITE:if(window.RTCPeerConnection)if(p.hasHeader("replaces")){const w=p.replaces;D=this._findDialog(w.call_id,w.from_tag,w.to_tag),D?(v=D.owner,v.isEnded()?p.reply(603):v.receiveRequest(p)):p.reply(481)}else v=new E(this),v.init_incoming(p);else C.warn("INVITE received but WebRTC is not supported"),p.reply(488);break;case i.BYE:p.reply(481);break;case i.CANCEL:v=this._findSession(p),v?v.receiveRequest(p):C.debug("received CANCEL request for a non existent session");break;case i.ACK:break;case i.NOTIFY:this.emit("sipEvent",{event:p.event,request:p}),p.reply(200);break;default:p.reply(405);break}}_findSession({call_id:p,from_tag:A,to_tag:D}){const v=p+A,w=this._sessions[v],U=p+D,M=this._sessions[U];return w||M||null}_findDialog(p,A,D){let v=p+A+D,w=this._dialogs[v];return w||(v=p+D+A,w=this._dialogs[v],w||null)}_loadConfig(p){try{k.load(this._configuration,p)}catch(v){throw v}this._configuration.display_name===0&&(this._configuration.display_name="0"),this._configuration.instance_id||(this._configuration.instance_id=g.newUUID()),this._configuration.jssip_id=g.createRandomToken(5);const A=this._configuration.uri.clone();A.user=null,this._configuration.hostport_params=A.toString().replace(/^sip:/i,"");try{this._transport=new l(this._configuration.sockets,{max_interval:this._configuration.connection_recovery_max_interval,min_interval:this._configuration.connection_recovery_min_interval}),this._transport.onconnecting=H.bind(this),this._transport.onconnect=F.bind(this),this._transport.ondisconnect=o.bind(this),this._transport.ondata=f.bind(this)}catch(v){throw C.warn(v),new c.ConfigurationError("sockets",this._configuration.sockets)}if(delete this._configuration.sockets,this._configuration.authorization_user||(this._configuration.authorization_user=this._configuration.uri.user),!this._configuration.registrar_server){const v=this._configuration.uri.clone();v.user=null,v.clearParams(),v.clearHeaders(),this._configuration.registrar_server=v}this._configuration.no_answer_timeout*=1e3,this._configuration.contact_uri?this._configuration.via_host=this._configuration.contact_uri.host:this._configuration.contact_uri=new R("sip",g.createRandomToken(8),this._configuration.via_host,null,{transport:"ws"}),this._contact={pub_gruu:null,temp_gruu:null,uri:this._configuration.contact_uri,toString(v={}){const w=v.anonymous||null,U=v.outbound||null;let M="<";return w?M+=this.temp_gruu||"sip:anonymous@anonymous.invalid;transport=ws":M+=this.pub_gruu||this.uri.toString(),U&&(w?!this.temp_gruu:!this.pub_gruu)&&(M+=";ob"),M+=">",M}};const D=["authorization_user","password","realm","ha1","authorization_jwt","display_name","register","extra_headers"];for(const v in this._configuration)Object.prototype.hasOwnProperty.call(this._configuration,v)&&(D.indexOf(v)!==-1?Object.defineProperty(this._configuration,v,{writable:!0,configurable:!1}):Object.defineProperty(this._configuration,v,{writable:!1,configurable:!1}));C.debug("configuration parameters after validation:");for(const v in this._configuration)if(Object.prototype.hasOwnProperty.call(k.settings,v))switch(v){case"uri":case"registrar_server":C.debug(`- ${v}: ${this._configuration[v]}`);break;case"password":case"ha1":case"authorization_jwt":C.debug(`- ${v}: NOT SHOWN`);break;default:C.debug(`- ${v}: ${JSON.stringify(this._configuration[v])}`)}}};function H(T){this.emit("connecting",T)}function F(T){this._status!==I.STATUS_USER_CLOSED&&(this._status=I.STATUS_READY,this._error=null,this.emit("connected",T),this._dynConfiguration.register&&this._registrator.register())}function o(T){const p=["nict","ict","nist","ist"];for(const A of p)for(const D in this._transactions[A])Object.prototype.hasOwnProperty.call(this._transactions[A],D)&&this._transactions[A][D].onTransportError();this.emit("disconnected",T),this._registrator.onTransportClosed(),this._status!==I.STATUS_USER_CLOSED&&(this._status=I.STATUS_NOT_READY,this._error=I.NETWORK_ERROR)}function f(T){const p=T.transport;let A=T.message;if(A=x.parseMessage(A,this),!!A&&!(this._status===I.STATUS_USER_CLOSED&&A instanceof S.IncomingRequest)&&N(A,this,p)){if(A instanceof S.IncomingRequest)A.transport=p,this.receiveRequest(A);else if(A instanceof S.IncomingResponse){let D;switch(A.method){case i.INVITE:D=this._transactions.ict[A.via_branch],D&&D.receiveResponse(A);break;case i.ACK:break;default:D=this._transactions.nict[A.via_branch],D&&D.receiveResponse(A);break}}}}return fs}var hs,Vn;function ci(){if(Vn)return hs;Vn=1;const O=oe(),y=ge(),i=new O("WebSocketInterface");return hs=class{constructor(E){i.debug('new() [url:"%s"]',E),this._url=E,this._sip_uri=null,this._via_transport=null,this._ws=null;const t=y.parse(E,"absoluteURI");if(t===-1)throw i.warn(`invalid WebSocket URI: ${E}`),new TypeError(`Invalid argument: ${E}`);if(t.scheme!=="wss"&&t.scheme!=="ws")throw i.warn(`invalid WebSocket URI scheme: ${t.scheme}`),new TypeError(`Invalid argument: ${E}`);this._sip_uri=`sip:${t.host}${t.port?`:${t.port}`:""};transport=ws`,this._via_transport=t.scheme.toUpperCase()}get via_transport(){return this._via_transport}set via_transport(E){this._via_transport=E.toUpperCase()}get sip_uri(){return this._sip_uri}get url(){return this._url}connect(){if(i.debug("connect()"),this.isConnected()){i.debug(`WebSocket ${this._url} is already connected`);return}else if(this.isConnecting()){i.debug(`WebSocket ${this._url} is connecting`);return}this._ws&&this.disconnect(),i.debug(`connecting to WebSocket ${this._url}`);try{this._ws=new WebSocket(this._url,"sip"),this._ws.binaryType="arraybuffer",this._ws.onopen=this._onOpen.bind(this),this._ws.onclose=this._onClose.bind(this),this._ws.onmessage=this._onMessage.bind(this),this._ws.onerror=this._onError.bind(this)}catch(E){this._onError(E)}}disconnect(){i.debug("disconnect()"),this._ws&&(this._ws.onopen=()=>{},this._ws.onclose=()=>{},this._ws.onmessage=()=>{},this._ws.onerror=()=>{},this._ws.close(),this._ws=null)}send(E){return i.debug("send()"),this.isConnected()?(this._ws.send(E),!0):(i.warn("unable to send message, WebSocket is not open"),!1)}isConnected(){return this._ws&&this._ws.readyState===this._ws.OPEN}isConnecting(){return this._ws&&this._ws.readyState===this._ws.CONNECTING}_onOpen(){i.debug(`WebSocket ${this._url} connected`),this.onconnect()}_onClose({wasClean:E,code:t,reason:h}){i.debug(`WebSocket ${this._url} closed`),E===!1&&i.debug("WebSocket abrupt disconnection"),this.ondisconnect(!E,t,h)}_onMessage({data:E}){i.debug("received WebSocket message"),this.ondata(E)}_onError(E){i.warn(`WebSocket ${this._url} error: `,E)}},hs}var ds,jn;function fi(){if(jn)return ds;jn=1;const O=zn,y=ie(),i=Re(),_=ue(),E=ui(),t=ye(),h=Ts(),d=ge(),l=ci(),g=ps()("JsSIP"),c=Zn();return g("version %s",O.version),ds={C:y,Exceptions:i,Utils:_,UA:E,URI:t,NameAddrHeader:h,WebSocketInterface:l,Grammar:d,RTCSession:c,debug:ps(),get name(){return O.title},get version(){return O.version}},ds}var hi=fi();const gs=Gl(hi);let xe=null,_s=null;function di(O){return`${O.websocketUrl}|${O.sipUri}|${O.authorizationUser}`}function _i(O){const i={sockets:[new gs.WebSocketInterface(O.websocketUrl)],uri:O.sipUri,password:O.password,registrar_server:O.registrarServer,display_name:O.displayName,authorization_user:O.authorizationUser,connection_recovery_min_interval:2,connection_recovery_max_interval:30},_=new gs.UA(i),E=document.createElement("audio");E.autoplay=!0;const t={ua:_,audio:E,isStarted:!1,listeners:new Set};return _.on("connecting",()=>{t.listeners.forEach(h=>h.onConnecting?.())}),_.on("connected",()=>{t.listeners.forEach(h=>h.onConnected?.())}),_.on("disconnected",()=>{t.listeners.forEach(h=>h.onDisconnected?.())}),_.on("registered",()=>{t.listeners.forEach(h=>h.onRegistered?.())}),_.on("unregistered",()=>{t.listeners.forEach(h=>h.onUnregistered?.())}),_.on("registrationFailed",h=>{t.listeners.forEach(d=>d.onRegistrationFailed?.(h?.cause))}),_.on("newRTCSession",h=>{const d=h.session;d.direction==="outgoing"&&(t.listeners.forEach(l=>l.onNewSession?.(d)),d.connection&&(d.connection.addEventListener("addstream",l=>{if(!l.streams?.length)return;const g=document.createElement("audio");g.srcObject=l.streams[0],g.play()}),d.connection.addEventListener("track",l=>{const g=document.createElement("audio");g.srcObject=l.streams[0],g.play()})))}),t}function Kn(O){const y=di(O);if(xe&&_s===y)return xe;if(xe&&_s!==y){try{xe.ua.stop()}catch{}xe=null}return _s=y,xe=_i(O),xe}class pi{constructor(y,i={},_={}){this.config=y,this.events=i,this.options={persistHistory:_.persistHistory??!0,historyKey:_.historyKey??"tbi-phone-call-history",maxHistoryItems:_.maxHistoryItems??50},this.listener={onConnecting:()=>{this.updateState({connectionStatus:"connecting"}),this.events.onConnecting?.(),this.events.onConnectionChange?.("connecting")},onConnected:()=>{this.updateState({connectionStatus:"connected"}),this.events.onConnected?.(),this.events.onConnectionChange?.("connected")},onDisconnected:()=>{this.updateState({connectionStatus:"disconnected",isReady:!1}),this.events.onDisconnected?.(),this.events.onConnectionChange?.("disconnected")},onRegistered:()=>{this.updateState({isReady:!0,connectionStatus:"connected"}),this.events.onRegistered?.(),this.events.onConnectionChange?.("connected")},onUnregistered:()=>{this.updateState({isReady:!1}),this.events.onUnregistered?.()},onRegistrationFailed:E=>{console.error("Registration failed:",E),this.updateState({isReady:!1,connectionStatus:"failed"}),this.events.onRegistrationFailed?.(E),this.events.onConnectionChange?.("failed")},onNewSession:E=>{this.currentSession=E}}}uaInstance=null;currentSession=null;callStartedTS=null;durationInterval=null;startCallEventListener=null;_state={status:"disconnected",callNumber:"",callHistory:[],currentCallDuration:0,isReady:!1,connectionStatus:"connecting"};events={};options;listener;get state(){return this._state}get ua(){return this.uaInstance?.ua??null}initialize(){this.uaInstance=Kn(this.config),this.uaInstance.ua.isRegistered()?this.updateState({isReady:!0,connectionStatus:"connected"}):this.uaInstance.ua.isConnected()&&this.updateState({connectionStatus:"connected"}),this.uaInstance.listeners.add(this.listener),this.uaInstance.isStarted||(this.uaInstance.ua.start(),this.uaInstance.isStarted=!0),this.loadHistory(),this.startCallEventListener=y=>{const _=y.detail.number;this._state.status==="disconnected"&&(!this.uaInstance||!this._state.isReady?this.initializeAndCall(_):this.startCall(_))},window.addEventListener("StartCallEvent",this.startCallEventListener)}destroy(){this.uaInstance&&this.uaInstance.listeners.delete(this.listener),this.startCallEventListener&&(window.removeEventListener("StartCallEvent",this.startCallEventListener),this.startCallEventListener=null),this.durationInterval&&(clearInterval(this.durationInterval),this.durationInterval=null)}setCallNumber(y){this.updateState({callNumber:y})}startCall(y){if(!y.trim()||!this.uaInstance)return;if(!this._state.isReady){console.warn("Phone is not ready yet. Please wait for registration.");return}this.updateState({callNumber:y}),this.events.onCallStart?.(y);const _={eventHandlers:{progress:()=>{this.updateState({status:"progress"}),this.events.onStatusChange?.("progress")},failed:E=>{console.error("Call failed:",E?.cause),this.updateState({status:"failed"}),this.events.onStatusChange?.("failed"),this.addToHistory(y,0,"failed"),this.events.onCallEnd?.(y,0,"failed"),this.currentSession=null,setTimeout(()=>{this.updateState({status:"disconnected"}),this.events.onStatusChange?.("disconnected")},3e3)},ended:()=>{this.updateState({status:"ended"}),this.events.onStatusChange?.("ended");const E=this.callStartedTS?Math.floor((Date.now()-this.callStartedTS)/1e3):0;this.addToHistory(y,E,"completed"),this.events.onCallEnd?.(y,E,"completed"),this.currentSession=null,this.stopDurationTimer(),setTimeout(()=>{this.updateState({status:"disconnected"}),this.events.onStatusChange?.("disconnected"),this.callStartedTS=null},2e3)},confirmed:()=>{this.callStartedTS=Date.now(),this.updateState({status:"confirmed"}),this.events.onStatusChange?.("confirmed"),this.startDurationTimer()}},mediaConstraints:{audio:!0,video:!1}};this.updateState({status:"progress"}),this.events.onStatusChange?.("progress");try{const E=this.uaInstance.ua.call(y,_);this.currentSession=E}catch(E){console.error("Failed to start call:",E),this.updateState({status:"failed"}),this.events.onStatusChange?.("failed"),this.addToHistory(y,0,"failed"),setTimeout(()=>{this.updateState({status:"disconnected"}),this.events.onStatusChange?.("disconnected")},3e3)}}endCall(){this.currentSession&&(this.currentSession.terminate(),this.currentSession=null)}initializeAndCall(y){if(this.uaInstance&&this._state.isReady){this.startCall(y);return}if(this.uaInstance||(this.uaInstance=Kn(this.config),this.uaInstance.ua.isRegistered()?this.updateState({isReady:!0,connectionStatus:"connected"}):this.uaInstance.ua.isConnected()&&this.updateState({connectionStatus:"connected"}),this.uaInstance.listeners.add(this.listener),this.loadHistory()),this.uaInstance.ua.isRegistered()){this.updateState({isReady:!0,connectionStatus:"connected"}),this.startCall(y);return}const i={onRegistered:()=>{this.uaInstance?.listeners.delete(i),this.startCall(y)},onRegistrationFailed:_=>{console.error("Registration failed while trying to start call:",_),this.uaInstance?.listeners.delete(i)}};this.uaInstance.listeners.add(i),this.uaInstance.isStarted||(this.uaInstance.ua.start(),this.uaInstance.isStarted=!0)}clearHistory(){this.updateState({callHistory:[]}),this.options.persistHistory&&localStorage.removeItem(this.options.historyKey)}setEvents(y){this.events={...this.events,...y}}updateState(y){this._state={...this._state,...y}}loadHistory(){if(!this.options.persistHistory)return;const y=localStorage.getItem(this.options.historyKey);if(y)try{this.updateState({callHistory:JSON.parse(y)})}catch(i){console.error("Error loading call history",i)}}saveHistory(){this.options.persistHistory&&this._state.callHistory.length>0&&localStorage.setItem(this.options.historyKey,JSON.stringify(this._state.callHistory))}addToHistory(y,i,_){const t=[{id:Date.now().toString(),number:y,timestamp:Date.now(),duration:i,status:_},...this._state.callHistory].slice(0,this.options.maxHistoryItems);this.updateState({callHistory:t}),this.saveHistory(),this.events.onHistoryUpdate?.(t)}startDurationTimer(){this.stopDurationTimer(),this.durationInterval=setInterval(()=>{if(this.callStartedTS){const y=Math.floor((Date.now()-this.callStartedTS)/1e3);this.updateState({currentCallDuration:y}),this.events.onDurationUpdate?.(y)}},1e3)}stopDurationTimer(){this.durationInterval&&(clearInterval(this.durationInterval),this.durationInterval=null),this.updateState({currentCallDuration:0})}}exports.JsSIP=gs;exports.PhoneManager=pi;exports.cn=$l;exports.defaultLabels=ql;exports.formatDuration=kl;
|