opensips-js 0.1.14 → 0.1.16

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.
@@ -1,6 +1,6 @@
1
- (function(Nt,Mt){typeof exports=="object"&&typeof module<"u"?Mt(exports):typeof define=="function"&&define.amd?define(["exports"],Mt):(Nt=typeof globalThis<"u"?globalThis:Nt||self,Mt(Nt.OpensipsJS={}))})(this,function(Nt){"use strict";var Zv=Object.defineProperty;var eS=(Nt,Mt,Me)=>Mt in Nt?Zv(Nt,Mt,{enumerable:!0,configurable:!0,writable:!0,value:Me}):Nt[Mt]=Me;var ts=(Nt,Mt,Me)=>(eS(Nt,typeof Mt!="symbol"?Mt+"":Mt,Me),Me);var Mt=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Me(c){return c&&c.__esModule&&Object.prototype.hasOwnProperty.call(c,"default")?c.default:c}const Tl={name:"jssip",title:"JsSIP",description:"the Javascript SIP library",version:"3.10.0",homepage:"https://jssip.net",contributors:["José Luis Millán <jmillan@aliax.net> (https://github.com/jmillan)","Iñaki Baz Castillo <ibc@aliax.net> (https://inakibaz.me)"],types:"lib/JsSIP.d.ts",main:"lib-es5/JsSIP.js",keywords:["sip","websocket","webrtc","node","browser","library"],license:"MIT",repository:{type:"git",url:"https://github.com/versatica/JsSIP.git"},bugs:{url:"https://github.com/versatica/JsSIP/issues"},dependencies:{"@types/events":"^3.0.0","@types/debug":"^4.1.7",debug:"^4.3.1",events:"^3.3.0","sdp-transform":"^2.14.1"},devDependencies:{"@babel/core":"^7.19.6","@babel/preset-env":"^7.19.4","ansi-colors":"^3.2.4",browserify:"^16.5.1",eslint:"^5.16.0","fancy-log":"^1.3.3",gulp:"^4.0.2","gulp-babel":"^8.0.0","gulp-eslint":"^5.0.0","gulp-expect-file":"^1.0.2","gulp-header":"^2.0.9","gulp-nodeunit-runner":"^0.2.2","gulp-plumber":"^1.2.1","gulp-rename":"^1.4.0","gulp-uglify-es":"^1.0.4",pegjs:"^0.7.0","vinyl-buffer":"^1.0.1","vinyl-source-stream":"^2.0.0"},scripts:{lint:"node npm-scripts.js lint",test:"node npm-scripts.js test",prepublish:"node npm-scripts.js prepublish",release:"node npm-scripts.js release"}};var Ku=Tl,st={USER_AGENT:"".concat(Ku.title," ").concat(Ku.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};function vl(c){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?vl=function(n){return typeof n}:vl=function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},vl(c)}function Sl(c,t){if(!(c instanceof t))throw new TypeError("Cannot call a class as a function")}function El(c,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");c.prototype=Object.create(t&&t.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),t&&Er(c,t)}function yl(c){var t=Yu();return function(){var a=yr(c),o;if(t){var s=yr(this).constructor;o=Reflect.construct(a,arguments,s)}else o=a.apply(this,arguments);return Hh(this,o)}}function Hh(c,t){return t&&(vl(t)==="object"||typeof t=="function")?t:Fh(c)}function Fh(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function On(c){var t=typeof Map=="function"?new Map:void 0;return On=function(a){if(a===null||!jh(a))return a;if(typeof a!="function")throw new TypeError("Super expression must either be null or a function");if(typeof t<"u"){if(t.has(a))return t.get(a);t.set(a,o)}function o(){return Cl(a,arguments,yr(this).constructor)}return o.prototype=Object.create(a.prototype,{constructor:{value:o,enumerable:!1,writable:!0,configurable:!0}}),Er(o,a)},On(c)}function Cl(c,t,n){return Yu()?Cl=Reflect.construct:Cl=function(o,s,r){var d=[null];d.push.apply(d,s);var h=Function.bind.apply(o,d),_=new h;return r&&Er(_,r.prototype),_},Cl.apply(null,arguments)}function Yu(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function jh(c){return Function.toString.call(c).indexOf("[native code]")!==-1}function Er(c,t){return Er=Object.setPrototypeOf||function(a,o){return a.__proto__=o,a},Er(c,t)}function yr(c){return yr=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},yr(c)}var Vh=function(c){El(n,c);var t=yl(n);function n(a,o){var s;return Sl(this,n),s=t.call(this),s.code=1,s.name="CONFIGURATION_ERROR",s.parameter=a,s.value=o,s.message=s.value?"Invalid value ".concat(JSON.stringify(s.value),' for parameter "').concat(s.parameter,'"'):"Missing parameter: ".concat(s.parameter),s}return n}(On(Error)),qh=function(c){El(n,c);var t=yl(n);function n(a){var o;return Sl(this,n),o=t.call(this),o.code=2,o.name="INVALID_STATE_ERROR",o.status=a,o.message="Invalid status: ".concat(a),o}return n}(On(Error)),Bh=function(c){El(n,c);var t=yl(n);function n(a){var o;return Sl(this,n),o=t.call(this),o.code=3,o.name="NOT_SUPPORTED_ERROR",o.message=a,o}return n}(On(Error)),Gh=function(c){El(n,c);var t=yl(n);function n(a){var o;return Sl(this,n),o=t.call(this),o.code=4,o.name="NOT_READY_ERROR",o.message=a,o}return n}(On(Error)),Is={ConfigurationError:Vh,InvalidStateError:qh,NotSupportedError:Bh,NotReadyError:Gh},Qe={},za,Ju;function Xa(){if(Ju)return za;Ju=1;function c(s,r){if(!(s instanceof r))throw new TypeError("Cannot call a class as a function")}function t(s,r){for(var d=0;d<r.length;d++){var h=r[d];h.enumerable=h.enumerable||!1,h.configurable=!0,"value"in h&&(h.writable=!0),Object.defineProperty(s,h.key,h)}}function n(s,r,d){return r&&t(s.prototype,r),d&&t(s,d),s}var a=bs(),o=ss();return za=function(){n(s,null,[{key:"parse",value:function(d){if(d=o.parse(d,"Name_Addr_Header"),d!==-1)return d}}]);function s(r,d,h){if(c(this,s),!r||!(r instanceof a))throw new TypeError('missing or invalid "uri" parameter');this._uri=r,this._parameters={},this.display_name=d;for(var _ in h)Object.prototype.hasOwnProperty.call(h,_)&&this.setParam(_,h[_])}return n(s,[{key:"setParam",value:function(d,h){d&&(this._parameters[d.toLowerCase()]=typeof h>"u"||h===null?null:h.toString())}},{key:"getParam",value:function(d){if(d)return this._parameters[d.toLowerCase()]}},{key:"hasParam",value:function(d){if(d)return this._parameters.hasOwnProperty(d.toLowerCase())&&!0||!1}},{key:"deleteParam",value:function(d){if(d=d.toLowerCase(),this._parameters.hasOwnProperty(d)){var h=this._parameters[d];return delete this._parameters[d],h}}},{key:"clearParams",value:function(){this._parameters={}}},{key:"clone",value:function(){return new s(this._uri.clone(),this._display_name,JSON.parse(JSON.stringify(this._parameters)))}},{key:"_quote",value:function(d){return d.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}},{key:"toString",value:function(){var d=this._display_name?'"'.concat(this._quote(this._display_name),'" '):"";d+="<".concat(this._uri.toString(),">");for(var h in this._parameters)Object.prototype.hasOwnProperty.call(this._parameters,h)&&(d+=";".concat(h),this._parameters[h]!==null&&(d+="=".concat(this._parameters[h])));return d}},{key:"uri",get:function(){return this._uri}},{key:"display_name",get:function(){return this._display_name},set:function(d){this._display_name=d===0?"0":d}}]),s}(),za}var Qa,zu;function ss(){return zu||(zu=1,Qa=function(){function c(n){return'"'+n.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 t={parse:function(a,o){var s={CRLF:g,DIGIT:T,ALPHA:S,HEXDIG:E,WSP:C,OCTET:A,DQUOTE:R,SP:k,HTAB:M,alphanum:ie,reserved:N,unreserved:j,mark:Ee,escaped:ve,LWS:L,SWS:D,HCOLON:B,TEXT_UTF8_TRIM:q,TEXT_UTF8char:J,UTF8_NONASCII:F,UTF8_CONT:Z,LHEX:U,token:x,token_nodot:se,separators:it,word:ee,STAR:Y,SLASH:G,EQUAL:re,LPAREN:ge,RPAREN:be,RAQUOT:ke,LAQUOT:Re,COMMA:ae,SEMI:ye,COLON:lt,LDQUOT:ot,RDQUOT:Se,comment:Ce,ctext:Ie,quoted_string:Oe,quoted_string_clean:pe,qdtext:de,quoted_pair:_e,SIP_URI_noparams:we,SIP_URI:Ne,uri_scheme:tt,uri_scheme_sips:He,uri_scheme_sip:qt,userinfo:At,user:qn,user_unreserved:Bn,password:un,hostport:as,host:Cs,hostname:cn,domainlabel:Gn,toplabel:Wn,IPv6reference:fn,IPv6address:me,h16:oe,ls32:ut,IPv4address:es,dec_octet:$s,port:oi,uri_parameters:Kn,uri_parameter:Yn,transport_param:ui,user_param:ci,method_param:fi,ttl_param:hi,maddr_param:di,lr_param:_i,other_param:pi,pname:mi,pvalue:Hs,paramchar:Fs,param_unreserved:gi,headers:hn,header:dn,hname:Ti,hvalue:js,hnv_unreserved:_n,Request_Response:wa,Request_Line:vi,Request_URI:Jn,absoluteURI:zn,hier_part:Si,net_path:pn,abs_path:mn,opaque_part:Vs,uric:qs,uric_no_slash:Ei,path_segments:gn,segment:Bs,param:As,pchar:Gs,scheme:yi,authority:Ci,srvr:Ai,reg_name:Ri,query:Xn,SIP_Version:Qn,INVITEm:Ii,ACKm:bi,OPTIONSm:wi,BYEm:Oi,CANCELm:Di,REGISTERm:Ni,SUBSCRIBEm:Ui,NOTIFYm:xi,REFERm:Tn,Method:vn,Status_Line:Pi,Status_Code:ki,extension_code:Mi,Reason_Phrase:Oa,Allow_Events:Du,Call_ID:Nu,Contact:Zn,contact_param:Bt,name_addr:Gt,display_name:Ws,contact_params:er,c_p_q:Li,c_p_expires:os,delta_seconds:us,qvalue:Je,generic_param:ze,gen_value:Da,Content_Disposition:Na,disp_type:tr,disp_param:sr,handling_param:Ua,Content_Encoding:Uu,Content_Length:xu,Content_Type:xa,media_type:$i,m_type:Hi,discrete_type:Fi,composite_type:Sn,extension_token:En,x_token:ji,m_subtype:nr,m_parameter:rr,m_value:Pa,CSeq:ka,CSeq_value:Ma,Expires:Pu,Event:yn,event_type:Cn,From:Vi,from_param:An,tag_param:qi,Max_Forwards:ku,Min_Expires:Mu,Name_Addr_Header:Lu,Proxy_Authenticate:Bi,challenge:ir,other_challenge:Ks,auth_param:cs,digest_cln:Rn,realm:Gi,realm_value:Wi,domain:In,URI:bn,nonce:Ki,nonce_value:Yi,opaque:Ji,stale:zi,algorithm:Xi,qop_options:wn,qop_value:lr,Proxy_Require:$u,Record_Route:ar,rec_route:or,Reason:Qi,reason_param:ur,reason_cause:La,Require:Hu,Route:cr,route_param:fr,Subscription_State:$a,substate_value:hr,subexp_params:dr,event_reason_value:Ha,Subject:Fu,Supported:ju,To:Zi,to_param:el,Via:_r,via_param:Ys,via_params:pr,via_ttl:tl,via_maddr:sl,via_received:nl,via_branch:rl,response_port:il,rport:ll,sent_protocol:al,protocol_name:ol,transport:ul,sent_by:cl,via_host:fl,via_port:mr,ttl:hl,WWW_Authenticate:Vu,Session_Expires:Fa,s_e_expires:gr,s_e_params:Tr,s_e_refresher:ja,extension_header:Va,header_value:qa,message_body:qu,uuid_URI:Ba,uuid:Wt,hex4:Kt,hex8:dl,hex12:Ga,Refer_To:Bu,Replaces:Wa,call_id:vr,replaces_param:Sr,to_tag:_l,from_tag:pl,early_flag:Ka};if(o!==void 0){if(s[o]===void 0)throw new Error("Invalid rule name: "+c(o)+".")}else o="CRLF";var r=0,d=0,h=[];function _(e){r<d||(r>d&&(d=r,h=[]),h.push(e))}function g(){var e;return a.substr(r,2)===`\r
1
+ (function(Nt,Mt){typeof exports=="object"&&typeof module<"u"?Mt(exports):typeof define=="function"&&define.amd?define(["exports"],Mt):(Nt=typeof globalThis<"u"?globalThis:Nt||self,Mt(Nt.OpensipsJS={}))})(this,function(Nt){"use strict";var Qv=Object.defineProperty;var Zv=(Nt,Mt,Me)=>Mt in Nt?Qv(Nt,Mt,{enumerable:!0,configurable:!0,writable:!0,value:Me}):Nt[Mt]=Me;var ts=(Nt,Mt,Me)=>(Zv(Nt,typeof Mt!="symbol"?Mt+"":Mt,Me),Me);var Mt=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Me(c){return c&&c.__esModule&&Object.prototype.hasOwnProperty.call(c,"default")?c.default:c}const Tl={name:"jssip",title:"JsSIP",description:"the Javascript SIP library",version:"3.10.0",homepage:"https://jssip.net",contributors:["José Luis Millán <jmillan@aliax.net> (https://github.com/jmillan)","Iñaki Baz Castillo <ibc@aliax.net> (https://inakibaz.me)"],types:"lib/JsSIP.d.ts",main:"lib-es5/JsSIP.js",keywords:["sip","websocket","webrtc","node","browser","library"],license:"MIT",repository:{type:"git",url:"https://github.com/versatica/JsSIP.git"},bugs:{url:"https://github.com/versatica/JsSIP/issues"},dependencies:{"@types/events":"^3.0.0","@types/debug":"^4.1.7",debug:"^4.3.1",events:"^3.3.0","sdp-transform":"^2.14.1"},devDependencies:{"@babel/core":"^7.19.6","@babel/preset-env":"^7.19.4","ansi-colors":"^3.2.4",browserify:"^16.5.1",eslint:"^5.16.0","fancy-log":"^1.3.3",gulp:"^4.0.2","gulp-babel":"^8.0.0","gulp-eslint":"^5.0.0","gulp-expect-file":"^1.0.2","gulp-header":"^2.0.9","gulp-nodeunit-runner":"^0.2.2","gulp-plumber":"^1.2.1","gulp-rename":"^1.4.0","gulp-uglify-es":"^1.0.4",pegjs:"^0.7.0","vinyl-buffer":"^1.0.1","vinyl-source-stream":"^2.0.0"},scripts:{lint:"node npm-scripts.js lint",test:"node npm-scripts.js test",prepublish:"node npm-scripts.js prepublish",release:"node npm-scripts.js release"}};var Ku=Tl,st={USER_AGENT:"".concat(Ku.title," ").concat(Ku.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};function vl(c){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?vl=function(n){return typeof n}:vl=function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},vl(c)}function Sl(c,t){if(!(c instanceof t))throw new TypeError("Cannot call a class as a function")}function El(c,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");c.prototype=Object.create(t&&t.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),t&&Er(c,t)}function yl(c){var t=Yu();return function(){var a=yr(c),o;if(t){var s=yr(this).constructor;o=Reflect.construct(a,arguments,s)}else o=a.apply(this,arguments);return Hh(this,o)}}function Hh(c,t){return t&&(vl(t)==="object"||typeof t=="function")?t:Fh(c)}function Fh(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function On(c){var t=typeof Map=="function"?new Map:void 0;return On=function(a){if(a===null||!jh(a))return a;if(typeof a!="function")throw new TypeError("Super expression must either be null or a function");if(typeof t<"u"){if(t.has(a))return t.get(a);t.set(a,o)}function o(){return Cl(a,arguments,yr(this).constructor)}return o.prototype=Object.create(a.prototype,{constructor:{value:o,enumerable:!1,writable:!0,configurable:!0}}),Er(o,a)},On(c)}function Cl(c,t,n){return Yu()?Cl=Reflect.construct:Cl=function(o,s,r){var d=[null];d.push.apply(d,s);var h=Function.bind.apply(o,d),_=new h;return r&&Er(_,r.prototype),_},Cl.apply(null,arguments)}function Yu(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function jh(c){return Function.toString.call(c).indexOf("[native code]")!==-1}function Er(c,t){return Er=Object.setPrototypeOf||function(a,o){return a.__proto__=o,a},Er(c,t)}function yr(c){return yr=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},yr(c)}var Vh=function(c){El(n,c);var t=yl(n);function n(a,o){var s;return Sl(this,n),s=t.call(this),s.code=1,s.name="CONFIGURATION_ERROR",s.parameter=a,s.value=o,s.message=s.value?"Invalid value ".concat(JSON.stringify(s.value),' for parameter "').concat(s.parameter,'"'):"Missing parameter: ".concat(s.parameter),s}return n}(On(Error)),qh=function(c){El(n,c);var t=yl(n);function n(a){var o;return Sl(this,n),o=t.call(this),o.code=2,o.name="INVALID_STATE_ERROR",o.status=a,o.message="Invalid status: ".concat(a),o}return n}(On(Error)),Bh=function(c){El(n,c);var t=yl(n);function n(a){var o;return Sl(this,n),o=t.call(this),o.code=3,o.name="NOT_SUPPORTED_ERROR",o.message=a,o}return n}(On(Error)),Gh=function(c){El(n,c);var t=yl(n);function n(a){var o;return Sl(this,n),o=t.call(this),o.code=4,o.name="NOT_READY_ERROR",o.message=a,o}return n}(On(Error)),Is={ConfigurationError:Vh,InvalidStateError:qh,NotSupportedError:Bh,NotReadyError:Gh},Qe={},za,Ju;function Xa(){if(Ju)return za;Ju=1;function c(s,r){if(!(s instanceof r))throw new TypeError("Cannot call a class as a function")}function t(s,r){for(var d=0;d<r.length;d++){var h=r[d];h.enumerable=h.enumerable||!1,h.configurable=!0,"value"in h&&(h.writable=!0),Object.defineProperty(s,h.key,h)}}function n(s,r,d){return r&&t(s.prototype,r),d&&t(s,d),s}var a=bs(),o=ss();return za=function(){n(s,null,[{key:"parse",value:function(d){if(d=o.parse(d,"Name_Addr_Header"),d!==-1)return d}}]);function s(r,d,h){if(c(this,s),!r||!(r instanceof a))throw new TypeError('missing or invalid "uri" parameter');this._uri=r,this._parameters={},this.display_name=d;for(var _ in h)Object.prototype.hasOwnProperty.call(h,_)&&this.setParam(_,h[_])}return n(s,[{key:"setParam",value:function(d,h){d&&(this._parameters[d.toLowerCase()]=typeof h>"u"||h===null?null:h.toString())}},{key:"getParam",value:function(d){if(d)return this._parameters[d.toLowerCase()]}},{key:"hasParam",value:function(d){if(d)return this._parameters.hasOwnProperty(d.toLowerCase())&&!0||!1}},{key:"deleteParam",value:function(d){if(d=d.toLowerCase(),this._parameters.hasOwnProperty(d)){var h=this._parameters[d];return delete this._parameters[d],h}}},{key:"clearParams",value:function(){this._parameters={}}},{key:"clone",value:function(){return new s(this._uri.clone(),this._display_name,JSON.parse(JSON.stringify(this._parameters)))}},{key:"_quote",value:function(d){return d.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}},{key:"toString",value:function(){var d=this._display_name?'"'.concat(this._quote(this._display_name),'" '):"";d+="<".concat(this._uri.toString(),">");for(var h in this._parameters)Object.prototype.hasOwnProperty.call(this._parameters,h)&&(d+=";".concat(h),this._parameters[h]!==null&&(d+="=".concat(this._parameters[h])));return d}},{key:"uri",get:function(){return this._uri}},{key:"display_name",get:function(){return this._display_name},set:function(d){this._display_name=d===0?"0":d}}]),s}(),za}var Qa,zu;function ss(){return zu||(zu=1,Qa=function(){function c(n){return'"'+n.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 t={parse:function(a,o){var s={CRLF:g,DIGIT:T,ALPHA:S,HEXDIG:E,WSP:C,OCTET:A,DQUOTE:R,SP:k,HTAB:M,alphanum:ie,reserved:N,unreserved:j,mark:Ee,escaped:ve,LWS:L,SWS:D,HCOLON:B,TEXT_UTF8_TRIM:q,TEXT_UTF8char:J,UTF8_NONASCII:F,UTF8_CONT:Z,LHEX:U,token:x,token_nodot:se,separators:it,word:ee,STAR:Y,SLASH:G,EQUAL:re,LPAREN:ge,RPAREN:be,RAQUOT:ke,LAQUOT:Re,COMMA:ae,SEMI:ye,COLON:lt,LDQUOT:ot,RDQUOT:Se,comment:Ce,ctext:Ie,quoted_string:Oe,quoted_string_clean:pe,qdtext:de,quoted_pair:_e,SIP_URI_noparams:we,SIP_URI:Ne,uri_scheme:tt,uri_scheme_sips:He,uri_scheme_sip:qt,userinfo:At,user:qn,user_unreserved:Bn,password:un,hostport:as,host:Cs,hostname:cn,domainlabel:Gn,toplabel:Wn,IPv6reference:fn,IPv6address:me,h16:oe,ls32:ut,IPv4address:es,dec_octet:$s,port:oi,uri_parameters:Kn,uri_parameter:Yn,transport_param:ui,user_param:ci,method_param:fi,ttl_param:hi,maddr_param:di,lr_param:_i,other_param:pi,pname:mi,pvalue:Hs,paramchar:Fs,param_unreserved:gi,headers:hn,header:dn,hname:Ti,hvalue:js,hnv_unreserved:_n,Request_Response:wa,Request_Line:vi,Request_URI:Jn,absoluteURI:zn,hier_part:Si,net_path:pn,abs_path:mn,opaque_part:Vs,uric:qs,uric_no_slash:Ei,path_segments:gn,segment:Bs,param:As,pchar:Gs,scheme:yi,authority:Ci,srvr:Ai,reg_name:Ri,query:Xn,SIP_Version:Qn,INVITEm:Ii,ACKm:bi,OPTIONSm:wi,BYEm:Oi,CANCELm:Di,REGISTERm:Ni,SUBSCRIBEm:Ui,NOTIFYm:xi,REFERm:Tn,Method:vn,Status_Line:Pi,Status_Code:ki,extension_code:Mi,Reason_Phrase:Oa,Allow_Events:Du,Call_ID:Nu,Contact:Zn,contact_param:Bt,name_addr:Gt,display_name:Ws,contact_params:er,c_p_q:Li,c_p_expires:os,delta_seconds:us,qvalue:Je,generic_param:ze,gen_value:Da,Content_Disposition:Na,disp_type:tr,disp_param:sr,handling_param:Ua,Content_Encoding:Uu,Content_Length:xu,Content_Type:xa,media_type:$i,m_type:Hi,discrete_type:Fi,composite_type:Sn,extension_token:En,x_token:ji,m_subtype:nr,m_parameter:rr,m_value:Pa,CSeq:ka,CSeq_value:Ma,Expires:Pu,Event:yn,event_type:Cn,From:Vi,from_param:An,tag_param:qi,Max_Forwards:ku,Min_Expires:Mu,Name_Addr_Header:Lu,Proxy_Authenticate:Bi,challenge:ir,other_challenge:Ks,auth_param:cs,digest_cln:Rn,realm:Gi,realm_value:Wi,domain:In,URI:bn,nonce:Ki,nonce_value:Yi,opaque:Ji,stale:zi,algorithm:Xi,qop_options:wn,qop_value:lr,Proxy_Require:$u,Record_Route:ar,rec_route:or,Reason:Qi,reason_param:ur,reason_cause:La,Require:Hu,Route:cr,route_param:fr,Subscription_State:$a,substate_value:hr,subexp_params:dr,event_reason_value:Ha,Subject:Fu,Supported:ju,To:Zi,to_param:el,Via:_r,via_param:Ys,via_params:pr,via_ttl:tl,via_maddr:sl,via_received:nl,via_branch:rl,response_port:il,rport:ll,sent_protocol:al,protocol_name:ol,transport:ul,sent_by:cl,via_host:fl,via_port:mr,ttl:hl,WWW_Authenticate:Vu,Session_Expires:Fa,s_e_expires:gr,s_e_params:Tr,s_e_refresher:ja,extension_header:Va,header_value:qa,message_body:qu,uuid_URI:Ba,uuid:Wt,hex4:Kt,hex8:dl,hex12:Ga,Refer_To:Bu,Replaces:Wa,call_id:vr,replaces_param:Sr,to_tag:_l,from_tag:pl,early_flag:Ka};if(o!==void 0){if(s[o]===void 0)throw new Error("Invalid rule name: "+c(o)+".")}else o="CRLF";var r=0,d=0,h=[];function _(e){r<d||(r>d&&(d=r,h=[]),h.push(e))}function g(){var e;return a.substr(r,2)===`\r
2
2
  `?(e=`\r
3
- `,r+=2):(e=null,_('"\\r\\n"')),e}function T(){var e;return/^[0-9]/.test(a.charAt(r))?(e=a.charAt(r),r++):(e=null,_("[0-9]")),e}function S(){var e;return/^[a-zA-Z]/.test(a.charAt(r))?(e=a.charAt(r),r++):(e=null,_("[a-zA-Z]")),e}function E(){var e;return/^[0-9a-fA-F]/.test(a.charAt(r))?(e=a.charAt(r),r++):(e=null,_("[0-9a-fA-F]")),e}function C(){var e;return e=k(),e===null&&(e=M()),e}function A(){var e;return/^[\0-\xFF]/.test(a.charAt(r))?(e=a.charAt(r),r++):(e=null,_("[\\0-\\xFF]")),e}function R(){var e;return/^["]/.test(a.charAt(r))?(e=a.charAt(r),r++):(e=null,_('["]')),e}function k(){var e;return a.charCodeAt(r)===32?(e=" ",r++):(e=null,_('" "')),e}function M(){var e;return a.charCodeAt(r)===9?(e=" ",r++):(e=null,_('"\\t"')),e}function ie(){var e;return/^[a-zA-Z0-9]/.test(a.charAt(r))?(e=a.charAt(r),r++):(e=null,_("[a-zA-Z0-9]")),e}function N(){var e;return a.charCodeAt(r)===59?(e=";",r++):(e=null,_('";"')),e===null&&(a.charCodeAt(r)===47?(e="/",r++):(e=null,_('"/"')),e===null&&(a.charCodeAt(r)===63?(e="?",r++):(e=null,_('"?"')),e===null&&(a.charCodeAt(r)===58?(e=":",r++):(e=null,_('":"')),e===null&&(a.charCodeAt(r)===64?(e="@",r++):(e=null,_('"@"')),e===null&&(a.charCodeAt(r)===38?(e="&",r++):(e=null,_('"&"')),e===null&&(a.charCodeAt(r)===61?(e="=",r++):(e=null,_('"="')),e===null&&(a.charCodeAt(r)===43?(e="+",r++):(e=null,_('"+"')),e===null&&(a.charCodeAt(r)===36?(e="$",r++):(e=null,_('"$"')),e===null&&(a.charCodeAt(r)===44?(e=",",r++):(e=null,_('","'))))))))))),e}function j(){var e;return e=ie(),e===null&&(e=Ee()),e}function Ee(){var e;return a.charCodeAt(r)===45?(e="-",r++):(e=null,_('"-"')),e===null&&(a.charCodeAt(r)===95?(e="_",r++):(e=null,_('"_"')),e===null&&(a.charCodeAt(r)===46?(e=".",r++):(e=null,_('"."')),e===null&&(a.charCodeAt(r)===33?(e="!",r++):(e=null,_('"!"')),e===null&&(a.charCodeAt(r)===126?(e="~",r++):(e=null,_('"~"')),e===null&&(a.charCodeAt(r)===42?(e="*",r++):(e=null,_('"*"')),e===null&&(a.charCodeAt(r)===39?(e="'",r++):(e=null,_(`"'"`)),e===null&&(a.charCodeAt(r)===40?(e="(",r++):(e=null,_('"("')),e===null&&(a.charCodeAt(r)===41?(e=")",r++):(e=null,_('")"')))))))))),e}function ve(){var e,l,u,f,p;return f=r,p=r,a.charCodeAt(r)===37?(e="%",r++):(e=null,_('"%"')),e!==null?(l=E(),l!==null?(u=E(),u!==null?e=[e,l,u]:(e=null,r=p)):(e=null,r=p)):(e=null,r=p),e!==null&&(e=function(m,v){return v.join("")}(f,e)),e===null&&(r=f),e}function L(){var e,l,u,f,p,m;for(f=r,p=r,m=r,e=[],l=C();l!==null;)e.push(l),l=C();if(e!==null?(l=g(),l!==null?e=[e,l]:(e=null,r=m)):(e=null,r=m),e=e!==null?e:"",e!==null){if(u=C(),u!==null)for(l=[];u!==null;)l.push(u),u=C();else l=null;l!==null?e=[e,l]:(e=null,r=p)}else e=null,r=p;return e!==null&&(e=function(v){return" "}()),e===null&&(r=f),e}function D(){var e;return e=L(),e=e!==null?e:"",e}function B(){var e,l,u,f,p;for(f=r,p=r,e=[],l=k(),l===null&&(l=M());l!==null;)e.push(l),l=k(),l===null&&(l=M());return e!==null?(a.charCodeAt(r)===58?(l=":",r++):(l=null,_('":"')),l!==null?(u=D(),u!==null?e=[e,l,u]:(e=null,r=p)):(e=null,r=p)):(e=null,r=p),e!==null&&(e=function(m){return":"}()),e===null&&(r=f),e}function q(){var e,l,u,f,p,m,v;if(p=r,m=r,l=J(),l!==null)for(e=[];l!==null;)e.push(l),l=J();else e=null;if(e!==null){for(l=[],v=r,u=[],f=L();f!==null;)u.push(f),f=L();for(u!==null?(f=J(),f!==null?u=[u,f]:(u=null,r=v)):(u=null,r=v);u!==null;){for(l.push(u),v=r,u=[],f=L();f!==null;)u.push(f),f=L();u!==null?(f=J(),f!==null?u=[u,f]:(u=null,r=v)):(u=null,r=v)}l!==null?e=[e,l]:(e=null,r=m)}else e=null,r=m;return e!==null&&(e=function(y){return a.substring(r,y)}(p)),e===null&&(r=p),e}function J(){var e;return/^[!-~]/.test(a.charAt(r))?(e=a.charAt(r),r++):(e=null,_("[!-~]")),e===null&&(e=F()),e}function F(){var e;return/^[\x80-\uFFFF]/.test(a.charAt(r))?(e=a.charAt(r),r++):(e=null,_("[\\x80-\\uFFFF]")),e}function Z(){var e;return/^[\x80-\xBF]/.test(a.charAt(r))?(e=a.charAt(r),r++):(e=null,_("[\\x80-\\xBF]")),e}function U(){var e;return e=T(),e===null&&(/^[a-f]/.test(a.charAt(r))?(e=a.charAt(r),r++):(e=null,_("[a-f]"))),e}function x(){var e,l,u;if(u=r,l=ie(),l===null&&(a.charCodeAt(r)===45?(l="-",r++):(l=null,_('"-"')),l===null&&(a.charCodeAt(r)===46?(l=".",r++):(l=null,_('"."')),l===null&&(a.charCodeAt(r)===33?(l="!",r++):(l=null,_('"!"')),l===null&&(a.charCodeAt(r)===37?(l="%",r++):(l=null,_('"%"')),l===null&&(a.charCodeAt(r)===42?(l="*",r++):(l=null,_('"*"')),l===null&&(a.charCodeAt(r)===95?(l="_",r++):(l=null,_('"_"')),l===null&&(a.charCodeAt(r)===43?(l="+",r++):(l=null,_('"+"')),l===null&&(a.charCodeAt(r)===96?(l="`",r++):(l=null,_('"`"')),l===null&&(a.charCodeAt(r)===39?(l="'",r++):(l=null,_(`"'"`)),l===null&&(a.charCodeAt(r)===126?(l="~",r++):(l=null,_('"~"')))))))))))),l!==null)for(e=[];l!==null;)e.push(l),l=ie(),l===null&&(a.charCodeAt(r)===45?(l="-",r++):(l=null,_('"-"')),l===null&&(a.charCodeAt(r)===46?(l=".",r++):(l=null,_('"."')),l===null&&(a.charCodeAt(r)===33?(l="!",r++):(l=null,_('"!"')),l===null&&(a.charCodeAt(r)===37?(l="%",r++):(l=null,_('"%"')),l===null&&(a.charCodeAt(r)===42?(l="*",r++):(l=null,_('"*"')),l===null&&(a.charCodeAt(r)===95?(l="_",r++):(l=null,_('"_"')),l===null&&(a.charCodeAt(r)===43?(l="+",r++):(l=null,_('"+"')),l===null&&(a.charCodeAt(r)===96?(l="`",r++):(l=null,_('"`"')),l===null&&(a.charCodeAt(r)===39?(l="'",r++):(l=null,_(`"'"`)),l===null&&(a.charCodeAt(r)===126?(l="~",r++):(l=null,_('"~"'))))))))))));else e=null;return e!==null&&(e=function(f){return a.substring(r,f)}(u)),e===null&&(r=u),e}function se(){var e,l,u;if(u=r,l=ie(),l===null&&(a.charCodeAt(r)===45?(l="-",r++):(l=null,_('"-"')),l===null&&(a.charCodeAt(r)===33?(l="!",r++):(l=null,_('"!"')),l===null&&(a.charCodeAt(r)===37?(l="%",r++):(l=null,_('"%"')),l===null&&(a.charCodeAt(r)===42?(l="*",r++):(l=null,_('"*"')),l===null&&(a.charCodeAt(r)===95?(l="_",r++):(l=null,_('"_"')),l===null&&(a.charCodeAt(r)===43?(l="+",r++):(l=null,_('"+"')),l===null&&(a.charCodeAt(r)===96?(l="`",r++):(l=null,_('"`"')),l===null&&(a.charCodeAt(r)===39?(l="'",r++):(l=null,_(`"'"`)),l===null&&(a.charCodeAt(r)===126?(l="~",r++):(l=null,_('"~"'))))))))))),l!==null)for(e=[];l!==null;)e.push(l),l=ie(),l===null&&(a.charCodeAt(r)===45?(l="-",r++):(l=null,_('"-"')),l===null&&(a.charCodeAt(r)===33?(l="!",r++):(l=null,_('"!"')),l===null&&(a.charCodeAt(r)===37?(l="%",r++):(l=null,_('"%"')),l===null&&(a.charCodeAt(r)===42?(l="*",r++):(l=null,_('"*"')),l===null&&(a.charCodeAt(r)===95?(l="_",r++):(l=null,_('"_"')),l===null&&(a.charCodeAt(r)===43?(l="+",r++):(l=null,_('"+"')),l===null&&(a.charCodeAt(r)===96?(l="`",r++):(l=null,_('"`"')),l===null&&(a.charCodeAt(r)===39?(l="'",r++):(l=null,_(`"'"`)),l===null&&(a.charCodeAt(r)===126?(l="~",r++):(l=null,_('"~"')))))))))));else e=null;return e!==null&&(e=function(f){return a.substring(r,f)}(u)),e===null&&(r=u),e}function it(){var e;return a.charCodeAt(r)===40?(e="(",r++):(e=null,_('"("')),e===null&&(a.charCodeAt(r)===41?(e=")",r++):(e=null,_('")"')),e===null&&(a.charCodeAt(r)===60?(e="<",r++):(e=null,_('"<"')),e===null&&(a.charCodeAt(r)===62?(e=">",r++):(e=null,_('">"')),e===null&&(a.charCodeAt(r)===64?(e="@",r++):(e=null,_('"@"')),e===null&&(a.charCodeAt(r)===44?(e=",",r++):(e=null,_('","')),e===null&&(a.charCodeAt(r)===59?(e=";",r++):(e=null,_('";"')),e===null&&(a.charCodeAt(r)===58?(e=":",r++):(e=null,_('":"')),e===null&&(a.charCodeAt(r)===92?(e="\\",r++):(e=null,_('"\\\\"')),e===null&&(e=R(),e===null&&(a.charCodeAt(r)===47?(e="/",r++):(e=null,_('"/"')),e===null&&(a.charCodeAt(r)===91?(e="[",r++):(e=null,_('"["')),e===null&&(a.charCodeAt(r)===93?(e="]",r++):(e=null,_('"]"')),e===null&&(a.charCodeAt(r)===63?(e="?",r++):(e=null,_('"?"')),e===null&&(a.charCodeAt(r)===61?(e="=",r++):(e=null,_('"="')),e===null&&(a.charCodeAt(r)===123?(e="{",r++):(e=null,_('"{"')),e===null&&(a.charCodeAt(r)===125?(e="}",r++):(e=null,_('"}"')),e===null&&(e=k(),e===null&&(e=M())))))))))))))))))),e}function ee(){var e,l,u;if(u=r,l=ie(),l===null&&(a.charCodeAt(r)===45?(l="-",r++):(l=null,_('"-"')),l===null&&(a.charCodeAt(r)===46?(l=".",r++):(l=null,_('"."')),l===null&&(a.charCodeAt(r)===33?(l="!",r++):(l=null,_('"!"')),l===null&&(a.charCodeAt(r)===37?(l="%",r++):(l=null,_('"%"')),l===null&&(a.charCodeAt(r)===42?(l="*",r++):(l=null,_('"*"')),l===null&&(a.charCodeAt(r)===95?(l="_",r++):(l=null,_('"_"')),l===null&&(a.charCodeAt(r)===43?(l="+",r++):(l=null,_('"+"')),l===null&&(a.charCodeAt(r)===96?(l="`",r++):(l=null,_('"`"')),l===null&&(a.charCodeAt(r)===39?(l="'",r++):(l=null,_(`"'"`)),l===null&&(a.charCodeAt(r)===126?(l="~",r++):(l=null,_('"~"')),l===null&&(a.charCodeAt(r)===40?(l="(",r++):(l=null,_('"("')),l===null&&(a.charCodeAt(r)===41?(l=")",r++):(l=null,_('")"')),l===null&&(a.charCodeAt(r)===60?(l="<",r++):(l=null,_('"<"')),l===null&&(a.charCodeAt(r)===62?(l=">",r++):(l=null,_('">"')),l===null&&(a.charCodeAt(r)===58?(l=":",r++):(l=null,_('":"')),l===null&&(a.charCodeAt(r)===92?(l="\\",r++):(l=null,_('"\\\\"')),l===null&&(l=R(),l===null&&(a.charCodeAt(r)===47?(l="/",r++):(l=null,_('"/"')),l===null&&(a.charCodeAt(r)===91?(l="[",r++):(l=null,_('"["')),l===null&&(a.charCodeAt(r)===93?(l="]",r++):(l=null,_('"]"')),l===null&&(a.charCodeAt(r)===63?(l="?",r++):(l=null,_('"?"')),l===null&&(a.charCodeAt(r)===123?(l="{",r++):(l=null,_('"{"')),l===null&&(a.charCodeAt(r)===125?(l="}",r++):(l=null,_('"}"'))))))))))))))))))))))))),l!==null)for(e=[];l!==null;)e.push(l),l=ie(),l===null&&(a.charCodeAt(r)===45?(l="-",r++):(l=null,_('"-"')),l===null&&(a.charCodeAt(r)===46?(l=".",r++):(l=null,_('"."')),l===null&&(a.charCodeAt(r)===33?(l="!",r++):(l=null,_('"!"')),l===null&&(a.charCodeAt(r)===37?(l="%",r++):(l=null,_('"%"')),l===null&&(a.charCodeAt(r)===42?(l="*",r++):(l=null,_('"*"')),l===null&&(a.charCodeAt(r)===95?(l="_",r++):(l=null,_('"_"')),l===null&&(a.charCodeAt(r)===43?(l="+",r++):(l=null,_('"+"')),l===null&&(a.charCodeAt(r)===96?(l="`",r++):(l=null,_('"`"')),l===null&&(a.charCodeAt(r)===39?(l="'",r++):(l=null,_(`"'"`)),l===null&&(a.charCodeAt(r)===126?(l="~",r++):(l=null,_('"~"')),l===null&&(a.charCodeAt(r)===40?(l="(",r++):(l=null,_('"("')),l===null&&(a.charCodeAt(r)===41?(l=")",r++):(l=null,_('")"')),l===null&&(a.charCodeAt(r)===60?(l="<",r++):(l=null,_('"<"')),l===null&&(a.charCodeAt(r)===62?(l=">",r++):(l=null,_('">"')),l===null&&(a.charCodeAt(r)===58?(l=":",r++):(l=null,_('":"')),l===null&&(a.charCodeAt(r)===92?(l="\\",r++):(l=null,_('"\\\\"')),l===null&&(l=R(),l===null&&(a.charCodeAt(r)===47?(l="/",r++):(l=null,_('"/"')),l===null&&(a.charCodeAt(r)===91?(l="[",r++):(l=null,_('"["')),l===null&&(a.charCodeAt(r)===93?(l="]",r++):(l=null,_('"]"')),l===null&&(a.charCodeAt(r)===63?(l="?",r++):(l=null,_('"?"')),l===null&&(a.charCodeAt(r)===123?(l="{",r++):(l=null,_('"{"')),l===null&&(a.charCodeAt(r)===125?(l="}",r++):(l=null,_('"}"')))))))))))))))))))))))));else e=null;return e!==null&&(e=function(f){return a.substring(r,f)}(u)),e===null&&(r=u),e}function Y(){var e,l,u,f,p;return f=r,p=r,e=D(),e!==null?(a.charCodeAt(r)===42?(l="*",r++):(l=null,_('"*"')),l!==null?(u=D(),u!==null?e=[e,l,u]:(e=null,r=p)):(e=null,r=p)):(e=null,r=p),e!==null&&(e=function(m){return"*"}()),e===null&&(r=f),e}function G(){var e,l,u,f,p;return f=r,p=r,e=D(),e!==null?(a.charCodeAt(r)===47?(l="/",r++):(l=null,_('"/"')),l!==null?(u=D(),u!==null?e=[e,l,u]:(e=null,r=p)):(e=null,r=p)):(e=null,r=p),e!==null&&(e=function(m){return"/"}()),e===null&&(r=f),e}function re(){var e,l,u,f,p;return f=r,p=r,e=D(),e!==null?(a.charCodeAt(r)===61?(l="=",r++):(l=null,_('"="')),l!==null?(u=D(),u!==null?e=[e,l,u]:(e=null,r=p)):(e=null,r=p)):(e=null,r=p),e!==null&&(e=function(m){return"="}()),e===null&&(r=f),e}function ge(){var e,l,u,f,p;return f=r,p=r,e=D(),e!==null?(a.charCodeAt(r)===40?(l="(",r++):(l=null,_('"("')),l!==null?(u=D(),u!==null?e=[e,l,u]:(e=null,r=p)):(e=null,r=p)):(e=null,r=p),e!==null&&(e=function(m){return"("}()),e===null&&(r=f),e}function be(){var e,l,u,f,p;return f=r,p=r,e=D(),e!==null?(a.charCodeAt(r)===41?(l=")",r++):(l=null,_('")"')),l!==null?(u=D(),u!==null?e=[e,l,u]:(e=null,r=p)):(e=null,r=p)):(e=null,r=p),e!==null&&(e=function(m){return")"}()),e===null&&(r=f),e}function ke(){var e,l,u,f;return u=r,f=r,a.charCodeAt(r)===62?(e=">",r++):(e=null,_('">"')),e!==null?(l=D(),l!==null?e=[e,l]:(e=null,r=f)):(e=null,r=f),e!==null&&(e=function(p){return">"}()),e===null&&(r=u),e}function Re(){var e,l,u,f;return u=r,f=r,e=D(),e!==null?(a.charCodeAt(r)===60?(l="<",r++):(l=null,_('"<"')),l!==null?e=[e,l]:(e=null,r=f)):(e=null,r=f),e!==null&&(e=function(p){return"<"}()),e===null&&(r=u),e}function ae(){var e,l,u,f,p;return f=r,p=r,e=D(),e!==null?(a.charCodeAt(r)===44?(l=",",r++):(l=null,_('","')),l!==null?(u=D(),u!==null?e=[e,l,u]:(e=null,r=p)):(e=null,r=p)):(e=null,r=p),e!==null&&(e=function(m){return","}()),e===null&&(r=f),e}function ye(){var e,l,u,f,p;return f=r,p=r,e=D(),e!==null?(a.charCodeAt(r)===59?(l=";",r++):(l=null,_('";"')),l!==null?(u=D(),u!==null?e=[e,l,u]:(e=null,r=p)):(e=null,r=p)):(e=null,r=p),e!==null&&(e=function(m){return";"}()),e===null&&(r=f),e}function lt(){var e,l,u,f,p;return f=r,p=r,e=D(),e!==null?(a.charCodeAt(r)===58?(l=":",r++):(l=null,_('":"')),l!==null?(u=D(),u!==null?e=[e,l,u]:(e=null,r=p)):(e=null,r=p)):(e=null,r=p),e!==null&&(e=function(m){return":"}()),e===null&&(r=f),e}function ot(){var e,l,u,f;return u=r,f=r,e=D(),e!==null?(l=R(),l!==null?e=[e,l]:(e=null,r=f)):(e=null,r=f),e!==null&&(e=function(p){return'"'}()),e===null&&(r=u),e}function Se(){var e,l,u,f;return u=r,f=r,e=R(),e!==null?(l=D(),l!==null?e=[e,l]:(e=null,r=f)):(e=null,r=f),e!==null&&(e=function(p){return'"'}()),e===null&&(r=u),e}function Ce(){var e,l,u,f;if(f=r,e=ge(),e!==null){for(l=[],u=Ie(),u===null&&(u=_e(),u===null&&(u=Ce()));u!==null;)l.push(u),u=Ie(),u===null&&(u=_e(),u===null&&(u=Ce()));l!==null?(u=be(),u!==null?e=[e,l,u]:(e=null,r=f)):(e=null,r=f)}else e=null,r=f;return e}function Ie(){var e;return/^[!-']/.test(a.charAt(r))?(e=a.charAt(r),r++):(e=null,_("[!-']")),e===null&&(/^[*-[]/.test(a.charAt(r))?(e=a.charAt(r),r++):(e=null,_("[*-[]")),e===null&&(/^[\]-~]/.test(a.charAt(r))?(e=a.charAt(r),r++):(e=null,_("[\\]-~]")),e===null&&(e=F(),e===null&&(e=L())))),e}function Oe(){var e,l,u,f,p,m;if(p=r,m=r,e=D(),e!==null)if(l=R(),l!==null){for(u=[],f=de(),f===null&&(f=_e());f!==null;)u.push(f),f=de(),f===null&&(f=_e());u!==null?(f=R(),f!==null?e=[e,l,u,f]:(e=null,r=m)):(e=null,r=m)}else e=null,r=m;else e=null,r=m;return e!==null&&(e=function(v){return a.substring(r,v)}(p)),e===null&&(r=p),e}function pe(){var e,l,u,f,p,m;if(p=r,m=r,e=D(),e!==null)if(l=R(),l!==null){for(u=[],f=de(),f===null&&(f=_e());f!==null;)u.push(f),f=de(),f===null&&(f=_e());u!==null?(f=R(),f!==null?e=[e,l,u,f]:(e=null,r=m)):(e=null,r=m)}else e=null,r=m;else e=null,r=m;return e!==null&&(e=function(v){var y=a.substring(r,v).trim();return y.substring(1,y.length-1).replace(/\\([\x00-\x09\x0b-\x0c\x0e-\x7f])/g,"$1")}(p)),e===null&&(r=p),e}function de(){var e;return e=L(),e===null&&(a.charCodeAt(r)===33?(e="!",r++):(e=null,_('"!"')),e===null&&(/^[#-[]/.test(a.charAt(r))?(e=a.charAt(r),r++):(e=null,_("[#-[]")),e===null&&(/^[\]-~]/.test(a.charAt(r))?(e=a.charAt(r),r++):(e=null,_("[\\]-~]")),e===null&&(e=F())))),e}function _e(){var e,l,u;return u=r,a.charCodeAt(r)===92?(e="\\",r++):(e=null,_('"\\\\"')),e!==null?(/^[\0-\t]/.test(a.charAt(r))?(l=a.charAt(r),r++):(l=null,_("[\\0-\\t]")),l===null&&(/^[\x0B-\f]/.test(a.charAt(r))?(l=a.charAt(r),r++):(l=null,_("[\\x0B-\\f]")),l===null&&(/^[\x0E-]/.test(a.charAt(r))?(l=a.charAt(r),r++):(l=null,_("[\\x0E-]")))),l!==null?e=[e,l]:(e=null,r=u)):(e=null,r=u),e}function we(){var e,l,u,f,p,m;return p=r,m=r,e=tt(),e!==null?(a.charCodeAt(r)===58?(l=":",r++):(l=null,_('":"')),l!==null?(u=At(),u=u!==null?u:"",u!==null?(f=as(),f!==null?e=[e,l,u,f]:(e=null,r=m)):(e=null,r=m)):(e=null,r=m)):(e=null,r=m),e!==null&&(e=function(v){try{w.uri=new Rs(w.scheme,w.user,w.host,w.port),delete w.scheme,delete w.user,delete w.host,delete w.host_type,delete w.port}catch{w=-1}}()),e===null&&(r=p),e}function Ne(){var e,l,u,f,p,m,v,y;return v=r,y=r,e=tt(),e!==null?(a.charCodeAt(r)===58?(l=":",r++):(l=null,_('":"')),l!==null?(u=At(),u=u!==null?u:"",u!==null?(f=as(),f!==null?(p=Kn(),p!==null?(m=hn(),m=m!==null?m:"",m!==null?e=[e,l,u,f,p,m]:(e=null,r=y)):(e=null,r=y)):(e=null,r=y)):(e=null,r=y)):(e=null,r=y)):(e=null,r=y),e!==null&&(e=function(O){try{w.uri=new Rs(w.scheme,w.user,w.host,w.port,w.uri_params,w.uri_headers),delete w.scheme,delete w.user,delete w.host,delete w.host_type,delete w.port,delete w.uri_params,o==="SIP_URI"&&(w=w.uri)}catch{w=-1}}()),e===null&&(r=v),e}function tt(){var e;return e=He(),e===null&&(e=qt()),e}function He(){var e,l;return l=r,a.substr(r,4).toLowerCase()==="sips"?(e=a.substr(r,4),r+=4):(e=null,_('"sips"')),e!==null&&(e=function(u,f){w.scheme=f.toLowerCase()}(l,e)),e===null&&(r=l),e}function qt(){var e,l;return l=r,a.substr(r,3).toLowerCase()==="sip"?(e=a.substr(r,3),r+=3):(e=null,_('"sip"')),e!==null&&(e=function(u,f){w.scheme=f.toLowerCase()}(l,e)),e===null&&(r=l),e}function At(){var e,l,u,f,p,m;return f=r,p=r,e=qn(),e!==null?(m=r,a.charCodeAt(r)===58?(l=":",r++):(l=null,_('":"')),l!==null?(u=un(),u!==null?l=[l,u]:(l=null,r=m)):(l=null,r=m),l=l!==null?l:"",l!==null?(a.charCodeAt(r)===64?(u="@",r++):(u=null,_('"@"')),u!==null?e=[e,l,u]:(e=null,r=p)):(e=null,r=p)):(e=null,r=p),e!==null&&(e=function(v){w.user=decodeURIComponent(a.substring(r-1,v))}(f)),e===null&&(r=f),e}function qn(){var e,l;if(l=j(),l===null&&(l=ve(),l===null&&(l=Bn())),l!==null)for(e=[];l!==null;)e.push(l),l=j(),l===null&&(l=ve(),l===null&&(l=Bn()));else e=null;return e}function Bn(){var e;return a.charCodeAt(r)===38?(e="&",r++):(e=null,_('"&"')),e===null&&(a.charCodeAt(r)===61?(e="=",r++):(e=null,_('"="')),e===null&&(a.charCodeAt(r)===43?(e="+",r++):(e=null,_('"+"')),e===null&&(a.charCodeAt(r)===36?(e="$",r++):(e=null,_('"$"')),e===null&&(a.charCodeAt(r)===44?(e=",",r++):(e=null,_('","')),e===null&&(a.charCodeAt(r)===59?(e=";",r++):(e=null,_('";"')),e===null&&(a.charCodeAt(r)===63?(e="?",r++):(e=null,_('"?"')),e===null&&(a.charCodeAt(r)===47?(e="/",r++):(e=null,_('"/"'))))))))),e}function un(){var e,l,u;for(u=r,e=[],l=j(),l===null&&(l=ve(),l===null&&(a.charCodeAt(r)===38?(l="&",r++):(l=null,_('"&"')),l===null&&(a.charCodeAt(r)===61?(l="=",r++):(l=null,_('"="')),l===null&&(a.charCodeAt(r)===43?(l="+",r++):(l=null,_('"+"')),l===null&&(a.charCodeAt(r)===36?(l="$",r++):(l=null,_('"$"')),l===null&&(a.charCodeAt(r)===44?(l=",",r++):(l=null,_('","'))))))));l!==null;)e.push(l),l=j(),l===null&&(l=ve(),l===null&&(a.charCodeAt(r)===38?(l="&",r++):(l=null,_('"&"')),l===null&&(a.charCodeAt(r)===61?(l="=",r++):(l=null,_('"="')),l===null&&(a.charCodeAt(r)===43?(l="+",r++):(l=null,_('"+"')),l===null&&(a.charCodeAt(r)===36?(l="$",r++):(l=null,_('"$"')),l===null&&(a.charCodeAt(r)===44?(l=",",r++):(l=null,_('","'))))))));return e!==null&&(e=function(f){w.password=a.substring(r,f)}(u)),e===null&&(r=u),e}function as(){var e,l,u,f,p;return f=r,e=Cs(),e!==null?(p=r,a.charCodeAt(r)===58?(l=":",r++):(l=null,_('":"')),l!==null?(u=oi(),u!==null?l=[l,u]:(l=null,r=p)):(l=null,r=p),l=l!==null?l:"",l!==null?e=[e,l]:(e=null,r=f)):(e=null,r=f),e}function Cs(){var e,l;return l=r,e=cn(),e===null&&(e=es(),e===null&&(e=fn())),e!==null&&(e=function(u){return w.host=a.substring(r,u).toLowerCase(),w.host}(l)),e===null&&(r=l),e}function cn(){var e,l,u,f,p,m;for(f=r,p=r,e=[],m=r,l=Gn(),l!==null?(a.charCodeAt(r)===46?(u=".",r++):(u=null,_('"."')),u!==null?l=[l,u]:(l=null,r=m)):(l=null,r=m);l!==null;)e.push(l),m=r,l=Gn(),l!==null?(a.charCodeAt(r)===46?(u=".",r++):(u=null,_('"."')),u!==null?l=[l,u]:(l=null,r=m)):(l=null,r=m);return e!==null?(l=Wn(),l!==null?(a.charCodeAt(r)===46?(u=".",r++):(u=null,_('"."')),u=u!==null?u:"",u!==null?e=[e,l,u]:(e=null,r=p)):(e=null,r=p)):(e=null,r=p),e!==null&&(e=function(v){return w.host_type="domain",a.substring(r,v)}(f)),e===null&&(r=f),e}function Gn(){var e,l,u,f;if(f=r,e=ie(),e!==null){for(l=[],u=ie(),u===null&&(a.charCodeAt(r)===45?(u="-",r++):(u=null,_('"-"')),u===null&&(a.charCodeAt(r)===95?(u="_",r++):(u=null,_('"_"'))));u!==null;)l.push(u),u=ie(),u===null&&(a.charCodeAt(r)===45?(u="-",r++):(u=null,_('"-"')),u===null&&(a.charCodeAt(r)===95?(u="_",r++):(u=null,_('"_"'))));l!==null?e=[e,l]:(e=null,r=f)}else e=null,r=f;return e}function Wn(){var e,l,u,f;if(f=r,e=S(),e!==null){for(l=[],u=ie(),u===null&&(a.charCodeAt(r)===45?(u="-",r++):(u=null,_('"-"')),u===null&&(a.charCodeAt(r)===95?(u="_",r++):(u=null,_('"_"'))));u!==null;)l.push(u),u=ie(),u===null&&(a.charCodeAt(r)===45?(u="-",r++):(u=null,_('"-"')),u===null&&(a.charCodeAt(r)===95?(u="_",r++):(u=null,_('"_"'))));l!==null?e=[e,l]:(e=null,r=f)}else e=null,r=f;return e}function fn(){var e,l,u,f,p;return f=r,p=r,a.charCodeAt(r)===91?(e="[",r++):(e=null,_('"["')),e!==null?(l=me(),l!==null?(a.charCodeAt(r)===93?(u="]",r++):(u=null,_('"]"')),u!==null?e=[e,l,u]:(e=null,r=p)):(e=null,r=p)):(e=null,r=p),e!==null&&(e=function(m){return w.host_type="IPv6",a.substring(r,m)}(f)),e===null&&(r=f),e}function me(){var e,l,u,f,p,m,v,y,O,le,Ue,Dt,Js,$,I,Te;return $=r,I=r,e=oe(),e!==null?(a.charCodeAt(r)===58?(l=":",r++):(l=null,_('":"')),l!==null?(u=oe(),u!==null?(a.charCodeAt(r)===58?(f=":",r++):(f=null,_('":"')),f!==null?(p=oe(),p!==null?(a.charCodeAt(r)===58?(m=":",r++):(m=null,_('":"')),m!==null?(v=oe(),v!==null?(a.charCodeAt(r)===58?(y=":",r++):(y=null,_('":"')),y!==null?(O=oe(),O!==null?(a.charCodeAt(r)===58?(le=":",r++):(le=null,_('":"')),le!==null?(Ue=oe(),Ue!==null?(a.charCodeAt(r)===58?(Dt=":",r++):(Dt=null,_('":"')),Dt!==null?(Js=ut(),Js!==null?e=[e,l,u,f,p,m,v,y,O,le,Ue,Dt,Js]:(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I),e===null&&(I=r,a.substr(r,2)==="::"?(e="::",r+=2):(e=null,_('"::"')),e!==null?(l=oe(),l!==null?(a.charCodeAt(r)===58?(u=":",r++):(u=null,_('":"')),u!==null?(f=oe(),f!==null?(a.charCodeAt(r)===58?(p=":",r++):(p=null,_('":"')),p!==null?(m=oe(),m!==null?(a.charCodeAt(r)===58?(v=":",r++):(v=null,_('":"')),v!==null?(y=oe(),y!==null?(a.charCodeAt(r)===58?(O=":",r++):(O=null,_('":"')),O!==null?(le=oe(),le!==null?(a.charCodeAt(r)===58?(Ue=":",r++):(Ue=null,_('":"')),Ue!==null?(Dt=ut(),Dt!==null?e=[e,l,u,f,p,m,v,y,O,le,Ue,Dt]:(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I),e===null&&(I=r,a.substr(r,2)==="::"?(e="::",r+=2):(e=null,_('"::"')),e!==null?(l=oe(),l!==null?(a.charCodeAt(r)===58?(u=":",r++):(u=null,_('":"')),u!==null?(f=oe(),f!==null?(a.charCodeAt(r)===58?(p=":",r++):(p=null,_('":"')),p!==null?(m=oe(),m!==null?(a.charCodeAt(r)===58?(v=":",r++):(v=null,_('":"')),v!==null?(y=oe(),y!==null?(a.charCodeAt(r)===58?(O=":",r++):(O=null,_('":"')),O!==null?(le=ut(),le!==null?e=[e,l,u,f,p,m,v,y,O,le]:(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I),e===null&&(I=r,a.substr(r,2)==="::"?(e="::",r+=2):(e=null,_('"::"')),e!==null?(l=oe(),l!==null?(a.charCodeAt(r)===58?(u=":",r++):(u=null,_('":"')),u!==null?(f=oe(),f!==null?(a.charCodeAt(r)===58?(p=":",r++):(p=null,_('":"')),p!==null?(m=oe(),m!==null?(a.charCodeAt(r)===58?(v=":",r++):(v=null,_('":"')),v!==null?(y=ut(),y!==null?e=[e,l,u,f,p,m,v,y]:(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I),e===null&&(I=r,a.substr(r,2)==="::"?(e="::",r+=2):(e=null,_('"::"')),e!==null?(l=oe(),l!==null?(a.charCodeAt(r)===58?(u=":",r++):(u=null,_('":"')),u!==null?(f=oe(),f!==null?(a.charCodeAt(r)===58?(p=":",r++):(p=null,_('":"')),p!==null?(m=ut(),m!==null?e=[e,l,u,f,p,m]:(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I),e===null&&(I=r,a.substr(r,2)==="::"?(e="::",r+=2):(e=null,_('"::"')),e!==null?(l=oe(),l!==null?(a.charCodeAt(r)===58?(u=":",r++):(u=null,_('":"')),u!==null?(f=ut(),f!==null?e=[e,l,u,f]:(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I),e===null&&(I=r,a.substr(r,2)==="::"?(e="::",r+=2):(e=null,_('"::"')),e!==null?(l=ut(),l!==null?e=[e,l]:(e=null,r=I)):(e=null,r=I),e===null&&(I=r,a.substr(r,2)==="::"?(e="::",r+=2):(e=null,_('"::"')),e!==null?(l=oe(),l!==null?e=[e,l]:(e=null,r=I)):(e=null,r=I),e===null&&(I=r,e=oe(),e!==null?(a.substr(r,2)==="::"?(l="::",r+=2):(l=null,_('"::"')),l!==null?(u=oe(),u!==null?(a.charCodeAt(r)===58?(f=":",r++):(f=null,_('":"')),f!==null?(p=oe(),p!==null?(a.charCodeAt(r)===58?(m=":",r++):(m=null,_('":"')),m!==null?(v=oe(),v!==null?(a.charCodeAt(r)===58?(y=":",r++):(y=null,_('":"')),y!==null?(O=oe(),O!==null?(a.charCodeAt(r)===58?(le=":",r++):(le=null,_('":"')),le!==null?(Ue=ut(),Ue!==null?e=[e,l,u,f,p,m,v,y,O,le,Ue]:(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I),e===null&&(I=r,e=oe(),e!==null?(Te=r,a.charCodeAt(r)===58?(l=":",r++):(l=null,_('":"')),l!==null?(u=oe(),u!==null?l=[l,u]:(l=null,r=Te)):(l=null,r=Te),l=l!==null?l:"",l!==null?(a.substr(r,2)==="::"?(u="::",r+=2):(u=null,_('"::"')),u!==null?(f=oe(),f!==null?(a.charCodeAt(r)===58?(p=":",r++):(p=null,_('":"')),p!==null?(m=oe(),m!==null?(a.charCodeAt(r)===58?(v=":",r++):(v=null,_('":"')),v!==null?(y=oe(),y!==null?(a.charCodeAt(r)===58?(O=":",r++):(O=null,_('":"')),O!==null?(le=ut(),le!==null?e=[e,l,u,f,p,m,v,y,O,le]:(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I),e===null&&(I=r,e=oe(),e!==null?(Te=r,a.charCodeAt(r)===58?(l=":",r++):(l=null,_('":"')),l!==null?(u=oe(),u!==null?l=[l,u]:(l=null,r=Te)):(l=null,r=Te),l=l!==null?l:"",l!==null?(Te=r,a.charCodeAt(r)===58?(u=":",r++):(u=null,_('":"')),u!==null?(f=oe(),f!==null?u=[u,f]:(u=null,r=Te)):(u=null,r=Te),u=u!==null?u:"",u!==null?(a.substr(r,2)==="::"?(f="::",r+=2):(f=null,_('"::"')),f!==null?(p=oe(),p!==null?(a.charCodeAt(r)===58?(m=":",r++):(m=null,_('":"')),m!==null?(v=oe(),v!==null?(a.charCodeAt(r)===58?(y=":",r++):(y=null,_('":"')),y!==null?(O=ut(),O!==null?e=[e,l,u,f,p,m,v,y,O]:(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I),e===null&&(I=r,e=oe(),e!==null?(Te=r,a.charCodeAt(r)===58?(l=":",r++):(l=null,_('":"')),l!==null?(u=oe(),u!==null?l=[l,u]:(l=null,r=Te)):(l=null,r=Te),l=l!==null?l:"",l!==null?(Te=r,a.charCodeAt(r)===58?(u=":",r++):(u=null,_('":"')),u!==null?(f=oe(),f!==null?u=[u,f]:(u=null,r=Te)):(u=null,r=Te),u=u!==null?u:"",u!==null?(Te=r,a.charCodeAt(r)===58?(f=":",r++):(f=null,_('":"')),f!==null?(p=oe(),p!==null?f=[f,p]:(f=null,r=Te)):(f=null,r=Te),f=f!==null?f:"",f!==null?(a.substr(r,2)==="::"?(p="::",r+=2):(p=null,_('"::"')),p!==null?(m=oe(),m!==null?(a.charCodeAt(r)===58?(v=":",r++):(v=null,_('":"')),v!==null?(y=ut(),y!==null?e=[e,l,u,f,p,m,v,y]:(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I),e===null&&(I=r,e=oe(),e!==null?(Te=r,a.charCodeAt(r)===58?(l=":",r++):(l=null,_('":"')),l!==null?(u=oe(),u!==null?l=[l,u]:(l=null,r=Te)):(l=null,r=Te),l=l!==null?l:"",l!==null?(Te=r,a.charCodeAt(r)===58?(u=":",r++):(u=null,_('":"')),u!==null?(f=oe(),f!==null?u=[u,f]:(u=null,r=Te)):(u=null,r=Te),u=u!==null?u:"",u!==null?(Te=r,a.charCodeAt(r)===58?(f=":",r++):(f=null,_('":"')),f!==null?(p=oe(),p!==null?f=[f,p]:(f=null,r=Te)):(f=null,r=Te),f=f!==null?f:"",f!==null?(Te=r,a.charCodeAt(r)===58?(p=":",r++):(p=null,_('":"')),p!==null?(m=oe(),m!==null?p=[p,m]:(p=null,r=Te)):(p=null,r=Te),p=p!==null?p:"",p!==null?(a.substr(r,2)==="::"?(m="::",r+=2):(m=null,_('"::"')),m!==null?(v=ut(),v!==null?e=[e,l,u,f,p,m,v]:(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I),e===null&&(I=r,e=oe(),e!==null?(Te=r,a.charCodeAt(r)===58?(l=":",r++):(l=null,_('":"')),l!==null?(u=oe(),u!==null?l=[l,u]:(l=null,r=Te)):(l=null,r=Te),l=l!==null?l:"",l!==null?(Te=r,a.charCodeAt(r)===58?(u=":",r++):(u=null,_('":"')),u!==null?(f=oe(),f!==null?u=[u,f]:(u=null,r=Te)):(u=null,r=Te),u=u!==null?u:"",u!==null?(Te=r,a.charCodeAt(r)===58?(f=":",r++):(f=null,_('":"')),f!==null?(p=oe(),p!==null?f=[f,p]:(f=null,r=Te)):(f=null,r=Te),f=f!==null?f:"",f!==null?(Te=r,a.charCodeAt(r)===58?(p=":",r++):(p=null,_('":"')),p!==null?(m=oe(),m!==null?p=[p,m]:(p=null,r=Te)):(p=null,r=Te),p=p!==null?p:"",p!==null?(Te=r,a.charCodeAt(r)===58?(m=":",r++):(m=null,_('":"')),m!==null?(v=oe(),v!==null?m=[m,v]:(m=null,r=Te)):(m=null,r=Te),m=m!==null?m:"",m!==null?(a.substr(r,2)==="::"?(v="::",r+=2):(v=null,_('"::"')),v!==null?(y=oe(),y!==null?e=[e,l,u,f,p,m,v,y]:(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I),e===null&&(I=r,e=oe(),e!==null?(Te=r,a.charCodeAt(r)===58?(l=":",r++):(l=null,_('":"')),l!==null?(u=oe(),u!==null?l=[l,u]:(l=null,r=Te)):(l=null,r=Te),l=l!==null?l:"",l!==null?(Te=r,a.charCodeAt(r)===58?(u=":",r++):(u=null,_('":"')),u!==null?(f=oe(),f!==null?u=[u,f]:(u=null,r=Te)):(u=null,r=Te),u=u!==null?u:"",u!==null?(Te=r,a.charCodeAt(r)===58?(f=":",r++):(f=null,_('":"')),f!==null?(p=oe(),p!==null?f=[f,p]:(f=null,r=Te)):(f=null,r=Te),f=f!==null?f:"",f!==null?(Te=r,a.charCodeAt(r)===58?(p=":",r++):(p=null,_('":"')),p!==null?(m=oe(),m!==null?p=[p,m]:(p=null,r=Te)):(p=null,r=Te),p=p!==null?p:"",p!==null?(Te=r,a.charCodeAt(r)===58?(m=":",r++):(m=null,_('":"')),m!==null?(v=oe(),v!==null?m=[m,v]:(m=null,r=Te)):(m=null,r=Te),m=m!==null?m:"",m!==null?(Te=r,a.charCodeAt(r)===58?(v=":",r++):(v=null,_('":"')),v!==null?(y=oe(),y!==null?v=[v,y]:(v=null,r=Te)):(v=null,r=Te),v=v!==null?v:"",v!==null?(a.substr(r,2)==="::"?(y="::",r+=2):(y=null,_('"::"')),y!==null?e=[e,l,u,f,p,m,v,y]:(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I))))))))))))))),e!==null&&(e=function(Qv){return w.host_type="IPv6",a.substring(r,Qv)}($)),e===null&&(r=$),e}function oe(){var e,l,u,f,p;return p=r,e=E(),e!==null?(l=E(),l=l!==null?l:"",l!==null?(u=E(),u=u!==null?u:"",u!==null?(f=E(),f=f!==null?f:"",f!==null?e=[e,l,u,f]:(e=null,r=p)):(e=null,r=p)):(e=null,r=p)):(e=null,r=p),e}function ut(){var e,l,u,f;return f=r,e=oe(),e!==null?(a.charCodeAt(r)===58?(l=":",r++):(l=null,_('":"')),l!==null?(u=oe(),u!==null?e=[e,l,u]:(e=null,r=f)):(e=null,r=f)):(e=null,r=f),e===null&&(e=es()),e}function es(){var e,l,u,f,p,m,v,y,O;return y=r,O=r,e=$s(),e!==null?(a.charCodeAt(r)===46?(l=".",r++):(l=null,_('"."')),l!==null?(u=$s(),u!==null?(a.charCodeAt(r)===46?(f=".",r++):(f=null,_('"."')),f!==null?(p=$s(),p!==null?(a.charCodeAt(r)===46?(m=".",r++):(m=null,_('"."')),m!==null?(v=$s(),v!==null?e=[e,l,u,f,p,m,v]:(e=null,r=O)):(e=null,r=O)):(e=null,r=O)):(e=null,r=O)):(e=null,r=O)):(e=null,r=O)):(e=null,r=O),e!==null&&(e=function(le){return w.host_type="IPv4",a.substring(r,le)}(y)),e===null&&(r=y),e}function $s(){var e,l,u,f;return f=r,a.substr(r,2)==="25"?(e="25",r+=2):(e=null,_('"25"')),e!==null?(/^[0-5]/.test(a.charAt(r))?(l=a.charAt(r),r++):(l=null,_("[0-5]")),l!==null?e=[e,l]:(e=null,r=f)):(e=null,r=f),e===null&&(f=r,a.charCodeAt(r)===50?(e="2",r++):(e=null,_('"2"')),e!==null?(/^[0-4]/.test(a.charAt(r))?(l=a.charAt(r),r++):(l=null,_("[0-4]")),l!==null?(u=T(),u!==null?e=[e,l,u]:(e=null,r=f)):(e=null,r=f)):(e=null,r=f),e===null&&(f=r,a.charCodeAt(r)===49?(e="1",r++):(e=null,_('"1"')),e!==null?(l=T(),l!==null?(u=T(),u!==null?e=[e,l,u]:(e=null,r=f)):(e=null,r=f)):(e=null,r=f),e===null&&(f=r,/^[1-9]/.test(a.charAt(r))?(e=a.charAt(r),r++):(e=null,_("[1-9]")),e!==null?(l=T(),l!==null?e=[e,l]:(e=null,r=f)):(e=null,r=f),e===null&&(e=T())))),e}function oi(){var e,l,u,f,p,m,v;return m=r,v=r,e=T(),e=e!==null?e:"",e!==null?(l=T(),l=l!==null?l:"",l!==null?(u=T(),u=u!==null?u:"",u!==null?(f=T(),f=f!==null?f:"",f!==null?(p=T(),p=p!==null?p:"",p!==null?e=[e,l,u,f,p]:(e=null,r=v)):(e=null,r=v)):(e=null,r=v)):(e=null,r=v)):(e=null,r=v),e!==null&&(e=function(y,O){return O=parseInt(O.join("")),w.port=O,O}(m,e)),e===null&&(r=m),e}function Kn(){var e,l,u,f;for(e=[],f=r,a.charCodeAt(r)===59?(l=";",r++):(l=null,_('";"')),l!==null?(u=Yn(),u!==null?l=[l,u]:(l=null,r=f)):(l=null,r=f);l!==null;)e.push(l),f=r,a.charCodeAt(r)===59?(l=";",r++):(l=null,_('";"')),l!==null?(u=Yn(),u!==null?l=[l,u]:(l=null,r=f)):(l=null,r=f);return e}function Yn(){var e;return e=ui(),e===null&&(e=ci(),e===null&&(e=fi(),e===null&&(e=hi(),e===null&&(e=di(),e===null&&(e=_i(),e===null&&(e=pi())))))),e}function ui(){var e,l,u,f;return u=r,f=r,a.substr(r,10).toLowerCase()==="transport="?(e=a.substr(r,10),r+=10):(e=null,_('"transport="')),e!==null?(a.substr(r,3).toLowerCase()==="udp"?(l=a.substr(r,3),r+=3):(l=null,_('"udp"')),l===null&&(a.substr(r,3).toLowerCase()==="tcp"?(l=a.substr(r,3),r+=3):(l=null,_('"tcp"')),l===null&&(a.substr(r,4).toLowerCase()==="sctp"?(l=a.substr(r,4),r+=4):(l=null,_('"sctp"')),l===null&&(a.substr(r,3).toLowerCase()==="tls"?(l=a.substr(r,3),r+=3):(l=null,_('"tls"')),l===null&&(l=x())))),l!==null?e=[e,l]:(e=null,r=f)):(e=null,r=f),e!==null&&(e=function(p,m){w.uri_params||(w.uri_params={}),w.uri_params.transport=m.toLowerCase()}(u,e[1])),e===null&&(r=u),e}function ci(){var e,l,u,f;return u=r,f=r,a.substr(r,5).toLowerCase()==="user="?(e=a.substr(r,5),r+=5):(e=null,_('"user="')),e!==null?(a.substr(r,5).toLowerCase()==="phone"?(l=a.substr(r,5),r+=5):(l=null,_('"phone"')),l===null&&(a.substr(r,2).toLowerCase()==="ip"?(l=a.substr(r,2),r+=2):(l=null,_('"ip"')),l===null&&(l=x())),l!==null?e=[e,l]:(e=null,r=f)):(e=null,r=f),e!==null&&(e=function(p,m){w.uri_params||(w.uri_params={}),w.uri_params.user=m.toLowerCase()}(u,e[1])),e===null&&(r=u),e}function fi(){var e,l,u,f;return u=r,f=r,a.substr(r,7).toLowerCase()==="method="?(e=a.substr(r,7),r+=7):(e=null,_('"method="')),e!==null?(l=vn(),l!==null?e=[e,l]:(e=null,r=f)):(e=null,r=f),e!==null&&(e=function(p,m){w.uri_params||(w.uri_params={}),w.uri_params.method=m}(u,e[1])),e===null&&(r=u),e}function hi(){var e,l,u,f;return u=r,f=r,a.substr(r,4).toLowerCase()==="ttl="?(e=a.substr(r,4),r+=4):(e=null,_('"ttl="')),e!==null?(l=hl(),l!==null?e=[e,l]:(e=null,r=f)):(e=null,r=f),e!==null&&(e=function(p,m){w.params||(w.params={}),w.params.ttl=m}(u,e[1])),e===null&&(r=u),e}function di(){var e,l,u,f;return u=r,f=r,a.substr(r,6).toLowerCase()==="maddr="?(e=a.substr(r,6),r+=6):(e=null,_('"maddr="')),e!==null?(l=Cs(),l!==null?e=[e,l]:(e=null,r=f)):(e=null,r=f),e!==null&&(e=function(p,m){w.uri_params||(w.uri_params={}),w.uri_params.maddr=m}(u,e[1])),e===null&&(r=u),e}function _i(){var e,l,u,f,p,m;return f=r,p=r,a.substr(r,2).toLowerCase()==="lr"?(e=a.substr(r,2),r+=2):(e=null,_('"lr"')),e!==null?(m=r,a.charCodeAt(r)===61?(l="=",r++):(l=null,_('"="')),l!==null?(u=x(),u!==null?l=[l,u]:(l=null,r=m)):(l=null,r=m),l=l!==null?l:"",l!==null?e=[e,l]:(e=null,r=p)):(e=null,r=p),e!==null&&(e=function(v){w.uri_params||(w.uri_params={}),w.uri_params.lr=void 0}()),e===null&&(r=f),e}function pi(){var e,l,u,f,p,m;return f=r,p=r,e=mi(),e!==null?(m=r,a.charCodeAt(r)===61?(l="=",r++):(l=null,_('"="')),l!==null?(u=Hs(),u!==null?l=[l,u]:(l=null,r=m)):(l=null,r=m),l=l!==null?l:"",l!==null?e=[e,l]:(e=null,r=p)):(e=null,r=p),e!==null&&(e=function(v,y,O){w.uri_params||(w.uri_params={}),typeof O>"u"?O=void 0:O=O[1],w.uri_params[y.toLowerCase()]=O}(f,e[0],e[1])),e===null&&(r=f),e}function mi(){var e,l,u;if(u=r,l=Fs(),l!==null)for(e=[];l!==null;)e.push(l),l=Fs();else e=null;return e!==null&&(e=function(f,p){return p.join("")}(u,e)),e===null&&(r=u),e}function Hs(){var e,l,u;if(u=r,l=Fs(),l!==null)for(e=[];l!==null;)e.push(l),l=Fs();else e=null;return e!==null&&(e=function(f,p){return p.join("")}(u,e)),e===null&&(r=u),e}function Fs(){var e;return e=gi(),e===null&&(e=j(),e===null&&(e=ve())),e}function gi(){var e;return a.charCodeAt(r)===91?(e="[",r++):(e=null,_('"["')),e===null&&(a.charCodeAt(r)===93?(e="]",r++):(e=null,_('"]"')),e===null&&(a.charCodeAt(r)===47?(e="/",r++):(e=null,_('"/"')),e===null&&(a.charCodeAt(r)===58?(e=":",r++):(e=null,_('":"')),e===null&&(a.charCodeAt(r)===38?(e="&",r++):(e=null,_('"&"')),e===null&&(a.charCodeAt(r)===43?(e="+",r++):(e=null,_('"+"')),e===null&&(a.charCodeAt(r)===36?(e="$",r++):(e=null,_('"$"')))))))),e}function hn(){var e,l,u,f,p,m,v;if(m=r,a.charCodeAt(r)===63?(e="?",r++):(e=null,_('"?"')),e!==null)if(l=dn(),l!==null){for(u=[],v=r,a.charCodeAt(r)===38?(f="&",r++):(f=null,_('"&"')),f!==null?(p=dn(),p!==null?f=[f,p]:(f=null,r=v)):(f=null,r=v);f!==null;)u.push(f),v=r,a.charCodeAt(r)===38?(f="&",r++):(f=null,_('"&"')),f!==null?(p=dn(),p!==null?f=[f,p]:(f=null,r=v)):(f=null,r=v);u!==null?e=[e,l,u]:(e=null,r=m)}else e=null,r=m;else e=null,r=m;return e}function dn(){var e,l,u,f,p;return f=r,p=r,e=Ti(),e!==null?(a.charCodeAt(r)===61?(l="=",r++):(l=null,_('"="')),l!==null?(u=js(),u!==null?e=[e,l,u]:(e=null,r=p)):(e=null,r=p)):(e=null,r=p),e!==null&&(e=function(m,v,y){v=v.join("").toLowerCase(),y=y.join(""),w.uri_headers||(w.uri_headers={}),w.uri_headers[v]?w.uri_headers[v].push(y):w.uri_headers[v]=[y]}(f,e[0],e[2])),e===null&&(r=f),e}function Ti(){var e,l;if(l=_n(),l===null&&(l=j(),l===null&&(l=ve())),l!==null)for(e=[];l!==null;)e.push(l),l=_n(),l===null&&(l=j(),l===null&&(l=ve()));else e=null;return e}function js(){var e,l;for(e=[],l=_n(),l===null&&(l=j(),l===null&&(l=ve()));l!==null;)e.push(l),l=_n(),l===null&&(l=j(),l===null&&(l=ve()));return e}function _n(){var e;return a.charCodeAt(r)===91?(e="[",r++):(e=null,_('"["')),e===null&&(a.charCodeAt(r)===93?(e="]",r++):(e=null,_('"]"')),e===null&&(a.charCodeAt(r)===47?(e="/",r++):(e=null,_('"/"')),e===null&&(a.charCodeAt(r)===63?(e="?",r++):(e=null,_('"?"')),e===null&&(a.charCodeAt(r)===58?(e=":",r++):(e=null,_('":"')),e===null&&(a.charCodeAt(r)===43?(e="+",r++):(e=null,_('"+"')),e===null&&(a.charCodeAt(r)===36?(e="$",r++):(e=null,_('"$"')))))))),e}function wa(){var e;return e=Pi(),e===null&&(e=vi()),e}function vi(){var e,l,u,f,p,m;return m=r,e=vn(),e!==null?(l=k(),l!==null?(u=Jn(),u!==null?(f=k(),f!==null?(p=Qn(),p!==null?e=[e,l,u,f,p]:(e=null,r=m)):(e=null,r=m)):(e=null,r=m)):(e=null,r=m)):(e=null,r=m),e}function Jn(){var e;return e=Ne(),e===null&&(e=zn()),e}function zn(){var e,l,u,f;return f=r,e=yi(),e!==null?(a.charCodeAt(r)===58?(l=":",r++):(l=null,_('":"')),l!==null?(u=Si(),u===null&&(u=Vs()),u!==null?e=[e,l,u]:(e=null,r=f)):(e=null,r=f)):(e=null,r=f),e}function Si(){var e,l,u,f,p;return f=r,e=pn(),e===null&&(e=mn()),e!==null?(p=r,a.charCodeAt(r)===63?(l="?",r++):(l=null,_('"?"')),l!==null?(u=Xn(),u!==null?l=[l,u]:(l=null,r=p)):(l=null,r=p),l=l!==null?l:"",l!==null?e=[e,l]:(e=null,r=f)):(e=null,r=f),e}function pn(){var e,l,u,f;return f=r,a.substr(r,2)==="//"?(e="//",r+=2):(e=null,_('"//"')),e!==null?(l=Ci(),l!==null?(u=mn(),u=u!==null?u:"",u!==null?e=[e,l,u]:(e=null,r=f)):(e=null,r=f)):(e=null,r=f),e}function mn(){var e,l,u;return u=r,a.charCodeAt(r)===47?(e="/",r++):(e=null,_('"/"')),e!==null?(l=gn(),l!==null?e=[e,l]:(e=null,r=u)):(e=null,r=u),e}function Vs(){var e,l,u,f;if(f=r,e=Ei(),e!==null){for(l=[],u=qs();u!==null;)l.push(u),u=qs();l!==null?e=[e,l]:(e=null,r=f)}else e=null,r=f;return e}function qs(){var e;return e=N(),e===null&&(e=j(),e===null&&(e=ve())),e}function Ei(){var e;return e=j(),e===null&&(e=ve(),e===null&&(a.charCodeAt(r)===59?(e=";",r++):(e=null,_('";"')),e===null&&(a.charCodeAt(r)===63?(e="?",r++):(e=null,_('"?"')),e===null&&(a.charCodeAt(r)===58?(e=":",r++):(e=null,_('":"')),e===null&&(a.charCodeAt(r)===64?(e="@",r++):(e=null,_('"@"')),e===null&&(a.charCodeAt(r)===38?(e="&",r++):(e=null,_('"&"')),e===null&&(a.charCodeAt(r)===61?(e="=",r++):(e=null,_('"="')),e===null&&(a.charCodeAt(r)===43?(e="+",r++):(e=null,_('"+"')),e===null&&(a.charCodeAt(r)===36?(e="$",r++):(e=null,_('"$"')),e===null&&(a.charCodeAt(r)===44?(e=",",r++):(e=null,_('","')))))))))))),e}function gn(){var e,l,u,f,p,m;if(p=r,e=Bs(),e!==null){for(l=[],m=r,a.charCodeAt(r)===47?(u="/",r++):(u=null,_('"/"')),u!==null?(f=Bs(),f!==null?u=[u,f]:(u=null,r=m)):(u=null,r=m);u!==null;)l.push(u),m=r,a.charCodeAt(r)===47?(u="/",r++):(u=null,_('"/"')),u!==null?(f=Bs(),f!==null?u=[u,f]:(u=null,r=m)):(u=null,r=m);l!==null?e=[e,l]:(e=null,r=p)}else e=null,r=p;return e}function Bs(){var e,l,u,f,p,m;for(p=r,e=[],l=Gs();l!==null;)e.push(l),l=Gs();if(e!==null){for(l=[],m=r,a.charCodeAt(r)===59?(u=";",r++):(u=null,_('";"')),u!==null?(f=As(),f!==null?u=[u,f]:(u=null,r=m)):(u=null,r=m);u!==null;)l.push(u),m=r,a.charCodeAt(r)===59?(u=";",r++):(u=null,_('";"')),u!==null?(f=As(),f!==null?u=[u,f]:(u=null,r=m)):(u=null,r=m);l!==null?e=[e,l]:(e=null,r=p)}else e=null,r=p;return e}function As(){var e,l;for(e=[],l=Gs();l!==null;)e.push(l),l=Gs();return e}function Gs(){var e;return e=j(),e===null&&(e=ve(),e===null&&(a.charCodeAt(r)===58?(e=":",r++):(e=null,_('":"')),e===null&&(a.charCodeAt(r)===64?(e="@",r++):(e=null,_('"@"')),e===null&&(a.charCodeAt(r)===38?(e="&",r++):(e=null,_('"&"')),e===null&&(a.charCodeAt(r)===61?(e="=",r++):(e=null,_('"="')),e===null&&(a.charCodeAt(r)===43?(e="+",r++):(e=null,_('"+"')),e===null&&(a.charCodeAt(r)===36?(e="$",r++):(e=null,_('"$"')),e===null&&(a.charCodeAt(r)===44?(e=",",r++):(e=null,_('","')))))))))),e}function yi(){var e,l,u,f,p;if(f=r,p=r,e=S(),e!==null){for(l=[],u=S(),u===null&&(u=T(),u===null&&(a.charCodeAt(r)===43?(u="+",r++):(u=null,_('"+"')),u===null&&(a.charCodeAt(r)===45?(u="-",r++):(u=null,_('"-"')),u===null&&(a.charCodeAt(r)===46?(u=".",r++):(u=null,_('"."'))))));u!==null;)l.push(u),u=S(),u===null&&(u=T(),u===null&&(a.charCodeAt(r)===43?(u="+",r++):(u=null,_('"+"')),u===null&&(a.charCodeAt(r)===45?(u="-",r++):(u=null,_('"-"')),u===null&&(a.charCodeAt(r)===46?(u=".",r++):(u=null,_('"."'))))));l!==null?e=[e,l]:(e=null,r=p)}else e=null,r=p;return e!==null&&(e=function(m){w.scheme=a.substring(r,m)}(f)),e===null&&(r=f),e}function Ci(){var e;return e=Ai(),e===null&&(e=Ri()),e}function Ai(){var e,l,u,f;return u=r,f=r,e=At(),e!==null?(a.charCodeAt(r)===64?(l="@",r++):(l=null,_('"@"')),l!==null?e=[e,l]:(e=null,r=f)):(e=null,r=f),e=e!==null?e:"",e!==null?(l=as(),l!==null?e=[e,l]:(e=null,r=u)):(e=null,r=u),e=e!==null?e:"",e}function Ri(){var e,l;if(l=j(),l===null&&(l=ve(),l===null&&(a.charCodeAt(r)===36?(l="$",r++):(l=null,_('"$"')),l===null&&(a.charCodeAt(r)===44?(l=",",r++):(l=null,_('","')),l===null&&(a.charCodeAt(r)===59?(l=";",r++):(l=null,_('";"')),l===null&&(a.charCodeAt(r)===58?(l=":",r++):(l=null,_('":"')),l===null&&(a.charCodeAt(r)===64?(l="@",r++):(l=null,_('"@"')),l===null&&(a.charCodeAt(r)===38?(l="&",r++):(l=null,_('"&"')),l===null&&(a.charCodeAt(r)===61?(l="=",r++):(l=null,_('"="')),l===null&&(a.charCodeAt(r)===43?(l="+",r++):(l=null,_('"+"'))))))))))),l!==null)for(e=[];l!==null;)e.push(l),l=j(),l===null&&(l=ve(),l===null&&(a.charCodeAt(r)===36?(l="$",r++):(l=null,_('"$"')),l===null&&(a.charCodeAt(r)===44?(l=",",r++):(l=null,_('","')),l===null&&(a.charCodeAt(r)===59?(l=";",r++):(l=null,_('";"')),l===null&&(a.charCodeAt(r)===58?(l=":",r++):(l=null,_('":"')),l===null&&(a.charCodeAt(r)===64?(l="@",r++):(l=null,_('"@"')),l===null&&(a.charCodeAt(r)===38?(l="&",r++):(l=null,_('"&"')),l===null&&(a.charCodeAt(r)===61?(l="=",r++):(l=null,_('"="')),l===null&&(a.charCodeAt(r)===43?(l="+",r++):(l=null,_('"+"')))))))))));else e=null;return e}function Xn(){var e,l;for(e=[],l=qs();l!==null;)e.push(l),l=qs();return e}function Qn(){var e,l,u,f,p,m,v,y;if(v=r,y=r,a.substr(r,3).toLowerCase()==="sip"?(e=a.substr(r,3),r+=3):(e=null,_('"SIP"')),e!==null)if(a.charCodeAt(r)===47?(l="/",r++):(l=null,_('"/"')),l!==null){if(f=T(),f!==null)for(u=[];f!==null;)u.push(f),f=T();else u=null;if(u!==null)if(a.charCodeAt(r)===46?(f=".",r++):(f=null,_('"."')),f!==null){if(m=T(),m!==null)for(p=[];m!==null;)p.push(m),m=T();else p=null;p!==null?e=[e,l,u,f,p]:(e=null,r=y)}else e=null,r=y;else e=null,r=y}else e=null,r=y;else e=null,r=y;return e!==null&&(e=function(O){w.sip_version=a.substring(r,O)}(v)),e===null&&(r=v),e}function Ii(){var e;return a.substr(r,6)==="INVITE"?(e="INVITE",r+=6):(e=null,_('"INVITE"')),e}function bi(){var e;return a.substr(r,3)==="ACK"?(e="ACK",r+=3):(e=null,_('"ACK"')),e}function wi(){var e;return a.substr(r,7)==="OPTIONS"?(e="OPTIONS",r+=7):(e=null,_('"OPTIONS"')),e}function Oi(){var e;return a.substr(r,3)==="BYE"?(e="BYE",r+=3):(e=null,_('"BYE"')),e}function Di(){var e;return a.substr(r,6)==="CANCEL"?(e="CANCEL",r+=6):(e=null,_('"CANCEL"')),e}function Ni(){var e;return a.substr(r,8)==="REGISTER"?(e="REGISTER",r+=8):(e=null,_('"REGISTER"')),e}function Ui(){var e;return a.substr(r,9)==="SUBSCRIBE"?(e="SUBSCRIBE",r+=9):(e=null,_('"SUBSCRIBE"')),e}function xi(){var e;return a.substr(r,6)==="NOTIFY"?(e="NOTIFY",r+=6):(e=null,_('"NOTIFY"')),e}function Tn(){var e;return a.substr(r,5)==="REFER"?(e="REFER",r+=5):(e=null,_('"REFER"')),e}function vn(){var e,l;return l=r,e=Ii(),e===null&&(e=bi(),e===null&&(e=wi(),e===null&&(e=Oi(),e===null&&(e=Di(),e===null&&(e=Ni(),e===null&&(e=Ui(),e===null&&(e=xi(),e===null&&(e=Tn(),e===null&&(e=x()))))))))),e!==null&&(e=function(u){return w.method=a.substring(r,u),w.method}(l)),e===null&&(r=l),e}function Pi(){var e,l,u,f,p,m;return m=r,e=Qn(),e!==null?(l=k(),l!==null?(u=ki(),u!==null?(f=k(),f!==null?(p=Oa(),p!==null?e=[e,l,u,f,p]:(e=null,r=m)):(e=null,r=m)):(e=null,r=m)):(e=null,r=m)):(e=null,r=m),e}function ki(){var e,l;return l=r,e=Mi(),e!==null&&(e=function(u,f){w.status_code=parseInt(f.join(""))}(l,e)),e===null&&(r=l),e}function Mi(){var e,l,u,f;return f=r,e=T(),e!==null?(l=T(),l!==null?(u=T(),u!==null?e=[e,l,u]:(e=null,r=f)):(e=null,r=f)):(e=null,r=f),e}function Oa(){var e,l,u;for(u=r,e=[],l=N(),l===null&&(l=j(),l===null&&(l=ve(),l===null&&(l=F(),l===null&&(l=Z(),l===null&&(l=k(),l===null&&(l=M()))))));l!==null;)e.push(l),l=N(),l===null&&(l=j(),l===null&&(l=ve(),l===null&&(l=F(),l===null&&(l=Z(),l===null&&(l=k(),l===null&&(l=M()))))));return e!==null&&(e=function(f){w.reason_phrase=a.substring(r,f)}(u)),e===null&&(r=u),e}function Du(){var e,l,u,f,p,m;if(p=r,e=Cn(),e!==null){for(l=[],m=r,u=ae(),u!==null?(f=Cn(),f!==null?u=[u,f]:(u=null,r=m)):(u=null,r=m);u!==null;)l.push(u),m=r,u=ae(),u!==null?(f=Cn(),f!==null?u=[u,f]:(u=null,r=m)):(u=null,r=m);l!==null?e=[e,l]:(e=null,r=p)}else e=null,r=p;return e}function Nu(){var e,l,u,f,p,m;return f=r,p=r,e=ee(),e!==null?(m=r,a.charCodeAt(r)===64?(l="@",r++):(l=null,_('"@"')),l!==null?(u=ee(),u!==null?l=[l,u]:(l=null,r=m)):(l=null,r=m),l=l!==null?l:"",l!==null?e=[e,l]:(e=null,r=p)):(e=null,r=p),e!==null&&(e=function(v){w=a.substring(r,v)}(f)),e===null&&(r=f),e}function Zn(){var e,l,u,f,p,m,v;if(p=r,e=Y(),e===null)if(m=r,e=Bt(),e!==null){for(l=[],v=r,u=ae(),u!==null?(f=Bt(),f!==null?u=[u,f]:(u=null,r=v)):(u=null,r=v);u!==null;)l.push(u),v=r,u=ae(),u!==null?(f=Bt(),f!==null?u=[u,f]:(u=null,r=v)):(u=null,r=v);l!==null?e=[e,l]:(e=null,r=m)}else e=null,r=m;return e!==null&&(e=function(y){var O,le;for(le=w.multi_header.length,O=0;O<le;O++)if(w.multi_header[O].parsed===null){w=null;break}w!==null?w=w.multi_header:w=-1}()),e===null&&(r=p),e}function Bt(){var e,l,u,f,p,m,v;if(p=r,m=r,e=we(),e===null&&(e=Gt()),e!==null){for(l=[],v=r,u=ye(),u!==null?(f=er(),f!==null?u=[u,f]:(u=null,r=v)):(u=null,r=v);u!==null;)l.push(u),v=r,u=ye(),u!==null?(f=er(),f!==null?u=[u,f]:(u=null,r=v)):(u=null,r=v);l!==null?e=[e,l]:(e=null,r=m)}else e=null,r=m;return e!==null&&(e=function(y){var O;w.multi_header||(w.multi_header=[]);try{O=new b(w.uri,w.display_name,w.params),delete w.uri,delete w.display_name,delete w.params}catch{O=null}w.multi_header.push({possition:r,offset:y,parsed:O})}(p)),e===null&&(r=p),e}function Gt(){var e,l,u,f,p;return p=r,e=Ws(),e=e!==null?e:"",e!==null?(l=Re(),l!==null?(u=Ne(),u!==null?(f=ke(),f!==null?e=[e,l,u,f]:(e=null,r=p)):(e=null,r=p)):(e=null,r=p)):(e=null,r=p),e}function Ws(){var e,l,u,f,p,m,v;if(p=r,m=r,e=x(),e!==null){for(l=[],v=r,u=L(),u!==null?(f=x(),f!==null?u=[u,f]:(u=null,r=v)):(u=null,r=v);u!==null;)l.push(u),v=r,u=L(),u!==null?(f=x(),f!==null?u=[u,f]:(u=null,r=v)):(u=null,r=v);l!==null?e=[e,l]:(e=null,r=m)}else e=null,r=m;return e===null&&(e=pe()),e!==null&&(e=function(y,O){typeof O=="string"?w.display_name=O:w.display_name=O[1].reduce(function(le,Ue){return le+Ue[0]+Ue[1]},O[0])}(p,e)),e===null&&(r=p),e}function er(){var e;return e=Li(),e===null&&(e=os(),e===null&&(e=ze())),e}function Li(){var e,l,u,f,p;return f=r,p=r,a.substr(r,1).toLowerCase()==="q"?(e=a.substr(r,1),r++):(e=null,_('"q"')),e!==null?(l=re(),l!==null?(u=Je(),u!==null?e=[e,l,u]:(e=null,r=p)):(e=null,r=p)):(e=null,r=p),e!==null&&(e=function(m,v){w.params||(w.params={}),w.params.q=v}(f,e[2])),e===null&&(r=f),e}function os(){var e,l,u,f,p;return f=r,p=r,a.substr(r,7).toLowerCase()==="expires"?(e=a.substr(r,7),r+=7):(e=null,_('"expires"')),e!==null?(l=re(),l!==null?(u=us(),u!==null?e=[e,l,u]:(e=null,r=p)):(e=null,r=p)):(e=null,r=p),e!==null&&(e=function(m,v){w.params||(w.params={}),w.params.expires=v}(f,e[2])),e===null&&(r=f),e}function us(){var e,l,u;if(u=r,l=T(),l!==null)for(e=[];l!==null;)e.push(l),l=T();else e=null;return e!==null&&(e=function(f,p){return parseInt(p.join(""))}(u,e)),e===null&&(r=u),e}function Je(){var e,l,u,f,p,m,v,y;return m=r,v=r,a.charCodeAt(r)===48?(e="0",r++):(e=null,_('"0"')),e!==null?(y=r,a.charCodeAt(r)===46?(l=".",r++):(l=null,_('"."')),l!==null?(u=T(),u=u!==null?u:"",u!==null?(f=T(),f=f!==null?f:"",f!==null?(p=T(),p=p!==null?p:"",p!==null?l=[l,u,f,p]:(l=null,r=y)):(l=null,r=y)):(l=null,r=y)):(l=null,r=y),l=l!==null?l:"",l!==null?e=[e,l]:(e=null,r=v)):(e=null,r=v),e!==null&&(e=function(O){return parseFloat(a.substring(r,O))}(m)),e===null&&(r=m),e}function ze(){var e,l,u,f,p,m;return f=r,p=r,e=x(),e!==null?(m=r,l=re(),l!==null?(u=Da(),u!==null?l=[l,u]:(l=null,r=m)):(l=null,r=m),l=l!==null?l:"",l!==null?e=[e,l]:(e=null,r=p)):(e=null,r=p),e!==null&&(e=function(v,y,O){w.params||(w.params={}),typeof O>"u"?O=void 0:O=O[1],w.params[y.toLowerCase()]=O}(f,e[0],e[1])),e===null&&(r=f),e}function Da(){var e;return e=x(),e===null&&(e=Cs(),e===null&&(e=Oe())),e}function Na(){var e,l,u,f,p,m;if(p=r,e=tr(),e!==null){for(l=[],m=r,u=ye(),u!==null?(f=sr(),f!==null?u=[u,f]:(u=null,r=m)):(u=null,r=m);u!==null;)l.push(u),m=r,u=ye(),u!==null?(f=sr(),f!==null?u=[u,f]:(u=null,r=m)):(u=null,r=m);l!==null?e=[e,l]:(e=null,r=p)}else e=null,r=p;return e}function tr(){var e;return a.substr(r,6).toLowerCase()==="render"?(e=a.substr(r,6),r+=6):(e=null,_('"render"')),e===null&&(a.substr(r,7).toLowerCase()==="session"?(e=a.substr(r,7),r+=7):(e=null,_('"session"')),e===null&&(a.substr(r,4).toLowerCase()==="icon"?(e=a.substr(r,4),r+=4):(e=null,_('"icon"')),e===null&&(a.substr(r,5).toLowerCase()==="alert"?(e=a.substr(r,5),r+=5):(e=null,_('"alert"')),e===null&&(e=x())))),e}function sr(){var e;return e=Ua(),e===null&&(e=ze()),e}function Ua(){var e,l,u,f;return f=r,a.substr(r,8).toLowerCase()==="handling"?(e=a.substr(r,8),r+=8):(e=null,_('"handling"')),e!==null?(l=re(),l!==null?(a.substr(r,8).toLowerCase()==="optional"?(u=a.substr(r,8),r+=8):(u=null,_('"optional"')),u===null&&(a.substr(r,8).toLowerCase()==="required"?(u=a.substr(r,8),r+=8):(u=null,_('"required"')),u===null&&(u=x())),u!==null?e=[e,l,u]:(e=null,r=f)):(e=null,r=f)):(e=null,r=f),e}function Uu(){var e,l,u,f,p,m;if(p=r,e=x(),e!==null){for(l=[],m=r,u=ae(),u!==null?(f=x(),f!==null?u=[u,f]:(u=null,r=m)):(u=null,r=m);u!==null;)l.push(u),m=r,u=ae(),u!==null?(f=x(),f!==null?u=[u,f]:(u=null,r=m)):(u=null,r=m);l!==null?e=[e,l]:(e=null,r=p)}else e=null,r=p;return e}function xu(){var e,l,u;if(u=r,l=T(),l!==null)for(e=[];l!==null;)e.push(l),l=T();else e=null;return e!==null&&(e=function(f,p){w=parseInt(p.join(""))}(u,e)),e===null&&(r=u),e}function xa(){var e,l;return l=r,e=$i(),e!==null&&(e=function(u){w=a.substring(r,u)}(l)),e===null&&(r=l),e}function $i(){var e,l,u,f,p,m,v,y;if(v=r,e=Hi(),e!==null)if(l=G(),l!==null)if(u=nr(),u!==null){for(f=[],y=r,p=ye(),p!==null?(m=rr(),m!==null?p=[p,m]:(p=null,r=y)):(p=null,r=y);p!==null;)f.push(p),y=r,p=ye(),p!==null?(m=rr(),m!==null?p=[p,m]:(p=null,r=y)):(p=null,r=y);f!==null?e=[e,l,u,f]:(e=null,r=v)}else e=null,r=v;else e=null,r=v;else e=null,r=v;return e}function Hi(){var e;return e=Fi(),e===null&&(e=Sn()),e}function Fi(){var e;return a.substr(r,4).toLowerCase()==="text"?(e=a.substr(r,4),r+=4):(e=null,_('"text"')),e===null&&(a.substr(r,5).toLowerCase()==="image"?(e=a.substr(r,5),r+=5):(e=null,_('"image"')),e===null&&(a.substr(r,5).toLowerCase()==="audio"?(e=a.substr(r,5),r+=5):(e=null,_('"audio"')),e===null&&(a.substr(r,5).toLowerCase()==="video"?(e=a.substr(r,5),r+=5):(e=null,_('"video"')),e===null&&(a.substr(r,11).toLowerCase()==="application"?(e=a.substr(r,11),r+=11):(e=null,_('"application"')),e===null&&(e=En()))))),e}function Sn(){var e;return a.substr(r,7).toLowerCase()==="message"?(e=a.substr(r,7),r+=7):(e=null,_('"message"')),e===null&&(a.substr(r,9).toLowerCase()==="multipart"?(e=a.substr(r,9),r+=9):(e=null,_('"multipart"')),e===null&&(e=En())),e}function En(){var e;return e=x(),e===null&&(e=ji()),e}function ji(){var e,l,u;return u=r,a.substr(r,2).toLowerCase()==="x-"?(e=a.substr(r,2),r+=2):(e=null,_('"x-"')),e!==null?(l=x(),l!==null?e=[e,l]:(e=null,r=u)):(e=null,r=u),e}function nr(){var e;return e=En(),e===null&&(e=x()),e}function rr(){var e,l,u,f;return f=r,e=x(),e!==null?(l=re(),l!==null?(u=Pa(),u!==null?e=[e,l,u]:(e=null,r=f)):(e=null,r=f)):(e=null,r=f),e}function Pa(){var e;return e=x(),e===null&&(e=Oe()),e}function ka(){var e,l,u,f;return f=r,e=Ma(),e!==null?(l=L(),l!==null?(u=vn(),u!==null?e=[e,l,u]:(e=null,r=f)):(e=null,r=f)):(e=null,r=f),e}function Ma(){var e,l,u;if(u=r,l=T(),l!==null)for(e=[];l!==null;)e.push(l),l=T();else e=null;return e!==null&&(e=function(f,p){w.value=parseInt(p.join(""))}(u,e)),e===null&&(r=u),e}function Pu(){var e,l;return l=r,e=us(),e!==null&&(e=function(u,f){w=f}(l,e)),e===null&&(r=l),e}function yn(){var e,l,u,f,p,m,v;if(p=r,m=r,e=Cn(),e!==null){for(l=[],v=r,u=ye(),u!==null?(f=ze(),f!==null?u=[u,f]:(u=null,r=v)):(u=null,r=v);u!==null;)l.push(u),v=r,u=ye(),u!==null?(f=ze(),f!==null?u=[u,f]:(u=null,r=v)):(u=null,r=v);l!==null?e=[e,l]:(e=null,r=m)}else e=null,r=m;return e!==null&&(e=function(y,O){w.event=O.join("").toLowerCase()}(p,e[0])),e===null&&(r=p),e}function Cn(){var e,l,u,f,p,m;if(p=r,e=se(),e!==null){for(l=[],m=r,a.charCodeAt(r)===46?(u=".",r++):(u=null,_('"."')),u!==null?(f=se(),f!==null?u=[u,f]:(u=null,r=m)):(u=null,r=m);u!==null;)l.push(u),m=r,a.charCodeAt(r)===46?(u=".",r++):(u=null,_('"."')),u!==null?(f=se(),f!==null?u=[u,f]:(u=null,r=m)):(u=null,r=m);l!==null?e=[e,l]:(e=null,r=p)}else e=null,r=p;return e}function Vi(){var e,l,u,f,p,m,v;if(p=r,m=r,e=we(),e===null&&(e=Gt()),e!==null){for(l=[],v=r,u=ye(),u!==null?(f=An(),f!==null?u=[u,f]:(u=null,r=v)):(u=null,r=v);u!==null;)l.push(u),v=r,u=ye(),u!==null?(f=An(),f!==null?u=[u,f]:(u=null,r=v)):(u=null,r=v);l!==null?e=[e,l]:(e=null,r=m)}else e=null,r=m;return e!==null&&(e=function(y){var O=w.tag;try{w=new b(w.uri,w.display_name,w.params),O&&w.setParam("tag",O)}catch{w=-1}}()),e===null&&(r=p),e}function An(){var e;return e=qi(),e===null&&(e=ze()),e}function qi(){var e,l,u,f,p;return f=r,p=r,a.substr(r,3).toLowerCase()==="tag"?(e=a.substr(r,3),r+=3):(e=null,_('"tag"')),e!==null?(l=re(),l!==null?(u=x(),u!==null?e=[e,l,u]:(e=null,r=p)):(e=null,r=p)):(e=null,r=p),e!==null&&(e=function(m,v){w.tag=v}(f,e[2])),e===null&&(r=f),e}function ku(){var e,l,u;if(u=r,l=T(),l!==null)for(e=[];l!==null;)e.push(l),l=T();else e=null;return e!==null&&(e=function(f,p){w=parseInt(p.join(""))}(u,e)),e===null&&(r=u),e}function Mu(){var e,l;return l=r,e=us(),e!==null&&(e=function(u,f){w=f}(l,e)),e===null&&(r=l),e}function Lu(){var e,l,u,f,p,m,v,y,O,le;for(y=r,O=r,e=[],l=Ws();l!==null;)e.push(l),l=Ws();if(e!==null)if(l=Re(),l!==null)if(u=Ne(),u!==null)if(f=ke(),f!==null){for(p=[],le=r,m=ye(),m!==null?(v=ze(),v!==null?m=[m,v]:(m=null,r=le)):(m=null,r=le);m!==null;)p.push(m),le=r,m=ye(),m!==null?(v=ze(),v!==null?m=[m,v]:(m=null,r=le)):(m=null,r=le);p!==null?e=[e,l,u,f,p]:(e=null,r=O)}else e=null,r=O;else e=null,r=O;else e=null,r=O;else e=null,r=O;return e!==null&&(e=function(Ue){try{w=new b(w.uri,w.display_name,w.params)}catch{w=-1}}()),e===null&&(r=y),e}function Bi(){var e;return e=ir(),e}function ir(){var e,l,u,f,p,m,v,y;if(v=r,a.substr(r,6).toLowerCase()==="digest"?(e=a.substr(r,6),r+=6):(e=null,_('"Digest"')),e!==null)if(l=L(),l!==null)if(u=Rn(),u!==null){for(f=[],y=r,p=ae(),p!==null?(m=Rn(),m!==null?p=[p,m]:(p=null,r=y)):(p=null,r=y);p!==null;)f.push(p),y=r,p=ae(),p!==null?(m=Rn(),m!==null?p=[p,m]:(p=null,r=y)):(p=null,r=y);f!==null?e=[e,l,u,f]:(e=null,r=v)}else e=null,r=v;else e=null,r=v;else e=null,r=v;return e===null&&(e=Ks()),e}function Ks(){var e,l,u,f,p,m,v,y;if(v=r,e=x(),e!==null)if(l=L(),l!==null)if(u=cs(),u!==null){for(f=[],y=r,p=ae(),p!==null?(m=cs(),m!==null?p=[p,m]:(p=null,r=y)):(p=null,r=y);p!==null;)f.push(p),y=r,p=ae(),p!==null?(m=cs(),m!==null?p=[p,m]:(p=null,r=y)):(p=null,r=y);f!==null?e=[e,l,u,f]:(e=null,r=v)}else e=null,r=v;else e=null,r=v;else e=null,r=v;return e}function cs(){var e,l,u,f;return f=r,e=x(),e!==null?(l=re(),l!==null?(u=x(),u===null&&(u=Oe()),u!==null?e=[e,l,u]:(e=null,r=f)):(e=null,r=f)):(e=null,r=f),e}function Rn(){var e;return e=Gi(),e===null&&(e=In(),e===null&&(e=Ki(),e===null&&(e=Ji(),e===null&&(e=zi(),e===null&&(e=Xi(),e===null&&(e=wn(),e===null&&(e=cs()))))))),e}function Gi(){var e,l,u,f;return f=r,a.substr(r,5).toLowerCase()==="realm"?(e=a.substr(r,5),r+=5):(e=null,_('"realm"')),e!==null?(l=re(),l!==null?(u=Wi(),u!==null?e=[e,l,u]:(e=null,r=f)):(e=null,r=f)):(e=null,r=f),e}function Wi(){var e,l;return l=r,e=pe(),e!==null&&(e=function(u,f){w.realm=f}(l,e)),e===null&&(r=l),e}function In(){var e,l,u,f,p,m,v,y,O;if(y=r,a.substr(r,6).toLowerCase()==="domain"?(e=a.substr(r,6),r+=6):(e=null,_('"domain"')),e!==null)if(l=re(),l!==null)if(u=ot(),u!==null)if(f=bn(),f!==null){if(p=[],O=r,v=k(),v!==null)for(m=[];v!==null;)m.push(v),v=k();else m=null;for(m!==null?(v=bn(),v!==null?m=[m,v]:(m=null,r=O)):(m=null,r=O);m!==null;){if(p.push(m),O=r,v=k(),v!==null)for(m=[];v!==null;)m.push(v),v=k();else m=null;m!==null?(v=bn(),v!==null?m=[m,v]:(m=null,r=O)):(m=null,r=O)}p!==null?(m=Se(),m!==null?e=[e,l,u,f,p,m]:(e=null,r=y)):(e=null,r=y)}else e=null,r=y;else e=null,r=y;else e=null,r=y;else e=null,r=y;return e}function bn(){var e;return e=zn(),e===null&&(e=mn()),e}function Ki(){var e,l,u,f;return f=r,a.substr(r,5).toLowerCase()==="nonce"?(e=a.substr(r,5),r+=5):(e=null,_('"nonce"')),e!==null?(l=re(),l!==null?(u=Yi(),u!==null?e=[e,l,u]:(e=null,r=f)):(e=null,r=f)):(e=null,r=f),e}function Yi(){var e,l;return l=r,e=pe(),e!==null&&(e=function(u,f){w.nonce=f}(l,e)),e===null&&(r=l),e}function Ji(){var e,l,u,f,p;return f=r,p=r,a.substr(r,6).toLowerCase()==="opaque"?(e=a.substr(r,6),r+=6):(e=null,_('"opaque"')),e!==null?(l=re(),l!==null?(u=pe(),u!==null?e=[e,l,u]:(e=null,r=p)):(e=null,r=p)):(e=null,r=p),e!==null&&(e=function(m,v){w.opaque=v}(f,e[2])),e===null&&(r=f),e}function zi(){var e,l,u,f,p;return f=r,a.substr(r,5).toLowerCase()==="stale"?(e=a.substr(r,5),r+=5):(e=null,_('"stale"')),e!==null?(l=re(),l!==null?(p=r,a.substr(r,4).toLowerCase()==="true"?(u=a.substr(r,4),r+=4):(u=null,_('"true"')),u!==null&&(u=function(m){w.stale=!0}()),u===null&&(r=p),u===null&&(p=r,a.substr(r,5).toLowerCase()==="false"?(u=a.substr(r,5),r+=5):(u=null,_('"false"')),u!==null&&(u=function(m){w.stale=!1}()),u===null&&(r=p)),u!==null?e=[e,l,u]:(e=null,r=f)):(e=null,r=f)):(e=null,r=f),e}function Xi(){var e,l,u,f,p;return f=r,p=r,a.substr(r,9).toLowerCase()==="algorithm"?(e=a.substr(r,9),r+=9):(e=null,_('"algorithm"')),e!==null?(l=re(),l!==null?(a.substr(r,3).toLowerCase()==="md5"?(u=a.substr(r,3),r+=3):(u=null,_('"MD5"')),u===null&&(a.substr(r,8).toLowerCase()==="md5-sess"?(u=a.substr(r,8),r+=8):(u=null,_('"MD5-sess"')),u===null&&(u=x())),u!==null?e=[e,l,u]:(e=null,r=p)):(e=null,r=p)):(e=null,r=p),e!==null&&(e=function(m,v){w.algorithm=v.toUpperCase()}(f,e[2])),e===null&&(r=f),e}function wn(){var e,l,u,f,p,m,v,y,O,le;if(y=r,a.substr(r,3).toLowerCase()==="qop"?(e=a.substr(r,3),r+=3):(e=null,_('"qop"')),e!==null)if(l=re(),l!==null)if(u=ot(),u!==null){if(O=r,f=lr(),f!==null){for(p=[],le=r,a.charCodeAt(r)===44?(m=",",r++):(m=null,_('","')),m!==null?(v=lr(),v!==null?m=[m,v]:(m=null,r=le)):(m=null,r=le);m!==null;)p.push(m),le=r,a.charCodeAt(r)===44?(m=",",r++):(m=null,_('","')),m!==null?(v=lr(),v!==null?m=[m,v]:(m=null,r=le)):(m=null,r=le);p!==null?f=[f,p]:(f=null,r=O)}else f=null,r=O;f!==null?(p=Se(),p!==null?e=[e,l,u,f,p]:(e=null,r=y)):(e=null,r=y)}else e=null,r=y;else e=null,r=y;else e=null,r=y;return e}function lr(){var e,l;return l=r,a.substr(r,8).toLowerCase()==="auth-int"?(e=a.substr(r,8),r+=8):(e=null,_('"auth-int"')),e===null&&(a.substr(r,4).toLowerCase()==="auth"?(e=a.substr(r,4),r+=4):(e=null,_('"auth"')),e===null&&(e=x())),e!==null&&(e=function(u,f){w.qop||(w.qop=[]),w.qop.push(f.toLowerCase())}(l,e)),e===null&&(r=l),e}function $u(){var e,l,u,f,p,m;if(p=r,e=x(),e!==null){for(l=[],m=r,u=ae(),u!==null?(f=x(),f!==null?u=[u,f]:(u=null,r=m)):(u=null,r=m);u!==null;)l.push(u),m=r,u=ae(),u!==null?(f=x(),f!==null?u=[u,f]:(u=null,r=m)):(u=null,r=m);l!==null?e=[e,l]:(e=null,r=p)}else e=null,r=p;return e}function ar(){var e,l,u,f,p,m,v;if(p=r,m=r,e=or(),e!==null){for(l=[],v=r,u=ae(),u!==null?(f=or(),f!==null?u=[u,f]:(u=null,r=v)):(u=null,r=v);u!==null;)l.push(u),v=r,u=ae(),u!==null?(f=or(),f!==null?u=[u,f]:(u=null,r=v)):(u=null,r=v);l!==null?e=[e,l]:(e=null,r=m)}else e=null,r=m;return e!==null&&(e=function(y){var O,le;for(le=w.multi_header.length,O=0;O<le;O++)if(w.multi_header[O].parsed===null){w=null;break}w!==null?w=w.multi_header:w=-1}()),e===null&&(r=p),e}function or(){var e,l,u,f,p,m,v;if(p=r,m=r,e=Gt(),e!==null){for(l=[],v=r,u=ye(),u!==null?(f=ze(),f!==null?u=[u,f]:(u=null,r=v)):(u=null,r=v);u!==null;)l.push(u),v=r,u=ye(),u!==null?(f=ze(),f!==null?u=[u,f]:(u=null,r=v)):(u=null,r=v);l!==null?e=[e,l]:(e=null,r=m)}else e=null,r=m;return e!==null&&(e=function(y){var O;w.multi_header||(w.multi_header=[]);try{O=new b(w.uri,w.display_name,w.params),delete w.uri,delete w.display_name,delete w.params}catch{O=null}w.multi_header.push({possition:r,offset:y,parsed:O})}(p)),e===null&&(r=p),e}function Qi(){var e,l,u,f,p,m,v;if(p=r,m=r,a.substr(r,3).toLowerCase()==="sip"?(e=a.substr(r,3),r+=3):(e=null,_('"SIP"')),e===null&&(e=x()),e!==null){for(l=[],v=r,u=ye(),u!==null?(f=ur(),f!==null?u=[u,f]:(u=null,r=v)):(u=null,r=v);u!==null;)l.push(u),v=r,u=ye(),u!==null?(f=ur(),f!==null?u=[u,f]:(u=null,r=v)):(u=null,r=v);l!==null?e=[e,l]:(e=null,r=m)}else e=null,r=m;return e!==null&&(e=function(y,O){if(w.protocol=O.toLowerCase(),w.params||(w.params={}),w.params.text&&w.params.text[0]==='"'){var le=w.params.text;w.text=le.substring(1,le.length-1),delete w.params.text}}(p,e[0])),e===null&&(r=p),e}function ur(){var e;return e=La(),e===null&&(e=ze()),e}function La(){var e,l,u,f,p,m;if(p=r,m=r,a.substr(r,5).toLowerCase()==="cause"?(e=a.substr(r,5),r+=5):(e=null,_('"cause"')),e!==null)if(l=re(),l!==null){if(f=T(),f!==null)for(u=[];f!==null;)u.push(f),f=T();else u=null;u!==null?e=[e,l,u]:(e=null,r=m)}else e=null,r=m;else e=null,r=m;return e!==null&&(e=function(v,y){w.cause=parseInt(y.join(""))}(p,e[2])),e===null&&(r=p),e}function Hu(){var e,l,u,f,p,m;if(p=r,e=x(),e!==null){for(l=[],m=r,u=ae(),u!==null?(f=x(),f!==null?u=[u,f]:(u=null,r=m)):(u=null,r=m);u!==null;)l.push(u),m=r,u=ae(),u!==null?(f=x(),f!==null?u=[u,f]:(u=null,r=m)):(u=null,r=m);l!==null?e=[e,l]:(e=null,r=p)}else e=null,r=p;return e}function cr(){var e,l,u,f,p,m;if(p=r,e=fr(),e!==null){for(l=[],m=r,u=ae(),u!==null?(f=fr(),f!==null?u=[u,f]:(u=null,r=m)):(u=null,r=m);u!==null;)l.push(u),m=r,u=ae(),u!==null?(f=fr(),f!==null?u=[u,f]:(u=null,r=m)):(u=null,r=m);l!==null?e=[e,l]:(e=null,r=p)}else e=null,r=p;return e}function fr(){var e,l,u,f,p,m;if(p=r,e=Gt(),e!==null){for(l=[],m=r,u=ye(),u!==null?(f=ze(),f!==null?u=[u,f]:(u=null,r=m)):(u=null,r=m);u!==null;)l.push(u),m=r,u=ye(),u!==null?(f=ze(),f!==null?u=[u,f]:(u=null,r=m)):(u=null,r=m);l!==null?e=[e,l]:(e=null,r=p)}else e=null,r=p;return e}function $a(){var e,l,u,f,p,m;if(p=r,e=hr(),e!==null){for(l=[],m=r,u=ye(),u!==null?(f=dr(),f!==null?u=[u,f]:(u=null,r=m)):(u=null,r=m);u!==null;)l.push(u),m=r,u=ye(),u!==null?(f=dr(),f!==null?u=[u,f]:(u=null,r=m)):(u=null,r=m);l!==null?e=[e,l]:(e=null,r=p)}else e=null,r=p;return e}function hr(){var e,l;return l=r,a.substr(r,6).toLowerCase()==="active"?(e=a.substr(r,6),r+=6):(e=null,_('"active"')),e===null&&(a.substr(r,7).toLowerCase()==="pending"?(e=a.substr(r,7),r+=7):(e=null,_('"pending"')),e===null&&(a.substr(r,10).toLowerCase()==="terminated"?(e=a.substr(r,10),r+=10):(e=null,_('"terminated"')),e===null&&(e=x()))),e!==null&&(e=function(u){w.state=a.substring(r,u)}(l)),e===null&&(r=l),e}function dr(){var e,l,u,f,p;return f=r,p=r,a.substr(r,6).toLowerCase()==="reason"?(e=a.substr(r,6),r+=6):(e=null,_('"reason"')),e!==null?(l=re(),l!==null?(u=Ha(),u!==null?e=[e,l,u]:(e=null,r=p)):(e=null,r=p)):(e=null,r=p),e!==null&&(e=function(m,v){typeof v<"u"&&(w.reason=v)}(f,e[2])),e===null&&(r=f),e===null&&(f=r,p=r,a.substr(r,7).toLowerCase()==="expires"?(e=a.substr(r,7),r+=7):(e=null,_('"expires"')),e!==null?(l=re(),l!==null?(u=us(),u!==null?e=[e,l,u]:(e=null,r=p)):(e=null,r=p)):(e=null,r=p),e!==null&&(e=function(m,v){typeof v<"u"&&(w.expires=v)}(f,e[2])),e===null&&(r=f),e===null&&(f=r,p=r,a.substr(r,11).toLowerCase()==="retry_after"?(e=a.substr(r,11),r+=11):(e=null,_('"retry_after"')),e!==null?(l=re(),l!==null?(u=us(),u!==null?e=[e,l,u]:(e=null,r=p)):(e=null,r=p)):(e=null,r=p),e!==null&&(e=function(m,v){typeof v<"u"&&(w.retry_after=v)}(f,e[2])),e===null&&(r=f),e===null&&(e=ze()))),e}function Ha(){var e;return a.substr(r,11).toLowerCase()==="deactivated"?(e=a.substr(r,11),r+=11):(e=null,_('"deactivated"')),e===null&&(a.substr(r,9).toLowerCase()==="probation"?(e=a.substr(r,9),r+=9):(e=null,_('"probation"')),e===null&&(a.substr(r,8).toLowerCase()==="rejected"?(e=a.substr(r,8),r+=8):(e=null,_('"rejected"')),e===null&&(a.substr(r,7).toLowerCase()==="timeout"?(e=a.substr(r,7),r+=7):(e=null,_('"timeout"')),e===null&&(a.substr(r,6).toLowerCase()==="giveup"?(e=a.substr(r,6),r+=6):(e=null,_('"giveup"')),e===null&&(a.substr(r,10).toLowerCase()==="noresource"?(e=a.substr(r,10),r+=10):(e=null,_('"noresource"')),e===null&&(a.substr(r,9).toLowerCase()==="invariant"?(e=a.substr(r,9),r+=9):(e=null,_('"invariant"')),e===null&&(e=x()))))))),e}function Fu(){var e;return e=q(),e=e!==null?e:"",e}function ju(){var e,l,u,f,p,m;if(p=r,e=x(),e!==null){for(l=[],m=r,u=ae(),u!==null?(f=x(),f!==null?u=[u,f]:(u=null,r=m)):(u=null,r=m);u!==null;)l.push(u),m=r,u=ae(),u!==null?(f=x(),f!==null?u=[u,f]:(u=null,r=m)):(u=null,r=m);l!==null?e=[e,l]:(e=null,r=p)}else e=null,r=p;return e=e!==null?e:"",e}function Zi(){var e,l,u,f,p,m,v;if(p=r,m=r,e=we(),e===null&&(e=Gt()),e!==null){for(l=[],v=r,u=ye(),u!==null?(f=el(),f!==null?u=[u,f]:(u=null,r=v)):(u=null,r=v);u!==null;)l.push(u),v=r,u=ye(),u!==null?(f=el(),f!==null?u=[u,f]:(u=null,r=v)):(u=null,r=v);l!==null?e=[e,l]:(e=null,r=m)}else e=null,r=m;return e!==null&&(e=function(y){var O=w.tag;try{w=new b(w.uri,w.display_name,w.params),O&&w.setParam("tag",O)}catch{w=-1}}()),e===null&&(r=p),e}function el(){var e;return e=qi(),e===null&&(e=ze()),e}function _r(){var e,l,u,f,p,m;if(p=r,e=Ys(),e!==null){for(l=[],m=r,u=ae(),u!==null?(f=Ys(),f!==null?u=[u,f]:(u=null,r=m)):(u=null,r=m);u!==null;)l.push(u),m=r,u=ae(),u!==null?(f=Ys(),f!==null?u=[u,f]:(u=null,r=m)):(u=null,r=m);l!==null?e=[e,l]:(e=null,r=p)}else e=null,r=p;return e}function Ys(){var e,l,u,f,p,m,v,y;if(v=r,e=al(),e!==null)if(l=L(),l!==null)if(u=cl(),u!==null){for(f=[],y=r,p=ye(),p!==null?(m=pr(),m!==null?p=[p,m]:(p=null,r=y)):(p=null,r=y);p!==null;)f.push(p),y=r,p=ye(),p!==null?(m=pr(),m!==null?p=[p,m]:(p=null,r=y)):(p=null,r=y);f!==null?e=[e,l,u,f]:(e=null,r=v)}else e=null,r=v;else e=null,r=v;else e=null,r=v;return e}function pr(){var e;return e=tl(),e===null&&(e=sl(),e===null&&(e=nl(),e===null&&(e=rl(),e===null&&(e=il(),e===null&&(e=ze()))))),e}function tl(){var e,l,u,f,p;return f=r,p=r,a.substr(r,3).toLowerCase()==="ttl"?(e=a.substr(r,3),r+=3):(e=null,_('"ttl"')),e!==null?(l=re(),l!==null?(u=hl(),u!==null?e=[e,l,u]:(e=null,r=p)):(e=null,r=p)):(e=null,r=p),e!==null&&(e=function(m,v){w.ttl=v}(f,e[2])),e===null&&(r=f),e}function sl(){var e,l,u,f,p;return f=r,p=r,a.substr(r,5).toLowerCase()==="maddr"?(e=a.substr(r,5),r+=5):(e=null,_('"maddr"')),e!==null?(l=re(),l!==null?(u=Cs(),u!==null?e=[e,l,u]:(e=null,r=p)):(e=null,r=p)):(e=null,r=p),e!==null&&(e=function(m,v){w.maddr=v}(f,e[2])),e===null&&(r=f),e}function nl(){var e,l,u,f,p;return f=r,p=r,a.substr(r,8).toLowerCase()==="received"?(e=a.substr(r,8),r+=8):(e=null,_('"received"')),e!==null?(l=re(),l!==null?(u=es(),u===null&&(u=me()),u!==null?e=[e,l,u]:(e=null,r=p)):(e=null,r=p)):(e=null,r=p),e!==null&&(e=function(m,v){w.received=v}(f,e[2])),e===null&&(r=f),e}function rl(){var e,l,u,f,p;return f=r,p=r,a.substr(r,6).toLowerCase()==="branch"?(e=a.substr(r,6),r+=6):(e=null,_('"branch"')),e!==null?(l=re(),l!==null?(u=x(),u!==null?e=[e,l,u]:(e=null,r=p)):(e=null,r=p)):(e=null,r=p),e!==null&&(e=function(m,v){w.branch=v}(f,e[2])),e===null&&(r=f),e}function il(){var e,l,u,f,p;return f=r,a.substr(r,5).toLowerCase()==="rport"?(e=a.substr(r,5),r+=5):(e=null,_('"rport"')),e!==null?(p=r,l=re(),l!==null?(u=ll(),u!==null?l=[l,u]:(l=null,r=p)):(l=null,r=p),l=l!==null?l:"",l!==null?e=[e,l]:(e=null,r=f)):(e=null,r=f),e}function ll(){var e,l,u,f,p,m,v;return m=r,v=r,e=T(),e=e!==null?e:"",e!==null?(l=T(),l=l!==null?l:"",l!==null?(u=T(),u=u!==null?u:"",u!==null?(f=T(),f=f!==null?f:"",f!==null?(p=T(),p=p!==null?p:"",p!==null?e=[e,l,u,f,p]:(e=null,r=v)):(e=null,r=v)):(e=null,r=v)):(e=null,r=v)):(e=null,r=v),e!==null&&(e=function(y,O){w.rport=parseInt(O.join(""))}(m,e)),e===null&&(r=m),e}function al(){var e,l,u,f,p,m;return m=r,e=ol(),e!==null?(l=G(),l!==null?(u=x(),u!==null?(f=G(),f!==null?(p=ul(),p!==null?e=[e,l,u,f,p]:(e=null,r=m)):(e=null,r=m)):(e=null,r=m)):(e=null,r=m)):(e=null,r=m),e}function ol(){var e,l;return l=r,a.substr(r,3).toLowerCase()==="sip"?(e=a.substr(r,3),r+=3):(e=null,_('"SIP"')),e===null&&(e=x()),e!==null&&(e=function(u,f){w.protocol=f}(l,e)),e===null&&(r=l),e}function ul(){var e,l;return l=r,a.substr(r,3).toLowerCase()==="udp"?(e=a.substr(r,3),r+=3):(e=null,_('"UDP"')),e===null&&(a.substr(r,3).toLowerCase()==="tcp"?(e=a.substr(r,3),r+=3):(e=null,_('"TCP"')),e===null&&(a.substr(r,3).toLowerCase()==="tls"?(e=a.substr(r,3),r+=3):(e=null,_('"TLS"')),e===null&&(a.substr(r,4).toLowerCase()==="sctp"?(e=a.substr(r,4),r+=4):(e=null,_('"SCTP"')),e===null&&(e=x())))),e!==null&&(e=function(u,f){w.transport=f}(l,e)),e===null&&(r=l),e}function cl(){var e,l,u,f,p;return f=r,e=fl(),e!==null?(p=r,l=lt(),l!==null?(u=mr(),u!==null?l=[l,u]:(l=null,r=p)):(l=null,r=p),l=l!==null?l:"",l!==null?e=[e,l]:(e=null,r=f)):(e=null,r=f),e}function fl(){var e,l;return l=r,e=es(),e===null&&(e=fn(),e===null&&(e=cn())),e!==null&&(e=function(u){w.host=a.substring(r,u)}(l)),e===null&&(r=l),e}function mr(){var e,l,u,f,p,m,v;return m=r,v=r,e=T(),e=e!==null?e:"",e!==null?(l=T(),l=l!==null?l:"",l!==null?(u=T(),u=u!==null?u:"",u!==null?(f=T(),f=f!==null?f:"",f!==null?(p=T(),p=p!==null?p:"",p!==null?e=[e,l,u,f,p]:(e=null,r=v)):(e=null,r=v)):(e=null,r=v)):(e=null,r=v)):(e=null,r=v),e!==null&&(e=function(y,O){w.port=parseInt(O.join(""))}(m,e)),e===null&&(r=m),e}function hl(){var e,l,u,f,p;return f=r,p=r,e=T(),e!==null?(l=T(),l=l!==null?l:"",l!==null?(u=T(),u=u!==null?u:"",u!==null?e=[e,l,u]:(e=null,r=p)):(e=null,r=p)):(e=null,r=p),e!==null&&(e=function(m,v){return parseInt(v.join(""))}(f,e)),e===null&&(r=f),e}function Vu(){var e;return e=ir(),e}function Fa(){var e,l,u,f,p,m;if(p=r,e=gr(),e!==null){for(l=[],m=r,u=ye(),u!==null?(f=Tr(),f!==null?u=[u,f]:(u=null,r=m)):(u=null,r=m);u!==null;)l.push(u),m=r,u=ye(),u!==null?(f=Tr(),f!==null?u=[u,f]:(u=null,r=m)):(u=null,r=m);l!==null?e=[e,l]:(e=null,r=p)}else e=null,r=p;return e}function gr(){var e,l;return l=r,e=us(),e!==null&&(e=function(u,f){w.expires=f}(l,e)),e===null&&(r=l),e}function Tr(){var e;return e=ja(),e===null&&(e=ze()),e}function ja(){var e,l,u,f,p;return f=r,p=r,a.substr(r,9).toLowerCase()==="refresher"?(e=a.substr(r,9),r+=9):(e=null,_('"refresher"')),e!==null?(l=re(),l!==null?(a.substr(r,3).toLowerCase()==="uac"?(u=a.substr(r,3),r+=3):(u=null,_('"uac"')),u===null&&(a.substr(r,3).toLowerCase()==="uas"?(u=a.substr(r,3),r+=3):(u=null,_('"uas"'))),u!==null?e=[e,l,u]:(e=null,r=p)):(e=null,r=p)):(e=null,r=p),e!==null&&(e=function(m,v){w.refresher=v.toLowerCase()}(f,e[2])),e===null&&(r=f),e}function Va(){var e,l,u,f;return f=r,e=x(),e!==null?(l=B(),l!==null?(u=qa(),u!==null?e=[e,l,u]:(e=null,r=f)):(e=null,r=f)):(e=null,r=f),e}function qa(){var e,l;for(e=[],l=J(),l===null&&(l=Z(),l===null&&(l=L()));l!==null;)e.push(l),l=J(),l===null&&(l=Z(),l===null&&(l=L()));return e}function qu(){var e,l;for(e=[],l=A();l!==null;)e.push(l),l=A();return e}function Ba(){var e,l,u;return u=r,a.substr(r,5)==="uuid:"?(e="uuid:",r+=5):(e=null,_('"uuid:"')),e!==null?(l=Wt(),l!==null?e=[e,l]:(e=null,r=u)):(e=null,r=u),e}function Wt(){var e,l,u,f,p,m,v,y,O,le,Ue;return le=r,Ue=r,e=dl(),e!==null?(a.charCodeAt(r)===45?(l="-",r++):(l=null,_('"-"')),l!==null?(u=Kt(),u!==null?(a.charCodeAt(r)===45?(f="-",r++):(f=null,_('"-"')),f!==null?(p=Kt(),p!==null?(a.charCodeAt(r)===45?(m="-",r++):(m=null,_('"-"')),m!==null?(v=Kt(),v!==null?(a.charCodeAt(r)===45?(y="-",r++):(y=null,_('"-"')),y!==null?(O=Ga(),O!==null?e=[e,l,u,f,p,m,v,y,O]:(e=null,r=Ue)):(e=null,r=Ue)):(e=null,r=Ue)):(e=null,r=Ue)):(e=null,r=Ue)):(e=null,r=Ue)):(e=null,r=Ue)):(e=null,r=Ue)):(e=null,r=Ue),e!==null&&(e=function(Dt,Js){w=a.substring(r+5,Dt)}(le,e[0])),e===null&&(r=le),e}function Kt(){var e,l,u,f,p;return p=r,e=E(),e!==null?(l=E(),l!==null?(u=E(),u!==null?(f=E(),f!==null?e=[e,l,u,f]:(e=null,r=p)):(e=null,r=p)):(e=null,r=p)):(e=null,r=p),e}function dl(){var e,l,u;return u=r,e=Kt(),e!==null?(l=Kt(),l!==null?e=[e,l]:(e=null,r=u)):(e=null,r=u),e}function Ga(){var e,l,u,f;return f=r,e=Kt(),e!==null?(l=Kt(),l!==null?(u=Kt(),u!==null?e=[e,l,u]:(e=null,r=f)):(e=null,r=f)):(e=null,r=f),e}function Bu(){var e,l,u,f,p,m,v;if(p=r,m=r,e=we(),e===null&&(e=Gt()),e!==null){for(l=[],v=r,u=ye(),u!==null?(f=ze(),f!==null?u=[u,f]:(u=null,r=v)):(u=null,r=v);u!==null;)l.push(u),v=r,u=ye(),u!==null?(f=ze(),f!==null?u=[u,f]:(u=null,r=v)):(u=null,r=v);l!==null?e=[e,l]:(e=null,r=m)}else e=null,r=m;return e!==null&&(e=function(y){try{w=new b(w.uri,w.display_name,w.params)}catch{w=-1}}()),e===null&&(r=p),e}function Wa(){var e,l,u,f,p,m;if(p=r,e=vr(),e!==null){for(l=[],m=r,u=ye(),u!==null?(f=Sr(),f!==null?u=[u,f]:(u=null,r=m)):(u=null,r=m);u!==null;)l.push(u),m=r,u=ye(),u!==null?(f=Sr(),f!==null?u=[u,f]:(u=null,r=m)):(u=null,r=m);l!==null?e=[e,l]:(e=null,r=p)}else e=null,r=p;return e}function vr(){var e,l,u,f,p,m;return f=r,p=r,e=ee(),e!==null?(m=r,a.charCodeAt(r)===64?(l="@",r++):(l=null,_('"@"')),l!==null?(u=ee(),u!==null?l=[l,u]:(l=null,r=m)):(l=null,r=m),l=l!==null?l:"",l!==null?e=[e,l]:(e=null,r=p)):(e=null,r=p),e!==null&&(e=function(v){w.call_id=a.substring(r,v)}(f)),e===null&&(r=f),e}function Sr(){var e;return e=_l(),e===null&&(e=pl(),e===null&&(e=Ka(),e===null&&(e=ze()))),e}function _l(){var e,l,u,f,p;return f=r,p=r,a.substr(r,6)==="to-tag"?(e="to-tag",r+=6):(e=null,_('"to-tag"')),e!==null?(l=re(),l!==null?(u=x(),u!==null?e=[e,l,u]:(e=null,r=p)):(e=null,r=p)):(e=null,r=p),e!==null&&(e=function(m,v){w.to_tag=v}(f,e[2])),e===null&&(r=f),e}function pl(){var e,l,u,f,p;return f=r,p=r,a.substr(r,8)==="from-tag"?(e="from-tag",r+=8):(e=null,_('"from-tag"')),e!==null?(l=re(),l!==null?(u=x(),u!==null?e=[e,l,u]:(e=null,r=p)):(e=null,r=p)):(e=null,r=p),e!==null&&(e=function(m,v){w.from_tag=v}(f,e[2])),e===null&&(r=f),e}function Ka(){var e,l;return l=r,a.substr(r,10)==="early-only"?(e="early-only",r+=10):(e=null,_('"early-only"')),e!==null&&(e=function(u){w.early_only=!0}()),e===null&&(r=l),e}function Gu(e){e.sort();for(var l=null,u=[],f=0;f<e.length;f++)e[f]!==l&&(u.push(e[f]),l=e[f]);return u}function Ya(){for(var e=1,l=1,u=!1,f=0;f<Math.max(r,d);f++){var p=a.charAt(f);p===`
3
+ `,r+=2):(e=null,_('"\\r\\n"')),e}function T(){var e;return/^[0-9]/.test(a.charAt(r))?(e=a.charAt(r),r++):(e=null,_("[0-9]")),e}function S(){var e;return/^[a-zA-Z]/.test(a.charAt(r))?(e=a.charAt(r),r++):(e=null,_("[a-zA-Z]")),e}function E(){var e;return/^[0-9a-fA-F]/.test(a.charAt(r))?(e=a.charAt(r),r++):(e=null,_("[0-9a-fA-F]")),e}function C(){var e;return e=k(),e===null&&(e=M()),e}function A(){var e;return/^[\0-\xFF]/.test(a.charAt(r))?(e=a.charAt(r),r++):(e=null,_("[\\0-\\xFF]")),e}function R(){var e;return/^["]/.test(a.charAt(r))?(e=a.charAt(r),r++):(e=null,_('["]')),e}function k(){var e;return a.charCodeAt(r)===32?(e=" ",r++):(e=null,_('" "')),e}function M(){var e;return a.charCodeAt(r)===9?(e=" ",r++):(e=null,_('"\\t"')),e}function ie(){var e;return/^[a-zA-Z0-9]/.test(a.charAt(r))?(e=a.charAt(r),r++):(e=null,_("[a-zA-Z0-9]")),e}function N(){var e;return a.charCodeAt(r)===59?(e=";",r++):(e=null,_('";"')),e===null&&(a.charCodeAt(r)===47?(e="/",r++):(e=null,_('"/"')),e===null&&(a.charCodeAt(r)===63?(e="?",r++):(e=null,_('"?"')),e===null&&(a.charCodeAt(r)===58?(e=":",r++):(e=null,_('":"')),e===null&&(a.charCodeAt(r)===64?(e="@",r++):(e=null,_('"@"')),e===null&&(a.charCodeAt(r)===38?(e="&",r++):(e=null,_('"&"')),e===null&&(a.charCodeAt(r)===61?(e="=",r++):(e=null,_('"="')),e===null&&(a.charCodeAt(r)===43?(e="+",r++):(e=null,_('"+"')),e===null&&(a.charCodeAt(r)===36?(e="$",r++):(e=null,_('"$"')),e===null&&(a.charCodeAt(r)===44?(e=",",r++):(e=null,_('","'))))))))))),e}function j(){var e;return e=ie(),e===null&&(e=Ee()),e}function Ee(){var e;return a.charCodeAt(r)===45?(e="-",r++):(e=null,_('"-"')),e===null&&(a.charCodeAt(r)===95?(e="_",r++):(e=null,_('"_"')),e===null&&(a.charCodeAt(r)===46?(e=".",r++):(e=null,_('"."')),e===null&&(a.charCodeAt(r)===33?(e="!",r++):(e=null,_('"!"')),e===null&&(a.charCodeAt(r)===126?(e="~",r++):(e=null,_('"~"')),e===null&&(a.charCodeAt(r)===42?(e="*",r++):(e=null,_('"*"')),e===null&&(a.charCodeAt(r)===39?(e="'",r++):(e=null,_(`"'"`)),e===null&&(a.charCodeAt(r)===40?(e="(",r++):(e=null,_('"("')),e===null&&(a.charCodeAt(r)===41?(e=")",r++):(e=null,_('")"')))))))))),e}function ve(){var e,l,u,f,p;return f=r,p=r,a.charCodeAt(r)===37?(e="%",r++):(e=null,_('"%"')),e!==null?(l=E(),l!==null?(u=E(),u!==null?e=[e,l,u]:(e=null,r=p)):(e=null,r=p)):(e=null,r=p),e!==null&&(e=function(m,v){return v.join("")}(f,e)),e===null&&(r=f),e}function L(){var e,l,u,f,p,m;for(f=r,p=r,m=r,e=[],l=C();l!==null;)e.push(l),l=C();if(e!==null?(l=g(),l!==null?e=[e,l]:(e=null,r=m)):(e=null,r=m),e=e!==null?e:"",e!==null){if(u=C(),u!==null)for(l=[];u!==null;)l.push(u),u=C();else l=null;l!==null?e=[e,l]:(e=null,r=p)}else e=null,r=p;return e!==null&&(e=function(v){return" "}()),e===null&&(r=f),e}function D(){var e;return e=L(),e=e!==null?e:"",e}function B(){var e,l,u,f,p;for(f=r,p=r,e=[],l=k(),l===null&&(l=M());l!==null;)e.push(l),l=k(),l===null&&(l=M());return e!==null?(a.charCodeAt(r)===58?(l=":",r++):(l=null,_('":"')),l!==null?(u=D(),u!==null?e=[e,l,u]:(e=null,r=p)):(e=null,r=p)):(e=null,r=p),e!==null&&(e=function(m){return":"}()),e===null&&(r=f),e}function q(){var e,l,u,f,p,m,v;if(p=r,m=r,l=J(),l!==null)for(e=[];l!==null;)e.push(l),l=J();else e=null;if(e!==null){for(l=[],v=r,u=[],f=L();f!==null;)u.push(f),f=L();for(u!==null?(f=J(),f!==null?u=[u,f]:(u=null,r=v)):(u=null,r=v);u!==null;){for(l.push(u),v=r,u=[],f=L();f!==null;)u.push(f),f=L();u!==null?(f=J(),f!==null?u=[u,f]:(u=null,r=v)):(u=null,r=v)}l!==null?e=[e,l]:(e=null,r=m)}else e=null,r=m;return e!==null&&(e=function(y){return a.substring(r,y)}(p)),e===null&&(r=p),e}function J(){var e;return/^[!-~]/.test(a.charAt(r))?(e=a.charAt(r),r++):(e=null,_("[!-~]")),e===null&&(e=F()),e}function F(){var e;return/^[\x80-\uFFFF]/.test(a.charAt(r))?(e=a.charAt(r),r++):(e=null,_("[\\x80-\\uFFFF]")),e}function Z(){var e;return/^[\x80-\xBF]/.test(a.charAt(r))?(e=a.charAt(r),r++):(e=null,_("[\\x80-\\xBF]")),e}function U(){var e;return e=T(),e===null&&(/^[a-f]/.test(a.charAt(r))?(e=a.charAt(r),r++):(e=null,_("[a-f]"))),e}function x(){var e,l,u;if(u=r,l=ie(),l===null&&(a.charCodeAt(r)===45?(l="-",r++):(l=null,_('"-"')),l===null&&(a.charCodeAt(r)===46?(l=".",r++):(l=null,_('"."')),l===null&&(a.charCodeAt(r)===33?(l="!",r++):(l=null,_('"!"')),l===null&&(a.charCodeAt(r)===37?(l="%",r++):(l=null,_('"%"')),l===null&&(a.charCodeAt(r)===42?(l="*",r++):(l=null,_('"*"')),l===null&&(a.charCodeAt(r)===95?(l="_",r++):(l=null,_('"_"')),l===null&&(a.charCodeAt(r)===43?(l="+",r++):(l=null,_('"+"')),l===null&&(a.charCodeAt(r)===96?(l="`",r++):(l=null,_('"`"')),l===null&&(a.charCodeAt(r)===39?(l="'",r++):(l=null,_(`"'"`)),l===null&&(a.charCodeAt(r)===126?(l="~",r++):(l=null,_('"~"')))))))))))),l!==null)for(e=[];l!==null;)e.push(l),l=ie(),l===null&&(a.charCodeAt(r)===45?(l="-",r++):(l=null,_('"-"')),l===null&&(a.charCodeAt(r)===46?(l=".",r++):(l=null,_('"."')),l===null&&(a.charCodeAt(r)===33?(l="!",r++):(l=null,_('"!"')),l===null&&(a.charCodeAt(r)===37?(l="%",r++):(l=null,_('"%"')),l===null&&(a.charCodeAt(r)===42?(l="*",r++):(l=null,_('"*"')),l===null&&(a.charCodeAt(r)===95?(l="_",r++):(l=null,_('"_"')),l===null&&(a.charCodeAt(r)===43?(l="+",r++):(l=null,_('"+"')),l===null&&(a.charCodeAt(r)===96?(l="`",r++):(l=null,_('"`"')),l===null&&(a.charCodeAt(r)===39?(l="'",r++):(l=null,_(`"'"`)),l===null&&(a.charCodeAt(r)===126?(l="~",r++):(l=null,_('"~"'))))))))))));else e=null;return e!==null&&(e=function(f){return a.substring(r,f)}(u)),e===null&&(r=u),e}function se(){var e,l,u;if(u=r,l=ie(),l===null&&(a.charCodeAt(r)===45?(l="-",r++):(l=null,_('"-"')),l===null&&(a.charCodeAt(r)===33?(l="!",r++):(l=null,_('"!"')),l===null&&(a.charCodeAt(r)===37?(l="%",r++):(l=null,_('"%"')),l===null&&(a.charCodeAt(r)===42?(l="*",r++):(l=null,_('"*"')),l===null&&(a.charCodeAt(r)===95?(l="_",r++):(l=null,_('"_"')),l===null&&(a.charCodeAt(r)===43?(l="+",r++):(l=null,_('"+"')),l===null&&(a.charCodeAt(r)===96?(l="`",r++):(l=null,_('"`"')),l===null&&(a.charCodeAt(r)===39?(l="'",r++):(l=null,_(`"'"`)),l===null&&(a.charCodeAt(r)===126?(l="~",r++):(l=null,_('"~"'))))))))))),l!==null)for(e=[];l!==null;)e.push(l),l=ie(),l===null&&(a.charCodeAt(r)===45?(l="-",r++):(l=null,_('"-"')),l===null&&(a.charCodeAt(r)===33?(l="!",r++):(l=null,_('"!"')),l===null&&(a.charCodeAt(r)===37?(l="%",r++):(l=null,_('"%"')),l===null&&(a.charCodeAt(r)===42?(l="*",r++):(l=null,_('"*"')),l===null&&(a.charCodeAt(r)===95?(l="_",r++):(l=null,_('"_"')),l===null&&(a.charCodeAt(r)===43?(l="+",r++):(l=null,_('"+"')),l===null&&(a.charCodeAt(r)===96?(l="`",r++):(l=null,_('"`"')),l===null&&(a.charCodeAt(r)===39?(l="'",r++):(l=null,_(`"'"`)),l===null&&(a.charCodeAt(r)===126?(l="~",r++):(l=null,_('"~"')))))))))));else e=null;return e!==null&&(e=function(f){return a.substring(r,f)}(u)),e===null&&(r=u),e}function it(){var e;return a.charCodeAt(r)===40?(e="(",r++):(e=null,_('"("')),e===null&&(a.charCodeAt(r)===41?(e=")",r++):(e=null,_('")"')),e===null&&(a.charCodeAt(r)===60?(e="<",r++):(e=null,_('"<"')),e===null&&(a.charCodeAt(r)===62?(e=">",r++):(e=null,_('">"')),e===null&&(a.charCodeAt(r)===64?(e="@",r++):(e=null,_('"@"')),e===null&&(a.charCodeAt(r)===44?(e=",",r++):(e=null,_('","')),e===null&&(a.charCodeAt(r)===59?(e=";",r++):(e=null,_('";"')),e===null&&(a.charCodeAt(r)===58?(e=":",r++):(e=null,_('":"')),e===null&&(a.charCodeAt(r)===92?(e="\\",r++):(e=null,_('"\\\\"')),e===null&&(e=R(),e===null&&(a.charCodeAt(r)===47?(e="/",r++):(e=null,_('"/"')),e===null&&(a.charCodeAt(r)===91?(e="[",r++):(e=null,_('"["')),e===null&&(a.charCodeAt(r)===93?(e="]",r++):(e=null,_('"]"')),e===null&&(a.charCodeAt(r)===63?(e="?",r++):(e=null,_('"?"')),e===null&&(a.charCodeAt(r)===61?(e="=",r++):(e=null,_('"="')),e===null&&(a.charCodeAt(r)===123?(e="{",r++):(e=null,_('"{"')),e===null&&(a.charCodeAt(r)===125?(e="}",r++):(e=null,_('"}"')),e===null&&(e=k(),e===null&&(e=M())))))))))))))))))),e}function ee(){var e,l,u;if(u=r,l=ie(),l===null&&(a.charCodeAt(r)===45?(l="-",r++):(l=null,_('"-"')),l===null&&(a.charCodeAt(r)===46?(l=".",r++):(l=null,_('"."')),l===null&&(a.charCodeAt(r)===33?(l="!",r++):(l=null,_('"!"')),l===null&&(a.charCodeAt(r)===37?(l="%",r++):(l=null,_('"%"')),l===null&&(a.charCodeAt(r)===42?(l="*",r++):(l=null,_('"*"')),l===null&&(a.charCodeAt(r)===95?(l="_",r++):(l=null,_('"_"')),l===null&&(a.charCodeAt(r)===43?(l="+",r++):(l=null,_('"+"')),l===null&&(a.charCodeAt(r)===96?(l="`",r++):(l=null,_('"`"')),l===null&&(a.charCodeAt(r)===39?(l="'",r++):(l=null,_(`"'"`)),l===null&&(a.charCodeAt(r)===126?(l="~",r++):(l=null,_('"~"')),l===null&&(a.charCodeAt(r)===40?(l="(",r++):(l=null,_('"("')),l===null&&(a.charCodeAt(r)===41?(l=")",r++):(l=null,_('")"')),l===null&&(a.charCodeAt(r)===60?(l="<",r++):(l=null,_('"<"')),l===null&&(a.charCodeAt(r)===62?(l=">",r++):(l=null,_('">"')),l===null&&(a.charCodeAt(r)===58?(l=":",r++):(l=null,_('":"')),l===null&&(a.charCodeAt(r)===92?(l="\\",r++):(l=null,_('"\\\\"')),l===null&&(l=R(),l===null&&(a.charCodeAt(r)===47?(l="/",r++):(l=null,_('"/"')),l===null&&(a.charCodeAt(r)===91?(l="[",r++):(l=null,_('"["')),l===null&&(a.charCodeAt(r)===93?(l="]",r++):(l=null,_('"]"')),l===null&&(a.charCodeAt(r)===63?(l="?",r++):(l=null,_('"?"')),l===null&&(a.charCodeAt(r)===123?(l="{",r++):(l=null,_('"{"')),l===null&&(a.charCodeAt(r)===125?(l="}",r++):(l=null,_('"}"'))))))))))))))))))))))))),l!==null)for(e=[];l!==null;)e.push(l),l=ie(),l===null&&(a.charCodeAt(r)===45?(l="-",r++):(l=null,_('"-"')),l===null&&(a.charCodeAt(r)===46?(l=".",r++):(l=null,_('"."')),l===null&&(a.charCodeAt(r)===33?(l="!",r++):(l=null,_('"!"')),l===null&&(a.charCodeAt(r)===37?(l="%",r++):(l=null,_('"%"')),l===null&&(a.charCodeAt(r)===42?(l="*",r++):(l=null,_('"*"')),l===null&&(a.charCodeAt(r)===95?(l="_",r++):(l=null,_('"_"')),l===null&&(a.charCodeAt(r)===43?(l="+",r++):(l=null,_('"+"')),l===null&&(a.charCodeAt(r)===96?(l="`",r++):(l=null,_('"`"')),l===null&&(a.charCodeAt(r)===39?(l="'",r++):(l=null,_(`"'"`)),l===null&&(a.charCodeAt(r)===126?(l="~",r++):(l=null,_('"~"')),l===null&&(a.charCodeAt(r)===40?(l="(",r++):(l=null,_('"("')),l===null&&(a.charCodeAt(r)===41?(l=")",r++):(l=null,_('")"')),l===null&&(a.charCodeAt(r)===60?(l="<",r++):(l=null,_('"<"')),l===null&&(a.charCodeAt(r)===62?(l=">",r++):(l=null,_('">"')),l===null&&(a.charCodeAt(r)===58?(l=":",r++):(l=null,_('":"')),l===null&&(a.charCodeAt(r)===92?(l="\\",r++):(l=null,_('"\\\\"')),l===null&&(l=R(),l===null&&(a.charCodeAt(r)===47?(l="/",r++):(l=null,_('"/"')),l===null&&(a.charCodeAt(r)===91?(l="[",r++):(l=null,_('"["')),l===null&&(a.charCodeAt(r)===93?(l="]",r++):(l=null,_('"]"')),l===null&&(a.charCodeAt(r)===63?(l="?",r++):(l=null,_('"?"')),l===null&&(a.charCodeAt(r)===123?(l="{",r++):(l=null,_('"{"')),l===null&&(a.charCodeAt(r)===125?(l="}",r++):(l=null,_('"}"')))))))))))))))))))))))));else e=null;return e!==null&&(e=function(f){return a.substring(r,f)}(u)),e===null&&(r=u),e}function Y(){var e,l,u,f,p;return f=r,p=r,e=D(),e!==null?(a.charCodeAt(r)===42?(l="*",r++):(l=null,_('"*"')),l!==null?(u=D(),u!==null?e=[e,l,u]:(e=null,r=p)):(e=null,r=p)):(e=null,r=p),e!==null&&(e=function(m){return"*"}()),e===null&&(r=f),e}function G(){var e,l,u,f,p;return f=r,p=r,e=D(),e!==null?(a.charCodeAt(r)===47?(l="/",r++):(l=null,_('"/"')),l!==null?(u=D(),u!==null?e=[e,l,u]:(e=null,r=p)):(e=null,r=p)):(e=null,r=p),e!==null&&(e=function(m){return"/"}()),e===null&&(r=f),e}function re(){var e,l,u,f,p;return f=r,p=r,e=D(),e!==null?(a.charCodeAt(r)===61?(l="=",r++):(l=null,_('"="')),l!==null?(u=D(),u!==null?e=[e,l,u]:(e=null,r=p)):(e=null,r=p)):(e=null,r=p),e!==null&&(e=function(m){return"="}()),e===null&&(r=f),e}function ge(){var e,l,u,f,p;return f=r,p=r,e=D(),e!==null?(a.charCodeAt(r)===40?(l="(",r++):(l=null,_('"("')),l!==null?(u=D(),u!==null?e=[e,l,u]:(e=null,r=p)):(e=null,r=p)):(e=null,r=p),e!==null&&(e=function(m){return"("}()),e===null&&(r=f),e}function be(){var e,l,u,f,p;return f=r,p=r,e=D(),e!==null?(a.charCodeAt(r)===41?(l=")",r++):(l=null,_('")"')),l!==null?(u=D(),u!==null?e=[e,l,u]:(e=null,r=p)):(e=null,r=p)):(e=null,r=p),e!==null&&(e=function(m){return")"}()),e===null&&(r=f),e}function ke(){var e,l,u,f;return u=r,f=r,a.charCodeAt(r)===62?(e=">",r++):(e=null,_('">"')),e!==null?(l=D(),l!==null?e=[e,l]:(e=null,r=f)):(e=null,r=f),e!==null&&(e=function(p){return">"}()),e===null&&(r=u),e}function Re(){var e,l,u,f;return u=r,f=r,e=D(),e!==null?(a.charCodeAt(r)===60?(l="<",r++):(l=null,_('"<"')),l!==null?e=[e,l]:(e=null,r=f)):(e=null,r=f),e!==null&&(e=function(p){return"<"}()),e===null&&(r=u),e}function ae(){var e,l,u,f,p;return f=r,p=r,e=D(),e!==null?(a.charCodeAt(r)===44?(l=",",r++):(l=null,_('","')),l!==null?(u=D(),u!==null?e=[e,l,u]:(e=null,r=p)):(e=null,r=p)):(e=null,r=p),e!==null&&(e=function(m){return","}()),e===null&&(r=f),e}function ye(){var e,l,u,f,p;return f=r,p=r,e=D(),e!==null?(a.charCodeAt(r)===59?(l=";",r++):(l=null,_('";"')),l!==null?(u=D(),u!==null?e=[e,l,u]:(e=null,r=p)):(e=null,r=p)):(e=null,r=p),e!==null&&(e=function(m){return";"}()),e===null&&(r=f),e}function lt(){var e,l,u,f,p;return f=r,p=r,e=D(),e!==null?(a.charCodeAt(r)===58?(l=":",r++):(l=null,_('":"')),l!==null?(u=D(),u!==null?e=[e,l,u]:(e=null,r=p)):(e=null,r=p)):(e=null,r=p),e!==null&&(e=function(m){return":"}()),e===null&&(r=f),e}function ot(){var e,l,u,f;return u=r,f=r,e=D(),e!==null?(l=R(),l!==null?e=[e,l]:(e=null,r=f)):(e=null,r=f),e!==null&&(e=function(p){return'"'}()),e===null&&(r=u),e}function Se(){var e,l,u,f;return u=r,f=r,e=R(),e!==null?(l=D(),l!==null?e=[e,l]:(e=null,r=f)):(e=null,r=f),e!==null&&(e=function(p){return'"'}()),e===null&&(r=u),e}function Ce(){var e,l,u,f;if(f=r,e=ge(),e!==null){for(l=[],u=Ie(),u===null&&(u=_e(),u===null&&(u=Ce()));u!==null;)l.push(u),u=Ie(),u===null&&(u=_e(),u===null&&(u=Ce()));l!==null?(u=be(),u!==null?e=[e,l,u]:(e=null,r=f)):(e=null,r=f)}else e=null,r=f;return e}function Ie(){var e;return/^[!-']/.test(a.charAt(r))?(e=a.charAt(r),r++):(e=null,_("[!-']")),e===null&&(/^[*-[]/.test(a.charAt(r))?(e=a.charAt(r),r++):(e=null,_("[*-[]")),e===null&&(/^[\]-~]/.test(a.charAt(r))?(e=a.charAt(r),r++):(e=null,_("[\\]-~]")),e===null&&(e=F(),e===null&&(e=L())))),e}function Oe(){var e,l,u,f,p,m;if(p=r,m=r,e=D(),e!==null)if(l=R(),l!==null){for(u=[],f=de(),f===null&&(f=_e());f!==null;)u.push(f),f=de(),f===null&&(f=_e());u!==null?(f=R(),f!==null?e=[e,l,u,f]:(e=null,r=m)):(e=null,r=m)}else e=null,r=m;else e=null,r=m;return e!==null&&(e=function(v){return a.substring(r,v)}(p)),e===null&&(r=p),e}function pe(){var e,l,u,f,p,m;if(p=r,m=r,e=D(),e!==null)if(l=R(),l!==null){for(u=[],f=de(),f===null&&(f=_e());f!==null;)u.push(f),f=de(),f===null&&(f=_e());u!==null?(f=R(),f!==null?e=[e,l,u,f]:(e=null,r=m)):(e=null,r=m)}else e=null,r=m;else e=null,r=m;return e!==null&&(e=function(v){var y=a.substring(r,v).trim();return y.substring(1,y.length-1).replace(/\\([\x00-\x09\x0b-\x0c\x0e-\x7f])/g,"$1")}(p)),e===null&&(r=p),e}function de(){var e;return e=L(),e===null&&(a.charCodeAt(r)===33?(e="!",r++):(e=null,_('"!"')),e===null&&(/^[#-[]/.test(a.charAt(r))?(e=a.charAt(r),r++):(e=null,_("[#-[]")),e===null&&(/^[\]-~]/.test(a.charAt(r))?(e=a.charAt(r),r++):(e=null,_("[\\]-~]")),e===null&&(e=F())))),e}function _e(){var e,l,u;return u=r,a.charCodeAt(r)===92?(e="\\",r++):(e=null,_('"\\\\"')),e!==null?(/^[\0-\t]/.test(a.charAt(r))?(l=a.charAt(r),r++):(l=null,_("[\\0-\\t]")),l===null&&(/^[\x0B-\f]/.test(a.charAt(r))?(l=a.charAt(r),r++):(l=null,_("[\\x0B-\\f]")),l===null&&(/^[\x0E-]/.test(a.charAt(r))?(l=a.charAt(r),r++):(l=null,_("[\\x0E-]")))),l!==null?e=[e,l]:(e=null,r=u)):(e=null,r=u),e}function we(){var e,l,u,f,p,m;return p=r,m=r,e=tt(),e!==null?(a.charCodeAt(r)===58?(l=":",r++):(l=null,_('":"')),l!==null?(u=At(),u=u!==null?u:"",u!==null?(f=as(),f!==null?e=[e,l,u,f]:(e=null,r=m)):(e=null,r=m)):(e=null,r=m)):(e=null,r=m),e!==null&&(e=function(v){try{w.uri=new Rs(w.scheme,w.user,w.host,w.port),delete w.scheme,delete w.user,delete w.host,delete w.host_type,delete w.port}catch{w=-1}}()),e===null&&(r=p),e}function Ne(){var e,l,u,f,p,m,v,y;return v=r,y=r,e=tt(),e!==null?(a.charCodeAt(r)===58?(l=":",r++):(l=null,_('":"')),l!==null?(u=At(),u=u!==null?u:"",u!==null?(f=as(),f!==null?(p=Kn(),p!==null?(m=hn(),m=m!==null?m:"",m!==null?e=[e,l,u,f,p,m]:(e=null,r=y)):(e=null,r=y)):(e=null,r=y)):(e=null,r=y)):(e=null,r=y)):(e=null,r=y),e!==null&&(e=function(O){try{w.uri=new Rs(w.scheme,w.user,w.host,w.port,w.uri_params,w.uri_headers),delete w.scheme,delete w.user,delete w.host,delete w.host_type,delete w.port,delete w.uri_params,o==="SIP_URI"&&(w=w.uri)}catch{w=-1}}()),e===null&&(r=v),e}function tt(){var e;return e=He(),e===null&&(e=qt()),e}function He(){var e,l;return l=r,a.substr(r,4).toLowerCase()==="sips"?(e=a.substr(r,4),r+=4):(e=null,_('"sips"')),e!==null&&(e=function(u,f){w.scheme=f.toLowerCase()}(l,e)),e===null&&(r=l),e}function qt(){var e,l;return l=r,a.substr(r,3).toLowerCase()==="sip"?(e=a.substr(r,3),r+=3):(e=null,_('"sip"')),e!==null&&(e=function(u,f){w.scheme=f.toLowerCase()}(l,e)),e===null&&(r=l),e}function At(){var e,l,u,f,p,m;return f=r,p=r,e=qn(),e!==null?(m=r,a.charCodeAt(r)===58?(l=":",r++):(l=null,_('":"')),l!==null?(u=un(),u!==null?l=[l,u]:(l=null,r=m)):(l=null,r=m),l=l!==null?l:"",l!==null?(a.charCodeAt(r)===64?(u="@",r++):(u=null,_('"@"')),u!==null?e=[e,l,u]:(e=null,r=p)):(e=null,r=p)):(e=null,r=p),e!==null&&(e=function(v){w.user=decodeURIComponent(a.substring(r-1,v))}(f)),e===null&&(r=f),e}function qn(){var e,l;if(l=j(),l===null&&(l=ve(),l===null&&(l=Bn())),l!==null)for(e=[];l!==null;)e.push(l),l=j(),l===null&&(l=ve(),l===null&&(l=Bn()));else e=null;return e}function Bn(){var e;return a.charCodeAt(r)===38?(e="&",r++):(e=null,_('"&"')),e===null&&(a.charCodeAt(r)===61?(e="=",r++):(e=null,_('"="')),e===null&&(a.charCodeAt(r)===43?(e="+",r++):(e=null,_('"+"')),e===null&&(a.charCodeAt(r)===36?(e="$",r++):(e=null,_('"$"')),e===null&&(a.charCodeAt(r)===44?(e=",",r++):(e=null,_('","')),e===null&&(a.charCodeAt(r)===59?(e=";",r++):(e=null,_('";"')),e===null&&(a.charCodeAt(r)===63?(e="?",r++):(e=null,_('"?"')),e===null&&(a.charCodeAt(r)===47?(e="/",r++):(e=null,_('"/"'))))))))),e}function un(){var e,l,u;for(u=r,e=[],l=j(),l===null&&(l=ve(),l===null&&(a.charCodeAt(r)===38?(l="&",r++):(l=null,_('"&"')),l===null&&(a.charCodeAt(r)===61?(l="=",r++):(l=null,_('"="')),l===null&&(a.charCodeAt(r)===43?(l="+",r++):(l=null,_('"+"')),l===null&&(a.charCodeAt(r)===36?(l="$",r++):(l=null,_('"$"')),l===null&&(a.charCodeAt(r)===44?(l=",",r++):(l=null,_('","'))))))));l!==null;)e.push(l),l=j(),l===null&&(l=ve(),l===null&&(a.charCodeAt(r)===38?(l="&",r++):(l=null,_('"&"')),l===null&&(a.charCodeAt(r)===61?(l="=",r++):(l=null,_('"="')),l===null&&(a.charCodeAt(r)===43?(l="+",r++):(l=null,_('"+"')),l===null&&(a.charCodeAt(r)===36?(l="$",r++):(l=null,_('"$"')),l===null&&(a.charCodeAt(r)===44?(l=",",r++):(l=null,_('","'))))))));return e!==null&&(e=function(f){w.password=a.substring(r,f)}(u)),e===null&&(r=u),e}function as(){var e,l,u,f,p;return f=r,e=Cs(),e!==null?(p=r,a.charCodeAt(r)===58?(l=":",r++):(l=null,_('":"')),l!==null?(u=oi(),u!==null?l=[l,u]:(l=null,r=p)):(l=null,r=p),l=l!==null?l:"",l!==null?e=[e,l]:(e=null,r=f)):(e=null,r=f),e}function Cs(){var e,l;return l=r,e=cn(),e===null&&(e=es(),e===null&&(e=fn())),e!==null&&(e=function(u){return w.host=a.substring(r,u).toLowerCase(),w.host}(l)),e===null&&(r=l),e}function cn(){var e,l,u,f,p,m;for(f=r,p=r,e=[],m=r,l=Gn(),l!==null?(a.charCodeAt(r)===46?(u=".",r++):(u=null,_('"."')),u!==null?l=[l,u]:(l=null,r=m)):(l=null,r=m);l!==null;)e.push(l),m=r,l=Gn(),l!==null?(a.charCodeAt(r)===46?(u=".",r++):(u=null,_('"."')),u!==null?l=[l,u]:(l=null,r=m)):(l=null,r=m);return e!==null?(l=Wn(),l!==null?(a.charCodeAt(r)===46?(u=".",r++):(u=null,_('"."')),u=u!==null?u:"",u!==null?e=[e,l,u]:(e=null,r=p)):(e=null,r=p)):(e=null,r=p),e!==null&&(e=function(v){return w.host_type="domain",a.substring(r,v)}(f)),e===null&&(r=f),e}function Gn(){var e,l,u,f;if(f=r,e=ie(),e!==null){for(l=[],u=ie(),u===null&&(a.charCodeAt(r)===45?(u="-",r++):(u=null,_('"-"')),u===null&&(a.charCodeAt(r)===95?(u="_",r++):(u=null,_('"_"'))));u!==null;)l.push(u),u=ie(),u===null&&(a.charCodeAt(r)===45?(u="-",r++):(u=null,_('"-"')),u===null&&(a.charCodeAt(r)===95?(u="_",r++):(u=null,_('"_"'))));l!==null?e=[e,l]:(e=null,r=f)}else e=null,r=f;return e}function Wn(){var e,l,u,f;if(f=r,e=S(),e!==null){for(l=[],u=ie(),u===null&&(a.charCodeAt(r)===45?(u="-",r++):(u=null,_('"-"')),u===null&&(a.charCodeAt(r)===95?(u="_",r++):(u=null,_('"_"'))));u!==null;)l.push(u),u=ie(),u===null&&(a.charCodeAt(r)===45?(u="-",r++):(u=null,_('"-"')),u===null&&(a.charCodeAt(r)===95?(u="_",r++):(u=null,_('"_"'))));l!==null?e=[e,l]:(e=null,r=f)}else e=null,r=f;return e}function fn(){var e,l,u,f,p;return f=r,p=r,a.charCodeAt(r)===91?(e="[",r++):(e=null,_('"["')),e!==null?(l=me(),l!==null?(a.charCodeAt(r)===93?(u="]",r++):(u=null,_('"]"')),u!==null?e=[e,l,u]:(e=null,r=p)):(e=null,r=p)):(e=null,r=p),e!==null&&(e=function(m){return w.host_type="IPv6",a.substring(r,m)}(f)),e===null&&(r=f),e}function me(){var e,l,u,f,p,m,v,y,O,le,Ue,Dt,Js,$,I,Te;return $=r,I=r,e=oe(),e!==null?(a.charCodeAt(r)===58?(l=":",r++):(l=null,_('":"')),l!==null?(u=oe(),u!==null?(a.charCodeAt(r)===58?(f=":",r++):(f=null,_('":"')),f!==null?(p=oe(),p!==null?(a.charCodeAt(r)===58?(m=":",r++):(m=null,_('":"')),m!==null?(v=oe(),v!==null?(a.charCodeAt(r)===58?(y=":",r++):(y=null,_('":"')),y!==null?(O=oe(),O!==null?(a.charCodeAt(r)===58?(le=":",r++):(le=null,_('":"')),le!==null?(Ue=oe(),Ue!==null?(a.charCodeAt(r)===58?(Dt=":",r++):(Dt=null,_('":"')),Dt!==null?(Js=ut(),Js!==null?e=[e,l,u,f,p,m,v,y,O,le,Ue,Dt,Js]:(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I),e===null&&(I=r,a.substr(r,2)==="::"?(e="::",r+=2):(e=null,_('"::"')),e!==null?(l=oe(),l!==null?(a.charCodeAt(r)===58?(u=":",r++):(u=null,_('":"')),u!==null?(f=oe(),f!==null?(a.charCodeAt(r)===58?(p=":",r++):(p=null,_('":"')),p!==null?(m=oe(),m!==null?(a.charCodeAt(r)===58?(v=":",r++):(v=null,_('":"')),v!==null?(y=oe(),y!==null?(a.charCodeAt(r)===58?(O=":",r++):(O=null,_('":"')),O!==null?(le=oe(),le!==null?(a.charCodeAt(r)===58?(Ue=":",r++):(Ue=null,_('":"')),Ue!==null?(Dt=ut(),Dt!==null?e=[e,l,u,f,p,m,v,y,O,le,Ue,Dt]:(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I),e===null&&(I=r,a.substr(r,2)==="::"?(e="::",r+=2):(e=null,_('"::"')),e!==null?(l=oe(),l!==null?(a.charCodeAt(r)===58?(u=":",r++):(u=null,_('":"')),u!==null?(f=oe(),f!==null?(a.charCodeAt(r)===58?(p=":",r++):(p=null,_('":"')),p!==null?(m=oe(),m!==null?(a.charCodeAt(r)===58?(v=":",r++):(v=null,_('":"')),v!==null?(y=oe(),y!==null?(a.charCodeAt(r)===58?(O=":",r++):(O=null,_('":"')),O!==null?(le=ut(),le!==null?e=[e,l,u,f,p,m,v,y,O,le]:(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I),e===null&&(I=r,a.substr(r,2)==="::"?(e="::",r+=2):(e=null,_('"::"')),e!==null?(l=oe(),l!==null?(a.charCodeAt(r)===58?(u=":",r++):(u=null,_('":"')),u!==null?(f=oe(),f!==null?(a.charCodeAt(r)===58?(p=":",r++):(p=null,_('":"')),p!==null?(m=oe(),m!==null?(a.charCodeAt(r)===58?(v=":",r++):(v=null,_('":"')),v!==null?(y=ut(),y!==null?e=[e,l,u,f,p,m,v,y]:(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I),e===null&&(I=r,a.substr(r,2)==="::"?(e="::",r+=2):(e=null,_('"::"')),e!==null?(l=oe(),l!==null?(a.charCodeAt(r)===58?(u=":",r++):(u=null,_('":"')),u!==null?(f=oe(),f!==null?(a.charCodeAt(r)===58?(p=":",r++):(p=null,_('":"')),p!==null?(m=ut(),m!==null?e=[e,l,u,f,p,m]:(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I),e===null&&(I=r,a.substr(r,2)==="::"?(e="::",r+=2):(e=null,_('"::"')),e!==null?(l=oe(),l!==null?(a.charCodeAt(r)===58?(u=":",r++):(u=null,_('":"')),u!==null?(f=ut(),f!==null?e=[e,l,u,f]:(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I),e===null&&(I=r,a.substr(r,2)==="::"?(e="::",r+=2):(e=null,_('"::"')),e!==null?(l=ut(),l!==null?e=[e,l]:(e=null,r=I)):(e=null,r=I),e===null&&(I=r,a.substr(r,2)==="::"?(e="::",r+=2):(e=null,_('"::"')),e!==null?(l=oe(),l!==null?e=[e,l]:(e=null,r=I)):(e=null,r=I),e===null&&(I=r,e=oe(),e!==null?(a.substr(r,2)==="::"?(l="::",r+=2):(l=null,_('"::"')),l!==null?(u=oe(),u!==null?(a.charCodeAt(r)===58?(f=":",r++):(f=null,_('":"')),f!==null?(p=oe(),p!==null?(a.charCodeAt(r)===58?(m=":",r++):(m=null,_('":"')),m!==null?(v=oe(),v!==null?(a.charCodeAt(r)===58?(y=":",r++):(y=null,_('":"')),y!==null?(O=oe(),O!==null?(a.charCodeAt(r)===58?(le=":",r++):(le=null,_('":"')),le!==null?(Ue=ut(),Ue!==null?e=[e,l,u,f,p,m,v,y,O,le,Ue]:(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I),e===null&&(I=r,e=oe(),e!==null?(Te=r,a.charCodeAt(r)===58?(l=":",r++):(l=null,_('":"')),l!==null?(u=oe(),u!==null?l=[l,u]:(l=null,r=Te)):(l=null,r=Te),l=l!==null?l:"",l!==null?(a.substr(r,2)==="::"?(u="::",r+=2):(u=null,_('"::"')),u!==null?(f=oe(),f!==null?(a.charCodeAt(r)===58?(p=":",r++):(p=null,_('":"')),p!==null?(m=oe(),m!==null?(a.charCodeAt(r)===58?(v=":",r++):(v=null,_('":"')),v!==null?(y=oe(),y!==null?(a.charCodeAt(r)===58?(O=":",r++):(O=null,_('":"')),O!==null?(le=ut(),le!==null?e=[e,l,u,f,p,m,v,y,O,le]:(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I),e===null&&(I=r,e=oe(),e!==null?(Te=r,a.charCodeAt(r)===58?(l=":",r++):(l=null,_('":"')),l!==null?(u=oe(),u!==null?l=[l,u]:(l=null,r=Te)):(l=null,r=Te),l=l!==null?l:"",l!==null?(Te=r,a.charCodeAt(r)===58?(u=":",r++):(u=null,_('":"')),u!==null?(f=oe(),f!==null?u=[u,f]:(u=null,r=Te)):(u=null,r=Te),u=u!==null?u:"",u!==null?(a.substr(r,2)==="::"?(f="::",r+=2):(f=null,_('"::"')),f!==null?(p=oe(),p!==null?(a.charCodeAt(r)===58?(m=":",r++):(m=null,_('":"')),m!==null?(v=oe(),v!==null?(a.charCodeAt(r)===58?(y=":",r++):(y=null,_('":"')),y!==null?(O=ut(),O!==null?e=[e,l,u,f,p,m,v,y,O]:(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I),e===null&&(I=r,e=oe(),e!==null?(Te=r,a.charCodeAt(r)===58?(l=":",r++):(l=null,_('":"')),l!==null?(u=oe(),u!==null?l=[l,u]:(l=null,r=Te)):(l=null,r=Te),l=l!==null?l:"",l!==null?(Te=r,a.charCodeAt(r)===58?(u=":",r++):(u=null,_('":"')),u!==null?(f=oe(),f!==null?u=[u,f]:(u=null,r=Te)):(u=null,r=Te),u=u!==null?u:"",u!==null?(Te=r,a.charCodeAt(r)===58?(f=":",r++):(f=null,_('":"')),f!==null?(p=oe(),p!==null?f=[f,p]:(f=null,r=Te)):(f=null,r=Te),f=f!==null?f:"",f!==null?(a.substr(r,2)==="::"?(p="::",r+=2):(p=null,_('"::"')),p!==null?(m=oe(),m!==null?(a.charCodeAt(r)===58?(v=":",r++):(v=null,_('":"')),v!==null?(y=ut(),y!==null?e=[e,l,u,f,p,m,v,y]:(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I),e===null&&(I=r,e=oe(),e!==null?(Te=r,a.charCodeAt(r)===58?(l=":",r++):(l=null,_('":"')),l!==null?(u=oe(),u!==null?l=[l,u]:(l=null,r=Te)):(l=null,r=Te),l=l!==null?l:"",l!==null?(Te=r,a.charCodeAt(r)===58?(u=":",r++):(u=null,_('":"')),u!==null?(f=oe(),f!==null?u=[u,f]:(u=null,r=Te)):(u=null,r=Te),u=u!==null?u:"",u!==null?(Te=r,a.charCodeAt(r)===58?(f=":",r++):(f=null,_('":"')),f!==null?(p=oe(),p!==null?f=[f,p]:(f=null,r=Te)):(f=null,r=Te),f=f!==null?f:"",f!==null?(Te=r,a.charCodeAt(r)===58?(p=":",r++):(p=null,_('":"')),p!==null?(m=oe(),m!==null?p=[p,m]:(p=null,r=Te)):(p=null,r=Te),p=p!==null?p:"",p!==null?(a.substr(r,2)==="::"?(m="::",r+=2):(m=null,_('"::"')),m!==null?(v=ut(),v!==null?e=[e,l,u,f,p,m,v]:(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I),e===null&&(I=r,e=oe(),e!==null?(Te=r,a.charCodeAt(r)===58?(l=":",r++):(l=null,_('":"')),l!==null?(u=oe(),u!==null?l=[l,u]:(l=null,r=Te)):(l=null,r=Te),l=l!==null?l:"",l!==null?(Te=r,a.charCodeAt(r)===58?(u=":",r++):(u=null,_('":"')),u!==null?(f=oe(),f!==null?u=[u,f]:(u=null,r=Te)):(u=null,r=Te),u=u!==null?u:"",u!==null?(Te=r,a.charCodeAt(r)===58?(f=":",r++):(f=null,_('":"')),f!==null?(p=oe(),p!==null?f=[f,p]:(f=null,r=Te)):(f=null,r=Te),f=f!==null?f:"",f!==null?(Te=r,a.charCodeAt(r)===58?(p=":",r++):(p=null,_('":"')),p!==null?(m=oe(),m!==null?p=[p,m]:(p=null,r=Te)):(p=null,r=Te),p=p!==null?p:"",p!==null?(Te=r,a.charCodeAt(r)===58?(m=":",r++):(m=null,_('":"')),m!==null?(v=oe(),v!==null?m=[m,v]:(m=null,r=Te)):(m=null,r=Te),m=m!==null?m:"",m!==null?(a.substr(r,2)==="::"?(v="::",r+=2):(v=null,_('"::"')),v!==null?(y=oe(),y!==null?e=[e,l,u,f,p,m,v,y]:(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I),e===null&&(I=r,e=oe(),e!==null?(Te=r,a.charCodeAt(r)===58?(l=":",r++):(l=null,_('":"')),l!==null?(u=oe(),u!==null?l=[l,u]:(l=null,r=Te)):(l=null,r=Te),l=l!==null?l:"",l!==null?(Te=r,a.charCodeAt(r)===58?(u=":",r++):(u=null,_('":"')),u!==null?(f=oe(),f!==null?u=[u,f]:(u=null,r=Te)):(u=null,r=Te),u=u!==null?u:"",u!==null?(Te=r,a.charCodeAt(r)===58?(f=":",r++):(f=null,_('":"')),f!==null?(p=oe(),p!==null?f=[f,p]:(f=null,r=Te)):(f=null,r=Te),f=f!==null?f:"",f!==null?(Te=r,a.charCodeAt(r)===58?(p=":",r++):(p=null,_('":"')),p!==null?(m=oe(),m!==null?p=[p,m]:(p=null,r=Te)):(p=null,r=Te),p=p!==null?p:"",p!==null?(Te=r,a.charCodeAt(r)===58?(m=":",r++):(m=null,_('":"')),m!==null?(v=oe(),v!==null?m=[m,v]:(m=null,r=Te)):(m=null,r=Te),m=m!==null?m:"",m!==null?(Te=r,a.charCodeAt(r)===58?(v=":",r++):(v=null,_('":"')),v!==null?(y=oe(),y!==null?v=[v,y]:(v=null,r=Te)):(v=null,r=Te),v=v!==null?v:"",v!==null?(a.substr(r,2)==="::"?(y="::",r+=2):(y=null,_('"::"')),y!==null?e=[e,l,u,f,p,m,v,y]:(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I)):(e=null,r=I))))))))))))))),e!==null&&(e=function(Xv){return w.host_type="IPv6",a.substring(r,Xv)}($)),e===null&&(r=$),e}function oe(){var e,l,u,f,p;return p=r,e=E(),e!==null?(l=E(),l=l!==null?l:"",l!==null?(u=E(),u=u!==null?u:"",u!==null?(f=E(),f=f!==null?f:"",f!==null?e=[e,l,u,f]:(e=null,r=p)):(e=null,r=p)):(e=null,r=p)):(e=null,r=p),e}function ut(){var e,l,u,f;return f=r,e=oe(),e!==null?(a.charCodeAt(r)===58?(l=":",r++):(l=null,_('":"')),l!==null?(u=oe(),u!==null?e=[e,l,u]:(e=null,r=f)):(e=null,r=f)):(e=null,r=f),e===null&&(e=es()),e}function es(){var e,l,u,f,p,m,v,y,O;return y=r,O=r,e=$s(),e!==null?(a.charCodeAt(r)===46?(l=".",r++):(l=null,_('"."')),l!==null?(u=$s(),u!==null?(a.charCodeAt(r)===46?(f=".",r++):(f=null,_('"."')),f!==null?(p=$s(),p!==null?(a.charCodeAt(r)===46?(m=".",r++):(m=null,_('"."')),m!==null?(v=$s(),v!==null?e=[e,l,u,f,p,m,v]:(e=null,r=O)):(e=null,r=O)):(e=null,r=O)):(e=null,r=O)):(e=null,r=O)):(e=null,r=O)):(e=null,r=O),e!==null&&(e=function(le){return w.host_type="IPv4",a.substring(r,le)}(y)),e===null&&(r=y),e}function $s(){var e,l,u,f;return f=r,a.substr(r,2)==="25"?(e="25",r+=2):(e=null,_('"25"')),e!==null?(/^[0-5]/.test(a.charAt(r))?(l=a.charAt(r),r++):(l=null,_("[0-5]")),l!==null?e=[e,l]:(e=null,r=f)):(e=null,r=f),e===null&&(f=r,a.charCodeAt(r)===50?(e="2",r++):(e=null,_('"2"')),e!==null?(/^[0-4]/.test(a.charAt(r))?(l=a.charAt(r),r++):(l=null,_("[0-4]")),l!==null?(u=T(),u!==null?e=[e,l,u]:(e=null,r=f)):(e=null,r=f)):(e=null,r=f),e===null&&(f=r,a.charCodeAt(r)===49?(e="1",r++):(e=null,_('"1"')),e!==null?(l=T(),l!==null?(u=T(),u!==null?e=[e,l,u]:(e=null,r=f)):(e=null,r=f)):(e=null,r=f),e===null&&(f=r,/^[1-9]/.test(a.charAt(r))?(e=a.charAt(r),r++):(e=null,_("[1-9]")),e!==null?(l=T(),l!==null?e=[e,l]:(e=null,r=f)):(e=null,r=f),e===null&&(e=T())))),e}function oi(){var e,l,u,f,p,m,v;return m=r,v=r,e=T(),e=e!==null?e:"",e!==null?(l=T(),l=l!==null?l:"",l!==null?(u=T(),u=u!==null?u:"",u!==null?(f=T(),f=f!==null?f:"",f!==null?(p=T(),p=p!==null?p:"",p!==null?e=[e,l,u,f,p]:(e=null,r=v)):(e=null,r=v)):(e=null,r=v)):(e=null,r=v)):(e=null,r=v),e!==null&&(e=function(y,O){return O=parseInt(O.join("")),w.port=O,O}(m,e)),e===null&&(r=m),e}function Kn(){var e,l,u,f;for(e=[],f=r,a.charCodeAt(r)===59?(l=";",r++):(l=null,_('";"')),l!==null?(u=Yn(),u!==null?l=[l,u]:(l=null,r=f)):(l=null,r=f);l!==null;)e.push(l),f=r,a.charCodeAt(r)===59?(l=";",r++):(l=null,_('";"')),l!==null?(u=Yn(),u!==null?l=[l,u]:(l=null,r=f)):(l=null,r=f);return e}function Yn(){var e;return e=ui(),e===null&&(e=ci(),e===null&&(e=fi(),e===null&&(e=hi(),e===null&&(e=di(),e===null&&(e=_i(),e===null&&(e=pi())))))),e}function ui(){var e,l,u,f;return u=r,f=r,a.substr(r,10).toLowerCase()==="transport="?(e=a.substr(r,10),r+=10):(e=null,_('"transport="')),e!==null?(a.substr(r,3).toLowerCase()==="udp"?(l=a.substr(r,3),r+=3):(l=null,_('"udp"')),l===null&&(a.substr(r,3).toLowerCase()==="tcp"?(l=a.substr(r,3),r+=3):(l=null,_('"tcp"')),l===null&&(a.substr(r,4).toLowerCase()==="sctp"?(l=a.substr(r,4),r+=4):(l=null,_('"sctp"')),l===null&&(a.substr(r,3).toLowerCase()==="tls"?(l=a.substr(r,3),r+=3):(l=null,_('"tls"')),l===null&&(l=x())))),l!==null?e=[e,l]:(e=null,r=f)):(e=null,r=f),e!==null&&(e=function(p,m){w.uri_params||(w.uri_params={}),w.uri_params.transport=m.toLowerCase()}(u,e[1])),e===null&&(r=u),e}function ci(){var e,l,u,f;return u=r,f=r,a.substr(r,5).toLowerCase()==="user="?(e=a.substr(r,5),r+=5):(e=null,_('"user="')),e!==null?(a.substr(r,5).toLowerCase()==="phone"?(l=a.substr(r,5),r+=5):(l=null,_('"phone"')),l===null&&(a.substr(r,2).toLowerCase()==="ip"?(l=a.substr(r,2),r+=2):(l=null,_('"ip"')),l===null&&(l=x())),l!==null?e=[e,l]:(e=null,r=f)):(e=null,r=f),e!==null&&(e=function(p,m){w.uri_params||(w.uri_params={}),w.uri_params.user=m.toLowerCase()}(u,e[1])),e===null&&(r=u),e}function fi(){var e,l,u,f;return u=r,f=r,a.substr(r,7).toLowerCase()==="method="?(e=a.substr(r,7),r+=7):(e=null,_('"method="')),e!==null?(l=vn(),l!==null?e=[e,l]:(e=null,r=f)):(e=null,r=f),e!==null&&(e=function(p,m){w.uri_params||(w.uri_params={}),w.uri_params.method=m}(u,e[1])),e===null&&(r=u),e}function hi(){var e,l,u,f;return u=r,f=r,a.substr(r,4).toLowerCase()==="ttl="?(e=a.substr(r,4),r+=4):(e=null,_('"ttl="')),e!==null?(l=hl(),l!==null?e=[e,l]:(e=null,r=f)):(e=null,r=f),e!==null&&(e=function(p,m){w.params||(w.params={}),w.params.ttl=m}(u,e[1])),e===null&&(r=u),e}function di(){var e,l,u,f;return u=r,f=r,a.substr(r,6).toLowerCase()==="maddr="?(e=a.substr(r,6),r+=6):(e=null,_('"maddr="')),e!==null?(l=Cs(),l!==null?e=[e,l]:(e=null,r=f)):(e=null,r=f),e!==null&&(e=function(p,m){w.uri_params||(w.uri_params={}),w.uri_params.maddr=m}(u,e[1])),e===null&&(r=u),e}function _i(){var e,l,u,f,p,m;return f=r,p=r,a.substr(r,2).toLowerCase()==="lr"?(e=a.substr(r,2),r+=2):(e=null,_('"lr"')),e!==null?(m=r,a.charCodeAt(r)===61?(l="=",r++):(l=null,_('"="')),l!==null?(u=x(),u!==null?l=[l,u]:(l=null,r=m)):(l=null,r=m),l=l!==null?l:"",l!==null?e=[e,l]:(e=null,r=p)):(e=null,r=p),e!==null&&(e=function(v){w.uri_params||(w.uri_params={}),w.uri_params.lr=void 0}()),e===null&&(r=f),e}function pi(){var e,l,u,f,p,m;return f=r,p=r,e=mi(),e!==null?(m=r,a.charCodeAt(r)===61?(l="=",r++):(l=null,_('"="')),l!==null?(u=Hs(),u!==null?l=[l,u]:(l=null,r=m)):(l=null,r=m),l=l!==null?l:"",l!==null?e=[e,l]:(e=null,r=p)):(e=null,r=p),e!==null&&(e=function(v,y,O){w.uri_params||(w.uri_params={}),typeof O>"u"?O=void 0:O=O[1],w.uri_params[y.toLowerCase()]=O}(f,e[0],e[1])),e===null&&(r=f),e}function mi(){var e,l,u;if(u=r,l=Fs(),l!==null)for(e=[];l!==null;)e.push(l),l=Fs();else e=null;return e!==null&&(e=function(f,p){return p.join("")}(u,e)),e===null&&(r=u),e}function Hs(){var e,l,u;if(u=r,l=Fs(),l!==null)for(e=[];l!==null;)e.push(l),l=Fs();else e=null;return e!==null&&(e=function(f,p){return p.join("")}(u,e)),e===null&&(r=u),e}function Fs(){var e;return e=gi(),e===null&&(e=j(),e===null&&(e=ve())),e}function gi(){var e;return a.charCodeAt(r)===91?(e="[",r++):(e=null,_('"["')),e===null&&(a.charCodeAt(r)===93?(e="]",r++):(e=null,_('"]"')),e===null&&(a.charCodeAt(r)===47?(e="/",r++):(e=null,_('"/"')),e===null&&(a.charCodeAt(r)===58?(e=":",r++):(e=null,_('":"')),e===null&&(a.charCodeAt(r)===38?(e="&",r++):(e=null,_('"&"')),e===null&&(a.charCodeAt(r)===43?(e="+",r++):(e=null,_('"+"')),e===null&&(a.charCodeAt(r)===36?(e="$",r++):(e=null,_('"$"')))))))),e}function hn(){var e,l,u,f,p,m,v;if(m=r,a.charCodeAt(r)===63?(e="?",r++):(e=null,_('"?"')),e!==null)if(l=dn(),l!==null){for(u=[],v=r,a.charCodeAt(r)===38?(f="&",r++):(f=null,_('"&"')),f!==null?(p=dn(),p!==null?f=[f,p]:(f=null,r=v)):(f=null,r=v);f!==null;)u.push(f),v=r,a.charCodeAt(r)===38?(f="&",r++):(f=null,_('"&"')),f!==null?(p=dn(),p!==null?f=[f,p]:(f=null,r=v)):(f=null,r=v);u!==null?e=[e,l,u]:(e=null,r=m)}else e=null,r=m;else e=null,r=m;return e}function dn(){var e,l,u,f,p;return f=r,p=r,e=Ti(),e!==null?(a.charCodeAt(r)===61?(l="=",r++):(l=null,_('"="')),l!==null?(u=js(),u!==null?e=[e,l,u]:(e=null,r=p)):(e=null,r=p)):(e=null,r=p),e!==null&&(e=function(m,v,y){v=v.join("").toLowerCase(),y=y.join(""),w.uri_headers||(w.uri_headers={}),w.uri_headers[v]?w.uri_headers[v].push(y):w.uri_headers[v]=[y]}(f,e[0],e[2])),e===null&&(r=f),e}function Ti(){var e,l;if(l=_n(),l===null&&(l=j(),l===null&&(l=ve())),l!==null)for(e=[];l!==null;)e.push(l),l=_n(),l===null&&(l=j(),l===null&&(l=ve()));else e=null;return e}function js(){var e,l;for(e=[],l=_n(),l===null&&(l=j(),l===null&&(l=ve()));l!==null;)e.push(l),l=_n(),l===null&&(l=j(),l===null&&(l=ve()));return e}function _n(){var e;return a.charCodeAt(r)===91?(e="[",r++):(e=null,_('"["')),e===null&&(a.charCodeAt(r)===93?(e="]",r++):(e=null,_('"]"')),e===null&&(a.charCodeAt(r)===47?(e="/",r++):(e=null,_('"/"')),e===null&&(a.charCodeAt(r)===63?(e="?",r++):(e=null,_('"?"')),e===null&&(a.charCodeAt(r)===58?(e=":",r++):(e=null,_('":"')),e===null&&(a.charCodeAt(r)===43?(e="+",r++):(e=null,_('"+"')),e===null&&(a.charCodeAt(r)===36?(e="$",r++):(e=null,_('"$"')))))))),e}function wa(){var e;return e=Pi(),e===null&&(e=vi()),e}function vi(){var e,l,u,f,p,m;return m=r,e=vn(),e!==null?(l=k(),l!==null?(u=Jn(),u!==null?(f=k(),f!==null?(p=Qn(),p!==null?e=[e,l,u,f,p]:(e=null,r=m)):(e=null,r=m)):(e=null,r=m)):(e=null,r=m)):(e=null,r=m),e}function Jn(){var e;return e=Ne(),e===null&&(e=zn()),e}function zn(){var e,l,u,f;return f=r,e=yi(),e!==null?(a.charCodeAt(r)===58?(l=":",r++):(l=null,_('":"')),l!==null?(u=Si(),u===null&&(u=Vs()),u!==null?e=[e,l,u]:(e=null,r=f)):(e=null,r=f)):(e=null,r=f),e}function Si(){var e,l,u,f,p;return f=r,e=pn(),e===null&&(e=mn()),e!==null?(p=r,a.charCodeAt(r)===63?(l="?",r++):(l=null,_('"?"')),l!==null?(u=Xn(),u!==null?l=[l,u]:(l=null,r=p)):(l=null,r=p),l=l!==null?l:"",l!==null?e=[e,l]:(e=null,r=f)):(e=null,r=f),e}function pn(){var e,l,u,f;return f=r,a.substr(r,2)==="//"?(e="//",r+=2):(e=null,_('"//"')),e!==null?(l=Ci(),l!==null?(u=mn(),u=u!==null?u:"",u!==null?e=[e,l,u]:(e=null,r=f)):(e=null,r=f)):(e=null,r=f),e}function mn(){var e,l,u;return u=r,a.charCodeAt(r)===47?(e="/",r++):(e=null,_('"/"')),e!==null?(l=gn(),l!==null?e=[e,l]:(e=null,r=u)):(e=null,r=u),e}function Vs(){var e,l,u,f;if(f=r,e=Ei(),e!==null){for(l=[],u=qs();u!==null;)l.push(u),u=qs();l!==null?e=[e,l]:(e=null,r=f)}else e=null,r=f;return e}function qs(){var e;return e=N(),e===null&&(e=j(),e===null&&(e=ve())),e}function Ei(){var e;return e=j(),e===null&&(e=ve(),e===null&&(a.charCodeAt(r)===59?(e=";",r++):(e=null,_('";"')),e===null&&(a.charCodeAt(r)===63?(e="?",r++):(e=null,_('"?"')),e===null&&(a.charCodeAt(r)===58?(e=":",r++):(e=null,_('":"')),e===null&&(a.charCodeAt(r)===64?(e="@",r++):(e=null,_('"@"')),e===null&&(a.charCodeAt(r)===38?(e="&",r++):(e=null,_('"&"')),e===null&&(a.charCodeAt(r)===61?(e="=",r++):(e=null,_('"="')),e===null&&(a.charCodeAt(r)===43?(e="+",r++):(e=null,_('"+"')),e===null&&(a.charCodeAt(r)===36?(e="$",r++):(e=null,_('"$"')),e===null&&(a.charCodeAt(r)===44?(e=",",r++):(e=null,_('","')))))))))))),e}function gn(){var e,l,u,f,p,m;if(p=r,e=Bs(),e!==null){for(l=[],m=r,a.charCodeAt(r)===47?(u="/",r++):(u=null,_('"/"')),u!==null?(f=Bs(),f!==null?u=[u,f]:(u=null,r=m)):(u=null,r=m);u!==null;)l.push(u),m=r,a.charCodeAt(r)===47?(u="/",r++):(u=null,_('"/"')),u!==null?(f=Bs(),f!==null?u=[u,f]:(u=null,r=m)):(u=null,r=m);l!==null?e=[e,l]:(e=null,r=p)}else e=null,r=p;return e}function Bs(){var e,l,u,f,p,m;for(p=r,e=[],l=Gs();l!==null;)e.push(l),l=Gs();if(e!==null){for(l=[],m=r,a.charCodeAt(r)===59?(u=";",r++):(u=null,_('";"')),u!==null?(f=As(),f!==null?u=[u,f]:(u=null,r=m)):(u=null,r=m);u!==null;)l.push(u),m=r,a.charCodeAt(r)===59?(u=";",r++):(u=null,_('";"')),u!==null?(f=As(),f!==null?u=[u,f]:(u=null,r=m)):(u=null,r=m);l!==null?e=[e,l]:(e=null,r=p)}else e=null,r=p;return e}function As(){var e,l;for(e=[],l=Gs();l!==null;)e.push(l),l=Gs();return e}function Gs(){var e;return e=j(),e===null&&(e=ve(),e===null&&(a.charCodeAt(r)===58?(e=":",r++):(e=null,_('":"')),e===null&&(a.charCodeAt(r)===64?(e="@",r++):(e=null,_('"@"')),e===null&&(a.charCodeAt(r)===38?(e="&",r++):(e=null,_('"&"')),e===null&&(a.charCodeAt(r)===61?(e="=",r++):(e=null,_('"="')),e===null&&(a.charCodeAt(r)===43?(e="+",r++):(e=null,_('"+"')),e===null&&(a.charCodeAt(r)===36?(e="$",r++):(e=null,_('"$"')),e===null&&(a.charCodeAt(r)===44?(e=",",r++):(e=null,_('","')))))))))),e}function yi(){var e,l,u,f,p;if(f=r,p=r,e=S(),e!==null){for(l=[],u=S(),u===null&&(u=T(),u===null&&(a.charCodeAt(r)===43?(u="+",r++):(u=null,_('"+"')),u===null&&(a.charCodeAt(r)===45?(u="-",r++):(u=null,_('"-"')),u===null&&(a.charCodeAt(r)===46?(u=".",r++):(u=null,_('"."'))))));u!==null;)l.push(u),u=S(),u===null&&(u=T(),u===null&&(a.charCodeAt(r)===43?(u="+",r++):(u=null,_('"+"')),u===null&&(a.charCodeAt(r)===45?(u="-",r++):(u=null,_('"-"')),u===null&&(a.charCodeAt(r)===46?(u=".",r++):(u=null,_('"."'))))));l!==null?e=[e,l]:(e=null,r=p)}else e=null,r=p;return e!==null&&(e=function(m){w.scheme=a.substring(r,m)}(f)),e===null&&(r=f),e}function Ci(){var e;return e=Ai(),e===null&&(e=Ri()),e}function Ai(){var e,l,u,f;return u=r,f=r,e=At(),e!==null?(a.charCodeAt(r)===64?(l="@",r++):(l=null,_('"@"')),l!==null?e=[e,l]:(e=null,r=f)):(e=null,r=f),e=e!==null?e:"",e!==null?(l=as(),l!==null?e=[e,l]:(e=null,r=u)):(e=null,r=u),e=e!==null?e:"",e}function Ri(){var e,l;if(l=j(),l===null&&(l=ve(),l===null&&(a.charCodeAt(r)===36?(l="$",r++):(l=null,_('"$"')),l===null&&(a.charCodeAt(r)===44?(l=",",r++):(l=null,_('","')),l===null&&(a.charCodeAt(r)===59?(l=";",r++):(l=null,_('";"')),l===null&&(a.charCodeAt(r)===58?(l=":",r++):(l=null,_('":"')),l===null&&(a.charCodeAt(r)===64?(l="@",r++):(l=null,_('"@"')),l===null&&(a.charCodeAt(r)===38?(l="&",r++):(l=null,_('"&"')),l===null&&(a.charCodeAt(r)===61?(l="=",r++):(l=null,_('"="')),l===null&&(a.charCodeAt(r)===43?(l="+",r++):(l=null,_('"+"'))))))))))),l!==null)for(e=[];l!==null;)e.push(l),l=j(),l===null&&(l=ve(),l===null&&(a.charCodeAt(r)===36?(l="$",r++):(l=null,_('"$"')),l===null&&(a.charCodeAt(r)===44?(l=",",r++):(l=null,_('","')),l===null&&(a.charCodeAt(r)===59?(l=";",r++):(l=null,_('";"')),l===null&&(a.charCodeAt(r)===58?(l=":",r++):(l=null,_('":"')),l===null&&(a.charCodeAt(r)===64?(l="@",r++):(l=null,_('"@"')),l===null&&(a.charCodeAt(r)===38?(l="&",r++):(l=null,_('"&"')),l===null&&(a.charCodeAt(r)===61?(l="=",r++):(l=null,_('"="')),l===null&&(a.charCodeAt(r)===43?(l="+",r++):(l=null,_('"+"')))))))))));else e=null;return e}function Xn(){var e,l;for(e=[],l=qs();l!==null;)e.push(l),l=qs();return e}function Qn(){var e,l,u,f,p,m,v,y;if(v=r,y=r,a.substr(r,3).toLowerCase()==="sip"?(e=a.substr(r,3),r+=3):(e=null,_('"SIP"')),e!==null)if(a.charCodeAt(r)===47?(l="/",r++):(l=null,_('"/"')),l!==null){if(f=T(),f!==null)for(u=[];f!==null;)u.push(f),f=T();else u=null;if(u!==null)if(a.charCodeAt(r)===46?(f=".",r++):(f=null,_('"."')),f!==null){if(m=T(),m!==null)for(p=[];m!==null;)p.push(m),m=T();else p=null;p!==null?e=[e,l,u,f,p]:(e=null,r=y)}else e=null,r=y;else e=null,r=y}else e=null,r=y;else e=null,r=y;return e!==null&&(e=function(O){w.sip_version=a.substring(r,O)}(v)),e===null&&(r=v),e}function Ii(){var e;return a.substr(r,6)==="INVITE"?(e="INVITE",r+=6):(e=null,_('"INVITE"')),e}function bi(){var e;return a.substr(r,3)==="ACK"?(e="ACK",r+=3):(e=null,_('"ACK"')),e}function wi(){var e;return a.substr(r,7)==="OPTIONS"?(e="OPTIONS",r+=7):(e=null,_('"OPTIONS"')),e}function Oi(){var e;return a.substr(r,3)==="BYE"?(e="BYE",r+=3):(e=null,_('"BYE"')),e}function Di(){var e;return a.substr(r,6)==="CANCEL"?(e="CANCEL",r+=6):(e=null,_('"CANCEL"')),e}function Ni(){var e;return a.substr(r,8)==="REGISTER"?(e="REGISTER",r+=8):(e=null,_('"REGISTER"')),e}function Ui(){var e;return a.substr(r,9)==="SUBSCRIBE"?(e="SUBSCRIBE",r+=9):(e=null,_('"SUBSCRIBE"')),e}function xi(){var e;return a.substr(r,6)==="NOTIFY"?(e="NOTIFY",r+=6):(e=null,_('"NOTIFY"')),e}function Tn(){var e;return a.substr(r,5)==="REFER"?(e="REFER",r+=5):(e=null,_('"REFER"')),e}function vn(){var e,l;return l=r,e=Ii(),e===null&&(e=bi(),e===null&&(e=wi(),e===null&&(e=Oi(),e===null&&(e=Di(),e===null&&(e=Ni(),e===null&&(e=Ui(),e===null&&(e=xi(),e===null&&(e=Tn(),e===null&&(e=x()))))))))),e!==null&&(e=function(u){return w.method=a.substring(r,u),w.method}(l)),e===null&&(r=l),e}function Pi(){var e,l,u,f,p,m;return m=r,e=Qn(),e!==null?(l=k(),l!==null?(u=ki(),u!==null?(f=k(),f!==null?(p=Oa(),p!==null?e=[e,l,u,f,p]:(e=null,r=m)):(e=null,r=m)):(e=null,r=m)):(e=null,r=m)):(e=null,r=m),e}function ki(){var e,l;return l=r,e=Mi(),e!==null&&(e=function(u,f){w.status_code=parseInt(f.join(""))}(l,e)),e===null&&(r=l),e}function Mi(){var e,l,u,f;return f=r,e=T(),e!==null?(l=T(),l!==null?(u=T(),u!==null?e=[e,l,u]:(e=null,r=f)):(e=null,r=f)):(e=null,r=f),e}function Oa(){var e,l,u;for(u=r,e=[],l=N(),l===null&&(l=j(),l===null&&(l=ve(),l===null&&(l=F(),l===null&&(l=Z(),l===null&&(l=k(),l===null&&(l=M()))))));l!==null;)e.push(l),l=N(),l===null&&(l=j(),l===null&&(l=ve(),l===null&&(l=F(),l===null&&(l=Z(),l===null&&(l=k(),l===null&&(l=M()))))));return e!==null&&(e=function(f){w.reason_phrase=a.substring(r,f)}(u)),e===null&&(r=u),e}function Du(){var e,l,u,f,p,m;if(p=r,e=Cn(),e!==null){for(l=[],m=r,u=ae(),u!==null?(f=Cn(),f!==null?u=[u,f]:(u=null,r=m)):(u=null,r=m);u!==null;)l.push(u),m=r,u=ae(),u!==null?(f=Cn(),f!==null?u=[u,f]:(u=null,r=m)):(u=null,r=m);l!==null?e=[e,l]:(e=null,r=p)}else e=null,r=p;return e}function Nu(){var e,l,u,f,p,m;return f=r,p=r,e=ee(),e!==null?(m=r,a.charCodeAt(r)===64?(l="@",r++):(l=null,_('"@"')),l!==null?(u=ee(),u!==null?l=[l,u]:(l=null,r=m)):(l=null,r=m),l=l!==null?l:"",l!==null?e=[e,l]:(e=null,r=p)):(e=null,r=p),e!==null&&(e=function(v){w=a.substring(r,v)}(f)),e===null&&(r=f),e}function Zn(){var e,l,u,f,p,m,v;if(p=r,e=Y(),e===null)if(m=r,e=Bt(),e!==null){for(l=[],v=r,u=ae(),u!==null?(f=Bt(),f!==null?u=[u,f]:(u=null,r=v)):(u=null,r=v);u!==null;)l.push(u),v=r,u=ae(),u!==null?(f=Bt(),f!==null?u=[u,f]:(u=null,r=v)):(u=null,r=v);l!==null?e=[e,l]:(e=null,r=m)}else e=null,r=m;return e!==null&&(e=function(y){var O,le;for(le=w.multi_header.length,O=0;O<le;O++)if(w.multi_header[O].parsed===null){w=null;break}w!==null?w=w.multi_header:w=-1}()),e===null&&(r=p),e}function Bt(){var e,l,u,f,p,m,v;if(p=r,m=r,e=we(),e===null&&(e=Gt()),e!==null){for(l=[],v=r,u=ye(),u!==null?(f=er(),f!==null?u=[u,f]:(u=null,r=v)):(u=null,r=v);u!==null;)l.push(u),v=r,u=ye(),u!==null?(f=er(),f!==null?u=[u,f]:(u=null,r=v)):(u=null,r=v);l!==null?e=[e,l]:(e=null,r=m)}else e=null,r=m;return e!==null&&(e=function(y){var O;w.multi_header||(w.multi_header=[]);try{O=new b(w.uri,w.display_name,w.params),delete w.uri,delete w.display_name,delete w.params}catch{O=null}w.multi_header.push({possition:r,offset:y,parsed:O})}(p)),e===null&&(r=p),e}function Gt(){var e,l,u,f,p;return p=r,e=Ws(),e=e!==null?e:"",e!==null?(l=Re(),l!==null?(u=Ne(),u!==null?(f=ke(),f!==null?e=[e,l,u,f]:(e=null,r=p)):(e=null,r=p)):(e=null,r=p)):(e=null,r=p),e}function Ws(){var e,l,u,f,p,m,v;if(p=r,m=r,e=x(),e!==null){for(l=[],v=r,u=L(),u!==null?(f=x(),f!==null?u=[u,f]:(u=null,r=v)):(u=null,r=v);u!==null;)l.push(u),v=r,u=L(),u!==null?(f=x(),f!==null?u=[u,f]:(u=null,r=v)):(u=null,r=v);l!==null?e=[e,l]:(e=null,r=m)}else e=null,r=m;return e===null&&(e=pe()),e!==null&&(e=function(y,O){typeof O=="string"?w.display_name=O:w.display_name=O[1].reduce(function(le,Ue){return le+Ue[0]+Ue[1]},O[0])}(p,e)),e===null&&(r=p),e}function er(){var e;return e=Li(),e===null&&(e=os(),e===null&&(e=ze())),e}function Li(){var e,l,u,f,p;return f=r,p=r,a.substr(r,1).toLowerCase()==="q"?(e=a.substr(r,1),r++):(e=null,_('"q"')),e!==null?(l=re(),l!==null?(u=Je(),u!==null?e=[e,l,u]:(e=null,r=p)):(e=null,r=p)):(e=null,r=p),e!==null&&(e=function(m,v){w.params||(w.params={}),w.params.q=v}(f,e[2])),e===null&&(r=f),e}function os(){var e,l,u,f,p;return f=r,p=r,a.substr(r,7).toLowerCase()==="expires"?(e=a.substr(r,7),r+=7):(e=null,_('"expires"')),e!==null?(l=re(),l!==null?(u=us(),u!==null?e=[e,l,u]:(e=null,r=p)):(e=null,r=p)):(e=null,r=p),e!==null&&(e=function(m,v){w.params||(w.params={}),w.params.expires=v}(f,e[2])),e===null&&(r=f),e}function us(){var e,l,u;if(u=r,l=T(),l!==null)for(e=[];l!==null;)e.push(l),l=T();else e=null;return e!==null&&(e=function(f,p){return parseInt(p.join(""))}(u,e)),e===null&&(r=u),e}function Je(){var e,l,u,f,p,m,v,y;return m=r,v=r,a.charCodeAt(r)===48?(e="0",r++):(e=null,_('"0"')),e!==null?(y=r,a.charCodeAt(r)===46?(l=".",r++):(l=null,_('"."')),l!==null?(u=T(),u=u!==null?u:"",u!==null?(f=T(),f=f!==null?f:"",f!==null?(p=T(),p=p!==null?p:"",p!==null?l=[l,u,f,p]:(l=null,r=y)):(l=null,r=y)):(l=null,r=y)):(l=null,r=y),l=l!==null?l:"",l!==null?e=[e,l]:(e=null,r=v)):(e=null,r=v),e!==null&&(e=function(O){return parseFloat(a.substring(r,O))}(m)),e===null&&(r=m),e}function ze(){var e,l,u,f,p,m;return f=r,p=r,e=x(),e!==null?(m=r,l=re(),l!==null?(u=Da(),u!==null?l=[l,u]:(l=null,r=m)):(l=null,r=m),l=l!==null?l:"",l!==null?e=[e,l]:(e=null,r=p)):(e=null,r=p),e!==null&&(e=function(v,y,O){w.params||(w.params={}),typeof O>"u"?O=void 0:O=O[1],w.params[y.toLowerCase()]=O}(f,e[0],e[1])),e===null&&(r=f),e}function Da(){var e;return e=x(),e===null&&(e=Cs(),e===null&&(e=Oe())),e}function Na(){var e,l,u,f,p,m;if(p=r,e=tr(),e!==null){for(l=[],m=r,u=ye(),u!==null?(f=sr(),f!==null?u=[u,f]:(u=null,r=m)):(u=null,r=m);u!==null;)l.push(u),m=r,u=ye(),u!==null?(f=sr(),f!==null?u=[u,f]:(u=null,r=m)):(u=null,r=m);l!==null?e=[e,l]:(e=null,r=p)}else e=null,r=p;return e}function tr(){var e;return a.substr(r,6).toLowerCase()==="render"?(e=a.substr(r,6),r+=6):(e=null,_('"render"')),e===null&&(a.substr(r,7).toLowerCase()==="session"?(e=a.substr(r,7),r+=7):(e=null,_('"session"')),e===null&&(a.substr(r,4).toLowerCase()==="icon"?(e=a.substr(r,4),r+=4):(e=null,_('"icon"')),e===null&&(a.substr(r,5).toLowerCase()==="alert"?(e=a.substr(r,5),r+=5):(e=null,_('"alert"')),e===null&&(e=x())))),e}function sr(){var e;return e=Ua(),e===null&&(e=ze()),e}function Ua(){var e,l,u,f;return f=r,a.substr(r,8).toLowerCase()==="handling"?(e=a.substr(r,8),r+=8):(e=null,_('"handling"')),e!==null?(l=re(),l!==null?(a.substr(r,8).toLowerCase()==="optional"?(u=a.substr(r,8),r+=8):(u=null,_('"optional"')),u===null&&(a.substr(r,8).toLowerCase()==="required"?(u=a.substr(r,8),r+=8):(u=null,_('"required"')),u===null&&(u=x())),u!==null?e=[e,l,u]:(e=null,r=f)):(e=null,r=f)):(e=null,r=f),e}function Uu(){var e,l,u,f,p,m;if(p=r,e=x(),e!==null){for(l=[],m=r,u=ae(),u!==null?(f=x(),f!==null?u=[u,f]:(u=null,r=m)):(u=null,r=m);u!==null;)l.push(u),m=r,u=ae(),u!==null?(f=x(),f!==null?u=[u,f]:(u=null,r=m)):(u=null,r=m);l!==null?e=[e,l]:(e=null,r=p)}else e=null,r=p;return e}function xu(){var e,l,u;if(u=r,l=T(),l!==null)for(e=[];l!==null;)e.push(l),l=T();else e=null;return e!==null&&(e=function(f,p){w=parseInt(p.join(""))}(u,e)),e===null&&(r=u),e}function xa(){var e,l;return l=r,e=$i(),e!==null&&(e=function(u){w=a.substring(r,u)}(l)),e===null&&(r=l),e}function $i(){var e,l,u,f,p,m,v,y;if(v=r,e=Hi(),e!==null)if(l=G(),l!==null)if(u=nr(),u!==null){for(f=[],y=r,p=ye(),p!==null?(m=rr(),m!==null?p=[p,m]:(p=null,r=y)):(p=null,r=y);p!==null;)f.push(p),y=r,p=ye(),p!==null?(m=rr(),m!==null?p=[p,m]:(p=null,r=y)):(p=null,r=y);f!==null?e=[e,l,u,f]:(e=null,r=v)}else e=null,r=v;else e=null,r=v;else e=null,r=v;return e}function Hi(){var e;return e=Fi(),e===null&&(e=Sn()),e}function Fi(){var e;return a.substr(r,4).toLowerCase()==="text"?(e=a.substr(r,4),r+=4):(e=null,_('"text"')),e===null&&(a.substr(r,5).toLowerCase()==="image"?(e=a.substr(r,5),r+=5):(e=null,_('"image"')),e===null&&(a.substr(r,5).toLowerCase()==="audio"?(e=a.substr(r,5),r+=5):(e=null,_('"audio"')),e===null&&(a.substr(r,5).toLowerCase()==="video"?(e=a.substr(r,5),r+=5):(e=null,_('"video"')),e===null&&(a.substr(r,11).toLowerCase()==="application"?(e=a.substr(r,11),r+=11):(e=null,_('"application"')),e===null&&(e=En()))))),e}function Sn(){var e;return a.substr(r,7).toLowerCase()==="message"?(e=a.substr(r,7),r+=7):(e=null,_('"message"')),e===null&&(a.substr(r,9).toLowerCase()==="multipart"?(e=a.substr(r,9),r+=9):(e=null,_('"multipart"')),e===null&&(e=En())),e}function En(){var e;return e=x(),e===null&&(e=ji()),e}function ji(){var e,l,u;return u=r,a.substr(r,2).toLowerCase()==="x-"?(e=a.substr(r,2),r+=2):(e=null,_('"x-"')),e!==null?(l=x(),l!==null?e=[e,l]:(e=null,r=u)):(e=null,r=u),e}function nr(){var e;return e=En(),e===null&&(e=x()),e}function rr(){var e,l,u,f;return f=r,e=x(),e!==null?(l=re(),l!==null?(u=Pa(),u!==null?e=[e,l,u]:(e=null,r=f)):(e=null,r=f)):(e=null,r=f),e}function Pa(){var e;return e=x(),e===null&&(e=Oe()),e}function ka(){var e,l,u,f;return f=r,e=Ma(),e!==null?(l=L(),l!==null?(u=vn(),u!==null?e=[e,l,u]:(e=null,r=f)):(e=null,r=f)):(e=null,r=f),e}function Ma(){var e,l,u;if(u=r,l=T(),l!==null)for(e=[];l!==null;)e.push(l),l=T();else e=null;return e!==null&&(e=function(f,p){w.value=parseInt(p.join(""))}(u,e)),e===null&&(r=u),e}function Pu(){var e,l;return l=r,e=us(),e!==null&&(e=function(u,f){w=f}(l,e)),e===null&&(r=l),e}function yn(){var e,l,u,f,p,m,v;if(p=r,m=r,e=Cn(),e!==null){for(l=[],v=r,u=ye(),u!==null?(f=ze(),f!==null?u=[u,f]:(u=null,r=v)):(u=null,r=v);u!==null;)l.push(u),v=r,u=ye(),u!==null?(f=ze(),f!==null?u=[u,f]:(u=null,r=v)):(u=null,r=v);l!==null?e=[e,l]:(e=null,r=m)}else e=null,r=m;return e!==null&&(e=function(y,O){w.event=O.join("").toLowerCase()}(p,e[0])),e===null&&(r=p),e}function Cn(){var e,l,u,f,p,m;if(p=r,e=se(),e!==null){for(l=[],m=r,a.charCodeAt(r)===46?(u=".",r++):(u=null,_('"."')),u!==null?(f=se(),f!==null?u=[u,f]:(u=null,r=m)):(u=null,r=m);u!==null;)l.push(u),m=r,a.charCodeAt(r)===46?(u=".",r++):(u=null,_('"."')),u!==null?(f=se(),f!==null?u=[u,f]:(u=null,r=m)):(u=null,r=m);l!==null?e=[e,l]:(e=null,r=p)}else e=null,r=p;return e}function Vi(){var e,l,u,f,p,m,v;if(p=r,m=r,e=we(),e===null&&(e=Gt()),e!==null){for(l=[],v=r,u=ye(),u!==null?(f=An(),f!==null?u=[u,f]:(u=null,r=v)):(u=null,r=v);u!==null;)l.push(u),v=r,u=ye(),u!==null?(f=An(),f!==null?u=[u,f]:(u=null,r=v)):(u=null,r=v);l!==null?e=[e,l]:(e=null,r=m)}else e=null,r=m;return e!==null&&(e=function(y){var O=w.tag;try{w=new b(w.uri,w.display_name,w.params),O&&w.setParam("tag",O)}catch{w=-1}}()),e===null&&(r=p),e}function An(){var e;return e=qi(),e===null&&(e=ze()),e}function qi(){var e,l,u,f,p;return f=r,p=r,a.substr(r,3).toLowerCase()==="tag"?(e=a.substr(r,3),r+=3):(e=null,_('"tag"')),e!==null?(l=re(),l!==null?(u=x(),u!==null?e=[e,l,u]:(e=null,r=p)):(e=null,r=p)):(e=null,r=p),e!==null&&(e=function(m,v){w.tag=v}(f,e[2])),e===null&&(r=f),e}function ku(){var e,l,u;if(u=r,l=T(),l!==null)for(e=[];l!==null;)e.push(l),l=T();else e=null;return e!==null&&(e=function(f,p){w=parseInt(p.join(""))}(u,e)),e===null&&(r=u),e}function Mu(){var e,l;return l=r,e=us(),e!==null&&(e=function(u,f){w=f}(l,e)),e===null&&(r=l),e}function Lu(){var e,l,u,f,p,m,v,y,O,le;for(y=r,O=r,e=[],l=Ws();l!==null;)e.push(l),l=Ws();if(e!==null)if(l=Re(),l!==null)if(u=Ne(),u!==null)if(f=ke(),f!==null){for(p=[],le=r,m=ye(),m!==null?(v=ze(),v!==null?m=[m,v]:(m=null,r=le)):(m=null,r=le);m!==null;)p.push(m),le=r,m=ye(),m!==null?(v=ze(),v!==null?m=[m,v]:(m=null,r=le)):(m=null,r=le);p!==null?e=[e,l,u,f,p]:(e=null,r=O)}else e=null,r=O;else e=null,r=O;else e=null,r=O;else e=null,r=O;return e!==null&&(e=function(Ue){try{w=new b(w.uri,w.display_name,w.params)}catch{w=-1}}()),e===null&&(r=y),e}function Bi(){var e;return e=ir(),e}function ir(){var e,l,u,f,p,m,v,y;if(v=r,a.substr(r,6).toLowerCase()==="digest"?(e=a.substr(r,6),r+=6):(e=null,_('"Digest"')),e!==null)if(l=L(),l!==null)if(u=Rn(),u!==null){for(f=[],y=r,p=ae(),p!==null?(m=Rn(),m!==null?p=[p,m]:(p=null,r=y)):(p=null,r=y);p!==null;)f.push(p),y=r,p=ae(),p!==null?(m=Rn(),m!==null?p=[p,m]:(p=null,r=y)):(p=null,r=y);f!==null?e=[e,l,u,f]:(e=null,r=v)}else e=null,r=v;else e=null,r=v;else e=null,r=v;return e===null&&(e=Ks()),e}function Ks(){var e,l,u,f,p,m,v,y;if(v=r,e=x(),e!==null)if(l=L(),l!==null)if(u=cs(),u!==null){for(f=[],y=r,p=ae(),p!==null?(m=cs(),m!==null?p=[p,m]:(p=null,r=y)):(p=null,r=y);p!==null;)f.push(p),y=r,p=ae(),p!==null?(m=cs(),m!==null?p=[p,m]:(p=null,r=y)):(p=null,r=y);f!==null?e=[e,l,u,f]:(e=null,r=v)}else e=null,r=v;else e=null,r=v;else e=null,r=v;return e}function cs(){var e,l,u,f;return f=r,e=x(),e!==null?(l=re(),l!==null?(u=x(),u===null&&(u=Oe()),u!==null?e=[e,l,u]:(e=null,r=f)):(e=null,r=f)):(e=null,r=f),e}function Rn(){var e;return e=Gi(),e===null&&(e=In(),e===null&&(e=Ki(),e===null&&(e=Ji(),e===null&&(e=zi(),e===null&&(e=Xi(),e===null&&(e=wn(),e===null&&(e=cs()))))))),e}function Gi(){var e,l,u,f;return f=r,a.substr(r,5).toLowerCase()==="realm"?(e=a.substr(r,5),r+=5):(e=null,_('"realm"')),e!==null?(l=re(),l!==null?(u=Wi(),u!==null?e=[e,l,u]:(e=null,r=f)):(e=null,r=f)):(e=null,r=f),e}function Wi(){var e,l;return l=r,e=pe(),e!==null&&(e=function(u,f){w.realm=f}(l,e)),e===null&&(r=l),e}function In(){var e,l,u,f,p,m,v,y,O;if(y=r,a.substr(r,6).toLowerCase()==="domain"?(e=a.substr(r,6),r+=6):(e=null,_('"domain"')),e!==null)if(l=re(),l!==null)if(u=ot(),u!==null)if(f=bn(),f!==null){if(p=[],O=r,v=k(),v!==null)for(m=[];v!==null;)m.push(v),v=k();else m=null;for(m!==null?(v=bn(),v!==null?m=[m,v]:(m=null,r=O)):(m=null,r=O);m!==null;){if(p.push(m),O=r,v=k(),v!==null)for(m=[];v!==null;)m.push(v),v=k();else m=null;m!==null?(v=bn(),v!==null?m=[m,v]:(m=null,r=O)):(m=null,r=O)}p!==null?(m=Se(),m!==null?e=[e,l,u,f,p,m]:(e=null,r=y)):(e=null,r=y)}else e=null,r=y;else e=null,r=y;else e=null,r=y;else e=null,r=y;return e}function bn(){var e;return e=zn(),e===null&&(e=mn()),e}function Ki(){var e,l,u,f;return f=r,a.substr(r,5).toLowerCase()==="nonce"?(e=a.substr(r,5),r+=5):(e=null,_('"nonce"')),e!==null?(l=re(),l!==null?(u=Yi(),u!==null?e=[e,l,u]:(e=null,r=f)):(e=null,r=f)):(e=null,r=f),e}function Yi(){var e,l;return l=r,e=pe(),e!==null&&(e=function(u,f){w.nonce=f}(l,e)),e===null&&(r=l),e}function Ji(){var e,l,u,f,p;return f=r,p=r,a.substr(r,6).toLowerCase()==="opaque"?(e=a.substr(r,6),r+=6):(e=null,_('"opaque"')),e!==null?(l=re(),l!==null?(u=pe(),u!==null?e=[e,l,u]:(e=null,r=p)):(e=null,r=p)):(e=null,r=p),e!==null&&(e=function(m,v){w.opaque=v}(f,e[2])),e===null&&(r=f),e}function zi(){var e,l,u,f,p;return f=r,a.substr(r,5).toLowerCase()==="stale"?(e=a.substr(r,5),r+=5):(e=null,_('"stale"')),e!==null?(l=re(),l!==null?(p=r,a.substr(r,4).toLowerCase()==="true"?(u=a.substr(r,4),r+=4):(u=null,_('"true"')),u!==null&&(u=function(m){w.stale=!0}()),u===null&&(r=p),u===null&&(p=r,a.substr(r,5).toLowerCase()==="false"?(u=a.substr(r,5),r+=5):(u=null,_('"false"')),u!==null&&(u=function(m){w.stale=!1}()),u===null&&(r=p)),u!==null?e=[e,l,u]:(e=null,r=f)):(e=null,r=f)):(e=null,r=f),e}function Xi(){var e,l,u,f,p;return f=r,p=r,a.substr(r,9).toLowerCase()==="algorithm"?(e=a.substr(r,9),r+=9):(e=null,_('"algorithm"')),e!==null?(l=re(),l!==null?(a.substr(r,3).toLowerCase()==="md5"?(u=a.substr(r,3),r+=3):(u=null,_('"MD5"')),u===null&&(a.substr(r,8).toLowerCase()==="md5-sess"?(u=a.substr(r,8),r+=8):(u=null,_('"MD5-sess"')),u===null&&(u=x())),u!==null?e=[e,l,u]:(e=null,r=p)):(e=null,r=p)):(e=null,r=p),e!==null&&(e=function(m,v){w.algorithm=v.toUpperCase()}(f,e[2])),e===null&&(r=f),e}function wn(){var e,l,u,f,p,m,v,y,O,le;if(y=r,a.substr(r,3).toLowerCase()==="qop"?(e=a.substr(r,3),r+=3):(e=null,_('"qop"')),e!==null)if(l=re(),l!==null)if(u=ot(),u!==null){if(O=r,f=lr(),f!==null){for(p=[],le=r,a.charCodeAt(r)===44?(m=",",r++):(m=null,_('","')),m!==null?(v=lr(),v!==null?m=[m,v]:(m=null,r=le)):(m=null,r=le);m!==null;)p.push(m),le=r,a.charCodeAt(r)===44?(m=",",r++):(m=null,_('","')),m!==null?(v=lr(),v!==null?m=[m,v]:(m=null,r=le)):(m=null,r=le);p!==null?f=[f,p]:(f=null,r=O)}else f=null,r=O;f!==null?(p=Se(),p!==null?e=[e,l,u,f,p]:(e=null,r=y)):(e=null,r=y)}else e=null,r=y;else e=null,r=y;else e=null,r=y;return e}function lr(){var e,l;return l=r,a.substr(r,8).toLowerCase()==="auth-int"?(e=a.substr(r,8),r+=8):(e=null,_('"auth-int"')),e===null&&(a.substr(r,4).toLowerCase()==="auth"?(e=a.substr(r,4),r+=4):(e=null,_('"auth"')),e===null&&(e=x())),e!==null&&(e=function(u,f){w.qop||(w.qop=[]),w.qop.push(f.toLowerCase())}(l,e)),e===null&&(r=l),e}function $u(){var e,l,u,f,p,m;if(p=r,e=x(),e!==null){for(l=[],m=r,u=ae(),u!==null?(f=x(),f!==null?u=[u,f]:(u=null,r=m)):(u=null,r=m);u!==null;)l.push(u),m=r,u=ae(),u!==null?(f=x(),f!==null?u=[u,f]:(u=null,r=m)):(u=null,r=m);l!==null?e=[e,l]:(e=null,r=p)}else e=null,r=p;return e}function ar(){var e,l,u,f,p,m,v;if(p=r,m=r,e=or(),e!==null){for(l=[],v=r,u=ae(),u!==null?(f=or(),f!==null?u=[u,f]:(u=null,r=v)):(u=null,r=v);u!==null;)l.push(u),v=r,u=ae(),u!==null?(f=or(),f!==null?u=[u,f]:(u=null,r=v)):(u=null,r=v);l!==null?e=[e,l]:(e=null,r=m)}else e=null,r=m;return e!==null&&(e=function(y){var O,le;for(le=w.multi_header.length,O=0;O<le;O++)if(w.multi_header[O].parsed===null){w=null;break}w!==null?w=w.multi_header:w=-1}()),e===null&&(r=p),e}function or(){var e,l,u,f,p,m,v;if(p=r,m=r,e=Gt(),e!==null){for(l=[],v=r,u=ye(),u!==null?(f=ze(),f!==null?u=[u,f]:(u=null,r=v)):(u=null,r=v);u!==null;)l.push(u),v=r,u=ye(),u!==null?(f=ze(),f!==null?u=[u,f]:(u=null,r=v)):(u=null,r=v);l!==null?e=[e,l]:(e=null,r=m)}else e=null,r=m;return e!==null&&(e=function(y){var O;w.multi_header||(w.multi_header=[]);try{O=new b(w.uri,w.display_name,w.params),delete w.uri,delete w.display_name,delete w.params}catch{O=null}w.multi_header.push({possition:r,offset:y,parsed:O})}(p)),e===null&&(r=p),e}function Qi(){var e,l,u,f,p,m,v;if(p=r,m=r,a.substr(r,3).toLowerCase()==="sip"?(e=a.substr(r,3),r+=3):(e=null,_('"SIP"')),e===null&&(e=x()),e!==null){for(l=[],v=r,u=ye(),u!==null?(f=ur(),f!==null?u=[u,f]:(u=null,r=v)):(u=null,r=v);u!==null;)l.push(u),v=r,u=ye(),u!==null?(f=ur(),f!==null?u=[u,f]:(u=null,r=v)):(u=null,r=v);l!==null?e=[e,l]:(e=null,r=m)}else e=null,r=m;return e!==null&&(e=function(y,O){if(w.protocol=O.toLowerCase(),w.params||(w.params={}),w.params.text&&w.params.text[0]==='"'){var le=w.params.text;w.text=le.substring(1,le.length-1),delete w.params.text}}(p,e[0])),e===null&&(r=p),e}function ur(){var e;return e=La(),e===null&&(e=ze()),e}function La(){var e,l,u,f,p,m;if(p=r,m=r,a.substr(r,5).toLowerCase()==="cause"?(e=a.substr(r,5),r+=5):(e=null,_('"cause"')),e!==null)if(l=re(),l!==null){if(f=T(),f!==null)for(u=[];f!==null;)u.push(f),f=T();else u=null;u!==null?e=[e,l,u]:(e=null,r=m)}else e=null,r=m;else e=null,r=m;return e!==null&&(e=function(v,y){w.cause=parseInt(y.join(""))}(p,e[2])),e===null&&(r=p),e}function Hu(){var e,l,u,f,p,m;if(p=r,e=x(),e!==null){for(l=[],m=r,u=ae(),u!==null?(f=x(),f!==null?u=[u,f]:(u=null,r=m)):(u=null,r=m);u!==null;)l.push(u),m=r,u=ae(),u!==null?(f=x(),f!==null?u=[u,f]:(u=null,r=m)):(u=null,r=m);l!==null?e=[e,l]:(e=null,r=p)}else e=null,r=p;return e}function cr(){var e,l,u,f,p,m;if(p=r,e=fr(),e!==null){for(l=[],m=r,u=ae(),u!==null?(f=fr(),f!==null?u=[u,f]:(u=null,r=m)):(u=null,r=m);u!==null;)l.push(u),m=r,u=ae(),u!==null?(f=fr(),f!==null?u=[u,f]:(u=null,r=m)):(u=null,r=m);l!==null?e=[e,l]:(e=null,r=p)}else e=null,r=p;return e}function fr(){var e,l,u,f,p,m;if(p=r,e=Gt(),e!==null){for(l=[],m=r,u=ye(),u!==null?(f=ze(),f!==null?u=[u,f]:(u=null,r=m)):(u=null,r=m);u!==null;)l.push(u),m=r,u=ye(),u!==null?(f=ze(),f!==null?u=[u,f]:(u=null,r=m)):(u=null,r=m);l!==null?e=[e,l]:(e=null,r=p)}else e=null,r=p;return e}function $a(){var e,l,u,f,p,m;if(p=r,e=hr(),e!==null){for(l=[],m=r,u=ye(),u!==null?(f=dr(),f!==null?u=[u,f]:(u=null,r=m)):(u=null,r=m);u!==null;)l.push(u),m=r,u=ye(),u!==null?(f=dr(),f!==null?u=[u,f]:(u=null,r=m)):(u=null,r=m);l!==null?e=[e,l]:(e=null,r=p)}else e=null,r=p;return e}function hr(){var e,l;return l=r,a.substr(r,6).toLowerCase()==="active"?(e=a.substr(r,6),r+=6):(e=null,_('"active"')),e===null&&(a.substr(r,7).toLowerCase()==="pending"?(e=a.substr(r,7),r+=7):(e=null,_('"pending"')),e===null&&(a.substr(r,10).toLowerCase()==="terminated"?(e=a.substr(r,10),r+=10):(e=null,_('"terminated"')),e===null&&(e=x()))),e!==null&&(e=function(u){w.state=a.substring(r,u)}(l)),e===null&&(r=l),e}function dr(){var e,l,u,f,p;return f=r,p=r,a.substr(r,6).toLowerCase()==="reason"?(e=a.substr(r,6),r+=6):(e=null,_('"reason"')),e!==null?(l=re(),l!==null?(u=Ha(),u!==null?e=[e,l,u]:(e=null,r=p)):(e=null,r=p)):(e=null,r=p),e!==null&&(e=function(m,v){typeof v<"u"&&(w.reason=v)}(f,e[2])),e===null&&(r=f),e===null&&(f=r,p=r,a.substr(r,7).toLowerCase()==="expires"?(e=a.substr(r,7),r+=7):(e=null,_('"expires"')),e!==null?(l=re(),l!==null?(u=us(),u!==null?e=[e,l,u]:(e=null,r=p)):(e=null,r=p)):(e=null,r=p),e!==null&&(e=function(m,v){typeof v<"u"&&(w.expires=v)}(f,e[2])),e===null&&(r=f),e===null&&(f=r,p=r,a.substr(r,11).toLowerCase()==="retry_after"?(e=a.substr(r,11),r+=11):(e=null,_('"retry_after"')),e!==null?(l=re(),l!==null?(u=us(),u!==null?e=[e,l,u]:(e=null,r=p)):(e=null,r=p)):(e=null,r=p),e!==null&&(e=function(m,v){typeof v<"u"&&(w.retry_after=v)}(f,e[2])),e===null&&(r=f),e===null&&(e=ze()))),e}function Ha(){var e;return a.substr(r,11).toLowerCase()==="deactivated"?(e=a.substr(r,11),r+=11):(e=null,_('"deactivated"')),e===null&&(a.substr(r,9).toLowerCase()==="probation"?(e=a.substr(r,9),r+=9):(e=null,_('"probation"')),e===null&&(a.substr(r,8).toLowerCase()==="rejected"?(e=a.substr(r,8),r+=8):(e=null,_('"rejected"')),e===null&&(a.substr(r,7).toLowerCase()==="timeout"?(e=a.substr(r,7),r+=7):(e=null,_('"timeout"')),e===null&&(a.substr(r,6).toLowerCase()==="giveup"?(e=a.substr(r,6),r+=6):(e=null,_('"giveup"')),e===null&&(a.substr(r,10).toLowerCase()==="noresource"?(e=a.substr(r,10),r+=10):(e=null,_('"noresource"')),e===null&&(a.substr(r,9).toLowerCase()==="invariant"?(e=a.substr(r,9),r+=9):(e=null,_('"invariant"')),e===null&&(e=x()))))))),e}function Fu(){var e;return e=q(),e=e!==null?e:"",e}function ju(){var e,l,u,f,p,m;if(p=r,e=x(),e!==null){for(l=[],m=r,u=ae(),u!==null?(f=x(),f!==null?u=[u,f]:(u=null,r=m)):(u=null,r=m);u!==null;)l.push(u),m=r,u=ae(),u!==null?(f=x(),f!==null?u=[u,f]:(u=null,r=m)):(u=null,r=m);l!==null?e=[e,l]:(e=null,r=p)}else e=null,r=p;return e=e!==null?e:"",e}function Zi(){var e,l,u,f,p,m,v;if(p=r,m=r,e=we(),e===null&&(e=Gt()),e!==null){for(l=[],v=r,u=ye(),u!==null?(f=el(),f!==null?u=[u,f]:(u=null,r=v)):(u=null,r=v);u!==null;)l.push(u),v=r,u=ye(),u!==null?(f=el(),f!==null?u=[u,f]:(u=null,r=v)):(u=null,r=v);l!==null?e=[e,l]:(e=null,r=m)}else e=null,r=m;return e!==null&&(e=function(y){var O=w.tag;try{w=new b(w.uri,w.display_name,w.params),O&&w.setParam("tag",O)}catch{w=-1}}()),e===null&&(r=p),e}function el(){var e;return e=qi(),e===null&&(e=ze()),e}function _r(){var e,l,u,f,p,m;if(p=r,e=Ys(),e!==null){for(l=[],m=r,u=ae(),u!==null?(f=Ys(),f!==null?u=[u,f]:(u=null,r=m)):(u=null,r=m);u!==null;)l.push(u),m=r,u=ae(),u!==null?(f=Ys(),f!==null?u=[u,f]:(u=null,r=m)):(u=null,r=m);l!==null?e=[e,l]:(e=null,r=p)}else e=null,r=p;return e}function Ys(){var e,l,u,f,p,m,v,y;if(v=r,e=al(),e!==null)if(l=L(),l!==null)if(u=cl(),u!==null){for(f=[],y=r,p=ye(),p!==null?(m=pr(),m!==null?p=[p,m]:(p=null,r=y)):(p=null,r=y);p!==null;)f.push(p),y=r,p=ye(),p!==null?(m=pr(),m!==null?p=[p,m]:(p=null,r=y)):(p=null,r=y);f!==null?e=[e,l,u,f]:(e=null,r=v)}else e=null,r=v;else e=null,r=v;else e=null,r=v;return e}function pr(){var e;return e=tl(),e===null&&(e=sl(),e===null&&(e=nl(),e===null&&(e=rl(),e===null&&(e=il(),e===null&&(e=ze()))))),e}function tl(){var e,l,u,f,p;return f=r,p=r,a.substr(r,3).toLowerCase()==="ttl"?(e=a.substr(r,3),r+=3):(e=null,_('"ttl"')),e!==null?(l=re(),l!==null?(u=hl(),u!==null?e=[e,l,u]:(e=null,r=p)):(e=null,r=p)):(e=null,r=p),e!==null&&(e=function(m,v){w.ttl=v}(f,e[2])),e===null&&(r=f),e}function sl(){var e,l,u,f,p;return f=r,p=r,a.substr(r,5).toLowerCase()==="maddr"?(e=a.substr(r,5),r+=5):(e=null,_('"maddr"')),e!==null?(l=re(),l!==null?(u=Cs(),u!==null?e=[e,l,u]:(e=null,r=p)):(e=null,r=p)):(e=null,r=p),e!==null&&(e=function(m,v){w.maddr=v}(f,e[2])),e===null&&(r=f),e}function nl(){var e,l,u,f,p;return f=r,p=r,a.substr(r,8).toLowerCase()==="received"?(e=a.substr(r,8),r+=8):(e=null,_('"received"')),e!==null?(l=re(),l!==null?(u=es(),u===null&&(u=me()),u!==null?e=[e,l,u]:(e=null,r=p)):(e=null,r=p)):(e=null,r=p),e!==null&&(e=function(m,v){w.received=v}(f,e[2])),e===null&&(r=f),e}function rl(){var e,l,u,f,p;return f=r,p=r,a.substr(r,6).toLowerCase()==="branch"?(e=a.substr(r,6),r+=6):(e=null,_('"branch"')),e!==null?(l=re(),l!==null?(u=x(),u!==null?e=[e,l,u]:(e=null,r=p)):(e=null,r=p)):(e=null,r=p),e!==null&&(e=function(m,v){w.branch=v}(f,e[2])),e===null&&(r=f),e}function il(){var e,l,u,f,p;return f=r,a.substr(r,5).toLowerCase()==="rport"?(e=a.substr(r,5),r+=5):(e=null,_('"rport"')),e!==null?(p=r,l=re(),l!==null?(u=ll(),u!==null?l=[l,u]:(l=null,r=p)):(l=null,r=p),l=l!==null?l:"",l!==null?e=[e,l]:(e=null,r=f)):(e=null,r=f),e}function ll(){var e,l,u,f,p,m,v;return m=r,v=r,e=T(),e=e!==null?e:"",e!==null?(l=T(),l=l!==null?l:"",l!==null?(u=T(),u=u!==null?u:"",u!==null?(f=T(),f=f!==null?f:"",f!==null?(p=T(),p=p!==null?p:"",p!==null?e=[e,l,u,f,p]:(e=null,r=v)):(e=null,r=v)):(e=null,r=v)):(e=null,r=v)):(e=null,r=v),e!==null&&(e=function(y,O){w.rport=parseInt(O.join(""))}(m,e)),e===null&&(r=m),e}function al(){var e,l,u,f,p,m;return m=r,e=ol(),e!==null?(l=G(),l!==null?(u=x(),u!==null?(f=G(),f!==null?(p=ul(),p!==null?e=[e,l,u,f,p]:(e=null,r=m)):(e=null,r=m)):(e=null,r=m)):(e=null,r=m)):(e=null,r=m),e}function ol(){var e,l;return l=r,a.substr(r,3).toLowerCase()==="sip"?(e=a.substr(r,3),r+=3):(e=null,_('"SIP"')),e===null&&(e=x()),e!==null&&(e=function(u,f){w.protocol=f}(l,e)),e===null&&(r=l),e}function ul(){var e,l;return l=r,a.substr(r,3).toLowerCase()==="udp"?(e=a.substr(r,3),r+=3):(e=null,_('"UDP"')),e===null&&(a.substr(r,3).toLowerCase()==="tcp"?(e=a.substr(r,3),r+=3):(e=null,_('"TCP"')),e===null&&(a.substr(r,3).toLowerCase()==="tls"?(e=a.substr(r,3),r+=3):(e=null,_('"TLS"')),e===null&&(a.substr(r,4).toLowerCase()==="sctp"?(e=a.substr(r,4),r+=4):(e=null,_('"SCTP"')),e===null&&(e=x())))),e!==null&&(e=function(u,f){w.transport=f}(l,e)),e===null&&(r=l),e}function cl(){var e,l,u,f,p;return f=r,e=fl(),e!==null?(p=r,l=lt(),l!==null?(u=mr(),u!==null?l=[l,u]:(l=null,r=p)):(l=null,r=p),l=l!==null?l:"",l!==null?e=[e,l]:(e=null,r=f)):(e=null,r=f),e}function fl(){var e,l;return l=r,e=es(),e===null&&(e=fn(),e===null&&(e=cn())),e!==null&&(e=function(u){w.host=a.substring(r,u)}(l)),e===null&&(r=l),e}function mr(){var e,l,u,f,p,m,v;return m=r,v=r,e=T(),e=e!==null?e:"",e!==null?(l=T(),l=l!==null?l:"",l!==null?(u=T(),u=u!==null?u:"",u!==null?(f=T(),f=f!==null?f:"",f!==null?(p=T(),p=p!==null?p:"",p!==null?e=[e,l,u,f,p]:(e=null,r=v)):(e=null,r=v)):(e=null,r=v)):(e=null,r=v)):(e=null,r=v),e!==null&&(e=function(y,O){w.port=parseInt(O.join(""))}(m,e)),e===null&&(r=m),e}function hl(){var e,l,u,f,p;return f=r,p=r,e=T(),e!==null?(l=T(),l=l!==null?l:"",l!==null?(u=T(),u=u!==null?u:"",u!==null?e=[e,l,u]:(e=null,r=p)):(e=null,r=p)):(e=null,r=p),e!==null&&(e=function(m,v){return parseInt(v.join(""))}(f,e)),e===null&&(r=f),e}function Vu(){var e;return e=ir(),e}function Fa(){var e,l,u,f,p,m;if(p=r,e=gr(),e!==null){for(l=[],m=r,u=ye(),u!==null?(f=Tr(),f!==null?u=[u,f]:(u=null,r=m)):(u=null,r=m);u!==null;)l.push(u),m=r,u=ye(),u!==null?(f=Tr(),f!==null?u=[u,f]:(u=null,r=m)):(u=null,r=m);l!==null?e=[e,l]:(e=null,r=p)}else e=null,r=p;return e}function gr(){var e,l;return l=r,e=us(),e!==null&&(e=function(u,f){w.expires=f}(l,e)),e===null&&(r=l),e}function Tr(){var e;return e=ja(),e===null&&(e=ze()),e}function ja(){var e,l,u,f,p;return f=r,p=r,a.substr(r,9).toLowerCase()==="refresher"?(e=a.substr(r,9),r+=9):(e=null,_('"refresher"')),e!==null?(l=re(),l!==null?(a.substr(r,3).toLowerCase()==="uac"?(u=a.substr(r,3),r+=3):(u=null,_('"uac"')),u===null&&(a.substr(r,3).toLowerCase()==="uas"?(u=a.substr(r,3),r+=3):(u=null,_('"uas"'))),u!==null?e=[e,l,u]:(e=null,r=p)):(e=null,r=p)):(e=null,r=p),e!==null&&(e=function(m,v){w.refresher=v.toLowerCase()}(f,e[2])),e===null&&(r=f),e}function Va(){var e,l,u,f;return f=r,e=x(),e!==null?(l=B(),l!==null?(u=qa(),u!==null?e=[e,l,u]:(e=null,r=f)):(e=null,r=f)):(e=null,r=f),e}function qa(){var e,l;for(e=[],l=J(),l===null&&(l=Z(),l===null&&(l=L()));l!==null;)e.push(l),l=J(),l===null&&(l=Z(),l===null&&(l=L()));return e}function qu(){var e,l;for(e=[],l=A();l!==null;)e.push(l),l=A();return e}function Ba(){var e,l,u;return u=r,a.substr(r,5)==="uuid:"?(e="uuid:",r+=5):(e=null,_('"uuid:"')),e!==null?(l=Wt(),l!==null?e=[e,l]:(e=null,r=u)):(e=null,r=u),e}function Wt(){var e,l,u,f,p,m,v,y,O,le,Ue;return le=r,Ue=r,e=dl(),e!==null?(a.charCodeAt(r)===45?(l="-",r++):(l=null,_('"-"')),l!==null?(u=Kt(),u!==null?(a.charCodeAt(r)===45?(f="-",r++):(f=null,_('"-"')),f!==null?(p=Kt(),p!==null?(a.charCodeAt(r)===45?(m="-",r++):(m=null,_('"-"')),m!==null?(v=Kt(),v!==null?(a.charCodeAt(r)===45?(y="-",r++):(y=null,_('"-"')),y!==null?(O=Ga(),O!==null?e=[e,l,u,f,p,m,v,y,O]:(e=null,r=Ue)):(e=null,r=Ue)):(e=null,r=Ue)):(e=null,r=Ue)):(e=null,r=Ue)):(e=null,r=Ue)):(e=null,r=Ue)):(e=null,r=Ue)):(e=null,r=Ue),e!==null&&(e=function(Dt,Js){w=a.substring(r+5,Dt)}(le,e[0])),e===null&&(r=le),e}function Kt(){var e,l,u,f,p;return p=r,e=E(),e!==null?(l=E(),l!==null?(u=E(),u!==null?(f=E(),f!==null?e=[e,l,u,f]:(e=null,r=p)):(e=null,r=p)):(e=null,r=p)):(e=null,r=p),e}function dl(){var e,l,u;return u=r,e=Kt(),e!==null?(l=Kt(),l!==null?e=[e,l]:(e=null,r=u)):(e=null,r=u),e}function Ga(){var e,l,u,f;return f=r,e=Kt(),e!==null?(l=Kt(),l!==null?(u=Kt(),u!==null?e=[e,l,u]:(e=null,r=f)):(e=null,r=f)):(e=null,r=f),e}function Bu(){var e,l,u,f,p,m,v;if(p=r,m=r,e=we(),e===null&&(e=Gt()),e!==null){for(l=[],v=r,u=ye(),u!==null?(f=ze(),f!==null?u=[u,f]:(u=null,r=v)):(u=null,r=v);u!==null;)l.push(u),v=r,u=ye(),u!==null?(f=ze(),f!==null?u=[u,f]:(u=null,r=v)):(u=null,r=v);l!==null?e=[e,l]:(e=null,r=m)}else e=null,r=m;return e!==null&&(e=function(y){try{w=new b(w.uri,w.display_name,w.params)}catch{w=-1}}()),e===null&&(r=p),e}function Wa(){var e,l,u,f,p,m;if(p=r,e=vr(),e!==null){for(l=[],m=r,u=ye(),u!==null?(f=Sr(),f!==null?u=[u,f]:(u=null,r=m)):(u=null,r=m);u!==null;)l.push(u),m=r,u=ye(),u!==null?(f=Sr(),f!==null?u=[u,f]:(u=null,r=m)):(u=null,r=m);l!==null?e=[e,l]:(e=null,r=p)}else e=null,r=p;return e}function vr(){var e,l,u,f,p,m;return f=r,p=r,e=ee(),e!==null?(m=r,a.charCodeAt(r)===64?(l="@",r++):(l=null,_('"@"')),l!==null?(u=ee(),u!==null?l=[l,u]:(l=null,r=m)):(l=null,r=m),l=l!==null?l:"",l!==null?e=[e,l]:(e=null,r=p)):(e=null,r=p),e!==null&&(e=function(v){w.call_id=a.substring(r,v)}(f)),e===null&&(r=f),e}function Sr(){var e;return e=_l(),e===null&&(e=pl(),e===null&&(e=Ka(),e===null&&(e=ze()))),e}function _l(){var e,l,u,f,p;return f=r,p=r,a.substr(r,6)==="to-tag"?(e="to-tag",r+=6):(e=null,_('"to-tag"')),e!==null?(l=re(),l!==null?(u=x(),u!==null?e=[e,l,u]:(e=null,r=p)):(e=null,r=p)):(e=null,r=p),e!==null&&(e=function(m,v){w.to_tag=v}(f,e[2])),e===null&&(r=f),e}function pl(){var e,l,u,f,p;return f=r,p=r,a.substr(r,8)==="from-tag"?(e="from-tag",r+=8):(e=null,_('"from-tag"')),e!==null?(l=re(),l!==null?(u=x(),u!==null?e=[e,l,u]:(e=null,r=p)):(e=null,r=p)):(e=null,r=p),e!==null&&(e=function(m,v){w.from_tag=v}(f,e[2])),e===null&&(r=f),e}function Ka(){var e,l;return l=r,a.substr(r,10)==="early-only"?(e="early-only",r+=10):(e=null,_('"early-only"')),e!==null&&(e=function(u){w.early_only=!0}()),e===null&&(r=l),e}function Gu(e){e.sort();for(var l=null,u=[],f=0;f<e.length;f++)e[f]!==l&&(u.push(e[f]),l=e[f]);return u}function Ya(){for(var e=1,l=1,u=!1,f=0;f<Math.max(r,d);f++){var p=a.charAt(f);p===`
4
4
  `?(u||e++,l=1,u=!1):p==="\r"||p==="\u2028"||p==="\u2029"?(e++,l=1,u=!0):(l++,u=!1)}return{line:e,column:l}}var Rs=bs(),b=Xa(),w={},ml=s[o]();if(ml===null||r!==a.length){var gl=Math.max(r,d),Ja=gl<a.length?a.charAt(gl):null,i=Ya();return new this.SyntaxError(Gu(h),Ja,gl,i.line,i.column),-1}return w},toSource:function(){return this._source}};return t.SyntaxError=function(n,a,o,s,r){function d(h,_){var g,T;switch(h.length){case 0:g="end of input";break;case 1:g=h[0];break;default:g=h.slice(0,h.length-1).join(", ")+" or "+h[h.length-1]}return T=_?c(_):"end of input","Expected "+g+" but "+T+" found."}this.name="SyntaxError",this.expected=n,this.found=a,this.message=d(n,a),this.offset=o,this.line=s,this.column=r},t.SyntaxError.prototype=Error.prototype,t}()),Qa}var Za,Xu;function bs(){if(Xu)return Za;Xu=1;function c(_,g){var T;if(typeof Symbol>"u"||_[Symbol.iterator]==null){if(Array.isArray(_)||(T=t(_))||g&&_&&typeof _.length=="number"){T&&(_=T);var S=0,E=function(){};return{s:E,n:function(){return S>=_.length?{done:!0}:{done:!1,value:_[S++]}},e:function(M){throw M},f:E}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
5
5
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var C=!0,A=!1,R;return{s:function(){T=_[Symbol.iterator]()},n:function(){var M=T.next();return C=M.done,M},e:function(M){A=!0,R=M},f:function(){try{!C&&T.return!=null&&T.return()}finally{if(A)throw R}}}}function t(_,g){if(_){if(typeof _=="string")return n(_,g);var T=Object.prototype.toString.call(_).slice(8,-1);if(T==="Object"&&_.constructor&&(T=_.constructor.name),T==="Map"||T==="Set")return Array.from(_);if(T==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(T))return n(_,g)}}function n(_,g){(g==null||g>_.length)&&(g=_.length);for(var T=0,S=new Array(g);T<g;T++)S[T]=_[T];return S}function a(_,g){if(!(_ instanceof g))throw new TypeError("Cannot call a class as a function")}function o(_,g){for(var T=0;T<g.length;T++){var S=g[T];S.enumerable=S.enumerable||!1,S.configurable=!0,"value"in S&&(S.writable=!0),Object.defineProperty(_,S.key,S)}}function s(_,g,T){return g&&o(_.prototype,g),T&&o(_,T),_}var r=st,d=Rt(),h=ss();return Za=function(){s(_,null,[{key:"parse",value:function(T){if(T=h.parse(T,"SIP_URI"),T!==-1)return T}}]);function _(g,T,S,E){var C=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{},A=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{};if(a(this,_),!S)throw new TypeError('missing or invalid "host" parameter');this._parameters={},this._headers={},this._scheme=g||r.SIP,this._user=T,this._host=S,this._port=E;for(var R in C)Object.prototype.hasOwnProperty.call(C,R)&&this.setParam(R,C[R]);for(var k in A)Object.prototype.hasOwnProperty.call(A,k)&&this.setHeader(k,A[k])}return s(_,[{key:"setParam",value:function(T,S){T&&(this._parameters[T.toLowerCase()]=typeof S>"u"||S===null?null:S.toString())}},{key:"getParam",value:function(T){if(T)return this._parameters[T.toLowerCase()]}},{key:"hasParam",value:function(T){if(T)return this._parameters.hasOwnProperty(T.toLowerCase())&&!0||!1}},{key:"deleteParam",value:function(T){if(T=T.toLowerCase(),this._parameters.hasOwnProperty(T)){var S=this._parameters[T];return delete this._parameters[T],S}}},{key:"clearParams",value:function(){this._parameters={}}},{key:"setHeader",value:function(T,S){this._headers[d.headerize(T)]=Array.isArray(S)?S:[S]}},{key:"getHeader",value:function(T){if(T)return this._headers[d.headerize(T)]}},{key:"hasHeader",value:function(T){if(T)return this._headers.hasOwnProperty(d.headerize(T))&&!0||!1}},{key:"deleteHeader",value:function(T){if(T=d.headerize(T),this._headers.hasOwnProperty(T)){var S=this._headers[T];return delete this._headers[T],S}}},{key:"clearHeaders",value:function(){this._headers={}}},{key:"clone",value:function(){return new _(this._scheme,this._user,this._host,this._port,JSON.parse(JSON.stringify(this._parameters)),JSON.parse(JSON.stringify(this._headers)))}},{key:"toString",value:function(){var T=[],S="".concat(this._scheme,":");this._user&&(S+="".concat(d.escapeUser(this._user),"@")),S+=this._host,(this._port||this._port===0)&&(S+=":".concat(this._port));for(var E in this._parameters)Object.prototype.hasOwnProperty.call(this._parameters,E)&&(S+=";".concat(E),this._parameters[E]!==null&&(S+="=".concat(this._parameters[E])));for(var C in this._headers)if(Object.prototype.hasOwnProperty.call(this._headers,C)){var A=c(this._headers[C]),R;try{for(A.s();!(R=A.n()).done;){var k=R.value;T.push("".concat(C,"=").concat(k))}}catch(M){A.e(M)}finally{A.f()}}return T.length>0&&(S+="?".concat(T.join("&"))),S}},{key:"toAor",value:function(T){var S="".concat(this._scheme,":");return this._user&&(S+="".concat(d.escapeUser(this._user),"@")),S+=this._host,T&&(this._port||this._port===0)&&(S+=":".concat(this._port)),S}},{key:"scheme",get:function(){return this._scheme},set:function(T){this._scheme=T.toLowerCase()}},{key:"user",get:function(){return this._user},set:function(T){this._user=T}},{key:"host",get:function(){return this._host},set:function(T){this._host=T.toLowerCase()}},{key:"port",get:function(){return this._port},set:function(T){this._port=T===0?T:parseInt(T,10)||null}}]),_}(),Za}var Qu;function Rt(){if(Qu)return Qe;Qu=1;function c(g){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?c=function(S){return typeof S}:c=function(S){return S&&typeof Symbol=="function"&&S.constructor===Symbol&&S!==Symbol.prototype?"symbol":typeof S},c(g)}function t(g,T){var S;if(typeof Symbol>"u"||g[Symbol.iterator]==null){if(Array.isArray(g)||(S=n(g))||T&&g&&typeof g.length=="number"){S&&(g=S);var E=0,C=function(){};return{s:C,n:function(){return E>=g.length?{done:!0}:{done:!1,value:g[E++]}},e:function(ie){throw ie},f:C}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
6
6
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var A=!0,R=!1,k;return{s:function(){S=g[Symbol.iterator]()},n:function(){var ie=S.next();return A=ie.done,ie},e:function(ie){R=!0,k=ie},f:function(){try{!A&&S.return!=null&&S.return()}finally{if(R)throw k}}}}function n(g,T){if(g){if(typeof g=="string")return a(g,T);var S=Object.prototype.toString.call(g).slice(8,-1);if(S==="Object"&&g.constructor&&(S=g.constructor.name),S==="Map"||S==="Set")return Array.from(g);if(S==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(S))return a(g,T)}}function a(g,T){(T==null||T>g.length)&&(T=g.length);for(var S=0,E=new Array(T);S<T;S++)E[S]=g[S];return E}var o=st,s=bs(),r=ss();Qe.str_utf8_length=function(g){return unescape(encodeURIComponent(g)).length};var d=Qe.isFunction=function(g){return g!==void 0?Object.prototype.toString.call(g)==="[object Function]":!1};Qe.isString=function(g){return g!==void 0?Object.prototype.toString.call(g)==="[object String]":!1},Qe.isDecimal=function(g){return!isNaN(g)&&parseFloat(g)===parseInt(g,10)},Qe.isEmpty=function(g){return g===null||g===""||g===void 0||Array.isArray(g)&&g.length===0||typeof g=="number"&&isNaN(g)},Qe.hasMethods=function(g){for(var T=arguments.length,S=new Array(T>1?T-1:0),E=1;E<T;E++)S[E-1]=arguments[E];for(var C=0,A=S;C<A.length;C++){var R=A[C];if(d(g[R]))return!1}return!0};var h=Qe.createRandomToken=function(g){var T=arguments.length>1&&arguments[1]!==void 0?arguments[1]:32,S,E,C="";for(S=0;S<g;S++)E=Math.random()*T|0,C+=E.toString(T);return C};Qe.newTag=function(){return h(10)},Qe.newUUID=function(){var g="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(T){var S=Math.random()*16|0,E=T==="x"?S:S&3|8;return E.toString(16)});return g},Qe.hostType=function(g){if(g){if(g=r.parse(g,"host"),g!==-1)return g.host_type}else return};var _=Qe.escapeUser=function(g){return encodeURIComponent(decodeURIComponent(g)).replace(/%3A/ig,":").replace(/%2B/ig,"+").replace(/%3F/ig,"?").replace(/%2F/ig,"/")};return Qe.normalizeTarget=function(g,T){if(g){if(g instanceof s)return g;if(typeof g=="string"){var S=g.split("@"),E,C;switch(S.length){case 1:if(!T)return;E=g,C=T;break;case 2:E=S[0],C=S[1];break;default:E=S.slice(0,S.length-1).join("@"),C=S[S.length-1]}E=E.replace(/^(sips?|tel):/i,""),/^[-.()]*\+?[0-9\-.()]+$/.test(E)&&(E=E.replace(/[-.()]/g,"")),g="".concat(o.SIP,":").concat(_(E),"@").concat(C);var A;return(A=s.parse(g))?A:void 0}else return}else return},Qe.headerize=function(g){var T={"Call-Id":"Call-ID",Cseq:"CSeq","Www-Authenticate":"WWW-Authenticate"},S=g.toLowerCase().replace(/_/g,"-").split("-"),E="",C=S.length,A;for(A=0;A<C;A++)A!==0&&(E+="-"),E+=S[A].charAt(0).toUpperCase()+S[A].substring(1);return T[E]&&(E=T[E]),E},Qe.sipErrorCause=function(g){for(var T in o.SIP_ERROR_CAUSES)if(o.SIP_ERROR_CAUSES[T].indexOf(g)!==-1)return o.causes[T];return o.causes.SIP_FAILURE_CODE},Qe.getRandomTestNetIP=function(){function g(T,S){return Math.floor(Math.random()*(S-T+1)+T)}return"192.0.2.".concat(g(1,254))},Qe.calculateMD5=function(g){function T(pe,de){return pe<<de|pe>>>32-de}function S(pe,de){var _e=pe&2147483648,we=de&2147483648,Ne=pe&1073741824,tt=de&1073741824,He=(pe&1073741823)+(de&1073741823);return Ne&tt?He^2147483648^_e^we:Ne|tt?He&1073741824?He^3221225472^_e^we:He^1073741824^_e^we:He^_e^we}function E(pe,de,_e){return pe&de|~pe&_e}function C(pe,de,_e){return pe&_e|de&~_e}function A(pe,de,_e){return pe^de^_e}function R(pe,de,_e){return de^(pe|~_e)}function k(pe,de,_e,we,Ne,tt,He){return pe=S(pe,S(S(E(de,_e,we),Ne),He)),S(T(pe,tt),de)}function M(pe,de,_e,we,Ne,tt,He){return pe=S(pe,S(S(C(de,_e,we),Ne),He)),S(T(pe,tt),de)}function ie(pe,de,_e,we,Ne,tt,He){return pe=S(pe,S(S(A(de,_e,we),Ne),He)),S(T(pe,tt),de)}function N(pe,de,_e,we,Ne,tt,He){return pe=S(pe,S(S(R(de,_e,we),Ne),He)),S(T(pe,tt),de)}function j(pe){for(var de,_e=pe.length,we=_e+8,Ne=(we-we%64)/64,tt=(Ne+1)*16,He=new Array(tt-1),qt=0,At=0;At<_e;)de=(At-At%4)/4,qt=At%4*8,He[de]=He[de]|pe.charCodeAt(At)<<qt,At++;return de=(At-At%4)/4,qt=At%4*8,He[de]=He[de]|128<<qt,He[tt-2]=_e<<3,He[tt-1]=_e>>>29,He}function Ee(pe){var de="",_e="",we,Ne;for(Ne=0;Ne<=3;Ne++)we=pe>>>Ne*8&255,_e="0".concat(we.toString(16)),de=de+_e.substr(_e.length-2,2);return de}function ve(pe){for(var de="",_e=0;_e<pe.length;_e++){var we=pe.charCodeAt(_e);we<128?de+=String.fromCharCode(we):we>127&&we<2048?(de+=String.fromCharCode(we>>6|192),de+=String.fromCharCode(we&63|128)):(de+=String.fromCharCode(we>>12|224),de+=String.fromCharCode(we>>6&63|128),de+=String.fromCharCode(we&63|128))}return de}var L=[],D,B,q,J,F,Z,U,x,se,it=7,ee=12,Y=17,G=22,re=5,ge=9,be=14,ke=20,Re=4,ae=11,ye=16,lt=23,ot=6,Se=10,Ce=15,Ie=21;for(g=ve(g),L=j(g),Z=1732584193,U=4023233417,x=2562383102,se=271733878,D=0;D<L.length;D+=16)B=Z,q=U,J=x,F=se,Z=k(Z,U,x,se,L[D+0],it,3614090360),se=k(se,Z,U,x,L[D+1],ee,3905402710),x=k(x,se,Z,U,L[D+2],Y,606105819),U=k(U,x,se,Z,L[D+3],G,3250441966),Z=k(Z,U,x,se,L[D+4],it,4118548399),se=k(se,Z,U,x,L[D+5],ee,1200080426),x=k(x,se,Z,U,L[D+6],Y,2821735955),U=k(U,x,se,Z,L[D+7],G,4249261313),Z=k(Z,U,x,se,L[D+8],it,1770035416),se=k(se,Z,U,x,L[D+9],ee,2336552879),x=k(x,se,Z,U,L[D+10],Y,4294925233),U=k(U,x,se,Z,L[D+11],G,2304563134),Z=k(Z,U,x,se,L[D+12],it,1804603682),se=k(se,Z,U,x,L[D+13],ee,4254626195),x=k(x,se,Z,U,L[D+14],Y,2792965006),U=k(U,x,se,Z,L[D+15],G,1236535329),Z=M(Z,U,x,se,L[D+1],re,4129170786),se=M(se,Z,U,x,L[D+6],ge,3225465664),x=M(x,se,Z,U,L[D+11],be,643717713),U=M(U,x,se,Z,L[D+0],ke,3921069994),Z=M(Z,U,x,se,L[D+5],re,3593408605),se=M(se,Z,U,x,L[D+10],ge,38016083),x=M(x,se,Z,U,L[D+15],be,3634488961),U=M(U,x,se,Z,L[D+4],ke,3889429448),Z=M(Z,U,x,se,L[D+9],re,568446438),se=M(se,Z,U,x,L[D+14],ge,3275163606),x=M(x,se,Z,U,L[D+3],be,4107603335),U=M(U,x,se,Z,L[D+8],ke,1163531501),Z=M(Z,U,x,se,L[D+13],re,2850285829),se=M(se,Z,U,x,L[D+2],ge,4243563512),x=M(x,se,Z,U,L[D+7],be,1735328473),U=M(U,x,se,Z,L[D+12],ke,2368359562),Z=ie(Z,U,x,se,L[D+5],Re,4294588738),se=ie(se,Z,U,x,L[D+8],ae,2272392833),x=ie(x,se,Z,U,L[D+11],ye,1839030562),U=ie(U,x,se,Z,L[D+14],lt,4259657740),Z=ie(Z,U,x,se,L[D+1],Re,2763975236),se=ie(se,Z,U,x,L[D+4],ae,1272893353),x=ie(x,se,Z,U,L[D+7],ye,4139469664),U=ie(U,x,se,Z,L[D+10],lt,3200236656),Z=ie(Z,U,x,se,L[D+13],Re,681279174),se=ie(se,Z,U,x,L[D+0],ae,3936430074),x=ie(x,se,Z,U,L[D+3],ye,3572445317),U=ie(U,x,se,Z,L[D+6],lt,76029189),Z=ie(Z,U,x,se,L[D+9],Re,3654602809),se=ie(se,Z,U,x,L[D+12],ae,3873151461),x=ie(x,se,Z,U,L[D+15],ye,530742520),U=ie(U,x,se,Z,L[D+2],lt,3299628645),Z=N(Z,U,x,se,L[D+0],ot,4096336452),se=N(se,Z,U,x,L[D+7],Se,1126891415),x=N(x,se,Z,U,L[D+14],Ce,2878612391),U=N(U,x,se,Z,L[D+5],Ie,4237533241),Z=N(Z,U,x,se,L[D+12],ot,1700485571),se=N(se,Z,U,x,L[D+3],Se,2399980690),x=N(x,se,Z,U,L[D+10],Ce,4293915773),U=N(U,x,se,Z,L[D+1],Ie,2240044497),Z=N(Z,U,x,se,L[D+8],ot,1873313359),se=N(se,Z,U,x,L[D+15],Se,4264355552),x=N(x,se,Z,U,L[D+6],Ce,2734768916),U=N(U,x,se,Z,L[D+13],Ie,1309151649),Z=N(Z,U,x,se,L[D+4],ot,4149444226),se=N(se,Z,U,x,L[D+11],Se,3174756917),x=N(x,se,Z,U,L[D+2],Ce,718787259),U=N(U,x,se,Z,L[D+9],Ie,3951481745),Z=S(Z,B),U=S(U,q),x=S(x,J),se=S(se,F);var Oe=Ee(Z)+Ee(U)+Ee(x)+Ee(se);return Oe.toLowerCase()},Qe.closeMediaStream=function(g){if(g)try{var T;if(g.getTracks){T=g.getTracks();var S=t(T),E;try{for(S.s();!(E=S.n()).done;){var C=E.value;C.stop()}}catch(j){S.e(j)}finally{S.f()}}else{T=g.getAudioTracks();var A=t(T),R;try{for(A.s();!(R=A.n()).done;){var k=R.value;k.stop()}}catch(j){A.e(j)}finally{A.f()}T=g.getVideoTracks();var M=t(T),ie;try{for(M.s();!(ie=M.n()).done;){var N=ie.value;N.stop()}}catch(j){M.e(j)}finally{M.f()}}}catch{(typeof g.stop=="function"||c(g.stop)==="object")&&g.stop()}},Qe.cloneArray=function(g){return g&&g.slice()||[]},Qe.cloneObject=function(g){var T=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return g&&Object.assign({},g)||T},Qe}var eo={exports:{}},Dn=typeof Reflect=="object"?Reflect:null,Zu=Dn&&typeof Dn.apply=="function"?Dn.apply:function(t,n,a){return Function.prototype.apply.call(t,n,a)},Al;Dn&&typeof Dn.ownKeys=="function"?Al=Dn.ownKeys:Object.getOwnPropertySymbols?Al=function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:Al=function(t){return Object.getOwnPropertyNames(t)};function Wh(c){console&&console.warn&&console.warn(c)}var ec=Number.isNaN||function(t){return t!==t};function Le(){Le.init.call(this)}eo.exports=Le,eo.exports.once=zh,Le.EventEmitter=Le,Le.prototype._events=void 0,Le.prototype._eventsCount=0,Le.prototype._maxListeners=void 0;var tc=10;function Rl(c){if(typeof c!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof c)}Object.defineProperty(Le,"defaultMaxListeners",{enumerable:!0,get:function(){return tc},set:function(c){if(typeof c!="number"||c<0||ec(c))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+c+".");tc=c}}),Le.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},Le.prototype.setMaxListeners=function(t){if(typeof t!="number"||t<0||ec(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this._maxListeners=t,this};function sc(c){return c._maxListeners===void 0?Le.defaultMaxListeners:c._maxListeners}Le.prototype.getMaxListeners=function(){return sc(this)},Le.prototype.emit=function(t){for(var n=[],a=1;a<arguments.length;a++)n.push(arguments[a]);var o=t==="error",s=this._events;if(s!==void 0)o=o&&s.error===void 0;else if(!o)return!1;if(o){var r;if(n.length>0&&(r=n[0]),r instanceof Error)throw r;var d=new Error("Unhandled error."+(r?" ("+r.message+")":""));throw d.context=r,d}var h=s[t];if(h===void 0)return!1;if(typeof h=="function")Zu(h,this,n);else for(var _=h.length,g=ac(h,_),a=0;a<_;++a)Zu(g[a],this,n);return!0};function nc(c,t,n,a){var o,s,r;if(Rl(n),s=c._events,s===void 0?(s=c._events=Object.create(null),c._eventsCount=0):(s.newListener!==void 0&&(c.emit("newListener",t,n.listener?n.listener:n),s=c._events),r=s[t]),r===void 0)r=s[t]=n,++c._eventsCount;else if(typeof r=="function"?r=s[t]=a?[n,r]:[r,n]:a?r.unshift(n):r.push(n),o=sc(c),o>0&&r.length>o&&!r.warned){r.warned=!0;var d=new Error("Possible EventEmitter memory leak detected. "+r.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");d.name="MaxListenersExceededWarning",d.emitter=c,d.type=t,d.count=r.length,Wh(d)}return c}Le.prototype.addListener=function(t,n){return nc(this,t,n,!1)},Le.prototype.on=Le.prototype.addListener,Le.prototype.prependListener=function(t,n){return nc(this,t,n,!0)};function Kh(){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 rc(c,t,n){var a={fired:!1,wrapFn:void 0,target:c,type:t,listener:n},o=Kh.bind(a);return o.listener=n,a.wrapFn=o,o}Le.prototype.once=function(t,n){return Rl(n),this.on(t,rc(this,t,n)),this},Le.prototype.prependOnceListener=function(t,n){return Rl(n),this.prependListener(t,rc(this,t,n)),this},Le.prototype.removeListener=function(t,n){var a,o,s,r,d;if(Rl(n),o=this._events,o===void 0)return this;if(a=o[t],a===void 0)return this;if(a===n||a.listener===n)--this._eventsCount===0?this._events=Object.create(null):(delete o[t],o.removeListener&&this.emit("removeListener",t,a.listener||n));else if(typeof a!="function"){for(s=-1,r=a.length-1;r>=0;r--)if(a[r]===n||a[r].listener===n){d=a[r].listener,s=r;break}if(s<0)return this;s===0?a.shift():Yh(a,s),a.length===1&&(o[t]=a[0]),o.removeListener!==void 0&&this.emit("removeListener",t,d||n)}return this},Le.prototype.off=Le.prototype.removeListener,Le.prototype.removeAllListeners=function(t){var n,a,o;if(a=this._events,a===void 0)return this;if(a.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):a[t]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete a[t]),this;if(arguments.length===0){var s=Object.keys(a),r;for(o=0;o<s.length;++o)r=s[o],r!=="removeListener"&&this.removeAllListeners(r);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(n=a[t],typeof n=="function")this.removeListener(t,n);else if(n!==void 0)for(o=n.length-1;o>=0;o--)this.removeListener(t,n[o]);return this};function ic(c,t,n){var a=c._events;if(a===void 0)return[];var o=a[t];return o===void 0?[]:typeof o=="function"?n?[o.listener||o]:[o]:n?Jh(o):ac(o,o.length)}Le.prototype.listeners=function(t){return ic(this,t,!0)},Le.prototype.rawListeners=function(t){return ic(this,t,!1)},Le.listenerCount=function(c,t){return typeof c.listenerCount=="function"?c.listenerCount(t):lc.call(c,t)},Le.prototype.listenerCount=lc;function lc(c){var t=this._events;if(t!==void 0){var n=t[c];if(typeof n=="function")return 1;if(n!==void 0)return n.length}return 0}Le.prototype.eventNames=function(){return this._eventsCount>0?Al(this._events):[]};function ac(c,t){for(var n=new Array(t),a=0;a<t;++a)n[a]=c[a];return n}function Yh(c,t){for(;t+1<c.length;t++)c[t]=c[t+1];c.pop()}function Jh(c){for(var t=new Array(c.length),n=0;n<t.length;++n)t[n]=c[n].listener||c[n];return t}function zh(c,t){return new Promise(function(n,a){function o(r){c.removeListener(t,s),a(r)}function s(){typeof c.removeListener=="function"&&c.removeListener("error",o),n([].slice.call(arguments))}oc(c,t,s,{once:!0}),t!=="error"&&Xh(c,o,{once:!0})})}function Xh(c,t,n){typeof c.on=="function"&&oc(c,"error",t,n)}function oc(c,t,n,a){if(typeof c.on=="function")a.once?c.once(t,n):c.on(t,n);else if(typeof c.addEventListener=="function")c.addEventListener(t,function o(s){a.once&&c.removeEventListener(t,o),n(s)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof c)}var ct=eo.exports,to={exports:{}},so,uc;function Qh(){if(uc)return so;uc=1;var c=1e3,t=c*60,n=t*60,a=n*24,o=a*7,s=a*365.25;so=function(g,T){T=T||{};var S=typeof g;if(S==="string"&&g.length>0)return r(g);if(S==="number"&&isFinite(g))return T.long?h(g):d(g);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(g))};function r(g){if(g=String(g),!(g.length>100)){var T=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(g);if(T){var S=parseFloat(T[1]),E=(T[2]||"ms").toLowerCase();switch(E){case"years":case"year":case"yrs":case"yr":case"y":return S*s;case"weeks":case"week":case"w":return S*o;case"days":case"day":case"d":return S*a;case"hours":case"hour":case"hrs":case"hr":case"h":return S*n;case"minutes":case"minute":case"mins":case"min":case"m":return S*t;case"seconds":case"second":case"secs":case"sec":case"s":return S*c;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return S;default:return}}}}function d(g){var T=Math.abs(g);return T>=a?Math.round(g/a)+"d":T>=n?Math.round(g/n)+"h":T>=t?Math.round(g/t)+"m":T>=c?Math.round(g/c)+"s":g+"ms"}function h(g){var T=Math.abs(g);return T>=a?_(g,T,a,"day"):T>=n?_(g,T,n,"hour"):T>=t?_(g,T,t,"minute"):T>=c?_(g,T,c,"second"):g+" ms"}function _(g,T,S,E){var C=T>=S*1.5;return Math.round(g/S)+" "+E+(C?"s":"")}return so}function Zh(c){n.debug=n,n.default=n,n.coerce=h,n.disable=s,n.enable=o,n.enabled=r,n.humanize=Qh(),n.destroy=_,Object.keys(c).forEach(g=>{n[g]=c[g]}),n.names=[],n.skips=[],n.formatters={};function t(g){let T=0;for(let S=0;S<g.length;S++)T=(T<<5)-T+g.charCodeAt(S),T|=0;return n.colors[Math.abs(T)%n.colors.length]}n.selectColor=t;function n(g){let T,S=null,E,C;function A(...R){if(!A.enabled)return;const k=A,M=Number(new Date),ie=M-(T||M);k.diff=ie,k.prev=T,k.curr=M,T=M,R[0]=n.coerce(R[0]),typeof R[0]!="string"&&R.unshift("%O");let N=0;R[0]=R[0].replace(/%([a-zA-Z%])/g,(Ee,ve)=>{if(Ee==="%%")return"%";N++;const L=n.formatters[ve];if(typeof L=="function"){const D=R[N];Ee=L.call(k,D),R.splice(N,1),N--}return Ee}),n.formatArgs.call(k,R),(k.log||n.log).apply(k,R)}return A.namespace=g,A.useColors=n.useColors(),A.color=n.selectColor(g),A.extend=a,A.destroy=n.destroy,Object.defineProperty(A,"enabled",{enumerable:!0,configurable:!1,get:()=>S!==null?S:(E!==n.namespaces&&(E=n.namespaces,C=n.enabled(g)),C),set:R=>{S=R}}),typeof n.init=="function"&&n.init(A),A}function a(g,T){const S=n(this.namespace+(typeof T>"u"?":":T)+g);return S.log=this.log,S}function o(g){n.save(g),n.namespaces=g,n.names=[],n.skips=[];let T;const S=(typeof g=="string"?g:"").split(/[\s,]+/),E=S.length;for(T=0;T<E;T++)S[T]&&(g=S[T].replace(/\*/g,".*?"),g[0]==="-"?n.skips.push(new RegExp("^"+g.slice(1)+"$")):n.names.push(new RegExp("^"+g+"$")))}function s(){const g=[...n.names.map(d),...n.skips.map(d).map(T=>"-"+T)].join(",");return n.enable(""),g}function r(g){if(g[g.length-1]==="*")return!0;let T,S;for(T=0,S=n.skips.length;T<S;T++)if(n.skips[T].test(g))return!1;for(T=0,S=n.names.length;T<S;T++)if(n.names[T].test(g))return!0;return!1}function d(g){return g.toString().substring(2,g.toString().length-2).replace(/\.\*\?$/,"*")}function h(g){return g instanceof Error?g.stack||g.message:g}function _(){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 n.enable(n.load()),n}var ed=Zh;(function(c,t){t.formatArgs=a,t.save=o,t.load=s,t.useColors=n,t.storage=r(),t.destroy=(()=>{let h=!1;return()=>{h||(h=!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`."))}})(),t.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 n(){return typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)?!1: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&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function a(h){if(h[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+h[0]+(this.useColors?"%c ":" ")+"+"+c.exports.humanize(this.diff),!this.useColors)return;const _="color: "+this.color;h.splice(1,0,_,"color: inherit");let g=0,T=0;h[0].replace(/%[a-zA-Z%]/g,S=>{S!=="%%"&&(g++,S==="%c"&&(T=g))}),h.splice(T,0,_)}t.log=console.debug||console.log||(()=>{});function o(h){try{h?t.storage.setItem("debug",h):t.storage.removeItem("debug")}catch{}}function s(){let h;try{h=t.storage.getItem("debug")}catch{}return!h&&typeof process<"u"&&"env"in process&&(h=process.env.DEBUG),h}function r(){try{return localStorage}catch{}}c.exports=ed(t);const{formatters:d}=c.exports;d.j=function(h){try{return JSON.stringify(h)}catch(_){return"[UnexpectedJSONParseError]: "+_.message}}})(to,to.exports);var Nn=to.exports;function td(c,t){if(!(c instanceof t))throw new TypeError("Cannot call a class as a function")}function cc(c,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(c,a.key,a)}}function sd(c,t,n){return t&&cc(c.prototype,t),n&&cc(c,n),c}var Un=Nn,xn="JsSIP",ft=function(){function c(t){td(this,c),t?(this._debug=Un.default("".concat(xn,":").concat(t)),this._warn=Un.default("".concat(xn,":WARN:").concat(t)),this._error=Un.default("".concat(xn,":ERROR:").concat(t))):(this._debug=Un.default(xn),this._warn=Un.default("".concat(xn,":WARN")),this._error=Un.default("".concat(xn,":ERROR"))),this._debug.log=console.info.bind(console),this._warn.log=console.warn.bind(console),this._error.log=console.error.bind(console)}return sd(c,[{key:"debug",get:function(){return this._debug}},{key:"warn",get:function(){return this._warn}},{key:"error",get:function(){return this._error}}]),c}(),Ut={},fc={},hc={exports:{}},dc=hc.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(c){return c.encoding?"rtpmap:%d %s/%s/%s":c.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(c){return c.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(c){return c.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(c){return"extmap:%d"+(c.direction?"/%s":"%v")+(c["encrypt-uri"]?" %s":"%v")+" %s"+(c.config?" %s":"")}},{name:"extmapAllowMixed",reg:/^(extmap-allow-mixed)/},{push:"crypto",reg:/^crypto:(\d*) ([\w_]*) (\S*)(?: (\S*))?/,names:["id","suite","config","sessionConfig"],format:function(c){return c.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(c){var t="candidate:%s %d %s %d %s %d typ %s";return t+=c.raddr!=null?" raddr %s rport %d":"%v%v",t+=c.tcptype!=null?" tcptype %s":"%v",c.generation!=null&&(t+=" generation %d"),t+=c["network-id"]!=null?" network-id %d":"%v",t+=c["network-cost"]!=null?" network-cost %d":"%v",t}},{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(c){var t="ssrc:%d";return c.attribute!=null&&(t+=" %s",c.value!=null&&(t+=":%s")),t}},{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(c){return c.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(c){return c.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(c){return"imageattr:%s %s %s"+(c.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(c){return"simulcast:%s %s"+(c.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(c){return"ts-refclk:%s"+(c.clksrcExt!=null?"=%s":"")}},{name:"mediaClk",reg:/^mediaclk:(?:id=(\S*))? *([^\s=]*)(?:=(\S*))?(?: *rate=(\d+)\/(\d+))?/,names:["id","mediaClockName","mediaClockValue","rateNumerator","rateDenominator"],format:function(c){var t="mediaclk:";return t+=c.id!=null?"id=%s %s":"%v%s",t+=c.mediaClockValue!=null?"=%s":"",t+=c.rateNumerator!=null?" rate=%s":"",t+=c.rateDenominator!=null?"/%s":"",t}},{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"]}]};Object.keys(dc).forEach(function(c){var t=dc[c];t.forEach(function(n){n.reg||(n.reg=/(.*)/),n.format||(n.format="%s")})});var _c=hc.exports;(function(c){var t=function(d){return String(Number(d))===d?Number(d):d},n=function(d,h,_,g){if(g&&!_)h[g]=t(d[1]);else for(var T=0;T<_.length;T+=1)d[T+1]!=null&&(h[_[T]]=t(d[T+1]))},a=function(d,h,_){var g=d.name&&d.names;d.push&&!h[d.push]?h[d.push]=[]:g&&!h[d.name]&&(h[d.name]={});var T=d.push?{}:g?h[d.name]:h;n(_.match(d.reg),T,d.names,d.name),d.push&&h[d.push].push(T)},o=_c,s=RegExp.prototype.test.bind(/^([a-z])=(.*)/);c.parse=function(d){var h={},_=[],g=h;return d.split(/(\r\n|\r|\n)/).filter(s).forEach(function(T){var S=T[0],E=T.slice(2);S==="m"&&(_.push({rtp:[],fmtp:[]}),g=_[_.length-1]);for(var C=0;C<(o[S]||[]).length;C+=1){var A=o[S][C];if(A.reg.test(E))return a(A,g,E)}}),h.media=_,h};var r=function(d,h){var _=h.split(/=(.+)/,2);return _.length===2?d[_[0]]=t(_[1]):_.length===1&&h.length>1&&(d[_[0]]=void 0),d};c.parseParams=function(d){return d.split(/;\s?/).reduce(r,{})},c.parseFmtpConfig=c.parseParams,c.parsePayloads=function(d){return d.toString().split(" ").map(Number)},c.parseRemoteCandidates=function(d){for(var h=[],_=d.split(" ").map(t),g=0;g<_.length;g+=3)h.push({component:_[g],ip:_[g+1],port:_[g+2]});return h},c.parseImageAttributes=function(d){return d.split(" ").map(function(h){return h.substring(1,h.length-1).split(",").reduce(r,{})})},c.parseSimulcastStreamList=function(d){return d.split(";").map(function(h){return h.split(",").map(function(_){var g,T=!1;return _[0]!=="~"?g=t(_):(g=t(_.substring(1,_.length)),T=!0),{scid:g,paused:T}})})}})(fc);var no=_c,nd=/%[sdv%]/g,rd=function(c){var t=1,n=arguments,a=n.length;return c.replace(nd,function(o){if(t>=a)return o;var s=n[t];switch(t+=1,o){case"%%":return"%";case"%s":return String(s);case"%d":return Number(s);case"%v":return""}})},Cr=function(c,t,n){var a=t.format instanceof Function?t.format(t.push?n:n[t.name]):t.format,o=[c+"="+a];if(t.names)for(var s=0;s<t.names.length;s+=1){var r=t.names[s];t.name?o.push(n[t.name][r]):o.push(n[t.names[s]])}else o.push(n[t.name]);return rd.apply(null,o)},id=["v","o","s","i","u","e","p","c","b","t","r","z","a"],ld=["i","c","b","a"],ad=function(c,t){t=t||{},c.version==null&&(c.version=0),c.name==null&&(c.name=" "),c.media.forEach(function(s){s.payloads==null&&(s.payloads="")});var n=t.outerOrder||id,a=t.innerOrder||ld,o=[];return n.forEach(function(s){no[s].forEach(function(r){r.name in c&&c[r.name]!=null?o.push(Cr(s,r,c)):r.push in c&&c[r.push]!=null&&c[r.push].forEach(function(d){o.push(Cr(s,r,d))})})}),c.media.forEach(function(s){o.push(Cr("m",no.m[0],s)),a.forEach(function(r){no[r].forEach(function(d){d.name in s&&s[d.name]!=null?o.push(Cr(r,d,s)):d.push in s&&s[d.push]!=null&&s[d.push].forEach(function(h){o.push(Cr(r,d,h))})})})}),o.join(`\r
@@ -155,5 +155,5 @@ a=accept-types:text/plain text/html
155
155
  a=path:${t.getHeader("Use-Path")} msrp://${this._ua._configuration.authorization_user}.${this._ua._configuration.realm}:2856/${this.auth_id};ws
156
156
  `),this._newMSRPSession("local",this._request),this._id=this._request.call_id+this._from_tag,new Wr(this._ua,this._request,{onRequestTimeout:()=>{this.onRequestTimeout(),console.log("to")},onTransportError:s=>{this.onTransportError(),console.log(s)},onAuthenticated:s=>{this._request=s},onReceiveResponse:s=>{this._receiveInviteResponse(s),s.status_code===200&&(s.parseSDP(!0),this._status=Ae.STATUS_CONFIRMED,this.target_addr=s.sdp.media[0].invalid[1].value.replaceAll("path:","").split(" ").reverse(),this.status="active",this.emit("active"),this.emit("confirmed"))}}).send(),this._status=Ae.STATUS_INVITE_SENT}terminate(t={}){const n=t.cause||H.causes.BYE,a=Pe.cloneArray(t.extraHeaders),o=t.body;let s,r=t.status_code,d=t.reason_phrase;if(this._status===Ae.STATUS_TERMINATED)throw new Ns.InvalidStateError(this._status);switch(this.status="terminated",this._status){case Ae.STATUS_NULL:case Ae.STATUS_INVITE_SENT:case Ae.STATUS_1XX_RECEIVED:if(r&&(r<200||r>=700))throw new TypeError(`Invalid status_code: ${r}`);r&&(d=d||H.REASON_PHRASE[r]||"",s=`SIP ;cause=${r} ;text="${d}"`),this._status===Ae.STATUS_NULL||this._status===Ae.STATUS_INVITE_SENT?(this._is_canceled=!0,this._cancel_reason=s):this._status===Ae.STATUS_1XX_RECEIVED&&this._request.cancel(s),this._status=Ae.STATUS_CANCELED,this._failed("local",null,H.causes.CANCELED);break;case Ae.STATUS_WAITING_FOR_ANSWER:case Ae.STATUS_ANSWERED:if(r=r||480,r<300||r>=700)throw new TypeError(`Invalid status_code: ${r}`);this._request.reply(r,d,a,o),this._failed("local",null,H.causes.REJECTED);break;case Ae.STATUS_WAITING_FOR_ACK:case Ae.STATUS_CONFIRMED:if(d=t.reason_phrase||H.REASON_PHRASE[r]||"",r&&(r<200||r>=700))throw new TypeError(`Invalid status_code: ${r}`);if(r&&a.push(`Reason: SIP ;cause=${r}; text="${d}"`),this._status===Ae.STATUS_WAITING_FOR_ACK&&this._direction==="incoming"&&this._request.server_transaction.state!==jt.C.STATUS_TERMINATED){const h=this._dialog;this.receiveRequest=({method:_})=>{_===H.ACK&&(this.sendRequest(H.BYE,{extraHeaders:a,body:o}),h.terminate())},this._request.server_transaction.on("stateChanged",()=>{this._request.server_transaction.state===jt.C.STATUS_TERMINATED&&(this.sendRequest(H.BYE,{extraHeaders:a,body:o}),h.terminate())}),this._ended("local",null,n),this._dialog=h,this._ua.newDialog(h)}else this.sendRequest(H.BYE,{extraHeaders:a,body:o}),this._ended("local",null,n)}}sendRequest(t,n){return this._dialog.sendRequest(t,n)}authenticate(t){this.status="auth";let n=new jn("");n.method="AUTH",n.addHeader("To-Path",`msrp://${this._ua._configuration.realm}:2856;ws`),n.addHeader("From-Path",`msrp://${this.credentials.username}.${this.credentials.realm}:2856/${this.auth_id};ws`),t&&n.addHeader("Authorization",t.toString());let a=n.toString(),o=[];for(var s=0;s<a.length;s++)o.push(a.charCodeAt(s).toString(16));this._connection.send(n.toString())}onmessage(t){const n=new jn(t.data);if(this.status==="auth"&&n.code===401){const a=this.parseAuth(n.getHeader("WWW-Authenticate")),o=new Om(this.credentials);o.authenticate({method:"AUTH",ruri:`msrp://${this._ua._configuration.realm}:2856;ws`,body:null},a,Pe.createRandomToken(12)),this.authenticate(o)}this.status==="auth"&&n.code===200&&this._direction==="outgoing"?(this.my_addr.push(n.getHeader("To-Path")),this.my_addr.push(n.getHeader("Use-Path")),this.status="active",this.inviteParty(n)):this.status==="auth"&&n.code===200&&this._direction==="incoming"?(this.my_addr.push(n.getHeader("To-Path")),this.my_addr.push(n.getHeader("Use-Path")),this.status="active",this.acceptParty(n),this.emit("confirmed")):n.method==="SEND"&&(this._sendOk(n),this._sendReport(n),n.direction="incoming",this.emit("newMessage",n),this._msgHistory.push(n),this.emit("msgHistoryUpdate",this._msgHistory)),n.code===480&&this._close()}onclose(){console.log("close")}onopen(){const t=new RTCPeerConnection({iceServers:[]});t.createDataChannel(""),t.createOffer().then(t.setLocalDescription.bind(t)),t.onicecandidate=n=>{if(!n||!n.candidate||!n.candidate.candidate)return;const a=/([0-9]{1,3}(\.[0-9]{1,3}){3})/,o=n.candidate.candidate.match(a);this.my_ip=o&&o[1],t.onicecandidate=()=>{},this.authenticate(null)}}onerror(t){console.log(t)}_receiveInviteResponse(t){if(console.log("resp0000000000000",t),this._dialog&&t.status_code>=200&&t.status_code<=299)if(console.log("200000000000000"),this._dialog.id.call_id===t.call_id&&this._dialog.id.local_tag===t.from_tag&&this._dialog.id.remote_tag===t.to_tag){this.sendRequest(H.ACK);return}else{const n=new ua(this,t,"UAC");if(n.error!==void 0){console.log(n.error);return}this.sendRequest(H.ACK),this.sendRequest(H.BYE);return}if(this._is_canceled){t.status_code>=100&&t.status_code<200?this._request.cancel(this._cancel_reason):t.status_code>=200&&t.status_code<299&&this._acceptAndTerminate(t);return}if(!(this._status!==Ae.STATUS_INVITE_SENT&&this._status!==Ae.STATUS_1XX_RECEIVED))switch(console.log("start Switch"),!0){case/^100$/.test(t.status_code):this._status=Ae.STATUS_1XX_RECEIVED;break;case/^1[0-9]{2}$/.test(t.status_code):{if(!t.to_tag){console.log("1xx response received without to tag");break}if(t.hasHeader("contact")&&!this._createDialog(t,"UAC",!0))break;if(this._status=Ae.STATUS_1XX_RECEIVED,!t.body){this._progress("remote",t);break}const n={originator:"remote",type:"answer",sdp:t.body};console.log('emit "sdp"'),this.emit("sdp",n);const a=new RTCSessionDescription({type:"answer",sdp:n.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(a)).then(()=>this._progress("remote",t)).catch(o=>{console.log('emit "peerconnection:setremotedescriptionfailed" [error:%o]',o),this.emit("peerconnection:setremotedescriptionfailed",o)});break}case/^2[0-9]{2}$/.test(t.status_code):{if(console.log("maybe here???"),this._status=Ae.STATUS_CONFIRMED,!t.body){this._acceptAndTerminate(t,400,H.causes.MISSING_SDP),console.log("failed 3"),this._failed("remote",t,H.causes.BAD_MEDIA_DESCRIPTION);break}if(!this._createDialog(t,"UAC"))break;const n={originator:"remote",type:"answer",sdp:t.body};console.log('emit "sdp"'),this.emit("sdp",n),new RTCSessionDescription({type:"answer",sdp:n.sdp}),this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>{if(this._connection.signalingState==="stable")return this._connection.createOffer(this._rtcOfferConstraints).then(a=>this._connection.setLocalDescription(a)).catch(a=>{this._acceptAndTerminate(t,500,a.toString()),console.log("failed 4"),this._failed("local",t,H.causes.WEBRTC_ERROR)})}).then(()=>{this._handleSessionTimersInIncomingResponse(t),this._accepted("remote",t),this.sendRequest(H.ACK),this._confirmed("local",null)});break}default:{const n=Pe.sipErrorCause(t.status_code);console.log("failed 5"),this._failed("remote",t,n)}}}sendMSRP(t){const n=new jn("");n.method="SEND",n.addHeader("To-Path",`${this.my_addr[1]} ${this.target_addr[1]} ${this.target_addr[0]}`),n.addHeader("From-Path",`${this.my_addr[0]}`),n.addHeader("Message-ID",Pe.createRandomToken(10)),n.addHeader("Byte-Range","1-25/25"),n.addHeader("Content-Type","text/plain"),n.addHeader("Success-Report","yes"),n.addHeader("Failure-Report","yes"),n.body=t;let a=n.toString();console.log(a);let o=[];for(var s=0;s<a.length;s++)o.push(a.charCodeAt(s).toString(16));console.log(o),this._connection.send(n.toString()),n.direction="outgoing",this.emit("newMessage",n),this._msgHistory.push(n),this.emit("msgHistoryUpdate",this._msgHistory)}_sendOk(t){let n=t.ident,a=t.getHeader("Message-ID"),o=new jn("");o.method="200 OK",o.addHeader("To-Path",`${this.my_addr[1]}`),o.addHeader("From-Path",`${this.my_addr[0]}`),o.addHeader("Message-ID",a),o.ident=n;let s=o.toString();console.log(s);let r=[];for(var d=0;d<s.length;d++)r.push(s.charCodeAt(d).toString(16));console.log(r),this._connection.send(o.toString())}_sendReport(t){let n=t.ident,a=t.getHeader("Message-ID"),o=new jn("");o.method="REPORT",o.addHeader("To-Path",`${t.getHeader("From-Path")}`),o.addHeader("From-Path",`${this.my_addr[0]}`),o.addHeader("Message-ID",a),o.addHeader("Byte-Range","1-25/25"),o.addHeader("Status","000 200 OK"),o.ident=n;let s=o.toString();console.log(s);let r=[];for(var d=0;d<s.length;d++)r.push(s.charCodeAt(d).toString(16));console.log(r),this._connection.send(o.toString())}parseAuth(t){const n={},a=t.replace("Digest","").split(",");for(const o of a){const s=o.trim().split("=");n[s[0]]=s[1].match('^"(.+)"$')[1]}return n}init_incoming(t,n){let a;const o=t.hasHeader("Content-Type")?t.getHeader("Content-Type").toLowerCase():void 0;if(t.body&&o!=="application/sdp"){t.reply(415);return}if(this._status=Ae.STATUS_INVITE_RECEIVED,this._from_tag=t.from_tag,this._id=t.call_id+this._from_tag,this._request=t,this._contact=this._ua.contact.toString(),t.hasHeader("expires")&&(a=t.getHeader("expires")*1e3),t.to_tag=Pe.newTag(),!this._createDialog(t,"UAS",!0)){t.reply(500,"Missing Contact header field");return}t.body?this._late_sdp=!1:this._late_sdp=!0,this._status=Ae.STATUS_WAITING_FOR_ANSWER,this._timers.userNoAnswerTimer=setTimeout(()=>{t.reply(408),console.log("failed 6"),this._failed("local",null,H.causes.NO_ANSWER)},this._ua.configuration.no_answer_timeout),a&&(this._timers.expiresTimer=setTimeout(()=>{this._status===Ae.STATUS_WAITING_FOR_ANSWER&&(t.reply(487),console.log("failed 7"),this._failed("system",null,H.causes.EXPIRES))},a)),this._direction="incoming",this._local_identity=t.to,this._remote_identity=t.from,n&&n(this),t.parseSDP(!0),this.target_addr=t.sdp.media[0].invalid[1].value.replaceAll("path:","").split(" ").reverse(),this._newMSRPSession("remote",t),this._status!==Ae.STATUS_TERMINATED&&(t.reply(180,null,[`Contact: ${this._ua._contact}`]),this._progress("local",null))}_failed(t,n,a){this.emit("_failed",{originator:t,message:n||null,cause:a}),this._close(),this.emit("failed",{originator:t,message:n||null,cause:a})}_close(){if(console.log("CLOSE SESSION"),this._status!==Ae.STATUS_TERMINATED){if(this._status=Ae.STATUS_TERMINATED,this._connection)try{this._connection.close()}catch(t){console.log("close() | error closing the RTCPeerConnection: %o",t)}for(const t in this._timers)Object.prototype.hasOwnProperty.call(this._timers,t)&&clearTimeout(this._timers[t]);clearTimeout(this._sessionTimers.timer),this._dialog&&(this._dialog.terminate(),delete this._dialog);for(const t in this._earlyDialogs)Object.prototype.hasOwnProperty.call(this._earlyDialogs,t)&&(this._earlyDialogs[t].terminate(),delete this._earlyDialogs[t]);for(const t in this._referSubscribers)Object.prototype.hasOwnProperty.call(this._referSubscribers,t)&&delete this._referSubscribers[t];this._ua.destroyMSRPSession(this)}}_createDialog(t,n,a){const o=n==="UAS"?t.to_tag:t.from_tag,s=n==="UAS"?t.from_tag:t.to_tag,r=t.call_id+o+s;let d=this._earlyDialogs[r];if(a)return d?!0:(d=new ua(this,t,n,ua.C.STATUS_EARLY),d.error?(console.log("failed 8"),this._failed("remote",t,H.causes.INTERNAL_ERROR),!1):(this._earlyDialogs[r]=d,!0));{if(this._from_tag=t.from_tag,this._to_tag=t.to_tag,d)return d.update(t,n),this._dialog=d,delete this._earlyDialogs[r],!0;const h=new ua(this,t,n);return h.error?(console.log("failed 9"),this._failed("remote",t,H.causes.INTERNAL_ERROR),!1):(this._dialog=h,!0)}}_newMSRPSession(t,n){this._ua.newMSRPSession(this,{originator:t,session:this,request:n})}_progress(t,n){this.emit("progress",{originator:t,response:n||null})}isEnded(){switch(this._status){case Ae.STATUS_CANCELED:case Ae.STATUS_TERMINATED:return!0;default:return!1}}_accepted(t,n){console.log("session accepted"),this._start_time=new Date,console.log('emit "accepted"'),this.emit("accepted",{originator:t,response:n||null})}_confirmed(t,n){console.log("session confirmed"),this._is_confirmed=!0,console.log('emit "confirmed"'),this.emit("confirmed",{originator:t,ack:n||null})}_ended(t,n,a){console.log("session ended"),this._end_time=new Date,this._close(),console.log('emit "ended"'),this.emit("ended",{originator:t,message:n||null,cause:a})}_handleSessionTimersInIncomingResponse(t){if(!this._sessionTimers.enabled)return;let n;t.session_expires&&t.session_expires>=H.MIN_SESSION_EXPIRES?(this._sessionTimers.currentExpires=t.session_expires,n=t.session_expires_refresher||"uac"):(this._sessionTimers.currentExpires=this._sessionTimers.defaultExpires,n="uac"),this._sessionTimers.refresher=n==="uac",this._runSessionTimer()}receiveRequest(t){if(console.log("receiveRequest()"),t.method===H.CANCEL)(this._status===Ae.STATUS_WAITING_FOR_ANSWER||this._status===Ae.STATUS_ANSWERED)&&(this._status=Ae.STATUS_CANCELED,this._request.reply(487),console.log("failed 10"),this._failed("remote",t,H.causes.CANCELED));else switch(t.method){case H.ACK:if(this._status!==Ae.STATUS_WAITING_FOR_ACK)return;if(this._status=Ae.STATUS_CONFIRMED,clearTimeout(this._timers.ackTimer),clearTimeout(this._timers.invite2xxTimer),this._late_sdp){if(!t.body){this.terminate({cause:H.causes.MISSING_SDP,status_code:400});break}const n={originator:"remote",type:"answer",sdp:t.body};console.log('emit "sdp"'),this.emit("sdp",n);const a=new RTCSessionDescription({type:"answer",sdp:n.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(a)).then(()=>{this._is_confirmed||this._confirmed("remote",t)}).catch(o=>{this.terminate({cause:H.causes.BAD_MEDIA_DESCRIPTION,status_code:488}),console.log('emit "peerconnection:setremotedescriptionfailed" [error:%o]',o),this.emit("peerconnection:setremotedescriptionfailed",o)})}else this._is_confirmed||this._confirmed("remote",t);break;case H.BYE:this._status===Ae.STATUS_CONFIRMED||this._status===Ae.STATUS_WAITING_FOR_ACK?(t.reply(200),this._ended("remote",t,H.causes.BYE)):this._status===Ae.STATUS_INVITE_RECEIVED||this._status===Ae.STATUS_WAITING_FOR_ANSWER?(t.reply(200),this._request.reply(487,"BYE Received"),this._ended("remote",t,H.causes.BYE)):t.reply(403,"Wrong Status");break;case H.INVITE:this._status===Ae.STATUS_CONFIRMED?t.hasHeader("replaces")?this._receiveReplaces(t):this._receiveReinvite(t):t.reply(403,"Wrong Status");break;case H.INFO:this._status===Ae.STATUS_1XX_RECEIVED||this._status===Ae.STATUS_WAITING_FOR_ANSWER||this._status===Ae.STATUS_ANSWERED||this._status===Ae.STATUS_WAITING_FOR_ACK||this._status===Ae.STATUS_CONFIRMED?(t.hasHeader("Content-Type")?t.getHeader("Content-Type").toLowerCase():void 0)!==void 0?new nu(this).init_incoming(t):t.reply(415):t.reply(403,"Wrong Status");break;case H.UPDATE:this._status===Ae.STATUS_CONFIRMED?this._receiveUpdate(t):t.reply(403,"Wrong Status");break;case H.REFER:this._status===Ae.STATUS_CONFIRMED?this._receiveRefer(t):t.reply(403,"Wrong Status");break;case H.NOTIFY:this._status===Ae.STATUS_CONFIRMED?this._receiveNotify(t):t.reply(403,"Wrong Status");break;default:t.reply(501)}}onTransportError(){console.log("onTransportError()"),this._status!==Ae.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:H.causes.CONNECTION_ERROR,cause:H.causes.CONNECTION_ERROR})}onRequestTimeout(){console.log("onRequestTimeout()"),this._status!==Ae.STATUS_TERMINATED&&this.terminate({status_code:408,reason_phrase:H.causes.REQUEST_TIMEOUT,cause:H.causes.REQUEST_TIMEOUT})}onDialogError(){console.log("onDialogError()"),this._status!==Ae.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:H.causes.DIALOG_ERROR,cause:H.causes.DIALOG_ERROR})}}var TT=Jt();const yu=Me(TT),Ea=new na("Parser"),vT=(c,t)=>{let n,a,o=c.indexOf(`\r
157
157
  `);if(o===-1){Ea.warn("parseMessage() | no CRLF found, not a SIP message");return}const s=c.substring(0,o);let r=yu.parse(s,"Request_Response");if(r===-1){Ea.warn(`parseMessage() | error parsing first line of SIP message: "${s}"`);return}else r.status_code?(n=new Ln.IncomingResponse,n.status_code=r.status_code,n.reason_phrase=r.reason_phrase):(n=new Ln.IncomingRequest(t),n.method=r.method,n.ruri=r.uri);n.data=c;let d=o+2;for(;;){if(o=ST(c,d),o===-2){a=d+2;break}else if(o===-1){Ea.warn("parseMessage() | malformed message");return}if(r=ET(n,c,d,o),r!==!0){Ea.warn("parseMessage() |",r.error);return}d=o+2}if(n.hasHeader("content-length")){const h=n.getHeader("content-length");n.body=c.substr(a,h)}else n.body=c.substring(a);return n};function ST(c,t){let n=t,a=0,o=0;if(c.substring(n,n+2).match(/(^\r\n)/))return-2;for(;a===0;){if(o=c.indexOf(`\r
158
- `,n),o===-1)return o;!c.substring(o+2,o+4).match(/(^\r\n)/)&&c.charAt(o+2).match(/(^\s+)/)?n=o+2:a=o}return a}function ET(c,t,n,a){let o;const s=t.indexOf(":",n),r=t.substring(n,s).trim(),d=t.substring(s+1,a).trim();switch(r.toLowerCase()){case"via":case"v":c.addHeader("via",d),c.getHeaders("via").length===1?(o=c.parseHeader("Via"),o&&(c.via=o,c.via_branch=o.branch)):o=0;break;case"from":case"f":c.setHeader("from",d),o=c.parseHeader("from"),o&&(c.from=o,c.from_tag=o.getParam("tag"));break;case"to":case"t":c.setHeader("to",d),o=c.parseHeader("to"),o&&(c.to=o,c.to_tag=o.getParam("tag"));break;case"record-route":if(o=yu.parse(d,"Record_Route"),o===-1)o=void 0;else for(const h of o)c.addHeader("record-route",d.substring(h.possition,h.offset)),c.headers["Record-Route"][c.getHeaders("record-route").length-1].parsed=h.parsed;break;case"call-id":case"i":c.setHeader("call-id",d),o=c.parseHeader("call-id"),o&&(c.call_id=d);break;case"contact":case"m":if(o=yu.parse(d,"Contact"),o===-1)o=void 0;else for(const h of o)c.addHeader("contact",d.substring(h.possition,h.offset)),c.headers.Contact[c.getHeaders("contact").length-1].parsed=h.parsed;break;case"content-length":case"l":c.setHeader("content-length",d),o=c.parseHeader("content-length");break;case"content-type":case"c":c.setHeader("content-type",d),o=c.parseHeader("content-type");break;case"cseq":c.setHeader("cseq",d),o=c.parseHeader("cseq"),o&&(c.cseq=o.value),c instanceof Ln.IncomingResponse&&(c.method=o.method);break;case"max-forwards":c.setHeader("max-forwards",d),o=c.parseHeader("max-forwards");break;case"www-authenticate":c.setHeader("www-authenticate",d),o=c.parseHeader("www-authenticate");break;case"proxy-authenticate":c.setHeader("proxy-authenticate",d),o=c.parseHeader("proxy-authenticate");break;case"session-expires":case"x":c.setHeader("session-expires",d),o=c.parseHeader("session-expires"),o&&(c.session_expires=o.expires,c.session_expires_refresher=o.refresher);break;case"refer-to":case"r":c.setHeader("refer-to",d),o=c.parseHeader("refer-to"),o&&(c.refer_to=o);break;case"replaces":c.setHeader("replaces",d),o=c.parseHeader("replaces"),o&&(c.replaces=o);break;case"event":case"o":c.setHeader("event",d),o=c.parseHeader("event"),o&&(c.event=o);break;default:c.addHeader(r,d),o=0}return o===void 0?{error:`error parsing header "${r}"`}:!0}const yT={parseMessage:vT},si=new na("Registrator"),ya=10;class CT{constructor(t,n){this._reg_id=1,this._ua=t,this._transport=n,this._registrar=t.configuration.registrar_server,this._expires=t.configuration.register_expires,this._call_id=vs.createRandomToken(22),this._cseq=0,this._to_uri=t.configuration.uri,this._registrationTimer=null,this._registering=!1,this._registered=!1,this._contact=this._ua.contact.toString();const a=this._contact.indexOf(">");if(a!==-1){const o=this._contact.slice(0,a)+this._contact.slice(a+1,this._contact.length);this._contact=o}this._extra_contact="",this._extraContactParams="",this._extra_contact+=";+sip.ice",this._extraHeaders=[],this._sipInstance=`"<urn:uuid:${this._ua.configuration.instance_id}>"`,this._extra_contact+=`;reg-id=${this._reg_id}`,this._extra_contact+=`;+sip.instance=${this._sipInstance}`}get registered(){return this._registered}setExtraHeaders(t){Array.isArray(t)||(t=[]),this._extraHeaders=t.slice()}setExtraContactParams(t){t instanceof Object||(t={}),this._extraContactParams="";for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)){const a=t[n];this._extraContactParams+=`;${n}`,a&&(this._extraContactParams+=`=${a}`)}}setExtraContactUriParams(t){t instanceof Object||(t={}),this._extraContactParams="";for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)){const a=t[n];this._extraContactParams+=`;${n}`,a&&(this._extraContactParams+=`=${a}`)}}register(){if(this._registering){si.debug("Register request in progress...");return}const t=this._extraHeaders.slice();t.push(`Contact: ${this._contact}${this._extraContactParams}>${this._extra_contact};expires=${this._expires}`),t.push(`Expires: ${this._expires}`);const n=new Tt.OutgoingRequest(H.REGISTER,this._registrar,this._ua,{to_uri:this._to_uri,call_id:this._call_id,cseq:this._cseq+=1},t),a=new Wr(this._ua,n,{onRequestTimeout:()=>{this._registrationFailure(null,H.causes.REQUEST_TIMEOUT)},onTransportError:()=>{this._registrationFailure(null,H.causes.CONNECTION_ERROR)},onAuthenticated:()=>{this._cseq+=1},onReceiveResponse:o=>{if(o.cseq===this._cseq)switch(this._registrationTimer!==null&&(clearTimeout(this._registrationTimer),this._registrationTimer=null),!0){case/^1[0-9]{2}$/.test(o.status_code):break;case/^2[0-9]{2}$/.test(o.status_code):{if(this._registering=!1,!o.hasHeader("Contact")){si.debug("no Contact header in response to REGISTER, response ignored");break}const s=o.headers.Contact.reduce((_,g)=>_.concat(g.parsed),[]);let r=s.find(_=>this._sipInstance===_.getParam("+sip.instance")&&this._reg_id===parseInt(_.getParam("reg-id")));if(r||(r=s.find(_=>_.uri.user===this._ua.contact.uri.user)),!r){si.debug("no Contact header pointing to us, response ignored");break}this._ua.clearKeepAliveInterval(),this._ua.setLastRegisterTimestamp();let d=r.getParam("expires");!d&&o.hasHeader("expires")&&(d=o.getHeader("expires")),d||(d=this._expires),d=Number(d),d<ya&&(d=ya);const h=d>64?d*1e3/2+Math.floor((d/2-32)*1e3*Math.random()):d*1e3-5e3;this._registrationTimer=setTimeout(()=>{this._registrationTimer=null,this._ua.listeners("registrationExpiring").length===0?this.register():this._ua.emit("registrationExpiring")},h),r.hasParam("temp-gruu")&&(this._ua.contact.temp_gruu=r.getParam("temp-gruu").replace(/"/g,"")),r.hasParam("pub-gruu")&&(this._ua.contact.pub_gruu=r.getParam("pub-gruu").replace(/"/g,"")),this._registered||(this._registered=!0,this._ua.registered({response:o}));break}case/^423$/.test(o.status_code):{o.hasHeader("min-expires")?(this._expires=Number(o.getHeader("min-expires")),this._expires<ya&&(this._expires=ya),this.register()):(si.debug("423 response received for REGISTER without Min-Expires"),this._registrationFailure(o,H.causes.SIP_FAILURE_CODE));break}default:{const s=vs.sipErrorCause(o.status_code);this._registrationFailure(o,s)}}}});this._registering=!0,a.send()}unregister(t={}){if(!this._registered){si.debug("already unregistered");return}this._registered=!1,this._registrationTimer!==null&&(clearTimeout(this._registrationTimer),this._registrationTimer=null);const n=this._extraHeaders.slice();t.all?n.push(`Contact: *${this._extraContactParams}`):n.push(`Contact: ${this._contact}${this._extraContactParams}>${this._extra_contact};expires=0`),n.push("Expires: 0");const a=new Tt.OutgoingRequest(H.REGISTER,this._registrar,this._ua,{to_uri:this._to_uri,call_id:this._call_id,cseq:this._cseq+=1},n);new Wr(this._ua,a,{onRequestTimeout:()=>{this._unregistered(null,H.causes.REQUEST_TIMEOUT)},onTransportError:()=>{this._unregistered(null,H.causes.CONNECTION_ERROR)},onAuthenticated:()=>{this._cseq+=1},onReceiveResponse:s=>{switch(!0){case/^1[0-9]{2}$/.test(s.status_code):break;case/^2[0-9]{2}$/.test(s.status_code):this._unregistered(s);break;default:{const r=vs.sipErrorCause(s.status_code);this._unregistered(s,r)}}}}).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(t,n){this._registering=!1,this._ua.registrationFailed({response:t||null,cause:n}),this._registered&&(this._registered=!1,this._ua.unregistered({response:t||null,cause:n}))}_unregistered(t,n){this._registering=!1,this._registered=!1,this._ua.unregistered({response:t||null,cause:n||null})}}const et=console,ks={STATUS_INIT:0,STATUS_READY:1,STATUS_USER_CLOSED:2,STATUS_NOT_READY:3,CONFIGURATION_ERROR:1,NETWORK_ERROR:2},AT=cT;class RT extends AT{constructor(t){super(t),this._msrp_sessions=[],this._transactions={nist:{},nict:{},ist:{},ict:{}},this._janus_sessions=[],this.newStreamPlugins=[],this.processStreamPlugins=[],this.optionsInterval=null,this.lastOptionsTimestamp=null,this.lastRegisterTimestamp=null,this._registrator=new CT(this)}setLastRegisterTimestamp(){this.lastRegisterTimestamp=Date.now()}call(t,n){return super.call(t,n)}joinVideoCall(t,n,a){et.debug("call()");const o=new Sa(this);return o.configureMedia({audio:!0,video:!0}),o.connect(t,n,a),o}startScreenShare(){et.debug("startScreenShare()");for(const t in this._janus_sessions)this._janus_sessions[t].connectScreenShare()}changeMediaConstraints(t){for(const n in this._janus_sessions)this._janus_sessions[n].changeMediaConstraints(t)}startBlur(){for(const t in this._janus_sessions)this._janus_sessions[t].connectBlur()}stopBlur(){for(const t in this._janus_sessions)this._janus_sessions[t].stopBlur()}_loadConfig(t){try{ti.load(this._configuration,t)}catch(s){throw s}this._configuration.display_name===0&&(this._configuration.display_name="0"),this._configuration.instance_id||(this._configuration.instance_id=vs.newUUID());let n;typeof window<"u"&&typeof window.document<"u"?n=window==null?void 0:window.navigator.userAgent:typeof self<"u"&&self.navigator&&(n=self.navigator.userAgent),n+=" "+De.USER_AGENT,this._configuration.user_agent=t.overrideUserAgent&&typeof t.overrideUserAgent=="function"?t.overrideUserAgent(n):n,t.onTransportCallback&&typeof t.onTransportCallback=="function"&&(this.onTransportCallback=t.onTransportCallback),this._configuration.jssip_id=vs.createRandomToken(5);const a=this._configuration.uri.clone();a.user=null,this._configuration.hostport_params=a.toString().replace(/^sip:/i,"");try{this._transport=new Mg(this._configuration.sockets,{max_interval:this._configuration.connection_recovery_max_interval,min_interval:this._configuration.connection_recovery_min_interval}),this._transport.onconnecting=IT.bind(this),this._transport.onconnect=bT.bind(this),this._transport.ondisconnect=wT.bind(this),this._transport.ondata=OT.bind(this)}catch(s){throw et.warn(s),new Ns.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 s=this._configuration.uri.clone();s.user=null,s.clearParams(),s.clearHeaders(),this._configuration.registrar_server=s}this._configuration.no_answer_timeout*=1e3,this._configuration.contact_uri?this._configuration.via_host=this._configuration.contact_uri.host:this._configuration.contact_uri=new ln("sip",vs.createRandomToken(8),this._configuration.via_host,null,{transport:"ws"}),this._contact={pub_gruu:null,temp_gruu:null,uri:this._configuration.contact_uri,toString(s={}){const r=s.anonymous||null,d=s.outbound||null;let h="<";return r?h+=this.temp_gruu||"sip:anonymous@anonymous.invalid;transport=ws":h+=this.pub_gruu||this.uri.toString(),d&&(r?!this.temp_gruu:!this.pub_gruu)&&(h+=";ob"),h+=">",h}};const o=["authorization_user","password","realm","ha1","authorization_jwt","display_name","register"];for(const s in this._configuration)Object.prototype.hasOwnProperty.call(this._configuration,s)&&(o.indexOf(s)!==-1?Object.defineProperty(this._configuration,s,{writable:!0,configurable:!1}):Object.defineProperty(this._configuration,s,{writable:!1,configurable:!1}));et.debug("configuration parameters after validation:");for(const s in this._configuration)if(Object.prototype.hasOwnProperty.call(ti.settings,s))switch(s){case"uri":case"registrar_server":et.debug(`- ${s}: ${this._configuration[s]}`);break;case"password":case"ha1":case"authorization_jwt":et.debug(`- ${s}: NOT SHOWN`);break;default:et.debug(`- ${s}: ${JSON.stringify(this._configuration[s])}`)}}newMSRPSession(t,n){t.on("msgHistoryUpdate",a=>{console.log(a)}),this._msrp_sessions[t.id]=t,this.emit("newMSRPSession",n)}newJanusSession(t,n){this._janus_sessions[t.id]=t,this.newStreamPlugins.forEach(a=>{a.setSession(t)}),this.processStreamPlugins.forEach(a=>{a.setSession(t)}),this.emit("newJanusSession",n)}kill(){}destroyMSRPSession(t){delete this._msrp_sessions[t.id]}destroyJanusSession(t){delete this._janus_sessions[t.id]}clearKeepAliveInterval(){clearInterval(this.optionsInterval),this.optionsInterval=null}receiveRequest(t){var s,r,d,h;const n=t.method;if(t.ruri.user!==this._configuration.uri.user&&t.ruri.user!==this._contact.uri.user){et.debug("Request-URI does not point to us"),t.method!==De.ACK&&t.reply_sl(404);return}if(t.ruri.scheme===De.SIPS){t.reply_sl(416);return}if(jt.checkTransaction(this,t))return;if(n===De.INVITE?new jt.InviteServerTransaction(this,this._transport,t):n!==De.ACK&&n!==De.CANCEL&&new jt.NonInviteServerTransaction(this,this._transport,t),n===De.OPTIONS){if(this.lastOptionsTimestamp=Date.now(),this.optionsInterval||(this.emit("initKeepAliveInterval"),this.optionsInterval=setInterval(()=>{const g=Date.now(),T=this.lastOptionsTimestamp>g-35e3,S=this.lastRegisterTimestamp+this._configuration.register_expires*1e3>g;T&&S&&this.emit("keepAliveInterval")},35e3)),this.listeners("newOptions").length===0){t.reply(200);return}new yf.Options(this).init_incoming(t)}else if(n===De.MESSAGE){if(this.listeners("newMessage").length===0){t.reply(405);return}new yf.Message(this).init_incoming(t)}else if(n===De.INVITE&&!t.to_tag&&this.listeners("newRTCSession").length===0){t.reply(405);return}let a,o;if(t.to_tag)if(a=this._findDialog(t.call_id,t.from_tag,t.to_tag),a)a.receiveRequest(t);else if(n===De.NOTIFY)if(o=this._findSession(t),o)o.receiveRequest(t);else{if(t.body)try{const _=JSON.parse(t.body)||{};(r=(s=_.plugindata)==null?void 0:s.data)!=null&&r.publishers&&Object.values(this._janus_sessions)[0].receivePublishers(_),(h=(d=_.plugindata)==null?void 0:d.data)!=null&&h.unpublished&&Object.values(this._janus_sessions)[0].receiveUnpublished(_.plugindata.data.unpublished)}catch(_){console.error(_)}t.reply(200)}else n!==De.ACK&&t.reply(481);else switch(n){case De.INVITE:if(window.RTCPeerConnection)if(t.hasHeader("replaces")){const _=t.replaces;a=this._findDialog(_.call_id,_.from_tag,_.to_tag),a?(o=a.owner,o.isEnded()?t.reply(603):o.receiveRequest(t)):t.reply(481)}else t.body.search(/MSRP/ig)>-1?(o=new Eu(this),o.init_incoming(t)):t.body.search(/JANUS/ig)>-1||(o=new Sg(this),o.init_incoming(t));else et.warn("INVITE received but WebRTC is not supported"),t.reply(488);break;case De.BYE:t.reply(481);break;case De.CANCEL:o=this._findSession(t),o?o.receiveRequest(t):et.debug("received CANCEL request for a non existent session");break;case De.ACK:break;case De.NOTIFY:this.emit("sipEvent",{event:t.event,request:t}),t.reply(200);break;default:t.reply(405);break}}startMSRP(t,n){et.debug("startMSRP()",n);const a=new Eu(this);return a.connect(t),a}startJanus(t,n){et.debug("startJanus()",n);const a=new Eu(this);return a.connect(t),a}terminateMSRPSessions(t){et.debug("terminateSessions()");for(const n in this._msrp_sessions)this._msrp_sessions[n].isEnded()||this._msrp_sessions[n].terminate(t)}terminateJanusSessions(t){et.debug("terminateSessions()");for(const n in this._janus_sessions)this._janus_sessions[n].isEnded()||this._janus_sessions[n].terminate(t)}enableJanusAudio(t){et.debug("enableJanusAudio()");for(const n in this._janus_sessions)this._janus_sessions[n].isEnded()||(t?this._janus_sessions[n].startAudio():this._janus_sessions[n].stopAudio())}enableJanusVideo(t){et.debug("enableJanusVideo()");for(const n in this._janus_sessions)this._janus_sessions[n].isEnded()||(t?this._janus_sessions[n].startVideo():this._janus_sessions[n].stopVideo())}terminateAllSessions(){for(const t in this._sessions)if(Object.prototype.hasOwnProperty.call(this._sessions,t)){et.debug(`closing session ${t}`);try{this._sessions[t].terminate()}catch(n){console.error(n)}}}stop(t=!0){if(et.debug("stop()"),this._dynConfiguration={},this._status===ks.STATUS_USER_CLOSED){et.debug("UA already closed");return}this._registrator.close();const n=Object.keys(this._sessions).length;t&&this.terminateAllSessions();for(const o in this._msrp_sessions)if(Object.prototype.hasOwnProperty.call(this._msrp_sessions,o)){et.debug(`closing session ${o}`);try{this._msrp_sessions[o].terminate()}catch(s){console.error(s)}}for(const o in this._janus_sessions)if(Object.prototype.hasOwnProperty.call(this._janus_sessions,o)){et.debug(`closing session ${o}`);try{this._janus_sessions[o].terminate()}catch(s){console.error(s)}}for(const o in this._applicants)if(Object.prototype.hasOwnProperty.call(this._applicants,o))try{this._applicants[o].close()}catch(s){console.error(s)}this._status=ks.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&&n===0?this._transport.disconnect():this._closeTimer=setTimeout(()=>{this._closeTimer=null,this._transport.disconnect()},2e3)}}function IT(c){this.emit("connecting",c)}function bT(c){this._status!==ks.STATUS_USER_CLOSED&&(this._status=ks.STATUS_READY,this._error=null,this.emit("connected",c),this._dynConfiguration.register&&this._registrator.register())}function wT(c){const t=["nict","ict","nist","ist"];for(const n of t)for(const a in this._transactions[n])Object.prototype.hasOwnProperty.call(this._transactions[n],a)&&this._transactions[n][a].onTransportError();this.emit("disconnected",c),this._registrator.onTransportClosed(),this._status!==ks.STATUS_USER_CLOSED&&(this._status=ks.STATUS_NOT_READY,this._error=ks.NETWORK_ERROR)}function OT(c){const t=c.transport;let n=c.message;const a=n;if(n=yT.parseMessage(n,this),this.onTransportCallback&&typeof this.onTransportCallback=="function"&&this.onTransportCallback(n,a),!!n&&!(this._status===ks.STATUS_USER_CLOSED&&n instanceof Ln.IncomingRequest)&&Xg(n,this,t)){if(n instanceof Ln.IncomingRequest)n.transport=t,this.receiveRequest(n);else if(n instanceof Ln.IncomingResponse){let o;switch(n.method){case De.INVITE:o=this._transactions.ict[n.via_branch],o&&o.receiveResponse(n);break;case De.ACK:break;default:o=this._transactions.nict[n.via_branch],o&&o.receiveResponse(n);break}}}}const DT=["roomId","_audioMuted","_cancel_reason","_contact","direction","_end_time","_eventsCount","_from_tag","_id","_is_canceled","_is_confirmed","_late_sdp","_localHold","_videoMuted","status","start_time","_remote_identity","audioTag","isOnHold","localMuted","autoAnswer","putOnHoldTimestamp"],NT=["_cancel_reason","_contact","direction","_end_time","_eventsCount","_from_tag","_id","_is_canceled","_is_confirmed","_late_sdp","status","start_time","_remote_identity","target_addr"];function gh(c){const t={};return DT.forEach(n=>{c[n]!==void 0&&(t[n]=c[n])}),t.localHold=c._localHold,t}function Th(c){const t={};return NT.forEach(n=>{c[n]!==void 0&&(t[n]=c[n])}),t}async function Cu(c,t,n){const a=c.createMediaStreamSource(t),o=c.createMediaStreamDestination(),s=c.createGain();return a.connect(s),s.connect(o),s.gain.value=n,o.stream}function UT(c,t,n,a){if(vh())return;const o=document.createElement("audio");o.id=t._id,o.className="audioTag",o.srcObject=c,o.setSinkId(n),o.volume=a,o.play(),t.audioTag=o}function xT(c){if(c&&typeof c.log=="function"&&typeof c.warn=="function"&&typeof c.error=="function")return!0}function vh(){return/Mobi|react-native|Android|iPhone/i.test(navigator.userAgent)}const PT=at,kT=Jt(),Ot=new PT("WebSocketInterface");var MT=class{constructor(t){Ot.debug('new() [url:"%s"]',t),this._url=t,this._sip_uri=null,this._via_transport=null,this._ws=null;const n=kT.parse(t,"absoluteURI");if(n===-1)throw Ot.warn(`invalid WebSocket URI: ${t}`),new TypeError(`Invalid argument: ${t}`);if(n.scheme!=="wss"&&n.scheme!=="ws")throw Ot.warn(`invalid WebSocket URI scheme: ${n.scheme}`),new TypeError(`Invalid argument: ${t}`);this._sip_uri=`sip:${n.host}${n.port?`:${n.port}`:""};transport=ws`,this._via_transport=n.scheme.toUpperCase()}get via_transport(){return this._via_transport}set via_transport(t){this._via_transport=t.toUpperCase()}get sip_uri(){return this._sip_uri}get url(){return this._url}connect(){if(Ot.debug("connect()"),this.isConnected()){Ot.debug(`WebSocket ${this._url} is already connected`);return}else if(this.isConnecting()){Ot.debug(`WebSocket ${this._url} is connecting`);return}this._ws&&this.disconnect(),Ot.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(t){this._onError(t)}}disconnect(){Ot.debug("disconnect()"),this._ws&&(this._ws.onopen=()=>{},this._ws.onclose=()=>{},this._ws.onmessage=()=>{},this._ws.onerror=()=>{},this._ws.close(),this._ws=null)}send(t){return Ot.debug("send()"),this.isConnected()?(this._ws.send(t),!0):(Ot.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(){Ot.debug(`WebSocket ${this._url} connected`),this.onconnect()}_onClose({wasClean:t,code:n,reason:a}){Ot.debug(`WebSocket ${this._url} closed`),t===!1&&Ot.debug("WebSocket abrupt disconnection"),this.ondisconnect(!t,n,a)}_onMessage({data:t}){Ot.debug("received WebSocket message"),this.ondata(t)}_onError(t){Ot.warn(`WebSocket ${this._url} error: `,t)}};const Au=Tl,LT=De,$T=Ts,HT=mt(),FT=_h,jT=ps(),VT=qo(),qT=Jt(),BT=MT;Nn("JsSIP")("version %s",Au.version);var GT={C:LT,Exceptions:$T,Utils:HT,UA:FT,URI:jT,NameAddrHeader:VT,WebSocketInterface:BT,Grammar:qT,debug:Nn,get name(){return Au.title},get version(){return Au.version}};const WT=Me(GT);function Ru(c){return c<10?`0${c}`:`${c}`}function KT(c){let t=c.hours||0,n=c.minutes||0,a=c.seconds||0;a++,a===60&&(a=0,n++,n===60&&(n=0,t++));const o=`${Ru(t)}:${Ru(n)}:${Ru(a)}`;return{seconds:a,minutes:n,hours:t,formatted:o}}function YT(c){let t=0;for(let n=0;n<c.length;n++)t+=c[n]*c[n];return Math.sqrt(t/c.length)}async function JT(c,t,n=150){const a=t.createMediaStreamSource(c),o=t.createDelay();o.delayTime.value=n/1e3;const s=t.createGain();s.gain.value=0;const r=t.createMediaStreamDestination();return a.connect(o).connect(s).connect(r),{stream:r.stream,setSpeaking:d=>{s.gain.value=d?1:0}}}var yt={};yt.forEach=async(c,t,n)=>{const a=[];for(let o=0;o<c.length;o++)if(o in c){const s=Promise.resolve(c[o]).then(r=>t.call(n||globalThis,r,o,c));a.push(s)}await Promise.all(a)},yt.forEachSeries=async(c,t,n)=>{for(let a=0;a<c.length;a++)a in c&&await t.call(n||globalThis,await c[a],a,c)},yt.map=async(c,t,n)=>{const a=[];for(let o=0;o<c.length;o++)o in c&&(a[o]=Promise.resolve(c[o]).then(s=>t.call(n||globalThis,s,o,c)));return Promise.all(a)},yt.mapSeries=async(c,t,n)=>{const a=[];for(let o=0;o<c.length;o++)o in c&&(a[o]=await t.call(n||globalThis,await c[o],o,c));return a},yt.find=(c,t,n)=>new Promise((a,o)=>{if(c.length===0)return a();let s=1;for(let r=0;r<c.length;r++){const d=h=>{h?a(c[r]):s===c.length&&a(),s++};Promise.resolve(c[r]).then(h=>t.call(n||globalThis,h,r,c)).then(d).catch(o)}}),yt.findSeries=async(c,t,n)=>{for(let a=0;a<c.length;a++)if(await t.call(n||globalThis,await c[a],a,c))return c[a]},yt.findIndex=(c,t,n)=>new Promise((a,o)=>{if(c.length===0)return a(-1);let s=1;for(let r=0;r<c.length;r++){const d=h=>{h?a(r):s===c.length&&a(-1),s++};Promise.resolve(c[r]).then(h=>t.call(n||globalThis,h,r,c)).then(d).catch(o)}}),yt.findIndexSeries=async(c,t,n)=>{for(let a=0;a<c.length;a++)if(await t.call(n||globalThis,await c[a],a,c))return a},yt.some=(c,t,n)=>new Promise((a,o)=>{if(c.length===0)return a(!1);let s=1;for(let r=0;r<c.length;r++){if(!(r in c)){s++;continue}const d=h=>{h?a(!0):s===c.length&&a(!1),s++};Promise.resolve(c[r]).then(h=>t.call(n||globalThis,h,r,c)).then(d).catch(o)}}),yt.someSeries=async(c,t,n)=>{for(let a=0;a<c.length;a++)if(a in c&&await t.call(n||globalThis,await c[a],a,c))return!0;return!1},yt.every=(c,t,n)=>new Promise((a,o)=>{if(c.length===0)return a(!0);let s=1;for(let r=0;r<c.length;r++){if(!(r in c)){s++;continue}const d=h=>{h?s===c.length&&a(!0):a(!1),s++};Promise.resolve(c[r]).then(h=>t.call(n||globalThis,h,r,c)).then(d).catch(o)}}),yt.everySeries=async(c,t,n)=>{for(let a=0;a<c.length;a++)if(a in c&&!await t.call(n||globalThis,await c[a],a,c))return!1;return!0},yt.filter=(c,t,n)=>new Promise(async(a,o)=>{const s=[];for(let d=0;d<c.length;d++)d in c&&(s[d]=Promise.resolve(c[d]).then(h=>t.call(n||globalThis,h,d,c)).catch(o));const r=[];for(let d=0;d<s.length;d++)await s[d]&&r.push(await c[d]);a(r)}),yt.filterSeries=async(c,t,n)=>{const a=[];for(let o=0;o<c.length;o++)o in c&&await t.call(n||globalThis,await c[o],o,c)&&a.push(await c[o]);return a},yt.reduce=async(c,t,n)=>{if(c.length===0&&n===void 0)throw TypeError("Reduce of empty array with no initial value");let a,o;for(n!==void 0?(o=n,a=0):(o=c[0],a=1),a;a<c.length;a++)a in c&&(o=await t(await o,await c[a],a,c));return o};var Sh={};(function(c){const t=yt;Object.keys(t).forEach(n=>{const a=n.charAt(0).toUpperCase()+n.slice(1);c[`async${a}`]=async function(...o){return t[n](this,...o)}})})(Sh);var zT=Object.assign(yt,{instanceMethods:Sh});const Qt={NEW_CALL:"new_call",CALL_CONFIRMED:"confirmed",CALL_FAILED:"failed",CALL_PROGRESS:"progress",CALL_ENDED:"ended"};var XT={exports:{}};(function(c){var t=function(n){var a=Object.prototype,o=a.hasOwnProperty,s=Object.defineProperty||function(ee,Y,G){ee[Y]=G.value},r,d=typeof Symbol=="function"?Symbol:{},h=d.iterator||"@@iterator",_=d.asyncIterator||"@@asyncIterator",g=d.toStringTag||"@@toStringTag";function T(ee,Y,G){return Object.defineProperty(ee,Y,{value:G,enumerable:!0,configurable:!0,writable:!0}),ee[Y]}try{T({},"")}catch{T=function(Y,G,re){return Y[G]=re}}function S(ee,Y,G,re){var ge=Y&&Y.prototype instanceof ie?Y:ie,be=Object.create(ge.prototype),ke=new x(re||[]);return s(be,"_invoke",{value:J(ee,G,ke)}),be}n.wrap=S;function E(ee,Y,G){try{return{type:"normal",arg:ee.call(Y,G)}}catch(re){return{type:"throw",arg:re}}}var C="suspendedStart",A="suspendedYield",R="executing",k="completed",M={};function ie(){}function N(){}function j(){}var Ee={};T(Ee,h,function(){return this});var ve=Object.getPrototypeOf,L=ve&&ve(ve(se([])));L&&L!==a&&o.call(L,h)&&(Ee=L);var D=j.prototype=ie.prototype=Object.create(Ee);N.prototype=j,s(D,"constructor",{value:j,configurable:!0}),s(j,"constructor",{value:N,configurable:!0}),N.displayName=T(j,g,"GeneratorFunction");function B(ee){["next","throw","return"].forEach(function(Y){T(ee,Y,function(G){return this._invoke(Y,G)})})}n.isGeneratorFunction=function(ee){var Y=typeof ee=="function"&&ee.constructor;return Y?Y===N||(Y.displayName||Y.name)==="GeneratorFunction":!1},n.mark=function(ee){return Object.setPrototypeOf?Object.setPrototypeOf(ee,j):(ee.__proto__=j,T(ee,g,"GeneratorFunction")),ee.prototype=Object.create(D),ee},n.awrap=function(ee){return{__await:ee}};function q(ee,Y){function G(be,ke,Re,ae){var ye=E(ee[be],ee,ke);if(ye.type==="throw")ae(ye.arg);else{var lt=ye.arg,ot=lt.value;return ot&&typeof ot=="object"&&o.call(ot,"__await")?Y.resolve(ot.__await).then(function(Se){G("next",Se,Re,ae)},function(Se){G("throw",Se,Re,ae)}):Y.resolve(ot).then(function(Se){lt.value=Se,Re(lt)},function(Se){return G("throw",Se,Re,ae)})}}var re;function ge(be,ke){function Re(){return new Y(function(ae,ye){G(be,ke,ae,ye)})}return re=re?re.then(Re,Re):Re()}s(this,"_invoke",{value:ge})}B(q.prototype),T(q.prototype,_,function(){return this}),n.AsyncIterator=q,n.async=function(ee,Y,G,re,ge){ge===void 0&&(ge=Promise);var be=new q(S(ee,Y,G,re),ge);return n.isGeneratorFunction(Y)?be:be.next().then(function(ke){return ke.done?ke.value:be.next()})};function J(ee,Y,G){var re=C;return function(be,ke){if(re===R)throw new Error("Generator is already running");if(re===k){if(be==="throw")throw ke;return it()}for(G.method=be,G.arg=ke;;){var Re=G.delegate;if(Re){var ae=F(Re,G);if(ae){if(ae===M)continue;return ae}}if(G.method==="next")G.sent=G._sent=G.arg;else if(G.method==="throw"){if(re===C)throw re=k,G.arg;G.dispatchException(G.arg)}else G.method==="return"&&G.abrupt("return",G.arg);re=R;var ye=E(ee,Y,G);if(ye.type==="normal"){if(re=G.done?k:A,ye.arg===M)continue;return{value:ye.arg,done:G.done}}else ye.type==="throw"&&(re=k,G.method="throw",G.arg=ye.arg)}}}function F(ee,Y){var G=Y.method,re=ee.iterator[G];if(re===r)return Y.delegate=null,G==="throw"&&ee.iterator.return&&(Y.method="return",Y.arg=r,F(ee,Y),Y.method==="throw")||G!=="return"&&(Y.method="throw",Y.arg=new TypeError("The iterator does not provide a '"+G+"' method")),M;var ge=E(re,ee.iterator,Y.arg);if(ge.type==="throw")return Y.method="throw",Y.arg=ge.arg,Y.delegate=null,M;var be=ge.arg;if(!be)return Y.method="throw",Y.arg=new TypeError("iterator result is not an object"),Y.delegate=null,M;if(be.done)Y[ee.resultName]=be.value,Y.next=ee.nextLoc,Y.method!=="return"&&(Y.method="next",Y.arg=r);else return be;return Y.delegate=null,M}B(D),T(D,g,"Generator"),T(D,h,function(){return this}),T(D,"toString",function(){return"[object Generator]"});function Z(ee){var Y={tryLoc:ee[0]};1 in ee&&(Y.catchLoc=ee[1]),2 in ee&&(Y.finallyLoc=ee[2],Y.afterLoc=ee[3]),this.tryEntries.push(Y)}function U(ee){var Y=ee.completion||{};Y.type="normal",delete Y.arg,ee.completion=Y}function x(ee){this.tryEntries=[{tryLoc:"root"}],ee.forEach(Z,this),this.reset(!0)}n.keys=function(ee){var Y=Object(ee),G=[];for(var re in Y)G.push(re);return G.reverse(),function ge(){for(;G.length;){var be=G.pop();if(be in Y)return ge.value=be,ge.done=!1,ge}return ge.done=!0,ge}};function se(ee){if(ee){var Y=ee[h];if(Y)return Y.call(ee);if(typeof ee.next=="function")return ee;if(!isNaN(ee.length)){var G=-1,re=function ge(){for(;++G<ee.length;)if(o.call(ee,G))return ge.value=ee[G],ge.done=!1,ge;return ge.value=r,ge.done=!0,ge};return re.next=re}}return{next:it}}n.values=se;function it(){return{value:r,done:!0}}return x.prototype={constructor:x,reset:function(ee){if(this.prev=0,this.next=0,this.sent=this._sent=r,this.done=!1,this.delegate=null,this.method="next",this.arg=r,this.tryEntries.forEach(U),!ee)for(var Y in this)Y.charAt(0)==="t"&&o.call(this,Y)&&!isNaN(+Y.slice(1))&&(this[Y]=r)},stop:function(){this.done=!0;var ee=this.tryEntries[0],Y=ee.completion;if(Y.type==="throw")throw Y.arg;return this.rval},dispatchException:function(ee){if(this.done)throw ee;var Y=this;function G(ae,ye){return be.type="throw",be.arg=ee,Y.next=ae,ye&&(Y.method="next",Y.arg=r),!!ye}for(var re=this.tryEntries.length-1;re>=0;--re){var ge=this.tryEntries[re],be=ge.completion;if(ge.tryLoc==="root")return G("end");if(ge.tryLoc<=this.prev){var ke=o.call(ge,"catchLoc"),Re=o.call(ge,"finallyLoc");if(ke&&Re){if(this.prev<ge.catchLoc)return G(ge.catchLoc,!0);if(this.prev<ge.finallyLoc)return G(ge.finallyLoc)}else if(ke){if(this.prev<ge.catchLoc)return G(ge.catchLoc,!0)}else if(Re){if(this.prev<ge.finallyLoc)return G(ge.finallyLoc)}else throw new Error("try statement without catch or finally")}}},abrupt:function(ee,Y){for(var G=this.tryEntries.length-1;G>=0;--G){var re=this.tryEntries[G];if(re.tryLoc<=this.prev&&o.call(re,"finallyLoc")&&this.prev<re.finallyLoc){var ge=re;break}}ge&&(ee==="break"||ee==="continue")&&ge.tryLoc<=Y&&Y<=ge.finallyLoc&&(ge=null);var be=ge?ge.completion:{};return be.type=ee,be.arg=Y,ge?(this.method="next",this.next=ge.finallyLoc,M):this.complete(be)},complete:function(ee,Y){if(ee.type==="throw")throw ee.arg;return ee.type==="break"||ee.type==="continue"?this.next=ee.arg:ee.type==="return"?(this.rval=this.arg=ee.arg,this.method="return",this.next="end"):ee.type==="normal"&&Y&&(this.next=Y),M},finish:function(ee){for(var Y=this.tryEntries.length-1;Y>=0;--Y){var G=this.tryEntries[Y];if(G.finallyLoc===ee)return this.complete(G.completion,G.afterLoc),U(G),M}},catch:function(ee){for(var Y=this.tryEntries.length-1;Y>=0;--Y){var G=this.tryEntries[Y];if(G.tryLoc===ee){var re=G.completion;if(re.type==="throw"){var ge=re.arg;U(G)}return ge}}throw new Error("illegal catch attempt")},delegateYield:function(ee,Y,G){return this.delegate={iterator:se(ee),resultName:Y,nextLoc:G},this.method==="next"&&(this.arg=r),M}},n}(c.exports);try{regeneratorRuntime=t}catch{typeof globalThis=="object"?globalThis.regeneratorRuntime=t:Function("r","regeneratorRuntime = r")(t)}})(XT);var Eh={exports:{}};(function(c){(function(t,n){c.exports?c.exports=n():t.log=n()})(Mt,function(){var t=function(){},n="undefined",a=typeof window!==n&&typeof window.navigator!==n&&/Trident\/|MSIE /.test(window.navigator.userAgent),o=["trace","debug","info","warn","error"];function s(A,R){var k=A[R];if(typeof k.bind=="function")return k.bind(A);try{return Function.prototype.bind.call(k,A)}catch{return function(){return Function.prototype.apply.apply(k,[A,arguments])}}}function r(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function d(A){return A==="debug"&&(A="log"),typeof console===n?!1:A==="trace"&&a?r:console[A]!==void 0?s(console,A):console.log!==void 0?s(console,"log"):t}function h(A,R){for(var k=0;k<o.length;k++){var M=o[k];this[M]=k<A?t:this.methodFactory(M,A,R)}this.log=this.debug}function _(A,R,k){return function(){typeof console!==n&&(h.call(this,R,k),this[A].apply(this,arguments))}}function g(A,R,k){return d(A)||_.apply(this,arguments)}function T(A,R,k){var M=this,ie;R=R??"WARN";var N="loglevel";typeof A=="string"?N+=":"+A:typeof A=="symbol"&&(N=void 0);function j(D){var B=(o[D]||"silent").toUpperCase();if(!(typeof window===n||!N)){try{window.localStorage[N]=B;return}catch{}try{window.document.cookie=encodeURIComponent(N)+"="+B+";"}catch{}}}function Ee(){var D;if(!(typeof window===n||!N)){try{D=window.localStorage[N]}catch{}if(typeof D===n)try{var B=window.document.cookie,q=B.indexOf(encodeURIComponent(N)+"=");q!==-1&&(D=/^([^;]+)/.exec(B.slice(q))[1])}catch{}return M.levels[D]===void 0&&(D=void 0),D}}function ve(){if(!(typeof window===n||!N)){try{window.localStorage.removeItem(N);return}catch{}try{window.document.cookie=encodeURIComponent(N)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}M.name=A,M.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},M.methodFactory=k||g,M.getLevel=function(){return ie},M.setLevel=function(D,B){if(typeof D=="string"&&M.levels[D.toUpperCase()]!==void 0&&(D=M.levels[D.toUpperCase()]),typeof D=="number"&&D>=0&&D<=M.levels.SILENT){if(ie=D,B!==!1&&j(D),h.call(M,D,A),typeof console===n&&D<M.levels.SILENT)return"No console available for logging"}else throw"log.setLevel() called with invalid level: "+D},M.setDefaultLevel=function(D){R=D,Ee()||M.setLevel(D,!1)},M.resetLevel=function(){M.setLevel(R,!1),ve()},M.enableAll=function(D){M.setLevel(M.levels.TRACE,D)},M.disableAll=function(D){M.setLevel(M.levels.SILENT,D)};var L=Ee();L==null&&(L=R),M.setLevel(L,!1)}var S=new T,E={};S.getLogger=function(R){if(typeof R!="symbol"&&typeof R!="string"||R==="")throw new TypeError("You must supply a name when creating a logger.");var k=E[R];return k||(k=E[R]=new T(R,S.getLevel(),S.methodFactory)),k};var C=typeof window!==n?window.log:void 0;return S.noConflict=function(){return typeof window!==n&&window.log===S&&(window.log=C),S},S.getLoggers=function(){return E},S.default=S,S})})(Eh);var It=Eh.exports;const Ss=()=>`${new Date().toISOString()} | metrics`,Es=(c,t,n)=>`${c} | ${t} | ${n}`;It.setDefaultLevel(It.levels.TRACE);const QT=c=>{It.info(Es(Ss(),"log ",`set log level to ${c?"verbose":"info"}`)),It.setLevel(c?It.levels.TRACE:It.levels.INFO)},ZT=c=>{const t=[...Object.keys(It.levels)];t.includes(c)?(It.info(Es(Ss(),"log ",`update log level to ${c.toLowerCase()}`)),It.setLevel(c)):It.warn(Es(Ss(),"log ","Incorrect log level please choose one of "),t)},xe=(c,t,n)=>{n?It.debug(Es(Ss(),c,t),n):It.debug(Es(Ss(),c,t))},Iu=(c,t)=>{It.info(Es(Ss(),c,t))},an=(c,t)=>{It.info(Es(Ss(),c,t))},Ca=(c,t)=>{It.warn(Es(Ss(),c,t))},Vn=(c,t)=>{It.error(Es(Ss(),c,t))};function ev(c){return Math.floor(Math.random()*c).toString()}function yh(c,t){let n=t;return c.forEach(a=>{n=n.replace(a,"")}),n}function tv(c,t){let n="";for(let a=0;a<t;a+=1)n+=c[ev(c.length)];return n}function sv({length:c=20,useLetters:t=!0,useNumbers:n=!0,includeSymbols:a=[],excludeSymbols:o=[]}={}){let s="abcdefghijklmnopqrstuvwxyz",r="0123456789",d=[],h=[],_=[];return t&&(o.length&&(s=yh(o,s)),h=s.split("")),n&&(o.length&&(r=yh(o,r)),_=r.split("")),d=[...h,..._,...a],tv(d,c)}var nv=sv;const ni=Me(nv),rv=()=>"WebRTCMetrics",iv=()=>"5.0.3",$e={INBOUND:"inbound",OUTBOUND:"outbound"},ys={IDLE:"idle",RUNNING:"running",MUTED:"muted"},ri={NEW:"new",CHECKING:"checking",CONNECTED:"connected",COMPLETED:"completed",DISCONNECTED:"disconnected",FAILED:"failed",CLOSED:"closed"},lv=()=>({...{delta_time_to_measure_probes_ms:0,delta_time_consumed_to_measure_ms:0,delta_KBytes_in:0,delta_KBytes_out:0,delta_kbs_in:0,delta_kbs_out:0,total_time_decoded_in:0,total_time_encoded_out:0,probes:[]}}),Ch={level_in:0,codec_id_in:"",codec_in:{mime_type:null,clock_rate:null,sdp_fmtp_line:null},delta_jitter_ms_in:0,percent_packets_lost_in:0,delta_packets_in:0,delta_packets_lost_in:0,total_packets_in:0,total_packets_lost_in:0,total_KBytes_in:0,delta_KBytes_in:0,delta_kbs_in:0,mos_in:0,mos_emodel_in:0,ssrc:"",direction:$e.INBOUND},Ah={level_out:0,codec_id_out:"",codec_out:{mime_type:null,clock_rate:null,sdp_fmtp_line:null},delta_jitter_ms_out:0,delta_rtt_ms_out:null,total_rtt_ms_out:0,total_rtt_measure_out:0,percent_packets_lost_out:0,delta_packets_out:0,delta_packets_lost_out:0,total_packets_out:0,total_packets_lost_out:0,total_KBytes_out:0,delta_KBytes_out:0,delta_kbs_out:0,timestamp_out:null,mos_out:0,mos_emodel_out:0,ssrc:"",direction:$e.OUTBOUND},Rh={codec_id_in:"",size_in:{width:null,height:null,framerate:null},codec_in:{mime_type:null,clock_rate:null},delta_jitter_ms_in:0,percent_packets_lost_in:0,delta_packets_in:0,delta_packets_lost_in:0,total_packets_in:0,total_packets_lost_in:0,total_KBytes_in:0,delta_KBytes_in:0,delta_kbs_in:0,decoder_in:null,delta_ms_decode_frame_in:0,total_frames_decoded_in:0,total_time_decoded_in:0,delta_nack_sent_in:0,delta_pli_sent_in:0,total_nack_sent_in:0,total_pli_sent_in:0,ssrc:"",direction:$e.INBOUND},Ih={codec_id_out:"",size_out:{width:null,height:null,framerate:null},codec_out:{mime_type:null,clock_rate:null},delta_jitter_ms_out:0,delta_rtt_ms_out:null,total_rtt_ms_out:0,total_rtt_measure_out:0,percent_packets_lost_out:0,delta_packets_out:0,delta_packets_lost_out:0,total_packets_out:0,total_packets_lost_out:0,total_KBytes_out:0,delta_KBytes_out:0,delta_kbs_out:0,encoder_out:null,delta_ms_encode_frame_out:0,total_time_encoded_out:0,total_frames_encoded_out:0,delta_nack_received_out:0,delta_pli_received_out:0,total_nack_received_out:0,total_pli_received_out:0,limitation_out:{reason:null,durations:null,resolutionChanges:0},timestamp_out:null,ssrc:"",direction:$e.OUTBOUND},av=c=>{const t={pname:"",call_id:"",user_id:"",timestamp:null,count:0,audio:{},video:{},network:{infrastructure:3,local_candidate_id:"",local_candidate_type:"",local_candidate_protocol:"",local_candidate_relay_protocol:"",remote_candidate_id:"",remote_candidate_type:"",remote_candidate_protocol:""},data:{total_KBytes_in:0,total_KBytes_out:0,delta_KBytes_in:0,delta_KBytes_out:0,delta_kbs_in:0,delta_kbs_out:0,delta_kbs_bandwidth_in:0,delta_kbs_bandwidth_out:0,delta_rtt_connectivity_ms:null,total_rtt_connectivity_ms:0,total_rtt_connectivity_measure:0},experimental:{time_to_measure_ms:0}};if(c){const n={...c,audio:{},video:{},data:{...c.data},network:{...c.network},experimental:{...c.experimental}};return Object.keys(c.audio).forEach(a=>{n.audio[a]={...c.audio[a]}}),Object.keys(c.video).forEach(a=>{n.video[a]={...c.video[a]}}),n}return{...t,audio:{},video:{},data:{...t.data},network:{...t.network},experimental:{...t.experimental}}},ov={refreshEvery:2e3,startAfter:0,stopAfter:-1,verbose:!1,pname:`p-${ni()}`,cid:`c-${ni()}`,uid:`u-${ni()}`,record:!1,ticket:!0},Zt={CANDIDATE_PAIR:"candidate-pair",CODEC:"codec",INBOUND_RTP:"inbound-rtp",LOCAL_CANDIDATE:"local-candidate",MEDIA_SOURCE:"media-source",OUTBOUND_RTP:"outbound-rtp",REMOTE_CANDIDATE:"remote-candidate",REMOTE_INBOUND_RTP:"remote-inbound-rtp",TRACK:"track"},V={AUDIO_LEVEL:"audioLevel",AVAILABLE_OUTGOING_BITRATE:"availableOutgoingBitrate",AVAILABLE_INCOMING_BITRATE:"availableIncomingBitrate",BYTES_RECEIVED:"bytesReceived",BYTES_SENT:"bytesSent",CANDIDATE_TYPE:"candidateType",CHANNELS:"channels",CLOCK_RATE:"clockRate",CODEC_ID:"codecId",CURRENT_ROUND_TRIP_TIME:"currentRoundTripTime",ROUND_TRIP_TIME:"roundTripTime",FRACTION_LOST:"fractionLost",FRAME_HEIGHT:"frameHeight",FRAME_WIDTH:"frameWidth",QUALITY_LIMITATION_REASON:"qualityLimitationReason",QUALITY_LIMITATION_DURATIONS:"qualityLimitationDurations",QUALITY_LIMITATION_RESOLUTION_CHANGES:"qualityLimitationResolutionChanges",ID:"id",JITTER:"jitter",KIND:"kind",MEDIA_TYPE:"mediaType",MIME_TYPE:"mimeType",LOCAL_CANDIDATE_ID:"localCandidateId",NETWORK_TYPE:"networkType",RELAY_PROTOCOL:"relayProtocol",NOMINATED:"nominated",PACKETS_LOST:"packetsLost",PACKETS_RECEIVED:"packetsReceived",PACKETS_SENT:"packetsSent",PROTOCOL:"protocol",PORT:"port",REMOTE_CANDIDATE_ID:"remoteCandidateId",REMOTE_SOURCE:"remoteSource",RESPONSES_RECEIVED:"responsesReceived",SDP_FMTP_LINE:"sdpFmtpLine",SSRC:"ssrc",SELECTED:"selected",STATE:"state",TIMESTAMP:"timestamp",TOTAL_ROUND_TRIP_TIME:"totalRoundTripTime",TOTAL_ROUND_TRIP_TIME_MEASUREMENTS:"roundTripTimeMeasurements",TYPE:"type",DECODER_IMPLEMENTATION:"decoderImplementation",ENCODER_IMPLEMENTATION:"encoderImplementation",FRAMES_DECODED:"framesDecoded",FRAMES_ENCODED:"framesEncoded",FRAMES_PER_SECOND:"framesPerSecond",TOTAL_DECODE_TIME:"totalDecodeTime",TOTAL_ENCODE_TIME:"totalEncodeTime",PLI:"pliCount",NACK:"nackCount"},P={SUCCEEDED:"succeeded",AUDIO:"audio",VIDEO:"video"},ii={ETHERNET:0,CELLULAR_5G:2,WIFI:3,CELLULAR_4G:5,CELLULAR:10},bu={ETHERNET:"ethernet",CELLULAR_4G:"cellular",WIFI:"wifi"},ne={AUDIO:"audio",VIDEO:"video",NETWORK:"network",DATA:"data"},wu="config ",uv=(c,t={},n)=>{const a={...n,...t};return t.pname||Ca(wu,`Argument [String] 'cfg.pname' for the peerConnection name or id is missing - use generated '${n.pname}'`),t.cid||Ca(wu,`Argument [String] 'cfg.cid' for the call name or id is missing - use generated '${n.cid}'`),t.uid||Ca(wu,`Argument [String] 'cfg.uid' for the user name or id is missing - use generated '${n.uid}'`),a.pc=c,a},cv=(c={})=>{const t={...ov,...c};return t.name=rv(),t.version=iv(),t},li=(c,t,n,a=!1,o)=>{let s=c.map(r=>{if(!n)return r[t];if(!o)return r[t][n];const d=r[t][o];return d?d[n]:null});return s=s.filter(r=>a?Number.isFinite(r)&&r>0:Number.isFinite(r)),s.length===0?[]:s},Ms=c=>c.reduce((t,n)=>t+n,0)/c.length,fv=()=>`probe-${ni()}`,hv=()=>`coltr-${ni()}`,bh=c=>new Promise(t=>setTimeout(t,c)),Ou=(c,t,n)=>{t?c.call(t,n):c(n)},We=(c,t,n,a)=>{const o=li(c,t,n,!0,a);if(o.length===0)return null;const s=o.reduce((_,g)=>_+g,0)/o.length;return s===0?null:o.map(_=>Math.abs(s-_)).reduce((_,g)=>_+g,0)/o.length*100/s},Xe=(c,t,n,a=!1,o)=>{const s=li(c,t,n,a,o);return s.length===0?null:s.reduce((r,d)=>r+d,0)/s.length},on=(c,t,n)=>li(c,t,n).reduce((o,s)=>o+s,0),Ke=(c,t,n,a)=>{const o=li(c,t,n,!0,a);return o.length===0?null:Math.min(...o)},Ye=(c,t,n,a)=>{const o=li(c,t,n,!1,a);return o.length===0?null:Math.max(...o)},Ct=(c,t,n,a)=>{const o=c.slice().pop();if(!o)return null;if(!n)return o[t];if(!a)return o[t][n];const s=o[t][a];return s?s[n]:null},dv=c=>c.slice().pop(),ht=(c,t,n)=>{if(!t)return null;const a={};let o=t[P.AUDIO][c];o||(o=n===$e.INBOUND?{...Ch}:{...Ah}),a[P.AUDIO]=o;let s=t[P.VIDEO][c];return s||(s=n===$e.INBOUND?{...Rh}:{...Ih}),a[P.VIDEO]=s,a},ai="exporter ",_v="2.0",wh=(c,t,n)=>{if(!c||c.length===0)return 0;const a=c[c.length-1];if(!a)return 0;const o=a[t][n];if(o){const s=o.total_rtt_ms_out,r=o.total_rtt_measure_out;return!r||!s?Xe(c,t,"delta_rtt_ms_out",!1,n):Number(s/r)}return null},pv=(c,t)=>{if(!c||c.length===0)return 0;const n=c[c.length-1];if(!n)return 0;const a=n[t].total_rtt_connectivity_ms,o=n[t].total_rtt_connectivity_measure;return!o||!a?Xe(c,t,"delta_rtt_connectivity_ms"):Number(a/o)},mv=c=>Ct(c,"network","local_candidate_type")!=="relay"?`direct/${Ct(c,"network","local_candidate_protocol")}`:`turn/${Ct(c,"network","local_candidate_relay_protocol")}`,gv=c=>{const t=Ct(c,"network","remote_candidate_type"),n=Ct(c,"network","remote_candidate_protocol");return t!=="relay"?`direct/${n}`:`turn/${n}`};class Tv{constructor(t){this._start=null,this._end=null,this._cfg=t,this._referenceReport=null,this._reports=[],this._events=[]}start(){Iu(ai,"start() - start exporter...");const t=new Date;return this._start=t.toJSON(),t}stop(){Iu(ai,"stop() - stop exporter...");const t=new Date;return this._end=t.toJSON(),t}saveReferenceReport(t){this._referenceReport=t}getReferenceReport(){return this._referenceReport}addReport(t){this._cfg.ticket&&(xe(ai,`addReport() - add report to exporter at ${t.timestamp}`),this._reports.push(t))}addCustomEvent(t){this._events.push(t)}reset(){Iu(ai,"resetReports() - reset reports"),this._reports=[],this._referenceReport=null,this._start=null,this._end=null}get ticket(){xe(ai,"ticket() - generate ticket");const t=Ct(this._reports,"audio","total_packets_lost_in"),n=Ct(this._reports,"audio","total_packets_in"),a=Ct(this._reports,"video","total_packets_lost_in"),o=Ct(this._reports,"video","total_packets_in"),s={},r=dv(this._reports);return r&&(Object.keys(r[P.AUDIO]).forEach(d=>{const h=r[P.AUDIO][d];if(s[h.ssrc]={type:P.AUDIO,direction:h.direction},h.direction===$e.INBOUND){const _={avg:Xe(this._reports,P.AUDIO,"delta_jitter_ms_in",!1,d),min:Ke(this._reports,P.AUDIO,"delta_jitter_ms_in",d),max:Ye(this._reports,P.AUDIO,"delta_jitter_ms_in",d),volatility:We(this._reports,P.AUDIO,"delta_jitter_ms_in",d),_unit:{avg:"ms",min:"ms",max:"ms",volatility:"percent"}},g={avg:Xe(this._reports,P.AUDIO,"delta_kbs_in",!1,d),min:Ke(this._reports,P.AUDIO,"delta_kbs_in",d),max:Ye(this._reports,P.AUDIO,"delta_kbs_in",d),volatility:We(this._reports,P.AUDIO,"delta_kbs_in",d),_unit:{avg:"kbs",min:"kbs",max:"kbs",volatility:"percent"}},T={avg:Xe(this._reports,P.AUDIO,"delta_KBytes_in",!1,d),min:Ke(this._reports,P.AUDIO,"delta_KBytes_in",d),max:Ye(this._reports,P.AUDIO,"delta_KBytes_in",d),volatility:We(this._reports,P.AUDIO,"delta_KBytes_in",d),_unit:{avg:"KB",min:"KB",max:"KB",volatility:"percent"}},S={emodel:{avg:Xe(this._reports,P.AUDIO,"mos_emodel_in",!1,d),min:Ke(this._reports,P.AUDIO,"mos_emodel_in",d),max:Ye(this._reports,P.AUDIO,"mos_emodel_in",d),volatility:We(this._reports,P.AUDIO,"mos_emodel_in",d)},effective:{avg:Xe(this._reports,P.AUDIO,"mos_in",!1,d),min:Ke(this._reports,P.AUDIO,"mos_in",d),max:Ye(this._reports,P.AUDIO,"mos_in",d),volatility:We(this._reports,P.AUDIO,"mos_in",d)},_unit:{avg:"number (1-5)",min:"number (1-5)",max:"number (1-5)",volatility:"percent"}},E=Ct(this._reports,P.AUDIO,"total_packets_lost_in",d),C=Ct(this._reports,P.AUDIO,"total_packets_in",d),A={lost:E,avg:Math.round((E/(E+C)*100||0)*100)/100,_unit:{avg:"percent",lost:"number"}};s[d].jitter=_,s[d].mos=S,s[d].traffic=T,s[d].bitrate=g,s[d].loss=A}else{const _={avg:Xe(this._reports,P.AUDIO,"delta_jitter_ms_out",!1,d),min:Ke(this._reports,P.AUDIO,"delta_jitter_ms_out",d),max:Ye(this._reports,P.AUDIO,"delta_jitter_ms_out",d),volatility:We(this._reports,P.AUDIO,"delta_jitter_ms_out",d),_unit:{avg:"ms",min:"ms",max:"ms",volatility:"percent"}},g={avg:Xe(this._reports,P.AUDIO,"delta_kbs_out",!1,d),min:Ke(this._reports,P.AUDIO,"delta_kbs_out",d),max:Ye(this._reports,P.AUDIO,"delta_kbs_out",d),volatility:We(this._reports,P.AUDIO,"delta_kbs_out",d),_unit:{avg:"kbs",min:"kbs",max:"kbs",volatility:"percent"}},T={avg:Xe(this._reports,P.AUDIO,"delta_KBytes_out",!1,d),min:Ke(this._reports,P.AUDIO,"delta_KBytes_out",d),max:Ye(this._reports,P.AUDIO,"delta_KBytes_out",d),volatility:We(this._reports,P.AUDIO,"delta_KBytes_out",d),_unit:{avg:"KB",min:"KB",max:"KB",bitrate:"kbs",volatility:"percent"}},S={avg:wh(this._reports,P.AUDIO,d),min:Ke(this._reports,P.AUDIO,"delta_rtt_ms_out",d),max:Ye(this._reports,P.AUDIO,"delta_rtt_ms_out",d),volatility:We(this._reports,P.AUDIO,"delta_rtt_ms_out",d),_unit:{avg:"ms",min:"ms",max:"ms",volatility:"percent"}},E=Ct(this._reports,P.AUDIO,"total_packets_lost_out",d),C=Ct(this._reports,P.AUDIO,"total_packets_out",d),A={lost:E,avg:Math.round((E/(E+C)*100||0)*100)/100,_unit:{avg:"percent",lost:"number"}},R={emodel:{avg:Xe(this._reports,P.AUDIO,"mos_emodel_out",!1,d),min:Ke(this._reports,P.AUDIO,"mos_emodel_out",d),max:Ye(this._reports,P.AUDIO,"mos_emodel_out",d),volatility:We(this._reports,P.AUDIO,"mos_emodel_out",d)},effective:{avg:Xe(this._reports,P.AUDIO,"mos_out",!1,d),min:Ke(this._reports,P.AUDIO,"mos_out",d),max:Ye(this._reports,P.AUDIO,"mos_out",d),volatility:We(this._reports,P.AUDIO,"mos_out",d)},_unit:{avg:"number (1-5)",min:"number (1-5)",max:"number (1-5)",volatility:"percent"}};s[d].jitter=_,s[d].rtt=S,s[d].traffic=T,s[d].bitrate=g,s[d].loss=A,s[d].mos=R}}),Object.keys(r[P.VIDEO]).forEach(d=>{const h=r[P.VIDEO][d];if(s[d]={type:P.VIDEO,direction:h.direction},h.direction===$e.INBOUND){const _={avg:Xe(this._reports,P.VIDEO,"delta_jitter_ms_in",!1,d),min:Ke(this._reports,P.VIDEO,"delta_jitter_ms_in",d),max:Ye(this._reports,P.VIDEO,"delta_jitter_ms_in",d),volatility:We(this._reports,P.VIDEO,"delta_jitter_ms_in",d),_unit:{avg:"ms",min:"ms",max:"ms",volatility:"percent"}},g={avg:Xe(this._reports,P.VIDEO,"delta_kbs_in",!1,d),min:Ke(this._reports,P.VIDEO,"delta_kbs_in",d),max:Ye(this._reports,P.VIDEO,"delta_kbs_in",d),volatility:We(this._reports,P.VIDEO,"delta_kbs_in",d),_unit:{avg:"kbs",min:"kbs",max:"kbs",volatility:"percent"}},T={avg:Xe(this._reports,P.VIDEO,"delta_KBytes_in",!1,d),min:Ke(this._reports,P.VIDEO,"delta_KBytes_in",d),max:Ye(this._reports,P.VIDEO,"delta_KBytes_in",d),volatility:We(this._reports,P.VIDEO,"delta_KBytes_in",d),_unit:{avg:"KB",min:"KB",max:"KB",volatility:"percent"}},S=Ct(this._reports,P.VIDEO,"total_packets_lost_in",d),E=Ct(this._reports,P.VIDEO,"total_packets_in",d),C={lost:S,avg:Math.round((S/(S+E)*100||0)*100)/100,_unit:{avg:"percent",lost:"number"}};s[d].jitter=_,s[d].traffic=T,s[d].bitrate=g,s[d].loss=C}else{const _={avg:Xe(this._reports,P.VIDEO,"delta_jitter_ms_out",!1,d),min:Ke(this._reports,P.VIDEO,"delta_jitter_ms_out",d),max:Ye(this._reports,P.VIDEO,"delta_jitter_ms_out",d),volatility:We(this._reports,P.VIDEO,"delta_jitter_ms_out",d),_unit:{avg:"ms",min:"ms",max:"ms",volatility:"percent"}},g={avg:Xe(this._reports,P.VIDEO,"delta_kbs_out",!1,d),min:Ke(this._reports,P.VIDEO,"delta_kbs_out",d),max:Ye(this._reports,P.VIDEO,"delta_kbs_out",d),volatility:We(this._reports,P.VIDEO,"delta_kbs_out",d),_unit:{avg:"kbs",min:"kbs",max:"kbs",volatility:"percent"}},T={avg:Xe(this._reports,P.VIDEO,"delta_KBytes_out",!1,d),min:Ke(this._reports,P.VIDEO,"delta_KBytes_out",d),max:Ye(this._reports,P.VIDEO,"delta_KBytes_out",d),volatility:We(this._reports,P.VIDEO,"delta_KBytes_out",d),_unit:{avg:"KB",min:"KB",max:"KB",volatility:"percent"}},S={avg:wh(this._reports,P.VIDEO,d),min:Ke(this._reports,P.VIDEO,"delta_rtt_ms_out",d),max:Ye(this._reports,P.VIDEO,"delta_rtt_ms_out",d),volatility:We(this._reports,P.VIDEO,"delta_rtt_ms_out",d),_unit:{avg:"ms",min:"ms",max:"ms",volatility:"percent"}},E=Ct(this._reports,P.VIDEO,"total_packets_lost_out",d),C=Ct(this._reports,P.VIDEO,"total_packets_out",d),A={lost:E,avg:Math.round((E/(E+C)*100||0)*100)/100,_unit:{avg:"percent",lost:"number"}};s[d].jitter=_,s[d].rtt=S,s[d].traffic=T,s[d].bitrate=g,s[d].loss=A}})),{version:_v,configuration:{frequency:this._cfg.refreshEvery},started:this._start,ended:this._end,ua:{agent:navigator.userAgent,pname:this._cfg.pname,user_id:this._cfg.uid},call:{call_id:this._cfg.cid,events:this._events},details:{count:this._reports.length,reports:this._cfg.record?this._reports:[],reference:this._referenceReport||null},ssrc:s,data:{rtt:{avg:pv(this._reports,"data"),min:Ke(this._reports,"data","delta_rtt_connectivity_ms"),max:Ye(this._reports,"data","delta_rtt_connectivity_ms"),volatility:We(this._reports,"data","delta_rtt_connectivity_ms"),_unit:{avg:"ms",min:"ms",max:"ms",volatility:"percent"}},packetsLost:{audio:{in:{avg:Math.round((t/(t+n)*100||0)*100)/100}},video:{in:{avg:Math.round((a/(a+o)*100||0)*100)/100}},unit:{avg:"percent"}},bitrate:{in:{avg:Xe(this._reports,"data","delta_kbs_in"),min:Ke(this._reports,"data","delta_kbs_in"),max:Ye(this._reports,"data","delta_kbs_in"),volatility:We(this._reports,"data","delta_kbs_in")},out:{avg:Xe(this._reports,"data","delta_kbs_out"),min:Ke(this._reports,"data","delta_kbs_out"),max:Ye(this._reports,"data","delta_kbs_out"),volatility:We(this._reports,"data","delta_kbs_out")},unit:{avg:"kbs",min:"kbs",max:"kbs",volatility:"percent"}},traffic:{in:{avg:Xe(this._reports,"data","delta_KBytes_in"),min:Ke(this._reports,"data","delta_KBytes_in"),max:Ye(this._reports,"data","delta_KBytes_in"),volatility:We(this._reports,"data","delta_KBytes_in")},out:{avg:Xe(this._reports,"data","delta_KBytes_out"),min:Ke(this._reports,"data","delta_KBytes_out"),max:Ye(this._reports,"data","delta_KBytes_out"),volatility:We(this._reports,"data","delta_KBytes_out")},unit:{avg:"KBytes",min:"KBytes",max:"KBytes",volatility:"percent"}},network:{localConnection:mv(this._reports),remoteConnection:gv(this._reports)}}}}updateConfig(t){this._cfg=t}getLastReport(){return this._reports.slice().pop()||null}getBeforeLastReport(){const t=this._reports.slice();return t.pop(),t.pop()||null}getReportsNumber(){return this._reports.length}}const Ls="extractor ",Oh=(c,t,n,a)=>{let o=!1;const s=a[t].total_rtt_ms_out,r=a[t].total_rtt_measure_out,d=n?n[t].total_rtt_ms_out:0,h=n?n[t].total_rtt_measure_out:0,_={rtt:null,totalRTT:s,totalRTTMeasurements:r};if(c[V.TIMESTAMP]===a[t].timestamp_out||!Object.prototype.hasOwnProperty.call(c,V.ROUND_TRIP_TIME)||Object.prototype.hasOwnProperty.call(c,V.TOTAL_ROUND_TRIP_TIME_MEASUREMENTS)&&(o=!0,Number(c[V.TOTAL_ROUND_TRIP_TIME_MEASUREMENTS])===0||Number(c[V.TOTAL_ROUND_TRIP_TIME_MEASUREMENTS])-h===r))return _;const g=1e3*Number(c[V.ROUND_TRIP_TIME]);let T=s+g,S=r+1;return o&&(T=1e3*Number(c[V.TOTAL_ROUND_TRIP_TIME])-d,S=Number(c[V.TOTAL_ROUND_TRIP_TIME_MEASUREMENTS])-h),{rtt:g,totalRTT:T,totalRTTMeasurements:S}},vv=(c,t,n,a)=>{if(!Object.prototype.hasOwnProperty.call(c,V.CURRENT_ROUND_TRIP_TIME))return{rtt:null,totalRTT:a[t].total_rtt_connectivity_ms,totalRTTMeasurements:a[t].total_rtt_connectivity_measure};const o=1e3*Number(c[V.CURRENT_ROUND_TRIP_TIME]);let s=a[t].total_rtt_connectivity_ms+o,r=a[t].total_rtt_connectivity_measure+1;return Object.prototype.hasOwnProperty.call(c,V.TOTAL_ROUND_TRIP_TIME)&&(s=1e3*Number(c[V.TOTAL_ROUND_TRIP_TIME])-(n?n[t].total_rtt_connectivity_ms:0)),Object.prototype.hasOwnProperty.call(c,V.RESPONSES_RECEIVED)&&(r=Number(c[V.RESPONSES_RECEIVED])-(n?n[t].total_rtt_connectivity_measure:0)),{rtt:o,totalRTT:s,totalRTTMeasurements:r}},Aa=(c,t,n)=>c[V.TIMESTAMP]===n[t].timestamp_out||!Object.prototype.hasOwnProperty.call(c,V.JITTER)?null:1e3*(Number(c[V.JITTER])||0),Sv=(c,t)=>{if(!Object.prototype.hasOwnProperty.call(c,V.FRAMES_DECODED)||!Object.prototype.hasOwnProperty.call(c,V.TOTAL_DECODE_TIME))return{delta_ms_decode_frame:t[P.VIDEO].delta_ms_decode_frame_in,frames_decoded:t[P.VIDEO].total_frames_decoded_in,total_decode_time:t[P.VIDEO].total_time_decoded_in};const n=c[V.FRAMES_DECODED],a=c[V.TOTAL_DECODE_TIME],o=a-t[P.VIDEO].total_time_decoded_in,s=n-t[P.VIDEO].total_frames_decoded_in;return{delta_ms_decode_frame:s>0?o*1e3/s:0,frames_decoded:n,total_decode_time:a}},Ev=(c,t)=>{if(!Object.prototype.hasOwnProperty.call(c,V.FRAMES_ENCODED)||!Object.prototype.hasOwnProperty.call(c,V.TOTAL_ENCODE_TIME))return{delta_ms_encode_frame:t[P.VIDEO].delta_ms_encode_frame_out,frames_encoded:t[P.VIDEO].total_frames_encoded_out,total_encode_time:t[P.VIDEO].total_time_encoded_out};const n=c[V.FRAMES_ENCODED],a=c[V.TOTAL_ENCODE_TIME],o=a-t[P.VIDEO].total_time_encoded_out,s=n-t[P.VIDEO].total_frames_encoded_out;return{delta_ms_encode_frame:s>0&&o?o*1e3/s:0,frames_encoded:n,total_encode_time:a}},Dh=(c,t,n,a)=>{if(!Object.prototype.hasOwnProperty.call(c,V.PACKETS_SENT)||!Object.prototype.hasOwnProperty.call(c,V.BYTES_SENT))return{packetsSent:n[t].total_packets_out,packetsLost:n[t].total_packets_lost_out,bytesSent:n[t].total_KBytes_out};const o=Number(c[V.PACKETS_SENT])||0-(a?a[t].total_packets_out:0),s=o-n[t].total_packets_out,r=Number(c[V.BYTES_SENT])/1024-(a?a[t].total_KBytes_out:0),d=r-n[t].total_KBytes_out,h=c[V.TIMESTAMP]||Date.now(),_=a?a.timestamp:null;let g=n.timestamp;!g&&_&&(g=_);const T=g?h-g:0,S=T>0?d*.008*1024/T*1e3:0;return{packetsSent:o,deltaPacketsSent:s,KBytesSent:r,deltaKBytesSent:d,kbsSent:S}},Nh=(c,t,n,a)=>{let o=n[t].total_packets_lost_out,s=0,r=0;return Object.prototype.hasOwnProperty.call(c,V.PACKETS_LOST)&&(o=Number(c[V.PACKETS_LOST])||0-(a?a[t].total_packets_lost_out:0),s=o-n[t].total_packets_lost_out),Object.prototype.hasOwnProperty.call(c,V.FRACTION_LOST)&&(r=Number(100*c[V.FRACTION_LOST])),{packetsLost:o,deltaPacketsLost:s,fractionLost:r}},Uh=(c,t,n,a)=>{if(!Object.prototype.hasOwnProperty.call(c,V.PACKETS_RECEIVED)||!Object.prototype.hasOwnProperty.call(c,V.PACKETS_LOST)||!Object.prototype.hasOwnProperty.call(c,V.BYTES_RECEIVED))return{percent_packets_lost:n[t].percent_packets_lost_in,packetsReceived:n[t].total_packets_in,packetsLost:n[t].total_packets_lost_in,bytesReceived:n[t].total_KBytes_in};const o=Number(c[V.PACKETS_RECEIVED])||0-(a?a[t].total_packets_in:0),s=Number(c[V.PACKETS_LOST])||0-(a?a[t].total_packets_lost_in:0),r=s-n[t].total_packets_lost_in,d=o-n[t].total_packets_in,h=o!==n[t].total_packets_in?r*100/(r+d):0,_=Number(c[V.BYTES_RECEIVED])/1024-(a?a[t].total_KBytes_in:0),g=_-n[t].total_KBytes_in,T=c[V.TIMESTAMP]||Date.now(),S=a?a.timestamp:null;let E=n.timestamp;!E&&S&&(E=S);const C=E?T-E:0,A=C>0?g*.008*1024/C*1e3:0;return{percentPacketsLost:h,packetsReceived:o,deltaPacketsReceived:d,packetsLost:s,deltaPacketsLost:r,KBytesReceived:_,deltaKBytesReceived:g,kbsReceived:A}},yv=c=>c[V.CANDIDATE_TYPE]!=="relay"?"":c[V.RELAY_PROTOCOL]||"",Cv=c=>{if(!Object.prototype.hasOwnProperty.call(c,V.NETWORK_TYPE))return ii.WIFI;switch(c[V.NETWORK_TYPE]){case bu.ETHERNET:return ii.ETHERNET;case bu.CELLULAR_4G:return ii.CELLULAR_4G;case bu.WIFI:return ii.WIFI;default:return ii.CELLULAR}},xh=c=>!Object.prototype.hasOwnProperty.call(c,V.FRAME_HEIGHT)||!Object.prototype.hasOwnProperty.call(c,V.FRAME_WIDTH)?{width:null,height:null,framerate:null}:{width:c[V.FRAME_WIDTH]||null,height:c[V.FRAME_HEIGHT]||null,framerate:c[V.FRAMES_PER_SECOND]},Av=c=>{const t=Object.prototype.hasOwnProperty.call(c,V.QUALITY_LIMITATION_REASON)?c[V.QUALITY_LIMITATION_REASON]:null,n=Object.prototype.hasOwnProperty.call(c,V.QUALITY_LIMITATION_RESOLUTION_CHANGES)?c[V.QUALITY_LIMITATION_RESOLUTION_CHANGES]:null,a=Object.prototype.hasOwnProperty.call(c,V.QUALITY_LIMITATION_DURATIONS)?c[V.QUALITY_LIMITATION_DURATIONS]:null;return a&&Object.keys(a).forEach(o=>{a[o]>1e3&&(a[o]=Number(a[o]/1e3))}),{reason:t,durations:a,resolutionChanges:n}},Rv=(c,t,n)=>{if(!Object.prototype.hasOwnProperty.call(c,V.PLI)||!Object.prototype.hasOwnProperty.call(c,V.NACK))return{pliCount:t.total_pli_sent_in,nackCount:t.total_nack_sent_in,deltaPliCount:0,deltaNackCount:0};const a=(c[V.PLI]||0)-(n?n[P.VIDEO].total_pli_sent_in:0),o=(c[V.NACK]||0)-(n?n[P.VIDEO].total_nack_sent_in:0);return{pliCount:a,nackCount:o,deltaPliCount:a-t[P.VIDEO].total_pli_sent_in,deltaNackCount:o-t[P.VIDEO].total_nack_sent_in}},Iv=(c,t,n)=>{if(!Object.prototype.hasOwnProperty.call(c,V.PLI)||!Object.prototype.hasOwnProperty.call(c,V.NACK))return{pliCount:t.total_pli_received_out,nackCount:t.total_nack_received_out,deltaPliCount:0,deltaNackCount:0};const a=(c[V.PLI]||0)-(n?n[P.VIDEO].total_pli_received_out:0),o=(c[V.NACK]||0)-(n?n[P.VIDEO].total_nack_received_out:0);return{pliCount:a,nackCount:o,deltaPliCount:a-t[P.VIDEO].total_pli_received_out,deltaNackCount:o-t[P.VIDEO].total_nack_received_out}},bv=c=>({channels:c[V.CHANNELS]||null,clock_rate:c[V.CLOCK_RATE]||null,mime_type:c[V.MIME_TYPE]||null,sdp_fmtp_line:c[V.SDP_FMTP_LINE]||null}),wv=c=>({clock_rate:c[V.CLOCK_RATE]||null,mime_type:c[V.MIME_TYPE]||null}),Ov=(c,t,n)=>{const a=(c[V.BYTES_RECEIVED]||0)/1024-(n?n.data.total_KBytes_in:0),o=(c[V.BYTES_SENT]||0)/1024-(n?n.data.total_KBytes_out:0),s=c[V.TIMESTAMP]||Date.now(),r=a-t.data.total_KBytes_in,d=o-t.data.total_KBytes_out,h=n?n.timestamp:null;let _=t.timestamp;!_&&h&&(_=h);const g=_?s-_:0,T=g>0?r*.008*1024/g*1e3:0,S=g>0?d*.008*1024/g*1e3:0;return{total_KBytes_received:a,total_KBytes_sent:o,delta_KBytes_received:r,delta_KBytes_sent:d,kbs_speed_received:T,kbs_speed_sent:S}},Dv=c=>{const t=c[V.AVAILABLE_INCOMING_BITRATE]/1024||0,n=c[V.AVAILABLE_OUTGOING_BITRATE]/1024||0;return{kbs_incoming_bandwidth:t,kbs_outgoing_bandwidth:n}},Nv=(c,t,n,a)=>{if(!c)return[];switch(c[V.TYPE]){case Zt.CANDIDATE_PAIR:let o=!1;if(c[V.NOMINATED]&&c[V.STATE]===P.SUCCEEDED&&(o=!0,xe(Ls,`analyze() - got stats ${c[V.TYPE]} for ${n}`,c),V.SELECTED in c&&!c[V.SELECTED]&&(o=!1)),o){const r=c[V.LOCAL_CANDIDATE_ID],d=c[V.REMOTE_CANDIDATE_ID],h=Ov(c,t,a),_=Dv(c),g=vv(c,"data",a,t);return[{type:ne.NETWORK,value:{local_candidate_id:r}},{type:ne.NETWORK,value:{remote_candidate_id:d}},{type:ne.DATA,value:{total_KBytes_in:h.total_KBytes_received}},{type:ne.DATA,value:{total_KBytes_out:h.total_KBytes_sent}},{type:ne.DATA,value:{delta_KBytes_in:h.delta_KBytes_received}},{type:ne.DATA,value:{delta_KBytes_out:h.delta_KBytes_sent}},{type:ne.DATA,value:{delta_kbs_in:h.kbs_speed_received}},{type:ne.DATA,value:{delta_kbs_out:h.kbs_speed_sent}},{type:ne.DATA,value:{delta_kbs_bandwidth_in:_.kbs_incoming_bandwidth}},{type:ne.DATA,value:{delta_kbs_bandwidth_out:_.kbs_outgoing_bandwidth}},{type:ne.DATA,value:{delta_rtt_connectivity_ms:g.rtt}},{type:ne.DATA,value:{total_rtt_connectivity_ms:g.totalRTT}},{type:ne.DATA,value:{total_rtt_connectivity_measure:g.totalRTTMeasurements}}]}break;case Zt.LOCAL_CANDIDATE:if(c[V.ID]===t.network.local_candidate_id)return[{type:ne.NETWORK,value:{infrastructure:Cv(c)}},{type:ne.NETWORK,value:{local_candidate_type:c[V.CANDIDATE_TYPE]||""}},{type:ne.NETWORK,value:{local_candidate_protocol:c[V.PROTOCOL]||""}},{type:ne.NETWORK,value:{local_candidate_relay_protocol:yv(c)}}];break;case Zt.REMOTE_CANDIDATE:if(c[V.ID]===t.network.remote_candidate_id)return[{type:ne.NETWORK,value:{remote_candidate_type:c[V.CANDIDATE_TYPE]||""}},{type:ne.NETWORK,value:{remote_candidate_protocol:c[V.PROTOCOL]||""}}];break;case Zt.INBOUND_RTP:{xe(Ls,`analyze() - got stats ${c[V.TYPE]} for ${n}`,c);const r=c[V.SSRC],d=ht(r,t,$e.INBOUND);d&&(d.timestamp=t.timestamp);const h=ht(r,a,$e.INBOUND);if(h&&(h.timestamp=a.timestamp),c[V.MEDIA_TYPE]===P.AUDIO){const _=Uh(c,P.AUDIO,d,h),g=Aa(c,P.AUDIO,d),T=c[V.CODEC_ID]||"";return[{ssrc:r,type:ne.AUDIO,value:{codec_id_in:T}},{ssrc:r,type:ne.AUDIO,value:{total_packets_in:_.packetsReceived}},{ssrc:r,type:ne.AUDIO,value:{delta_packets_in:_.deltaPacketsReceived}},{ssrc:r,type:ne.AUDIO,value:{total_packets_lost_in:_.packetsLost}},{ssrc:r,type:ne.AUDIO,value:{delta_packets_lost_in:_.deltaPacketsLost}},{ssrc:r,type:ne.AUDIO,value:{percent_packets_lost_in:_.percentPacketsLost}},{ssrc:r,type:ne.AUDIO,value:{total_KBytes_in:_.KBytesReceived}},{ssrc:r,type:ne.AUDIO,value:{delta_KBytes_in:_.deltaKBytesReceived}},{ssrc:r,type:ne.AUDIO,value:{delta_kbs_in:_.kbsReceived}},{ssrc:r,type:ne.AUDIO,value:{delta_jitter_ms_in:g}}]}if(c[V.MEDIA_TYPE]===P.VIDEO){const _=Sv(c,d),g=Uh(c,P.VIDEO,d,h),T=Aa(c,P.VIDEO,d),S=c[V.DECODER_IMPLEMENTATION]||null,E=c[V.CODEC_ID]||null,C=xh(c),A=Rv(c,d,h);return[{ssrc:r,type:ne.VIDEO,value:{codec_id_in:E}},{ssrc:r,type:ne.VIDEO,value:{total_packets_in:g.packetsReceived}},{ssrc:r,type:ne.VIDEO,value:{delta_packets_in:g.deltaPacketsReceived}},{ssrc:r,type:ne.VIDEO,value:{total_packets_lost_in:g.packetsLost}},{ssrc:r,type:ne.VIDEO,value:{delta_packets_lost_in:g.deltaPacketsLost}},{ssrc:r,type:ne.VIDEO,value:{percent_packets_lost_in:g.percentPacketsLost}},{ssrc:r,type:ne.VIDEO,value:{total_KBytes_in:g.KBytesReceived}},{ssrc:r,type:ne.VIDEO,value:{delta_KBytes_in:g.deltaKBytesReceived}},{ssrc:r,type:ne.VIDEO,value:{delta_kbs_in:g.kbsReceived}},{ssrc:r,type:ne.VIDEO,value:{delta_jitter_ms_in:T}},{ssrc:r,type:ne.VIDEO,value:{decoder_in:S}},{ssrc:r,type:ne.VIDEO,value:{delta_ms_decode_frame_in:_.delta_ms_decode_frame}},{ssrc:r,type:ne.VIDEO,value:{total_frames_decoded_in:_.frames_decoded}},{ssrc:r,type:ne.VIDEO,value:{total_time_decoded_in:_.total_decode_time}},{ssrc:r,type:ne.VIDEO,value:{total_nack_sent_in:A.nackCount}},{ssrc:r,type:ne.VIDEO,value:{delta_nack_sent_in:A.deltaNackCount}},{ssrc:r,type:ne.VIDEO,value:{total_pli_sent_in:A.pliCount}},{ssrc:r,type:ne.VIDEO,value:{delta_pli_sent_in:A.deltaPliCount}},{ssrc:r,type:ne.VIDEO,value:{size_in:C}}]}break}case Zt.OUTBOUND_RTP:{xe(Ls,`analyze() - got stats ${c[V.TYPE]} for ${n}`,c);const r=c[V.SSRC],d=ht(r,t,$e.OUTBOUND);d&&(d.timestamp=t.timestamp);const h=ht(r,a,$e.OUTBOUND);if(h&&(h.timestamp=a.timestamp),c[V.MEDIA_TYPE]===P.AUDIO){const _=c[V.CODEC_ID]||null,g=Dh(c,P.AUDIO,d,h);return[{ssrc:r,type:ne.AUDIO,value:{codec_id_out:_}},{ssrc:r,type:ne.AUDIO,value:{total_packets_out:g.packetsSent}},{ssrc:r,type:ne.AUDIO,value:{delta_packets_out:g.deltaPacketsSent}},{ssrc:r,type:ne.AUDIO,value:{total_KBytes_out:g.KBytesSent}},{ssrc:r,type:ne.AUDIO,value:{delta_KBytes_out:g.deltaKBytesSent}},{ssrc:r,type:ne.AUDIO,value:{delta_kbs_out:g.kbsSent}}]}if(c[V.MEDIA_TYPE]===P.VIDEO){const _=c[V.ENCODER_IMPLEMENTATION]||null,g=c[V.CODEC_ID]||null,T=Ev(c,d),S=xh(c),E=Av(c),C=Iv(c,d,h),A=Dh(c,P.VIDEO,d,h);return[{ssrc:r,type:ne.VIDEO,value:{codec_id_out:g}},{ssrc:r,type:ne.VIDEO,value:{total_packets_out:A.packetsSent}},{ssrc:r,type:ne.VIDEO,value:{delta_packets_out:A.deltaPacketsSent}},{ssrc:r,type:ne.VIDEO,value:{total_KBytes_out:A.KBytesSent}},{ssrc:r,type:ne.VIDEO,value:{delta_KBytes_out:A.deltaKBytesSent}},{ssrc:r,type:ne.VIDEO,value:{delta_kbs_out:A.kbsSent}},{ssrc:r,type:ne.VIDEO,value:{encoder_out:_}},{ssrc:r,type:ne.VIDEO,value:{delta_ms_encode_frame_out:T.delta_ms_encode_frame}},{ssrc:r,type:ne.VIDEO,value:{total_frames_encoded_out:T.frames_encoded}},{ssrc:r,type:ne.VIDEO,value:{total_time_encoded_out:T.total_encode_time}},{ssrc:r,type:ne.VIDEO,value:{total_nack_received_out:C.nackCount}},{ssrc:r,type:ne.VIDEO,value:{delta_nack_received_out:C.deltaNackCount}},{ssrc:r,type:ne.VIDEO,value:{total_pli_received_out:C.pliCount}},{ssrc:r,type:ne.VIDEO,value:{delta_pli_received_out:C.deltaPliCount}},{ssrc:r,type:ne.VIDEO,value:{size_out:S}},{ssrc:r,type:ne.VIDEO,value:{limitation_out:E}}]}break}case Zt.MEDIA_SOURCE:{xe(Ls,`analyze() - got stats ${c[V.TYPE]} for ${n}`,c);break}case Zt.TRACK:{xe(Ls,`analyze() - got stats ${c[V.TYPE]} for ${n}`,c);break}case Zt.CODEC:const s=[];return Object.keys(t[P.AUDIO]).forEach(r=>{const d=t[P.AUDIO][r];if(d.codec_id_in===c[V.ID]||d.codec_id_out===c[V.ID]){xe(Ls,`analyze() - got stats ${c[V.TYPE]} for ${n}`,c);const h=bv(c);c[V.ID]===d.codec_id_in?s.push({ssrc:d.ssrc,type:ne.AUDIO,value:{codec_in:h}}):s.push({ssrc:d.ssrc,type:ne.AUDIO,value:{codec_out:h}})}}),Object.keys(t[P.VIDEO]).forEach(r=>{const d=t[P.VIDEO][r];if(d.codec_id_in===c[V.ID]||d.codec_id_out===c[V.ID]){xe(Ls,`analyze() - got stats ${c[V.TYPE]} for ${n}`,c);const h=wv(c);c[V.ID]===d.codec_id_in?s.push({ssrc:d.ssrc,type:ne.VIDEO,value:{codec_in:h}}):s.push({ssrc:d.ssrc,type:ne.VIDEO,value:{codec_out:h}})}}),s;case Zt.REMOTE_INBOUND_RTP:{xe(Ls,`analyze() - got stats ${c[V.TYPE]} for ${n}`,c);const r=c[V.SSRC],d=ht(r,t,$e.OUTBOUND),h=ht(r,a,$e.OUTBOUND);if(c[V.KIND]===P.AUDIO){const _=Oh(c,P.AUDIO,h,d),g=Aa(c,P.AUDIO,d),T=Nh(c,P.AUDIO,d,h);return[{ssrc:r,type:ne.AUDIO,value:{delta_rtt_ms_out:_.rtt}},{ssrc:r,type:ne.AUDIO,value:{total_rtt_ms_out:_.totalRTT}},{ssrc:r,type:ne.AUDIO,value:{total_rtt_measure_out:_.totalRTTMeasurements}},{ssrc:r,type:ne.AUDIO,value:{delta_jitter_ms_out:g}},{ssrc:r,type:ne.AUDIO,value:{timestamp_out:c[V.TIMESTAMP]}},{ssrc:r,type:ne.AUDIO,value:{total_packets_lost_out:T.packetsLost}},{ssrc:r,type:ne.AUDIO,value:{delta_packets_lost_out:T.deltaPacketsLost}},{ssrc:r,type:ne.AUDIO,value:{percent_packets_lost_out:T.fractionLost}}]}if(c[V.KIND]===P.VIDEO){const _=Oh(c,P.VIDEO,h,d),g=Aa(c,P.VIDEO,d),T=Nh(c,P.VIDEO,d,h);return[{ssrc:r,type:ne.VIDEO,value:{delta_rtt_ms_out:_.rtt}},{ssrc:r,type:ne.VIDEO,value:{total_rtt_ms_out:_.totalRTT}},{ssrc:r,type:ne.VIDEO,value:{total_rtt_measure_out:_.totalRTTMeasurements}},{ssrc:r,type:ne.VIDEO,value:{delta_jitter_ms_out:g}},{ssrc:r,type:ne.VIDEO,value:{timestamp_out:c[V.TIMESTAMP]}},{ssrc:r,type:ne.VIDEO,value:{total_packets_lost_out:T.packetsLost}},{ssrc:r,type:ne.VIDEO,value:{delta_packets_lost_out:T.deltaPacketsLost}},{ssrc:r,type:ne.VIDEO,value:{percent_packets_lost_out:T.fractionLost}}]}break}}return[]},Ra=c=>c<0?1:c>100?4.5:1+.035*c+7/1e6*c*(c-60)*(100-c),Uv=(c,t=P.AUDIO,n,a,o)=>{const s=ht(o,c,$e.INBOUND),r=ht(o,n,$e.INBOUND),d=ht(o,a,$e.INBOUND),h=[],_=[],g=s[t].percent_packets_lost_in,T=s[t].delta_jitter_ms_in,S=r&&r[t].delta_jitter_ms_in||null,E=d&&d[t].delta_jitter_ms_in||null,C=c.data.delta_rtt_connectivity_ms,A=n&&n.data.delta_rtt_connectivity_ms||null,R=a&&a.data.delta_rtt_connectivity_ms||null;C&&h.push(C),A&&h.push(A),R&&h.push(R),T&&_.push(T),n&&S&&_.push(S),a&&E&&_.push(E);const k=h.length>0?Ms(h):100,M=_.length>0?Ms(_):10,ie=93.2-g,N=.18*ie*ie-27.9*ie+1126.62,j=(k+M)/2,Ee=j-177.3<0?0:1,ve=.024*j+.11*(j-177.3)*Ee,L=N-ve;return Ra(L)},xv=(c,t=P.AUDIO,n,a,o)=>{const s=ht(o,c,$e.OUTBOUND),r=ht(o,n,$e.OUTBOUND),d=ht(o,a,$e.OUTBOUND),h=[],_=[],g=s[t].percent_packets_lost_out,T=s[t].delta_rtt_ms_out,S=r&&r[t].delta_rtt_ms_out||null,E=d&&d[t].delta_rtt_ms_out||null,C=s[t].delta_jitter_ms_out,A=r&&r[t].delta_jitter_ms_out||null,R=d&&d[t].delta_jitter_ms_out||null,k=c.data.delta_rtt_connectivity_ms,M=n&&n.data.delta_rtt_connectivity_ms||null,ie=a&&a.data.delta_rtt_connectivity_ms||null;T?h.push(T):k&&h.push(k),S?h.push(S):M&&h.push(M),E?h.push(E):ie&&h.push(ie),C&&_.push(C),n&&A&&_.push(A),a&&R&&_.push(R);const N=h.length>0?Ms(h):100,j=_.length>0?Ms(_):10,Ee=93.2-g,ve=.18*Ee*Ee-27.9*Ee+1126.62,L=(N+j)/2,D=L-177.3<0?0:1,B=.024*L+.11*(L-177.3)*D,q=ve-B;return Ra(q)},Pv=(c,t=P.AUDIO,n,a,o)=>{const s=ht(o,c,$e.INBOUND),r=ht(o,n,$e.INBOUND),d=ht(o,a,$e.INBOUND),h=[],_=[],g=s[t].percent_packets_lost_in/100,T=s[t].delta_jitter_ms_in,S=r&&r[t].delta_jitter_ms_in||null,E=d&&d[t].delta_jitter_ms_in||null,C=c.data.delta_rtt_connectivity_ms,A=n&&n.data.delta_rtt_connectivity_ms||null,R=a&&a.data.delta_rtt_connectivity_ms||null;C&&h.push(C),A&&h.push(A),R&&h.push(R),T&&_.push(T),r&&S&&_.push(S),d&&E&&_.push(E);const k=h.length>0?Ms(h):100,M=_.length>0?Ms(_):10,ie=0,N=19.8,j=29.7,Ee=30,ve=(k+M)/2+Ee,L=ve-177.3<0?0:1,D=.024*ve+.11*(ve-177.3)*L,q=93.2-(ie+N*Math.log(1+j*g)+D);return Ra(q)},kv=(c,t=P.AUDIO,n,a,o)=>{const s=ht(o,c,$e.OUTBOUND),r=ht(o,n,$e.OUTBOUND),d=ht(o,a,$e.OUTBOUND),h=[],_=[],g=s[t].percent_packets_lost_out/100,T=s[t].delta_rtt_ms_out,S=r&&r[t].delta_rtt_ms_out||null,E=d&&d[t].delta_rtt_ms_out||null,C=s[t].delta_jitter_ms_out,A=r&&r[t].delta_jitter_ms_out||null,R=d&&d[t].delta_jitter_ms_out||null,k=c.data.delta_rtt_connectivity_ms,M=n&&n.data.delta_rtt_connectivity_ms||null,ie=a&&a.data.delta_rtt_connectivity_ms||null;T?h.push(T):k&&h.push(k),S?h.push(S):M&&h.push(M),E?h.push(E):ie&&h.push(ie),C&&_.push(C),r&&A&&_.push(A),d&&R&&_.push(R);const N=h.length>0?Ms(h):100,j=_.length>0?Ms(_):10,Ee=0,ve=19.8,L=29.7,D=30,B=(N+j)/2+D,q=B-177.3<0?0:1,J=.024*B+.11*(B-177.3)*q,Z=93.2-(Ee+ve*Math.log(1+L*g)+J);return Ra(Z)};class Mv{constructor(t,n){this._callbacks={onreport:null,onticket:null},this._id=hv(),this._moduleName=this._id,this._probeId=n,this._config=t,this._exporter=new Tv(t),this._state=ys.IDLE,this.registerToPCEvents(),an(this._moduleName,`new collector created for probe ${this._probeId}`)}analyze(t,n,a,o){const s=(h,_)=>h===P.AUDIO?_===Zt.INBOUND_RTP?{...Ch}:{...Ah}:_===Zt.INBOUND_RTP?{...Rh}:{...Ih},r=av(n);r.pname=this._config.pname,r.call_id=this._config.cid,r.user_id=this._config.uid,r.count=n?n.count+1:1;let d=null;return t.forEach(h=>{!d&&h.timestamp&&(d=h.timestamp),Nv(h,r,r.pname,o).forEach(g=>{if(g.value&&g.type)if(g.ssrc){let T=r[g.type][g.ssrc];T||(T=s(g.type,h.type),T.ssrc=g.ssrc,r[g.type][g.ssrc]=T),Object.keys(g.value).forEach(S=>{T[S]=g.value[S]})}else Object.keys(g.value).forEach(T=>{r[g.type][T]=g.value[T]})})}),r.timestamp=d,Object.keys(r[P.AUDIO]).forEach(h=>{const _=r[P.AUDIO][h];_.direction===$e.INBOUND?(_.mos_emodel_in=Uv(r,P.AUDIO,n,a,_.ssrc),_.mos_in=Pv(r,P.AUDIO,n,a,_.ssrc)):(_.mos_emodel_out=xv(r,P.AUDIO,n,a,_.ssrc),_.mos_out=kv(r,P.AUDIO,n,a,_.ssrc))}),r}async takeReferenceStats(){return new Promise((t,n)=>{const a=Date.now();setTimeout(async()=>{try{const o=Date.now()-a,s=Date.now(),r=await this._config.pc.getStats(),d=this.analyze(r,null,null,null),h=Date.now();d.experimental.time_to_measure_ms=h-s,d.experimental.time_to_wait_ms=o,this._exporter.saveReferenceReport(d),xe(this._moduleName,`got reference report for probe ${this._probeId}`),t()}catch(o){n(o)}},this._config.startAfter)})}async collectStats(){try{if(this._state!==ys.RUNNING||!this._config.pc)return xe(this._moduleName,`report discarded (too late) for probe ${this._probeId}`),null;const t=Date.now(),n=await this._config.pc.getStats(),a=this.analyze(n,this._exporter.getLastReport(),this._exporter.getBeforeLastReport(),this._exporter.getReferenceReport()),o=Date.now();return a.experimental.time_to_measure_ms=o-t,this._exporter.addReport(a),xe(this._moduleName,`got report for probe ${this._probeId}#${this._exporter.getReportsNumber()+1}`),this.fireOnReport(a),a}catch(t){return Vn(this._moduleName,`got error ${t}`),null}}async start(){xe(this._moduleName,"starting"),this.state=ys.RUNNING,this._startedTime=this._exporter.start(),xe(this._moduleName,"started")}async mute(){this.state=ys.MUTED,xe(this._moduleName,"muted")}async unmute(){this.state=ys.RUNNING,xe(this._moduleName,"unmuted")}async stop(t){if(xe(this._moduleName,`stopping${t?" by watchdog":""}...`),this._stoppedTime=this._exporter.stop(),this.state=ys.IDLE,this._config.ticket){const{ticket:n}=this._exporter;this.fireOnTicket(n)}this._exporter.reset(),xe(this._moduleName,"stopped")}registerCallback(t,n,a){t in this._callbacks?(this._callbacks[t]={callback:n,context:a},xe(this._moduleName,`registered callback '${t}'`)):Vn(this._moduleName,`can't register callback for '${t}' - not found`)}unregisterCallback(t){t in this._callbacks?(this._callbacks[t]=null,delete this._callbacks[t],xe(this._moduleName,`unregistered callback '${t}'`)):Vn(this._moduleName,`can't unregister callback for '${t}' - not found`)}fireOnReport(t){this._callbacks.onreport&&Ou(this._callbacks.onreport.callback,this._callbacks.onreport.context,t)}fireOnTicket(t){this._callbacks.onticket&&Ou(this._callbacks.onticket.callback,this._callbacks.onticket.context,t)}updateConfig(t){this._config=t,this._exporter.updateConfig(t)}get state(){return this._state}set state(t){this._state=t,xe(this._moduleName,`state changed to ${t}`)}addCustomEvent(t,n,a,o){this._exporter.addCustomEvent({at:typeof t=="object"?t.toJSON():t,category:n,name:a,description:o})}async registerToPCEvents(){const{pc:t}=this._config;if(navigator.mediaDevices.ondevicechange=async()=>{try{const n=await navigator.mediaDevices.enumerateDevices();this.addCustomEvent(new Date().toJSON(),"device",`${n.length} devices found`,"Media Devices state")}catch{Vn(this._moduleName,"can't get devices")}},t){t.oniceconnectionstatechange=()=>{const a=t.iceConnectionState;a===ri.CONNECTED||a===ri.COMPLETED?this.addCustomEvent(new Date().toJSON(),"call",a,"ICE connection state"):a===ri.DISCONNECTED||a===ri.FAILED?this.addCustomEvent(new Date().toJSON(),"call",a,"ICE connection state"):a===ri.CLOSED&&this.addCustomEvent(new Date().toJSON(),"call","ended","ICE connection state")},t.onicegatheringstatechange=()=>{const a=t.iceGatheringState;this.addCustomEvent(new Date().toJSON(),"call",a,"ICE gathering state")},t.ontrack=a=>{this.addCustomEvent(new Date().toJSON(),"call",`${a.track.kind}track`,"MediaStreamTrack received")},t.onnegotiationneeded=()=>{this.addCustomEvent(new Date().toJSON(),"call","negotiation","Media changed")};const n=t.getReceivers();if(n&&n.length>0){const a=n[0],{transport:o}=a;if(o){const{iceTransport:s}=o;s&&(s.onselectedcandidatepairchange=()=>{this.addCustomEvent(new Date().toJSON(),"call","transport","Candidates Pair changed")})}}}}}class Lv{constructor(t){this._id=t.pname&&t.pname.substr(0,12).padEnd(12," ")||fv(),this._moduleName=this._id,an(this._moduleName,"probe created"),this._config=t,this._collector=new Mv(this._config,this._id)}set onreport(t){t?this._collector.registerCallback("onreport",t):this._collector.unregisterCallback("onreport")}set onticket(t){t?this._collector.registerCallback("onticket",t):this._collector.unregisterCallback("onticket")}get id(){return this._id}get pname(){return this._config.pname}get cid(){return this._config.cid}get uid(){return this._config.uid}get state(){return this._collector.state}set state(t){this._collector.state=t}addCustomEvent(t,n,a,o=new Date().toJSON()){this._collector.addCustomEvent(o,n,t,a)}get isRunning(){return this._collector.state===ys.RUNNING}get isIdle(){return this._collector.state===ys.IDLE}updateUserId(t){this._config.uid=t,this._collector.updateConfig(this._config)}updateCallId(t){this._config.cid=t,this._collector.updateConfig(this._config)}start(){if(!this.isIdle){Ca(this._moduleName,"probe is already running");return}this._collector.start()}stop(t=!1){this.isRunning&&this._collector.stop(t)}async takeReferenceStats(){return this._collector.takeReferenceStats()}async collectStats(){return this._collector.collectStats()}}const bt="engine ";class $v{constructor(t){this._config=t,this._probes=[],this._startedTime=null,this._callbacks={onresult:null},an(bt,`configured for probing every ${this._config.refreshEvery}ms`),an(bt,`configured for starting after ${this._config.startAfter}ms`),an(bt,`${!this._config.stopAfter||this._config.stopAfter!==-1?`configured for stopped after ${this._config.stopAfter}ms`:"configured for never stopped"}`),xe(bt,"engine initialized")}get probes(){return this._probes}get isRunning(){return this._probes.some(t=>t.isRunning)}get isIdle(){return this._probes.every(t=>t.isIdle)}addNewProbe(t,n){if(!t)throw new Error("undefined peer connection");const a=uv(t,n,this._config),o=new Lv(a);return this._probes.push(o),xe(bt,`${this._probes.length} probes registered`),o}removeExistingProbe(t){if(!t)throw new Error("undefined probe");t.state===ys.RUNNING&&t.stop(),this._probes=this._probes.filter(n=>t.id!==n.id)}async start(){const t=()=>{this._probes.forEach(s=>s.start())},n=async()=>Promise.all(this._probes.map(s=>s.takeReferenceStats())),a=()=>this.isIdle?!1:!this._config.stopAfter||this._config.stopAfter<0?!0:Date.now()<this._startedTime+this._config.stopAfter,o=async()=>{const s=lv(),r=this._probes.filter(d=>d.isRunning);for(const d of r){const h=await d.collectStats();h&&s.probes.push(h),xe(bt,`got probe ${d.id}`),await bh(0)}return s.delta_time_to_measure_probes_ms=on(s.probes,"experimental","time_to_measure_ms"),s.delta_KBytes_in=on(s.probes,"data","delta_KBytes_in"),s.delta_KBytes_out=on(s.probes,"data","delta_KBytes_out"),s.delta_kbs_in=on(s.probes,"data","delta_kbs_in"),s.delta_kbs_out=on(s.probes,"data","delta_kbs_out"),s.total_time_decoded_in=on(s.probes,"video","total_time_decoded_in"),s.total_time_encoded_out=on(s.probes,"video","total_time_encoded_out"),s};for(xe(bt,"starting to collect"),t(),xe(bt,"generating reference reports..."),await n(),xe(bt,"reference reports generated"),this._startedTime=Date.now();a();)if(xe(bt,`wait ${this._config.refreshEvery}ms before collecting`),await bh(this._config.refreshEvery),a()){xe(bt,"collecting...");const s=Date.now(),r=await o(),d=Date.now();r.delta_time_consumed_to_measure_ms=d-s,this.fireOnReports(r),xe(bt,"collected")}xe(bt,"reaching end of the collecting period..."),this.isRunning&&setTimeout(()=>{this.stop()},0)}stop(t){const n=a=>{this._probes.forEach(o=>{o.stop(a)})};an(bt,"stop collecting"),n(t)}registerCallback(t,n,a){t in this._callbacks?(this._callbacks[t]={callback:n,context:a},xe(bt,`registered callback '${t}'`)):Vn(bt,`can't register callback for '${t}' - not found`)}unregisterCallback(t){t in this._callbacks?(this._callbacks[t]=null,delete this._callbacks[t],xe(this._moduleName,`unregistered callback '${t}'`)):Vn(this._moduleName,`can't unregister callback for '${t}' - not found`)}fireOnReports(t){this._callbacks.onresult&&t.probes.length>0&&Ou(this._callbacks.onresult.callback,this._callbacks.onresult.context,t)}}const Hv="interface ";class Fv{constructor(t){this._config=cv(t),an(Hv,`welcome to ${this._config.name} version ${this._config.version}`),QT(this._config.verbose||!1),this._engine=new $v(this._config)}setupLogLevel(t){ZT(t)}get version(){return this._config.version}get name(){return this._config.name}get probes(){return this._engine.probes}createProbe(t,n){return this._engine.addNewProbe(t,n)}startAllProbes(){this._engine.start()}stopAllProbes(){this._engine.stop()}get running(){return this._engine.isRunning}get idle(){return this._engine.isIdle}removeProbe(t){this._engine.removeExistingProbe(t)}set onresult(t){t?this._engine.registerCallback("onresult",t):this._engine.unregisterCallback("onresult")}}function jv(c,t){return Object.keys(c).filter(n=>t.includes(n)).reduce((n,a)=>{const o=a;return{...n,[o]:c[o]}},{})}const Vv=["mos_in","codec_in","delta_KBytes_in","delta_kbs_in","delta_jitter_ms_in","delta_packets_lost_in"],qv={positiveSpeechThreshold:.6,negativeSpeechThreshold:.3,preSpeechPadMs:150,redemptionMs:1500,minSpeechMs:50};class Bv{constructor(t){this.intervals={},this.analysers={},this.emitInterval=t.emitInterval||200,this.onChangeFunction=t.onChangeFunction}async start(t,n,a){n&&n.getTracks().length&&await this.beginCalculation(t,n,a)}stop(t){this.clearVolumeInterval(t),this.analysers[t]&&typeof this.analysers[t].disconnect=="function"&&(this.analysers[t].disconnect(),delete this.analysers[t])}clearVolumeInterval(t){this.intervals[t]&&(clearInterval(this.intervals[t]),delete this.intervals[t])}clearAllIntervals(){Object.keys(this.intervals).forEach(t=>{this.stop(t)}),this.intervals={},this.analysers={}}async beginCalculation(t,n,a){this.clearVolumeInterval(a);const o=t.createAnalyser(),s=t.createMediaStreamSource(n);o.smoothingTimeConstant=.8,o.fftSize=1024,s.connect(o),this.analysers[a]=o,this.intervals[a]=setInterval(()=>{const r=new Uint8Array(o.frequencyBinCount);o.getByteFrequencyData(r);let d=0;const h=r.length;for(let g=0;g<h;g++)d+=r[g];const _=d/h;this.onChangeFunction(a,_)},this.emitInterval)}}class Gv{constructor(){this.resumePromise=null,this.context=new AudioContext}async getContext(){return this.context.state==="suspended"&&(this.resumePromise||(this.resumePromise=this.context.resume().then(()=>{this.resumePromise=null}).catch(t=>{throw this.resumePromise=null,t})),await this.resumePromise),this.context}}class Wv{constructor(t){this.id=t}new(t){console.log(t)}}const Ia={SELECTED_INPUT_DEVICE:"OpensipsJSInputDevice",SELECTED_OUTPUT_DEVICE:"OpensipsJSOutputDevice"},Kv=0;class Yv{constructor(t){this.isAutoAnswer=!1,this.muteWhenJoinEnabled=!1,this.isDNDEnabled=!1,this.isCallWaitingEnabled=!0,this.muted=!1,this.microphoneInputLevelValue=1,this.speakerVolumeValue=1,this.activeRooms={},this.activeCalls={},this.extendedCalls={},this.conferenceNodes={},this.availableMediaDevices=[],this.selectedMediaDevices={input:"default",output:"default"},this.callStatus={},this.callTime={},this.callMetrics={},this.timeIntervals={},this.metricConfig={refreshEvery:1e3},this.activeStreamValue=null,this.initialStreamValue=null,this.vadSessions={},this.vadSessionsState={},this.vadIntervals={},this.vadMrsIntervals={},this.managedAudioContext=new Gv,this.context=t,this.context.on(this.context.newRTCSessionEventName,this.newRTCSessionCallback.bind(this)),this.VUMeter=new Bv({onChangeFunction:this.emitVolumeChange.bind(this)}),this.processVADConfiguration(),this.initializeMediaDevices()}processVADConfiguration(){var n;const t=((n=this.context.options.configuration)==null?void 0:n.noiseReductionOptions)||{};this.noiseReduction={mode:t.mode||"disabled",checkEveryMs:t.checkEveryMs||500,noiseCheckInterval:t.noiseCheckInterval||2e3,noiseThreshold:t.noiseThreshold||.004,vadConfig:t.vadConfig||{}}}get sipOptions(){return{...this.context.options.sipOptions,mediaConstraints:this.getUserMediaConstraints}}get currentActiveRoomId(){return this.currentActiveRoomIdValue}set currentActiveRoomId(t){this.currentActiveRoomIdValue=t,this.context.emit("currentActiveRoomChanged",t)}get autoAnswer(){return this.isAutoAnswer}get callAddingInProgress(){return this.isCallAddingInProgress}set callAddingInProgress(t){this.isCallAddingInProgress=t,this.context.emit("callAddingInProgressChanged",t)}get muteWhenJoin(){return this.muteWhenJoinEnabled}get isDND(){return this.isDNDEnabled}get isCallWaiting(){return this.isCallWaitingEnabled}get speakerVolume(){return this.speakerVolumeValue}get microphoneInputLevel(){return this.microphoneInputLevelValue}get getActiveCalls(){return this.activeCalls}get hasActiveCalls(){return Object.values(this.extendedCalls).length>0}get hasActiveAnsweredCalls(){return Object.values(this.activeRooms).filter(a=>!a.incomingInProgress).length>0}get getActiveRooms(){return this.activeRooms}get isMuted(){return this.muted}get getInputDeviceList(){return this.availableMediaDevices.filter(t=>t.kind==="audioinput")}get getOutputDeviceList(){return this.availableMediaDevices.filter(t=>t.kind==="audiooutput")}get getUserMediaConstraints(){return vh()?{video:!1,audio:!0}:{audio:{deviceId:{exact:this.selectedMediaDevices.input},echoCancellation:!0,echoCancellationType:"system",noiseSuppression:!0,autoGainControl:!0,sampleRate:48e3,latency:.01},video:!1}}get selectedInputDevice(){return this.selectedMediaDevices.input}get selectedOutputDevice(){return this.selectedMediaDevices.output}get activeStream(){return this.activeStreamValue}setAvailableMediaDevices(t){this.availableMediaDevices=t,this.context.emit("changeAvailableDeviceList",t)}async updateDeviceList(){await navigator.mediaDevices.getUserMedia(this.getUserMediaConstraints);const t=await navigator.mediaDevices.enumerateDevices();this.setAvailableMediaDevices(t)}async initializeMediaDevices(){const t=localStorage.getItem(Ia.SELECTED_INPUT_DEVICE)||"default",n=localStorage.getItem(Ia.SELECTED_OUTPUT_DEVICE)||"default";try{const a=await navigator.mediaDevices.getUserMedia(this.getUserMediaConstraints),o=await navigator.mediaDevices.enumerateDevices();this.setAvailableMediaDevices(o),await this.setMicrophone(t),await this.setSpeaker(n),navigator.mediaDevices.addEventListener("devicechange",async()=>{const s=await navigator.mediaDevices.enumerateDevices();this.setAvailableMediaDevices(s)}),a.getTracks().forEach(s=>s.stop())}catch(a){console.error(a)}}async cleanupConferenceNodes(t){const n=this.conferenceNodes[t];if(!n)return;let a=0;n.sources.forEach((r,d)=>{try{r.disconnect(),a++}catch(h){console.error(`[cleanupConferenceNodes] Error disconnecting source ${d}:`,h)}});let o=0;n.destinations.forEach((r,d)=>{try{r.disconnect(),o++}catch(h){console.error(`[cleanupConferenceNodes] Error disconnecting destination ${d}:`,h)}});let s=0;n.gains.forEach((r,d)=>{try{r.disconnect(),s++}catch(h){console.error(`[cleanupConferenceNodes] Error disconnecting gain ${d}:`,h)}}),delete this.conferenceNodes[t]}setCallTime(t){const n={...t};delete n.callId,this.callTime={...this.callTime,[t.callId]:n},this.context.emit("changeCallTime",this.callTime)}removeCallTime(t){const n={...this.callTime};delete n[t],this.callTime={...n},this.context.emit("changeCallTime",this.callTime)}setTimeInterval(t,n){this.timeIntervals={...this.timeIntervals,[t]:n}}removeTimeInterval(t){const n={...this.timeIntervals};n[t]&&(clearInterval(n[t]),delete n[t],this.timeIntervals={...n})}stopCallTimer(t){this.removeTimeInterval(t),this.removeCallTime(t)}emitVolumeChange(t,n){this.context.emit("changeCallVolume",{callId:t,volume:n})}setMetricsConfig(t){this.metricConfig={...this.metricConfig,...t}}sendDTMF(t,n){if(!/^[A-D0-9*#]+$/g.test(n))throw new Error("Not allowed character used in the DTMF input");this.extendedCalls[t].sendDTMF(n)}setIsMuted(t){this.muted=t,this.context.emit("changeIsMuted",t)}processMute(t){const n=this.currentActiveRoomId;this.setIsMuted(t),this.initialStreamValue.getTracks().forEach(a=>a.enabled=!t),this.roomReconfigure(n)}mute(){this.processMute(!0)}unmute(){this.processMute(!1)}async processHold({callId:t,toHold:n,automatic:a}){const o=this.extendedCalls[t];if(!o)return;o._automaticHold=a??!1;const s=new Promise((r,d)=>{const h=setTimeout(()=>{d(new Error("Hold operation timeout"))},5e3),_=()=>{clearTimeout(h),o.putOnHoldTimestamp=n?Date.now():void 0,r()},g=T=>{clearTimeout(h),d(T)};try{n?(this.stopSessionVad(o._id),o.hold({},_)):o.unhold({},_)}catch(T){g(T)}});try{await s,this.updateCall(o);const r=Object.values(this.extendedCalls).filter(d=>d.roomId===o.roomId&&(n?t!==d._id:!0));r.length>1&&await this.doConference(r)}catch(r){throw console.error("Hold operation failed:",r),r}}holdCall(t,n=!1){return this.processHold({callId:t,automatic:n,toHold:!0})}unholdCall(t){return this.processHold({callId:t,toHold:!1})}cancelAllOutgoingUnanswered(){Object.values(this.getActiveCalls).filter(t=>t.direction==="outgoing"&&t.status===Kv).forEach(t=>this.terminateCall(t._id))}answerCall(t){const n=this.extendedCalls[t];this.cancelAllOutgoingUnanswered(),n.answer(this.sipOptions),this.updateCall(n),this.setActiveRoom(n.roomId),n.connection.addEventListener("track",a=>{this.triggerAddStream(a,n)})}async moveCall(t,n){this.updateCallStatus({callId:t,isMoving:!0}),await this.processRoomChange({callId:t,roomId:n}),this.updateCallStatus({callId:t,isMoving:!1})}updateCall(t){this.activeCalls[t._id]=gh(t),this.context.emit("changeActiveCalls",this.activeCalls)}updateRoom(t){const a={...this.activeRooms[t.roomId],...t};this.activeRooms={...this.activeRooms,[t.roomId]:{...a}},this.context.emit("updateRoom",{room:a,roomList:this.activeRooms})}hasAutoAnswerHeaders(t){const n=/answer-after=0/,o=t.request.getHeader("Call-Info");return o&&n.test(o)}addCall(t,n=!0){this.activeCalls={...this.activeCalls,[t._id]:gh(t)},this.extendedCalls[t._id]=t,n&&this.context.emit("changeActiveCalls",this.activeCalls)}addCallStatus(t){this.callStatus={...this.callStatus,[t]:{isMoving:!1,isTransferring:!1,isMerging:!1,isTransferred:!1}},this.context.emit("changeCallStatus",this.callStatus)}updateCallStatus(t){const a={...{...this.callStatus[t.callId]}};t.isMoving!==void 0&&(a.isMoving=t.isMoving),t.isTransferring!==void 0&&(a.isTransferring=t.isTransferring),t.isMerging!==void 0&&(a.isMerging=t.isMerging),t.isTransferred!==void 0&&(a.isTransferred=t.isTransferred),this.callStatus={...this.callStatus,[t.callId]:{...a}},this.context.emit("changeCallStatus",this.callStatus)}removeCallStatus(t){const n={...this.callStatus};delete n[t],this.callStatus={...n},this.context.emit("changeCallStatus",this.callStatus)}addRoom(t){this.activeRooms={...this.activeRooms,[t.roomId]:t},this.context.emit("addRoom",{room:t,roomList:this.activeRooms})}async setupActiveStream(){const t=await Cu(await this.managedAudioContext.getContext(),this.initialStreamValue,this.microphoneInputLevel*2);t.getTracks().forEach(n=>n.enabled=!this.isMuted),await this.setActiveStream(t)}async getActiveStream(){const t=await Cu(await this.managedAudioContext.getContext(),this.initialStreamValue,this.microphoneInputLevel*2);return t.getTracks().forEach(n=>n.enabled=!this.isMuted),await this.setActiveStream(t),t}async setMicrophone(t){if(!this.getInputDeviceList.find(({deviceId:a})=>a===t)||(this.setSelectedInputDevice(t),Object.keys(this.getActiveCalls).length===0))return;await this.setupStream();const n=Object.values(this.extendedCalls).filter(a=>a.roomId===this.currentActiveRoomId);n.length===1?Object.values(n).forEach(async a=>{await this.setupActiveStream();const o=this.activeStream;a.connection.getSenders()[0].replaceTrack(o.getTracks()[0]),this.updateCall(a)}):await this.doConference(n)}async setActiveStream(t){this.activeStream&&this.stopVUMeter("origin"),await this.setupVUMeter(t,"origin"),this.activeStreamValue=t,this.context.emit("changeActiveStream",t)}async setSpeaker(t){if(!this.getOutputDeviceList.find(({deviceId:o})=>o===t))return;this.setSelectedOutputDevice(t);const n=Object.values(this.extendedCalls);if(n.length===0)return;const a=n.filter(o=>o.roomId===this.currentActiveRoomId);a.length===1?n.forEach(o=>{var s;(s=o.audioTag)==null||s.setSinkId(t),this.updateCall(o)}):await this.doConference(a)}removeRoom(t){const n={...this.activeRooms},a={...n[t]};delete n[t],this.activeRooms={...n},this.context.emit("removeRoom",{room:a,roomList:this.activeRooms})}deleteRoomIfEmpty(t){t!==void 0&&Object.values(this.extendedCalls).filter(n=>n.roomId===t).length===0&&(this.removeRoom(t),this.currentActiveRoomId===t&&(this.currentActiveRoomId=void 0))}checkInitialized(){if(!this.context.initialized)throw new Error("[OpenSIPSJS] You must call `start` method first!")}muteReconfigure(t){this.muted?t.mute({audio:!0}):t.unmute({audio:!0})}startNoiseMonitor({sessionId:t,stream:n,onNoiseDetected:a,onNoiseStop:o}){const s=new AudioContext,r=s.createMediaStreamSource(n.clone()),d=s.createAnalyser();d.fftSize=1024;const h=new Float32Array(d.fftSize);r.connect(d);const _=[];this.vadIntervals[t]&&(clearInterval(this.vadIntervals[t]),this.vadIntervals[t]=null),this.vadMrsIntervals[t]&&(clearInterval(this.vadMrsIntervals[t]),this.vadMrsIntervals[t]=null),this.vadMrsIntervals[t]=setInterval(()=>{d.getFloatTimeDomainData(h);const g=YT(h);_.push(g);const T=Math.ceil(this.noiseReduction.noiseCheckInterval/this.noiseReduction.checkEveryMs);_.length>T&&_.shift()},this.noiseReduction.checkEveryMs),this.vadIntervals[t]=setInterval(()=>{if(_.length===0)return;const g=_.reduce((E,C)=>E+C,0)/_.length,T=this.vadSessionsState[t],S=g>this.noiseReduction.noiseThreshold;T.isSpeaking||(S&&T.currentMode==="clean"?(T.currentMode="noisy",console.log("Average noise high → enable VAD"),this.context.emit("changeNoiseReductionState",{sessionId:t,enabled:!0}),a()):!S&&T.currentMode==="noisy"&&(T.currentMode="clean",console.log("Average noise low → disable VAD"),this.context.emit("changeNoiseReductionState",{sessionId:t,enabled:!1}),o()))},this.noiseReduction.noiseCheckInterval)}async processVAD(t,n){const a=n.clone();this.stopSessionVad(t._id),this.vadSessionsState[t._id]={currentMode:"clean",isSpeaking:!1};const o=await this.managedAudioContext.getContext(),s=await JT(a,o,150);let r=!1;const d=await Wv.new({getStream:()=>new Promise(h=>h(a)),...qv,...this.noiseReduction.vadConfig,baseAssetPath:"https://cdn.jsdelivr.net/npm/@ricky0123/vad-web@0.0.28/dist/",onnxWASMBasePath:"https://cdn.jsdelivr.net/npm/onnxruntime-web@1.22.0/dist/",onFrameProcessed:()=>{if(!r){if(r=!0,console.log("✅ VAD initialized, starting background noise monitoring"),this.noiseReduction.mode==="enabled"){t.connection.getSenders()[0]&&t.connection.getSenders()[0].replaceTrack(s.stream.getAudioTracks()[0]);return}this.startNoiseMonitor({sessionId:t._id,stream:a,onNoiseDetected:async()=>{var h;console.log("Replace track with Vad Controlled"),await((h=t.connection.getSenders()[0])==null?void 0:h.replaceTrack(s.stream.getAudioTracks()[0]))},onNoiseStop:async()=>{const h=t.connection.getSenders()[0];h&&h.track&&h.transport&&h.transport.state!=="closed"&&h.transport.state!=="failed"&&(console.log("Replace track with Original"),await h.replaceTrack(a.getAudioTracks()[0]))}})}},onSpeechStart:()=>{var h;console.log("🎤 Speech started"),s.setSpeaking(!0),this.noiseReduction.mode==="enabled"&&((h=t.connection.getSenders()[0])==null||h.replaceTrack(s.stream.getAudioTracks()[0])),this.vadSessionsState[t._id].isSpeaking=!0},onSpeechEnd:()=>{var h;console.log("🛑 Speech end"),s.setSpeaking(!1),this.noiseReduction.mode==="enabled"&&((h=t.connection.getSenders()[0])==null||h.replaceTrack(s.stream.getAudioTracks()[0])),this.vadSessionsState[t._id].isSpeaking=!1}});this.vadSessions[t._id]&&(this.vadSessions[t._id].pause(),delete this.vadSessions[t._id]),this.vadSessions[t._id]=d,d.start()}stopSessionVad(t){this.vadSessions[t]&&(this.vadSessions[t].pause(),delete this.vadSessions[t]),this.vadIntervals[t]&&(clearInterval(this.vadIntervals[t]),delete this.vadIntervals[t]),this.vadMrsIntervals[t]&&(clearInterval(this.vadMrsIntervals[t]),delete this.vadMrsIntervals[t]),this.vadSessionsState[t]&&delete this.vadSessionsState[t]}async roomReconfigure(t){var o;if(t===void 0)return;const n=Object.values(this.extendedCalls).filter(s=>s.roomId===t),a=this.currentActiveRoomId===t;if(n.forEach((s,r)=>{if(s.audioTag){s.connection.getReceivers().forEach(h=>{h.track.enabled=!s.localMuted}),a&&this.muteReconfigure(s);const d=!a;s.audioTag.muted=d,this.updateCall(s)}}),n.length===0){!!this.conferenceNodes[t]&&await this.cleanupConferenceNodes(t),this.deleteRoomIfEmpty(t);return}if(n.length===1&&!a){const s=n[0];s.isOnHold().local||await this.holdCall(s._id,!0),!!this.conferenceNodes[t]&&await this.cleanupConferenceNodes(t);return}if(n.length===1&&a){const s=n[0];s.isOnHold().local&&s._automaticHold&&await this.unholdCall(s._id);const h=(((o=s.connection)==null?void 0:o.getSenders())||[])[0];if(s.connection&&h)try{await this.setupActiveStream();const g=this.activeStream;["enabled","dynamic"].includes(this.noiseReduction.mode)&&this.processVAD(n[0],g);const T=g.getTracks();await h.replaceTrack(T[0]),this.muteReconfigure(s)}catch(g){console.error(g)}!!this.conferenceNodes[t]&&await this.cleanupConferenceNodes(t);return}n.length>1&&await this.doConference(n)}async doConference(t){if(t.length===0)return;const n=t[0].roomId,a=this.currentActiveRoomId===n;if(t.find(h=>h.roomId!==n))return;const s=await this.managedAudioContext.getContext();if(s.state!=="running"){console.error(`[doConference] ERROR: AudioContext is not running! State: ${s.state}`);return}await this.cleanupConferenceNodes(n),this.conferenceNodes[n]={sources:new Map,destinations:new Map,gains:new Map};const r=this.conferenceNodes[n],d=new Map;t.forEach((h,_)=>{h&&h.connection&&h.connection.getReceivers().forEach((T,S)=>{var A,R,k;T.track.enabled=!h.localMuted;const E=(A=T.track)==null?void 0:A.id;(R=T.track)==null||R.readyState,(k=T.track)==null||k.kind;const C=`${h._id}-${E}`;T.track&&T.track.readyState==="live"&&d.set(C,T.track)})}),await this.setupActiveStream(),await zT.forEach(t,async(h,_)=>{if(!h||!h.connection)return;const g=s.createMediaStreamDestination();r.destinations.set(h._id,g);let T=0;if(d.forEach((A,R)=>{if(!R.startsWith(h._id))try{const k=s.createMediaStreamSource(new MediaStream([A])),M=s.createGain(),ie=`${h._id}-${R}`;k.connect(M),M.connect(g),r.sources.set(ie,k),r.gains.set(ie,M),T++}catch(k){console.error(k)}}),a&&this.activeStreamValue)try{const A=this.activeStream,R=s.createMediaStreamSource(A),k=s.createGain(),M=`${h._id}-local`;R.connect(k),k.connect(g),r.sources.set(M,R),r.gains.set(M,k)}catch(A){console.error(A)}else a&&console.error(`Host room but no activeStreamValue - skipping host microphone for session ${h._id}`);const E=h.connection.getSenders()[0],C=g.stream.getTracks();if(["enabled","dynamic"].includes(this.noiseReduction.mode)&&this.processVAD(h,g.stream),E&&C[0])try{await E.replaceTrack(C[0]),this.muteReconfigure(h)}catch(A){console.error(A)}})}processCallerMute(t,n){const a=this.extendedCalls[t];a&&a.connection.getReceivers().length&&(a.localMuted=n,a.connection.getReceivers().forEach(o=>{o.track.enabled=!n}),this.updateCall(a))}muteCaller(t){this.processCallerMute(t,!0)}unmuteCaller(t){this.processCallerMute(t,!1)}terminateCall(t){const n=this.extendedCalls[t];n._status===4?n.terminate({status_code:603,reason_phrase:"Decline"}):n._status!==8&&n.terminate()}transferCall(t,n){if(n.toString().length===0)return new Error("Target must be passed");const a=this.extendedCalls[t];if(!a._is_confirmed&&!a._is_canceled){const o=`sip:${n}@${this.context.sipDomain}`;a.terminate({status_code:302,reason_phrase:"Moved Temporarily",extraHeaders:[`Contact: ${o}`]});return}this.updateCallStatus({callId:t,isTransferring:!0,isTransferred:!1}),a.refer(`sip:${n}@${this.context.sipDomain}`,{eventHandlers:{requestSucceeded:()=>{this.updateCallStatus({callId:t,isTransferring:!1,isTransferred:!0})},requestFailed:()=>{this.updateCallStatus({callId:t,isTransferring:!1,isTransferred:!1})}}}),this.updateCall(a)}mergeCall(t){const n=Object.values(this.extendedCalls).filter(s=>s.roomId===t);if(n.length!==2)return;const a=n[0],o=n[1];!a||!o||(this.updateCallStatus({callId:a._id,isMerging:!0}),this.updateCallStatus({callId:o._id,isMerging:!0}),a.refer(o.remote_identity.uri.toString(),{replaces:o}),this.updateCall(a))}mergeCallByIds(t,n){const a=Object.values(this.extendedCalls).find(s=>s._id===t),o=Object.values(this.extendedCalls).find(s=>s._id===n);if(!a||!o)throw new Error("Call ID is not provided");this.updateCallStatus({callId:t,isMerging:!0}),this.updateCallStatus({callId:n,isMerging:!0}),a.refer(o.remote_identity.uri.toString(),{replaces:o}),this.updateCall(a)}setDND(t){this.isDNDEnabled=t,this.context.emit("changeIsDND",t)}setCallWaiting(t){this.isCallWaitingEnabled=t,this.context.emit("changeIsCallWaiting",t)}startCallTimer(t){this.removeTimeInterval(t);const n={callId:t,hours:0,minutes:0,seconds:0,formatted:""};this.setCallTime(n);const a=setInterval(()=>{const o={...this.callTime[t]},s=KT(o);this.setCallTime({callId:t,...s})},1e3);this.setTimeInterval(t,a)}async setActiveRoom(t){const n=this.currentActiveRoomId;t!==n&&(this.currentActiveRoomId=t,await this.roomReconfigure(n),await this.roomReconfigure(t))}getNewRoomId(){const t=Object.keys(this.activeRooms);return t.length===0?1:parseInt(t.sort()[t.length-1])+1}async setupCall(t){var _,g;const n=t.session;if(this.getActiveCalls[n.id]!==void 0)return;const o=this.getNewRoomId(),s={started:new Date,incomingInProgress:!1,roomId:o};n.direction==="incoming"?(this.context.logger.log("New incoming call from",(g=(_=n._remote_identity)==null?void 0:_._uri)==null?void 0:g._user),s.incomingInProgress=!0,this.context.subscribe(Qt.CALL_CONFIRMED,T=>{n.id===T.id&&(this.updateRoom({incomingInProgress:!1,roomId:o}),this.startCallTimer(n.id))}),this.context.subscribe(Qt.CALL_FAILED,T=>{n.id===T.id&&(this.updateRoom({incomingInProgress:!1,roomId:o}),this.deleteRoomIfEmpty(o))})):n.direction==="outgoing"&&(n.once("confirmed",()=>{this.startCallTimer(n.id)}),this.startCallTimer(n.id));const r=n,d=this.hasAutoAnswerHeaders(t),h=r.direction==="incoming"&&!this.hasActiveCalls&&(d||this.autoAnswer);r.roomId=o,r.localMuted=!1,r.autoAnswer=h,h?this.addCall(r,!1):this.addCall(r),this.addCallStatus(n.id),this.addRoom(s),h&&this.answerCall(r._id)}removeCall(t){const n={...this.activeCalls};delete n[t],this.activeCalls={...n};const a={...this.extendedCalls};delete a[t],this.extendedCalls={...a},this.context.emit("changeActiveCalls",this.activeCalls)}activeCallListRemove(t){const n=this.extendedCalls[t._id];if(!n)return;this.stopVUMeter("origin"),this.stopVUMeter(t._id);const a=n.roomId;this.removeCall(t._id),this.roomReconfigure(a).then(()=>{}).catch(o=>{console.error("Error reconfiguring room after call removal:",o)})}shouldTerminateNewSession(t){if(t.session.direction==="outgoing")return!1;const a=!this.isCallWaiting&&this.hasActiveCalls;return this.isDND||a}async newRTCSessionCallback(t){const n=t.session;if(this.shouldTerminateNewSession(t)){n.terminate({status_code:486,reason_phrase:"Do Not Disturb"});return}if(this.context.triggerListener({listenerType:Qt.NEW_CALL,session:n,event:t}),n.on("ended",a=>{var s,r,d;this.stopVUMeter(n.id),this.context.logger.log("Session ended for",(r=(s=n._remote_identity)==null?void 0:s._uri)==null?void 0:r._user),this.context.triggerListener({listenerType:Qt.CALL_ENDED,session:n,event:a}),["enabled","dynamic"].includes(this.noiseReduction.mode)&&this.stopSessionVad(n._id);const o=this.getActiveCalls[n.id];o&&this.activeCallListRemove(o),this.stopCallTimer(n.id),this.removeCallStatus(n.id),this.removeCallMetrics(n.id),Object.keys(this.extendedCalls).length||(this.setIsMuted(!1),(d=this.initialStreamValue)==null||d.getTracks().forEach(h=>h.stop()),this.initialStreamValue=null),this.context.isWaitingForSessionHangup()&&!this.hasActiveAnsweredCalls&&this.context.stopSessionAfterWaiting()}),n.on("progress",a=>{var o,s;this.context.logger.log("Session in progress for",(s=(o=n._remote_identity)==null?void 0:o._uri)==null?void 0:s._user),this.context.triggerListener({listenerType:Qt.CALL_PROGRESS,session:n,event:a})}),n.on("failed",a=>{var s,r,d;this.stopVUMeter(n.id),this.context.logger.log("Session failed for",(r=(s=n._remote_identity)==null?void 0:s._uri)==null?void 0:r._user),this.context.triggerListener({listenerType:Qt.CALL_FAILED,session:n,event:a}),["enabled","dynamic"].includes(this.noiseReduction.mode)&&this.stopSessionVad(n._id),n.id===this.callAddingInProgress&&(this.callAddingInProgress=void 0);const o=this.getActiveCalls[n.id];o&&this.activeCallListRemove(o),this.stopCallTimer(n.id),this.removeCallStatus(n.id),this.removeCallMetrics(n.id),Object.keys(this.extendedCalls).length||(this.setIsMuted(!1),(d=this.initialStreamValue)==null||d.getTracks().forEach(h=>h.stop()),this.initialStreamValue=null),this.context.isWaitingForSessionHangup()&&!this.hasActiveAnsweredCalls&&this.context.stopSessionAfterWaiting()}),n.on("confirmed",a=>{var o,s;this.context.logger.log("Session confirmed for",(s=(o=n._remote_identity)==null?void 0:o._uri)==null?void 0:s._user),this.context.triggerListener({listenerType:Qt.CALL_CONFIRMED,session:n,event:a}),this.updateCall(n),n.id===this.callAddingInProgress&&(this.callAddingInProgress=void 0)}),await this.setupCall(t),n.direction==="outgoing"){const a=this.getActiveCalls[n.id].roomId;await this.setActiveRoom(a)}}setMuteWhenJoin(t){this.muteWhenJoinEnabled=t,this.context.emit("changeMuteWhenJoin",t)}setMicrophoneSensitivity(t){if(t<0||t>1)throw new Error("Value should be in range from 0 to 1!");this.microphoneInputLevelValue=t,this.roomReconfigure(this.currentActiveRoomId)}setSpeakerVolume(t){this.speakerVolumeValue=t,Object.values(this.extendedCalls).forEach(n=>{n.audioTag&&(n.audioTag.volume=t,this.updateCall(n))})}setAutoAnswer(t){this.isAutoAnswer=t}setSelectedInputDevice(t){localStorage.setItem(Ia.SELECTED_INPUT_DEVICE,t),this.selectedMediaDevices.input=t,this.context.emit("changeActiveInputMediaDevice",t)}setSelectedOutputDevice(t){localStorage.setItem(Ia.SELECTED_OUTPUT_DEVICE,t),this.selectedMediaDevices.output=t,this.context.emit("changeActiveOutputMediaDevice",t)}setCallMetrics(t){const n={...t};delete n.callId,this.callMetrics={...this.callMetrics,[t.callId]:n},this.context.emit("changeCallMetrics",this.callMetrics)}removeCallMetrics(t){const n={...this.callMetrics};delete n[t],this.callMetrics={...n},this.context.emit("changeCallMetrics",this.callMetrics)}getCallQuality(t){const n=new Fv(this.metricConfig),a=n.createProbe(t.connection,{cid:t._id}),o=[];let s;a.onreport=r=>{Object.entries(r.audio).forEach(([_,g])=>{g.direction==="inbound"&&!o.includes(_)&&(o.push(_),s=_)});const d=r.audio[s];if(!d)return;const h=jv(d,Vv);h.callId=t._id,this.setCallMetrics(h)},this.context.subscribe(Qt.CALL_ENDED,r=>{r._id===t._id&&n.stopAllProbes()}),n.startAllProbes()}async setupVUMeter(t,n){await this.VUMeter.start(await this.managedAudioContext.getContext(),t,n)}stopVUMeter(t){this.VUMeter.stop(t)}async setupStream(){try{const t=Date.now(),n=await navigator.mediaDevices.getUserMedia(this.getUserMediaConstraints);this.initialStreamValue&&(this.initialStreamValue.getTracks().forEach((o,s)=>{o.stop()}),this.initialStreamValue=null),this.initialStreamValue=n}catch(t){throw t}}async triggerAddStream(t,n){const a=this.muteWhenJoin||this.isMuted;this.setIsMuted(a),this.initialStreamValue||await this.setupStream();const o=await this.managedAudioContext.getContext(),s=await Cu(o,this.initialStreamValue,this.microphoneInputLevel*2),r=this.isMuted||this.muteWhenJoin;s.getTracks().forEach(S=>{S.enabled=!r}),await this.setActiveStream(s),await n.connection.getSenders()[0].replaceTrack(s.getTracks()[0]);const _=new MediaStream([t.track]);!Object.values(this.extendedCalls).find(S=>S.audioTag&&S.audioTag.id===n._id)&&UT(_,n,this.selectedOutputDevice,this.speakerVolume);const T=n.roomId===this.currentActiveRoomId;n.audioTag&&(n.audioTag.muted=!T),await this.setupVUMeter(_,n._id),this.getCallQuality(n),this.updateCall(n),["enabled","dynamic"].includes(this.noiseReduction.mode)&&this.processVAD(n,s)}initCall(t,n,a=!1){if(t.length===0)return console.error("Target must be a valid string");this.context.logger.log(`Calling sip:${t}@${this.context.sipDomain}...`);const o=this.context.call(`sip:${t}@${this.context.sipDomain}`,this.sipOptions);if(this.callAddingInProgress=o.id,n&&this.currentActiveRoomId!==void 0&&(this.processRoomChange({callId:o.id,roomId:this.currentActiveRoomId}),a)){const s=Object.values(this.extendedCalls).filter(r=>r.roomId===this.currentActiveRoomId&&r._id!==o.id);for(const r of s)this.holdCall(r._id,!0)}o.connection.addEventListener("track",s=>{this.triggerAddStream(s,o)})}async processRoomChange({callId:t,roomId:n}){const a=this.extendedCalls[t];if(!a)return;const o=a.roomId;a.roomId=n,this.updateCall(a),await this.roomReconfigure(o),await this.roomReconfigure(n)}}class Jv{constructor(t){this.context=t}get sipOptions(){return{...this.context.options.sipOptions}}initCall(t,n){if(t.length===0)return console.error("Target must be a valid string");this.context.logger.log(`Calling sip:${t}@${this.context.sipDomain}...`),this.context.joinVideoCall(`sip:${t}@${this.context.sipDomain}`,n,this.sipOptions)}stop(t={}){this.context.terminateJanusSessions(t)}startAudio(){this.context.enableJanusAudio(!0)}stopAudio(){this.context.enableJanusAudio(!1)}startVideo(){this.context.enableJanusVideo(!0)}stopVideo(){this.context.enableJanusVideo(!1)}changeMediaConstraints(t){this.context.changeMediaConstraints(t)}startScreenShare(){this.context.startScreenShare()}startBlur(){this.context.startBlur()}stopBlur(){this.context.stopBlur()}}class zv{constructor(t){this.activeMessages={},this.extendedMessages={},this.msrpHistory={},this.context=t,this.context.on(this.context.newMSRPSessionEventName,this.newMSRPSessionCallback.bind(this.context))}get isMSRPInitializing(){return this.isMSRPInitializingValue}get getActiveMessages(){return this.activeMessages}msrpAnswer(t){const n=this.extendedMessages[t];this.updateMSRPSession(n)}updateMSRPSession(t){this.activeMessages[t._id]=Th(t),this.context.emit("changeActiveMessages",this.activeMessages)}addMMSRPSession(t){this.activeMessages={...this.activeMessages,[t._id]:Th(t)},this.extendedMessages[t._id]=t,this.context.emit("changeActiveMessages",this.activeMessages)}addMSRPMessage(t,n){const a=this.msrpHistory[n.id]||[];a.push(t),this.msrpHistory={...this.msrpHistory,[n.id]:[...a]},this.context.emit("newMSRPMessage",{message:t,session:n})}messageTerminate(t){const n=this.extendedMessages[t];n._status!==8&&n.terminate()}addMessageSession(t){if(!t._id||this.getActiveMessages[t._id]!==void 0)return;const a=t;this.addMMSRPSession(a)}triggerMSRPListener({listenerType:t,session:n,event:a}){const o=this.context.listenersList[t];!o||!o.length||o.forEach(s=>{s(n,a)})}removeMMSRPSession(t){const n={...this.activeMessages};delete n[t],this.activeMessages={...n};const a={...this.extendedMessages};delete a[t],this.extendedMessages={...a},this.context.emit("changeActiveMessages",this.activeMessages)}activeMessageListRemove(t){this.removeMMSRPSession(t._id)}newMSRPSessionCallback(t){const n=t.session;n.on("ended",a=>{this.triggerMSRPListener({listenerType:Qt.CALL_ENDED,session:n,event:a});const o=this.getActiveMessages[n.id];this.activeMessageListRemove(o)}),n.on("failed",a=>{this.triggerMSRPListener({listenerType:Qt.CALL_FAILED,session:n,event:a});const o=this.getActiveMessages[n.id];this.activeMessageListRemove(o)}),n.on("confirmed",a=>{this.triggerMSRPListener({listenerType:Qt.CALL_CONFIRMED,session:n,event:a}),this.updateMSRPSession(n)}),n.on("newMessage",a=>{this.addMSRPMessage(a,n)}),this.addMessageSession(n)}setIsMSRPInitializing(t){this.isMSRPInitializingValue=t,this.context.emit("isMSRPInitializingChanged",t)}initMSRP(t,n,a){if(t.length===0)return console.error("Target must be a valid string");const o=this.context.startMSRP(t,a);o.on("active",()=>{this.addMessageSession(o),o.sendMSRP(n),this.setIsMSRPInitializing(!1)}),this.setIsMSRPInitializing(!0)}sendMSRP(t,n){const a=this.extendedMessages[t];if(!a)throw new Error(`MSRP session with id ${t} doesn't exist!`);a.sendMSRP(n)}}const ba={AUDIO:"audio",VIDEO:"video",MSRP:"msrp"};class Ph{constructor(t){this.opensips=null,this.session=null,this.name=null,this.name=t}setOpensips(t){this.opensips=t}setSession(t){this.session=t}kill(){this.opensips.kill(this.name)}}class kh extends Ph{constructor(t,n){super(t),this._candidates=[],this._subscribeSent=!1,this._configureSent=!1,this._lastTrickleReceived=!1,this.type=n}connect(t={}){this.opaqueId=this.session.generateOpaqueId();const n=Pe.cloneArray(t.extraHeaders),a={from_tag:this.session._from_tag};t.fromUserName&&(a.from_uri=new ln("sip",t.fromUserName,this.session._ua.configuration.uri.host),n.push(`P-Preferred-Identity: ${this.session._ua.configuration.uri.toString()}`)),t.fromDisplayName&&(a.from_display_name=t.fromDisplayName),n.push(`Contact: ${this.session._contact}`),n.push("Content-Type: application/json"),this.session._sessionTimers.enabled&&n.push(`Session-Expires: ${this.session._sessionTimers.defaultExpires}${this.session._ua.configuration.session_timers_force_refresher?";refresher=uac":""}`),this._request=new Tt.InitialOutgoingInviteRequest(this.session.target,this.session._ua,a,n),this._createRTCConnection(),this._sendInitialRequest()}getStream(){return this.stream}getConnection(){return this._connection}_createRTCConnection(){this._connection=new RTCPeerConnection({iceServers:[{urls:"stun:turn.voicenter.co",credential:"kxsjahnsdjns3eds23esd",username:"turn2es21e"}]});let t;this._connection.onicecandidate=n=>{this._connection.signalingState!=="stable"&&this._connection.signalingState!=="have-local-offer"||n.candidate&&(this._candidates.push(n.candidate),clearTimeout(t),t=setTimeout(()=>{this._lastTrickleReceived=!0,this._subscribeSent&&!this._configureSent&&this._sendConfigureMessage({audio:!0,video:!0})},500))}}addTracks(t){t.forEach(n=>{this._connection.addTrack(n)})}async _sendInitialRequest(){const t=new Wr(this.session._ua,this._request,{onRequestTimeout:()=>{this.session.onRequestTimeout()},onTransportError:()=>{this.session.onTransportError()},onAuthenticated:s=>{this._request=s},onReceiveResponse:s=>{this._receiveInviteResponse(s)}});if(await this.generateStream(),!this.stream||!this.stream.getTracks().length)return;this.addTracks(this.stream.getTracks());const n={audio:!1,video:!0};this.jsep_offer=await this._connection.createOffer(n),await this._connection.setLocalDescription(this.jsep_offer);const a={janus:"attach",plugin:"janus.plugin.videoroom",opaque_id:this.opaqueId},o=JSON.stringify(a);this._request.body=o,t.send()}_receiveInviteResponse(t){if(this._publisherSubscribeSent||!t.body)return;const n=JSON.parse(t.body);this.handleId=n.data.id;const a={janus:"message",body:{request:"join",room:this.session.room_id,ptype:"publisher",display:this.session.display_name+" (Screen Share)",opaque_id:this.opaqueId},handle_id:this.handleId},o=[this.session.getPTypeHeader(kt.PUBLISHER)];this.session.sendRequest(H.SUBSCRIBE,{extraHeaders:o,body:JSON.stringify(a),eventHandlers:{onSuccessResponse:async s=>{var r,d,h,_;if(s.status_code===200){if(this._subscribeSent=!0,s.body)try{const g=JSON.parse(s.body)||{};((d=(r=g.plugindata)==null?void 0:r.data)==null?void 0:d.videoroom)==="joined"&&this.session.myFeedList.push(g.plugindata.data.id),(_=(h=g.plugindata)==null?void 0:h.data)!=null&&_.publishers&&this.session.receivePublishers(g)}catch(g){console.error(g)}this._lastTrickleReceived&&!this._configureSent&&this._sendConfigureMessage({audio:!0,video:!0})}}}}),this._publisherSubscribeSent=!0}async _sendConfigureMessage(t){const n=this._candidates.map(r=>({janus:"trickle",candidate:r,handle_id:this.handleId,session_id:this.session.session_id})),o={configure:{janus:"message",body:{request:"configure",record:!0,filename:this.session.getRecordFileName(),...t},jsep:this.jsep_offer,handle_id:this.handleId,session_id:this.session.session_id},trickles:[...n]},s=["Content-Type: application/json",this.session.getPTypeHeader(kt.ICE)];this.session.sendRequest(H.INFO,{extraHeaders:s,body:JSON.stringify(o),eventHandlers:{onSuccessResponse:async r=>{this._configureSent=!0;const h=r.data.split(`\r
159
- `),_=h[h.length-1],g=JSON.parse(_);await this._connection.setRemoteDescription(g.jsep),this._candidates=[]}}})}_sendDetach(){const t={janus:"detach",handle_id:this.handleId,session_id:this.session.session_id},n=[this.session.getPTypeHeader(kt.DETACH)];this.session.sendRequest(H.INFO,{extraHeaders:n,body:JSON.stringify(t)}),this.session._ua.emit("pluginDetach",this.name)}async stopMedia(){this._connection&&(this._connection.close(),this._connection=null),this.stream&&(this.stream=null)}async stop(){await this.session.stopProcessPlugins(this.type);const t=this._connection.getSenders();t.forEach(n=>{const a=n.track;a&&a.stop()}),t.forEach(n=>{this._connection.removeTrack(n)}),await this.stopMedia(),this._sendDetach()}async generateStream(){throw new Error("generateStream method is not implemented")}}class Mh extends Ph{constructor(t,n,a={}){super(t),this.stream=null,this.running=!1,this.immediate=!1,this.type="video",this.immediate=a.immediate||!1,this.type=n}start(t){return t}stop(){throw new Error("stop method is not implemented")}async process(t){if(this.immediate){const n=await this.start(t);return this.running=!0,n}return t}async connect(){this.running=!0,await this.session.resyncPlugins(this.type)}terminate(){this.stop()}async kill(){this.stop(),this.running=!1,await this.session.resyncPlugins(this.type)}}class Xv extends RT{constructor(t,n){if(!t.modules.length)throw new Error("options.modules should include at least 1 module");const a={...t.configuration,sockets:t.socketInterfaces.map(o=>new WT.WebSocketInterface(o))};super(a),this.initialized=!1,this.connected=!1,this.logger=console,this.newRTCSessionEventName="newRTCSession",this.registeredEventName="registered",this.unregisteredEventName="unregistered",this.disconnectedEventName="disconnected",this.connectedEventName="connected",this.newMSRPSessionEventName="newMSRPSession",this.isReconnecting=!1,this.activeConnection=!1,this.waitingForSessionHangup=!1,this.waitingForSessionTimeout=null,this.reconnectionAttemptsLimit=1/0,this.reconnectionAttemptsCounter=0,this.audio=null,this.msrp=null,this.video=null,this.listenersList={},this.modules=[],t.pnExtraHeaders&&Object.keys(t.pnExtraHeaders).length&&this.registrator().setExtraContactUriParams(t.pnExtraHeaders),this.options=t,this.modules=t.modules,t.configuration.reconnectionAttemptsLimit&&(this.reconnectionAttemptsLimit=t.configuration.reconnectionAttemptsLimit),n&&xT(n)&&(this.logger=n)}isWaitingForSessionHangup(){return this.waitingForSessionHangup}stopSessionAfterWaiting(){this.setInitialized(!1),this.waitingForSessionHangup=!1,clearTimeout(this.waitingForSessionTimeout),this.waitingForSessionTimeout=null,this.activeConnection&&this.reconnect()}get hasActiveSessions(){return this.modules.includes(ba.AUDIO)?this.audio.hasActiveAnsweredCalls:!1}on(t,n){return super.on(t,n)}off(t,n){return super.off(t,n)}emit(t,n){return super.emit(t,n)}get sipDomain(){return this.options.sipDomain}use(t){if(this.newStreamPlugins.find(n=>n.name===t.name)||this.processStreamPlugins.find(n=>n.name===t.name))throw new Error(`Plugin with name ${t.name} already exists`);if(t instanceof kh)t.setOpensips(this),this.newStreamPlugins.push(t);else if(t instanceof Mh)t.setOpensips(this),this.processStreamPlugins.push(t);else throw new Error("Wrong plugin instance")}getPlugin(t){return this.newStreamPlugins.find(n=>n.name===t)||this.processStreamPlugins.find(n=>n.name===t)}reconnect(){if(this.reconnectionAttemptsCounter<this.reconnectionAttemptsLimit){const n=5e3*Math.pow(2,this.reconnectionAttemptsCounter);this.reconnectionAttemptsCounter++,setTimeout(this.start.bind(this),n)}else this.emit("reconnectionAttemptsLimitReached",void 0)}begin(){if(this.isConnected()){console.error("Connection is already established");return}return this.modules.includes(ba.AUDIO)&&(this.audio=new Yv(this)),this.modules.includes(ba.MSRP)&&(this.msrp=new zv(this)),this.modules.includes(ba.VIDEO)&&(this.video=new Jv(this)),this.on(this.registeredEventName,()=>{this.logger.log("Successfully registered to",this.options.socketInterfaces[0]),this.setInitialized(!0)}),this.on(this.unregisteredEventName,()=>{this.logger.log("Unregistered from",this.options.socketInterfaces[0]),this.setInitialized(!1)}),this.on(this.connectedEventName,()=>{this.logger.log("Connected to",this.options.socketInterfaces[0]),this.setConnected(!0),this.setReconnecting(!1),this.activeConnection=!0,this.waitingForSessionHangup=!1,this.reconnectionAttemptsCounter=0}),this.on(this.disconnectedEventName,()=>{this.setConnected(!1),!this.isReconnecting&&(this.setReconnecting(!0),this.logger.log("Disconnected from",this.options.socketInterfaces[0]),this.logger.log("Reconnecting to",this.options.socketInterfaces[0]),this.hasActiveSessions?(this.waitingForSessionHangup=!0,this.stop(!1),this.waitingForSessionTimeout=setTimeout(()=>{this.terminateAllSessions(),this.setInitialized(!1),this.waitingForSessionHangup=!1,this.activeConnection&&this.reconnect()},12e5)):(this.stop(),this.setInitialized(!1),this.activeConnection&&this.reconnect()))}),this.logger.log("Connecting to",this.options.socketInterfaces[0]),this.start(),this}disconnect(){this.activeConnection=!1,this.stop()}subscribe(t,n){const o=!this.listenersList[t]||!this.listenersList[t].length?[n]:[...this.listenersList[t],n];this.listenersList={...this.listenersList,[t]:o}}removeIListener(t){const n={...this.listenersList};delete n[t],this.listenersList={...n}}triggerListener({listenerType:t,session:n,event:a}){const o=this.listenersList[t];!o||!o.length||o.forEach(s=>{s(n,a)})}setInitialized(t){this.initialized=t,this.emit("ready",t)}setConnected(t){this.connected=t,this.emit("connection",t)}setReconnecting(t){this.isReconnecting=t,this.emit("reconnecting",t)}}Nt.BaseNewStreamPlugin=kh,Nt.BaseProcessStreamPlugin=Mh,Nt.default=Xv,Object.defineProperties(Nt,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
158
+ `,n),o===-1)return o;!c.substring(o+2,o+4).match(/(^\r\n)/)&&c.charAt(o+2).match(/(^\s+)/)?n=o+2:a=o}return a}function ET(c,t,n,a){let o;const s=t.indexOf(":",n),r=t.substring(n,s).trim(),d=t.substring(s+1,a).trim();switch(r.toLowerCase()){case"via":case"v":c.addHeader("via",d),c.getHeaders("via").length===1?(o=c.parseHeader("Via"),o&&(c.via=o,c.via_branch=o.branch)):o=0;break;case"from":case"f":c.setHeader("from",d),o=c.parseHeader("from"),o&&(c.from=o,c.from_tag=o.getParam("tag"));break;case"to":case"t":c.setHeader("to",d),o=c.parseHeader("to"),o&&(c.to=o,c.to_tag=o.getParam("tag"));break;case"record-route":if(o=yu.parse(d,"Record_Route"),o===-1)o=void 0;else for(const h of o)c.addHeader("record-route",d.substring(h.possition,h.offset)),c.headers["Record-Route"][c.getHeaders("record-route").length-1].parsed=h.parsed;break;case"call-id":case"i":c.setHeader("call-id",d),o=c.parseHeader("call-id"),o&&(c.call_id=d);break;case"contact":case"m":if(o=yu.parse(d,"Contact"),o===-1)o=void 0;else for(const h of o)c.addHeader("contact",d.substring(h.possition,h.offset)),c.headers.Contact[c.getHeaders("contact").length-1].parsed=h.parsed;break;case"content-length":case"l":c.setHeader("content-length",d),o=c.parseHeader("content-length");break;case"content-type":case"c":c.setHeader("content-type",d),o=c.parseHeader("content-type");break;case"cseq":c.setHeader("cseq",d),o=c.parseHeader("cseq"),o&&(c.cseq=o.value),c instanceof Ln.IncomingResponse&&(c.method=o.method);break;case"max-forwards":c.setHeader("max-forwards",d),o=c.parseHeader("max-forwards");break;case"www-authenticate":c.setHeader("www-authenticate",d),o=c.parseHeader("www-authenticate");break;case"proxy-authenticate":c.setHeader("proxy-authenticate",d),o=c.parseHeader("proxy-authenticate");break;case"session-expires":case"x":c.setHeader("session-expires",d),o=c.parseHeader("session-expires"),o&&(c.session_expires=o.expires,c.session_expires_refresher=o.refresher);break;case"refer-to":case"r":c.setHeader("refer-to",d),o=c.parseHeader("refer-to"),o&&(c.refer_to=o);break;case"replaces":c.setHeader("replaces",d),o=c.parseHeader("replaces"),o&&(c.replaces=o);break;case"event":case"o":c.setHeader("event",d),o=c.parseHeader("event"),o&&(c.event=o);break;default:c.addHeader(r,d),o=0}return o===void 0?{error:`error parsing header "${r}"`}:!0}const yT={parseMessage:vT},si=new na("Registrator"),ya=10;class CT{constructor(t,n){this._reg_id=1,this._ua=t,this._transport=n,this._registrar=t.configuration.registrar_server,this._expires=t.configuration.register_expires,this._call_id=vs.createRandomToken(22),this._cseq=0,this._to_uri=t.configuration.uri,this._registrationTimer=null,this._registering=!1,this._registered=!1,this._contact=this._ua.contact.toString();const a=this._contact.indexOf(">");if(a!==-1){const o=this._contact.slice(0,a)+this._contact.slice(a+1,this._contact.length);this._contact=o}this._extra_contact="",this._extraContactParams="",this._extra_contact+=";+sip.ice",this._extraHeaders=[],this._sipInstance=`"<urn:uuid:${this._ua.configuration.instance_id}>"`,this._extra_contact+=`;reg-id=${this._reg_id}`,this._extra_contact+=`;+sip.instance=${this._sipInstance}`}get registered(){return this._registered}setExtraHeaders(t){Array.isArray(t)||(t=[]),this._extraHeaders=t.slice()}setExtraContactParams(t){t instanceof Object||(t={}),this._extraContactParams="";for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)){const a=t[n];this._extraContactParams+=`;${n}`,a&&(this._extraContactParams+=`=${a}`)}}setExtraContactUriParams(t){t instanceof Object||(t={}),this._extraContactParams="";for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)){const a=t[n];this._extraContactParams+=`;${n}`,a&&(this._extraContactParams+=`=${a}`)}}register(){if(this._registering){si.debug("Register request in progress...");return}const t=this._extraHeaders.slice();t.push(`Contact: ${this._contact}${this._extraContactParams}>${this._extra_contact};expires=${this._expires}`),t.push(`Expires: ${this._expires}`);const n=new Tt.OutgoingRequest(H.REGISTER,this._registrar,this._ua,{to_uri:this._to_uri,call_id:this._call_id,cseq:this._cseq+=1},t),a=new Wr(this._ua,n,{onRequestTimeout:()=>{this._registrationFailure(null,H.causes.REQUEST_TIMEOUT)},onTransportError:()=>{this._registrationFailure(null,H.causes.CONNECTION_ERROR)},onAuthenticated:()=>{this._cseq+=1},onReceiveResponse:o=>{if(o.cseq===this._cseq)switch(this._registrationTimer!==null&&(clearTimeout(this._registrationTimer),this._registrationTimer=null),!0){case/^1[0-9]{2}$/.test(o.status_code):break;case/^2[0-9]{2}$/.test(o.status_code):{if(this._registering=!1,!o.hasHeader("Contact")){si.debug("no Contact header in response to REGISTER, response ignored");break}const s=o.headers.Contact.reduce((_,g)=>_.concat(g.parsed),[]);let r=s.find(_=>this._sipInstance===_.getParam("+sip.instance")&&this._reg_id===parseInt(_.getParam("reg-id")));if(r||(r=s.find(_=>_.uri.user===this._ua.contact.uri.user)),!r){si.debug("no Contact header pointing to us, response ignored");break}this._ua.clearKeepAliveInterval(),this._ua.setLastRegisterTimestamp();let d=r.getParam("expires");!d&&o.hasHeader("expires")&&(d=o.getHeader("expires")),d||(d=this._expires),d=Number(d),d<ya&&(d=ya);const h=d>64?d*1e3/2+Math.floor((d/2-32)*1e3*Math.random()):d*1e3-5e3;this._registrationTimer=setTimeout(()=>{this._registrationTimer=null,this._ua.listeners("registrationExpiring").length===0?this.register():this._ua.emit("registrationExpiring")},h),r.hasParam("temp-gruu")&&(this._ua.contact.temp_gruu=r.getParam("temp-gruu").replace(/"/g,"")),r.hasParam("pub-gruu")&&(this._ua.contact.pub_gruu=r.getParam("pub-gruu").replace(/"/g,"")),this._registered||(this._registered=!0,this._ua.registered({response:o}));break}case/^423$/.test(o.status_code):{o.hasHeader("min-expires")?(this._expires=Number(o.getHeader("min-expires")),this._expires<ya&&(this._expires=ya),this.register()):(si.debug("423 response received for REGISTER without Min-Expires"),this._registrationFailure(o,H.causes.SIP_FAILURE_CODE));break}default:{const s=vs.sipErrorCause(o.status_code);this._registrationFailure(o,s)}}}});this._registering=!0,a.send()}unregister(t={}){if(!this._registered){si.debug("already unregistered");return}this._registered=!1,this._registrationTimer!==null&&(clearTimeout(this._registrationTimer),this._registrationTimer=null);const n=this._extraHeaders.slice();t.all?n.push(`Contact: *${this._extraContactParams}`):n.push(`Contact: ${this._contact}${this._extraContactParams}>${this._extra_contact};expires=0`),n.push("Expires: 0");const a=new Tt.OutgoingRequest(H.REGISTER,this._registrar,this._ua,{to_uri:this._to_uri,call_id:this._call_id,cseq:this._cseq+=1},n);new Wr(this._ua,a,{onRequestTimeout:()=>{this._unregistered(null,H.causes.REQUEST_TIMEOUT)},onTransportError:()=>{this._unregistered(null,H.causes.CONNECTION_ERROR)},onAuthenticated:()=>{this._cseq+=1},onReceiveResponse:s=>{switch(!0){case/^1[0-9]{2}$/.test(s.status_code):break;case/^2[0-9]{2}$/.test(s.status_code):this._unregistered(s);break;default:{const r=vs.sipErrorCause(s.status_code);this._unregistered(s,r)}}}}).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(t,n){this._registering=!1,this._ua.registrationFailed({response:t||null,cause:n}),this._registered&&(this._registered=!1,this._ua.unregistered({response:t||null,cause:n}))}_unregistered(t,n){this._registering=!1,this._registered=!1,this._ua.unregistered({response:t||null,cause:n||null})}}const et=console,ks={STATUS_INIT:0,STATUS_READY:1,STATUS_USER_CLOSED:2,STATUS_NOT_READY:3,CONFIGURATION_ERROR:1,NETWORK_ERROR:2},AT=cT;class RT extends AT{constructor(t){super(t),this._msrp_sessions=[],this._transactions={nist:{},nict:{},ist:{},ict:{}},this._janus_sessions=[],this.newStreamPlugins=[],this.processStreamPlugins=[],this.optionsInterval=null,this.lastOptionsTimestamp=null,this.lastRegisterTimestamp=null,this._registrator=new CT(this)}setLastRegisterTimestamp(){this.lastRegisterTimestamp=Date.now()}call(t,n){return super.call(t,n)}joinVideoCall(t,n,a){et.debug("call()");const o=new Sa(this);return o.configureMedia({audio:!0,video:!0}),o.connect(t,n,a),o}startScreenShare(){et.debug("startScreenShare()");for(const t in this._janus_sessions)this._janus_sessions[t].connectScreenShare()}changeMediaConstraints(t){for(const n in this._janus_sessions)this._janus_sessions[n].changeMediaConstraints(t)}startBlur(){for(const t in this._janus_sessions)this._janus_sessions[t].connectBlur()}stopBlur(){for(const t in this._janus_sessions)this._janus_sessions[t].stopBlur()}_loadConfig(t){try{ti.load(this._configuration,t)}catch(s){throw s}this._configuration.display_name===0&&(this._configuration.display_name="0"),this._configuration.instance_id||(this._configuration.instance_id=vs.newUUID());let n;typeof window<"u"&&typeof window.document<"u"?n=window==null?void 0:window.navigator.userAgent:typeof self<"u"&&self.navigator&&(n=self.navigator.userAgent),n+=" "+De.USER_AGENT,this._configuration.user_agent=t.overrideUserAgent&&typeof t.overrideUserAgent=="function"?t.overrideUserAgent(n):n,t.onTransportCallback&&typeof t.onTransportCallback=="function"&&(this.onTransportCallback=t.onTransportCallback),this._configuration.jssip_id=vs.createRandomToken(5);const a=this._configuration.uri.clone();a.user=null,this._configuration.hostport_params=a.toString().replace(/^sip:/i,"");try{this._transport=new Mg(this._configuration.sockets,{max_interval:this._configuration.connection_recovery_max_interval,min_interval:this._configuration.connection_recovery_min_interval}),this._transport.onconnecting=IT.bind(this),this._transport.onconnect=bT.bind(this),this._transport.ondisconnect=wT.bind(this),this._transport.ondata=OT.bind(this)}catch(s){throw et.warn(s),new Ns.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 s=this._configuration.uri.clone();s.user=null,s.clearParams(),s.clearHeaders(),this._configuration.registrar_server=s}this._configuration.no_answer_timeout*=1e3,this._configuration.contact_uri?this._configuration.via_host=this._configuration.contact_uri.host:this._configuration.contact_uri=new ln("sip",vs.createRandomToken(8),this._configuration.via_host,null,{transport:"ws"}),this._contact={pub_gruu:null,temp_gruu:null,uri:this._configuration.contact_uri,toString(s={}){const r=s.anonymous||null,d=s.outbound||null;let h="<";return r?h+=this.temp_gruu||"sip:anonymous@anonymous.invalid;transport=ws":h+=this.pub_gruu||this.uri.toString(),d&&(r?!this.temp_gruu:!this.pub_gruu)&&(h+=";ob"),h+=">",h}};const o=["authorization_user","password","realm","ha1","authorization_jwt","display_name","register"];for(const s in this._configuration)Object.prototype.hasOwnProperty.call(this._configuration,s)&&(o.indexOf(s)!==-1?Object.defineProperty(this._configuration,s,{writable:!0,configurable:!1}):Object.defineProperty(this._configuration,s,{writable:!1,configurable:!1}));et.debug("configuration parameters after validation:");for(const s in this._configuration)if(Object.prototype.hasOwnProperty.call(ti.settings,s))switch(s){case"uri":case"registrar_server":et.debug(`- ${s}: ${this._configuration[s]}`);break;case"password":case"ha1":case"authorization_jwt":et.debug(`- ${s}: NOT SHOWN`);break;default:et.debug(`- ${s}: ${JSON.stringify(this._configuration[s])}`)}}newMSRPSession(t,n){t.on("msgHistoryUpdate",a=>{console.log(a)}),this._msrp_sessions[t.id]=t,this.emit("newMSRPSession",n)}newJanusSession(t,n){this._janus_sessions[t.id]=t,this.newStreamPlugins.forEach(a=>{a.setSession(t)}),this.processStreamPlugins.forEach(a=>{a.setSession(t)}),this.emit("newJanusSession",n)}kill(){}destroyMSRPSession(t){delete this._msrp_sessions[t.id]}destroyJanusSession(t){delete this._janus_sessions[t.id]}clearKeepAliveInterval(){clearInterval(this.optionsInterval),this.optionsInterval=null}receiveRequest(t){var s,r,d,h;const n=t.method;if(t.ruri.user!==this._configuration.uri.user&&t.ruri.user!==this._contact.uri.user){et.debug("Request-URI does not point to us"),t.method!==De.ACK&&t.reply_sl(404);return}if(t.ruri.scheme===De.SIPS){t.reply_sl(416);return}if(jt.checkTransaction(this,t))return;if(n===De.INVITE?new jt.InviteServerTransaction(this,this._transport,t):n!==De.ACK&&n!==De.CANCEL&&new jt.NonInviteServerTransaction(this,this._transport,t),n===De.OPTIONS){if(this.lastOptionsTimestamp=Date.now(),this.optionsInterval||(this.emit("initKeepAliveInterval"),this.optionsInterval=setInterval(()=>{const g=Date.now(),T=this.lastOptionsTimestamp>g-35e3,S=this.lastRegisterTimestamp+this._configuration.register_expires*1e3>g;T&&S&&this.emit("keepAliveInterval")},35e3)),this.listeners("newOptions").length===0){t.reply(200);return}new yf.Options(this).init_incoming(t)}else if(n===De.MESSAGE){if(this.listeners("newMessage").length===0){t.reply(405);return}new yf.Message(this).init_incoming(t)}else if(n===De.INVITE&&!t.to_tag&&this.listeners("newRTCSession").length===0){t.reply(405);return}let a,o;if(t.to_tag)if(a=this._findDialog(t.call_id,t.from_tag,t.to_tag),a)a.receiveRequest(t);else if(n===De.NOTIFY)if(o=this._findSession(t),o)o.receiveRequest(t);else{if(t.body)try{const _=JSON.parse(t.body)||{};(r=(s=_.plugindata)==null?void 0:s.data)!=null&&r.publishers&&Object.values(this._janus_sessions)[0].receivePublishers(_),(h=(d=_.plugindata)==null?void 0:d.data)!=null&&h.unpublished&&Object.values(this._janus_sessions)[0].receiveUnpublished(_.plugindata.data.unpublished)}catch(_){console.error(_)}t.reply(200)}else n!==De.ACK&&t.reply(481);else switch(n){case De.INVITE:if(window.RTCPeerConnection)if(t.hasHeader("replaces")){const _=t.replaces;a=this._findDialog(_.call_id,_.from_tag,_.to_tag),a?(o=a.owner,o.isEnded()?t.reply(603):o.receiveRequest(t)):t.reply(481)}else t.body.search(/MSRP/ig)>-1?(o=new Eu(this),o.init_incoming(t)):t.body.search(/JANUS/ig)>-1||(o=new Sg(this),o.init_incoming(t));else et.warn("INVITE received but WebRTC is not supported"),t.reply(488);break;case De.BYE:t.reply(481);break;case De.CANCEL:o=this._findSession(t),o?o.receiveRequest(t):et.debug("received CANCEL request for a non existent session");break;case De.ACK:break;case De.NOTIFY:this.emit("sipEvent",{event:t.event,request:t}),t.reply(200);break;default:t.reply(405);break}}startMSRP(t,n){et.debug("startMSRP()",n);const a=new Eu(this);return a.connect(t),a}startJanus(t,n){et.debug("startJanus()",n);const a=new Eu(this);return a.connect(t),a}terminateMSRPSessions(t){et.debug("terminateSessions()");for(const n in this._msrp_sessions)this._msrp_sessions[n].isEnded()||this._msrp_sessions[n].terminate(t)}terminateJanusSessions(t){et.debug("terminateSessions()");for(const n in this._janus_sessions)this._janus_sessions[n].isEnded()||this._janus_sessions[n].terminate(t)}enableJanusAudio(t){et.debug("enableJanusAudio()");for(const n in this._janus_sessions)this._janus_sessions[n].isEnded()||(t?this._janus_sessions[n].startAudio():this._janus_sessions[n].stopAudio())}enableJanusVideo(t){et.debug("enableJanusVideo()");for(const n in this._janus_sessions)this._janus_sessions[n].isEnded()||(t?this._janus_sessions[n].startVideo():this._janus_sessions[n].stopVideo())}terminateAllSessions(){for(const t in this._sessions)if(Object.prototype.hasOwnProperty.call(this._sessions,t)){et.debug(`closing session ${t}`);try{this._sessions[t].terminate()}catch(n){console.error(n)}}}stop(t=!0){if(et.debug("stop()"),this._dynConfiguration={},this._status===ks.STATUS_USER_CLOSED){et.debug("UA already closed");return}this._registrator.close();const n=Object.keys(this._sessions).length;t&&this.terminateAllSessions();for(const o in this._msrp_sessions)if(Object.prototype.hasOwnProperty.call(this._msrp_sessions,o)){et.debug(`closing session ${o}`);try{this._msrp_sessions[o].terminate()}catch(s){console.error(s)}}for(const o in this._janus_sessions)if(Object.prototype.hasOwnProperty.call(this._janus_sessions,o)){et.debug(`closing session ${o}`);try{this._janus_sessions[o].terminate()}catch(s){console.error(s)}}for(const o in this._applicants)if(Object.prototype.hasOwnProperty.call(this._applicants,o))try{this._applicants[o].close()}catch(s){console.error(s)}this._status=ks.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&&n===0?this._transport.disconnect():this._closeTimer=setTimeout(()=>{this._closeTimer=null,this._transport.disconnect()},2e3)}}function IT(c){this.emit("connecting",c)}function bT(c){this._status!==ks.STATUS_USER_CLOSED&&(this._status=ks.STATUS_READY,this._error=null,this.emit("connected",c),this._dynConfiguration.register&&this._registrator.register())}function wT(c){const t=["nict","ict","nist","ist"];for(const n of t)for(const a in this._transactions[n])Object.prototype.hasOwnProperty.call(this._transactions[n],a)&&this._transactions[n][a].onTransportError();this.emit("disconnected",c),this._registrator.onTransportClosed(),this._status!==ks.STATUS_USER_CLOSED&&(this._status=ks.STATUS_NOT_READY,this._error=ks.NETWORK_ERROR)}function OT(c){const t=c.transport;let n=c.message;const a=n;if(n=yT.parseMessage(n,this),this.onTransportCallback&&typeof this.onTransportCallback=="function"&&this.onTransportCallback(n,a),!!n&&!(this._status===ks.STATUS_USER_CLOSED&&n instanceof Ln.IncomingRequest)&&Xg(n,this,t)){if(n instanceof Ln.IncomingRequest)n.transport=t,this.receiveRequest(n);else if(n instanceof Ln.IncomingResponse){let o;switch(n.method){case De.INVITE:o=this._transactions.ict[n.via_branch],o&&o.receiveResponse(n);break;case De.ACK:break;default:o=this._transactions.nict[n.via_branch],o&&o.receiveResponse(n);break}}}}const DT=["roomId","_audioMuted","_cancel_reason","_contact","direction","_end_time","_eventsCount","_from_tag","_id","_is_canceled","_is_confirmed","_late_sdp","_localHold","_videoMuted","status","start_time","_remote_identity","audioTag","isOnHold","localMuted","autoAnswer","putOnHoldTimestamp"],NT=["_cancel_reason","_contact","direction","_end_time","_eventsCount","_from_tag","_id","_is_canceled","_is_confirmed","_late_sdp","status","start_time","_remote_identity","target_addr"];function gh(c){const t={};return DT.forEach(n=>{c[n]!==void 0&&(t[n]=c[n])}),t.localHold=c._localHold,t}function Th(c){const t={};return NT.forEach(n=>{c[n]!==void 0&&(t[n]=c[n])}),t}async function Cu(c,t,n){const a=c.createMediaStreamSource(t),o=c.createMediaStreamDestination(),s=c.createGain();return a.connect(s),s.connect(o),s.gain.value=n,o.stream}function UT(c,t,n,a){if(vh())return;const o=document.createElement("audio");o.id=t._id,o.className="audioTag",o.srcObject=c,o.setSinkId(n),o.volume=a,o.play(),t.audioTag=o}function xT(c){if(c&&typeof c.log=="function"&&typeof c.warn=="function"&&typeof c.error=="function")return!0}function vh(){return/Mobi|react-native|Android|iPhone/i.test(navigator.userAgent)}const PT=at,kT=Jt(),Ot=new PT("WebSocketInterface");var MT=class{constructor(t){Ot.debug('new() [url:"%s"]',t),this._url=t,this._sip_uri=null,this._via_transport=null,this._ws=null;const n=kT.parse(t,"absoluteURI");if(n===-1)throw Ot.warn(`invalid WebSocket URI: ${t}`),new TypeError(`Invalid argument: ${t}`);if(n.scheme!=="wss"&&n.scheme!=="ws")throw Ot.warn(`invalid WebSocket URI scheme: ${n.scheme}`),new TypeError(`Invalid argument: ${t}`);this._sip_uri=`sip:${n.host}${n.port?`:${n.port}`:""};transport=ws`,this._via_transport=n.scheme.toUpperCase()}get via_transport(){return this._via_transport}set via_transport(t){this._via_transport=t.toUpperCase()}get sip_uri(){return this._sip_uri}get url(){return this._url}connect(){if(Ot.debug("connect()"),this.isConnected()){Ot.debug(`WebSocket ${this._url} is already connected`);return}else if(this.isConnecting()){Ot.debug(`WebSocket ${this._url} is connecting`);return}this._ws&&this.disconnect(),Ot.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(t){this._onError(t)}}disconnect(){Ot.debug("disconnect()"),this._ws&&(this._ws.onopen=()=>{},this._ws.onclose=()=>{},this._ws.onmessage=()=>{},this._ws.onerror=()=>{},this._ws.close(),this._ws=null)}send(t){return Ot.debug("send()"),this.isConnected()?(this._ws.send(t),!0):(Ot.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(){Ot.debug(`WebSocket ${this._url} connected`),this.onconnect()}_onClose({wasClean:t,code:n,reason:a}){Ot.debug(`WebSocket ${this._url} closed`),t===!1&&Ot.debug("WebSocket abrupt disconnection"),this.ondisconnect(!t,n,a)}_onMessage({data:t}){Ot.debug("received WebSocket message"),this.ondata(t)}_onError(t){Ot.warn(`WebSocket ${this._url} error: `,t)}};const Au=Tl,LT=De,$T=Ts,HT=mt(),FT=_h,jT=ps(),VT=qo(),qT=Jt(),BT=MT;Nn("JsSIP")("version %s",Au.version);var GT={C:LT,Exceptions:$T,Utils:HT,UA:FT,URI:jT,NameAddrHeader:VT,WebSocketInterface:BT,Grammar:qT,debug:Nn,get name(){return Au.title},get version(){return Au.version}};const WT=Me(GT);function Ru(c){return c<10?`0${c}`:`${c}`}function KT(c){let t=c.hours||0,n=c.minutes||0,a=c.seconds||0;a++,a===60&&(a=0,n++,n===60&&(n=0,t++));const o=`${Ru(t)}:${Ru(n)}:${Ru(a)}`;return{seconds:a,minutes:n,hours:t,formatted:o}}function YT(c){let t=0;for(let n=0;n<c.length;n++)t+=c[n]*c[n];return Math.sqrt(t/c.length)}async function JT(c,t,n=150){const a=t.createMediaStreamSource(c),o=t.createDelay();o.delayTime.value=n/1e3;const s=t.createGain();s.gain.value=0;const r=t.createMediaStreamDestination();return a.connect(o).connect(s).connect(r),{stream:r.stream,setSpeaking:d=>{s.gain.value=d?1:0}}}var yt={};yt.forEach=async(c,t,n)=>{const a=[];for(let o=0;o<c.length;o++)if(o in c){const s=Promise.resolve(c[o]).then(r=>t.call(n||globalThis,r,o,c));a.push(s)}await Promise.all(a)},yt.forEachSeries=async(c,t,n)=>{for(let a=0;a<c.length;a++)a in c&&await t.call(n||globalThis,await c[a],a,c)},yt.map=async(c,t,n)=>{const a=[];for(let o=0;o<c.length;o++)o in c&&(a[o]=Promise.resolve(c[o]).then(s=>t.call(n||globalThis,s,o,c)));return Promise.all(a)},yt.mapSeries=async(c,t,n)=>{const a=[];for(let o=0;o<c.length;o++)o in c&&(a[o]=await t.call(n||globalThis,await c[o],o,c));return a},yt.find=(c,t,n)=>new Promise((a,o)=>{if(c.length===0)return a();let s=1;for(let r=0;r<c.length;r++){const d=h=>{h?a(c[r]):s===c.length&&a(),s++};Promise.resolve(c[r]).then(h=>t.call(n||globalThis,h,r,c)).then(d).catch(o)}}),yt.findSeries=async(c,t,n)=>{for(let a=0;a<c.length;a++)if(await t.call(n||globalThis,await c[a],a,c))return c[a]},yt.findIndex=(c,t,n)=>new Promise((a,o)=>{if(c.length===0)return a(-1);let s=1;for(let r=0;r<c.length;r++){const d=h=>{h?a(r):s===c.length&&a(-1),s++};Promise.resolve(c[r]).then(h=>t.call(n||globalThis,h,r,c)).then(d).catch(o)}}),yt.findIndexSeries=async(c,t,n)=>{for(let a=0;a<c.length;a++)if(await t.call(n||globalThis,await c[a],a,c))return a},yt.some=(c,t,n)=>new Promise((a,o)=>{if(c.length===0)return a(!1);let s=1;for(let r=0;r<c.length;r++){if(!(r in c)){s++;continue}const d=h=>{h?a(!0):s===c.length&&a(!1),s++};Promise.resolve(c[r]).then(h=>t.call(n||globalThis,h,r,c)).then(d).catch(o)}}),yt.someSeries=async(c,t,n)=>{for(let a=0;a<c.length;a++)if(a in c&&await t.call(n||globalThis,await c[a],a,c))return!0;return!1},yt.every=(c,t,n)=>new Promise((a,o)=>{if(c.length===0)return a(!0);let s=1;for(let r=0;r<c.length;r++){if(!(r in c)){s++;continue}const d=h=>{h?s===c.length&&a(!0):a(!1),s++};Promise.resolve(c[r]).then(h=>t.call(n||globalThis,h,r,c)).then(d).catch(o)}}),yt.everySeries=async(c,t,n)=>{for(let a=0;a<c.length;a++)if(a in c&&!await t.call(n||globalThis,await c[a],a,c))return!1;return!0},yt.filter=(c,t,n)=>new Promise(async(a,o)=>{const s=[];for(let d=0;d<c.length;d++)d in c&&(s[d]=Promise.resolve(c[d]).then(h=>t.call(n||globalThis,h,d,c)).catch(o));const r=[];for(let d=0;d<s.length;d++)await s[d]&&r.push(await c[d]);a(r)}),yt.filterSeries=async(c,t,n)=>{const a=[];for(let o=0;o<c.length;o++)o in c&&await t.call(n||globalThis,await c[o],o,c)&&a.push(await c[o]);return a},yt.reduce=async(c,t,n)=>{if(c.length===0&&n===void 0)throw TypeError("Reduce of empty array with no initial value");let a,o;for(n!==void 0?(o=n,a=0):(o=c[0],a=1),a;a<c.length;a++)a in c&&(o=await t(await o,await c[a],a,c));return o};var Sh={};(function(c){const t=yt;Object.keys(t).forEach(n=>{const a=n.charAt(0).toUpperCase()+n.slice(1);c[`async${a}`]=async function(...o){return t[n](this,...o)}})})(Sh);var zT=Object.assign(yt,{instanceMethods:Sh});const Qt={NEW_CALL:"new_call",CALL_CONFIRMED:"confirmed",CALL_FAILED:"failed",CALL_PROGRESS:"progress",CALL_ENDED:"ended"};var XT={exports:{}};(function(c){var t=function(n){var a=Object.prototype,o=a.hasOwnProperty,s=Object.defineProperty||function(ee,Y,G){ee[Y]=G.value},r,d=typeof Symbol=="function"?Symbol:{},h=d.iterator||"@@iterator",_=d.asyncIterator||"@@asyncIterator",g=d.toStringTag||"@@toStringTag";function T(ee,Y,G){return Object.defineProperty(ee,Y,{value:G,enumerable:!0,configurable:!0,writable:!0}),ee[Y]}try{T({},"")}catch{T=function(Y,G,re){return Y[G]=re}}function S(ee,Y,G,re){var ge=Y&&Y.prototype instanceof ie?Y:ie,be=Object.create(ge.prototype),ke=new x(re||[]);return s(be,"_invoke",{value:J(ee,G,ke)}),be}n.wrap=S;function E(ee,Y,G){try{return{type:"normal",arg:ee.call(Y,G)}}catch(re){return{type:"throw",arg:re}}}var C="suspendedStart",A="suspendedYield",R="executing",k="completed",M={};function ie(){}function N(){}function j(){}var Ee={};T(Ee,h,function(){return this});var ve=Object.getPrototypeOf,L=ve&&ve(ve(se([])));L&&L!==a&&o.call(L,h)&&(Ee=L);var D=j.prototype=ie.prototype=Object.create(Ee);N.prototype=j,s(D,"constructor",{value:j,configurable:!0}),s(j,"constructor",{value:N,configurable:!0}),N.displayName=T(j,g,"GeneratorFunction");function B(ee){["next","throw","return"].forEach(function(Y){T(ee,Y,function(G){return this._invoke(Y,G)})})}n.isGeneratorFunction=function(ee){var Y=typeof ee=="function"&&ee.constructor;return Y?Y===N||(Y.displayName||Y.name)==="GeneratorFunction":!1},n.mark=function(ee){return Object.setPrototypeOf?Object.setPrototypeOf(ee,j):(ee.__proto__=j,T(ee,g,"GeneratorFunction")),ee.prototype=Object.create(D),ee},n.awrap=function(ee){return{__await:ee}};function q(ee,Y){function G(be,ke,Re,ae){var ye=E(ee[be],ee,ke);if(ye.type==="throw")ae(ye.arg);else{var lt=ye.arg,ot=lt.value;return ot&&typeof ot=="object"&&o.call(ot,"__await")?Y.resolve(ot.__await).then(function(Se){G("next",Se,Re,ae)},function(Se){G("throw",Se,Re,ae)}):Y.resolve(ot).then(function(Se){lt.value=Se,Re(lt)},function(Se){return G("throw",Se,Re,ae)})}}var re;function ge(be,ke){function Re(){return new Y(function(ae,ye){G(be,ke,ae,ye)})}return re=re?re.then(Re,Re):Re()}s(this,"_invoke",{value:ge})}B(q.prototype),T(q.prototype,_,function(){return this}),n.AsyncIterator=q,n.async=function(ee,Y,G,re,ge){ge===void 0&&(ge=Promise);var be=new q(S(ee,Y,G,re),ge);return n.isGeneratorFunction(Y)?be:be.next().then(function(ke){return ke.done?ke.value:be.next()})};function J(ee,Y,G){var re=C;return function(be,ke){if(re===R)throw new Error("Generator is already running");if(re===k){if(be==="throw")throw ke;return it()}for(G.method=be,G.arg=ke;;){var Re=G.delegate;if(Re){var ae=F(Re,G);if(ae){if(ae===M)continue;return ae}}if(G.method==="next")G.sent=G._sent=G.arg;else if(G.method==="throw"){if(re===C)throw re=k,G.arg;G.dispatchException(G.arg)}else G.method==="return"&&G.abrupt("return",G.arg);re=R;var ye=E(ee,Y,G);if(ye.type==="normal"){if(re=G.done?k:A,ye.arg===M)continue;return{value:ye.arg,done:G.done}}else ye.type==="throw"&&(re=k,G.method="throw",G.arg=ye.arg)}}}function F(ee,Y){var G=Y.method,re=ee.iterator[G];if(re===r)return Y.delegate=null,G==="throw"&&ee.iterator.return&&(Y.method="return",Y.arg=r,F(ee,Y),Y.method==="throw")||G!=="return"&&(Y.method="throw",Y.arg=new TypeError("The iterator does not provide a '"+G+"' method")),M;var ge=E(re,ee.iterator,Y.arg);if(ge.type==="throw")return Y.method="throw",Y.arg=ge.arg,Y.delegate=null,M;var be=ge.arg;if(!be)return Y.method="throw",Y.arg=new TypeError("iterator result is not an object"),Y.delegate=null,M;if(be.done)Y[ee.resultName]=be.value,Y.next=ee.nextLoc,Y.method!=="return"&&(Y.method="next",Y.arg=r);else return be;return Y.delegate=null,M}B(D),T(D,g,"Generator"),T(D,h,function(){return this}),T(D,"toString",function(){return"[object Generator]"});function Z(ee){var Y={tryLoc:ee[0]};1 in ee&&(Y.catchLoc=ee[1]),2 in ee&&(Y.finallyLoc=ee[2],Y.afterLoc=ee[3]),this.tryEntries.push(Y)}function U(ee){var Y=ee.completion||{};Y.type="normal",delete Y.arg,ee.completion=Y}function x(ee){this.tryEntries=[{tryLoc:"root"}],ee.forEach(Z,this),this.reset(!0)}n.keys=function(ee){var Y=Object(ee),G=[];for(var re in Y)G.push(re);return G.reverse(),function ge(){for(;G.length;){var be=G.pop();if(be in Y)return ge.value=be,ge.done=!1,ge}return ge.done=!0,ge}};function se(ee){if(ee){var Y=ee[h];if(Y)return Y.call(ee);if(typeof ee.next=="function")return ee;if(!isNaN(ee.length)){var G=-1,re=function ge(){for(;++G<ee.length;)if(o.call(ee,G))return ge.value=ee[G],ge.done=!1,ge;return ge.value=r,ge.done=!0,ge};return re.next=re}}return{next:it}}n.values=se;function it(){return{value:r,done:!0}}return x.prototype={constructor:x,reset:function(ee){if(this.prev=0,this.next=0,this.sent=this._sent=r,this.done=!1,this.delegate=null,this.method="next",this.arg=r,this.tryEntries.forEach(U),!ee)for(var Y in this)Y.charAt(0)==="t"&&o.call(this,Y)&&!isNaN(+Y.slice(1))&&(this[Y]=r)},stop:function(){this.done=!0;var ee=this.tryEntries[0],Y=ee.completion;if(Y.type==="throw")throw Y.arg;return this.rval},dispatchException:function(ee){if(this.done)throw ee;var Y=this;function G(ae,ye){return be.type="throw",be.arg=ee,Y.next=ae,ye&&(Y.method="next",Y.arg=r),!!ye}for(var re=this.tryEntries.length-1;re>=0;--re){var ge=this.tryEntries[re],be=ge.completion;if(ge.tryLoc==="root")return G("end");if(ge.tryLoc<=this.prev){var ke=o.call(ge,"catchLoc"),Re=o.call(ge,"finallyLoc");if(ke&&Re){if(this.prev<ge.catchLoc)return G(ge.catchLoc,!0);if(this.prev<ge.finallyLoc)return G(ge.finallyLoc)}else if(ke){if(this.prev<ge.catchLoc)return G(ge.catchLoc,!0)}else if(Re){if(this.prev<ge.finallyLoc)return G(ge.finallyLoc)}else throw new Error("try statement without catch or finally")}}},abrupt:function(ee,Y){for(var G=this.tryEntries.length-1;G>=0;--G){var re=this.tryEntries[G];if(re.tryLoc<=this.prev&&o.call(re,"finallyLoc")&&this.prev<re.finallyLoc){var ge=re;break}}ge&&(ee==="break"||ee==="continue")&&ge.tryLoc<=Y&&Y<=ge.finallyLoc&&(ge=null);var be=ge?ge.completion:{};return be.type=ee,be.arg=Y,ge?(this.method="next",this.next=ge.finallyLoc,M):this.complete(be)},complete:function(ee,Y){if(ee.type==="throw")throw ee.arg;return ee.type==="break"||ee.type==="continue"?this.next=ee.arg:ee.type==="return"?(this.rval=this.arg=ee.arg,this.method="return",this.next="end"):ee.type==="normal"&&Y&&(this.next=Y),M},finish:function(ee){for(var Y=this.tryEntries.length-1;Y>=0;--Y){var G=this.tryEntries[Y];if(G.finallyLoc===ee)return this.complete(G.completion,G.afterLoc),U(G),M}},catch:function(ee){for(var Y=this.tryEntries.length-1;Y>=0;--Y){var G=this.tryEntries[Y];if(G.tryLoc===ee){var re=G.completion;if(re.type==="throw"){var ge=re.arg;U(G)}return ge}}throw new Error("illegal catch attempt")},delegateYield:function(ee,Y,G){return this.delegate={iterator:se(ee),resultName:Y,nextLoc:G},this.method==="next"&&(this.arg=r),M}},n}(c.exports);try{regeneratorRuntime=t}catch{typeof globalThis=="object"?globalThis.regeneratorRuntime=t:Function("r","regeneratorRuntime = r")(t)}})(XT);var Eh={exports:{}};(function(c){(function(t,n){c.exports?c.exports=n():t.log=n()})(Mt,function(){var t=function(){},n="undefined",a=typeof window!==n&&typeof window.navigator!==n&&/Trident\/|MSIE /.test(window.navigator.userAgent),o=["trace","debug","info","warn","error"];function s(A,R){var k=A[R];if(typeof k.bind=="function")return k.bind(A);try{return Function.prototype.bind.call(k,A)}catch{return function(){return Function.prototype.apply.apply(k,[A,arguments])}}}function r(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function d(A){return A==="debug"&&(A="log"),typeof console===n?!1:A==="trace"&&a?r:console[A]!==void 0?s(console,A):console.log!==void 0?s(console,"log"):t}function h(A,R){for(var k=0;k<o.length;k++){var M=o[k];this[M]=k<A?t:this.methodFactory(M,A,R)}this.log=this.debug}function _(A,R,k){return function(){typeof console!==n&&(h.call(this,R,k),this[A].apply(this,arguments))}}function g(A,R,k){return d(A)||_.apply(this,arguments)}function T(A,R,k){var M=this,ie;R=R??"WARN";var N="loglevel";typeof A=="string"?N+=":"+A:typeof A=="symbol"&&(N=void 0);function j(D){var B=(o[D]||"silent").toUpperCase();if(!(typeof window===n||!N)){try{window.localStorage[N]=B;return}catch{}try{window.document.cookie=encodeURIComponent(N)+"="+B+";"}catch{}}}function Ee(){var D;if(!(typeof window===n||!N)){try{D=window.localStorage[N]}catch{}if(typeof D===n)try{var B=window.document.cookie,q=B.indexOf(encodeURIComponent(N)+"=");q!==-1&&(D=/^([^;]+)/.exec(B.slice(q))[1])}catch{}return M.levels[D]===void 0&&(D=void 0),D}}function ve(){if(!(typeof window===n||!N)){try{window.localStorage.removeItem(N);return}catch{}try{window.document.cookie=encodeURIComponent(N)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}M.name=A,M.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},M.methodFactory=k||g,M.getLevel=function(){return ie},M.setLevel=function(D,B){if(typeof D=="string"&&M.levels[D.toUpperCase()]!==void 0&&(D=M.levels[D.toUpperCase()]),typeof D=="number"&&D>=0&&D<=M.levels.SILENT){if(ie=D,B!==!1&&j(D),h.call(M,D,A),typeof console===n&&D<M.levels.SILENT)return"No console available for logging"}else throw"log.setLevel() called with invalid level: "+D},M.setDefaultLevel=function(D){R=D,Ee()||M.setLevel(D,!1)},M.resetLevel=function(){M.setLevel(R,!1),ve()},M.enableAll=function(D){M.setLevel(M.levels.TRACE,D)},M.disableAll=function(D){M.setLevel(M.levels.SILENT,D)};var L=Ee();L==null&&(L=R),M.setLevel(L,!1)}var S=new T,E={};S.getLogger=function(R){if(typeof R!="symbol"&&typeof R!="string"||R==="")throw new TypeError("You must supply a name when creating a logger.");var k=E[R];return k||(k=E[R]=new T(R,S.getLevel(),S.methodFactory)),k};var C=typeof window!==n?window.log:void 0;return S.noConflict=function(){return typeof window!==n&&window.log===S&&(window.log=C),S},S.getLoggers=function(){return E},S.default=S,S})})(Eh);var It=Eh.exports;const Ss=()=>`${new Date().toISOString()} | metrics`,Es=(c,t,n)=>`${c} | ${t} | ${n}`;It.setDefaultLevel(It.levels.TRACE);const QT=c=>{It.info(Es(Ss(),"log ",`set log level to ${c?"verbose":"info"}`)),It.setLevel(c?It.levels.TRACE:It.levels.INFO)},ZT=c=>{const t=[...Object.keys(It.levels)];t.includes(c)?(It.info(Es(Ss(),"log ",`update log level to ${c.toLowerCase()}`)),It.setLevel(c)):It.warn(Es(Ss(),"log ","Incorrect log level please choose one of "),t)},xe=(c,t,n)=>{n?It.debug(Es(Ss(),c,t),n):It.debug(Es(Ss(),c,t))},Iu=(c,t)=>{It.info(Es(Ss(),c,t))},an=(c,t)=>{It.info(Es(Ss(),c,t))},Ca=(c,t)=>{It.warn(Es(Ss(),c,t))},Vn=(c,t)=>{It.error(Es(Ss(),c,t))};function ev(c){return Math.floor(Math.random()*c).toString()}function yh(c,t){let n=t;return c.forEach(a=>{n=n.replace(a,"")}),n}function tv(c,t){let n="";for(let a=0;a<t;a+=1)n+=c[ev(c.length)];return n}function sv({length:c=20,useLetters:t=!0,useNumbers:n=!0,includeSymbols:a=[],excludeSymbols:o=[]}={}){let s="abcdefghijklmnopqrstuvwxyz",r="0123456789",d=[],h=[],_=[];return t&&(o.length&&(s=yh(o,s)),h=s.split("")),n&&(o.length&&(r=yh(o,r)),_=r.split("")),d=[...h,..._,...a],tv(d,c)}var nv=sv;const ni=Me(nv),rv=()=>"WebRTCMetrics",iv=()=>"5.0.3",$e={INBOUND:"inbound",OUTBOUND:"outbound"},ys={IDLE:"idle",RUNNING:"running",MUTED:"muted"},ri={NEW:"new",CHECKING:"checking",CONNECTED:"connected",COMPLETED:"completed",DISCONNECTED:"disconnected",FAILED:"failed",CLOSED:"closed"},lv=()=>({...{delta_time_to_measure_probes_ms:0,delta_time_consumed_to_measure_ms:0,delta_KBytes_in:0,delta_KBytes_out:0,delta_kbs_in:0,delta_kbs_out:0,total_time_decoded_in:0,total_time_encoded_out:0,probes:[]}}),Ch={level_in:0,codec_id_in:"",codec_in:{mime_type:null,clock_rate:null,sdp_fmtp_line:null},delta_jitter_ms_in:0,percent_packets_lost_in:0,delta_packets_in:0,delta_packets_lost_in:0,total_packets_in:0,total_packets_lost_in:0,total_KBytes_in:0,delta_KBytes_in:0,delta_kbs_in:0,mos_in:0,mos_emodel_in:0,ssrc:"",direction:$e.INBOUND},Ah={level_out:0,codec_id_out:"",codec_out:{mime_type:null,clock_rate:null,sdp_fmtp_line:null},delta_jitter_ms_out:0,delta_rtt_ms_out:null,total_rtt_ms_out:0,total_rtt_measure_out:0,percent_packets_lost_out:0,delta_packets_out:0,delta_packets_lost_out:0,total_packets_out:0,total_packets_lost_out:0,total_KBytes_out:0,delta_KBytes_out:0,delta_kbs_out:0,timestamp_out:null,mos_out:0,mos_emodel_out:0,ssrc:"",direction:$e.OUTBOUND},Rh={codec_id_in:"",size_in:{width:null,height:null,framerate:null},codec_in:{mime_type:null,clock_rate:null},delta_jitter_ms_in:0,percent_packets_lost_in:0,delta_packets_in:0,delta_packets_lost_in:0,total_packets_in:0,total_packets_lost_in:0,total_KBytes_in:0,delta_KBytes_in:0,delta_kbs_in:0,decoder_in:null,delta_ms_decode_frame_in:0,total_frames_decoded_in:0,total_time_decoded_in:0,delta_nack_sent_in:0,delta_pli_sent_in:0,total_nack_sent_in:0,total_pli_sent_in:0,ssrc:"",direction:$e.INBOUND},Ih={codec_id_out:"",size_out:{width:null,height:null,framerate:null},codec_out:{mime_type:null,clock_rate:null},delta_jitter_ms_out:0,delta_rtt_ms_out:null,total_rtt_ms_out:0,total_rtt_measure_out:0,percent_packets_lost_out:0,delta_packets_out:0,delta_packets_lost_out:0,total_packets_out:0,total_packets_lost_out:0,total_KBytes_out:0,delta_KBytes_out:0,delta_kbs_out:0,encoder_out:null,delta_ms_encode_frame_out:0,total_time_encoded_out:0,total_frames_encoded_out:0,delta_nack_received_out:0,delta_pli_received_out:0,total_nack_received_out:0,total_pli_received_out:0,limitation_out:{reason:null,durations:null,resolutionChanges:0},timestamp_out:null,ssrc:"",direction:$e.OUTBOUND},av=c=>{const t={pname:"",call_id:"",user_id:"",timestamp:null,count:0,audio:{},video:{},network:{infrastructure:3,local_candidate_id:"",local_candidate_type:"",local_candidate_protocol:"",local_candidate_relay_protocol:"",remote_candidate_id:"",remote_candidate_type:"",remote_candidate_protocol:""},data:{total_KBytes_in:0,total_KBytes_out:0,delta_KBytes_in:0,delta_KBytes_out:0,delta_kbs_in:0,delta_kbs_out:0,delta_kbs_bandwidth_in:0,delta_kbs_bandwidth_out:0,delta_rtt_connectivity_ms:null,total_rtt_connectivity_ms:0,total_rtt_connectivity_measure:0},experimental:{time_to_measure_ms:0}};if(c){const n={...c,audio:{},video:{},data:{...c.data},network:{...c.network},experimental:{...c.experimental}};return Object.keys(c.audio).forEach(a=>{n.audio[a]={...c.audio[a]}}),Object.keys(c.video).forEach(a=>{n.video[a]={...c.video[a]}}),n}return{...t,audio:{},video:{},data:{...t.data},network:{...t.network},experimental:{...t.experimental}}},ov={refreshEvery:2e3,startAfter:0,stopAfter:-1,verbose:!1,pname:`p-${ni()}`,cid:`c-${ni()}`,uid:`u-${ni()}`,record:!1,ticket:!0},Zt={CANDIDATE_PAIR:"candidate-pair",CODEC:"codec",INBOUND_RTP:"inbound-rtp",LOCAL_CANDIDATE:"local-candidate",MEDIA_SOURCE:"media-source",OUTBOUND_RTP:"outbound-rtp",REMOTE_CANDIDATE:"remote-candidate",REMOTE_INBOUND_RTP:"remote-inbound-rtp",TRACK:"track"},V={AUDIO_LEVEL:"audioLevel",AVAILABLE_OUTGOING_BITRATE:"availableOutgoingBitrate",AVAILABLE_INCOMING_BITRATE:"availableIncomingBitrate",BYTES_RECEIVED:"bytesReceived",BYTES_SENT:"bytesSent",CANDIDATE_TYPE:"candidateType",CHANNELS:"channels",CLOCK_RATE:"clockRate",CODEC_ID:"codecId",CURRENT_ROUND_TRIP_TIME:"currentRoundTripTime",ROUND_TRIP_TIME:"roundTripTime",FRACTION_LOST:"fractionLost",FRAME_HEIGHT:"frameHeight",FRAME_WIDTH:"frameWidth",QUALITY_LIMITATION_REASON:"qualityLimitationReason",QUALITY_LIMITATION_DURATIONS:"qualityLimitationDurations",QUALITY_LIMITATION_RESOLUTION_CHANGES:"qualityLimitationResolutionChanges",ID:"id",JITTER:"jitter",KIND:"kind",MEDIA_TYPE:"mediaType",MIME_TYPE:"mimeType",LOCAL_CANDIDATE_ID:"localCandidateId",NETWORK_TYPE:"networkType",RELAY_PROTOCOL:"relayProtocol",NOMINATED:"nominated",PACKETS_LOST:"packetsLost",PACKETS_RECEIVED:"packetsReceived",PACKETS_SENT:"packetsSent",PROTOCOL:"protocol",PORT:"port",REMOTE_CANDIDATE_ID:"remoteCandidateId",REMOTE_SOURCE:"remoteSource",RESPONSES_RECEIVED:"responsesReceived",SDP_FMTP_LINE:"sdpFmtpLine",SSRC:"ssrc",SELECTED:"selected",STATE:"state",TIMESTAMP:"timestamp",TOTAL_ROUND_TRIP_TIME:"totalRoundTripTime",TOTAL_ROUND_TRIP_TIME_MEASUREMENTS:"roundTripTimeMeasurements",TYPE:"type",DECODER_IMPLEMENTATION:"decoderImplementation",ENCODER_IMPLEMENTATION:"encoderImplementation",FRAMES_DECODED:"framesDecoded",FRAMES_ENCODED:"framesEncoded",FRAMES_PER_SECOND:"framesPerSecond",TOTAL_DECODE_TIME:"totalDecodeTime",TOTAL_ENCODE_TIME:"totalEncodeTime",PLI:"pliCount",NACK:"nackCount"},P={SUCCEEDED:"succeeded",AUDIO:"audio",VIDEO:"video"},ii={ETHERNET:0,CELLULAR_5G:2,WIFI:3,CELLULAR_4G:5,CELLULAR:10},bu={ETHERNET:"ethernet",CELLULAR_4G:"cellular",WIFI:"wifi"},ne={AUDIO:"audio",VIDEO:"video",NETWORK:"network",DATA:"data"},wu="config ",uv=(c,t={},n)=>{const a={...n,...t};return t.pname||Ca(wu,`Argument [String] 'cfg.pname' for the peerConnection name or id is missing - use generated '${n.pname}'`),t.cid||Ca(wu,`Argument [String] 'cfg.cid' for the call name or id is missing - use generated '${n.cid}'`),t.uid||Ca(wu,`Argument [String] 'cfg.uid' for the user name or id is missing - use generated '${n.uid}'`),a.pc=c,a},cv=(c={})=>{const t={...ov,...c};return t.name=rv(),t.version=iv(),t},li=(c,t,n,a=!1,o)=>{let s=c.map(r=>{if(!n)return r[t];if(!o)return r[t][n];const d=r[t][o];return d?d[n]:null});return s=s.filter(r=>a?Number.isFinite(r)&&r>0:Number.isFinite(r)),s.length===0?[]:s},Ms=c=>c.reduce((t,n)=>t+n,0)/c.length,fv=()=>`probe-${ni()}`,hv=()=>`coltr-${ni()}`,bh=c=>new Promise(t=>setTimeout(t,c)),Ou=(c,t,n)=>{t?c.call(t,n):c(n)},We=(c,t,n,a)=>{const o=li(c,t,n,!0,a);if(o.length===0)return null;const s=o.reduce((_,g)=>_+g,0)/o.length;return s===0?null:o.map(_=>Math.abs(s-_)).reduce((_,g)=>_+g,0)/o.length*100/s},Xe=(c,t,n,a=!1,o)=>{const s=li(c,t,n,a,o);return s.length===0?null:s.reduce((r,d)=>r+d,0)/s.length},on=(c,t,n)=>li(c,t,n).reduce((o,s)=>o+s,0),Ke=(c,t,n,a)=>{const o=li(c,t,n,!0,a);return o.length===0?null:Math.min(...o)},Ye=(c,t,n,a)=>{const o=li(c,t,n,!1,a);return o.length===0?null:Math.max(...o)},Ct=(c,t,n,a)=>{const o=c.slice().pop();if(!o)return null;if(!n)return o[t];if(!a)return o[t][n];const s=o[t][a];return s?s[n]:null},dv=c=>c.slice().pop(),ht=(c,t,n)=>{if(!t)return null;const a={};let o=t[P.AUDIO][c];o||(o=n===$e.INBOUND?{...Ch}:{...Ah}),a[P.AUDIO]=o;let s=t[P.VIDEO][c];return s||(s=n===$e.INBOUND?{...Rh}:{...Ih}),a[P.VIDEO]=s,a},ai="exporter ",_v="2.0",wh=(c,t,n)=>{if(!c||c.length===0)return 0;const a=c[c.length-1];if(!a)return 0;const o=a[t][n];if(o){const s=o.total_rtt_ms_out,r=o.total_rtt_measure_out;return!r||!s?Xe(c,t,"delta_rtt_ms_out",!1,n):Number(s/r)}return null},pv=(c,t)=>{if(!c||c.length===0)return 0;const n=c[c.length-1];if(!n)return 0;const a=n[t].total_rtt_connectivity_ms,o=n[t].total_rtt_connectivity_measure;return!o||!a?Xe(c,t,"delta_rtt_connectivity_ms"):Number(a/o)},mv=c=>Ct(c,"network","local_candidate_type")!=="relay"?`direct/${Ct(c,"network","local_candidate_protocol")}`:`turn/${Ct(c,"network","local_candidate_relay_protocol")}`,gv=c=>{const t=Ct(c,"network","remote_candidate_type"),n=Ct(c,"network","remote_candidate_protocol");return t!=="relay"?`direct/${n}`:`turn/${n}`};class Tv{constructor(t){this._start=null,this._end=null,this._cfg=t,this._referenceReport=null,this._reports=[],this._events=[]}start(){Iu(ai,"start() - start exporter...");const t=new Date;return this._start=t.toJSON(),t}stop(){Iu(ai,"stop() - stop exporter...");const t=new Date;return this._end=t.toJSON(),t}saveReferenceReport(t){this._referenceReport=t}getReferenceReport(){return this._referenceReport}addReport(t){this._cfg.ticket&&(xe(ai,`addReport() - add report to exporter at ${t.timestamp}`),this._reports.push(t))}addCustomEvent(t){this._events.push(t)}reset(){Iu(ai,"resetReports() - reset reports"),this._reports=[],this._referenceReport=null,this._start=null,this._end=null}get ticket(){xe(ai,"ticket() - generate ticket");const t=Ct(this._reports,"audio","total_packets_lost_in"),n=Ct(this._reports,"audio","total_packets_in"),a=Ct(this._reports,"video","total_packets_lost_in"),o=Ct(this._reports,"video","total_packets_in"),s={},r=dv(this._reports);return r&&(Object.keys(r[P.AUDIO]).forEach(d=>{const h=r[P.AUDIO][d];if(s[h.ssrc]={type:P.AUDIO,direction:h.direction},h.direction===$e.INBOUND){const _={avg:Xe(this._reports,P.AUDIO,"delta_jitter_ms_in",!1,d),min:Ke(this._reports,P.AUDIO,"delta_jitter_ms_in",d),max:Ye(this._reports,P.AUDIO,"delta_jitter_ms_in",d),volatility:We(this._reports,P.AUDIO,"delta_jitter_ms_in",d),_unit:{avg:"ms",min:"ms",max:"ms",volatility:"percent"}},g={avg:Xe(this._reports,P.AUDIO,"delta_kbs_in",!1,d),min:Ke(this._reports,P.AUDIO,"delta_kbs_in",d),max:Ye(this._reports,P.AUDIO,"delta_kbs_in",d),volatility:We(this._reports,P.AUDIO,"delta_kbs_in",d),_unit:{avg:"kbs",min:"kbs",max:"kbs",volatility:"percent"}},T={avg:Xe(this._reports,P.AUDIO,"delta_KBytes_in",!1,d),min:Ke(this._reports,P.AUDIO,"delta_KBytes_in",d),max:Ye(this._reports,P.AUDIO,"delta_KBytes_in",d),volatility:We(this._reports,P.AUDIO,"delta_KBytes_in",d),_unit:{avg:"KB",min:"KB",max:"KB",volatility:"percent"}},S={emodel:{avg:Xe(this._reports,P.AUDIO,"mos_emodel_in",!1,d),min:Ke(this._reports,P.AUDIO,"mos_emodel_in",d),max:Ye(this._reports,P.AUDIO,"mos_emodel_in",d),volatility:We(this._reports,P.AUDIO,"mos_emodel_in",d)},effective:{avg:Xe(this._reports,P.AUDIO,"mos_in",!1,d),min:Ke(this._reports,P.AUDIO,"mos_in",d),max:Ye(this._reports,P.AUDIO,"mos_in",d),volatility:We(this._reports,P.AUDIO,"mos_in",d)},_unit:{avg:"number (1-5)",min:"number (1-5)",max:"number (1-5)",volatility:"percent"}},E=Ct(this._reports,P.AUDIO,"total_packets_lost_in",d),C=Ct(this._reports,P.AUDIO,"total_packets_in",d),A={lost:E,avg:Math.round((E/(E+C)*100||0)*100)/100,_unit:{avg:"percent",lost:"number"}};s[d].jitter=_,s[d].mos=S,s[d].traffic=T,s[d].bitrate=g,s[d].loss=A}else{const _={avg:Xe(this._reports,P.AUDIO,"delta_jitter_ms_out",!1,d),min:Ke(this._reports,P.AUDIO,"delta_jitter_ms_out",d),max:Ye(this._reports,P.AUDIO,"delta_jitter_ms_out",d),volatility:We(this._reports,P.AUDIO,"delta_jitter_ms_out",d),_unit:{avg:"ms",min:"ms",max:"ms",volatility:"percent"}},g={avg:Xe(this._reports,P.AUDIO,"delta_kbs_out",!1,d),min:Ke(this._reports,P.AUDIO,"delta_kbs_out",d),max:Ye(this._reports,P.AUDIO,"delta_kbs_out",d),volatility:We(this._reports,P.AUDIO,"delta_kbs_out",d),_unit:{avg:"kbs",min:"kbs",max:"kbs",volatility:"percent"}},T={avg:Xe(this._reports,P.AUDIO,"delta_KBytes_out",!1,d),min:Ke(this._reports,P.AUDIO,"delta_KBytes_out",d),max:Ye(this._reports,P.AUDIO,"delta_KBytes_out",d),volatility:We(this._reports,P.AUDIO,"delta_KBytes_out",d),_unit:{avg:"KB",min:"KB",max:"KB",bitrate:"kbs",volatility:"percent"}},S={avg:wh(this._reports,P.AUDIO,d),min:Ke(this._reports,P.AUDIO,"delta_rtt_ms_out",d),max:Ye(this._reports,P.AUDIO,"delta_rtt_ms_out",d),volatility:We(this._reports,P.AUDIO,"delta_rtt_ms_out",d),_unit:{avg:"ms",min:"ms",max:"ms",volatility:"percent"}},E=Ct(this._reports,P.AUDIO,"total_packets_lost_out",d),C=Ct(this._reports,P.AUDIO,"total_packets_out",d),A={lost:E,avg:Math.round((E/(E+C)*100||0)*100)/100,_unit:{avg:"percent",lost:"number"}},R={emodel:{avg:Xe(this._reports,P.AUDIO,"mos_emodel_out",!1,d),min:Ke(this._reports,P.AUDIO,"mos_emodel_out",d),max:Ye(this._reports,P.AUDIO,"mos_emodel_out",d),volatility:We(this._reports,P.AUDIO,"mos_emodel_out",d)},effective:{avg:Xe(this._reports,P.AUDIO,"mos_out",!1,d),min:Ke(this._reports,P.AUDIO,"mos_out",d),max:Ye(this._reports,P.AUDIO,"mos_out",d),volatility:We(this._reports,P.AUDIO,"mos_out",d)},_unit:{avg:"number (1-5)",min:"number (1-5)",max:"number (1-5)",volatility:"percent"}};s[d].jitter=_,s[d].rtt=S,s[d].traffic=T,s[d].bitrate=g,s[d].loss=A,s[d].mos=R}}),Object.keys(r[P.VIDEO]).forEach(d=>{const h=r[P.VIDEO][d];if(s[d]={type:P.VIDEO,direction:h.direction},h.direction===$e.INBOUND){const _={avg:Xe(this._reports,P.VIDEO,"delta_jitter_ms_in",!1,d),min:Ke(this._reports,P.VIDEO,"delta_jitter_ms_in",d),max:Ye(this._reports,P.VIDEO,"delta_jitter_ms_in",d),volatility:We(this._reports,P.VIDEO,"delta_jitter_ms_in",d),_unit:{avg:"ms",min:"ms",max:"ms",volatility:"percent"}},g={avg:Xe(this._reports,P.VIDEO,"delta_kbs_in",!1,d),min:Ke(this._reports,P.VIDEO,"delta_kbs_in",d),max:Ye(this._reports,P.VIDEO,"delta_kbs_in",d),volatility:We(this._reports,P.VIDEO,"delta_kbs_in",d),_unit:{avg:"kbs",min:"kbs",max:"kbs",volatility:"percent"}},T={avg:Xe(this._reports,P.VIDEO,"delta_KBytes_in",!1,d),min:Ke(this._reports,P.VIDEO,"delta_KBytes_in",d),max:Ye(this._reports,P.VIDEO,"delta_KBytes_in",d),volatility:We(this._reports,P.VIDEO,"delta_KBytes_in",d),_unit:{avg:"KB",min:"KB",max:"KB",volatility:"percent"}},S=Ct(this._reports,P.VIDEO,"total_packets_lost_in",d),E=Ct(this._reports,P.VIDEO,"total_packets_in",d),C={lost:S,avg:Math.round((S/(S+E)*100||0)*100)/100,_unit:{avg:"percent",lost:"number"}};s[d].jitter=_,s[d].traffic=T,s[d].bitrate=g,s[d].loss=C}else{const _={avg:Xe(this._reports,P.VIDEO,"delta_jitter_ms_out",!1,d),min:Ke(this._reports,P.VIDEO,"delta_jitter_ms_out",d),max:Ye(this._reports,P.VIDEO,"delta_jitter_ms_out",d),volatility:We(this._reports,P.VIDEO,"delta_jitter_ms_out",d),_unit:{avg:"ms",min:"ms",max:"ms",volatility:"percent"}},g={avg:Xe(this._reports,P.VIDEO,"delta_kbs_out",!1,d),min:Ke(this._reports,P.VIDEO,"delta_kbs_out",d),max:Ye(this._reports,P.VIDEO,"delta_kbs_out",d),volatility:We(this._reports,P.VIDEO,"delta_kbs_out",d),_unit:{avg:"kbs",min:"kbs",max:"kbs",volatility:"percent"}},T={avg:Xe(this._reports,P.VIDEO,"delta_KBytes_out",!1,d),min:Ke(this._reports,P.VIDEO,"delta_KBytes_out",d),max:Ye(this._reports,P.VIDEO,"delta_KBytes_out",d),volatility:We(this._reports,P.VIDEO,"delta_KBytes_out",d),_unit:{avg:"KB",min:"KB",max:"KB",volatility:"percent"}},S={avg:wh(this._reports,P.VIDEO,d),min:Ke(this._reports,P.VIDEO,"delta_rtt_ms_out",d),max:Ye(this._reports,P.VIDEO,"delta_rtt_ms_out",d),volatility:We(this._reports,P.VIDEO,"delta_rtt_ms_out",d),_unit:{avg:"ms",min:"ms",max:"ms",volatility:"percent"}},E=Ct(this._reports,P.VIDEO,"total_packets_lost_out",d),C=Ct(this._reports,P.VIDEO,"total_packets_out",d),A={lost:E,avg:Math.round((E/(E+C)*100||0)*100)/100,_unit:{avg:"percent",lost:"number"}};s[d].jitter=_,s[d].rtt=S,s[d].traffic=T,s[d].bitrate=g,s[d].loss=A}})),{version:_v,configuration:{frequency:this._cfg.refreshEvery},started:this._start,ended:this._end,ua:{agent:navigator.userAgent,pname:this._cfg.pname,user_id:this._cfg.uid},call:{call_id:this._cfg.cid,events:this._events},details:{count:this._reports.length,reports:this._cfg.record?this._reports:[],reference:this._referenceReport||null},ssrc:s,data:{rtt:{avg:pv(this._reports,"data"),min:Ke(this._reports,"data","delta_rtt_connectivity_ms"),max:Ye(this._reports,"data","delta_rtt_connectivity_ms"),volatility:We(this._reports,"data","delta_rtt_connectivity_ms"),_unit:{avg:"ms",min:"ms",max:"ms",volatility:"percent"}},packetsLost:{audio:{in:{avg:Math.round((t/(t+n)*100||0)*100)/100}},video:{in:{avg:Math.round((a/(a+o)*100||0)*100)/100}},unit:{avg:"percent"}},bitrate:{in:{avg:Xe(this._reports,"data","delta_kbs_in"),min:Ke(this._reports,"data","delta_kbs_in"),max:Ye(this._reports,"data","delta_kbs_in"),volatility:We(this._reports,"data","delta_kbs_in")},out:{avg:Xe(this._reports,"data","delta_kbs_out"),min:Ke(this._reports,"data","delta_kbs_out"),max:Ye(this._reports,"data","delta_kbs_out"),volatility:We(this._reports,"data","delta_kbs_out")},unit:{avg:"kbs",min:"kbs",max:"kbs",volatility:"percent"}},traffic:{in:{avg:Xe(this._reports,"data","delta_KBytes_in"),min:Ke(this._reports,"data","delta_KBytes_in"),max:Ye(this._reports,"data","delta_KBytes_in"),volatility:We(this._reports,"data","delta_KBytes_in")},out:{avg:Xe(this._reports,"data","delta_KBytes_out"),min:Ke(this._reports,"data","delta_KBytes_out"),max:Ye(this._reports,"data","delta_KBytes_out"),volatility:We(this._reports,"data","delta_KBytes_out")},unit:{avg:"KBytes",min:"KBytes",max:"KBytes",volatility:"percent"}},network:{localConnection:mv(this._reports),remoteConnection:gv(this._reports)}}}}updateConfig(t){this._cfg=t}getLastReport(){return this._reports.slice().pop()||null}getBeforeLastReport(){const t=this._reports.slice();return t.pop(),t.pop()||null}getReportsNumber(){return this._reports.length}}const Ls="extractor ",Oh=(c,t,n,a)=>{let o=!1;const s=a[t].total_rtt_ms_out,r=a[t].total_rtt_measure_out,d=n?n[t].total_rtt_ms_out:0,h=n?n[t].total_rtt_measure_out:0,_={rtt:null,totalRTT:s,totalRTTMeasurements:r};if(c[V.TIMESTAMP]===a[t].timestamp_out||!Object.prototype.hasOwnProperty.call(c,V.ROUND_TRIP_TIME)||Object.prototype.hasOwnProperty.call(c,V.TOTAL_ROUND_TRIP_TIME_MEASUREMENTS)&&(o=!0,Number(c[V.TOTAL_ROUND_TRIP_TIME_MEASUREMENTS])===0||Number(c[V.TOTAL_ROUND_TRIP_TIME_MEASUREMENTS])-h===r))return _;const g=1e3*Number(c[V.ROUND_TRIP_TIME]);let T=s+g,S=r+1;return o&&(T=1e3*Number(c[V.TOTAL_ROUND_TRIP_TIME])-d,S=Number(c[V.TOTAL_ROUND_TRIP_TIME_MEASUREMENTS])-h),{rtt:g,totalRTT:T,totalRTTMeasurements:S}},vv=(c,t,n,a)=>{if(!Object.prototype.hasOwnProperty.call(c,V.CURRENT_ROUND_TRIP_TIME))return{rtt:null,totalRTT:a[t].total_rtt_connectivity_ms,totalRTTMeasurements:a[t].total_rtt_connectivity_measure};const o=1e3*Number(c[V.CURRENT_ROUND_TRIP_TIME]);let s=a[t].total_rtt_connectivity_ms+o,r=a[t].total_rtt_connectivity_measure+1;return Object.prototype.hasOwnProperty.call(c,V.TOTAL_ROUND_TRIP_TIME)&&(s=1e3*Number(c[V.TOTAL_ROUND_TRIP_TIME])-(n?n[t].total_rtt_connectivity_ms:0)),Object.prototype.hasOwnProperty.call(c,V.RESPONSES_RECEIVED)&&(r=Number(c[V.RESPONSES_RECEIVED])-(n?n[t].total_rtt_connectivity_measure:0)),{rtt:o,totalRTT:s,totalRTTMeasurements:r}},Aa=(c,t,n)=>c[V.TIMESTAMP]===n[t].timestamp_out||!Object.prototype.hasOwnProperty.call(c,V.JITTER)?null:1e3*(Number(c[V.JITTER])||0),Sv=(c,t)=>{if(!Object.prototype.hasOwnProperty.call(c,V.FRAMES_DECODED)||!Object.prototype.hasOwnProperty.call(c,V.TOTAL_DECODE_TIME))return{delta_ms_decode_frame:t[P.VIDEO].delta_ms_decode_frame_in,frames_decoded:t[P.VIDEO].total_frames_decoded_in,total_decode_time:t[P.VIDEO].total_time_decoded_in};const n=c[V.FRAMES_DECODED],a=c[V.TOTAL_DECODE_TIME],o=a-t[P.VIDEO].total_time_decoded_in,s=n-t[P.VIDEO].total_frames_decoded_in;return{delta_ms_decode_frame:s>0?o*1e3/s:0,frames_decoded:n,total_decode_time:a}},Ev=(c,t)=>{if(!Object.prototype.hasOwnProperty.call(c,V.FRAMES_ENCODED)||!Object.prototype.hasOwnProperty.call(c,V.TOTAL_ENCODE_TIME))return{delta_ms_encode_frame:t[P.VIDEO].delta_ms_encode_frame_out,frames_encoded:t[P.VIDEO].total_frames_encoded_out,total_encode_time:t[P.VIDEO].total_time_encoded_out};const n=c[V.FRAMES_ENCODED],a=c[V.TOTAL_ENCODE_TIME],o=a-t[P.VIDEO].total_time_encoded_out,s=n-t[P.VIDEO].total_frames_encoded_out;return{delta_ms_encode_frame:s>0&&o?o*1e3/s:0,frames_encoded:n,total_encode_time:a}},Dh=(c,t,n,a)=>{if(!Object.prototype.hasOwnProperty.call(c,V.PACKETS_SENT)||!Object.prototype.hasOwnProperty.call(c,V.BYTES_SENT))return{packetsSent:n[t].total_packets_out,packetsLost:n[t].total_packets_lost_out,bytesSent:n[t].total_KBytes_out};const o=Number(c[V.PACKETS_SENT])||0-(a?a[t].total_packets_out:0),s=o-n[t].total_packets_out,r=Number(c[V.BYTES_SENT])/1024-(a?a[t].total_KBytes_out:0),d=r-n[t].total_KBytes_out,h=c[V.TIMESTAMP]||Date.now(),_=a?a.timestamp:null;let g=n.timestamp;!g&&_&&(g=_);const T=g?h-g:0,S=T>0?d*.008*1024/T*1e3:0;return{packetsSent:o,deltaPacketsSent:s,KBytesSent:r,deltaKBytesSent:d,kbsSent:S}},Nh=(c,t,n,a)=>{let o=n[t].total_packets_lost_out,s=0,r=0;return Object.prototype.hasOwnProperty.call(c,V.PACKETS_LOST)&&(o=Number(c[V.PACKETS_LOST])||0-(a?a[t].total_packets_lost_out:0),s=o-n[t].total_packets_lost_out),Object.prototype.hasOwnProperty.call(c,V.FRACTION_LOST)&&(r=Number(100*c[V.FRACTION_LOST])),{packetsLost:o,deltaPacketsLost:s,fractionLost:r}},Uh=(c,t,n,a)=>{if(!Object.prototype.hasOwnProperty.call(c,V.PACKETS_RECEIVED)||!Object.prototype.hasOwnProperty.call(c,V.PACKETS_LOST)||!Object.prototype.hasOwnProperty.call(c,V.BYTES_RECEIVED))return{percent_packets_lost:n[t].percent_packets_lost_in,packetsReceived:n[t].total_packets_in,packetsLost:n[t].total_packets_lost_in,bytesReceived:n[t].total_KBytes_in};const o=Number(c[V.PACKETS_RECEIVED])||0-(a?a[t].total_packets_in:0),s=Number(c[V.PACKETS_LOST])||0-(a?a[t].total_packets_lost_in:0),r=s-n[t].total_packets_lost_in,d=o-n[t].total_packets_in,h=o!==n[t].total_packets_in?r*100/(r+d):0,_=Number(c[V.BYTES_RECEIVED])/1024-(a?a[t].total_KBytes_in:0),g=_-n[t].total_KBytes_in,T=c[V.TIMESTAMP]||Date.now(),S=a?a.timestamp:null;let E=n.timestamp;!E&&S&&(E=S);const C=E?T-E:0,A=C>0?g*.008*1024/C*1e3:0;return{percentPacketsLost:h,packetsReceived:o,deltaPacketsReceived:d,packetsLost:s,deltaPacketsLost:r,KBytesReceived:_,deltaKBytesReceived:g,kbsReceived:A}},yv=c=>c[V.CANDIDATE_TYPE]!=="relay"?"":c[V.RELAY_PROTOCOL]||"",Cv=c=>{if(!Object.prototype.hasOwnProperty.call(c,V.NETWORK_TYPE))return ii.WIFI;switch(c[V.NETWORK_TYPE]){case bu.ETHERNET:return ii.ETHERNET;case bu.CELLULAR_4G:return ii.CELLULAR_4G;case bu.WIFI:return ii.WIFI;default:return ii.CELLULAR}},xh=c=>!Object.prototype.hasOwnProperty.call(c,V.FRAME_HEIGHT)||!Object.prototype.hasOwnProperty.call(c,V.FRAME_WIDTH)?{width:null,height:null,framerate:null}:{width:c[V.FRAME_WIDTH]||null,height:c[V.FRAME_HEIGHT]||null,framerate:c[V.FRAMES_PER_SECOND]},Av=c=>{const t=Object.prototype.hasOwnProperty.call(c,V.QUALITY_LIMITATION_REASON)?c[V.QUALITY_LIMITATION_REASON]:null,n=Object.prototype.hasOwnProperty.call(c,V.QUALITY_LIMITATION_RESOLUTION_CHANGES)?c[V.QUALITY_LIMITATION_RESOLUTION_CHANGES]:null,a=Object.prototype.hasOwnProperty.call(c,V.QUALITY_LIMITATION_DURATIONS)?c[V.QUALITY_LIMITATION_DURATIONS]:null;return a&&Object.keys(a).forEach(o=>{a[o]>1e3&&(a[o]=Number(a[o]/1e3))}),{reason:t,durations:a,resolutionChanges:n}},Rv=(c,t,n)=>{if(!Object.prototype.hasOwnProperty.call(c,V.PLI)||!Object.prototype.hasOwnProperty.call(c,V.NACK))return{pliCount:t.total_pli_sent_in,nackCount:t.total_nack_sent_in,deltaPliCount:0,deltaNackCount:0};const a=(c[V.PLI]||0)-(n?n[P.VIDEO].total_pli_sent_in:0),o=(c[V.NACK]||0)-(n?n[P.VIDEO].total_nack_sent_in:0);return{pliCount:a,nackCount:o,deltaPliCount:a-t[P.VIDEO].total_pli_sent_in,deltaNackCount:o-t[P.VIDEO].total_nack_sent_in}},Iv=(c,t,n)=>{if(!Object.prototype.hasOwnProperty.call(c,V.PLI)||!Object.prototype.hasOwnProperty.call(c,V.NACK))return{pliCount:t.total_pli_received_out,nackCount:t.total_nack_received_out,deltaPliCount:0,deltaNackCount:0};const a=(c[V.PLI]||0)-(n?n[P.VIDEO].total_pli_received_out:0),o=(c[V.NACK]||0)-(n?n[P.VIDEO].total_nack_received_out:0);return{pliCount:a,nackCount:o,deltaPliCount:a-t[P.VIDEO].total_pli_received_out,deltaNackCount:o-t[P.VIDEO].total_nack_received_out}},bv=c=>({channels:c[V.CHANNELS]||null,clock_rate:c[V.CLOCK_RATE]||null,mime_type:c[V.MIME_TYPE]||null,sdp_fmtp_line:c[V.SDP_FMTP_LINE]||null}),wv=c=>({clock_rate:c[V.CLOCK_RATE]||null,mime_type:c[V.MIME_TYPE]||null}),Ov=(c,t,n)=>{const a=(c[V.BYTES_RECEIVED]||0)/1024-(n?n.data.total_KBytes_in:0),o=(c[V.BYTES_SENT]||0)/1024-(n?n.data.total_KBytes_out:0),s=c[V.TIMESTAMP]||Date.now(),r=a-t.data.total_KBytes_in,d=o-t.data.total_KBytes_out,h=n?n.timestamp:null;let _=t.timestamp;!_&&h&&(_=h);const g=_?s-_:0,T=g>0?r*.008*1024/g*1e3:0,S=g>0?d*.008*1024/g*1e3:0;return{total_KBytes_received:a,total_KBytes_sent:o,delta_KBytes_received:r,delta_KBytes_sent:d,kbs_speed_received:T,kbs_speed_sent:S}},Dv=c=>{const t=c[V.AVAILABLE_INCOMING_BITRATE]/1024||0,n=c[V.AVAILABLE_OUTGOING_BITRATE]/1024||0;return{kbs_incoming_bandwidth:t,kbs_outgoing_bandwidth:n}},Nv=(c,t,n,a)=>{if(!c)return[];switch(c[V.TYPE]){case Zt.CANDIDATE_PAIR:let o=!1;if(c[V.NOMINATED]&&c[V.STATE]===P.SUCCEEDED&&(o=!0,xe(Ls,`analyze() - got stats ${c[V.TYPE]} for ${n}`,c),V.SELECTED in c&&!c[V.SELECTED]&&(o=!1)),o){const r=c[V.LOCAL_CANDIDATE_ID],d=c[V.REMOTE_CANDIDATE_ID],h=Ov(c,t,a),_=Dv(c),g=vv(c,"data",a,t);return[{type:ne.NETWORK,value:{local_candidate_id:r}},{type:ne.NETWORK,value:{remote_candidate_id:d}},{type:ne.DATA,value:{total_KBytes_in:h.total_KBytes_received}},{type:ne.DATA,value:{total_KBytes_out:h.total_KBytes_sent}},{type:ne.DATA,value:{delta_KBytes_in:h.delta_KBytes_received}},{type:ne.DATA,value:{delta_KBytes_out:h.delta_KBytes_sent}},{type:ne.DATA,value:{delta_kbs_in:h.kbs_speed_received}},{type:ne.DATA,value:{delta_kbs_out:h.kbs_speed_sent}},{type:ne.DATA,value:{delta_kbs_bandwidth_in:_.kbs_incoming_bandwidth}},{type:ne.DATA,value:{delta_kbs_bandwidth_out:_.kbs_outgoing_bandwidth}},{type:ne.DATA,value:{delta_rtt_connectivity_ms:g.rtt}},{type:ne.DATA,value:{total_rtt_connectivity_ms:g.totalRTT}},{type:ne.DATA,value:{total_rtt_connectivity_measure:g.totalRTTMeasurements}}]}break;case Zt.LOCAL_CANDIDATE:if(c[V.ID]===t.network.local_candidate_id)return[{type:ne.NETWORK,value:{infrastructure:Cv(c)}},{type:ne.NETWORK,value:{local_candidate_type:c[V.CANDIDATE_TYPE]||""}},{type:ne.NETWORK,value:{local_candidate_protocol:c[V.PROTOCOL]||""}},{type:ne.NETWORK,value:{local_candidate_relay_protocol:yv(c)}}];break;case Zt.REMOTE_CANDIDATE:if(c[V.ID]===t.network.remote_candidate_id)return[{type:ne.NETWORK,value:{remote_candidate_type:c[V.CANDIDATE_TYPE]||""}},{type:ne.NETWORK,value:{remote_candidate_protocol:c[V.PROTOCOL]||""}}];break;case Zt.INBOUND_RTP:{xe(Ls,`analyze() - got stats ${c[V.TYPE]} for ${n}`,c);const r=c[V.SSRC],d=ht(r,t,$e.INBOUND);d&&(d.timestamp=t.timestamp);const h=ht(r,a,$e.INBOUND);if(h&&(h.timestamp=a.timestamp),c[V.MEDIA_TYPE]===P.AUDIO){const _=Uh(c,P.AUDIO,d,h),g=Aa(c,P.AUDIO,d),T=c[V.CODEC_ID]||"";return[{ssrc:r,type:ne.AUDIO,value:{codec_id_in:T}},{ssrc:r,type:ne.AUDIO,value:{total_packets_in:_.packetsReceived}},{ssrc:r,type:ne.AUDIO,value:{delta_packets_in:_.deltaPacketsReceived}},{ssrc:r,type:ne.AUDIO,value:{total_packets_lost_in:_.packetsLost}},{ssrc:r,type:ne.AUDIO,value:{delta_packets_lost_in:_.deltaPacketsLost}},{ssrc:r,type:ne.AUDIO,value:{percent_packets_lost_in:_.percentPacketsLost}},{ssrc:r,type:ne.AUDIO,value:{total_KBytes_in:_.KBytesReceived}},{ssrc:r,type:ne.AUDIO,value:{delta_KBytes_in:_.deltaKBytesReceived}},{ssrc:r,type:ne.AUDIO,value:{delta_kbs_in:_.kbsReceived}},{ssrc:r,type:ne.AUDIO,value:{delta_jitter_ms_in:g}}]}if(c[V.MEDIA_TYPE]===P.VIDEO){const _=Sv(c,d),g=Uh(c,P.VIDEO,d,h),T=Aa(c,P.VIDEO,d),S=c[V.DECODER_IMPLEMENTATION]||null,E=c[V.CODEC_ID]||null,C=xh(c),A=Rv(c,d,h);return[{ssrc:r,type:ne.VIDEO,value:{codec_id_in:E}},{ssrc:r,type:ne.VIDEO,value:{total_packets_in:g.packetsReceived}},{ssrc:r,type:ne.VIDEO,value:{delta_packets_in:g.deltaPacketsReceived}},{ssrc:r,type:ne.VIDEO,value:{total_packets_lost_in:g.packetsLost}},{ssrc:r,type:ne.VIDEO,value:{delta_packets_lost_in:g.deltaPacketsLost}},{ssrc:r,type:ne.VIDEO,value:{percent_packets_lost_in:g.percentPacketsLost}},{ssrc:r,type:ne.VIDEO,value:{total_KBytes_in:g.KBytesReceived}},{ssrc:r,type:ne.VIDEO,value:{delta_KBytes_in:g.deltaKBytesReceived}},{ssrc:r,type:ne.VIDEO,value:{delta_kbs_in:g.kbsReceived}},{ssrc:r,type:ne.VIDEO,value:{delta_jitter_ms_in:T}},{ssrc:r,type:ne.VIDEO,value:{decoder_in:S}},{ssrc:r,type:ne.VIDEO,value:{delta_ms_decode_frame_in:_.delta_ms_decode_frame}},{ssrc:r,type:ne.VIDEO,value:{total_frames_decoded_in:_.frames_decoded}},{ssrc:r,type:ne.VIDEO,value:{total_time_decoded_in:_.total_decode_time}},{ssrc:r,type:ne.VIDEO,value:{total_nack_sent_in:A.nackCount}},{ssrc:r,type:ne.VIDEO,value:{delta_nack_sent_in:A.deltaNackCount}},{ssrc:r,type:ne.VIDEO,value:{total_pli_sent_in:A.pliCount}},{ssrc:r,type:ne.VIDEO,value:{delta_pli_sent_in:A.deltaPliCount}},{ssrc:r,type:ne.VIDEO,value:{size_in:C}}]}break}case Zt.OUTBOUND_RTP:{xe(Ls,`analyze() - got stats ${c[V.TYPE]} for ${n}`,c);const r=c[V.SSRC],d=ht(r,t,$e.OUTBOUND);d&&(d.timestamp=t.timestamp);const h=ht(r,a,$e.OUTBOUND);if(h&&(h.timestamp=a.timestamp),c[V.MEDIA_TYPE]===P.AUDIO){const _=c[V.CODEC_ID]||null,g=Dh(c,P.AUDIO,d,h);return[{ssrc:r,type:ne.AUDIO,value:{codec_id_out:_}},{ssrc:r,type:ne.AUDIO,value:{total_packets_out:g.packetsSent}},{ssrc:r,type:ne.AUDIO,value:{delta_packets_out:g.deltaPacketsSent}},{ssrc:r,type:ne.AUDIO,value:{total_KBytes_out:g.KBytesSent}},{ssrc:r,type:ne.AUDIO,value:{delta_KBytes_out:g.deltaKBytesSent}},{ssrc:r,type:ne.AUDIO,value:{delta_kbs_out:g.kbsSent}}]}if(c[V.MEDIA_TYPE]===P.VIDEO){const _=c[V.ENCODER_IMPLEMENTATION]||null,g=c[V.CODEC_ID]||null,T=Ev(c,d),S=xh(c),E=Av(c),C=Iv(c,d,h),A=Dh(c,P.VIDEO,d,h);return[{ssrc:r,type:ne.VIDEO,value:{codec_id_out:g}},{ssrc:r,type:ne.VIDEO,value:{total_packets_out:A.packetsSent}},{ssrc:r,type:ne.VIDEO,value:{delta_packets_out:A.deltaPacketsSent}},{ssrc:r,type:ne.VIDEO,value:{total_KBytes_out:A.KBytesSent}},{ssrc:r,type:ne.VIDEO,value:{delta_KBytes_out:A.deltaKBytesSent}},{ssrc:r,type:ne.VIDEO,value:{delta_kbs_out:A.kbsSent}},{ssrc:r,type:ne.VIDEO,value:{encoder_out:_}},{ssrc:r,type:ne.VIDEO,value:{delta_ms_encode_frame_out:T.delta_ms_encode_frame}},{ssrc:r,type:ne.VIDEO,value:{total_frames_encoded_out:T.frames_encoded}},{ssrc:r,type:ne.VIDEO,value:{total_time_encoded_out:T.total_encode_time}},{ssrc:r,type:ne.VIDEO,value:{total_nack_received_out:C.nackCount}},{ssrc:r,type:ne.VIDEO,value:{delta_nack_received_out:C.deltaNackCount}},{ssrc:r,type:ne.VIDEO,value:{total_pli_received_out:C.pliCount}},{ssrc:r,type:ne.VIDEO,value:{delta_pli_received_out:C.deltaPliCount}},{ssrc:r,type:ne.VIDEO,value:{size_out:S}},{ssrc:r,type:ne.VIDEO,value:{limitation_out:E}}]}break}case Zt.MEDIA_SOURCE:{xe(Ls,`analyze() - got stats ${c[V.TYPE]} for ${n}`,c);break}case Zt.TRACK:{xe(Ls,`analyze() - got stats ${c[V.TYPE]} for ${n}`,c);break}case Zt.CODEC:const s=[];return Object.keys(t[P.AUDIO]).forEach(r=>{const d=t[P.AUDIO][r];if(d.codec_id_in===c[V.ID]||d.codec_id_out===c[V.ID]){xe(Ls,`analyze() - got stats ${c[V.TYPE]} for ${n}`,c);const h=bv(c);c[V.ID]===d.codec_id_in?s.push({ssrc:d.ssrc,type:ne.AUDIO,value:{codec_in:h}}):s.push({ssrc:d.ssrc,type:ne.AUDIO,value:{codec_out:h}})}}),Object.keys(t[P.VIDEO]).forEach(r=>{const d=t[P.VIDEO][r];if(d.codec_id_in===c[V.ID]||d.codec_id_out===c[V.ID]){xe(Ls,`analyze() - got stats ${c[V.TYPE]} for ${n}`,c);const h=wv(c);c[V.ID]===d.codec_id_in?s.push({ssrc:d.ssrc,type:ne.VIDEO,value:{codec_in:h}}):s.push({ssrc:d.ssrc,type:ne.VIDEO,value:{codec_out:h}})}}),s;case Zt.REMOTE_INBOUND_RTP:{xe(Ls,`analyze() - got stats ${c[V.TYPE]} for ${n}`,c);const r=c[V.SSRC],d=ht(r,t,$e.OUTBOUND),h=ht(r,a,$e.OUTBOUND);if(c[V.KIND]===P.AUDIO){const _=Oh(c,P.AUDIO,h,d),g=Aa(c,P.AUDIO,d),T=Nh(c,P.AUDIO,d,h);return[{ssrc:r,type:ne.AUDIO,value:{delta_rtt_ms_out:_.rtt}},{ssrc:r,type:ne.AUDIO,value:{total_rtt_ms_out:_.totalRTT}},{ssrc:r,type:ne.AUDIO,value:{total_rtt_measure_out:_.totalRTTMeasurements}},{ssrc:r,type:ne.AUDIO,value:{delta_jitter_ms_out:g}},{ssrc:r,type:ne.AUDIO,value:{timestamp_out:c[V.TIMESTAMP]}},{ssrc:r,type:ne.AUDIO,value:{total_packets_lost_out:T.packetsLost}},{ssrc:r,type:ne.AUDIO,value:{delta_packets_lost_out:T.deltaPacketsLost}},{ssrc:r,type:ne.AUDIO,value:{percent_packets_lost_out:T.fractionLost}}]}if(c[V.KIND]===P.VIDEO){const _=Oh(c,P.VIDEO,h,d),g=Aa(c,P.VIDEO,d),T=Nh(c,P.VIDEO,d,h);return[{ssrc:r,type:ne.VIDEO,value:{delta_rtt_ms_out:_.rtt}},{ssrc:r,type:ne.VIDEO,value:{total_rtt_ms_out:_.totalRTT}},{ssrc:r,type:ne.VIDEO,value:{total_rtt_measure_out:_.totalRTTMeasurements}},{ssrc:r,type:ne.VIDEO,value:{delta_jitter_ms_out:g}},{ssrc:r,type:ne.VIDEO,value:{timestamp_out:c[V.TIMESTAMP]}},{ssrc:r,type:ne.VIDEO,value:{total_packets_lost_out:T.packetsLost}},{ssrc:r,type:ne.VIDEO,value:{delta_packets_lost_out:T.deltaPacketsLost}},{ssrc:r,type:ne.VIDEO,value:{percent_packets_lost_out:T.fractionLost}}]}break}}return[]},Ra=c=>c<0?1:c>100?4.5:1+.035*c+7/1e6*c*(c-60)*(100-c),Uv=(c,t=P.AUDIO,n,a,o)=>{const s=ht(o,c,$e.INBOUND),r=ht(o,n,$e.INBOUND),d=ht(o,a,$e.INBOUND),h=[],_=[],g=s[t].percent_packets_lost_in,T=s[t].delta_jitter_ms_in,S=r&&r[t].delta_jitter_ms_in||null,E=d&&d[t].delta_jitter_ms_in||null,C=c.data.delta_rtt_connectivity_ms,A=n&&n.data.delta_rtt_connectivity_ms||null,R=a&&a.data.delta_rtt_connectivity_ms||null;C&&h.push(C),A&&h.push(A),R&&h.push(R),T&&_.push(T),n&&S&&_.push(S),a&&E&&_.push(E);const k=h.length>0?Ms(h):100,M=_.length>0?Ms(_):10,ie=93.2-g,N=.18*ie*ie-27.9*ie+1126.62,j=(k+M)/2,Ee=j-177.3<0?0:1,ve=.024*j+.11*(j-177.3)*Ee,L=N-ve;return Ra(L)},xv=(c,t=P.AUDIO,n,a,o)=>{const s=ht(o,c,$e.OUTBOUND),r=ht(o,n,$e.OUTBOUND),d=ht(o,a,$e.OUTBOUND),h=[],_=[],g=s[t].percent_packets_lost_out,T=s[t].delta_rtt_ms_out,S=r&&r[t].delta_rtt_ms_out||null,E=d&&d[t].delta_rtt_ms_out||null,C=s[t].delta_jitter_ms_out,A=r&&r[t].delta_jitter_ms_out||null,R=d&&d[t].delta_jitter_ms_out||null,k=c.data.delta_rtt_connectivity_ms,M=n&&n.data.delta_rtt_connectivity_ms||null,ie=a&&a.data.delta_rtt_connectivity_ms||null;T?h.push(T):k&&h.push(k),S?h.push(S):M&&h.push(M),E?h.push(E):ie&&h.push(ie),C&&_.push(C),n&&A&&_.push(A),a&&R&&_.push(R);const N=h.length>0?Ms(h):100,j=_.length>0?Ms(_):10,Ee=93.2-g,ve=.18*Ee*Ee-27.9*Ee+1126.62,L=(N+j)/2,D=L-177.3<0?0:1,B=.024*L+.11*(L-177.3)*D,q=ve-B;return Ra(q)},Pv=(c,t=P.AUDIO,n,a,o)=>{const s=ht(o,c,$e.INBOUND),r=ht(o,n,$e.INBOUND),d=ht(o,a,$e.INBOUND),h=[],_=[],g=s[t].percent_packets_lost_in/100,T=s[t].delta_jitter_ms_in,S=r&&r[t].delta_jitter_ms_in||null,E=d&&d[t].delta_jitter_ms_in||null,C=c.data.delta_rtt_connectivity_ms,A=n&&n.data.delta_rtt_connectivity_ms||null,R=a&&a.data.delta_rtt_connectivity_ms||null;C&&h.push(C),A&&h.push(A),R&&h.push(R),T&&_.push(T),r&&S&&_.push(S),d&&E&&_.push(E);const k=h.length>0?Ms(h):100,M=_.length>0?Ms(_):10,ie=0,N=19.8,j=29.7,Ee=30,ve=(k+M)/2+Ee,L=ve-177.3<0?0:1,D=.024*ve+.11*(ve-177.3)*L,q=93.2-(ie+N*Math.log(1+j*g)+D);return Ra(q)},kv=(c,t=P.AUDIO,n,a,o)=>{const s=ht(o,c,$e.OUTBOUND),r=ht(o,n,$e.OUTBOUND),d=ht(o,a,$e.OUTBOUND),h=[],_=[],g=s[t].percent_packets_lost_out/100,T=s[t].delta_rtt_ms_out,S=r&&r[t].delta_rtt_ms_out||null,E=d&&d[t].delta_rtt_ms_out||null,C=s[t].delta_jitter_ms_out,A=r&&r[t].delta_jitter_ms_out||null,R=d&&d[t].delta_jitter_ms_out||null,k=c.data.delta_rtt_connectivity_ms,M=n&&n.data.delta_rtt_connectivity_ms||null,ie=a&&a.data.delta_rtt_connectivity_ms||null;T?h.push(T):k&&h.push(k),S?h.push(S):M&&h.push(M),E?h.push(E):ie&&h.push(ie),C&&_.push(C),r&&A&&_.push(A),d&&R&&_.push(R);const N=h.length>0?Ms(h):100,j=_.length>0?Ms(_):10,Ee=0,ve=19.8,L=29.7,D=30,B=(N+j)/2+D,q=B-177.3<0?0:1,J=.024*B+.11*(B-177.3)*q,Z=93.2-(Ee+ve*Math.log(1+L*g)+J);return Ra(Z)};class Mv{constructor(t,n){this._callbacks={onreport:null,onticket:null},this._id=hv(),this._moduleName=this._id,this._probeId=n,this._config=t,this._exporter=new Tv(t),this._state=ys.IDLE,this.registerToPCEvents(),an(this._moduleName,`new collector created for probe ${this._probeId}`)}analyze(t,n,a,o){const s=(h,_)=>h===P.AUDIO?_===Zt.INBOUND_RTP?{...Ch}:{...Ah}:_===Zt.INBOUND_RTP?{...Rh}:{...Ih},r=av(n);r.pname=this._config.pname,r.call_id=this._config.cid,r.user_id=this._config.uid,r.count=n?n.count+1:1;let d=null;return t.forEach(h=>{!d&&h.timestamp&&(d=h.timestamp),Nv(h,r,r.pname,o).forEach(g=>{if(g.value&&g.type)if(g.ssrc){let T=r[g.type][g.ssrc];T||(T=s(g.type,h.type),T.ssrc=g.ssrc,r[g.type][g.ssrc]=T),Object.keys(g.value).forEach(S=>{T[S]=g.value[S]})}else Object.keys(g.value).forEach(T=>{r[g.type][T]=g.value[T]})})}),r.timestamp=d,Object.keys(r[P.AUDIO]).forEach(h=>{const _=r[P.AUDIO][h];_.direction===$e.INBOUND?(_.mos_emodel_in=Uv(r,P.AUDIO,n,a,_.ssrc),_.mos_in=Pv(r,P.AUDIO,n,a,_.ssrc)):(_.mos_emodel_out=xv(r,P.AUDIO,n,a,_.ssrc),_.mos_out=kv(r,P.AUDIO,n,a,_.ssrc))}),r}async takeReferenceStats(){return new Promise((t,n)=>{const a=Date.now();setTimeout(async()=>{try{const o=Date.now()-a,s=Date.now(),r=await this._config.pc.getStats(),d=this.analyze(r,null,null,null),h=Date.now();d.experimental.time_to_measure_ms=h-s,d.experimental.time_to_wait_ms=o,this._exporter.saveReferenceReport(d),xe(this._moduleName,`got reference report for probe ${this._probeId}`),t()}catch(o){n(o)}},this._config.startAfter)})}async collectStats(){try{if(this._state!==ys.RUNNING||!this._config.pc)return xe(this._moduleName,`report discarded (too late) for probe ${this._probeId}`),null;const t=Date.now(),n=await this._config.pc.getStats(),a=this.analyze(n,this._exporter.getLastReport(),this._exporter.getBeforeLastReport(),this._exporter.getReferenceReport()),o=Date.now();return a.experimental.time_to_measure_ms=o-t,this._exporter.addReport(a),xe(this._moduleName,`got report for probe ${this._probeId}#${this._exporter.getReportsNumber()+1}`),this.fireOnReport(a),a}catch(t){return Vn(this._moduleName,`got error ${t}`),null}}async start(){xe(this._moduleName,"starting"),this.state=ys.RUNNING,this._startedTime=this._exporter.start(),xe(this._moduleName,"started")}async mute(){this.state=ys.MUTED,xe(this._moduleName,"muted")}async unmute(){this.state=ys.RUNNING,xe(this._moduleName,"unmuted")}async stop(t){if(xe(this._moduleName,`stopping${t?" by watchdog":""}...`),this._stoppedTime=this._exporter.stop(),this.state=ys.IDLE,this._config.ticket){const{ticket:n}=this._exporter;this.fireOnTicket(n)}this._exporter.reset(),xe(this._moduleName,"stopped")}registerCallback(t,n,a){t in this._callbacks?(this._callbacks[t]={callback:n,context:a},xe(this._moduleName,`registered callback '${t}'`)):Vn(this._moduleName,`can't register callback for '${t}' - not found`)}unregisterCallback(t){t in this._callbacks?(this._callbacks[t]=null,delete this._callbacks[t],xe(this._moduleName,`unregistered callback '${t}'`)):Vn(this._moduleName,`can't unregister callback for '${t}' - not found`)}fireOnReport(t){this._callbacks.onreport&&Ou(this._callbacks.onreport.callback,this._callbacks.onreport.context,t)}fireOnTicket(t){this._callbacks.onticket&&Ou(this._callbacks.onticket.callback,this._callbacks.onticket.context,t)}updateConfig(t){this._config=t,this._exporter.updateConfig(t)}get state(){return this._state}set state(t){this._state=t,xe(this._moduleName,`state changed to ${t}`)}addCustomEvent(t,n,a,o){this._exporter.addCustomEvent({at:typeof t=="object"?t.toJSON():t,category:n,name:a,description:o})}async registerToPCEvents(){const{pc:t}=this._config;if(navigator.mediaDevices.ondevicechange=async()=>{try{const n=await navigator.mediaDevices.enumerateDevices();this.addCustomEvent(new Date().toJSON(),"device",`${n.length} devices found`,"Media Devices state")}catch{Vn(this._moduleName,"can't get devices")}},t){t.oniceconnectionstatechange=()=>{const a=t.iceConnectionState;a===ri.CONNECTED||a===ri.COMPLETED?this.addCustomEvent(new Date().toJSON(),"call",a,"ICE connection state"):a===ri.DISCONNECTED||a===ri.FAILED?this.addCustomEvent(new Date().toJSON(),"call",a,"ICE connection state"):a===ri.CLOSED&&this.addCustomEvent(new Date().toJSON(),"call","ended","ICE connection state")},t.onicegatheringstatechange=()=>{const a=t.iceGatheringState;this.addCustomEvent(new Date().toJSON(),"call",a,"ICE gathering state")},t.ontrack=a=>{this.addCustomEvent(new Date().toJSON(),"call",`${a.track.kind}track`,"MediaStreamTrack received")},t.onnegotiationneeded=()=>{this.addCustomEvent(new Date().toJSON(),"call","negotiation","Media changed")};const n=t.getReceivers();if(n&&n.length>0){const a=n[0],{transport:o}=a;if(o){const{iceTransport:s}=o;s&&(s.onselectedcandidatepairchange=()=>{this.addCustomEvent(new Date().toJSON(),"call","transport","Candidates Pair changed")})}}}}}class Lv{constructor(t){this._id=t.pname&&t.pname.substr(0,12).padEnd(12," ")||fv(),this._moduleName=this._id,an(this._moduleName,"probe created"),this._config=t,this._collector=new Mv(this._config,this._id)}set onreport(t){t?this._collector.registerCallback("onreport",t):this._collector.unregisterCallback("onreport")}set onticket(t){t?this._collector.registerCallback("onticket",t):this._collector.unregisterCallback("onticket")}get id(){return this._id}get pname(){return this._config.pname}get cid(){return this._config.cid}get uid(){return this._config.uid}get state(){return this._collector.state}set state(t){this._collector.state=t}addCustomEvent(t,n,a,o=new Date().toJSON()){this._collector.addCustomEvent(o,n,t,a)}get isRunning(){return this._collector.state===ys.RUNNING}get isIdle(){return this._collector.state===ys.IDLE}updateUserId(t){this._config.uid=t,this._collector.updateConfig(this._config)}updateCallId(t){this._config.cid=t,this._collector.updateConfig(this._config)}start(){if(!this.isIdle){Ca(this._moduleName,"probe is already running");return}this._collector.start()}stop(t=!1){this.isRunning&&this._collector.stop(t)}async takeReferenceStats(){return this._collector.takeReferenceStats()}async collectStats(){return this._collector.collectStats()}}const bt="engine ";class $v{constructor(t){this._config=t,this._probes=[],this._startedTime=null,this._callbacks={onresult:null},an(bt,`configured for probing every ${this._config.refreshEvery}ms`),an(bt,`configured for starting after ${this._config.startAfter}ms`),an(bt,`${!this._config.stopAfter||this._config.stopAfter!==-1?`configured for stopped after ${this._config.stopAfter}ms`:"configured for never stopped"}`),xe(bt,"engine initialized")}get probes(){return this._probes}get isRunning(){return this._probes.some(t=>t.isRunning)}get isIdle(){return this._probes.every(t=>t.isIdle)}addNewProbe(t,n){if(!t)throw new Error("undefined peer connection");const a=uv(t,n,this._config),o=new Lv(a);return this._probes.push(o),xe(bt,`${this._probes.length} probes registered`),o}removeExistingProbe(t){if(!t)throw new Error("undefined probe");t.state===ys.RUNNING&&t.stop(),this._probes=this._probes.filter(n=>t.id!==n.id)}async start(){const t=()=>{this._probes.forEach(s=>s.start())},n=async()=>Promise.all(this._probes.map(s=>s.takeReferenceStats())),a=()=>this.isIdle?!1:!this._config.stopAfter||this._config.stopAfter<0?!0:Date.now()<this._startedTime+this._config.stopAfter,o=async()=>{const s=lv(),r=this._probes.filter(d=>d.isRunning);for(const d of r){const h=await d.collectStats();h&&s.probes.push(h),xe(bt,`got probe ${d.id}`),await bh(0)}return s.delta_time_to_measure_probes_ms=on(s.probes,"experimental","time_to_measure_ms"),s.delta_KBytes_in=on(s.probes,"data","delta_KBytes_in"),s.delta_KBytes_out=on(s.probes,"data","delta_KBytes_out"),s.delta_kbs_in=on(s.probes,"data","delta_kbs_in"),s.delta_kbs_out=on(s.probes,"data","delta_kbs_out"),s.total_time_decoded_in=on(s.probes,"video","total_time_decoded_in"),s.total_time_encoded_out=on(s.probes,"video","total_time_encoded_out"),s};for(xe(bt,"starting to collect"),t(),xe(bt,"generating reference reports..."),await n(),xe(bt,"reference reports generated"),this._startedTime=Date.now();a();)if(xe(bt,`wait ${this._config.refreshEvery}ms before collecting`),await bh(this._config.refreshEvery),a()){xe(bt,"collecting...");const s=Date.now(),r=await o(),d=Date.now();r.delta_time_consumed_to_measure_ms=d-s,this.fireOnReports(r),xe(bt,"collected")}xe(bt,"reaching end of the collecting period..."),this.isRunning&&setTimeout(()=>{this.stop()},0)}stop(t){const n=a=>{this._probes.forEach(o=>{o.stop(a)})};an(bt,"stop collecting"),n(t)}registerCallback(t,n,a){t in this._callbacks?(this._callbacks[t]={callback:n,context:a},xe(bt,`registered callback '${t}'`)):Vn(bt,`can't register callback for '${t}' - not found`)}unregisterCallback(t){t in this._callbacks?(this._callbacks[t]=null,delete this._callbacks[t],xe(this._moduleName,`unregistered callback '${t}'`)):Vn(this._moduleName,`can't unregister callback for '${t}' - not found`)}fireOnReports(t){this._callbacks.onresult&&t.probes.length>0&&Ou(this._callbacks.onresult.callback,this._callbacks.onresult.context,t)}}const Hv="interface ";class Fv{constructor(t){this._config=cv(t),an(Hv,`welcome to ${this._config.name} version ${this._config.version}`),QT(this._config.verbose||!1),this._engine=new $v(this._config)}setupLogLevel(t){ZT(t)}get version(){return this._config.version}get name(){return this._config.name}get probes(){return this._engine.probes}createProbe(t,n){return this._engine.addNewProbe(t,n)}startAllProbes(){this._engine.start()}stopAllProbes(){this._engine.stop()}get running(){return this._engine.isRunning}get idle(){return this._engine.isIdle}removeProbe(t){this._engine.removeExistingProbe(t)}set onresult(t){t?this._engine.registerCallback("onresult",t):this._engine.unregisterCallback("onresult")}}function jv(c,t){return Object.keys(c).filter(n=>t.includes(n)).reduce((n,a)=>{const o=a;return{...n,[o]:c[o]}},{})}const Vv=["mos_in","codec_in","delta_KBytes_in","delta_kbs_in","delta_jitter_ms_in","delta_packets_lost_in"],qv={positiveSpeechThreshold:.6,negativeSpeechThreshold:.3,preSpeechPadMs:150,redemptionMs:1500,minSpeechMs:50};class Bv{constructor(t){this.intervals={},this.analysers={},this.emitInterval=t.emitInterval||200,this.onChangeFunction=t.onChangeFunction}async start(t,n,a){n&&n.getTracks().length&&await this.beginCalculation(t,n,a)}stop(t){this.clearVolumeInterval(t),this.analysers[t]&&typeof this.analysers[t].disconnect=="function"&&(this.analysers[t].disconnect(),delete this.analysers[t])}clearVolumeInterval(t){this.intervals[t]&&(clearInterval(this.intervals[t]),delete this.intervals[t])}clearAllIntervals(){Object.keys(this.intervals).forEach(t=>{this.stop(t)}),this.intervals={},this.analysers={}}async beginCalculation(t,n,a){this.clearVolumeInterval(a);const o=t.createAnalyser(),s=t.createMediaStreamSource(n);o.smoothingTimeConstant=.8,o.fftSize=1024,s.connect(o),this.analysers[a]=o,this.intervals[a]=setInterval(()=>{const r=new Uint8Array(o.frequencyBinCount);o.getByteFrequencyData(r);let d=0;const h=r.length;for(let g=0;g<h;g++)d+=r[g];const _=d/h;this.onChangeFunction(a,_)},this.emitInterval)}}class Gv{constructor(){this.resumePromise=null,this.context=new AudioContext}async getContext(){return this.context.state==="suspended"&&(this.resumePromise||(this.resumePromise=this.context.resume().then(()=>{this.resumePromise=null}).catch(t=>{throw this.resumePromise=null,t})),await this.resumePromise),this.context}}const Ia={SELECTED_INPUT_DEVICE:"OpensipsJSInputDevice",SELECTED_OUTPUT_DEVICE:"OpensipsJSOutputDevice"},Wv=0;class Kv{constructor(t){var n;if(this.isAutoAnswer=!1,this.muteWhenJoinEnabled=!1,this.isDNDEnabled=!1,this.isCallWaitingEnabled=!0,this.muted=!1,this.microphoneInputLevelValue=1,this.speakerVolumeValue=1,this.activeRooms={},this.activeCalls={},this.extendedCalls={},this.conferenceNodes={},this.availableMediaDevices=[],this.selectedMediaDevices={input:"default",output:"default"},this.callStatus={},this.callTime={},this.callMetrics={},this.timeIntervals={},this.metricConfig={refreshEvery:1e3},this.activeStreamValue=null,this.initialStreamValue=null,this.vadSessions={},this.vadSessionsState={},this.vadIntervals={},this.vadMrsIntervals={},this.managedAudioContext=new Gv,this.context=t,this.context.on(this.context.newRTCSessionEventName,this.newRTCSessionCallback.bind(this)),this.VUMeter=new Bv({onChangeFunction:this.emitVolumeChange.bind(this)}),this.processVADConfiguration(),this.initializeMediaDevices(),["enabled","dynamic"].includes(this.noiseReduction.mode)){const a=(n=this.context.options.configuration)==null?void 0:n.vadModule;a&&a.MicVAD?(this.MicVAD=a.MicVAD,console.log("✅ VAD module loaded successfully")):(console.warn("⚠️ Noise reduction is enabled but VAD module is not provided. To use VAD features, please install @ricky0123/vad-web and pass it via configuration.vadModule option."),this.noiseReduction.mode="disabled")}}processVADConfiguration(){var n;const t=((n=this.context.options.configuration)==null?void 0:n.noiseReductionOptions)||{};this.noiseReduction={mode:t.mode||"disabled",checkEveryMs:t.checkEveryMs||500,noiseCheckInterval:t.noiseCheckInterval||2e3,noiseThreshold:t.noiseThreshold||.004,vadConfig:t.vadConfig||{}}}get sipOptions(){return{...this.context.options.sipOptions,mediaConstraints:this.getUserMediaConstraints}}get currentActiveRoomId(){return this.currentActiveRoomIdValue}set currentActiveRoomId(t){this.currentActiveRoomIdValue=t,this.context.emit("currentActiveRoomChanged",t)}get autoAnswer(){return this.isAutoAnswer}get callAddingInProgress(){return this.isCallAddingInProgress}set callAddingInProgress(t){this.isCallAddingInProgress=t,this.context.emit("callAddingInProgressChanged",t)}get muteWhenJoin(){return this.muteWhenJoinEnabled}get isDND(){return this.isDNDEnabled}get isCallWaiting(){return this.isCallWaitingEnabled}get speakerVolume(){return this.speakerVolumeValue}get microphoneInputLevel(){return this.microphoneInputLevelValue}get getActiveCalls(){return this.activeCalls}get hasActiveCalls(){return Object.values(this.extendedCalls).length>0}get hasActiveAnsweredCalls(){return Object.values(this.activeRooms).filter(a=>!a.incomingInProgress).length>0}get getActiveRooms(){return this.activeRooms}get isMuted(){return this.muted}get getInputDeviceList(){return this.availableMediaDevices.filter(t=>t.kind==="audioinput")}get getOutputDeviceList(){return this.availableMediaDevices.filter(t=>t.kind==="audiooutput")}get getUserMediaConstraints(){return vh()?{video:!1,audio:!0}:{audio:{deviceId:{exact:this.selectedMediaDevices.input},echoCancellation:!0,echoCancellationType:"system",noiseSuppression:!0,autoGainControl:!0,sampleRate:48e3,latency:.01},video:!1}}get selectedInputDevice(){return this.selectedMediaDevices.input}get selectedOutputDevice(){return this.selectedMediaDevices.output}get activeStream(){return this.activeStreamValue}setAvailableMediaDevices(t){this.availableMediaDevices=t,this.context.emit("changeAvailableDeviceList",t)}async updateDeviceList(){await navigator.mediaDevices.getUserMedia(this.getUserMediaConstraints);const t=await navigator.mediaDevices.enumerateDevices();this.setAvailableMediaDevices(t)}async initializeMediaDevices(){const t=localStorage.getItem(Ia.SELECTED_INPUT_DEVICE)||"default",n=localStorage.getItem(Ia.SELECTED_OUTPUT_DEVICE)||"default";try{const a=await navigator.mediaDevices.getUserMedia(this.getUserMediaConstraints),o=await navigator.mediaDevices.enumerateDevices();this.setAvailableMediaDevices(o),await this.setMicrophone(t),await this.setSpeaker(n),navigator.mediaDevices.addEventListener("devicechange",async()=>{const s=await navigator.mediaDevices.enumerateDevices();this.setAvailableMediaDevices(s)}),a.getTracks().forEach(s=>s.stop())}catch(a){console.error(a)}}async cleanupConferenceNodes(t){const n=this.conferenceNodes[t];if(!n)return;let a=0;n.sources.forEach((r,d)=>{try{r.disconnect(),a++}catch(h){console.error(`[cleanupConferenceNodes] Error disconnecting source ${d}:`,h)}});let o=0;n.destinations.forEach((r,d)=>{try{r.disconnect(),o++}catch(h){console.error(`[cleanupConferenceNodes] Error disconnecting destination ${d}:`,h)}});let s=0;n.gains.forEach((r,d)=>{try{r.disconnect(),s++}catch(h){console.error(`[cleanupConferenceNodes] Error disconnecting gain ${d}:`,h)}}),delete this.conferenceNodes[t]}setCallTime(t){const n={...t};delete n.callId,this.callTime={...this.callTime,[t.callId]:n},this.context.emit("changeCallTime",this.callTime)}removeCallTime(t){const n={...this.callTime};delete n[t],this.callTime={...n},this.context.emit("changeCallTime",this.callTime)}setTimeInterval(t,n){this.timeIntervals={...this.timeIntervals,[t]:n}}removeTimeInterval(t){const n={...this.timeIntervals};n[t]&&(clearInterval(n[t]),delete n[t],this.timeIntervals={...n})}stopCallTimer(t){this.removeTimeInterval(t),this.removeCallTime(t)}emitVolumeChange(t,n){this.context.emit("changeCallVolume",{callId:t,volume:n})}setMetricsConfig(t){this.metricConfig={...this.metricConfig,...t}}sendDTMF(t,n){if(!/^[A-D0-9*#]+$/g.test(n))throw new Error("Not allowed character used in the DTMF input");this.extendedCalls[t].sendDTMF(n)}setIsMuted(t){this.muted=t,this.context.emit("changeIsMuted",t)}processMute(t){const n=this.currentActiveRoomId;this.setIsMuted(t),this.initialStreamValue.getTracks().forEach(a=>a.enabled=!t),this.roomReconfigure(n)}mute(){this.processMute(!0)}unmute(){this.processMute(!1)}async processHold({callId:t,toHold:n,automatic:a}){const o=this.extendedCalls[t];if(!o)return;o._automaticHold=a??!1;const s=new Promise((r,d)=>{const h=setTimeout(()=>{d(new Error("Hold operation timeout"))},5e3),_=()=>{clearTimeout(h),o.putOnHoldTimestamp=n?Date.now():void 0,r()},g=T=>{clearTimeout(h),d(T)};try{n?(this.stopSessionVad(o._id),o.hold({},_)):o.unhold({},_)}catch(T){g(T)}});try{await s,this.updateCall(o);const r=Object.values(this.extendedCalls).filter(d=>d.roomId===o.roomId&&(n?t!==d._id:!0));r.length>1&&await this.doConference(r)}catch(r){throw console.error("Hold operation failed:",r),r}}holdCall(t,n=!1){return this.processHold({callId:t,automatic:n,toHold:!0})}unholdCall(t){return this.processHold({callId:t,toHold:!1})}cancelAllOutgoingUnanswered(){Object.values(this.getActiveCalls).filter(t=>t.direction==="outgoing"&&t.status===Wv).forEach(t=>this.terminateCall(t._id))}answerCall(t){const n=this.extendedCalls[t];this.cancelAllOutgoingUnanswered(),n.answer(this.sipOptions),this.updateCall(n),this.setActiveRoom(n.roomId),n.connection.addEventListener("track",a=>{this.triggerAddStream(a,n)})}async moveCall(t,n){this.updateCallStatus({callId:t,isMoving:!0}),await this.processRoomChange({callId:t,roomId:n}),this.updateCallStatus({callId:t,isMoving:!1})}updateCall(t){this.activeCalls[t._id]=gh(t),this.context.emit("changeActiveCalls",this.activeCalls)}updateRoom(t){const a={...this.activeRooms[t.roomId],...t};this.activeRooms={...this.activeRooms,[t.roomId]:{...a}},this.context.emit("updateRoom",{room:a,roomList:this.activeRooms})}hasAutoAnswerHeaders(t){const n=/answer-after=0/,o=t.request.getHeader("Call-Info");return o&&n.test(o)}addCall(t,n=!0){this.activeCalls={...this.activeCalls,[t._id]:gh(t)},this.extendedCalls[t._id]=t,n&&this.context.emit("changeActiveCalls",this.activeCalls)}addCallStatus(t){this.callStatus={...this.callStatus,[t]:{isMoving:!1,isTransferring:!1,isMerging:!1,isTransferred:!1}},this.context.emit("changeCallStatus",this.callStatus)}updateCallStatus(t){const a={...{...this.callStatus[t.callId]}};t.isMoving!==void 0&&(a.isMoving=t.isMoving),t.isTransferring!==void 0&&(a.isTransferring=t.isTransferring),t.isMerging!==void 0&&(a.isMerging=t.isMerging),t.isTransferred!==void 0&&(a.isTransferred=t.isTransferred),this.callStatus={...this.callStatus,[t.callId]:{...a}},this.context.emit("changeCallStatus",this.callStatus)}removeCallStatus(t){const n={...this.callStatus};delete n[t],this.callStatus={...n},this.context.emit("changeCallStatus",this.callStatus)}addRoom(t){this.activeRooms={...this.activeRooms,[t.roomId]:t},this.context.emit("addRoom",{room:t,roomList:this.activeRooms})}async setupActiveStream(){const t=await Cu(await this.managedAudioContext.getContext(),this.initialStreamValue,this.microphoneInputLevel*2);t.getTracks().forEach(n=>n.enabled=!this.isMuted),await this.setActiveStream(t)}async getActiveStream(){const t=await Cu(await this.managedAudioContext.getContext(),this.initialStreamValue,this.microphoneInputLevel*2);return t.getTracks().forEach(n=>n.enabled=!this.isMuted),await this.setActiveStream(t),t}async setMicrophone(t){if(!this.getInputDeviceList.find(({deviceId:a})=>a===t)||(this.setSelectedInputDevice(t),Object.keys(this.getActiveCalls).length===0))return;await this.setupStream();const n=Object.values(this.extendedCalls).filter(a=>a.roomId===this.currentActiveRoomId);n.length===1?Object.values(n).forEach(async a=>{await this.setupActiveStream();const o=this.activeStream;a.connection.getSenders()[0].replaceTrack(o.getTracks()[0]),this.updateCall(a)}):await this.doConference(n)}async setActiveStream(t){this.activeStream&&this.stopVUMeter("origin"),await this.setupVUMeter(t,"origin"),this.activeStreamValue=t,this.context.emit("changeActiveStream",t)}async setSpeaker(t){if(!this.getOutputDeviceList.find(({deviceId:o})=>o===t))return;this.setSelectedOutputDevice(t);const n=Object.values(this.extendedCalls);if(n.length===0)return;const a=n.filter(o=>o.roomId===this.currentActiveRoomId);a.length===1?n.forEach(o=>{var s;(s=o.audioTag)==null||s.setSinkId(t),this.updateCall(o)}):await this.doConference(a)}removeRoom(t){const n={...this.activeRooms},a={...n[t]};delete n[t],this.activeRooms={...n},this.context.emit("removeRoom",{room:a,roomList:this.activeRooms})}deleteRoomIfEmpty(t){t!==void 0&&Object.values(this.extendedCalls).filter(n=>n.roomId===t).length===0&&(this.removeRoom(t),this.currentActiveRoomId===t&&(this.currentActiveRoomId=void 0))}checkInitialized(){if(!this.context.initialized)throw new Error("[OpenSIPSJS] You must call `start` method first!")}muteReconfigure(t){this.muted?t.mute({audio:!0}):t.unmute({audio:!0})}startNoiseMonitor({sessionId:t,stream:n,onNoiseDetected:a,onNoiseStop:o}){const s=new AudioContext,r=s.createMediaStreamSource(n.clone()),d=s.createAnalyser();d.fftSize=1024;const h=new Float32Array(d.fftSize);r.connect(d);const _=[];this.vadIntervals[t]&&(clearInterval(this.vadIntervals[t]),this.vadIntervals[t]=null),this.vadMrsIntervals[t]&&(clearInterval(this.vadMrsIntervals[t]),this.vadMrsIntervals[t]=null),this.vadMrsIntervals[t]=setInterval(()=>{d.getFloatTimeDomainData(h);const g=YT(h);_.push(g);const T=Math.ceil(this.noiseReduction.noiseCheckInterval/this.noiseReduction.checkEveryMs);_.length>T&&_.shift()},this.noiseReduction.checkEveryMs),this.vadIntervals[t]=setInterval(()=>{if(_.length===0)return;const g=_.reduce((E,C)=>E+C,0)/_.length,T=this.vadSessionsState[t],S=g>this.noiseReduction.noiseThreshold;T.isSpeaking||(S&&T.currentMode==="clean"?(T.currentMode="noisy",console.log("Average noise high → enable VAD"),this.context.emit("changeNoiseReductionState",{sessionId:t,enabled:!0}),a()):!S&&T.currentMode==="noisy"&&(T.currentMode="clean",console.log("Average noise low → disable VAD"),this.context.emit("changeNoiseReductionState",{sessionId:t,enabled:!1}),o()))},this.noiseReduction.noiseCheckInterval)}async processVAD(t,n){const a=n.clone();this.stopSessionVad(t._id),this.vadSessionsState[t._id]={currentMode:"clean",isSpeaking:!1};const o=await this.managedAudioContext.getContext(),s=await JT(a,o,150);let r=!1;const d=await this.MicVAD.new({getStream:()=>new Promise(h=>h(a)),...qv,...this.noiseReduction.vadConfig,baseAssetPath:"https://cdn.jsdelivr.net/npm/@ricky0123/vad-web@0.0.28/dist/",onnxWASMBasePath:"https://cdn.jsdelivr.net/npm/onnxruntime-web@1.22.0/dist/",onFrameProcessed:()=>{if(!r){if(r=!0,console.log("✅ VAD initialized, starting background noise monitoring"),this.noiseReduction.mode==="enabled"){t.connection.getSenders()[0]&&t.connection.getSenders()[0].replaceTrack(s.stream.getAudioTracks()[0]);return}this.startNoiseMonitor({sessionId:t._id,stream:a,onNoiseDetected:async()=>{var h;console.log("Replace track with Vad Controlled"),await((h=t.connection.getSenders()[0])==null?void 0:h.replaceTrack(s.stream.getAudioTracks()[0]))},onNoiseStop:async()=>{const h=t.connection.getSenders()[0];h&&h.track&&h.transport&&h.transport.state!=="closed"&&h.transport.state!=="failed"&&(console.log("Replace track with Original"),await h.replaceTrack(a.getAudioTracks()[0]))}})}},onSpeechStart:()=>{var h;console.log("🎤 Speech started"),s.setSpeaking(!0),this.noiseReduction.mode==="enabled"&&((h=t.connection.getSenders()[0])==null||h.replaceTrack(s.stream.getAudioTracks()[0])),this.vadSessionsState[t._id].isSpeaking=!0},onSpeechEnd:()=>{var h;console.log("🛑 Speech end"),s.setSpeaking(!1),this.noiseReduction.mode==="enabled"&&((h=t.connection.getSenders()[0])==null||h.replaceTrack(s.stream.getAudioTracks()[0])),this.vadSessionsState[t._id].isSpeaking=!1}});this.vadSessions[t._id]&&(this.vadSessions[t._id].pause(),delete this.vadSessions[t._id]),this.vadSessions[t._id]=d,d.start()}stopSessionVad(t){this.vadSessions[t]&&(this.vadSessions[t].pause(),delete this.vadSessions[t]),this.vadIntervals[t]&&(clearInterval(this.vadIntervals[t]),delete this.vadIntervals[t]),this.vadMrsIntervals[t]&&(clearInterval(this.vadMrsIntervals[t]),delete this.vadMrsIntervals[t]),this.vadSessionsState[t]&&delete this.vadSessionsState[t]}async roomReconfigure(t){var o;if(t===void 0)return;const n=Object.values(this.extendedCalls).filter(s=>s.roomId===t),a=this.currentActiveRoomId===t;if(n.forEach((s,r)=>{if(s.audioTag){s.connection.getReceivers().forEach(h=>{h.track.enabled=!s.localMuted}),a&&this.muteReconfigure(s);const d=!a;s.audioTag.muted=d,this.updateCall(s)}}),n.length===0){!!this.conferenceNodes[t]&&await this.cleanupConferenceNodes(t),this.deleteRoomIfEmpty(t);return}if(n.length===1&&!a){const s=n[0];s.isOnHold().local||await this.holdCall(s._id,!0),!!this.conferenceNodes[t]&&await this.cleanupConferenceNodes(t);return}if(n.length===1&&a){const s=n[0];s.isOnHold().local&&s._automaticHold&&await this.unholdCall(s._id);const h=(((o=s.connection)==null?void 0:o.getSenders())||[])[0];if(s.connection&&h)try{await this.setupActiveStream();const g=this.activeStream;["enabled","dynamic"].includes(this.noiseReduction.mode)&&this.processVAD(n[0],g);const T=g.getTracks();await h.replaceTrack(T[0]),this.muteReconfigure(s)}catch(g){console.error(g)}!!this.conferenceNodes[t]&&await this.cleanupConferenceNodes(t);return}n.length>1&&await this.doConference(n)}async doConference(t){if(t.length===0)return;const n=t[0].roomId,a=this.currentActiveRoomId===n;if(t.find(h=>h.roomId!==n))return;const s=await this.managedAudioContext.getContext();if(s.state!=="running"){console.error(`[doConference] ERROR: AudioContext is not running! State: ${s.state}`);return}await this.cleanupConferenceNodes(n),this.conferenceNodes[n]={sources:new Map,destinations:new Map,gains:new Map};const r=this.conferenceNodes[n],d=new Map;t.forEach((h,_)=>{h&&h.connection&&h.connection.getReceivers().forEach((T,S)=>{var A,R,k;T.track.enabled=!h.localMuted;const E=(A=T.track)==null?void 0:A.id;(R=T.track)==null||R.readyState,(k=T.track)==null||k.kind;const C=`${h._id}-${E}`;T.track&&T.track.readyState==="live"&&d.set(C,T.track)})}),await this.setupActiveStream(),await zT.forEach(t,async(h,_)=>{if(!h||!h.connection)return;const g=s.createMediaStreamDestination();r.destinations.set(h._id,g);let T=0;if(d.forEach((A,R)=>{if(!R.startsWith(h._id))try{const k=s.createMediaStreamSource(new MediaStream([A])),M=s.createGain(),ie=`${h._id}-${R}`;k.connect(M),M.connect(g),r.sources.set(ie,k),r.gains.set(ie,M),T++}catch(k){console.error(k)}}),a&&this.activeStreamValue)try{const A=this.activeStream,R=s.createMediaStreamSource(A),k=s.createGain(),M=`${h._id}-local`;R.connect(k),k.connect(g),r.sources.set(M,R),r.gains.set(M,k)}catch(A){console.error(A)}else a&&console.error(`Host room but no activeStreamValue - skipping host microphone for session ${h._id}`);const E=h.connection.getSenders()[0],C=g.stream.getTracks();if(["enabled","dynamic"].includes(this.noiseReduction.mode)&&this.processVAD(h,g.stream),E&&C[0])try{await E.replaceTrack(C[0]),this.muteReconfigure(h)}catch(A){console.error(A)}})}processCallerMute(t,n){const a=this.extendedCalls[t];a&&a.connection.getReceivers().length&&(a.localMuted=n,a.connection.getReceivers().forEach(o=>{o.track.enabled=!n}),this.updateCall(a))}muteCaller(t){this.processCallerMute(t,!0)}unmuteCaller(t){this.processCallerMute(t,!1)}terminateCall(t){const n=this.extendedCalls[t];n._status===4?n.terminate({status_code:603,reason_phrase:"Decline"}):n._status!==8&&n.terminate()}transferCall(t,n){if(n.toString().length===0)return new Error("Target must be passed");const a=this.extendedCalls[t];if(!a._is_confirmed&&!a._is_canceled){const o=`sip:${n}@${this.context.sipDomain}`;a.terminate({status_code:302,reason_phrase:"Moved Temporarily",extraHeaders:[`Contact: ${o}`]});return}this.updateCallStatus({callId:t,isTransferring:!0,isTransferred:!1}),a.refer(`sip:${n}@${this.context.sipDomain}`,{eventHandlers:{requestSucceeded:()=>{this.updateCallStatus({callId:t,isTransferring:!1,isTransferred:!0})},requestFailed:()=>{this.updateCallStatus({callId:t,isTransferring:!1,isTransferred:!1})}}}),this.updateCall(a)}mergeCall(t){const n=Object.values(this.extendedCalls).filter(s=>s.roomId===t);if(n.length!==2)return;const a=n[0],o=n[1];!a||!o||(this.updateCallStatus({callId:a._id,isMerging:!0}),this.updateCallStatus({callId:o._id,isMerging:!0}),a.refer(o.remote_identity.uri.toString(),{replaces:o}),this.updateCall(a))}mergeCallByIds(t,n){const a=Object.values(this.extendedCalls).find(s=>s._id===t),o=Object.values(this.extendedCalls).find(s=>s._id===n);if(!a||!o)throw new Error("Call ID is not provided");this.updateCallStatus({callId:t,isMerging:!0}),this.updateCallStatus({callId:n,isMerging:!0}),a.refer(o.remote_identity.uri.toString(),{replaces:o}),this.updateCall(a)}setDND(t){this.isDNDEnabled=t,this.context.emit("changeIsDND",t)}setCallWaiting(t){this.isCallWaitingEnabled=t,this.context.emit("changeIsCallWaiting",t)}startCallTimer(t){this.removeTimeInterval(t);const n={callId:t,hours:0,minutes:0,seconds:0,formatted:""};this.setCallTime(n);const a=setInterval(()=>{const o={...this.callTime[t]},s=KT(o);this.setCallTime({callId:t,...s})},1e3);this.setTimeInterval(t,a)}async setActiveRoom(t){const n=this.currentActiveRoomId;t!==n&&(this.currentActiveRoomId=t,await this.roomReconfigure(n),await this.roomReconfigure(t))}getNewRoomId(){const t=Object.keys(this.activeRooms);return t.length===0?1:parseInt(t.sort()[t.length-1])+1}async setupCall(t){var _,g;const n=t.session;if(this.getActiveCalls[n.id]!==void 0)return;const o=this.getNewRoomId(),s={started:new Date,incomingInProgress:!1,roomId:o};n.direction==="incoming"?(this.context.logger.log("New incoming call from",(g=(_=n._remote_identity)==null?void 0:_._uri)==null?void 0:g._user),s.incomingInProgress=!0,this.context.subscribe(Qt.CALL_CONFIRMED,T=>{n.id===T.id&&(this.updateRoom({incomingInProgress:!1,roomId:o}),this.startCallTimer(n.id))}),this.context.subscribe(Qt.CALL_FAILED,T=>{n.id===T.id&&(this.updateRoom({incomingInProgress:!1,roomId:o}),this.deleteRoomIfEmpty(o))})):n.direction==="outgoing"&&(n.once("confirmed",()=>{this.startCallTimer(n.id)}),this.startCallTimer(n.id));const r=n,d=this.hasAutoAnswerHeaders(t),h=r.direction==="incoming"&&!this.hasActiveCalls&&(d||this.autoAnswer);r.roomId=o,r.localMuted=!1,r.autoAnswer=h,h?this.addCall(r,!1):this.addCall(r),this.addCallStatus(n.id),this.addRoom(s),h&&this.answerCall(r._id)}removeCall(t){const n={...this.activeCalls};delete n[t],this.activeCalls={...n};const a={...this.extendedCalls};delete a[t],this.extendedCalls={...a},this.context.emit("changeActiveCalls",this.activeCalls)}activeCallListRemove(t){const n=this.extendedCalls[t._id];if(!n)return;this.stopVUMeter("origin"),this.stopVUMeter(t._id);const a=n.roomId;this.removeCall(t._id),this.roomReconfigure(a).then(()=>{}).catch(o=>{console.error("Error reconfiguring room after call removal:",o)})}shouldTerminateNewSession(t){if(t.session.direction==="outgoing")return!1;const a=!this.isCallWaiting&&this.hasActiveCalls;return this.isDND||a}async newRTCSessionCallback(t){const n=t.session;if(this.shouldTerminateNewSession(t)){n.terminate({status_code:486,reason_phrase:"Do Not Disturb"});return}if(this.context.triggerListener({listenerType:Qt.NEW_CALL,session:n,event:t}),n.on("ended",a=>{var s,r,d;this.stopVUMeter(n.id),this.context.logger.log("Session ended for",(r=(s=n._remote_identity)==null?void 0:s._uri)==null?void 0:r._user),this.context.triggerListener({listenerType:Qt.CALL_ENDED,session:n,event:a}),["enabled","dynamic"].includes(this.noiseReduction.mode)&&this.stopSessionVad(n._id);const o=this.getActiveCalls[n.id];o&&this.activeCallListRemove(o),this.stopCallTimer(n.id),this.removeCallStatus(n.id),this.removeCallMetrics(n.id),Object.keys(this.extendedCalls).length||(this.setIsMuted(!1),(d=this.initialStreamValue)==null||d.getTracks().forEach(h=>h.stop()),this.initialStreamValue=null),this.context.isWaitingForSessionHangup()&&!this.hasActiveAnsweredCalls&&this.context.stopSessionAfterWaiting()}),n.on("progress",a=>{var o,s;this.context.logger.log("Session in progress for",(s=(o=n._remote_identity)==null?void 0:o._uri)==null?void 0:s._user),this.context.triggerListener({listenerType:Qt.CALL_PROGRESS,session:n,event:a})}),n.on("failed",a=>{var s,r,d;this.stopVUMeter(n.id),this.context.logger.log("Session failed for",(r=(s=n._remote_identity)==null?void 0:s._uri)==null?void 0:r._user),this.context.triggerListener({listenerType:Qt.CALL_FAILED,session:n,event:a}),["enabled","dynamic"].includes(this.noiseReduction.mode)&&this.stopSessionVad(n._id),n.id===this.callAddingInProgress&&(this.callAddingInProgress=void 0);const o=this.getActiveCalls[n.id];o&&this.activeCallListRemove(o),this.stopCallTimer(n.id),this.removeCallStatus(n.id),this.removeCallMetrics(n.id),Object.keys(this.extendedCalls).length||(this.setIsMuted(!1),(d=this.initialStreamValue)==null||d.getTracks().forEach(h=>h.stop()),this.initialStreamValue=null),this.context.isWaitingForSessionHangup()&&!this.hasActiveAnsweredCalls&&this.context.stopSessionAfterWaiting()}),n.on("confirmed",a=>{var o,s;this.context.logger.log("Session confirmed for",(s=(o=n._remote_identity)==null?void 0:o._uri)==null?void 0:s._user),this.context.triggerListener({listenerType:Qt.CALL_CONFIRMED,session:n,event:a}),this.updateCall(n),n.id===this.callAddingInProgress&&(this.callAddingInProgress=void 0)}),await this.setupCall(t),n.direction==="outgoing"){const a=this.getActiveCalls[n.id].roomId;await this.setActiveRoom(a)}}setMuteWhenJoin(t){this.muteWhenJoinEnabled=t,this.context.emit("changeMuteWhenJoin",t)}setMicrophoneSensitivity(t){if(t<0||t>1)throw new Error("Value should be in range from 0 to 1!");this.microphoneInputLevelValue=t,this.roomReconfigure(this.currentActiveRoomId)}setSpeakerVolume(t){this.speakerVolumeValue=t,Object.values(this.extendedCalls).forEach(n=>{n.audioTag&&(n.audioTag.volume=t,this.updateCall(n))})}setAutoAnswer(t){this.isAutoAnswer=t}setSelectedInputDevice(t){localStorage.setItem(Ia.SELECTED_INPUT_DEVICE,t),this.selectedMediaDevices.input=t,this.context.emit("changeActiveInputMediaDevice",t)}setSelectedOutputDevice(t){localStorage.setItem(Ia.SELECTED_OUTPUT_DEVICE,t),this.selectedMediaDevices.output=t,this.context.emit("changeActiveOutputMediaDevice",t)}setCallMetrics(t){const n={...t};delete n.callId,this.callMetrics={...this.callMetrics,[t.callId]:n},this.context.emit("changeCallMetrics",this.callMetrics)}removeCallMetrics(t){const n={...this.callMetrics};delete n[t],this.callMetrics={...n},this.context.emit("changeCallMetrics",this.callMetrics)}getCallQuality(t){const n=new Fv(this.metricConfig),a=n.createProbe(t.connection,{cid:t._id}),o=[];let s;a.onreport=r=>{Object.entries(r.audio).forEach(([_,g])=>{g.direction==="inbound"&&!o.includes(_)&&(o.push(_),s=_)});const d=r.audio[s];if(!d)return;const h=jv(d,Vv);h.callId=t._id,this.setCallMetrics(h)},this.context.subscribe(Qt.CALL_ENDED,r=>{r._id===t._id&&n.stopAllProbes()}),n.startAllProbes()}async setupVUMeter(t,n){await this.VUMeter.start(await this.managedAudioContext.getContext(),t,n)}stopVUMeter(t){this.VUMeter.stop(t)}async setupStream(){try{const t=Date.now(),n=await navigator.mediaDevices.getUserMedia(this.getUserMediaConstraints);this.initialStreamValue&&(this.initialStreamValue.getTracks().forEach((o,s)=>{o.stop()}),this.initialStreamValue=null),this.initialStreamValue=n}catch(t){throw t}}async triggerAddStream(t,n){const a=this.muteWhenJoin||this.isMuted;this.setIsMuted(a),this.initialStreamValue||await this.setupStream();const o=await this.managedAudioContext.getContext(),s=await Cu(o,this.initialStreamValue,this.microphoneInputLevel*2),r=this.isMuted||this.muteWhenJoin;s.getTracks().forEach(S=>{S.enabled=!r}),await this.setActiveStream(s),await n.connection.getSenders()[0].replaceTrack(s.getTracks()[0]);const _=new MediaStream([t.track]);!Object.values(this.extendedCalls).find(S=>S.audioTag&&S.audioTag.id===n._id)&&UT(_,n,this.selectedOutputDevice,this.speakerVolume);const T=n.roomId===this.currentActiveRoomId;n.audioTag&&(n.audioTag.muted=!T),await this.setupVUMeter(_,n._id),this.getCallQuality(n),this.updateCall(n),["enabled","dynamic"].includes(this.noiseReduction.mode)&&this.processVAD(n,s)}initCall(t,n,a=!1){if(t.length===0)return console.error("Target must be a valid string");this.context.logger.log(`Calling sip:${t}@${this.context.sipDomain}...`);const o=this.context.call(`sip:${t}@${this.context.sipDomain}`,this.sipOptions);if(this.callAddingInProgress=o.id,n&&this.currentActiveRoomId!==void 0&&(this.processRoomChange({callId:o.id,roomId:this.currentActiveRoomId}),a)){const s=Object.values(this.extendedCalls).filter(r=>r.roomId===this.currentActiveRoomId&&r._id!==o.id);for(const r of s)this.holdCall(r._id,!0)}o.connection.addEventListener("track",s=>{this.triggerAddStream(s,o)})}async processRoomChange({callId:t,roomId:n}){const a=this.extendedCalls[t];if(!a)return;const o=a.roomId;a.roomId=n,this.updateCall(a),await this.roomReconfigure(o),await this.roomReconfigure(n)}}class Yv{constructor(t){this.context=t}get sipOptions(){return{...this.context.options.sipOptions}}initCall(t,n){if(t.length===0)return console.error("Target must be a valid string");this.context.logger.log(`Calling sip:${t}@${this.context.sipDomain}...`),this.context.joinVideoCall(`sip:${t}@${this.context.sipDomain}`,n,this.sipOptions)}stop(t={}){this.context.terminateJanusSessions(t)}startAudio(){this.context.enableJanusAudio(!0)}stopAudio(){this.context.enableJanusAudio(!1)}startVideo(){this.context.enableJanusVideo(!0)}stopVideo(){this.context.enableJanusVideo(!1)}changeMediaConstraints(t){this.context.changeMediaConstraints(t)}startScreenShare(){this.context.startScreenShare()}startBlur(){this.context.startBlur()}stopBlur(){this.context.stopBlur()}}class Jv{constructor(t){this.activeMessages={},this.extendedMessages={},this.msrpHistory={},this.context=t,this.context.on(this.context.newMSRPSessionEventName,this.newMSRPSessionCallback.bind(this.context))}get isMSRPInitializing(){return this.isMSRPInitializingValue}get getActiveMessages(){return this.activeMessages}msrpAnswer(t){const n=this.extendedMessages[t];this.updateMSRPSession(n)}updateMSRPSession(t){this.activeMessages[t._id]=Th(t),this.context.emit("changeActiveMessages",this.activeMessages)}addMMSRPSession(t){this.activeMessages={...this.activeMessages,[t._id]:Th(t)},this.extendedMessages[t._id]=t,this.context.emit("changeActiveMessages",this.activeMessages)}addMSRPMessage(t,n){const a=this.msrpHistory[n.id]||[];a.push(t),this.msrpHistory={...this.msrpHistory,[n.id]:[...a]},this.context.emit("newMSRPMessage",{message:t,session:n})}messageTerminate(t){const n=this.extendedMessages[t];n._status!==8&&n.terminate()}addMessageSession(t){if(!t._id||this.getActiveMessages[t._id]!==void 0)return;const a=t;this.addMMSRPSession(a)}triggerMSRPListener({listenerType:t,session:n,event:a}){const o=this.context.listenersList[t];!o||!o.length||o.forEach(s=>{s(n,a)})}removeMMSRPSession(t){const n={...this.activeMessages};delete n[t],this.activeMessages={...n};const a={...this.extendedMessages};delete a[t],this.extendedMessages={...a},this.context.emit("changeActiveMessages",this.activeMessages)}activeMessageListRemove(t){this.removeMMSRPSession(t._id)}newMSRPSessionCallback(t){const n=t.session;n.on("ended",a=>{this.triggerMSRPListener({listenerType:Qt.CALL_ENDED,session:n,event:a});const o=this.getActiveMessages[n.id];this.activeMessageListRemove(o)}),n.on("failed",a=>{this.triggerMSRPListener({listenerType:Qt.CALL_FAILED,session:n,event:a});const o=this.getActiveMessages[n.id];this.activeMessageListRemove(o)}),n.on("confirmed",a=>{this.triggerMSRPListener({listenerType:Qt.CALL_CONFIRMED,session:n,event:a}),this.updateMSRPSession(n)}),n.on("newMessage",a=>{this.addMSRPMessage(a,n)}),this.addMessageSession(n)}setIsMSRPInitializing(t){this.isMSRPInitializingValue=t,this.context.emit("isMSRPInitializingChanged",t)}initMSRP(t,n,a){if(t.length===0)return console.error("Target must be a valid string");const o=this.context.startMSRP(t,a);o.on("active",()=>{this.addMessageSession(o),o.sendMSRP(n),this.setIsMSRPInitializing(!1)}),this.setIsMSRPInitializing(!0)}sendMSRP(t,n){const a=this.extendedMessages[t];if(!a)throw new Error(`MSRP session with id ${t} doesn't exist!`);a.sendMSRP(n)}}const ba={AUDIO:"audio",VIDEO:"video",MSRP:"msrp"};class Ph{constructor(t){this.opensips=null,this.session=null,this.name=null,this.name=t}setOpensips(t){this.opensips=t}setSession(t){this.session=t}kill(){this.opensips.kill(this.name)}}class kh extends Ph{constructor(t,n){super(t),this._candidates=[],this._subscribeSent=!1,this._configureSent=!1,this._lastTrickleReceived=!1,this.type=n}connect(t={}){this.opaqueId=this.session.generateOpaqueId();const n=Pe.cloneArray(t.extraHeaders),a={from_tag:this.session._from_tag};t.fromUserName&&(a.from_uri=new ln("sip",t.fromUserName,this.session._ua.configuration.uri.host),n.push(`P-Preferred-Identity: ${this.session._ua.configuration.uri.toString()}`)),t.fromDisplayName&&(a.from_display_name=t.fromDisplayName),n.push(`Contact: ${this.session._contact}`),n.push("Content-Type: application/json"),this.session._sessionTimers.enabled&&n.push(`Session-Expires: ${this.session._sessionTimers.defaultExpires}${this.session._ua.configuration.session_timers_force_refresher?";refresher=uac":""}`),this._request=new Tt.InitialOutgoingInviteRequest(this.session.target,this.session._ua,a,n),this._createRTCConnection(),this._sendInitialRequest()}getStream(){return this.stream}getConnection(){return this._connection}_createRTCConnection(){this._connection=new RTCPeerConnection({iceServers:[{urls:"stun:turn.voicenter.co",credential:"kxsjahnsdjns3eds23esd",username:"turn2es21e"}]});let t;this._connection.onicecandidate=n=>{this._connection.signalingState!=="stable"&&this._connection.signalingState!=="have-local-offer"||n.candidate&&(this._candidates.push(n.candidate),clearTimeout(t),t=setTimeout(()=>{this._lastTrickleReceived=!0,this._subscribeSent&&!this._configureSent&&this._sendConfigureMessage({audio:!0,video:!0})},500))}}addTracks(t){t.forEach(n=>{this._connection.addTrack(n)})}async _sendInitialRequest(){const t=new Wr(this.session._ua,this._request,{onRequestTimeout:()=>{this.session.onRequestTimeout()},onTransportError:()=>{this.session.onTransportError()},onAuthenticated:s=>{this._request=s},onReceiveResponse:s=>{this._receiveInviteResponse(s)}});if(await this.generateStream(),!this.stream||!this.stream.getTracks().length)return;this.addTracks(this.stream.getTracks());const n={audio:!1,video:!0};this.jsep_offer=await this._connection.createOffer(n),await this._connection.setLocalDescription(this.jsep_offer);const a={janus:"attach",plugin:"janus.plugin.videoroom",opaque_id:this.opaqueId},o=JSON.stringify(a);this._request.body=o,t.send()}_receiveInviteResponse(t){if(this._publisherSubscribeSent||!t.body)return;const n=JSON.parse(t.body);this.handleId=n.data.id;const a={janus:"message",body:{request:"join",room:this.session.room_id,ptype:"publisher",display:this.session.display_name+" (Screen Share)",opaque_id:this.opaqueId},handle_id:this.handleId},o=[this.session.getPTypeHeader(kt.PUBLISHER)];this.session.sendRequest(H.SUBSCRIBE,{extraHeaders:o,body:JSON.stringify(a),eventHandlers:{onSuccessResponse:async s=>{var r,d,h,_;if(s.status_code===200){if(this._subscribeSent=!0,s.body)try{const g=JSON.parse(s.body)||{};((d=(r=g.plugindata)==null?void 0:r.data)==null?void 0:d.videoroom)==="joined"&&this.session.myFeedList.push(g.plugindata.data.id),(_=(h=g.plugindata)==null?void 0:h.data)!=null&&_.publishers&&this.session.receivePublishers(g)}catch(g){console.error(g)}this._lastTrickleReceived&&!this._configureSent&&this._sendConfigureMessage({audio:!0,video:!0})}}}}),this._publisherSubscribeSent=!0}async _sendConfigureMessage(t){const n=this._candidates.map(r=>({janus:"trickle",candidate:r,handle_id:this.handleId,session_id:this.session.session_id})),o={configure:{janus:"message",body:{request:"configure",record:!0,filename:this.session.getRecordFileName(),...t},jsep:this.jsep_offer,handle_id:this.handleId,session_id:this.session.session_id},trickles:[...n]},s=["Content-Type: application/json",this.session.getPTypeHeader(kt.ICE)];this.session.sendRequest(H.INFO,{extraHeaders:s,body:JSON.stringify(o),eventHandlers:{onSuccessResponse:async r=>{this._configureSent=!0;const h=r.data.split(`\r
159
+ `),_=h[h.length-1],g=JSON.parse(_);await this._connection.setRemoteDescription(g.jsep),this._candidates=[]}}})}_sendDetach(){const t={janus:"detach",handle_id:this.handleId,session_id:this.session.session_id},n=[this.session.getPTypeHeader(kt.DETACH)];this.session.sendRequest(H.INFO,{extraHeaders:n,body:JSON.stringify(t)}),this.session._ua.emit("pluginDetach",this.name)}async stopMedia(){this._connection&&(this._connection.close(),this._connection=null),this.stream&&(this.stream=null)}async stop(){await this.session.stopProcessPlugins(this.type);const t=this._connection.getSenders();t.forEach(n=>{const a=n.track;a&&a.stop()}),t.forEach(n=>{this._connection.removeTrack(n)}),await this.stopMedia(),this._sendDetach()}async generateStream(){throw new Error("generateStream method is not implemented")}}class Mh extends Ph{constructor(t,n,a={}){super(t),this.stream=null,this.running=!1,this.immediate=!1,this.type="video",this.immediate=a.immediate||!1,this.type=n}start(t){return t}stop(){throw new Error("stop method is not implemented")}async process(t){if(this.immediate){const n=await this.start(t);return this.running=!0,n}return t}async connect(){this.running=!0,await this.session.resyncPlugins(this.type)}terminate(){this.stop()}async kill(){this.stop(),this.running=!1,await this.session.resyncPlugins(this.type)}}class zv extends RT{constructor(t,n){if(!t.modules.length)throw new Error("options.modules should include at least 1 module");const a={...t.configuration,sockets:t.socketInterfaces.map(o=>new WT.WebSocketInterface(o))};super(a),this.initialized=!1,this.connected=!1,this.logger=console,this.newRTCSessionEventName="newRTCSession",this.registeredEventName="registered",this.unregisteredEventName="unregistered",this.disconnectedEventName="disconnected",this.connectedEventName="connected",this.newMSRPSessionEventName="newMSRPSession",this.isReconnecting=!1,this.activeConnection=!1,this.waitingForSessionHangup=!1,this.waitingForSessionTimeout=null,this.reconnectionAttemptsLimit=1/0,this.reconnectionAttemptsCounter=0,this.audio=null,this.msrp=null,this.video=null,this.listenersList={},this.modules=[],t.pnExtraHeaders&&Object.keys(t.pnExtraHeaders).length&&this.registrator().setExtraContactUriParams(t.pnExtraHeaders),this.options=t,this.modules=t.modules,t.configuration.reconnectionAttemptsLimit&&(this.reconnectionAttemptsLimit=t.configuration.reconnectionAttemptsLimit),n&&xT(n)&&(this.logger=n)}isWaitingForSessionHangup(){return this.waitingForSessionHangup}stopSessionAfterWaiting(){this.setInitialized(!1),this.waitingForSessionHangup=!1,clearTimeout(this.waitingForSessionTimeout),this.waitingForSessionTimeout=null,this.activeConnection&&this.reconnect()}get hasActiveSessions(){return this.modules.includes(ba.AUDIO)?this.audio.hasActiveAnsweredCalls:!1}on(t,n){return super.on(t,n)}off(t,n){return super.off(t,n)}emit(t,n){return super.emit(t,n)}get sipDomain(){return this.options.sipDomain}use(t){if(this.newStreamPlugins.find(n=>n.name===t.name)||this.processStreamPlugins.find(n=>n.name===t.name))throw new Error(`Plugin with name ${t.name} already exists`);if(t instanceof kh)t.setOpensips(this),this.newStreamPlugins.push(t);else if(t instanceof Mh)t.setOpensips(this),this.processStreamPlugins.push(t);else throw new Error("Wrong plugin instance")}getPlugin(t){return this.newStreamPlugins.find(n=>n.name===t)||this.processStreamPlugins.find(n=>n.name===t)}reconnect(){if(this.reconnectionAttemptsCounter<this.reconnectionAttemptsLimit){const n=5e3*Math.pow(2,this.reconnectionAttemptsCounter);this.reconnectionAttemptsCounter++,setTimeout(this.start.bind(this),n)}else this.emit("reconnectionAttemptsLimitReached",void 0)}begin(){if(this.isConnected()){console.error("Connection is already established");return}return this.modules.includes(ba.AUDIO)&&(this.audio=new Kv(this)),this.modules.includes(ba.MSRP)&&(this.msrp=new Jv(this)),this.modules.includes(ba.VIDEO)&&(this.video=new Yv(this)),this.on(this.registeredEventName,()=>{this.logger.log("Successfully registered to",this.options.socketInterfaces[0]),this.setInitialized(!0)}),this.on(this.unregisteredEventName,()=>{this.logger.log("Unregistered from",this.options.socketInterfaces[0]),this.setInitialized(!1)}),this.on(this.connectedEventName,()=>{this.logger.log("Connected to",this.options.socketInterfaces[0]),this.setConnected(!0),this.setReconnecting(!1),this.activeConnection=!0,this.waitingForSessionHangup=!1,this.reconnectionAttemptsCounter=0}),this.on(this.disconnectedEventName,()=>{this.setConnected(!1),!this.isReconnecting&&(this.setReconnecting(!0),this.logger.log("Disconnected from",this.options.socketInterfaces[0]),this.logger.log("Reconnecting to",this.options.socketInterfaces[0]),this.hasActiveSessions?(this.waitingForSessionHangup=!0,this.stop(!1),this.waitingForSessionTimeout=setTimeout(()=>{this.terminateAllSessions(),this.setInitialized(!1),this.waitingForSessionHangup=!1,this.activeConnection&&this.reconnect()},12e5)):(this.stop(),this.setInitialized(!1),this.activeConnection&&this.reconnect()))}),this.logger.log("Connecting to",this.options.socketInterfaces[0]),this.start(),this}disconnect(){this.activeConnection=!1,this.stop()}subscribe(t,n){const o=!this.listenersList[t]||!this.listenersList[t].length?[n]:[...this.listenersList[t],n];this.listenersList={...this.listenersList,[t]:o}}removeIListener(t){const n={...this.listenersList};delete n[t],this.listenersList={...n}}triggerListener({listenerType:t,session:n,event:a}){const o=this.listenersList[t];!o||!o.length||o.forEach(s=>{s(n,a)})}setInitialized(t){this.initialized=t,this.emit("ready",t)}setConnected(t){this.connected=t,this.emit("connection",t)}setReconnecting(t){this.isReconnecting=t,this.emit("reconnecting",t)}}Nt.BaseNewStreamPlugin=kh,Nt.BaseProcessStreamPlugin=Mh,Nt.default=zv,Object.defineProperties(Nt,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});