@tbisoftware/phone 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs ADDED
@@ -0,0 +1,68 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const q=require("react/jsx-runtime"),ae=require("react");function gs(...I){return I.filter(Boolean).join(" ")}function _t(I){const y=Math.floor(I/3600),i=Math.floor(I%3600/60),p=I%60;return y>0?`${y.toString().padStart(2,"0")}:${i.toString().padStart(2,"0")}:${p.toString().padStart(2,"0")}`:`${i.toString().padStart(2,"0")}:${p.toString().padStart(2,"0")}`}const Vl={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 zl(I){return I&&I.__esModule&&Object.prototype.hasOwnProperty.call(I,"default")?I.default:I}const Kl="JsSIP",Yl="3.11.1",Xn={title:Kl,version:Yl};var $t,hn;function oe(){if(hn)return $t;hn=1;const I=Xn;return $t={USER_AGENT:`${I.title} ${I.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},$t}var kt,dn;function we(){if(dn)return kt;dn=1;class I extends Error{constructor(t,_){super(),this.code=1,this.name="CONFIGURATION_ERROR",this.parameter=t,this.value=_,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 p extends Error{constructor(t){super(),this.code=4,this.name="NOT_READY_ERROR",this.message=t}}return kt={ConfigurationError:I,InvalidStateError:y,NotSupportedError:i,NotReadyError:p},kt}var le={},qt,_n;function Es(){if(_n)return qt;_n=1;const I=ye(),y=Ce();return qt=class Qn{static parse(p){if(p=y.parse(p,"Name_Addr_Header"),p!==-1)return p}constructor(p,R,t){if(!p||!(p instanceof I))throw new TypeError('missing or invalid "uri" parameter');this._uri=p,this._parameters={},this.display_name=R;for(const _ in t)Object.prototype.hasOwnProperty.call(t,_)&&this.setParam(_,t[_])}get uri(){return this._uri}get display_name(){return this._display_name}set display_name(p){this._display_name=p===0?"0":p}setParam(p,R){p&&(this._parameters[p.toLowerCase()]=typeof R>"u"||R===null?null:R.toString())}getParam(p){if(p)return this._parameters[p.toLowerCase()]}hasParam(p){if(p)return this._parameters.hasOwnProperty(p.toLowerCase())&&!0||!1}deleteParam(p){if(p=p.toLowerCase(),this._parameters.hasOwnProperty(p)){const R=this._parameters[p];return delete this._parameters[p],R}}clearParams(){this._parameters={}}clone(){return new Qn(this._uri.clone(),this._display_name,JSON.parse(JSON.stringify(this._parameters)))}_quote(p){return p.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}toString(){let p=this._display_name?`"${this._quote(this._display_name)}" `:"";p+=`<${this._uri.toString()}>`;for(const R in this._parameters)Object.prototype.hasOwnProperty.call(this._parameters,R)&&(p+=`;${R}`,this._parameters[R]!==null&&(p+=`=${this._parameters[R]}`));return p}},qt}var jt,pn;function Ce(){return pn||(pn=1,jt=(function(){function I(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,p){var R={CRLF:g,DIGIT:c,ALPHA:S,HEXDIG:D,WSP:E,OCTET:N,DQUOTE:$,SP:C,HTAB:w,alphanum:F,reserved:H,unreserved:o,mark:f,escaped:T,LWS:d,SWS:A,HCOLON:O,TEXT_UTF8_TRIM:v,TEXT_UTF8char:b,UTF8_NONASCII:U,UTF8_CONT:M,LHEX:Z,token:B,token_nodot:ue,separators:de,word:he,STAR:J,SLASH:_e,EQUAL:X,LPAREN:xe,RPAREN:Ne,RAQUOT:Ae,LAQUOT:Re,COMMA:ee,SEMI:Y,COLON:Oe,LDQUOT:be,RDQUOT:Ve,comment:z,ctext:V,quoted_string:K,quoted_string_clean:Q,qdtext:re,quoted_pair:ne,SIP_URI_noparams:te,SIP_URI:ve,uri_scheme:pe,uri_scheme_sips:As,uri_scheme_sip:Rs,userinfo:ze,user:bs,user_unreserved:pt,password:ws,hostport:Ke,host:Me,hostname:mt,domainlabel:gt,toplabel:ys,IPv6reference:Tt,IPv6address:Ct,h16:j,ls32:me,IPv4address:Le,dec_octet:Fe,port:Is,uri_parameters:xs,uri_parameter:vt,transport_param:Ns,user_param:Os,method_param:Ds,ttl_param:Us,maddr_param:Ps,lr_param:Ms,other_param:Ls,pname:Fs,pvalue:Hs,paramchar:He,param_unreserved:$s,headers:ks,header:Ye,hname:qs,hvalue:js,hnv_unreserved:$e,Request_Response:ol,Request_Line:Gs,Request_URI:Bs,absoluteURI:Et,hier_part:Ws,net_path:Vs,abs_path:Je,opaque_part:zs,uric:ke,uric_no_slash:Ks,path_segments:Ys,segment:Xe,param:St,pchar:qe,scheme:Js,authority:Xs,srvr:Qs,reg_name:Zs,query:er,SIP_Version:At,INVITEm:tr,ACKm:sr,OPTIONSm:rr,BYEm:nr,CANCELm:lr,REGISTERm:ir,SUBSCRIBEm:ar,NOTIFYm:or,REFERm:ur,Method:Qe,Status_Line:cr,Status_Code:fr,extension_code:hr,Reason_Phrase:dr,Allow_Events:ul,Call_ID:cl,Contact:fl,contact_param:Ze,name_addr:De,display_name:et,contact_params:Rt,c_p_q:_r,c_p_expires:pr,delta_seconds:Ue,qvalue:mr,generic_param:ie,gen_value:gr,Content_Disposition:hl,disp_type:Tr,disp_param:bt,handling_param:Cr,Content_Encoding:dl,Content_Length:_l,Content_Type:pl,media_type:vr,m_type:Er,discrete_type:Sr,composite_type:Ar,extension_token:tt,x_token:Rr,m_subtype:br,m_parameter:wt,m_value:wr,CSeq:ml,CSeq_value:yr,Expires:gl,Event:Tl,event_type:je,From:Cl,from_param:yt,tag_param:It,Max_Forwards:vl,Min_Expires:El,Name_Addr_Header:Sl,Proxy_Authenticate:Al,challenge:xt,other_challenge:Ir,auth_param:Ge,digest_cln:st,realm:xr,realm_value:Nr,domain:Or,URI:rt,nonce:Dr,nonce_value:Ur,opaque:Pr,stale:Mr,algorithm:Lr,qop_options:Fr,qop_value:nt,Proxy_Require:Rl,Record_Route:bl,rec_route:lt,Reason:wl,reason_param:Nt,reason_cause:Hr,Require:yl,Route:Il,route_param:it,Subscription_State:xl,substate_value:$r,subexp_params:Ot,event_reason_value:kr,Subject:Nl,Supported:Ol,To:Dl,to_param:Dt,Via:Ul,via_param:at,via_params:Ut,via_ttl:qr,via_maddr:jr,via_received:Gr,via_branch:Br,response_port:Wr,rport:Vr,sent_protocol:zr,protocol_name:Kr,transport:Yr,sent_by:Jr,via_host:Xr,via_port:Qr,ttl:Pt,WWW_Authenticate:Pl,Session_Expires:Ml,s_e_expires:Zr,s_e_params:Mt,s_e_refresher:en,extension_header:Ll,header_value:tn,message_body:Fl,uuid_URI:Hl,uuid:sn,hex4:Ee,hex8:rn,hex12:nn,Refer_To:$l,Replaces:kl,call_id:ln,replaces_param:Lt,to_tag:an,from_tag:on,early_flag:un};if(p!==void 0){if(R[p]===void 0)throw new Error("Invalid rule name: "+I(p)+".")}else p="CRLF";var t=0,_=0,h=[];function l(e){t<_||(t>_&&(_=t,h=[]),h.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 S(){var e;return/^[a-zA-Z]/.test(i.charAt(t))?(e=i.charAt(t),t++):(e=null,l("[a-zA-Z]")),e}function D(){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 E(){var e;return e=C(),e===null&&(e=w()),e}function N(){var e;return/^[\0-\xFF]/.test(i.charAt(t))?(e=i.charAt(t),t++):(e=null,l("[\\0-\\xFF]")),e}function $(){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 w(){var e;return i.charCodeAt(t)===9?(e=" ",t++):(e=null,l('"\\t"')),e}function F(){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 H(){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=F(),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=D(),s!==null?(r=D(),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 d(){var e,s,r,n,a,u;for(n=t,a=t,u=t,e=[],s=E();s!==null;)e.push(s),s=E();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=E(),r!==null)for(s=[];r!==null;)s.push(r),r=E();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=d(),e=e!==null?e:"",e}function O(){var e,s,r,n,a;for(n=t,a=t,e=[],s=C(),s===null&&(s=w());s!==null;)e.push(s),s=C(),s===null&&(s=w());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=b(),s!==null)for(e=[];s!==null;)e.push(s),s=b();else e=null;if(e!==null){for(s=[],m=t,r=[],n=d();n!==null;)r.push(n),n=d();for(r!==null?(n=b(),n!==null?r=[r,n]:(r=null,t=m)):(r=null,t=m);r!==null;){for(s.push(r),m=t,r=[],n=d();n!==null;)r.push(n),n=d();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=(function(P){return i.substring(t,P)})(a)),e===null&&(t=a),e}function b(){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 Z(){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=F(),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=F(),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 ue(){var e,s,r;if(r=t,s=F(),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=F(),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 de(){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=$(),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=w())))))))))))))))))),e}function he(){var e,s,r;if(r=t,s=F(),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=$(),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=F(),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=$(),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 J(){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 _e(){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 X(){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 xe(){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 Ne(){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 Ae(){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 Re(){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 ee(){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 Y(){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 Oe(){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 be(){var e,s,r,n;return r=t,n=t,e=A(),e!==null?(s=$(),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=$(),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 z(){var e,s,r,n;if(n=t,e=xe(),e!==null){for(s=[],r=V(),r===null&&(r=ne(),r===null&&(r=z()));r!==null;)s.push(r),r=V(),r===null&&(r=ne(),r===null&&(r=z()));s!==null?(r=Ne(),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=d())))),e}function K(){var e,s,r,n,a,u;if(a=t,u=t,e=A(),e!==null)if(s=$(),s!==null){for(r=[],n=re(),n===null&&(n=ne());n!==null;)r.push(n),n=re(),n===null&&(n=ne());r!==null?(n=$(),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 Q(){var e,s,r,n,a,u;if(a=t,u=t,e=A(),e!==null)if(s=$(),s!==null){for(r=[],n=re(),n===null&&(n=ne());n!==null;)r.push(n),n=re(),n===null&&(n=ne());r!==null?(n=$(),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 re(){var e;return e=d(),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 ne(){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 te(){var e,s,r,n,a,u;return a=t,u=t,e=pe(),e!==null?(i.charCodeAt(t)===58?(s=":",t++):(s=null,l('":"')),s!==null?(r=ze(),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{x.uri=new cn(x.scheme,x.user,x.host,x.port),delete x.scheme,delete x.user,delete x.host,delete x.host_type,delete x.port}catch{x=-1}})()),e===null&&(t=a),e}function ve(){var e,s,r,n,a,u,m,P;return m=t,P=t,e=pe(),e!==null?(i.charCodeAt(t)===58?(s=":",t++):(s=null,l('":"')),s!==null?(r=ze(),r=r!==null?r:"",r!==null?(n=Ke(),n!==null?(a=xs(),a!==null?(u=ks(),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(k){try{x.uri=new cn(x.scheme,x.user,x.host,x.port,x.uri_params,x.uri_headers),delete x.scheme,delete x.user,delete x.host,delete x.host_type,delete x.port,delete x.uri_params,p==="SIP_URI"&&(x=x.uri)}catch{x=-1}})()),e===null&&(t=m),e}function pe(){var e;return e=As(),e===null&&(e=Rs()),e}function As(){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){x.scheme=n.toLowerCase()})(s,e)),e===null&&(t=s),e}function Rs(){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){x.scheme=n.toLowerCase()})(s,e)),e===null&&(t=s),e}function ze(){var e,s,r,n,a,u;return n=t,a=t,e=bs(),e!==null?(u=t,i.charCodeAt(t)===58?(s=":",t++):(s=null,l('":"')),s!==null?(r=ws(),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){x.user=decodeURIComponent(i.substring(t-1,m))})(n)),e===null&&(t=n),e}function bs(){var e,s;if(s=o(),s===null&&(s=T(),s===null&&(s=pt())),s!==null)for(e=[];s!==null;)e.push(s),s=o(),s===null&&(s=T(),s===null&&(s=pt()));else e=null;return e}function pt(){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 ws(){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){x.password=i.substring(t,n)})(r)),e===null&&(t=r),e}function Ke(){var e,s,r,n,a;return n=t,e=Me(),e!==null?(a=t,i.charCodeAt(t)===58?(s=":",t++):(s=null,l('":"')),s!==null?(r=Is(),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 Me(){var e,s;return s=t,e=mt(),e===null&&(e=Le(),e===null&&(e=Tt())),e!==null&&(e=(function(r){return x.host=i.substring(t,r).toLowerCase(),x.host})(s)),e===null&&(t=s),e}function mt(){var e,s,r,n,a,u;for(n=t,a=t,e=[],u=t,s=gt(),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=gt(),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=ys(),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 x.host_type="domain",i.substring(t,m)})(n)),e===null&&(t=n),e}function gt(){var e,s,r,n;if(n=t,e=F(),e!==null){for(s=[],r=F(),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=F(),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 ys(){var e,s,r,n;if(n=t,e=S(),e!==null){for(s=[],r=F(),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=F(),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 Tt(){var e,s,r,n,a;return n=t,a=t,i.charCodeAt(t)===91?(e="[",t++):(e=null,l('"["')),e!==null?(s=Ct(),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 x.host_type="IPv6",i.substring(t,u)})(n)),e===null&&(t=n),e}function Ct(){var e,s,r,n,a,u,m,P,k,W,se,Te,ot,Ht,L,G;return Ht=t,L=t,e=j(),e!==null?(i.charCodeAt(t)===58?(s=":",t++):(s=null,l('":"')),s!==null?(r=j(),r!==null?(i.charCodeAt(t)===58?(n=":",t++):(n=null,l('":"')),n!==null?(a=j(),a!==null?(i.charCodeAt(t)===58?(u=":",t++):(u=null,l('":"')),u!==null?(m=j(),m!==null?(i.charCodeAt(t)===58?(P=":",t++):(P=null,l('":"')),P!==null?(k=j(),k!==null?(i.charCodeAt(t)===58?(W=":",t++):(W=null,l('":"')),W!==null?(se=j(),se!==null?(i.charCodeAt(t)===58?(Te=":",t++):(Te=null,l('":"')),Te!==null?(ot=me(),ot!==null?e=[e,s,r,n,a,u,m,P,k,W,se,Te,ot]:(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=j(),s!==null?(i.charCodeAt(t)===58?(r=":",t++):(r=null,l('":"')),r!==null?(n=j(),n!==null?(i.charCodeAt(t)===58?(a=":",t++):(a=null,l('":"')),a!==null?(u=j(),u!==null?(i.charCodeAt(t)===58?(m=":",t++):(m=null,l('":"')),m!==null?(P=j(),P!==null?(i.charCodeAt(t)===58?(k=":",t++):(k=null,l('":"')),k!==null?(W=j(),W!==null?(i.charCodeAt(t)===58?(se=":",t++):(se=null,l('":"')),se!==null?(Te=me(),Te!==null?e=[e,s,r,n,a,u,m,P,k,W,se,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,t=L),e===null&&(L=t,i.substr(t,2)==="::"?(e="::",t+=2):(e=null,l('"::"')),e!==null?(s=j(),s!==null?(i.charCodeAt(t)===58?(r=":",t++):(r=null,l('":"')),r!==null?(n=j(),n!==null?(i.charCodeAt(t)===58?(a=":",t++):(a=null,l('":"')),a!==null?(u=j(),u!==null?(i.charCodeAt(t)===58?(m=":",t++):(m=null,l('":"')),m!==null?(P=j(),P!==null?(i.charCodeAt(t)===58?(k=":",t++):(k=null,l('":"')),k!==null?(W=me(),W!==null?e=[e,s,r,n,a,u,m,P,k,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=j(),s!==null?(i.charCodeAt(t)===58?(r=":",t++):(r=null,l('":"')),r!==null?(n=j(),n!==null?(i.charCodeAt(t)===58?(a=":",t++):(a=null,l('":"')),a!==null?(u=j(),u!==null?(i.charCodeAt(t)===58?(m=":",t++):(m=null,l('":"')),m!==null?(P=me(),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=j(),s!==null?(i.charCodeAt(t)===58?(r=":",t++):(r=null,l('":"')),r!==null?(n=j(),n!==null?(i.charCodeAt(t)===58?(a=":",t++):(a=null,l('":"')),a!==null?(u=me(),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=j(),s!==null?(i.charCodeAt(t)===58?(r=":",t++):(r=null,l('":"')),r!==null?(n=me(),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=me(),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=j(),s!==null?e=[e,s]:(e=null,t=L)):(e=null,t=L),e===null&&(L=t,e=j(),e!==null?(i.substr(t,2)==="::"?(s="::",t+=2):(s=null,l('"::"')),s!==null?(r=j(),r!==null?(i.charCodeAt(t)===58?(n=":",t++):(n=null,l('":"')),n!==null?(a=j(),a!==null?(i.charCodeAt(t)===58?(u=":",t++):(u=null,l('":"')),u!==null?(m=j(),m!==null?(i.charCodeAt(t)===58?(P=":",t++):(P=null,l('":"')),P!==null?(k=j(),k!==null?(i.charCodeAt(t)===58?(W=":",t++):(W=null,l('":"')),W!==null?(se=me(),se!==null?e=[e,s,r,n,a,u,m,P,k,W,se]:(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=j(),e!==null?(G=t,i.charCodeAt(t)===58?(s=":",t++):(s=null,l('":"')),s!==null?(r=j(),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=j(),n!==null?(i.charCodeAt(t)===58?(a=":",t++):(a=null,l('":"')),a!==null?(u=j(),u!==null?(i.charCodeAt(t)===58?(m=":",t++):(m=null,l('":"')),m!==null?(P=j(),P!==null?(i.charCodeAt(t)===58?(k=":",t++):(k=null,l('":"')),k!==null?(W=me(),W!==null?e=[e,s,r,n,a,u,m,P,k,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=j(),e!==null?(G=t,i.charCodeAt(t)===58?(s=":",t++):(s=null,l('":"')),s!==null?(r=j(),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=j(),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=j(),a!==null?(i.charCodeAt(t)===58?(u=":",t++):(u=null,l('":"')),u!==null?(m=j(),m!==null?(i.charCodeAt(t)===58?(P=":",t++):(P=null,l('":"')),P!==null?(k=me(),k!==null?e=[e,s,r,n,a,u,m,P,k]:(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=j(),e!==null?(G=t,i.charCodeAt(t)===58?(s=":",t++):(s=null,l('":"')),s!==null?(r=j(),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=j(),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=j(),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=j(),u!==null?(i.charCodeAt(t)===58?(m=":",t++):(m=null,l('":"')),m!==null?(P=me(),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=j(),e!==null?(G=t,i.charCodeAt(t)===58?(s=":",t++):(s=null,l('":"')),s!==null?(r=j(),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=j(),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=j(),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=j(),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=me(),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=j(),e!==null?(G=t,i.charCodeAt(t)===58?(s=":",t++):(s=null,l('":"')),s!==null?(r=j(),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=j(),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=j(),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=j(),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=j(),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=j(),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=j(),e!==null?(G=t,i.charCodeAt(t)===58?(s=":",t++):(s=null,l('":"')),s!==null?(r=j(),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=j(),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=j(),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=j(),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=j(),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=j(),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(Wl){return x.host_type="IPv6",i.substring(t,Wl)})(Ht)),e===null&&(t=Ht),e}function j(){var e,s,r,n,a;return a=t,e=D(),e!==null?(s=D(),s=s!==null?s:"",s!==null?(r=D(),r=r!==null?r:"",r!==null?(n=D(),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 me(){var e,s,r,n;return n=t,e=j(),e!==null?(i.charCodeAt(t)===58?(s=":",t++):(s=null,l('":"')),s!==null?(r=j(),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,k;return P=t,k=t,e=Fe(),e!==null?(i.charCodeAt(t)===46?(s=".",t++):(s=null,l('"."')),s!==null?(r=Fe(),r!==null?(i.charCodeAt(t)===46?(n=".",t++):(n=null,l('"."')),n!==null?(a=Fe(),a!==null?(i.charCodeAt(t)===46?(u=".",t++):(u=null,l('"."')),u!==null?(m=Fe(),m!==null?e=[e,s,r,n,a,u,m]:(e=null,t=k)):(e=null,t=k)):(e=null,t=k)):(e=null,t=k)):(e=null,t=k)):(e=null,t=k)):(e=null,t=k),e!==null&&(e=(function(W){return x.host_type="IPv4",i.substring(t,W)})(P)),e===null&&(t=P),e}function Fe(){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 Is(){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,k){return k=parseInt(k.join("")),x.port=k,k})(u,e)),e===null&&(t=u),e}function xs(){var e,s,r,n;for(e=[],n=t,i.charCodeAt(t)===59?(s=";",t++):(s=null,l('";"')),s!==null?(r=vt(),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=vt(),r!==null?s=[s,r]:(s=null,t=n)):(s=null,t=n);return e}function vt(){var e;return e=Ns(),e===null&&(e=Os(),e===null&&(e=Ds(),e===null&&(e=Us(),e===null&&(e=Ps(),e===null&&(e=Ms(),e===null&&(e=Ls())))))),e}function Ns(){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){x.uri_params||(x.uri_params={}),x.uri_params.transport=u.toLowerCase()})(r,e[1])),e===null&&(t=r),e}function Os(){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){x.uri_params||(x.uri_params={}),x.uri_params.user=u.toLowerCase()})(r,e[1])),e===null&&(t=r),e}function Ds(){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=Qe(),s!==null?e=[e,s]:(e=null,t=n)):(e=null,t=n),e!==null&&(e=(function(a,u){x.uri_params||(x.uri_params={}),x.uri_params.method=u})(r,e[1])),e===null&&(t=r),e}function Us(){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=Pt(),s!==null?e=[e,s]:(e=null,t=n)):(e=null,t=n),e!==null&&(e=(function(a,u){x.params||(x.params={}),x.params.ttl=u})(r,e[1])),e===null&&(t=r),e}function Ps(){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=Me(),s!==null?e=[e,s]:(e=null,t=n)):(e=null,t=n),e!==null&&(e=(function(a,u){x.uri_params||(x.uri_params={}),x.uri_params.maddr=u})(r,e[1])),e===null&&(t=r),e}function Ms(){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){x.uri_params||(x.uri_params={}),x.uri_params.lr=void 0})()),e===null&&(t=n),e}function Ls(){var e,s,r,n,a,u;return n=t,a=t,e=Fs(),e!==null?(u=t,i.charCodeAt(t)===61?(s="=",t++):(s=null,l('"="')),s!==null?(r=Hs(),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,k){x.uri_params||(x.uri_params={}),typeof k>"u"?k=void 0:k=k[1],x.uri_params[P.toLowerCase()]=k})(n,e[0],e[1])),e===null&&(t=n),e}function Fs(){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 Hs(){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=$s(),e===null&&(e=o(),e===null&&(e=T())),e}function $s(){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 ks(){var e,s,r,n,a,u,m;if(u=t,i.charCodeAt(t)===63?(e="?",t++):(e=null,l('"?"')),e!==null)if(s=Ye(),s!==null){for(r=[],m=t,i.charCodeAt(t)===38?(n="&",t++):(n=null,l('"&"')),n!==null?(a=Ye(),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=Ye(),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 Ye(){var e,s,r,n,a;return n=t,a=t,e=qs(),e!==null?(i.charCodeAt(t)===61?(s="=",t++):(s=null,l('"="')),s!==null?(r=js(),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(""),x.uri_headers||(x.uri_headers={}),x.uri_headers[m]?x.uri_headers[m].push(P):x.uri_headers[m]=[P]})(n,e[0],e[2])),e===null&&(t=n),e}function qs(){var e,s;if(s=$e(),s===null&&(s=o(),s===null&&(s=T())),s!==null)for(e=[];s!==null;)e.push(s),s=$e(),s===null&&(s=o(),s===null&&(s=T()));else e=null;return e}function js(){var e,s;for(e=[],s=$e(),s===null&&(s=o(),s===null&&(s=T()));s!==null;)e.push(s),s=$e(),s===null&&(s=o(),s===null&&(s=T()));return e}function $e(){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 ol(){var e;return e=cr(),e===null&&(e=Gs()),e}function Gs(){var e,s,r,n,a,u;return u=t,e=Qe(),e!==null?(s=C(),s!==null?(r=Bs(),r!==null?(n=C(),n!==null?(a=At(),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 Bs(){var e;return e=ve(),e===null&&(e=Et()),e}function Et(){var e,s,r,n;return n=t,e=Js(),e!==null?(i.charCodeAt(t)===58?(s=":",t++):(s=null,l('":"')),s!==null?(r=Ws(),r===null&&(r=zs()),r!==null?e=[e,s,r]:(e=null,t=n)):(e=null,t=n)):(e=null,t=n),e}function Ws(){var e,s,r,n,a;return n=t,e=Vs(),e===null&&(e=Je()),e!==null?(a=t,i.charCodeAt(t)===63?(s="?",t++):(s=null,l('"?"')),s!==null?(r=er(),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 Vs(){var e,s,r,n;return n=t,i.substr(t,2)==="//"?(e="//",t+=2):(e=null,l('"//"')),e!==null?(s=Xs(),s!==null?(r=Je(),r=r!==null?r:"",r!==null?e=[e,s,r]:(e=null,t=n)):(e=null,t=n)):(e=null,t=n),e}function Je(){var e,s,r;return r=t,i.charCodeAt(t)===47?(e="/",t++):(e=null,l('"/"')),e!==null?(s=Ys(),s!==null?e=[e,s]:(e=null,t=r)):(e=null,t=r),e}function zs(){var e,s,r,n;if(n=t,e=Ks(),e!==null){for(s=[],r=ke();r!==null;)s.push(r),r=ke();s!==null?e=[e,s]:(e=null,t=n)}else e=null,t=n;return e}function ke(){var e;return e=H(),e===null&&(e=o(),e===null&&(e=T())),e}function Ks(){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 Ys(){var e,s,r,n,a,u;if(a=t,e=Xe(),e!==null){for(s=[],u=t,i.charCodeAt(t)===47?(r="/",t++):(r=null,l('"/"')),r!==null?(n=Xe(),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=Xe(),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 Xe(){var e,s,r,n,a,u;for(a=t,e=[],s=qe();s!==null;)e.push(s),s=qe();if(e!==null){for(s=[],u=t,i.charCodeAt(t)===59?(r=";",t++):(r=null,l('";"')),r!==null?(n=St(),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=St(),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 St(){var e,s;for(e=[],s=qe();s!==null;)e.push(s),s=qe();return e}function qe(){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 Js(){var e,s,r,n,a;if(n=t,a=t,e=S(),e!==null){for(s=[],r=S(),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=S(),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){x.scheme=i.substring(t,u)})(n)),e===null&&(t=n),e}function Xs(){var e;return e=Qs(),e===null&&(e=Zs()),e}function Qs(){var e,s,r,n;return r=t,n=t,e=ze(),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 Zs(){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 er(){var e,s;for(e=[],s=ke();s!==null;)e.push(s),s=ke();return e}function At(){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(k){x.sip_version=i.substring(t,k)})(m)),e===null&&(t=m),e}function tr(){var e;return i.substr(t,6)==="INVITE"?(e="INVITE",t+=6):(e=null,l('"INVITE"')),e}function sr(){var e;return i.substr(t,3)==="ACK"?(e="ACK",t+=3):(e=null,l('"ACK"')),e}function rr(){var e;return i.substr(t,7)==="OPTIONS"?(e="OPTIONS",t+=7):(e=null,l('"OPTIONS"')),e}function nr(){var e;return i.substr(t,3)==="BYE"?(e="BYE",t+=3):(e=null,l('"BYE"')),e}function lr(){var e;return i.substr(t,6)==="CANCEL"?(e="CANCEL",t+=6):(e=null,l('"CANCEL"')),e}function ir(){var e;return i.substr(t,8)==="REGISTER"?(e="REGISTER",t+=8):(e=null,l('"REGISTER"')),e}function ar(){var e;return i.substr(t,9)==="SUBSCRIBE"?(e="SUBSCRIBE",t+=9):(e=null,l('"SUBSCRIBE"')),e}function or(){var e;return i.substr(t,6)==="NOTIFY"?(e="NOTIFY",t+=6):(e=null,l('"NOTIFY"')),e}function ur(){var e;return i.substr(t,5)==="REFER"?(e="REFER",t+=5):(e=null,l('"REFER"')),e}function Qe(){var e,s;return s=t,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=ar(),e===null&&(e=or(),e===null&&(e=ur(),e===null&&(e=B()))))))))),e!==null&&(e=(function(r){return x.method=i.substring(t,r),x.method})(s)),e===null&&(t=s),e}function cr(){var e,s,r,n,a,u;return u=t,e=At(),e!==null?(s=C(),s!==null?(r=fr(),r!==null?(n=C(),n!==null?(a=dr(),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 fr(){var e,s;return s=t,e=hr(),e!==null&&(e=(function(r,n){x.status_code=parseInt(n.join(""))})(s,e)),e===null&&(t=s),e}function hr(){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 dr(){var e,s,r;for(r=t,e=[],s=H(),s===null&&(s=o(),s===null&&(s=T(),s===null&&(s=U(),s===null&&(s=M(),s===null&&(s=C(),s===null&&(s=w()))))));s!==null;)e.push(s),s=H(),s===null&&(s=o(),s===null&&(s=T(),s===null&&(s=U(),s===null&&(s=M(),s===null&&(s=C(),s===null&&(s=w()))))));return e!==null&&(e=(function(n){x.reason_phrase=i.substring(t,n)})(r)),e===null&&(t=r),e}function ul(){var e,s,r,n,a,u;if(a=t,e=je(),e!==null){for(s=[],u=t,r=ee(),r!==null?(n=je(),n!==null?r=[r,n]:(r=null,t=u)):(r=null,t=u);r!==null;)s.push(r),u=t,r=ee(),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 cl(){var e,s,r,n,a,u;return n=t,a=t,e=he(),e!==null?(u=t,i.charCodeAt(t)===64?(s="@",t++):(s=null,l('"@"')),s!==null?(r=he(),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){x=i.substring(t,m)})(n)),e===null&&(t=n),e}function fl(){var e,s,r,n,a,u,m;if(a=t,e=J(),e===null)if(u=t,e=Ze(),e!==null){for(s=[],m=t,r=ee(),r!==null?(n=Ze(),n!==null?r=[r,n]:(r=null,t=m)):(r=null,t=m);r!==null;)s.push(r),m=t,r=ee(),r!==null?(n=Ze(),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 k,W;for(W=x.multi_header.length,k=0;k<W;k++)if(x.multi_header[k].parsed===null){x=null;break}x!==null?x=x.multi_header:x=-1})()),e===null&&(t=a),e}function Ze(){var e,s,r,n,a,u,m;if(a=t,u=t,e=te(),e===null&&(e=De()),e!==null){for(s=[],m=t,r=Y(),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=Y(),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 k;x.multi_header||(x.multi_header=[]);try{k=new Pe(x.uri,x.display_name,x.params),delete x.uri,delete x.display_name,delete x.params}catch{k=null}x.multi_header.push({possition:t,offset:P,parsed:k})})(a)),e===null&&(t=a),e}function De(){var e,s,r,n,a;return a=t,e=et(),e=e!==null?e:"",e!==null?(s=Re(),s!==null?(r=ve(),r!==null?(n=Ae(),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 et(){var e,s,r,n,a,u,m;if(a=t,u=t,e=B(),e!==null){for(s=[],m=t,r=d(),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=d(),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=Q()),e!==null&&(e=(function(P,k){typeof k=="string"?x.display_name=k:x.display_name=k[1].reduce(function(W,se){return W+se[0]+se[1]},k[0])})(a,e)),e===null&&(t=a),e}function Rt(){var e;return e=_r(),e===null&&(e=pr(),e===null&&(e=ie())),e}function _r(){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=X(),s!==null?(r=mr(),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u,m){x.params||(x.params={}),x.params.q=m})(n,e[2])),e===null&&(t=n),e}function pr(){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=X(),s!==null?(r=Ue(),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u,m){x.params||(x.params={}),x.params.expires=m})(n,e[2])),e===null&&(t=n),e}function Ue(){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 mr(){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(k){return parseFloat(i.substring(t,k))})(u)),e===null&&(t=u),e}function ie(){var e,s,r,n,a,u;return n=t,a=t,e=B(),e!==null?(u=t,s=X(),s!==null?(r=gr(),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,k){x.params||(x.params={}),typeof k>"u"?k=void 0:k=k[1],x.params[P.toLowerCase()]=k})(n,e[0],e[1])),e===null&&(t=n),e}function gr(){var e;return e=B(),e===null&&(e=Me(),e===null&&(e=K())),e}function hl(){var e,s,r,n,a,u;if(a=t,e=Tr(),e!==null){for(s=[],u=t,r=Y(),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=Y(),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 Tr(){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 bt(){var e;return e=Cr(),e===null&&(e=ie()),e}function Cr(){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=X(),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 dl(){var e,s,r,n,a,u;if(a=t,e=B(),e!==null){for(s=[],u=t,r=ee(),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=ee(),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 _l(){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){x=parseInt(a.join(""))})(r,e)),e===null&&(t=r),e}function pl(){var e,s;return s=t,e=vr(),e!==null&&(e=(function(r){x=i.substring(t,r)})(s)),e===null&&(t=s),e}function vr(){var e,s,r,n,a,u,m,P;if(m=t,e=Er(),e!==null)if(s=_e(),s!==null)if(r=br(),r!==null){for(n=[],P=t,a=Y(),a!==null?(u=wt(),u!==null?a=[a,u]:(a=null,t=P)):(a=null,t=P);a!==null;)n.push(a),P=t,a=Y(),a!==null?(u=wt(),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 Er(){var e;return e=Sr(),e===null&&(e=Ar()),e}function Sr(){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=tt()))))),e}function Ar(){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=tt())),e}function tt(){var e;return e=B(),e===null&&(e=Rr()),e}function Rr(){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 br(){var e;return e=tt(),e===null&&(e=B()),e}function wt(){var e,s,r,n;return n=t,e=B(),e!==null?(s=X(),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;return e=B(),e===null&&(e=K()),e}function ml(){var e,s,r,n;return n=t,e=yr(),e!==null?(s=d(),s!==null?(r=Qe(),r!==null?e=[e,s,r]:(e=null,t=n)):(e=null,t=n)):(e=null,t=n),e}function yr(){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){x.value=parseInt(a.join(""))})(r,e)),e===null&&(t=r),e}function gl(){var e,s;return s=t,e=Ue(),e!==null&&(e=(function(r,n){x=n})(s,e)),e===null&&(t=s),e}function Tl(){var e,s,r,n,a,u,m;if(a=t,u=t,e=je(),e!==null){for(s=[],m=t,r=Y(),r!==null?(n=ie(),n!==null?r=[r,n]:(r=null,t=m)):(r=null,t=m);r!==null;)s.push(r),m=t,r=Y(),r!==null?(n=ie(),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,k){x.event=k.join("").toLowerCase()})(a,e[0])),e===null&&(t=a),e}function je(){var e,s,r,n,a,u;if(a=t,e=ue(),e!==null){for(s=[],u=t,i.charCodeAt(t)===46?(r=".",t++):(r=null,l('"."')),r!==null?(n=ue(),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=ue(),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 Cl(){var e,s,r,n,a,u,m;if(a=t,u=t,e=te(),e===null&&(e=De()),e!==null){for(s=[],m=t,r=Y(),r!==null?(n=yt(),n!==null?r=[r,n]:(r=null,t=m)):(r=null,t=m);r!==null;)s.push(r),m=t,r=Y(),r!==null?(n=yt(),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 k=x.tag;try{x=new Pe(x.uri,x.display_name,x.params),k&&x.setParam("tag",k)}catch{x=-1}})()),e===null&&(t=a),e}function yt(){var e;return e=It(),e===null&&(e=ie()),e}function It(){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=X(),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){x.tag=m})(n,e[2])),e===null&&(t=n),e}function vl(){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){x=parseInt(a.join(""))})(r,e)),e===null&&(t=r),e}function El(){var e,s;return s=t,e=Ue(),e!==null&&(e=(function(r,n){x=n})(s,e)),e===null&&(t=s),e}function Sl(){var e,s,r,n,a,u,m,P,k,W;for(P=t,k=t,e=[],s=et();s!==null;)e.push(s),s=et();if(e!==null)if(s=Re(),s!==null)if(r=ve(),r!==null)if(n=Ae(),n!==null){for(a=[],W=t,u=Y(),u!==null?(m=ie(),m!==null?u=[u,m]:(u=null,t=W)):(u=null,t=W);u!==null;)a.push(u),W=t,u=Y(),u!==null?(m=ie(),m!==null?u=[u,m]:(u=null,t=W)):(u=null,t=W);a!==null?e=[e,s,r,n,a]:(e=null,t=k)}else e=null,t=k;else e=null,t=k;else e=null,t=k;else e=null,t=k;return e!==null&&(e=(function(se){try{x=new Pe(x.uri,x.display_name,x.params)}catch{x=-1}})()),e===null&&(t=P),e}function Al(){var e;return e=xt(),e}function xt(){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=d(),s!==null)if(r=st(),r!==null){for(n=[],P=t,a=ee(),a!==null?(u=st(),u!==null?a=[a,u]:(a=null,t=P)):(a=null,t=P);a!==null;)n.push(a),P=t,a=ee(),a!==null?(u=st(),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=Ir()),e}function Ir(){var e,s,r,n,a,u,m,P;if(m=t,e=B(),e!==null)if(s=d(),s!==null)if(r=Ge(),r!==null){for(n=[],P=t,a=ee(),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=ee(),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=X(),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 st(){var e;return e=xr(),e===null&&(e=Or(),e===null&&(e=Dr(),e===null&&(e=Pr(),e===null&&(e=Mr(),e===null&&(e=Lr(),e===null&&(e=Fr(),e===null&&(e=Ge()))))))),e}function xr(){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=X(),s!==null?(r=Nr(),r!==null?e=[e,s,r]:(e=null,t=n)):(e=null,t=n)):(e=null,t=n),e}function Nr(){var e,s;return s=t,e=Q(),e!==null&&(e=(function(r,n){x.realm=n})(s,e)),e===null&&(t=s),e}function Or(){var e,s,r,n,a,u,m,P,k;if(P=t,i.substr(t,6).toLowerCase()==="domain"?(e=i.substr(t,6),t+=6):(e=null,l('"domain"')),e!==null)if(s=X(),s!==null)if(r=be(),r!==null)if(n=rt(),n!==null){if(a=[],k=t,m=C(),m!==null)for(u=[];m!==null;)u.push(m),m=C();else u=null;for(u!==null?(m=rt(),m!==null?u=[u,m]:(u=null,t=k)):(u=null,t=k);u!==null;){if(a.push(u),k=t,m=C(),m!==null)for(u=[];m!==null;)u.push(m),m=C();else u=null;u!==null?(m=rt(),m!==null?u=[u,m]:(u=null,t=k)):(u=null,t=k)}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 rt(){var e;return e=Et(),e===null&&(e=Je()),e}function Dr(){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=X(),s!==null?(r=Ur(),r!==null?e=[e,s,r]:(e=null,t=n)):(e=null,t=n)):(e=null,t=n),e}function Ur(){var e,s;return s=t,e=Q(),e!==null&&(e=(function(r,n){x.nonce=n})(s,e)),e===null&&(t=s),e}function Pr(){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=X(),s!==null?(r=Q(),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u,m){x.opaque=m})(n,e[2])),e===null&&(t=n),e}function Mr(){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=X(),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){x.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){x.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 Lr(){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=X(),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){x.algorithm=m.toUpperCase()})(n,e[2])),e===null&&(t=n),e}function Fr(){var e,s,r,n,a,u,m,P,k,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=X(),s!==null)if(r=be(),r!==null){if(k=t,n=nt(),n!==null){for(a=[],W=t,i.charCodeAt(t)===44?(u=",",t++):(u=null,l('","')),u!==null?(m=nt(),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=nt(),m!==null?u=[u,m]:(u=null,t=W)):(u=null,t=W);a!==null?n=[n,a]:(n=null,t=k)}else n=null,t=k;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 nt(){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){x.qop||(x.qop=[]),x.qop.push(n.toLowerCase())})(s,e)),e===null&&(t=s),e}function Rl(){var e,s,r,n,a,u;if(a=t,e=B(),e!==null){for(s=[],u=t,r=ee(),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=ee(),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 bl(){var e,s,r,n,a,u,m;if(a=t,u=t,e=lt(),e!==null){for(s=[],m=t,r=ee(),r!==null?(n=lt(),n!==null?r=[r,n]:(r=null,t=m)):(r=null,t=m);r!==null;)s.push(r),m=t,r=ee(),r!==null?(n=lt(),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 k,W;for(W=x.multi_header.length,k=0;k<W;k++)if(x.multi_header[k].parsed===null){x=null;break}x!==null?x=x.multi_header:x=-1})()),e===null&&(t=a),e}function lt(){var e,s,r,n,a,u,m;if(a=t,u=t,e=De(),e!==null){for(s=[],m=t,r=Y(),r!==null?(n=ie(),n!==null?r=[r,n]:(r=null,t=m)):(r=null,t=m);r!==null;)s.push(r),m=t,r=Y(),r!==null?(n=ie(),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 k;x.multi_header||(x.multi_header=[]);try{k=new Pe(x.uri,x.display_name,x.params),delete x.uri,delete x.display_name,delete x.params}catch{k=null}x.multi_header.push({possition:t,offset:P,parsed:k})})(a)),e===null&&(t=a),e}function wl(){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=Y(),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=Y(),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,k){if(x.protocol=k.toLowerCase(),x.params||(x.params={}),x.params.text&&x.params.text[0]==='"'){var W=x.params.text;x.text=W.substring(1,W.length-1),delete x.params.text}})(a,e[0])),e===null&&(t=a),e}function Nt(){var e;return e=Hr(),e===null&&(e=ie()),e}function Hr(){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=X(),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){x.cause=parseInt(P.join(""))})(a,e[2])),e===null&&(t=a),e}function yl(){var e,s,r,n,a,u;if(a=t,e=B(),e!==null){for(s=[],u=t,r=ee(),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=ee(),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 Il(){var e,s,r,n,a,u;if(a=t,e=it(),e!==null){for(s=[],u=t,r=ee(),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=ee(),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;if(a=t,e=De(),e!==null){for(s=[],u=t,r=Y(),r!==null?(n=ie(),n!==null?r=[r,n]:(r=null,t=u)):(r=null,t=u);r!==null;)s.push(r),u=t,r=Y(),r!==null?(n=ie(),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 xl(){var e,s,r,n,a,u;if(a=t,e=$r(),e!==null){for(s=[],u=t,r=Y(),r!==null?(n=Ot(),n!==null?r=[r,n]:(r=null,t=u)):(r=null,t=u);r!==null;)s.push(r),u=t,r=Y(),r!==null?(n=Ot(),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 $r(){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){x.state=i.substring(t,r)})(s)),e===null&&(t=s),e}function Ot(){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=X(),s!==null?(r=kr(),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"&&(x.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=X(),s!==null?(r=Ue(),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"&&(x.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=X(),s!==null?(r=Ue(),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"&&(x.retry_after=m)})(n,e[2])),e===null&&(t=n),e===null&&(e=ie()))),e}function kr(){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 Nl(){var e;return e=v(),e=e!==null?e:"",e}function Ol(){var e,s,r,n,a,u;if(a=t,e=B(),e!==null){for(s=[],u=t,r=ee(),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=ee(),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 Dl(){var e,s,r,n,a,u,m;if(a=t,u=t,e=te(),e===null&&(e=De()),e!==null){for(s=[],m=t,r=Y(),r!==null?(n=Dt(),n!==null?r=[r,n]:(r=null,t=m)):(r=null,t=m);r!==null;)s.push(r),m=t,r=Y(),r!==null?(n=Dt(),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 k=x.tag;try{x=new Pe(x.uri,x.display_name,x.params),k&&x.setParam("tag",k)}catch{x=-1}})()),e===null&&(t=a),e}function Dt(){var e;return e=It(),e===null&&(e=ie()),e}function Ul(){var e,s,r,n,a,u;if(a=t,e=at(),e!==null){for(s=[],u=t,r=ee(),r!==null?(n=at(),n!==null?r=[r,n]:(r=null,t=u)):(r=null,t=u);r!==null;)s.push(r),u=t,r=ee(),r!==null?(n=at(),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 at(){var e,s,r,n,a,u,m,P;if(m=t,e=zr(),e!==null)if(s=d(),s!==null)if(r=Jr(),r!==null){for(n=[],P=t,a=Y(),a!==null?(u=Ut(),u!==null?a=[a,u]:(a=null,t=P)):(a=null,t=P);a!==null;)n.push(a),P=t,a=Y(),a!==null?(u=Ut(),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 Ut(){var e;return e=qr(),e===null&&(e=jr(),e===null&&(e=Gr(),e===null&&(e=Br(),e===null&&(e=Wr(),e===null&&(e=ie()))))),e}function qr(){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=X(),s!==null?(r=Pt(),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u,m){x.ttl=m})(n,e[2])),e===null&&(t=n),e}function jr(){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=X(),s!==null?(r=Me(),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u,m){x.maddr=m})(n,e[2])),e===null&&(t=n),e}function Gr(){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=X(),s!==null?(r=Le(),r===null&&(r=Ct()),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u,m){x.received=m})(n,e[2])),e===null&&(t=n),e}function Br(){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=X(),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){x.branch=m})(n,e[2])),e===null&&(t=n),e}function Wr(){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=X(),s!==null?(r=Vr(),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 Vr(){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,k){x.rport=parseInt(k.join(""))})(u,e)),e===null&&(t=u),e}function zr(){var e,s,r,n,a,u;return u=t,e=Kr(),e!==null?(s=_e(),s!==null?(r=B(),r!==null?(n=_e(),n!==null?(a=Yr(),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 Kr(){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){x.protocol=n})(s,e)),e===null&&(t=s),e}function Yr(){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){x.transport=n})(s,e)),e===null&&(t=s),e}function Jr(){var e,s,r,n,a;return n=t,e=Xr(),e!==null?(a=t,s=Oe(),s!==null?(r=Qr(),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 Xr(){var e,s;return s=t,e=Le(),e===null&&(e=Tt(),e===null&&(e=mt())),e!==null&&(e=(function(r){x.host=i.substring(t,r)})(s)),e===null&&(t=s),e}function Qr(){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,k){x.port=parseInt(k.join(""))})(u,e)),e===null&&(t=u),e}function Pt(){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 Pl(){var e;return e=xt(),e}function Ml(){var e,s,r,n,a,u;if(a=t,e=Zr(),e!==null){for(s=[],u=t,r=Y(),r!==null?(n=Mt(),n!==null?r=[r,n]:(r=null,t=u)):(r=null,t=u);r!==null;)s.push(r),u=t,r=Y(),r!==null?(n=Mt(),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 Zr(){var e,s;return s=t,e=Ue(),e!==null&&(e=(function(r,n){x.expires=n})(s,e)),e===null&&(t=s),e}function Mt(){var e;return e=en(),e===null&&(e=ie()),e}function en(){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=X(),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){x.refresher=m.toLowerCase()})(n,e[2])),e===null&&(t=n),e}function Ll(){var e,s,r,n;return n=t,e=B(),e!==null?(s=O(),s!==null?(r=tn(),r!==null?e=[e,s,r]:(e=null,t=n)):(e=null,t=n)):(e=null,t=n),e}function tn(){var e,s;for(e=[],s=b(),s===null&&(s=M(),s===null&&(s=d()));s!==null;)e.push(s),s=b(),s===null&&(s=M(),s===null&&(s=d()));return e}function Fl(){var e,s;for(e=[],s=N();s!==null;)e.push(s),s=N();return e}function Hl(){var e,s,r;return r=t,i.substr(t,5)==="uuid:"?(e="uuid:",t+=5):(e=null,l('"uuid:"')),e!==null?(s=sn(),s!==null?e=[e,s]:(e=null,t=r)):(e=null,t=r),e}function sn(){var e,s,r,n,a,u,m,P,k,W,se;return W=t,se=t,e=rn(),e!==null?(i.charCodeAt(t)===45?(s="-",t++):(s=null,l('"-"')),s!==null?(r=Ee(),r!==null?(i.charCodeAt(t)===45?(n="-",t++):(n=null,l('"-"')),n!==null?(a=Ee(),a!==null?(i.charCodeAt(t)===45?(u="-",t++):(u=null,l('"-"')),u!==null?(m=Ee(),m!==null?(i.charCodeAt(t)===45?(P="-",t++):(P=null,l('"-"')),P!==null?(k=nn(),k!==null?e=[e,s,r,n,a,u,m,P,k]:(e=null,t=se)):(e=null,t=se)):(e=null,t=se)):(e=null,t=se)):(e=null,t=se)):(e=null,t=se)):(e=null,t=se)):(e=null,t=se)):(e=null,t=se),e!==null&&(e=(function(Te,ot){x=i.substring(t+5,Te)})(W,e[0])),e===null&&(t=W),e}function Ee(){var e,s,r,n,a;return a=t,e=D(),e!==null?(s=D(),s!==null?(r=D(),r!==null?(n=D(),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 rn(){var e,s,r;return r=t,e=Ee(),e!==null?(s=Ee(),s!==null?e=[e,s]:(e=null,t=r)):(e=null,t=r),e}function nn(){var e,s,r,n;return n=t,e=Ee(),e!==null?(s=Ee(),s!==null?(r=Ee(),r!==null?e=[e,s,r]:(e=null,t=n)):(e=null,t=n)):(e=null,t=n),e}function $l(){var e,s,r,n,a,u,m;if(a=t,u=t,e=te(),e===null&&(e=De()),e!==null){for(s=[],m=t,r=Y(),r!==null?(n=ie(),n!==null?r=[r,n]:(r=null,t=m)):(r=null,t=m);r!==null;)s.push(r),m=t,r=Y(),r!==null?(n=ie(),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{x=new Pe(x.uri,x.display_name,x.params)}catch{x=-1}})()),e===null&&(t=a),e}function kl(){var e,s,r,n,a,u;if(a=t,e=ln(),e!==null){for(s=[],u=t,r=Y(),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=Y(),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 ln(){var e,s,r,n,a,u;return n=t,a=t,e=he(),e!==null?(u=t,i.charCodeAt(t)===64?(s="@",t++):(s=null,l('"@"')),s!==null?(r=he(),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){x.call_id=i.substring(t,m)})(n)),e===null&&(t=n),e}function Lt(){var e;return e=an(),e===null&&(e=on(),e===null&&(e=un(),e===null&&(e=ie()))),e}function an(){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=X(),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){x.to_tag=m})(n,e[2])),e===null&&(t=n),e}function on(){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=X(),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){x.from_tag=m})(n,e[2])),e===null&&(t=n),e}function un(){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){x.early_only=!0})()),e===null&&(t=s),e}function ql(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 jl(){for(var e=1,s=1,r=!1,n=0;n<Math.max(t,_);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 cn=ye(),Pe=Es(),x={},Gl=R[p]();if(Gl===null||t!==i.length){var Ft=Math.max(t,_),Bl=Ft<i.length?i.charAt(Ft):null,fn=jl();return new this.SyntaxError(ql(h),Bl,Ft,fn.line,fn.column),-1}return x},toSource:function(){return this._source}};return y.SyntaxError=function(i,p,R,t,_){function h(l,g){var c,S;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 S=g?I(g):"end of input","Expected "+c+" but "+S+" found."}this.name="SyntaxError",this.expected=i,this.found=p,this.message=h(i,p),this.offset=R,this.line=t,this.column=_},y.SyntaxError.prototype=Error.prototype,y})()),jt}var Gt,mn;function ye(){if(mn)return Gt;mn=1;const I=oe(),y=fe(),i=Ce();return Gt=class Zn{static parse(R){if(R=i.parse(R,"SIP_URI"),R!==-1)return R}constructor(R,t,_,h,l={},g={}){if(!_)throw new TypeError('missing or invalid "host" parameter');this._parameters={},this._headers={},this._scheme=R||I.SIP,this._user=t,this._host=_,this._port=h;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(R){this._scheme=R.toLowerCase()}get user(){return this._user}set user(R){this._user=R}get host(){return this._host}set host(R){this._host=R.toLowerCase()}get port(){return this._port}set port(R){this._port=R===0?R:parseInt(R,10)||null}setParam(R,t){R&&(this._parameters[R.toLowerCase()]=typeof t>"u"||t===null?null:t.toString())}getParam(R){if(R)return this._parameters[R.toLowerCase()]}hasParam(R){if(R)return this._parameters.hasOwnProperty(R.toLowerCase())&&!0||!1}deleteParam(R){if(R=R.toLowerCase(),this._parameters.hasOwnProperty(R)){const t=this._parameters[R];return delete this._parameters[R],t}}clearParams(){this._parameters={}}setHeader(R,t){this._headers[y.headerize(R)]=Array.isArray(t)?t:[t]}getHeader(R){if(R)return this._headers[y.headerize(R)]}hasHeader(R){if(R)return this._headers.hasOwnProperty(y.headerize(R))&&!0||!1}deleteHeader(R){if(R=y.headerize(R),this._headers.hasOwnProperty(R)){const t=this._headers[R];return delete this._headers[R],t}}clearHeaders(){this._headers={}}clone(){return new Zn(this._scheme,this._user,this._host,this._port,JSON.parse(JSON.stringify(this._parameters)),JSON.parse(JSON.stringify(this._headers)))}toString(){const R=[];let t=`${this._scheme}:`;this._user&&(t+=`${y.escapeUser(this._user)}@`),t+=this._host,(this._port||this._port===0)&&(t+=`:${this._port}`);for(const _ in this._parameters)Object.prototype.hasOwnProperty.call(this._parameters,_)&&(t+=`;${_}`,this._parameters[_]!==null&&(t+=`=${this._parameters[_]}`));for(const _ in this._headers)if(Object.prototype.hasOwnProperty.call(this._headers,_))for(const h of this._headers[_])R.push(`${_}=${h}`);return R.length>0&&(t+=`?${R.join("&")}`),t}toAor(R){let t=`${this._scheme}:`;return this._user&&(t+=`${y.escapeUser(this._user)}@`),t+=this._host,R&&(this._port||this._port===0)&&(t+=`:${this._port}`),t}},Gt}var gn;function fe(){if(gn)return le;gn=1;const I=oe(),y=ye(),i=Ce();le.str_utf8_length=_=>unescape(encodeURIComponent(_)).length;const p=le.isFunction=_=>_!==void 0?Object.prototype.toString.call(_)==="[object Function]":!1;le.isString=_=>_!==void 0?Object.prototype.toString.call(_)==="[object String]":!1,le.isDecimal=_=>!isNaN(_)&&parseFloat(_)===parseInt(_,10),le.isEmpty=_=>_===null||_===""||_===void 0||Array.isArray(_)&&_.length===0||typeof _=="number"&&isNaN(_),le.hasMethods=function(_,...h){for(const l of h)if(p(_[l]))return!1;return!0};const R=le.createRandomToken=(_,h=32)=>{let l,g,c="";for(l=0;l<_;l++)g=Math.random()*h|0,c+=g.toString(h);return c};le.newTag=()=>R(10),le.newUUID=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,h=>{const l=Math.random()*16|0;return(h==="x"?l:l&3|8).toString(16)}),le.hostType=_=>{if(_){if(_=i.parse(_,"host"),_!==-1)return _.host_type}else return};const t=le.escapeUser=_=>encodeURIComponent(decodeURIComponent(_)).replace(/%3A/ig,":").replace(/%2B/ig,"+").replace(/%3F/ig,"?").replace(/%2F/ig,"/");return le.normalizeTarget=(_,h)=>{if(_){if(_ instanceof y)return _;if(typeof _=="string"){const l=_.split("@");let g,c;switch(l.length){case 1:if(!h)return;g=_,c=h;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,"")),_=`${I.SIP}:${t(g)}@${c}`;let S;return(S=y.parse(_))?S:void 0}else return}else return},le.headerize=_=>{const h={"Call-Id":"Call-ID",Cseq:"CSeq","Www-Authenticate":"WWW-Authenticate"},l=_.toLowerCase().replace(/_/g,"-").split("-");let g="";const c=l.length;let S;for(S=0;S<c;S++)S!==0&&(g+="-"),g+=l[S].charAt(0).toUpperCase()+l[S].substring(1);return h[g]&&(g=h[g]),g},le.sipErrorCause=_=>{for(const h in I.SIP_ERROR_CAUSES)if(I.SIP_ERROR_CAUSES[h].indexOf(_)!==-1)return I.causes[h];return I.causes.SIP_FAILURE_CODE},le.getRandomTestNetIP=()=>{function _(h,l){return Math.floor(Math.random()*(l-h+1)+h)}return`192.0.2.${_(1,254)}`},le.calculateMD5=_=>{function h(z,V){return z<<V|z>>>32-V}function l(z,V){const K=z&2147483648,Q=V&2147483648,re=z&1073741824,ne=V&1073741824,te=(z&1073741823)+(V&1073741823);return re&ne?te^2147483648^K^Q:re|ne?te&1073741824?te^3221225472^K^Q:te^1073741824^K^Q:te^K^Q}function g(z,V,K){return z&V|~z&K}function c(z,V,K){return z&K|V&~K}function S(z,V,K){return z^V^K}function D(z,V,K){return V^(z|~K)}function E(z,V,K,Q,re,ne,te){return z=l(z,l(l(g(V,K,Q),re),te)),l(h(z,ne),V)}function N(z,V,K,Q,re,ne,te){return z=l(z,l(l(c(V,K,Q),re),te)),l(h(z,ne),V)}function $(z,V,K,Q,re,ne,te){return z=l(z,l(l(S(V,K,Q),re),te)),l(h(z,ne),V)}function C(z,V,K,Q,re,ne,te){return z=l(z,l(l(D(V,K,Q),re),te)),l(h(z,ne),V)}function w(z){let V;const K=z.length,Q=K+8,ne=((Q-Q%64)/64+1)*16,te=new Array(ne-1);let ve=0,pe=0;for(;pe<K;)V=(pe-pe%4)/4,ve=pe%4*8,te[V]=te[V]|z.charCodeAt(pe)<<ve,pe++;return V=(pe-pe%4)/4,ve=pe%4*8,te[V]=te[V]|128<<ve,te[ne-2]=K<<3,te[ne-1]=K>>>29,te}function F(z){let V="",K="",Q,re;for(re=0;re<=3;re++)Q=z>>>re*8&255,K=`0${Q.toString(16)}`,V=V+K.substr(K.length-2,2);return V}function H(z){let V="";for(let K=0;K<z.length;K++){const Q=z.charCodeAt(K);Q<128?V+=String.fromCharCode(Q):Q>127&&Q<2048?(V+=String.fromCharCode(Q>>6|192),V+=String.fromCharCode(Q&63|128)):(V+=String.fromCharCode(Q>>12|224),V+=String.fromCharCode(Q>>6&63|128),V+=String.fromCharCode(Q&63|128))}return V}let o=[],f,T,d,A,O,v,b,U,M;const Z=7,B=12,ue=17,de=22,he=5,J=9,_e=14,X=20,xe=4,Ne=11,Ae=16,Re=23,ee=6,Y=10,Oe=15,be=21;for(_=H(_),o=w(_),v=1732584193,b=4023233417,U=2562383102,M=271733878,f=0;f<o.length;f+=16)T=v,d=b,A=U,O=M,v=E(v,b,U,M,o[f+0],Z,3614090360),M=E(M,v,b,U,o[f+1],B,3905402710),U=E(U,M,v,b,o[f+2],ue,606105819),b=E(b,U,M,v,o[f+3],de,3250441966),v=E(v,b,U,M,o[f+4],Z,4118548399),M=E(M,v,b,U,o[f+5],B,1200080426),U=E(U,M,v,b,o[f+6],ue,2821735955),b=E(b,U,M,v,o[f+7],de,4249261313),v=E(v,b,U,M,o[f+8],Z,1770035416),M=E(M,v,b,U,o[f+9],B,2336552879),U=E(U,M,v,b,o[f+10],ue,4294925233),b=E(b,U,M,v,o[f+11],de,2304563134),v=E(v,b,U,M,o[f+12],Z,1804603682),M=E(M,v,b,U,o[f+13],B,4254626195),U=E(U,M,v,b,o[f+14],ue,2792965006),b=E(b,U,M,v,o[f+15],de,1236535329),v=N(v,b,U,M,o[f+1],he,4129170786),M=N(M,v,b,U,o[f+6],J,3225465664),U=N(U,M,v,b,o[f+11],_e,643717713),b=N(b,U,M,v,o[f+0],X,3921069994),v=N(v,b,U,M,o[f+5],he,3593408605),M=N(M,v,b,U,o[f+10],J,38016083),U=N(U,M,v,b,o[f+15],_e,3634488961),b=N(b,U,M,v,o[f+4],X,3889429448),v=N(v,b,U,M,o[f+9],he,568446438),M=N(M,v,b,U,o[f+14],J,3275163606),U=N(U,M,v,b,o[f+3],_e,4107603335),b=N(b,U,M,v,o[f+8],X,1163531501),v=N(v,b,U,M,o[f+13],he,2850285829),M=N(M,v,b,U,o[f+2],J,4243563512),U=N(U,M,v,b,o[f+7],_e,1735328473),b=N(b,U,M,v,o[f+12],X,2368359562),v=$(v,b,U,M,o[f+5],xe,4294588738),M=$(M,v,b,U,o[f+8],Ne,2272392833),U=$(U,M,v,b,o[f+11],Ae,1839030562),b=$(b,U,M,v,o[f+14],Re,4259657740),v=$(v,b,U,M,o[f+1],xe,2763975236),M=$(M,v,b,U,o[f+4],Ne,1272893353),U=$(U,M,v,b,o[f+7],Ae,4139469664),b=$(b,U,M,v,o[f+10],Re,3200236656),v=$(v,b,U,M,o[f+13],xe,681279174),M=$(M,v,b,U,o[f+0],Ne,3936430074),U=$(U,M,v,b,o[f+3],Ae,3572445317),b=$(b,U,M,v,o[f+6],Re,76029189),v=$(v,b,U,M,o[f+9],xe,3654602809),M=$(M,v,b,U,o[f+12],Ne,3873151461),U=$(U,M,v,b,o[f+15],Ae,530742520),b=$(b,U,M,v,o[f+2],Re,3299628645),v=C(v,b,U,M,o[f+0],ee,4096336452),M=C(M,v,b,U,o[f+7],Y,1126891415),U=C(U,M,v,b,o[f+14],Oe,2878612391),b=C(b,U,M,v,o[f+5],be,4237533241),v=C(v,b,U,M,o[f+12],ee,1700485571),M=C(M,v,b,U,o[f+3],Y,2399980690),U=C(U,M,v,b,o[f+10],Oe,4293915773),b=C(b,U,M,v,o[f+1],be,2240044497),v=C(v,b,U,M,o[f+8],ee,1873313359),M=C(M,v,b,U,o[f+15],Y,4264355552),U=C(U,M,v,b,o[f+6],Oe,2734768916),b=C(b,U,M,v,o[f+13],be,1309151649),v=C(v,b,U,M,o[f+4],ee,4149444226),M=C(M,v,b,U,o[f+11],Y,3174756917),U=C(U,M,v,b,o[f+2],Oe,718787259),b=C(b,U,M,v,o[f+9],be,3951481745),v=l(v,T),b=l(b,d),U=l(U,A),M=l(M,O);return(F(v)+F(b)+F(U)+F(M)).toLowerCase()},le.closeMediaStream=_=>{if(_)try{let h;if(_.getTracks){h=_.getTracks();for(const l of h)l.stop()}else{h=_.getAudioTracks();for(const l of h)l.stop();h=_.getVideoTracks();for(const l of h)l.stop()}}catch{(typeof _.stop=="function"||typeof _.stop=="object")&&_.stop()}},le.cloneArray=_=>_&&_.slice()||[],le.cloneObject=(_,h={})=>_&&Object.assign({},_)||h,le}var ut={exports:{}},Tn;function Ie(){if(Tn)return ut.exports;Tn=1;var I=typeof Reflect=="object"?Reflect:null,y=I&&typeof I.apply=="function"?I.apply:function(f,T,d){return Function.prototype.apply.call(f,T,d)},i;I&&typeof I.ownKeys=="function"?i=I.ownKeys:Object.getOwnPropertySymbols?i=function(f){return Object.getOwnPropertyNames(f).concat(Object.getOwnPropertySymbols(f))}:i=function(f){return Object.getOwnPropertyNames(f)};function p(o){console&&console.warn&&console.warn(o)}var R=Number.isNaN||function(f){return f!==f};function t(){t.init.call(this)}ut.exports=t,ut.exports.once=w,t.EventEmitter=t,t.prototype._events=void 0,t.prototype._eventsCount=0,t.prototype._maxListeners=void 0;var _=10;function h(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 _},set:function(o){if(typeof o!="number"||o<0||R(o))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+o+".");_=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||R(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=[],d=1;d<arguments.length;d++)T.push(arguments[d]);var A=f==="error",O=this._events;if(O!==void 0)A=A&&O.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 b=new Error("Unhandled error."+(v?" ("+v.message+")":""));throw b.context=v,b}var U=O[f];if(U===void 0)return!1;if(typeof U=="function")y(U,this,T);else for(var M=U.length,Z=N(U,M),d=0;d<M;++d)y(Z[d],this,T);return!0};function g(o,f,T,d){var A,O,v;if(h(T),O=o._events,O===void 0?(O=o._events=Object.create(null),o._eventsCount=0):(O.newListener!==void 0&&(o.emit("newListener",f,T.listener?T.listener:T),O=o._events),v=O[f]),v===void 0)v=O[f]=T,++o._eventsCount;else if(typeof v=="function"?v=O[f]=d?[T,v]:[v,T]:d?v.unshift(T):v.push(T),A=l(o),A>0&&v.length>A&&!v.warned){v.warned=!0;var b=new Error("Possible EventEmitter memory leak detected. "+v.length+" "+String(f)+" listeners added. Use emitter.setMaxListeners() to increase limit");b.name="MaxListenersExceededWarning",b.emitter=o,b.type=f,b.count=v.length,p(b)}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 S(o,f,T){var d={fired:!1,wrapFn:void 0,target:o,type:f,listener:T},A=c.bind(d);return A.listener=T,d.wrapFn=A,A}t.prototype.once=function(f,T){return h(T),this.on(f,S(this,f,T)),this},t.prototype.prependOnceListener=function(f,T){return h(T),this.prependListener(f,S(this,f,T)),this},t.prototype.removeListener=function(f,T){var d,A,O,v,b;if(h(T),A=this._events,A===void 0)return this;if(d=A[f],d===void 0)return this;if(d===T||d.listener===T)--this._eventsCount===0?this._events=Object.create(null):(delete A[f],A.removeListener&&this.emit("removeListener",f,d.listener||T));else if(typeof d!="function"){for(O=-1,v=d.length-1;v>=0;v--)if(d[v]===T||d[v].listener===T){b=d[v].listener,O=v;break}if(O<0)return this;O===0?d.shift():$(d,O),d.length===1&&(A[f]=d[0]),A.removeListener!==void 0&&this.emit("removeListener",f,b||T)}return this},t.prototype.off=t.prototype.removeListener,t.prototype.removeAllListeners=function(f){var T,d,A;if(d=this._events,d===void 0)return this;if(d.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):d[f]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete d[f]),this;if(arguments.length===0){var O=Object.keys(d),v;for(A=0;A<O.length;++A)v=O[A],v!=="removeListener"&&this.removeAllListeners(v);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(T=d[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 D(o,f,T){var d=o._events;if(d===void 0)return[];var A=d[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 D(this,f,!0)},t.prototype.rawListeners=function(f){return D(this,f,!1)},t.listenerCount=function(o,f){return typeof o.listenerCount=="function"?o.listenerCount(f):E.call(o,f)},t.prototype.listenerCount=E;function E(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),d=0;d<f;++d)T[d]=o[d];return T}function $(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 w(o,f){return new Promise(function(T,d){function A(v){o.removeListener(f,O),d(v)}function O(){typeof o.removeListener=="function"&&o.removeListener("error",A),T([].slice.call(arguments))}H(o,f,O,{once:!0}),f!=="error"&&F(o,A,{once:!0})})}function F(o,f,T){typeof o.on=="function"&&H(o,"error",f,T)}function H(o,f,T,d){if(typeof o.on=="function")d.once?o.once(f,T):o.on(f,T);else if(typeof o.addEventListener=="function")o.addEventListener(f,function A(O){d.once&&o.removeEventListener(f,A),T(O)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof o)}return ut.exports}var ct={exports:{}},Bt,Cn;function Jl(){if(Cn)return Bt;Cn=1;var I=1e3,y=I*60,i=y*60,p=i*24,R=p*7,t=p*365.25;Bt=function(c,S){S=S||{};var D=typeof c;if(D==="string"&&c.length>0)return _(c);if(D==="number"&&isFinite(c))return S.long?l(c):h(c);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(c))};function _(c){if(c=String(c),!(c.length>100)){var S=/^(-?(?:\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(S){var D=parseFloat(S[1]),E=(S[2]||"ms").toLowerCase();switch(E){case"years":case"year":case"yrs":case"yr":case"y":return D*t;case"weeks":case"week":case"w":return D*R;case"days":case"day":case"d":return D*p;case"hours":case"hour":case"hrs":case"hr":case"h":return D*i;case"minutes":case"minute":case"mins":case"min":case"m":return D*y;case"seconds":case"second":case"secs":case"sec":case"s":return D*I;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return D;default:return}}}}function h(c){var S=Math.abs(c);return S>=p?Math.round(c/p)+"d":S>=i?Math.round(c/i)+"h":S>=y?Math.round(c/y)+"m":S>=I?Math.round(c/I)+"s":c+"ms"}function l(c){var S=Math.abs(c);return S>=p?g(c,S,p,"day"):S>=i?g(c,S,i,"hour"):S>=y?g(c,S,y,"minute"):S>=I?g(c,S,I,"second"):c+" ms"}function g(c,S,D,E){var N=S>=D*1.5;return Math.round(c/D)+" "+E+(N?"s":"")}return Bt}var Wt,vn;function Xl(){if(vn)return Wt;vn=1;function I(y){p.debug=p,p.default=p,p.coerce=g,p.disable=h,p.enable=t,p.enabled=l,p.humanize=Jl(),p.destroy=c,Object.keys(y).forEach(S=>{p[S]=y[S]}),p.names=[],p.skips=[],p.formatters={};function i(S){let D=0;for(let E=0;E<S.length;E++)D=(D<<5)-D+S.charCodeAt(E),D|=0;return p.colors[Math.abs(D)%p.colors.length]}p.selectColor=i;function p(S){let D,E=null,N,$;function C(...w){if(!C.enabled)return;const F=C,H=Number(new Date),o=H-(D||H);F.diff=o,F.prev=D,F.curr=H,D=H,w[0]=p.coerce(w[0]),typeof w[0]!="string"&&w.unshift("%O");let f=0;w[0]=w[0].replace(/%([a-zA-Z%])/g,(d,A)=>{if(d==="%%")return"%";f++;const O=p.formatters[A];if(typeof O=="function"){const v=w[f];d=O.call(F,v),w.splice(f,1),f--}return d}),p.formatArgs.call(F,w),(F.log||p.log).apply(F,w)}return C.namespace=S,C.useColors=p.useColors(),C.color=p.selectColor(S),C.extend=R,C.destroy=p.destroy,Object.defineProperty(C,"enabled",{enumerable:!0,configurable:!1,get:()=>E!==null?E:(N!==p.namespaces&&(N=p.namespaces,$=p.enabled(S)),$),set:w=>{E=w}}),typeof p.init=="function"&&p.init(C),C}function R(S,D){const E=p(this.namespace+(typeof D>"u"?":":D)+S);return E.log=this.log,E}function t(S){p.save(S),p.namespaces=S,p.names=[],p.skips=[];const D=(typeof S=="string"?S:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const E of D)E[0]==="-"?p.skips.push(E.slice(1)):p.names.push(E)}function _(S,D){let E=0,N=0,$=-1,C=0;for(;E<S.length;)if(N<D.length&&(D[N]===S[E]||D[N]==="*"))D[N]==="*"?($=N,C=E,N++):(E++,N++);else if($!==-1)N=$+1,C++,E=C;else return!1;for(;N<D.length&&D[N]==="*";)N++;return N===D.length}function h(){const S=[...p.names,...p.skips.map(D=>"-"+D)].join(",");return p.enable(""),S}function l(S){for(const D of p.skips)if(_(S,D))return!1;for(const D of p.names)if(_(S,D))return!0;return!1}function g(S){return S instanceof Error?S.stack||S.message:S}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 p.enable(p.load()),p}return Wt=I,Wt}var En;function Ts(){return En||(En=1,(function(I,y){y.formatArgs=p,y.save=R,y.load=t,y.useColors=i,y.storage=_(),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 p(l){if(l[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+l[0]+(this.useColors?"%c ":" ")+"+"+I.exports.humanize(this.diff),!this.useColors)return;const g="color: "+this.color;l.splice(1,0,g,"color: inherit");let c=0,S=0;l[0].replace(/%[a-zA-Z%]/g,D=>{D!=="%%"&&(c++,D==="%c"&&(S=c))}),l.splice(S,0,g)}y.log=console.debug||console.log||(()=>{});function R(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 _(){try{return localStorage}catch{}}I.exports=Xl()(y);const{formatters:h}=I.exports;h.j=function(l){try{return JSON.stringify(l)}catch(g){return"[UnexpectedJSONParseError]: "+g.message}}})(ct,ct.exports)),ct.exports}var Vt,Sn;function ce(){if(Sn)return Vt;Sn=1;const I=Ts(),y="JsSIP";return Vt=class{constructor(p){p?(this._debug=I.default(`${y}:${p}`),this._warn=I.default(`${y}:WARN:${p}`),this._error=I.default(`${y}:ERROR:${p}`)):(this._debug=I.default(y),this._warn=I.default(`${y}:WARN`),this._error=I.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}},Vt}var ge={},zt={},Kt={exports:{}},An;function Ss(){if(An)return Kt.exports;An=1;var I=Kt.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(I).forEach(function(y){var i=I[y];i.forEach(function(p){p.reg||(p.reg=/(.*)/),p.format||(p.format="%s")})}),Kt.exports}var Rn;function Ql(){return Rn||(Rn=1,(function(I){var y=function(h){return String(Number(h))===h?Number(h):h},i=function(h,l,g,c){if(c&&!g)l[c]=y(h[1]);else for(var S=0;S<g.length;S+=1)h[S+1]!=null&&(l[g[S]]=y(h[S+1]))},p=function(h,l,g){var c=h.name&&h.names;h.push&&!l[h.push]?l[h.push]=[]:c&&!l[h.name]&&(l[h.name]={});var S=h.push?{}:c?l[h.name]:l;i(g.match(h.reg),S,h.names,h.name),h.push&&l[h.push].push(S)},R=Ss(),t=RegExp.prototype.test.bind(/^([a-z])=(.*)/);I.parse=function(h){var l={},g=[],c=l;return h.split(/(\r\n|\r|\n)/).filter(t).forEach(function(S){var D=S[0],E=S.slice(2);D==="m"&&(g.push({rtp:[],fmtp:[]}),c=g[g.length-1]);for(var N=0;N<(R[D]||[]).length;N+=1){var $=R[D][N];if($.reg.test(E))return p($,c,E)}}),l.media=g,l};var _=function(h,l){var g=l.split(/=(.+)/,2);return g.length===2?h[g[0]]=y(g[1]):g.length===1&&l.length>1&&(h[g[0]]=void 0),h};I.parseParams=function(h){return h.split(/;\s?/).reduce(_,{})},I.parseFmtpConfig=I.parseParams,I.parsePayloads=function(h){return h.toString().split(" ").map(Number)},I.parseRemoteCandidates=function(h){for(var l=[],g=h.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},I.parseImageAttributes=function(h){return h.split(" ").map(function(l){return l.substring(1,l.length-1).split(",").reduce(_,{})})},I.parseSimulcastStreamList=function(h){return h.split(";").map(function(l){return l.split(",").map(function(g){var c,S=!1;return g[0]!=="~"?c=y(g):(c=y(g.substring(1,g.length)),S=!0),{scid:c,paused:S}})})}})(zt)),zt}var Yt,bn;function Zl(){if(bn)return Yt;bn=1;var I=Ss(),y=/%[sdv%]/g,i=function(_){var h=1,l=arguments,g=l.length;return _.replace(y,function(c){if(h>=g)return c;var S=l[h];switch(h+=1,c){case"%%":return"%";case"%s":return String(S);case"%d":return Number(S);case"%v":return""}})},p=function(_,h,l){var g=h.format instanceof Function?h.format(h.push?l:l[h.name]):h.format,c=[_+"="+g];if(h.names)for(var S=0;S<h.names.length;S+=1){var D=h.names[S];h.name?c.push(l[h.name][D]):c.push(l[h.names[S]])}else c.push(l[h.name]);return i.apply(null,c)},R=["v","o","s","i","u","e","p","c","b","t","r","z","a"],t=["i","c","b","a"];return Yt=function(_,h){h=h||{},_.version==null&&(_.version=0),_.name==null&&(_.name=" "),_.media.forEach(function(S){S.payloads==null&&(S.payloads="")});var l=h.outerOrder||R,g=h.innerOrder||t,c=[];return l.forEach(function(S){I[S].forEach(function(D){D.name in _&&_[D.name]!=null?c.push(p(S,D,_)):D.push in _&&_[D.push]!=null&&_[D.push].forEach(function(E){c.push(p(S,D,E))})})}),_.media.forEach(function(S){c.push(p("m",I.m[0],S)),g.forEach(function(D){I[D].forEach(function(E){E.name in S&&S[E.name]!=null?c.push(p(D,E,S)):E.push in S&&S[E.push]!=null&&S[E.push].forEach(function(N){c.push(p(D,E,N))})})})}),c.join(`\r
5
+ `)+`\r
6
+ `},Yt}var wn;function el(){if(wn)return ge;wn=1;var I=Ql(),y=Zl(),i=Ss();return ge.grammar=i,ge.write=y,ge.parse=I.parse,ge.parseParams=I.parseParams,ge.parseFmtpConfig=I.parseFmtpConfig,ge.parsePayloads=I.parsePayloads,ge.parseRemoteCandidates=I.parseRemoteCandidates,ge.parseImageAttributes=I.parseImageAttributes,ge.parseSimulcastStreamList=I.parseSimulcastStreamList,ge}var Jt,yn;function Se(){if(yn)return Jt;yn=1;const I=el(),y=ce(),i=oe(),p=fe(),R=Es(),t=Ce(),_=new y("SIPMessage");class h{constructor(E,N,$,C,w,F){if(!E||!N||!$)return null;C=C||{},this.ua=$,this.headers={},this.method=E,this.ruri=N,this.body=F,this.extraHeaders=p.cloneArray(w),this.ua.configuration.extra_headers&&(this.extraHeaders=this.extraHeaders.concat(this.ua.configuration.extra_headers)),C.route_set?this.setHeader("route",C.route_set):$.configuration.use_preloaded_route&&this.setHeader("route",`<${$.transport.sip_uri};lr>`),this.setHeader("via",""),this.setHeader("max-forwards",i.MAX_FORWARDS);const H=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 R(H,f,o),this.setHeader("to",this.to.toString());const T=C.from_uri||$.configuration.uri,d={tag:C.from_tag||p.newTag()};let A;typeof C.from_display_name<"u"?A=C.from_display_name:$.configuration.display_name?A=$.configuration.display_name:A=null,this.from=new R(T,A,d),this.setHeader("from",this.from.toString());const O=C.call_id||$.configuration.jssip_id+p.createRandomToken(15);this.call_id=O,this.setHeader("call-id",O);const v=C.cseq||Math.floor(Math.random()*1e4);this.cseq=v,this.setHeader("cseq",`${v} ${E}`)}setHeader(E,N){const $=new RegExp(`^\\s*${E}\\s*:`,"i");for(let C=0;C<this.extraHeaders.length;C++)$.test(this.extraHeaders[C])&&this.extraHeaders.splice(C,1);this.headers[p.headerize(E)]=Array.isArray(N)?N:[N]}getHeader(E){const N=this.headers[p.headerize(E)];if(N){if(N[0])return N[0]}else{const $=new RegExp(`^\\s*${E}\\s*:`,"i");for(const C of this.extraHeaders)if($.test(C))return C.substring(C.indexOf(":")+1).trim()}}getHeaders(E){const N=this.headers[p.headerize(E)],$=[];if(N){for(const C of N)$.push(C);return $}else{const C=new RegExp(`^\\s*${E}\\s*:`,"i");for(const w of this.extraHeaders)C.test(w)&&$.push(w.substring(w.indexOf(":")+1).trim());return $}}hasHeader(E){if(this.headers[p.headerize(E)])return!0;{const N=new RegExp(`^\\s*${E}\\s*:`,"i");for(const $ of this.extraHeaders)if(N.test($))return!0}return!1}parseSDP(E){return!E&&this.sdp?this.sdp:(this.sdp=I.parse(this.body||""),this.sdp)}toString(){let E=`${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 w of this.headers[C])E+=`${C}: ${w}\r
8
+ `;for(const C of this.extraHeaders)E+=`${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 $=this.ua.configuration.user_agent||i.USER_AGENT;if(E+=`Allow: ${i.ALLOWED_METHODS}\r
10
+ `,E+=`Supported: ${N}\r
11
+ `,E+=`User-Agent: ${$}\r
12
+ `,this.body){const C=p.str_utf8_length(this.body);E+=`Content-Length: ${C}\r
13
+ \r
14
+ `,E+=this.body}else E+=`Content-Length: 0\r
15
+ \r
16
+ `;return E}clone(){const E=new h(this.method,this.ruri,this.ua);return Object.keys(this.headers).forEach(function(N){E.headers[N]=this.headers[N].slice()},this),E.body=this.body,E.extraHeaders=p.cloneArray(this.extraHeaders),E.to=this.to,E.from=this.from,E.call_id=this.call_id,E.cseq=this.cseq,E}}class l extends h{constructor(E,N,$,C,w){super(i.INVITE,E,N,$,C,w),this.transaction=null}cancel(E){this.transaction.cancel(E)}clone(){const E=new l(this.ruri,this.ua);return Object.keys(this.headers).forEach(function(N){E.headers[N]=this.headers[N].slice()},this),E.body=this.body,E.extraHeaders=p.cloneArray(this.extraHeaders),E.to=this.to,E.from=this.from,E.call_id=this.call_id,E.cseq=this.cseq,E.transaction=this.transaction,E}}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(E,N){const $={raw:N};E=p.headerize(E),this.headers[E]?this.headers[E].push($):this.headers[E]=[$]}getHeader(E){const N=this.headers[p.headerize(E)];if(N){if(N[0])return N[0].raw}else return}getHeaders(E){const N=this.headers[p.headerize(E)],$=[];if(!N)return[];for(const C of N)$.push(C.raw);return $}hasHeader(E){return!!this.headers[p.headerize(E)]}parseHeader(E,N=0){if(E=p.headerize(E),this.headers[E]){if(N>=this.headers[E].length){_.debug(`not so many "${E}" headers present`);return}}else{_.debug(`header "${E}" not present`);return}const $=this.headers[E][N],C=$.raw;if($.parsed)return $.parsed;const w=t.parse(C,E.replace(/-/g,"_"));if(w===-1){this.headers[E].splice(N,1),_.debug(`error parsing "${E}" header field with value "${C}"`);return}else return $.parsed=w,w}s(E,N){return this.parseHeader(E,N)}setHeader(E,N){const $={raw:N};this.headers[p.headerize(E)]=[$]}parseSDP(E){return!E&&this.sdp?this.sdp:(this.sdp=I.parse(this.body||""),this.sdp)}toString(){return this.data}}class c extends g{constructor(E){super(),this.ua=E,this.headers={},this.ruri=null,this.transport=null,this.server_transaction=null}reply(E,N,$,C,w,F){const H=[];let o=this.getHeader("To");if(E=E||null,N=N||null,!E||E<100||E>699)throw new TypeError(`Invalid status_code: ${E}`);if(N&&typeof N!="string"&&!(N instanceof String))throw new TypeError(`Invalid reason_phrase: ${N}`);N=N||i.REASON_PHRASE[E]||"",$=p.cloneArray($),this.ua.configuration.extra_headers&&($=$.concat(this.ua.configuration.extra_headers));let f=`SIP/2.0 ${E} ${N}\r
17
+ `;if(this.method===i.INVITE&&E>100&&E<=200){const d=this.getHeaders("record-route");for(const A of d)f+=`Record-Route: ${A}\r
18
+ `}const T=this.getHeaders("via");for(const d of T)f+=`Via: ${d}\r
19
+ `;!this.to_tag&&E>100?o+=`;tag=${p.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 d of $)f+=`${d.trim()}\r
24
+ `;switch(this.method){case i.INVITE:this.ua.configuration.session_timers&&H.push("timer"),(this.ua.contact.pub_gruu||this.ua.contact.temp_gruu)&&H.push("gruu"),H.push("ice","replaces");break;case i.UPDATE:this.ua.configuration.session_timers&&H.push("timer"),C&&H.push("ice"),H.push("replaces")}if(H.push("outbound"),this.method===i.OPTIONS?(f+=`Allow: ${i.ALLOWED_METHODS}\r
25
+ `,f+=`Accept: ${i.ACCEPTED_BODY_TYPES}\r
26
+ `):E===405?f+=`Allow: ${i.ALLOWED_METHODS}\r
27
+ `:E===415&&(f+=`Accept: ${i.ACCEPTED_BODY_TYPES}\r
28
+ `),f+=`Supported: ${H}\r
29
+ `,C){const d=p.str_utf8_length(C);f+=`Content-Type: application/sdp\r
30
+ `,f+=`Content-Length: ${d}\r
31
+ \r
32
+ `,f+=C}else f+=`Content-Length: 0\r
33
+ \r
34
+ `;this.server_transaction.receiveResponse(E,f,w,F)}reply_sl(E=null,N=null){const $=this.getHeaders("via");if(!E||E<100||E>699)throw new TypeError(`Invalid status_code: ${E}`);if(N&&typeof N!="string"&&!(N instanceof String))throw new TypeError(`Invalid reason_phrase: ${N}`);N=N||i.REASON_PHRASE[E]||"";let C=`SIP/2.0 ${E} ${N}\r
35
+ `;for(const F of $)C+=`Via: ${F}\r
36
+ `;let w=this.getHeader("To");if(!this.to_tag&&E>100?w+=`;tag=${p.newTag()}`:this.to_tag&&!this.s("to").hasParam("tag")&&(w+=`;tag=${this.to_tag}`),C+=`To: ${w}\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 F of this.ua.configuration.extra_headers)C+=`${F.trim()}\r
41
+ `;C+=`Content-Length: 0\r
42
+ \r
43
+ `,this.transport.send(C)}}class S extends g{constructor(){super(),this.headers={},this.status_code=null,this.reason_phrase=null}}return Jt={OutgoingRequest:h,InitialOutgoingInviteRequest:l,IncomingRequest:c,IncomingResponse:S},Jt}var Xt,In;function ei(){if(In)return Xt;In=1;const I=ce(),y=fe(),i=new I("DigestAuthentication");return Xt=class{constructor(R){this._credentials=R,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(R){switch(R){case"realm":return this._realm;case"ha1":return this._ha1;default:i.warn('get() | cannot get "%s" parameter',R);return}}authenticate({method:R,ruri:t,body:_},h,l=null){if(this._algorithm=h.algorithm,this._realm=h.realm,this._nonce=h.nonce,this._opaque=h.opaque,this._stale=h.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(h.qop)if(h.qop.indexOf("auth-int")>-1)this._qop="auth-int";else if(h.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=R,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,S;return this._qop==="auth"?(c=`${this._method}:${this._uri}`,S=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:${S}`)):this._qop==="auth-int"?(c=`${this._method}:${this._uri}:${y.calculateMD5(_||"")}`,S=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:${S}`)):this._qop===null&&(c=`${this._method}:${this._uri}`,S=y.calculateMD5(c),i.debug('authenticate() | using qop=null [a2:"%s"]',c),this._response=y.calculateMD5(`${this._ha1}:${this._nonce}:${S}`)),i.debug("authenticate() | response generated"),!0}toString(){const R=[];if(!this._response)throw new Error("response field does not exist, cannot generate Authorization header");return R.push(`algorithm=${this._algorithm}`),R.push(`username="${this._credentials.username}"`),R.push(`realm="${this._realm}"`),R.push(`nonce="${this._nonce}"`),R.push(`uri="${this._uri}"`),R.push(`response="${this._response}"`),this._opaque&&R.push(`opaque="${this._opaque}"`),this._qop&&(R.push(`qop=${this._qop}`),R.push(`cnonce="${this._cnonce}"`),R.push(`nc=${this._ncHex}`)),`Digest ${R.join(", ")}`}},Xt}var Qt,xn;function tl(){if(xn)return Qt;xn=1;const I=500,y=4e3,i=5e3;return Qt={T1:I,T2:y,T4:i,TIMER_B:64*I,TIMER_D:0*I,TIMER_F:64*I,TIMER_H:64*I,TIMER_I:0*I,TIMER_J:0*I,TIMER_K:0*i,TIMER_L:64*I,TIMER_M:64*I,PROVISIONAL_RESPONSE_INTERVAL:6e4},Qt}var Zt,Nn;function Be(){if(Nn)return Zt;Nn=1;const I=Ie().EventEmitter,y=ce(),i=oe(),p=Se(),R=tl(),t=new y("NonInviteClientTransaction"),_=new y("InviteClientTransaction"),h=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 S extends I{constructor(F,H,o,f){super(),this.type=c.NON_INVITE_CLIENT,this.id=`z9hG4bK${Math.floor(Math.random()*1e7)}`,this.ua=F,this.transport=H,this.request=o,this.eventHandlers=f;let T=`SIP/2.0/${H.via_transport}`;T+=` ${F.configuration.via_host};branch=${this.id}`,this.request.setHeader("via",T),this.ua.newTransaction(this)}get C(){return c}stateChanged(F){this.state=F,this.emit("stateChanged")}send(){this.stateChanged(c.STATUS_TRYING),this.F=setTimeout(()=>{this.timer_F()},R.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(F){const H=F.status_code;if(H<200)switch(this.state){case c.STATUS_TRYING:case c.STATUS_PROCEEDING:this.stateChanged(c.STATUS_PROCEEDING),this.eventHandlers.onReceiveResponse(F);break}else switch(this.state){case c.STATUS_TRYING:case c.STATUS_PROCEEDING:this.stateChanged(c.STATUS_COMPLETED),clearTimeout(this.F),H===408?this.eventHandlers.onRequestTimeout():this.eventHandlers.onReceiveResponse(F),this.K=setTimeout(()=>{this.timer_K()},R.TIMER_K);break;case c.STATUS_COMPLETED:break}}}class D extends I{constructor(F,H,o,f){super(),this.type=c.INVITE_CLIENT,this.id=`z9hG4bK${Math.floor(Math.random()*1e7)}`,this.ua=F,this.transport=H,this.request=o,this.eventHandlers=f,o.transaction=this;let T=`SIP/2.0/${H.via_transport}`;T+=` ${F.configuration.via_host};branch=${this.id}`,this.request.setHeader("via",T),this.ua.newTransaction(this)}get C(){return c}stateChanged(F){this.state=F,this.emit("stateChanged")}send(){this.stateChanged(c.STATUS_CALLING),this.B=setTimeout(()=>{this.timer_B()},R.TIMER_B),this.transport.send(this.request)||this.onTransportError()}onTransportError(){clearTimeout(this.B),clearTimeout(this.D),clearTimeout(this.M),this.state!==c.STATUS_ACCEPTED&&(_.debug(`transport error occurred, deleting transaction ${this.id}`),this.eventHandlers.onTransportError()),this.stateChanged(c.STATUS_TERMINATED),this.ua.destroyTransaction(this)}timer_M(){_.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(){_.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(){_.debug(`Timer D expired for transaction ${this.id}`),clearTimeout(this.B),this.stateChanged(c.STATUS_TERMINATED),this.ua.destroyTransaction(this)}sendACK(F){const H=new p.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});H.setHeader("from",this.request.getHeader("from")),H.setHeader("via",this.request.getHeader("via")),H.setHeader("to",F.getHeader("to")),this.D=setTimeout(()=>{this.timer_D()},R.TIMER_D),this.transport.send(H)}cancel(F){if(this.state!==c.STATUS_PROCEEDING)return;const H=new p.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});H.setHeader("from",this.request.getHeader("from")),H.setHeader("via",this.request.getHeader("via")),H.setHeader("to",this.request.getHeader("to")),F&&H.setHeader("reason",F),this.transport.send(H)}receiveResponse(F){const H=F.status_code;if(H>=100&&H<=199)switch(this.state){case c.STATUS_CALLING:this.stateChanged(c.STATUS_PROCEEDING),this.eventHandlers.onReceiveResponse(F);break;case c.STATUS_PROCEEDING:this.eventHandlers.onReceiveResponse(F);break}else if(H>=200&&H<=299)switch(this.state){case c.STATUS_CALLING:case c.STATUS_PROCEEDING:this.stateChanged(c.STATUS_ACCEPTED),this.M=setTimeout(()=>{this.timer_M()},R.TIMER_M),this.eventHandlers.onReceiveResponse(F);break;case c.STATUS_ACCEPTED:this.eventHandlers.onReceiveResponse(F);break}else if(H>=300&&H<=699)switch(this.state){case c.STATUS_CALLING:case c.STATUS_PROCEEDING:this.stateChanged(c.STATUS_COMPLETED),this.sendACK(F),this.eventHandlers.onReceiveResponse(F);break;case c.STATUS_COMPLETED:this.sendACK(F);break}}}class E extends I{constructor(F,H,o,f){super(),this.id=`z9hG4bK${Math.floor(Math.random()*1e7)}`,this.transport=H,this.request=o,this.eventHandlers=f;let T=`SIP/2.0/${H.via_transport}`;T+=` ${F.configuration.via_host};branch=${this.id}`,this.request.setHeader("via",T)}get C(){return c}send(){this.transport.send(this.request)||this.onTransportError()}onTransportError(){h.debug(`transport error occurred for transaction ${this.id}`),this.eventHandlers.onTransportError()}}class N extends I{constructor(F,H,o){super(),this.type=c.NON_INVITE_SERVER,this.id=o.via_branch,this.ua=F,this.transport=H,this.request=o,this.last_response="",o.server_transaction=this,this.state=c.STATUS_TRYING,F.newTransaction(this)}get C(){return c}stateChanged(F){this.state=F,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(F,H,o,f){if(F===100)switch(this.state){case c.STATUS_TRYING:this.stateChanged(c.STATUS_PROCEEDING),this.transport.send(H)||this.onTransportError();break;case c.STATUS_PROCEEDING:this.last_response=H,this.transport.send(H)?o&&o():(this.onTransportError(),f&&f());break}else if(F>=200&&F<=699)switch(this.state){case c.STATUS_TRYING:case c.STATUS_PROCEEDING:this.stateChanged(c.STATUS_COMPLETED),this.last_response=H,this.J=setTimeout(()=>{this.timer_J()},R.TIMER_J),this.transport.send(H)?o&&o():(this.onTransportError(),f&&f());break;case c.STATUS_COMPLETED:break}}}class $ extends I{constructor(F,H,o){super(),this.type=c.INVITE_SERVER,this.id=o.via_branch,this.ua=F,this.transport=H,this.request=o,this.last_response="",o.server_transaction=this,this.state=c.STATUS_PROCEEDING,F.newTransaction(this),this.resendProvisionalTimer=null,o.reply(100)}get C(){return c}stateChanged(F){this.state=F,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(F,H,o,f){if(F>=100&&F<=199&&this.state===c.STATUS_PROCEEDING&&(this.transport.send(H)||this.onTransportError(),this.last_response=H),F>100&&F<=199&&this.state===c.STATUS_PROCEEDING)this.resendProvisionalTimer===null&&(this.resendProvisionalTimer=setInterval(()=>{this.resend_provisional()},R.PROVISIONAL_RESPONSE_INTERVAL));else if(F>=200&&F<=299)switch(this.state){case c.STATUS_PROCEEDING:this.stateChanged(c.STATUS_ACCEPTED),this.last_response=H,this.L=setTimeout(()=>{this.timer_L()},R.TIMER_L),this.resendProvisionalTimer!==null&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null);case c.STATUS_ACCEPTED:this.transport.send(H)?o&&o():(this.onTransportError(),f&&f());break}else F>=300&&F<=699&&this.state===c.STATUS_PROCEEDING&&(this.resendProvisionalTimer!==null&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null),this.transport.send(H)?(this.stateChanged(c.STATUS_COMPLETED),this.H=setTimeout(()=>{this.timer_H()},R.TIMER_H),o&&o()):(this.onTransportError(),f&&f()))}}function C({_transactions:w},F){let H;switch(F.method){case i.INVITE:if(H=w.ist[F.via_branch],H){switch(H.state){case c.STATUS_PROCEEDING:H.transport.send(H.last_response);break;case c.STATUS_ACCEPTED:break}return!0}break;case i.ACK:if(H=w.ist[F.via_branch],H){if(H.state===c.STATUS_ACCEPTED)return!1;if(H.state===c.STATUS_COMPLETED)return H.state=c.STATUS_CONFIRMED,H.I=setTimeout(()=>{H.timer_I()},R.TIMER_I),!0}else return!1;break;case i.CANCEL:return H=w.ist[F.via_branch],H?(F.reply_sl(200),H.state!==c.STATUS_PROCEEDING):(F.reply_sl(481),!0);default:if(H=w.nist[F.via_branch],H){switch(H.state){case c.STATUS_TRYING:break;case c.STATUS_PROCEEDING:case c.STATUS_COMPLETED:H.transport.send(H.last_response);break}return!0}break}}return Zt={C:c,NonInviteClientTransaction:S,InviteClientTransaction:D,AckClientTransaction:E,NonInviteServerTransaction:N,InviteServerTransaction:$,checkTransaction:C},Zt}var es,On;function We(){if(On)return es;On=1;const I=ce(),y=oe(),i=ei(),p=Be(),R=new I("RequestSender"),t={onRequestTimeout:()=>{},onTransportError:()=>{},onReceiveResponse:()=>{},onAuthenticated:()=>{}};return es=class{constructor(h,l,g){this._ua=h,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]));h.status===h.C.STATUS_USER_CLOSED&&(this._method!==y.BYE||this._method!==y.ACK)&&this._eventHandlers.onTransportError()}send(){const h={onRequestTimeout:()=>{this._eventHandlers.onRequestTimeout()},onTransportError:()=>{this._eventHandlers.onTransportError()},onReceiveResponse:l=>{this._receiveResponse(l)}};switch(this._method){case"INVITE":this.clientTransaction=new p.InviteClientTransaction(this._ua,this._ua.transport,this._request,h);break;case"ACK":this.clientTransaction=new p.AckClientTransaction(this._ua,this._ua.transport,this._request,h);break;default:this.clientTransaction=new p.NonInviteClientTransaction(this._ua,this._ua.transport,this._request,h)}this._ua._configuration.authorization_jwt&&this._request.setHeader("Authorization",this._ua._configuration.authorization_jwt),this.clientTransaction.send()}_receiveResponse(h){let l,g;const c=h.status_code;if((c===401||c===407)&&(this._ua.configuration.password!==null||this._ua.configuration.ha1!==null)){if(h.status_code===401?(l=h.parseHeader("www-authenticate"),g="authorization"):(l=h.parseHeader("proxy-authenticate"),g="proxy-authorization"),!l){R.debug(`${h.status_code} with wrong or missing challenge, cannot authenticate`),this._eventHandlers.onReceiveResponse(h);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(h);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(h)}else this._eventHandlers.onReceiveResponse(h)}},es}var ts,Dn;function ti(){if(Dn)return ts;Dn=1;const I=ce(),y=fe(),i=oe(),p=Se(),R=We(),t=new I("Registrator"),_=10;return ts=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 S=new p.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),D=new R(this._ua,S,{onRequestTimeout:()=>{this._registrationFailure(null,i.causes.REQUEST_TIMEOUT)},onTransportError:()=>{this._registrationFailure(null,i.causes.CONNECTION_ERROR)},onAuthenticated:()=>{this._cseq+=1},onReceiveResponse:E=>{if(E.cseq===this._cseq)switch(this._registrationTimer!==null&&(clearTimeout(this._registrationTimer),this._registrationTimer=null),!0){case/^1[0-9]{2}$/.test(E.status_code):break;case/^2[0-9]{2}$/.test(E.status_code):{if(this._registering=!1,!E.hasHeader("Contact")){t.debug("no Contact header in response to REGISTER, response ignored");break}const N=E.headers.Contact.reduce((F,H)=>F.concat(H.parsed),[]);let $=N.find(F=>this._sipInstance===F.getParam("+sip.instance")&&this._reg_id===parseInt(F.getParam("reg-id")));if($||($=N.find(F=>F.uri.user===this._ua.contact.uri.user)),!$){t.debug("no Contact header pointing to us, response ignored");break}let C=$.getParam("expires");!C&&E.hasHeader("expires")&&(C=E.getHeader("expires")),C||(C=this._expires),C=Number(C),C<_&&(C=_);const w=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")},w),$.hasParam("temp-gruu")&&(this._ua.contact.temp_gruu=$.getParam("temp-gruu").replace(/"/g,"")),$.hasParam("pub-gruu")&&(this._ua.contact.pub_gruu=$.getParam("pub-gruu").replace(/"/g,"")),this._registered||(this._registered=!0,this._ua.registered({response:E}));break}case/^423$/.test(E.status_code):{E.hasHeader("min-expires")?(this._expires=Number(E.getHeader("min-expires")),this._expires<_&&(this._expires=_),this._registering=!1,this.register()):(t.debug("423 response received for REGISTER without Min-Expires"),this._registrationFailure(E,i.causes.SIP_FAILURE_CODE));break}default:{const N=y.sipErrorCause(E.status_code);this._registrationFailure(E,N)}}}});this._registering=!0,D.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 p.OutgoingRequest(i.REGISTER,this._registrar,this._ua,{to_uri:this._to_uri,call_id:this._call_id,cseq:this._cseq+=1},g);new R(this._ua,c,{onRequestTimeout:()=>{this._unregistered(null,i.causes.REQUEST_TIMEOUT)},onTransportError:()=>{this._unregistered(null,i.causes.CONNECTION_ERROR)},onAuthenticated:()=>{this._cseq+=1},onReceiveResponse:D=>{switch(!0){case/^1[0-9]{2}$/.test(D.status_code):break;case/^2[0-9]{2}$/.test(D.status_code):this._unregistered(D);break;default:{const E=y.sipErrorCause(D.status_code);this._unregistered(D,E)}}}}).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})}},ts}var ss,Un;function si(){if(Un)return ss;Un=1;const I=oe(),y=Be(),i=We(),p={onRequestTimeout:()=>{},onTransportError:()=>{},onSuccessResponse:()=>{},onErrorResponse:()=>{},onAuthenticated:()=>{},onDialogError:()=>{}};return ss=class{constructor(t,_,h){this._dialog=t,this._ua=t._ua,this._request=_,this._eventHandlers=h,this._reattempt=!1,this._reattemptTimer=null;for(const l in p)Object.prototype.hasOwnProperty.call(p,l)&&(this._eventHandlers[l]||(this._eventHandlers[l]=p[l]))}get request(){return this._request}send(){const t=new i(this._ua,this._request,{onRequestTimeout:()=>{this._eventHandlers.onRequestTimeout()},onTransportError:()=>{this._eventHandlers.onTransportError()},onAuthenticated:_=>{this._eventHandlers.onAuthenticated(_)},onReceiveResponse:_=>{this._receiveResponse(_)}});if(t.send(),(this._request.method===I.INVITE||this._request.method===I.UPDATE&&this._request.body)&&t.clientTransaction.state!==y.C.STATUS_TERMINATED){this._dialog.uac_pending_reply=!0;const _=()=>{(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",_),this._dialog.uac_pending_reply=!1)};t.clientTransaction.on("stateChanged",_)}}_receiveResponse(t){t.status_code===408||t.status_code===481?this._eventHandlers.onDialogError(t):t.method===I.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)}},ss}var rs,Pn;function ri(){if(Pn)return rs;Pn=1;const I=ce(),y=Se(),i=oe(),p=Be(),R=si(),t=fe(),_=new I("Dialog"),h={STATUS_EARLY:1,STATUS_CONFIRMED:2,STATUS_TERMINATED:3};return rs=class{static get C(){return h}constructor(g,c,S,D=h.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&&(D=c.status_code<200?h.STATUS_EARLY:h.STATUS_CONFIRMED);const E=c.parseHeader("contact");S==="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=D,this._remote_seqnum=c.cseq,this._local_uri=c.parseHeader("to").uri,this._remote_uri=c.parseHeader("from").uri,this._remote_target=E.uri,this._route_set=c.getHeaders("record-route"),this.incoming_ack_seqnum=c.cseq,this.outgoing_ack_seqnum=null):S==="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=D,this._local_seqnum=c.cseq,this._local_uri=c.parseHeader("from").uri,this._remote_uri=c.parseHeader("to").uri,this._remote_target=E.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),_.debug(`new ${S} dialog created with status ${this._state===h.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===h.STATUS_TERMINATED}update(g,c){this._state=h.STATUS_CONFIRMED,_.debug(`dialog ${this._id.toString()} changed to CONFIRMED state`),c==="UAC"&&(this._route_set=g.getHeaders("record-route").reverse())}terminate(){_.debug(`dialog ${this._id.toString()} deleted`),this._ua.destroyDialog(this),this._state=h.STATUS_TERMINATED}sendRequest(g,c={}){const S=t.cloneArray(c.extraHeaders),D=t.cloneObject(c.eventHandlers),E=c.body||null,N=this._createRequest(g,S,E);return D.onAuthenticated=()=>{this._local_seqnum+=1,N.method===i.INVITE&&(this._outgoing_ack_seqnum=this._local_seqnum)},new R(this,N,D).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,S){c=t.cloneArray(c),this._local_seqnum||(this._local_seqnum=Math.floor(Math.random()*1e4));const D=g===i.CANCEL||g===i.ACK?this.outgoing_ack_seqnum:this._local_seqnum+=1;return g===i.INVITE&&(this.outgoing_ack_seqnum=D),new y.OutgoingRequest(g,this._remote_target,this._ua,{cseq:D,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,S)}_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===p.C.STATUS_ACCEPTED||g.server_transaction.state===p.C.STATUS_COMPLETED||g.server_transaction.state===p.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===p.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===p.C.STATUS_COMPLETED&&(this._remote_target=g.parseHeader("contact").uri)});return!0}},rs}var ft={exports:{}},Mn;function ni(){if(Mn)return ft.exports;Mn=1;const I=Ie().EventEmitter,y=ce(),i=oe(),p=we(),R=fe(),t=new y("RTCSession:DTMF"),_={MIN_DURATION:70,MAX_DURATION:6e3,DEFAULT_DURATION:100,MIN_INTER_TONE_GAP:50,DEFAULT_INTER_TONE_GAP:500};return ft.exports=class extends I{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 p.InvalidStateError(this._session.status);const c=R.cloneArray(g.extraHeaders);if(this.eventHandlers=R.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 S=`Signal=${this._tone}\r
44
+ `;S+=`Duration=${this._duration}`,this._session.newDTMF({originator:"local",dtmf:this,request:this._request}),this._session.sendRequest(i.INFO,{extraHeaders:c,eventHandlers:{onSuccessResponse:D=>{this.emit("succeeded",{originator:"remote",response:D})},onErrorResponse:D=>{this.eventHandlers.onFailed&&this.eventHandlers.onFailed(),this.emit("failed",{originator:"remote",response:D})},onRequestTimeout:()=>{this._session.onRequestTimeout()},onTransportError:()=>{this._session.onTransportError()},onDialogError:()=>{this._session.onDialogError()}},body:S})}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 S=l.body.split(`
45
+ `);S.length>=1&&g.test(S[0])&&(this._tone=S[0].replace(g,"$2")),S.length>=2&&c.test(S[1])&&(this._duration=parseInt(S[1].replace(c,"$2"),10))}this._duration||(this._duration=_.DEFAULT_DURATION),this._tone?this._session.newDTMF({originator:"remote",dtmf:this,request:l}):t.debug("invalid INFO DTMF received, discarded")}},ft.exports.C=_,ft.exports}var ns,Ln;function li(){if(Ln)return ns;Ln=1;const I=Ie().EventEmitter,y=oe(),i=we(),p=fe();return ns=class extends I{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={}){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=_;const l=p.cloneArray(h.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:_})}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})}},ns}var ls,Fn;function ii(){if(Fn)return ls;Fn=1;const I=ce(),y=oe(),i=new I("RTCSession:ReferNotifier"),p={event_type:"refer",body_type:"message/sipfrag;version=2.0",expires:300};return ls=class{constructor(t,_,h){this._session=t,this._id=_,this._expires=h||p.expires,this._active=!0,this.notify(100)}notify(t,_){if(i.debug("notify()"),this._active===!1)return;_=_||y.REASON_PHRASE[t]||"";let h;t>=200?h="terminated;reason=noresource":h=`active;expires=${this._expires}`,this._session.sendRequest(y.NOTIFY,{extraHeaders:[`Event: ${p.event_type};id=${this._id}`,`Subscription-State: ${h}`,`Content-Type: ${p.body_type}`],body:`SIP/2.0 ${t} ${_}`,eventHandlers:{onErrorResponse(){this._active=!1}}})}},ls}var is,Hn;function ai(){if(Hn)return is;Hn=1;const I=Ie().EventEmitter,y=ce(),i=oe(),p=Ce(),R=fe(),t=new y("RTCSession:ReferSubscriber");return is=class extends I{constructor(h){super(),this._id=null,this._session=h}get id(){return this._id}sendRefer(h,l={}){t.debug("sendRefer()");const g=R.cloneArray(l.extraHeaders),c=R.cloneObject(l.eventHandlers);for(const N in c)Object.prototype.hasOwnProperty.call(c,N)&&this.on(N,c[N]);let S=null;l.replaces&&(S=l.replaces._request.call_id,S+=`;to-tag=${l.replaces._to_tag}`,S+=`;from-tag=${l.replaces._from_tag}`,S=encodeURIComponent(S));const D=`Refer-To: <${h}${S?`?Replaces=${S}`:""}>`;if(g.push(D),!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 E=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=E.cseq}receiveNotify(h){if(t.debug("receiveNotify()"),!h.body)return;const l=p.parse(h.body.trim().split(`\r
46
+ `,1)[0],"Status_Line");if(l===-1){t.debug(`receiveNotify() | error parsing NOTIFY body: "${h.body}"`);return}switch(!0){case/^100$/.test(l.status_code):this.emit("trying",{request:h,status_line:l});break;case/^1[0-9]{2}$/.test(l.status_code):this.emit("progress",{request:h,status_line:l});break;case/^2[0-9]{2}$/.test(l.status_code):this.emit("accepted",{request:h,status_line:l});break;default:this.emit("failed",{request:h,status_line:l});break}}_requestSucceeded(h){t.debug("REFER succeeded"),t.debug('emit "requestSucceeded"'),this.emit("requestSucceeded",{response:h})}_requestFailed(h,l){t.debug("REFER failed"),t.debug('emit "requestFailed"'),this.emit("requestFailed",{response:h||null,cause:l})}},is}var as,$n;function sl(){if($n)return as;$n=1;const I=Ie().EventEmitter,y=el(),i=ce(),p=oe(),R=we(),t=Be(),_=fe(),h=tl(),l=Se(),g=ri(),c=We(),S=ni(),D=li(),E=ii(),N=ai(),$=ye(),C=new i("RTCSession"),w={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},F=["audio","video"];return as=class Cs extends I{static get C(){return w}constructor(o){C.debug("new"),super(),this._id=null,this._ua=o,this._status=w.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:p.SESSION_EXPIRES,currentExpires:null,running:!1,refresher:!1,timer:null},this._referSubscribers={},this._data={}}get C(){return w}get causes(){return p.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 w.STATUS_NULL:case w.STATUS_INVITE_SENT:case w.STATUS_1XX_RECEIVED:case w.STATUS_INVITE_RECEIVED:case w.STATUS_WAITING_FOR_ANSWER:return!0;default:return!1}}isEstablished(){switch(this._status){case w.STATUS_ANSWERED:case w.STATUS_WAITING_FOR_ACK:case w.STATUS_CONFIRMED:return!0;default:return!1}}isEnded(){switch(this._status){case w.STATUS_CANCELED:case w.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 d=o,A=_.cloneObject(f.eventHandlers),O=_.cloneArray(f.extraHeaders),v=_.cloneObject(f.mediaConstraints,{audio:!0,video:!0}),b=f.mediaStream||null,U=_.cloneObject(f.pcConfig,{iceServers:[]}),M=f.rtcConstraints||null,Z=f.rtcOfferConstraints||null;if(this._rtcOfferConstraints=Z,this._rtcAnswerConstraints=f.rtcAnswerConstraints||null,this._data=f.data||this._data,o===void 0)throw new TypeError("Not enough arguments");if(this._status!==w.STATUS_NULL)throw new R.InvalidStateError(this._status);if(!window.RTCPeerConnection)throw new R.NotSupportedError("WebRTC not supported");if(o=this._ua.normalizeTarget(o),!o)throw new TypeError(`Invalid target: ${d}`);this._sessionTimers.enabled&&_.isDecimal(f.sessionTimersExpires)&&(f.sessionTimersExpires>=p.MIN_SESSION_EXPIRES?this._sessionTimers.defaultExpires=f.sessionTimersExpires:this._sessionTimers.defaultExpires=p.SESSION_EXPIRES);for(const de in A)Object.prototype.hasOwnProperty.call(A,de)&&this.on(de,A[de]);this._from_tag=_.newTag();const B=f.anonymous||!1,ue={from_tag:this._from_tag};this._contact=this._ua.contact.toString({anonymous:B,outbound:!0}),B?(ue.from_display_name="Anonymous",ue.from_uri=new $("sip","anonymous","anonymous.invalid"),O.push(`P-Preferred-Identity: ${this._ua.configuration.uri.toString()}`),O.push("Privacy: id")):f.fromUserName&&(ue.from_uri=new $("sip",f.fromUserName,this._ua.configuration.uri.host),O.push(`P-Preferred-Identity: ${this._ua.configuration.uri.toString()}`)),f.fromDisplayName&&(ue.from_display_name=f.fromDisplayName),O.push(`Contact: ${this._contact}`),O.push("Content-Type: application/sdp"),this._sessionTimers.enabled&&O.push(`Session-Expires: ${this._sessionTimers.defaultExpires}${this._ua.configuration.session_timers_force_refresher?";refresher=uac":""}`),this._request=new l.InitialOutgoingInviteRequest(o,this._ua,ue,O),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,Z,b)}init_incoming(o,f){C.debug("init_incoming()");let T;const d=o.hasHeader("Content-Type")?o.getHeader("Content-Type").toLowerCase():void 0;if(o.body&&d!=="application/sdp"){o.reply(415);return}if(this._status=w.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=_.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=w.STATUS_WAITING_FOR_ANSWER,this._timers.userNoAnswerTimer=setTimeout(()=>{o.reply(408),this._failed("local",null,p.causes.NO_ANSWER)},this._ua.configuration.no_answer_timeout),T&&(this._timers.expiresTimer=setTimeout(()=>{this._status===w.STATUS_WAITING_FOR_ANSWER&&(o.reply(487),this._failed("system",null,p.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!==w.STATUS_TERMINATED&&(o.reply(180,null,[`Contact: ${this._contact}`]),this._progress("local",null))}answer(o={}){C.debug("answer()");const f=this._request,T=_.cloneArray(o.extraHeaders),d=_.cloneObject(o.mediaConstraints),A=o.mediaStream||null,O=_.cloneObject(o.pcConfig,{iceServers:[]}),v=o.rtcConstraints||null,b=o.rtcAnswerConstraints||null,U=_.cloneObject(o.rtcOfferConstraints);let M,Z=!1,B=!1,ue=!1,de=!1;if(this._rtcAnswerConstraints=b,this._rtcOfferConstraints=o.rtcOfferConstraints||null,this._data=o.data||this._data,this._direction!=="incoming")throw new R.NotSupportedError('"answer" not supported for outgoing RTCSession');if(this._status!==w.STATUS_WAITING_FOR_ANSWER)throw new R.InvalidStateError(this._status);if(this._sessionTimers.enabled&&_.isDecimal(o.sessionTimersExpires)&&(o.sessionTimersExpires>=p.MIN_SESSION_EXPIRES?this._sessionTimers.defaultExpires=o.sessionTimersExpires:this._sessionTimers.defaultExpires=p.SESSION_EXPIRES),this._status=w.STATUS_ANSWERED,!this._createDialog(f,"UAS")){f.reply(500,"Error creating dialog");return}clearTimeout(this._timers.userNoAnswerTimer),T.unshift(`Contact: ${this._contact}`);const he=f.parseSDP();Array.isArray(he.media)||(he.media=[he.media]);for(const J of he.media)J.type==="audio"&&(Z=!0,(!J.direction||J.direction==="sendrecv")&&(ue=!0)),J.type==="video"&&(B=!0,(!J.direction||J.direction==="sendrecv")&&(de=!0));if(A&&d.audio===!1){M=A.getAudioTracks();for(const J of M)A.removeTrack(J)}if(A&&d.video===!1){M=A.getVideoTracks();for(const J of M)A.removeTrack(J)}!A&&d.audio===void 0&&(d.audio=ue),!A&&d.video===void 0&&(d.video=de),!A&&!Z&&!U.offerToReceiveAudio&&(d.audio=!1),!A&&!B&&!U.offerToReceiveVideo&&(d.video=!1),this._createRTCConnection(O,v),Promise.resolve().then(()=>{if(A)return A;if(d.audio||d.video)return this._localMediaStreamLocallyGenerated=!0,navigator.mediaDevices.getUserMedia(d).catch(J=>{throw this._status===w.STATUS_TERMINATED?new Error("terminated"):(f.reply(480),this._failed("local",null,p.causes.USER_DENIED_MEDIA_ACCESS),C.warn('emit "getusermediafailed" [error:%o]',J),this.emit("getusermediafailed",J),new Error("getUserMedia() failed"))})}).then(J=>{if(this._status===w.STATUS_TERMINATED)throw new Error("terminated");this._localMediaStream=J,J&&J.getTracks().forEach(_e=>{this._connection.addTrack(_e,J)})}).then(()=>{if(this._late_sdp)return;const J={originator:"remote",type:"offer",sdp:f.body};C.debug('emit "sdp"'),this.emit("sdp",J);const _e=new RTCSessionDescription({type:"offer",sdp:J.sdp});return this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(_e)).catch(X=>{throw f.reply(488),this._failed("system",null,p.causes.WEBRTC_ERROR),C.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',X),this.emit("peerconnection:setremotedescriptionfailed",X),new Error("peerconnection.setRemoteDescription() failed")}),this._connectionPromiseQueue}).then(()=>{if(this._status===w.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",b).catch(()=>{throw f.reply(500),new Error("_createLocalDescription() failed")})}).then(J=>{if(this._status===w.STATUS_TERMINATED)throw new Error("terminated");this._handleSessionTimersInIncomingRequest(f,T),f.reply(200,null,T,J,()=>{this._status=w.STATUS_WAITING_FOR_ACK,this._setInvite2xxTimer(f,J),this._setACKTimer(),this._accepted("local")},()=>{this._failed("system",null,p.causes.CONNECTION_ERROR)})}).catch(J=>{this._status!==w.STATUS_TERMINATED&&(C.warn(`answer() failed: ${J.message}`),this._failed("system",J.message,p.causes.INTERNAL_ERROR))})}terminate(o={}){C.debug("terminate()");const f=o.cause||p.causes.BYE,T=_.cloneArray(o.extraHeaders),d=o.body;let A,O=o.status_code,v=o.reason_phrase;if(this._status===w.STATUS_TERMINATED)throw new R.InvalidStateError(this._status);switch(this._status){case w.STATUS_NULL:case w.STATUS_INVITE_SENT:case w.STATUS_1XX_RECEIVED:if(C.debug("canceling session"),O&&(O<200||O>=700))throw new TypeError(`Invalid status_code: ${O}`);O&&(v=v||p.REASON_PHRASE[O]||"",A=`SIP ;cause=${O} ;text="${v}"`),this._status===w.STATUS_NULL||this._status===w.STATUS_INVITE_SENT?(this._is_canceled=!0,this._cancel_reason=A):this._status===w.STATUS_1XX_RECEIVED&&this._request.cancel(A),this._status=w.STATUS_CANCELED,this._failed("local",null,p.causes.CANCELED);break;case w.STATUS_WAITING_FOR_ANSWER:case w.STATUS_ANSWERED:if(C.debug("rejecting session"),O=O||480,O<300||O>=700)throw new TypeError(`Invalid status_code: ${O}`);this._request.reply(O,v,T,d),this._failed("local",null,p.causes.REJECTED);break;case w.STATUS_WAITING_FOR_ACK:case w.STATUS_CONFIRMED:if(C.debug("terminating session"),v=o.reason_phrase||p.REASON_PHRASE[O]||"",O&&(O<200||O>=700))throw new TypeError(`Invalid status_code: ${O}`);if(O&&T.push(`Reason: SIP ;cause=${O}; text="${v}"`),this._status===w.STATUS_WAITING_FOR_ACK&&this._direction==="incoming"&&this._request.server_transaction.state!==t.C.STATUS_TERMINATED){const b=this._dialog;this.receiveRequest=({method:U})=>{U===p.ACK&&(this.sendRequest(p.BYE,{extraHeaders:T,body:d}),b.terminate())},this._request.server_transaction.on("stateChanged",()=>{this._request.server_transaction.state===t.C.STATUS_TERMINATED&&(this.sendRequest(p.BYE,{extraHeaders:T,body:d}),b.terminate())}),this._ended("local",null,f),this._dialog=b,this._ua.newDialog(b)}else this.sendRequest(p.BYE,{extraHeaders:T,body:d}),this._ended("local",null,f)}}sendDTMF(o,f={}){C.debug("sendDTMF() | tones: %s",o);let T=f.duration||null,d=f.interToneGap||null;const A=f.transportType||p.DTMF_TRANSPORT.INFO;if(o===void 0)throw new TypeError("Not enough arguments");if(this._status!==w.STATUS_CONFIRMED&&this._status!==w.STATUS_WAITING_FOR_ACK&&this._status!==w.STATUS_1XX_RECEIVED)throw new R.InvalidStateError(this._status);if(A!==p.DTMF_TRANSPORT.INFO&&A!==p.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&&!_.isDecimal(T))throw new TypeError(`Invalid tone duration: ${T}`);if(T?T<S.C.MIN_DURATION?(C.debug(`"duration" value is lower than the minimum allowed, setting it to ${S.C.MIN_DURATION} milliseconds`),T=S.C.MIN_DURATION):T>S.C.MAX_DURATION?(C.debug(`"duration" value is greater than the maximum allowed, setting it to ${S.C.MAX_DURATION} milliseconds`),T=S.C.MAX_DURATION):T=Math.abs(T):T=S.C.DEFAULT_DURATION,f.duration=T,d&&!_.isDecimal(d))throw new TypeError(`Invalid interToneGap: ${d}`);if(d?d<S.C.MIN_INTER_TONE_GAP?(C.debug(`"interToneGap" value is lower than the minimum allowed, setting it to ${S.C.MIN_INTER_TONE_GAP} milliseconds`),d=S.C.MIN_INTER_TONE_GAP):d=Math.abs(d):d=S.C.DEFAULT_INTER_TONE_GAP,A===p.DTMF_TRANSPORT.RFC2833){const v=this._getDTMFRTPSender();v&&(o=v.toneBuffer+o,v.insertDTMF(o,T,d));return}if(this._tones){this._tones+=o;return}this._tones=o,O.call(this);function O(){let v;if(this._status===w.STATUS_TERMINATED||!this._tones){this._tones=null;return}const b=this._tones[0];if(this._tones=this._tones.substring(1),b===",")v=2e3;else{const U=new S(this);f.eventHandlers={onFailed:()=>{this._tones=null}},U.send(b,f),v=T+d}setTimeout(O.bind(this),v)}}sendInfo(o,f,T={}){if(C.debug("sendInfo()"),this._status!==w.STATUS_CONFIRMED&&this._status!==w.STATUS_WAITING_FOR_ACK&&this._status!==w.STATUS_1XX_RECEIVED)throw new R.InvalidStateError(this._status);new D(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!==w.STATUS_WAITING_FOR_ACK&&this._status!==w.STATUS_CONFIRMED||this._localHold===!0||!this.isReadyToReOffer())return!1;this._localHold=!0,this._onhold("local");const T={succeeded:()=>{f&&f()},failed:()=>{this.terminate({cause:p.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!==w.STATUS_WAITING_FOR_ACK&&this._status!==w.STATUS_CONFIRMED||this._localHold===!1||!this.isReadyToReOffer())return!1;this._localHold=!1,this._onunhold("local");const T={succeeded:()=>{f&&f()},failed:()=>{this.terminate({cause:p.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!==w.STATUS_WAITING_FOR_ACK&&this._status!==w.STATUS_CONFIRMED||!this.isReadyToReOffer())return!1;const d={succeeded:()=>{f&&f()},failed:()=>{this.terminate({cause:p.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Media Renegotiation Failed"})}};return this._setLocalMediaStatus(),o.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:d,rtcOfferConstraints:T,extraHeaders:o.extraHeaders}):this._sendReinvite({eventHandlers:d,rtcOfferConstraints:T,extraHeaders:o.extraHeaders}),!0}refer(o,f){C.debug("refer()");const T=o;if(this._status!==w.STATUS_WAITING_FOR_ACK&&this._status!==w.STATUS_CONFIRMED)return!1;if(o=this._ua.normalizeTarget(o),!o)throw new TypeError(`Invalid target: ${T}`);const d=new N(this);d.sendRefer(o,f);const A=d.id;return this._referSubscribers[A]=d,d.on("requestFailed",()=>{delete this._referSubscribers[A]}),d.on("accepted",()=>{delete this._referSubscribers[A]}),d.on("failed",()=>{delete this._referSubscribers[A]}),d}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===p.CANCEL)(this._status===w.STATUS_WAITING_FOR_ANSWER||this._status===w.STATUS_ANSWERED)&&(this._status=w.STATUS_CANCELED,this._request.reply(487),this._failed("remote",o,p.causes.CANCELED));else switch(o.method){case p.ACK:if(this._status!==w.STATUS_WAITING_FOR_ACK)return;if(this._status=w.STATUS_CONFIRMED,clearTimeout(this._timers.ackTimer),clearTimeout(this._timers.invite2xxTimer),this._late_sdp){if(!o.body){this.terminate({cause:p.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(d=>{this.terminate({cause:p.causes.BAD_MEDIA_DESCRIPTION,status_code:488}),C.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',d),this.emit("peerconnection:setremotedescriptionfailed",d)})}else this._is_confirmed||this._confirmed("remote",o);break;case p.BYE:this._status===w.STATUS_CONFIRMED||this._status===w.STATUS_WAITING_FOR_ACK?(o.reply(200),this._ended("remote",o,p.causes.BYE)):this._status===w.STATUS_INVITE_RECEIVED||this._status===w.STATUS_WAITING_FOR_ANSWER?(o.reply(200),this._request.reply(487,"BYE Received"),this._ended("remote",o,p.causes.BYE)):o.reply(403,"Wrong Status");break;case p.INVITE:this._status===w.STATUS_CONFIRMED?o.hasHeader("replaces")?this._receiveReplaces(o):this._receiveReinvite(o):o.reply(403,"Wrong Status");break;case p.INFO:if(this._status===w.STATUS_1XX_RECEIVED||this._status===w.STATUS_WAITING_FOR_ANSWER||this._status===w.STATUS_ANSWERED||this._status===w.STATUS_WAITING_FOR_ACK||this._status===w.STATUS_CONFIRMED){const f=o.hasHeader("Content-Type")?o.getHeader("Content-Type").toLowerCase():void 0;f&&f.match(/^application\/dtmf-relay/i)?new S(this).init_incoming(o):f!==void 0?new D(this).init_incoming(o):o.reply(415)}else o.reply(403,"Wrong Status");break;case p.UPDATE:this._status===w.STATUS_CONFIRMED?this._receiveUpdate(o):o.reply(403,"Wrong Status");break;case p.REFER:this._status===w.STATUS_CONFIRMED?this._receiveRefer(o):o.reply(403,"Wrong Status");break;case p.NOTIFY:this._status===w.STATUS_CONFIRMED?this._receiveNotify(o):o.reply(403,"Wrong Status");break;default:o.reply(501)}}onTransportError(){C.warn("onTransportError()"),this._status!==w.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:p.causes.CONNECTION_ERROR,cause:p.causes.CONNECTION_ERROR})}onRequestTimeout(){C.warn("onRequestTimeout()"),this._status!==w.STATUS_TERMINATED&&this.terminate({status_code:408,reason_phrase:p.causes.REQUEST_TIMEOUT,cause:p.causes.REQUEST_TIMEOUT})}onDialogError(){C.warn("onDialogError()"),this._status!==w.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:p.causes.DIALOG_ERROR,cause:p.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"),_.closeMediaStream(this._localMediaStream)),this._status!==w.STATUS_TERMINATED){if(this._status=w.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=h.T1;function d(){this._status===w.STATUS_WAITING_FOR_ACK&&(o.reply(200,null,[`Contact: ${this._contact}`],f),T<h.T2&&(T=T*2,T>h.T2&&(T=h.T2)),this._timers.invite2xxTimer=setTimeout(d.bind(this),T))}this._timers.invite2xxTimer=setTimeout(d.bind(this),T)}_setACKTimer(){this._timers.ackTimer=setTimeout(()=>{this._status===w.STATUS_WAITING_FOR_ACK&&(C.debug("no ACK received, terminating the session"),clearTimeout(this._timers.invite2xxTimer),this.sendRequest(p.BYE),this._ended("remote",null,p.causes.NO_ACK))},h.TIMER_H)}_createRTCConnection(o,f){this._connection=new RTCPeerConnection(o,f),this._connection.addEventListener("iceconnectionstatechange",()=>{this._connection.iceConnectionState==="failed"&&this.terminate({cause:p.causes.RTP_TIMEOUT,status_code:408,reason_phrase:p.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(d=>(C.warn('emit "peerconnection:createofferfailed" [error:%o]',d),this.emit("peerconnection:createofferfailed",d),Promise.reject(d))):T.createAnswer(f).catch(d=>(C.warn('emit "peerconnection:createanswerfailed" [error:%o]',d),this.emit("peerconnection:createanswerfailed",d),Promise.reject(d)))).then(d=>T.setLocalDescription(d).catch(A=>(this._rtcReady=!0,C.warn('emit "peerconnection:setlocaldescriptionfailed" [error:%o]',A),this.emit("peerconnection:setlocaldescriptionfailed",A),Promise.reject(A)))).then(()=>{const d=f&&f.iceRestart;if(T.iceGatheringState==="complete"&&!d||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 O=!1,v,b;this._iceReady=!1;const U=()=>{if(O)return;T.removeEventListener("icecandidate",v),T.removeEventListener("icegatheringstatechange",b),O=!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 Z=M.candidate;Z?this.emit("icecandidate",{candidate:Z,ready:U}):U()}),T.addEventListener("icegatheringstatechange",b=()=>{T.iceGatheringState==="complete"&&U()})})})}_createDialog(o,f,T){const d=f==="UAS"?o.to_tag:o.from_tag,A=f==="UAS"?o.from_tag:o.to_tag,O=o.call_id+d+A;let v=this._earlyDialogs[O];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,p.causes.INTERNAL_ERROR),!1):(this._earlyDialogs[O]=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[O],!0;const b=new g(this,o,f);return b.error?(C.debug(b.error),this._failed("remote",o,p.causes.INTERNAL_ERROR),!1):(this._dialog=b,!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 d=!1;function A(v={}){d=!0;const b=v.status_code||403,U=v.reason_phrase||"",M=_.cloneArray(v.extraHeaders);if(this._status!==w.STATUS_CONFIRMED)return!1;if(b<300||b>=700)throw new TypeError(`Invalid status_code: ${b}`);o.reply(b,U,M)}if(this.emit("reinvite",T),d)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=>{O.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!==w.STATUS_TERMINATED&&O.call(this,v)}).catch(v=>{C.warn(v)});function O(v){const b=[`Contact: ${this._contact}`];this._handleSessionTimersInIncomingRequest(o,b),this._late_sdp&&(v=this._mangleOffer(v)),o.reply(200,null,b,v,()=>{this._status=w.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 d=!1;function A(v={}){d=!0;const b=v.status_code||403,U=v.reason_phrase||"",M=_.cloneArray(v.extraHeaders);if(this._status!==w.STATUS_CONFIRMED)return!1;if(b<300||b>=700)throw new TypeError(`Invalid status_code: ${b}`);o.reply(b,U,M)}if(this.emit("update",T),d)return;if(!o.body){O.call(this,null);return}if(f!=="application/sdp"){C.debug("invalid Content-Type"),o.reply(415);return}this._processInDialogSdpOffer(o).then(v=>{this._status!==w.STATUS_TERMINATED&&O.call(this,v)}).catch(v=>{C.warn(v)});function O(v){const b=[`Contact: ${this._contact}`];this._handleSessionTimersInIncomingRequest(o,b),o.reply(200,null,b,v),typeof T.callback=="function"&&T.callback()}}_processInDialogSdpOffer(o){C.debug("_processInDialogSdpOffer()");const f=o.parseSDP();let T=!1;for(const O of f.media){if(F.indexOf(O.type)===-1)continue;const v=O.direction||f.direction||"sendrecv";if(v==="sendonly"||v==="inactive")T=!0;else{T=!1;break}}const d={originator:"remote",type:"offer",sdp:o.body};C.debug('emit "sdp"'),this.emit("sdp",d);const A=new RTCSessionDescription({type:"offer",sdp:d.sdp});return this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>{if(this._status===w.STATUS_TERMINATED)throw new Error("terminated");return this._connection.setRemoteDescription(A).catch(O=>{throw o.reply(488),C.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',O),this.emit("peerconnection:setremotedescriptionfailed",O),O})}).then(()=>{if(this._status===w.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===w.STATUS_TERMINATED)throw new Error("terminated");return this._createLocalDescription("answer",this._rtcAnswerConstraints).catch(O=>{throw o.reply(500),C.warn('emit "peerconnection:createtelocaldescriptionfailed" [error:%o]',O),O})}).catch(O=>{C.warn("_processInDialogSdpOffer() failed [error: %o]",O)}),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!==p.SIP){C.debug("Refer-To header field points to a non-SIP URI scheme"),o.reply(416);return}o.reply(202);const f=new E(this,o.cseq);C.debug('emit "refer"'),this.emit("refer",{request:o,accept:(A,O)=>{T.call(this,A,O)},reject:()=>{d.call(this)}});function T(A,O={}){if(A=typeof A=="function"?A:null,this._status!==w.STATUS_WAITING_FOR_ACK&&this._status!==w.STATUS_CONFIRMED)return!1;const v=new Cs(this._ua);if(v.on("progress",({response:b})=>{f.notify(b.status_code,b.reason_phrase)}),v.on("accepted",({response:b})=>{f.notify(b.status_code,b.reason_phrase)}),v.on("_failed",({message:b,cause:U})=>{b?f.notify(b.status_code,b.reason_phrase):f.notify(487,U)}),o.refer_to.uri.hasHeader("replaces")){const b=decodeURIComponent(o.refer_to.uri.getHeader("replaces"));O.extraHeaders=_.cloneArray(O.extraHeaders),O.extraHeaders.push(`Replaces: ${b}`)}v.connect(o.refer_to.uri.toAor(),O,A)}function d(){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(d){if(this._status!==w.STATUS_WAITING_FOR_ACK&&this._status!==w.STATUS_CONFIRMED)return!1;const A=new Cs(this._ua);A.on("confirmed",()=>{this.terminate()}),A.init_incoming(o,d)}function T(){C.debug("Replaced INVITE rejected by the user"),o.reply(486)}this.emit("replaces",{request:o,accept:d=>{f.call(this,d)},reject:()=>{T.call(this)}})}_sendInitialRequest(o,f,T){const d=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===w.STATUS_TERMINATED?new Error("terminated"):(this._failed("local",null,p.causes.USER_DENIED_MEDIA_ACCESS),C.warn('emit "getusermediafailed" [error:%o]',A),this.emit("getusermediafailed",A),A)})}).then(A=>{if(this._status===w.STATUS_TERMINATED)throw new Error("terminated");return this._localMediaStream=A,A&&A.getTracks().forEach(O=>{this._connection.addTrack(O,A)}),this._connecting(this._request),this._createLocalDescription("offer",f).catch(O=>{throw this._failed("local",null,p.causes.WEBRTC_ERROR),O})}).then(A=>{if(this._is_canceled||this._status===w.STATUS_TERMINATED)throw new Error("terminated");this._request.body=A,this._status=w.STATUS_INVITE_SENT,C.debug('emit "sending" [request:%o]',this._request),this.emit("sending",{request:this._request}),d.send()}).catch(A=>{this._status!==w.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(p.ACK);return}else{const f=new g(this,o,"UAC");if(f.error!==void 0){C.debug(f.error);return}this.sendRequest(p.ACK),this.sendRequest(p.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!==w.STATUS_INVITE_SENT&&this._status!==w.STATUS_1XX_RECEIVED))switch(!0){case/^100$/.test(o.status_code):this._status=w.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=w.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(d=>{C.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',d),this.emit("peerconnection:setremotedescriptionfailed",d)});break}case/^2[0-9]{2}$/.test(o.status_code):{if(this._status=w.STATUS_CONFIRMED,!o.body){this._acceptAndTerminate(o,400,p.causes.MISSING_SDP),this._failed("remote",o,p.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(d=>this._connection.setLocalDescription(d)).catch(d=>{this._acceptAndTerminate(o,500,d.toString()),this._failed("local",o,p.causes.WEBRTC_ERROR)})}).then(()=>{this._connection.setRemoteDescription(T).then(()=>{this._handleSessionTimersInIncomingResponse(o),this._accepted("remote",o),this.sendRequest(p.ACK),this._confirmed("local",null)}).catch(d=>{this._acceptAndTerminate(o,488,"Not Acceptable Here"),this._failed("remote",o,p.causes.BAD_MEDIA_DESCRIPTION),C.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',d),this.emit("peerconnection:setremotedescriptionfailed",d)})});break}default:{const f=_.sipErrorCause(o.status_code);this._failed("remote",o,f)}}}_sendReinvite(o={}){C.debug("sendReinvite()");const f=_.cloneArray(o.extraHeaders),T=_.cloneObject(o.eventHandlers),d=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",d)).then(b=>{b=this._mangleOffer(b);const U={originator:"local",type:"offer",sdp:b};C.debug('emit "sdp"'),this.emit("sdp",U),this.sendRequest(p.INVITE,{extraHeaders:f,body:b,eventHandlers:{onSuccessResponse:M=>{O.call(this,M),A=!0},onErrorResponse:M=>{v.call(this,M)},onTransportError:()=>{this.onTransportError()},onRequestTimeout:()=>{this.onRequestTimeout()},onDialogError:()=>{this.onDialogError()}}})}).catch(()=>{v()});function O(b){if(this._status===w.STATUS_TERMINATED||(this.sendRequest(p.ACK),A))return;if(this._handleSessionTimersInIncomingResponse(b),b.body){if(!b.hasHeader("Content-Type")||b.getHeader("Content-Type").toLowerCase()!=="application/sdp"){v.call(this);return}}else{v.call(this);return}const U={originator:"remote",type:"answer",sdp:b.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(b)}).catch(Z=>{v.call(this),C.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',Z),this.emit("peerconnection:setremotedescriptionfailed",Z)})}function v(b){T.failed&&T.failed(b)}}_sendUpdate(o={}){C.debug("sendUpdate()");const f=_.cloneArray(o.extraHeaders),T=_.cloneObject(o.eventHandlers),d=o.rtcOfferConstraints||this._rtcOfferConstraints||null,A=o.sdpOffer||!1;let O=!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",d)).then(U=>{U=this._mangleOffer(U);const M={originator:"local",type:"offer",sdp:U};C.debug('emit "sdp"'),this.emit("sdp",M),this.sendRequest(p.UPDATE,{extraHeaders:f,body:U,eventHandlers:{onSuccessResponse:Z=>{v.call(this,Z),O=!0},onErrorResponse:Z=>{b.call(this,Z)},onTransportError:()=>{this.onTransportError()},onRequestTimeout:()=>{this.onRequestTimeout()},onDialogError:()=>{this.onDialogError()}}})}).catch(()=>{b.call(this)})):this.sendRequest(p.UPDATE,{extraHeaders:f,eventHandlers:{onSuccessResponse:U=>{v.call(this,U)},onErrorResponse:U=>{b.call(this,U)},onTransportError:()=>{this.onTransportError()},onRequestTimeout:()=>{this.onRequestTimeout()},onDialogError:()=>{this.onDialogError()}}});function v(U){if(this._status!==w.STATUS_TERMINATED&&!O)if(this._handleSessionTimersInIncomingResponse(U),A){if(U.body){if(!U.hasHeader("Content-Type")||U.getHeader("Content-Type").toLowerCase()!=="application/sdp"){b.call(this);return}}else{b.call(this);return}const M={originator:"remote",type:"answer",sdp:U.body};C.debug('emit "sdp"'),this.emit("sdp",M);const Z=new RTCSessionDescription({type:"answer",sdp:M.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(Z)).then(()=>{T.succeeded&&T.succeeded(U)}).catch(B=>{b.call(this),C.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',B),this.emit("peerconnection:setremotedescriptionfailed",B)})}else T.succeeded&&T.succeeded(U)}function b(U){T.failed&&T.failed(U)}}_acceptAndTerminate(o,f,T){C.debug("acceptAndTerminate()");const d=[];f&&(T=T||p.REASON_PHRASE[f]||"",d.push(`Reason: SIP ;cause=${f}; text="${T}"`)),(this._dialog||this._createDialog(o,"UAC"))&&(this.sendRequest(p.ACK),this.sendRequest(p.BYE,{extraHeaders:d})),this._status=w.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)F.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)F.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)F.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>=p.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>=p.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!==w.STATUS_TERMINATED&&this.isReadyToReOffer()&&(C.debug("runSessionTimer() | sending session refresh request"),this._sessionTimers.refreshMethod===p.UPDATE?this._sendUpdate():this._sendReinvite())},o*500):this._sessionTimers.timer=setTimeout(()=>{this._status!==w.STATUS_TERMINATED&&(C.warn("runSessionTimer() | timer expired, terminating the session"),this.terminate({cause:p.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})}},as}var os,kn;function oi(){if(kn)return os;kn=1;const I=Ie().EventEmitter,y=ce(),i=oe(),p=Se(),R=fe(),t=We(),_=we(),h=ye(),l=new y("Message");return os=class extends I{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,S,D={}){const E=c;if(c===void 0||S===void 0)throw new TypeError("Not enough arguments");if(c=this._ua.normalizeTarget(c),!c)throw new TypeError(`Invalid target: ${E}`);const N=R.cloneArray(D.extraHeaders),$=R.cloneObject(D.eventHandlers),C=D.contentType||"text/plain",w={};D.fromUserName&&(w.from_uri=new h("sip",D.fromUserName,this._ua.configuration.uri.host),N.push(`P-Preferred-Identity: ${this._ua.configuration.uri.toString()}`)),D.fromDisplayName&&(w.from_display_name=D.fromDisplayName);for(const H in $)Object.prototype.hasOwnProperty.call($,H)&&this.on(H,$[H]);N.push(`Content-Type: ${C}`),this._request=new p.OutgoingRequest(i.MESSAGE,c,this._ua,w,N),S&&(this._request.body=S);const F=new t(this._ua,this._request,{onRequestTimeout:()=>{this._onRequestTimeout()},onTransportError:()=>{this._onTransportError()},onReceiveResponse:H=>{this._receiveResponse(H)}});this._newMessage("local",this._request),F.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 S=R.cloneArray(c.extraHeaders),D=c.body;if(this._direction!=="incoming")throw new _.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,S,D)}reject(c={}){const S=c.status_code||480,D=c.reason_phrase,E=R.cloneArray(c.extraHeaders),N=c.body;if(this._direction!=="incoming")throw new _.NotSupportedError('"reject" not supported for outgoing Message');if(this._is_replied)throw new Error("incoming Message already replied");if(S<300||S>=700)throw new TypeError(`Invalid status_code: ${S}`);this._is_replied=!0,this._request.reply(S,D,E,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 S=R.sipErrorCause(c.status_code);this._failed("remote",c,S);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,S){c==="remote"?(this._direction="incoming",this._local_identity=S.to,this._remote_identity=S.from):c==="local"&&(this._direction="outgoing",this._local_identity=S.from,this._remote_identity=S.to),this._ua.newMessage(this,{originator:c,message:this,request:S})}_failed(c,S,D){l.debug("MESSAGE failed"),this._close(),l.debug('emit "failed"'),this.emit("failed",{originator:c,response:S||null,cause:D})}_succeeded(c,S){l.debug("MESSAGE succeeded"),this._close(),l.debug('emit "succeeded"'),this.emit("succeeded",{originator:c,response:S})}},os}var us,qn;function ui(){if(qn)return us;qn=1;const I=Ie().EventEmitter,y=ce(),i=oe(),p=Se(),R=fe(),t=We(),_=we(),h=new y("Options");return us=class extends I{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,S={}){const D=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: ${D}`);const E=R.cloneArray(S.extraHeaders),N=R.cloneObject(S.eventHandlers),$=S.contentType||"application/sdp";for(const w in N)Object.prototype.hasOwnProperty.call(N,w)&&this.on(w,N[w]);E.push(`Content-Type: ${$}`),this._request=new p.OutgoingRequest(i.OPTIONS,g,this._ua,null,E),c&&(this._request.body=c);const C=new t(this._ua,this._request,{onRequestTimeout:()=>{this._onRequestTimeout()},onTransportError:()=>{this._onTransportError()},onReceiveResponse:w=>{this._receiveResponse(w)}});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=R.cloneArray(g.extraHeaders),S=g.body;if(this._direction!=="incoming")throw new _.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,S)}reject(g={}){const c=g.status_code||480,S=g.reason_phrase,D=R.cloneArray(g.extraHeaders),E=g.body;if(this._direction!=="incoming")throw new _.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,S,D,E)}_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=R.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,S){h.debug("OPTIONS failed"),this._close(),h.debug('emit "failed"'),this.emit("failed",{originator:g,response:c||null,cause:S})}_succeeded(g,c){h.debug("OPTIONS succeeded"),this._close(),h.debug('emit "succeeded"'),this.emit("succeeded",{originator:g,response:c})}},us}var cs={},jn;function rl(){if(jn)return cs;jn=1;const I=ce(),y=fe(),i=Ce(),p=new I("Socket");return cs.isSocket=R=>{if(Array.isArray(R))return!1;if(typeof R>"u")return p.warn("undefined JsSIP.Socket instance"),!1;try{if(!y.isString(R.url))throw p.warn("missing or invalid JsSIP.Socket url property"),new Error("Missing or invalid JsSIP.Socket url property");if(!y.isString(R.via_transport))throw p.warn("missing or invalid JsSIP.Socket via_transport property"),new Error("Missing or invalid JsSIP.Socket via_transport property");if(i.parse(R.sip_uri,"SIP_URI")===-1)throw p.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(R[t]))throw p.warn(`missing or invalid JsSIP.Socket method: ${t}`),new Error(`Missing or invalid JsSIP.Socket method: ${t}`)})}catch{return!1}return!0},cs}var fs,Gn;function ci(){if(Gn)return fs;Gn=1;const I=ce(),y=rl(),i=oe(),p=new I("Transport"),R={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 fs=class{constructor(_,h=R.recovery_options){p.debug("new()"),this.status=R.STATUS_DISCONNECTED,this.socket=null,this.sockets=[],this.recovery_options=h,this.recover_attempts=0,this.recovery_timer=null,this.close_requested=!1;try{this.textDecoder=new TextDecoder("utf8")}catch(l){p.warn(`cannot use TextDecoder: ${l}`)}if(typeof _>"u")throw new TypeError("Invalid argument. undefined 'sockets' argument");_ instanceof Array||(_=[_]),_.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:R.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(p.debug("connect()"),this.isConnected()){p.debug("Transport is already connected");return}else if(this.isConnecting()){p.debug("Transport is connecting");return}this.close_requested=!1,this.status=R.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(){p.debug("close()"),this.close_requested=!0,this.recover_attempts=0,this.status=R.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(_){if(p.debug("send()"),!this.isConnected())return p.warn("unable to send message, transport is not connected"),!1;const h=_.toString();return p.debug(`sending message:
47
+
48
+ ${h}
49
+ `),this.socket.send(h)}isConnected(){return this.status===R.STATUS_CONNECTED}isConnecting(){return this.status===R.STATUS_CONNECTING}_reconnect(){this.recover_attempts+=1;let _=Math.floor(Math.random()*Math.pow(2,this.recover_attempts)+1);_<this.recovery_options.min_interval?_=this.recovery_options.min_interval:_>this.recovery_options.max_interval&&(_=this.recovery_options.max_interval),p.debug(`reconnection attempt: ${this.recover_attempts}. next connection attempt in ${_} seconds`),this.recovery_timer=setTimeout(()=>{!this.close_requested&&!(this.isConnected()||this.isConnecting())&&(this._getSocket(),this.connect())},_*1e3)}_getSocket(){let _=[];if(this.sockets.forEach(l=>{l.status!==R.SOCKET_STATUS_ERROR&&(_.length===0?_.push(l):l.weight>_[0].weight?_=[l]:l.weight===_[0].weight&&_.push(l))}),_.length===0){this.sockets.forEach(l=>{l.status=R.SOCKET_STATUS_READY}),this._getSocket();return}const h=Math.floor(Math.random()*_.length);this.socket=_[h].socket}_onConnect(){this.recover_attempts=0,this.status=R.STATUS_CONNECTED,this.recovery_timer!==null&&(clearTimeout(this.recovery_timer),this.recovery_timer=null),this.onconnect({socket:this})}_onDisconnect(_,h,l){this.status=R.STATUS_DISCONNECTED,this.ondisconnect({socket:this.socket,error:_,code:h,reason:l}),!this.close_requested&&(this.sockets.forEach(function(g){this.socket===g.socket&&(g.status=R.SOCKET_STATUS_ERROR)},this),this._reconnect(_))}_onData(_){if(_===`\r
50
+ \r
51
+ `){p.debug("received message with double-CRLF Keep Alive request");try{this.socket.send(`\r
52
+ `)}catch(h){p.warn(`error sending Keep Alive response: ${h}`)}return}if(_===`\r
53
+ `){p.debug("received message with CRLF Keep Alive response");return}else if(typeof _!="string"){try{this.textDecoder?_=this.textDecoder.decode(_):_=String.fromCharCode.apply(null,new Uint8Array(_))}catch{p.debug("received binary message failed to be converted into string, message discarded");return}p.debug(`received binary message:
54
+
55
+ ${_}
56
+ `)}else p.debug(`received text message:
57
+
58
+ ${_}
59
+ `);this.ondata({transport:this,message:_})}},fs}var hs={},Bn;function fi(){if(Bn)return hs;Bn=1;const I=ce(),y=Ce(),i=Se(),p=new I("Parser");hs.parseMessage=(_,h)=>{let l,g,c=_.indexOf(`\r
60
+ `);if(c===-1){p.warn("parseMessage() | no CRLF found, not a SIP message");return}const S=_.substring(0,c);let D=y.parse(S,"Request_Response");if(D===-1){p.warn(`parseMessage() | error parsing first line of SIP message: "${S}"`);return}else D.status_code?(l=new i.IncomingResponse,l.status_code=D.status_code,l.reason_phrase=D.reason_phrase):(l=new i.IncomingRequest(h),l.method=D.method,l.ruri=D.uri);l.data=_;let E=c+2;for(;;){if(c=R(_,E),c===-2){g=E+2;break}else if(c===-1){p.warn("parseMessage() | malformed message");return}if(D=t(l,_,E,c),D!==!0){p.warn("parseMessage() |",D.error);return}E=c+2}if(l.hasHeader("content-length")){const N=l.getHeader("content-length");l.body=_.substr(g,N)}else l.body=_.substring(g);return l};function R(_,h){let l=h,g=0,c=0;if(_.substring(l,l+2).match(/(^\r\n)/))return-2;for(;g===0;){if(c=_.indexOf(`\r
61
+ `,l),c===-1)return c;!_.substring(c+2,c+4).match(/(^\r\n)/)&&_.charAt(c+2).match(/(^\s+)/)?l=c+2:g=c}return g}function t(_,h,l,g){let c;const S=h.indexOf(":",l),D=h.substring(l,S).trim(),E=h.substring(S+1,g).trim();switch(D.toLowerCase()){case"via":case"v":_.addHeader("via",E),_.getHeaders("via").length===1?(c=_.parseHeader("Via"),c&&(_.via=c,_.via_branch=c.branch)):c=0;break;case"from":case"f":_.setHeader("from",E),c=_.parseHeader("from"),c&&(_.from=c,_.from_tag=c.getParam("tag"));break;case"to":case"t":_.setHeader("to",E),c=_.parseHeader("to"),c&&(_.to=c,_.to_tag=c.getParam("tag"));break;case"record-route":if(c=y.parse(E,"Record_Route"),c===-1)c=void 0;else for(const N of c)_.addHeader("record-route",E.substring(N.possition,N.offset)),_.headers["Record-Route"][_.getHeaders("record-route").length-1].parsed=N.parsed;break;case"call-id":case"i":_.setHeader("call-id",E),c=_.parseHeader("call-id"),c&&(_.call_id=E);break;case"contact":case"m":if(c=y.parse(E,"Contact"),c===-1)c=void 0;else for(const N of c)_.addHeader("contact",E.substring(N.possition,N.offset)),_.headers.Contact[_.getHeaders("contact").length-1].parsed=N.parsed;break;case"content-length":case"l":_.setHeader("content-length",E),c=_.parseHeader("content-length");break;case"content-type":case"c":_.setHeader("content-type",E),c=_.parseHeader("content-type");break;case"cseq":_.setHeader("cseq",E),c=_.parseHeader("cseq"),c&&(_.cseq=c.value),_ instanceof i.IncomingResponse&&(_.method=c.method);break;case"max-forwards":_.setHeader("max-forwards",E),c=_.parseHeader("max-forwards");break;case"www-authenticate":_.setHeader("www-authenticate",E),c=_.parseHeader("www-authenticate");break;case"proxy-authenticate":_.setHeader("proxy-authenticate",E),c=_.parseHeader("proxy-authenticate");break;case"session-expires":case"x":_.setHeader("session-expires",E),c=_.parseHeader("session-expires"),c&&(_.session_expires=c.expires,_.session_expires_refresher=c.refresher);break;case"refer-to":case"r":_.setHeader("refer-to",E),c=_.parseHeader("refer-to"),c&&(_.refer_to=c);break;case"replaces":_.setHeader("replaces",E),c=_.parseHeader("replaces"),c&&(_.replaces=c);break;case"event":case"o":_.setHeader("event",E),c=_.parseHeader("event"),c&&(_.event=c);break;default:_.addHeader(D,E),c=0}return c===void 0?{error:`error parsing header "${D}"`}:!0}return hs}var ds,Wn;function hi(){if(Wn)return ds;Wn=1;const I=ce(),y=oe(),i=Se(),p=fe(),R=new I("sanityCheck"),t=[w],_=[S,D,E,N],h=[$,C];let l,g,c;ds=(H,o,f)=>{l=H,g=o,c=f;for(const T of t)if(T()===!1)return!1;if(l instanceof i.IncomingRequest){for(const T of _)if(T()===!1)return!1}else if(l instanceof i.IncomingResponse){for(const T of h)if(T()===!1)return!1}return!0};function S(){if(l.s("to").uri.scheme!=="sip")return F(416),!1}function D(){if(!l.to_tag&&l.call_id.substr(0,5)===g.configuration.jssip_id)return F(482),!1}function E(){const H=p.str_utf8_length(l.body),o=l.getHeader("content-length");if(H<o)return F(400),!1}function N(){const H=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 d in g._transactions.ist)if(Object.prototype.hasOwnProperty.call(g._transactions.ist,d)&&(T=g._transactions.ist[d],T.request.from_tag===H&&T.request.call_id===o&&T.request.cseq===f))return F(482),!1}else{if(g._transactions.nist[l.via_branch])return!1;for(const d in g._transactions.nist)if(Object.prototype.hasOwnProperty.call(g._transactions.nist,d)&&(T=g._transactions.nist[d],T.request.from_tag===H&&T.request.call_id===o&&T.request.cseq===f))return F(482),!1}}function $(){if(l.getHeaders("via").length>1)return R.debug("more than one Via header field present in the response, dropping the response"),!1}function C(){const H=p.str_utf8_length(l.body),o=l.getHeader("content-length");if(H<o)return R.debug("message body length is lower than the value in Content-Length header field, dropping the response"),!1}function w(){const H=["from","to","call_id","cseq","via"];for(const o of H)if(!l.hasHeader(o))return R.debug(`missing mandatory header field : ${o}, dropping the response`),!1}function F(H){const o=l.getHeaders("via");let f,T=`SIP/2.0 ${H} ${y.REASON_PHRASE[H]}\r
62
+ `;for(const d of o)T+=`Via: ${d}\r
63
+ `;f=l.getHeader("To"),l.to_tag||(f+=`;tag=${p.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 ds}var ht={},Vn;function di(){if(Vn)return ht;Vn=1;const I=fe(),y=oe(),i=Ce(),p=ye(),R=rl(),t=we();ht.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:`${I.createRandomToken(12)}.invalid`};const _={mandatory:{sockets(h){const l=[];if(R.isSocket(h))l.push({socket:h});else if(Array.isArray(h)&&h.length)for(const g of h)Object.prototype.hasOwnProperty.call(g,"socket")&&R.isSocket(g.socket)?l.push(g):R.isSocket(g)&&l.push({socket:g});else return;return l},uri(h){/^sip:/i.test(h)||(h=`${y.SIP}:${h}`);const l=p.parse(h);if(l)return l.user?l:void 0}},optional:{authorization_user(h){if(i.parse(`"${h}"`,"quoted_string")!==-1)return h},authorization_jwt(h){if(typeof h=="string")return h},user_agent(h){if(typeof h=="string")return h},connection_recovery_max_interval(h){if(I.isDecimal(h)){const l=Number(h);if(l>0)return l}},connection_recovery_min_interval(h){if(I.isDecimal(h)){const l=Number(h);if(l>0)return l}},contact_uri(h){if(typeof h=="string"){const l=i.parse(h,"SIP_URI");if(l!==-1)return l}},display_name(h){return h},instance_id(h){if(/^uuid:/i.test(h)&&(h=h.substr(5)),i.parse(h,"uuid")!==-1)return h},no_answer_timeout(h){if(I.isDecimal(h)){const l=Number(h);if(l>0)return l}},session_timers(h){if(typeof h=="boolean")return h},session_timers_refresh_method(h){if(typeof h=="string"&&(h=h.toUpperCase(),h===y.INVITE||h===y.UPDATE))return h},session_timers_force_refresher(h){if(typeof h=="boolean")return h},password(h){return String(h)},realm(h){return String(h)},ha1(h){return String(h)},register(h){if(typeof h=="boolean")return h},register_expires(h){if(I.isDecimal(h)){const l=Number(h);if(l>=0)return l}},register_from_tag_trail(h){return typeof h=="function"?h:String(h)},registrar_server(h){/^sip:/i.test(h)||(h=`${y.SIP}:${h}`);const l=p.parse(h);if(l)return l.user?void 0:l},use_preloaded_route(h){if(typeof h=="boolean")return h},extra_headers(h){const l=[];if(Array.isArray(h)&&h.length)for(const g of h)typeof g=="string"&&l.push(g);else return;return l}}};return ht.load=(h,l)=>{for(const g in _.mandatory)if(l.hasOwnProperty(g)){const c=l[g],S=_.mandatory[g](c);if(S!==void 0)h[g]=S;else throw new t.ConfigurationError(g,c)}else throw new t.ConfigurationError(g);for(const g in _.optional)if(l.hasOwnProperty(g)){const c=l[g];if(I.isEmpty(c))continue;const S=_.optional[g](c);if(S!==void 0)h[g]=S;else throw new t.ConfigurationError(g,c)}},ht}var _s,zn;function _i(){if(zn)return _s;zn=1;const I=Ie().EventEmitter,y=ce(),i=oe(),p=ti(),R=sl(),t=oi(),_=ui(),h=Be(),l=ci(),g=fe(),c=we(),S=ye(),D=fi(),E=Se(),N=hi(),$=di(),C=new y("UA"),w={STATUS_INIT:0,STATUS_READY:1,STATUS_USER_CLOSED:2,STATUS_NOT_READY:3,CONFIGURATION_ERROR:1,NETWORK_ERROR:2};_s=class extends I{static get C(){return w}constructor(d){if(!d)throw new TypeError("Not enough arguments");const A=["password","ha1","authorization_jwt"];C.debug("new() [configuration:%o]",Object.entries(d).filter(([O])=>!A.includes(O))),super(),this._cache={credentials:{}},this._configuration=Object.assign({},$.settings),this._dynConfiguration={},this._dialogs={},this._applicants={},this._sessions={},this._transport=null,this._contact=null,this._status=w.STATUS_INIT,this._error=null,this._transactions={nist:{},nict:{},ist:{},ict:{}},this._data={},this._closeTimer=null;try{this._loadConfig(d)}catch(O){throw this._status=w.STATUS_NOT_READY,this._error=w.CONFIGURATION_ERROR,O}this._registrator=new p(this)}get C(){return w}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===w.STATUS_INIT?this._transport.connect():this._status===w.STATUS_USER_CLOSED?(C.debug("restarting UA"),this._closeTimer!==null&&(clearTimeout(this._closeTimer),this._closeTimer=null,this._transport.disconnect()),this._status=w.STATUS_INIT,this._transport.connect()):this._status===w.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(d){C.debug("unregister()"),this._dynConfiguration.register=!1,this._registrator.unregister(d)}registrator(){return this._registrator}isRegistered(){return this._registrator.registered}isConnected(){return this._transport.isConnected()}call(d,A){C.debug("call()");const O=new R(this);return O.connect(d,A),O}sendMessage(d,A,O){C.debug("sendMessage()");const v=new t(this);return v.send(d,A,O),v}sendOptions(d,A,O){C.debug("sendOptions()");const v=new _(this);return v.send(d,A,O),v}terminateSessions(d){C.debug("terminateSessions()");for(const A in this._sessions)this._sessions[A].isEnded()||this._sessions[A].terminate(d)}stop(){if(C.debug("stop()"),this._dynConfiguration={},this._status===w.STATUS_USER_CLOSED){C.debug("UA already closed");return}this._registrator.close();const d=Object.keys(this._sessions).length;for(const O in this._sessions)if(Object.prototype.hasOwnProperty.call(this._sessions,O)){C.debug(`closing session ${O}`);try{this._sessions[O].terminate()}catch{}}for(const O in this._applicants)if(Object.prototype.hasOwnProperty.call(this._applicants,O))try{this._applicants[O].close()}catch{}this._status=w.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&&d===0?this._transport.disconnect():this._closeTimer=setTimeout(()=>{this._closeTimer=null,this._transport.disconnect()},2e3)}normalizeTarget(d){return g.normalizeTarget(d,this._configuration.hostport_params)}get(d){switch(d){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',d);return}}set(d,A){switch(d){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',d),!1}return!0}newTransaction(d){this._transactions[d.type][d.id]=d,this.emit("newTransaction",{transaction:d})}destroyTransaction(d){delete this._transactions[d.type][d.id],this.emit("transactionDestroyed",{transaction:d})}newDialog(d){this._dialogs[d.id]=d}destroyDialog(d){delete this._dialogs[d.id]}newMessage(d,A){this._applicants[d]=d,this.emit("newMessage",A)}newOptions(d,A){this._applicants[d]=d,this.emit("newOptions",A)}destroyMessage(d){delete this._applicants[d]}newRTCSession(d,A){this._sessions[d.id]=d,this.emit("newRTCSession",A)}destroyRTCSession(d){delete this._sessions[d.id]}registered(d){this.emit("registered",d)}unregistered(d){this.emit("unregistered",d)}registrationFailed(d){this.emit("registrationFailed",d)}receiveRequest(d){const A=d.method;if(d.ruri.user!==this._configuration.uri.user&&d.ruri.user!==this._contact.uri.user){C.debug("Request-URI does not point to us"),d.method!==i.ACK&&d.reply_sl(404);return}if(d.ruri.scheme===i.SIPS){d.reply_sl(416);return}if(h.checkTransaction(this,d))return;if(A===i.INVITE?new h.InviteServerTransaction(this,this._transport,d):A!==i.ACK&&A!==i.CANCEL&&new h.NonInviteServerTransaction(this,this._transport,d),A===i.OPTIONS){if(this.listeners("newOptions").length===0){d.reply(200);return}new _(this).init_incoming(d)}else if(A===i.MESSAGE){if(this.listeners("newMessage").length===0){d.reply(405);return}new t(this).init_incoming(d)}else if(A===i.INVITE&&!d.to_tag&&this.listeners("newRTCSession").length===0){d.reply(405);return}let O,v;if(d.to_tag)O=this._findDialog(d.call_id,d.from_tag,d.to_tag),O?O.receiveRequest(d):A===i.NOTIFY?(v=this._findSession(d),v?v.receiveRequest(d):(C.debug("received NOTIFY request for a non existent subscription"),d.reply(481,"Subscription does not exist"))):A!==i.ACK&&d.reply(481);else switch(A){case i.INVITE:if(window.RTCPeerConnection)if(d.hasHeader("replaces")){const b=d.replaces;O=this._findDialog(b.call_id,b.from_tag,b.to_tag),O?(v=O.owner,v.isEnded()?d.reply(603):v.receiveRequest(d)):d.reply(481)}else v=new R(this),v.init_incoming(d);else C.warn("INVITE received but WebRTC is not supported"),d.reply(488);break;case i.BYE:d.reply(481);break;case i.CANCEL:v=this._findSession(d),v?v.receiveRequest(d):C.debug("received CANCEL request for a non existent session");break;case i.ACK:break;case i.NOTIFY:this.emit("sipEvent",{event:d.event,request:d}),d.reply(200);break;default:d.reply(405);break}}_findSession({call_id:d,from_tag:A,to_tag:O}){const v=d+A,b=this._sessions[v],U=d+O,M=this._sessions[U];return b||M||null}_findDialog(d,A,O){let v=d+A+O,b=this._dialogs[v];return b||(v=d+O+A,b=this._dialogs[v],b||null)}_loadConfig(d){try{$.load(this._configuration,d)}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=F.bind(this),this._transport.onconnect=H.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 S("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 b=v.anonymous||null,U=v.outbound||null;let M="<";return b?M+=this.temp_gruu||"sip:anonymous@anonymous.invalid;transport=ws":M+=this.pub_gruu||this.uri.toString(),U&&(b?!this.temp_gruu:!this.pub_gruu)&&(M+=";ob"),M+=">",M}};const O=["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)&&(O.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($.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 F(T){this.emit("connecting",T)}function H(T){this._status!==w.STATUS_USER_CLOSED&&(this._status=w.STATUS_READY,this._error=null,this.emit("connected",T),this._dynConfiguration.register&&this._registrator.register())}function o(T){const d=["nict","ict","nist","ist"];for(const A of d)for(const O in this._transactions[A])Object.prototype.hasOwnProperty.call(this._transactions[A],O)&&this._transactions[A][O].onTransportError();this.emit("disconnected",T),this._registrator.onTransportClosed(),this._status!==w.STATUS_USER_CLOSED&&(this._status=w.STATUS_NOT_READY,this._error=w.NETWORK_ERROR)}function f(T){const d=T.transport;let A=T.message;if(A=D.parseMessage(A,this),!!A&&!(this._status===w.STATUS_USER_CLOSED&&A instanceof E.IncomingRequest)&&N(A,this,d)){if(A instanceof E.IncomingRequest)A.transport=d,this.receiveRequest(A);else if(A instanceof E.IncomingResponse){let O;switch(A.method){case i.INVITE:O=this._transactions.ict[A.via_branch],O&&O.receiveResponse(A);break;case i.ACK:break;default:O=this._transactions.nict[A.via_branch],O&&O.receiveResponse(A);break}}}}return _s}var ps,Kn;function pi(){if(Kn)return ps;Kn=1;const I=ce(),y=Ce(),i=new I("WebSocketInterface");return ps=class{constructor(R){i.debug('new() [url:"%s"]',R),this._url=R,this._sip_uri=null,this._via_transport=null,this._ws=null;const t=y.parse(R,"absoluteURI");if(t===-1)throw i.warn(`invalid WebSocket URI: ${R}`),new TypeError(`Invalid argument: ${R}`);if(t.scheme!=="wss"&&t.scheme!=="ws")throw i.warn(`invalid WebSocket URI scheme: ${t.scheme}`),new TypeError(`Invalid argument: ${R}`);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(R){this._via_transport=R.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(R){this._onError(R)}}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(R){return i.debug("send()"),this.isConnected()?(this._ws.send(R),!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:R,code:t,reason:_}){i.debug(`WebSocket ${this._url} closed`),R===!1&&i.debug("WebSocket abrupt disconnection"),this.ondisconnect(!R,t,_)}_onMessage({data:R}){i.debug("received WebSocket message"),this.ondata(R)}_onError(R){i.warn(`WebSocket ${this._url} error: `,R)}},ps}var ms,Yn;function mi(){if(Yn)return ms;Yn=1;const I=Xn,y=oe(),i=we(),p=fe(),R=_i(),t=ye(),_=Es(),h=Ce(),l=pi(),g=Ts()("JsSIP"),c=sl();return g("version %s",I.version),ms={C:y,Exceptions:i,Utils:p,UA:R,URI:t,NameAddrHeader:_,WebSocketInterface:l,Grammar:h,RTCSession:c,debug:Ts(),get name(){return I.title},get version(){return I.version}},ms}var gi=mi();const Jn=zl(gi),nl=ae.createContext(null);function ll({config:I,children:y,onCallStart:i,onCallEnd:p,onStatusChange:R}){const[t,_]=ae.useState(""),[h,l]=ae.useState("disconnected"),[g,c]=ae.useState(null),[S,D]=ae.useState(0),[E,N]=ae.useState([]),[$,C]=ae.useState(!1),w=ae.useRef(null),F=ae.useRef(null);ae.useEffect(()=>{const A={sockets:[new Jn.WebSocketInterface(I.websocketUrl)],uri:I.sipUri,password:I.password,registrar_server:I.registrarServer,display_name:I.displayName,authorization_user:I.authorizationUser},O=new Jn.UA(A);return w.current=O,O.on("registered",()=>C(!0)),O.on("unregistered",()=>C(!1)),O.on("registrationFailed",()=>C(!1)),O.start(),()=>{O.stop()}},[I]),ae.useEffect(()=>{R?.(h)},[h,R]),ae.useEffect(()=>{const d=localStorage.getItem("tbi-phone-call-history");if(d)try{N(JSON.parse(d))}catch(A){console.error("Error loading call history",A)}},[]),ae.useEffect(()=>{E.length>0&&localStorage.setItem("tbi-phone-call-history",JSON.stringify(E))},[E]),ae.useEffect(()=>{if(h==="confirmed"&&g){const d=setInterval(()=>{D(Math.floor((Date.now()-g)/1e3))},1e3);return()=>clearInterval(d)}else D(0)},[h,g]),ae.useEffect(()=>{const d=A=>{const O=A.detail.number;h==="disconnected"&&f(O)};return window.addEventListener("StartCallEvent",d),()=>{window.removeEventListener("StartCallEvent",d)}},[h]);const H=ae.useCallback((d,A,O)=>{const v={id:Date.now().toString(),number:d,timestamp:Date.now(),duration:A,status:O};N(b=>[v,...b].slice(0,50))},[]),o=ae.useCallback(()=>{F.current&&(F.current.terminate(),F.current=null)},[]),f=ae.useCallback(d=>{if(!d.trim()||!w.current)return;_(d),i?.(d);const O={eventHandlers:{progress:()=>{l("progress")},failed:()=>{l("failed"),H(d,0,"failed"),p?.(d,0,"failed"),o(),setTimeout(()=>l("disconnected"),3e3)},ended:()=>{l("ended");const b=g?Math.floor((Date.now()-g)/1e3):0;H(d,b,"completed"),p?.(d,b,"completed"),o(),setTimeout(()=>{l("disconnected"),c(null)},2e3)},confirmed:()=>{l("confirmed"),c(Date.now())}},mediaConstraints:{audio:!0,video:!1}};w.current.on("newRTCSession",b=>{const U=b.session;F.current=U,U.connection&&(U.connection.addEventListener("addstream",M=>{if(!M.streams?.length)return;const Z=document.createElement("audio");Z.srcObject=M.streams[0],Z.play()}),U.connection.addEventListener("track",M=>{const Z=document.createElement("audio");Z.srcObject=M.streams[0],Z.play()}))}),l("progress");const v=w.current.call(d,O);F.current=v},[H,o,i,p,g]),T={status:h,callNumber:t,setCallNumber:_,callHistory:E,currentCallDuration:S,startCall:f,endCall:o,isReady:$};return q.jsx(nl.Provider,{value:T,children:y})}function il(){const I=ae.useContext(nl);if(!I)throw new Error("usePhone must be used within a PhoneProvider");return I}const vs=({className:I})=>q.jsx("svg",{className:I,viewBox:"0 0 24 24",fill:"currentColor",children:q.jsx("path",{d:"M6.62 10.79c1.44 2.83 3.76 5.14 6.59 6.59l2.2-2.2c.27-.27.67-.36 1.02-.24 1.12.37 2.33.57 3.57.57.55 0 1 .45 1 1V20c0 .55-.45 1-1 1-9.39 0-17-7.61-17-17 0-.55.45-1 1-1h3.5c.55 0 1 .45 1 1 0 1.25.2 2.45.57 3.57.11.35.03.74-.25 1.02l-2.2 2.2z"})}),Ti=({className:I})=>q.jsx("svg",{className:I,viewBox:"0 0 24 24",fill:"currentColor",children:q.jsx("path",{d:"M15.05 5A7 7 0 0 1 19 8.95M15.05 1A11 11 0 0 1 23 8.94m-1 7.98v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z"})}),Ci=({className:I})=>q.jsx("svg",{className:I,viewBox:"0 0 24 24",fill:"currentColor",children:q.jsx("path",{d:"M20 15.5c-1.25 0-2.45-.2-3.57-.57-.35-.12-.74-.03-1.02.24l-2.2 2.2c-2.83-1.45-5.15-3.76-6.59-6.59l2.2-2.21c.28-.26.36-.65.25-1C8.7 6.45 8.5 5.25 8.5 4c0-.55-.45-1-1-1H4c-.55 0-1 .45-1 1 0 9.39 7.61 17 17 17 .55 0 1-.45 1-1v-3.5c0-.55-.45-1-1-1zM19 12h2c0-4.97-4.03-9-9-9v2c3.87 0 7 3.13 7 7zm-4 0h2c0-2.76-2.24-5-5-5v2c1.66 0 3 1.34 3 3z"})}),dt=({className:I})=>q.jsx("svg",{className:I,viewBox:"0 0 24 24",fill:"currentColor",children:q.jsx("path",{d:"M12 9c-1.6 0-3.15.25-4.6.72v3.1c0 .39-.23.74-.56.9-.98.49-1.87 1.12-2.66 1.85-.18.18-.43.28-.7.28-.28 0-.53-.11-.71-.29L.29 13.08a.956.956 0 0 1-.29-.7c0-.28.11-.53.29-.71C3.34 8.78 7.46 7 12 7s8.66 1.78 11.71 4.67c.18.18.29.43.29.71 0 .28-.11.53-.29.71l-2.48 2.48c-.18.18-.43.29-.71.29-.27 0-.52-.11-.7-.28a11.27 11.27 0 0 0-2.67-1.85.996.996 0 0 1-.56-.9v-3.1C15.15 9.25 13.6 9 12 9z"})}),al=({className:I})=>q.jsx("svg",{className:I,viewBox:"0 0 24 24",fill:"currentColor",children:q.jsx("path",{d:"M6.5 5.5 12 11l7-7-1-1-6 6-4.5-4.5H11V3H5v6h1.5V5.5zm17.21 11.17C20.66 13.78 16.54 12 12 12 7.46 12 3.34 13.78.29 16.67c-.18.18-.29.43-.29.71s.11.53.29.71l2.48 2.48c.18.18.43.29.71.29.27 0 .52-.11.7-.28.79-.74 1.69-1.36 2.66-1.85.33-.16.56-.5.56-.9v-3.1c1.45-.48 3-.73 4.6-.73 1.6 0 3.15.25 4.6.72v3.1c0 .39.23.74.56.9.98.49 1.87 1.12 2.67 1.85.18.18.43.28.7.28.28 0 .53-.11.71-.29l2.48-2.48c.18-.18.29-.43.29-.71s-.12-.52-.3-.7z"})}),vi=({className:I})=>q.jsxs("svg",{className:I,viewBox:"0 0 24 24",fill:"currentColor",children:[q.jsx("path",{d:"M6.62 10.79c1.44 2.83 3.76 5.14 6.59 6.59l2.2-2.2c.27-.27.67-.36 1.02-.24 1.12.37 2.33.57 3.57.57.55 0 1 .45 1 1V20c0 .55-.45 1-1 1-9.39 0-17-7.61-17-17 0-.55.45-1 1-1h3.5c.55 0 1 .45 1 1 0 1.25.2 2.45.57 3.57.11.35.03.74-.25 1.02l-2.2 2.2z"}),q.jsx("path",{d:"M16 3l-5 5-2-2-1.5 1.5L11 11l6.5-6.5z"})]}),Ei=({className:I})=>q.jsxs("svg",{className:I,viewBox:"0 0 24 24",fill:"currentColor",children:[q.jsx("path",{d:"M6.62 10.79c1.44 2.83 3.76 5.14 6.59 6.59l2.2-2.2c.27-.27.67-.36 1.02-.24 1.12.37 2.33.57 3.57.57.55 0 1 .45 1 1V20c0 .55-.45 1-1 1-9.39 0-17-7.61-17-17 0-.55.45-1 1-1h3.5c.55 0 1 .45 1 1 0 1.25.2 2.45.57 3.57.11.35.03.74-.25 1.02l-2.2 2.2z"}),q.jsx("path",{d:"M19 6.41L17.59 5 15 7.59 12.41 5 11 6.41 13.59 9 11 11.59 12.41 13 15 10.41 17.59 13 19 11.59 16.41 9z"})]}),Si=({className:I})=>q.jsx("svg",{className:I,viewBox:"0 0 24 24",fill:"currentColor",children:q.jsx("path",{d:"M13 3a9 9 0 0 0-9 9H1l3.89 3.89.07.14L9 12H6c0-3.87 3.13-7 7-7s7 3.13 7 7-3.13 7-7 7c-1.93 0-3.68-.79-4.94-2.06l-1.42 1.42A8.954 8.954 0 0 0 13 21a9 9 0 0 0 0-18zm-1 5v5l4.28 2.54.72-1.21-3.5-2.08V8H12z"})}),Ai=({className:I})=>q.jsx("svg",{className:I,viewBox:"0 0 24 24",fill:"currentColor",children:q.jsx("path",{d:"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"})});function Ri({className:I,labels:y}){const{status:i,callNumber:p,setCallNumber:R,callHistory:t,currentCallDuration:_,startCall:h,endCall:l}=il(),[g,c]=ae.useState(!1),S={...Vl,...y},E=(()=>{switch(i){case"progress":return{text:`${S.calling}...`,color:"text-yellow-500",Icon:Ti};case"confirmed":return{text:`${S.inCall} - ${_t(_)}`,color:"text-green-500",Icon:Ci};case"failed":return{text:S.callEnded,color:"text-red-500",Icon:al};case"ended":return{text:S.callEnded,color:"text-gray-500",Icon:dt};default:return{text:S.inactive,color:"text-gray-300",Icon:vs}}})();return q.jsxs("div",{className:gs("tbi-phone w-full max-w-md mx-auto bg-white rounded-2xl shadow-lg border border-gray-200 p-2",I),children:[i==="disconnected"&&q.jsxs("div",{className:"flex gap-2 items-center",children:[q.jsx("button",{onClick:()=>c(!0),className:"h-8 w-8 flex items-center justify-center rounded-xl border border-gray-200 hover:bg-gray-50 transition-colors",type:"button",children:q.jsx(Si,{className:"w-4 h-4"})}),q.jsx("input",{type:"text",value:p,onChange:N=>R(N.target.value),onKeyDown:N=>{N.key==="Enter"&&h(p)},placeholder:S.placeholder,className:"flex-1 h-8 px-3 rounded-xl border border-gray-200 text-sm focus:outline-none focus:ring-2 focus:ring-green-500 focus:border-transparent"}),q.jsx("button",{onClick:()=>h(p),disabled:p.length<9,className:"h-8 w-8 flex items-center justify-center rounded-xl bg-green-500 hover:bg-green-600 disabled:bg-gray-300 disabled:cursor-not-allowed text-white transition-colors",type:"button",children:q.jsx(vs,{className:"w-4 h-4"})})]}),i==="progress"&&q.jsxs("div",{className:"flex flex-col items-center gap-3 py-6",children:[q.jsxs("div",{className:"relative",children:[q.jsx(E.Icon,{className:"w-12 h-12 text-yellow-500 animate-pulse"}),q.jsx("div",{className:"absolute inset-0 rounded-full border-4 border-yellow-500/30 animate-ping"})]}),q.jsxs("div",{className:"text-center",children:[q.jsxs("p",{className:"text-base font-semibold",children:[S.calling," ",p]}),q.jsx("p",{className:"text-sm text-gray-500",children:S.waitingResponse})]}),q.jsxs("button",{onClick:l,className:"flex items-center gap-2 px-6 py-2 rounded-full bg-red-500 hover:bg-red-600 text-white text-sm font-medium transition-colors",type:"button",children:[q.jsx(dt,{className:"w-4 h-4"}),S.cancel]})]}),i==="confirmed"&&q.jsxs("div",{className:"flex flex-col items-center gap-4 py-6",children:[q.jsxs("div",{className:"relative",children:[q.jsx(E.Icon,{className:"w-12 h-12 text-green-500"}),q.jsx("div",{className:"absolute inset-0 rounded-full bg-green-500/20 animate-pulse"})]}),q.jsxs("div",{className:"text-center space-y-1",children:[q.jsx("p",{className:"text-xl font-bold",children:p}),q.jsx("p",{className:"text-2xl font-mono text-green-600 tabular-nums",children:_t(_)})]}),q.jsxs("button",{onClick:l,className:"flex items-center gap-2 px-6 py-2 rounded-full bg-red-500 hover:bg-red-600 text-white text-sm font-medium transition-colors",type:"button",children:[q.jsx(dt,{className:"w-4 h-4"}),S.hangUp]})]}),(i==="failed"||i==="ended")&&q.jsxs("div",{className:"flex flex-col items-center gap-3 py-6",children:[q.jsx(E.Icon,{className:gs("w-12 h-12",i==="failed"?"text-red-500":"text-gray-500")}),q.jsx("div",{className:"text-center",children:q.jsx("p",{className:"text-base font-semibold",children:E.text})})]}),g&&q.jsxs("div",{className:"fixed inset-0 z-50 flex",children:[q.jsx("div",{className:"fixed inset-0 bg-black/50",onClick:()=>c(!1)}),q.jsx("div",{className:"fixed right-0 top-0 h-full w-full max-w-md bg-white shadow-xl",children:q.jsxs("div",{className:"flex flex-col h-full",children:[q.jsxs("div",{className:"flex items-center justify-between p-4 border-b",children:[q.jsxs("div",{children:[q.jsx("h2",{className:"text-lg font-semibold",children:S.callHistory}),q.jsx("p",{className:"text-sm text-gray-500",children:t.length===0?S.noCallsRegistered:`${t.length} ${S.callsRegistered}`})]}),q.jsx("button",{onClick:()=>c(!1),className:"h-8 w-8 flex items-center justify-center rounded-lg hover:bg-gray-100 transition-colors",type:"button",children:q.jsx(Ai,{className:"w-5 h-5"})})]}),q.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:t.length===0?q.jsxs("div",{className:"text-center py-12 text-gray-500",children:[q.jsx(dt,{className:"w-12 h-12 mx-auto mb-2 opacity-50"}),q.jsx("p",{children:S.noCalls})]}):q.jsx("div",{className:"space-y-2",children:t.map((N,$)=>q.jsx(bi,{entry:N,index:$,onCall:()=>{R(N.number),c(!1),h(N.number)}},N.id))})})]})})]})]})}function bi({entry:I,index:y,onCall:i}){const p=()=>{switch(I.status){case"completed":return q.jsx(vi,{className:"w-4 h-4 text-green-600"});case"failed":return q.jsx(Ei,{className:"w-4 h-4 text-red-600"});case"missed":return q.jsx(al,{className:"w-4 h-4 text-yellow-600"})}},R=()=>{switch(I.status){case"completed":return"bg-green-100";case"failed":return"bg-red-100";case"missed":return"bg-yellow-100"}};return q.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg hover:bg-gray-50 transition-colors duration-200",style:{animationDelay:`${y*30}ms`},children:[q.jsx("div",{className:gs("w-9 h-9 rounded-full flex items-center justify-center shrink-0",R()),children:p()}),q.jsxs("div",{className:"flex-1 min-w-0",children:[q.jsx("p",{className:"font-medium text-sm truncate",children:I.number}),q.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500",children:[q.jsx("span",{children:new Date(I.timestamp).toLocaleString("es-ES",{day:"2-digit",month:"2-digit",hour:"2-digit",minute:"2-digit"})}),I.duration>0&&q.jsxs(q.Fragment,{children:[q.jsx("span",{children:"•"}),q.jsx("span",{className:"font-mono tabular-nums",children:_t(I.duration)})]})]})]}),q.jsx("button",{onClick:i,className:"h-8 w-8 flex items-center justify-center shrink-0 rounded-lg hover:bg-gray-100 transition-colors",type:"button",children:q.jsx(vs,{className:"w-4 h-4"})})]})}function wi({config:I,className:y,onCallStart:i,onCallEnd:p,onStatusChange:R,labels:t}){return q.jsx(ll,{config:I,onCallStart:i,onCallEnd:p,onStatusChange:R,children:q.jsx(Ri,{className:y,labels:t})})}exports.Phone=wi;exports.PhoneProvider=ll;exports.formatDuration=_t;exports.usePhone=il;